mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-03-25 02:09:48 +01:00
support deleting sip plugins via context menu
This commit is contained in:
parent
5b6317b282
commit
fca9da24cf
@ -257,6 +257,18 @@ SipHandler::addSipPlugin( SipPlugin* p, bool enabled, bool startup )
|
||||
emit pluginAdded( p );
|
||||
}
|
||||
|
||||
void
|
||||
SipHandler::removeSipPlugin( SipPlugin* p )
|
||||
{
|
||||
p->disconnectPlugin();
|
||||
emit pluginRemoved( p );
|
||||
// emit first so sipmodel can find the indexOf
|
||||
|
||||
TomahawkSettings::instance()->removeSipPlugin( p->pluginId() );
|
||||
m_allPlugins.removeAll( p );
|
||||
m_enabledPlugins.removeAll( p );
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
SipHandler::loadFromConfig( bool startup )
|
||||
|
@ -45,6 +45,7 @@ public:
|
||||
void loadFromConfig( bool startup = false );
|
||||
|
||||
void addSipPlugin( SipPlugin* p, bool enable = true, bool connectImmediately = true );
|
||||
void removeSipPlugin( SipPlugin* p );
|
||||
|
||||
const QPixmap avatar( const QString& name ) const;
|
||||
|
||||
|
@ -434,6 +434,9 @@ TomahawkSettings::removeSipPlugin( const QString& pluginId )
|
||||
QStringList list = sipPlugins();
|
||||
list.removeAll( pluginId );
|
||||
setSipPlugins( list );
|
||||
|
||||
if( enabledSipPlugins().contains( pluginId ) )
|
||||
disableSipPlugin( pluginId );
|
||||
}
|
||||
|
||||
|
||||
|
@ -82,8 +82,10 @@ SettingsDialog::SettingsDialog( QWidget *parent )
|
||||
// SIP PLUGINS
|
||||
SipConfigDelegate* sipdel = new SipConfigDelegate( this );
|
||||
ui->accountsView->setItemDelegate( sipdel );
|
||||
ui->accountsView->setContextMenuPolicy( Qt::CustomContextMenu );
|
||||
connect( ui->accountsView, SIGNAL( clicked( QModelIndex ) ), this, SLOT( sipItemClicked( QModelIndex ) ) );
|
||||
connect( sipdel, SIGNAL( openConfig( SipPlugin* ) ), this, SLOT( openSipConfig( SipPlugin* ) ) );
|
||||
connect( ui->accountsView, SIGNAL( customContextMenuRequested( QPoint ) ), this, SLOT( sipContextMenuRequest( QPoint ) ) );
|
||||
m_sipModel = new SipModel( this );
|
||||
ui->accountsView->setModel( m_sipModel );
|
||||
|
||||
@ -502,3 +504,25 @@ SettingsDialog::sipFactoryClicked( SipPluginFactory* factory )
|
||||
SipHandler::instance()->addSipPlugin( p );
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
SettingsDialog::sipContextMenuRequest( const QPoint& p )
|
||||
{
|
||||
QModelIndex idx = ui->accountsView->indexAt( p );
|
||||
// if it's an account, allow to delete
|
||||
if( idx.isValid() && !idx.data( SipModel::FactoryRole ).toBool() && !idx.data( SipModel::FactoryItemRole ).toBool() )
|
||||
{
|
||||
QList< QAction* > acts;
|
||||
acts << new QAction( tr( "Delete Account" ), this );
|
||||
acts.first()->setProperty( "sipplugin", idx.data( SipModel::SipPluginData ) );
|
||||
connect( acts.first(), SIGNAL( triggered( bool ) ), this, SLOT( sipPluginDeleted( bool ) ) );
|
||||
QMenu::exec( acts, ui->accountsView->mapToGlobal( p ) );
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
SettingsDialog::sipPluginDeleted( bool )
|
||||
{
|
||||
SipPlugin* p = qobject_cast< SipPlugin* >( qobject_cast< QAction* >( sender() )->property( "sipplugin" ).value< QObject* >() );
|
||||
SipHandler::instance()->removeSipPlugin( p );
|
||||
}
|
||||
|
@ -82,6 +82,9 @@ private slots:
|
||||
void sipItemClicked ( const QModelIndex& );
|
||||
void openSipConfig( SipPlugin* );
|
||||
void sipFactoryClicked( SipPluginFactory* );
|
||||
void sipContextMenuRequest( const QPoint& );
|
||||
void sipPluginDeleted( bool );
|
||||
|
||||
void changePage( QListWidgetItem*, QListWidgetItem* );
|
||||
|
||||
private:
|
||||
|
Loading…
x
Reference in New Issue
Block a user