Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove Limited Session #3545

Merged
merged 1 commit into from
May 13, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -737,10 +737,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 @@ -751,10 +747,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 @@ -766,25 +758,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 @@ -797,7 +784,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 @@ -812,13 +798,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 @@ -861,14 +840,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 @@ -891,8 +867,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