summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorAdasauce <adasauce@with.parts>2020-02-20 11:50:56 -0400
committerAdasauce <adasauce@with.parts>2020-02-20 11:50:56 -0400
commitf86cbbe16a36c097a609e0bd1020136e6708eb32 (patch)
tree5f0fbb1497fb588e3256c1530d6375b23c6d549a /src
parentFormLayout cleanup (diff)
downloadnheko-f86cbbe16a36c097a609e0bd1020136e6708eb32.tar.xz
Add constexpr for the minimum formlayout width
to save on recalculation of the size and having to subtract the margins
to do the tally, then re-apply.
Diffstat (limited to 'src')
-rw-r--r--src/UserSettingsPage.cpp11
-rw-r--r--src/UserSettingsPage.h5
2 files changed, 9 insertions, 7 deletions
diff --git a/src/UserSettingsPage.cpp b/src/UserSettingsPage.cpp

index ace8bab9..4e134888 100644 --- a/src/UserSettingsPage.cpp +++ b/src/UserSettingsPage.cpp
@@ -437,15 +437,12 @@ UserSettingsPage::resizeEvent(QResizeEvent *event) { auto preWidth_ = width(); - formLayout_->setContentsMargins(0, LayoutTopMargin, 0, LayoutBottomMargin); - double contentMinWidth = formLayout_->minimumSize().width(); - - if (preWidth_ * 0.6 > contentMinWidth) - sideMargin_ = preWidth_ * 0.2; + if (preWidth_ * 0.5 > LayoutMinWidth) + sideMargin_ = preWidth_ * 0.25; else - sideMargin_ = static_cast<double>(preWidth_ - contentMinWidth) / 2.; + sideMargin_ = static_cast<double>(preWidth_ - LayoutMinWidth) / 2.; - if (sideMargin_ < 40) + if (sideMargin_ < 60) sideMargin_ = 0; formLayout_->setContentsMargins( diff --git a/src/UserSettingsPage.h b/src/UserSettingsPage.h
index ef8258b6..2b588412 100644 --- a/src/UserSettingsPage.h +++ b/src/UserSettingsPage.h
@@ -33,6 +33,11 @@ constexpr int OptionMargin = 6; constexpr int LayoutTopMargin = 50; constexpr int LayoutBottomMargin = LayoutTopMargin; +// based on the width of the widest item currently in the layout (deviceFingerprintValue_) +// used for recalculating the margins of the formLayout_ on resize to help with small screens and +// mobile devices. +constexpr int LayoutMinWidth = 385; + class UserSettings : public QObject { Q_OBJECT