summary refs log tree commit diff
path: root/src/UserSettingsPage.cpp
diff options
context:
space:
mode:
authorNicolas Werner <nicolas.werner@hotmail.de>2020-02-15 03:37:54 +0100
committerNicolas Werner <nicolas.werner@hotmail.de>2020-02-15 03:48:23 +0100
commitef5edbb3ea4e44e4f5d235345b800b5b1382c568 (patch)
tree19d1ffa69caf3c164bc058238b887f62b867a466 /src/UserSettingsPage.cpp
parentMerge pull request #117 from adasauce/file-download-path (diff)
downloadnheko-ef5edbb3ea4e44e4f5d235345b800b5b1382c568.tar.xz
Lower general settings margins, if the window is narrow
Diffstat (limited to '')
-rw-r--r--src/UserSettingsPage.cpp13
1 files changed, 12 insertions, 1 deletions
diff --git a/src/UserSettingsPage.cpp b/src/UserSettingsPage.cpp
index bcd50d80..da8f2f56 100644
--- a/src/UserSettingsPage.cpp
+++ b/src/UserSettingsPage.cpp
@@ -25,6 +25,7 @@
 #include <QPainter>
 #include <QProcessEnvironment>
 #include <QPushButton>
+#include <QResizeEvent>
 #include <QScrollArea>
 #include <QSettings>
 #include <QStandardPaths>
@@ -495,7 +496,17 @@ UserSettingsPage::showEvent(QShowEvent *)
 void
 UserSettingsPage::resizeEvent(QResizeEvent *event)
 {
-        sideMargin_ = width() * 0.2;
+        mainLayout_->setContentsMargins(0, LayoutTopMargin, 0, LayoutBottomMargin);
+        double contentMinWidth = mainLayout_->minimumSize().width();
+
+        if (event->size().width() * 0.6 > contentMinWidth)
+                sideMargin_ = width() * 0.2;
+        else
+                sideMargin_ = static_cast<double>(event->size().width() - contentMinWidth) / 2.;
+
+        if (sideMargin_ < 40)
+                sideMargin_ = 0;
+
         mainLayout_->setContentsMargins(
           sideMargin_, LayoutTopMargin, sideMargin_, LayoutBottomMargin);