From 59b64bfdd9b4c35e4a684b4fe06b42f1a31de4ce Mon Sep 17 00:00:00 2001 From: Leo Franchi Date: Wed, 4 May 2011 10:42:54 -0400 Subject: [PATCH] open config dialogs as a sheet on osx, and call gmail google --- src/delegateconfigwrapper.h | 2 +- src/settingsdialog.cpp | 42 ++++++++++++++++++- src/settingsdialog.h | 4 ++ src/sip/jreen/googlewrapper/googlewrapper.cpp | 4 +- 4 files changed, 48 insertions(+), 4 deletions(-) diff --git a/src/delegateconfigwrapper.h b/src/delegateconfigwrapper.h index 810b46333..162f5c29c 100644 --- a/src/delegateconfigwrapper.h +++ b/src/delegateconfigwrapper.h @@ -26,7 +26,7 @@ class DelegateConfigWrapper : public QDialog { Q_OBJECT public: - DelegateConfigWrapper( QWidget* conf, const QString& title, QWidget* parent ) : QDialog( parent ), m_widget( conf ) + DelegateConfigWrapper( QWidget* conf, const QString& title, QWidget* parent, Qt::WindowFlags flags = 0 ) : QDialog( parent, flags ), m_widget( conf ) { m_widget->setVisible( true ); m_widget->setWindowFlags( Qt::Sheet ); diff --git a/src/settingsdialog.cpp b/src/settingsdialog.cpp index 669917ddf..fbd9def16 100644 --- a/src/settingsdialog.cpp +++ b/src/settingsdialog.cpp @@ -468,6 +468,7 @@ SettingsDialog::openResolverConfig( const QString& resolver ) { Tomahawk::ExternalResolver* r = TomahawkApp::instance()->resolverForPath( resolver ); if( r && r->configUI() ) { +#ifndef Q_OS_MAC DelegateConfigWrapper dialog( r->configUI(), "Resolver Configuration", this ); QWeakPointer< DelegateConfigWrapper > watcher( &dialog ); int ret = dialog.exec(); @@ -475,6 +476,25 @@ SettingsDialog::openResolverConfig( const QString& resolver ) // send changed config to resolver r->saveConfig(); } +#else + // on osx a sheet needs to be non-modal + DelegateConfigWrapper* dialog = new DelegateConfigWrapper( r->configUI(), "Resolver Configuration", this, Qt::Sheet ); + dialog->setProperty( "resolver", QVariant::fromValue< QObject* >( r ) ); + connect( dialog, SIGNAL( finished( int ) ), this, SLOT( resolverConfigClosed( int ) ) ); + + dialog->show(); +#endif + + } +} + +void +SettingsDialog::resolverConfigClosed( int value ) +{ + if( value == QDialog::Accepted ) { + DelegateConfigWrapper* dialog = qobject_cast< DelegateConfigWrapper* >( sender() ); + Tomahawk::ExternalResolver* r = qobject_cast< Tomahawk::ExternalResolver* >( dialog->property( "resolver" ).value< QObject* >() ); + r->saveConfig(); } } @@ -494,13 +514,33 @@ void SettingsDialog::openSipConfig( SipPlugin* p ) { if( p->configWidget() ) { - DelegateConfigWrapper dialog( p->configWidget(), QString("%1 Config" ).arg( p->friendlyName() ), this ); +#ifndef Q_OS_MAC + DelegateConfigWrapper dialog( p->configWidget(), QString("%1 Configuration" ).arg( p->friendlyName() ), this ); QWeakPointer< DelegateConfigWrapper > watcher( &dialog ); int ret = dialog.exec(); if( !watcher.isNull() && ret == QDialog::Accepted ) { // send changed config to resolver p->saveConfig(); } +#else + // on osx a sheet needs to be non-modal + DelegateConfigWrapper* dialog = new DelegateConfigWrapper( p->configWidget(), QString("%1 Configuration" ).arg( p->friendlyName() ), this, Qt::Sheet ); + dialog->setProperty( "sipplugin", QVariant::fromValue< QObject* >( p ) ); + connect( dialog, SIGNAL( finished( int ) ), this, SLOT( sipConfigClosed( int ) ) ); + + dialog->show(); +#endif + } +} + + +void +SettingsDialog::sipConfigClosed( int value ) +{ + if( value == QDialog::Accepted ) { + DelegateConfigWrapper* dialog = qobject_cast< DelegateConfigWrapper* >( sender() ); + SipPlugin* p = qobject_cast< SipPlugin* >( dialog->property( "sipplugin" ).value< QObject* >() ); + p->saveConfig(); } } diff --git a/src/settingsdialog.h b/src/settingsdialog.h index 00f1eb4e0..f6269daa9 100644 --- a/src/settingsdialog.h +++ b/src/settingsdialog.h @@ -87,6 +87,10 @@ private slots: void sipPluginDeleted( bool ); void sipPluginRowDeleted( bool ); + // dialog slots + void resolverConfigClosed( int value ); + void sipConfigClosed( int value ); + void changePage( QListWidgetItem*, QListWidgetItem* ); private: diff --git a/src/sip/jreen/googlewrapper/googlewrapper.cpp b/src/sip/jreen/googlewrapper/googlewrapper.cpp index dd30c557e..a98afe242 100644 --- a/src/sip/jreen/googlewrapper/googlewrapper.cpp +++ b/src/sip/jreen/googlewrapper/googlewrapper.cpp @@ -38,8 +38,8 @@ GoogleWrapper::GoogleWrapper ( const QString& pluginID ) : JabberPlugin ( pluginID ) { m_ui->headerLabel->setText( tr( "Configure this Google Account" ) ); - m_ui->emailLabel->setText( tr( "GMail Address" ) ); - m_ui->jabberBlurb->setText( tr( "Enter your GMail login to connect with your friends using Tomahawk!" ) ); + m_ui->emailLabel->setText( tr( "Google Address" ) ); + m_ui->jabberBlurb->setText( tr( "Enter your Google login to connect with your friends using Tomahawk!" ) ); m_ui->logoLabel->setPixmap( QPixmap( ":/gmail-logo.png" ) ); }