mirror of
https://github.com/ciphervance/supercell-wx.git
synced 2025-10-30 16:00:08 +00:00
added saving geometry
This commit is contained in:
parent
449912e655
commit
1b16b903a0
3 changed files with 27 additions and 5 deletions
|
|
@ -443,10 +443,15 @@ void MainWindow::keyReleaseEvent(QKeyEvent* ev)
|
||||||
void MainWindow::showEvent(QShowEvent* event)
|
void MainWindow::showEvent(QShowEvent* event)
|
||||||
{
|
{
|
||||||
QMainWindow::showEvent(event);
|
QMainWindow::showEvent(event);
|
||||||
|
auto& uiSettings = settings::UiSettings::Instance();
|
||||||
|
|
||||||
|
// restore the geometry state
|
||||||
|
std::string uiGeometry = uiSettings.main_ui_geometry().GetValue();
|
||||||
|
restoreGeometry(
|
||||||
|
QByteArray::fromBase64(QByteArray::fromStdString(uiGeometry)));
|
||||||
|
|
||||||
// restore the UI state
|
// restore the UI state
|
||||||
std::string uiState =
|
std::string uiState = uiSettings.main_ui_state().GetValue();
|
||||||
settings::UiSettings::Instance().main_ui_state().GetValue();
|
|
||||||
|
|
||||||
bool restored =
|
bool restored =
|
||||||
restoreState(QByteArray::fromBase64(QByteArray::fromStdString(uiState)));
|
restoreState(QByteArray::fromBase64(QByteArray::fromStdString(uiState)));
|
||||||
|
|
@ -458,9 +463,15 @@ void MainWindow::showEvent(QShowEvent* event)
|
||||||
|
|
||||||
void MainWindow::closeEvent(QCloseEvent* event)
|
void MainWindow::closeEvent(QCloseEvent* event)
|
||||||
{
|
{
|
||||||
|
auto& uiSettings = settings::UiSettings::Instance();
|
||||||
|
|
||||||
|
// save the UI geometry
|
||||||
|
QByteArray uiGeometry = saveGeometry().toBase64();
|
||||||
|
uiSettings.main_ui_geometry().StageValue(uiGeometry.data());
|
||||||
|
|
||||||
// save the UI state
|
// save the UI state
|
||||||
QByteArray uiState = saveState().toBase64();
|
QByteArray uiState = saveState().toBase64();
|
||||||
settings::UiSettings::Instance().main_ui_state().StageValue(uiState.data());
|
uiSettings.main_ui_state().StageValue(uiState.data());
|
||||||
|
|
||||||
QMainWindow::closeEvent(event);
|
QMainWindow::closeEvent(event);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -20,6 +20,7 @@ public:
|
||||||
mapSettingsExpanded_.SetDefault(true);
|
mapSettingsExpanded_.SetDefault(true);
|
||||||
timelineExpanded_.SetDefault(true);
|
timelineExpanded_.SetDefault(true);
|
||||||
mainUIState_.SetDefault("");
|
mainUIState_.SetDefault("");
|
||||||
|
mainUIGeometry_.SetDefault("");
|
||||||
}
|
}
|
||||||
|
|
||||||
~UiSettingsImpl() {}
|
~UiSettingsImpl() {}
|
||||||
|
|
@ -30,6 +31,7 @@ public:
|
||||||
SettingsVariable<bool> mapSettingsExpanded_ {"map_settings_expanded"};
|
SettingsVariable<bool> mapSettingsExpanded_ {"map_settings_expanded"};
|
||||||
SettingsVariable<bool> timelineExpanded_ {"timeline_expanded"};
|
SettingsVariable<bool> timelineExpanded_ {"timeline_expanded"};
|
||||||
SettingsVariable<std::string> mainUIState_ {"main_ui_state"};
|
SettingsVariable<std::string> mainUIState_ {"main_ui_state"};
|
||||||
|
SettingsVariable<std::string> mainUIGeometry_ {"main_ui_geometry"};
|
||||||
};
|
};
|
||||||
|
|
||||||
UiSettings::UiSettings() :
|
UiSettings::UiSettings() :
|
||||||
|
|
@ -40,7 +42,8 @@ UiSettings::UiSettings() :
|
||||||
&p->level3ProductsExpanded_,
|
&p->level3ProductsExpanded_,
|
||||||
&p->mapSettingsExpanded_,
|
&p->mapSettingsExpanded_,
|
||||||
&p->timelineExpanded_,
|
&p->timelineExpanded_,
|
||||||
&p->mainUIState_});
|
&p->mainUIState_,
|
||||||
|
&p->mainUIGeometry_});
|
||||||
SetDefaults();
|
SetDefaults();
|
||||||
}
|
}
|
||||||
UiSettings::~UiSettings() = default;
|
UiSettings::~UiSettings() = default;
|
||||||
|
|
@ -78,6 +81,11 @@ SettingsVariable<std::string>& UiSettings::main_ui_state() const
|
||||||
return p->mainUIState_;
|
return p->mainUIState_;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SettingsVariable<std::string>& UiSettings::main_ui_geometry() const
|
||||||
|
{
|
||||||
|
return p->mainUIGeometry_;
|
||||||
|
}
|
||||||
|
|
||||||
bool UiSettings::Shutdown()
|
bool UiSettings::Shutdown()
|
||||||
{
|
{
|
||||||
bool dataChanged = false;
|
bool dataChanged = false;
|
||||||
|
|
@ -89,6 +97,7 @@ bool UiSettings::Shutdown()
|
||||||
dataChanged |= p->mapSettingsExpanded_.Commit();
|
dataChanged |= p->mapSettingsExpanded_.Commit();
|
||||||
dataChanged |= p->timelineExpanded_.Commit();
|
dataChanged |= p->timelineExpanded_.Commit();
|
||||||
dataChanged |= p->mainUIState_.Commit();
|
dataChanged |= p->mainUIState_.Commit();
|
||||||
|
dataChanged |= p->mainUIGeometry_.Commit();
|
||||||
|
|
||||||
return dataChanged;
|
return dataChanged;
|
||||||
}
|
}
|
||||||
|
|
@ -106,7 +115,8 @@ bool operator==(const UiSettings& lhs, const UiSettings& rhs)
|
||||||
lhs.p->level3ProductsExpanded_ == rhs.p->level3ProductsExpanded_ &&
|
lhs.p->level3ProductsExpanded_ == rhs.p->level3ProductsExpanded_ &&
|
||||||
lhs.p->mapSettingsExpanded_ == rhs.p->mapSettingsExpanded_ &&
|
lhs.p->mapSettingsExpanded_ == rhs.p->mapSettingsExpanded_ &&
|
||||||
lhs.p->timelineExpanded_ == rhs.p->timelineExpanded_ &&
|
lhs.p->timelineExpanded_ == rhs.p->timelineExpanded_ &&
|
||||||
lhs.p->mainUIState_ == rhs.p->mainUIState_);
|
lhs.p->mainUIState_ == rhs.p->mainUIState_ &&
|
||||||
|
lhs.p->mainUIGeometry_ == rhs.p->mainUIGeometry_);
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace settings
|
} // namespace settings
|
||||||
|
|
|
||||||
|
|
@ -33,6 +33,7 @@ public:
|
||||||
SettingsVariable<bool>& map_settings_expanded() const;
|
SettingsVariable<bool>& map_settings_expanded() const;
|
||||||
SettingsVariable<bool>& timeline_expanded() const;
|
SettingsVariable<bool>& timeline_expanded() const;
|
||||||
SettingsVariable<std::string>& main_ui_state() const;
|
SettingsVariable<std::string>& main_ui_state() const;
|
||||||
|
SettingsVariable<std::string>& main_ui_geometry() const;
|
||||||
|
|
||||||
bool Shutdown();
|
bool Shutdown();
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue