mirror of
https://github.com/d47081/qBittorrent.git
synced 2025-01-11 15:27:54 +00:00
Fix startup with different profiles
This commit is contained in:
parent
046b741700
commit
a734199383
@ -55,9 +55,20 @@
|
||||
|
||||
#include "algorithm.h"
|
||||
#include "global.h"
|
||||
#include "profile.h"
|
||||
#include "settingsstorage.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() = default;
|
||||
@ -310,21 +321,31 @@ void Preferences::setPreventFromSuspendWhenSeeding(const bool b)
|
||||
#ifdef Q_OS_WIN
|
||||
bool Preferences::WinStartup() const
|
||||
{
|
||||
QSettings settings("HKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\CurrentVersion\\Run", QSettings::NativeFormat);
|
||||
return settings.contains("qBittorrent");
|
||||
const QString profileName = Profile::instance()->profileName();
|
||||
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)
|
||||
{
|
||||
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)
|
||||
{
|
||||
const QString binPath = '"' + Utils::Fs::toNativePath(qApp->applicationFilePath()) + '"';
|
||||
settings.setValue("qBittorrent", binPath);
|
||||
const QString configuration = Profile::instance()->configurationName();
|
||||
|
||||
const auto cmd = QString::fromLatin1(R"("%1" "--profile=%2" "--configuration=%3")")
|
||||
.arg(Utils::Fs::toNativePath(qApp->applicationFilePath()), profilePath, configuration);
|
||||
settings.setValue(profileID, cmd);
|
||||
}
|
||||
else
|
||||
{
|
||||
settings.remove("qBittorrent");
|
||||
settings.remove(profileID);
|
||||
}
|
||||
}
|
||||
#endif // Q_OS_WIN
|
||||
|
Loading…
Reference in New Issue
Block a user