Browse Source

Improved savepath algorithm on Linux. It now uses xdg to figure out the default download folder. Unfortunately only new install will benefit.

adaptive-webui-19844
sledgehammer_999 13 years ago
parent
commit
37f5c8710e
  1. 20
      src/preferences/preferences.h

20
src/preferences/preferences.h

@ -49,6 +49,10 @@
#include <QDesktopServices> #include <QDesktopServices>
#endif #endif
#ifdef Q_OS_LINUX
#include <cstdlib>
#endif
#include "misc.h" #include "misc.h"
#include "qinisettings.h" #include "qinisettings.h"
@ -185,6 +189,22 @@ public:
#ifdef Q_WS_WIN #ifdef Q_WS_WIN
return value(QString::fromUtf8("Preferences/Downloads/SavePath"), return value(QString::fromUtf8("Preferences/Downloads/SavePath"),
QDir(QDesktopServices::storageLocation(QDesktopServices::DocumentsLocation)).absoluteFilePath("Downloads")).toString(); QDir(QDesktopServices::storageLocation(QDesktopServices::DocumentsLocation)).absoluteFilePath("Downloads")).toString();
#elif defined Q_OS_LINUX
QString downloads(QDir::homePath() + "/Downloads");
QString conf(getenv("XDG_CONFIG_HOME"));
if (conf.isEmpty()) conf = QDir::homePath() + "/.config";
if (QFile::exists(conf + "/user-dirs.dirs"))
{
QSettings settings(conf + "/user-dirs.dirs", QSettings::IniFormat);
QString temp(settings.value("XDG_DOWNLOAD_DIR").toString());
if (!temp.isEmpty())
{
if (temp.startsWith("$HOME")) downloads = QDir::homePath() + temp.remove(0, 5);
else downloads = temp;
}
}
return value(QString::fromUtf8("Preferences/Downloads/SavePath"), downloads).toString();
#else #else
return value(QString::fromUtf8("Preferences/Downloads/SavePath"), QDir::home().absoluteFilePath("qBT_dir")).toString(); return value(QString::fromUtf8("Preferences/Downloads/SavePath"), QDir::home().absoluteFilePath("qBT_dir")).toString();
#endif #endif

Loading…
Cancel
Save