From db434348a44c47bfd68e79c815bc5da3299e37e0 Mon Sep 17 00:00:00 2001 From: "Charles J. Cliffe" Date: Sat, 18 Jul 2015 21:49:53 -0400 Subject: [PATCH] save frequency snap value --- src/AppConfig.cpp | 17 ++++++++++++++++- src/AppConfig.h | 6 +++++- src/AppFrame.cpp | 4 ++++ 3 files changed, 25 insertions(+), 2 deletions(-) diff --git a/src/AppConfig.cpp b/src/AppConfig.cpp index d6db8dc..9b057ee 100644 --- a/src/AppConfig.cpp +++ b/src/AppConfig.cpp @@ -121,6 +121,7 @@ AppConfig::AppConfig() { winH.store(0); winMax.store(false); themeId.store(0); + snap.store(1); } @@ -186,6 +187,15 @@ int AppConfig::getTheme() { } +void AppConfig::setSnap(long long snapVal) { + this->snap.store(snapVal); +} + +long long AppConfig::getSnap() { + return snap.load(); +} + + bool AppConfig::save() { DataTree cfg; @@ -200,8 +210,8 @@ bool AppConfig::save() { *window_node->newChild("h") = winH.load(); *window_node->newChild("max") = winMax.load(); - *window_node->newChild("theme") = themeId.load(); + *window_node->newChild("snap") = snap.load(); } DataNode *devices_node = cfg.rootNode()->newChild("devices"); @@ -275,6 +285,11 @@ bool AppConfig::load() { themeId.store(theme); } + if (win_node->hasAnother("snap")) { + long long snapVal; + win_node->getNext("snap")->element()->get(snapVal); + snap.store(snapVal); + } } if (cfg.rootNode()->hasAnother("devices")) { diff --git a/src/AppConfig.h b/src/AppConfig.h index debc640..9d13f49 100644 --- a/src/AppConfig.h +++ b/src/AppConfig.h @@ -55,7 +55,10 @@ public: void setTheme(int themeId); int getTheme(); - + + void setSnap(long long snapVal); + long long getSnap(); + bool save(); bool load(); bool reset(); @@ -65,4 +68,5 @@ private: std::atomic_int winX,winY,winW,winH; std::atomic_bool winMax; std::atomic_int themeId; + std::atomic_llong snap; }; diff --git a/src/AppFrame.cpp b/src/AppFrame.cpp index 1336f81..5b8396b 100644 --- a/src/AppFrame.cpp +++ b/src/AppFrame.cpp @@ -319,6 +319,9 @@ AppFrame::AppFrame() : if (max) { this->Maximize(); } + + long long freqSnap = wxGetApp().getConfig()->getSnap(); + wxGetApp().setFrequencySnap(freqSnap); ThemeMgr::mgr.setTheme(wxGetApp().getConfig()->getTheme()); @@ -528,6 +531,7 @@ void AppFrame::OnClose(wxCloseEvent& event) { wxGetApp().getConfig()->setWindow(this->GetPosition(), this->GetClientSize()); wxGetApp().getConfig()->setWindowMaximized(this->IsMaximized()); wxGetApp().getConfig()->setTheme(ThemeMgr::mgr.getTheme()); + wxGetApp().getConfig()->setSnap(wxGetApp().getFrequencySnap()); wxGetApp().getConfig()->save(); event.Skip(); }