diff options
author | Saturneric <[email protected]> | 2022-09-03 12:11:36 +0000 |
---|---|---|
committer | Saturneric <[email protected]> | 2022-09-03 12:11:36 +0000 |
commit | 4201e3d55cc3bd467c2e49f694a445744f9af93f (patch) | |
tree | 281aa2ad51b2753d6295e821a14d8b1737484855 /src/ui/main_window/GeneralMainWindow.cpp | |
parent | feat(project): support freebsd build (diff) | |
download | GpgFrontend-4201e3d55cc3bd467c2e49f694a445744f9af93f.tar.gz GpgFrontend-4201e3d55cc3bd467c2e49f694a445744f9af93f.zip |
fix(ui): fix user feedback issues.
1. add the font size settings of text editor.
2. fix exception under Russia lang when doing verification.
Diffstat (limited to 'src/ui/main_window/GeneralMainWindow.cpp')
-rw-r--r-- | src/ui/main_window/GeneralMainWindow.cpp | 43 |
1 files changed, 38 insertions, 5 deletions
diff --git a/src/ui/main_window/GeneralMainWindow.cpp b/src/ui/main_window/GeneralMainWindow.cpp index 7df73aba..73d9fcc3 100644 --- a/src/ui/main_window/GeneralMainWindow.cpp +++ b/src/ui/main_window/GeneralMainWindow.cpp @@ -33,14 +33,14 @@ #include "ui/struct/SettingsObject.h" GpgFrontend::UI::GeneralMainWindow::GeneralMainWindow(std::string name, - QWidget* parent) + QWidget *parent) : name_(std::move(name)), QMainWindow(parent) { slot_restore_settings(); } GpgFrontend::UI::GeneralMainWindow::~GeneralMainWindow() = default; -void GpgFrontend::UI::GeneralMainWindow::closeEvent(QCloseEvent* event) { +void GpgFrontend::UI::GeneralMainWindow::closeEvent(QCloseEvent *event) { slot_save_settings(); QMainWindow::closeEvent(event); } @@ -65,7 +65,6 @@ void GpgFrontend::UI::GeneralMainWindow::slot_restore_settings() noexcept { int x = general_windows_state.Check("window_pos").Check("x", 100), y = general_windows_state.Check("window_pos").Check("y", 100); - this->move({x, y}); pos_ = {x, y}; int width = @@ -73,10 +72,44 @@ void GpgFrontend::UI::GeneralMainWindow::slot_restore_settings() noexcept { height = general_windows_state.Check("window_size").Check("height", 450); - this->resize({width, height}); size_ = {width, height}; - } + if (this->parent() != nullptr) { + LOG(INFO) << "parent address" << this->parent(); + + QPoint parent_pos = {0, 0}; + QSize parent_size = {0, 0}; + + auto *parent_dialog = qobject_cast<QDialog *>(this->parent()); + if (parent_dialog != nullptr) { + parent_pos = parent_dialog->pos(); + parent_size = parent_dialog->size(); + } + + auto *parent_window = qobject_cast<QMainWindow *>(this->parent()); + if (parent_window != nullptr) { + parent_pos = parent_window->pos(); + parent_size = parent_window->size(); + } + + LOG(INFO) << "parent pos x:" << parent_pos.x() + << "y:" << parent_pos.y(); + + LOG(INFO) << "parent size width:" << parent_size.width() + << "height:" << parent_size.height(); + + if (parent_pos != QPoint{0, 0}) { + QPoint parent_center{parent_pos.x() + parent_size.width() / 2, + parent_pos.y() + parent_size.height() / 2}; + + pos_ = {parent_center.x() - size_.width() / 2, + parent_center.y() - size_.height() / 2}; + } + } + + this->move(pos_); + this->resize(size_); + } // appearance SettingsObject general_settings_state("general_settings_state"); |