Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Fix up the advanced settings dialog. Make it more clear whether

UPnP/Static/LAN-only is going to be used. Use a checkbox to enable proxy
since we'll likely never support anything other than socks -- at least,
not anytime soon. Group items in a nicer fashion.
  • Loading branch information...
commit 3b332d6d12746eb40c6c44655ace2a1388450260 1 parent b1210ea
Jeff Mitchell jefferai authored
62 src/ProxyDialog.ui
@@ -29,39 +29,6 @@
29 29 <number>4</number>
30 30 </property>
31 31 <item row="0" column="1">
32   - <layout class="QHBoxLayout" name="horizontalLayout">
33   - <item>
34   - <spacer name="horizontalSpacer">
35   - <property name="orientation">
36   - <enum>Qt::Horizontal</enum>
37   - </property>
38   - <property name="sizeHint" stdset="0">
39   - <size>
40   - <width>40</width>
41   - <height>20</height>
42   - </size>
43   - </property>
44   - </spacer>
45   - </item>
46   - <item>
47   - <widget class="QComboBox" name="typeBox"/>
48   - </item>
49   - <item>
50   - <spacer name="horizontalSpacer_2">
51   - <property name="orientation">
52   - <enum>Qt::Horizontal</enum>
53   - </property>
54   - <property name="sizeHint" stdset="0">
55   - <size>
56   - <width>40</width>
57   - <height>20</height>
58   - </size>
59   - </property>
60   - </spacer>
61   - </item>
62   - </layout>
63   - </item>
64   - <item row="1" column="1">
65 32 <widget class="QLineEdit" name="hostLineEdit">
66 33 <property name="text">
67 34 <string/>
@@ -71,21 +38,21 @@
71 38 </property>
72 39 </widget>
73 40 </item>
74   - <item row="1" column="0">
  41 + <item row="0" column="0">
75 42 <widget class="QLabel" name="hostLabel">
76 43 <property name="text">
77 44 <string>Host</string>
78 45 </property>
79 46 </widget>
80 47 </item>
81   - <item row="2" column="0">
  48 + <item row="1" column="0">
82 49 <widget class="QLabel" name="portLabel">
83 50 <property name="text">
84 51 <string>Port</string>
85 52 </property>
86 53 </widget>
87 54 </item>
88   - <item row="2" column="1">
  55 + <item row="1" column="1">
89 56 <widget class="QSpinBox" name="portSpinBox">
90 57 <property name="minimum">
91 58 <number>1</number>
@@ -98,28 +65,28 @@
98 65 </property>
99 66 </widget>
100 67 </item>
101   - <item row="3" column="1">
  68 + <item row="2" column="1">
102 69 <widget class="QLineEdit" name="userLineEdit">
103 70 <property name="placeholderText">
104 71 <string>Proxy login</string>
105 72 </property>
106 73 </widget>
107 74 </item>
108   - <item row="3" column="0">
  75 + <item row="2" column="0">
109 76 <widget class="QLabel" name="userLabel">
110 77 <property name="text">
111 78 <string>User</string>
112 79 </property>
113 80 </widget>
114 81 </item>
115   - <item row="4" column="0">
  82 + <item row="3" column="0">
116 83 <widget class="QLabel" name="passwordLabel">
117 84 <property name="text">
118 85 <string>Password</string>
119 86 </property>
120 87 </widget>
121 88 </item>
122   - <item row="4" column="1">
  89 + <item row="3" column="1">
123 90 <widget class="QLineEdit" name="passwordLineEdit">
124 91 <property name="echoMode">
125 92 <enum>QLineEdit::Password</enum>
@@ -129,14 +96,7 @@
129 96 </property>
130 97 </widget>
131 98 </item>
132   - <item row="0" column="0">
133   - <widget class="QLabel" name="typeLabel">
134   - <property name="text">
135   - <string>Type</string>
136   - </property>
137   - </widget>
138   - </item>
139   - <item row="5" column="0">
  99 + <item row="4" column="0">
140 100 <widget class="QLabel" name="label">
141 101 <property name="text">
142 102 <string>No Proxy Hosts:
@@ -144,21 +104,21 @@
144 104 </property>
145 105 </widget>
146 106 </item>
147   - <item row="5" column="1">
  107 + <item row="4" column="1">
148 108 <widget class="QLineEdit" name="noHostLineEdit">
149 109 <property name="placeholderText">
150 110 <string>localhost *.example.com (space separated)</string>
151 111 </property>
152 112 </widget>
153 113 </item>
154   - <item row="6" column="0">
  114 + <item row="5" column="0">
155 115 <widget class="QLabel" name="dnsLabel">
156 116 <property name="text">
157 117 <string/>
158 118 </property>
159 119 </widget>
160 120 </item>
161   - <item row="6" column="1">
  121 + <item row="5" column="1">
