|
55 | 55 |
|
56 | 56 | #include "algorithm.h" |
57 | 57 | #include "global.h" |
| 58 | +#include "profile.h" |
58 | 59 | #include "settingsstorage.h" |
59 | 60 | #include "utils/fs.h" |
60 | 61 |
|
| 62 | +namespace |
| 63 | +{ |
| 64 | + QString makeProfileID(const QString &profilePath, const QString &profileName) |
| 65 | + { |
| 66 | + return profilePath.isEmpty() |
| 67 | + ? profileName |
| 68 | + : profileName + QLatin1Char('@') + Utils::Fs::toValidFileSystemName(profilePath, false, {}); |
| 69 | + } |
| 70 | +} |
| 71 | + |
61 | 72 | Preferences *Preferences::m_instance = nullptr; |
62 | 73 |
|
63 | 74 | Preferences::Preferences() = default; |
@@ -310,21 +321,31 @@ void Preferences::setPreventFromSuspendWhenSeeding(const bool b) |
310 | 321 | #ifdef Q_OS_WIN |
311 | 322 | bool Preferences::WinStartup() const |
312 | 323 | { |
313 | | - QSettings settings("HKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\CurrentVersion\\Run", QSettings::NativeFormat); |
314 | | - return settings.contains("qBittorrent"); |
| 324 | + const QString profileName = Profile::instance()->profileName(); |
| 325 | + const QString profilePath = Profile::instance()->rootPath(); |
| 326 | + const QString profileID = makeProfileID(profilePath, profileName); |
| 327 | + const QSettings settings {"HKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\CurrentVersion\\Run", QSettings::NativeFormat}; |
| 328 | + |
| 329 | + return settings.contains(profileID); |
315 | 330 | } |
316 | 331 |
|
317 | 332 | void Preferences::setWinStartup(const bool b) |
318 | 333 | { |
319 | | - QSettings settings("HKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\CurrentVersion\\Run", QSettings::NativeFormat); |
| 334 | + const QString profileName = Profile::instance()->profileName(); |
| 335 | + const QString profilePath = Profile::instance()->rootPath(); |
| 336 | + const QString profileID = makeProfileID(profilePath, profileName); |
| 337 | + QSettings settings {"HKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\CurrentVersion\\Run", QSettings::NativeFormat}; |
320 | 338 | if (b) |
321 | 339 | { |
322 | | - const QString binPath = '"' + Utils::Fs::toNativePath(qApp->applicationFilePath()) + '"'; |
323 | | - settings.setValue("qBittorrent", binPath); |
| 340 | + const QString configuration = Profile::instance()->configurationName(); |
| 341 | + |
| 342 | + const auto cmd = QString::fromLatin1(R"("%1" "--profile=%2" "--configuration=%3")") |
| 343 | + .arg(Utils::Fs::toNativePath(qApp->applicationFilePath()), profilePath, configuration); |
| 344 | + settings.setValue(profileID, cmd); |
324 | 345 | } |
325 | 346 | else |
326 | 347 | { |
327 | | - settings.remove("qBittorrent"); |
| 348 | + settings.remove(profileID); |
328 | 349 | } |
329 | 350 | } |
330 | 351 | #endif // Q_OS_WIN |
|
0 commit comments