summaryrefslogtreecommitdiff
path: root/core/src/Model/GlobalStates.cpp
diff options
context:
space:
mode:
authorrtk0c <[email protected]>2021-03-31 20:19:18 -0700
committerrtk0c <[email protected]>2021-03-31 20:19:18 -0700
commit44f5fa5c8f258e8fc1f7d7e2e45e0485bd6cc490 (patch)
tree3f09a1cce46d38f5a8c6266150e67af3802d4b95 /core/src/Model/GlobalStates.cpp
parent31950890c939862f79c817053c106bf711c63a64 (diff)
Complete items tab (UI and serialization)
Diffstat (limited to 'core/src/Model/GlobalStates.cpp')
-rw-r--r--core/src/Model/GlobalStates.cpp17
1 files changed, 16 insertions, 1 deletions
diff --git a/core/src/Model/GlobalStates.cpp b/core/src/Model/GlobalStates.cpp
index cd076f4..0c4e58e 100644
--- a/core/src/Model/GlobalStates.cpp
+++ b/core/src/Model/GlobalStates.cpp
@@ -17,8 +17,12 @@ static std::unique_ptr<GlobalStates> globalStateInstance;
static fs::path globalDataPath;
void GlobalStates::Init() {
+ Init(StandardDirectories::UserData() / "cplt");
+}
+
+void GlobalStates::Init(std::filesystem::path userDataDir) {
globalStateInstance = std::make_unique<GlobalStates>();
- globalDataPath = StandardDirectories::UserData() / "cplt";
+ globalDataPath = userDataDir;
fs::create_directories(globalDataPath);
// Reading recent projects
@@ -79,6 +83,17 @@ void GlobalStates::AddRecentProject(const Project& project) {
MarkDirty();
}
+void GlobalStates::MoveProjectToTop(const Project& project) {
+ for (auto it = mRecentProjects.begin(); it != mRecentProjects.end(); ++it) {
+ if (it->path == project.GetPath()) {
+ std::rotate(it, it + 1, mRecentProjects.end());
+ MarkDirty();
+ return;
+ }
+ }
+ AddRecentProject(project);
+}
+
void GlobalStates::RemoveRecentProject(int idx) {
assert(idx >= 0 && idx < mRecentProjects.size());