SettingsDialog::~SettingsDialog() { qDebug() << Q_FUNC_INFO; if ( !m_rejected ) { TomahawkSettings* s = TomahawkSettings::instance(); s->setHttpEnabled( ui->checkBoxHttp->checkState() == Qt::Checked ); s->setPreferStaticHostPort( ui->checkBoxStaticPreferred->checkState() == Qt::Checked ); s->setExternalAddressMode( ui->checkBoxUpnp->checkState() == Qt::Checked ? TomahawkSettings::Upnp : TomahawkSettings::Lan ); s->setExternalHostname( ui->staticHostName->text() ); s->setExternalPort( ui->staticPort->value() ); s->setScannerPaths( QStringList( ui->lineEditMusicPath_2->text() ) ); s->setWatchForChanges( ui->checkBoxWatchForChanges->isChecked() ); s->setScrobblingEnabled( ui->checkBoxEnableLastfm->isChecked() ); s->setLastFmUsername( ui->lineEditLastfmUsername->text() ); s->setLastFmPassword( ui->lineEditLastfmPassword->text() ); s->setAllScriptResolvers( m_resolversModel->allResolvers() ); s->setEnabledScriptResolvers( m_resolversModel->enabledResolvers() ); s->applyChanges(); } else qDebug() << "Settings dialog cancelled, NOT saving prefs."; delete ui; }
void SettingsDialog::saveSettings() { qDebug() << Q_FUNC_INFO; TomahawkSettings* s = TomahawkSettings::instance(); s->setCrashReporterEnabled( m_advancedWidgetUi->checkBoxReporter->checkState() == Qt::Checked ); s->setHttpEnabled( m_advancedWidgetUi->checkBoxHttp->checkState() == Qt::Checked ); s->setHttpBindAll( m_advancedWidgetUi->checkBoxListenApi->checkState() == Qt::Checked ); 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 ) ); QStringList libraryPaths; for ( int i = 0; i < m_collectionWidgetUi->pathListWidget->count(); i++ ) { libraryPaths << m_collectionWidgetUi->pathListWidget->item( i )->text(); } s->setScannerPaths( libraryPaths ); // s->setScannerPaths( m_collectionWidgetUi->dirTree->getCheckedPaths() ); s->setWatchForChanges( m_collectionWidgetUi->checkBoxWatchForChanges->isChecked() ); s->setScannerTime( m_collectionWidgetUi->scannerTimeSpinBox->value() ); s->setEnableEchonestCatalogs( m_collectionWidgetUi->enableEchonestCatalog->isChecked() ); s->setDownloadsPath( m_downloadsWidgetUi->downloadsFolder->text() ); s->setDownloadsPreferredFormat( m_downloadsFormats.key( m_downloadsWidgetUi->preferredFormatComboBox->currentText() ) ); // s->setNowPlayingEnabled( ui->checkBoxEnableAdium->isChecked() ); s->applyChanges(); s->sync(); if ( m_restartRequired ) QMessageBox::information( 0, tr( "Information" ), tr( "Some changed settings will not take effect until Tomahawk is restarted" ) ); // m_collectionWidgetUi->dirTree->cleanup(); Tomahawk::Utils::NetworkProxyFactory* proxyFactory = Tomahawk::Utils::proxyFactory(); if ( !m_advancedWidgetUi->enableProxyCheckBox->isChecked() ) { tDebug() << Q_FUNC_INFO << "Got NoProxy selected"; proxyFactory->setProxy( QNetworkProxy::NoProxy, s->proxyDns() ); } else { tDebug() << Q_FUNC_INFO << "Got Socks5Proxy selected"; proxyFactory->setProxy( QNetworkProxy( QNetworkProxy::Socks5Proxy, s->proxyHost(), s->proxyPort(), s->proxyUsername(), s->proxyPassword() ), s->proxyDns() ); if ( !s->proxyNoProxyHosts().isEmpty() ) { tDebug() << Q_FUNC_INFO << "noproxy hosts:" << s->proxyNoProxyHosts(); tDebug() << Q_FUNC_INFO << "split noproxy line edit is " << s->proxyNoProxyHosts().split( ' ', QString::SkipEmptyParts ); proxyFactory->setNoProxyHosts( s->proxyNoProxyHosts().split( ' ', QString::SkipEmptyParts ) ); } } emit finished( true ); }