mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-08-07 22:56:42 +02:00
Make the treeview work, and config work, and lots of things work
This commit is contained in:
Binary file not shown.
Before Width: | Height: | Size: 489 B After Width: | Height: | Size: 757 B |
@@ -110,7 +110,7 @@ SET( tomahawkHeadersGui ${tomahawkHeadersGui}
|
|||||||
resolverconfigdelegate.h
|
resolverconfigdelegate.h
|
||||||
sipconfigdelegate.h
|
sipconfigdelegate.h
|
||||||
resolversmodel.h
|
resolversmodel.h
|
||||||
resolverconfigwrapper.h
|
delegateconfigwrapper.h
|
||||||
tomahawkwindow.h
|
tomahawkwindow.h
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@@ -52,7 +52,7 @@ ConfigDelegateBase::sizeHint( const QStyleOptionViewItem& option, const QModelIn
|
|||||||
|
|
||||||
QFontMetrics bfm( name );
|
QFontMetrics bfm( name );
|
||||||
QFontMetrics sfm( path );
|
QFontMetrics sfm( path );
|
||||||
return QSize( width, 3 * PADDING + bfm.height() + sfm.height() );
|
return QSize( width, 2 * PADDING + bfm.height() + sfm.height() );
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@@ -22,14 +22,15 @@
|
|||||||
#include <QDialogButtonBox>
|
#include <QDialogButtonBox>
|
||||||
#include <QVBoxLayout>
|
#include <QVBoxLayout>
|
||||||
|
|
||||||
class ResolverConfigWrapper : public QDialog
|
class DelegateConfigWrapper : public QDialog
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
ResolverConfigWrapper( QWidget* conf, const QString& title, QWidget* parent ) : QDialog( parent ), m_widget( conf )
|
DelegateConfigWrapper( QWidget* conf, const QString& title, QWidget* parent ) : QDialog( parent ), m_widget( conf )
|
||||||
{
|
{
|
||||||
setWindowTitle( title );
|
m_widget->setVisible( true );
|
||||||
|
|
||||||
|
setWindowTitle( title );
|
||||||
QVBoxLayout* v = new QVBoxLayout( this );
|
QVBoxLayout* v = new QVBoxLayout( this );
|
||||||
v->addWidget( m_widget );
|
v->addWidget( m_widget );
|
||||||
|
|
||||||
@@ -46,6 +47,7 @@ public slots:
|
|||||||
// let the config widget live to see another day
|
// let the config widget live to see another day
|
||||||
layout()->removeWidget( m_widget );
|
layout()->removeWidget( m_widget );
|
||||||
m_widget->setParent( 0 );
|
m_widget->setParent( 0 );
|
||||||
|
m_widget->setVisible( false );
|
||||||
|
|
||||||
QDialogButtonBox* buttons = qobject_cast< QDialogButtonBox* >( sender() );
|
QDialogButtonBox* buttons = qobject_cast< QDialogButtonBox* >( sender() );
|
||||||
if( buttons->standardButton( b ) == QDialogButtonBox::Ok )
|
if( buttons->standardButton( b ) == QDialogButtonBox::Ok )
|
||||||
@@ -59,6 +61,7 @@ public slots:
|
|||||||
{
|
{
|
||||||
layout()->removeWidget( m_widget );
|
layout()->removeWidget( m_widget );
|
||||||
m_widget->setParent( 0 );
|
m_widget->setParent( 0 );
|
||||||
|
m_widget->setVisible( false );
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
@@ -243,6 +243,21 @@ SipHandler::checkSettings()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
SipHandler::addSipPlugin( SipPlugin* p, bool enabled, bool startup )
|
||||||
|
{
|
||||||
|
m_allPlugins << p;
|
||||||
|
|
||||||
|
if ( enabled )
|
||||||
|
{
|
||||||
|
p->connectPlugin( startup );
|
||||||
|
m_enabledPlugins << p;
|
||||||
|
}
|
||||||
|
|
||||||
|
emit pluginAdded( p );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
SipHandler::loadFromConfig( bool startup )
|
SipHandler::loadFromConfig( bool startup )
|
||||||
{
|
{
|
||||||
@@ -254,13 +269,7 @@ SipHandler::loadFromConfig( bool startup )
|
|||||||
if( m_pluginFactories.contains( pluginFactory ) )
|
if( m_pluginFactories.contains( pluginFactory ) )
|
||||||
{
|
{
|
||||||
SipPlugin* p = loadPlugin( pluginId );
|
SipPlugin* p = loadPlugin( pluginId );
|
||||||
m_allPlugins << p;
|
addSipPlugin( p, enabled.contains( pluginId ), startup );
|
||||||
|
|
||||||
if ( enabled.contains( pluginId ) )
|
|
||||||
{
|
|
||||||
p->connectPlugin( startup );
|
|
||||||
m_enabledPlugins << p;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
m_connected = true;
|
m_connected = true;
|
||||||
|
@@ -44,6 +44,8 @@ public:
|
|||||||
QList< SipPlugin* > connectedPlugins() const;
|
QList< SipPlugin* > connectedPlugins() const;
|
||||||
void loadFromConfig( bool startup = false );
|
void loadFromConfig( bool startup = false );
|
||||||
|
|
||||||
|
void addSipPlugin( SipPlugin* p, bool enable = true, bool connectImmediately = true );
|
||||||
|
|
||||||
const QPixmap avatar( const QString& name ) const;
|
const QPixmap avatar( const QString& name ) const;
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
|
@@ -21,11 +21,20 @@
|
|||||||
#include "tomahawksettings.h"
|
#include "tomahawksettings.h"
|
||||||
#include "tomahawk/tomahawkapp.h"
|
#include "tomahawk/tomahawkapp.h"
|
||||||
#include "sip/SipHandler.h"
|
#include "sip/SipHandler.h"
|
||||||
|
#include "sip/SipPlugin.h"
|
||||||
|
|
||||||
SipModel::SipModel( QObject* parent )
|
SipModel::SipModel( QObject* parent )
|
||||||
: QAbstractItemModel( parent )
|
: QAbstractItemModel( parent )
|
||||||
{
|
{
|
||||||
connect( SipHandler::instance(), SIGNAL( stateChanged( SipPlugin*, SipPlugin::ConnectionState ) ), this, SLOT( pluginStateChanged( SipPlugin* ) ) );
|
connect( SipHandler::instance(), SIGNAL( stateChanged( SipPlugin*, SipPlugin::ConnectionState ) ), this, SLOT( pluginStateChanged( SipPlugin* ) ) );
|
||||||
|
connect( SipHandler::instance(), SIGNAL( pluginAdded( SipPlugin* ) ), this, SLOT( pluginAdded( SipPlugin* ) ) );
|
||||||
|
connect( SipHandler::instance(), SIGNAL( pluginRemoved( SipPlugin* ) ), this, SLOT( pluginRemoved( SipPlugin* ) ) );
|
||||||
|
|
||||||
|
foreach( SipPluginFactory* f, SipHandler::instance()->pluginFactories() ) {
|
||||||
|
if( f->isCreatable() )
|
||||||
|
m_factories << f;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -40,15 +49,16 @@ SipModel::data( const QModelIndex& index, int role ) const
|
|||||||
if( !index.isValid() )
|
if( !index.isValid() )
|
||||||
return QVariant();
|
return QVariant();
|
||||||
|
|
||||||
if( index.row() == SipHandler::instance()->allPlugins().count() ) { // last row, this is the factory
|
if( !index.parent().isValid() && index.row() == SipHandler::instance()->allPlugins().count() ) { // last row, this is the factory
|
||||||
if( role == Qt::DisplayRole )
|
if( role == Qt::DisplayRole )
|
||||||
return tr( "Add New Account" );
|
return tr( "Add New Account..." );
|
||||||
else if( role == FactoryRole )
|
else if( role == FactoryRole )
|
||||||
return true;
|
return true;
|
||||||
else
|
else
|
||||||
return QVariant();
|
return QVariant();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if( !index.parent().isValid() ) { // account
|
||||||
QList< SipPlugin* > plugins = SipHandler::instance()->allPlugins();
|
QList< SipPlugin* > plugins = SipHandler::instance()->allPlugins();
|
||||||
Q_ASSERT( index.row() <= plugins.size() );
|
Q_ASSERT( index.row() <= plugins.size() );
|
||||||
SipPlugin* p = plugins[ index.row() ];
|
SipPlugin* p = plugins[ index.row() ];
|
||||||
@@ -60,16 +70,38 @@ SipModel::data( const QModelIndex& index, int role ) const
|
|||||||
case SipModel::ConnectionStateRole:
|
case SipModel::ConnectionStateRole:
|
||||||
return p->connectionState();
|
return p->connectionState();
|
||||||
case SipModel::HasConfig:
|
case SipModel::HasConfig:
|
||||||
return ( p->configWidget() == 0 );
|
return ( p->configWidget() != 0 );
|
||||||
case SipModel::FactoryRole:
|
case SipModel::FactoryRole:
|
||||||
return false;
|
return false;
|
||||||
case Qt::DecorationRole:
|
case Qt::DecorationRole:
|
||||||
return p->icon();
|
return p->icon();
|
||||||
|
case SipModel::SipPluginData:
|
||||||
|
return QVariant::fromValue< QObject* >( p );
|
||||||
case Qt::CheckStateRole:
|
case Qt::CheckStateRole:
|
||||||
return SipHandler::instance()->enabledPlugins().contains( p ) ? Qt::Checked : Qt::Unchecked;
|
return SipHandler::instance()->enabledPlugins().contains( p ) ? Qt::Checked : Qt::Unchecked;
|
||||||
default:
|
default:
|
||||||
return QVariant();
|
return QVariant();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if( index.parent().isValid() ) { // this is a factory type
|
||||||
|
SipPluginFactory* p = m_factories.at( index.row() );
|
||||||
|
switch( role )
|
||||||
|
{
|
||||||
|
case Qt::DisplayRole:
|
||||||
|
return p->prettyName();
|
||||||
|
case SipModel::FactoryItemRole:
|
||||||
|
return true;
|
||||||
|
case SipModel::FactoryItemIcon:
|
||||||
|
return p->icon();
|
||||||
|
case SipModel::SipPluginFactoryData:
|
||||||
|
return QVariant::fromValue< QObject* >( p );
|
||||||
|
default:
|
||||||
|
return QVariant();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return QVariant();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
@@ -100,9 +132,10 @@ SipModel::index( int row, int column, const QModelIndex& parent ) const
|
|||||||
if( !parent.isValid() )
|
if( !parent.isValid() )
|
||||||
return hasIndex( row, column, parent ) ? createIndex( row, column, 0 ) : QModelIndex();
|
return hasIndex( row, column, parent ) ? createIndex( row, column, 0 ) : QModelIndex();
|
||||||
|
|
||||||
|
// qDebug() << "Creating index for non-top level row!";
|
||||||
// it's a child of the Add Account, e.g. a factory
|
// it's a child of the Add Account, e.g. a factory
|
||||||
if( hasIndex( row, column, parent ) ) {
|
if( hasIndex( row, column, parent ) ) {
|
||||||
createIndex( row, column, 1 /* magic */ );
|
return createIndex( row, column, 1 /* magic */ );
|
||||||
}
|
}
|
||||||
|
|
||||||
return QModelIndex();
|
return QModelIndex();
|
||||||
@@ -115,7 +148,7 @@ SipModel::parent( const QModelIndex& child ) const
|
|||||||
return QModelIndex();
|
return QModelIndex();
|
||||||
|
|
||||||
if( child.internalId() == 1 ) {
|
if( child.internalId() == 1 ) {
|
||||||
return createIndex( SipHandler::instance()->allPlugins().size() - 1, 0, 0 );
|
return index( SipHandler::instance()->allPlugins().size(), 0, QModelIndex() );
|
||||||
}
|
}
|
||||||
|
|
||||||
return QModelIndex();
|
return QModelIndex();
|
||||||
@@ -124,25 +157,29 @@ SipModel::parent( const QModelIndex& child ) const
|
|||||||
int
|
int
|
||||||
SipModel::rowCount( const QModelIndex& parent ) const
|
SipModel::rowCount( const QModelIndex& parent ) const
|
||||||
{
|
{
|
||||||
if( !parent.isValid() ) { // top level item
|
if( !parent.isValid() ) // invalid root node
|
||||||
if( parent.row() == SipHandler::instance()->allPlugins().count() ) { // last row, this is the factory
|
|
||||||
return SipHandler::instance()->pluginFactories().count();
|
|
||||||
} else {
|
|
||||||
return SipHandler::instance()->allPlugins().size() + 1;
|
return SipHandler::instance()->allPlugins().size() + 1;
|
||||||
|
if( parent.isValid() && !parent.parent().isValid() ) { // top level item
|
||||||
|
if( parent.row() == SipHandler::instance()->allPlugins().count() ) {// last row, this is the factory
|
||||||
|
return m_factories.count();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
SipModel::columnCount(const QModelIndex& parent) const
|
SipModel::columnCount(const QModelIndex& parent) const
|
||||||
{
|
{
|
||||||
|
Q_UNUSED( parent );
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
Qt::ItemFlags
|
Qt::ItemFlags
|
||||||
SipModel::flags( const QModelIndex& index ) const
|
SipModel::flags( const QModelIndex& index ) const
|
||||||
{
|
{
|
||||||
|
if( index.data( SipModel::FactoryRole ).toBool() || index.data( SipModel::FactoryItemRole ).toBool() )
|
||||||
|
return QAbstractItemModel::flags( index ) & ~Qt::ItemIsSelectable;
|
||||||
return QAbstractItemModel::flags( index ) | Qt::ItemIsUserCheckable;
|
return QAbstractItemModel::flags( index ) | Qt::ItemIsUserCheckable;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -153,6 +190,7 @@ SipModel::pluginAdded( SipPlugin* p )
|
|||||||
Q_ASSERT( SipHandler::instance()->allPlugins().last() == p );
|
Q_ASSERT( SipHandler::instance()->allPlugins().last() == p );
|
||||||
int size = SipHandler::instance()->allPlugins().count() - 1;
|
int size = SipHandler::instance()->allPlugins().count() - 1;
|
||||||
beginInsertRows( QModelIndex(), size, size );
|
beginInsertRows( QModelIndex(), size, size );
|
||||||
|
endInsertRows();
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@@ -25,6 +25,7 @@
|
|||||||
#include <QModelIndex>
|
#include <QModelIndex>
|
||||||
#include <QStringList>
|
#include <QStringList>
|
||||||
|
|
||||||
|
class SipPluginFactory;
|
||||||
class SipPlugin;
|
class SipPlugin;
|
||||||
|
|
||||||
class DLLEXPORT SipModel : public QAbstractItemModel
|
class DLLEXPORT SipModel : public QAbstractItemModel
|
||||||
@@ -36,7 +37,11 @@ public:
|
|||||||
ConnectionStateRole = Qt::UserRole + 17,
|
ConnectionStateRole = Qt::UserRole + 17,
|
||||||
HasConfig = Qt::UserRole + 18,
|
HasConfig = Qt::UserRole + 18,
|
||||||
FactoryRole = Qt::UserRole + 19,
|
FactoryRole = Qt::UserRole + 19,
|
||||||
ErrorString = Qt::UserRole + 20
|
ErrorString = Qt::UserRole + 20,
|
||||||
|
FactoryItemRole = Qt::UserRole + 21,
|
||||||
|
FactoryItemIcon = Qt::UserRole + 22,
|
||||||
|
SipPluginData = Qt::UserRole + 23,
|
||||||
|
SipPluginFactoryData = Qt::UserRole + 24
|
||||||
};
|
};
|
||||||
|
|
||||||
explicit SipModel( QObject* parent = 0 );
|
explicit SipModel( QObject* parent = 0 );
|
||||||
@@ -54,6 +59,9 @@ private slots:
|
|||||||
void pluginAdded( SipPlugin* p );
|
void pluginAdded( SipPlugin* p );
|
||||||
void pluginRemoved( SipPlugin* p );
|
void pluginRemoved( SipPlugin* p );
|
||||||
void pluginStateChanged( SipPlugin* p );
|
void pluginStateChanged( SipPlugin* p );
|
||||||
|
|
||||||
|
private:
|
||||||
|
QList< SipPluginFactory* > m_factories;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // SIPMODEL_H
|
#endif // SIPMODEL_H
|
||||||
|
@@ -38,6 +38,9 @@ public:
|
|||||||
virtual QString prettyName() const = 0;
|
virtual QString prettyName() const = 0;
|
||||||
// internal name
|
// internal name
|
||||||
virtual QString factoryId() const = 0;
|
virtual QString factoryId() const = 0;
|
||||||
|
// if the user can create multiple
|
||||||
|
virtual QIcon icon() const { return QIcon(); }
|
||||||
|
virtual bool isCreatable() const { return true; }
|
||||||
virtual SipPlugin* createPlugin( const QString& pluginId = QString() ) = 0;
|
virtual SipPlugin* createPlugin( const QString& pluginId = QString() ) = 0;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
@@ -66,6 +69,7 @@ public:
|
|||||||
virtual QString errorMessage() const;
|
virtual QString errorMessage() const;
|
||||||
virtual QMenu* menu();
|
virtual QMenu* menu();
|
||||||
virtual QWidget* configWidget();
|
virtual QWidget* configWidget();
|
||||||
|
virtual void saveConfig() {} // called when the widget has been edited
|
||||||
virtual QIcon icon() const;
|
virtual QIcon icon() const;
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
|
@@ -42,7 +42,7 @@
|
|||||||
#include "scanmanager.h"
|
#include "scanmanager.h"
|
||||||
#include "resolverconfigdelegate.h"
|
#include "resolverconfigdelegate.h"
|
||||||
#include "resolversmodel.h"
|
#include "resolversmodel.h"
|
||||||
#include "resolverconfigwrapper.h"
|
#include "delegateconfigwrapper.h"
|
||||||
#include "sip/SipModel.h"
|
#include "sip/SipModel.h"
|
||||||
#include "sipconfigdelegate.h"
|
#include "sipconfigdelegate.h"
|
||||||
|
|
||||||
@@ -73,16 +73,11 @@ 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 );
|
||||||
// connect( sipdel, SIGNAL( openConfig( SipPlugin* ) ), this, SLOT( openSipPluginConfig( SipPlugin* ) ) );
|
connect( ui->accountsView, SIGNAL( clicked( QModelIndex ) ), this, SLOT( sipItemClicked( QModelIndex ) ) );
|
||||||
|
connect( sipdel, SIGNAL( openConfig( SipPlugin* ) ), this, SLOT( openSipConfig( SipPlugin* ) ) );
|
||||||
m_sipModel = new SipModel( this );
|
m_sipModel = new SipModel( this );
|
||||||
ui->accountsView->setModel( m_sipModel );
|
ui->accountsView->setModel( m_sipModel );
|
||||||
|
|
||||||
// ui->checkBoxJabberAutoConnect->setChecked( s->jabberAutoConnect() );
|
|
||||||
// ui->jabberUsername->setText( s->jabberUsername() );
|
|
||||||
// ui->jabberPassword->setText( s->jabberPassword() );
|
|
||||||
// ui->jabberServer->setText( s->jabberServer() );
|
|
||||||
// ui->jabberPort->setValue( s->jabberPort() );
|
|
||||||
|
|
||||||
ui->staticHostName->setText( s->externalHostname() );
|
ui->staticHostName->setText( s->externalHostname() );
|
||||||
ui->staticPort->setValue( s->externalPort() );
|
ui->staticPort->setValue( s->externalPort() );
|
||||||
|
|
||||||
@@ -368,8 +363,8 @@ SettingsDialog::openResolverConfig( const QString& resolver )
|
|||||||
{
|
{
|
||||||
Tomahawk::ExternalResolver* r = TomahawkApp::instance()->resolverForPath( resolver );
|
Tomahawk::ExternalResolver* r = TomahawkApp::instance()->resolverForPath( resolver );
|
||||||
if( r && r->configUI() ) {
|
if( r && r->configUI() ) {
|
||||||
ResolverConfigWrapper dialog( r->configUI(), "Resolver Config", this );
|
DelegateConfigWrapper dialog( r->configUI(), "Resolver Config", this );
|
||||||
QWeakPointer< ResolverConfigWrapper > watcher( &dialog );
|
QWeakPointer< DelegateConfigWrapper > watcher( &dialog );
|
||||||
int ret = dialog.exec();
|
int ret = dialog.exec();
|
||||||
if( !watcher.isNull() && ret == QDialog::Accepted ) {
|
if( !watcher.isNull() && ret == QDialog::Accepted ) {
|
||||||
// send changed config to resolver
|
// send changed config to resolver
|
||||||
@@ -377,3 +372,56 @@ SettingsDialog::openResolverConfig( const QString& resolver )
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
SettingsDialog::sipItemClicked( const QModelIndex& item )
|
||||||
|
{
|
||||||
|
if( item.data( SipModel::FactoryRole ).toBool() )
|
||||||
|
if( ui->accountsView->isExpanded( item ) )
|
||||||
|
ui->accountsView->collapse( item );
|
||||||
|
else
|
||||||
|
ui->accountsView->expand( item );
|
||||||
|
else if( item.data( SipModel::FactoryItemRole ).toBool() )
|
||||||
|
sipFactoryClicked( qobject_cast<SipPluginFactory* >( item.data( SipModel::SipPluginFactoryData ).value< QObject* >() ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
SettingsDialog::openSipConfig( SipPlugin* p )
|
||||||
|
{
|
||||||
|
if( p->configWidget() ) {
|
||||||
|
DelegateConfigWrapper dialog( p->configWidget(), QString("%1 Config" ).arg( p->friendlyName() ), this );
|
||||||
|
QWeakPointer< DelegateConfigWrapper > watcher( &dialog );
|
||||||
|
int ret = dialog.exec();
|
||||||
|
if( !watcher.isNull() && ret == QDialog::Accepted ) {
|
||||||
|
// send changed config to resolver
|
||||||
|
p->saveConfig();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
SettingsDialog::sipFactoryClicked( SipPluginFactory* factory )
|
||||||
|
{
|
||||||
|
Q_ASSERT( factory->isCreatable() );
|
||||||
|
//if exited with OK, create it, if not, delete it immediately!
|
||||||
|
SipPlugin* p = factory->createPlugin();
|
||||||
|
if( p->configWidget() ) {
|
||||||
|
DelegateConfigWrapper dialog( p->configWidget(), QString("%1 Config" ).arg( p->friendlyName() ), this );
|
||||||
|
QWeakPointer< DelegateConfigWrapper > watcher( &dialog );
|
||||||
|
int ret = dialog.exec();
|
||||||
|
if( !watcher.isNull() && ret == QDialog::Accepted ) {
|
||||||
|
// send changed config to resolver
|
||||||
|
p->saveConfig();
|
||||||
|
|
||||||
|
// accepted, so add it to tomahawk
|
||||||
|
TomahawkSettings::instance()->addSipPlugin( p->pluginId() );
|
||||||
|
SipHandler::instance()->addSipPlugin( p );
|
||||||
|
} else {
|
||||||
|
// canceled, delete it
|
||||||
|
delete p;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// no config, so just add it
|
||||||
|
SipHandler::instance()->addSipPlugin( p );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@@ -20,7 +20,10 @@
|
|||||||
#define SETTINGSDIALOG_H
|
#define SETTINGSDIALOG_H
|
||||||
|
|
||||||
#include <QDialog>
|
#include <QDialog>
|
||||||
|
#include <QModelIndex>
|
||||||
|
|
||||||
|
class SipPluginFactory;
|
||||||
|
class SipPlugin;
|
||||||
class SipModel;
|
class SipModel;
|
||||||
class ResolversModel;
|
class ResolversModel;
|
||||||
class QNetworkReply;
|
class QNetworkReply;
|
||||||
@@ -74,6 +77,9 @@ private slots:
|
|||||||
void scriptSelectionChanged();
|
void scriptSelectionChanged();
|
||||||
void removeScriptResolver();
|
void removeScriptResolver();
|
||||||
void openResolverConfig( const QString& );
|
void openResolverConfig( const QString& );
|
||||||
|
void sipItemClicked ( const QModelIndex& );
|
||||||
|
void openSipConfig( SipPlugin* );
|
||||||
|
void sipFactoryClicked( SipPluginFactory* );
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Ui::SettingsDialog* ui;
|
Ui::SettingsDialog* ui;
|
||||||
|
@@ -32,6 +32,9 @@
|
|||||||
<layout class="QVBoxLayout" name="verticalLayout_20">
|
<layout class="QVBoxLayout" name="verticalLayout_20">
|
||||||
<item>
|
<item>
|
||||||
<widget class="QTreeView" name="accountsView">
|
<widget class="QTreeView" name="accountsView">
|
||||||
|
<property name="indentation">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
<property name="rootIsDecorated">
|
<property name="rootIsDecorated">
|
||||||
<bool>false</bool>
|
<bool>false</bool>
|
||||||
</property>
|
</property>
|
||||||
@@ -44,6 +47,9 @@
|
|||||||
<property name="headerHidden">
|
<property name="headerHidden">
|
||||||
<bool>true</bool>
|
<bool>true</bool>
|
||||||
</property>
|
</property>
|
||||||
|
<property name="expandsOnDoubleClick">
|
||||||
|
<bool>false</bool>
|
||||||
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
|
@@ -22,13 +22,19 @@ set( jabberHeaders
|
|||||||
avatarmanager.h
|
avatarmanager.h
|
||||||
)
|
)
|
||||||
|
|
||||||
|
set( jabberUI
|
||||||
|
configwidget.ui
|
||||||
|
)
|
||||||
|
|
||||||
include_directories( . ${CMAKE_CURRENT_BINARY_DIR} ..
|
include_directories( . ${CMAKE_CURRENT_BINARY_DIR} ..
|
||||||
${QT_INCLUDE_DIR}
|
${QT_INCLUDE_DIR}
|
||||||
${LIBJREEN_INCLUDE_DIR}
|
${LIBJREEN_INCLUDE_DIR}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
qt4_add_resources( RC_SRCS "resources.qrc" )
|
||||||
|
qt4_wrap_ui( jabberUI_H ${jabberUI} )
|
||||||
qt4_wrap_cpp( jabberMoc ${jabberHeaders} )
|
qt4_wrap_cpp( jabberMoc ${jabberHeaders} )
|
||||||
add_library( tomahawk_sipjabber SHARED ${jabberSources} ${jabberMoc} )
|
add_library( tomahawk_sipjabber SHARED ${jabberSources} ${jabberMoc} ${jabberUI_H} ${RC_SRCS} )
|
||||||
|
|
||||||
IF( WIN32 )
|
IF( WIN32 )
|
||||||
SET( OS_SPECIFIC_LINK_LIBRARIES
|
SET( OS_SPECIFIC_LINK_LIBRARIES
|
||||||
|
264
src/sip/jreen/configwidget.ui
Normal file
264
src/sip/jreen/configwidget.ui
Normal file
@@ -0,0 +1,264 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<ui version="4.0">
|
||||||
|
<class>JabberConfig</class>
|
||||||
|
<widget class="QWidget" name="JabberConfig">
|
||||||
|
<property name="geometry">
|
||||||
|
<rect>
|
||||||
|
<x>0</x>
|
||||||
|
<y>0</y>
|
||||||
|
<width>437</width>
|
||||||
|
<height>207</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
|
<property name="windowTitle">
|
||||||
|
<string>Form</string>
|
||||||
|
</property>
|
||||||
|
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||||
|
<item>
|
||||||
|
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||||
|
<item>
|
||||||
|
<spacer name="horizontalSpacer">
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Horizontal</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeHint" stdset="0">
|
||||||
|
<size>
|
||||||
|
<width>40</width>
|
||||||
|
<height>20</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</spacer>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QLabel" name="headerLabel">
|
||||||
|
<property name="font">
|
||||||
|
<font>
|
||||||
|
<pointsize>12</pointsize>
|
||||||
|
</font>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Configure this Jabber account</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<spacer name="horizontalSpacer_2">
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Horizontal</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeHint" stdset="0">
|
||||||
|
<size>
|
||||||
|
<width>40</width>
|
||||||
|
<height>20</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</spacer>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QGroupBox" name="groupBox">
|
||||||
|
<property name="title">
|
||||||
|
<string>Login Information</string>
|
||||||
|
</property>
|
||||||
|
<layout class="QVBoxLayout" name="verticalLayout">
|
||||||
|
<item>
|
||||||
|
<layout class="QHBoxLayout" name="horizontalLayout_8">
|
||||||
|
<item>
|
||||||
|
<widget class="QLabel" name="emailLabel">
|
||||||
|
<property name="sizePolicy">
|
||||||
|
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
|
||||||
|
<horstretch>0</horstretch>
|
||||||
|
<verstretch>0</verstretch>
|
||||||
|
</sizepolicy>
|
||||||
|
</property>
|
||||||
|
<property name="minimumSize">
|
||||||
|
<size>
|
||||||
|
<width>0</width>
|
||||||
|
<height>0</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Jabber ID:</string>
|
||||||
|
</property>
|
||||||
|
<property name="buddy">
|
||||||
|
<cstring>jabberUsername</cstring>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QLineEdit" name="jabberUsername">
|
||||||
|
<property name="sizePolicy">
|
||||||
|
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
|
||||||
|
<horstretch>0</horstretch>
|
||||||
|
<verstretch>0</verstretch>
|
||||||
|
</sizepolicy>
|
||||||
|
</property>
|
||||||
|
<property name="placeholderText">
|
||||||
|
<string>e.g. user@example.com</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QLabel" name="label_4">
|
||||||
|
<property name="sizePolicy">
|
||||||
|
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
|
||||||
|
<horstretch>0</horstretch>
|
||||||
|
<verstretch>0</verstretch>
|
||||||
|
</sizepolicy>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Password:</string>
|
||||||
|
</property>
|
||||||
|
<property name="buddy">
|
||||||
|
<cstring>jabberPassword</cstring>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QLineEdit" name="jabberPassword">
|
||||||
|
<property name="sizePolicy">
|
||||||
|
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
|
||||||
|
<horstretch>0</horstretch>
|
||||||
|
<verstretch>0</verstretch>
|
||||||
|
</sizepolicy>
|
||||||
|
</property>
|
||||||
|
<property name="inputMask">
|
||||||
|
<string/>
|
||||||
|
</property>
|
||||||
|
<property name="echoMode">
|
||||||
|
<enum>QLineEdit::Password</enum>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QCheckBox" name="checkBoxAutoConnect">
|
||||||
|
<property name="text">
|
||||||
|
<string>Connect automatically when Tomahawk starts</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QGroupBox" name="groupBoxJabberAdvanced">
|
||||||
|
<property name="enabled">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
<property name="sizePolicy">
|
||||||
|
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
|
||||||
|
<horstretch>0</horstretch>
|
||||||
|
<verstretch>0</verstretch>
|
||||||
|
</sizepolicy>
|
||||||
|
</property>
|
||||||
|
<property name="title">
|
||||||
|
<string>Advanced Jabber Settings</string>
|
||||||
|
</property>
|
||||||
|
<layout class="QHBoxLayout" name="horizontalLayout_5">
|
||||||
|
<item>
|
||||||
|
<layout class="QHBoxLayout" name="horizontalLayout_3">
|
||||||
|
<item>
|
||||||
|
<widget class="QLabel" name="labelJabberServer">
|
||||||
|
<property name="sizePolicy">
|
||||||
|
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||||
|
<horstretch>0</horstretch>
|
||||||
|
<verstretch>0</verstretch>
|
||||||
|
</sizepolicy>
|
||||||
|
</property>
|
||||||
|
<property name="minimumSize">
|
||||||
|
<size>
|
||||||
|
<width>50</width>
|
||||||
|
<height>0</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Server:</string>
|
||||||
|
</property>
|
||||||
|
<property name="alignment">
|
||||||
|
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||||
|
</property>
|
||||||
|
<property name="buddy">
|
||||||
|
<cstring>jabberServer</cstring>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QLineEdit" name="jabberServer">
|
||||||
|
<property name="sizePolicy">
|
||||||
|
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
|
||||||
|
<horstretch>0</horstretch>
|
||||||
|
<verstretch>0</verstretch>
|
||||||
|
</sizepolicy>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QLabel" name="labelJabberPort">
|
||||||
|
<property name="text">
|
||||||
|
<string>Port:</string>
|
||||||
|
</property>
|
||||||
|
<property name="alignment">
|
||||||
|
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QSpinBox" name="jabberPort">
|
||||||
|
<property name="sizePolicy">
|
||||||
|
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
|
||||||
|
<horstretch>0</horstretch>
|
||||||
|
<verstretch>0</verstretch>
|
||||||
|
</sizepolicy>
|
||||||
|
</property>
|
||||||
|
<property name="minimumSize">
|
||||||
|
<size>
|
||||||
|
<width>90</width>
|
||||||
|
<height>0</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
<property name="maximumSize">
|
||||||
|
<size>
|
||||||
|
<width>90</width>
|
||||||
|
<height>16777215</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
<property name="alignment">
|
||||||
|
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||||
|
</property>
|
||||||
|
<property name="minimum">
|
||||||
|
<number>1</number>
|
||||||
|
</property>
|
||||||
|
<property name="maximum">
|
||||||
|
<number>65535</number>
|
||||||
|
</property>
|
||||||
|
<property name="value">
|
||||||
|
<number>5222</number>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<spacer name="verticalSpacer">
|
||||||
|
<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>
|
||||||
|
</widget>
|
||||||
|
<resources/>
|
||||||
|
<connections/>
|
||||||
|
</ui>
|
@@ -18,8 +18,10 @@ set( googleSources
|
|||||||
|
|
||||||
add_definitions(-DGOOGLE_WRAPPER)
|
add_definitions(-DGOOGLE_WRAPPER)
|
||||||
|
|
||||||
|
qt4_add_resources( RCX_SRCS "resources.qrc" )
|
||||||
|
|
||||||
qt4_wrap_cpp( googleMoc googlewrapper.h )
|
qt4_wrap_cpp( googleMoc googlewrapper.h )
|
||||||
add_library( tomahawk_sipgoogle SHARED ${googleSources} ${googleMoc} ${jabberMoc} )
|
add_library( tomahawk_sipgoogle SHARED ${googleSources} ${googleMoc} ${jabberMoc} ${RCX_SRCS} )
|
||||||
|
|
||||||
target_link_libraries( tomahawk_sipgoogle
|
target_link_libraries( tomahawk_sipgoogle
|
||||||
${QT_LIBRARIES}
|
${QT_LIBRARIES}
|
||||||
|
BIN
src/sip/jreen/googlewrapper/gmail-logo.jpg
Normal file
BIN
src/sip/jreen/googlewrapper/gmail-logo.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 73 KiB |
@@ -20,18 +20,35 @@
|
|||||||
#include "googlewrapper.h"
|
#include "googlewrapper.h"
|
||||||
#include <QtPlugin>
|
#include <QtPlugin>
|
||||||
|
|
||||||
|
#include "ui_configwidget.h"
|
||||||
|
|
||||||
SipPlugin*
|
SipPlugin*
|
||||||
GoogleWrapperFactory::createPlugin( const QString& pluginId )
|
GoogleWrapperFactory::createPlugin( const QString& pluginId )
|
||||||
{
|
{
|
||||||
return new GoogleWrapper( pluginId.isEmpty() ? generateId() : pluginId );
|
return new GoogleWrapper( pluginId.isEmpty() ? generateId() : pluginId );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QIcon
|
||||||
|
GoogleWrapperFactory::icon() const
|
||||||
|
{
|
||||||
|
return QIcon( ":/gmail-logo.jpg" );
|
||||||
|
}
|
||||||
|
|
||||||
GoogleWrapper::GoogleWrapper ( const QString& pluginID )
|
GoogleWrapper::GoogleWrapper ( const QString& pluginID )
|
||||||
: JabberPlugin ( pluginID )
|
: JabberPlugin ( pluginID )
|
||||||
{
|
{
|
||||||
|
m_ui->headerLabel->setText( tr( "Configure this Google Account" ) );
|
||||||
|
m_ui->emailLabel->setText( tr( "GMail Address" ) );
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QIcon
|
||||||
|
GoogleWrapper::icon() const
|
||||||
|
{
|
||||||
|
return QIcon( ":/gmail-logo.jpg" );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
#ifdef GOOGLE_WRAPPER
|
#ifdef GOOGLE_WRAPPER
|
||||||
Q_EXPORT_PLUGIN2( sipfactory, GoogleWrapperFactory )
|
Q_EXPORT_PLUGIN2( sipfactory, GoogleWrapperFactory )
|
||||||
#endif
|
#endif
|
||||||
|
@@ -32,6 +32,7 @@ public:
|
|||||||
|
|
||||||
virtual QString prettyName() const { return "GMail"; }
|
virtual QString prettyName() const { return "GMail"; }
|
||||||
virtual QString factoryId() const { return "sipgoogle"; }
|
virtual QString factoryId() const { return "sipgoogle"; }
|
||||||
|
virtual QIcon icon() const;
|
||||||
virtual SipPlugin* createPlugin( const QString& pluginId );
|
virtual SipPlugin* createPlugin( const QString& pluginId );
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -44,6 +45,7 @@ public:
|
|||||||
|
|
||||||
virtual const QString name() const { return QString( "GMail" ); }
|
virtual const QString name() const { return QString( "GMail" ); }
|
||||||
virtual const QString friendlyName() const { return "GMail Friends"; }
|
virtual const QString friendlyName() const { return "GMail Friends"; }
|
||||||
|
virtual QIcon icon() const;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // GOOGLEWRAPPER_H
|
#endif // GOOGLEWRAPPER_H
|
||||||
|
5
src/sip/jreen/googlewrapper/resources.qrc
Normal file
5
src/sip/jreen/googlewrapper/resources.qrc
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
<!DOCTYPE RCC><RCC version="1.0">
|
||||||
|
<qresource>
|
||||||
|
<file>gmail-logo.jpg</file>
|
||||||
|
</qresource>
|
||||||
|
</RCC>
|
BIN
src/sip/jreen/jabber-icon.png
Normal file
BIN
src/sip/jreen/jabber-icon.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 2.4 KiB |
@@ -27,12 +27,21 @@
|
|||||||
#include <QLineEdit>
|
#include <QLineEdit>
|
||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
|
|
||||||
|
#include "ui_configwidget.h"
|
||||||
|
|
||||||
SipPlugin*
|
SipPlugin*
|
||||||
JabberFactory::createPlugin( const QString& pluginId )
|
JabberFactory::createPlugin( const QString& pluginId )
|
||||||
{
|
{
|
||||||
return new JabberPlugin( pluginId.isEmpty() ? generateId() : pluginId );
|
return new JabberPlugin( pluginId.isEmpty() ? generateId() : pluginId );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QIcon
|
||||||
|
JabberFactory::icon() const
|
||||||
|
{
|
||||||
|
return QIcon( ":/jabber-icon.png" );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
JabberPlugin::JabberPlugin( const QString& pluginId )
|
JabberPlugin::JabberPlugin( const QString& pluginId )
|
||||||
: SipPlugin( pluginId )
|
: SipPlugin( pluginId )
|
||||||
, p( 0 )
|
, p( 0 )
|
||||||
@@ -40,6 +49,17 @@ JabberPlugin::JabberPlugin( const QString& pluginId )
|
|||||||
, m_addFriendAction( 0 )
|
, m_addFriendAction( 0 )
|
||||||
, m_state( Disconnected )
|
, m_state( Disconnected )
|
||||||
{
|
{
|
||||||
|
m_configWidget = QWeakPointer< QWidget >( new QWidget );
|
||||||
|
m_ui = new Ui_JabberConfig;
|
||||||
|
m_ui->setupUi( m_configWidget.data() );
|
||||||
|
m_configWidget.data()->setVisible( false );
|
||||||
|
|
||||||
|
m_ui->checkBoxAutoConnect->setChecked( readAutoConnect() );
|
||||||
|
m_ui->jabberUsername->setText( accountName() );
|
||||||
|
m_ui->jabberPassword->setText( readPassword() );
|
||||||
|
m_ui->jabberServer->setText( readServer() );
|
||||||
|
m_ui->jabberPort->setValue( readPort() );
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
JabberPlugin::~JabberPlugin()
|
JabberPlugin::~JabberPlugin()
|
||||||
@@ -78,6 +98,19 @@ JabberPlugin::menu()
|
|||||||
return m_menu;
|
return m_menu;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QWidget*
|
||||||
|
JabberPlugin::configWidget()
|
||||||
|
{
|
||||||
|
return m_configWidget.data();
|
||||||
|
}
|
||||||
|
|
||||||
|
QIcon
|
||||||
|
JabberPlugin::icon() const
|
||||||
|
{
|
||||||
|
return QIcon( ":/jabber-icon.png" );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
bool
|
bool
|
||||||
JabberPlugin::connectPlugin( bool startup )
|
JabberPlugin::connectPlugin( bool startup )
|
||||||
{
|
{
|
||||||
@@ -285,6 +318,19 @@ JabberPlugin::readAutoConnect()
|
|||||||
return TomahawkSettings::instance()->value( pluginId() + "/autoconnect", true ).toBool();
|
return TomahawkSettings::instance()->value( pluginId() + "/autoconnect", true ).toBool();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
JabberPlugin::saveConfig()
|
||||||
|
{
|
||||||
|
TomahawkSettings::instance()->setValue( pluginId() + "/autoconnect", m_ui->checkBoxAutoConnect->isChecked() );
|
||||||
|
TomahawkSettings::instance()->setValue( pluginId() + "/username", m_ui->jabberUsername->text() );
|
||||||
|
TomahawkSettings::instance()->setValue( pluginId() + "/pasword", m_ui->jabberPassword->text() );
|
||||||
|
TomahawkSettings::instance()->setValue( pluginId() + "/port", m_ui->jabberPort->value() );
|
||||||
|
TomahawkSettings::instance()->setValue( pluginId() + "/server", m_ui->jabberServer->text() );
|
||||||
|
|
||||||
|
checkSettings();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
SipPlugin::ConnectionState
|
SipPlugin::ConnectionState
|
||||||
JabberPlugin::connectionState() const
|
JabberPlugin::connectionState() const
|
||||||
{
|
{
|
||||||
|
@@ -27,6 +27,8 @@
|
|||||||
|
|
||||||
#define MYNAME "SIPJREEN"
|
#define MYNAME "SIPJREEN"
|
||||||
|
|
||||||
|
class Ui_JabberConfig;
|
||||||
|
|
||||||
class SIPDLLEXPORT JabberFactory : public SipPluginFactory
|
class SIPDLLEXPORT JabberFactory : public SipPluginFactory
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
@@ -38,6 +40,7 @@ public:
|
|||||||
|
|
||||||
virtual QString prettyName() const { return "Jabber"; }
|
virtual QString prettyName() const { return "Jabber"; }
|
||||||
virtual QString factoryId() const { return "sipjabber"; }
|
virtual QString factoryId() const { return "sipjabber"; }
|
||||||
|
virtual QIcon icon() const;
|
||||||
virtual SipPlugin* createPlugin( const QString& pluginId );
|
virtual SipPlugin* createPlugin( const QString& pluginId );
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -56,6 +59,9 @@ public:
|
|||||||
virtual const QString accountName() const;
|
virtual const QString accountName() const;
|
||||||
virtual ConnectionState connectionState() const;
|
virtual ConnectionState connectionState() const;
|
||||||
virtual QMenu* menu();
|
virtual QMenu* menu();
|
||||||
|
virtual QIcon icon() const;
|
||||||
|
virtual QWidget* configWidget();
|
||||||
|
virtual void saveConfig();
|
||||||
|
|
||||||
void setProxy( QNetworkProxy* proxy );
|
void setProxy( QNetworkProxy* proxy );
|
||||||
|
|
||||||
@@ -67,6 +73,9 @@ public slots:
|
|||||||
void broadcastMsg( const QString &msg );
|
void broadcastMsg( const QString &msg );
|
||||||
void addContact( const QString &jid, const QString& msg = QString() );
|
void addContact( const QString &jid, const QString& msg = QString() );
|
||||||
|
|
||||||
|
protected:
|
||||||
|
Ui_JabberConfig* m_ui; // so the google wrapper can change the config dialog a bit
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void showAddFriendDialog();
|
void showAddFriendDialog();
|
||||||
void onConnected();
|
void onConnected();
|
||||||
@@ -88,6 +97,8 @@ private:
|
|||||||
QString m_currentServer;
|
QString m_currentServer;
|
||||||
unsigned int m_currentPort;
|
unsigned int m_currentPort;
|
||||||
ConnectionState m_state;
|
ConnectionState m_state;
|
||||||
|
|
||||||
|
QWeakPointer< QWidget > m_configWidget;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
5
src/sip/jreen/resources.qrc
Normal file
5
src/sip/jreen/resources.qrc
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
<!DOCTYPE RCC><RCC version="1.0">
|
||||||
|
<qresource>
|
||||||
|
<file>jabber-icon.png</file>
|
||||||
|
</qresource>
|
||||||
|
</RCC>
|
@@ -26,9 +26,10 @@ include_directories( . ${CMAKE_CURRENT_BINARY_DIR} ..
|
|||||||
${CMAKE_SOURCE_DIR}/thirdparty/qtweetlib/tomahawk-custom
|
${CMAKE_SOURCE_DIR}/thirdparty/qtweetlib/tomahawk-custom
|
||||||
)
|
)
|
||||||
|
|
||||||
|
qt4_add_resources( RC_SRCS "resources.qrc" )
|
||||||
qt4_wrap_cpp( twitterMoc ${twitterHeaders} )
|
qt4_wrap_cpp( twitterMoc ${twitterHeaders} )
|
||||||
qt4_wrap_ui( twitterUI_H ${twitterUI} )
|
qt4_wrap_ui( twitterUI_H ${twitterUI} )
|
||||||
add_library( tomahawk_siptwitter SHARED ${twitterUI_H} ${twitterSources} ${twitterMoc} )
|
add_library( tomahawk_siptwitter SHARED ${twitterUI_H} ${twitterSources} ${twitterMoc} ${RC_SRCS} )
|
||||||
|
|
||||||
IF( WIN32 )
|
IF( WIN32 )
|
||||||
SET( OS_SPECIFIC_LINK_LIBRARIES
|
SET( OS_SPECIFIC_LINK_LIBRARIES
|
||||||
|
5
src/sip/twitter/resources.qrc
Normal file
5
src/sip/twitter/resources.qrc
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
<!DOCTYPE RCC><RCC version="1.0">
|
||||||
|
<qresource>
|
||||||
|
<file>twitter-icon.jpg</file>
|
||||||
|
</qresource>
|
||||||
|
</RCC>
|
BIN
src/sip/twitter/twitter-icon.jpg
Normal file
BIN
src/sip/twitter/twitter-icon.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.5 KiB |
@@ -41,6 +41,11 @@ TwitterFactory::createPlugin( const QString& pluginId )
|
|||||||
return new TwitterPlugin( pluginId.isEmpty() ? generateId() : pluginId );
|
return new TwitterPlugin( pluginId.isEmpty() ? generateId() : pluginId );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QIcon TwitterFactory::icon() const
|
||||||
|
{
|
||||||
|
return QIcon( ":/twitter-icon.jpg" );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
TwitterPlugin::TwitterPlugin( const QString& pluginId )
|
TwitterPlugin::TwitterPlugin( const QString& pluginId )
|
||||||
: SipPlugin( pluginId )
|
: SipPlugin( pluginId )
|
||||||
@@ -55,7 +60,6 @@ TwitterPlugin::TwitterPlugin( const QString& pluginId )
|
|||||||
, m_finishedFriends( false )
|
, m_finishedFriends( false )
|
||||||
, m_finishedMentions( false )
|
, m_finishedMentions( false )
|
||||||
, m_state( Disconnected )
|
, m_state( Disconnected )
|
||||||
, m_configWidget( 0 )
|
|
||||||
{
|
{
|
||||||
qDebug() << Q_FUNC_INFO;
|
qDebug() << Q_FUNC_INFO;
|
||||||
m_checkTimer.setInterval( 60000 );
|
m_checkTimer.setInterval( 60000 );
|
||||||
@@ -65,18 +69,29 @@ TwitterPlugin::TwitterPlugin( const QString& pluginId )
|
|||||||
m_connectTimer.setInterval( 60000 );
|
m_connectTimer.setInterval( 60000 );
|
||||||
m_connectTimer.setSingleShot( false );
|
m_connectTimer.setSingleShot( false );
|
||||||
connect( &m_connectTimer, SIGNAL( timeout() ), SLOT( connectTimerFired() ) );
|
connect( &m_connectTimer, SIGNAL( timeout() ), SLOT( connectTimerFired() ) );
|
||||||
|
|
||||||
|
m_configWidget = QWeakPointer< TwitterConfigWidget >( new TwitterConfigWidget( this, 0 ) );
|
||||||
|
connect( m_configWidget.data(), SIGNAL( twitterAuthed( bool ) ), SLOT( configDialogAuthedSignalSlot( bool ) ) );
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
TwitterPlugin::configDialogAuthedSignalSlot( bool authed )
|
TwitterPlugin::configDialogAuthedSignalSlot( bool authed )
|
||||||
{
|
{
|
||||||
m_isAuthed = authed;
|
|
||||||
if ( !authed )
|
if ( !authed )
|
||||||
{
|
{
|
||||||
|
if( m_isAuthed ) {
|
||||||
|
m_state = Disconnected;
|
||||||
|
emit stateChanged( m_state );
|
||||||
|
}
|
||||||
|
|
||||||
setTwitterScreenName( QString() );
|
setTwitterScreenName( QString() );
|
||||||
setTwitterOAuthToken( QString() );
|
setTwitterOAuthToken( QString() );
|
||||||
setTwitterOAuthTokenSecret( QString() );
|
setTwitterOAuthTokenSecret( QString() );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
m_isAuthed = authed;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
@@ -100,9 +115,19 @@ TwitterPlugin::friendlyName() const
|
|||||||
const QString
|
const QString
|
||||||
TwitterPlugin::accountName() const
|
TwitterPlugin::accountName() const
|
||||||
{
|
{
|
||||||
|
if( twitterScreenName().isEmpty() )
|
||||||
|
return friendlyName();
|
||||||
|
else
|
||||||
return twitterScreenName();
|
return twitterScreenName();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QIcon
|
||||||
|
TwitterPlugin::icon() const
|
||||||
|
{
|
||||||
|
return QIcon( ":/twitter-icon.jpg" );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
SipPlugin::ConnectionState
|
SipPlugin::ConnectionState
|
||||||
TwitterPlugin::connectionState() const
|
TwitterPlugin::connectionState() const
|
||||||
{
|
{
|
||||||
@@ -112,11 +137,7 @@ TwitterPlugin::connectionState() const
|
|||||||
|
|
||||||
QWidget* TwitterPlugin::configWidget()
|
QWidget* TwitterPlugin::configWidget()
|
||||||
{
|
{
|
||||||
m_configWidget = new TwitterConfigWidget( this, 0 );
|
return m_configWidget.data();
|
||||||
|
|
||||||
connect( m_configWidget, SIGNAL( twitterAuthed(bool) ), SLOT( configDialogAuthedSignalSlot(bool) ) );
|
|
||||||
|
|
||||||
return m_configWidget;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
|
@@ -51,6 +51,7 @@ public:
|
|||||||
|
|
||||||
virtual QString prettyName() const { return "Twitter"; }
|
virtual QString prettyName() const { return "Twitter"; }
|
||||||
virtual QString factoryId() const { return "siptwitter"; }
|
virtual QString factoryId() const { return "siptwitter"; }
|
||||||
|
virtual QIcon icon() const;
|
||||||
virtual SipPlugin* createPlugin( const QString& pluginId = QString() );
|
virtual SipPlugin* createPlugin( const QString& pluginId = QString() );
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -68,6 +69,7 @@ public:
|
|||||||
virtual const QString accountName() const;
|
virtual const QString accountName() const;
|
||||||
virtual const QString friendlyName() const;
|
virtual const QString friendlyName() const;
|
||||||
virtual ConnectionState connectionState() const;
|
virtual ConnectionState connectionState() const;
|
||||||
|
virtual QIcon icon() const;
|
||||||
virtual QWidget* configWidget();
|
virtual QWidget* configWidget();
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
@@ -146,7 +148,7 @@ private:
|
|||||||
bool m_finishedMentions;
|
bool m_finishedMentions;
|
||||||
ConnectionState m_state;
|
ConnectionState m_state;
|
||||||
|
|
||||||
TwitterConfigWidget *m_configWidget;
|
QWeakPointer<TwitterConfigWidget > m_configWidget;
|
||||||
|
|
||||||
// for settings access
|
// for settings access
|
||||||
friend class TwitterConfigWidget;
|
friend class TwitterConfigWidget;
|
||||||
|
@@ -6,10 +6,16 @@
|
|||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>795</width>
|
<width>438</width>
|
||||||
<height>509</height>
|
<height>266</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
|
<property name="minimumSize">
|
||||||
|
<size>
|
||||||
|
<width>0</width>
|
||||||
|
<height>0</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
<layout class="QVBoxLayout" name="verticalLayout_10">
|
<layout class="QVBoxLayout" name="verticalLayout_10">
|
||||||
<item>
|
<item>
|
||||||
<layout class="QVBoxLayout" name="twitterVertLayout">
|
<layout class="QVBoxLayout" name="twitterVertLayout">
|
||||||
|
@@ -36,6 +36,7 @@ public:
|
|||||||
|
|
||||||
virtual QString factoryId() const { return "sipzeroconf"; }
|
virtual QString factoryId() const { return "sipzeroconf"; }
|
||||||
virtual QString prettyName() const { return "Local Network"; }
|
virtual QString prettyName() const { return "Local Network"; }
|
||||||
|
virtual bool isCreatable() const { return false; };
|
||||||
virtual SipPlugin* createPlugin ( const QString& pluginId = QString() );
|
virtual SipPlugin* createPlugin ( const QString& pluginId = QString() );
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@@ -27,7 +27,7 @@
|
|||||||
SipConfigDelegate::SipConfigDelegate( QObject* parent )
|
SipConfigDelegate::SipConfigDelegate( QObject* parent )
|
||||||
: ConfigDelegateBase ( parent )
|
: ConfigDelegateBase ( parent )
|
||||||
{
|
{
|
||||||
|
connect( this, SIGNAL( configPressed( QModelIndex ) ), this, SLOT( askedForEdit( QModelIndex ) ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
@@ -44,7 +44,6 @@ SipConfigDelegate::paint ( QPainter* painter, const QStyleOptionViewItem& option
|
|||||||
QRect itemRect = opt.rect;
|
QRect itemRect = opt.rect;
|
||||||
int top = itemRect.top();
|
int top = itemRect.top();
|
||||||
int mid = itemRect.height() / 2;
|
int mid = itemRect.height() / 2;
|
||||||
int leftEdge = PADDING;
|
|
||||||
|
|
||||||
// one line bold for account name
|
// one line bold for account name
|
||||||
// space below it fro an error
|
// space below it fro an error
|
||||||
@@ -62,19 +61,91 @@ SipConfigDelegate::paint ( QPainter* painter, const QStyleOptionViewItem& option
|
|||||||
QStyle* style = w ? w->style() : QApplication::style();
|
QStyle* style = w ? w->style() : QApplication::style();
|
||||||
style->drawPrimitive( QStyle::PE_PanelItemViewItem, &opt, painter, w );
|
style->drawPrimitive( QStyle::PE_PanelItemViewItem, &opt, painter, w );
|
||||||
|
|
||||||
// draw checkbox first
|
int iconSize = 24;
|
||||||
int rectW = 24;
|
int checkLeftEdge = 8;
|
||||||
|
int iconLeftEdge = checkLeftEdge + iconSize + PADDING;
|
||||||
|
int textLeftEdge = iconLeftEdge + iconSize + PADDING;
|
||||||
|
|
||||||
|
if( index.data( SipModel::FactoryRole ).toBool() ) { // this is the "add new account" row
|
||||||
|
// draw a border and background
|
||||||
|
painter->save();
|
||||||
|
painter->setRenderHints( QPainter::Antialiasing );
|
||||||
|
painter->setBrush( QApplication::palette().color( QPalette::Active, QPalette::Highlight ).lighter( 150 ) );
|
||||||
|
QPainterPath roundedRect;
|
||||||
|
roundedRect.addRoundedRect( itemRect.adjusted( 1, 1, -1, -1 ), 3, 3 );
|
||||||
|
painter->drawPath( roundedRect );
|
||||||
|
painter->setBrush( QApplication::palette().color( QPalette::Active, QPalette::Highlight ).lighter( 170 ) );
|
||||||
|
painter->fillPath( roundedRect, painter->brush() );
|
||||||
|
painter->restore();
|
||||||
|
|
||||||
|
// draw "+" icon in checkbox column
|
||||||
|
int rectW = 18;
|
||||||
|
int diff = ( iconSize/ 2 ) - ( rectW / 2) ;
|
||||||
int pos = ( mid ) - ( rectW / 2 );
|
int pos = ( mid ) - ( rectW / 2 );
|
||||||
QRect checkRect = QRect( pos, pos + top, rectW, rectW );
|
QRect plusRect = QRect( checkLeftEdge + diff, pos + top, rectW, rectW );
|
||||||
|
QPixmap p( RESPATH "images/list-add.png" );
|
||||||
|
painter->drawPixmap( plusRect, p );
|
||||||
|
|
||||||
|
// draw text
|
||||||
|
QFont f = opt.font;
|
||||||
|
f.setPointSize( f.pointSize() );
|
||||||
|
f.setBold( true );
|
||||||
|
QFontMetrics fm( f );
|
||||||
|
QString text = index.data( Qt::DisplayRole ).toString();
|
||||||
|
QRect textR = fm.boundingRect( text );
|
||||||
|
textR.moveLeft( textLeftEdge );
|
||||||
|
textR.moveTop( mid - ( textR.height() / 2 ) + top );
|
||||||
|
textR.setRight( itemRect.right() );
|
||||||
|
painter->setFont( f );
|
||||||
|
painter->drawText( textR, text );
|
||||||
|
} else if( index.data( SipModel::FactoryItemRole ).toBool() ) { // this is an account type
|
||||||
|
|
||||||
|
// ConfigDelegateBase::paint( painter, opt, index );
|
||||||
|
// int indent = 10;
|
||||||
|
// draw a border and background
|
||||||
|
painter->save();
|
||||||
|
painter->setRenderHints( QPainter::Antialiasing );
|
||||||
|
painter->setBrush( QApplication::palette().color( QPalette::Active, QPalette::Highlight ).lighter( 170 ) );
|
||||||
|
QPainterPath roundedRect;
|
||||||
|
roundedRect.addRoundedRect( itemRect.adjusted( 1, 1, -1, -1 ), 3, 3 );
|
||||||
|
painter->drawPath( roundedRect );
|
||||||
|
painter->setBrush( QApplication::palette().color( QPalette::Active, QPalette::Highlight ).lighter( 180 ) );
|
||||||
|
painter->fillPath( roundedRect, painter->brush() );
|
||||||
|
painter->restore();
|
||||||
|
|
||||||
|
QIcon icon = index.data( SipModel::FactoryItemIcon ).value< QIcon >();
|
||||||
|
if( !icon.isNull() ) {
|
||||||
|
int rectW = 18;
|
||||||
|
int diff = ( iconSize/ 2 ) - ( rectW / 2) ;
|
||||||
|
int pos = ( mid ) - ( rectW / 2 );
|
||||||
|
QRect rect = QRect( checkLeftEdge + diff, pos + top, rectW, rectW );
|
||||||
|
QPixmap p( icon.pixmap( rect.size() ) );
|
||||||
|
painter->drawPixmap( rect, p );
|
||||||
|
}
|
||||||
|
|
||||||
|
// draw text
|
||||||
|
QFont f = opt.font;
|
||||||
|
f.setPointSize( f.pointSize() );
|
||||||
|
f.setBold( true );
|
||||||
|
QFontMetrics fm( f );
|
||||||
|
QString text = index.data( Qt::DisplayRole ).toString();
|
||||||
|
QRect textR = fm.boundingRect( text );
|
||||||
|
textR.moveLeft( textLeftEdge );
|
||||||
|
textR.moveTop( mid - ( textR.height() / 2 ) + top );
|
||||||
|
textR.setRight( itemRect.right() );
|
||||||
|
painter->setFont( f );
|
||||||
|
painter->drawText( textR, text );
|
||||||
|
} else { // this is an existing account to show
|
||||||
|
// draw checkbox first
|
||||||
|
int pos = ( mid ) - ( iconSize / 2 );
|
||||||
|
QRect checkRect = QRect( checkLeftEdge, pos + top, iconSize, iconSize );
|
||||||
opt.rect = checkRect;
|
opt.rect = checkRect;
|
||||||
drawCheckBox( opt, painter, w );
|
drawCheckBox( opt, painter, w );
|
||||||
|
|
||||||
// draw the icon if it exists
|
// draw the icon if it exists
|
||||||
leftEdge = checkRect.right() + PADDING;
|
|
||||||
int iconSize = 24;
|
|
||||||
pos = ( mid ) - ( iconSize / 2 );
|
pos = ( mid ) - ( iconSize / 2 );
|
||||||
if( !index.data( Qt::DecorationRole ).value< QIcon >().isNull() ) {
|
if( !index.data( Qt::DecorationRole ).value< QIcon >().isNull() ) {
|
||||||
QRect prect = QRect( leftEdge, pos + top, iconSize, iconSize );
|
QRect prect = QRect( iconLeftEdge, pos + top, iconSize, iconSize );
|
||||||
|
|
||||||
painter->save();
|
painter->save();
|
||||||
painter->drawPixmap( prect, index.data( Qt::DecorationRole ).value< QIcon >().pixmap( prect.size() ) );
|
painter->drawPixmap( prect, index.data( Qt::DecorationRole ).value< QIcon >().pixmap( prect.size() ) );
|
||||||
@@ -119,16 +190,15 @@ SipConfigDelegate::paint ( QPainter* painter, const QStyleOptionViewItem& option
|
|||||||
|
|
||||||
// name
|
// name
|
||||||
painter->save();
|
painter->save();
|
||||||
leftEdge = leftEdge + iconSize + PADDING;
|
|
||||||
QFontMetrics namefm( name );
|
QFontMetrics namefm( name );
|
||||||
int nameHeight = namefm.boundingRect( "test" ).height();
|
int nameHeight = namefm.boundingRect( "test" ).height();
|
||||||
// pos will the top-left point of the text rect
|
// pos will the top-left point of the text rect
|
||||||
pos = mid - ( nameHeight / 2 );
|
pos = mid - ( nameHeight / 2 );
|
||||||
// TODO bound with config icon and offline/online status
|
// TODO bound with config icon and offline/online status
|
||||||
width = itemRect.width() - leftEdge;
|
width = itemRect.width() - textLeftEdge;
|
||||||
|
|
||||||
if( !index.data( SipModel::ErrorString ).toString().isEmpty() ) { // error, show that too
|
if( !index.data( SipModel::ErrorString ).toString().isEmpty() ) { // error, show that too
|
||||||
QRect errorRect( leftEdge, mid + top, width, mid - PADDING );
|
QRect errorRect( textLeftEdge, mid + top, width, mid - PADDING );
|
||||||
|
|
||||||
QFontMetrics errorFm( error );
|
QFontMetrics errorFm( error );
|
||||||
QString str = errorFm.elidedText( index.data( SipModel::ErrorString ).toString(), Qt::ElideRight, errorRect.width() );
|
QString str = errorFm.elidedText( index.data( SipModel::ErrorString ).toString(), Qt::ElideRight, errorRect.width() );
|
||||||
@@ -139,6 +209,34 @@ SipConfigDelegate::paint ( QPainter* painter, const QStyleOptionViewItem& option
|
|||||||
}
|
}
|
||||||
QString nameStr = namefm.elidedText( index.data( Qt::DisplayRole ).toString(), Qt::ElideRight, width );
|
QString nameStr = namefm.elidedText( index.data( Qt::DisplayRole ).toString(), Qt::ElideRight, width );
|
||||||
painter->setFont( name );
|
painter->setFont( name );
|
||||||
painter->drawText( QRect( leftEdge, pos + top, width, nameHeight ), nameStr );
|
painter->drawText( QRect( textLeftEdge, pos + top, width, nameHeight ), nameStr );
|
||||||
painter->restore();
|
painter->restore();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QSize
|
||||||
|
SipConfigDelegate::sizeHint( const QStyleOptionViewItem& option, const QModelIndex& index ) const
|
||||||
|
{
|
||||||
|
if( index.data( SipModel::FactoryRole ).toBool() || index.data( SipModel::FactoryItemRole ).toBool() ) { // this is the "add new account" row
|
||||||
|
// enough space for one line of text
|
||||||
|
QStyleOptionViewItemV4 opt = option;
|
||||||
|
initStyleOption( &opt, index );
|
||||||
|
int width = QStyledItemDelegate::sizeHint( option, index ).width();
|
||||||
|
|
||||||
|
QFont name = opt.font;
|
||||||
|
name.setPointSize( name.pointSize() + 1 );
|
||||||
|
name.setBold( true );
|
||||||
|
QFontMetrics sfm( name );
|
||||||
|
return QSize( width, 3 * PADDING + sfm.height() );
|
||||||
|
} else { // this is an existing account to show
|
||||||
|
return ConfigDelegateBase::sizeHint( option, index );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
SipConfigDelegate::askedForEdit( const QModelIndex& idx )
|
||||||
|
{
|
||||||
|
emit openConfig( qobject_cast< SipPlugin* >( idx.data( SipModel::SipPluginData ).value< QObject* >() ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@@ -21,6 +21,8 @@
|
|||||||
|
|
||||||
#include "configdelegatebase.h"
|
#include "configdelegatebase.h"
|
||||||
|
|
||||||
|
class SipPlugin;
|
||||||
|
class SipPluginFactory;
|
||||||
class SipConfigDelegate : public ConfigDelegateBase
|
class SipConfigDelegate : public ConfigDelegateBase
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
@@ -29,6 +31,14 @@ public:
|
|||||||
|
|
||||||
virtual void paint ( QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index ) const;
|
virtual void paint ( QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index ) const;
|
||||||
virtual bool editorEvent ( QEvent* event, QAbstractItemModel* model, const QStyleOptionViewItem& option, const QModelIndex& index );
|
virtual bool editorEvent ( QEvent* event, QAbstractItemModel* model, const QStyleOptionViewItem& option, const QModelIndex& index );
|
||||||
|
virtual QSize sizeHint ( const QStyleOptionViewItem& option, const QModelIndex& index ) const;
|
||||||
|
|
||||||
|
private slots:
|
||||||
|
void askedForEdit( const QModelIndex& idx );
|
||||||
|
|
||||||
|
signals:
|
||||||
|
void sipFactoryClicked( SipPluginFactory* );
|
||||||
|
void openConfig( SipPlugin* );
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // SIPCONFIGDELEGATE_H
|
#endif // SIPCONFIGDELEGATE_H
|
||||||
|
Reference in New Issue
Block a user