forked from qt-creator/qt-creator
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 <thomas.hartmann@qt.io>
This commit is contained in:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user