2006-09-30 20:02:39 +04:00
/*
* Bittorrent Client using Qt4 and libtorrent .
2007-07-14 18:31:59 +04:00
* Copyright ( C ) 2006 Christophe Dumez
2006-09-30 20:02:39 +04:00
*
2007-07-14 18:31:59 +04:00
* This program is free software ; you can redistribute it and / or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation ; either version 2
* of the License , or ( at your option ) any later version .
2006-09-30 20:02:39 +04:00
*
* This program is distributed in the hope that it will be useful ,
* but WITHOUT ANY WARRANTY ; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE . See the
* GNU General Public License for more details .
*
* You should have received a copy of the GNU General Public License
2007-07-14 18:31:59 +04:00
* along with this program ; if not , write to the Free Software
* Foundation , Inc . , 51 Franklin Street , Fifth Floor , Boston , MA 02110 - 1301 , USA .
*
2009-04-05 21:00:55 +04:00
* In addition , as a special exception , the copyright holders give permission to
* link this program with the OpenSSL project ' s " OpenSSL " library ( or with
* modified versions of it that use the same license as the " OpenSSL " library ) ,
* and distribute the linked executables . You must obey the GNU General Public
* License in all respects for all of the code used other than " OpenSSL " . If you
* modify file ( s ) , you may extend this exception to your version of the file ( s ) ,
* but you are not obligated to do so . If you do not wish to do so , delete this
* exception statement from your version .
*
2007-07-14 18:31:59 +04:00
* Contact : chris @ qbittorrent . org
2006-09-30 20:02:39 +04:00
*/
# include <QTextStream>
# include <QFileDialog>
# include <QMessageBox>
2006-10-19 00:48:41 +04:00
# include <QSystemTrayIcon>
2007-03-29 22:43:04 +04:00
# include <QApplication>
2007-04-11 22:19:20 +04:00
# include <QDialogButtonBox>
2007-07-23 16:56:57 +04:00
# include <QCloseEvent>
2009-03-15 20:48:20 +03:00
# include <QDesktopWidget>
2010-09-25 16:42:19 +04:00
# include <QTranslator>
2011-04-15 17:02:39 +04:00
# include <QDesktopServices>
2006-09-30 20:02:39 +04:00
2010-06-07 12:32:41 +04:00
# include <libtorrent/version.hpp>
2009-08-25 13:19:02 +04:00
2006-09-30 20:02:39 +04:00
# include "options_imp.h"
2009-11-14 22:08:28 +03:00
# include "preferences.h"
2012-05-16 22:19:05 +04:00
# include "fs_utils.h"
2010-01-31 18:11:15 +03:00
# include "advancedsettings.h"
2010-02-28 18:15:00 +03:00
# include "scannedfoldersmodel.h"
2010-07-16 19:03:18 +04:00
# include "qinisettings.h"
2010-12-25 17:47:52 +03:00
# include "qbtsession.h"
2011-01-01 16:05:28 +03:00
# include "iconprovider.h"
2011-04-15 17:02:39 +04:00
# include "dnsupdater.h"
2006-09-30 20:02:39 +04:00
2011-06-05 20:08:30 +04:00
# ifndef QT_NO_OPENSSL
# include <QSslKey>
# include <QSslCertificate>
# endif
2010-11-23 00:55:32 +03:00
using namespace libtorrent ;
2006-09-30 20:02:39 +04:00
// Constructor
2010-12-25 17:47:52 +03:00
options_imp : : options_imp ( QWidget * parent ) :
QDialog ( parent ) , m_refreshingIpFilter ( false ) {
2007-03-10 21:14:53 +03:00
qDebug ( " -> Constructing Options " ) ;
2010-12-12 22:37:59 +03:00
setupUi ( this ) ;
2009-11-14 22:08:28 +03:00
setAttribute ( Qt : : WA_DeleteOnClose ) ;
2010-03-10 23:21:56 +03:00
setModal ( true ) ;
2010-12-12 22:37:59 +03:00
// Icons
2011-01-01 16:05:28 +03:00
tabSelection - > item ( TAB_UI ) - > setIcon ( IconProvider : : instance ( ) - > getIcon ( " preferences-desktop " ) ) ;
tabSelection - > item ( TAB_BITTORRENT ) - > setIcon ( IconProvider : : instance ( ) - > getIcon ( " preferences-system-network " ) ) ;
tabSelection - > item ( TAB_CONNECTION ) - > setIcon ( IconProvider : : instance ( ) - > getIcon ( " network-wired " ) ) ;
tabSelection - > item ( TAB_DOWNLOADS ) - > setIcon ( IconProvider : : instance ( ) - > getIcon ( " download " ) ) ;
tabSelection - > item ( TAB_SPEED ) - > setIcon ( IconProvider : : instance ( ) - > getIcon ( " chronometer " ) ) ;
tabSelection - > item ( TAB_WEBUI ) - > setIcon ( IconProvider : : instance ( ) - > getIcon ( " network-server " ) ) ;
tabSelection - > item ( TAB_ADVANCED ) - > setIcon ( IconProvider : : instance ( ) - > getIcon ( " preferences-other " ) ) ;
IpFilterRefreshBtn - > setIcon ( IconProvider : : instance ( ) - > getIcon ( " view-refresh " ) ) ;
2010-03-10 23:21:56 +03:00
2010-03-13 17:10:26 +03:00
hsplitter - > setCollapsible ( 0 , false ) ;
hsplitter - > setCollapsible ( 1 , false ) ;
2007-04-11 22:19:20 +04:00
// Get apply button in button box
QList < QAbstractButton * > buttons = buttonBox - > buttons ( ) ;
2012-02-20 21:56:07 +04:00
foreach ( QAbstractButton * button , buttons ) {
if ( buttonBox - > buttonRole ( button ) = = QDialogButtonBox : : ApplyRole ) {
2007-04-11 22:19:20 +04:00
applyButton = button ;
break ;
}
}
2010-02-28 18:15:00 +03:00
scanFoldersView - > horizontalHeader ( ) - > setResizeMode ( QHeaderView : : ResizeToContents ) ;
scanFoldersView - > setModel ( ScanFoldersModel : : instance ( ) ) ;
connect ( ScanFoldersModel : : instance ( ) , SIGNAL ( dataChanged ( QModelIndex , QModelIndex ) ) , this , SLOT ( enableApplyButton ( ) ) ) ;
connect ( scanFoldersView - > selectionModel ( ) , SIGNAL ( selectionChanged ( QItemSelection , QItemSelection ) ) , this , SLOT ( handleScanFolderViewSelectionChanged ( ) ) ) ;
2007-04-11 22:19:20 +04:00
connect ( buttonBox , SIGNAL ( clicked ( QAbstractButton * ) ) , this , SLOT ( applySettings ( QAbstractButton * ) ) ) ;
2006-09-30 20:02:39 +04:00
// Languages supported
2010-11-20 18:59:17 +03:00
initializeLanguageCombo ( ) ;
2006-09-30 20:02:39 +04:00
2010-01-23 23:44:09 +03:00
// Load week days (scheduler)
2012-02-20 21:30:53 +04:00
for ( uint i = 1 ; i < = 7 ; + + i ) {
2010-01-23 23:44:09 +03:00
schedule_days - > addItem ( QDate : : longDayName ( i , QDate : : StandaloneFormat ) ) ;
}
2006-11-14 23:26:32 +03:00
// Load options
loadOptions ( ) ;
2007-03-29 23:54:45 +04:00
// Disable systray integration if it is not supported by the system
2012-02-22 22:06:11 +04:00
# ifndef Q_WS_MAC
2012-02-20 21:56:07 +04:00
if ( ! QSystemTrayIcon : : isSystemTrayAvailable ( ) ) {
2012-02-22 22:06:11 +04:00
# endif
2010-10-09 19:36:39 +04:00
checkShowSystray - > setChecked ( false ) ;
checkShowSystray - > setEnabled ( false ) ;
2012-02-22 22:06:11 +04:00
# ifndef Q_WS_MAC
2010-10-09 19:36:39 +04:00
}
2012-02-22 22:06:11 +04:00
# endif
2011-03-26 12:03:12 +03:00
# if !defined(Q_WS_X11)
2011-03-27 12:34:51 +04:00
label_trayIconStyle - > setVisible ( false ) ;
comboTrayIcon - > setVisible ( false ) ;
2011-06-05 20:08:30 +04:00
# endif
# if defined(QT_NO_OPENSSL)
checkWebUiHttps - > setVisible ( false ) ;
2011-03-12 23:59:44 +03:00
# endif
2011-09-18 17:42:50 +04:00
# ifndef Q_WS_WIN
2012-10-08 00:05:33 +04:00
checkStartup - > setVisible ( false ) ;
2011-09-18 17:42:50 +04:00
groupFileAssociation - > setVisible ( false ) ;
# endif
2010-10-09 19:36:39 +04:00
// Connect signals / slots
2010-11-18 23:05:56 +03:00
connect ( comboProxyType , SIGNAL ( currentIndexChanged ( int ) ) , this , SLOT ( enableProxy ( int ) ) ) ;
2011-09-20 21:15:47 +04:00
connect ( checkAnonymousMode , SIGNAL ( toggled ( bool ) ) , this , SLOT ( toggleAnonymousMode ( bool ) ) ) ;
2012-09-16 02:28:58 +04:00
connect ( checkRandomPort , SIGNAL ( toggled ( bool ) ) , spinPort , SLOT ( setDisabled ( bool ) ) ) ;
2010-10-09 19:36:39 +04:00
// Apply button is activated when a value is changed
// General tab
connect ( comboI18n , SIGNAL ( currentIndexChanged ( int ) ) , this , SLOT ( enableApplyButton ( ) ) ) ;
connect ( checkAltRowColors , SIGNAL ( toggled ( bool ) ) , this , SLOT ( enableApplyButton ( ) ) ) ;
connect ( checkShowSystray , SIGNAL ( toggled ( bool ) ) , this , SLOT ( enableApplyButton ( ) ) ) ;
connect ( checkCloseToSystray , SIGNAL ( toggled ( bool ) ) , this , SLOT ( enableApplyButton ( ) ) ) ;
connect ( checkMinimizeToSysTray , SIGNAL ( toggled ( bool ) ) , this , SLOT ( enableApplyButton ( ) ) ) ;
connect ( checkStartMinimized , SIGNAL ( toggled ( bool ) ) , this , SLOT ( enableApplyButton ( ) ) ) ;
2012-10-08 00:05:33 +04:00
# ifdef Q_WS_WIN
connect ( checkStartup , SIGNAL ( toggled ( bool ) ) , this , SLOT ( enableApplyButton ( ) ) ) ;
# endif
2010-10-09 19:36:39 +04:00
connect ( checkShowSplash , SIGNAL ( toggled ( bool ) ) , this , SLOT ( enableApplyButton ( ) ) ) ;
2011-02-27 12:43:58 +03:00
connect ( checkProgramExitConfirm , SIGNAL ( toggled ( bool ) ) , this , SLOT ( enableApplyButton ( ) ) ) ;
2011-02-06 17:27:34 +03:00
connect ( checkPreventFromSuspend , SIGNAL ( toggled ( bool ) ) , this , SLOT ( enableApplyButton ( ) ) ) ;
2011-03-27 12:34:51 +04:00
connect ( comboTrayIcon , SIGNAL ( currentIndexChanged ( int ) ) , this , SLOT ( enableApplyButton ( ) ) ) ;
2011-03-07 23:22:35 +03:00
# if defined(Q_WS_X11) && !defined(QT_DBUS_LIB)
checkPreventFromSuspend - > setDisabled ( true ) ;
2011-09-18 20:45:46 +04:00
# endif
# ifdef Q_WS_WIN
connect ( checkAssociateTorrents , SIGNAL ( toggled ( bool ) ) , this , SLOT ( enableApplyButton ( ) ) ) ;
connect ( checkAssociateMagnetLinks , SIGNAL ( toggled ( bool ) ) , this , SLOT ( enableApplyButton ( ) ) ) ;
2011-03-07 23:22:35 +03:00
# endif
2010-10-09 19:36:39 +04:00
// Downloads tab
connect ( textSavePath , SIGNAL ( textChanged ( QString ) ) , this , SLOT ( enableApplyButton ( ) ) ) ;
connect ( textTempPath , SIGNAL ( textChanged ( QString ) ) , this , SLOT ( enableApplyButton ( ) ) ) ;
connect ( checkAppendLabel , SIGNAL ( toggled ( bool ) ) , this , SLOT ( enableApplyButton ( ) ) ) ;
connect ( checkAppendqB , SIGNAL ( toggled ( bool ) ) , this , SLOT ( enableApplyButton ( ) ) ) ;
connect ( checkPreallocateAll , SIGNAL ( toggled ( bool ) ) , this , SLOT ( enableApplyButton ( ) ) ) ;
connect ( checkAdditionDialog , SIGNAL ( toggled ( bool ) ) , this , SLOT ( enableApplyButton ( ) ) ) ;
2013-10-06 19:42:56 +04:00
connect ( checkAdditionDialogFront , SIGNAL ( toggled ( bool ) ) , this , SLOT ( enableApplyButton ( ) ) ) ;
2010-10-09 19:36:39 +04:00
connect ( checkStartPaused , SIGNAL ( toggled ( bool ) ) , this , SLOT ( enableApplyButton ( ) ) ) ;
connect ( checkExportDir , SIGNAL ( toggled ( bool ) ) , this , SLOT ( enableApplyButton ( ) ) ) ;
2012-08-21 11:16:49 +04:00
connect ( checkExportDirFin , SIGNAL ( toggled ( bool ) ) , this , SLOT ( enableApplyButton ( ) ) ) ;
2010-10-09 19:36:39 +04:00
connect ( textExportDir , SIGNAL ( textChanged ( QString ) ) , this , SLOT ( enableApplyButton ( ) ) ) ;
2012-08-21 11:16:49 +04:00
connect ( textExportDirFin , SIGNAL ( textChanged ( QString ) ) , this , SLOT ( enableApplyButton ( ) ) ) ;
2010-10-09 19:36:39 +04:00
connect ( actionTorrentDlOnDblClBox , SIGNAL ( currentIndexChanged ( int ) ) , this , SLOT ( enableApplyButton ( ) ) ) ;
connect ( actionTorrentFnOnDblClBox , SIGNAL ( currentIndexChanged ( int ) ) , this , SLOT ( enableApplyButton ( ) ) ) ;
connect ( checkTempFolder , SIGNAL ( toggled ( bool ) ) , this , SLOT ( enableApplyButton ( ) ) ) ;
connect ( addScanFolderButton , SIGNAL ( clicked ( ) ) , this , SLOT ( enableApplyButton ( ) ) ) ;
connect ( removeScanFolderButton , SIGNAL ( clicked ( ) ) , this , SLOT ( enableApplyButton ( ) ) ) ;
connect ( groupMailNotification , SIGNAL ( toggled ( bool ) ) , this , SLOT ( enableApplyButton ( ) ) ) ;
connect ( dest_email_txt , SIGNAL ( textChanged ( QString ) ) , this , SLOT ( enableApplyButton ( ) ) ) ;
connect ( smtp_server_txt , SIGNAL ( textChanged ( QString ) ) , this , SLOT ( enableApplyButton ( ) ) ) ;
2011-04-09 21:39:51 +04:00
connect ( checkSmtpSSL , SIGNAL ( toggled ( bool ) ) , this , SLOT ( enableApplyButton ( ) ) ) ;
connect ( groupMailNotifAuth , SIGNAL ( toggled ( bool ) ) , this , SLOT ( enableApplyButton ( ) ) ) ;
connect ( mailNotifUsername , SIGNAL ( textChanged ( QString ) ) , this , SLOT ( enableApplyButton ( ) ) ) ;
connect ( mailNotifPassword , SIGNAL ( textChanged ( QString ) ) , this , SLOT ( enableApplyButton ( ) ) ) ;
2010-10-09 19:36:39 +04:00
connect ( autoRunBox , SIGNAL ( toggled ( bool ) ) , this , SLOT ( enableApplyButton ( ) ) ) ;
connect ( autoRun_txt , SIGNAL ( textChanged ( QString ) ) , this , SLOT ( enableApplyButton ( ) ) ) ;
// Connection tab
connect ( spinPort , SIGNAL ( valueChanged ( QString ) ) , this , SLOT ( enableApplyButton ( ) ) ) ;
2012-09-16 02:28:58 +04:00
connect ( checkRandomPort , SIGNAL ( toggled ( bool ) ) , this , SLOT ( enableApplyButton ( ) ) ) ;
2010-10-09 19:36:39 +04:00
connect ( checkUPnP , SIGNAL ( toggled ( bool ) ) , this , SLOT ( enableApplyButton ( ) ) ) ;
connect ( checkUploadLimit , SIGNAL ( toggled ( bool ) ) , this , SLOT ( enableApplyButton ( ) ) ) ;
connect ( checkDownloadLimit , SIGNAL ( toggled ( bool ) ) , this , SLOT ( enableApplyButton ( ) ) ) ;
connect ( spinUploadLimit , SIGNAL ( valueChanged ( QString ) ) , this , SLOT ( enableApplyButton ( ) ) ) ;
connect ( spinDownloadLimit , SIGNAL ( valueChanged ( QString ) ) , this , SLOT ( enableApplyButton ( ) ) ) ;
connect ( spinUploadLimitAlt , SIGNAL ( valueChanged ( QString ) ) , this , SLOT ( enableApplyButton ( ) ) ) ;
connect ( spinDownloadLimitAlt , SIGNAL ( valueChanged ( QString ) ) , this , SLOT ( enableApplyButton ( ) ) ) ;
connect ( check_schedule , SIGNAL ( toggled ( bool ) ) , this , SLOT ( enableApplyButton ( ) ) ) ;
connect ( schedule_from , SIGNAL ( timeChanged ( QTime ) ) , this , SLOT ( enableApplyButton ( ) ) ) ;
connect ( schedule_to , SIGNAL ( timeChanged ( QTime ) ) , this , SLOT ( enableApplyButton ( ) ) ) ;
connect ( schedule_days , SIGNAL ( currentIndexChanged ( int ) ) , this , SLOT ( enableApplyButton ( ) ) ) ;
2011-04-17 22:11:03 +04:00
connect ( checkuTP , SIGNAL ( toggled ( bool ) ) , SLOT ( enableApplyButton ( ) ) ) ;
2011-04-17 18:42:38 +04:00
connect ( checkLimituTPConnections , SIGNAL ( toggled ( bool ) ) , SLOT ( enableApplyButton ( ) ) ) ;
connect ( checkLimitTransportOverhead , SIGNAL ( toggled ( bool ) ) , SLOT ( enableApplyButton ( ) ) ) ;
2010-10-09 19:36:39 +04:00
// Bittorrent tab
connect ( checkMaxConnecs , SIGNAL ( toggled ( bool ) ) , this , SLOT ( enableApplyButton ( ) ) ) ;
connect ( checkMaxConnecsPerTorrent , SIGNAL ( toggled ( bool ) ) , this , SLOT ( enableApplyButton ( ) ) ) ;
2013-07-22 02:20:48 +04:00
connect ( checkMaxUploads , SIGNAL ( toggled ( bool ) ) , this , SLOT ( enableApplyButton ( ) ) ) ;
2010-10-09 19:36:39 +04:00
connect ( checkMaxUploadsPerTorrent , SIGNAL ( toggled ( bool ) ) , this , SLOT ( enableApplyButton ( ) ) ) ;
connect ( spinMaxConnec , SIGNAL ( valueChanged ( QString ) ) , this , SLOT ( enableApplyButton ( ) ) ) ;
connect ( spinMaxConnecPerTorrent , SIGNAL ( valueChanged ( QString ) ) , this , SLOT ( enableApplyButton ( ) ) ) ;
2013-07-22 02:20:48 +04:00
connect ( spinMaxUploads , SIGNAL ( valueChanged ( QString ) ) , this , SLOT ( enableApplyButton ( ) ) ) ;
2010-10-09 19:36:39 +04:00
connect ( spinMaxUploadsPerTorrent , SIGNAL ( valueChanged ( QString ) ) , this , SLOT ( enableApplyButton ( ) ) ) ;
connect ( checkDHT , SIGNAL ( toggled ( bool ) ) , this , SLOT ( enableApplyButton ( ) ) ) ;
2011-09-20 21:15:47 +04:00
connect ( checkAnonymousMode , SIGNAL ( toggled ( bool ) ) , this , SLOT ( enableApplyButton ( ) ) ) ;
2010-10-09 19:36:39 +04:00
connect ( checkPeX , SIGNAL ( toggled ( bool ) ) , this , SLOT ( enableApplyButton ( ) ) ) ;
connect ( checkDifferentDHTPort , SIGNAL ( toggled ( bool ) ) , this , SLOT ( enableApplyButton ( ) ) ) ;
connect ( spinDHTPort , SIGNAL ( valueChanged ( QString ) ) , this , SLOT ( enableApplyButton ( ) ) ) ;
connect ( checkLSD , SIGNAL ( toggled ( bool ) ) , this , SLOT ( enableApplyButton ( ) ) ) ;
connect ( comboEncryption , SIGNAL ( currentIndexChanged ( int ) ) , this , SLOT ( enableApplyButton ( ) ) ) ;
connect ( checkMaxRatio , SIGNAL ( toggled ( bool ) ) , this , SLOT ( enableApplyButton ( ) ) ) ;
connect ( spinMaxRatio , SIGNAL ( valueChanged ( QString ) ) , this , SLOT ( enableApplyButton ( ) ) ) ;
connect ( comboRatioLimitAct , SIGNAL ( currentIndexChanged ( int ) ) , this , SLOT ( enableApplyButton ( ) ) ) ;
// Proxy tab
connect ( comboProxyType , SIGNAL ( currentIndexChanged ( int ) ) , this , SLOT ( enableApplyButton ( ) ) ) ;
connect ( textProxyIP , SIGNAL ( textChanged ( QString ) ) , this , SLOT ( enableApplyButton ( ) ) ) ;
connect ( spinProxyPort , SIGNAL ( valueChanged ( QString ) ) , this , SLOT ( enableApplyButton ( ) ) ) ;
2011-05-01 15:22:17 +04:00
connect ( checkProxyPeerConnecs , SIGNAL ( toggled ( bool ) ) , SLOT ( enableApplyButton ( ) ) ) ;
2010-10-09 19:36:39 +04:00
connect ( checkProxyAuth , SIGNAL ( toggled ( bool ) ) , this , SLOT ( enableApplyButton ( ) ) ) ;
connect ( textProxyUsername , SIGNAL ( textChanged ( QString ) ) , this , SLOT ( enableApplyButton ( ) ) ) ;
connect ( textProxyPassword , SIGNAL ( textChanged ( QString ) ) , this , SLOT ( enableApplyButton ( ) ) ) ;
// Misc tab
connect ( checkIPFilter , SIGNAL ( toggled ( bool ) ) , this , SLOT ( enableApplyButton ( ) ) ) ;
connect ( textFilterPath , SIGNAL ( textChanged ( QString ) ) , this , SLOT ( enableApplyButton ( ) ) ) ;
connect ( checkEnableQueueing , SIGNAL ( toggled ( bool ) ) , this , SLOT ( enableApplyButton ( ) ) ) ;
connect ( spinMaxActiveDownloads , SIGNAL ( valueChanged ( QString ) ) , this , SLOT ( enableApplyButton ( ) ) ) ;
connect ( spinMaxActiveUploads , SIGNAL ( valueChanged ( QString ) ) , this , SLOT ( enableApplyButton ( ) ) ) ;
connect ( spinMaxActiveTorrents , SIGNAL ( valueChanged ( QString ) ) , this , SLOT ( enableApplyButton ( ) ) ) ;
2011-09-18 20:34:29 +04:00
connect ( checkIgnoreSlowTorrentsForQueueing , SIGNAL ( toggled ( bool ) ) , this , SLOT ( enableApplyButton ( ) ) ) ;
2010-10-09 19:36:39 +04:00
// Web UI tab
connect ( checkWebUi , SIGNAL ( toggled ( bool ) ) , this , SLOT ( enableApplyButton ( ) ) ) ;
connect ( spinWebUiPort , SIGNAL ( valueChanged ( int ) ) , this , SLOT ( enableApplyButton ( ) ) ) ;
2011-04-12 23:50:05 +04:00
connect ( checkWebUIUPnP , SIGNAL ( toggled ( bool ) ) , SLOT ( enableApplyButton ( ) ) ) ;
2011-06-05 20:08:30 +04:00
connect ( checkWebUiHttps , SIGNAL ( toggled ( bool ) ) , SLOT ( enableApplyButton ( ) ) ) ;
connect ( btnWebUiKey , SIGNAL ( clicked ( ) ) , SLOT ( enableApplyButton ( ) ) ) ;
connect ( btnWebUiCrt , SIGNAL ( clicked ( ) ) , SLOT ( enableApplyButton ( ) ) ) ;
2010-10-09 19:36:39 +04:00
connect ( textWebUiUsername , SIGNAL ( textChanged ( QString ) ) , this , SLOT ( enableApplyButton ( ) ) ) ;
connect ( textWebUiPassword , SIGNAL ( textChanged ( QString ) ) , this , SLOT ( enableApplyButton ( ) ) ) ;
2011-02-27 12:34:42 +03:00
connect ( checkBypassLocalAuth , SIGNAL ( toggled ( bool ) ) , this , SLOT ( enableApplyButton ( ) ) ) ;
2011-04-15 17:02:39 +04:00
connect ( checkDynDNS , SIGNAL ( toggled ( bool ) ) , SLOT ( enableApplyButton ( ) ) ) ;
connect ( comboDNSService , SIGNAL ( currentIndexChanged ( int ) ) , SLOT ( enableApplyButton ( ) ) ) ;
connect ( domainNameTxt , SIGNAL ( textChanged ( QString ) ) , SLOT ( enableApplyButton ( ) ) ) ;
connect ( DNSUsernameTxt , SIGNAL ( textChanged ( QString ) ) , SLOT ( enableApplyButton ( ) ) ) ;
connect ( DNSPasswordTxt , SIGNAL ( textChanged ( QString ) ) , SLOT ( enableApplyButton ( ) ) ) ;
2010-10-09 19:36:39 +04:00
// Disable apply Button
applyButton - > setEnabled ( false ) ;
// Tab selection mecanism
connect ( tabSelection , SIGNAL ( currentItemChanged ( QListWidgetItem * , QListWidgetItem * ) ) , this , SLOT ( changePage ( QListWidgetItem * , QListWidgetItem * ) ) ) ;
// Load Advanced settings
QVBoxLayout * adv_layout = new QVBoxLayout ( ) ;
advancedSettings = new AdvancedSettings ( ) ;
adv_layout - > addWidget ( advancedSettings ) ;
scrollArea_advanced - > setLayout ( adv_layout ) ;
connect ( advancedSettings , SIGNAL ( settingsChanged ( ) ) , this , SLOT ( enableApplyButton ( ) ) ) ;
// Adapt size
show ( ) ;
loadWindowState ( ) ;
}
2010-11-20 18:59:17 +03:00
void options_imp : : initializeLanguageCombo ( )
{
// List language files
const QDir lang_dir ( " :/lang " ) ;
const QStringList lang_files = lang_dir . entryList ( QStringList ( ) < < " qbittorrent_*.qm " , QDir : : Files ) ;
2012-02-20 21:30:53 +04:00
foreach ( QString lang_file , lang_files ) {
2010-11-20 18:59:17 +03:00
QString localeStr = lang_file . mid ( 12 ) ; // remove "qbittorrent_"
localeStr . chop ( 3 ) ; // Remove ".qm"
2013-10-20 20:31:01 +04:00
QLocale locale ( localeStr ) ;
QString language_name = languageToLocalizedString ( locale ) ;
2011-03-07 23:22:35 +03:00
comboI18n - > addItem ( /*QIcon(":/Icons/flags/"+country+".png"), */ language_name , locale . name ( ) ) ;
2010-11-20 18:59:17 +03:00
qDebug ( ) < < " Supported locale: " < < locale . name ( ) ;
}
}
2010-10-09 19:36:39 +04:00
// Main destructor
2012-02-20 21:56:07 +04:00
options_imp : : ~ options_imp ( ) {
2010-10-09 19:36:39 +04:00
qDebug ( " -> destructing Options " ) ;
foreach ( const QString & path , addedScanDirs )
ScanFoldersModel : : instance ( ) - > removePath ( path ) ;
delete scrollArea_advanced - > layout ( ) ;
delete advancedSettings ;
}
void options_imp : : changePage ( QListWidgetItem * current , QListWidgetItem * previous ) {
if ( ! current )
current = previous ;
tabOption - > setCurrentIndex ( tabSelection - > row ( current ) ) ;
}
void options_imp : : loadWindowState ( ) {
2013-02-16 22:04:48 +04:00
QIniSettings settings ;
2010-10-09 19:36:39 +04:00
resize ( settings . value ( QString : : fromUtf8 ( " Preferences/State/size " ) , sizeFittingScreen ( ) ) . toSize ( ) ) ;
QPoint p = settings . value ( QString : : fromUtf8 ( " Preferences/State/pos " ) , QPoint ( ) ) . toPoint ( ) ;
2012-02-20 21:30:53 +04:00
if ( ! p . isNull ( ) )
2010-10-09 19:36:39 +04:00
move ( p ) ;
// Load slider size
const QStringList sizes_str = settings . value ( " Preferences/State/hSplitterSizes " , QStringList ( ) ) . toStringList ( ) ;
// Splitter size
QList < int > sizes ;
2012-02-20 21:30:53 +04:00
if ( sizes_str . size ( ) = = 2 ) {
2010-10-09 19:36:39 +04:00
sizes < < sizes_str . first ( ) . toInt ( ) ;
sizes < < sizes_str . last ( ) . toInt ( ) ;
} else {
sizes < < 130 ;
sizes < < hsplitter - > width ( ) - 130 ;
}
hsplitter - > setSizes ( sizes ) ;
}
void options_imp : : saveWindowState ( ) const {
2013-02-16 22:04:48 +04:00
QIniSettings settings ;
2010-10-09 19:36:39 +04:00
settings . setValue ( QString : : fromUtf8 ( " Preferences/State/size " ) , size ( ) ) ;
settings . setValue ( QString : : fromUtf8 ( " Preferences/State/pos " ) , pos ( ) ) ;
// Splitter size
QStringList sizes_str ;
sizes_str < < QString : : number ( hsplitter - > sizes ( ) . first ( ) ) ;
sizes_str < < QString : : number ( hsplitter - > sizes ( ) . last ( ) ) ;
settings . setValue ( QString : : fromUtf8 ( " Preferences/State/hSplitterSizes " ) , sizes_str ) ;
}
2011-04-11 21:21:16 +04:00
QSize options_imp : : sizeFittingScreen ( ) const {
2010-10-09 19:36:39 +04:00
int scrn = 0 ;
QWidget * w = this - > topLevelWidget ( ) ;
2012-02-20 21:30:53 +04:00
if ( w )
2010-10-09 19:36:39 +04:00
scrn = QApplication : : desktop ( ) - > screenNumber ( w ) ;
2012-02-20 21:30:53 +04:00
else if ( QApplication : : desktop ( ) - > isVirtualDesktop ( ) )
2010-10-09 19:36:39 +04:00
scrn = QApplication : : desktop ( ) - > screenNumber ( QCursor : : pos ( ) ) ;
else
scrn = QApplication : : desktop ( ) - > screenNumber ( this ) ;
QRect desk ( QApplication : : desktop ( ) - > availableGeometry ( scrn ) ) ;
2012-02-20 21:30:53 +04:00
if ( width ( ) > desk . width ( ) | | height ( ) > desk . height ( ) ) {
if ( desk . width ( ) > 0 & & desk . height ( ) > 0 )
2010-10-09 19:36:39 +04:00
return QSize ( desk . width ( ) , desk . height ( ) ) ;
}
return size ( ) ;
}
2012-02-20 21:56:07 +04:00
void options_imp : : saveOptions ( ) {
2010-10-09 19:36:39 +04:00
applyButton - > setEnabled ( false ) ;
2010-11-16 23:34:31 +03:00
Preferences pref ;
2010-10-09 19:36:39 +04:00
// Load the translation
QString locale = getLocale ( ) ;
2012-02-20 21:30:53 +04:00
if ( pref . getLocale ( ) ! = locale ) {
2010-10-09 19:36:39 +04:00
QTranslator * translator = new QTranslator ;
2012-02-20 21:56:07 +04:00
if ( translator - > load ( QString : : fromUtf8 ( " :/lang/qbittorrent_ " ) + locale ) ) {
2010-10-09 19:36:39 +04:00
qDebug ( " %s locale recognized, using translation. " , qPrintable ( locale ) ) ;
} else {
2013-10-20 20:31:01 +04:00
qDebug ( " %s locale unrecognized, using default (en). " , qPrintable ( locale ) ) ;
2010-09-25 16:42:19 +04:00
}
2010-10-09 19:36:39 +04:00
qApp - > installTranslator ( translator ) ;
}
// General preferences
2010-11-16 23:34:31 +03:00
pref . setLocale ( locale ) ;
pref . setAlternatingRowColors ( checkAltRowColors - > isChecked ( ) ) ;
pref . setSystrayIntegration ( systrayIntegration ( ) ) ;
2011-03-27 12:34:51 +04:00
pref . setTrayIconStyle ( TrayIcon : : Style ( comboTrayIcon - > currentIndex ( ) ) ) ;
2010-11-16 23:34:31 +03:00
pref . setCloseToTray ( closeToTray ( ) ) ;
pref . setMinimizeToTray ( minimizeToTray ( ) ) ;
pref . setStartMinimized ( startMinimized ( ) ) ;
pref . setSplashScreenDisabled ( isSlashScreenDisabled ( ) ) ;
2011-02-27 12:43:58 +03:00
pref . setConfirmOnExit ( checkProgramExitConfirm - > isChecked ( ) ) ;
2011-02-06 17:27:34 +03:00
pref . setPreventFromSuspend ( preventFromSuspend ( ) ) ;
2011-09-18 17:42:50 +04:00
# ifdef Q_WS_WIN
2012-10-08 00:05:33 +04:00
pref . setStartup ( Startup ( ) ) ;
2011-09-18 17:42:50 +04:00
// Windows: file association settings
Preferences : : setTorrentFileAssoc ( checkAssociateTorrents - > isChecked ( ) ) ;
Preferences : : setMagnetLinkAssoc ( checkAssociateMagnetLinks - > isChecked ( ) ) ;
# endif
2010-10-09 19:36:39 +04:00
// End General preferences
2010-11-16 23:34:31 +03:00
2010-10-09 19:36:39 +04:00
// Downloads preferences
QString save_path = getSavePath ( ) ;
2010-06-22 23:17:47 +04:00
# if defined(Q_WS_WIN) || defined(Q_OS_OS2)
2011-09-25 16:04:51 +04:00
save_path . replace ( " \\ " , " / " ) ;
2010-06-04 01:08:28 +04:00
# endif
2010-11-16 23:34:31 +03:00
pref . setSavePath ( save_path ) ;
pref . setTempPathEnabled ( isTempPathEnabled ( ) ) ;
2010-10-09 19:36:39 +04:00
QString temp_path = getTempPath ( ) ;
2010-06-22 23:17:47 +04:00
# if defined(Q_WS_WIN) || defined(Q_OS_OS2)
2011-09-25 16:04:51 +04:00
temp_path . replace ( " \\ " , " / " ) ;
2010-06-04 01:08:28 +04:00
# endif
2010-11-16 23:34:31 +03:00
pref . setTempPath ( temp_path ) ;
pref . setAppendTorrentLabel ( checkAppendLabel - > isChecked ( ) ) ;
pref . useIncompleteFilesExtension ( checkAppendqB - > isChecked ( ) ) ;
pref . preAllocateAllFiles ( preAllocateAllFiles ( ) ) ;
pref . useAdditionDialog ( useAdditionDialog ( ) ) ;
2013-10-06 19:42:56 +04:00
pref . AdditionDialogFront ( checkAdditionDialogFront - > isChecked ( ) ) ;
2010-11-16 23:34:31 +03:00
pref . addTorrentsInPause ( addTorrentsInPause ( ) ) ;
2010-12-27 22:26:21 +03:00
ScanFoldersModel : : instance ( ) - > makePersistent ( ) ;
2010-10-09 19:36:39 +04:00
addedScanDirs . clear ( ) ;
2012-08-21 11:16:49 +04:00
QString export_dir = getTorrentExportDir ( ) ;
QString export_dir_fin = getFinishedTorrentExportDir ( ) ;
2010-06-22 23:17:47 +04:00
# if defined(Q_WS_WIN) || defined(Q_OS_OS2)
2012-08-21 11:16:49 +04:00
export_dir_fin . replace ( " \\ " , " / " ) ;
2011-09-25 16:04:51 +04:00
export_dir . replace ( " \\ " , " / " ) ;
2010-06-04 01:08:28 +04:00
# endif
2012-08-21 11:16:49 +04:00
pref . setTorrentExportDir ( export_dir ) ;
pref . setFinishedTorrentExportDir ( export_dir_fin ) ;
2010-11-16 23:34:31 +03:00
pref . setMailNotificationEnabled ( groupMailNotification - > isChecked ( ) ) ;
pref . setMailNotificationEmail ( dest_email_txt - > text ( ) ) ;
pref . setMailNotificationSMTP ( smtp_server_txt - > text ( ) ) ;
2011-04-09 21:39:51 +04:00
pref . setMailNotificationSMTPSSL ( checkSmtpSSL - > isChecked ( ) ) ;
pref . setMailNotificationSMTPAuth ( groupMailNotifAuth - > isChecked ( ) ) ;
pref . setMailNotificationSMTPUsername ( mailNotifUsername - > text ( ) ) ;
pref . setMailNotificationSMTPPassword ( mailNotifPassword - > text ( ) ) ;
2010-11-16 23:34:31 +03:00
pref . setAutoRunEnabled ( autoRunBox - > isChecked ( ) ) ;
pref . setAutoRunProgram ( autoRun_txt - > text ( ) ) ;
pref . setActionOnDblClOnTorrentDl ( getActionOnDblClOnTorrentDl ( ) ) ;
pref . setActionOnDblClOnTorrentFn ( getActionOnDblClOnTorrentFn ( ) ) ;
2010-10-09 19:36:39 +04:00
// End Downloads preferences
// Connection preferences
2010-11-16 23:34:31 +03:00
pref . setSessionPort ( getPort ( ) ) ;
2012-09-16 02:28:58 +04:00
pref . setRandomPort ( checkRandomPort - > isChecked ( ) ) ;
2010-11-16 23:34:31 +03:00
pref . setUPnPEnabled ( isUPnPEnabled ( ) ) ;
2010-12-02 20:17:50 +03:00
const QPair < int , int > down_up_limit = getGlobalBandwidthLimits ( ) ;
pref . setGlobalDownloadLimit ( down_up_limit . first ) ;
pref . setGlobalUploadLimit ( down_up_limit . second ) ;
2011-04-17 22:11:03 +04:00
pref . setuTPEnabled ( checkuTP - > isChecked ( ) ) ;
2011-04-17 18:42:38 +04:00
pref . setuTPRateLimited ( checkLimituTPConnections - > isChecked ( ) ) ;
pref . includeOverheadInLimits ( checkLimitTransportOverhead - > isChecked ( ) ) ;
2010-11-16 23:34:31 +03:00
pref . setAltGlobalDownloadLimit ( spinDownloadLimitAlt - > value ( ) ) ;
pref . setAltGlobalUploadLimit ( spinUploadLimitAlt - > value ( ) ) ;
pref . setSchedulerEnabled ( check_schedule - > isChecked ( ) ) ;
pref . setSchedulerStartTime ( schedule_from - > time ( ) ) ;
pref . setSchedulerEndTime ( schedule_to - > time ( ) ) ;
pref . setSchedulerDays ( ( scheduler_days ) schedule_days - > currentIndex ( ) ) ;
2010-11-18 23:05:56 +03:00
pref . setProxyType ( getProxyType ( ) ) ;
pref . setProxyIp ( getProxyIp ( ) ) ;
pref . setProxyPort ( getProxyPort ( ) ) ;
2011-05-01 15:22:17 +04:00
pref . setProxyPeerConnections ( checkProxyPeerConnecs - > isChecked ( ) ) ;
2010-11-18 23:05:56 +03:00
pref . setProxyAuthEnabled ( isProxyAuthEnabled ( ) ) ;
pref . setProxyUsername ( getProxyUsername ( ) ) ;
pref . setProxyPassword ( getProxyPassword ( ) ) ;
2010-10-09 19:36:39 +04:00
// End Connection preferences
// Bittorrent preferences
2010-11-16 23:34:31 +03:00
pref . setMaxConnecs ( getMaxConnecs ( ) ) ;
pref . setMaxConnecsPerTorrent ( getMaxConnecsPerTorrent ( ) ) ;
2013-07-22 02:20:48 +04:00
pref . setMaxUploads ( getMaxUploads ( ) ) ;
2010-11-16 23:34:31 +03:00
pref . setMaxUploadsPerTorrent ( getMaxUploadsPerTorrent ( ) ) ;
pref . setDHTEnabled ( isDHTEnabled ( ) ) ;
pref . setPeXEnabled ( checkPeX - > isChecked ( ) ) ;
pref . setDHTPortSameAsBT ( isDHTPortSameAsBT ( ) ) ;
pref . setDHTPort ( getDHTPort ( ) ) ;
pref . setLSDEnabled ( isLSDEnabled ( ) ) ;
pref . setEncryptionSetting ( getEncryptionSetting ( ) ) ;
2011-09-20 21:15:47 +04:00
pref . enableAnonymousMode ( checkAnonymousMode - > isChecked ( ) ) ;
2011-03-07 22:26:44 +03:00
pref . setGlobalMaxRatio ( getMaxRatio ( ) ) ;
2010-11-16 23:34:31 +03:00
pref . setMaxRatioAction ( comboRatioLimitAct - > currentIndex ( ) ) ;
2010-10-09 19:36:39 +04:00
// End Bittorrent preferences
// Misc preferences
// * IPFilter
2010-11-16 23:34:31 +03:00
pref . setFilteringEnabled ( isFilteringEnabled ( ) ) ;
2012-02-20 21:56:07 +04:00
if ( isFilteringEnabled ( ) ) {
2010-10-09 19:36:39 +04:00
QString filter_path = textFilterPath - > text ( ) ;
2010-06-22 23:17:47 +04:00
# if defined(Q_WS_WIN) || defined(Q_OS_OS2)
2011-09-25 16:04:51 +04:00
filter_path . replace ( " \\ " , " / " ) ;
2010-06-04 01:08:28 +04:00
# endif
2010-11-16 23:34:31 +03:00
pref . setFilter ( filter_path ) ;
2010-10-09 19:36:39 +04:00
}
// End IPFilter preferences
// Queueing system
2010-11-16 23:34:31 +03:00
pref . setQueueingSystemEnabled ( isQueueingSystemEnabled ( ) ) ;
pref . setMaxActiveDownloads ( spinMaxActiveDownloads - > value ( ) ) ;
pref . setMaxActiveUploads ( spinMaxActiveUploads - > value ( ) ) ;
pref . setMaxActiveTorrents ( spinMaxActiveTorrents - > value ( ) ) ;
2011-09-18 20:34:29 +04:00
pref . setIgnoreSlowTorrentsForQueueing ( checkIgnoreSlowTorrentsForQueueing - > isChecked ( ) ) ;
2010-10-09 19:36:39 +04:00
// End Queueing system preferences
// Web UI
2010-11-16 23:34:31 +03:00
pref . setWebUiEnabled ( isWebUiEnabled ( ) ) ;
2012-02-20 21:30:53 +04:00
if ( isWebUiEnabled ( ) )
2010-10-09 19:36:39 +04:00
{
2010-11-16 23:34:31 +03:00
pref . setWebUiPort ( webUiPort ( ) ) ;
2011-04-12 23:50:05 +04:00
pref . setUPnPForWebUIPort ( checkWebUIUPnP - > isChecked ( ) ) ;
2011-06-05 20:08:30 +04:00
pref . setWebUiHttpsEnabled ( checkWebUiHttps - > isChecked ( ) ) ;
2012-02-20 21:30:53 +04:00
if ( checkWebUiHttps - > isChecked ( ) )
2011-06-05 20:08:30 +04:00
{
pref . setWebUiHttpsCertificate ( m_sslCert ) ;
pref . setWebUiHttpsKey ( m_sslKey ) ;
}
2010-11-16 23:34:31 +03:00
pref . setWebUiUsername ( webUiUsername ( ) ) ;
2010-10-09 19:36:39 +04:00
// FIXME: Check that the password is valid (not empty at least)
2010-11-16 23:34:31 +03:00
pref . setWebUiPassword ( webUiPassword ( ) ) ;
2011-02-27 12:34:42 +03:00
pref . setWebUiLocalAuthEnabled ( ! checkBypassLocalAuth - > isChecked ( ) ) ;
2011-04-15 17:02:39 +04:00
// DynDNS
pref . setDynDNSEnabled ( checkDynDNS - > isChecked ( ) ) ;
pref . setDynDNSService ( comboDNSService - > currentIndex ( ) ) ;
pref . setDynDomainName ( domainNameTxt - > text ( ) ) ;
pref . setDynDNSUsername ( DNSUsernameTxt - > text ( ) ) ;
pref . setDynDNSPassword ( DNSPasswordTxt - > text ( ) ) ;
2010-10-09 19:36:39 +04:00
}
// End Web UI
// End preferences
// Save advanced settings
advancedSettings - > saveAdvancedSettings ( ) ;
}
2012-02-20 23:32:58 +04:00
bool options_imp : : isFilteringEnabled ( ) const {
2010-10-09 19:36:39 +04:00
return checkIPFilter - > isChecked ( ) ;
}
2012-02-20 23:32:58 +04:00
int options_imp : : getProxyType ( ) const {
2010-10-09 19:36:39 +04:00
switch ( comboProxyType - > currentIndex ( ) ) {
case 1 :
2010-10-24 01:46:05 +04:00
return Proxy : : SOCKS4 ;
2010-10-09 19:36:39 +04:00
break ;
case 2 :
2012-02-20 21:56:07 +04:00
if ( isProxyAuthEnabled ( ) ) {
2010-10-24 01:46:05 +04:00
return Proxy : : SOCKS5_PW ;
2007-05-14 00:02:30 +04:00
}
2010-10-24 01:46:05 +04:00
return Proxy : : SOCKS5 ;
2010-10-09 19:36:39 +04:00
case 3 :
2012-02-20 21:56:07 +04:00
if ( isProxyAuthEnabled ( ) ) {
2010-10-24 01:46:05 +04:00
return Proxy : : HTTP_PW ;
2010-01-15 19:41:39 +03:00
}
2010-10-24 01:46:05 +04:00
return Proxy : : HTTP ;
2010-10-09 19:36:39 +04:00
default :
return - 1 ;
2007-05-14 00:02:30 +04:00
}
2010-10-09 19:36:39 +04:00
}
2007-05-14 00:02:30 +04:00
2012-02-20 21:56:07 +04:00
void options_imp : : loadOptions ( ) {
2010-10-09 19:36:39 +04:00
int intValue ;
2011-01-25 20:01:09 +03:00
qreal floatValue ;
2010-10-09 19:36:39 +04:00
QString strValue ;
// General preferences
2010-11-16 23:34:31 +03:00
const Preferences pref ;
setLocale ( pref . getLocale ( ) ) ;
checkAltRowColors - > setChecked ( pref . useAlternatingRowColors ( ) ) ;
checkShowSystray - > setChecked ( pref . systrayIntegration ( ) ) ;
checkShowSplash - > setChecked ( ! pref . isSlashScreenDisabled ( ) ) ;
2012-02-20 21:30:53 +04:00
if ( checkShowSystray - > isChecked ( ) ) {
2010-11-16 23:34:31 +03:00
checkCloseToSystray - > setChecked ( pref . closeToTray ( ) ) ;
checkMinimizeToSysTray - > setChecked ( pref . minimizeToTray ( ) ) ;
checkStartMinimized - > setChecked ( pref . startMinimized ( ) ) ;
2010-10-09 19:36:39 +04:00
}
2011-03-27 12:34:51 +04:00
comboTrayIcon - > setCurrentIndex ( pref . trayIconStyle ( ) ) ;
2011-02-27 12:43:58 +03:00
checkProgramExitConfirm - > setChecked ( pref . confirmOnExit ( ) ) ;
2011-02-06 17:27:34 +03:00
checkPreventFromSuspend - > setChecked ( pref . preventFromSuspend ( ) ) ;
2011-09-18 17:42:50 +04:00
# ifdef Q_WS_WIN
2012-10-08 00:05:33 +04:00
checkStartup - > setChecked ( pref . Startup ( ) ) ;
2011-09-18 17:42:50 +04:00
// Windows: file association settings
checkAssociateTorrents - > setChecked ( Preferences : : isTorrentFileAssocSet ( ) ) ;
checkAssociateMagnetLinks - > setChecked ( Preferences : : isMagnetLinkAssocSet ( ) ) ;
# endif
2010-10-09 19:36:39 +04:00
// End General preferences
// Downloads preferences
2010-11-16 23:34:31 +03:00
QString save_path = pref . getSavePath ( ) ;
2010-06-22 23:17:47 +04:00
# if defined(Q_WS_WIN) || defined(Q_OS_OS2)
2011-09-25 16:04:51 +04:00
save_path . replace ( " / " , " \\ " ) ;
2010-06-04 01:08:28 +04:00
# endif
2010-10-09 19:36:39 +04:00
textSavePath - > setText ( save_path ) ;
2012-02-20 21:30:53 +04:00
if ( pref . isTempPathEnabled ( ) ) {
2010-10-09 19:36:39 +04:00
// enable
checkTempFolder - > setChecked ( true ) ;
} else {
checkTempFolder - > setChecked ( false ) ;
}
2010-11-16 23:34:31 +03:00
QString temp_path = pref . getTempPath ( ) ;
2010-06-22 23:17:47 +04:00
# if defined(Q_WS_WIN) || defined(Q_OS_OS2)
2011-09-25 16:04:51 +04:00
temp_path . replace ( " / " , " \\ " ) ;
2010-06-04 01:08:28 +04:00
# endif
2010-10-09 19:36:39 +04:00
textTempPath - > setText ( temp_path ) ;
2010-11-16 23:34:31 +03:00
checkAppendLabel - > setChecked ( pref . appendTorrentLabel ( ) ) ;
checkAppendqB - > setChecked ( pref . useIncompleteFilesExtension ( ) ) ;
checkPreallocateAll - > setChecked ( pref . preAllocateAllFiles ( ) ) ;
checkAdditionDialog - > setChecked ( pref . useAdditionDialog ( ) ) ;
2013-10-06 19:42:56 +04:00
checkAdditionDialogFront - > setChecked ( pref . AdditionDialogFront ( ) ) ;
2010-11-16 23:34:31 +03:00
checkStartPaused - > setChecked ( pref . addTorrentsInPause ( ) ) ;
2010-10-09 19:36:39 +04:00
2012-08-21 11:16:49 +04:00
strValue = pref . getTorrentExportDir ( ) ;
2012-02-20 21:30:53 +04:00
if ( strValue . isEmpty ( ) ) {
2010-10-09 19:36:39 +04:00
// Disable
checkExportDir - > setChecked ( false ) ;
} else {
// enable
checkExportDir - > setChecked ( true ) ;
2010-06-22 23:17:47 +04:00
# if defined(Q_WS_WIN) || defined(Q_OS_OS2)
2011-09-25 16:04:51 +04:00
strValue . replace ( " / " , " \\ " ) ;
2010-06-04 01:08:28 +04:00
# endif
2010-10-09 19:36:39 +04:00
textExportDir - > setText ( strValue ) ;
}
2012-08-21 11:16:49 +04:00
strValue = pref . getFinishedTorrentExportDir ( ) ;
if ( strValue . isEmpty ( ) ) {
// Disable
checkExportDirFin - > setChecked ( false ) ;
} else {
// enable
checkExportDirFin - > setChecked ( true ) ;
# if defined(Q_WS_WIN) || defined(Q_OS_OS2)
strValue . replace ( " / " , " \\ " ) ;
# endif
textExportDirFin - > setText ( strValue ) ;
}
2010-11-16 23:34:31 +03:00
groupMailNotification - > setChecked ( pref . isMailNotificationEnabled ( ) ) ;
dest_email_txt - > setText ( pref . getMailNotificationEmail ( ) ) ;
smtp_server_txt - > setText ( pref . getMailNotificationSMTP ( ) ) ;
2011-04-09 21:39:51 +04:00
checkSmtpSSL - > setChecked ( pref . getMailNotificationSMTPSSL ( ) ) ;
groupMailNotifAuth - > setChecked ( pref . getMailNotificationSMTPAuth ( ) ) ;
mailNotifUsername - > setText ( pref . getMailNotificationSMTPUsername ( ) ) ;
mailNotifPassword - > setText ( pref . getMailNotificationSMTPPassword ( ) ) ;
2010-11-16 23:34:31 +03:00
autoRunBox - > setChecked ( pref . isAutoRunEnabled ( ) ) ;
autoRun_txt - > setText ( pref . getAutoRunProgram ( ) ) ;
intValue = pref . getActionOnDblClOnTorrentDl ( ) ;
2012-02-20 21:30:53 +04:00
if ( intValue > = actionTorrentDlOnDblClBox - > count ( ) )
2010-10-09 19:36:39 +04:00
intValue = 0 ;
actionTorrentDlOnDblClBox - > setCurrentIndex ( intValue ) ;
2010-11-16 23:34:31 +03:00
intValue = pref . getActionOnDblClOnTorrentFn ( ) ;
2012-02-20 21:30:53 +04:00
if ( intValue > = actionTorrentFnOnDblClBox - > count ( ) )
2010-10-09 19:36:39 +04:00
intValue = 1 ;
actionTorrentFnOnDblClBox - > setCurrentIndex ( intValue ) ;
// End Downloads preferences
// Connection preferences
2010-11-16 23:34:31 +03:00
spinPort - > setValue ( pref . getSessionPort ( ) ) ;
checkUPnP - > setChecked ( pref . isUPnPEnabled ( ) ) ;
2012-09-16 02:28:58 +04:00
checkRandomPort - > setChecked ( pref . useRandomPort ( ) ) ;
2013-06-30 16:51:15 +04:00
spinPort - > setDisabled ( checkRandomPort - > isChecked ( ) ) ;
2010-11-16 23:34:31 +03:00
intValue = pref . getGlobalDownloadLimit ( ) ;
2012-02-20 21:30:53 +04:00
if ( intValue > 0 ) {
2010-10-09 19:36:39 +04:00
// Enabled
checkDownloadLimit - > setChecked ( true ) ;
spinDownloadLimit - > setEnabled ( true ) ;
spinDownloadLimit - > setValue ( intValue ) ;
} else {
// Disabled
checkDownloadLimit - > setChecked ( false ) ;
spinDownloadLimit - > setEnabled ( false ) ;
}
2010-11-16 23:34:31 +03:00
intValue = pref . getGlobalUploadLimit ( ) ;
2012-02-20 21:30:53 +04:00
if ( intValue ! = - 1 ) {
2010-10-09 19:36:39 +04:00
// Enabled
checkUploadLimit - > setChecked ( true ) ;
spinUploadLimit - > setEnabled ( true ) ;
spinUploadLimit - > setValue ( intValue ) ;
} else {
// Disabled
checkUploadLimit - > setChecked ( false ) ;
spinUploadLimit - > setEnabled ( false ) ;
}
2010-11-16 23:34:31 +03:00
spinUploadLimitAlt - > setValue ( pref . getAltGlobalUploadLimit ( ) ) ;
spinDownloadLimitAlt - > setValue ( pref . getAltGlobalDownloadLimit ( ) ) ;
2011-04-17 18:42:38 +04:00
// Options
2011-04-17 22:11:03 +04:00
checkuTP - > setChecked ( pref . isuTPEnabled ( ) ) ;
2011-04-17 18:42:38 +04:00
checkLimituTPConnections - > setChecked ( pref . isuTPRateLimited ( ) ) ;
checkLimitTransportOverhead - > setChecked ( pref . includeOverheadInLimits ( ) ) ;
2010-10-09 19:36:39 +04:00
// Scheduler
2010-11-16 23:34:31 +03:00
check_schedule - > setChecked ( pref . isSchedulerEnabled ( ) ) ;
schedule_from - > setTime ( pref . getSchedulerStartTime ( ) ) ;
schedule_to - > setTime ( pref . getSchedulerEndTime ( ) ) ;
schedule_days - > setCurrentIndex ( ( int ) pref . getSchedulerDays ( ) ) ;
2010-10-09 19:36:39 +04:00
2010-11-18 23:05:56 +03:00
intValue = pref . getProxyType ( ) ;
2010-10-09 19:36:39 +04:00
switch ( intValue ) {
2010-10-24 01:46:05 +04:00
case Proxy : : SOCKS4 :
2010-10-09 19:36:39 +04:00
comboProxyType - > setCurrentIndex ( 1 ) ;
break ;
2010-10-24 01:46:05 +04:00
case Proxy : : SOCKS5 :
case Proxy : : SOCKS5_PW :
2010-10-09 19:36:39 +04:00
comboProxyType - > setCurrentIndex ( 2 ) ;
break ;
2010-10-24 01:46:05 +04:00
case Proxy : : HTTP :
case Proxy : : HTTP_PW :
2010-10-09 19:36:39 +04:00
comboProxyType - > setCurrentIndex ( 3 ) ;
break ;
default :
comboProxyType - > setCurrentIndex ( 0 ) ;
}
2010-11-18 23:05:56 +03:00
enableProxy ( comboProxyType - > currentIndex ( ) ) ;
2012-02-20 21:30:53 +04:00
//if (isProxyEnabled()) {
2010-10-09 19:36:39 +04:00
// Proxy is enabled, save settings
2010-11-18 23:05:56 +03:00
textProxyIP - > setText ( pref . getProxyIp ( ) ) ;
spinProxyPort - > setValue ( pref . getProxyPort ( ) ) ;
2011-05-01 15:22:17 +04:00
checkProxyPeerConnecs - > setChecked ( pref . proxyPeerConnections ( ) ) ;
2010-11-18 23:05:56 +03:00
checkProxyAuth - > setChecked ( pref . isProxyAuthEnabled ( ) ) ;
textProxyUsername - > setText ( pref . getProxyUsername ( ) ) ;
textProxyPassword - > setText ( pref . getProxyPassword ( ) ) ;
2010-10-09 19:36:39 +04:00
//}
// End Connection preferences
// Bittorrent preferences
2010-11-16 23:34:31 +03:00
intValue = pref . getMaxConnecs ( ) ;
2012-02-20 21:30:53 +04:00
if ( intValue > 0 ) {
2010-10-09 19:36:39 +04:00
// enable
checkMaxConnecs - > setChecked ( true ) ;
spinMaxConnec - > setEnabled ( true ) ;
spinMaxConnec - > setValue ( intValue ) ;
} else {
// disable
checkMaxConnecs - > setChecked ( false ) ;
spinMaxConnec - > setEnabled ( false ) ;
}
2010-11-16 23:34:31 +03:00
intValue = pref . getMaxConnecsPerTorrent ( ) ;
2012-02-20 21:30:53 +04:00
if ( intValue > 0 ) {
2010-10-09 19:36:39 +04:00
// enable
checkMaxConnecsPerTorrent - > setChecked ( true ) ;
spinMaxConnecPerTorrent - > setEnabled ( true ) ;
spinMaxConnecPerTorrent - > setValue ( intValue ) ;
} else {
// disable
checkMaxConnecsPerTorrent - > setChecked ( false ) ;
spinMaxConnecPerTorrent - > setEnabled ( false ) ;
}
2013-07-22 02:20:48 +04:00
intValue = pref . getMaxUploads ( ) ;
if ( intValue > 0 ) {
// enable
checkMaxUploads - > setChecked ( true ) ;
spinMaxUploads - > setEnabled ( true ) ;
spinMaxUploads - > setValue ( intValue ) ;
} else {
// disable
checkMaxUploads - > setChecked ( false ) ;
spinMaxUploads - > setEnabled ( false ) ;
}
2010-11-16 23:34:31 +03:00
intValue = pref . getMaxUploadsPerTorrent ( ) ;
2012-02-20 21:30:53 +04:00
if ( intValue > 0 ) {
2010-10-09 19:36:39 +04:00
// enable
checkMaxUploadsPerTorrent - > setChecked ( true ) ;
spinMaxUploadsPerTorrent - > setEnabled ( true ) ;
spinMaxUploadsPerTorrent - > setValue ( intValue ) ;
} else {
// disable
checkMaxUploadsPerTorrent - > setChecked ( false ) ;
spinMaxUploadsPerTorrent - > setEnabled ( false ) ;
}
2010-11-16 23:34:31 +03:00
checkDHT - > setChecked ( pref . isDHTEnabled ( ) ) ;
checkDifferentDHTPort - > setChecked ( ! pref . isDHTPortSameAsBT ( ) ) ;
spinDHTPort - > setValue ( pref . getDHTPort ( ) ) ;
checkPeX - > setChecked ( pref . isPeXEnabled ( ) ) ;
checkLSD - > setChecked ( pref . isLSDEnabled ( ) ) ;
comboEncryption - > setCurrentIndex ( pref . getEncryptionSetting ( ) ) ;
2011-09-20 21:15:47 +04:00
checkAnonymousMode - > setChecked ( pref . isAnonymousModeEnabled ( ) ) ;
2012-09-07 15:38:35 +04:00
/* make sure ui matches options */
toggleAnonymousMode ( checkAnonymousMode - > isChecked ( ) ) ;
2010-10-09 19:36:39 +04:00
// Ratio limit
2011-03-07 22:26:44 +03:00
floatValue = pref . getGlobalMaxRatio ( ) ;
2012-02-20 21:30:53 +04:00
if ( floatValue > = 0. ) {
2010-10-09 19:36:39 +04:00
// Enable
checkMaxRatio - > setChecked ( true ) ;
spinMaxRatio - > setEnabled ( true ) ;
comboRatioLimitAct - > setEnabled ( true ) ;
spinMaxRatio - > setValue ( floatValue ) ;
} else {
// Disable
checkMaxRatio - > setChecked ( false ) ;
spinMaxRatio - > setEnabled ( false ) ;
comboRatioLimitAct - > setEnabled ( false ) ;
}
2010-11-16 23:34:31 +03:00
comboRatioLimitAct - > setCurrentIndex ( pref . getMaxRatioAction ( ) ) ;
2010-10-09 19:36:39 +04:00
// End Bittorrent preferences
// Misc preferences
// * IP Filter
2010-11-16 23:34:31 +03:00
checkIPFilter - > setChecked ( pref . isFilteringEnabled ( ) ) ;
textFilterPath - > setText ( pref . getFilter ( ) ) ;
2010-10-09 19:36:39 +04:00
// End IP Filter
// Queueing system preferences
2010-11-16 23:34:31 +03:00
checkEnableQueueing - > setChecked ( pref . isQueueingSystemEnabled ( ) ) ;
spinMaxActiveDownloads - > setValue ( pref . getMaxActiveDownloads ( ) ) ;
spinMaxActiveUploads - > setValue ( pref . getMaxActiveUploads ( ) ) ;
spinMaxActiveTorrents - > setValue ( pref . getMaxActiveTorrents ( ) ) ;
2011-09-18 20:34:29 +04:00
checkIgnoreSlowTorrentsForQueueing - > setChecked ( pref . ignoreSlowTorrentsForQueueing ( ) ) ;
2010-10-09 19:36:39 +04:00
// End Queueing system preferences
// Web UI
2010-11-16 23:34:31 +03:00
checkWebUi - > setChecked ( pref . isWebUiEnabled ( ) ) ;
spinWebUiPort - > setValue ( pref . getWebUiPort ( ) ) ;
2011-04-12 23:50:05 +04:00
checkWebUIUPnP - > setChecked ( pref . useUPnPForWebUIPort ( ) ) ;
2011-06-05 20:08:30 +04:00
checkWebUiHttps - > setChecked ( pref . isWebUiHttpsEnabled ( ) ) ;
setSslCertificate ( pref . getWebUiHttpsCertificate ( ) , false ) ;
setSslKey ( pref . getWebUiHttpsKey ( ) , false ) ;
2010-11-16 23:34:31 +03:00
textWebUiUsername - > setText ( pref . getWebUiUsername ( ) ) ;
textWebUiPassword - > setText ( pref . getWebUiPassword ( ) ) ;
2011-02-27 12:34:42 +03:00
checkBypassLocalAuth - > setChecked ( ! pref . isWebUiLocalAuthEnabled ( ) ) ;
2011-04-15 17:02:39 +04:00
// Dynamic DNS
checkDynDNS - > setChecked ( pref . isDynDNSEnabled ( ) ) ;
comboDNSService - > setCurrentIndex ( ( int ) pref . getDynDNSService ( ) ) ;
domainNameTxt - > setText ( pref . getDynDomainName ( ) ) ;
DNSUsernameTxt - > setText ( pref . getDynDNSUsername ( ) ) ;
DNSPasswordTxt - > setText ( pref . getDynDNSPassword ( ) ) ;
2013-06-30 16:32:45 +04:00
// End Web UI
2010-10-09 19:36:39 +04:00
}
// return min & max ports
// [min, max]
2012-02-20 23:32:58 +04:00
int options_imp : : getPort ( ) const {
2010-10-09 19:36:39 +04:00
return spinPort - > value ( ) ;
}
void options_imp : : on_randomButton_clicked ( ) {
// Range [1024: 65535]
spinPort - > setValue ( rand ( ) % 64512 + 1024 ) ;
}
2012-02-20 23:32:58 +04:00
int options_imp : : getEncryptionSetting ( ) const {
2010-10-09 19:36:39 +04:00
return comboEncryption - > currentIndex ( ) ;
}
int options_imp : : getMaxActiveDownloads ( ) const {
return spinMaxActiveDownloads - > value ( ) ;
}
int options_imp : : getMaxActiveUploads ( ) const {
return spinMaxActiveUploads - > value ( ) ;
}
int options_imp : : getMaxActiveTorrents ( ) const {
return spinMaxActiveTorrents - > value ( ) ;
}
2012-02-20 23:32:58 +04:00
bool options_imp : : minimizeToTray ( ) const {
2012-02-20 21:30:53 +04:00
if ( ! checkShowSystray - > isChecked ( ) ) return false ;
2010-10-09 19:36:39 +04:00
return checkMinimizeToSysTray - > isChecked ( ) ;
}
2012-02-20 23:32:58 +04:00
bool options_imp : : closeToTray ( ) const {
2012-02-20 21:30:53 +04:00
if ( ! checkShowSystray - > isChecked ( ) ) return false ;
2010-10-09 19:36:39 +04:00
return checkCloseToSystray - > isChecked ( ) ;
}
bool options_imp : : isQueueingSystemEnabled ( ) const {
return checkEnableQueueing - > isChecked ( ) ;
}
2012-02-20 23:32:58 +04:00
bool options_imp : : isDHTEnabled ( ) const {
2010-10-09 19:36:39 +04:00
return checkDHT - > isChecked ( ) ;
}
2012-02-20 23:32:58 +04:00
bool options_imp : : isLSDEnabled ( ) const {
2010-10-09 19:36:39 +04:00
return checkLSD - > isChecked ( ) ;
}
2012-02-20 23:32:58 +04:00
bool options_imp : : isUPnPEnabled ( ) const {
2010-10-09 19:36:39 +04:00
return checkUPnP - > isChecked ( ) ;
}
// Return Download & Upload limits in kbps
// [download,upload]
2012-02-20 23:32:58 +04:00
QPair < int , int > options_imp : : getGlobalBandwidthLimits ( ) const {
2010-10-09 19:36:39 +04:00
int DL = - 1 , UP = - 1 ;
2012-02-20 21:56:07 +04:00
if ( checkDownloadLimit - > isChecked ( ) ) {
2010-10-09 19:36:39 +04:00
DL = spinDownloadLimit - > value ( ) ;
}
2012-02-20 21:56:07 +04:00
if ( checkUploadLimit - > isChecked ( ) ) {
2010-10-09 19:36:39 +04:00
UP = spinUploadLimit - > value ( ) ;
}
return qMakePair ( DL , UP ) ;
}
bool options_imp : : startMinimized ( ) const {
return checkStartMinimized - > isChecked ( ) ;
}
2012-02-20 23:32:58 +04:00
bool options_imp : : systrayIntegration ( ) const {
2010-10-09 19:36:39 +04:00
if ( ! QSystemTrayIcon : : isSystemTrayAvailable ( ) ) return false ;
return checkShowSystray - > isChecked ( ) ;
}
int options_imp : : getDHTPort ( ) const {
return spinDHTPort - > value ( ) ;
}
// Return Share ratio
2012-02-20 23:32:58 +04:00
qreal options_imp : : getMaxRatio ( ) const {
2012-02-20 21:56:07 +04:00
if ( checkMaxRatio - > isChecked ( ) ) {
2010-10-09 19:36:39 +04:00
return spinMaxRatio - > value ( ) ;
}
return - 1 ;
}
// Return Save Path
2012-02-20 23:32:58 +04:00
QString options_imp : : getSavePath ( ) const {
2012-02-20 21:56:07 +04:00
if ( textSavePath - > text ( ) . trimmed ( ) . isEmpty ( ) ) {
2010-11-16 23:34:31 +03:00
QString save_path = Preferences ( ) . getSavePath ( ) ;
2010-06-22 23:17:47 +04:00
# if defined(Q_WS_WIN) || defined(Q_OS_OS2)
2011-09-25 16:04:51 +04:00
save_path . replace ( " / " , " \\ " ) ;
2009-01-04 22:37:55 +03:00
# endif
2010-10-09 19:36:39 +04:00
textSavePath - > setText ( save_path ) ;
2006-09-30 20:02:39 +04:00
}
2012-05-16 22:19:05 +04:00
return fsutils : : expandPath ( textSavePath - > text ( ) ) ;
2010-10-09 19:36:39 +04:00
}
2006-09-30 20:02:39 +04:00
2010-10-09 19:36:39 +04:00
QString options_imp : : getTempPath ( ) const {
2012-05-16 22:19:05 +04:00
return fsutils : : expandPath ( textTempPath - > text ( ) ) ;
2010-10-09 19:36:39 +04:00
}
2006-09-30 20:02:39 +04:00
2010-10-09 19:36:39 +04:00
bool options_imp : : isTempPathEnabled ( ) const {
return checkTempFolder - > isChecked ( ) ;
}
2006-09-30 20:02:39 +04:00
2010-10-09 19:36:39 +04:00
// Return max connections number
2012-02-20 23:32:58 +04:00
int options_imp : : getMaxConnecs ( ) const {
2012-02-20 21:56:07 +04:00
if ( ! checkMaxConnecs - > isChecked ( ) ) {
2010-10-09 19:36:39 +04:00
return - 1 ;
} else {
return spinMaxConnec - > value ( ) ;
2010-06-21 23:20:58 +04:00
}
2010-10-09 19:36:39 +04:00
}
2010-06-21 23:20:58 +04:00
2012-02-20 23:32:58 +04:00
int options_imp : : getMaxConnecsPerTorrent ( ) const {
2012-02-20 21:56:07 +04:00
if ( ! checkMaxConnecsPerTorrent - > isChecked ( ) ) {
2010-10-09 19:36:39 +04:00
return - 1 ;
} else {
return spinMaxConnecPerTorrent - > value ( ) ;
2010-06-21 23:20:58 +04:00
}
2010-10-09 19:36:39 +04:00
}
2010-06-21 23:20:58 +04:00
2013-07-22 02:20:48 +04:00
int options_imp : : getMaxUploads ( ) const {
if ( ! checkMaxUploads - > isChecked ( ) ) {
return - 1 ;
} else {
return spinMaxUploads - > value ( ) ;
}
}
2012-02-20 23:32:58 +04:00
int options_imp : : getMaxUploadsPerTorrent ( ) const {
2012-02-20 21:56:07 +04:00
if ( ! checkMaxUploadsPerTorrent - > isChecked ( ) ) {
2010-10-09 19:36:39 +04:00
return - 1 ;
} else {
return spinMaxUploadsPerTorrent - > value ( ) ;
2010-06-21 23:20:58 +04:00
}
2010-10-09 19:36:39 +04:00
}
2010-06-21 23:20:58 +04:00
2012-02-20 21:56:07 +04:00
void options_imp : : on_buttonBox_accepted ( ) {
if ( applyButton - > isEnabled ( ) ) {
2013-09-14 13:54:22 +04:00
if ( ! schedTimesOk ( ) ) {
tabSelection - > setCurrentRow ( TAB_SPEED ) ;
return ;
}
2010-10-09 19:36:39 +04:00
saveOptions ( ) ;
applyButton - > setEnabled ( false ) ;
this - > hide ( ) ;
emit status_changed ( ) ;
2010-06-21 23:20:58 +04:00
}
2010-10-09 19:36:39 +04:00
saveWindowState ( ) ;
accept ( ) ;
}
2010-06-21 23:20:58 +04:00
2010-10-09 19:36:39 +04:00
void options_imp : : applySettings ( QAbstractButton * button ) {
2012-02-20 21:56:07 +04:00
if ( button = = applyButton ) {
2013-09-14 13:54:22 +04:00
if ( ! schedTimesOk ( ) ) {
tabSelection - > setCurrentRow ( TAB_SPEED ) ;
return ;
}
2010-10-09 19:36:39 +04:00
saveOptions ( ) ;
emit status_changed ( ) ;
2010-06-21 23:20:58 +04:00
}
2010-10-09 19:36:39 +04:00
}
2010-06-21 23:20:58 +04:00
2012-02-20 21:56:07 +04:00
void options_imp : : closeEvent ( QCloseEvent * e ) {
2010-10-09 19:36:39 +04:00
setAttribute ( Qt : : WA_DeleteOnClose ) ;
e - > accept ( ) ;
}
2010-06-21 23:20:58 +04:00
2012-02-20 21:56:07 +04:00
void options_imp : : on_buttonBox_rejected ( ) {
2010-10-09 19:36:39 +04:00
setAttribute ( Qt : : WA_DeleteOnClose ) ;
reject ( ) ;
}
2012-02-20 23:32:58 +04:00
bool options_imp : : useAdditionDialog ( ) const {
2010-10-09 19:36:39 +04:00
return checkAdditionDialog - > isChecked ( ) ;
}
2012-02-20 21:56:07 +04:00
void options_imp : : enableApplyButton ( ) {
2010-10-09 19:36:39 +04:00
applyButton - > setEnabled ( true ) ;
}
2012-02-20 21:56:07 +04:00
void options_imp : : enableProxy ( int index ) {
if ( index ) {
2010-10-09 19:36:39 +04:00
//enable
lblProxyIP - > setEnabled ( true ) ;
textProxyIP - > setEnabled ( true ) ;
lblProxyPort - > setEnabled ( true ) ;
spinProxyPort - > setEnabled ( true ) ;
2011-05-01 15:22:17 +04:00
checkProxyPeerConnecs - > setEnabled ( true ) ;
2012-02-20 21:30:53 +04:00
if ( index > 1 ) {
2010-10-09 19:36:39 +04:00
checkProxyAuth - > setEnabled ( true ) ;
2009-12-30 13:53:58 +03:00
} else {
checkProxyAuth - > setEnabled ( false ) ;
checkProxyAuth - > setChecked ( false ) ;
}
2010-10-09 19:36:39 +04:00
} else {
//disable
lblProxyIP - > setEnabled ( false ) ;
textProxyIP - > setEnabled ( false ) ;
lblProxyPort - > setEnabled ( false ) ;
spinProxyPort - > setEnabled ( false ) ;
2011-05-01 15:22:17 +04:00
checkProxyPeerConnecs - > setEnabled ( false ) ;
2010-10-09 19:36:39 +04:00
checkProxyAuth - > setEnabled ( false ) ;
checkProxyAuth - > setChecked ( false ) ;
}
}
bool options_imp : : isSlashScreenDisabled ( ) const {
return ! checkShowSplash - > isChecked ( ) ;
}
2012-10-08 00:05:33 +04:00
# ifdef Q_WS_WIN
bool options_imp : : Startup ( ) const {
return checkStartup - > isChecked ( ) ;
}
# endif
2011-02-06 17:27:34 +03:00
bool options_imp : : preventFromSuspend ( ) const {
2011-03-07 23:22:35 +03:00
return checkPreventFromSuspend - > isChecked ( ) ;
2011-02-06 17:27:34 +03:00
}
2010-10-09 19:36:39 +04:00
bool options_imp : : preAllocateAllFiles ( ) const {
return checkPreallocateAll - > isChecked ( ) ;
}
bool options_imp : : addTorrentsInPause ( ) const {
return checkStartPaused - > isChecked ( ) ;
}
bool options_imp : : isDHTPortSameAsBT ( ) const {
return ! checkDifferentDHTPort - > isChecked ( ) ;
}
// Proxy settings
2012-02-20 23:32:58 +04:00
bool options_imp : : isProxyEnabled ( ) const {
2010-10-09 19:36:39 +04:00
return comboProxyType - > currentIndex ( ) ;
}
2012-02-20 23:32:58 +04:00
bool options_imp : : isProxyAuthEnabled ( ) const {
2010-10-09 19:36:39 +04:00
return checkProxyAuth - > isChecked ( ) ;
}
2012-02-20 23:32:58 +04:00
QString options_imp : : getProxyIp ( ) const {
2011-04-11 21:21:16 +04:00
return textProxyIP - > text ( ) . trimmed ( ) ;
2010-10-09 19:36:39 +04:00
}
2012-02-20 23:32:58 +04:00
unsigned short options_imp : : getProxyPort ( ) const {
2010-10-09 19:36:39 +04:00
return spinProxyPort - > value ( ) ;
}
2012-02-20 23:32:58 +04:00
QString options_imp : : getProxyUsername ( ) const {
2010-10-09 19:36:39 +04:00
QString username = textProxyUsername - > text ( ) ;
username = username . trimmed ( ) ;
return username ;
}
2012-02-20 23:32:58 +04:00
QString options_imp : : getProxyPassword ( ) const {
2010-10-09 19:36:39 +04:00
QString password = textProxyPassword - > text ( ) ;
password = password . trimmed ( ) ;
return password ;
}
// Locale Settings
2012-02-20 23:32:58 +04:00
QString options_imp : : getLocale ( ) const {
2010-11-20 18:59:17 +03:00
return comboI18n - > itemData ( comboI18n - > currentIndex ( ) , Qt : : UserRole ) . toString ( ) ;
2010-10-09 19:36:39 +04:00
}
2011-04-11 21:21:16 +04:00
void options_imp : : setLocale ( const QString & localeStr ) {
2010-11-20 18:59:17 +03:00
QLocale locale ( localeStr ) ;
// Attempt to find exact match
int index = comboI18n - > findData ( locale . name ( ) , Qt : : UserRole ) ;
2012-02-20 21:30:53 +04:00
if ( index < 0 ) {
2010-11-20 18:59:17 +03:00
// Unreconized, use US English
index = comboI18n - > findData ( QLocale ( " en " ) . name ( ) , Qt : : UserRole ) ;
Q_ASSERT ( index > = 0 ) ;
2010-10-09 19:36:39 +04:00
}
2010-11-20 18:59:17 +03:00
comboI18n - > setCurrentIndex ( index ) ;
2010-10-09 19:36:39 +04:00
}
2012-08-21 11:16:49 +04:00
QString options_imp : : getTorrentExportDir ( ) const {
2012-02-20 21:30:53 +04:00
if ( checkExportDir - > isChecked ( ) )
2012-05-16 22:19:05 +04:00
return fsutils : : expandPath ( textExportDir - > text ( ) ) ;
2011-04-11 21:21:16 +04:00
return QString ( ) ;
2010-10-09 19:36:39 +04:00
}
2012-08-21 11:16:49 +04:00
QString options_imp : : getFinishedTorrentExportDir ( ) const {
if ( checkExportDirFin - > isChecked ( ) )
return fsutils : : expandPath ( textExportDirFin - > text ( ) ) ;
return QString ( ) ;
}
2010-10-09 19:36:39 +04:00
// Return action on double-click on a downloading torrent set in options
int options_imp : : getActionOnDblClOnTorrentDl ( ) const {
2012-02-20 21:30:53 +04:00
if ( actionTorrentDlOnDblClBox - > currentIndex ( ) < 1 )
2010-10-09 19:36:39 +04:00
return 0 ;
return actionTorrentDlOnDblClBox - > currentIndex ( ) ;
}
// Return action on double-click on a finished torrent set in options
int options_imp : : getActionOnDblClOnTorrentFn ( ) const {
2012-02-20 21:30:53 +04:00
if ( actionTorrentFnOnDblClBox - > currentIndex ( ) < 1 )
2010-10-09 19:36:39 +04:00
return 0 ;
return actionTorrentFnOnDblClBox - > currentIndex ( ) ;
}
void options_imp : : on_addScanFolderButton_clicked ( ) {
const QString dir = QFileDialog : : getExistingDirectory ( this , tr ( " Add directory to scan " ) ) ;
if ( ! dir . isEmpty ( ) ) {
const ScanFoldersModel : : PathStatus status = ScanFoldersModel : : instance ( ) - > addPath ( dir , false ) ;
QString error ;
switch ( status ) {
case ScanFoldersModel : : AlreadyInList :
error = tr ( " Folder is already being watched. " ) . arg ( dir ) ;
break ;
case ScanFoldersModel : : DoesNotExist :
error = tr ( " Folder does not exist. " ) ;
break ;
case ScanFoldersModel : : CannotRead :
error = tr ( " Folder is not readable. " ) ;
break ;
default :
addedScanDirs < < dir ;
enableApplyButton ( ) ;
2010-02-28 18:15:00 +03:00
}
2010-06-21 23:20:58 +04:00
2010-10-09 19:36:39 +04:00
if ( ! error . isEmpty ( ) ) {
QMessageBox : : warning ( this , tr ( " Failure " ) , tr ( " Failed to add Scan Folder '%1': %2 " ) . arg ( dir ) . arg ( error ) ) ;
2010-06-21 23:20:58 +04:00
}
}
2010-10-09 19:36:39 +04:00
}
void options_imp : : on_removeScanFolderButton_clicked ( ) {
const QModelIndexList selected
= scanFoldersView - > selectionModel ( ) - > selectedIndexes ( ) ;
if ( selected . isEmpty ( ) )
return ;
Q_ASSERT ( selected . count ( ) = = ScanFoldersModel : : instance ( ) - > columnCount ( ) ) ;
ScanFoldersModel : : instance ( ) - > removePath ( selected . first ( ) . row ( ) ) ;
}
void options_imp : : handleScanFolderViewSelectionChanged ( ) {
removeScanFolderButton - > setEnabled ( ! scanFoldersView - > selectionModel ( ) - > selectedIndexes ( ) . isEmpty ( ) ) ;
}
2012-08-21 11:16:49 +04:00
QString options_imp : : askForExportDir ( const QString & currentExportPath )
{
QDir currentExportDir ( fsutils : : expandPath ( currentExportPath ) ) ;
2010-10-09 19:36:39 +04:00
QString dir ;
2012-08-21 11:16:49 +04:00
if ( ! currentExportPath . isEmpty ( ) & & currentExportDir . exists ( ) ) {
dir = QFileDialog : : getExistingDirectory ( this , tr ( " Choose export directory " ) , currentExportDir . absolutePath ( ) ) ;
2010-10-09 19:36:39 +04:00
} else {
dir = QFileDialog : : getExistingDirectory ( this , tr ( " Choose export directory " ) , QDir : : homePath ( ) ) ;
}
2012-08-21 11:16:49 +04:00
return dir ;
}
void options_imp : : on_browseExportDirButton_clicked ( ) {
const QString newExportDir = askForExportDir ( textExportDir - > text ( ) ) ;
if ( ! newExportDir . isNull ( ) )
textExportDir - > setText ( fsutils : : toDisplayPath ( newExportDir ) ) ;
}
void options_imp : : on_browseExportDirFinButton_clicked ( ) {
const QString newExportDir = askForExportDir ( textExportDirFin - > text ( ) ) ;
if ( ! newExportDir . isNull ( ) )
textExportDirFin - > setText ( fsutils : : toDisplayPath ( newExportDir ) ) ;
2010-10-09 19:36:39 +04:00
}
2006-09-30 20:02:39 +04:00
2010-10-09 19:36:39 +04:00
void options_imp : : on_browseFilterButton_clicked ( ) {
2012-05-16 22:19:05 +04:00
const QString filter_path = fsutils : : expandPath ( textFilterPath - > text ( ) ) ;
2010-10-09 19:36:39 +04:00
QDir filterDir ( filter_path ) ;
QString ipfilter ;
2012-02-20 21:30:53 +04:00
if ( ! filter_path . isEmpty ( ) & & filterDir . exists ( ) ) {
2010-10-09 19:36:39 +04:00
ipfilter = QFileDialog : : getOpenFileName ( this , tr ( " Choose an ip filter file " ) , filterDir . absolutePath ( ) , tr ( " Filters " ) + QString ( " (*.dat *.p2p *.p2b) " ) ) ;
} else {
ipfilter = QFileDialog : : getOpenFileName ( this , tr ( " Choose an ip filter file " ) , QDir : : homePath ( ) , tr ( " Filters " ) + QString ( " (*.dat *.p2p *.p2b) " ) ) ;
}
2012-02-20 21:56:07 +04:00
if ( ! ipfilter . isNull ( ) ) {
2010-06-22 23:17:47 +04:00
# if defined(Q_WS_WIN) || defined(Q_OS_OS2)
2011-09-25 16:04:51 +04:00
ipfilter . replace ( " / " , " \\ " ) ;
2010-06-04 01:08:28 +04:00
# endif
2010-10-09 19:36:39 +04:00
textFilterPath - > setText ( ipfilter ) ;
2006-09-30 20:02:39 +04:00
}
2010-10-09 19:36:39 +04:00
}
2006-09-30 20:02:39 +04:00
2010-10-09 19:36:39 +04:00
// Display dialog to choose save dir
2012-02-20 21:56:07 +04:00
void options_imp : : on_browseSaveDirButton_clicked ( ) {
2012-05-16 22:19:05 +04:00
const QString save_path = fsutils : : expandPath ( textSavePath - > text ( ) ) ;
2010-10-09 19:36:39 +04:00
QDir saveDir ( save_path ) ;
QString dir ;
2012-02-20 21:30:53 +04:00
if ( ! save_path . isEmpty ( ) & & saveDir . exists ( ) ) {
2010-10-09 19:36:39 +04:00
dir = QFileDialog : : getExistingDirectory ( this , tr ( " Choose a save directory " ) , saveDir . absolutePath ( ) ) ;
} else {
dir = QFileDialog : : getExistingDirectory ( this , tr ( " Choose a save directory " ) , QDir : : homePath ( ) ) ;
}
2012-02-20 21:56:07 +04:00
if ( ! dir . isNull ( ) ) {
2010-06-22 23:17:47 +04:00
# if defined(Q_WS_WIN) || defined(Q_OS_OS2)
2011-09-25 16:04:51 +04:00
dir . replace ( " / " , " \\ " ) ;
2010-06-21 23:20:58 +04:00
# endif
2010-10-09 19:36:39 +04:00
textSavePath - > setText ( dir ) ;
2009-12-22 13:29:39 +03:00
}
2010-10-09 19:36:39 +04:00
}
2010-06-21 23:20:58 +04:00
2012-02-20 21:56:07 +04:00
void options_imp : : on_browseTempDirButton_clicked ( ) {
2012-05-16 22:19:05 +04:00
const QString temp_path = fsutils : : expandPath ( textTempPath - > text ( ) ) ;
2010-10-09 19:36:39 +04:00
QDir tempDir ( temp_path ) ;
QString dir ;
2012-02-20 21:30:53 +04:00
if ( ! temp_path . isEmpty ( ) & & tempDir . exists ( ) ) {
2010-10-09 19:36:39 +04:00
dir = QFileDialog : : getExistingDirectory ( this , tr ( " Choose a save directory " ) , tempDir . absolutePath ( ) ) ;
} else {
dir = QFileDialog : : getExistingDirectory ( this , tr ( " Choose a save directory " ) , QDir : : homePath ( ) ) ;
}
2012-02-20 21:56:07 +04:00
if ( ! dir . isNull ( ) ) {
2010-06-22 23:17:47 +04:00
# if defined(Q_WS_WIN) || defined(Q_OS_OS2)
2011-09-25 16:04:51 +04:00
dir . replace ( " / " , " \\ " ) ;
2010-06-04 01:08:28 +04:00
# endif
2010-10-09 19:36:39 +04:00
textTempPath - > setText ( dir ) ;
2009-12-19 23:39:38 +03:00
}
2010-10-09 19:36:39 +04:00
}
2009-12-19 23:39:38 +03:00
2010-10-09 19:36:39 +04:00
// Return Filter object to apply to BT session
2012-02-20 23:32:58 +04:00
QString options_imp : : getFilter ( ) const {
2010-10-09 19:36:39 +04:00
return textFilterPath - > text ( ) ;
}
2006-09-30 20:02:39 +04:00
2010-10-09 19:36:39 +04:00
// Web UI
2008-05-16 11:10:50 +04:00
2010-10-09 19:36:39 +04:00
bool options_imp : : isWebUiEnabled ( ) const
{
return checkWebUi - > isChecked ( ) ;
}
2008-05-16 11:10:50 +04:00
2010-10-09 19:36:39 +04:00
quint16 options_imp : : webUiPort ( ) const
{
return spinWebUiPort - > value ( ) ;
}
2008-05-16 11:10:50 +04:00
2010-10-09 19:36:39 +04:00
QString options_imp : : webUiUsername ( ) const
{
return textWebUiUsername - > text ( ) ;
}
2008-05-16 11:10:50 +04:00
2010-10-09 19:36:39 +04:00
QString options_imp : : webUiPassword ( ) const
{
return textWebUiPassword - > text ( ) ;
}
2010-11-08 21:17:54 +03:00
void options_imp : : showConnectionTab ( )
{
2013-09-14 13:54:22 +04:00
tabSelection - > setCurrentRow ( TAB_CONNECTION ) ;
2010-11-08 21:17:54 +03:00
}
2010-11-20 18:59:17 +03:00
2011-06-05 20:08:30 +04:00
void options_imp : : on_btnWebUiCrt_clicked ( ) {
QString filename = QFileDialog : : getOpenFileName ( this , QString ( ) , QString ( ) , tr ( " SSL Certificate (*.crt *.pem) " ) ) ;
2012-02-20 21:30:53 +04:00
if ( filename . isNull ( ) )
2011-06-05 20:08:30 +04:00
return ;
QFile file ( filename ) ;
if ( file . open ( QIODevice : : ReadOnly ) ) {
setSslCertificate ( file . readAll ( ) ) ;
file . close ( ) ;
}
}
void options_imp : : on_btnWebUiKey_clicked ( ) {
QString filename = QFileDialog : : getOpenFileName ( this , QString ( ) , QString ( ) , tr ( " SSL Key (*.key *.pem) " ) ) ;
2012-02-20 21:30:53 +04:00
if ( filename . isNull ( ) )
2011-06-05 20:08:30 +04:00
return ;
QFile file ( filename ) ;
if ( file . open ( QIODevice : : ReadOnly ) ) {
setSslKey ( file . readAll ( ) ) ;
file . close ( ) ;
}
}
2011-04-15 17:02:39 +04:00
void options_imp : : on_registerDNSBtn_clicked ( ) {
QDesktopServices : : openUrl ( DNSUpdater : : getRegistrationUrl ( comboDNSService - > currentIndex ( ) ) ) ;
}
2010-12-25 17:47:52 +03:00
void options_imp : : on_IpFilterRefreshBtn_clicked ( ) {
2012-02-20 21:30:53 +04:00
if ( m_refreshingIpFilter ) return ;
2010-12-25 17:47:52 +03:00
m_refreshingIpFilter = true ;
// Updating program preferences
Preferences pref ;
pref . setFilteringEnabled ( true ) ;
pref . setFilter ( getFilter ( ) ) ;
// Force refresh
connect ( QBtSession : : instance ( ) , SIGNAL ( ipFilterParsed ( bool , int ) ) , SLOT ( handleIPFilterParsed ( bool , int ) ) ) ;
setCursor ( QCursor ( Qt : : WaitCursor ) ) ;
QBtSession : : instance ( ) - > enableIPFilter ( getFilter ( ) , true ) ;
}
void options_imp : : handleIPFilterParsed ( bool error , int ruleCount )
{
setCursor ( QCursor ( Qt : : ArrowCursor ) ) ;
2012-02-20 21:30:53 +04:00
if ( error ) {
2010-12-25 17:47:52 +03:00
QMessageBox : : warning ( this , tr ( " Parsing error " ) , tr ( " Failed to parse the provided IP filter " ) ) ;
} else {
2012-02-20 23:46:02 +04:00
QMessageBox : : information ( this , tr ( " Successfully refreshed " ) , tr ( " Successfully parsed the provided IP filter: %1 rules were applied. " , " %1 is a number " ) . arg ( ruleCount ) ) ;
2010-12-25 17:47:52 +03:00
}
m_refreshingIpFilter = false ;
disconnect ( QBtSession : : instance ( ) , SIGNAL ( ipFilterParsed ( bool , int ) ) , this , SLOT ( handleIPFilterParsed ( bool , int ) ) ) ;
}
2011-01-12 20:42:55 +03:00
2013-10-20 20:31:01 +04:00
QString options_imp : : languageToLocalizedString ( const QLocale & locale )
2011-01-12 20:42:55 +03:00
{
2013-10-20 20:31:01 +04:00
switch ( locale . language ( ) ) {
case QLocale : : English : {
if ( locale . country ( ) = = QLocale : : Australia )
return " English(Australia) " ;
else if ( locale . country ( ) = = QLocale : : UnitedKingdom )
return " English(United Kingdom) " ;
return " English " ;
}
2011-01-12 20:42:55 +03:00
case QLocale : : French : return QString : : fromUtf8 ( " Français " ) ;
case QLocale : : German : return QString : : fromUtf8 ( " Deutsch " ) ;
case QLocale : : Hungarian : return QString : : fromUtf8 ( " Magyar " ) ;
case QLocale : : Italian : return QString : : fromUtf8 ( " Italiano " ) ;
case QLocale : : Dutch : return QString : : fromUtf8 ( " Nederlands " ) ;
case QLocale : : Spanish : return QString : : fromUtf8 ( " Español " ) ;
case QLocale : : Catalan : return QString : : fromUtf8 ( " Català " ) ;
case QLocale : : Galician : return QString : : fromUtf8 ( " Galego " ) ;
case QLocale : : Portuguese : {
2013-10-20 20:31:01 +04:00
if ( locale . country ( ) = = QLocale : : Brazil )
2011-01-12 20:42:55 +03:00
return QString : : fromUtf8 ( " Português brasileiro " ) ;
return QString : : fromUtf8 ( " Português " ) ;
}
case QLocale : : Polish : return QString : : fromUtf8 ( " Polski " ) ;
2011-02-07 21:56:17 +03:00
case QLocale : : Lithuanian : return QString : : fromUtf8 ( " Lietuvių " ) ;
2011-01-12 20:42:55 +03:00
case QLocale : : Czech : return QString : : fromUtf8 ( " Čeština " ) ;
case QLocale : : Slovak : return QString : : fromUtf8 ( " Slovenčina " ) ;
case QLocale : : Serbian : return QString : : fromUtf8 ( " Српски " ) ;
case QLocale : : Croatian : return QString : : fromUtf8 ( " Hrvatski " ) ;
case QLocale : : Armenian : return QString : : fromUtf8 ( " Հայերեն " ) ;
case QLocale : : Romanian : return QString : : fromUtf8 ( " Română " ) ;
case QLocale : : Turkish : return QString : : fromUtf8 ( " Türkçe " ) ;
case QLocale : : Greek : return QString : : fromUtf8 ( " Ελληνικά " ) ;
case QLocale : : Swedish : return QString : : fromUtf8 ( " Svenska " ) ;
case QLocale : : Finnish : return QString : : fromUtf8 ( " Suomi " ) ;
case QLocale : : Norwegian : return QString : : fromUtf8 ( " Norsk " ) ;
case QLocale : : Danish : return QString : : fromUtf8 ( " Dansk " ) ;
case QLocale : : Bulgarian : return QString : : fromUtf8 ( " Български " ) ;
case QLocale : : Ukrainian : return QString : : fromUtf8 ( " Українська " ) ;
case QLocale : : Russian : return QString : : fromUtf8 ( " Русский " ) ;
case QLocale : : Japanese : return QString : : fromUtf8 ( " 日本語 " ) ;
2012-09-15 11:05:50 +04:00
case QLocale : : Hebrew : return QString : : fromUtf8 ( " עברית " ) ;
2011-01-12 20:42:55 +03:00
case QLocale : : Arabic : return QString : : fromUtf8 ( " عربي " ) ;
2011-12-27 15:29:35 +04:00
case QLocale : : Georgian : return QString : : fromUtf8 ( " ქართული " ) ;
2012-01-31 21:25:57 +04:00
case QLocale : : Byelorussian : return QString : : fromUtf8 ( " Беларуская " ) ;
2012-03-07 20:12:14 +04:00
case QLocale : : Basque : return QString : : fromUtf8 ( " Euskara " ) ;
2013-10-12 17:13:27 +04:00
case QLocale : : Vietnamese : return QString : : fromUtf8 ( " tiếng Việt " ) ;
2011-01-12 20:42:55 +03:00
case QLocale : : Chinese : {
2013-10-20 20:31:01 +04:00
if ( locale . country ( ) = = QLocale : : China )
2011-01-12 20:42:55 +03:00
return QString : : fromUtf8 ( " 中文 (简体) " ) ;
return QString : : fromUtf8 ( " 中文 (繁體) " ) ;
}
case QLocale : : Korean : return QString : : fromUtf8 ( " 한글 " ) ;
default : {
// Fallback to English
2013-10-20 20:31:01 +04:00
const QString eng_lang = QLocale : : languageToString ( locale . language ( ) ) ;
2011-01-12 20:42:55 +03:00
qWarning ( ) < < " Unrecognized language name: " < < eng_lang ;
return eng_lang ;
}
}
}
2011-06-05 20:08:30 +04:00
void options_imp : : setSslKey ( const QByteArray & key , bool interactive )
{
# ifndef QT_NO_OPENSSL
if ( ! key . isEmpty ( ) & & ! QSslKey ( key , QSsl : : Rsa ) . isNull ( ) ) {
lblSslKeyStatus - > setPixmap ( QPixmap ( " :/Icons/oxygen/security-high.png " ) . scaledToHeight ( 20 , Qt : : SmoothTransformation ) ) ;
m_sslKey = key ;
} else {
lblSslKeyStatus - > setPixmap ( QPixmap ( " :/Icons/oxygen/security-low.png " ) . scaledToHeight ( 20 , Qt : : SmoothTransformation ) ) ;
m_sslKey . clear ( ) ;
if ( interactive )
QMessageBox : : warning ( this , tr ( " Invalid key " ) , tr ( " This is not a valid SSL key. " ) ) ;
}
# endif
}
void options_imp : : setSslCertificate ( const QByteArray & cert , bool interactive )
{
# ifndef QT_NO_OPENSSL
if ( ! cert . isEmpty ( ) & & ! QSslCertificate ( cert ) . isNull ( ) ) {
lblSslCertStatus - > setPixmap ( QPixmap ( " :/Icons/oxygen/security-high.png " ) . scaledToHeight ( 20 , Qt : : SmoothTransformation ) ) ;
m_sslCert = cert ;
} else {
lblSslCertStatus - > setPixmap ( QPixmap ( " :/Icons/oxygen/security-low.png " ) . scaledToHeight ( 20 , Qt : : SmoothTransformation ) ) ;
m_sslCert . clear ( ) ;
if ( interactive )
QMessageBox : : warning ( this , tr ( " Invalid certificate " ) , tr ( " This is not a valid SSL certificate. " ) ) ;
}
# endif
}
2011-09-20 21:15:47 +04:00
void options_imp : : toggleAnonymousMode ( bool enabled )
{
if ( enabled ) {
// Disable DHT, LSD, UPnP / NAT-PMP
checkDHT - > setEnabled ( false ) ;
checkDifferentDHTPort - > setEnabled ( false ) ;
checkDHT - > setChecked ( false ) ;
checkLSD - > setEnabled ( false ) ;
checkLSD - > setChecked ( false ) ;
checkUPnP - > setEnabled ( false ) ;
checkUPnP - > setChecked ( false ) ;
} else {
checkDHT - > setEnabled ( true ) ;
checkDifferentDHTPort - > setEnabled ( true ) ;
checkLSD - > setEnabled ( true ) ;
checkUPnP - > setEnabled ( true ) ;
}
}
2013-09-14 13:54:22 +04:00
bool options_imp : : schedTimesOk ( ) {
QString msg ;
if ( schedule_from - > time ( ) = = schedule_to - > time ( ) )
msg = tr ( " The start time and the end time can't be the same. " ) ;
if ( ! msg . isEmpty ( ) ) {
QMessageBox : : critical ( this , tr ( " Time Error " ) , msg ) ;
return false ;
}
return true ;
}