mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-04-05 00:22:31 +02:00
SHow initial config dialog as sheet on osx, WIP
This commit is contained in:
parent
aeedf286eb
commit
b4e0674e2b
@ -382,7 +382,7 @@ SettingsDialog::onLastFmFinished()
|
||||
ui->pushButtonTestLastfmLogin->setText( tr( "Failed" ) );
|
||||
ui->pushButtonTestLastfmLogin->setEnabled( true );
|
||||
break;
|
||||
|
||||
|
||||
default:
|
||||
qDebug() << "Couldn't get last.fm auth result";
|
||||
ui->pushButtonTestLastfmLogin->setText( tr( "Could not contact server" ) );
|
||||
@ -528,6 +528,15 @@ SettingsDialog::sipFactoryClicked( SipPluginFactory* factory )
|
||||
SipPlugin* p = factory->createPlugin();
|
||||
bool added = false;
|
||||
if( p->configWidget() ) {
|
||||
|
||||
#ifdef Q_OS_MAC
|
||||
// on osx a sheet needs to be non-modal
|
||||
DelegateConfigWrapper* dialog = new DelegateConfigWrapper( p->configWidget(), QString("%1 Config" ).arg( p->friendlyName() ), this, Qt::Sheet );
|
||||
dialog->setProperty( "sipplugin", QVariant::fromValue< QObject* >( p ) );
|
||||
connect( dialog, SIGNAL( finished( int ) ), this, SLOT( sipCreateConfigClosed( int ) ) );
|
||||
|
||||
dialog->show();
|
||||
#else
|
||||
DelegateConfigWrapper dialog( p->configWidget(), QString("%1 Config" ).arg( p->friendlyName() ), this );
|
||||
QWeakPointer< DelegateConfigWrapper > watcher( &dialog );
|
||||
int ret = dialog.exec();
|
||||
@ -544,13 +553,44 @@ SettingsDialog::sipFactoryClicked( SipPluginFactory* factory )
|
||||
// canceled, delete it
|
||||
added = false;
|
||||
}
|
||||
|
||||
handleSipPluginAdded( p, added );
|
||||
#endif
|
||||
} else {
|
||||
// no config, so just add it
|
||||
added = true;
|
||||
TomahawkSettings::instance()->addSipPlugin( p->pluginId() );
|
||||
SipHandler::instance()->addSipPlugin( p );
|
||||
|
||||
handleSipPluginAdded( p, added );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void
|
||||
SettingsDialog::sipCreateConfigClosed( int finished )
|
||||
{
|
||||
DelegateConfigWrapper* dialog = qobject_cast< DelegateConfigWrapper* >( sender() );
|
||||
SipPlugin* p = qobject_cast< SipPlugin* >( dialog->property( "sipplugin" ).value< QObject* >() );
|
||||
Q_ASSERT( p );
|
||||
|
||||
bool added = false;
|
||||
if( finished == QDialog::Accepted ) {
|
||||
|
||||
p->saveConfig();
|
||||
TomahawkSettings::instance()->addSipPlugin( p->pluginId() );
|
||||
SipHandler::instance()->addSipPlugin( p );
|
||||
|
||||
added = true;
|
||||
}
|
||||
|
||||
handleSipPluginAdded( p, added );
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
SettingsDialog::handleSipPluginAdded( SipPlugin* p, bool added )
|
||||
{
|
||||
SipPluginFactory* f = SipHandler::instance()->factoryFromPlugin( p );
|
||||
if( added && f && f->isUnique() ) {
|
||||
// remove from actions list
|
||||
@ -570,6 +610,7 @@ SettingsDialog::sipFactoryClicked( SipPluginFactory* factory )
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
SettingsDialog::sipContextMenuRequest( const QPoint& p )
|
||||
{
|
||||
@ -625,9 +666,9 @@ ProxyDialog::ProxyDialog( QWidget *parent )
|
||||
, ui( new Ui::ProxyDialog )
|
||||
{
|
||||
ui->setupUi( this );
|
||||
|
||||
|
||||
// ugly, I know, but...
|
||||
|
||||
|
||||
int i = 0;
|
||||
ui->typeBox->insertItem( i, "No Proxy", QNetworkProxy::NoProxy );
|
||||
m_forwardMap[ QNetworkProxy::NoProxy ] = i;
|
||||
@ -637,9 +678,9 @@ ProxyDialog::ProxyDialog( QWidget *parent )
|
||||
m_forwardMap[ QNetworkProxy::Socks5Proxy ] = i;
|
||||
m_backwardMap[ i ] = QNetworkProxy::Socks5Proxy;
|
||||
i++;
|
||||
|
||||
|
||||
TomahawkSettings* s = TomahawkSettings::instance();
|
||||
|
||||
|
||||
ui->typeBox->setCurrentIndex( m_forwardMap[s->proxyType()] );
|
||||
ui->hostLineEdit->setText( s->proxyHost() );
|
||||
ui->portSpinBox->setValue( s->proxyPort() );
|
||||
@ -681,18 +722,18 @@ ProxyDialog::proxyTypeChangedSlot( int index )
|
||||
ui->passwordLineEdit->setEnabled( true );
|
||||
ui->checkBoxUseProxyForDns->setEnabled( true );
|
||||
ui->noHostLineEdit->setEnabled( true );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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->setProxyNoProxyHosts( ui->noHostLineEdit->text() );
|
||||
@ -700,10 +741,10 @@ ProxyDialog::saveSettings()
|
||||
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;
|
||||
|
||||
|
||||
TomahawkUtils::NetworkProxyFactory* proxyFactory = new TomahawkUtils::NetworkProxyFactory();
|
||||
QNetworkProxy proxy( static_cast<QNetworkProxy::ProxyType>(s->proxyType()), s->proxyHost(), s->proxyPort(), s->proxyUsername(), s->proxyPassword() );
|
||||
proxyFactory->setProxy( proxy );
|
||||
|
@ -48,7 +48,7 @@ public:
|
||||
|
||||
private slots:
|
||||
void proxyTypeChangedSlot( int index );
|
||||
|
||||
|
||||
private:
|
||||
Ui::ProxyDialog* ui;
|
||||
QHash<int,int> m_forwardMap;
|
||||
@ -95,12 +95,14 @@ private slots:
|
||||
// dialog slots
|
||||
void resolverConfigClosed( int value );
|
||||
void sipConfigClosed( int value );
|
||||
void sipCreateConfigClosed( int value );
|
||||
|
||||
void changePage( QListWidgetItem*, QListWidgetItem* );
|
||||
|
||||
private:
|
||||
void createIcons();
|
||||
void setupSipButtons();
|
||||
void handleSipPluginAdded( SipPlugin* p, bool added );
|
||||
|
||||
Ui_StackedSettingsDialog* ui;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user