diff --git a/include/MainWindow.h b/include/MainWindow.h index 82f3cd365..86ab8adc6 100644 --- a/include/MainWindow.h +++ b/include/MainWindow.h @@ -172,6 +172,7 @@ private: friend class GuiApplication; + QMenu * m_viewMenu; private slots: void browseHelp(); @@ -179,6 +180,8 @@ private slots: void openRecentlyOpenedProject( QAction * _action ); void showTool( QAction * _idx ); void updateRecentlyOpenedProjectsMenu(); + void updateViewMenu( void ); + void updateConfig( QAction * _who ); void autoSave(); diff --git a/src/gui/MainWindow.cpp b/src/gui/MainWindow.cpp index b37c3a79b..de1599112 100644 --- a/src/gui/MainWindow.cpp +++ b/src/gui/MainWindow.cpp @@ -74,7 +74,8 @@ MainWindow::MainWindow() : m_templatesMenu( NULL ), m_recentlyOpenedProjectsMenu( NULL ), m_toolsMenu( NULL ), - m_autoSaveTimer( this ) + m_autoSaveTimer( this ), + m_viewMenu( NULL ) { setAttribute( Qt::WA_DeleteOnClose ); @@ -300,6 +301,13 @@ void MainWindow::finalize() tr( "Settings" ), this, SLOT( showSettingsDialog() ) ); + m_viewMenu = new QMenu( this ); + menuBar()->addMenu( m_viewMenu )->setText( tr( "&View" ) ); + connect( m_viewMenu, SIGNAL( aboutToShow() ), + this, SLOT( updateViewMenu() ) ); + connect( m_viewMenu, SIGNAL(triggered(QAction*)), this, + SLOT(updateConfig(QAction*))); + m_toolsMenu = new QMenu( this ); Plugin::DescriptorList pluginDescriptors; @@ -1008,6 +1016,111 @@ void MainWindow::toggleFxMixerWin() } +void MainWindow::updateViewMenu() +{ + m_viewMenu->clear(); + // TODO: get current visibility for these and indicate in menu? + // Not that it's straight visible <-> invisible, more like + // not on top -> top <-> invisible + m_viewMenu->addAction(embed::getIconPixmap( "songeditor" ), + tr( "Song Editor" ) + " (F5)", + this, SLOT( toggleSongEditorWin() ) + ); + m_viewMenu->addAction(embed::getIconPixmap( "bb_track" ), + tr( "Pattern Editor" ) + " (F6)", + this, SLOT( toggleBBEditorWin() ) + ); + m_viewMenu->addAction(embed::getIconPixmap( "piano" ), + tr( "Piano Roll" ) + " (F7)", + this, SLOT( togglePianoRollWin() ) + ); + m_viewMenu->addAction(embed::getIconPixmap( "automation" ), + tr( "Automation Editor" ) + " (F8)", + this, + SLOT( toggleAutomationEditorWin()) + ); + m_viewMenu->addAction(embed::getIconPixmap( "fx_mixer" ), + tr( "FX Mixer" ) + " (F9)", + this, SLOT( toggleFxMixerWin() ) + ); + m_viewMenu->addAction(embed::getIconPixmap( "project_notes" ), + tr( "Project Notes" ) + " (F10)", + this, SLOT( toggleProjectNotesWin() ) + ); + m_viewMenu->addAction(embed::getIconPixmap( "controller" ), + tr( "Show/hide controller rack" ) + + " (F11)", + this, SLOT( toggleControllerRack() ) + ); + + m_viewMenu->addSeparator(); + + // Here we should put all look&feel -stuff from configmanager + // that is safe to change on the fly. There is probably some + // more elegant way to do this. + QAction *qa; + qa = new QAction(tr( "Volume as dBV" ), this); + qa->setData("displaydbv"); + qa->setCheckable( true ); + qa->setChecked( ConfigManager::inst()->value( "app", "displaydbv" ). + toInt() ? true : false ); + m_viewMenu->addAction(qa); + + // Maybe this is impossible? + /* qa = new QAction(tr( "Tooltips" ), this); + qa->setData("tooltips"); + qa->setCheckable( true ); + qa->setChecked( ConfigManager::inst()->value( "tooltips", "disabled" ). + toInt() ? false : true ); + m_viewMenu->addAction(qa); + */ + + // Should be doable. + /* qa = new QAction(tr( "Smooth scroll" ), this); + qa->setData("smoothscroll"); + qa->setCheckable( true ); + qa->setChecked( ConfigManager::inst()->value( "ui", "smoothscroll" ). + toInt() ? true : false ); + m_viewMenu->addAction(qa); + */ + + // Not yet. + /* qa = new QAction(tr( "One instrument track window" ), this); + qa->setData("oneinstrument"); + qa->setCheckable( true ); + qa->setChecked( ConfigManager::inst()->value( "ui", "oneinstrumenttrackwindow" ). + toInt() ? true : false ); + m_viewMenu->addAction(qa); + */ +} + + +void MainWindow::updateConfig( QAction * _who ) +{ + QString tag = _who->data().toString(); + bool checked = _who->isChecked(); + + if( tag == "displaydbv" ) + { + ConfigManager::inst()->setValue( "app", "displaydbv", + QString::number(checked) ); + } + else if ( tag == "tooltips" ) + { + ConfigManager::inst()->setValue( "tooltips", "disabled", + QString::number(!checked) ); + } + else if ( tag == "smoothscroll" ) + { + ConfigManager::inst()->setValue( "ui", "smoothscroll", + QString::number(checked) ); + } + else if ( tag == "oneinstrument" ) + { + ConfigManager::inst()->setValue( "ui", "oneinstrumenttrackwindow", + QString::number(checked) ); + } +} void MainWindow::toggleControllerRack()