reimplemented infrastructure for autorecovery projects

Foundation for a fairly simple but likely essential autorecovery process.
Basically the same as what it was in 0.1.x but with a huge improvement: custom
autorecovery intervals. Ironically there isn't any "saving" to be done
just yet, but when there is, this infrastructure will be ready for it.
This commit is contained in:
itsmattkc
2019-11-18 13:47:42 +09:00
parent 7385e3dc56
commit db9f188733
3 changed files with 58 additions and 1 deletions
+1
View File
@@ -53,6 +53,7 @@ void Config::SetDefaults()
config_map_["DefaultStillLength"] = QVariant::fromValue(rational(2));
config_map_["HoverFocus"] = false;
config_map_["AudioScrubbing"] = true;
config_map_["AutorecoveryInterval"] = 1;
}
void Config::Load()
+27 -1
View File
@@ -52,7 +52,8 @@ Core olive::core;
Core::Core() :
main_window_(nullptr),
tool_(olive::tool::kPointer),
snapping_(true)
snapping_(true),
queue_autorecovery_(false)
{
}
@@ -351,6 +352,19 @@ void Core::StartGUI(bool full_screen)
// Initialize audio service
AudioManager::CreateInstance();
// Start autorecovery timer using the config value as its interval
SetAutorecoveryInterval(Config::Current()["AutorecoveryInterval"].toInt());
autorecovery_timer_.start();
}
void Core::SaveAutorecovery()
{
if (queue_autorecovery_) {
// FIXME: Save autorecovery of projects open
queue_autorecovery_ = false;
}
}
Project *Core::GetActiveProject()
@@ -366,3 +380,15 @@ Project *Core::GetActiveProject()
// Otherwise, return the project panel's project (which may be nullptr but in most cases shouldn't be)
return active_project_panel->project();
}
void Core::SetProjectModified()
{
main_window()->setWindowModified(true);
queue_autorecovery_ = true;
}
void Core::SetAutorecoveryInterval(int minutes)
{
// Convert minutes to milliseconds
autorecovery_timer_.setInterval(minutes * 60000);
}
+30
View File
@@ -22,6 +22,7 @@
#define CORE_H
#include <QList>
#include <QTimer>
#include "project/project.h"
#include "project/projectviewmodel.h"
@@ -113,6 +114,19 @@ public:
*/
Project* GetActiveProject();
/**
* @brief Sets state to "modified" so that the GUI will prompt the user to save before closing
*
* Call this function whenever a change is made to a currently active project. Saving the project will automatically
* unset this.
*/
void SetProjectModified();
/**
* @brief Set how frequently an autorecovery should be saved (if the project has changed, see SetProjectModified())
*/
void SetAutorecoveryInterval(int minutes);
public slots:
/**
* @brief Set the current application-wide tool
@@ -226,6 +240,22 @@ private:
*/
bool snapping_;
/**
* @brief Internal value for whether to make an autorecovery next interval
*
* True if the project has changed since the last autorecovery and we should save next time. False if the project has
* not changed and saving another autorecovery would be a waste.
*/
bool queue_autorecovery_;
/**
* @brief Internal timer for saving autorecovery files
*/
QTimer autorecovery_timer_;
private slots:
void SaveAutorecovery();
};
namespace olive {