merged with master
This commit is contained in:
+19
-3
@@ -48,7 +48,9 @@ std::unique_ptr<OliveGlobal> olive::Global;
|
||||
QString olive::ActiveProjectFilename;
|
||||
QString olive::AppName;
|
||||
|
||||
OliveGlobal::OliveGlobal() {
|
||||
OliveGlobal::OliveGlobal() :
|
||||
changed_since_last_autorecovery(false)
|
||||
{
|
||||
// sets current app name
|
||||
QString version_id;
|
||||
|
||||
@@ -107,6 +109,17 @@ void OliveGlobal::set_rendering_state(bool rendering) {
|
||||
}
|
||||
}
|
||||
|
||||
void OliveGlobal::set_modified(bool modified)
|
||||
{
|
||||
olive::MainWindow->setWindowModified(modified);
|
||||
changed_since_last_autorecovery = modified;
|
||||
}
|
||||
|
||||
bool OliveGlobal::is_modified()
|
||||
{
|
||||
return olive::MainWindow->isWindowModified();
|
||||
}
|
||||
|
||||
void OliveGlobal::load_project_on_launch(const QString& s) {
|
||||
olive::ActiveProjectFilename = s;
|
||||
enable_load_project_on_init = true;
|
||||
@@ -219,7 +232,7 @@ bool OliveGlobal::save_project() {
|
||||
}
|
||||
|
||||
bool OliveGlobal::can_close_project() {
|
||||
if (olive::MainWindow->isWindowModified()) {
|
||||
if (is_modified()) {
|
||||
QMessageBox* m = new QMessageBox(
|
||||
QMessageBox::Question,
|
||||
tr("Unsaved Project"),
|
||||
@@ -281,8 +294,11 @@ void OliveGlobal::finished_initialize() {
|
||||
}
|
||||
|
||||
void OliveGlobal::save_autorecovery_file() {
|
||||
if (olive::MainWindow->isWindowModified()) {
|
||||
if (changed_since_last_autorecovery) {
|
||||
panel_project->save_project(true);
|
||||
|
||||
changed_since_last_autorecovery = false;
|
||||
|
||||
qInfo() << "Auto-recovery project saved";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -92,6 +92,31 @@ public:
|
||||
*/
|
||||
void set_rendering_state(bool rendering);
|
||||
|
||||
/**
|
||||
* @brief Set the application's "modified" state
|
||||
*
|
||||
* Primarily controls whether the application prompts the user to save the project upon closing or not. Also
|
||||
* technically controls whether to create autorecovery files as they'll only be generated if there are unsaved
|
||||
* changes.
|
||||
*
|
||||
* @param modified
|
||||
*
|
||||
* TRUE if the project has been modified, FALSE if it has not.
|
||||
*/
|
||||
void set_modified(bool modified);
|
||||
|
||||
/**
|
||||
* @brief Get application's current "modified" state
|
||||
*
|
||||
* Currently just a wrapper around MainWindow::isWindowModified(), but use this instead in case it changes.
|
||||
* This value is used to determine whether the currently open project has unsaved changes.
|
||||
*
|
||||
* @return
|
||||
*
|
||||
* TRUE if the project has been modified since the last save.
|
||||
*/
|
||||
bool is_modified();
|
||||
|
||||
/**
|
||||
* @brief Set a project to load just after launching
|
||||
*
|
||||
@@ -324,6 +349,16 @@ private:
|
||||
*/
|
||||
std::unique_ptr<QTranslator> translator;
|
||||
|
||||
/**
|
||||
* @brief Internal variable for whether the project has changed since the last autorecovery
|
||||
*
|
||||
* Set by set_modified(), which should be called alongside any change made to the project file and is "unset" when
|
||||
* an autorecovery file is made. Provides an extra layer of abstraction from the application "modified" state to
|
||||
* prevents an autorecovery file saving multiple times if the project hasn't actually changed since the last
|
||||
* autorecovery, but still hasn't been saved into the original file yet.
|
||||
*/
|
||||
bool changed_since_last_autorecovery;
|
||||
|
||||
private slots:
|
||||
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user