diff options
author | Jens Bache-Wiig <jbache@trolltech.com> | 2010-03-23 15:47:43 +0100 |
---|---|---|
committer | Jens Bache-Wiig <jbache@trolltech.com> | 2010-03-23 16:57:41 +0100 |
commit | 74928d0199b8c644e3a03b1eeb8b296c7175a345 (patch) | |
tree | e5f50d117b4097404f163f3aad15db48cd5eadd3 /src/plugins/coreplugin/fancyactionbar.cpp | |
parent | f5e0dc409dec27321d8e43199cc496dd064c21aa (diff) |
Make disabled icons sharper in sidebar
This overrides the styles default behavior for disabled
icons and simply generates their grayscale equivalent so
they look a bit crisper.
Diffstat (limited to 'src/plugins/coreplugin/fancyactionbar.cpp')
-rw-r--r-- | src/plugins/coreplugin/fancyactionbar.cpp | 26 |
1 files changed, 12 insertions, 14 deletions
diff --git a/src/plugins/coreplugin/fancyactionbar.cpp b/src/plugins/coreplugin/fancyactionbar.cpp index 57145d3d84..b15a67b01d 100644 --- a/src/plugins/coreplugin/fancyactionbar.cpp +++ b/src/plugins/coreplugin/fancyactionbar.cpp @@ -136,12 +136,12 @@ void FancyToolButton::paintEvent(QPaintEvent *event) QPixmap borderPixmap; QMargins margins; - QPixmap pix = icon().pixmap(Core::Constants::TARGET_ICON_SIZE, Core::Constants::TARGET_ICON_SIZE, isEnabled() ? QIcon::Normal : QIcon::Disabled); - QSizeF halfPixSize = pix.size()/2.0; + QRect iconRect(0, 0, Core::Constants::TARGET_ICON_SIZE, Core::Constants::TARGET_ICON_SIZE); // draw popup texts if (isTitledAction) { QFont normalFont(painter.font()); + QRect centerRect = rect(); normalFont.setPointSizeF(Utils::StyleHelper::sidebarFontSize()); QFont boldFont(normalFont); boldFont.setBold(true); @@ -150,22 +150,20 @@ void FancyToolButton::paintEvent(QPaintEvent *event) int lineHeight = boldFm.height(); int textFlags = Qt::AlignVCenter|Qt::AlignHCenter; - QRect iconRect = rect(); const QString projectName = defaultAction()->property("heading").toString(); if (!projectName.isNull()) - iconRect.adjust(0, lineHeight + 4, 0, 0); + centerRect.adjust(0, lineHeight + 4, 0, 0); const QString buildConfiguration = defaultAction()->property("subtitle").toString(); if (!buildConfiguration.isNull()) - iconRect.adjust(0, 0, 0, -lineHeight - 4); + centerRect.adjust(0, 0, 0, -lineHeight - 4); - - QPoint center = iconRect.center(); - Utils::StyleHelper::drawIconWithShadow(pix, center-QPoint(halfPixSize.width()-1, halfPixSize.height()-1), &painter); + iconRect.moveCenter(centerRect.center()); + Utils::StyleHelper::drawIconWithShadow(icon(), iconRect, &painter, isEnabled() ? QIcon::Normal : QIcon::Disabled); painter.setFont(normalFont); - QPoint textOffset = center - QPoint(pix.rect().width()/2, pix.rect().height()/2); - textOffset = textOffset - QPoint(0, lineHeight+5); + QPoint textOffset = centerRect.center() - QPoint(iconRect.width()/2, iconRect.height()/2); + textOffset = textOffset - QPoint(0, lineHeight + 4); QRectF r(0, textOffset.y(), rect().width(), lineHeight); QColor penColor; if (isEnabled()) @@ -182,7 +180,7 @@ void FancyToolButton::paintEvent(QPaintEvent *event) painter.setPen(penColor); } painter.drawText(r, textFlags, ellidedProjectName); - textOffset = center + QPoint(pix.rect().width()/2, pix.rect().height()/2); + textOffset = iconRect.center() + QPoint(iconRect.width()/2, iconRect.height()/2); r = QRectF(0, textOffset.y()+5, rect().width(), lineHeight); painter.setFont(boldFont); QString ellidedBuildConfiguration = boldFm.elidedText(buildConfiguration, Qt::ElideMiddle, r.width()); @@ -196,12 +194,12 @@ void FancyToolButton::paintEvent(QPaintEvent *event) painter.drawText(r, textFlags, ellidedBuildConfiguration); QStyleOption opt; opt.initFrom(this); - opt.rect = iconRect.adjusted(iconRect.width() - 16, 0, -8, 0); + opt.rect = rect().adjusted(rect().width() - 16, 0, -8, 0); Utils::StyleHelper::drawArrow(QStyle::PE_IndicatorArrowRight, &painter, &opt); } } else { - QPoint center = rect().center(); - Utils::StyleHelper::drawIconWithShadow(pix, center-QPoint(halfPixSize.width()-1, halfPixSize.height()-1), &painter); + iconRect.moveCenter(rect().center()); + Utils::StyleHelper::drawIconWithShadow(icon(), iconRect, &painter, isEnabled() ? QIcon::Normal : QIcon::Disabled); } } |