diff --git a/src/TomahawkWindow.cpp b/src/TomahawkWindow.cpp index ff7490077..8f01a4103 100644 --- a/src/TomahawkWindow.cpp +++ b/src/TomahawkWindow.cpp @@ -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() { diff --git a/src/TomahawkWindow.h b/src/TomahawkWindow.h index 5715fee69..5191efce1 100644 --- a/src/TomahawkWindow.h +++ b/src/TomahawkWindow.h @@ -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(); diff --git a/src/widgets/AccountsToolButton.cpp b/src/widgets/AccountsToolButton.cpp index 09198e8b2..326276184 100644 --- a/src/widgets/AccountsToolButton.cpp +++ b/src/widgets/AccountsToolButton.cpp @@ -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(); } diff --git a/src/widgets/AccountsToolButton.h b/src/widgets/AccountsToolButton.h index 3034b5f1a..eb245946c 100644 --- a/src/widgets/AccountsToolButton.h +++ b/src/widgets/AccountsToolButton.h @@ -36,6 +36,9 @@ public: QSize sizeHint() const; +signals: + void widthChanged(); + protected: void mousePressEvent( QMouseEvent* event ); void paintEvent( QPaintEvent* event );