162 122 <widget class="QCheckBox" name="checkBoxUseProxyForDns">
163 123 <property name="layoutDirection">
164 124 <enum>Qt::RightToLeft</enum>
149 src/SettingsDialog.cpp
@@ -64,6 +64,7 @@ SettingsDialog::SettingsDialog( QWidget *parent )
64 64 , ui( new Ui_StackedSettingsDialog )
65 65 , m_proxySettings( this )
66 66 , m_rejected( false )
  67 + , m_restartRequired( false )
67 68 , m_accountModel( 0 )
68 69 , m_sipSpinner( 0 )
69 70 {
@@ -75,10 +76,28 @@ SettingsDialog::SettingsDialog( QWidget *parent )
75 76
76 77 ui->checkBoxReporter->setChecked( s->crashReporterEnabled() );
77 78 ui->checkBoxHttp->setChecked( s->httpEnabled() );
78   - ui->checkBoxStaticPreferred->setChecked( s->preferStaticHostPort() );
79   - ui->checkBoxUpnp->setChecked( s->externalAddressMode() == TomahawkSettings::Upnp );
80   - ui->checkBoxUpnp->setEnabled( !s->preferStaticHostPort() );
81 79
  80 +
  81 + //Network settings
  82 + TomahawkSettings::ExternalAddressMode mode = TomahawkSettings::instance()->externalAddressMode();
  83 + if ( mode == TomahawkSettings::Lan )
  84 + ui->lanOnlyRadioButton->setChecked( true );
  85 + else if ( mode == TomahawkSettings::Static )
  86 + ui->staticIpRadioButton->setChecked( true );
  87 + else
  88 + ui->upnpRadioButton->setChecked( true );
  89 +
  90 + ui->staticHostNamePortLabel->setEnabled( ui->staticIpRadioButton->isChecked() );
  91 + ui->staticHostName->setEnabled( ui->staticIpRadioButton->isChecked() );
  92 + ui->staticPort->setEnabled( ui->staticIpRadioButton->isChecked() );
  93 + ui->staticHostNameLabel->setEnabled( ui->staticIpRadioButton->isChecked() );
  94 + ui->staticPortLabel->setEnabled( ui->staticIpRadioButton->isChecked() );
  95 +
  96 + bool useProxy = TomahawkSettings::instance()->proxyType() == QNetworkProxy::Socks5Proxy;
  97 + ui->enableProxyCheckBox->setChecked( useProxy );
  98 + ui->proxyButton->setEnabled( useProxy );
  99 +
  100 +
82 101 createIcons();
83 102 #ifdef Q_WS_X11
84 103 ui->listWidget->setFrameShape( QFrame::StyledPanel );
@@ -173,10 +192,13 @@ SettingsDialog::SettingsDialog( QWidget *parent )
173 192 // #endif
174 193
175 194 connect( ui->proxyButton, SIGNAL( clicked() ), SLOT( showProxySettings() ) );
176   - connect( ui->checkBoxStaticPreferred, SIGNAL( toggled(bool) ), SLOT( toggleUpnp(bool) ) );
177   - connect( ui->checkBoxStaticPreferred, SIGNAL( toggled(bool) ), SLOT( requiresRestart() ) );
178   - connect( ui->checkBoxUpnp, SIGNAL( toggled(bool) ), SLOT( requiresRestart() ) );
179   - connect( ui->checkBoxReporter, SIGNAL( toggled(bool) ), SLOT( requiresRestart() ) );
  195 + connect( ui->lanOnlyRadioButton, SIGNAL( toggled(bool) ), SLOT( requiresRestart() ) );
  196 + connect( ui->staticIpRadioButton, SIGNAL( toggled(bool) ), SLOT( requiresRestart() ) );
  197 + connect( ui->upnpRadioButton, SIGNAL( toggled(bool) ), SLOT( requiresRestart() ) );
  198 + connect( ui->lanOnlyRadioButton, SIGNAL( toggled(bool) ), SLOT( toggleRemoteMode() ) );
  199 + connect( ui->staticIpRadioButton, SIGNAL( toggled(bool) ), SLOT( toggleRemoteMode() ) );
  200 + connect( ui->upnpRadioButton, SIGNAL( toggled(bool) ), SLOT( toggleRemoteMode() ) );
  201 + connect( ui->enableProxyCheckBox, SIGNAL( toggled(bool) ), SLOT( toggleProxyEnabled() ) );
180 202 connect( this, SIGNAL( rejected() ), SLOT( onRejected() ) );
181 203
182 204 ui->listWidget->setCurrentRow( 0 );
@@ -194,8 +216,8 @@ SettingsDialog::~SettingsDialog()
194 216
195 217 s->setCrashReporterEnabled( ui->checkBoxReporter->checkState() == Qt::Checked );
196 218 s->setHttpEnabled( ui->checkBoxHttp->checkState() == Qt::Checked );
197   - s->setPreferStaticHostPort( ui->checkBoxStaticPreferred->checkState() == Qt::Checked );
198   - s->setExternalAddressMode( ui->checkBoxUpnp->checkState() == Qt::Checked ? TomahawkSettings::Upnp : TomahawkSettings::Lan );
  219 + s->setProxyType( ui->enableProxyCheckBox->isChecked() ? QNetworkProxy::Socks5Proxy : QNetworkProxy::NoProxy );
  220 + s->setExternalAddressMode( ui->upnpRadioButton->isChecked() ? TomahawkSettings::Upnp : ( ui->lanOnlyRadioButton->isChecked() ? TomahawkSettings::Lan : TomahawkSettings::Static ) );
199 221
200 222 s->setExternalHostname( ui->staticHostName->text() );
201 223 s->setExternalPort( ui->staticPort->value() );
@@ -209,10 +231,31 @@ SettingsDialog::~SettingsDialog()
209 231
210 232 s->applyChanges();
211 233 s->sync();
  234 +
  235 + if ( m_restartRequired )
  236 + QMessageBox::information( this, tr( "Information" ), tr( "Some changed settings will not take effect until Tomahawk is restarted" ) );
  237 +
  238 + TomahawkUtils::NetworkProxyFactory* proxyFactory = TomahawkUtils::proxyFactory();
  239 + if ( !ui->enableProxyCheckBox->isChecked() )
  240 + {
  241 + tDebug() << Q_FUNC_INFO << "Got NoProxy selected";
  242 + proxyFactory->setProxy( QNetworkProxy::NoProxy );
  243 + }
  244 + else
  245 + {
  246 + tDebug() << Q_FUNC_INFO << "Got Socks5Proxy selected";
  247 + proxyFactory->setProxy( QNetworkProxy( QNetworkProxy::Socks5Proxy, s->proxyHost(), s->proxyPort(), s->proxyUsername(), s->proxyPassword() ) );
  248 + if ( !s->proxyNoProxyHosts().isEmpty() )
  249 + {
  250 + tDebug() << Q_FUNC_INFO << "noproxy hosts:" << s->proxyNoProxyHosts();
  251 + tDebug() << Q_FUNC_INFO << "split noproxy line edit is " << s->proxyNoProxyHosts().split( ' ', QString::SkipEmptyParts );
  252 + proxyFactory->setNoProxyHosts( s->proxyNoProxyHosts().split( ' ', QString::SkipEmptyParts ) );
  253 + }
  254 + }
212 255 }
213 256 else
214 257 qDebug() << "Settings dialog cancelled, NOT saving prefs.";
215   -
  258 +
