aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSaturneric <[email protected]>2023-07-14 15:15:30 +0000
committerSaturneric <[email protected]>2023-07-14 15:15:30 +0000
commite85c69378e4c8f29b4c147924381b73c164814eb (patch)
treed2cb1899825cd12b814b4a1fa1097dd858137707
parentfix: improve waiting dialog (diff)
downloadGpgFrontend-dev/2.1.0/main.tar.gz
GpgFrontend-dev/2.1.0/main.zip
fix: slove border issues at GernalDialogdev/2.1.0/main
-rw-r--r--src/ui/dialog/GeneralDialog.cpp24
-rw-r--r--src/ui/dialog/GeneralDialog.h1
2 files changed, 16 insertions, 9 deletions
diff --git a/src/ui/dialog/GeneralDialog.cpp b/src/ui/dialog/GeneralDialog.cpp
index 71a8f5c7..d4b6613e 100644
--- a/src/ui/dialog/GeneralDialog.cpp
+++ b/src/ui/dialog/GeneralDialog.cpp
@@ -60,10 +60,13 @@ void GpgFrontend::UI::GeneralDialog::slot_restore_settings() noexcept {
general_windows_state.Check("window_size").Check("height", 0);
SPDLOG_DEBUG("stored dialog size, width: {}, height: {}", width, height);
+ QRect target_rect_ = {pos.x(), pos.y(), width, height};
+ SPDLOG_DEBUG("dialog stored target rect, width: {}, height: {}", width,
+ height);
+
// check for valid
- if (width > 0 && height > 0) {
- this->resize(width, height);
- this->move(pos);
+ if (width > 0 && height > 0 && screen_rect_.contains(target_rect_)) {
+ this->setGeometry(target_rect_);
this->rect_restored_ = true;
}
}
@@ -101,17 +104,17 @@ void GpgFrontend::UI::GeneralDialog::slot_save_settings() noexcept {
}
void GpgFrontend::UI::GeneralDialog::setPosCenterOfScreen() {
- auto *screen = QGuiApplication::primaryScreen();
- QRect geo = screen->availableGeometry();
- int screen_width = geo.width();
- int screen_height = geo.height();
+ update_rect_cache();
- SPDLOG_DEBUG("primary screen available geometry", screen_width,
+ int screen_width = screen_rect_.width();
+ int screen_height = screen_rect_.height();
+ SPDLOG_DEBUG("dialog current screen available geometry", screen_width,
screen_height);
// update rect of current dialog
rect_ = this->geometry();
- this->move(geo.center() - rect_.center());
+ this->move(screen_rect_.center() -
+ QPoint(rect_.width() / 2, rect_.height() / 2));
}
/**
@@ -156,6 +159,9 @@ void GpgFrontend::UI::GeneralDialog::update_rect_cache() {
// update size of current dialog
rect_ = this->geometry();
+ auto *screen = this->window()->screen();
+ screen_rect_ = screen->availableGeometry();
+
// read pos and size from parent
if (this->parent() != nullptr) {
QRect parent_rect;
diff --git a/src/ui/dialog/GeneralDialog.h b/src/ui/dialog/GeneralDialog.h
index 1e265a8e..dc42fb6b 100644
--- a/src/ui/dialog/GeneralDialog.h
+++ b/src/ui/dialog/GeneralDialog.h
@@ -89,6 +89,7 @@ class GeneralDialog : public QDialog {
std::string name_; ///<
QRect rect_;
QRect parent_rect_;
+ QRect screen_rect_;
bool rect_restored_ = false;
};
} // namespace GpgFrontend::UI