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 @@ @@ -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
- FEATURE: qBittorrent can now act as a tracker
- FEATURE: New and improved RSS feed automated downloader

2
src/Icons/qBittorrent.desktop

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

2
src/Info.plist

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

27
src/preferences/options.ui

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

7
src/preferences/options_imp.cpp

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

1
src/preferences/options_imp.h

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

8
src/preferences/preferences.h

@ -335,14 +335,6 @@ public: @@ -335,14 +335,6 @@ public:
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 {
return value("Preferences/Connection/GlobalDLLimit", -1).toInt();
}

38
src/qtlibtorrent/qbtsession.cpp

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

2
src/qtlibtorrent/qbtsession.h

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

Loading…
Cancel
Save