|
|
@ -55,9 +55,20 @@ |
|
|
|
|
|
|
|
|
|
|
|
#include "algorithm.h" |
|
|
|
#include "algorithm.h" |
|
|
|
#include "global.h" |
|
|
|
#include "global.h" |
|
|
|
|
|
|
|
#include "profile.h" |
|
|
|
#include "settingsstorage.h" |
|
|
|
#include "settingsstorage.h" |
|
|
|
#include "utils/fs.h" |
|
|
|
#include "utils/fs.h" |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
namespace |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
QString makeProfileID(const QString &profilePath, const QString &profileName) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
return profilePath.isEmpty() |
|
|
|
|
|
|
|
? profileName |
|
|
|
|
|
|
|
: profileName + QLatin1Char('@') + Utils::Fs::toValidFileSystemName(profilePath, false, {}); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
Preferences *Preferences::m_instance = nullptr; |
|
|
|
Preferences *Preferences::m_instance = nullptr; |
|
|
|
|
|
|
|
|
|
|
|
Preferences::Preferences() = default; |
|
|
|
Preferences::Preferences() = default; |
|
|
@ -310,21 +321,31 @@ void Preferences::setPreventFromSuspendWhenSeeding(const bool b) |
|
|
|
#ifdef Q_OS_WIN |
|
|
|
#ifdef Q_OS_WIN |
|
|
|
bool Preferences::WinStartup() const |
|
|
|
bool Preferences::WinStartup() const |
|
|
|
{ |
|
|
|
{ |
|
|
|
QSettings settings("HKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\CurrentVersion\\Run", QSettings::NativeFormat); |
|
|
|
const QString profileName = Profile::instance()->profileName(); |
|
|
|
return settings.contains("qBittorrent"); |
|
|
|
const QString profilePath = Profile::instance()->rootPath(); |
|
|
|
|
|
|
|
const QString profileID = makeProfileID(profilePath, profileName); |
|
|
|
|
|
|
|
const QSettings settings {"HKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\CurrentVersion\\Run", QSettings::NativeFormat}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return settings.contains(profileID); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void Preferences::setWinStartup(const bool b) |
|
|
|
void Preferences::setWinStartup(const bool b) |
|
|
|
{ |
|
|
|
{ |
|
|
|
QSettings settings("HKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\CurrentVersion\\Run", QSettings::NativeFormat); |
|
|
|
const QString profileName = Profile::instance()->profileName(); |
|
|
|
|
|
|
|
const QString profilePath = Profile::instance()->rootPath(); |
|
|
|
|
|
|
|
const QString profileID = makeProfileID(profilePath, profileName); |
|
|
|
|
|
|
|
QSettings settings {"HKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\CurrentVersion\\Run", QSettings::NativeFormat}; |
|
|
|
if (b) |
|
|
|
if (b) |
|
|
|
{ |
|
|
|
{ |
|
|
|
const QString binPath = '"' + Utils::Fs::toNativePath(qApp->applicationFilePath()) + '"'; |
|
|
|
const QString configuration = Profile::instance()->configurationName(); |
|
|
|
settings.setValue("qBittorrent", binPath); |
|
|
|
|
|
|
|
|
|
|
|
const auto cmd = QString::fromLatin1(R"("%1" "--profile=%2" "--configuration=%3")") |
|
|
|
|
|
|
|
.arg(Utils::Fs::toNativePath(qApp->applicationFilePath()), profilePath, configuration); |
|
|
|
|
|
|
|
settings.setValue(profileID, cmd); |
|
|
|
} |
|
|
|
} |
|
|
|
else |
|
|
|
else |
|
|
|
{ |
|
|
|
{ |
|
|
|
settings.remove("qBittorrent"); |
|
|
|
settings.remove(profileID); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
#endif // Q_OS_WIN
|
|
|
|
#endif // Q_OS_WIN
|
|
|
|