Browse Source

Started to simplify program preferences (merged UPnP/NAT-PMP)

adaptive-webui-19844
Christophe Dumez 14 years ago
parent
commit
3feffdf8fa
  1. 3
      Changelog
  2. 2
      src/Icons/qBittorrent.desktop
  3. 2
      src/Info.plist
  4. 27
      src/preferences/options.ui
  5. 7
      src/preferences/options_imp.cpp
  6. 1
      src/preferences/options_imp.h
  7. 8
      src/preferences/preferences.h
  8. 38
      src/qtlibtorrent/qbtsession.cpp
  9. 2
      src/qtlibtorrent/qbtsession.h

3
Changelog

@ -1,3 +1,6 @@
* Unreleased - Christophe Dumez <chris@qbittorrent.org> - v2.6.0
- FEATURE: Simplify program preferences
* Sun Dec 5 2010 - Christophe Dumez <chris@qbittorrent.org> - v2.5.0 * Sun Dec 5 2010 - Christophe Dumez <chris@qbittorrent.org> - v2.5.0
- FEATURE: qBittorrent can now act as a tracker - FEATURE: qBittorrent can now act as a tracker
- FEATURE: New and improved RSS feed automated downloader - FEATURE: New and improved RSS feed automated downloader

2
src/Icons/qBittorrent.desktop

@ -1,6 +1,6 @@
[Desktop Entry] [Desktop Entry]
Categories=Qt;Network;P2P; Categories=Qt;Network;P2P;
Comment=V2.5.0 Comment=V2.6.0
Exec=qbittorrent %f Exec=qbittorrent %f
GenericName=Bittorrent client GenericName=Bittorrent client
GenericName[ar]=العميل Bittorrent GenericName[ar]=العميل Bittorrent

2
src/Info.plist

@ -47,7 +47,7 @@
<key>CFBundlePackageType</key> <key>CFBundlePackageType</key>
<string>APPL</string> <string>APPL</string>
<key>CFBundleGetInfoString</key> <key>CFBundleGetInfoString</key>
<string>2.5.0</string> <string>2.6.0</string>
<key>CFBundleSignature</key> <key>CFBundleSignature</key>
<string>????</string> <string>????</string>
<key>CFBundleExecutable</key> <key>CFBundleExecutable</key>

27
src/preferences/options.ui

