mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-08-06 14:16:32 +02:00
support deleting sip plugins via context menu
This commit is contained in:
@@ -257,6 +257,18 @@ SipHandler::addSipPlugin( SipPlugin* p, bool enabled, bool startup )
|
|||||||
emit pluginAdded( p );
|
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
|
void
|
||||||
SipHandler::loadFromConfig( bool startup )
|
SipHandler::loadFromConfig( bool startup )
|
||||||
|
@@ -45,6 +45,7 @@ public:
|
|||||||
void loadFromConfig( bool startup = false );
|
void loadFromConfig( bool startup = false );
|
||||||
|
|
||||||
void addSipPlugin( SipPlugin* p, bool enable = true, bool connectImmediately = true );
|
void addSipPlugin( SipPlugin* p, bool enable = true, bool connectImmediately = true );
|
||||||
|
void removeSipPlugin( SipPlugin* p );
|
||||||
|
|
||||||
const QPixmap avatar( const QString& name ) const;
|
const QPixmap avatar( const QString& name ) const;
|
||||||
|
|
||||||
|
@@ -434,6 +434,9 @@ TomahawkSettings::removeSipPlugin( const QString& pluginId )
|
|||||||
QStringList list = sipPlugins();
|
QStringList list = sipPlugins();
|
||||||
list.removeAll( pluginId );
|
list.removeAll( pluginId );
|
||||||
setSipPlugins( list );
|
setSipPlugins( list );
|
||||||
|
|
||||||
|
if( enabledSipPlugins().contains( pluginId ) )
|
||||||
|
disableSipPlugin( pluginId );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@@ -82,8 +82,10 @@ SettingsDialog::SettingsDialog( QWidget *parent )
|
|||||||
// SIP PLUGINS
|
// SIP PLUGINS
|
||||||
SipConfigDelegate* sipdel = new SipConfigDelegate( this );
|
SipConfigDelegate* sipdel = new SipConfigDelegate( this );
|
||||||
ui->accountsView->setItemDelegate( sipdel );
|
ui->accountsView->setItemDelegate( sipdel );
|
||||||
|
ui->accountsView->setContextMenuPolicy( Qt::CustomContextMenu );
|
||||||
connect( ui->accountsView, SIGNAL( clicked( QModelIndex ) ), this, SLOT( sipItemClicked( QModelIndex ) ) );
|
connect( ui->accountsView, SIGNAL( clicked( QModelIndex ) ), this, SLOT( sipItemClicked( QModelIndex ) ) );
|
||||||
connect( sipdel, SIGNAL( openConfig( SipPlugin* ) ), this, SLOT( openSipConfig( SipPlugin* ) ) );
|
connect( sipdel, SIGNAL( openConfig( SipPlugin* ) ), this, SLOT( openSipConfig( SipPlugin* ) ) );
|
||||||
|
connect( ui->accountsView, SIGNAL( customContextMenuRequested( QPoint ) ), this, SLOT( sipContextMenuRequest( QPoint ) ) );
|
||||||
m_sipModel = new SipModel( this );
|
m_sipModel = new SipModel( this );
|
||||||
ui->accountsView->setModel( m_sipModel );
|
ui->accountsView->setModel( m_sipModel );
|
||||||
|
|
||||||
@@ -502,3 +504,25 @@ SettingsDialog::sipFactoryClicked( SipPluginFactory* factory )
|
|||||||
SipHandler::instance()->addSipPlugin( p );
|
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 sipItemClicked ( const QModelIndex& );
|
||||||
void openSipConfig( SipPlugin* );
|
void openSipConfig( SipPlugin* );
|
||||||
void sipFactoryClicked( SipPluginFactory* );
|
void sipFactoryClicked( SipPluginFactory* );
|
||||||
|
void sipContextMenuRequest( const QPoint& );
|
||||||
|
void sipPluginDeleted( bool );
|
||||||
|
|
||||||
void changePage( QListWidgetItem*, QListWidgetItem* );
|
void changePage( QListWidgetItem*, QListWidgetItem* );
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
Reference in New Issue
Block a user