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