2 * Bittorrent Client using Qt and libtorrent.
3 * Copyright (C) 2014 sledgehammer999 <hammered999@gmail.com>
4 * Copyright (C) 2006 Christophe Dumez <chris@qbittorrent.org>
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.
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.
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.
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.
32 #include <QtContainerFwd>
36 #include "base/utils/net.h"
77 class Preferences
: public QObject
80 Q_DISABLE_COPY_MOVE(Preferences
)
84 QVariant
value(const QString
&key
, const QVariant
&defaultValue
= {}) const;
85 void setValue(const QString
&key
, const QVariant
&value
);
87 static Preferences
*m_instance
;
93 static void initInstance();
94 static void freeInstance();
95 static Preferences
*instance();
98 QString
getLocale() const;
99 void setLocale(const QString
&locale
);
100 bool useCustomUITheme() const;
101 void setUseCustomUITheme(bool use
);
102 QString
customUIThemePath() const;
103 void setCustomUIThemePath(const QString
&path
);
104 bool deleteTorrentFilesAsDefault() const;
105 void setDeleteTorrentFilesAsDefault(bool del
);
106 bool confirmOnExit() const;
107 void setConfirmOnExit(bool confirm
);
108 bool speedInTitleBar() const;
109 void showSpeedInTitleBar(bool show
);
110 bool useAlternatingRowColors() const;
111 void setAlternatingRowColors(bool b
);
112 bool getHideZeroValues() const;
113 void setHideZeroValues(bool b
);
114 int getHideZeroComboValues() const;
115 void setHideZeroComboValues(int n
);
116 bool isStatusbarDisplayed() const;
117 void setStatusbarDisplayed(bool displayed
);
118 bool isToolbarDisplayed() const;
119 void setToolbarDisplayed(bool displayed
);
120 bool startMinimized() const;
121 void setStartMinimized(bool b
);
122 bool isSplashScreenDisabled() const;
123 void setSplashScreenDisabled(bool b
);
124 bool preventFromSuspendWhenDownloading() const;
125 void setPreventFromSuspendWhenDownloading(bool b
);
126 bool preventFromSuspendWhenSeeding() const;
127 void setPreventFromSuspendWhenSeeding(bool b
);
129 bool WinStartup() const;
130 void setWinStartup(bool b
);
134 QString
lastLocationPath() const;
135 void setLastLocationPath(const QString
&path
);
136 QString
getScanDirsLastPath() const;
137 void setScanDirsLastPath(const QString
&path
);
138 bool isMailNotificationEnabled() const;
139 void setMailNotificationEnabled(bool enabled
);
140 QString
getMailNotificationSender() const;
141 void setMailNotificationSender(const QString
&mail
);
142 QString
getMailNotificationEmail() const;
143 void setMailNotificationEmail(const QString
&mail
);
144 QString
getMailNotificationSMTP() const;
145 void setMailNotificationSMTP(const QString
&smtp_server
);
146 bool getMailNotificationSMTPSSL() const;
147 void setMailNotificationSMTPSSL(bool use
);
148 bool getMailNotificationSMTPAuth() const;
149 void setMailNotificationSMTPAuth(bool use
);
150 QString
getMailNotificationSMTPUsername() const;
151 void setMailNotificationSMTPUsername(const QString
&username
);
152 QString
getMailNotificationSMTPPassword() const;
153 void setMailNotificationSMTPPassword(const QString
&password
);
154 int getActionOnDblClOnTorrentDl() const;
155 void setActionOnDblClOnTorrentDl(int act
);
156 int getActionOnDblClOnTorrentFn() const;
157 void setActionOnDblClOnTorrentFn(int act
);
159 // Connection options
160 QTime
getSchedulerStartTime() const;
161 void setSchedulerStartTime(const QTime
&time
);
162 QTime
getSchedulerEndTime() const;
163 void setSchedulerEndTime(const QTime
&time
);
164 SchedulerDays
getSchedulerDays() const;
165 void setSchedulerDays(SchedulerDays days
);
168 bool isSearchEnabled() const;
169 void setSearchEnabled(bool enabled
);
172 bool isWebUiEnabled() const;
173 void setWebUiEnabled(bool enabled
);
174 QString
getServerDomains() const;
175 void setServerDomains(const QString
&str
);
176 QString
getWebUiAddress() const;
177 void setWebUiAddress(const QString
&addr
);
178 quint16
getWebUiPort() const;
179 void setWebUiPort(quint16 port
);
180 bool useUPnPForWebUIPort() const;
181 void setUPnPForWebUIPort(bool enabled
);
184 bool isWebUiLocalAuthEnabled() const;
185 void setWebUiLocalAuthEnabled(bool enabled
);
186 bool isWebUiAuthSubnetWhitelistEnabled() const;
187 void setWebUiAuthSubnetWhitelistEnabled(bool enabled
);
188 QVector
<Utils::Net::Subnet
> getWebUiAuthSubnetWhitelist() const;
189 void setWebUiAuthSubnetWhitelist(QStringList subnets
);
190 QString
getWebUiUsername() const;
191 void setWebUiUsername(const QString
&username
);
192 QByteArray
getWebUIPassword() const;
193 void setWebUIPassword(const QByteArray
&password
);
194 int getWebUIMaxAuthFailCount() const;
195 void setWebUIMaxAuthFailCount(int count
);
196 std::chrono::seconds
getWebUIBanDuration() const;
197 void setWebUIBanDuration(std::chrono::seconds duration
);
198 int getWebUISessionTimeout() const;
199 void setWebUISessionTimeout(int timeout
);
202 bool isWebUiClickjackingProtectionEnabled() const;
203 void setWebUiClickjackingProtectionEnabled(bool enabled
);
204 bool isWebUiCSRFProtectionEnabled() const;
205 void setWebUiCSRFProtectionEnabled(bool enabled
);
206 bool isWebUiSecureCookieEnabled () const;
207 void setWebUiSecureCookieEnabled(bool enabled
);
208 bool isWebUIHostHeaderValidationEnabled() const;
209 void setWebUIHostHeaderValidationEnabled(bool enabled
);
212 bool isWebUiHttpsEnabled() const;
213 void setWebUiHttpsEnabled(bool enabled
);
214 QString
getWebUIHttpsCertificatePath() const;
215 void setWebUIHttpsCertificatePath(const QString
&path
);
216 QString
getWebUIHttpsKeyPath() const;
217 void setWebUIHttpsKeyPath(const QString
&path
);
218 bool isAltWebUiEnabled() const;
219 void setAltWebUiEnabled(bool enabled
);
220 QString
getWebUiRootFolder() const;
221 void setWebUiRootFolder(const QString
&path
);
223 // WebUI custom HTTP headers
224 bool isWebUICustomHTTPHeadersEnabled() const;
225 void setWebUICustomHTTPHeadersEnabled(bool enabled
);
226 QString
getWebUICustomHTTPHeaders() const;
227 void setWebUICustomHTTPHeaders(const QString
&headers
);
230 bool isWebUIReverseProxySupportEnabled() const;
231 void setWebUIReverseProxySupportEnabled(bool enabled
);
232 QString
getWebUITrustedReverseProxiesList() const;
233 void setWebUITrustedReverseProxiesList(const QString
&addr
);
236 bool isDynDNSEnabled() const;
237 void setDynDNSEnabled(bool enabled
);
238 DNS::Service
getDynDNSService() const;
239 void setDynDNSService(int service
);
240 QString
getDynDomainName() const;
241 void setDynDomainName(const QString
&name
);
242 QString
getDynDNSUsername() const;
243 void setDynDNSUsername(const QString
&username
);
244 QString
getDynDNSPassword() const;
245 void setDynDNSPassword(const QString
&password
);
248 QByteArray
getUILockPassword() const;
249 void setUILockPassword(const QByteArray
&password
);
250 bool isUILocked() const;
251 void setUILocked(bool locked
);
252 bool isAutoRunEnabled() const;
253 void setAutoRunEnabled(bool enabled
);
254 QString
getAutoRunProgram() const;
255 void setAutoRunProgram(const QString
&program
);
256 #if defined(Q_OS_WIN)
257 bool isAutoRunConsoleEnabled() const;
258 void setAutoRunConsoleEnabled(bool enabled
);
260 bool shutdownWhenDownloadsComplete() const;
261 void setShutdownWhenDownloadsComplete(bool shutdown
);
262 bool suspendWhenDownloadsComplete() const;
263 void setSuspendWhenDownloadsComplete(bool suspend
);
264 bool hibernateWhenDownloadsComplete() const;
265 void setHibernateWhenDownloadsComplete(bool hibernate
);
266 bool shutdownqBTWhenDownloadsComplete() const;
267 void setShutdownqBTWhenDownloadsComplete(bool shutdown
);
268 bool dontConfirmAutoExit() const;
269 void setDontConfirmAutoExit(bool dontConfirmAutoExit
);
270 bool recheckTorrentsOnCompletion() const;
271 void recheckTorrentsOnCompletion(bool recheck
);
272 bool resolvePeerCountries() const;
273 void resolvePeerCountries(bool resolve
);
274 bool resolvePeerHostNames() const;
275 void resolvePeerHostNames(bool resolve
);
276 #if (defined(Q_OS_UNIX) && !defined(Q_OS_MACOS))
277 bool useSystemIconTheme() const;
278 void useSystemIconTheme(bool enabled
);
280 bool recursiveDownloadDisabled() const;
281 void disableRecursiveDownload(bool disable
= true);
283 bool neverCheckFileAssoc() const;
284 void setNeverCheckFileAssoc(bool check
= true);
285 static bool isTorrentFileAssocSet();
286 static bool isMagnetLinkAssocSet();
287 static void setTorrentFileAssoc(bool set
);
288 static void setMagnetLinkAssoc(bool set
);
291 static bool isTorrentFileAssocSet();
292 static bool isMagnetLinkAssocSet();
293 static void setTorrentFileAssoc();
294 static void setMagnetLinkAssoc();
296 int getTrackerPort() const;
297 void setTrackerPort(int port
);
298 #if defined(Q_OS_WIN) || defined(Q_OS_MACOS)
299 bool isUpdateCheckEnabled() const;
300 void setUpdateCheckEnabled(bool enabled
);
302 bool confirmTorrentDeletion() const;
303 void setConfirmTorrentDeletion(bool enabled
);
304 bool confirmTorrentRecheck() const;
305 void setConfirmTorrentRecheck(bool enabled
);
306 bool confirmRemoveAllTags() const;
307 void setConfirmRemoveAllTags(bool enabled
);
309 bool systrayIntegration() const;
310 void setSystrayIntegration(bool enabled
);
311 bool minimizeToTrayNotified() const;
312 void setMinimizeToTrayNotified(bool b
);
313 bool minimizeToTray() const;
314 void setMinimizeToTray(bool b
);
315 bool closeToTray() const;
316 void setCloseToTray(bool b
);
317 bool closeToTrayNotified() const;
318 void setCloseToTrayNotified(bool b
);
319 TrayIcon::Style
trayIconStyle() const;
320 void setTrayIconStyle(TrayIcon::Style style
);
321 bool iconsInMenusEnabled() const;
322 void setIconsInMenusEnabled(bool enable
);
325 // Stuff that don't appear in the Options GUI but are saved
327 QDateTime
getDNSLastUpd() const;
328 void setDNSLastUpd(const QDateTime
&date
);
329 QString
getDNSLastIP() const;
330 void setDNSLastIP(const QString
&ip
);
331 bool getAcceptedLegal() const;
332 void setAcceptedLegal(bool accepted
);
333 QByteArray
getMainGeometry() const;
334 void setMainGeometry(const QByteArray
&geometry
);
335 QByteArray
getMainVSplitterState() const;
336 void setMainVSplitterState(const QByteArray
&state
);
337 QString
getMainLastDir() const;
338 void setMainLastDir(const QString
&path
);
339 QByteArray
getPeerListState() const;
340 void setPeerListState(const QByteArray
&state
);
341 QString
getPropSplitterSizes() const;
342 void setPropSplitterSizes(const QString
&sizes
);
343 QByteArray
getPropFileListState() const;
344 void setPropFileListState(const QByteArray
&state
);
345 int getPropCurTab() const;
346 void setPropCurTab(int tab
);
347 bool getPropVisible() const;
348 void setPropVisible(bool visible
);
349 QByteArray
getPropTrackerListState() const;
350 void setPropTrackerListState(const QByteArray
&state
);
351 QSize
getRssGeometrySize() const;
352 void setRssGeometrySize(const QSize
&geometry
);
353 QByteArray
getRssHSplitterSizes() const;
354 void setRssHSplitterSizes(const QByteArray
&sizes
);
355 QStringList
getRssOpenFolders() const;
356 void setRssOpenFolders(const QStringList
&folders
);
357 QByteArray
getRssSideSplitterState() const;
358 void setRssSideSplitterState(const QByteArray
&state
);
359 QByteArray
getRssMainSplitterState() const;
360 void setRssMainSplitterState(const QByteArray
&state
);
361 QByteArray
getSearchTabHeaderState() const;
362 void setSearchTabHeaderState(const QByteArray
&state
);
363 bool getRegexAsFilteringPatternForSearchJob() const;
364 void setRegexAsFilteringPatternForSearchJob(bool checked
);
365 QStringList
getSearchEngDisabled() const;
366 void setSearchEngDisabled(const QStringList
&engines
);
367 QString
getTorImportLastContentDir() const;
368 void setTorImportLastContentDir(const QString
&path
);
369 QByteArray
getTorImportGeometry() const;
370 void setTorImportGeometry(const QByteArray
&geometry
);
371 bool getStatusFilterState() const;
372 bool getCategoryFilterState() const;
373 bool getTagFilterState() const;
374 bool getTrackerFilterState() const;
375 int getTransSelFilter() const;
376 void setTransSelFilter(int index
);
377 QByteArray
getTransHeaderState() const;
378 void setTransHeaderState(const QByteArray
&state
);
379 bool getRegexAsFilteringPatternForTransferList() const;
380 void setRegexAsFilteringPatternForTransferList(bool checked
);
381 int getToolbarTextPosition() const;
382 void setToolbarTextPosition(int position
);
384 // From old RssSettings class
385 bool isRSSWidgetEnabled() const;
386 void setRSSWidgetVisible(bool enabled
);
389 QList
<QNetworkCookie
> getNetworkCookies() const;
390 void setNetworkCookies(const QList
<QNetworkCookie
> &cookies
);
393 bool isSpeedWidgetEnabled() const;
394 void setSpeedWidgetEnabled(bool enabled
);
395 int getSpeedWidgetPeriod() const;
396 void setSpeedWidgetPeriod(int period
);
397 bool getSpeedWidgetGraphEnable(int id
) const;
398 void setSpeedWidgetGraphEnable(int id
, bool enable
);
401 void setStatusFilterState(bool checked
);
402 void setCategoryFilterState(bool checked
);
403 void setTagFilterState(bool checked
);
404 void setTrackerFilterState(bool checked
);