mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-10-05 01:52:28 +02:00
Moved all menu actions to ActionCollection and removed menubar from .ui.
This commit does several things: * remove the main menu from TomahawkWindow.ui * all menu actions are created in ActionCollection.cpp, and some are merged from the old menubar where they were duplicated * some menu actions are removed entirely * the menubar is generated and returned to TomahawkWindow from ActionCollection::createMenuBar, to minimize the risk of having unused actions in the future * "Legal Info..." becomes "Legal Information..." Please note that while I did my best to #ifdef relevant Windows and Mac chunks of code, and update and split existing #ifdefs where necessary, I have not been able to test those code paths.
This commit is contained in:
@@ -109,14 +109,12 @@ TomahawkWindow::TomahawkWindow( QWidget* parent )
|
||||
#endif
|
||||
ui->setupUi( this );
|
||||
|
||||
ui->menuApp->insertAction( ui->actionCreatePlaylist, ActionCollection::instance()->getAction( "togglePrivacy" ) );
|
||||
ui->menuApp->insertSeparator( ui->actionCreatePlaylist );
|
||||
|
||||
applyPlatformTweaks();
|
||||
|
||||
ui->centralWidget->setContentsMargins( 0, 0, 0, 0 );
|
||||
TomahawkUtils::unmarginLayout( ui->centralWidget->layout() );
|
||||
|
||||
setMenuBar( ActionCollection::instance()->createMenuBar( this ) );
|
||||
setupAccountsMenu();
|
||||
setupToolBar();
|
||||
setupSideBar();
|
||||
@@ -128,8 +126,8 @@ TomahawkWindow::TomahawkWindow( QWidget* parent )
|
||||
|
||||
if ( qApp->arguments().contains( "--debug" ) )
|
||||
{
|
||||
ui->menu_Help->addSeparator();
|
||||
ui->menu_Help->addAction( "Crash now...", this, SLOT( crashNow() ) );
|
||||
connect( ActionCollection::instance()->getAction( "crashNow" ), SIGNAL( triggered() ),
|
||||
this, SLOT( crashNow() ) );
|
||||
}
|
||||
|
||||
// set initial state
|
||||
@@ -311,21 +309,17 @@ TomahawkWindow::setupSideBar()
|
||||
ui->splitter->addWidget( ViewManager::instance()->widget() );
|
||||
ui->splitter->setCollapsible( 1, false );
|
||||
|
||||
ui->actionShowOfflineSources->setChecked( TomahawkSettings::instance()->showOfflineSources() );
|
||||
ActionCollection::instance()->getAction( "showOfflineSources" )
|
||||
->setChecked( TomahawkSettings::instance()->showOfflineSources() );
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
TomahawkWindow::setupUpdateCheck()
|
||||
{
|
||||
#ifndef Q_OS_MAC
|
||||
ui->menu_Help->insertSeparator( ui->actionAboutTomahawk );
|
||||
#endif
|
||||
|
||||
#if defined( Q_OS_MAC ) && defined( HAVE_SPARKLE )
|
||||
QAction* checkForUpdates = ui->menu_Help->addAction( tr( "Check For Updates..." ) );
|
||||
checkForUpdates->setMenuRole( QAction::ApplicationSpecificRole );
|
||||
connect( checkForUpdates, SIGNAL( triggered( bool ) ), SLOT( checkForUpdates() ) );
|
||||
connect( ActionCollection::instance()->getAction( "checkForUpdates" ), SIGNAL( triggered( bool ) ),
|
||||
SLOT( checkForUpdates() ) );
|
||||
#elif defined( Q_WS_WIN )
|
||||
QUrl updaterUrl;
|
||||
|
||||
@@ -339,9 +333,8 @@ TomahawkWindow::setupUpdateCheck()
|
||||
updater->SetNetworkAccessManager( TomahawkUtils::nam() );
|
||||
updater->SetVersion( TomahawkUtils::appFriendlyVersion() );
|
||||
|
||||
ui->menu_Help->addSeparator();
|
||||
QAction* checkForUpdates = ui->menu_Help->addAction( tr( "Check For Updates..." ) );
|
||||
connect( checkForUpdates, SIGNAL( triggered() ), updater, SLOT( CheckNow() ) );
|
||||
connect( ActionCollection::instance()->getAction( "checkForUpdates" ), SIGNAL( triggered() ),
|
||||
updater, SLOT( CheckNow() ) );
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -430,30 +423,22 @@ TomahawkWindow::setupSignals()
|
||||
connect( AudioEngine::instance(), SIGNAL( stopped() ), SLOT( audioStopped() ) );
|
||||
|
||||
// <Menu Items>
|
||||
ActionCollection *ac = ActionCollection::instance();
|
||||
// connect( ui->actionAddPeerManually, SIGNAL( triggered() ), SLOT( addPeerManually() ) );
|
||||
connect( ui->actionPreferences, SIGNAL( triggered() ), SLOT( showSettingsDialog() ) );
|
||||
connect( ui->actionDiagnostics, SIGNAL( triggered() ), SLOT( showDiagnosticsDialog() ) );
|
||||
connect( ui->actionLegalInfo, SIGNAL( triggered() ), SLOT( legalInfo() ) );
|
||||
connect( ac->getAction( "preferences" ), SIGNAL( triggered() ), SLOT( showSettingsDialog() ) );
|
||||
connect( ac->getAction( "diagnostics" ), SIGNAL( triggered() ), SLOT( showDiagnosticsDialog() ) );
|
||||
connect( ac->getAction( "legalInfo" ), SIGNAL( triggered() ), SLOT( legalInfo() ) );
|
||||
connect( m_actionToggleConnect, SIGNAL( triggered() ), AccountManager::instance(), SLOT( toggleAccountsConnected() ) );
|
||||
connect( ui->actionUpdateCollection, SIGNAL( triggered() ), SLOT( updateCollectionManually() ) );
|
||||
connect( ui->actionRescanCollection, SIGNAL( triggered() ), SLOT( rescanCollectionManually() ) );
|
||||
connect( ui->actionLoadXSPF, SIGNAL( triggered() ), SLOT( loadSpiff() ));
|
||||
connect( ui->actionCreatePlaylist, SIGNAL( triggered() ), SLOT( createPlaylist() ));
|
||||
connect( ui->actionCreate_New_Station, SIGNAL( triggered() ), SLOT( createStation() ));
|
||||
connect( ui->actionAboutTomahawk, SIGNAL( triggered() ), SLOT( showAboutTomahawk() ) );
|
||||
connect( ui->actionExit, SIGNAL( triggered() ), qApp, SLOT( quit() ) );
|
||||
connect( ui->actionShowOfflineSources, SIGNAL( triggered() ), SLOT( showOfflineSources() ) );
|
||||
|
||||
connect( ui->actionPlay, SIGNAL( triggered() ), AudioEngine::instance(), SLOT( playPause() ) );
|
||||
connect( ui->actionNext, SIGNAL( triggered() ), AudioEngine::instance(), SLOT( next() ) );
|
||||
connect( ui->actionPrevious, SIGNAL( triggered() ), AudioEngine::instance(), SLOT( previous() ) );
|
||||
connect( ac->getAction( "updateCollection" ), SIGNAL( triggered() ), SLOT( updateCollectionManually() ) );
|
||||
connect( ac->getAction( "rescanCollection" ), SIGNAL( triggered() ), SLOT( rescanCollectionManually() ) );
|
||||
connect( ac->getAction( "loadXSPF" ), SIGNAL( triggered() ), SLOT( loadSpiff() ));
|
||||
connect( ac->getAction( "aboutTomahawk" ), SIGNAL( triggered() ), SLOT( showAboutTomahawk() ) );
|
||||
connect( ac->getAction( "quit" ), SIGNAL( triggered() ), qApp, SLOT( quit() ) );
|
||||
connect( ac->getAction( "showOfflineSources" ), SIGNAL( triggered() ), SLOT( showOfflineSources() ) );
|
||||
|
||||
#if defined( Q_OS_MAC )
|
||||
connect( ui->actionMinimize, SIGNAL( triggered() ), SLOT( minimize() ) );
|
||||
connect( ui->actionZoom, SIGNAL( triggered() ), SLOT( maximize() ) );
|
||||
#else
|
||||
ui->menuWindow->clear();
|
||||
ui->menuWindow->menuAction()->setVisible( false );
|
||||
connect( ac->getAction( "minimize" ), SIGNAL( triggered() ), SLOT( minimize() ) );
|
||||
connect( ac->getAction( "zoom" ), SIGNAL( triggered() ), SLOT( maximize() ) );
|
||||
#endif
|
||||
|
||||
// <AccountHandler>
|
||||
@@ -528,8 +513,8 @@ TomahawkWindow::showEvent( QShowEvent* e )
|
||||
QMainWindow::showEvent( e );
|
||||
|
||||
#if defined( Q_OS_MAC )
|
||||
ui->actionMinimize->setDisabled( false );
|
||||
ui->actionZoom->setDisabled( false );
|
||||
ActionCollection::instance()->getAction( "minimize" )->setDisabled( false );
|
||||
ActionCollection::instance()->getAction( "zoom" )->setDisabled( false );
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -540,8 +525,8 @@ TomahawkWindow::hideEvent( QHideEvent* e )
|
||||
QMainWindow::hideEvent( e );
|
||||
|
||||
#if defined( Q_OS_MAC )
|
||||
ui->actionMinimize->setDisabled( true );
|
||||
ui->actionZoom->setDisabled( true );
|
||||
ActionCollection::instance()->getAction( "minimize" )->setDisabled( true );
|
||||
ActionCollection::instance()->getAction( "zoom" )->setDisabled( true );
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -818,8 +803,10 @@ TomahawkWindow::pluginMenuRemoved( QMenu* menu )
|
||||
void
|
||||
TomahawkWindow::showOfflineSources()
|
||||
{
|
||||
m_sourcetree->showOfflineSources( ui->actionShowOfflineSources->isChecked() );
|
||||
TomahawkSettings::instance()->setShowOfflineSources( ui->actionShowOfflineSources->isChecked() );
|
||||
m_sourcetree->showOfflineSources( ActionCollection::instance()
|
||||
->getAction( "showOfflineSources" )->isChecked() );
|
||||
TomahawkSettings::instance()->setShowOfflineSources( ActionCollection::instance()
|
||||
->getAction( "showOfflineSources" )->isChecked() );
|
||||
}
|
||||
|
||||
|
||||
@@ -1054,7 +1041,7 @@ TomahawkWindow::audioStarted()
|
||||
{
|
||||
m_audioRetryCounter = 0;
|
||||
|
||||
ui->actionPlay->setText( tr( "Pause" ) );
|
||||
ActionCollection::instance()->getAction( "playPause" )->setText( tr( "Pause" ) );
|
||||
ActionCollection::instance()->getAction( "stop" )->setEnabled( true );
|
||||
|
||||
#ifdef Q_OS_WIN
|
||||
@@ -1074,7 +1061,7 @@ TomahawkWindow::audioFinished()
|
||||
void
|
||||
TomahawkWindow::audioPaused()
|
||||
{
|
||||
ui->actionPlay->setText( tr( "Play" ) );
|
||||
ActionCollection::instance()->getAction( "playPause" )->setText( tr( "&Play" ) );
|
||||
}
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user