-
-
Notifications
You must be signed in to change notification settings - Fork 462
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
fix: missing word wrap in update popup #5811
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Nerixyz
suggested changes
Jan 11, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should probably do this->ui_.label->setWordWrap(true)
instead.
Sorry, I didn't see that we use our custom label. Diffdiff --git a/src/widgets/Label.cpp b/src/widgets/Label.cpp
index 6f56acb27..6fe1bcdad 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 285980641..f3a7c845d 100644
--- a/src/widgets/Label.hpp
+++ b/src/widgets/Label.hpp
@@ -27,6 +27,9 @@ public:
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 @@ private:
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 64ec27eec..13a7cad69 100644
--- a/src/widgets/dialogs/UpdateDialog.cpp
+++ b/src/widgets/dialogs/UpdateDialog.cpp
@@ -19,7 +19,8 @@ UpdateDialog::UpdateDialog()
LayoutCreator<UpdateDialog>(this).setLayoutType<QVBoxLayout>();
layout.emplace<Label>("You shouldn't be seeing this dialog.")
- .assign(&this->ui_.label);
+ .assign(&this->ui_.label)
+ ->setWordWrap(true);
auto buttons = layout.emplace<QDialogButtonBox>();
auto *install = buttons->addButton("Install", QDialogButtonBox::AcceptRole); |
pajlada
approved these changes
Jan 12, 2025
# for free
to join this conversation on GitHub.
Already have an account?
# to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes #5797