216 259 delete ui;
217 260 }
218 261
@@ -313,12 +356,20 @@ SettingsDialog::showProxySettings()
313 356
314 357
315 358 void
316   -SettingsDialog::toggleUpnp( bool preferStaticEnabled )
  359 +SettingsDialog::toggleRemoteMode()
317 360 {
318   - if ( preferStaticEnabled )
319   - ui->checkBoxUpnp->setEnabled( false );
320   - else
321   - ui->checkBoxUpnp->setEnabled( true );
  361 + ui->staticHostNamePortLabel->setEnabled( ui->staticIpRadioButton->isChecked() );
  362 + ui->staticHostName->setEnabled( ui->staticIpRadioButton->isChecked() );
  363 + ui->staticPort->setEnabled( ui->staticIpRadioButton->isChecked() );
  364 + ui->staticHostNameLabel->setEnabled( ui->staticIpRadioButton->isChecked() );
  365 + ui->staticPortLabel->setEnabled( ui->staticIpRadioButton->isChecked() );
  366 +}
  367 +
  368 +
  369 +void
  370 +SettingsDialog::toggleProxyEnabled()
  371 +{
  372 + ui->proxyButton->setEnabled( ui->enableProxyCheckBox->isChecked() );
322 373 }
323 374
324 375
@@ -422,7 +473,7 @@ SettingsDialog::scrollTo( const QModelIndex& idx )
422 473 void
423 474 SettingsDialog::requiresRestart()
424 475 {
425   - QMessageBox::information( this, tr( "Information" ), tr( "Changing this setting requires a restart of Tomahawk!" ) );
  476 + m_restartRequired = true;
426 477 }
427 478
428 479
@@ -434,58 +485,14 @@ ProxyDialog::ProxyDialog( QWidget *parent )
434 485
435 486 // ugly, I know, but...
436 487
437   - int i = 0;
438   - ui->typeBox->insertItem( i, "No Proxy", QNetworkProxy::NoProxy );
439   - m_forwardMap[ QNetworkProxy::NoProxy ] = i;
440   - m_backwardMap[ i ] = QNetworkProxy::NoProxy;
441   - i++;
442   - ui->typeBox->insertItem( i, "SOCKS 5", QNetworkProxy::Socks5Proxy );
443   - m_forwardMap[ QNetworkProxy::Socks5Proxy ] = i;
444   - m_backwardMap[ i ] = QNetworkProxy::Socks5Proxy;
445   - i++;
446   -
447 488 TomahawkSettings* s = TomahawkSettings::instance();
448 489
449   - ui->typeBox->setCurrentIndex( m_forwardMap[s->proxyType()] );
450 490 ui->hostLineEdit->setText( s->proxyHost() );
451 491 ui->portSpinBox->setValue( s->proxyPort() );
452 492 ui->userLineEdit->setText( s->proxyUsername() );
453 493 ui->passwordLineEdit->setText( s->proxyPassword() );
454 494 ui->checkBoxUseProxyForDns->setChecked( s->proxyDns() );
455 495 ui->noHostLineEdit->setText( s->proxyNoProxyHosts() );
456   -
457   - if ( s->proxyType() == QNetworkProxy::NoProxy )
458   - {
459   - ui->hostLineEdit->setEnabled( false );
460   - ui->portSpinBox->setEnabled( false );
461   - ui->userLineEdit->setEnabled( false );
462   - ui->passwordLineEdit->setEnabled( false );
463   - ui->checkBoxUseProxyForDns->setEnabled( false );
464   - }
465   -
466   - connect( ui->typeBox, SIGNAL( currentIndexChanged( int ) ), SLOT( proxyTypeChangedSlot( int ) ) );
467   -}
468   -
469   -
470   -void
471   -ProxyDialog::proxyTypeChangedSlot( int index )
472   -{
473   - if ( m_backwardMap[ index ] == QNetworkProxy::NoProxy )
474   - {
475   - ui->hostLineEdit->setEnabled( false );
476   - ui->portSpinBox->setEnabled( false );
477   - ui->userLineEdit->setEnabled( false );
478   - ui->passwordLineEdit->setEnabled( false );
479   - ui->checkBoxUseProxyForDns->setEnabled( false );
480   - }
481   - else
482   - {
483   - ui->hostLineEdit->setEnabled( true );
484   - ui->portSpinBox->setEnabled( true );
485   - ui->userLineEdit->setEnabled( true );
486   - ui->passwordLineEdit->setEnabled( true );
487   - ui->checkBoxUseProxyForDns->setEnabled( true );
488   - }
489 496 }
490 497
491 498
@@ -494,8 +501,6 @@ ProxyDialog::saveSettings()
494 501 {
495 502 qDebug() << Q_FUNC_INFO;
496 503
497   - QNetworkProxy::ProxyType type = static_cast< QNetworkProxy::ProxyType>( m_backwardMap[ ui->typeBox->currentIndex() ] );
498   -
499 504 //First set settings
500 505 TomahawkSettings* s = TomahawkSettings::instance();
501 506 s->setProxyHost( ui->hostLineEdit->text() );
@@ -505,26 +510,6 @@ ProxyDialog::saveSettings()
505 510 s->setProxyNoProxyHosts( ui->noHostLineEdit->text() );
506 511 s->setProxyUsername( ui->userLineEdit->text() );
507 512 s->setProxyPassword( ui->passwordLineEdit->text() );
508   - s->setProxyType( type );
509 513 s->setProxyDns( ui->checkBoxUseProxyForDns->checkState() == Qt::Checked );
510 514 s->sync();
511   -
512   - TomahawkUtils::NetworkProxyFactory* proxyFactory = TomahawkUtils::proxyFactory();
513   - tDebug() << Q_FUNC_INFO << "Got proxyFactory: " << proxyFactory;
514   - if ( type == QNetworkProxy::NoProxy )
515   - {
516   - tDebug() << Q_FUNC_INFO << "Got NoProxy selected";
517   - proxyFactory->setProxy( QNetworkProxy::NoProxy );
518   - }
519   - else
520   - {
521   - tDebug() << Q_FUNC_INFO << "Got Socks5Proxy selected";
522   - proxyFactory->setProxy( QNetworkProxy( type, s->proxyHost(), s->proxyPort(), s->proxyUsername(), s->proxyPassword() ) );
523   - if ( !ui->noHostLineEdit->text().isEmpty() )
524   - {
525   - tDebug() << Q_FUNC_INFO << "noproxy line edit is " << ui->noHostLineEdit->text();
526   - tDebug() << Q_FUNC_INFO << "split noproxy line edit is " << ui->noHostLineEdit->text().split( ' ', QString::SkipEmptyParts );
527   - proxyFactory->setNoProxyHosts( ui->noHostLineEdit->text().split( ' ', QString::SkipEmptyParts ) );
528   - }
529   - }
530 515 }
9 src/SettingsDialog.h
@@ -61,13 +61,8 @@ Q_OBJECT
61 61
62 62 void saveSettings();
63 63
64   -private slots:
65   - void proxyTypeChangedSlot( int index );
66   -
67 64 private:
68 65 Ui::ProxyDialog* ui;
69   - QHash<int,int> m_forwardMap;
70   - QHash<int,int> m_backwardMap;
71 66 };
72 67
73 68 class SettingsDialog : public QDialog
@@ -84,7 +79,8 @@ Q_OBJECT
84 79 private slots:
85 80 void onRejected();
86 81
87   - void toggleUpnp( bool preferStaticEnabled );
  82 + void toggleRemoteMode();
  83 + void toggleProxyEnabled();
