Skip to content

Commit

Permalink
Make the blink effect work with QToolButton
Browse files Browse the repository at this point in the history
It's not perfect but we're not after perfection. It works.

See longturn#940.
  • Loading branch information
lmoureaux committed Mar 20, 2022
1 parent 4077ff9 commit 4581e63
Showing 1 changed file with 6 additions and 10 deletions.
16 changes: 6 additions & 10 deletions client/gui-qt/top_bar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -172,22 +172,18 @@ void top_bar_widget::paintEvent(QPaintEvent *event)
const auto highlight_rect =
QRectF(0.5, 0, width() - 1. / devicePixelRatio(),
height() - 1. / devicePixelRatio());
p.end();

if (current) {
p.setPen(QPen(palette().color(QPalette::Highlight), 0));
p.drawRect(highlight_rect);
}
QToolButton::paintEvent(event);

if (blink) {
p.setCompositionMode(QPainter::CompositionMode_ColorDodge);
p.setPen(QPen(Qt::black, 0));
p.begin(this);
p.setPen(Qt::NoPen);
p.setCompositionMode(QPainter::CompositionMode_SoftLight);
p.setBrush(palette().color(QPalette::HighlightedText));
p.drawRect(highlight_rect);
p.end();
}

p.end();

QToolButton::paintEvent(event);
}

/**
Expand Down

0 comments on commit 4581e63

Please sign in to comment.