Skip to content

Commit

Permalink
Remove custom text processing in top_bar_widget
Browse files Browse the repository at this point in the history
Simplifies the code.

See longturn#940.
  • Loading branch information
lmoureaux committed Mar 25, 2022
1 parent 16ae104 commit da19d19
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 20 deletions.
17 changes: 1 addition & 16 deletions client/gui-qt/top_bar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ top_bar_widget::top_bar_widget(const QString &label, const QString &pg,
pfcn_bool func, standards type)
: QToolButton(), blink(false), keep_blinking(false), standard(type),
page(pg), hover(false), right_click(nullptr), wheel_down(nullptr),
wheel_up(nullptr), left_click(func), desc(label)
wheel_up(nullptr), left_click(func)
{
setText(label);
setToolButtonStyle(Qt::ToolButtonTextBesideIcon);
Expand Down Expand Up @@ -95,11 +95,6 @@ void top_bar_widget::setTooltip(const QString &tooltip)
setToolTip(tooltip);
}

/**
Sets default label on bottom of sidewidget
*/
void top_bar_widget::setLabel(const QString &str) { desc = str; }

/**
Paint event for sidewidget
*/
Expand All @@ -116,12 +111,9 @@ void top_bar_widget::paintEvent(QPaintEvent *event)
}

p.begin(this);
p.setFont(sfont);
pen.setColor(QColor(232, 255, 0));
p.setPen(pen);

const auto rect = QRectF(0, 0, width(), height());

if (standard == SW_TAX && !client_is_global_observer()) {
pos = 0;
int d, modulo;
Expand Down Expand Up @@ -176,13 +168,6 @@ void top_bar_widget::paintEvent(QPaintEvent *event)
p.drawPixmap(pos, 5, *sprite);
}

p.setPen(palette().color(QPalette::Text));
if (!custom_label.isEmpty()) {
p.setFont(info_font);
p.drawText(rect, Qt::AlignLeft | Qt::AlignBottom | Qt::TextWordWrap,
custom_label);
}

// Remove 1px for the border on the right and at the bottom
const auto highlight_rect =
QRectF(0.5, 0, width() - 1. / devicePixelRatio(),
Expand Down
4 changes: 0 additions & 4 deletions client/gui-qt/top_bar.h
Original file line number Diff line number Diff line change
Expand Up @@ -75,10 +75,6 @@ public slots:
pfcn wheel_down;
pfcn wheel_up;
pfcn_bool left_click;
QFont sfont;
QFont info_font;
QString custom_label;
QString desc;
QTimer *timer;
};

Expand Down

0 comments on commit da19d19

Please sign in to comment.