diff --git a/src/app/main.cpp b/src/app/main.cpp index c7fe2c623cc61f926ca18374c0e0875a35f06aa4..f9b2cd747a09981bd875a5dba332c5b0d3e82672 100644 --- a/src/app/main.cpp +++ b/src/app/main.cpp @@ -307,6 +307,10 @@ int main(int argc, char **argv) QtSystemExceptionHandler systemExceptionHandler; #endif +#if QT_VERSION >= 0x050100 + app.setAttribute(Qt::AA_UseHighDpiPixmaps); +#endif + // Manually determine -settingspath command line option // We can't use the regular way of the plugin manager, because that needs to parse pluginspecs // but the settings path can influence which plugins are enabled diff --git a/src/libs/utils/stylehelper.cpp b/src/libs/utils/stylehelper.cpp index 5d7285c5baae0d8822aa64b73e9e6828ad652e1c..0bb8327d44eaa7a5b8825eed825edfb2ea931370 100644 --- a/src/libs/utils/stylehelper.cpp +++ b/src/libs/utils/stylehelper.cpp @@ -35,6 +35,7 @@ #include <QPainter> #include <QApplication> #include <QStyleOption> +#include <qmath.h> // Clamps float color values within (0, 255) static int clamp(float x) @@ -363,15 +364,32 @@ void StyleHelper::menuGradient(QPainter *painter, const QRect &spanRect, const Q } } +static qreal pixmapDevicePixelRatio(const QPixmap &pixmap) +{ +#if QT_VERSION > 0x050000 + return pixmap.devicePixelRatio(); +#else + return 1.0; +#endif +} + // Draws a cached pixmap with shadow void StyleHelper::drawIconWithShadow(const QIcon &icon, const QRect &rect, - QPainter *p, QIcon::Mode iconMode, int radius, const QColor &color, const QPoint &offset) + 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()); if (!QPixmapCache::find(pixmapName, cache)) { + // High-dpi support: The in parameters (rect, radius, offset) are in + // device-independent pixels. The call to QIcon::pixmap() below might + // 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. QPixmap px = icon.pixmap(rect.size()); + int devicePixelRatio = qCeil(pixmapDevicePixelRatio(px)); + int radius = dipRadius * devicePixelRatio; + QPoint offset = dipOffset * devicePixelRatio; cache = QPixmap(px.size() + QSize(radius * 2, radius * 2)); cache.fill(Qt::transparent); @@ -396,7 +414,7 @@ void StyleHelper::drawIconWithShadow(const QIcon &icon, const QRect &rect, QPainter tmpPainter(&tmp); tmpPainter.setCompositionMode(QPainter::CompositionMode_Source); - tmpPainter.drawPixmap(QPoint(radius, radius), px); + tmpPainter.drawPixmap(QRect(radius, radius, px.width(), px.height()), px); tmpPainter.end(); // blur the alpha channel @@ -423,13 +441,17 @@ void StyleHelper::drawIconWithShadow(const QIcon &icon, const QRect &rect, cachePainter.drawImage(QRect(0, 0, cache.rect().width(), cache.rect().height()), tmp); // Draw the actual pixmap... - cachePainter.drawPixmap(QPoint(radius, radius) + offset, px); + cachePainter.drawPixmap(QRect(QPoint(radius, radius) + offset, QSize(px.width(), px.height())), px); +#if QT_VERSION > 0x050000 + cache.setDevicePixelRatio(devicePixelRatio); +#endif QPixmapCache::insert(pixmapName, cache); } QRect targetRect = cache.rect(); - targetRect.moveCenter(rect.center()); - p->drawPixmap(targetRect.topLeft() - offset, cache); + targetRect.setSize(targetRect.size() / pixmapDevicePixelRatio(cache)); + targetRect.moveCenter(rect.center() - dipOffset); + p->drawPixmap(targetRect, cache); } // Draws a CSS-like border image where the defined borders are not stretched diff --git a/src/libs/utils/stylehelper.h b/src/libs/utils/stylehelper.h index 75be2220adc4ffab4c38c0fa2fd6c992f2cd4007..39044d8aafb9763a799642b7d84386bc27c2272d 100644 --- a/src/libs/utils/stylehelper.h +++ b/src/libs/utils/stylehelper.h @@ -83,8 +83,8 @@ public: static bool usePixmapCache() { return true; } static void drawIconWithShadow(const QIcon &icon, const QRect &rect, QPainter *p, QIcon::Mode iconMode, - int radius = 3, const QColor &color = QColor(0, 0, 0, 130), - const QPoint &offset = QPoint(1, -2)); + int dipRadius = 3, const QColor &color = QColor(0, 0, 0, 130), + const QPoint &dipOffset = QPoint(1, -2)); static void drawCornerImage(const QImage &img, QPainter *painter, QRect rect, int left = 0, int top = 0, int right = 0, int bottom = 0); diff --git a/src/plugins/analyzerbase/analyzerbase.qrc b/src/plugins/analyzerbase/analyzerbase.qrc index 679ef7db3dfdb179f390ca856a574fc5b21e3d98..12b8ad1f54eba94d1ed4e217e717b8610179cb94 100644 --- a/src/plugins/analyzerbase/analyzerbase.qrc +++ b/src/plugins/analyzerbase/analyzerbase.qrc @@ -1,6 +1,7 @@ <RCC> <qresource prefix="/"> <file>images/analyzer_mode.png</file> + <file>images/analyzer_mode@2x.png</file> <file>images/analyzer_category.png</file> <file>images/analyzer_start_small.png</file> </qresource> diff --git a/src/plugins/analyzerbase/images/analyzer_mode@2x.png b/src/plugins/analyzerbase/images/analyzer_mode@2x.png new file mode 100644 index 0000000000000000000000000000000000000000..af8b8dea8c10643b393bf6ab5d16c62a377098ee Binary files /dev/null and b/src/plugins/analyzerbase/images/analyzer_mode@2x.png differ diff --git a/src/plugins/coreplugin/coreconstants.h b/src/plugins/coreplugin/coreconstants.h index ab257ca744d90a04db7ef63e3643c7baf8ae8e88..eb234d3d866817b9f438f787fa02fdd9241fb81f 100644 --- a/src/plugins/coreplugin/coreconstants.h +++ b/src/plugins/coreplugin/coreconstants.h @@ -204,6 +204,7 @@ const char ICON_CLOSE_SPLIT_RIGHT[] = ":/core/images/splitbutton_closeright.png const char ICON_FILTER[] = ":/core/images/filtericon.png"; const char ICON_LINK[] = ":/core/images/linkicon.png"; const char ICON_QTLOGO_32[] = ":/core/images/logo/32/QtProject-qtcreator.png"; +const char ICON_QTLOGO_64[] = ":/core/images/logo/64/QtProject-qtcreator.png"; const char ICON_QTLOGO_128[] = ":/core/images/logo/128/QtProject-qtcreator.png"; const char WIZARD_CATEGORY_QT[] = "R.Qt"; diff --git a/src/plugins/coreplugin/fancyactionbar.qrc b/src/plugins/coreplugin/fancyactionbar.qrc index c06c43e476dccfcba30d73ad25d98180aba23729..cc1edb5ef3416446631f91c1053fd1304af2cb86 100644 --- a/src/plugins/coreplugin/fancyactionbar.qrc +++ b/src/plugins/coreplugin/fancyactionbar.qrc @@ -1,10 +1,15 @@ <RCC> <qresource prefix="/fancyactionbar"> <file>images/mode_Debug.png</file> + <file>images/mode_Debug@2x.png</file> <file>images/mode_Edit.png</file> + <file>images/mode_Edit@2x.png</file> <file>images/mode_Output.png</file> <file>images/mode_Project.png</file> + <file>images/mode_Project@2x.png</file> <file>images/mode_Reference.png</file> + <file>images/mode_Reference@2x.png</file> <file>images/mode_Design.png</file> + <file>images/mode_Design@2x.png</file> </qresource> </RCC> diff --git a/src/plugins/coreplugin/images/mode_Debug@2x.png b/src/plugins/coreplugin/images/mode_Debug@2x.png new file mode 100644 index 0000000000000000000000000000000000000000..0dc56c6d93c7825db6972f06f9c5d8d9cc4a6c73 Binary files /dev/null and b/src/plugins/coreplugin/images/mode_Debug@2x.png differ diff --git a/src/plugins/coreplugin/images/mode_Design@2x.png b/src/plugins/coreplugin/images/mode_Design@2x.png new file mode 100644 index 0000000000000000000000000000000000000000..85e08c360b834c2e36f04431777329f24ce4cace Binary files /dev/null and b/src/plugins/coreplugin/images/mode_Design@2x.png differ diff --git a/src/plugins/coreplugin/images/mode_Edit@2x.png b/src/plugins/coreplugin/images/mode_Edit@2x.png new file mode 100644 index 0000000000000000000000000000000000000000..d223679dc36605d6f16ef8899cf7f87b2d3a41f1 Binary files /dev/null and b/src/plugins/coreplugin/images/mode_Edit@2x.png differ diff --git a/src/plugins/coreplugin/images/mode_Project@2x.png b/src/plugins/coreplugin/images/mode_Project@2x.png new file mode 100644 index 0000000000000000000000000000000000000000..f0b7fdae0efaf3abcd4fdd1f04e1eb02c951b418 Binary files /dev/null and b/src/plugins/coreplugin/images/mode_Project@2x.png differ diff --git a/src/plugins/coreplugin/images/mode_Reference@2x.png b/src/plugins/coreplugin/images/mode_Reference@2x.png new file mode 100644 index 0000000000000000000000000000000000000000..ae8db24fd7521aa80701ce25ebc7d603bf74be9c Binary files /dev/null and b/src/plugins/coreplugin/images/mode_Reference@2x.png differ diff --git a/src/plugins/welcome/welcomeplugin.cpp b/src/plugins/welcome/welcomeplugin.cpp index bf8fdf9e946b840d2594a3238a58087ca6c6a6a1..36c53cda76418beb74b87213e4136604109d70dc 100644 --- a/src/plugins/welcome/welcomeplugin.cpp +++ b/src/plugins/welcome/welcomeplugin.cpp @@ -136,7 +136,11 @@ WelcomeMode::WelcomeMode() : , m_networkAccessManagerFactory(new NetworkAccessManagerFactory) { setDisplayName(tr("Welcome")); - setIcon(QIcon(QLatin1String(Core::Constants::ICON_QTLOGO_32))); + QIcon qtLogo; + qtLogo.addFile(QLatin1String(Core::Constants::ICON_QTLOGO_32)); + qtLogo.addFile(QLatin1String(Core::Constants::ICON_QTLOGO_64)); + qtLogo.addFile(QLatin1String(Core::Constants::ICON_QTLOGO_128)); + setIcon(qtLogo); setPriority(Core::Constants::P_MODE_WELCOME); setId(Core::Constants::MODE_WELCOME); setType(Core::Constants::MODE_WELCOME_TYPE);