Fix disabled appearance of toolbox buttons.
Ensures ‘fly’ button appears disabled as appropriate in the launcher.
This commit is contained in:
parent
a05860608b
commit
cbdbe2882b
1 changed files with 8 additions and 2 deletions
|
@ -2,6 +2,7 @@
|
|||
|
||||
#include <QPainter>
|
||||
#include <QFontMetrics>
|
||||
#include <QPalette>
|
||||
|
||||
const int ICON_SIZE = 50;
|
||||
const int INDICATOR_WIDTH = 4;
|
||||
|
@ -26,9 +27,14 @@ void ToolboxButton::paintEvent(QPaintEvent *event)
|
|||
const int iconLeft = (width() - ICON_SIZE) / 2;
|
||||
QRect iconRect(iconLeft, PADDING, ICON_SIZE, ICON_SIZE);
|
||||
|
||||
icon().paint(&painter, iconRect);
|
||||
// QIcon can paint itself disabled, but it's hard to synchronize the
|
||||
// text appearance with that
|
||||
icon().paint(&painter, iconRect, Qt::AlignCenter,
|
||||
isEnabled() ? QIcon::Normal : QIcon::Disabled);
|
||||
|
||||
painter.setPen(Qt::white);
|
||||
// white with 50% opacity is what Mac style uses
|
||||
const QColor iconColor = isEnabled() ? Qt::white : QColor(255, 255, 255, 128);
|
||||
painter.setPen(iconColor);
|
||||
QRect textRect = rect();
|
||||
textRect.setTop(iconRect.bottom());
|
||||
painter.drawText(textRect, Qt::AlignHCenter, text());
|
||||
|
|
Loading…
Reference in a new issue