Skip to content

Commit

Permalink
Remove Limited Session
Browse files Browse the repository at this point in the history
  • Loading branch information
zonkmachine committed May 13, 2017
1 parent 08201c2 commit 290556e
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 38 deletions.
3 changes: 1 addition & 2 deletions include/MainWindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,7 @@ class MainWindow : public QMainWindow
enum SessionState
{
Normal,
Recover,
Limited,
Recover
};

void setSession( SessionState session )
Expand Down
31 changes: 3 additions & 28 deletions src/core/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -739,10 +739,6 @@ int main( int argc, char * * argv )
" <td><b>%4</b></td>"
" <td>%5</td>"
" </tr>"
" <tr>"
" <td><b>%6</b></td>"
" <td>%7</td>"
" </tr>"
"</table>"
"</html>" ).arg(
MainWindow::tr( "There is a recovery file present. "
Expand All @@ -753,10 +749,6 @@ int main( int argc, char * * argv )
MainWindow::tr( "Recover" ),
MainWindow::tr( "Recover the file. Please don't run "
"multiple instances of LMMS when you do this." ),
MainWindow::tr( "Ignore" ),
MainWindow::tr( "Launch LMMS as usual but with "
"automatic backup disabled to prevent the "
"present recover file from being overwritten." ),
MainWindow::tr( "Discard" ),
MainWindow::tr( "Launch a default session and delete "
"the restored files. This is not reversible." )
Expand All @@ -768,25 +760,20 @@ int main( int argc, char * * argv )

QPushButton * recover;
QPushButton * discard;
QPushButton * ignore;
QPushButton * exit;

#if QT_VERSION >= 0x050000
// setting all buttons to the same roles allows us
// to have a custom layout
discard = mb.addButton( MainWindow::tr( "Discard" ),
QMessageBox::AcceptRole );
ignore = mb.addButton( MainWindow::tr( "Ignore" ),
QMessageBox::AcceptRole );
recover = mb.addButton( MainWindow::tr( "Recover" ),
QMessageBox::AcceptRole );

# else
// in qt4 the button order is reversed
recover = mb.addButton( MainWindow::tr( "Recover" ),
QMessageBox::AcceptRole );
ignore = mb.addButton( MainWindow::tr( "Ignore" ),
QMessageBox::AcceptRole );
discard = mb.addButton( MainWindow::tr( "Discard" ),
QMessageBox::AcceptRole );

Expand All @@ -799,7 +786,6 @@ int main( int argc, char * * argv )
// set icons
recover->setIcon( embed::getIconPixmap( "recover" ) );
discard->setIcon( embed::getIconPixmap( "discard" ) );
ignore->setIcon( embed::getIconPixmap( "ignore" ) );

mb.setDefaultButton( recover );
mb.setEscapeButton( exit );
Expand All @@ -814,13 +800,6 @@ int main( int argc, char * * argv )
fileToLoad = recoveryFile;
gui->mainWindow()->setSession( MainWindow::SessionState::Recover );
}
else if( mb.clickedButton() == ignore )
{
if( autoSaveEnabled )
{
gui->mainWindow()->setSession( MainWindow::SessionState::Limited );
}
}
else // Exit
{
return 0;
Expand Down Expand Up @@ -863,14 +842,11 @@ int main( int argc, char * * argv )
}
}
// If enabled, open last project if there is one. Else, create
// a new one. Also skip recently opened file if limited session to
// lower the chance of opening an already opened file.
// a new one.
else if( ConfigManager::inst()->
value( "app", "openlastproject" ).toInt() &&
!ConfigManager::inst()->
recentlyOpenedProjects().isEmpty() &&
gui->mainWindow()->getSession() !=
MainWindow::SessionState::Limited )
recentlyOpenedProjects().isEmpty() )
{
QString f = ConfigManager::inst()->
recentlyOpenedProjects().first();
Expand All @@ -893,8 +869,7 @@ int main( int argc, char * * argv )
// Finally we start the auto save timer and also trigger the
// autosave one time as recover.mmp is a signal to possible other
// instances of LMMS.
if( autoSaveEnabled &&
gui->mainWindow()->getSession() != MainWindow::SessionState::Limited )
if( autoSaveEnabled )
{
gui->mainWindow()->autoSaveTimerReset();
gui->mainWindow()->autoSave();
Expand Down
11 changes: 3 additions & 8 deletions src/gui/MainWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -664,10 +664,6 @@ void MainWindow::resetWindowTitle()
{
title += " - " + tr( "Recover session. Please save your work!" );
}
if( getSession() == Limited )
{
title += " - " + tr( "Automatic backup disabled. Remember to save your work!" );
}
setWindowTitle( title + " - " + tr( "LMMS %1" ).arg( LMMS_VERSION ) );
}

Expand Down Expand Up @@ -1374,8 +1370,8 @@ void MainWindow::closeEvent( QCloseEvent * _ce )
if( mayChangeProject(true) )
{
// delete recovery file
if( ConfigManager::inst()->value( "ui", "enableautosave" ).toInt()
&& getSession() != Limited )
if( ConfigManager::inst()->
value( "ui", "enableautosave" ).toInt() )
{
sessionCleanup();
_ce->accept();
Expand Down Expand Up @@ -1562,8 +1558,7 @@ void MainWindow::autoSave()
// from the timer where we need to do extra tests.
void MainWindow::runAutoSave()
{
if( ConfigManager::inst()->value( "ui", "enableautosave" ).toInt() &&
getSession() != Limited )
if( ConfigManager::inst()->value( "ui", "enableautosave" ).toInt() )
{
autoSave();
autoSaveTimerReset(); // Reset timer
Expand Down

0 comments on commit 290556e

Please sign in to comment.