diff options
author | saturneric <[email protected]> | 2024-01-15 09:22:32 +0000 |
---|---|---|
committer | saturneric <[email protected]> | 2024-01-15 09:22:32 +0000 |
commit | 6c632d70b391f8b317c68f7db8cfd217f9370995 (patch) | |
tree | 4136eb7164d9f910527c0392d12bd4854a2fdcff /src/ui/dialog/GeneralDialog.cpp | |
parent | refactor: remove boost and use QString instead of std::filesystem::path (diff) | |
download | GpgFrontend-6c632d70b391f8b317c68f7db8cfd217f9370995.tar.gz GpgFrontend-6c632d70b391f8b317c68f7db8cfd217f9370995.zip |
feat: use qt json support components in data object and infos gathering module
Diffstat (limited to 'src/ui/dialog/GeneralDialog.cpp')
-rw-r--r-- | src/ui/dialog/GeneralDialog.cpp | 32 |
1 files changed, 19 insertions, 13 deletions
diff --git a/src/ui/dialog/GeneralDialog.cpp b/src/ui/dialog/GeneralDialog.cpp index 498e2941..386573a3 100644 --- a/src/ui/dialog/GeneralDialog.cpp +++ b/src/ui/dialog/GeneralDialog.cpp @@ -29,6 +29,9 @@ #include "GeneralDialog.h" #include "ui/struct/SettingsObject.h" +#include "ui/struct/settings/WindowStateSO.h" + +namespace GpgFrontend { GpgFrontend::UI::GeneralDialog::GeneralDialog(QString name, QWidget *parent) : QDialog(parent), name_(std::move(name)) { @@ -43,12 +46,12 @@ void GpgFrontend::UI::GeneralDialog::slot_restore_settings() noexcept { update_rect_cache(); SettingsObject general_windows_state(name_ + "_dialog_state"); - bool window_save = general_windows_state.Check("window_save", false); + auto window_state = WindowStateSO(general_windows_state); // Restore window size & location - if (window_save) { - int x = general_windows_state.Check("window_pos").Check("x", 0); - int y = general_windows_state.Check("window_pos").Check("y", 0); + if (window_state.window_save) { + int x = window_state.x; + int y = window_state.y; GF_UI_LOG_DEBUG("stored dialog pos, x: {}, y: {}", x, y); QPoint relative_pos = {x, y}; @@ -56,9 +59,8 @@ void GpgFrontend::UI::GeneralDialog::slot_restore_settings() noexcept { GF_UI_LOG_DEBUG("relative dialog pos, x: {}, y: {}", relative_pos.x(), relative_pos.y()); - int width = general_windows_state.Check("window_size").Check("width", 0); - int height = - general_windows_state.Check("window_size").Check("height", 0); + int width = window_state.width; + int height = window_state.height; GF_UI_LOG_DEBUG("stored dialog size, width: {}, height: {}", width, height); @@ -93,12 +95,14 @@ void GpgFrontend::UI::GeneralDialog::slot_save_settings() noexcept { GF_UI_LOG_DEBUG("store dialog pos, x: {}, y: {}", relative_pos.x(), relative_pos.y()); - general_windows_state["window_pos"]["x"] = relative_pos.x(); - general_windows_state["window_pos"]["y"] = relative_pos.y(); + WindowStateSO window_state; + window_state.x = relative_pos.x(); + window_state.y = relative_pos.y(); + window_state.width = rect_.width(); + window_state.height = rect_.height(); + window_state.window_save = true; - general_windows_state["window_size"]["width"] = rect_.width(); - general_windows_state["window_size"]["height"] = rect_.height(); - general_windows_state["window_save"] = true; + general_windows_state.Store(window_state.Json()); } catch (...) { GF_UI_LOG_ERROR("general dialog: {}, caught exception", name_); @@ -210,4 +214,6 @@ void GpgFrontend::UI::GeneralDialog::showEvent(QShowEvent *event) { if (!isRectRestored()) movePosition2CenterOfParent(); QDialog::showEvent(event); -}
\ No newline at end of file +} + +} // namespace GpgFrontend
\ No newline at end of file |