88 84 void showProxySettings();
89 85
90 86 void accountsFilterChanged( int );
@@ -110,6 +106,7 @@ private slots:
110 106
111 107 ProxyDialog m_proxySettings;
112 108 bool m_rejected;
  109 + bool m_restartRequired;
113 110 Tomahawk::Accounts::AccountModel* m_accountModel;
114 111 Tomahawk::Accounts::AccountModelFilterProxy* m_accountProxy;
115 112 AnimatedSpinner* m_sipSpinner;
299 src/StackedSettingsDialog.ui
@@ -85,7 +85,7 @@
85 85 <item>
86 86 <widget class="QStackedWidget" name="stackedWidget">
87 87 <property name="currentIndex">
88   - <number>0</number>
  88 + <number>2</number>
89 89 </property>
90 90 <widget class="QWidget" name="accountsPage">
91 91 <layout class="QVBoxLayout" name="verticalLayout_11">
@@ -242,127 +242,103 @@
242 242 </sizepolicy>
243 243 </property>
244 244 <property name="title">
245   - <string>Advanced Network Settings</string>
  245 + <string>Advanced Settings</string>
246 246 </property>
247 247 <layout class="QVBoxLayout" name="verticalLayout_13">
248 248 <property name="margin">
249 249 <number>2</number>
250 250 </property>
251 251 <item>
252   - <layout class="QVBoxLayout" name="staticSettingsLayout">
253   - <item>
254   - <layout class="QHBoxLayout" name="staticPreferredLayout"/>
255   - </item>
256   - <item>
257   - <widget class="QLabel" name="staticHostNamePortLabel">
258   - <property name="sizePolicy">
259   - <sizepolicy hsizetype="Preferred" vsizetype="Fixed">
260   - <horstretch>0</horstretch>
261   - <verstretch>0</verstretch>
262   - </sizepolicy>
263   - </property>
264   - <property name="text">
265   - <string>If you're having difficulty connecting to peers, try setting this to your external IP address/host name and a port number (default 50210). Make sure to forward that port to this machine!</string>
266   - </property>
267   - <property name="wordWrap">
268   - <bool>true</bool>
269   - </property>
270   - </widget>
271   - </item>
272   - <item>
273   - <layout class="QHBoxLayout" name="staticHostNamePortLayout">
274   - <item>
275   - <widget class="QLabel" name="staticHostNameLabel">
276   - <property name="sizePolicy">
277   - <sizepolicy hsizetype="Preferred" vsizetype="Fixed">
278   - <horstretch>0</horstretch>
279   - <verstretch>0</verstretch>
280   - </sizepolicy>
281   - </property>
282   - <property name="text">
283   - <string>Static Host Name:</string>
284   - </property>
285   - </widget>
286   - </item>
287   - <item>
288   - <widget class="QLineEdit" name="staticHostName"/>
289   - </item>
290   - <item>
291   - <widget class="QLabel" name="staticPortLabel">
292   - <property name="sizePolicy">
293   - <sizepolicy hsizetype="Preferred" vsizetype="Fixed">
294   - <horstretch>0</horstretch>
295   - <verstretch>0</verstretch>
296   - </sizepolicy>
297   - </property>
298   - <property name="text">
299   - <string>Static Port:</string>
300   - </property>
301   - </widget>
302   - </item>
303   - <item>
304   - <widget class="QSpinBox" name="staticPort">
305   - <property name="maximum">
306   - <number>65535</number>
307   - </property>
308   - <property name="value">
309   - <number>50210</number>
310   - </property>
311   - </widget>
312   - </item>
313   - </layout>
314   - </item>
315   - <item>
316   - <widget class="QCheckBox" name="checkBoxStaticPreferred">
317   - <property name="layoutDirection">
318   - <enum>Qt::RightToLeft</enum>
319   - </property>
320   - <property name="text">
321   - <string>Always use static host name/port? (Overrides UPnP discovery/port forwarding)</string>
322   - </property>
323   - </widget>
324   - </item>
325   - </layout>
326   - </item>
327   - <item>
328   - <layout class="QHBoxLayout" name="proxySettingsHLayout">
329   - <item>
330   - <spacer name="proxySettingsLeftSpacer">
331   - <property name="orientation">
332   - <enum>Qt::Horizontal</enum>
333   - </property>
334   - <property name="sizeHint" stdset="0">
335   - <size>
336   - <width>40</width>
337   - <height>20</height>
338   - </size>
339   - </property>
340   - </spacer>
341   - </item>
342   - <item>
343   - <widget class="QPushButton" name="proxyButton">
344   - <property name="text">
345   - <string>Proxy Settings...</string>
346   - </property>
347   - </widget>
348   - </item>
349   - <item>
350   - <spacer name="proxySettingsRightSpacer">
351   - <property name="orientation">
352   - <enum>Qt::Horizontal</enum>
353   - </property>
354   - <property name="sizeHint" stdset="0">
355   - <size>
356   - <width>40</width>
357   - <height>20</height>
358   - </size>
359   - </property>
360   - </spacer>
361   - </item>
362   - </layout>
  252 + <widget class="QGroupBox" name="remoteConnectionsGroupBox">
  253 + <property name="title">
  254 + <string>Remote Peer Connection Method</string>
  255 + </property>
  256 + <layout class="QVBoxLayout" name="verticalLayout_6">
  257 + <item>
  258 + <widget class="QRadioButton" name="lanOnlyRadioButton">
  259 + <property name="text">
  260 + <string>None (outgoing connections only)</string>
  261 + </property>
  262 + </widget>
  263 + </item>
  264 + <item>
  265 + <widget class="QRadioButton" name="upnpRadioButton">
  266 + <property name="text">
  267 + <string>Use UPnP to establish port forward (recommended)</string>
  268 + </property>
  269 + </widget>
  270 + </item>
  271 + <item>
  272 + <widget class="QRadioButton" name="staticIpRadioButton">
  273 + <property name="text">
  274 + <string>Use static external IP address/host name and port</string>
  275 + </property>
  276 + </widget>
  277 + </item>
  278 + <item>
  279 + <widget class="QLabel" name="staticHostNamePortLabel">
  280 + <property name="sizePolicy">
  281 + <sizepolicy hsizetype="Preferred" vsizetype="Fixed">
  282 + <horstretch>0</horstretch>
  283 + <verstretch>0</verstretch>
  284 + </sizepolicy>
  285 + </property>
  286 + <property name="text">
  287 + <string>Set this to your external IP address or host name. Make sure to forward the port to this host!</string>
  288 + </property>
  289 + <property name="wordWrap">
  290 + <bool>true</bool>
  291 + </property>
  292 + </widget>
  293 + </item>
  294 + <item>
  295 + <layout class="QHBoxLayout" name="staticHostNamePortLayout">
  296 + <item>
  297 + <widget class="QLabel" name="staticHostNameLabel">
  298 + <property name="sizePolicy">
  299 + <sizepolicy hsizetype="Preferred" vsizetype="Fixed">
  300 + <horstretch>0</horstretch>
  301 + <verstretch>0</verstretch>
  302 + </sizepolicy>
  303 + </property>
  304 + <property name="text">
  305 + <string>Static Host Name:</string>
  306 + </property>
  307 + </widget>
  308 + </item>
  309 + <item>
  310 + <widget class="QLineEdit" name="staticHostName"/>
  311 + </item>
  312 + <item>
  313 + <widget class="QLabel" name="staticPortLabel">
  314 + <property name="sizePolicy">
  315 + <sizepolicy hsizetype="Preferred" vsizetype="Fixed">
  316 + <horstretch>0</horstretch>
  317 + <verstretch>0</verstretch>
  318 + </sizepolicy>
  319 + </property>
  320 + <property name="text">
  321 + <string>Static Port:</string>
  322 + </property>
  323 + </widget>
  324 + </item>
  325 + <item>
  326 + <widget class="QSpinBox" name="staticPort">
  327 + <property name="maximum">
  328 + <number>65535</number>
  329 + </property>
  330 + <property name="value">
  331 + <number>50210</number>
  332 + </property>
  333 + </widget>
  334 + </item>
  335 + </layout>
  336 + </item>
  337 + </layout>
  338 + </widget>
