diff options
Diffstat (limited to 'core/src/Model/GlobalStates.hpp')
-rw-r--r-- | core/src/Model/GlobalStates.hpp | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/core/src/Model/GlobalStates.hpp b/core/src/Model/GlobalStates.hpp new file mode 100644 index 0000000..e6d823b --- /dev/null +++ b/core/src/Model/GlobalStates.hpp @@ -0,0 +1,43 @@ +#pragma once + +#include "Utils/Sigslot.hpp" +#include "cplt_fwd.hpp" + +#include <filesystem> +#include <string> +#include <vector> + +class GlobalStates { +public: + static void Init(); + static void Shutdown(); + + static GlobalStates& GetInstance(); + static const std::filesystem::path& GetUserDataPath(); + + struct RecentProject { + std::filesystem::path path; + std::string cachedUtf8String; + }; + +public: + Signal<> OnModified; + +private: + std::vector<RecentProject> mRecentProjects; + mutable bool mDirty = false; + +public: + const std::vector<RecentProject>& GetRecentProjects() const; + void ClearRecentProjects(); + void AddRecentProject(const Project& project); + void RemoveRecentProject(int idx); + + // TODO async autosaving to prevent data loss on crash + void WriteToDisk() const; + + bool IsDirty() const; + +private: + void MarkDirty(); +}; |