Merge pull request #1852 from csimons/do-not-halt-playback-upon-open-dialog

Prevent playback from halting when 'Open Project' dialog is summoned.
This commit is contained in:
Tres Finocchiaro
2015-03-10 12:56:58 +00:00
4 changed files with 16 additions and 11 deletions

View File

@@ -69,10 +69,12 @@ public:
/// opens another file...) must call this before and may only proceed if
/// this function returns true.
///
/// \param stopPlayback whether playback should be stopped upon prompting. If set to false, the caller should ensure that Engine::getSong()->stop() is called before unloading/loading a song.
///
/// \return true if the user allows the software to proceed, false if they
/// cancel the action.
///
bool mayChangeProject();
bool mayChangeProject(bool stopPlayback);
void clearKeyModifiers();

View File

@@ -583,7 +583,7 @@ void FileBrowserTreeWidget::handleFile(FileItem * f, InstrumentTrack * it )
switch( f->handling() )
{
case FileItem::LoadAsProject:
if( gui->mainWindow()->mayChangeProject() )
if( gui->mainWindow()->mayChangeProject(true) )
{
Engine::getSong()->loadProject( f->fullName() );
}
@@ -614,7 +614,7 @@ void FileBrowserTreeWidget::handleFile(FileItem * f, InstrumentTrack * it )
case FileItem::ImportAsProject:
if( f->type() == FileItem::FlpFile &&
!gui->mainWindow()->mayChangeProject() )
!gui->mainWindow()->mayChangeProject(true) )
{
break;
}

View File

@@ -618,9 +618,10 @@ void MainWindow::resetWindowTitle()
bool MainWindow::mayChangeProject()
bool MainWindow::mayChangeProject(bool stopPlayback)
{
Engine::getSong()->stop();
if( stopPlayback )
Engine::getSong()->stop();
if( !Engine::getSong()->isModified() )
{
@@ -733,7 +734,7 @@ void MainWindow::enterWhatsThisMode()
void MainWindow::createNewProject()
{
if( mayChangeProject() )
if( mayChangeProject(true) )
{
Engine::getSong()->createNewProject();
}
@@ -744,7 +745,7 @@ void MainWindow::createNewProject()
void MainWindow::createNewProjectFromTemplate( QAction * _idx )
{
if( m_templatesMenu != NULL && mayChangeProject() )
if( m_templatesMenu != NULL && mayChangeProject(true) )
{
QString dir_base = m_templatesMenu->actions().indexOf( _idx )
>= m_custom_templates_count ?
@@ -760,7 +761,7 @@ void MainWindow::createNewProjectFromTemplate( QAction * _idx )
void MainWindow::openProject()
{
if( mayChangeProject() )
if( mayChangeProject(false) )
{
FileDialog ofd( this, tr( "Open Project" ), "", tr( "LMMS (*.mmp *.mmpz)" ) );
@@ -769,6 +770,8 @@ void MainWindow::openProject()
if( ofd.exec () == QDialog::Accepted &&
!ofd.selectedFiles().isEmpty() )
{
Engine::getSong()->stop();
setCursor( Qt::WaitCursor );
Engine::getSong()->loadProject(
ofd.selectedFiles()[0] );
@@ -796,7 +799,7 @@ void MainWindow::updateRecentlyOpenedProjectsMenu()
void MainWindow::openRecentlyOpenedProject( QAction * _action )
{
if ( mayChangeProject() )
if ( mayChangeProject(true) )
{
const QString & f = _action->text();
setCursor( Qt::WaitCursor );
@@ -1185,7 +1188,7 @@ void MainWindow::redo()
void MainWindow::closeEvent( QCloseEvent * _ce )
{
if( mayChangeProject() )
if( mayChangeProject(true) )
{
// delete recovery file
QFile::remove(ConfigManager::inst()->recoveryFile());

View File

@@ -377,7 +377,7 @@ void TrackContainerView::dropEvent( QDropEvent * _de )
else if( type == "projectfile")
{
if( gui->mainWindow()->mayChangeProject() )
if( gui->mainWindow()->mayChangeProject(true) )
{
Engine::getSong()->loadProject( value );
}