Browse Source

new fix for selecting random port when system starts up

adaptive-webui-19844
tungnian lee 12 years ago committed by sledgehammer999
parent
commit
9913484f68
  1. 20
      src/preferences/options.ui
  2. 10
      src/preferences/options_imp.cpp
  3. 4
      src/qtlibtorrent/qbtsession.cpp

20
src/preferences/options.ui

@ -262,16 +262,6 @@ @@ -262,16 +262,6 @@
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="checkRandomPort">
<property name="text">
<string>Use random port to communicate</string>
</property>
<property name="checked">
<bool>false</bool>
</property>
</widget>
</item>
<item>
<widget class="QGroupBox" name="groupBox_7">
<property name="font">
@ -1108,6 +1098,16 @@ @@ -1108,6 +1098,16 @@
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="checkRandomPort">
<property name="text">
<string>Use random port to communicate</string>
</property>
<property name="checked">
<bool>false</bool>
</property>
</widget>
</item>
</layout>
</widget>
</item>

10
src/preferences/options_imp.cpp

@ -133,13 +133,12 @@ options_imp::options_imp(QWidget *parent): @@ -133,13 +133,12 @@ options_imp::options_imp(QWidget *parent):
// Connect signals / slots
connect(comboProxyType, SIGNAL(currentIndexChanged(int)),this, SLOT(enableProxy(int)));
connect(checkAnonymousMode, SIGNAL(toggled(bool)), this, SLOT(toggleAnonymousMode(bool)));
connect(checkRandomPort, SIGNAL(toggled(bool)), spinPort, SLOT(setDisabled(bool)));
// 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()));
// add checkbox for random port
connect(checkRandomPort, 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()));
@ -186,6 +185,7 @@ options_imp::options_imp(QWidget *parent): @@ -186,6 +185,7 @@ options_imp::options_imp(QWidget *parent):
connect(autoRun_txt, SIGNAL(textChanged(QString)), this, SLOT(enableApplyButton()));
// Connection tab
connect(spinPort, SIGNAL(valueChanged(QString)), this, SLOT(enableApplyButton()));
connect(checkRandomPort, SIGNAL(toggled(bool)), this, SLOT(enableApplyButton()));
connect(checkUPnP, SIGNAL(toggled(bool)), this, SLOT(enableApplyButton()));
connect(checkUploadLimit, SIGNAL(toggled(bool)), this, SLOT(enableApplyButton()));
connect(checkDownloadLimit, SIGNAL(toggled(bool)), this, SLOT(enableApplyButton()));
@ -369,8 +369,6 @@ void options_imp::saveOptions() { @@ -369,8 +369,6 @@ void options_imp::saveOptions() {
// General preferences
pref.setLocale(locale);
pref.setAlternatingRowColors(checkAltRowColors->isChecked());
// set random port
pref.setRandomPort(checkRandomPort->isChecked());
pref.setSystrayIntegration(systrayIntegration());
pref.setTrayIconStyle(TrayIcon::Style(comboTrayIcon->currentIndex()));
pref.setCloseToTray(closeToTray());
@ -428,6 +426,7 @@ void options_imp::saveOptions() { @@ -428,6 +426,7 @@ void options_imp::saveOptions() {
// End Downloads preferences
// Connection preferences
pref.setSessionPort(getPort());
pref.setRandomPort(checkRandomPort->isChecked());
pref.setUPnPEnabled(isUPnPEnabled());
const QPair<int, int> down_up_limit = getGlobalBandwidthLimits();
pref.setGlobalDownloadLimit(down_up_limit.first);
@ -544,8 +543,6 @@ void options_imp::loadOptions() { @@ -544,8 +543,6 @@ void options_imp::loadOptions() {
const Preferences pref;
setLocale(pref.getLocale());
checkAltRowColors->setChecked(pref.useAlternatingRowColors());
// get random port
checkRandomPort->setChecked(pref.useRandomPort());
checkShowSystray->setChecked(pref.systrayIntegration());
checkShowSplash->setChecked(!pref.isSlashScreenDisabled());
if (checkShowSystray->isChecked()) {
@ -632,6 +629,7 @@ void options_imp::loadOptions() { @@ -632,6 +629,7 @@ void options_imp::loadOptions() {
// Connection preferences
spinPort->setValue(pref.getSessionPort());
checkUPnP->setChecked(pref.isUPnPEnabled());
checkRandomPort->setChecked(pref.useRandomPort());
intValue = pref.getGlobalDownloadLimit();
if (intValue > 0) {
// Enabled

4
src/qtlibtorrent/qbtsession.cpp

@ -1532,7 +1532,7 @@ void QBtSession::loadSessionState() { @@ -1532,7 +1532,7 @@ void QBtSession::loadSessionState() {
// bdecode
lazy_entry e;
#if LIBTORRENT_VERSION_NUM >= 001600
error_code ec;
libtorrent::error_code ec;
lazy_bdecode(&in[0], &in[0] + in.size(), e, ec);
if (!ec) {
#else
@ -1916,7 +1916,7 @@ void QBtSession::setListeningPort(int port) { @@ -1916,7 +1916,7 @@ void QBtSession::setListeningPort(int port) {
Preferences pref;
std::pair<int,int> ports(port, port);
#if LIBTORRENT_VERSION_NUM >= 001600
error_code ec;
libtorrent::error_code ec;
#endif
const QString iface_name = pref.getNetworkInterface();
if (iface_name.isEmpty()) {

Loading…
Cancel
Save