aboutsummaryrefslogtreecommitdiff
path: root/app/source/Cplt/Model/GlobalStates.cpp
diff options
context:
space:
mode:
authorrtk0c <[email protected]>2022-11-27 12:04:31 -0800
committerrtk0c <[email protected]>2022-11-27 12:04:31 -0800
commit182c8f8357739f905bbd721006480502435b6b43 (patch)
tree082613a474d863182e2ad8f2167f1643f26e67a3 /app/source/Cplt/Model/GlobalStates.cpp
parentb01ed99a1cd0c863c8709930658513c04dd70f61 (diff)
Update brace style to match rest of my projectscplt-imgui
Diffstat (limited to 'app/source/Cplt/Model/GlobalStates.cpp')
-rw-r--r--app/source/Cplt/Model/GlobalStates.cpp48
1 files changed, 16 insertions, 32 deletions
diff --git a/app/source/Cplt/Model/GlobalStates.cpp b/app/source/Cplt/Model/GlobalStates.cpp
index 417514f..b21e299 100644
--- a/app/source/Cplt/Model/GlobalStates.cpp
+++ b/app/source/Cplt/Model/GlobalStates.cpp
@@ -16,13 +16,11 @@ namespace fs = std::filesystem;
static std::unique_ptr<GlobalStates> globalStateInstance;
static fs::path globalDataPath;
-void GlobalStates::Init()
-{
+void GlobalStates::Init() {
Init(StandardDirectories::UserData() / "cplt");
}
-void GlobalStates::Init(std::filesystem::path userDataDir)
-{
+void GlobalStates::Init(std::filesystem::path userDataDir) {
globalStateInstance = std::make_unique<GlobalStates>();
globalDataPath = userDataDir;
fs::create_directories(globalDataPath);
@@ -53,8 +51,7 @@ void GlobalStates::Init(std::filesystem::path userDataDir)
}
}
-void GlobalStates::Shutdown()
-{
+void GlobalStates::Shutdown() {
if (!globalStateInstance) return;
globalStateInstance->SetCurrentProject(nullptr);
@@ -64,29 +61,24 @@ void GlobalStates::Shutdown()
}
}
-GlobalStates& GlobalStates::GetInstance()
-{
+GlobalStates& GlobalStates::GetInstance() {
return *globalStateInstance;
}
-const std::filesystem::path& GlobalStates::GetUserDataPath()
-{
+const std::filesystem::path& GlobalStates::GetUserDataPath() {
return globalDataPath;
}
-const std::vector<GlobalStates::RecentProject>& GlobalStates::GetRecentProjects() const
-{
+const std::vector<GlobalStates::RecentProject>& GlobalStates::GetRecentProjects() const {
return mRecentProjects;
}
-void GlobalStates::ClearRecentProjects()
-{
+void GlobalStates::ClearRecentProjects() {
mRecentProjects.clear();
MarkDirty();
}
-void GlobalStates::AddRecentProject(const Project& project)
-{
+void GlobalStates::AddRecentProject(const Project& project) {
mRecentProjects.push_back(RecentProject{
.Path = project.GetPath(),
.CachedUtf8String = project.GetPath().string(),
@@ -94,8 +86,7 @@ void GlobalStates::AddRecentProject(const Project& project)
MarkDirty();
}
-void GlobalStates::MoveProjectToTop(const Project& project)
-{
+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());
@@ -106,26 +97,22 @@ void GlobalStates::MoveProjectToTop(const Project& project)
AddRecentProject(project);
}
-void GlobalStates::RemoveRecentProject(int idx)
-{
+void GlobalStates::RemoveRecentProject(int idx) {
assert(idx >= 0 && idx < mRecentProjects.size());
mRecentProjects.erase(mRecentProjects.begin() + idx);
MarkDirty();
}
-bool GlobalStates::HasCurrentProject() const
-{
+bool GlobalStates::HasCurrentProject() const {
return mCurrentProject != nullptr;
}
-Project* GlobalStates::GetCurrentProject() const
-{
+Project* GlobalStates::GetCurrentProject() const {
return mCurrentProject.get();
}
-void GlobalStates::SetCurrentProject(std::unique_ptr<Project> project)
-{
+void GlobalStates::SetCurrentProject(std::unique_ptr<Project> project) {
if (mCurrentProject) {
mCurrentProject->WriteToDisk();
mCurrentProject = nullptr;
@@ -136,8 +123,7 @@ void GlobalStates::SetCurrentProject(std::unique_ptr<Project> project)
mCurrentProject = std::move(project);
}
-void GlobalStates::WriteToDisk() const
-{
+void GlobalStates::WriteToDisk() const {
Json::Value root;
auto& recentProjects = root["RecentProjects"] = Json::Value(Json::arrayValue);
@@ -151,13 +137,11 @@ void GlobalStates::WriteToDisk() const
mDirty = false;
}
-bool GlobalStates::IsDirty() const
-{
+bool GlobalStates::IsDirty() const {
return mDirty;
}
-void GlobalStates::MarkDirty()
-{
+void GlobalStates::MarkDirty() {
mDirty = true;
OnModified();
}