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>
33 #include <QtSystemDetection>
36 #include "base/pathfwd.h"
37 #include "base/utils/net.h"
67 enum class Service
: int
80 enum class Style
: int
89 class Preferences final
: public QObject
92 Q_DISABLE_COPY_MOVE(Preferences
)
97 static void initInstance();
98 static void freeInstance();
99 static Preferences
*instance();
102 QString
getLocale() const;
103 void setLocale(const QString
&locale
);
104 bool useCustomUITheme() const;
105 void setUseCustomUITheme(bool use
);
106 Path
customUIThemePath() const;
107 void setCustomUIThemePath(const Path
&path
);
108 bool removeTorrentContent() const;
109 void setRemoveTorrentContent(bool remove
);
110 bool confirmOnExit() const;
111 void setConfirmOnExit(bool confirm
);
112 bool speedInTitleBar() const;
113 void showSpeedInTitleBar(bool show
);
114 bool useAlternatingRowColors() const;
115 void setAlternatingRowColors(bool b
);
116 bool getHideZeroValues() const;
117 void setHideZeroValues(bool b
);
118 int getHideZeroComboValues() const;
119 void setHideZeroComboValues(int n
);
120 bool isStatusbarDisplayed() const;
121 void setStatusbarDisplayed(bool displayed
);
122 bool isStatusbarExternalIPDisplayed() const;
123 void setStatusbarExternalIPDisplayed(bool displayed
);
124 bool isToolbarDisplayed() const;
125 void setToolbarDisplayed(bool displayed
);
126 bool isSplashScreenDisabled() const;
127 void setSplashScreenDisabled(bool b
);
128 bool preventFromSuspendWhenDownloading() const;
129 void setPreventFromSuspendWhenDownloading(bool b
);
130 bool preventFromSuspendWhenSeeding() const;
131 void setPreventFromSuspendWhenSeeding(bool b
);
133 bool WinStartup() const;
134 void setWinStartup(bool b
);
135 QString
getStyle() const;
136 void setStyle(const QString
&styleName
);
140 Path
getScanDirsLastPath() const;
141 void setScanDirsLastPath(const Path
&path
);
142 bool isMailNotificationEnabled() const;
143 void setMailNotificationEnabled(bool enabled
);
144 QString
getMailNotificationSender() const;
145 void setMailNotificationSender(const QString
&mail
);
146 QString
getMailNotificationEmail() const;
147 void setMailNotificationEmail(const QString
&mail
);
148 QString
getMailNotificationSMTP() const;
149 void setMailNotificationSMTP(const QString
&smtpServer
);
150 bool getMailNotificationSMTPSSL() const;
151 void setMailNotificationSMTPSSL(bool use
);
152 bool getMailNotificationSMTPAuth() const;
153 void setMailNotificationSMTPAuth(bool use
);
154 QString
getMailNotificationSMTPUsername() const;
155 void setMailNotificationSMTPUsername(const QString
&username
);
156 QString
getMailNotificationSMTPPassword() const;
157 void setMailNotificationSMTPPassword(const QString
&password
);
158 int getActionOnDblClOnTorrentDl() const;
159 void setActionOnDblClOnTorrentDl(int act
);
160 int getActionOnDblClOnTorrentFn() const;
161 void setActionOnDblClOnTorrentFn(int act
);
163 // Connection options
164 QTime
getSchedulerStartTime() const;
165 void setSchedulerStartTime(const QTime
&time
);
166 QTime
getSchedulerEndTime() const;
167 void setSchedulerEndTime(const QTime
&time
);
168 Scheduler::Days
getSchedulerDays() const;
169 void setSchedulerDays(Scheduler::Days days
);
172 bool isSearchEnabled() const;
173 void setSearchEnabled(bool enabled
);
176 bool isWebUIEnabled() const;
177 void setWebUIEnabled(bool enabled
);
178 QString
getServerDomains() const;
179 void setServerDomains(const QString
&str
);
180 QString
getWebUIAddress() const;
181 void setWebUIAddress(const QString
&addr
);
182 quint16
getWebUIPort() const;
183 void setWebUIPort(quint16 port
);
184 bool useUPnPForWebUIPort() const;
185 void setUPnPForWebUIPort(bool enabled
);
188 bool isWebUILocalAuthEnabled() const;
189 void setWebUILocalAuthEnabled(bool enabled
);
190 bool isWebUIAuthSubnetWhitelistEnabled() const;
191 void setWebUIAuthSubnetWhitelistEnabled(bool enabled
);
192 QList
<Utils::Net::Subnet
> getWebUIAuthSubnetWhitelist() const;
193 void setWebUIAuthSubnetWhitelist(QStringList subnets
);
194 QString
getWebUIUsername() const;
195 void setWebUIUsername(const QString
&username
);
196 QByteArray
getWebUIPassword() const;
197 void setWebUIPassword(const QByteArray
&password
);
198 int getWebUIMaxAuthFailCount() const;
199 void setWebUIMaxAuthFailCount(int count
);
200 std::chrono::seconds
getWebUIBanDuration() const;
201 void setWebUIBanDuration(std::chrono::seconds duration
);
202 int getWebUISessionTimeout() const;
203 void setWebUISessionTimeout(int timeout
);
204 QString
getWebAPISessionCookieName() const;
205 void setWebAPISessionCookieName(const QString
&cookieName
);
208 bool isWebUIClickjackingProtectionEnabled() const;
209 void setWebUIClickjackingProtectionEnabled(bool enabled
);
210 bool isWebUICSRFProtectionEnabled() const;
211 void setWebUICSRFProtectionEnabled(bool enabled
);
212 bool isWebUISecureCookieEnabled () const;
213 void setWebUISecureCookieEnabled(bool enabled
);
214 bool isWebUIHostHeaderValidationEnabled() const;
215 void setWebUIHostHeaderValidationEnabled(bool enabled
);
218 bool isWebUIHttpsEnabled() const;
219 void setWebUIHttpsEnabled(bool enabled
);
220 Path
getWebUIHttpsCertificatePath() const;
221 void setWebUIHttpsCertificatePath(const Path
&path
);
222 Path
getWebUIHttpsKeyPath() const;
223 void setWebUIHttpsKeyPath(const Path
&path
);
224 bool isAltWebUIEnabled() const;
225 void setAltWebUIEnabled(bool enabled
);
226 Path
getWebUIRootFolder() const;
227 void setWebUIRootFolder(const Path
&path
);
229 // WebUI custom HTTP headers
230 bool isWebUICustomHTTPHeadersEnabled() const;
231 void setWebUICustomHTTPHeadersEnabled(bool enabled
);
232 QString
getWebUICustomHTTPHeaders() const;
233 void setWebUICustomHTTPHeaders(const QString
&headers
);
236 bool isWebUIReverseProxySupportEnabled() const;
237 void setWebUIReverseProxySupportEnabled(bool enabled
);
238 QString
getWebUITrustedReverseProxiesList() const;
239 void setWebUITrustedReverseProxiesList(const QString
&addr
);
242 bool isDynDNSEnabled() const;
243 void setDynDNSEnabled(bool enabled
);
244 DNS::Service
getDynDNSService() const;
245 void setDynDNSService(DNS::Service service
);
246 QString
getDynDomainName() const;
247 void setDynDomainName(const QString
&name
);
248 QString
getDynDNSUsername() const;
249 void setDynDNSUsername(const QString
&username
);
250 QString
getDynDNSPassword() const;
251 void setDynDNSPassword(const QString
&password
);
254 QByteArray
getUILockPassword() const;
255 void setUILockPassword(const QByteArray
&password
);
256 bool isUILocked() const;
257 void setUILocked(bool locked
);
259 bool isAutoRunOnTorrentAddedEnabled() const;
260 void setAutoRunOnTorrentAddedEnabled(bool enabled
);
261 QString
getAutoRunOnTorrentAddedProgram() const;
262 void setAutoRunOnTorrentAddedProgram(const QString
&program
);
263 bool isAutoRunOnTorrentFinishedEnabled() const;
264 void setAutoRunOnTorrentFinishedEnabled(bool enabled
);
265 QString
getAutoRunOnTorrentFinishedProgram() const;
266 void setAutoRunOnTorrentFinishedProgram(const QString
&program
);
267 #if defined(Q_OS_WIN)
268 bool isAutoRunConsoleEnabled() const;
269 void setAutoRunConsoleEnabled(bool enabled
);
272 bool shutdownWhenDownloadsComplete() const;
273 void setShutdownWhenDownloadsComplete(bool shutdown
);
274 bool suspendWhenDownloadsComplete() const;
275 void setSuspendWhenDownloadsComplete(bool suspend
);
276 bool hibernateWhenDownloadsComplete() const;
277 void setHibernateWhenDownloadsComplete(bool hibernate
);
278 bool shutdownqBTWhenDownloadsComplete() const;
279 void setShutdownqBTWhenDownloadsComplete(bool shutdown
);
280 bool dontConfirmAutoExit() const;
281 void setDontConfirmAutoExit(bool dontConfirmAutoExit
);
282 bool recheckTorrentsOnCompletion() const;
283 void recheckTorrentsOnCompletion(bool recheck
);
284 bool resolvePeerCountries() const;
285 void resolvePeerCountries(bool resolve
);
286 bool resolvePeerHostNames() const;
287 void resolvePeerHostNames(bool resolve
);
288 #if (defined(Q_OS_UNIX) && !defined(Q_OS_MACOS))
289 bool useSystemIcons() const;
290 void useSystemIcons(bool enabled
);
292 bool isRecursiveDownloadEnabled() const;
293 void setRecursiveDownloadEnabled(bool enable
);
294 int getTrackerPort() const;
295 void setTrackerPort(int port
);
296 bool isTrackerPortForwardingEnabled() const;
297 void setTrackerPortForwardingEnabled(bool enabled
);
298 bool isMarkOfTheWebEnabled() const;
299 void setMarkOfTheWebEnabled(bool enabled
);
300 bool isIgnoreSSLErrors() const;
301 void setIgnoreSSLErrors(bool enabled
);
302 Path
getPythonExecutablePath() const;
303 void setPythonExecutablePath(const Path
&path
);
304 #if defined(Q_OS_WIN) || defined(Q_OS_MACOS)
305 bool isUpdateCheckEnabled() const;
306 void setUpdateCheckEnabled(bool enabled
);
308 bool confirmTorrentDeletion() const;
309 void setConfirmTorrentDeletion(bool enabled
);
310 bool confirmTorrentRecheck() const;
311 void setConfirmTorrentRecheck(bool enabled
);
312 bool confirmRemoveAllTags() const;
313 void setConfirmRemoveAllTags(bool enabled
);
314 bool confirmMergeTrackers() const;
315 void setConfirmMergeTrackers(bool enabled
);
316 bool confirmRemoveTrackerFromAllTorrents() const;
317 void setConfirmRemoveTrackerFromAllTorrents(bool enabled
);
319 bool systemTrayEnabled() const;
320 void setSystemTrayEnabled(bool enabled
);
321 bool minimizeToTrayNotified() const;
322 void setMinimizeToTrayNotified(bool b
);
323 bool minimizeToTray() const;
324 void setMinimizeToTray(bool b
);
325 bool closeToTray() const;
326 void setCloseToTray(bool b
);
327 bool closeToTrayNotified() const;
328 void setCloseToTrayNotified(bool b
);
329 TrayIcon::Style
trayIconStyle() const;
330 void setTrayIconStyle(TrayIcon::Style style
);
331 bool iconsInMenusEnabled() const;
332 void setIconsInMenusEnabled(bool enable
);
334 qint64
getTorrentFileSizeLimit() const;
335 void setTorrentFileSizeLimit(qint64 value
);
336 int getBdecodeDepthLimit() const;
337 void setBdecodeDepthLimit(int value
);
338 int getBdecodeTokenLimit() const;
339 void setBdecodeTokenLimit(int value
);
341 // Stuff that don't appear in the Options GUI but are saved
343 QDateTime
getDNSLastUpd() const;
344 void setDNSLastUpd(const QDateTime
&date
);
345 QString
getDNSLastIP() const;
346 void setDNSLastIP(const QString
&ip
);
347 QByteArray
getMainGeometry() const;
348 void setMainGeometry(const QByteArray
&geometry
);
349 bool isFiltersSidebarVisible() const;
350 void setFiltersSidebarVisible(bool value
);
351 int getFiltersSidebarWidth() const;
352 void setFiltersSidebarWidth(int value
);
353 Path
getMainLastDir() const;
354 void setMainLastDir(const Path
&path
);
355 QByteArray
getPeerListState() const;
356 void setPeerListState(const QByteArray
&state
);
357 QString
getPropSplitterSizes() const;
358 void setPropSplitterSizes(const QString
&sizes
);
359 QByteArray
getPropFileListState() const;
360 void setPropFileListState(const QByteArray
&state
);
361 int getPropCurTab() const;
362 void setPropCurTab(int tab
);
363 bool getPropVisible() const;
364 void setPropVisible(bool visible
);
365 QByteArray
getTrackerListState() const;
366 void setTrackerListState(const QByteArray
&state
);
367 QStringList
getRssOpenFolders() const;
368 void setRssOpenFolders(const QStringList
&folders
);
369 QByteArray
getRssSideSplitterState() const;
370 void setRssSideSplitterState(const QByteArray
&state
);
371 QByteArray
getRssMainSplitterState() const;
372 void setRssMainSplitterState(const QByteArray
&state
);
373 QByteArray
getSearchTabHeaderState() const;
374 void setSearchTabHeaderState(const QByteArray
&state
);
375 bool getRegexAsFilteringPatternForSearchJob() const;
376 void setRegexAsFilteringPatternForSearchJob(bool checked
);
377 QStringList
getSearchEngDisabled() const;
378 void setSearchEngDisabled(const QStringList
&engines
);
379 QString
getTorImportLastContentDir() const;
380 void setTorImportLastContentDir(const QString
&path
);
381 QByteArray
getTorImportGeometry() const;
382 void setTorImportGeometry(const QByteArray
&geometry
);
383 bool getStatusFilterState() const;
384 bool getCategoryFilterState() const;
385 bool getTagFilterState() const;
386 bool getTrackerFilterState() const;
387 int getTransSelFilter() const;
388 void setTransSelFilter(int index
);
389 bool getHideZeroStatusFilters() const;
390 void setHideZeroStatusFilters(bool hide
);
391 QByteArray
getTransHeaderState() const;
392 void setTransHeaderState(const QByteArray
&state
);
393 bool getRegexAsFilteringPatternForTransferList() const;
394 void setRegexAsFilteringPatternForTransferList(bool checked
);
395 int getToolbarTextPosition() const;
396 void setToolbarTextPosition(int position
);
398 // From old RssSettings class
399 bool isRSSWidgetEnabled() const;
400 void setRSSWidgetVisible(bool enabled
);
403 QList
<QNetworkCookie
> getNetworkCookies() const;
404 void setNetworkCookies(const QList
<QNetworkCookie
> &cookies
);
406 bool useProxyForBT() const;
407 void setUseProxyForBT(bool value
);
408 bool useProxyForRSS() const;
409 void setUseProxyForRSS(bool value
);
410 bool useProxyForGeneralPurposes() const;
411 void setUseProxyForGeneralPurposes(bool value
);
414 bool isSpeedWidgetEnabled() const;
415 void setSpeedWidgetEnabled(bool enabled
);
416 int getSpeedWidgetPeriod() const;
417 void setSpeedWidgetPeriod(int period
);
418 bool getSpeedWidgetGraphEnable(int id
) const;
419 void setSpeedWidgetGraphEnable(int id
, bool enable
);
421 // AddNewTorrentDialog
422 bool isAddNewTorrentDialogEnabled() const;
423 void setAddNewTorrentDialogEnabled(bool value
);
424 bool isAddNewTorrentDialogTopLevel() const;
425 void setAddNewTorrentDialogTopLevel(bool value
);
426 int addNewTorrentDialogSavePathHistoryLength() const;
427 void setAddNewTorrentDialogSavePathHistoryLength(int value
);
430 void setStatusFilterState(bool checked
);
431 void setCategoryFilterState(bool checked
);
432 void setTagFilterState(bool checked
);
433 void setTrackerFilterState(bool checked
);
441 static Preferences
*m_instance
;