diff --git a/src/tomahawk/CMakeLists.txt b/src/tomahawk/CMakeLists.txt
index ba1127c30..48a34c2e4 100644
--- a/src/tomahawk/CMakeLists.txt
+++ b/src/tomahawk/CMakeLists.txt
@@ -80,6 +80,7 @@ SET( tomahawkUI ${tomahawkUI}
Settings_Accounts.ui
Settings_Advanced.ui
Settings_Collection.ui
+ HostDialog.ui
ProxyDialog.ui
AudioControls.ui
diff --git a/src/tomahawk/HostDialog.ui b/src/tomahawk/HostDialog.ui
new file mode 100644
index 000000000..e1a354793
--- /dev/null
+++ b/src/tomahawk/HostDialog.ui
@@ -0,0 +1,161 @@
+
+
+ HostDialog
+
+
+ Qt::WindowModal
+
+
+
+ 0
+ 0
+ 585
+ 170
+
+
+
+ Host Settings
+
+
+
+ -1
+
+
+ 2
+
+ -
+
+
+
+ 0
+ 0
+
+
+
+ Configure your external IP address or host name here. Make sure to manually forward the selected port to this host on your router.
+
+
+ true
+
+
+
+ -
+
+
-
+
+
+
+ 0
+ 0
+
+
+
+ Static Host Name:
+
+
+
+ -
+
+
+ -
+
+
+
+ 0
+ 0
+
+
+
+ Static Port:
+
+
+
+ -
+
+
+ 65535
+
+
+ 50210
+
+
+
+
+
+ -
+
+
-
+
+
+ Qt::Horizontal
+
+
+ QSizePolicy::Expanding
+
+
+
+ 40
+ 20
+
+
+
+
+ -
+
+
+ Automatically detect external IP address
+
+
+
+
+
+ -
+
+
+ Qt::Horizontal
+
+
+ QDialogButtonBox::Cancel|QDialogButtonBox::Ok
+
+
+
+
+ buttonBox
+ staticHostNamePortLabel
+
+
+
+
+ buttonBox
+ accepted()
+ HostDialog
+ accept()
+
+
+ 248
+ 254
+
+
+ 157
+ 274
+
+
+
+
+ buttonBox
+ rejected()
+ HostDialog
+ reject()
+
+
+ 316
+ 260
+
+
+ 286
+ 274
+
+
+
+
+
diff --git a/src/tomahawk/SettingsDialog.cpp b/src/tomahawk/SettingsDialog.cpp
index f99fd3290..cb37e0a46 100644
--- a/src/tomahawk/SettingsDialog.cpp
+++ b/src/tomahawk/SettingsDialog.cpp
@@ -3,7 +3,7 @@
* Copyright 2010-2013, Christian Muehlhaeuser
* Copyright 2010-2011, Leo Franchi
* Copyright 2010-2012, Jeff Mitchell
- * Copyright 2012, Teo Mrnjavac
+ * Copyright 2012-2014, Teo Mrnjavac
*
* Tomahawk is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -20,6 +20,7 @@
*/
#include "SettingsDialog.h"
+#include "ui_HostDialog.h"
#include "ui_ProxyDialog.h"
#include "ui_Settings_Accounts.h"
#include "ui_Settings_Collection.h"
@@ -77,6 +78,7 @@ SettingsDialog::SettingsDialog(QObject *parent )
, m_collectionWidget( new QWidget )
, m_advancedWidgetUi( new Ui_Settings_Advanced )
, m_advancedWidget( new QWidget )
+ , m_staticHostSettings( 0 )
, m_proxySettings( 0 )
, m_restartRequired( false )
, m_accountModel( 0 )
@@ -106,11 +108,7 @@ SettingsDialog::SettingsDialog(QObject *parent )
else
m_advancedWidgetUi->upnpRadioButton->setChecked( true );
- m_advancedWidgetUi->staticHostNamePortLabel->setEnabled( m_advancedWidgetUi->staticIpRadioButton->isChecked() );
- m_advancedWidgetUi->staticHostName->setEnabled( m_advancedWidgetUi->staticIpRadioButton->isChecked() && !s->autoDetectExternalIp() );
- m_advancedWidgetUi->staticPort->setEnabled( m_advancedWidgetUi->staticIpRadioButton->isChecked() );
- m_advancedWidgetUi->staticHostNameLabel->setEnabled( m_advancedWidgetUi->staticIpRadioButton->isChecked() );
- m_advancedWidgetUi->staticPortLabel->setEnabled( m_advancedWidgetUi->staticIpRadioButton->isChecked() );
+ m_advancedWidgetUi->staticHostSettingsButton->setEnabled( m_advancedWidgetUi->staticIpRadioButton->isChecked() );
bool useProxy = TomahawkSettings::instance()->proxyType() == QNetworkProxy::Socks5Proxy;
m_advancedWidgetUi->enableProxyCheckBox->setChecked( useProxy );
@@ -124,6 +122,9 @@ SettingsDialog::SettingsDialog(QObject *parent )
m_proxySettings.setSizeGripEnabled( true );
QSizeGrip* p = m_proxySettings.findChild< QSizeGrip* >();
p->setFixedSize( 0, 0 );
+ m_staticHostSettings.setSizeGripEnabled( true );
+ p = m_staticHostSettings.findChild< QSizeGrip* >();
+ p->setFixedSize( 0, 0 );
#endif
m_accountsWidgetUi->installFromFileBtn->setText( tr( "Install from file" ) );
@@ -169,10 +170,7 @@ SettingsDialog::SettingsDialog(QObject *parent )
}
// ADVANCED
- m_advancedWidgetUi->staticHostName->setText( s->externalHostname() );
- m_advancedWidgetUi->staticPort->setValue( s->externalPort() );
m_advancedWidgetUi->proxyButton->setVisible( true );
- m_advancedWidgetUi->autoDetectIpCheckBox->setChecked( s->autoDetectExternalIp() );
m_collectionWidgetUi->checkBoxWatchForChanges->setChecked( s->watchForChanges() );
m_collectionWidgetUi->scannerTimeSpinBox->setValue( s->scannerTime() );
@@ -249,6 +247,7 @@ SettingsDialog::SettingsDialog(QObject *parent )
m_dialog->setCurrentIndex( 0 );
+ connect( m_advancedWidgetUi->staticHostSettingsButton, SIGNAL( clicked() ), SLOT( showStaticHostSettings() ) );
connect( m_advancedWidgetUi->proxyButton, SIGNAL( clicked() ), SLOT( showProxySettings() ) );
connect( m_advancedWidgetUi->lanOnlyRadioButton, SIGNAL( toggled( bool ) ), SLOT( requiresRestart() ) );
connect( m_advancedWidgetUi->staticIpRadioButton, SIGNAL( toggled( bool ) ), SLOT( requiresRestart() ) );
@@ -256,7 +255,6 @@ SettingsDialog::SettingsDialog(QObject *parent )
connect( m_advancedWidgetUi->lanOnlyRadioButton, SIGNAL( toggled( bool ) ), SLOT( toggleRemoteMode() ) );
connect( m_advancedWidgetUi->staticIpRadioButton, SIGNAL( toggled( bool ) ), SLOT( toggleRemoteMode() ) );
connect( m_advancedWidgetUi->upnpRadioButton, SIGNAL( toggled( bool ) ), SLOT( toggleRemoteMode() ) );
- connect( m_advancedWidgetUi->autoDetectIpCheckBox, SIGNAL( toggled( bool ) ), SLOT( toggleAutoDetectIp( bool ) ) );
connect( m_advancedWidgetUi->enableProxyCheckBox, SIGNAL( toggled( bool ) ), SLOT( toggleProxyEnabled() ) );
connect( m_advancedWidgetUi->enableProxyCheckBox, SIGNAL( toggled( bool ) ), SLOT( requiresRestart() ) );
@@ -277,10 +275,6 @@ SettingsDialog::saveSettings()
s->setSongChangeNotificationEnabled( m_advancedWidgetUi->checkBoxSongChangeNotifications->checkState() == Qt::Checked );
s->setProxyType( m_advancedWidgetUi->enableProxyCheckBox->isChecked() ? QNetworkProxy::Socks5Proxy : QNetworkProxy::NoProxy );
s->setExternalAddressMode( m_advancedWidgetUi->upnpRadioButton->isChecked() ? Tomahawk::Network::ExternalAddress::Upnp : ( m_advancedWidgetUi->lanOnlyRadioButton->isChecked() ? Tomahawk::Network::ExternalAddress::Lan : Tomahawk::Network::ExternalAddress::Static ) );
- s->setAutoDetectExternalIp( m_advancedWidgetUi->autoDetectIpCheckBox->isChecked() );
-
- s->setExternalHostname( m_advancedWidgetUi->staticHostName->text() );
- s->setExternalPort( m_advancedWidgetUi->staticPort->value() );
QStringList libraryPaths;
for ( int i = 0; i < m_collectionWidgetUi->pathListWidget->count(); i++ )
@@ -375,6 +369,18 @@ SettingsDialog::changeEvent( QEvent *e )
}
+void
+SettingsDialog::showStaticHostSettings()
+{
+ m_staticHostSettings.exec();
+ if ( m_staticHostSettings.result() == QDialog::Accepted )
+ {
+ requiresRestart();
+ m_staticHostSettings.saveSettings();
+ }
+}
+
+
void
SettingsDialog::showProxySettings()
{
@@ -390,11 +396,7 @@ SettingsDialog::showProxySettings()
void
SettingsDialog::toggleRemoteMode()
{
- m_advancedWidgetUi->staticHostNamePortLabel->setEnabled( m_advancedWidgetUi->staticIpRadioButton->isChecked() );
- m_advancedWidgetUi->staticHostName->setEnabled( m_advancedWidgetUi->staticIpRadioButton->isChecked() );
- m_advancedWidgetUi->staticPort->setEnabled( m_advancedWidgetUi->staticIpRadioButton->isChecked() );
- m_advancedWidgetUi->staticHostNameLabel->setEnabled( m_advancedWidgetUi->staticIpRadioButton->isChecked() );
- m_advancedWidgetUi->staticPortLabel->setEnabled( m_advancedWidgetUi->staticIpRadioButton->isChecked() );
+ m_advancedWidgetUi->staticHostSettingsButton->setEnabled( m_advancedWidgetUi->staticIpRadioButton->isChecked() );
}
@@ -405,13 +407,6 @@ SettingsDialog::toggleProxyEnabled()
}
-void
-SettingsDialog::toggleAutoDetectIp( bool checked )
-{
- m_advancedWidgetUi->staticHostName->setEnabled( !checked );
-}
-
-
void
SettingsDialog::addLibraryPath()
{
@@ -600,6 +595,43 @@ SettingsDialog::requiresRestart()
}
+HostDialog::HostDialog( QWidget* parent )
+ : QDialog( parent )
+ , ui( new Ui::HostDialog )
+{
+ ui->setupUi( this );
+
+ TomahawkSettings* s = TomahawkSettings::instance();
+
+ connect( ui->autoDetectIpCheckBox, SIGNAL( toggled( bool ) ),
+ SLOT( toggleAutoDetectIp( bool ) ) );
+
+ ui->staticHostName->setText( s->externalHostname() );
+ ui->staticPort->setValue( s->externalPort() );
+ ui->autoDetectIpCheckBox->setChecked( s->autoDetectExternalIp() );
+}
+
+
+void
+HostDialog::saveSettings()
+{
+ TomahawkSettings* s = TomahawkSettings::instance();
+
+ s->setAutoDetectExternalIp( ui->autoDetectIpCheckBox->isChecked() );
+ s->setExternalHostname( ui->staticHostName->text() );
+ s->setExternalPort( ui->staticPort->value() );
+
+ s->sync();
+}
+
+
+void
+HostDialog::toggleAutoDetectIp( bool checked )
+{
+ ui->staticHostName->setEnabled( !checked );
+}
+
+
ProxyDialog::ProxyDialog( QWidget *parent )
: QDialog( parent )
, ui( new Ui::ProxyDialog )
diff --git a/src/tomahawk/SettingsDialog.h b/src/tomahawk/SettingsDialog.h
index 035940cea..ed687aaa4 100644
--- a/src/tomahawk/SettingsDialog.h
+++ b/src/tomahawk/SettingsDialog.h
@@ -3,7 +3,7 @@
* Copyright 2010-2011, Christian Muehlhaeuser
* Copyright 2010-2011, Leo Franchi
* Copyright 2010-2012, Jeff Mitchell
- * Copyright 2012, Teo Mrnjavac
+ * Copyright 2012-2014, Teo Mrnjavac
*
* Tomahawk is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -39,6 +39,7 @@ class QToolbarTabDialog;
namespace Ui
{
+class HostDialog;
class ProxyDialog;
}
@@ -54,6 +55,24 @@ class AccountModelFilterProxy;
}
}
+
+class HostDialog : public QDialog
+{
+Q_OBJECT
+
+public:
+ explicit HostDialog( QWidget* parent = 0 );
+ ~HostDialog() {}
+
+ void saveSettings();
+
+private slots:
+ void toggleAutoDetectIp( bool checked );
+
+private:
+ Ui::HostDialog* ui;
+};
+
class ProxyDialog : public QDialog
{
Q_OBJECT
@@ -87,7 +106,7 @@ protected:
private slots:
void toggleRemoteMode();
void toggleProxyEnabled();
- void toggleAutoDetectIp( bool checked );
+ void showStaticHostSettings();
void showProxySettings();
void addLibraryPath();
void removeLibraryPath();
@@ -121,6 +140,7 @@ private:
QToolbarTabDialog* m_dialog;
+ HostDialog m_staticHostSettings;
ProxyDialog m_proxySettings;
bool m_restartRequired;
Tomahawk::Accounts::AccountModel* m_accountModel;
diff --git a/src/tomahawk/Settings_Advanced.ui b/src/tomahawk/Settings_Advanced.ui
index 51996a1f9..371d53ab7 100644
--- a/src/tomahawk/Settings_Advanced.ui
+++ b/src/tomahawk/Settings_Advanced.ui
@@ -39,37 +39,30 @@
-
- Use UPnP to establish port forward (recommended)
+ Automatic port forward with UPnP (recommended)
-
-
-
- Use static external IP address/host name and port
+
+
+ 0
-
-
- -
-
-
-
- 0
- 0
-
-
-
- Set this to your external IP address or host name. Make sure to forward the port to this host!
-
-
- true
-
-
-
- -
-
-
-
+
+
+
+ 0
+ 0
+
+
+
+ Manual port forward
+
+
+
+ -
+
0
@@ -77,60 +70,7 @@
- Static Host Name:
-
-
-
- -
-
-
- -
-
-
-
- 0
- 0
-
-
-
- Static Port:
-
-
-
- -
-
-
- 65535
-
-
- 50210
-
-
-
-
-
- -
-
-
-
-
-
- Qt::Horizontal
-
-
- QSizePolicy::Fixed
-
-
-
- 40
- 20
-
-
-
-
- -
-
-
- Automatically detect external IP address
+ Host Settings...