From f7140491cdb11254fc497abb8f615a80a956a3f2 Mon Sep 17 00:00:00 2001 From: Christophe Dumez Date: Tue, 24 Oct 2006 11:28:32 +0000 Subject: [PATCH] - Now user can change DHT port in options - Reworked options window a little --- Changelog | 2 + TODO | 2 - src/GUI.cpp | 7 + src/options.ui | 608 ++++++++++++++++++++++++++------------------ src/options_imp.cpp | 62 ++++- src/options_imp.h | 6 +- 6 files changed, 436 insertions(+), 251 deletions(-) diff --git a/Changelog b/Changelog index 44ebf09b8..b0d841454 100644 --- a/Changelog +++ b/Changelog @@ -2,10 +2,12 @@ - FEATURE: Based on Qt 4.2 - FEATURE: Brand new trayicon from Qt 4.2 - FEATURE: Added a torrent addition dialog + - FEATURE: Allow user to change DHT port - I18N: Added Finnish translation - BUGFIX: Made right click menu work for multiple selection in DL list - COSMETIC: Replaced OSD messages by systray messages - COSMETIC: Displaying save path in torrent properties window + - COSMETIC: Reworked options window a little * Mon Oct 16 2006 - Christophe Dumez - v0.7.1 - I18N: Updated French, Polish, Dutch, Swedish, Slovak translations diff --git a/TODO b/TODO index fd6adac79..bd0d2f696 100644 --- a/TODO +++ b/TODO @@ -31,9 +31,7 @@ - Add upnp port forwarding support - Add Visit qBittorrent website menu entry - Add Report a bug in qBittorrent menu entry -- Popup when adding a torrent (Save path, select files in the torrent...) - Display remaining HD space (check it before adding a new torrent?) - Move novaUpdater to a Thread (probably use downloadThread) to prevent GUI freezing -- Allow user to choose DHT port - Add button : delete from list and Hard drive - Check if there is at least one file in selection (torrent properties) diff --git a/src/GUI.cpp b/src/GUI.cpp index b4383a379..9f29bfa4b 100644 --- a/src/GUI.cpp +++ b/src/GUI.cpp @@ -1690,6 +1690,13 @@ void GUI::configureSession(){ qDebug("Disabling DHT Support"); } } + int dht_port = options->getDHTPort(); + if(dht_port >= 1000){ + struct dht_settings DHTSettings; + DHTSettings.service_port = dht_port; + s->set_dht_settings(DHTSettings); + qDebug("Set DHT Port to %d", dht_port); + } // Apply filtering settings if(options->isFilteringEnabled()){ qDebug("Ip Filter enabled"); diff --git a/src/options.ui b/src/options.ui index c0aa70b50..82c84d2e6 100644 --- a/src/options.ui +++ b/src/options.ui @@ -6,7 +6,7 @@ 0 0 506 - 490 + 491 @@ -75,50 +75,6 @@ 6 - - - - 0 - - - 6 - - - - - Save Path: - - - proxy_username - - - - - - - 0 - - - 6 - - - - - - - - - - - - ... - - - - - - - @@ -200,13 +156,6 @@ - - - - DHT (Trackerless): - - - @@ -423,7 +372,7 @@ - 60000 + 65525 1000 @@ -549,17 +498,81 @@ - - - - Disable DHT (Trackerless) support - - - + + + + Disable DHT (Trackerless) support + + + + + + + DHT configuration + + + + 9 + + + 6 + + + + + 0 + + + 6 + + + + + DHT port: + + + + + + + + 6 + 0 + + + + 65525 + + + 1000 + + + 6881 + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + @@ -620,6 +633,127 @@ + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + Language + + + + 9 + + + 6 + + + + + Localization + + + + 9 + + + 6 + + + + + 0 + + + 6 + + + + + + + + + + + + Language: + + + + + + + + 300 + 25 + + + + QComboBox::AdjustToContents + + + 0 + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + + + + <b>Note:</b> Changes will be applied after qBittorrent is restarted. + + + + + + + <b>Translators note:</b> If qBittorrent is not available in your language, <br/>and if you would like to translate it in your mother tongue, <br/>please contact me (chris@qbittorrent.org). + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + @@ -1007,224 +1141,212 @@ Misc - - - - 0 - 0 - 452 - 66 - + + + 9 - - Localization + + 6 - - - 9 - - - 6 - - - + + + + Display a torrent addition dialog everytime I add a torrent + + + true + + + + + + + false + + + Default save path + + - 0 + 9 6 - - - - - - - - - - Language: - - - - - - - - 300 - 25 - - - - QComboBox::AdjustToContents - - + + 0 - - - - - - Qt::Horizontal + + 6 - - - 40 - 20 - - - + + + + Save Path: + + + proxy_username + + + + + + + 0 + + + 6 + + + + + + + + + + + + ... + + + + + + - - - - - - - 9 - 81 - 466 - 95 - - - - Behaviour - - - - 9 - - - 6 - - - - - Ask for confirmation on exit - - - true - - - - - - - Automatically clear finished downloads - - - true - - - - - - - Go to systray when minimizing window - - - true - - - - - - - - - 10 - 180 - 461 - 67 - - - - Preview program - - - - 9 - - - 6 - - - + + + + + + Behaviour + + - 0 + 9 6 - + - Audio/Video player: + Ask for confirmation on exit + + + true - + + + Automatically clear finished downloads + + + true + + - + - ... + Go to systray when minimizing window + + + true - - - - - - - 10 - 250 - 466 - 100 - - - - Systray Messages - - - - 9 - - - 6 - - - - - Always display systray messages + + + + + + Preview program + + + + 9 - - true + + 6 - - - - - - Display systray messages only when window is hidden + + + + 0 + + + 6 + + + + + Audio/Video player: + + + + + + + + + + ... + + + + + + + + + + + + Systray Messages + + + + 9 - - - - - - Never display systray messages + + 6 - - - - + + + + Always display systray messages + + + true + + + + + + + Display systray messages only when window is hidden + + + + + + + Never display systray messages + + + + + + + diff --git a/src/options_imp.cpp b/src/options_imp.cpp index 70a7586d8..00534c225 100644 --- a/src/options_imp.cpp +++ b/src/options_imp.cpp @@ -34,9 +34,10 @@ options_imp::options_imp(QWidget *parent):QDialog(parent){ setupUi(this); // Setting icons tabWidget->setTabIcon(0, QIcon(QString::fromUtf8(":/Icons/systemtray.png"))); - tabWidget->setTabIcon(1, QIcon(QString::fromUtf8(":/Icons/filter.png"))); - tabWidget->setTabIcon(2, QIcon(QString::fromUtf8(":/Icons/proxy.png"))); - tabWidget->setTabIcon(3, QIcon(QString::fromUtf8(":/Icons/style.png"))); + tabWidget->setTabIcon(1, QIcon(QString::fromUtf8(":/Icons/locale.png"))); + tabWidget->setTabIcon(2, QIcon(QString::fromUtf8(":/Icons/filter.png"))); + tabWidget->setTabIcon(3, QIcon(QString::fromUtf8(":/Icons/proxy.png"))); + tabWidget->setTabIcon(4, QIcon(QString::fromUtf8(":/Icons/style.png"))); lbl_icon_i18n->setPixmap(QPixmap(QString::fromUtf8(":/Icons/locale.png"))); addFilterRange->setIcon(QIcon(QString::fromUtf8(":/Icons/skin/add.png"))); delFilterRange->setIcon(QIcon(QString::fromUtf8(":/Icons/skin/remove.png"))); @@ -105,15 +106,16 @@ options_imp::options_imp(QWidget *parent):QDialog(parent){ // Connect signals / slots connect(disableUPLimit, SIGNAL(stateChanged(int)), this, SLOT(disableUpload(int))); connect(disableDLLimit, SIGNAL(stateChanged(int)), this, SLOT(disableDownload(int))); + connect(disableDHT, SIGNAL(stateChanged(int)), this, SLOT(disableDHTGroup(int))); connect(disableRatio, SIGNAL(stateChanged(int)), this, SLOT(disableShareRatio(int))); connect(activateFilter, SIGNAL(stateChanged(int)), this, SLOT(enableFilter(int))); connect(enableProxy_checkBox, SIGNAL(stateChanged(int)), this, SLOT(enableProxy(int))); connect(enableProxyAuth_checkBox, SIGNAL(stateChanged(int)), this, SLOT(enableProxyAuth(int))); connect(enableScan_checkBox, SIGNAL(stateChanged(int)), this, SLOT(enableDirScan(int))); connect(disableMaxConnec, SIGNAL(stateChanged(int)), this, SLOT(disableMaxConnecLimit(int))); + connect(checkAdditionDialog, SIGNAL(stateChanged(int)), this, SLOT(enableSavePath(int))); // Apply button is activated when a value is changed // Main - connect(txt_savePath, SIGNAL(textChanged(QString)), this, SLOT(enableApplyButton())); connect(spin_download, SIGNAL(valueChanged(QString)), this, SLOT(enableApplyButton())); connect(spin_upload, SIGNAL(valueChanged(QString)), this, SLOT(enableApplyButton())); connect(spin_port_min, SIGNAL(valueChanged(QString)), this, SLOT(enableApplyButton())); @@ -127,6 +129,9 @@ options_imp::options_imp(QWidget *parent):QDialog(parent){ connect(enableScan_checkBox, SIGNAL(stateChanged(int)), this, SLOT(enableApplyButton())); connect(disableMaxConnec, SIGNAL(stateChanged(int)), this, SLOT(enableApplyButton())); connect(disableDHT, SIGNAL(stateChanged(int)), this, SLOT(enableApplyButton())); + connect(spin_dht_port, SIGNAL(valueChanged(QString)), this, SLOT(enableApplyButton())); + // Language + connect(combo_i18n, SIGNAL(currentIndexChanged(int)), this, SLOT(enableApplyButton())); // IPFilter connect(activateFilter, SIGNAL(stateChanged(int)), this, SLOT(enableApplyButton())); connect(filterFile, SIGNAL(textChanged(QString)), this, SLOT(enableApplyButton())); @@ -138,7 +143,8 @@ options_imp::options_imp(QWidget *parent):QDialog(parent){ connect(proxy_username, SIGNAL(textChanged(QString)), this, SLOT(enableApplyButton())); connect(proxy_password, SIGNAL(textChanged(QString)), this, SLOT(enableApplyButton())); // Misc Settings - connect(combo_i18n, SIGNAL(currentIndexChanged(int)), this, SLOT(enableApplyButton())); + connect(checkAdditionDialog, SIGNAL(stateChanged(int)), this, SLOT(enableApplyButton())); + connect(txt_savePath, SIGNAL(textChanged(QString)), this, SLOT(enableApplyButton())); connect(check_goToSysTray, SIGNAL(stateChanged(int)), this, SLOT(enableApplyButton())); connect(clearFinished_checkBox, SIGNAL(stateChanged(int)), this, SLOT(enableApplyButton())); connect(confirmExit_checkBox, SIGNAL(stateChanged(int)), this, SLOT(enableApplyButton())); @@ -227,6 +233,10 @@ bool options_imp::saveOptions(){ optionValue = doc.createTextNode("1"); } tag.appendChild(optionValue); + tag = doc.createElement("DHTPort"); + root.appendChild(tag); + optionValue = doc.createTextNode(misc::toString(getDHTPort()).c_str()); + tag.appendChild(optionValue); if(scanDir->isEnabled()){ tag = doc.createElement("scan_dir"); root.appendChild(tag); @@ -405,8 +415,18 @@ bool options_imp::loadOptions(){ if(!tag.isNull()){ if(tag.text().toInt() == 0){ disableDHT->setChecked(true); + groupDHT->setEnabled(false); }else{ disableDHT->setChecked(false); + groupDHT->setEnabled(true); + } + } + tag = root.firstChildElement("DHTPort"); + if(!tag.isNull()){ + if(tag.text().toInt() < 1000){ + spin_dht_port->setValue(6881); + }else{ + spin_dht_port->setValue(tag.text().toInt()); } } tmp = root.firstChildElement("max_connec").text().toInt(); @@ -510,6 +530,14 @@ std::pair options_imp::getPorts() const{ return std::make_pair(this->spin_port_min->value(), this->spin_port_min->value()); } +int options_imp::getDHTPort() const{ + if(isDHTEnabled()){ + return spin_dht_port->value(); + }else{ + return -1; + } +} + QString options_imp::getPreviewProgram() const{ QString preview_txt = preview_program->text(); preview_txt.trimmed(); @@ -611,6 +639,30 @@ void options_imp::disableDownload(int checkBoxValue){ } } +void options_imp::disableDHTGroup(int checkBoxValue){ + if(checkBoxValue==2){ + //Disable + groupDHT->setEnabled(false); + }else{ + //enable + groupDHT->setEnabled(true); + } +} + +void options_imp::enableSavePath(int checkBoxValue){ + if(checkBoxValue==2){ + //enable + groupSavePath->setEnabled(false); + }else{ + //disable + groupSavePath->setEnabled(true); + } +} + +bool options_imp::useAdditionDialog() const{ + return checkAdditionDialog->isChecked(); +} + void options_imp::disableMaxConnecLimit(int checkBoxValue){ if(checkBoxValue==2){ //Disable diff --git a/src/options_imp.h b/src/options_imp.h index 84affef0c..67457b862 100644 --- a/src/options_imp.h +++ b/src/options_imp.h @@ -46,12 +46,12 @@ class options_imp : public QDialog, private Ui::Dialog{ bool loadOptions(); // Main options std::pair getPorts() const; - QString getSavePath() const; QPair getLimits() const; float getRatio() const; int getMaxConnec() const; QString getScanDir() const; bool isDHTEnabled() const; + int getDHTPort() const; // Filter Settings bool isFilteringEnabled() const; ip_filter getFilter() const; @@ -66,6 +66,8 @@ class options_imp : public QDialog, private Ui::Dialog{ QString getLocale() const; QTranslator translator; // Misc Settings + bool useAdditionDialog() const; + QString getSavePath() const; bool getClearFinishedOnExit() const; bool getGoToSysTrayOnMinimizingWindow() const; bool getConfirmOnExit() const; @@ -84,6 +86,7 @@ class options_imp : public QDialog, private Ui::Dialog{ void on_browsePreview_clicked(); void on_filterBrowse_clicked(); void disableDownload(int checkBoxValue); + void disableDHTGroup(int checkBoxValue); void disableMaxConnecLimit(int); void enableFilter(int checkBoxValue); void disableUpload(int checkBoxValue); @@ -95,6 +98,7 @@ class options_imp : public QDialog, private Ui::Dialog{ void processFilterFile(const QString& filePath=QString()); void enableApplyButton(); void checkPortsLogic(); + void enableSavePath(int checkBoxValue); public slots: void setLocale(QString locale);