Skip to content
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 5 commits into from
Jan 12, 2025

Conversation

8thony
Copy link
Contributor

@8thony 8thony commented Jan 11, 2025

Fixes #5797

Copy link
Contributor

@Nerixyz Nerixyz left a 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.

@8thony
Copy link
Contributor Author

8thony commented Jan 11, 2025

I can't get this working with your recommendation @Nerixyz .
The window width is locked to a fix size anyway. (8e87886)

@Nerixyz
Copy link
Contributor

Nerixyz commented Jan 11, 2025

I can't get this working with your recommendation @Nerixyz . The window width is locked to a fix size anyway. (8e87886)

Sorry, I didn't see that we use our custom label.

Diff
diff --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 pajlada merged commit ae964be into Chatterino:master Jan 12, 2025
18 checks passed
@8thony 8thony deleted the dl-missing-word-wrap branch January 12, 2025 10:35
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Missing word wrap in "Downloading updates" popup
3 participants