1
0
mirror of https://github.com/tomahawk-player/tomahawk.git synced 2025-08-06 22:26:32 +02:00

SHow initial config dialog as sheet on osx, WIP

This commit is contained in:
Leo Franchi
2011-06-01 17:41:44 -04:00
parent aeedf286eb
commit b4e0674e2b
2 changed files with 54 additions and 11 deletions

View File

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

View File

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