From b7650d343e2ae685dc06a62a32c89e303742901a Mon Sep 17 00:00:00 2001 From: Jens Bache-Wiig <jbache@trolltech.com> Date: Wed, 24 Feb 2010 19:54:35 +0100 Subject: [PATCH] Fix an icon centering problem on the actionbar The actualPixmapSize is different from the resulting pixmap when using svg icons. This seems to be a bug in Qt, but using the resulting pixmap is safe for now. --- src/plugins/coreplugin/fancyactionbar.cpp | 5 ++--- .../projectexplorer/miniprojecttargetselector.cpp | 14 ++++++-------- 2 files changed, 8 insertions(+), 11 deletions(-) diff --git a/src/plugins/coreplugin/fancyactionbar.cpp b/src/plugins/coreplugin/fancyactionbar.cpp index 00822110aff..66f8a819b63 100644 --- a/src/plugins/coreplugin/fancyactionbar.cpp +++ b/src/plugins/coreplugin/fancyactionbar.cpp @@ -105,7 +105,7 @@ void FancyToolButton::paintEvent(QPaintEvent *event) painter.drawLine(rect().bottomLeft(), rect().bottomRight()); painter.restore(); } else -#endif +#endif if (isDown() || isChecked()) { painter.save(); QLinearGradient grad(rect().topLeft(), rect().topRight()); @@ -130,7 +130,6 @@ void FancyToolButton::paintEvent(QPaintEvent *event) QSizeF halfPixSize = pix.size()/2.0; painter.drawPixmap(center-QPointF(halfPixSize.width()-1, halfPixSize.height()-1), pix); - // draw popup texts if (isTitledAction) { QFont normalFont(painter.font()); @@ -155,7 +154,7 @@ void FancyToolButton::paintEvent(QPaintEvent *event) penColor = Qt::gray; painter.setPen(penColor); const QString projectName = defaultAction()->property("heading").toString(); - QString ellidedProjectName = fm.elidedText(projectName, Qt::ElideMiddle, r.width()); + QString ellidedProjectName = fm.elidedText(projectName, Qt::ElideMiddle, r.width() - 6); if (isEnabled()) { const QRectF shadowR = r.translated(0, 1); painter.setPen(QColor(30, 30, 30, 80)); diff --git a/src/plugins/projectexplorer/miniprojecttargetselector.cpp b/src/plugins/projectexplorer/miniprojecttargetselector.cpp index f13831d0b65..c0e4f9537a8 100644 --- a/src/plugins/projectexplorer/miniprojecttargetselector.cpp +++ b/src/plugins/projectexplorer/miniprojecttargetselector.cpp @@ -63,15 +63,13 @@ static QIcon createCenteredIcon(const QIcon &icon, const QIcon &overlay) targetPixmap.fill(Qt::transparent); QPainter painter(&targetPixmap); - QSize actualSize = icon.actualSize(QSize(Core::Constants::TARGET_ICON_SIZE, Core::Constants::TARGET_ICON_SIZE)); - painter.drawPixmap((Core::Constants::TARGET_ICON_SIZE - actualSize.width())/2, - (Core::Constants::TARGET_ICON_SIZE - actualSize.height())/2, - icon.pixmap(Core::Constants::TARGET_ICON_SIZE)); + QPixmap pixmap = icon.pixmap(Core::Constants::TARGET_ICON_SIZE); + painter.drawPixmap((Core::Constants::TARGET_ICON_SIZE - pixmap.width())/2, + (Core::Constants::TARGET_ICON_SIZE - pixmap.height())/2, pixmap); if (!overlay.isNull()) { - actualSize = overlay.actualSize(QSize(Core::Constants::TARGET_ICON_SIZE, Core::Constants::TARGET_ICON_SIZE)); - painter.drawPixmap((Core::Constants::TARGET_ICON_SIZE - actualSize.width())/2, - (Core::Constants::TARGET_ICON_SIZE - actualSize.height())/2, - overlay.pixmap(Core::Constants::TARGET_ICON_SIZE)); + pixmap = overlay.pixmap(Core::Constants::TARGET_ICON_SIZE); + painter.drawPixmap((Core::Constants::TARGET_ICON_SIZE - pixmap.width())/2, + (Core::Constants::TARGET_ICON_SIZE - pixmap.height())/2, pixmap); } return QIcon(targetPixmap); } -- GitLab