From 0e04b8bbef13a9d6bb2cd5230e94395174eb4919 Mon Sep 17 00:00:00 2001 From: 8thony <114905842+8thony@users.noreply.github.com> Date: Sat, 11 Jan 2025 22:52:22 +0100 Subject: [PATCH] fix: word wrap --- CHANGELOG.md | 1 + src/widgets/Label.cpp | 21 ++++++++++++++++++++- src/widgets/Label.hpp | 4 ++++ src/widgets/dialogs/UpdateDialog.cpp | 9 +++++---- 4 files changed, 30 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c7d98db827f..e0653234007 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,7 @@ - Minor: Remove incognito browser support for `opera/launcher` (this should no longer be a thing). (#5805) - Minor: Remove incognito browser support for `iexplore`, because internet explorer is EOL. (#5810) - Bugfix: Fixed a crash relating to Lua HTTP. (#5800) +- Bugfix: Fixed missing word wrap in update popup. (#5811) - Dev: Updated Conan dependencies. (#5776) ## 2.5.2 diff --git a/src/widgets/Label.cpp b/src/widgets/Label.cpp index 6f56acb2767..6fe1bcdadc9 100644 --- a/src/widgets/Label.cpp +++ b/src/widgets/Label.cpp @@ -64,6 +64,18 @@ void Label::setHasOffset(bool hasOffset) this->hasOffset_ = hasOffset; this->updateSize(); } + +bool Label::getWordWrap() const +{ + return this->wordWrap_; +} + +void Label::setWordWrap(bool wrap) +{ + this->wordWrap_ = wrap; + this->update(); +} + void Label::setFontStyle(FontStyle style) { this->fontStyle_ = style; @@ -107,7 +119,14 @@ void Label::paintEvent(QPaintEvent *) painter.setBrush(this->palette().windowText()); QTextOption option(alignment); - option.setWrapMode(QTextOption::NoWrap); + if (this->wordWrap_) + { + option.setWrapMode(QTextOption::WrapAtWordBoundaryOrAnywhere); + } + else + { + option.setWrapMode(QTextOption::NoWrap); + } painter.drawText(textRect, this->text_, option); #if 0 diff --git a/src/widgets/Label.hpp b/src/widgets/Label.hpp index 285980641bf..30a04d53505 100644 --- a/src/widgets/Label.hpp +++ b/src/widgets/Label.hpp @@ -27,6 +27,9 @@ class Label : public BaseWidget bool getHasOffset() const; void setHasOffset(bool hasOffset); + bool getWordWrap() const; + void setWordWrap(bool wrap); + protected: void scaleChangedEvent(float scale_) override; void paintEvent(QPaintEvent *) override; @@ -43,6 +46,7 @@ class Label : public BaseWidget QSize preferedSize_; bool centered_ = false; bool hasOffset_ = true; + bool wordWrap_ = false; pajlada::Signals::SignalHolder connections_; }; diff --git a/src/widgets/dialogs/UpdateDialog.cpp b/src/widgets/dialogs/UpdateDialog.cpp index 8d4faf79da4..64e0e881922 100644 --- a/src/widgets/dialogs/UpdateDialog.cpp +++ b/src/widgets/dialogs/UpdateDialog.cpp @@ -19,7 +19,8 @@ UpdateDialog::UpdateDialog() LayoutCreator(this).setLayoutType(); layout.emplace