363 339 </item>
364 340 <item>
365   - <spacer name="verticalSpacer_5">
  341 + <spacer name="verticalSpacer">
366 342 <property name="orientation">
367 343 <enum>Qt::Vertical</enum>
368 344 </property>
@@ -375,43 +351,88 @@
375 351 </spacer>
376 352 </item>
377 353 <item>
378   - <widget class="QCheckBox" name="checkBoxReporter">
379   - <property name="layoutDirection">
380   - <enum>Qt::RightToLeft</enum>
381   - </property>
382   - <property name="text">
383   - <string>Send reports after Tomahawk crashed</string>
384   - </property>
385   - <property name="checked">
386   - <bool>true</bool>
  354 + <widget class="QGroupBox" name="proxyGroupBox">
  355 + <property name="title">
  356 + <string>SOCKS Proxy</string>
387 357 </property>
  358 + <layout class="QHBoxLayout" name="horizontalLayout_3">
  359 + <item>
  360 + <widget class="QCheckBox" name="enableProxyCheckBox">
  361 + <property name="text">
  362 + <string>Use SOCKS Proxy</string>
  363 + </property>
  364 + </widget>
  365 + </item>
  366 + <item>
  367 + <widget class="QPushButton" name="proxyButton">
  368 + <property name="text">
  369 + <string>Proxy Settings...</string>
  370 + </property>
  371 + </widget>
  372 + </item>
  373 + </layout>
