From 7c60b03c9bb91d177876467b6ad0b1dedf68000a Mon Sep 17 00:00:00 2001 From: John Preston Date: Tue, 1 Aug 2023 19:05:34 +0200 Subject: [PATCH] Resize centered labels wide by default. --- ui/widgets/labels.cpp | 6 +++++- ui/widgets/labels.h | 1 + 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/ui/widgets/labels.cpp b/ui/widgets/labels.cpp index 902b9c4..daf48c9 100644 --- a/ui/widgets/labels.cpp +++ b/ui/widgets/labels.cpp @@ -318,10 +318,14 @@ int FlatLabel::resizeGetHeight(int newWidth) { return countTextHeight(_textWidth); } -int FlatLabel::naturalWidth() const { +int FlatLabel::textMaxWidth() const { return _text.maxWidth(); } +int FlatLabel::naturalWidth() const { + return (_st.align == style::al_top) ? -1 : textMaxWidth(); +} + QMargins FlatLabel::getMargins() const { return _st.margin; } diff --git a/ui/widgets/labels.h b/ui/widgets/labels.h index fe0bf3c..46552d4 100644 --- a/ui/widgets/labels.h +++ b/ui/widgets/labels.h @@ -139,6 +139,7 @@ public: _animationsPausedCallback = std::move(callback); } + [[nodiscard]] int textMaxWidth() const; int naturalWidth() const override; QMargins getMargins() const override;