mirror of
https://github.com/d47081/qBittorrent.git
synced 2025-01-10 23:07:59 +00:00
Improved savepath algorithm on Linux. It now uses xdg to figure out the default download folder. Unfortunately only new install will benefit.
This commit is contained in:
parent
384eae7014
commit
37f5c8710e
@ -49,6 +49,10 @@
|
||||
#include <QDesktopServices>
|
||||
#endif
|
||||
|
||||
#ifdef Q_OS_LINUX
|
||||
#include <cstdlib>
|
||||
#endif
|
||||
|
||||
#include "misc.h"
|
||||
#include "qinisettings.h"
|
||||
|
||||
@ -185,6 +189,22 @@ public:
|
||||
#ifdef Q_WS_WIN
|
||||
return value(QString::fromUtf8("Preferences/Downloads/SavePath"),
|
||||
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
|
||||
return value(QString::fromUtf8("Preferences/Downloads/SavePath"), QDir::home().absoluteFilePath("qBT_dir")).toString();
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user