388 374 </widget>
389 375 </item>
390 376 <item>
391   - <widget class="QCheckBox" name="checkBoxHttp">
392   - <property name="layoutDirection">
393   - <enum>Qt::RightToLeft</enum>
  377 + <spacer name="verticalSpacer_2">
  378 + <property name="orientation">
  379 + <enum>Qt::Vertical</enum>
394 380 </property>
395   - <property name="text">
396   - <string>Allow web browsers to interact with Tomahawk (recommended)</string>
  381 + <property name="sizeHint" stdset="0">
  382 + <size>
  383 + <width>20</width>
  384 + <height>40</height>
  385 + </size>
397 386 </property>
398   - <property name="checked">
399   - <bool>true</bool>
  387 + </spacer>
  388 + </item>
  389 + <item>
  390 + <widget class="QGroupBox" name="otherSettingsGroupBox">
  391 + <property name="title">
  392 + <string>Other Settings</string>
400 393 </property>
  394 + <layout class="QVBoxLayout" name="verticalLayout_2">
  395 + <item>
  396 + <widget class="QCheckBox" name="checkBoxHttp">
  397 + <property name="layoutDirection">
  398 + <enum>Qt::RightToLeft</enum>
  399 + </property>
  400 + <property name="text">
  401 + <string>Allow web browsers to interact with Tomahawk (recommended)</string>
  402 + </property>
  403 + <property name="checked">
  404 + <bool>true</bool>
  405 + </property>
  406 + </widget>
  407 + </item>
  408 + <item>
  409 + <widget class="QCheckBox" name="checkBoxReporter">
  410 + <property name="layoutDirection">
  411 + <enum>Qt::RightToLeft</enum>
  412 + </property>
  413 + <property name="text">
  414 + <string>Send reports after Tomahawk crashed</string>
  415 + </property>
  416 + <property name="checked">
  417 + <bool>true</bool>
  418 + </property>
  419 + </widget>
  420 + </item>
  421 + </layout>
