From 70cc233165b5efa3a3888af34f7afce095fe6947 Mon Sep 17 00:00:00 2001 From: rtk0c Date: Mon, 29 Mar 2021 17:55:02 -0700 Subject: More work on project tab --- core/src/Model/GlobalStates.hpp | 43 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 core/src/Model/GlobalStates.hpp (limited to 'core/src/Model/GlobalStates.hpp') 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 +#include +#include + +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 mRecentProjects; + mutable bool mDirty = false; + +public: + const std::vector& 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(); +}; -- cgit v1.2.3-70-g09d2