mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-08-06 14:16:32 +02:00
Initial account UI update. Buttons needs styling and implementation
This commit is contained in:
@@ -27,9 +27,9 @@
|
|||||||
#include "utils/tomahawkutils.h"
|
#include "utils/tomahawkutils.h"
|
||||||
#include "utils/logger.h"
|
#include "utils/logger.h"
|
||||||
|
|
||||||
#define ICONSIZE 36
|
#define ICONSIZE 34
|
||||||
#define WRENCH_SIZE 24
|
#define WRENCH_SIZE 24
|
||||||
#define STATUS_ICON_SIZE 18
|
#define STATUS_ICON_SIZE 13
|
||||||
#define CHECK_LEFT_EDGE 8
|
#define CHECK_LEFT_EDGE 8
|
||||||
|
|
||||||
using namespace Tomahawk;
|
using namespace Tomahawk;
|
||||||
@@ -39,6 +39,10 @@ AccountDelegate::AccountDelegate( QObject* parent )
|
|||||||
: ConfigDelegateBase ( parent )
|
: ConfigDelegateBase ( parent )
|
||||||
{
|
{
|
||||||
connect( this, SIGNAL( configPressed( QModelIndex ) ), this, SLOT( askedForEdit( QModelIndex ) ) );
|
connect( this, SIGNAL( configPressed( QModelIndex ) ), this, SLOT( askedForEdit( QModelIndex ) ) );
|
||||||
|
|
||||||
|
m_cachedIcons[ "sipplugin-online" ] = QPixmap( RESPATH "images/sipplugin-online.png" ).scaled( STATUS_ICON_SIZE, STATUS_ICON_SIZE, Qt::KeepAspectRatio, Qt::SmoothTransformation );
|
||||||
|
m_cachedIcons[ "sipplugin-offline" ] = QPixmap( RESPATH "images/sipplugin-offline.png" ).scaled( STATUS_ICON_SIZE, STATUS_ICON_SIZE, Qt::KeepAspectRatio, Qt::SmoothTransformation );
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
@@ -55,24 +59,25 @@ AccountDelegate::paint ( QPainter* painter, const QStyleOptionViewItem& option,
|
|||||||
const QRect itemRect = opt.rect;
|
const QRect itemRect = opt.rect;
|
||||||
const int top = itemRect.top();
|
const int top = itemRect.top();
|
||||||
const int mid = itemRect.height() / 2;
|
const int mid = itemRect.height() / 2;
|
||||||
|
const int quarter = mid - ( itemRect.height() / 4 );
|
||||||
|
|
||||||
// one line bold for account name
|
// one line bold for account name
|
||||||
// space below it for account description
|
// space below it for online/offline status
|
||||||
// checkbox, icon, name, online/offline status, config icon
|
// checkbox, icon, name/status, features, config icon
|
||||||
QFont name = opt.font;
|
QFont name = opt.font;
|
||||||
name.setPointSize( name.pointSize() + 2 );
|
name.setPointSize( name.pointSize() + 2 );
|
||||||
name.setBold( true );
|
name.setBold( true );
|
||||||
|
|
||||||
QFont desc = opt.font;
|
QFont smallFont = opt.font;
|
||||||
desc.setItalic( true );
|
smallFont.setPointSize( smallFont.pointSize() - 1 );
|
||||||
desc.setPointSize( desc.pointSize() - 2 );
|
QFontMetrics smallFontFM( smallFont );
|
||||||
|
|
||||||
// draw the background
|
// draw the background
|
||||||
const QWidget* w = opt.widget;
|
const QWidget* w = opt.widget;
|
||||||
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 );
|
||||||
|
|
||||||
int iconLeftEdge = CHECK_LEFT_EDGE + ICONSIZE + PADDING;
|
int iconLeftEdge = CHECK_LEFT_EDGE + WRENCH_SIZE + PADDING;
|
||||||
int textLeftEdge = iconLeftEdge + ICONSIZE + PADDING;
|
int textLeftEdge = iconLeftEdge + ICONSIZE + PADDING;
|
||||||
|
|
||||||
// draw checkbox first
|
// draw checkbox first
|
||||||
@@ -91,6 +96,51 @@ AccountDelegate::paint ( QPainter* painter, const QStyleOptionViewItem& option,
|
|||||||
painter->restore();
|
painter->restore();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// name
|
||||||
|
painter->save();
|
||||||
|
painter->setFont( name );
|
||||||
|
QFontMetrics namefm( name );
|
||||||
|
// pos will the top-left point of the text rect
|
||||||
|
pos = quarter - ( namefm.height() / 2 ) + top;
|
||||||
|
const QString nameStr = index.data( AccountModel::AccountName ).toString();
|
||||||
|
const int titleWidth = namefm.width( nameStr );
|
||||||
|
const QRect nameRect( textLeftEdge, pos, titleWidth, namefm.height() );
|
||||||
|
painter->drawText( nameRect, nameStr );
|
||||||
|
painter->restore();
|
||||||
|
|
||||||
|
// draw the online/offline status
|
||||||
|
const int stateY = mid + quarter - ( smallFontFM.height() / 2 ) + top;
|
||||||
|
|
||||||
|
QPixmap p;
|
||||||
|
QString statusText;
|
||||||
|
Account::ConnectionState state = static_cast< Account::ConnectionState >( index.data( AccountModel::ConnectionStateRole ).toInt() );
|
||||||
|
if ( state == Account::Connected )
|
||||||
|
{
|
||||||
|
p = m_cachedIcons[ "sipplugin-online" ];
|
||||||
|
statusText = tr( "Online" );
|
||||||
|
}
|
||||||
|
else if ( state == Account::Connecting )
|
||||||
|
{
|
||||||
|
p = m_cachedIcons[ "sipplugin-offline" ];
|
||||||
|
statusText = tr( "Connecting..." );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
p = m_cachedIcons[ "sipplugin-offline" ];
|
||||||
|
statusText = tr( "Offline" );
|
||||||
|
}
|
||||||
|
painter->drawPixmap( textLeftEdge, stateY, STATUS_ICON_SIZE, STATUS_ICON_SIZE, p );
|
||||||
|
|
||||||
|
int width = smallFontFM.width( statusText );
|
||||||
|
int statusTextX = textLeftEdge + STATUS_ICON_SIZE + PADDING;
|
||||||
|
painter->save();
|
||||||
|
painter->setFont( smallFont );
|
||||||
|
painter->drawText( QRect( statusTextX, stateY, width, smallFontFM.height() ), statusText );
|
||||||
|
painter->restore();
|
||||||
|
|
||||||
|
// right-most edge of text on left (name, desc) is the cutoff point for the rest of the delegate
|
||||||
|
width = qMax( statusTextX + width, textLeftEdge + titleWidth );
|
||||||
|
|
||||||
// from the right edge--config status and online/offline
|
// from the right edge--config status and online/offline
|
||||||
QRect confRect = QRect( itemRect.width() - WRENCH_SIZE - 2 * PADDING, mid - WRENCH_SIZE / 2 + top, WRENCH_SIZE, WRENCH_SIZE );
|
QRect confRect = QRect( itemRect.width() - WRENCH_SIZE - 2 * PADDING, mid - WRENCH_SIZE / 2 + top, WRENCH_SIZE, WRENCH_SIZE );
|
||||||
if( index.data( AccountModel::HasConfig ).toBool() ) {
|
if( index.data( AccountModel::HasConfig ).toBool() ) {
|
||||||
@@ -102,81 +152,34 @@ AccountDelegate::paint ( QPainter* painter, const QStyleOptionViewItem& option,
|
|||||||
drawConfigWrench( painter, opt, topt );
|
drawConfigWrench( painter, opt, topt );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const bool hasCapability = ( static_cast< Accounts::AccountTypes >( index.data( AccountModel::AccountTypeRole ).toInt() ) != Accounts::NoType );
|
||||||
// draw the online/offline status
|
|
||||||
const bool hasCapability = ( static_cast< AccountModel::BasicCapabilities >( index.data( AccountModel::BasicCapabilityRole ).toInt() ) != AccountModel::NoCapabilities );
|
|
||||||
const int quarter = mid - ( itemRect.height() / 4 );
|
|
||||||
const int statusY = hasCapability ? quarter : mid;
|
|
||||||
const int statusX = confRect.left() - 2*PADDING - STATUS_ICON_SIZE;
|
|
||||||
|
|
||||||
QFont statusF = opt.font;
|
|
||||||
statusF.setPointSize( statusF.pointSize() - 2 );
|
|
||||||
QFontMetrics statusFM( statusF );
|
|
||||||
|
|
||||||
QPixmap p;
|
|
||||||
QString statusText;
|
|
||||||
Account::ConnectionState state = static_cast< Account::ConnectionState >( index.data( AccountModel::ConnectionStateRole ).toInt() );
|
|
||||||
if( state == Account::Connected ) {
|
|
||||||
p = QPixmap( RESPATH "images/sipplugin-online.png" );
|
|
||||||
statusText = tr( "Online" );
|
|
||||||
} else if( state == Account::Connecting ) {
|
|
||||||
p = QPixmap( RESPATH "images/sipplugin-offline.png" );
|
|
||||||
statusText = tr( "Connecting..." );
|
|
||||||
} else {
|
|
||||||
p = QPixmap( RESPATH "images/sipplugin-offline.png" );
|
|
||||||
statusText = tr( "Offline" );
|
|
||||||
}
|
|
||||||
p = p.scaled( STATUS_ICON_SIZE, STATUS_ICON_SIZE, Qt::KeepAspectRatio, Qt::SmoothTransformation );
|
|
||||||
painter->drawPixmap( statusX, statusY - STATUS_ICON_SIZE / 2 + top, STATUS_ICON_SIZE, STATUS_ICON_SIZE, p );
|
|
||||||
int width = statusFM.width( statusText );
|
|
||||||
int statusTextX = statusX - PADDING - width;
|
|
||||||
painter->save();
|
|
||||||
painter->setFont( statusF );
|
|
||||||
painter->drawText( QRect( statusTextX, statusY - statusFM.height() / 2 + top, width, statusFM.height() ), statusText );
|
|
||||||
|
|
||||||
// draw optional capability text if it exists
|
// draw optional capability text if it exists
|
||||||
if ( hasCapability )
|
if ( hasCapability )
|
||||||
{
|
{
|
||||||
QString capString;
|
QString capString;
|
||||||
AccountModel::BasicCapabilities cap = static_cast< AccountModel::BasicCapabilities >( index.data( AccountModel::BasicCapabilityRole ).toInt() );
|
AccountTypes types = AccountTypes( index.data( AccountModel::AccountTypeRole ).toInt() );
|
||||||
if ( ( cap & AccountModel::SipCapability ) && ( cap & AccountModel::ResolverCapability ) )
|
if ( ( types & Accounts::SipType ) && ( types & Accounts::ResolverType ) )
|
||||||
capString = tr( "Connect to and play from friends" );
|
capString = tr( "Connects to, plays from friends" );
|
||||||
else if ( cap & AccountModel::SipCapability )
|
else if ( types & Accounts::SipType )
|
||||||
capString = tr( "Connect to friends" );
|
capString = tr( "Connects to friends" );
|
||||||
else if ( cap & AccountModel::ResolverCapability )
|
else if ( types & Accounts::ResolverType )
|
||||||
capString = tr( "Find Music");
|
capString = tr( "Finds Music");
|
||||||
|
|
||||||
// checkbox for capability
|
// checkbox for capability
|
||||||
const int capY = statusY + ( itemRect.height() / 2 );
|
// QRect capCheckRect( statusX, capY - STATUS_ICON_SIZE / 2 + top, STATUS_ICON_SIZE, STATUS_ICON_SIZE );
|
||||||
QRect capCheckRect( statusX, capY - STATUS_ICON_SIZE / 2 + top, STATUS_ICON_SIZE, STATUS_ICON_SIZE );
|
// opt.rect = capCheckRect;
|
||||||
opt.rect = capCheckRect;
|
// drawCheckBox( opt, painter, w );
|
||||||
drawCheckBox( opt, painter, w );
|
|
||||||
|
|
||||||
// text to accompany checkbox
|
// text to accompany checkbox
|
||||||
const int capW = statusFM.width( capString );
|
const int capY = mid - ( smallFontFM.height() / 2 ) + top;
|
||||||
const int capTextX = statusX - PADDING - capW;
|
const int configLeftEdge = confRect.left() - PADDING;
|
||||||
painter->drawText( QRect( capTextX, capY - statusFM.height() / 2 + top, capW, statusFM.height() ), capString );
|
const int capW = configLeftEdge - width;
|
||||||
|
// Right-align text
|
||||||
if ( capTextX < statusTextX )
|
const int capTextX = qMax( width, configLeftEdge - smallFontFM.width( capString ) );
|
||||||
statusTextX = capTextX;
|
painter->setFont( smallFont );
|
||||||
|
painter->drawText( QRect( capTextX, capY, configLeftEdge - capTextX, smallFontFM.height() ), Qt::AlignRight, capString );
|
||||||
}
|
}
|
||||||
painter->restore();
|
|
||||||
|
|
||||||
// name
|
|
||||||
painter->save();
|
|
||||||
painter->setFont( name );
|
|
||||||
QFontMetrics namefm( name );
|
|
||||||
// pos will the top-left point of the text rect
|
|
||||||
pos = mid - ( namefm.height() / 2 ) + top;
|
|
||||||
// TODO bound with config icon and offline/online status
|
|
||||||
width = itemRect.width() - statusTextX;
|
|
||||||
QRect nameRect( textLeftEdge, pos, width, namefm.height() );
|
|
||||||
painter->drawText( nameRect, index.data( AccountModel::AccountName ).toString() );
|
|
||||||
|
|
||||||
nameRect.translate( mid, 0 ); // move down by half the hight
|
|
||||||
painter->drawText( nameRect, index.data( AccountModel::DescText ).toString() );
|
|
||||||
painter->restore();
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QRect
|
QRect
|
||||||
@@ -192,7 +195,7 @@ AccountDelegate::checkRectForIndex( const QStyleOptionViewItem &option, const QM
|
|||||||
QRect checkRect( CHECK_LEFT_EDGE, pos + opt.rect.top(), ICONSIZE, ICONSIZE );
|
QRect checkRect( CHECK_LEFT_EDGE, pos + opt.rect.top(), ICONSIZE, ICONSIZE );
|
||||||
|
|
||||||
return checkRect;
|
return checkRect;
|
||||||
} else if ( role == AccountModel::BasicCapabilityRole )
|
} else if ( role == AccountModel::AccountTypeRole )
|
||||||
{
|
{
|
||||||
// The capabilities checkbox
|
// The capabilities checkbox
|
||||||
QStyleOptionViewItemV4 opt = option;
|
QStyleOptionViewItemV4 opt = option;
|
||||||
|
@@ -42,12 +42,15 @@ public:
|
|||||||
virtual QRect checkRectForIndex( const QStyleOptionViewItem &option, const QModelIndex &idx, int role ) const;
|
virtual QRect checkRectForIndex( const QStyleOptionViewItem &option, const QModelIndex &idx, int role ) const;
|
||||||
virtual QRect configRectForIndex( const QStyleOptionViewItem& option, const QModelIndex& idx ) const;
|
virtual QRect configRectForIndex( const QStyleOptionViewItem& option, const QModelIndex& idx ) const;
|
||||||
|
|
||||||
virtual QList<int> extraCheckRoles() const { return QList<int>() << (int)AccountModel::BasicCapabilityRole; }
|
virtual QList<int> extraCheckRoles() const { return QList<int>() << (int)AccountModel::AccountTypeRole; }
|
||||||
private slots:
|
private slots:
|
||||||
void askedForEdit( const QModelIndex& idx );
|
void askedForEdit( const QModelIndex& idx );
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void openConfig( Tomahawk::Accounts::Account* );
|
void openConfig( Tomahawk::Accounts::Account* );
|
||||||
|
|
||||||
|
private:
|
||||||
|
QMap< QString, QPixmap > m_cachedIcons;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -48,7 +48,7 @@ TwitterAccount::TwitterAccount( const QString &accountId )
|
|||||||
, m_isAuthenticated( false )
|
, m_isAuthenticated( false )
|
||||||
{
|
{
|
||||||
setAccountServiceName( "Twitter" );
|
setAccountServiceName( "Twitter" );
|
||||||
setTypes( QSet< AccountType >() << InfoType << SipType );
|
setTypes( AccountTypes( InfoType | SipType ) );
|
||||||
|
|
||||||
m_configWidget = QWeakPointer< TwitterConfigWidget >( new TwitterConfigWidget( this, 0 ) );
|
m_configWidget = QWeakPointer< TwitterConfigWidget >( new TwitterConfigWidget( this, 0 ) );
|
||||||
connect( m_configWidget.data(), SIGNAL( twitterAuthed( bool ) ), SLOT( configDialogAuthedSignalSlot( bool ) ) );
|
connect( m_configWidget.data(), SIGNAL( twitterAuthed( bool ) ), SLOT( configDialogAuthedSignalSlot( bool ) ) );
|
||||||
|
@@ -41,9 +41,7 @@ XmppAccount::XmppAccount( const QString &accountId )
|
|||||||
: Account( accountId )
|
: Account( accountId )
|
||||||
{
|
{
|
||||||
setAccountServiceName( "XMPP (Jabber)" );
|
setAccountServiceName( "XMPP (Jabber)" );
|
||||||
QSet< AccountType > types;
|
setTypes( SipType );
|
||||||
types << SipType;
|
|
||||||
setTypes( types );
|
|
||||||
|
|
||||||
m_configWidget = QWeakPointer< QWidget >( new XmppConfigWidget( this, 0 ) );
|
m_configWidget = QWeakPointer< QWidget >( new XmppConfigWidget( this, 0 ) );
|
||||||
}
|
}
|
||||||
|
@@ -66,7 +66,7 @@ ZeroconfAccount::ZeroconfAccount( const QString& accountId )
|
|||||||
setAccountServiceName( "Local Network" );
|
setAccountServiceName( "Local Network" );
|
||||||
setAccountFriendlyName( "Local Network" );
|
setAccountFriendlyName( "Local Network" );
|
||||||
|
|
||||||
setTypes( QSet< AccountType >() << SipType );
|
setTypes( SipType );
|
||||||
}
|
}
|
||||||
|
|
||||||
ZeroconfAccount::~ZeroconfAccount()
|
ZeroconfAccount::~ZeroconfAccount()
|
||||||
|
@@ -25,7 +25,7 @@
|
|||||||
#include "utils/tomahawkutils.h"
|
#include "utils/tomahawkutils.h"
|
||||||
#include "utils/logger.h"
|
#include "utils/logger.h"
|
||||||
|
|
||||||
#define ROW_HEIGHT 50
|
#define ROW_HEIGHT 40
|
||||||
|
|
||||||
ConfigDelegateBase::ConfigDelegateBase ( QObject* parent )
|
ConfigDelegateBase::ConfigDelegateBase ( QObject* parent )
|
||||||
: QStyledItemDelegate ( parent )
|
: QStyledItemDelegate ( parent )
|
||||||
|
@@ -60,7 +60,7 @@ public:
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
~DelegateConfigWrapper() { delete m_widget; }
|
~DelegateConfigWrapper() {}
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void toggleOkButton( bool dataError )
|
void toggleOkButton( bool dataError )
|
||||||
|
@@ -147,39 +147,33 @@ Account::removeFromConfig()
|
|||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
Account::setTypes( const QSet< AccountType > types )
|
Account::setTypes( AccountTypes types )
|
||||||
{
|
{
|
||||||
QMutexLocker locker( &m_mutex );
|
QMutexLocker locker( &m_mutex );
|
||||||
m_types = QStringList();
|
m_types = QStringList();
|
||||||
foreach ( AccountType type, types )
|
if ( types & InfoType )
|
||||||
{
|
m_types << "InfoType";
|
||||||
switch( type )
|
if ( types & SipType )
|
||||||
{
|
m_types << "SipType";
|
||||||
case InfoType:
|
if ( types & ResolverType )
|
||||||
m_types << "InfoType";
|
m_types << "ResolverType";
|
||||||
break;
|
|
||||||
case SipType:
|
|
||||||
m_types << "SipType";
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
syncConfig();
|
syncConfig();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
QSet< AccountType >
|
AccountTypes
|
||||||
Account::types() const
|
Account::types() const
|
||||||
{
|
{
|
||||||
QMutexLocker locker( &m_mutex );
|
QMutexLocker locker( &m_mutex );
|
||||||
QSet< AccountType > set;
|
AccountTypes types;
|
||||||
foreach ( QString type, m_types )
|
if ( m_types.contains( "InfoType" ) )
|
||||||
{
|
types |= InfoType;
|
||||||
if ( type == "InfoType" )
|
if ( m_types.contains( "SipType" ) )
|
||||||
set << InfoType;
|
types |= SipType;
|
||||||
else if ( type == "SipType" )
|
if ( m_types.contains( "ResolverType" ) )
|
||||||
set << SipType;
|
types |= ResolverType;
|
||||||
}
|
|
||||||
return set;
|
return types;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@@ -44,7 +44,16 @@ namespace InfoSystem
|
|||||||
namespace Accounts
|
namespace Accounts
|
||||||
{
|
{
|
||||||
|
|
||||||
enum AccountType { InfoType, SipType };
|
enum AccountType
|
||||||
|
{
|
||||||
|
NoType = 0x00,
|
||||||
|
|
||||||
|
InfoType = 0x01,
|
||||||
|
SipType = 0x02,
|
||||||
|
ResolverType = 0x04
|
||||||
|
};
|
||||||
|
|
||||||
|
Q_DECLARE_FLAGS(AccountTypes, AccountType);
|
||||||
|
|
||||||
inline QString generateId( const QString &factoryId )
|
inline QString generateId( const QString &factoryId )
|
||||||
{
|
{
|
||||||
@@ -92,7 +101,7 @@ public:
|
|||||||
virtual Tomahawk::InfoSystem::InfoPlugin* infoPlugin() = 0;
|
virtual Tomahawk::InfoSystem::InfoPlugin* infoPlugin() = 0;
|
||||||
virtual SipPlugin* sipPlugin() = 0;
|
virtual SipPlugin* sipPlugin() = 0;
|
||||||
|
|
||||||
QSet< AccountType > types() const;
|
AccountTypes types() const;
|
||||||
|
|
||||||
void setAccountServiceName( const QString &serviceName ) { QMutexLocker locker( &m_mutex ); m_accountServiceName = serviceName; }
|
void setAccountServiceName( const QString &serviceName ) { QMutexLocker locker( &m_mutex ); m_accountServiceName = serviceName; }
|
||||||
void setAccountFriendlyName( const QString &friendlyName ) { QMutexLocker locker( &m_mutex ); m_accountFriendlyName = friendlyName; }
|
void setAccountFriendlyName( const QString &friendlyName ) { QMutexLocker locker( &m_mutex ); m_accountFriendlyName = friendlyName; }
|
||||||
@@ -102,7 +111,7 @@ public:
|
|||||||
void setCredentials( const QVariantHash &credentialHash ) { QMutexLocker locker( &m_mutex ); m_credentials = credentialHash; }
|
void setCredentials( const QVariantHash &credentialHash ) { QMutexLocker locker( &m_mutex ); m_credentials = credentialHash; }
|
||||||
void setConfiguration( const QVariantHash &configuration ) { QMutexLocker locker( &m_mutex ); m_configuration = configuration; }
|
void setConfiguration( const QVariantHash &configuration ) { QMutexLocker locker( &m_mutex ); m_configuration = configuration; }
|
||||||
void setAcl( const QVariantMap &acl ) { QMutexLocker locker( &m_mutex ); m_acl = acl; }
|
void setAcl( const QVariantMap &acl ) { QMutexLocker locker( &m_mutex ); m_acl = acl; }
|
||||||
void setTypes( const QSet< AccountType > types );
|
void setTypes( AccountTypes types );
|
||||||
|
|
||||||
virtual void sync() { QMutexLocker locker( &m_mutex ); syncConfig(); };
|
virtual void sync() { QMutexLocker locker( &m_mutex ); syncConfig(); };
|
||||||
|
|
||||||
|
@@ -175,7 +175,7 @@ AccountManager::connectAll()
|
|||||||
{
|
{
|
||||||
foreach( Account* acc, m_accounts )
|
foreach( Account* acc, m_accounts )
|
||||||
{
|
{
|
||||||
if ( acc->types().contains( Accounts::SipType ) && acc->sipPlugin() )
|
if ( acc->types() & Accounts::SipType && acc->sipPlugin() )
|
||||||
acc->sipPlugin()->connectPlugin();
|
acc->sipPlugin()->connectPlugin();
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -252,8 +252,12 @@ AccountManager::addAccount( Account* account )
|
|||||||
tDebug() << Q_FUNC_INFO << "adding account plugin";
|
tDebug() << Q_FUNC_INFO << "adding account plugin";
|
||||||
m_accounts.append( account );
|
m_accounts.append( account );
|
||||||
|
|
||||||
foreach( AccountType type, account->types() )
|
if ( account->types() & Accounts::SipType )
|
||||||
m_accountsByAccountType[ type ].append( account );
|
m_accountsByAccountType[ Accounts::SipType ].append( account );
|
||||||
|
if ( account->types() & Accounts::InfoType )
|
||||||
|
m_accountsByAccountType[ Accounts::InfoType ].append( account );
|
||||||
|
if ( account->types() & Accounts::ResolverType )
|
||||||
|
m_accountsByAccountType[ Accounts::ResolverType ].append( account );
|
||||||
|
|
||||||
emit added( account );
|
emit added( account );
|
||||||
}
|
}
|
||||||
@@ -330,7 +334,7 @@ AccountManager::onSettingsChanged()
|
|||||||
{
|
{
|
||||||
foreach( Account* account, m_accounts )
|
foreach( Account* account, m_accounts )
|
||||||
{
|
{
|
||||||
if ( account->types().contains( Accounts::SipType ) && account->sipPlugin() )
|
if ( account->types() & Accounts::SipType && account->sipPlugin() )
|
||||||
account->sipPlugin()->checkSettings();
|
account->sipPlugin()->checkSettings();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -58,6 +58,8 @@ AccountModel::data( const QModelIndex& index, int role ) const
|
|||||||
return account->connectionState();
|
return account->connectionState();
|
||||||
case AccountModel::HasConfig:
|
case AccountModel::HasConfig:
|
||||||
return ( account->configurationWidget() != 0 );
|
return ( account->configurationWidget() != 0 );
|
||||||
|
case AccountModel::AccountTypeRole:
|
||||||
|
return (int)account->types();
|
||||||
case Qt::DecorationRole:
|
case Qt::DecorationRole:
|
||||||
return account->icon();
|
return account->icon();
|
||||||
case AccountModel::AccountData:
|
case AccountModel::AccountData:
|
||||||
@@ -90,7 +92,7 @@ AccountModel::setData( const QModelIndex& index, const QVariant& value, int role
|
|||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else if ( role == BasicCapabilityRole )
|
else if ( role == AccountTypeRole )
|
||||||
{
|
{
|
||||||
// TODO
|
// TODO
|
||||||
}
|
}
|
||||||
@@ -115,7 +117,7 @@ AccountModel::accountAdded( Account* account )
|
|||||||
{
|
{
|
||||||
// TODO HACK we assume account plugins are added at the end of the list.
|
// TODO HACK we assume account plugins are added at the end of the list.
|
||||||
Q_ASSERT( AccountManager::instance()->accounts().last() == account );
|
Q_ASSERT( AccountManager::instance()->accounts().last() == account );
|
||||||
if ( account->types().contains( SipType ) )
|
if ( account->types() & SipType )
|
||||||
connect( account, SIGNAL( connectionStateChanged( Tomahawk::Accounts::Account::ConnectionState ) ), this, SLOT( accountStateChanged( Tomahawk::Accounts::Account::ConnectionState ) ) );
|
connect( account, SIGNAL( connectionStateChanged( Tomahawk::Accounts::Account::ConnectionState ) ), this, SLOT( accountStateChanged( Tomahawk::Accounts::Account::ConnectionState ) ) );
|
||||||
|
|
||||||
int size = AccountManager::instance()->accounts().count() - 1;
|
int size = AccountManager::instance()->accounts().count() - 1;
|
||||||
|
@@ -37,19 +37,11 @@ class DLLEXPORT AccountModel : public QAbstractListModel
|
|||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
enum BasicCapabilities
|
|
||||||
{
|
|
||||||
NoCapabilities = 0,
|
|
||||||
SipCapability = 0x1,
|
|
||||||
ResolverCapability = 0x2
|
|
||||||
};
|
|
||||||
|
|
||||||
enum Roles {
|
enum Roles {
|
||||||
AccountName = Qt::UserRole + 15,
|
AccountName = Qt::UserRole + 15,
|
||||||
AccountIcon = Qt::UserRole + 16,
|
AccountIcon = Qt::UserRole + 16,
|
||||||
HeadlineText = Qt::UserRole + 17,
|
HeadlineText = Qt::UserRole + 17,
|
||||||
DescText = Qt::UserRole + 18,
|
AccountTypeRole = Qt::UserRole + 19,
|
||||||
BasicCapabilityRole = Qt::UserRole + 19,
|
|
||||||
ConnectionStateRole = Qt::UserRole + 20,
|
ConnectionStateRole = Qt::UserRole + 20,
|
||||||
HasConfig = Qt::UserRole + 21,
|
HasConfig = Qt::UserRole + 21,
|
||||||
ErrorString = Qt::UserRole + 22,
|
ErrorString = Qt::UserRole + 22,
|
||||||
|
@@ -318,7 +318,7 @@ PlaylistDelegate::paint( QPainter* painter, const QStyleOptionViewItem& option,
|
|||||||
|
|
||||||
painter->setFont( font );
|
painter->setFont( font );
|
||||||
QString author = index.data( RecentlyPlayedPlaylistsModel::PlaylistRole ).value< Tomahawk::playlist_ptr >()->author()->friendlyName();
|
QString author = index.data( RecentlyPlayedPlaylistsModel::PlaylistRole ).value< Tomahawk::playlist_ptr >()->author()->friendlyName();
|
||||||
if ( author.contains( "@" ) )
|
if ( author.indexOf( '@' ) > 0 )
|
||||||
author = author.mid( 0, author.indexOf( '@' ) );
|
author = author.mid( 0, author.indexOf( '@' ) );
|
||||||
|
|
||||||
const int w = painter->fontMetrics().width( author ) + 2;
|
const int w = painter->fontMetrics().width( author ) + 2;
|
||||||
|
@@ -1,6 +1,7 @@
|
|||||||
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
|
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
|
||||||
*
|
*
|
||||||
* Copyright 2010-2011, Christian Muehlhaeuser <muesli@tomahawk-player.org>
|
* Copyright 2010-2011, Christian Muehlhaeuser <muesli@tomahawk-player.org>
|
||||||
|
* Copyright 2011, Leo Franchi <lfranchi@kde.org>
|
||||||
*
|
*
|
||||||
* Tomahawk is free software: you can redistribute it and/or modify
|
* Tomahawk is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
@@ -86,8 +86,6 @@ SettingsDialog::SettingsDialog( QWidget *parent )
|
|||||||
TomahawkUtils::unmarginLayout( layout() );
|
TomahawkUtils::unmarginLayout( layout() );
|
||||||
ui->stackedWidget->setContentsMargins( 4, 4, 4, 0 );
|
ui->stackedWidget->setContentsMargins( 4, 4, 4, 0 );
|
||||||
|
|
||||||
ui->addSipButton->setFixedWidth( 42 );
|
|
||||||
ui->removeSipButton->setFixedWidth( ui->addSipButton->width() );
|
|
||||||
ui->addScript->setFixedWidth( 42 );
|
ui->addScript->setFixedWidth( 42 );
|
||||||
ui->removeScript->setFixedWidth( ui->addScript->width() );
|
ui->removeScript->setFixedWidth( ui->addScript->width() );
|
||||||
|
|
||||||
@@ -133,8 +131,8 @@ SettingsDialog::SettingsDialog( QWidget *parent )
|
|||||||
m_sipSpinner = new LoadingSpinner( ui->accountsView );
|
m_sipSpinner = new LoadingSpinner( ui->accountsView );
|
||||||
m_sipSpinner->fadeIn();
|
m_sipSpinner->fadeIn();
|
||||||
|
|
||||||
ui->addSipButton->setEnabled( false );
|
ui->addNewServiceBtn->setEnabled( false );
|
||||||
ui->removeSipButton->setEnabled( false );
|
ui->removeServiceBtn->setEnabled( false );
|
||||||
connect( Servent::instance(), SIGNAL( ready() ), this, SLOT( serventReady() ) );
|
connect( Servent::instance(), SIGNAL( ready() ), this, SLOT( serventReady() ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -260,8 +258,8 @@ void
|
|||||||
SettingsDialog::serventReady()
|
SettingsDialog::serventReady()
|
||||||
{
|
{
|
||||||
m_sipSpinner->fadeOut();
|
m_sipSpinner->fadeOut();
|
||||||
ui->addSipButton->setEnabled( true );
|
ui->addNewServiceBtn->setEnabled( true );
|
||||||
ui->removeSipButton->setEnabled( true );
|
ui->removeScript->setEnabled( true );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -330,21 +328,21 @@ SettingsDialog::createIcons()
|
|||||||
void
|
void
|
||||||
SettingsDialog::setupAccountButtons()
|
SettingsDialog::setupAccountButtons()
|
||||||
{
|
{
|
||||||
foreach( AccountFactory* f, AccountManager::instance()->factories() )
|
// foreach( AccountFactory* f, AccountManager::instance()->factories() )
|
||||||
{
|
// {
|
||||||
if( f->isUnique() && AccountManager::instance()->hasPluginWithFactory( f->factoryId() ) )
|
// if( f->isUnique() && AccountManager::instance()->hasPluginWithFactory( f->factoryId() ) )
|
||||||
{
|
// {
|
||||||
continue;
|
// 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 ) ) );
|
||||||
|
// }
|
||||||
|
|
||||||
QAction* action = new QAction( f->icon(), f->prettyName(), ui->addSipButton );
|
connect( ui->removeServiceBtn, SIGNAL( clicked( bool ) ), this, SLOT( accountDeleted( bool ) ) );
|
||||||
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( accountDeleted( bool ) ) );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -731,21 +729,21 @@ SettingsDialog::handleAccountAdded( Account* account, bool added )
|
|||||||
AccountManager::instance()->addAccount( account );
|
AccountManager::instance()->addAccount( account );
|
||||||
AccountManager::instance()->hookupAndEnable( account );
|
AccountManager::instance()->hookupAndEnable( account );
|
||||||
|
|
||||||
if ( f && f->isUnique() )
|
// if ( f && f->isUnique() )
|
||||||
{
|
// {
|
||||||
// remove from actions list
|
// // remove from actions list
|
||||||
QAction* toremove = 0;
|
// QAction* toremove = 0;
|
||||||
foreach( QAction* a, ui->addSipButton->actions() )
|
// foreach( QAction* a, ui->addSipButton->actions() )
|
||||||
{
|
// {
|
||||||
if( f == qobject_cast< AccountFactory* >( a->property( "factory" ).value< QObject* >() ) )
|
// if( f == qobject_cast< AccountFactory* >( a->property( "factory" ).value< QObject* >() ) )
|
||||||
{
|
// {
|
||||||
toremove = a;
|
// toremove = a;
|
||||||
break;
|
// break;
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
if ( toremove )
|
// if ( toremove )
|
||||||
ui->addSipButton->removeAction( toremove );
|
// ui->addSipButton->removeAction( toremove );
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -778,14 +776,14 @@ SettingsDialog::onAccountRowDeleted( bool )
|
|||||||
|
|
||||||
if( AccountFactory* f = AccountManager::instance()->factoryForAccount( account ) )
|
if( AccountFactory* f = AccountManager::instance()->factoryForAccount( account ) )
|
||||||
{
|
{
|
||||||
if( f->isUnique() ) // just deleted a unique plugin->re-add to add menu
|
// if( f->isUnique() ) // just deleted a unique plugin->re-add to add menu
|
||||||
{
|
// {
|
||||||
QAction* action = new QAction( f->icon(), f->prettyName(), ui->addSipButton );
|
// QAction* action = new QAction( f->icon(), f->prettyName(), ui->addSipButton );
|
||||||
action->setProperty( "factory", QVariant::fromValue< QObject* >( f ) );
|
// action->setProperty( "factory", QVariant::fromValue< QObject* >( f ) );
|
||||||
ui->addSipButton->addAction( action );
|
// ui->addSipButton->addAction( action );
|
||||||
|
//
|
||||||
connect( action, SIGNAL( triggered(bool) ), this, SLOT( factoryActionTriggered( bool ) ) );
|
// connect( action, SIGNAL( triggered(bool) ), this, SLOT( factoryActionTriggered( bool ) ) );
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
AccountManager::instance()->removeAccount( account );
|
AccountManager::instance()->removeAccount( account );
|
||||||
@@ -805,14 +803,14 @@ SettingsDialog::accountDeleted( bool )
|
|||||||
|
|
||||||
if( AccountFactory* f = AccountManager::instance()->factoryForAccount( account ) )
|
if( AccountFactory* f = AccountManager::instance()->factoryForAccount( account ) )
|
||||||
{
|
{
|
||||||
if( f->isUnique() ) // just deleted a unique plugin->re-add to add menu
|
// if( f->isUnique() ) // just deleted a unique plugin->re-add to add menu
|
||||||
{
|
// {
|
||||||
QAction* action = new QAction( f->icon(), f->prettyName(), ui->addSipButton );
|
// QAction* action = new QAction( f->icon(), f->prettyName(), ui->addSipButton );
|
||||||
action->setProperty( "factory", QVariant::fromValue< QObject* >( f ) );
|
// action->setProperty( "factory", QVariant::fromValue< QObject* >( f ) );
|
||||||
ui->addSipButton->addAction( action );
|
// ui->addSipButton->addAction( action );
|
||||||
|
//
|
||||||
connect( action, SIGNAL( triggered(bool) ), this, SLOT( factoryActionTriggered( bool ) ) );
|
// connect( action, SIGNAL( triggered(bool) ), this, SLOT( factoryActionTriggered( bool ) ) );
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
AccountManager::instance()->removeAccount( account );
|
AccountManager::instance()->removeAccount( account );
|
||||||
}
|
}
|
||||||
|
@@ -6,8 +6,8 @@
|
|||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>641</width>
|
<width>655</width>
|
||||||
<height>393</height>
|
<height>500</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="windowTitle">
|
<property name="windowTitle">
|
||||||
@@ -95,87 +95,74 @@
|
|||||||
<item>
|
<item>
|
||||||
<widget class="QGroupBox" name="groupBox_4">
|
<widget class="QGroupBox" name="groupBox_4">
|
||||||
<property name="title">
|
<property name="title">
|
||||||
<string>Accounts</string>
|
<string>Internet Sources</string>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QVBoxLayout" name="verticalLayout_14">
|
<layout class="QVBoxLayout" name="verticalLayout_14">
|
||||||
<property name="margin">
|
<property name="margin">
|
||||||
<number>2</number>
|
<number>2</number>
|
||||||
</property>
|
</property>
|
||||||
<item>
|
|
||||||
<widget class="QLabel" name="label_2">
|
|
||||||
<property name="text">
|
|
||||||
<string>Connect to your friends with Google Chat, Twitter, and more.</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
<item>
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
||||||
<item>
|
<item>
|
||||||
<widget class="QTreeView" name="accountsView">
|
<widget class="QPushButton" name="showResolvers">
|
||||||
<property name="indentation">
|
<property name="text">
|
||||||
<number>0</number>
|
<string>Show music sources</string>
|
||||||
</property>
|
|
||||||
<property name="rootIsDecorated">
|
|
||||||
<bool>false</bool>
|
|
||||||
</property>
|
|
||||||
<property name="uniformRowHeights">
|
|
||||||
<bool>false</bool>
|
|
||||||
</property>
|
|
||||||
<property name="animated">
|
|
||||||
<bool>true</bool>
|
|
||||||
</property>
|
|
||||||
<property name="headerHidden">
|
|
||||||
<bool>true</bool>
|
|
||||||
</property>
|
|
||||||
<property name="expandsOnDoubleClick">
|
|
||||||
<bool>false</bool>
|
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<layout class="QVBoxLayout" name="addSipLayout">
|
<widget class="QPushButton" name="showSIP">
|
||||||
<item>
|
<property name="text">
|
||||||
<widget class="QToolButton" name="addSipButton">
|
<string>Show friend sources</string>
|
||||||
<property name="text">
|
</property>
|
||||||
<string>...</string>
|
</widget>
|
||||||
</property>
|
</item>
|
||||||
<property name="icon">
|
<item>
|
||||||
<iconset resource="../resources.qrc">
|
<widget class="QPushButton" name="showPushAccounts">
|
||||||
<normaloff>:/data/images/sipplugin-add.png</normaloff>:/data/images/sipplugin-add.png</iconset>
|
<property name="text">
|
||||||
</property>
|
<string>Show update services</string>
|
||||||
<property name="popupMode">
|
</property>
|
||||||
<enum>QToolButton::InstantPopup</enum>
|
</widget>
|
||||||
</property>
|
</item>
|
||||||
</widget>
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QToolButton" name="removeSipButton">
|
<widget class="QTreeView" name="accountsView">
|
||||||
<property name="text">
|
<property name="indentation">
|
||||||
<string>...</string>
|
<number>0</number>
|
||||||
</property>
|
</property>
|
||||||
<property name="icon">
|
<property name="rootIsDecorated">
|
||||||
<iconset resource="../resources.qrc">
|
<bool>false</bool>
|
||||||
<normaloff>:/data/images/sipplugin-remove.png</normaloff>:/data/images/sipplugin-remove.png</iconset>
|
</property>
|
||||||
</property>
|
<property name="uniformRowHeights">
|
||||||
<property name="popupMode">
|
<bool>false</bool>
|
||||||
<enum>QToolButton::DelayedPopup</enum>
|
</property>
|
||||||
</property>
|
<property name="animated">
|
||||||
</widget>
|
<bool>true</bool>
|
||||||
</item>
|
</property>
|
||||||
<item>
|
<property name="headerHidden">
|
||||||
<spacer name="verticalSpacer_6">
|
<bool>true</bool>
|
||||||
<property name="orientation">
|
</property>
|
||||||
<enum>Qt::Vertical</enum>
|
<property name="expandsOnDoubleClick">
|
||||||
</property>
|
<bool>false</bool>
|
||||||
<property name="sizeHint" stdset="0">
|
</property>
|
||||||
<size>
|
</widget>
|
||||||
<width>20</width>
|
</item>
|
||||||
<height>40</height>
|
<item>
|
||||||
</size>
|
<layout class="QHBoxLayout" name="horizontalLayout_5">
|
||||||
</property>
|
<item>
|
||||||
</spacer>
|
<widget class="QPushButton" name="addNewServiceBtn">
|
||||||
</item>
|
<property name="text">
|
||||||
</layout>
|
<string>Add new service...</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QPushButton" name="removeServiceBtn">
|
||||||
|
<property name="text">
|
||||||
|
<string>Remove Service</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
|
@@ -690,8 +690,7 @@ TomahawkWindow::onAccountDisconnected()
|
|||||||
void
|
void
|
||||||
TomahawkWindow::onAccountAdded( Account* acc )
|
TomahawkWindow::onAccountAdded( Account* acc )
|
||||||
{
|
{
|
||||||
if ( !acc->types().contains( SipType ) ||
|
if ( !acc->types() & SipType || !acc->sipPlugin() )
|
||||||
!acc->sipPlugin() )
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
connect( acc->sipPlugin(), SIGNAL( addMenu( QMenu* ) ), this, SLOT( pluginMenuAdded( QMenu* ) ) );
|
connect( acc->sipPlugin(), SIGNAL( addMenu( QMenu* ) ), this, SLOT( pluginMenuAdded( QMenu* ) ) );
|
||||||
|
Reference in New Issue
Block a user