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