@ -941,7 +941,7 @@ QGroupBox {
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>507</width> <width>507</width>
<height>485</height> <height>457</height>
</rect> </rect>
</property> </property>
<layout class="QVBoxLayout" name="verticalLayout_20"> <layout class="QVBoxLayout" name="verticalLayout_20">
@ -1000,17 +1000,7 @@ QGroupBox {
<item> <item>
<widget class="QCheckBox" name="checkUPnP"> <widget class="QCheckBox" name="checkUPnP">
<property name="text"> <property name="text">
<string>Enable UPnP port mapping</string> <string>Use UPnP / NAT-PMP port forwarding from my router</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="checkNATPMP">
<property name="text">
<string>Enable NAT-PMP port mapping</string>
</property> </property>
<property name="checked"> <property name="checked">
<bool>true</bool> <bool>true</bool>
@ -1409,8 +1399,8 @@ QGroupBox {
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>524</width> <width>423</width>
<height>406</height> <height>334</height>
</rect> </rect>
</property> </property>
<layout class="QVBoxLayout" name="verticalLayout_33"> <layout class="QVBoxLayout" name="verticalLayout_33">
@ -2181,8 +2171,8 @@ QGroupBox {
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>524</width> <width>396</width>
<height>406</height> <height>229</height>
</rect> </rect>
</property> </property>
<layout class="QVBoxLayout" name="verticalLayout_23"> <layout class="QVBoxLayout" name="verticalLayout_23">
@ -2344,8 +2334,8 @@ QGroupBox {
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>524</width> <width>98</width>
<height>406</height> <height>28</height>
</rect> </rect>
</property> </property>
<layout class="QVBoxLayout" name="verticalLayout_36"/> <layout class="QVBoxLayout" name="verticalLayout_36"/>
@ -2401,7 +2391,6 @@ QGroupBox {
<tabstop>checkStartPaused</tabstop> <tabstop>checkStartPaused</tabstop>
<tabstop>spinPort</tabstop> <tabstop>spinPort</tabstop>
<tabstop>checkUPnP</tabstop> <tabstop>checkUPnP</tabstop>
<tabstop>checkNATPMP</tabstop>
<tabstop>checkLSD</tabstop> <tabstop>checkLSD</tabstop>
<tabstop>comboEncryption</tabstop> <tabstop>comboEncryption</tabstop>
<tabstop>checkMaxRatio</tabstop> <tabstop>checkMaxRatio</tabstop>

7
src/preferences/options_imp.cpp

@ -144,7 +144,6 @@ options_imp::options_imp(QWidget *parent):QDialog(parent){
// Connection tab // Connection tab
connect(spinPort, SIGNAL(valueChanged(QString)), this, SLOT(enableApplyButton())); connect(spinPort, SIGNAL(valueChanged(QString)), this, SLOT(enableApplyButton()));
connect(checkUPnP, SIGNAL(toggled(bool)), this, SLOT(enableApplyButton())); connect(checkUPnP, SIGNAL(toggled(bool)), this, SLOT(enableApplyButton()));
connect(checkNATPMP, SIGNAL(toggled(bool)), this, SLOT(enableApplyButton()));
connect(checkUploadLimit, SIGNAL(toggled(bool)), this, SLOT(enableApplyButton())); connect(checkUploadLimit, SIGNAL(toggled(bool)), this, SLOT(enableApplyButton()));
connect(checkDownloadLimit, SIGNAL(toggled(bool)), this, SLOT(enableApplyButton())); connect(checkDownloadLimit, SIGNAL(toggled(bool)), this, SLOT(enableApplyButton()));
connect(spinUploadLimit, SIGNAL(valueChanged(QString)), this, SLOT(enableApplyButton())); connect(spinUploadLimit, SIGNAL(valueChanged(QString)), this, SLOT(enableApplyButton()));
@ -359,7 +358,6 @@ void options_imp::saveOptions(){
// Connection preferences // Connection preferences
pref.setSessionPort(getPort()); pref.setSessionPort(getPort());
pref.setUPnPEnabled(isUPnPEnabled()); pref.setUPnPEnabled(isUPnPEnabled());
pref.setNATPMPEnabled(isNATPMPEnabled());
const QPair<int, int> down_up_limit = getGlobalBandwidthLimits(); const QPair<int, int> down_up_limit = getGlobalBandwidthLimits();
pref.setGlobalDownloadLimit(down_up_limit.first); pref.setGlobalDownloadLimit(down_up_limit.first);
pref.setGlobalUploadLimit(down_up_limit.second); pref.setGlobalUploadLimit(down_up_limit.second);
@ -529,7 +527,6 @@ void options_imp::loadOptions(){
// Connection preferences // Connection preferences
spinPort->setValue(pref.getSessionPort()); spinPort->setValue(pref.getSessionPort());
checkUPnP->setChecked(pref.isUPnPEnabled()); checkUPnP->setChecked(pref.isUPnPEnabled());
checkNATPMP->setChecked(pref.isNATPMPEnabled());
intValue = pref.getGlobalDownloadLimit(); intValue = pref.getGlobalDownloadLimit();
if(intValue > 0) { if(intValue > 0) {
// Enabled // Enabled
@ -717,10 +714,6 @@ bool options_imp::isUPnPEnabled() const{
return checkUPnP->isChecked(); return checkUPnP->isChecked();
} }
bool options_imp::isNATPMPEnabled() const{
return checkNATPMP->isChecked();
}
// Return Download & Upload limits in kbps // Return Download & Upload limits in kbps
// [download,upload] // [download,upload]
QPair<int,int> options_imp::getGlobalBandwidthLimits() const{ QPair<int,int> options_imp::getGlobalBandwidthLimits() const{

1
src/preferences/options_imp.h

@ -114,7 +114,6 @@ private:
// Connection options // Connection options
int getPort() const; int getPort() const;
bool isUPnPEnabled() const; bool isUPnPEnabled() const;
bool isNATPMPEnabled() const;
QPair<int,int> getGlobalBandwidthLimits() const; QPair<int,int> getGlobalBandwidthLimits() const;
// Bittorrent options // Bittorrent options
int getMaxConnecs() const; int getMaxConnecs() const;

8
src/preferences/preferences.h

@ -335,14 +335,6 @@ public:
setValue(QString::fromUtf8("Preferences/Connection/UPnP"), enabled); setValue(QString::fromUtf8("Preferences/Connection/UPnP"), enabled);
} }
bool isNATPMPEnabled() const {
return value(QString::fromUtf8("Preferences/Connection/NAT-PMP"), true).toBool();
}
void setNATPMPEnabled(bool enabled) {
setValue(QString::fromUtf8("Preferences/Connection/NAT-PMP"), enabled);
}
int getGlobalDownloadLimit() const { int getGlobalDownloadLimit() const {
return value("Preferences/Connection/GlobalDLLimit", -1).toInt(); return value("Preferences/Connection/GlobalDLLimit", -1).toInt();
} }

38
src/qtlibtorrent/qbtsession.cpp

@ -86,7 +86,7 @@ enum VersionType { NORMAL,ALPHA,BETA,RELEASE_CANDIDATE,DEVEL };
QBtSession::QBtSession() QBtSession::QBtSession()
: m_scanFolders(ScanFoldersModel::instance(this)), : m_scanFolders(ScanFoldersModel::instance(this)),
preAllocateAll(false), addInPause(false), ratio_limit(-1), preAllocateAll(false), addInPause(false), ratio_limit(-1),
UPnPEnabled(false), NATPMPEnabled(false), LSDEnabled(false), UPnPEnabled(false), LSDEnabled(false),
DHTEnabled(false), current_dht_port(0), queueingEnabled(false), DHTEnabled(false), current_dht_port(0), queueingEnabled(false),
torrentExport(false) torrentExport(false)
#ifndef DISABLE_GUI #ifndef DISABLE_GUI
@ -354,21 +354,13 @@ void QBtSession::configureSession() {
} }
} }
#endif #endif
// * UPnP // * UPnP / NAT-PMP
if(pref.isUPnPEnabled()) { if(pref.isUPnPEnabled()) {
enableUPnP(true); enableUPnP(true);
addConsoleMessage(tr("UPnP support [ON]"), QString::fromUtf8("blue")); addConsoleMessage(tr("UPnP / NAT-PMP support [ON]"), QString::fromUtf8("blue"));
} else { } else {
enableUPnP(false); enableUPnP(false);
addConsoleMessage(tr("UPnP support [OFF]"), QString::fromUtf8("blue")); addConsoleMessage(tr("UPnP / NAT-PMP support [OFF]"), QString::fromUtf8("blue"));
}
// * NAT-PMP
if(pref.isNATPMPEnabled()) {
enableNATPMP(true);
addConsoleMessage(tr("NAT-PMP support [ON]"), QString::fromUtf8("blue"));
} else {
enableNATPMP(false);
addConsoleMessage(tr("NAT-PMP support [OFF]"), QString::fromUtf8("blue"));
} }
// * Session settings // * Session settings
session_settings sessionSettings; session_settings sessionSettings;
@ -1307,31 +1299,17 @@ void QBtSession::setMaxUploadsPerTorrent(int max) {
void QBtSession::enableUPnP(bool b) { void QBtSession::enableUPnP(bool b) {
if(b) { if(b) {
if(!UPnPEnabled) { if(!UPnPEnabled) {
qDebug("Enabling UPnP"); qDebug("Enabling UPnP / NAT-PMP");
s->start_upnp(); s->start_upnp();
s->start_natpmp();
UPnPEnabled = true; UPnPEnabled = true;
} }
} else { } else {
if(UPnPEnabled) { if(UPnPEnabled) {
qDebug("Disabling UPnP"); qDebug("Disabling UPnP / NAT-PMP");
s->stop_upnp(); s->stop_upnp();
UPnPEnabled = false;
}
}
}
void QBtSession::enableNATPMP(bool b) {
if(b) {
if(!NATPMPEnabled) {
qDebug("Enabling NAT-PMP");
s->start_natpmp();
NATPMPEnabled = true;
}
} else {
if(NATPMPEnabled) {
qDebug("Disabling NAT-PMP");
s->stop_natpmp(); s->stop_natpmp();
NATPMPEnabled = false; UPnPEnabled = false;
} }
} }
} }

2
src/qtlibtorrent/qbtsession.h

@ -145,7 +145,6 @@ public slots:
void setDownloadLimit(QString hash, long val); void setDownloadLimit(QString hash, long val);
void setUploadLimit(QString hash, long val); void setUploadLimit(QString hash, long val);
void enableUPnP(bool b); void enableUPnP(bool b);
void enableNATPMP(bool b);
void enableLSD(bool b); void enableLSD(bool b);
bool enableDHT(bool b); bool enableDHT(bool b);
#ifdef DISABLE_GUI #ifdef DISABLE_GUI
@ -232,7 +231,6 @@ private:
float ratio_limit; float ratio_limit;
int high_ratio_action; int high_ratio_action;
bool UPnPEnabled; bool UPnPEnabled;
bool NATPMPEnabled;
bool LSDEnabled; bool LSDEnabled;
bool DHTEnabled; bool DHTEnabled;
int current_dht_port; int current_dht_port;

Loading…
Cancel
Save