Skip to content

Commit

Permalink
Use 'const' and QStringLiteral where possible
Browse files Browse the repository at this point in the history
Co-authored-by: ronso0 <ronso0@mixxx.org>
  • Loading branch information
cr7pt0gr4ph7 and ronso0 authored Nov 2, 2024
1 parent 335c4cb commit 7266f4d
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 8 deletions.
12 changes: 5 additions & 7 deletions src/widget/wbasicpushbutton.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,16 +71,14 @@ void WBasicPushButton::paintEvent(QPaintEvent* /*unused*/) {
QString WBasicPushButton::buildToolTip() const {
// Show the button label as a tooltip when the label text
// is partially hidden due to the button's size

QString txtToolTip = toolTip();

const QString txtToolTip = toolTip();
if (!txtToolTip.isEmpty()) {
return txtToolTip;
}

QString txtLabel = text();
QSize currentSize = size();
QSize fullSize = sizeHint();
const QString txtLabel = text();
const QSize currentSize = size();
const QSize fullSize = sizeHint();

if ((currentSize.height() < fullSize.height() ||
currentSize.width() < fullSize.width()) &&
Expand All @@ -96,7 +94,7 @@ QString WBasicPushButton::buildToolTip() const {
bool WBasicPushButton::event(QEvent* e) {
switch (e->type()) {
case QEvent::ToolTip: {
QString toolTipToShow = buildToolTip();
const QString toolTipToShow = buildToolTip();
if (!toolTipToShow.isEmpty()) {
QToolTip::showText(static_cast<QHelpEvent*>(e)->globalPos(),
toolTipToShow,
Expand Down
2 changes: 1 addition & 1 deletion src/widget/wcolorpicker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ WColorGridButton::WColorGridButton(const mixxx::RgbColor::optional_t& color,
// Set the background color of the button.
// This can't be overridden in skin stylesheets.
setStyleSheet(
QString("QPushButton { background-color: %1; }")
QStringLiteral("QPushButton { background-color: %1; }")
.arg(mixxx::RgbColor::toQString(color.value())));
setToolTip(mixxx::RgbColor::toQString(color.value()));
} else {
Expand Down

0 comments on commit 7266f4d

Please sign in to comment.