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
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
21 changes: 20 additions & 1 deletion src/widgets/Label.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions src/widgets/Label.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -43,6 +46,7 @@ class Label : public BaseWidget
QSize preferedSize_;
bool centered_ = false;
bool hasOffset_ = true;
bool wordWrap_ = false;

pajlada::Signals::SignalHolder connections_;
};
Expand Down
27 changes: 14 additions & 13 deletions src/widgets/dialogs/UpdateDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -52,18 +53,18 @@ void UpdateDialog::updateStatusChanged(Updates::Status status)
switch (status)
{
case Updates::UpdateAvailable: {
this->ui_.label->setText((
getApp()->getUpdates().isDowngrade()
? QString(
"The version online (%1) seems to be\nlower than the "
"current (%2).\nEither a version was reverted or "
"you are\nrunning a newer build.\n\nDo you want to "
"download and install it?")
.arg(getApp()->getUpdates().getOnlineVersion(),
getApp()->getUpdates().getCurrentVersion())
: QString("An update (%1) is available.\n\nDo you want to "
"download and install it?")
.arg(getApp()->getUpdates().getOnlineVersion())));
this->ui_.label->setText(
(getApp()->getUpdates().isDowngrade()
? QString(
"The version online (%1) seems to be lower than the "
"current (%2).\nEither a version was reverted or "
"you are running a newer build.\n\nDo you want to "
"download and install it?")
.arg(getApp()->getUpdates().getOnlineVersion(),
getApp()->getUpdates().getCurrentVersion())
: QString("An update (%1) is available.\n\nDo you want to "
"download and install it?")
.arg(getApp()->getUpdates().getOnlineVersion())));
this->updateGeometry();
}
break;
Expand Down
Loading