mirror of
https://github.com/Nheko-Reborn/nheko.git
synced 2024-11-25 20:48:52 +03:00
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.
This commit is contained in:
parent
b5aa615ef5
commit
f86cbbe16a
2 changed files with 9 additions and 7 deletions
|
@ -437,15 +437,12 @@ UserSettingsPage::resizeEvent(QResizeEvent *event)
|
||||||
{
|
{
|
||||||
auto preWidth_ = width();
|
auto preWidth_ = width();
|
||||||
|
|
||||||
formLayout_->setContentsMargins(0, LayoutTopMargin, 0, LayoutBottomMargin);
|
if (preWidth_ * 0.5 > LayoutMinWidth)
|
||||||
double contentMinWidth = formLayout_->minimumSize().width();
|
sideMargin_ = preWidth_ * 0.25;
|
||||||
|
|
||||||
if (preWidth_ * 0.6 > contentMinWidth)
|
|
||||||
sideMargin_ = preWidth_ * 0.2;
|
|
||||||
else
|
else
|
||||||
sideMargin_ = static_cast<double>(preWidth_ - contentMinWidth) / 2.;
|
sideMargin_ = static_cast<double>(preWidth_ - LayoutMinWidth) / 2.;
|
||||||
|
|
||||||
if (sideMargin_ < 40)
|
if (sideMargin_ < 60)
|
||||||
sideMargin_ = 0;
|
sideMargin_ = 0;
|
||||||
|
|
||||||
formLayout_->setContentsMargins(
|
formLayout_->setContentsMargins(
|
||||||
|
|
|
@ -33,6 +33,11 @@ constexpr int OptionMargin = 6;
|
||||||
constexpr int LayoutTopMargin = 50;
|
constexpr int LayoutTopMargin = 50;
|
||||||
constexpr int LayoutBottomMargin = LayoutTopMargin;
|
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
|
class UserSettings : public QObject
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
Loading…
Reference in a new issue