From 3a0e7ba093b46b4cd38ff34d57d5f546e32a169b Mon Sep 17 00:00:00 2001 From: vladimir-kirillovskiy Date: Tue, 4 Jul 2017 23:24:19 +0300 Subject: [PATCH] Enhancement - Indicator for open windows (#511) * Possible fix for missing raptor.h #496 * this line was added for #194 but it seems like it's not needed * fixed spelling error * added checkboxes for view menu's options * remove unneeded header I added by mistake * removed fix for #496 to match with main branch of the main repository * revert last commit * workaround for my wrong branch managment * added checkboxes for view menu's options * remove unneeded header I added by mistake * workaround for my wrong branch managment * commit CMakeList as in the main branch * converted spaces to tabs --- src/gui/src/Director.cpp | 26 ++++-- src/gui/src/Director.h | 3 +- src/gui/src/HydrogenApp.cpp | 26 ++++-- src/gui/src/HydrogenApp.h | 3 +- src/gui/src/MainForm.cpp | 87 ++++++++++++------- src/gui/src/MainForm.h | 13 ++- src/gui/src/Mixer/Mixer.cpp | 15 ++-- src/gui/src/Mixer/Mixer.h | 1 + src/gui/src/PlaylistEditor/PlaylistDialog.cpp | 12 +++ src/gui/src/PlaylistEditor/PlaylistDialog.h | 8 +- 10 files changed, 135 insertions(+), 59 deletions(-) diff --git a/src/gui/src/Director.cpp b/src/gui/src/Director.cpp index a84f69b93b..fc2c270e65 100644 --- a/src/gui/src/Director.cpp +++ b/src/gui/src/Director.cpp @@ -35,15 +35,15 @@ ** ------------------------------------------- ** | | ** | song name | - ** | | + ** | | ** ------------------------------------------- ** | | | - ** | Bar | Beat | - ** | | | + ** | Bar | Beat | + ** | | | ** ------------------------------------------- ** | | ** | current bar tag | - ** | | + ** | | ** ------------------------------------------- ** | | ** | next bar tag | @@ -91,13 +91,27 @@ Director::~Director() //INFOLOG ( "DESTROY" ); } +void Director::keyPressEvent( QKeyEvent* ev ) +{ + if(ev->key() == Qt::Key_Escape) { + HydrogenApp::get_instance()->showDirector(); + } +} + +void Director::closeEvent( QCloseEvent* ev ) +{ + HydrogenApp::get_instance()->showDirector(); +} + + + void Director::metronomeEvent( int nValue ) { //load a new song if( nValue == 3 ){ - + //update songname QStringList list = Hydrogen::get_instance()->getSong()->get_filename().split("/"); @@ -109,7 +123,7 @@ void Director::metronomeEvent( int nValue ) __songName = QString("Untitled Song"); } } - + update(); return; } diff --git a/src/gui/src/Director.h b/src/gui/src/Director.h index d39be120f2..9d34292719 100644 --- a/src/gui/src/Director.h +++ b/src/gui/src/Director.h @@ -44,6 +44,8 @@ class Director : public QDialog, public Ui_Director_UI, public H2Core::Object, p virtual void metronomeEvent( int nValue ); virtual void paintEvent( QPaintEvent*); + void keyPressEvent( QKeyEvent* ev ); + void closeEvent( QCloseEvent* ev ); private slots: void updateMetronomBackground(); @@ -68,4 +70,3 @@ private slots: #endif - diff --git a/src/gui/src/HydrogenApp.cpp b/src/gui/src/HydrogenApp.cpp index 038c84fb55..1ead1c7f46 100644 --- a/src/gui/src/HydrogenApp.cpp +++ b/src/gui/src/HydrogenApp.cpp @@ -112,7 +112,7 @@ HydrogenApp::HydrogenApp( MainForm *pMainForm, Song *pFirstSong ) else { m_pAudioEngineInfoForm->hide(); } - + m_pPlaylistDialog = new PlaylistDialog( 0 ); m_pDirector = new Director( 0 ); } @@ -150,7 +150,7 @@ HydrogenApp::~HydrogenApp() delete m_pLadspaFXProperties[nFX]; } #endif - + } @@ -341,6 +341,8 @@ void HydrogenApp::showMixer(bool show) } else { m_pMixer->setVisible( show ); } + + m_pMainForm->update_mixer_checkbox(); } void HydrogenApp::showInstrumentPanel(bool show) @@ -360,6 +362,7 @@ void HydrogenApp::showInstrumentPanel(bool show) } else { getInstrumentRack()->setHidden( show ); } + m_pMainForm->update_instrument_checkbox( !show ); } @@ -417,15 +420,23 @@ void HydrogenApp::showAudioEngineInfoForm() void HydrogenApp::showPlaylistDialog() { - m_pPlaylistDialog->hide(); - m_pPlaylistDialog->show(); + if ( m_pPlaylistDialog->isVisible() ) { + m_pPlaylistDialog->hide(); + } else { + m_pPlaylistDialog->show(); + } + m_pMainForm->update_playlist_checkbox(); } void HydrogenApp::showDirector() { - m_pDirector->hide(); - m_pDirector->show(); + if ( m_pDirector->isVisible() ) { + m_pDirector->hide(); + } else { + m_pDirector->show(); + } + m_pMainForm->update_director_checkbox(); } @@ -537,7 +548,7 @@ void HydrogenApp::onEventQueueTimer() case EVENT_UNDO_REDO: pListener->undoRedoActionEvent( event.value ); break; - + case EVENT_TEMPO_CHANGED: pListener->tempoChangedEvent( event.value ); break; @@ -618,4 +629,3 @@ void HydrogenApp::cleanupTemporaryFiles() Filesystem::rm( Preferences::get_instance()->getTmpDirectory() ); } - diff --git a/src/gui/src/HydrogenApp.h b/src/gui/src/HydrogenApp.h index 0583b23454..d927714886 100644 --- a/src/gui/src/HydrogenApp.h +++ b/src/gui/src/HydrogenApp.h @@ -64,7 +64,7 @@ class InfoBar; class HydrogenApp : public QObject, public H2Core::Object { - H2_OBJECT + H2_OBJECT Q_OBJECT public: HydrogenApp( MainForm* pMainForm, H2Core::Song *pFirstSong ); @@ -77,6 +77,7 @@ class HydrogenApp : public QObject, public H2Core::Object void setSong( H2Core::Song* pSong ); void showPreferencesDialog(); + void updateMixerCheckbox(); void showMixer(bool bShow); void showInstrumentPanel(bool); void showAudioEngineInfoForm(); diff --git a/src/gui/src/MainForm.cpp b/src/gui/src/MainForm.cpp index 7988683177..da0a0f9728 100644 --- a/src/gui/src/MainForm.cpp +++ b/src/gui/src/MainForm.cpp @@ -208,7 +208,7 @@ MainForm::MainForm( QApplication *app, const QString& songFilename ) undoView->setWindowTitle(tr("Undo history")); //restore last playlist - if( Preferences::get_instance()->isRestoreLastPlaylistEnabled() + if( Preferences::get_instance()->isRestoreLastPlaylistEnabled() && !Preferences::get_instance()->getLastPlaylistFilename().isEmpty() ){ bool loadlist = h2app->getPlayListDialog()->loadListByFileName( Preferences::get_instance()->getLastPlaylistFilename() ); if( !loadlist ){ @@ -331,24 +331,24 @@ void MainForm::createMenuBar() // VIEW MENU QMenu *m_pViewMenu = m_pMenubar->addMenu( trUtf8( "&View" ) ); - m_pViewMenu->addAction( trUtf8("Playlist &editor"), this, SLOT( action_window_showPlaylistDialog() ), QKeySequence( "" ) ); - m_pViewMenu->addAction( trUtf8("Director"), this, SLOT( action_window_show_DirectorWidget() ), QKeySequence( "Alt+D" ) ); + m_pViewPlaylistEditorAction = m_pViewMenu->addAction( trUtf8("Playlist &editor"), this, SLOT( action_window_showPlaylistDialog() ), QKeySequence( "" ) ); + m_pViewPlaylistEditorAction->setCheckable( true ); + m_pViewDirectorAction = m_pViewMenu->addAction( trUtf8("Director"), this, SLOT( action_window_show_DirectorWidget() ), QKeySequence( "Alt+D" ) ); + m_pViewDirectorAction->setCheckable( true ); - m_pFileMenu->addSeparator(); // ----- + m_pFileMenu->addSeparator(); + m_pViewMixerAction = m_pViewMenu->addAction( trUtf8("&Mixer"), this, SLOT( action_window_showMixer() ), QKeySequence( "Alt+M" ) ); + m_pViewMixerAction->setCheckable( true ); + update_mixer_checkbox(); // if checkbox need to be checked. + m_pViewMixerInstrumentRackAction = m_pViewMenu->addAction( trUtf8("&Instrument Rack"), this, SLOT( action_window_showDrumkitManagerPanel() ), QKeySequence( "Alt+I" ) ); + m_pViewMixerInstrumentRackAction->setCheckable( true ); + update_instrument_checkbox( true ); // check it as Instrument panel is always open on start - m_pViewMenu->addAction( trUtf8("Playlist &editor"), this, SLOT( action_window_showPlaylistDialog() ), QKeySequence( "" ) ); - m_pViewMenu->addAction( trUtf8("Director"), this, SLOT( action_window_show_DirectorWidget() ), QKeySequence( "Alt+D" ) ); - - m_pViewMenu->addAction( trUtf8("&Mixer"), this, SLOT( action_window_showMixer() ), QKeySequence( "Alt+M" ) ); - - - m_pViewMenu->addAction( trUtf8("&Instrument Rack"), this, SLOT( action_window_showDrumkitManagerPanel() ), QKeySequence( "Alt+I" ) ); - m_pViewMenu->addAction( trUtf8("&Automation path"), this, SLOT( action_window_showAutomationArea() ), QKeySequence( "Alt+A" ) ); - + m_pViewMenu->addSeparator(); // ----- - + m_pViewMenu->addAction( trUtf8("Full screen"), this, SLOT( action_window_toggleFullscreen() ), QKeySequence( "Alt+F" ) ); @@ -534,7 +534,7 @@ void MainForm::action_file_save_as() Hydrogen* pEngine = Hydrogen::get_instance(); if ( pEngine->getState() == STATE_PLAYING ) { - pEngine->sequencer_stop(); + pEngine->sequencer_stop(); } //std::auto_ptr fd( new QFileDialog ); @@ -788,11 +788,11 @@ void MainForm::action_file_openPattern() else { H2Core::Pattern *pNewPattern = err; - + if(!pPatternList->check_name( pNewPattern->get_name() ) ){ pNewPattern->set_name( pPatternList->find_unused_pattern_name( pNewPattern->get_name() ) ); } - + pPatternList->add ( pNewPattern ); pSong->set_is_modified( true ); EventQueue::get_instance()->push_event( EVENT_SONG_MODIFIED, -1 ); @@ -847,12 +847,25 @@ void MainForm::action_window_showPlaylistDialog() h2app->showPlaylistDialog(); } -void MainForm::action_window_show_DirectorWidget() +// function to update director status in menu bar +void MainForm::update_playlist_checkbox() { + bool isVisible = HydrogenApp::get_instance()->getPlayListDialog()->isVisible(); + m_pViewPlaylistEditorAction->setChecked( isVisible ); +} +void MainForm::action_window_show_DirectorWidget() +{ h2app->showDirector(); } +// function to update director status in menu bar +void MainForm::update_director_checkbox() +{ + bool isVisible = HydrogenApp::get_instance()->getDirector()->isVisible(); + m_pViewDirectorAction->setChecked( isVisible ); +} + void MainForm::action_window_toggleFullscreen() { if( this->isFullScreen() ){ @@ -868,7 +881,12 @@ void MainForm::action_window_showMixer() h2app->showMixer( !isVisible ); } - +// function to update mixer status in menu bar +void MainForm::update_mixer_checkbox() +{ + bool isVisible = HydrogenApp::get_instance()->getMixer()->isVisible(); + m_pViewMixerAction->setChecked( isVisible ); +} void MainForm::action_debug_showAudioEngineInfo() { @@ -938,7 +956,7 @@ void MainForm::action_banks_open() void MainForm::action_instruments_clearAll() { switch( - QMessageBox::information( this, + QMessageBox::information( this, "Hydrogen", trUtf8("Clear all instruments?"), trUtf8("Ok"), @@ -1088,6 +1106,7 @@ void MainForm::action_instruments_saveAsLibrary() /// void MainForm::closeEvent( QCloseEvent* ev ) { + if ( action_file_exit() == false ) { // don't close!!! ev->ignore(); @@ -1115,9 +1134,13 @@ void MainForm::action_window_showDrumkitManagerPanel() { InstrumentRack *pPanel = HydrogenApp::get_instance()->getInstrumentRack(); pPanel->setHidden( pPanel->isVisible() ); + update_instrument_checkbox( pPanel->isVisible() ); } - +void MainForm::update_instrument_checkbox( bool show ) +{ + m_pViewMixerInstrumentRackAction->setChecked( show ); +} void MainForm::closeAll() { @@ -1628,15 +1651,15 @@ void MainForm::action_file_export_lilypond() Hydrogen::get_instance()->sequencer_stop(); } switch ( QMessageBox::information( - this, - "Hydrogen", - trUtf8( "\nThe LilyPond export is an experimental feature.\n" - "It should work like a charm provided that you use the " - "GM-kit, and that you do not use triplet\n" ), - trUtf8( "Ok" ), - trUtf8( "&Cancel" ), - 0, - 2 ) ) { + this, + "Hydrogen", + trUtf8( "\nThe LilyPond export is an experimental feature.\n" + "It should work like a charm provided that you use the " + "GM-kit, and that you do not use triplet\n" ), + trUtf8( "Ok" ), + trUtf8( "&Cancel" ), + 0, + 2 ) ) { case 1: case 2: return; } @@ -1842,7 +1865,7 @@ bool MainForm::handleUnsavedChanges() bool rv = true; while ( !done && Hydrogen::get_instance()->getSong()->get_is_modified() ) { switch( - QMessageBox::information( this, "Hydrogen", + QMessageBox::information( this, "Hydrogen", trUtf8("\nThe document contains unsaved changes.\n" "Do you want to save the changes?\n"), trUtf8("&Save"), trUtf8("&Discard"), trUtf8("&Cancel"), @@ -1989,5 +2012,3 @@ void MainForm::action_banks_properties() SoundLibraryPropertiesDialog dialog( this , drumkitInfo, drumkitInfo ); dialog.exec(); } - - diff --git a/src/gui/src/MainForm.h b/src/gui/src/MainForm.h index d545dbdf2e..3e65b2f191 100644 --- a/src/gui/src/MainForm.h +++ b/src/gui/src/MainForm.h @@ -45,7 +45,7 @@ class QUndoView;///debug only /// class MainForm : public QMainWindow, public EventListener, public H2Core::Object { - H2_OBJECT + H2_OBJECT Q_OBJECT public: @@ -106,6 +106,11 @@ public slots: void action_window_showAutomationArea(); void action_window_toggleFullscreen(); + void update_mixer_checkbox(); + void update_instrument_checkbox( bool show ); + void update_director_checkbox(); + void update_playlist_checkbox(); + void action_debug_printObjects(); void action_debug_showAudioEngineInfo(); @@ -149,6 +154,10 @@ public slots: void functionDeleteInstrument(int instrument); QMenu * m_pInputModeMenu; + QAction * m_pViewPlaylistEditorAction; + QAction * m_pViewDirectorAction; + QAction * m_pViewMixerAction; + QAction * m_pViewMixerInstrumentRackAction; QAction * m_pInstrumentAction; QAction * m_pDrumkitAction; @@ -158,7 +167,7 @@ public slots: QAction * m_pRecentFileAction2; QAction * m_pRecentFileAction3; QAction * m_pRecentFileAction4; - + QUndoView * undoView;///debug only QTimer m_autosaveTimer; diff --git a/src/gui/src/Mixer/Mixer.cpp b/src/gui/src/Mixer/Mixer.cpp index f1d6844820..6a4bce2456 100644 --- a/src/gui/src/Mixer/Mixer.cpp +++ b/src/gui/src/Mixer/Mixer.cpp @@ -186,6 +186,11 @@ MixerLine* Mixer::createMixerLine( int nInstr ) return pMixerLine; } +void Mixer::closeEvent( QCloseEvent* ev ) +{ + HydrogenApp::get_instance()->showMixer(false); +} + ComponentMixerLine* Mixer::createComponentMixerLine( int theCompoID ) { @@ -206,11 +211,11 @@ void Mixer::muteClicked(MixerLine* ref) { int nLine = findMixerLineByRef(ref); bool isMuteClicked = ref->isMuteClicked(); - + Hydrogen *pEngine = Hydrogen::get_instance(); CoreActionController* pController = pEngine->getCoreActionController(); pEngine->setSelectedInstrumentNumber( nLine ); - + pController->setStripIsMuted( nLine, isMuteClicked ); } @@ -225,7 +230,7 @@ void Mixer::muteClicked(ComponentMixerLine* ref) void Mixer::soloClicked(ComponentMixerLine* ref) { - Hydrogen *pEngine = Hydrogen::get_instance(); + Hydrogen *pEngine = Hydrogen::get_instance(); Song *pSong = pEngine->getSong(); std::vector pCompoList = *(pSong->get_components()); int nComponents = pCompoList.size(); @@ -299,7 +304,7 @@ void Mixer::soloClicked(MixerLine* ref) int nInstruments = pInstrList->size(); int nLine = findMixerLineByRef(ref); - + pController->setStripIsSoloed( nLine, ref->isSoloClicked() ); for ( int i = 0; i < nInstruments; ++i ) { @@ -391,7 +396,7 @@ void Mixer::volumeChanged(MixerLine* ref) { Hydrogen *pEngine = Hydrogen::get_instance(); CoreActionController* pController = pEngine->getCoreActionController(); - + int nLine = findMixerLineByRef(ref); pController->setStripVolume( nLine, ref->getVolume() ); } diff --git a/src/gui/src/Mixer/Mixer.h b/src/gui/src/Mixer/Mixer.h index d37ccd2d90..ae24903111 100644 --- a/src/gui/src/Mixer/Mixer.h +++ b/src/gui/src/Mixer/Mixer.h @@ -81,6 +81,7 @@ class Mixer : public QWidget, public EventListener, public H2Core::Object void ladspaActiveBtnClicked( LadspaFXMixerLine* ref ); void ladspaEditBtnClicked( LadspaFXMixerLine *ref ); void ladspaVolumeChanged( LadspaFXMixerLine* ref); + void closeEvent(QCloseEvent *event); private: QHBoxLayout *m_pFaderHBox; diff --git a/src/gui/src/PlaylistEditor/PlaylistDialog.cpp b/src/gui/src/PlaylistEditor/PlaylistDialog.cpp index 759b577d2b..d08d749fbe 100644 --- a/src/gui/src/PlaylistEditor/PlaylistDialog.cpp +++ b/src/gui/src/PlaylistEditor/PlaylistDialog.cpp @@ -260,6 +260,18 @@ PlaylistDialog::~PlaylistDialog() INFOLOG ( "DESTROY" ); } +void PlaylistDialog::keyPressEvent( QKeyEvent* ev ) +{ + if(ev->key() == Qt::Key_Escape) { + HydrogenApp::get_instance()->showPlaylistDialog(); + } +} + +void PlaylistDialog::closeEvent( QCloseEvent* ev ) +{ + HydrogenApp::get_instance()->showPlaylistDialog(); +} + void PlaylistDialog::addSong() { static QString songDir = Preferences::get_instance()->getDataDirectory() + "/songs";; diff --git a/src/gui/src/PlaylistEditor/PlaylistDialog.h b/src/gui/src/PlaylistEditor/PlaylistDialog.h index c7a8c872ac..6cfa53fa2a 100644 --- a/src/gui/src/PlaylistEditor/PlaylistDialog.h +++ b/src/gui/src/PlaylistEditor/PlaylistDialog.h @@ -42,17 +42,19 @@ class PixmapWidget; class PlaylistDialog : public QDialog, public Ui_PlaylistDialog_UI, public H2Core::Object { - H2_OBJECT + H2_OBJECT Q_OBJECT public: - + PlaylistDialog( QWidget* pParent ); ~PlaylistDialog(); - bool loadListByFileName( QString filename); + bool loadListByFileName( QString filename); private slots: + void keyPressEvent( QKeyEvent* ev ); + void closeEvent( QCloseEvent* ev ); void addSong(); void addCurrentSong(); void removeFromList();