Commit 5e89fae1 authored by Alessandro Portale's avatar Alessandro Portale

Unify the dimensions for all mode/action bar icons

Having icons of all different kinds of sizes makes it difficult to get
the painting right in all cases. It definitely fails when the szsytem is
running in multi-monitor mode with different scaling factors. Unifying
the dimensions makes it possible.

This change should not cause any visual difference in a purely scaled or
unscaled screen.

Task-number: QTCREATORBUG-18869
Change-Id: I3a864c9a86036b4f4f3b350a489077b247ca85b7
Reviewed-by: Thomas Hartmann's avatarThomas Hartmann <thomas.hartmann@qt.io>
parent be376ae7
......@@ -34,6 +34,7 @@
#include <QFileInfo>
#include <QCommonStyle>
#include <QStyleOption>
#include <QWindow>
#include <qmath.h>
// Clamps float color values within (0, 255)
......@@ -397,7 +398,9 @@ void StyleHelper::drawIconWithShadow(const QIcon &icon, const QRect &rect,
QPainter *p, QIcon::Mode iconMode, int dipRadius, const QColor &color, const QPoint &dipOffset)
{
QPixmap cache;
QString pixmapName = QString::fromLatin1("icon %0 %1 %2").arg(icon.cacheKey()).arg(iconMode).arg(rect.height());
const int devicePixelRatio = p->device()->devicePixelRatio();
QString pixmapName = QString::fromLatin1("icon %0 %1 %2 %3")
.arg(icon.cacheKey()).arg(iconMode).arg(rect.height()).arg(devicePixelRatio);
if (!QPixmapCache::find(pixmapName, cache)) {
// High-dpi support: The in parameters (rect, radius, offset) are in
......@@ -405,9 +408,8 @@ void StyleHelper::drawIconWithShadow(const QIcon &icon, const QRect &rect,
// return a high-dpi pixmap, which will in that case have a devicePixelRatio
// different than 1. The shadow drawing caluculations are done in device
// pixels.
QWindow *window = QApplication::allWidgets().first()->windowHandle();
QWindow *window = dynamic_cast<QWidget*>(p->device())->window()->windowHandle();
QPixmap px = icon.pixmap(window, rect.size(), iconMode);
int devicePixelRatio = qCeil(px.devicePixelRatio());
int radius = dipRadius * devicePixelRatio;
QPoint offset = dipOffset * devicePixelRatio;
cache = QPixmap(px.size() + QSize(radius * 2, radius * 2));
......@@ -415,7 +417,8 @@ void StyleHelper::drawIconWithShadow(const QIcon &icon, const QRect &rect,
QPainter cachePainter(&cache);
if (iconMode == QIcon::Disabled) {
const bool hasDisabledState = icon.availableSizes(QIcon::Disabled).contains(px.size());
const bool hasDisabledState =
icon.availableSizes().count() == icon.availableSizes(QIcon::Disabled).count();
if (!hasDisabledState)
px = disabledSideBarIcon(icon.pixmap(window, rect.size()));
} else if (creatorTheme()->flag(Theme::ToolBarIconShadow)) {
......
src/plugins/android/images/androiddevice.png

211 Bytes | W: | H:

src/plugins/android/images/androiddevice.png

216 Bytes | W: | H:

src/plugins/android/images/androiddevice.png
src/plugins/android/images/androiddevice.png
src/plugins/android/images/androiddevice.png
src/plugins/android/images/androiddevice.png
  • 2-up
  • Swipe
  • Onion skin
......@@ -207,7 +207,7 @@ const char TR_CLEAR_MENU[] = QT_TRANSLATE_NOOP("Core", "Clear Menu");
const char DEFAULT_BUILD_DIRECTORY[] = "../%{JS: Util.asciify(\"build-%{CurrentProject:Name}-%{CurrentKit:FileSystemName}-%{CurrentBuild:Name}\")}";
const int TARGET_ICON_SIZE = 32;
const int MODEBAR_ICON_SIZE = 34;
const int DEFAULT_MAX_LINE_COUNT = 100000;
} // namespace Constants
......
......@@ -178,7 +178,7 @@ void FancyToolButton::paintEvent(QPaintEvent *event)
const QIcon::Mode iconMode = isEnabled() ? ((isDown() || isChecked()) ? QIcon::Active : QIcon::Normal)
: QIcon::Disabled;
QRect iconRect(0, 0, Constants::TARGET_ICON_SIZE, Constants::TARGET_ICON_SIZE);
QRect iconRect(0, 0, Constants::MODEBAR_ICON_SIZE, Constants::MODEBAR_ICON_SIZE);
// draw popup texts
if (isTitledAction) {
......@@ -203,7 +203,7 @@ void FancyToolButton::paintEvent(QPaintEvent *event)
painter.setFont(normalFont);
QPoint textOffset = centerRect.center() - QPoint(iconRect.width()/2, iconRect.height()/2);
textOffset = textOffset - QPoint(0, lineHeight + 4);
textOffset = textOffset - QPoint(0, lineHeight + 3);
QRectF r(0, textOffset.y(), rect().width(), lineHeight);
painter.setPen(creatorTheme()->color(isEnabled()
? Theme::PanelTextColorLight
......@@ -218,8 +218,8 @@ void FancyToolButton::paintEvent(QPaintEvent *event)
// draw build configuration name
textOffset = iconRect.center() + QPoint(iconRect.width()/2, iconRect.height()/2);
QRectF buildConfigRect[2];
buildConfigRect[0] = QRectF(0, textOffset.y() + 5, rect().width(), lineHeight);
buildConfigRect[1] = QRectF(0, textOffset.y() + 5 + lineHeight, rect().width(), lineHeight);
buildConfigRect[0] = QRectF(0, textOffset.y() + 4, rect().width(), lineHeight);
buildConfigRect[1] = QRectF(0, textOffset.y() + 4 + lineHeight, rect().width(), lineHeight);
painter.setFont(boldFont);
QVector<QString> splitBuildConfiguration(2);
const QString buildConfiguration = defaultAction()->property("subtitle").toString();
......
......@@ -25,6 +25,7 @@
#include "fancytabwidget.h"
#include "fancyactionbar.h"
#include "coreconstants.h"
#include <utils/hostosinfo.h>
#include <utils/stylehelper.h>
......@@ -324,7 +325,10 @@ void FancyTabBar::paintTab(QPainter *painter, int tabIndex) const
tabIconRect.adjust(0, 4, 0, -textHeight);
const QIcon::Mode iconMode = enabled ? (selected ? QIcon::Active : QIcon::Normal)
: QIcon::Disabled;
StyleHelper::drawIconWithShadow(tab->icon, tabIconRect, painter, iconMode);
QRect iconRect(0, 0, Core::Constants::MODEBAR_ICON_SIZE, Core::Constants::MODEBAR_ICON_SIZE);
iconRect.moveCenter(tabIconRect.center());
iconRect = iconRect.intersected(tabIconRect);
StyleHelper::drawIconWithShadow(tab->icon, iconRect, painter, iconMode);
}
painter->setOpacity(1.0); //FIXME: was 0.7 before?
......
src/plugins/coreplugin/images/mode_Edit.png

426 Bytes | W: | H:

src/plugins/coreplugin/images/mode_Edit.png

389 Bytes | W: | H:

src/plugins/coreplugin/images/mode_Edit.png
src/plugins/coreplugin/images/mode_Edit.png
src/plugins/coreplugin/images/mode_Edit.png
src/plugins/coreplugin/images/mode_Edit.png
  • 2-up
  • Swipe
  • Onion skin
src/plugins/help/images/mode_help.png

1.41 KB | W: | H:

src/plugins/help/images/mode_help.png

1.3 KB | W: | H:

src/plugins/help/images/mode_help.png
src/plugins/help/images/mode_help.png
src/plugins/help/images/mode_help.png
src/plugins/help/images/mode_help.png
  • 2-up
  • Swipe
  • Onion skin
src/plugins/help/images/mode_help_mask.png

316 Bytes | W: | H:

src/plugins/help/images/mode_help_mask.png

312 Bytes | W: | H:

src/plugins/help/images/mode_help_mask.png
src/plugins/help/images/mode_help_mask.png
src/plugins/help/images/mode_help_mask.png
src/plugins/help/images/mode_help_mask.png
  • 2-up
  • Swipe
  • Onion skin
src/plugins/help/images/mode_help_mask@2x.png

629 Bytes | W: | H:

src/plugins/help/images/mode_help_mask@2x.png

614 Bytes | W: | H:

src/plugins/help/images/mode_help_mask@2x.png
src/plugins/help/images/mode_help_mask@2x.png
src/plugins/help/images/mode_help_mask@2x.png
src/plugins/help/images/mode_help_mask@2x.png
  • 2-up
  • Swipe
  • Onion skin
src/plugins/ios/images/iosdevice.png

196 Bytes | W: | H:

src/plugins/ios/images/iosdevice.png

196 Bytes | W: | H:

src/plugins/ios/images/iosdevice.png
src/plugins/ios/images/iosdevice.png
src/plugins/ios/images/iosdevice.png
src/plugins/ios/images/iosdevice.png
  • 2-up
  • Swipe
  • Onion skin
src/plugins/ios/images/iosdevice@2x.png

349 Bytes | W: | H:

src/plugins/ios/images/iosdevice@2x.png

351 Bytes | W: | H:

src/plugins/ios/images/iosdevice@2x.png
src/plugins/ios/images/iosdevice@2x.png
src/plugins/ios/images/iosdevice@2x.png
src/plugins/ios/images/iosdevice@2x.png
  • 2-up
  • Swipe
  • Onion skin
......@@ -65,21 +65,21 @@ static QIcon createCenteredIcon(const QIcon &icon, const QIcon &overlay)
{
QPixmap targetPixmap;
const qreal appDevicePixelRatio = qApp->devicePixelRatio();
int deviceSpaceIconSize = Core::Constants::TARGET_ICON_SIZE * appDevicePixelRatio;
targetPixmap = QPixmap(deviceSpaceIconSize, deviceSpaceIconSize);
targetPixmap = QPixmap(Core::Constants::MODEBAR_ICON_SIZE * appDevicePixelRatio,
Core::Constants::MODEBAR_ICON_SIZE * appDevicePixelRatio);
targetPixmap.setDevicePixelRatio(appDevicePixelRatio);
targetPixmap.fill(Qt::transparent);
QPainter painter(&targetPixmap); // painter in user space
QPixmap pixmap = icon.pixmap(Core::Constants::TARGET_ICON_SIZE); // already takes app devicePixelRatio into account
QPixmap pixmap = icon.pixmap(Core::Constants::MODEBAR_ICON_SIZE); // already takes app devicePixelRatio into account
qreal pixmapDevicePixelRatio = pixmap.devicePixelRatio();
painter.drawPixmap((Core::Constants::TARGET_ICON_SIZE - pixmap.width() / pixmapDevicePixelRatio) / 2,
(Core::Constants::TARGET_ICON_SIZE - pixmap.height() / pixmapDevicePixelRatio) / 2, pixmap);
painter.drawPixmap((Core::Constants::MODEBAR_ICON_SIZE - pixmap.width() / pixmapDevicePixelRatio) / 2,
(Core::Constants::MODEBAR_ICON_SIZE - pixmap.height() / pixmapDevicePixelRatio) / 2, pixmap);
if (!overlay.isNull()) {
pixmap = overlay.pixmap(Core::Constants::TARGET_ICON_SIZE); // already takes app devicePixelRatio into account
pixmap = overlay.pixmap(Core::Constants::MODEBAR_ICON_SIZE); // already takes app devicePixelRatio into account
pixmapDevicePixelRatio = pixmap.devicePixelRatio();
painter.drawPixmap((Core::Constants::TARGET_ICON_SIZE - pixmap.width() / pixmapDevicePixelRatio) / 2,
(Core::Constants::TARGET_ICON_SIZE - pixmap.height() / pixmapDevicePixelRatio) / 2, pixmap);
painter.drawPixmap((Core::Constants::MODEBAR_ICON_SIZE - pixmap.width() / pixmapDevicePixelRatio) / 2,
(Core::Constants::MODEBAR_ICON_SIZE - pixmap.height() / pixmapDevicePixelRatio) / 2, pixmap);
}
return QIcon(targetPixmap);
......
src/plugins/winrt/images/winrtdevice.png

163 Bytes | W: | H:

src/plugins/winrt/images/winrtdevice.png

164 Bytes | W: | H:

src/plugins/winrt/images/winrtdevice.png
src/plugins/winrt/images/winrtdevice.png
src/plugins/winrt/images/winrtdevice.png
src/plugins/winrt/images/winrtdevice.png
  • 2-up
  • Swipe
  • Onion skin
src/plugins/winrt/images/winrtdevice@2x.png

235 Bytes | W: | H:

src/plugins/winrt/images/winrtdevice@2x.png

239 Bytes | W: | H:

src/plugins/winrt/images/winrtdevice@2x.png
src/plugins/winrt/images/winrtdevice@2x.png
src/plugins/winrt/images/winrtdevice@2x.png
src/plugins/winrt/images/winrtdevice@2x.png
  • 2-up
  • Swipe
  • Onion skin
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment