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>
@@ -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)) {
|
||||
|
||||
|
Before Width: | Height: | Size: 211 B After Width: | Height: | Size: 216 B |
|
Before Width: | Height: | Size: 255 B After Width: | Height: | Size: 259 B |
|
Before Width: | Height: | Size: 184 B After Width: | Height: | Size: 185 B |
|
Before Width: | Height: | Size: 277 B After Width: | Height: | Size: 280 B |
@@ -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?
|
||||
|
||||
|
Before Width: | Height: | Size: 1.7 KiB After Width: | Height: | Size: 1.5 KiB |
|
Before Width: | Height: | Size: 6.1 KiB After Width: | Height: | Size: 5.0 KiB |
|
Before Width: | Height: | Size: 426 B After Width: | Height: | Size: 389 B |
|
Before Width: | Height: | Size: 3.1 KiB After Width: | Height: | Size: 1.1 KiB |
|
Before Width: | Height: | Size: 223 B After Width: | Height: | Size: 218 B |
|
Before Width: | Height: | Size: 369 B After Width: | Height: | Size: 362 B |
|
Before Width: | Height: | Size: 109 B After Width: | Height: | Size: 110 B |
|
Before Width: | Height: | Size: 118 B After Width: | Height: | Size: 117 B |
|
Before Width: | Height: | Size: 2.7 KiB After Width: | Height: | Size: 2.5 KiB |
|
Before Width: | Height: | Size: 2.2 KiB After Width: | Height: | Size: 2.2 KiB |
|
Before Width: | Height: | Size: 97 B After Width: | Height: | Size: 97 B |
|
Before Width: | Height: | Size: 99 B After Width: | Height: | Size: 101 B |
|
Before Width: | Height: | Size: 147 B After Width: | Height: | Size: 157 B |
|
Before Width: | Height: | Size: 192 B After Width: | Height: | Size: 202 B |
|
Before Width: | Height: | Size: 1.2 KiB After Width: | Height: | Size: 1.2 KiB |
|
Before Width: | Height: | Size: 1.4 KiB After Width: | Height: | Size: 1.4 KiB |
|
Before Width: | Height: | Size: 98 B After Width: | Height: | Size: 100 B |
|
Before Width: | Height: | Size: 101 B After Width: | Height: | Size: 105 B |
|
Before Width: | Height: | Size: 2.0 KiB After Width: | Height: | Size: 1.7 KiB |
|
Before Width: | Height: | Size: 6.4 KiB After Width: | Height: | Size: 5.4 KiB |
|
Before Width: | Height: | Size: 285 B After Width: | Height: | Size: 282 B |
|
Before Width: | Height: | Size: 547 B After Width: | Height: | Size: 531 B |
|
Before Width: | Height: | Size: 1.4 KiB After Width: | Height: | Size: 1.3 KiB |
|
Before Width: | Height: | Size: 5.1 KiB After Width: | Height: | Size: 4.2 KiB |
|
Before Width: | Height: | Size: 316 B After Width: | Height: | Size: 312 B |
|
Before Width: | Height: | Size: 629 B After Width: | Height: | Size: 614 B |
|
Before Width: | Height: | Size: 196 B After Width: | Height: | Size: 196 B |
|
Before Width: | Height: | Size: 349 B After Width: | Height: | Size: 351 B |
|
Before Width: | Height: | Size: 1.2 KiB After Width: | Height: | Size: 925 B |
|
Before Width: | Height: | Size: 2.7 KiB After Width: | Height: | Size: 2.3 KiB |
|
Before Width: | Height: | Size: 165 B After Width: | Height: | Size: 173 B |
|
Before Width: | Height: | Size: 240 B After Width: | Height: | Size: 258 B |
|
Before Width: | Height: | Size: 183 B After Width: | Height: | Size: 183 B |
|
Before Width: | Height: | Size: 228 B After Width: | Height: | Size: 246 B |
|
Before Width: | Height: | Size: 198 B After Width: | Height: | Size: 207 B |
|
Before Width: | Height: | Size: 357 B After Width: | Height: | Size: 375 B |
|
Before Width: | Height: | Size: 2.0 KiB After Width: | Height: | Size: 1.6 KiB |
|
Before Width: | Height: | Size: 5.0 KiB After Width: | Height: | Size: 5.0 KiB |
|
Before Width: | Height: | Size: 181 B After Width: | Height: | Size: 187 B |
|
Before Width: | Height: | Size: 227 B After Width: | Height: | Size: 233 B |
|
Before Width: | Height: | Size: 158 B After Width: | Height: | Size: 157 B |
|
Before Width: | Height: | Size: 265 B After Width: | Height: | Size: 269 B |
|
Before Width: | Height: | Size: 1.6 KiB After Width: | Height: | Size: 870 B |
|
Before Width: | Height: | Size: 4.1 KiB After Width: | Height: | Size: 3.2 KiB |
|
Before Width: | Height: | Size: 239 B After Width: | Height: | Size: 235 B |
|
Before Width: | Height: | Size: 410 B After Width: | Height: | Size: 399 B |
|
Before Width: | Height: | Size: 1.7 KiB After Width: | Height: | Size: 1.1 KiB |
|
Before Width: | Height: | Size: 3.0 KiB After Width: | Height: | Size: 2.8 KiB |
|
Before Width: | Height: | Size: 177 B After Width: | Height: | Size: 179 B |
|
Before Width: | Height: | Size: 273 B After Width: | Height: | Size: 291 B |
@@ -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);
|
||||
|
||||
|
Before Width: | Height: | Size: 1.2 KiB After Width: | Height: | Size: 1.1 KiB |
|
Before Width: | Height: | Size: 2.2 KiB After Width: | Height: | Size: 2.2 KiB |
|
Before Width: | Height: | Size: 100 B After Width: | Height: | Size: 101 B |
|
Before Width: | Height: | Size: 106 B After Width: | Height: | Size: 107 B |
|
Before Width: | Height: | Size: 163 B After Width: | Height: | Size: 164 B |
|
Before Width: | Height: | Size: 235 B After Width: | Height: | Size: 239 B |
|
Before Width: | Height: | Size: 308 KiB After Width: | Height: | Size: 310 KiB |