1
0
mirror of https://github.com/tomahawk-player/tomahawk.git synced 2025-03-31 06:02:27 +02:00

Removed old account toolbuttons and fixed toolbar balancing.

This commit is contained in:
Teo Mrnjavac 2012-08-15 16:51:48 +02:00
parent 98507c733f
commit 0542f4f63f
4 changed files with 9 additions and 70 deletions

View File

@ -288,7 +288,8 @@ TomahawkWindow::setupToolBar()
m_accountsButton = new AccountsToolButton( m_toolbar );
m_toolbar->addWidget( m_accountsButton );
//TODO: hook up signals for the new accounts widget
connect( m_accountsButton, SIGNAL( widthChanged() ),
this, SLOT( balanceToolbar() ) );
#ifndef Q_OS_MAC
ContainedMenuButton* compactMenuButton = new ContainedMenuButton( m_toolbar );
@ -541,18 +542,6 @@ TomahawkWindow::setupSignals()
connect( AccountManager::instance(), SIGNAL( disconnected( Tomahawk::Accounts::Account* ) ), SLOT( onAccountDisconnected() ) );
connect( AccountManager::instance(), SIGNAL( authError( Tomahawk::Accounts::Account* ) ), SLOT( onAccountError() ) );
// Menus for accounts that support them
connect( AccountManager::instance(), SIGNAL( added( Tomahawk::Accounts::Account* ) ), this, SLOT( onAccountAdded( Tomahawk::Accounts::Account* ) ) );
foreach ( Account* account, AccountManager::instance()->accounts( Tomahawk::Accounts::SipType ) )
{
if ( !account || !account->sipPlugin() )
continue;
connect( account->sipPlugin(), SIGNAL( addMenu( QMenu* ) ), this, SLOT( pluginMenuAdded( QMenu* ) ) );
connect( account->sipPlugin(), SIGNAL( removeMenu( QMenu* ) ), this, SLOT( pluginMenuRemoved( QMenu* ) ) );
}
connect( ViewManager::instance(), SIGNAL( historyBackAvailable( bool ) ), SLOT( onHistoryBackAvailable( bool ) ) );
connect( ViewManager::instance(), SIGNAL( historyForwardAvailable( bool ) ), SLOT( onHistoryForwardAvailable( bool ) ) );
}
@ -881,48 +870,6 @@ TomahawkWindow::addPeerManually()
}
void
TomahawkWindow::pluginMenuAdded( QMenu* menu )
{
SipPlugin* plugin = qobject_cast< SipPlugin* >( sender() );
if ( plugin )
{
ContainedMenuButton *button = new ContainedMenuButton( m_toolbar );
button->setIcon( plugin->account()->icon() );
button->setText( menu->title() );
button->setMenu( menu );
button->setToolButtonStyle( Qt::ToolButtonIconOnly );
#ifdef Q_OS_MAC
QAction *action = m_toolbar->addWidget( button );
#else
QAction *action = m_toolbar->insertWidget( m_compactMenuAction, button );
#endif
action->setProperty( "id", plugin->account()->accountId() );
balanceToolbar();
}
}
void
TomahawkWindow::pluginMenuRemoved( QMenu* menu )
{
Q_UNUSED( menu )
SipPlugin* plugin = qobject_cast< SipPlugin* >( sender() );
if ( plugin )
{
foreach ( QAction* action, m_toolbar->actions() )
{
if ( action->property( "id" ) == plugin->account()->accountId() )
{
m_toolbar->removeAction( action );
return;
}
}
balanceToolbar();
}
}
void
TomahawkWindow::showOfflineSources()
{
@ -1221,17 +1168,6 @@ TomahawkWindow::onAccountDisconnected()
}
void
TomahawkWindow::onAccountAdded( Account* acc )
{
if ( !acc->types() & SipType || !acc->sipPlugin() )
return;
connect( acc->sipPlugin(), SIGNAL( addMenu( QMenu* ) ), this, SLOT( pluginMenuAdded( QMenu* ) ) );
connect( acc->sipPlugin(), SIGNAL( removeMenu( QMenu* ) ), this, SLOT( pluginMenuRemoved( QMenu* ) ) );
}
void
TomahawkWindow::onAccountError()
{

View File

@ -100,15 +100,12 @@ public slots:
void legalInfo();
void updateCollectionManually();
void rescanCollectionManually();
void pluginMenuAdded( QMenu* );
void pluginMenuRemoved( QMenu* );
void showOfflineSources();
void fullScreenEntered();
void fullScreenExited();
private slots:
void onAccountAdded( Tomahawk::Accounts::Account* account );
void onAccountConnected();
void onAccountDisconnected();
void onAccountError();
@ -149,6 +146,7 @@ private slots:
void crashNow();
void toggleMenuBar();
void balanceToolbar();
#ifdef Q_OS_WIN
void audioStateChanged( AudioState newState, AudioState oldState );
@ -165,7 +163,6 @@ private:
void setupToolBar();
void setupSideBar();
void setupUpdateCheck();
void balanceToolbar();
#ifdef Q_OS_WIN
bool setupWindowsButtons();

View File

@ -159,6 +159,7 @@ void
AccountsToolButton::updateIcons()
{
m_factoryPixmaps.clear();
int oldWidth = sizeHint().width();
for ( int i = 0; i < m_proxy->rowCount(); ++i )
{
@ -208,6 +209,8 @@ AccountsToolButton::updateIcons()
}
resize( sizeHint() );
if ( oldWidth != sizeHint().width() )
emit widthChanged();
repaint();
}

View File

@ -36,6 +36,9 @@ public:
QSize sizeHint() const;
signals:
void widthChanged();
protected:
void mousePressEvent( QMouseEvent* event );
void paintEvent( QPaintEvent* event );