Remove GUI related code from Song::stop
Add the new signal Song::stopped which is emitted when the song is stopped. Connect the new slot method MainWindow::onSongStopped to that signal. Remove all GUI updates from Song::stop and handle them in MainWindow::onSongStopped.
This commit is contained in:
@@ -640,19 +640,13 @@ void Song::stop()
|
||||
m_paused = false;
|
||||
m_recording = true;
|
||||
|
||||
if( tl != NULL )
|
||||
if( tl )
|
||||
{
|
||||
|
||||
switch( tl->behaviourAtStop() )
|
||||
{
|
||||
case TimeLineWidget::BackToZero:
|
||||
m_playPos[m_playMode].setTicks(0);
|
||||
m_elapsedMilliSeconds[m_playMode] = 0;
|
||||
if( gui && gui->songEditor() &&
|
||||
( tl->autoScroll() == TimeLineWidget::AutoScrollEnabled ) )
|
||||
{
|
||||
gui->songEditor()->m_editor->updatePosition(0);
|
||||
}
|
||||
break;
|
||||
|
||||
case TimeLineWidget::BackToStart:
|
||||
@@ -661,17 +655,11 @@ void Song::stop()
|
||||
m_playPos[m_playMode].setTicks(tl->savedPos().getTicks());
|
||||
setToTime(tl->savedPos());
|
||||
|
||||
if( gui && gui->songEditor() &&
|
||||
( tl->autoScroll() == TimeLineWidget::AutoScrollEnabled ) )
|
||||
{
|
||||
gui->songEditor()->m_editor->updatePosition( MidiTime(tl->savedPos().getTicks() ) );
|
||||
}
|
||||
tl->savePos( -1 );
|
||||
}
|
||||
break;
|
||||
|
||||
case TimeLineWidget::KeepStopPosition:
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -695,6 +683,7 @@ void Song::stop()
|
||||
|
||||
m_playMode = Mode_None;
|
||||
|
||||
emit stopped();
|
||||
emit playbackStateChanged();
|
||||
}
|
||||
|
||||
|
||||
@@ -63,6 +63,7 @@
|
||||
#include "SideBar.h"
|
||||
#include "SongEditor.h"
|
||||
#include "TextFloat.h"
|
||||
#include "TimeLineWidget.h"
|
||||
#include "ToolButton.h"
|
||||
#include "ToolPlugin.h"
|
||||
#include "VersionedSaveDialog.h"
|
||||
@@ -233,6 +234,8 @@ MainWindow::MainWindow() :
|
||||
|
||||
connect( Engine::getSong(), SIGNAL( playbackStateChanged() ),
|
||||
this, SLOT( updatePlayPauseIcons() ) );
|
||||
|
||||
connect(Engine::getSong(), SIGNAL(stopped()), SLOT(onSongStopped()));
|
||||
}
|
||||
|
||||
|
||||
@@ -1764,3 +1767,39 @@ void MainWindow::onImportProject()
|
||||
song->setLoadOnLauch(false);
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::onSongStopped()
|
||||
{
|
||||
Song * song = Engine::getSong();
|
||||
Song::PlayPos const & playPos = song->getPlayPos();
|
||||
|
||||
TimeLineWidget * tl = playPos.m_timeLine;
|
||||
|
||||
if( tl )
|
||||
{
|
||||
SongEditorWindow* songEditor = gui->songEditor();
|
||||
switch( tl->behaviourAtStop() )
|
||||
{
|
||||
case TimeLineWidget::BackToZero:
|
||||
if( songEditor && ( tl->autoScroll() == TimeLineWidget::AutoScrollEnabled ) )
|
||||
{
|
||||
songEditor->m_editor->updatePosition(0);
|
||||
}
|
||||
break;
|
||||
|
||||
case TimeLineWidget::BackToStart:
|
||||
if( tl->savedPos() >= 0 )
|
||||
{
|
||||
if(songEditor && ( tl->autoScroll() == TimeLineWidget::AutoScrollEnabled ) )
|
||||
{
|
||||
songEditor->m_editor->updatePosition( MidiTime(tl->savedPos().getTicks() ) );
|
||||
}
|
||||
tl->savePos( -1 );
|
||||
}
|
||||
break;
|
||||
|
||||
case TimeLineWidget::KeepStopPosition:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user