From cbdbe2882be07ba8e3b49e6c9b627604a5b54c40 Mon Sep 17 00:00:00 2001 From: James Turner Date: Wed, 19 Apr 2017 13:31:45 +0100 Subject: [PATCH] Fix disabled appearance of toolbox buttons. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Ensures ‘fly’ button appears disabled as appropriate in the launcher. --- src/GUI/ToolboxButton.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/GUI/ToolboxButton.cpp b/src/GUI/ToolboxButton.cpp index fe6d8706d..cbe20da93 100644 --- a/src/GUI/ToolboxButton.cpp +++ b/src/GUI/ToolboxButton.cpp @@ -2,6 +2,7 @@ #include #include +#include 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());