Skip to content

Commit

Permalink
Replace custom "enabled" flag with the QWidget property
Browse files Browse the repository at this point in the history
Simplifies the implementation.

See #940.
  • Loading branch information
lmoureaux authored and jwrober committed Mar 27, 2022
1 parent 2197616 commit 35092ca
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 21 deletions.
24 changes: 4 additions & 20 deletions client/gui-qt/top_bar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,9 @@ void reduce_mod(int &mod, int &val)
top_bar_widget::top_bar_widget(QPixmap *pix, const QString &label,
const QString &pg, pfcn_bool func,
standards type)
: QToolButton(), blink(false), keep_blinking(false), disabled(false),
standard(type), page(pg), hover(false), right_click(nullptr),
wheel_down(nullptr), wheel_up(nullptr), left_click(func),
def_pixmap(pix), desc(label)
: QToolButton(), blink(false), keep_blinking(false), standard(type),
page(pg), hover(false), right_click(nullptr), wheel_down(nullptr),
wheel_up(nullptr), left_click(func), def_pixmap(pix), desc(label)
{
if (def_pixmap == nullptr) {
def_pixmap = new QPixmap(5, 5);
Expand Down Expand Up @@ -228,20 +227,6 @@ void top_bar_widget::paintEvent(QPaintEvent *event)
p.drawRect(highlight_rect);
}

if (hover && !disabled) {
p.setCompositionMode(QPainter::CompositionMode_ColorDodge);
p.setPen(QPen(palette().color(QPalette::Highlight), 0));
p.setBrush(palette().color(QPalette::AlternateBase));
p.drawRect(highlight_rect);
}

if (disabled) {
p.setCompositionMode(QPainter::CompositionMode_Darken);
p.setPen(QPen(Qt::black, 0));
p.setBrush(QColor(0, 0, 50, 95));
p.drawRect(highlight_rect);
}

if (blink) {
p.setCompositionMode(QPainter::CompositionMode_ColorDodge);
p.setPen(QPen(Qt::black, 0));
Expand Down Expand Up @@ -494,8 +479,7 @@ void top_bar_disable_end_turn(bool do_restore)
if (king()->current_page() != PAGE_GAME) {
return;
}
queen()->sw_endturn->disabled = !do_restore;
queen()->sw_endturn->update();
queen()->sw_endturn->setEnabled(do_restore);
}

/**
Expand Down
1 change: 0 additions & 1 deletion client/gui-qt/top_bar.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ class top_bar_widget : public QToolButton {

bool blink;
bool keep_blinking;
bool disabled;
standards standard;
QString page;
public slots:
Expand Down

0 comments on commit 35092ca

Please sign in to comment.