mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-03-23 09:19:41 +01:00
Re-add proxy dialog, and add option for using proxy for DNS lookups (or not)
This commit is contained in:
parent
dee9c14579
commit
2fb1c0a817
@ -100,7 +100,17 @@
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<widget class="QLineEdit" name="portLineEdit"/>
|
||||
<widget class="QSpinBox" name="portSpinBox">
|
||||
<property name="minimum">
|
||||
<number>1</number>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<number>65535</number>
|
||||
</property>
|
||||
<property name="value">
|
||||
<number>1080</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="1">
|
||||
<widget class="QLineEdit" name="userLineEdit"/>
|
||||
@ -113,7 +123,7 @@
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="0">
|
||||
<widget class="QLabel" name="passwordLable">
|
||||
<widget class="QLabel" name="passwordLabel">
|
||||
<property name="text">
|
||||
<string>Password</string>
|
||||
</property>
|
||||
@ -133,6 +143,23 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="0">
|
||||
<widget class="QLabel" name="dnsLabel">
|
||||
<property name="text">
|
||||
<string></string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="1">
|
||||
<widget class="QCheckBox" name="checkBoxUseProxyForDns">
|
||||
<property name="layoutDirection">
|
||||
<enum>Qt::RightToLeft</enum>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Use proxy for DNS lookups?</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</widget>
|
||||
|
@ -96,7 +96,7 @@ SettingsDialog::SettingsDialog( QWidget *parent )
|
||||
ui->staticHostName->setText( s->externalHostname() );
|
||||
ui->staticPort->setValue( s->externalPort() );
|
||||
|
||||
ui->proxyButton->setVisible( false );
|
||||
ui->proxyButton->setVisible( true );
|
||||
|
||||
// MUSIC SCANNER
|
||||
//FIXME: MULTIPLECOLLECTIONDIRS
|
||||
@ -375,66 +375,6 @@ SettingsDialog::onLastFmFinished()
|
||||
}
|
||||
|
||||
|
||||
ProxyDialog::ProxyDialog( QWidget *parent )
|
||||
: QDialog( parent )
|
||||
, ui( new Ui::ProxyDialog )
|
||||
{
|
||||
ui->setupUi( this );
|
||||
|
||||
// ugly, I know, but...
|
||||
QHash<int,int> enumMap;
|
||||
int i = 0;
|
||||
ui->typeBox->insertItem( i, "No Proxy", QNetworkProxy::NoProxy );
|
||||
enumMap[QNetworkProxy::NoProxy] = i++;
|
||||
ui->typeBox->insertItem( i, "SOCKS 5", QNetworkProxy::Socks5Proxy );
|
||||
enumMap[QNetworkProxy::Socks5Proxy] = i++;
|
||||
|
||||
TomahawkSettings* s = TomahawkSettings::instance();
|
||||
|
||||
ui->typeBox->setCurrentIndex( enumMap[s->proxyType()] );
|
||||
ui->hostLineEdit->setText( s->proxyHost() );
|
||||
ui->portLineEdit->setText( QString::number( s->proxyPort() ) );
|
||||
ui->userLineEdit->setText( s->proxyUsername() );
|
||||
ui->passwordLineEdit->setText( s->proxyPassword() );
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
ProxyDialog::saveSettings()
|
||||
{
|
||||
qDebug() << Q_FUNC_INFO;
|
||||
|
||||
//First set settings
|
||||
TomahawkSettings* s = TomahawkSettings::instance();
|
||||
s->setProxyHost( ui->hostLineEdit->text() );
|
||||
|
||||
bool ok;
|
||||
qulonglong port = ui->portLineEdit->text().toULongLong( &ok );
|
||||
if( ok )
|
||||
s->setProxyPort( port );
|
||||
|
||||
s->setProxyUsername( ui->userLineEdit->text() );
|
||||
s->setProxyPassword( ui->passwordLineEdit->text() );
|
||||
s->setProxyType( ui->typeBox->itemData( ui->typeBox->currentIndex() ).toInt() );
|
||||
|
||||
if( s->proxyHost().isEmpty() )
|
||||
return;
|
||||
|
||||
// Now, set QNAM
|
||||
QNetworkProxy proxy( static_cast<QNetworkProxy::ProxyType>(s->proxyType()), s->proxyHost(), s->proxyPort(), s->proxyUsername(), s->proxyPassword() );
|
||||
Q_ASSERT( TomahawkUtils::nam() != 0 );
|
||||
QNetworkAccessManager* nam = TomahawkUtils::nam();
|
||||
nam->setProxy( proxy );
|
||||
QNetworkProxy* globalProxy = TomahawkUtils::proxy();
|
||||
QNetworkProxy* oldProxy = globalProxy;
|
||||
globalProxy = new QNetworkProxy( proxy );
|
||||
if( oldProxy )
|
||||
delete oldProxy;
|
||||
|
||||
QNetworkProxy::setApplicationProxy( proxy );
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
SettingsDialog::addScriptResolver()
|
||||
{
|
||||
@ -659,3 +599,63 @@ SettingsDialog::sipPluginDeleted( bool )
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
ProxyDialog::ProxyDialog( QWidget *parent )
|
||||
: QDialog( parent )
|
||||
, ui( new Ui::ProxyDialog )
|
||||
{
|
||||
ui->setupUi( this );
|
||||
|
||||
// ugly, I know, but...
|
||||
QHash<int,int> enumMap;
|
||||
int i = 0;
|
||||
ui->typeBox->insertItem( i, "No Proxy", QNetworkProxy::NoProxy );
|
||||
enumMap[QNetworkProxy::NoProxy] = i++;
|
||||
ui->typeBox->insertItem( i, "SOCKS 5", QNetworkProxy::Socks5Proxy );
|
||||
enumMap[QNetworkProxy::Socks5Proxy] = i++;
|
||||
|
||||
TomahawkSettings* s = TomahawkSettings::instance();
|
||||
|
||||
ui->typeBox->setCurrentIndex( enumMap[s->proxyType()] );
|
||||
ui->hostLineEdit->setText( s->proxyHost() );
|
||||
ui->portSpinBox->setValue( s->proxyPort() );
|
||||
ui->userLineEdit->setText( s->proxyUsername() );
|
||||
ui->passwordLineEdit->setText( s->proxyPassword() );
|
||||
ui->checkBoxUseProxyForDns->setChecked( s->proxyDns() );
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
ProxyDialog::saveSettings()
|
||||
{
|
||||
qDebug() << Q_FUNC_INFO;
|
||||
|
||||
//First set settings
|
||||
TomahawkSettings* s = TomahawkSettings::instance();
|
||||
s->setProxyHost( ui->hostLineEdit->text() );
|
||||
|
||||
int port = ui->portSpinBox->value();
|
||||
s->setProxyPort( port );
|
||||
|
||||
s->setProxyUsername( ui->userLineEdit->text() );
|
||||
s->setProxyPassword( ui->passwordLineEdit->text() );
|
||||
s->setProxyType( ui->typeBox->itemData( ui->typeBox->currentIndex() ).toInt() );
|
||||
s->setProxyDns( ui->checkBoxUseProxyForDns->checkState() == Qt::Checked );
|
||||
|
||||
if( s->proxyHost().isEmpty() )
|
||||
return;
|
||||
|
||||
// Now, set QNAM
|
||||
QNetworkProxy proxy( static_cast<QNetworkProxy::ProxyType>(s->proxyType()), s->proxyHost(), s->proxyPort(), s->proxyUsername(), s->proxyPassword() );
|
||||
Q_ASSERT( TomahawkUtils::nam() != 0 );
|
||||
QNetworkAccessManager* nam = TomahawkUtils::nam();
|
||||
nam->setProxy( proxy );
|
||||
QNetworkProxy* globalProxy = TomahawkUtils::proxy();
|
||||
QNetworkProxy* oldProxy = globalProxy;
|
||||
globalProxy = new QNetworkProxy( proxy );
|
||||
if( oldProxy )
|
||||
delete oldProxy;
|
||||
|
||||
QNetworkProxy::setApplicationProxy( proxy );
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user