mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-08-20 12:52:30 +02:00
disable inline factories and use +/- button for now
This commit is contained in:
@@ -30,10 +30,12 @@ SipModel::SipModel( QObject* parent )
|
|||||||
connect( SipHandler::instance(), SIGNAL( pluginAdded( SipPlugin* ) ), this, SLOT( pluginAdded( SipPlugin* ) ) );
|
connect( SipHandler::instance(), SIGNAL( pluginAdded( SipPlugin* ) ), this, SLOT( pluginAdded( SipPlugin* ) ) );
|
||||||
connect( SipHandler::instance(), SIGNAL( pluginRemoved( SipPlugin* ) ), this, SLOT( pluginRemoved( SipPlugin* ) ) );
|
connect( SipHandler::instance(), SIGNAL( pluginRemoved( SipPlugin* ) ), this, SLOT( pluginRemoved( SipPlugin* ) ) );
|
||||||
|
|
||||||
|
// TODO disable inline factories for now
|
||||||
|
/*
|
||||||
foreach( SipPluginFactory* f, SipHandler::instance()->pluginFactories() ) {
|
foreach( SipPluginFactory* f, SipHandler::instance()->pluginFactories() ) {
|
||||||
if( f->isCreatable() )
|
if( f->isCreatable() )
|
||||||
m_factories << f;
|
m_factories << f;
|
||||||
}
|
} */
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -158,7 +160,7 @@ int
|
|||||||
SipModel::rowCount( const QModelIndex& parent ) const
|
SipModel::rowCount( const QModelIndex& parent ) const
|
||||||
{
|
{
|
||||||
if( !parent.isValid() ) // invalid root node
|
if( !parent.isValid() ) // invalid root node
|
||||||
return SipHandler::instance()->allPlugins().size() + 1;
|
return SipHandler::instance()->allPlugins().size() /* TODO inline factories disabled + 1*/;
|
||||||
if( parent.isValid() && !parent.parent().isValid() ) { // top level item
|
if( parent.isValid() && !parent.parent().isValid() ) { // top level item
|
||||||
if( parent.row() == SipHandler::instance()->allPlugins().count() ) {// last row, this is the factory
|
if( parent.row() == SipHandler::instance()->allPlugins().count() ) {// last row, this is the factory
|
||||||
return m_factories.count();
|
return m_factories.count();
|
||||||
|
@@ -84,12 +84,15 @@ SettingsDialog::SettingsDialog( QWidget *parent )
|
|||||||
SipConfigDelegate* sipdel = new SipConfigDelegate( this );
|
SipConfigDelegate* sipdel = new SipConfigDelegate( this );
|
||||||
ui->accountsView->setItemDelegate( sipdel );
|
ui->accountsView->setItemDelegate( sipdel );
|
||||||
ui->accountsView->setContextMenuPolicy( Qt::CustomContextMenu );
|
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 ) ) );
|
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 );
|
||||||
|
|
||||||
|
setupSipButtons();
|
||||||
|
|
||||||
ui->staticHostName->setText( s->externalHostname() );
|
ui->staticHostName->setText( s->externalHostname() );
|
||||||
ui->staticPort->setValue( s->externalPort() );
|
ui->staticPort->setValue( s->externalPort() );
|
||||||
|
|
||||||
@@ -220,6 +223,24 @@ SettingsDialog::createIcons()
|
|||||||
connect( ui->listWidget, SIGNAL( currentItemChanged( QListWidgetItem* ,QListWidgetItem* ) ), this, SLOT( changePage( QListWidgetItem*, QListWidgetItem* ) ) );
|
connect( ui->listWidget, SIGNAL( currentItemChanged( QListWidgetItem* ,QListWidgetItem* ) ), this, SLOT( changePage( QListWidgetItem*, QListWidgetItem* ) ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
SettingsDialog::setupSipButtons()
|
||||||
|
{
|
||||||
|
foreach( SipPluginFactory* f, SipHandler::instance()->pluginFactories() ) {
|
||||||
|
if( !f->isCreatable() )
|
||||||
|
continue;
|
||||||
|
|
||||||
|
QAction* action = new QAction( f->icon(), f->prettyName(), ui->addSipButton );
|
||||||
|
action->setProperty( "factory", QVariant::fromValue< QObject* >( f ) );
|
||||||
|
ui->addSipButton->addAction( action );
|
||||||
|
|
||||||
|
connect( action, SIGNAL( triggered(bool) ), this, SLOT( factoryActionTriggered( bool ) ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
connect( ui->removeSipButton, SIGNAL( clicked( bool ) ), this, SLOT( sipPluginDeleted( bool ) ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
SettingsDialog::changePage( QListWidgetItem* current, QListWidgetItem* previous )
|
SettingsDialog::changePage( QListWidgetItem* current, QListWidgetItem* previous )
|
||||||
{
|
{
|
||||||
@@ -481,6 +502,19 @@ SettingsDialog::openSipConfig( SipPlugin* p )
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
SettingsDialog::factoryActionTriggered( bool )
|
||||||
|
{
|
||||||
|
Q_ASSERT( sender() && qobject_cast< QAction* >( sender() ) );
|
||||||
|
|
||||||
|
QAction* a = qobject_cast< QAction* >( sender() );
|
||||||
|
Q_ASSERT( qobject_cast< SipPluginFactory* >( a->property( "factory" ).value< QObject* >() ) );
|
||||||
|
|
||||||
|
SipPluginFactory* f = qobject_cast< SipPluginFactory* >( a->property( "factory" ).value< QObject* >() );
|
||||||
|
sipFactoryClicked( f );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
SettingsDialog::sipFactoryClicked( SipPluginFactory* factory )
|
SettingsDialog::sipFactoryClicked( SipPluginFactory* factory )
|
||||||
{
|
{
|
||||||
@@ -518,14 +552,29 @@ SettingsDialog::sipContextMenuRequest( const QPoint& p )
|
|||||||
QList< QAction* > acts;
|
QList< QAction* > acts;
|
||||||
acts << new QAction( tr( "Delete Account" ), this );
|
acts << new QAction( tr( "Delete Account" ), this );
|
||||||
acts.first()->setProperty( "sipplugin", idx.data( SipModel::SipPluginData ) );
|
acts.first()->setProperty( "sipplugin", idx.data( SipModel::SipPluginData ) );
|
||||||
connect( acts.first(), SIGNAL( triggered( bool ) ), this, SLOT( sipPluginDeleted( bool ) ) );
|
connect( acts.first(), SIGNAL( triggered( bool ) ), this, SLOT( sipPluginRowDeleted( bool ) ) );
|
||||||
QMenu::exec( acts, ui->accountsView->mapToGlobal( p ) );
|
QMenu::exec( acts, ui->accountsView->mapToGlobal( p ) );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
SettingsDialog::sipPluginDeleted( bool )
|
SettingsDialog::sipPluginRowDeleted( bool )
|
||||||
{
|
{
|
||||||
SipPlugin* p = qobject_cast< SipPlugin* >( qobject_cast< QAction* >( sender() )->property( "sipplugin" ).value< QObject* >() );
|
SipPlugin* p = qobject_cast< SipPlugin* >( qobject_cast< QAction* >( sender() )->property( "sipplugin" ).value< QObject* >() );
|
||||||
SipHandler::instance()->removeSipPlugin( p );
|
SipHandler::instance()->removeSipPlugin( p );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
SettingsDialog::sipPluginDeleted( bool )
|
||||||
|
{
|
||||||
|
QModelIndexList indexes = ui->accountsView->selectionModel()->selectedIndexes();
|
||||||
|
// if it's an account, allow to delete
|
||||||
|
foreach( const QModelIndex& idx, indexes )
|
||||||
|
{
|
||||||
|
if( idx.isValid() && !idx.data( SipModel::FactoryRole ).toBool() && !idx.data( SipModel::FactoryItemRole ).toBool() )
|
||||||
|
{
|
||||||
|
SipPlugin* p = qobject_cast< SipPlugin* >( idx.data( SipModel::SipPluginData ).value< QObject* >() );
|
||||||
|
SipHandler::instance()->removeSipPlugin( p );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@@ -81,14 +81,17 @@ private slots:
|
|||||||
void openResolverConfig( const QString& );
|
void openResolverConfig( const QString& );
|
||||||
void sipItemClicked ( const QModelIndex& );
|
void sipItemClicked ( const QModelIndex& );
|
||||||
void openSipConfig( SipPlugin* );
|
void openSipConfig( SipPlugin* );
|
||||||
|
void factoryActionTriggered ( bool );
|
||||||
void sipFactoryClicked( SipPluginFactory* );
|
void sipFactoryClicked( SipPluginFactory* );
|
||||||
void sipContextMenuRequest( const QPoint& );
|
void sipContextMenuRequest( const QPoint& );
|
||||||
void sipPluginDeleted( bool );
|
void sipPluginDeleted( bool );
|
||||||
|
void sipPluginRowDeleted( bool );
|
||||||
|
|
||||||
void changePage( QListWidgetItem*, QListWidgetItem* );
|
void changePage( QListWidgetItem*, QListWidgetItem* );
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void createIcons();
|
void createIcons();
|
||||||
|
void setupSipButtons();
|
||||||
|
|
||||||
Ui_StackedSettingsDialog* ui;
|
Ui_StackedSettingsDialog* ui;
|
||||||
|
|
||||||
|
@@ -100,7 +100,7 @@
|
|||||||
<item>
|
<item>
|
||||||
<widget class="QStackedWidget" name="stackedWidget">
|
<widget class="QStackedWidget" name="stackedWidget">
|
||||||
<property name="currentIndex">
|
<property name="currentIndex">
|
||||||
<number>1</number>
|
<number>0</number>
|
||||||
</property>
|
</property>
|
||||||
<widget class="QWidget" name="accountsPage">
|
<widget class="QWidget" name="accountsPage">
|
||||||
<layout class="QVBoxLayout" name="verticalLayout_11">
|
<layout class="QVBoxLayout" name="verticalLayout_11">
|
||||||
@@ -112,10 +112,7 @@
|
|||||||
<property name="title">
|
<property name="title">
|
||||||
<string>Accounts</string>
|
<string>Accounts</string>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
<layout class="QVBoxLayout" name="verticalLayout_14">
|
||||||
<property name="margin">
|
|
||||||
<number>2</number>
|
|
||||||
</property>
|
|
||||||
<item>
|
<item>
|
||||||
<widget class="QLabel" name="label_2">
|
<widget class="QLabel" name="label_2">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
@@ -124,26 +121,75 @@
|
|||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QTreeView" name="accountsView">
|
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
||||||
<property name="indentation">
|
<item>
|
||||||
<number>0</number>
|
<widget class="QTreeView" name="accountsView">
|
||||||
</property>
|
<property name="indentation">
|
||||||
<property name="rootIsDecorated">
|
<number>0</number>
|
||||||
<bool>false</bool>
|
</property>
|
||||||
</property>
|
<property name="rootIsDecorated">
|
||||||
<property name="uniformRowHeights">
|
<bool>false</bool>
|
||||||
<bool>false</bool>
|
</property>
|
||||||
</property>
|
<property name="uniformRowHeights">
|
||||||
<property name="animated">
|
<bool>false</bool>
|
||||||
<bool>true</bool>
|
</property>
|
||||||
</property>
|
<property name="animated">
|
||||||
<property name="headerHidden">
|
<bool>true</bool>
|
||||||
<bool>true</bool>
|
</property>
|
||||||
</property>
|
<property name="headerHidden">
|
||||||
<property name="expandsOnDoubleClick">
|
<bool>true</bool>
|
||||||
<bool>false</bool>
|
</property>
|
||||||
</property>
|
<property name="expandsOnDoubleClick">
|
||||||
</widget>
|
<bool>false</bool>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<layout class="QVBoxLayout" name="addSipLayout">
|
||||||
|
<item>
|
||||||
|
<widget class="QToolButton" name="addSipButton">
|
||||||
|
<property name="text">
|
||||||
|
<string>...</string>
|
||||||
|
</property>
|
||||||
|
<property name="icon">
|
||||||
|
<iconset resource="../resources.qrc">
|
||||||
|
<normaloff>:/data/images/list-add.png</normaloff>:/data/images/list-add.png</iconset>
|
||||||
|
</property>
|
||||||
|
<property name="popupMode">
|
||||||
|
<enum>QToolButton::InstantPopup</enum>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QToolButton" name="removeSipButton">
|
||||||
|
<property name="text">
|
||||||
|
<string>...</string>
|
||||||
|
</property>
|
||||||
|
<property name="icon">
|
||||||
|
<iconset resource="../resources.qrc">
|
||||||
|
<normaloff>:/data/images/list-remove.png</normaloff>:/data/images/list-remove.png</iconset>
|
||||||
|
</property>
|
||||||
|
<property name="popupMode">
|
||||||
|
<enum>QToolButton::DelayedPopup</enum>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<spacer name="verticalSpacer_6">
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Vertical</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeHint" stdset="0">
|
||||||
|
<size>
|
||||||
|
<width>20</width>
|
||||||
|
<height>40</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</spacer>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
@@ -157,6 +203,12 @@
|
|||||||
</property>
|
</property>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QGroupBox" name="groupBox_2">
|
<widget class="QGroupBox" name="groupBox_2">
|
||||||
|
<property name="font">
|
||||||
|
<font>
|
||||||
|
<weight>50</weight>
|
||||||
|
<bold>false</bold>
|
||||||
|
</font>
|
||||||
|
</property>
|
||||||
<property name="title">
|
<property name="title">
|
||||||
<string>Local Music Information</string>
|
<string>Local Music Information</string>
|
||||||
</property>
|
</property>
|
||||||
|
Reference in New Issue
Block a user