@ -49,6 +49,9 @@
# include <QMacStyle>
# include <QMacStyle>
# endif
# endif
# include <time.h>
# include <stdlib.h>
# include "options_imp.h"
# include "options_imp.h"
# include "misc.h"
# include "misc.h"
@ -187,8 +190,7 @@ options_imp::options_imp(QWidget *parent):QDialog(parent){
connect ( checkScanDir , SIGNAL ( stateChanged ( int ) ) , this , SLOT ( enableApplyButton ( ) ) ) ;
connect ( checkScanDir , SIGNAL ( stateChanged ( int ) ) , this , SLOT ( enableApplyButton ( ) ) ) ;
connect ( textScanDir , SIGNAL ( textChanged ( QString ) ) , this , SLOT ( enableApplyButton ( ) ) ) ;
connect ( textScanDir , SIGNAL ( textChanged ( QString ) ) , this , SLOT ( enableApplyButton ( ) ) ) ;
// Connection tab
// Connection tab
connect ( spinPortMin , SIGNAL ( valueChanged ( QString ) ) , this , SLOT ( enableApplyButton ( ) ) ) ;
connect ( spinPort , SIGNAL ( valueChanged ( QString ) ) , this , SLOT ( enableApplyButton ( ) ) ) ;
connect ( spinPortMax , SIGNAL ( valueChanged ( QString ) ) , this , SLOT ( enableApplyButton ( ) ) ) ;
connect ( checkUPnP , SIGNAL ( stateChanged ( int ) ) , this , SLOT ( enableApplyButton ( ) ) ) ;
connect ( checkUPnP , SIGNAL ( stateChanged ( int ) ) , this , SLOT ( enableApplyButton ( ) ) ) ;
connect ( checkNATPMP , SIGNAL ( stateChanged ( int ) ) , this , SLOT ( enableApplyButton ( ) ) ) ;
connect ( checkNATPMP , SIGNAL ( stateChanged ( int ) ) , this , SLOT ( enableApplyButton ( ) ) ) ;
connect ( checkUploadLimit , SIGNAL ( stateChanged ( int ) ) , this , SLOT ( enableApplyButton ( ) ) ) ;
connect ( checkUploadLimit , SIGNAL ( stateChanged ( int ) ) , this , SLOT ( enableApplyButton ( ) ) ) ;
@ -319,8 +321,6 @@ void options_imp::saveOptions(){
QSettings settings ( " qBittorrent " , " qBittorrent " ) ;
QSettings settings ( " qBittorrent " , " qBittorrent " ) ;
// Apply style
// Apply style
useStyle ( ) ;
useStyle ( ) ;
// Check if min port < max port
checkPortsLogic ( ) ;
settings . beginGroup ( " Preferences " ) ;
settings . beginGroup ( " Preferences " ) ;
// General preferences
// General preferences
settings . beginGroup ( " General " ) ;
settings . beginGroup ( " General " ) ;
@ -352,8 +352,7 @@ void options_imp::saveOptions(){
settings . endGroup ( ) ;
settings . endGroup ( ) ;
// Connection preferences
// Connection preferences
settings . beginGroup ( " Connection " ) ;
settings . beginGroup ( " Connection " ) ;
settings . setValue ( QString : : fromUtf8 ( " PortRangeMin " ) , getPorts ( ) . first ) ;
settings . setValue ( QString : : fromUtf8 ( " PortRangeMin " ) , getPort ( ) ) ;
settings . setValue ( QString : : fromUtf8 ( " PortRangeMax " ) , getPorts ( ) . second ) ;
settings . setValue ( QString : : fromUtf8 ( " UPnP " ) , isUPnPEnabled ( ) ) ;
settings . setValue ( QString : : fromUtf8 ( " UPnP " ) , isUPnPEnabled ( ) ) ;
settings . setValue ( QString : : fromUtf8 ( " NAT-PMP " ) , isNATPMPEnabled ( ) ) ;
settings . setValue ( QString : : fromUtf8 ( " NAT-PMP " ) , isNATPMPEnabled ( ) ) ;
settings . setValue ( QString : : fromUtf8 ( " GlobalDLLimit " ) , getGlobalBandwidthLimits ( ) . first ) ;
settings . setValue ( QString : : fromUtf8 ( " GlobalDLLimit " ) , getGlobalBandwidthLimits ( ) . first ) ;
@ -578,10 +577,7 @@ void options_imp::loadOptions(){
settings . endGroup ( ) ;
settings . endGroup ( ) ;
// Connection preferences
// Connection preferences
settings . beginGroup ( " Connection " ) ;
settings . beginGroup ( " Connection " ) ;
spinPortMin - > setValue ( settings . value ( QString : : fromUtf8 ( " PortRangeMin " ) , 6881 ) . toInt ( ) ) ;
spinPort - > setValue ( settings . value ( QString : : fromUtf8 ( " PortRangeMin " ) , 6881 ) . toInt ( ) ) ;
spinPortMax - > setValue ( settings . value ( QString : : fromUtf8 ( " PortRangeMax " ) , 6889 ) . toInt ( ) ) ;
// Check if min port < max port
checkPortsLogic ( ) ;
checkUPnP - > setChecked ( settings . value ( QString : : fromUtf8 ( " UPnP " ) , true ) . toBool ( ) ) ;
checkUPnP - > setChecked ( settings . value ( QString : : fromUtf8 ( " UPnP " ) , true ) . toBool ( ) ) ;
checkNATPMP - > setChecked ( settings . value ( QString : : fromUtf8 ( " NAT-PMP " ) , true ) . toBool ( ) ) ;
checkNATPMP - > setChecked ( settings . value ( QString : : fromUtf8 ( " NAT-PMP " ) , true ) . toBool ( ) ) ;
intValue = settings . value ( QString : : fromUtf8 ( " GlobalDLLimit " ) , - 1 ) . toInt ( ) ;
intValue = settings . value ( QString : : fromUtf8 ( " GlobalDLLimit " ) , - 1 ) . toInt ( ) ;
@ -777,12 +773,19 @@ void options_imp::loadOptions(){
textWebUiPassword - > setText ( settings . value ( " Password " , " " ) . toString ( ) ) ;
textWebUiPassword - > setText ( settings . value ( " Password " , " " ) . toString ( ) ) ;
// End Web UI
// End Web UI
settings . endGroup ( ) ;
settings . endGroup ( ) ;
// Random stuff
srand ( time ( 0 ) ) ;
}
}
// return min & max ports
// return min & max ports
// [min, max]
// [min, max]
std : : pair < unsigned short , unsigned short > options_imp : : getPorts ( ) const {
int options_imp : : getPort ( ) const {
return std : : make_pair ( spinPortMin - > value ( ) , spinPortMax - > value ( ) ) ;
return spinPort - > value ( ) ;
}
void options_imp : : on_randomButton_clicked ( ) {
// Range [1024: 65535]
spinPort - > setValue ( rand ( ) % 64512 + 1024 ) ;
}
}
int options_imp : : getEncryptionSetting ( ) const {
int options_imp : : getEncryptionSetting ( ) const {
@ -1317,15 +1320,6 @@ void options_imp::setLocale(QString locale){
}
}
}
}
// Is called before saving to check if minPort < maxPort
void options_imp : : checkPortsLogic ( ) {
int maxValue = spinPortMax - > value ( ) ;
if ( spinPortMin - > value ( ) > spinPortMax - > value ( ) ) {
spinPortMax - > setValue ( spinPortMin - > value ( ) ) ;
spinPortMin - > setValue ( maxValue ) ;
}
}
// Return scan dir set in options
// Return scan dir set in options
QString options_imp : : getScanDir ( ) const {
QString options_imp : : getScanDir ( ) const {
if ( checkScanDir - > isChecked ( ) ) {
if ( checkScanDir - > isChecked ( ) ) {