mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-08-09 07:36:48 +02:00
SHow initial config dialog as sheet on osx, WIP
This commit is contained in:
@@ -528,6 +528,15 @@ SettingsDialog::sipFactoryClicked( SipPluginFactory* factory )
|
|||||||
SipPlugin* p = factory->createPlugin();
|
SipPlugin* p = factory->createPlugin();
|
||||||
bool added = false;
|
bool added = false;
|
||||||
if( p->configWidget() ) {
|
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 );
|
DelegateConfigWrapper dialog( p->configWidget(), QString("%1 Config" ).arg( p->friendlyName() ), this );
|
||||||
QWeakPointer< DelegateConfigWrapper > watcher( &dialog );
|
QWeakPointer< DelegateConfigWrapper > watcher( &dialog );
|
||||||
int ret = dialog.exec();
|
int ret = dialog.exec();
|
||||||
@@ -544,13 +553,44 @@ SettingsDialog::sipFactoryClicked( SipPluginFactory* factory )
|
|||||||
// canceled, delete it
|
// canceled, delete it
|
||||||
added = false;
|
added = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
handleSipPluginAdded( p, added );
|
||||||
|
#endif
|
||||||
} else {
|
} else {
|
||||||
// no config, so just add it
|
// no config, so just add it
|
||||||
added = true;
|
added = true;
|
||||||
TomahawkSettings::instance()->addSipPlugin( p->pluginId() );
|
TomahawkSettings::instance()->addSipPlugin( p->pluginId() );
|
||||||
SipHandler::instance()->addSipPlugin( p );
|
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 );
|
SipPluginFactory* f = SipHandler::instance()->factoryFromPlugin( p );
|
||||||
if( added && f && f->isUnique() ) {
|
if( added && f && f->isUnique() ) {
|
||||||
// remove from actions list
|
// remove from actions list
|
||||||
@@ -570,6 +610,7 @@ SettingsDialog::sipFactoryClicked( SipPluginFactory* factory )
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
SettingsDialog::sipContextMenuRequest( const QPoint& p )
|
SettingsDialog::sipContextMenuRequest( const QPoint& p )
|
||||||
{
|
{
|
||||||
|
@@ -95,12 +95,14 @@ private slots:
|
|||||||
// dialog slots
|
// dialog slots
|
||||||
void resolverConfigClosed( int value );
|
void resolverConfigClosed( int value );
|
||||||
void sipConfigClosed( int value );
|
void sipConfigClosed( int value );
|
||||||
|
void sipCreateConfigClosed( int value );
|
||||||
|
|
||||||
void changePage( QListWidgetItem*, QListWidgetItem* );
|
void changePage( QListWidgetItem*, QListWidgetItem* );
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void createIcons();
|
void createIcons();
|
||||||
void setupSipButtons();
|
void setupSipButtons();
|
||||||
|
void handleSipPluginAdded( SipPlugin* p, bool added );
|
||||||
|
|
||||||
Ui_StackedSettingsDialog* ui;
|
Ui_StackedSettingsDialog* ui;
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user