1
0
mirror of https://github.com/tomahawk-player/tomahawk.git synced 2025-03-21 08:19:42 +01:00

open config dialogs as a sheet on osx, and call gmail google

This commit is contained in:
Leo Franchi 2011-05-04 10:42:54 -04:00
parent 3dc317377f
commit 59b64bfdd9
4 changed files with 48 additions and 4 deletions

View File

@ -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 );

View File

@ -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();
}
}

View File

@ -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:

View File

@ -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" ) );
}