qBittorrent
preferences.cpp
Go to the documentation of this file.
1 /*
2  * Bittorrent Client using Qt and libtorrent.
3  * Copyright (C) 2014 sledgehammer999 <hammered999@gmail.com>
4  * Copyright (C) 2006 Christophe Dumez <chris@qbittorrent.org>
5  *
6  * This program is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU General Public License
8  * as published by the Free Software Foundation; either version 2
9  * of the License, or (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19  *
20  * In addition, as a special exception, the copyright holders give permission to
21  * link this program with the OpenSSL project's "OpenSSL" library (or with
22  * modified versions of it that use the same license as the "OpenSSL" library),
23  * and distribute the linked executables. You must obey the GNU General Public
24  * License in all respects for all of the code used other than "OpenSSL". If you
25  * modify file(s), you may extend this exception to your version of the file(s),
26  * but you are not obligated to do so. If you do not wish to do so, delete this
27  * exception statement from your version.
28  */
29 
30 #include "preferences.h"
31 
32 #include <chrono>
33 
34 #ifdef Q_OS_MACOS
35 #include <CoreServices/CoreServices.h>
36 #endif
37 #ifdef Q_OS_WIN
38 #include <shlobj.h>
39 #endif
40 
41 #include <QCoreApplication>
42 #include <QDateTime>
43 #include <QDir>
44 #include <QList>
45 #include <QLocale>
46 #include <QNetworkCookie>
47 #include <QSettings>
48 #include <QSize>
49 #include <QTime>
50 
51 #ifdef Q_OS_WIN
52 #include <QRegularExpression>
53 #endif
54 
55 #include "algorithm.h"
56 #include "global.h"
57 #include "profile.h"
58 #include "settingsstorage.h"
59 #include "utils/fs.h"
60 
61 namespace
62 {
63  template <typename T>
64  T value(const QString &key, const T &defaultValue = {})
65  {
66  return SettingsStorage::instance()->loadValue(key, defaultValue);
67  }
68 
69  template <typename T>
70  T value(const char *key, const T &defaultValue = {})
71  {
72  return value(QLatin1String(key), defaultValue);
73  }
74 
75  template <typename T>
76  void setValue(const QString &key, const T &value)
77  {
79  }
80 
81  template <typename T>
82  void setValue(const char *key, const T &value)
83  {
84  setValue(QLatin1String(key), value);
85  }
86 
87 #ifdef Q_OS_WIN
88  QString makeProfileID(const QString &profilePath, const QString &profileName)
89  {
90  return profilePath.isEmpty()
91  ? profileName
92  : profileName + QLatin1Char('@') + Utils::Fs::toValidFileSystemName(profilePath, false, {});
93  }
94 #endif
95 }
96 
98 
99 Preferences::Preferences() = default;
100 
102 {
103  return m_instance;
104 }
105 
107 {
108  if (!m_instance)
109  m_instance = new Preferences;
110 }
111 
113 {
114  delete m_instance;
115  m_instance = nullptr;
116 }
117 
118 // General options
119 QString Preferences::getLocale() const
120 {
121  const auto localeName = value<QString>("Preferences/General/Locale");
122  return (localeName.isEmpty() ? QLocale::system().name() : localeName);
123 }
124 
125 void Preferences::setLocale(const QString &locale)
126 {
127  setValue("Preferences/General/Locale", locale);
128 }
129 
131 {
132  return value("Preferences/General/UseCustomUITheme", false) && !customUIThemePath().isEmpty();
133 }
134 
136 {
137  setValue("Preferences/General/UseCustomUITheme", use);
138 }
139 
141 {
142  return value<QString>("Preferences/General/CustomUIThemePath");
143 }
144 
145 void Preferences::setCustomUIThemePath(const QString &path)
146 {
147  setValue("Preferences/General/CustomUIThemePath", path);
148 }
149 
151 {
152  return value("Preferences/General/DeleteTorrentsFilesAsDefault", false);
153 }
154 
156 {
157  setValue("Preferences/General/DeleteTorrentsFilesAsDefault", del);
158 }
159 
161 {
162  return value("Preferences/General/ExitConfirm", true);
163 }
164 
165 void Preferences::setConfirmOnExit(const bool confirm)
166 {
167  setValue("Preferences/General/ExitConfirm", confirm);
168 }
169 
171 {
172  return value("Preferences/General/SpeedInTitleBar", false);
173 }
174 
175 void Preferences::showSpeedInTitleBar(const bool show)
176 {
177  setValue("Preferences/General/SpeedInTitleBar", show);
178 }
179 
181 {
182  return value("Preferences/General/AlternatingRowColors", true);
183 }
184 
186 {
187  setValue("Preferences/General/AlternatingRowColors", b);
188 }
189 
191 {
192  return value("Preferences/General/HideZeroValues", false);
193 }
194 
196 {
197  setValue("Preferences/General/HideZeroValues", b);
198 }
199 
201 {
202  return value<int>("Preferences/General/HideZeroComboValues", 0);
203 }
204 
206 {
207  setValue("Preferences/General/HideZeroComboValues", n);
208 }
209 
210 // In Mac OS X the dock is sufficient for our needs so we disable the sys tray functionality.
211 // See extensive discussion in https://github.com/qbittorrent/qBittorrent/pull/3018
212 #ifndef Q_OS_MACOS
214 {
215  return value("Preferences/General/SystrayEnabled", true);
216 }
217 
218 void Preferences::setSystemTrayEnabled(const bool enabled)
219 {
220  setValue("Preferences/General/SystrayEnabled", enabled);
221 }
222 
224 {
225  return value("Preferences/General/MinimizeToTray", false);
226 }
227 
229 {
230  setValue("Preferences/General/MinimizeToTray", b);
231 }
232 
234 {
235  return value("Preferences/General/MinimizeToTrayNotified", false);
236 }
237 
239 {
240  setValue("Preferences/General/MinimizeToTrayNotified", b);
241 }
242 
244 {
245  return value("Preferences/General/CloseToTray", true);
246 }
247 
248 void Preferences::setCloseToTray(const bool b)
249 {
250  setValue("Preferences/General/CloseToTray", b);
251 }
252 
254 {
255  return value("Preferences/General/CloseToTrayNotified", false);
256 }
257 
259 {
260  setValue("Preferences/General/CloseToTrayNotified", b);
261 }
262 
264 {
265  return value("Preferences/Advanced/EnableIconsInMenus", true);
266 }
267 
268 void Preferences::setIconsInMenusEnabled(const bool enable)
269 {
270  setValue("Preferences/Advanced/EnableIconsInMenus", enable);
271 }
272 #endif // Q_OS_MACOS
273 
275 {
276  return value("Preferences/General/ToolbarDisplayed", true);
277 }
278 
279 void Preferences::setToolbarDisplayed(const bool displayed)
280 {
281  setValue("Preferences/General/ToolbarDisplayed", displayed);
282 }
283 
285 {
286  return value("Preferences/General/StatusbarDisplayed", true);
287 }
288 
289 void Preferences::setStatusbarDisplayed(const bool displayed)
290 {
291  setValue("Preferences/General/StatusbarDisplayed", displayed);
292 }
293 
295 {
296  return value("Preferences/General/StartMinimized", false);
297 }
298 
300 {
301  setValue("Preferences/General/StartMinimized", b);
302 }
303 
305 {
306  return value("Preferences/General/NoSplashScreen", true);
307 }
308 
310 {
311  setValue("Preferences/General/NoSplashScreen", b);
312 }
313 
314 // Preventing from system suspend while active torrents are presented.
316 {
317  return value("Preferences/General/PreventFromSuspendWhenDownloading", false);
318 }
319 
321 {
322  setValue("Preferences/General/PreventFromSuspendWhenDownloading", b);
323 }
324 
326 {
327  return value("Preferences/General/PreventFromSuspendWhenSeeding", false);
328 }
329 
331 {
332  setValue("Preferences/General/PreventFromSuspendWhenSeeding", b);
333 }
334 
335 #ifdef Q_OS_WIN
336 bool Preferences::WinStartup() const
337 {
338  const QString profileName = Profile::instance()->profileName();
339  const QString profilePath = Profile::instance()->rootPath();
340  const QString profileID = makeProfileID(profilePath, profileName);
341  const QSettings settings {"HKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\CurrentVersion\\Run", QSettings::NativeFormat};
342 
343  return settings.contains(profileID);
344 }
345 
346 void Preferences::setWinStartup(const bool b)
347 {
348  const QString profileName = Profile::instance()->profileName();
349  const QString profilePath = Profile::instance()->rootPath();
350  const QString profileID = makeProfileID(profilePath, profileName);
351  QSettings settings {"HKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\CurrentVersion\\Run", QSettings::NativeFormat};
352  if (b)
353  {
354  const QString configuration = Profile::instance()->configurationName();
355 
356  const auto cmd = QString::fromLatin1(R"("%1" "--profile=%2" "--configuration=%3")")
357  .arg(Utils::Fs::toNativePath(qApp->applicationFilePath()), profilePath, configuration);
358  settings.setValue(profileID, cmd);
359  }
360  else
361  {
362  settings.remove(profileID);
363  }
364 }
365 #endif // Q_OS_WIN
366 
367 // Downloads
369 {
370  return Utils::Fs::toUniformPath(value<QString>("Preferences/Downloads/LastLocationPath"));
371 }
372 
373 void Preferences::setLastLocationPath(const QString &path)
374 {
375  setValue("Preferences/Downloads/LastLocationPath", Utils::Fs::toUniformPath(path));
376 }
377 
379 {
380  return Utils::Fs::toUniformPath(value<QString>("Preferences/Downloads/ScanDirsLastPath"));
381 }
382 
383 void Preferences::setScanDirsLastPath(const QString &path)
384 {
385  setValue("Preferences/Downloads/ScanDirsLastPath", Utils::Fs::toUniformPath(path));
386 }
387 
389 {
390  return value("Preferences/MailNotification/enabled", false);
391 }
392 
394 {
395  setValue("Preferences/MailNotification/enabled", enabled);
396 }
397 
399 {
400  return value<QString>("Preferences/MailNotification/sender"
401  , QLatin1String("qBittorrent_notification@example.com"));
402 }
403 
404 void Preferences::setMailNotificationSender(const QString &mail)
405 {
406  setValue("Preferences/MailNotification/sender", mail);
407 }
408 
410 {
411  return value<QString>("Preferences/MailNotification/email");
412 }
413 
414 void Preferences::setMailNotificationEmail(const QString &mail)
415 {
416  setValue("Preferences/MailNotification/email", mail);
417 }
418 
420 {
421  return value<QString>("Preferences/MailNotification/smtp_server", QLatin1String("smtp.changeme.com"));
422 }
423 
424 void Preferences::setMailNotificationSMTP(const QString &smtp_server)
425 {
426  setValue("Preferences/MailNotification/smtp_server", smtp_server);
427 }
428 
430 {
431  return value("Preferences/MailNotification/req_ssl", false);
432 }
433 
435 {
436  setValue("Preferences/MailNotification/req_ssl", use);
437 }
438 
440 {
441  return value("Preferences/MailNotification/req_auth", false);
442 }
443 
445 {
446  setValue("Preferences/MailNotification/req_auth", use);
447 }
448 
450 {
451  return value<QString>("Preferences/MailNotification/username");
452 }
453 
454 void Preferences::setMailNotificationSMTPUsername(const QString &username)
455 {
456  setValue("Preferences/MailNotification/username", username);
457 }
458 
460 {
461  return value<QString>("Preferences/MailNotification/password");
462 }
463 
464 void Preferences::setMailNotificationSMTPPassword(const QString &password)
465 {
466  setValue("Preferences/MailNotification/password", password);
467 }
468 
470 {
471  return value<int>("Preferences/Downloads/DblClOnTorDl", 0);
472 }
473 
475 {
476  setValue("Preferences/Downloads/DblClOnTorDl", act);
477 }
478 
480 {
481  return value<int>("Preferences/Downloads/DblClOnTorFn", 1);
482 }
483 
485 {
486  setValue("Preferences/Downloads/DblClOnTorFn", act);
487 }
488 
490 {
491  return value("Preferences/Scheduler/start_time", QTime(8, 0));
492 }
493 
494 void Preferences::setSchedulerStartTime(const QTime &time)
495 {
496  setValue("Preferences/Scheduler/start_time", time);
497 }
498 
500 {
501  return value("Preferences/Scheduler/end_time", QTime(20, 0));
502 }
503 
504 void Preferences::setSchedulerEndTime(const QTime &time)
505 {
506  setValue("Preferences/Scheduler/end_time", time);
507 }
508 
510 {
511  return value("Preferences/Scheduler/days", Scheduler::Days::EveryDay);
512 }
513 
515 {
516  setValue("Preferences/Scheduler/days", days);
517 }
518 
519 // Search
521 {
522  return value("Preferences/Search/SearchEnabled", false);
523 }
524 
525 void Preferences::setSearchEnabled(const bool enabled)
526 {
527  setValue("Preferences/Search/SearchEnabled", enabled);
528 }
529 
531 {
532 #ifdef DISABLE_GUI
533  return true;
534 #else
535  return value("Preferences/WebUI/Enabled", false);
536 #endif
537 }
538 
539 void Preferences::setWebUiEnabled(const bool enabled)
540 {
541  setValue("Preferences/WebUI/Enabled", enabled);
542 }
543 
545 {
546  return value("Preferences/WebUI/LocalHostAuth", true);
547 }
548 
550 {
551  setValue("Preferences/WebUI/LocalHostAuth", enabled);
552 }
553 
555 {
556  return value("Preferences/WebUI/AuthSubnetWhitelistEnabled", false);
557 }
558 
560 {
561  setValue("Preferences/WebUI/AuthSubnetWhitelistEnabled", enabled);
562 }
563 
564 QVector<Utils::Net::Subnet> Preferences::getWebUiAuthSubnetWhitelist() const
565 {
566  const auto subnets = value<QStringList>("Preferences/WebUI/AuthSubnetWhitelist");
567 
568  QVector<Utils::Net::Subnet> ret;
569  ret.reserve(subnets.size());
570 
571  for (const QString &rawSubnet : subnets)
572  {
573  bool ok = false;
574  const Utils::Net::Subnet subnet = Utils::Net::parseSubnet(rawSubnet.trimmed(), &ok);
575  if (ok)
576  ret.append(subnet);
577  }
578 
579  return ret;
580 }
581 
583 {
584  Algorithm::removeIf(subnets, [](const QString &subnet)
585  {
586  bool ok = false;
587  Utils::Net::parseSubnet(subnet.trimmed(), &ok);
588  return !ok;
589  });
590 
591  setValue("Preferences/WebUI/AuthSubnetWhitelist", subnets);
592 }
593 
595 {
596  return value<QString>("Preferences/WebUI/ServerDomains", QChar('*'));
597 }
598 
599 void Preferences::setServerDomains(const QString &str)
600 {
601  setValue("Preferences/WebUI/ServerDomains", str);
602 }
603 
605 {
606  return value<QString>("Preferences/WebUI/Address", QChar('*')).trimmed();
607 }
608 
609 void Preferences::setWebUiAddress(const QString &addr)
610 {
611  setValue("Preferences/WebUI/Address", addr.trimmed());
612 }
613 
615 {
616  return value<int>("Preferences/WebUI/Port", 8080);
617 }
618 
619 void Preferences::setWebUiPort(const quint16 port)
620 {
621  setValue("Preferences/WebUI/Port", port);
622 }
623 
625 {
626 #ifdef DISABLE_GUI
627  return value("Preferences/WebUI/UseUPnP", true);
628 #else
629  return value("Preferences/WebUI/UseUPnP", false);
630 #endif
631 }
632 
633 void Preferences::setUPnPForWebUIPort(const bool enabled)
634 {
635  setValue("Preferences/WebUI/UseUPnP", enabled);
636 }
637 
639 {
640  return value<QString>("Preferences/WebUI/Username", QLatin1String("admin"));
641 }
642 
643 void Preferences::setWebUiUsername(const QString &username)
644 {
645  setValue("Preferences/WebUI/Username", username);
646 }
647 
649 {
650  // default: adminadmin
651  const QByteArray defaultValue = "ARQ77eY1NUZaQsuDHbIMCA==:0WMRkYTUWVT9wVvdDtHAjU9b3b7uB8NR1Gur2hmQCvCDpm39Q+PsJRJPaCU51dEiz+dTzh8qbPsL8WkFljQYFQ==";
652  return value("Preferences/WebUI/Password_PBKDF2", defaultValue);
653 }
654 
655 void Preferences::setWebUIPassword(const QByteArray &password)
656 {
657  setValue("Preferences/WebUI/Password_PBKDF2", password);
658 }
659 
661 {
662  return value<int>("Preferences/WebUI/MaxAuthenticationFailCount", 5);
663 }
664 
666 {
667  setValue("Preferences/WebUI/MaxAuthenticationFailCount", count);
668 }
669 
670 std::chrono::seconds Preferences::getWebUIBanDuration() const
671 {
672  return std::chrono::seconds(value<int>("Preferences/WebUI/BanDuration", 3600));
673 }
674 
675 void Preferences::setWebUIBanDuration(const std::chrono::seconds duration)
676 {
677  setValue("Preferences/WebUI/BanDuration", static_cast<int>(duration.count()));
678 }
679 
681 {
682  return value<int>("Preferences/WebUI/SessionTimeout", 3600);
683 }
684 
685 void Preferences::setWebUISessionTimeout(const int timeout)
686 {
687  setValue("Preferences/WebUI/SessionTimeout", timeout);
688 }
689 
691 {
692  return value("Preferences/WebUI/ClickjackingProtection", true);
693 }
694 
696 {
697  setValue("Preferences/WebUI/ClickjackingProtection", enabled);
698 }
699 
701 {
702  return value("Preferences/WebUI/CSRFProtection", true);
703 }
704 
706 {
707  setValue("Preferences/WebUI/CSRFProtection", enabled);
708 }
709 
711 {
712  return value("Preferences/WebUI/SecureCookie", true);
713 }
714 
716 {
717  setValue("Preferences/WebUI/SecureCookie", enabled);
718 }
719 
721 {
722  return value("Preferences/WebUI/HostHeaderValidation", true);
723 }
724 
726 {
727  setValue("Preferences/WebUI/HostHeaderValidation", enabled);
728 }
729 
731 {
732  return value("Preferences/WebUI/HTTPS/Enabled", false);
733 }
734 
735 void Preferences::setWebUiHttpsEnabled(const bool enabled)
736 {
737  setValue("Preferences/WebUI/HTTPS/Enabled", enabled);
738 }
739 
741 {
742  return value<QString>("Preferences/WebUI/HTTPS/CertificatePath");
743 }
744 
746 {
747  setValue("Preferences/WebUI/HTTPS/CertificatePath", path);
748 }
749 
751 {
752  return value<QString>("Preferences/WebUI/HTTPS/KeyPath");
753 }
754 
755 void Preferences::setWebUIHttpsKeyPath(const QString &path)
756 {
757  setValue("Preferences/WebUI/HTTPS/KeyPath", path);
758 }
759 
761 {
762  return value("Preferences/WebUI/AlternativeUIEnabled", false);
763 }
764 
765 void Preferences::setAltWebUiEnabled(const bool enabled)
766 {
767  setValue("Preferences/WebUI/AlternativeUIEnabled", enabled);
768 }
769 
771 {
772  return value<QString>("Preferences/WebUI/RootFolder");
773 }
774 
775 void Preferences::setWebUiRootFolder(const QString &path)
776 {
777  setValue("Preferences/WebUI/RootFolder", path);
778 }
779 
781 {
782  return value("Preferences/WebUI/CustomHTTPHeadersEnabled", false);
783 }
784 
786 {
787  setValue("Preferences/WebUI/CustomHTTPHeadersEnabled", enabled);
788 }
789 
791 {
792  return value<QString>("Preferences/WebUI/CustomHTTPHeaders");
793 }
794 
796 {
797  setValue("Preferences/WebUI/CustomHTTPHeaders", headers);
798 }
799 
801 {
802  return value("Preferences/WebUI/ReverseProxySupportEnabled", false);
803 }
804 
806 {
807  setValue("Preferences/WebUI/ReverseProxySupportEnabled", enabled);
808 }
809 
811 {
812  return value<QString>("Preferences/WebUI/TrustedReverseProxiesList");
813 }
814 
816 {
817  setValue("Preferences/WebUI/TrustedReverseProxiesList", addr);
818 }
819 
821 {
822  return value("Preferences/DynDNS/Enabled", false);
823 }
824 
825 void Preferences::setDynDNSEnabled(const bool enabled)
826 {
827  setValue("Preferences/DynDNS/Enabled", enabled);
828 }
829 
831 {
832  return value("Preferences/DynDNS/Service", DNS::Service::DynDNS);
833 }
834 
836 {
837  setValue("Preferences/DynDNS/Service", service);
838 }
839 
841 {
842  return value<QString>("Preferences/DynDNS/DomainName", QLatin1String("changeme.dyndns.org"));
843 }
844 
845 void Preferences::setDynDomainName(const QString &name)
846 {
847  setValue("Preferences/DynDNS/DomainName", name);
848 }
849 
851 {
852  return value<QString>("Preferences/DynDNS/Username");
853 }
854 
855 void Preferences::setDynDNSUsername(const QString &username)
856 {
857  setValue("Preferences/DynDNS/Username", username);
858 }
859 
861 {
862  return value<QString>("Preferences/DynDNS/Password");
863 }
864 
865 void Preferences::setDynDNSPassword(const QString &password)
866 {
867  setValue("Preferences/DynDNS/Password", password);
868 }
869 
870 // Advanced settings
872 {
873  return value<QByteArray>("Locking/password_PBKDF2");
874 }
875 
876 void Preferences::setUILockPassword(const QByteArray &password)
877 {
878  setValue("Locking/password_PBKDF2", password);
879 }
880 
882 {
883  return value("Locking/locked", false);
884 }
885 
886 void Preferences::setUILocked(const bool locked)
887 {
888  setValue("Locking/locked", locked);
889 }
890 
892 {
893  return value("AutoRun/enabled", false);
894 }
895 
896 void Preferences::setAutoRunEnabled(const bool enabled)
897 {
898  setValue("AutoRun/enabled", enabled);
899 }
900 
902 {
903  return value<QString>("AutoRun/program");
904 }
905 
906 void Preferences::setAutoRunProgram(const QString &program)
907 {
908  setValue("AutoRun/program", program);
909 }
910 
911 #if defined(Q_OS_WIN)
912 bool Preferences::isAutoRunConsoleEnabled() const
913 {
914  return value("AutoRun/ConsoleEnabled", false);
915 }
916 
917 void Preferences::setAutoRunConsoleEnabled(const bool enabled)
918 {
919  setValue("AutoRun/ConsoleEnabled", enabled);
920 }
921 #endif
922 
924 {
925  return value("Preferences/Downloads/AutoShutDownOnCompletion", false);
926 }
927 
929 {
930  setValue("Preferences/Downloads/AutoShutDownOnCompletion", shutdown);
931 }
932 
934 {
935  return value("Preferences/Downloads/AutoSuspendOnCompletion", false);
936 }
937 
939 {
940  setValue("Preferences/Downloads/AutoSuspendOnCompletion", suspend);
941 }
942 
944 {
945  return value("Preferences/Downloads/AutoHibernateOnCompletion", false);
946 }
947 
949 {
950  setValue("Preferences/Downloads/AutoHibernateOnCompletion", hibernate);
951 }
952 
954 {
955  return value("Preferences/Downloads/AutoShutDownqBTOnCompletion", false);
956 }
957 
959 {
960  setValue("Preferences/Downloads/AutoShutDownqBTOnCompletion", shutdown);
961 }
962 
964 {
965  return value("ShutdownConfirmDlg/DontConfirmAutoExit", false);
966 }
967 
968 void Preferences::setDontConfirmAutoExit(const bool dontConfirmAutoExit)
969 {
970  setValue("ShutdownConfirmDlg/DontConfirmAutoExit", dontConfirmAutoExit);
971 }
972 
974 {
975  return value("Preferences/Advanced/RecheckOnCompletion", false);
976 }
977 
979 {
980  setValue("Preferences/Advanced/RecheckOnCompletion", recheck);
981 }
982 
984 {
985  return value("Preferences/Connection/ResolvePeerCountries", true);
986 }
987 
988 void Preferences::resolvePeerCountries(const bool resolve)
989 {
990  setValue("Preferences/Connection/ResolvePeerCountries", resolve);
991 }
992 
994 {
995  return value("Preferences/Connection/ResolvePeerHostNames", false);
996 }
997 
998 void Preferences::resolvePeerHostNames(const bool resolve)
999 {
1000  setValue("Preferences/Connection/ResolvePeerHostNames", resolve);
1001 }
1002 
1003 #if (defined(Q_OS_UNIX) && !defined(Q_OS_MACOS))
1004 bool Preferences::useSystemIconTheme() const
1005 {
1006  return value("Preferences/Advanced/useSystemIconTheme", true);
1007 }
1008 
1009 void Preferences::useSystemIconTheme(const bool enabled)
1010 {
1011  setValue("Preferences/Advanced/useSystemIconTheme", enabled);
1012 }
1013 #endif
1014 
1016 {
1017  return value("Preferences/Advanced/DisableRecursiveDownload", false);
1018 }
1019 
1021 {
1022  setValue("Preferences/Advanced/DisableRecursiveDownload", disable);
1023 }
1024 
1025 #ifdef Q_OS_WIN
1026 bool Preferences::neverCheckFileAssoc() const
1027 {
1028  return value("Preferences/Win32/NeverCheckFileAssocation", false);
1029 }
1030 
1031 void Preferences::setNeverCheckFileAssoc(const bool check)
1032 {
1033  setValue("Preferences/Win32/NeverCheckFileAssocation", check);
1034 }
1035 
1036 bool Preferences::isTorrentFileAssocSet()
1037 {
1038  const QSettings settings("HKEY_CURRENT_USER\\Software\\Classes", QSettings::NativeFormat);
1039  if (settings.value(".torrent/Default").toString() != "qBittorrent")
1040  {
1041  qDebug(".torrent != qBittorrent");
1042  return false;
1043  }
1044 
1045  return true;
1046 }
1047 
1048 bool Preferences::isMagnetLinkAssocSet()
1049 {
1050  const QSettings settings("HKEY_CURRENT_USER\\Software\\Classes", QSettings::NativeFormat);
1051 
1052  // Check magnet link assoc
1053  const QString shellCommand = Utils::Fs::toNativePath(settings.value("magnet/shell/open/command/Default", "").toString());
1054 
1055  const QRegularExpressionMatch exeRegMatch = QRegularExpression("\"([^\"]+)\".*").match(shellCommand);
1056  if (!exeRegMatch.hasMatch())
1057  return false;
1058 
1059  const QString assocExe = exeRegMatch.captured(1);
1060  if (assocExe.compare(Utils::Fs::toNativePath(qApp->applicationFilePath()), Qt::CaseInsensitive) != 0)
1061  return false;
1062 
1063  return true;
1064 }
1065 
1066 void Preferences::setTorrentFileAssoc(const bool set)
1067 {
1068  QSettings settings("HKEY_CURRENT_USER\\Software\\Classes", QSettings::NativeFormat);
1069 
1070  // .Torrent association
1071  if (set)
1072  {
1073  const QString oldProgId = settings.value(".torrent/Default").toString();
1074  if (!oldProgId.isEmpty() && (oldProgId != "qBittorrent"))
1075  settings.setValue(".torrent/OpenWithProgids/" + oldProgId, "");
1076  settings.setValue(".torrent/Default", "qBittorrent");
1077  }
1078  else if (isTorrentFileAssocSet())
1079  {
1080  settings.setValue(".torrent/Default", "");
1081  }
1082 
1083  SHChangeNotify(SHCNE_ASSOCCHANGED, SHCNF_IDLIST, 0, 0);
1084 }
1085 
1086 void Preferences::setMagnetLinkAssoc(const bool set)
1087 {
1088  QSettings settings("HKEY_CURRENT_USER\\Software\\Classes", QSettings::NativeFormat);
1089 
1090  // Magnet association
1091  if (set)
1092  {
1093  const QString commandStr = '"' + qApp->applicationFilePath() + "\" \"%1\"";
1094  const QString iconStr = '"' + qApp->applicationFilePath() + "\",1";
1095 
1096  settings.setValue("magnet/Default", "URL:Magnet link");
1097  settings.setValue("magnet/Content Type", "application/x-magnet");
1098  settings.setValue("magnet/URL Protocol", "");
1099  settings.setValue("magnet/DefaultIcon/Default", Utils::Fs::toNativePath(iconStr));
1100  settings.setValue("magnet/shell/Default", "open");
1101  settings.setValue("magnet/shell/open/command/Default", Utils::Fs::toNativePath(commandStr));
1102  }
1103  else if (isMagnetLinkAssocSet())
1104  {
1105  settings.remove("magnet");
1106  }
1107 
1108  SHChangeNotify(SHCNE_ASSOCCHANGED, SHCNF_IDLIST, 0, 0);
1109 }
1110 #endif // Q_OS_WIN
1111 
1112 #ifdef Q_OS_MACOS
1113 namespace
1114 {
1115  const CFStringRef torrentExtension = CFSTR("torrent");
1116  const CFStringRef magnetUrlScheme = CFSTR("magnet");
1117 }
1118 
1119 bool Preferences::isTorrentFileAssocSet()
1120 {
1121  bool isSet = false;
1122  const CFStringRef torrentId = UTTypeCreatePreferredIdentifierForTag(kUTTagClassFilenameExtension, torrentExtension, NULL);
1123  if (torrentId != NULL)
1124  {
1125  const CFStringRef defaultHandlerId = LSCopyDefaultRoleHandlerForContentType(torrentId, kLSRolesViewer);
1126  if (defaultHandlerId != NULL)
1127  {
1128  const CFStringRef myBundleId = CFBundleGetIdentifier(CFBundleGetMainBundle());
1129  isSet = CFStringCompare(myBundleId, defaultHandlerId, 0) == kCFCompareEqualTo;
1130  CFRelease(defaultHandlerId);
1131  }
1132  CFRelease(torrentId);
1133  }
1134  return isSet;
1135 }
1136 
1137 bool Preferences::isMagnetLinkAssocSet()
1138 {
1139  bool isSet = false;
1140  const CFStringRef defaultHandlerId = LSCopyDefaultHandlerForURLScheme(magnetUrlScheme);
1141  if (defaultHandlerId != NULL)
1142  {
1143  const CFStringRef myBundleId = CFBundleGetIdentifier(CFBundleGetMainBundle());
1144  isSet = CFStringCompare(myBundleId, defaultHandlerId, 0) == kCFCompareEqualTo;
1145  CFRelease(defaultHandlerId);
1146  }
1147  return isSet;
1148 }
1149 
1150 void Preferences::setTorrentFileAssoc()
1151 {
1152  if (isTorrentFileAssocSet())
1153  return;
1154  const CFStringRef torrentId = UTTypeCreatePreferredIdentifierForTag(kUTTagClassFilenameExtension, torrentExtension, NULL);
1155  if (torrentId != NULL)
1156  {
1157  const CFStringRef myBundleId = CFBundleGetIdentifier(CFBundleGetMainBundle());
1158  LSSetDefaultRoleHandlerForContentType(torrentId, kLSRolesViewer, myBundleId);
1159  CFRelease(torrentId);
1160  }
1161 }
1162 
1163 void Preferences::setMagnetLinkAssoc()
1164 {
1165  if (isMagnetLinkAssocSet())
1166  return;
1167  const CFStringRef myBundleId = CFBundleGetIdentifier(CFBundleGetMainBundle());
1168  LSSetDefaultHandlerForURLScheme(magnetUrlScheme, myBundleId);
1169 }
1170 #endif // Q_OS_MACOS
1171 
1173 {
1174  return value<int>("Preferences/Advanced/trackerPort", 9000);
1175 }
1176 
1177 void Preferences::setTrackerPort(const int port)
1178 {
1179  setValue("Preferences/Advanced/trackerPort", port);
1180 }
1181 
1182 #if defined(Q_OS_WIN) || defined(Q_OS_MACOS)
1183 bool Preferences::isUpdateCheckEnabled() const
1184 {
1185  return value("Preferences/Advanced/updateCheck", true);
1186 }
1187 
1188 void Preferences::setUpdateCheckEnabled(const bool enabled)
1189 {
1190  setValue("Preferences/Advanced/updateCheck", enabled);
1191 }
1192 #endif
1193 
1195 {
1196  return value("Preferences/Advanced/confirmTorrentDeletion", true);
1197 }
1198 
1200 {
1201  setValue("Preferences/Advanced/confirmTorrentDeletion", enabled);
1202 }
1203 
1205 {
1206  return value("Preferences/Advanced/confirmTorrentRecheck", true);
1207 }
1208 
1210 {
1211  setValue("Preferences/Advanced/confirmTorrentRecheck", enabled);
1212 }
1213 
1215 {
1216  return value("Preferences/Advanced/confirmRemoveAllTags", true);
1217 }
1218 
1220 {
1221  setValue("Preferences/Advanced/confirmRemoveAllTags", enabled);
1222 }
1223 
1224 #ifndef Q_OS_MACOS
1226 {
1227  return value("Preferences/Advanced/TrayIconStyle", TrayIcon::Style::Normal);
1228 }
1229 
1231 {
1232  setValue("Preferences/Advanced/TrayIconStyle", style);
1233 }
1234 #endif
1235 
1236 // Stuff that don't appear in the Options GUI but are saved
1237 // in the same file.
1238 
1240 {
1241  return value<QDateTime>("DNSUpdater/lastUpdateTime");
1242 }
1243 
1244 void Preferences::setDNSLastUpd(const QDateTime &date)
1245 {
1246  setValue("DNSUpdater/lastUpdateTime", date);
1247 }
1248 
1250 {
1251  return value<QString>("DNSUpdater/lastIP");
1252 }
1253 
1254 void Preferences::setDNSLastIP(const QString &ip)
1255 {
1256  setValue("DNSUpdater/lastIP", ip);
1257 }
1258 
1260 {
1261  return value("LegalNotice/Accepted", false);
1262 }
1263 
1264 void Preferences::setAcceptedLegal(const bool accepted)
1265 {
1266  setValue("LegalNotice/Accepted", accepted);
1267 }
1268 
1270 {
1271  return value<QByteArray>("MainWindow/geometry");
1272 }
1273 
1274 void Preferences::setMainGeometry(const QByteArray &geometry)
1275 {
1276  setValue("MainWindow/geometry", geometry);
1277 }
1278 
1280 {
1281 #if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
1282  return value<QByteArray>("GUI/Qt6/MainWindow/VSplitterState");
1283 #else
1284  return value<QByteArray>("MainWindow/qt5/vsplitterState");
1285 #endif
1286 }
1287 
1288 void Preferences::setMainVSplitterState(const QByteArray &state)
1289 {
1290 #if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
1291  setValue("GUI/Qt6/MainWindow/VSplitterState", state);
1292 #else
1293  setValue("MainWindow/qt5/vsplitterState", state);
1294 #endif
1295 }
1296 
1298 {
1299  return value("MainWindow/LastDir", QDir::homePath());
1300 }
1301 
1302 void Preferences::setMainLastDir(const QString &path)
1303 {
1304  setValue("MainWindow/LastDir", path);
1305 }
1306 
1308 {
1309 #if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
1310  return value<QByteArray>("GUI/Qt6/TorrentProperties/PeerListState");
1311 #else
1312  return value<QByteArray>("TorrentProperties/Peers/qt5/PeerListState");
1313 #endif
1314 }
1315 
1316 void Preferences::setPeerListState(const QByteArray &state)
1317 {
1318 #if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
1319  setValue("GUI/Qt6/TorrentProperties/PeerListState", state);
1320 #else
1321  setValue("TorrentProperties/Peers/qt5/PeerListState", state);
1322 #endif
1323 }
1324 
1326 {
1327  return value<QString>("TorrentProperties/SplitterSizes");
1328 }
1329 
1330 void Preferences::setPropSplitterSizes(const QString &sizes)
1331 {
1332  setValue("TorrentProperties/SplitterSizes", sizes);
1333 }
1334 
1336 {
1337 #if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
1338  return value<QByteArray>("GUI/Qt6/TorrentProperties/FilesListState");
1339 #else
1340  return value<QByteArray>("TorrentProperties/qt5/FilesListState");
1341 #endif
1342 }
1343 
1344 void Preferences::setPropFileListState(const QByteArray &state)
1345 {
1346 #if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
1347  setValue("GUI/Qt6/TorrentProperties/FilesListState", state);
1348 #else
1349  setValue("TorrentProperties/qt5/FilesListState", state);
1350 #endif
1351 }
1352 
1354 {
1355  return value<int>("TorrentProperties/CurrentTab", -1);
1356 }
1357 
1358 void Preferences::setPropCurTab(const int tab)
1359 {
1360  setValue("TorrentProperties/CurrentTab", tab);
1361 }
1362 
1364 {
1365  return value("TorrentProperties/Visible", false);
1366 }
1367 
1368 void Preferences::setPropVisible(const bool visible)
1369 {
1370  setValue("TorrentProperties/Visible", visible);
1371 }
1372 
1374 {
1375 #if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
1376  return value<QByteArray>("GUI/Qt6/TorrentProperties/TrackerListState");
1377 #else
1378  return value<QByteArray>("TorrentProperties/Trackers/qt5/TrackerListState");
1379 #endif
1380 }
1381 
1382 void Preferences::setPropTrackerListState(const QByteArray &state)
1383 {
1384 #if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
1385  setValue("GUI/Qt6/TorrentProperties/TrackerListState", state);
1386 #else
1387  setValue("TorrentProperties/Trackers/qt5/TrackerListState", state);
1388 #endif
1389 }
1390 
1392 {
1393  return value<QSize>("RssFeedDownloader/geometrySize");
1394 }
1395 
1396 void Preferences::setRssGeometrySize(const QSize &geometry)
1397 {
1398  setValue("RssFeedDownloader/geometrySize", geometry);
1399 }
1400 
1402 {
1403 #if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
1404  return value<QByteArray>("GUI/Qt6/RSSFeedDownloader/HSplitterSizes");
1405 #else
1406  return value<QByteArray>("RssFeedDownloader/qt5/hsplitterSizes");
1407 #endif
1408 }
1409 
1410 void Preferences::setRssHSplitterSizes(const QByteArray &sizes)
1411 {
1412 #if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
1413  setValue("GUI/Qt6/RSSFeedDownloader/HSplitterSizes", sizes);
1414 #else
1415  setValue("RssFeedDownloader/qt5/hsplitterSizes", sizes);
1416 #endif
1417 }
1418 
1420 {
1421  return value<QStringList>("GUI/RSSWidget/OpenedFolders");
1422 }
1423 
1424 void Preferences::setRssOpenFolders(const QStringList &folders)
1425 {
1426  setValue("GUI/RSSWidget/OpenedFolders", folders);
1427 }
1428 
1430 {
1431 #if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
1432  return value<QByteArray>("GUI/Qt6/RSSWidget/SideSplitterState");
1433 #else
1434  return value<QByteArray>("GUI/RSSWidget/qt5/splitter_h");
1435 #endif
1436 }
1437 
1438 void Preferences::setRssSideSplitterState(const QByteArray &state)
1439 {
1440 #if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
1441  setValue("GUI/Qt6/RSSWidget/SideSplitterState", state);
1442 #else
1443  setValue("GUI/RSSWidget/qt5/splitter_h", state);
1444 #endif
1445 }
1446 
1448 {
1449 #if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
1450  return value<QByteArray>("GUI/Qt6/RSSWidget/MainSplitterState");
1451 #else
1452  return value<QByteArray>("GUI/RSSWidget/qt5/splitterMain");
1453 #endif
1454 }
1455 
1456 void Preferences::setRssMainSplitterState(const QByteArray &state)
1457 {
1458 #if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
1459  setValue("GUI/Qt6/RSSWidget/MainSplitterState", state);
1460 #else
1461  setValue("GUI/RSSWidget/qt5/splitterMain", state);
1462 #endif
1463 }
1464 
1466 {
1467 #if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
1468  return value<QByteArray>("GUI/Qt6/SearchTab/HeaderState");
1469 #else
1470  return value<QByteArray>("SearchTab/qt5/HeaderState");
1471 #endif
1472 }
1473 
1474 void Preferences::setSearchTabHeaderState(const QByteArray &state)
1475 {
1476 #if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
1477  setValue("GUI/Qt6/SearchTab/HeaderState", state);
1478 #else
1479  setValue("SearchTab/qt5/HeaderState", state);
1480 #endif
1481 }
1482 
1484 {
1485  return value("SearchTab/UseRegexAsFilteringPattern", false);
1486 }
1487 
1489 {
1490  setValue("SearchTab/UseRegexAsFilteringPattern", checked);
1491 }
1492 
1494 {
1495  return value<QStringList>("SearchEngines/disabledEngines");
1496 }
1497 
1499 {
1500  setValue("SearchEngines/disabledEngines", engines);
1501 }
1502 
1504 {
1505  return value("TorrentImport/LastContentDir", QDir::homePath());
1506 }
1507 
1509 {
1510  setValue("TorrentImport/LastContentDir", path);
1511 }
1512 
1514 {
1515  return value<QByteArray>("TorrentImportDlg/dimensions");
1516 }
1517 
1518 void Preferences::setTorImportGeometry(const QByteArray &geometry)
1519 {
1520  setValue("TorrentImportDlg/dimensions", geometry);
1521 }
1522 
1524 {
1525  return value("TransferListFilters/statusFilterState", true);
1526 }
1527 
1528 void Preferences::setStatusFilterState(const bool checked)
1529 {
1530  setValue("TransferListFilters/statusFilterState", checked);
1531 }
1532 
1534 {
1535  return value("TransferListFilters/CategoryFilterState", true);
1536 }
1537 
1538 void Preferences::setCategoryFilterState(const bool checked)
1539 {
1540  setValue("TransferListFilters/CategoryFilterState", checked);
1541 }
1542 
1544 {
1545  return value("TransferListFilters/TagFilterState", true);
1546 }
1547 
1548 void Preferences::setTagFilterState(const bool checked)
1549 {
1550  setValue("TransferListFilters/TagFilterState", checked);
1551 }
1552 
1554 {
1555  return value("TransferListFilters/trackerFilterState", true);
1556 }
1557 
1558 void Preferences::setTrackerFilterState(const bool checked)
1559 {
1560  setValue("TransferListFilters/trackerFilterState", checked);
1561 }
1562 
1564 {
1565  return value<int>("TransferListFilters/selectedFilterIndex", 0);
1566 }
1567 
1568 void Preferences::setTransSelFilter(const int index)
1569 {
1570  setValue("TransferListFilters/selectedFilterIndex", index);
1571 }
1572 
1574 {
1575 #if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
1576  return value<QByteArray>("GUI/Qt6/TransferList/HeaderState");
1577 #else
1578  return value<QByteArray>("TransferList/qt5/HeaderState");
1579 #endif
1580 }
1581 
1582 void Preferences::setTransHeaderState(const QByteArray &state)
1583 {
1584 #if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
1585  setValue("GUI/Qt6/TransferList/HeaderState", state);
1586 #else
1587  setValue("TransferList/qt5/HeaderState", state);
1588 #endif
1589 }
1590 
1592 {
1593  return value("TransferList/UseRegexAsFilteringPattern", false);
1594 }
1595 
1597 {
1598  setValue("TransferList/UseRegexAsFilteringPattern", checked);
1599 }
1600 
1601 // From old RssSettings class
1603 {
1604  return value("GUI/RSSWidget/Enabled", false);
1605 }
1606 
1607 void Preferences::setRSSWidgetVisible(const bool enabled)
1608 {
1609  setValue("GUI/RSSWidget/Enabled", enabled);
1610 }
1611 
1613 {
1614  return value<int>("Toolbar/textPosition", -1);
1615 }
1616 
1617 void Preferences::setToolbarTextPosition(const int position)
1618 {
1619  setValue("Toolbar/textPosition", position);
1620 }
1621 
1622 QList<QNetworkCookie> Preferences::getNetworkCookies() const
1623 {
1624  const auto rawCookies = value<QStringList>("Network/Cookies");
1625  QList<QNetworkCookie> cookies;
1626  cookies.reserve(rawCookies.size());
1627  for (const QString &rawCookie : rawCookies)
1628  cookies << QNetworkCookie::parseCookies(rawCookie.toUtf8());
1629  return cookies;
1630 }
1631 
1632 void Preferences::setNetworkCookies(const QList<QNetworkCookie> &cookies)
1633 {
1634  QStringList rawCookies;
1635  rawCookies.reserve(cookies.size());
1636  for (const QNetworkCookie &cookie : cookies)
1637  rawCookies << cookie.toRawForm();
1638  setValue("Network/Cookies", rawCookies);
1639 }
1640 
1642 {
1643  return value("SpeedWidget/Enabled", true);
1644 }
1645 
1646 void Preferences::setSpeedWidgetEnabled(const bool enabled)
1647 {
1648  setValue("SpeedWidget/Enabled", enabled);
1649 }
1650 
1652 {
1653  return value<int>("SpeedWidget/period", 1);
1654 }
1655 
1657 {
1658  setValue("SpeedWidget/period", period);
1659 }
1660 
1662 {
1663  // UP and DOWN graphs enabled by default
1664  return value(QString::fromLatin1("SpeedWidget/graph_enable_%1").arg(id), ((id == 0) || (id == 1)));
1665 }
1666 
1667 void Preferences::setSpeedWidgetGraphEnable(const int id, const bool enable)
1668 {
1669  setValue(QString::fromLatin1("SpeedWidget/graph_enable_%1").arg(id), enable);
1670 }
1671 
1673 {
1674  if (SettingsStorage::instance()->save())
1675  emit changed();
1676 }
void setTorImportGeometry(const QByteArray &geometry)
void setTransHeaderState(const QByteArray &state)
void setWebUIHttpsCertificatePath(const QString &path)
void disableRecursiveDownload(bool disable=true)
QString getMailNotificationSMTPUsername() const
void setWebUiRootFolder(const QString &path)
bool deleteTorrentFilesAsDefault() const
bool recursiveDownloadDisabled() const
bool shutdownqBTWhenDownloadsComplete() const
void setActionOnDblClOnTorrentDl(int act)
QByteArray getTransHeaderState() const
QString getWebUICustomHTTPHeaders() const
QString getMailNotificationSMTPPassword() const
bool resolvePeerCountries() const
QString getAutoRunProgram() const
void setAltWebUiEnabled(bool enabled)
static Preferences * instance()
void setDynDNSEnabled(bool enabled)
bool shutdownWhenDownloadsComplete() const
int getWebUIMaxAuthFailCount() const
QString getWebUiRootFolder() const
QString getWebUIHttpsCertificatePath() const
void setSuspendWhenDownloadsComplete(bool suspend)
void setPropCurTab(int tab)
void setMailNotificationSMTPUsername(const QString &username)
int getPropCurTab() const
bool getStatusFilterState() const
void setCloseToTray(bool b)
void setSpeedWidgetPeriod(int period)
int getTrackerPort() const
void setMinimizeToTray(bool b)
void setUPnPForWebUIPort(bool enabled)
QString lastLocationPath() const
void setHideZeroValues(bool b)
bool resolvePeerHostNames() const
void setNetworkCookies(const QList< QNetworkCookie > &cookies)
void setIconsInMenusEnabled(bool enable)
void setWebUiCSRFProtectionEnabled(bool enabled)
void setWebUiSecureCookieEnabled(bool enabled)
bool getTrackerFilterState() const
bool isSplashScreenDisabled() const
QByteArray getPropTrackerListState() const
void setWebUIReverseProxySupportEnabled(bool enabled)
void setCloseToTrayNotified(bool b)
void setConfirmOnExit(bool confirm)
std::chrono::seconds getWebUIBanDuration() const
QString getMailNotificationEmail() const
bool preventFromSuspendWhenSeeding() const
void setShutdownqBTWhenDownloadsComplete(bool shutdown)
bool isWebUiLocalAuthEnabled() const
void setStartMinimized(bool b)
int getTransSelFilter() const
QString getWebUiAddress() const
void setAlternatingRowColors(bool b)
void setWebUIBanDuration(std::chrono::seconds duration)
void setSpeedWidgetGraphEnable(int id, bool enable)
bool useAlternatingRowColors() const
bool getMailNotificationSMTPAuth() const
void setPropTrackerListState(const QByteArray &state)
void setPreventFromSuspendWhenDownloading(bool b)
bool isWebUiSecureCookieEnabled() const
void setCustomUIThemePath(const QString &path)
bool isStatusbarDisplayed() const
QString getDynDNSUsername() const
void setStatusFilterState(bool checked)
void setRssMainSplitterState(const QByteArray &state)
QByteArray getMainGeometry() const
void changed()
void setServerDomains(const QString &str)
bool suspendWhenDownloadsComplete() const
void setDynDNSUsername(const QString &username)
QString getMailNotificationSender() const
bool isSearchEnabled() const
QString customUIThemePath() const
bool useCustomUITheme() const
void setRegexAsFilteringPatternForTransferList(bool checked)
void setMinimizeToTrayNotified(bool b)
void setSchedulerEndTime(const QTime &time)
bool getMailNotificationSMTPSSL() const
bool confirmOnExit() const
void setConfirmTorrentDeletion(bool enabled)
void setRegexAsFilteringPatternForSearchJob(bool checked)
void setMainLastDir(const QString &path)
void setWebUIHostHeaderValidationEnabled(bool enabled)
QString getPropSplitterSizes() const
static void initInstance()
QByteArray getTorImportGeometry() const
void setDontConfirmAutoExit(bool dontConfirmAutoExit)
QList< QNetworkCookie > getNetworkCookies() const
bool systemTrayEnabled() const
void setWebUiAddress(const QString &addr)
void setSchedulerDays(Scheduler::Days days)
void setMailNotificationEnabled(bool enabled)
QDateTime getDNSLastUpd() const
void setScanDirsLastPath(const QString &path)
QString getDynDNSPassword() const
bool isWebUIHostHeaderValidationEnabled() const
void setDNSLastIP(const QString &ip)
void showSpeedInTitleBar(bool show)
bool closeToTray() const
QByteArray getRssMainSplitterState() const
void setStatusbarDisplayed(bool displayed)
bool getPropVisible() const
void setSearchTabHeaderState(const QByteArray &state)
void setSystemTrayEnabled(bool enabled)
void setWebUIPassword(const QByteArray &password)
void setWebUiAuthSubnetWhitelist(QStringList subnets)
QTime getSchedulerStartTime() const
void setAutoRunEnabled(bool enabled)
void setTorImportLastContentDir(const QString &path)
bool useUPnPForWebUIPort() const
QByteArray getWebUIPassword() const
void setWebUiClickjackingProtectionEnabled(bool enabled)
int getActionOnDblClOnTorrentFn() const
void setTrayIconStyle(TrayIcon::Style style)
bool isAltWebUiEnabled() const
void setMainGeometry(const QByteArray &geometry)
QStringList getSearchEngDisabled() const
void setUILocked(bool locked)
void setSearchEngDisabled(const QStringList &engines)
void setWebUiUsername(const QString &username)
bool isWebUiAuthSubnetWhitelistEnabled() const
static void freeInstance()
bool speedInTitleBar() const
void setUILockPassword(const QByteArray &password)
bool getRegexAsFilteringPatternForTransferList() const
QString getWebUITrustedReverseProxiesList() const
bool dontConfirmAutoExit() const
bool recheckTorrentsOnCompletion() const
QByteArray getRssSideSplitterState() const
void setDeleteTorrentFilesAsDefault(bool del)
void setPropVisible(bool visible)
QTime getSchedulerEndTime() const
void setDynDomainName(const QString &name)
bool isUILocked() const
void setWebUISessionTimeout(int timeout)
QByteArray getPeerListState() const
bool isWebUICustomHTTPHeadersEnabled() const
bool isWebUiClickjackingProtectionEnabled() const
DNS::Service getDynDNSService() const
void setPeerListState(const QByteArray &state)
TrayIcon::Style trayIconStyle() const
bool isRSSWidgetEnabled() const
void setActionOnDblClOnTorrentFn(int act)
void setLastLocationPath(const QString &path)
void setWebUICustomHTTPHeaders(const QString &headers)
void setRssGeometrySize(const QSize &geometry)
bool closeToTrayNotified() const
void setDynDNSPassword(const QString &password)
bool confirmRemoveAllTags() const
void setToolbarTextPosition(int position)
void setMailNotificationSMTPPassword(const QString &password)
void setUseCustomUITheme(bool use)
void setTrackerPort(int port)
bool isDynDNSEnabled() const
void setWebUiLocalAuthEnabled(bool enabled)
void setHideZeroComboValues(int n)
bool confirmTorrentDeletion() const
void setWebUICustomHTTPHeadersEnabled(bool enabled)
QByteArray getMainVSplitterState() const
void setLocale(const QString &locale)
void setWebUITrustedReverseProxiesList(const QString &addr)
QString getScanDirsLastPath() const
void setWebUIMaxAuthFailCount(int count)
int getHideZeroComboValues() const
void setAcceptedLegal(bool accepted)
QString getLocale() const
void setShutdownWhenDownloadsComplete(bool shutdown)
void setDynDNSService(DNS::Service service)
bool isSpeedWidgetEnabled() const
bool getAcceptedLegal() const
bool getSpeedWidgetGraphEnable(int id) const
static Preferences * m_instance
Definition: preferences.h:96
void setMailNotificationSender(const QString &mail)
void setSchedulerStartTime(const QTime &time)
void setWebUiPort(quint16 port)
void setAutoRunProgram(const QString &program)
QString getMainLastDir() const
quint16 getWebUiPort() const
void setTagFilterState(bool checked)
bool isWebUiCSRFProtectionEnabled() const
bool getCategoryFilterState() const
bool getHideZeroValues() const
bool isToolbarDisplayed() const
bool confirmTorrentRecheck() const
QSize getRssGeometrySize() const
void setRSSWidgetVisible(bool enabled)
void setSearchEnabled(bool enabled)
bool isWebUIReverseProxySupportEnabled() const
QString getWebUiUsername() const
bool minimizeToTray() const
void setToolbarDisplayed(bool displayed)
Scheduler::Days getSchedulerDays() const
void setWebUIHttpsKeyPath(const QString &path)
void setMailNotificationSMTPSSL(bool use)
int getToolbarTextPosition() const
void setWebUiEnabled(bool enabled)
QString getTorImportLastContentDir() const
void setSplashScreenDisabled(bool b)
QString getServerDomains() const
void setSpeedWidgetEnabled(bool enabled)
void setHibernateWhenDownloadsComplete(bool hibernate)
void setTrackerFilterState(bool checked)
QString getMailNotificationSMTP() const
QString getDNSLastIP() const
QByteArray getUILockPassword() const
void setRssOpenFolders(const QStringList &folders)
void setDNSLastUpd(const QDateTime &date)
QByteArray getSearchTabHeaderState() const
int getWebUISessionTimeout() const
void setRssSideSplitterState(const QByteArray &state)
bool preventFromSuspendWhenDownloading() const
bool iconsInMenusEnabled() const
int getActionOnDblClOnTorrentDl() const
bool minimizeToTrayNotified() const
bool getTagFilterState() const
int getSpeedWidgetPeriod() const
bool isWebUiEnabled() const
QVector< Utils::Net::Subnet > getWebUiAuthSubnetWhitelist() const
void setRssHSplitterSizes(const QByteArray &sizes)
void setConfirmRemoveAllTags(bool enabled)
void setTransSelFilter(int index)
void setPropFileListState(const QByteArray &state)
QByteArray getRssHSplitterSizes() const
bool isMailNotificationEnabled() const
bool isWebUiHttpsEnabled() const
void setWebUiAuthSubnetWhitelistEnabled(bool enabled)
QStringList getRssOpenFolders() const
bool isAutoRunEnabled() const
void setPropSplitterSizes(const QString &sizes)
void setPreventFromSuspendWhenSeeding(bool b)
void setWebUiHttpsEnabled(bool enabled)
void setMailNotificationEmail(const QString &mail)
bool getRegexAsFilteringPatternForSearchJob() const
void setCategoryFilterState(bool checked)
QByteArray getPropFileListState() const
void setMainVSplitterState(const QByteArray &state)
QString getDynDomainName() const
void setMailNotificationSMTP(const QString &smtp_server)
void setMailNotificationSMTPAuth(bool use)
bool hibernateWhenDownloadsComplete() const
void setConfirmTorrentRecheck(bool enabled)
bool startMinimized() const
QString getWebUIHttpsKeyPath() const
QString rootPath() const
Definition: profile.cpp:94
QString profileName() const
Definition: profile.cpp:104
QString configurationName() const
Definition: profile.cpp:99
static const Profile * instance()
Definition: profile.cpp:67
void storeValue(const QString &key, const T &value)
T loadValue(const QString &key, const T &defaultValue={}) const
static SettingsStorage * instance()
flag icons free of to any person obtaining a copy of this software and associated documentation to deal in the Software without including without limitation the rights to use
void removeIf(T &dict, BinaryPredicate &&p)
Definition: algorithm.h:50
Service
Definition: preferences.h:68
QString toValidFileSystemName(const QString &name, bool allowSeparators=false, const QString &pad=QLatin1String(" "))
Definition: fs.cpp:237
QString toUniformPath(const QString &path)
Definition: fs.cpp:69
QString toNativePath(const QString &path)
Definition: fs.cpp:64
Subnet parseSubnet(const QString &subnetStr, bool *ok)
Definition: net.cpp:48
QPair< QHostAddress, int > Subnet
Definition: net.h:40
T value(const char *key, const T &defaultValue={})
Definition: preferences.cpp:70
void setValue(const char *key, const T &value)
Definition: preferences.cpp:82
dictionary headers
Definition: helpers.py:44