401 422 </widget>
402 423 </item>
403 424 <item>
404   - <widget class="QCheckBox" name="checkBoxUpnp">
405   - <property name="layoutDirection">
406   - <enum>Qt::RightToLeft</enum>
407   - </property>
408   - <property name="text">
409   - <string>Use UPnP to establish port forward</string>
  425 + <spacer name="verticalSpacer_4">
  426 + <property name="orientation">
  427 + <enum>Qt::Vertical</enum>
410 428 </property>
411   - <property name="checked">
412   - <bool>true</bool>
  429 + <property name="sizeHint" stdset="0">
  430 + <size>
  431 + <width>20</width>
  432 + <height>40</height>
  433 + </size>
413 434 </property>
414   - </widget>
  435 + </spacer>
415 436 </item>
416 437 </layout>
417 438 </widget>
2  src/TomahawkApp.cpp
@@ -562,7 +562,7 @@ TomahawkApp::initServent()
562 562 {
563 563 tDebug() << "Init Servent.";
564 564
565   - bool upnp = !arguments().contains( "--noupnp" ) && TomahawkSettings::instance()->value( "network/upnp", true ).toBool() && !TomahawkSettings::instance()->preferStaticHostPort();
  565 + bool upnp = !arguments().contains( "--noupnp" );
566 566 int port = TomahawkSettings::instance()->externalPort();
567 567 if ( !Servent::instance()->startListening( QHostAddress( QHostAddress::Any ), upnp, port ) )
568 568 {
19 src/libtomahawk/TomahawkSettings.cpp
@@ -1048,8 +1048,13 @@ TomahawkSettings::removeAccount( const QString& accountId )
1048 1048
1049 1049
1050 1050 TomahawkSettings::ExternalAddressMode
1051   -TomahawkSettings::externalAddressMode() const
  1051 +TomahawkSettings::externalAddressMode()
1052 1052 {
  1053 + if ( value( "network/prefer-static-host-and-port", false ).toBool() )
  1054 + {
  1055 + remove( "network/prefer-static-host-and-port" );
  1056 + setValue( "network/external-address-mode", TomahawkSettings::Static );
  1057 + }
1053 1058 return (TomahawkSettings::ExternalAddressMode) value( "network/external-address-mode", TomahawkSettings::Upnp ).toInt();
1054 1059 }
1055 1060
@@ -1061,18 +1066,6 @@ TomahawkSettings::setExternalAddressMode( ExternalAddressMode externalAddressMod
1061 1066 }
1062 1067
1063 1068
1064   -bool TomahawkSettings::preferStaticHostPort() const
1065   -{
1066   - return value( "network/prefer-static-host-and-port", false ).toBool();
1067   -}
1068   -
1069   -
1070   -void TomahawkSettings::setPreferStaticHostPort( bool prefer )
1071   -{
1072   - setValue( "network/prefer-static-host-and-port", prefer );
1073   -}
1074   -
1075   -
1076 1069 QString
1077 1070 TomahawkSettings::externalHostname() const
1078 1071 {
7 src/libtomahawk/TomahawkSettings.h
@@ -123,13 +123,10 @@ Q_OBJECT
123 123 QString bookmarkPlaylist() const;
124 124
125 125 /// Network settings
126   - enum ExternalAddressMode { Lan, Upnp };
127   - ExternalAddressMode externalAddressMode() const;
  126 + enum ExternalAddressMode { Lan, Upnp, Static };
  127 + ExternalAddressMode externalAddressMode();
128 128 void setExternalAddressMode( ExternalAddressMode externalAddressMode );
129 129
130   - bool preferStaticHostPort() const;
131   - void setPreferStaticHostPort( bool prefer );
132   -
133 130 bool httpEnabled() const; /// true by default
134 131 void setHttpEnabled( bool enable );
135 132
45 src/libtomahawk/network/Servent.cpp
@@ -118,30 +118,31 @@ Servent::startListening( QHostAddress ha, bool upnp, int port )
118 118 }
119 119 }
120 120
  121 + TomahawkSettings::ExternalAddressMode mode = TomahawkSettings::instance()->externalAddressMode();
  122 +
121 123 tLog() << "Servent listening on port" << m_port << "- servent thread:" << thread()
122   - << "- address mode:" << (int)( TomahawkSettings::instance()->externalAddressMode() );
  124 + << "- address mode:" << (int)( mode );
123 125
124 126 // --lanhack means to advertise your LAN IP as if it were externally visible
125   - if ( TomahawkSettings::instance()->preferStaticHostPort() )
126   - {
127   - m_externalHostname = TomahawkSettings::instance()->externalHostname();
128   - m_externalPort = TomahawkSettings::instance()->externalPort();
129   - m_ready = true;
130   - emit ready();
131   - return true;
132   - }
133   -
134   - TomahawkSettings::ExternalAddressMode mode = TomahawkSettings::instance()->externalAddressMode();
135   - if ( mode == TomahawkSettings::Upnp && !upnp )
136   - mode = TomahawkSettings::Lan;
137   -
138 127 switch ( mode )
139 128 {
  129 + case TomahawkSettings::Static:
  130 + m_externalHostname = TomahawkSettings::instance()->externalHostname();
  131 + m_externalPort = TomahawkSettings::instance()->externalPort();
  132 + m_ready = true;
  133 + emit ready();
  134 + break;
  135 +
140 136 case TomahawkSettings::Lan:
141 137 setInternalAddress();
142 138 break;
143 139
144 140 case TomahawkSettings::Upnp:
  141 + if ( !upnp )
  142 + {
  143 + setInternalAddress();
  144 + break;
  145 + }
145 146 // TODO check if we have a public/internet IP on this machine directly
146 147 tLog() << "External address mode set to upnp...";
147 148 m_portfwd = new PortFwdThread( m_port );
@@ -221,19 +222,9 @@ Servent::setExternalAddress( QHostAddress ha, unsigned int port )
221 222
222 223 if ( m_externalPort == 0 || !isValidExternalIP( ha ) )
223 224 {
224   - if ( !TomahawkSettings::instance()->externalHostname().isEmpty() &&
225   - !TomahawkSettings::instance()->externalPort() == 0 )
226   - {
227   - m_externalHostname = TomahawkSettings::instance()->externalHostname();
228   - m_externalPort = TomahawkSettings::instance()->externalPort();
229   - tDebug() << "UPnP failed, have external address/port - falling back" << m_externalHostname << m_externalPort << m_externalAddress;
230   - }
231   - else
232   - {
233   - tLog() << "No external access, LAN and outbound connections only!";
234   - setInternalAddress();
235   - return;
236   - }
  225 + tLog() << "UPnP failed, LAN and outbound connections only!";
  226 + setInternalAddress();
  227 + return;
237 228 }
238 229
239 230 m_ready = true;

0 comments on commit 3b332d6

Please sign in to comment.
Something went wrong with that request. Please try again.