Save window maximized state
This commit is contained in:
parent
291ec7038a
commit
9c9e82cffc
|
@ -114,6 +114,16 @@ void DeviceConfig::load(DataNode *node) {
|
||||||
busy_lock.unlock();
|
busy_lock.unlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
AppConfig::AppConfig() {
|
||||||
|
winX.store(0);
|
||||||
|
winY.store(0);
|
||||||
|
winW.store(0);
|
||||||
|
winH.store(0);
|
||||||
|
winMax.store(false);
|
||||||
|
themeId.store(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
DeviceConfig *AppConfig::getDevice(std::string deviceId) {
|
DeviceConfig *AppConfig::getDevice(std::string deviceId) {
|
||||||
if (deviceConfig.find(deviceId) == deviceConfig.end()) {
|
if (deviceConfig.find(deviceId) == deviceConfig.end()) {
|
||||||
|
@ -150,6 +160,14 @@ void AppConfig::setWindow(wxPoint winXY, wxSize winWH) {
|
||||||
winH.store(winWH.y);
|
winH.store(winWH.y);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void AppConfig::setWindowMaximized(bool max) {
|
||||||
|
winMax.store(max);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool AppConfig::getWindowMaximized() {
|
||||||
|
return winMax.load();
|
||||||
|
}
|
||||||
|
|
||||||
wxRect *AppConfig::getWindow() {
|
wxRect *AppConfig::getWindow() {
|
||||||
wxRect *r = NULL;
|
wxRect *r = NULL;
|
||||||
if (winH.load() && winW.load()) {
|
if (winH.load() && winW.load()) {
|
||||||
|
@ -181,6 +199,8 @@ bool AppConfig::save() {
|
||||||
*window_node->newChild("w") = winW.load();
|
*window_node->newChild("w") = winW.load();
|
||||||
*window_node->newChild("h") = winH.load();
|
*window_node->newChild("h") = winH.load();
|
||||||
|
|
||||||
|
*window_node->newChild("max") = winMax.load();
|
||||||
|
|
||||||
*window_node->newChild("theme") = themeId.load();
|
*window_node->newChild("theme") = themeId.load();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -228,6 +248,7 @@ bool AppConfig::load() {
|
||||||
|
|
||||||
if (cfg.rootNode()->hasAnother("window")) {
|
if (cfg.rootNode()->hasAnother("window")) {
|
||||||
int x,y,w,h;
|
int x,y,w,h;
|
||||||
|
int max;
|
||||||
|
|
||||||
DataNode *win_node = cfg.rootNode()->getNext("window");
|
DataNode *win_node = cfg.rootNode()->getNext("window");
|
||||||
|
|
||||||
|
@ -243,6 +264,11 @@ bool AppConfig::load() {
|
||||||
winH.store(h);
|
winH.store(h);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (win_node->hasAnother("max")) {
|
||||||
|
win_node->getNext("max")->element()->get(max);
|
||||||
|
winMax.store(max?true:false);
|
||||||
|
}
|
||||||
|
|
||||||
if (win_node->hasAnother("theme")) {
|
if (win_node->hasAnother("theme")) {
|
||||||
int theme;
|
int theme;
|
||||||
win_node->getNext("theme")->element()->get(theme);
|
win_node->getNext("theme")->element()->get(theme);
|
||||||
|
|
|
@ -43,12 +43,16 @@ private:
|
||||||
|
|
||||||
class AppConfig {
|
class AppConfig {
|
||||||
public:
|
public:
|
||||||
|
AppConfig();
|
||||||
std::string getConfigDir();
|
std::string getConfigDir();
|
||||||
DeviceConfig *getDevice(std::string deviceId);
|
DeviceConfig *getDevice(std::string deviceId);
|
||||||
|
|
||||||
void setWindow(wxPoint winXY, wxSize winWH);
|
void setWindow(wxPoint winXY, wxSize winWH);
|
||||||
wxRect *getWindow();
|
wxRect *getWindow();
|
||||||
|
|
||||||
|
void setWindowMaximized(bool max);
|
||||||
|
bool getWindowMaximized();
|
||||||
|
|
||||||
void setTheme(int themeId);
|
void setTheme(int themeId);
|
||||||
int getTheme();
|
int getTheme();
|
||||||
|
|
||||||
|
@ -59,5 +63,6 @@ public:
|
||||||
private:
|
private:
|
||||||
std::map<std::string, DeviceConfig *> deviceConfig;
|
std::map<std::string, DeviceConfig *> deviceConfig;
|
||||||
std::atomic_int winX,winY,winW,winH;
|
std::atomic_int winX,winY,winW,winH;
|
||||||
|
std::atomic_bool winMax;
|
||||||
std::atomic_int themeId;
|
std::atomic_int themeId;
|
||||||
};
|
};
|
||||||
|
|
|
@ -313,6 +313,11 @@ AppFrame::AppFrame() :
|
||||||
SetClientSize(1280, 600);
|
SetClientSize(1280, 600);
|
||||||
Centre();
|
Centre();
|
||||||
}
|
}
|
||||||
|
bool max = wxGetApp().getConfig()->getWindowMaximized();
|
||||||
|
|
||||||
|
if (max) {
|
||||||
|
this->Maximize();
|
||||||
|
}
|
||||||
|
|
||||||
ThemeMgr::mgr.setTheme(wxGetApp().getConfig()->getTheme());
|
ThemeMgr::mgr.setTheme(wxGetApp().getConfig()->getTheme());
|
||||||
|
|
||||||
|
@ -520,6 +525,7 @@ void AppFrame::OnMenu(wxCommandEvent& event) {
|
||||||
|
|
||||||
void AppFrame::OnClose(wxCloseEvent& event) {
|
void AppFrame::OnClose(wxCloseEvent& event) {
|
||||||
wxGetApp().getConfig()->setWindow(this->GetPosition(), this->GetClientSize());
|
wxGetApp().getConfig()->setWindow(this->GetPosition(), this->GetClientSize());
|
||||||
|
wxGetApp().getConfig()->setWindowMaximized(this->IsMaximized());
|
||||||
wxGetApp().getConfig()->setTheme(ThemeMgr::mgr.getTheme());
|
wxGetApp().getConfig()->setTheme(ThemeMgr::mgr.getTheme());
|
||||||
wxGetApp().getConfig()->save();
|
wxGetApp().getConfig()->save();
|
||||||
event.Skip();
|
event.Skip();
|
||||||
|
|
Loading…
Reference in New Issue