Control play/pause buttons in slot of MainWindow via signal in Song class

The engine class as the component instance manager is the wrong place to
control the play/pause buttons. Instead emit a signal in the Song class
and update the buttons in a slot in MainWindow. This fixes problems with
GUI/pixmap operations happening outside the GUI thread when exporting a
project.

Closes #435.
This commit is contained in:
Tobias Doerffel
2014-03-18 20:39:52 +01:00
parent b45c0c5f02
commit 41c154dc95
6 changed files with 48 additions and 49 deletions

View File

@@ -190,6 +190,9 @@ MainWindow::MainWindow() :
connect(&m_autoSaveTimer, SIGNAL(timeout()), this, SLOT(autoSave()));
m_autoSaveTimer.start(1000 * 60); // 1 minute
}
connect( engine::getSong(), SIGNAL( playbackStateChanged() ),
this, SLOT( updatePlayPauseIcons() ) );
}
@@ -926,6 +929,42 @@ void MainWindow::toggleControllerRack()
void MainWindow::updatePlayPauseIcons()
{
engine::songEditor()->setPauseIcon( false );
engine::automationEditor()->setPauseIcon( false );
engine::getBBEditor()->setPauseIcon( false );
engine::pianoRoll()->setPauseIcon( false );
if( engine::getSong()->isPlaying() )
{
switch( engine::getSong()->playMode() )
{
case song::Mode_PlaySong:
engine::songEditor()->setPauseIcon( true );
break;
case song::Mode_PlayAutomationPattern:
engine::automationEditor()->setPauseIcon( true );
break;
case song::Mode_PlayBB:
engine::getBBEditor()->setPauseIcon( true );
break;
case song::Mode_PlayPattern:
engine::pianoRoll()->setPauseIcon( true );
break;
default:
break;
}
}
}
void MainWindow::undo()
{
engine::projectJournal()->undo();