Skip to content

Commit

Permalink
Enhancement - Indicator for open windows (#511)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
vladimir-kirillovskiy authored and mauser committed Jul 4, 2017
1 parent fb64b7f commit 3a0e7ba
Show file tree
Hide file tree
Showing 10 changed files with 135 additions and 59 deletions.
26 changes: 20 additions & 6 deletions src/gui/src/Director.cpp
Expand Up @@ -35,15 +35,15 @@
** -------------------------------------------
** | |
** | song name |
** | |
** | |
** -------------------------------------------
** | | |
** | Bar | Beat |
** | | |
** | Bar | Beat |
** | | |
** -------------------------------------------
** | |
** | current bar tag |
** | |
** | |
** -------------------------------------------
** | |
** | next bar tag |
Expand Down Expand Up @@ -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("/");

Expand All @@ -109,7 +123,7 @@ void Director::metronomeEvent( int nValue )
__songName = QString("Untitled Song");
}
}

update();
return;
}
Expand Down
3 changes: 2 additions & 1 deletion src/gui/src/Director.h
Expand Up @@ -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();
Expand All @@ -68,4 +70,3 @@ private slots:


#endif

26 changes: 18 additions & 8 deletions src/gui/src/HydrogenApp.cpp
Expand Up @@ -112,7 +112,7 @@ HydrogenApp::HydrogenApp( MainForm *pMainForm, Song *pFirstSong )
else {
m_pAudioEngineInfoForm->hide();
}

m_pPlaylistDialog = new PlaylistDialog( 0 );
m_pDirector = new Director( 0 );
}
Expand Down Expand Up @@ -150,7 +150,7 @@ HydrogenApp::~HydrogenApp()
delete m_pLadspaFXProperties[nFX];
}
#endif

}


Expand Down Expand Up @@ -341,6 +341,8 @@ void HydrogenApp::showMixer(bool show)
} else {
m_pMixer->setVisible( show );
}

m_pMainForm->update_mixer_checkbox();
}

void HydrogenApp::showInstrumentPanel(bool show)
Expand All @@ -360,6 +362,7 @@ void HydrogenApp::showInstrumentPanel(bool show)
} else {
getInstrumentRack()->setHidden( show );
}
m_pMainForm->update_instrument_checkbox( !show );
}


Expand Down Expand Up @@ -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();
}


Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -618,4 +629,3 @@ void HydrogenApp::cleanupTemporaryFiles()

Filesystem::rm( Preferences::get_instance()->getTmpDirectory() );
}

3 changes: 2 additions & 1 deletion src/gui/src/HydrogenApp.h
Expand Up @@ -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 );
Expand All @@ -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();
Expand Down
87 changes: 54 additions & 33 deletions src/gui/src/MainForm.cpp
Expand Up @@ -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 ){
Expand Down Expand Up @@ -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" ) );


Expand Down Expand Up @@ -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<QFileDialog> fd( new QFileDialog );
Expand Down Expand Up @@ -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 );
Expand Down Expand Up @@ -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() ){
Expand All @@ -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()
{
Expand Down Expand Up @@ -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"),
Expand Down Expand Up @@ -1088,6 +1106,7 @@ void MainForm::action_instruments_saveAsLibrary()
///
void MainForm::closeEvent( QCloseEvent* ev )
{

if ( action_file_exit() == false ) {
// don't close!!!
ev->ignore();
Expand Down Expand Up @@ -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() {
Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -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"),
Expand Down Expand Up @@ -1989,5 +2012,3 @@ void MainForm::action_banks_properties()
SoundLibraryPropertiesDialog dialog( this , drumkitInfo, drumkitInfo );
dialog.exec();
}


13 changes: 11 additions & 2 deletions src/gui/src/MainForm.h
Expand Up @@ -45,7 +45,7 @@ class QUndoView;///debug only
///
class MainForm : public QMainWindow, public EventListener, public H2Core::Object
{
H2_OBJECT
H2_OBJECT
Q_OBJECT

public:
Expand Down Expand Up @@ -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();

Expand Down Expand Up @@ -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;

Expand All @@ -158,7 +167,7 @@ public slots:
QAction * m_pRecentFileAction2;
QAction * m_pRecentFileAction3;
QAction * m_pRecentFileAction4;

QUndoView * undoView;///debug only

QTimer m_autosaveTimer;
Expand Down

0 comments on commit 3a0e7ba

Please sign in to comment.