diff options
Diffstat (limited to 'src/widgets/styles')
-rw-r--r-- | src/widgets/styles/qcommonstyle.cpp | 10 | ||||
-rw-r--r-- | src/widgets/styles/qfusionstyle.cpp | 2 | ||||
-rw-r--r-- | src/widgets/styles/qmacstyle_mac.mm | 8 | ||||
-rw-r--r-- | src/widgets/styles/qstylehelper.cpp | 22 | ||||
-rw-r--r-- | src/widgets/styles/qwindowsxpstyle.cpp | 36 | ||||
-rw-r--r-- | src/widgets/styles/qwindowsxpstyle_p_p.h | 4 |
6 files changed, 54 insertions, 28 deletions
diff --git a/src/widgets/styles/qcommonstyle.cpp b/src/widgets/styles/qcommonstyle.cpp index cf81f53ad0..e48217155e 100644 --- a/src/widgets/styles/qcommonstyle.cpp +++ b/src/widgets/styles/qcommonstyle.cpp @@ -5237,6 +5237,8 @@ static QPixmap cachedPixmapFromXPM(const char * const *xpm) return result; } +static inline QPixmap titleBarMenuCachedPixmapFromXPM() { return cachedPixmapFromXPM(qt_menu_xpm); } + #ifndef QT_NO_IMAGEFORMAT_PNG static inline QString clearText16IconPath() { @@ -5581,7 +5583,7 @@ QPixmap QCommonStyle::standardPixmap(StandardPixmap sp, const QStyleOption *opti #ifndef QT_NO_IMAGEFORMAT_XPM switch (sp) { case SP_TitleBarMenuButton: - return cachedPixmapFromXPM(qt_menu_xpm); + return titleBarMenuCachedPixmapFromXPM(); case SP_TitleBarShadeButton: return cachedPixmapFromXPM(qt_shade_xpm); case SP_TitleBarUnshadeButton: @@ -6121,6 +6123,12 @@ QIcon QCommonStyle::standardIcon(StandardPixmap standardIcon, const QStyleOption case SP_MediaVolumeMuted: icon.addFile(QLatin1String(":/qt-project.org/styles/commonstyle/images/media-volume-muted-16.png"), QSize(16, 16)); break; + case SP_TitleBarMenuButton: +# ifndef QT_NO_IMAGEFORMAT_XPM + icon.addPixmap(titleBarMenuCachedPixmapFromXPM()); +# endif + icon.addFile(QLatin1String(":/qt-project.org/qmessagebox/images/qtlogo-64.png")); + break; #endif // QT_NO_IMAGEFORMAT_PNG default: icon.addPixmap(proxy()->standardPixmap(standardIcon, option, widget)); diff --git a/src/widgets/styles/qfusionstyle.cpp b/src/widgets/styles/qfusionstyle.cpp index 3a39441785..1e98b1775a 100644 --- a/src/widgets/styles/qfusionstyle.cpp +++ b/src/widgets/styles/qfusionstyle.cpp @@ -1080,8 +1080,8 @@ void QFusionStyle::drawControl(ControlElement element, const QStyleOption *optio painter->setPen(innerLine); painter->drawRoundedRect(option->rect.adjusted(1, 1, -2, -2), 1, 1); painter->restore(); - return; } + break; case CE_SizeGrip: painter->save(); { diff --git a/src/widgets/styles/qmacstyle_mac.mm b/src/widgets/styles/qmacstyle_mac.mm index 9a07eaf851..2fbe3be62f 100644 --- a/src/widgets/styles/qmacstyle_mac.mm +++ b/src/widgets/styles/qmacstyle_mac.mm @@ -1039,6 +1039,8 @@ static QSize qt_aqua_get_known_size(QStyle::ContentsType ct, const QWidget *widg #if defined(QMAC_QAQUASTYLE_SIZE_CONSTRAIN) || defined(DEBUG_SIZE_CONSTRAINT) static QAquaWidgetSize qt_aqua_guess_size(const QWidget *widg, QSize large, QSize small, QSize mini) { + Q_UNUSED(widg); + if (large == QSize(-1, -1)) { if (small != QSize(-1, -1)) return QAquaSizeSmall; @@ -1054,7 +1056,7 @@ static QAquaWidgetSize qt_aqua_guess_size(const QWidget *widg, QSize large, QSiz } #ifndef QT_NO_MAINWINDOW - if (qobject_cast<QDockWidget *>(widg->window()) || qEnvironmentVariableIsSet("QWIDGET_ALL_SMALL")) { + if (qEnvironmentVariableIsSet("QWIDGET_ALL_SMALL")) { //if (small.width() != -1 || small.height() != -1) return QAquaSizeSmall; } else if (qEnvironmentVariableIsSet("QWIDGET_ALL_MINI")) { @@ -4263,10 +4265,6 @@ void QMacStyle::drawControl(ControlElement ce, const QStyleOption *opt, QPainter bool verticalTabs = ttd == kThemeTabWest || ttd == kThemeTabEast; bool selected = (myTab.state & QStyle::State_Selected); - if (selected && !myTab.documentMode - && (!usingYosemiteOrLater || myTab.state & State_Active)) - myTab.palette.setColor(QPalette::WindowText, Qt::white); - // Check to see if we use have the same as the system font // (QComboMenuItem is internal and should never be seen by the // outside world, unless they read the source, in which case, it's diff --git a/src/widgets/styles/qstylehelper.cpp b/src/widgets/styles/qstylehelper.cpp index f073f1cccb..754062ac26 100644 --- a/src/widgets/styles/qstylehelper.cpp +++ b/src/widgets/styles/qstylehelper.cpp @@ -49,6 +49,8 @@ #include "qstylehelper_p.h" #include <qstringbuilder.h> +#include <qdatastream.h> +#include <qcryptographichash.h> QT_BEGIN_NAMESPACE @@ -62,7 +64,6 @@ QString uniqueName(const QString &key, const QStyleOption *option, const QSize & QString tmp = key % HexString<uint>(option->state) % HexString<uint>(option->direction) % HexString<uint>(complexOption ? uint(complexOption->activeSubControls) : 0u) - % HexString<quint64>(option->palette.cacheKey()) % HexString<uint>(size.width()) % HexString<uint>(size.height()); @@ -73,6 +74,25 @@ QString uniqueName(const QString &key, const QStyleOption *option, const QSize & % QLatin1Char(spinBox->frame ? '1' : '0'); ; } #endif // QT_NO_SPINBOX + + // QTBUG-56743, try to create a palette cache key reflecting the value, + // as leaks may occur in conjunction with QStyleSheetStyle/QRenderRule modifying + // palettes when using QPalette::cacheKey() + if (option->palette != QGuiApplication::palette()) { + tmp.append(QLatin1Char('P')); +#ifndef QT_NO_DATASTREAM + QByteArray key; + key.reserve(5120); // Observed 5040B for a serialized palette on 64bit + { + QDataStream str(&key, QIODevice::WriteOnly); + str << option->palette; + } + const QByteArray sha1 = QCryptographicHash::hash(key, QCryptographicHash::Sha1).toHex(); + tmp.append(QString::fromLatin1(sha1)); +#else // QT_NO_DATASTREAM + tmp.append(QString::number(option->palette.cacheKey(), 16)); +#endif // !QT_NO_DATASTREAM + } return tmp; } diff --git a/src/widgets/styles/qwindowsxpstyle.cpp b/src/widgets/styles/qwindowsxpstyle.cpp index 9fb18f63e8..1aa53de486 100644 --- a/src/widgets/styles/qwindowsxpstyle.cpp +++ b/src/widgets/styles/qwindowsxpstyle.cpp @@ -811,7 +811,7 @@ bool QWindowsXPStylePrivate::drawBackground(XPThemeData &themeData) bool translucentToplevel = false; const QPaintDevice *paintDevice = painter->device(); - const qreal aditionalDevicePixelRatio = themeData.widget ? themeData.widget->devicePixelRatio() : 1; + const qreal aditionalDevicePixelRatio = themeData.widget ? themeData.widget->devicePixelRatioF() : qreal(1); if (paintDevice->devType() == QInternal::Widget) { const QWidget *window = static_cast<const QWidget *>(paintDevice)->window(); translucentToplevel = window->testAttribute(Qt::WA_TranslucentBackground); @@ -840,28 +840,28 @@ bool QWindowsXPStylePrivate::drawBackground(XPThemeData &themeData) const HDC dc = canDrawDirectly ? hdcForWidgetBackingStore(themeData.widget) : HDC(0); const bool result = dc - ? drawBackgroundDirectly(dc, themeData, qRound(aditionalDevicePixelRatio)) - : drawBackgroundThruNativeBuffer(themeData, qRound(aditionalDevicePixelRatio)); + ? drawBackgroundDirectly(dc, themeData, aditionalDevicePixelRatio) + : drawBackgroundThruNativeBuffer(themeData, aditionalDevicePixelRatio); painter->restore(); return result; } -static inline QRect scaleRect(const QRect &r, int factor) +static inline QRectF scaleRect(const QRectF &r, qreal factor) { return r.isValid() && factor > 1 - ? QRect(r.topLeft() * factor, r.size() * factor) + ? QRectF(r.topLeft() * factor, r.size() * factor) : r; } -static QRegion scaleRegion(const QRegion ®ion, int factor) +static QRegion scaleRegion(const QRegion ®ion, qreal factor) { - if (region.isEmpty() || factor == 1) + if (region.isEmpty() || qFuzzyCompare(factor, qreal(1))) return region; if (region.rectCount() == 1) - return QRegion(scaleRect(region.boundingRect(), factor)); + return QRegion(scaleRect(QRectF(region.boundingRect()), factor).toRect()); QRegion result; foreach (const QRect &rect, region.rects()) - result += QRect(rect.topLeft() * factor, rect.size() * factor); + result += QRectF(QPointF(rect.topLeft()) * factor, QSizeF(rect.size() * factor)).toRect(); return result; } @@ -870,13 +870,12 @@ static QRegion scaleRegion(const QRegion ®ion, int factor) Do not use this if you need to perform other transformations on the resulting data. */ -bool QWindowsXPStylePrivate::drawBackgroundDirectly(HDC dc, XPThemeData &themeData, int additionalDevicePixelRatio) +bool QWindowsXPStylePrivate::drawBackgroundDirectly(HDC dc, XPThemeData &themeData, qreal additionalDevicePixelRatio) { QPainter *painter = themeData.painter; - QPoint redirectionDelta(int(painter->deviceMatrix().dx()), - int(painter->deviceMatrix().dy())); - QRect area = scaleRect(themeData.rect, additionalDevicePixelRatio).translated(redirectionDelta); + const QPointF redirectionDelta(painter->deviceMatrix().dx(), painter->deviceMatrix().dy()); + const QRect area = scaleRect(QRectF(themeData.rect), additionalDevicePixelRatio).translated(redirectionDelta).toRect(); QRegion sysRgn = painter->paintEngine()->systemClip(); if (sysRgn.isEmpty()) @@ -884,7 +883,7 @@ bool QWindowsXPStylePrivate::drawBackgroundDirectly(HDC dc, XPThemeData &themeDa else sysRgn &= area; if (painter->hasClipping()) - sysRgn &= scaleRegion(painter->clipRegion(), additionalDevicePixelRatio).translated(redirectionDelta); + sysRgn &= scaleRegion(painter->clipRegion(), additionalDevicePixelRatio).translated(redirectionDelta.toPoint()); HRGN hrgn = qt_hrgn_from_qregion(sysRgn); SelectClipRgn(dc, hrgn); @@ -956,15 +955,16 @@ bool QWindowsXPStylePrivate::drawBackgroundDirectly(HDC dc, XPThemeData &themeDa engine). */ bool QWindowsXPStylePrivate::drawBackgroundThruNativeBuffer(XPThemeData &themeData, - int additionalDevicePixelRatio) + qreal additionalDevicePixelRatio) { QPainter *painter = themeData.painter; - QRect rect = scaleRect(themeData.rect, additionalDevicePixelRatio); + QRectF rectF = scaleRect(QRectF(themeData.rect), additionalDevicePixelRatio); if ((themeData.rotate + 90) % 180 == 0) { // Catch 90,270,etc.. degree flips. - rect = QRect(0, 0, rect.height(), rect.width()); + rectF = QRectF(0, 0, rectF.height(), rectF.width()); } - rect.moveTo(0,0); + rectF.moveTo(0, 0); + QRect rect = rectF.toRect(); int partId = themeData.partId; int stateId = themeData.stateId; int w = rect.width(); diff --git a/src/widgets/styles/qwindowsxpstyle_p_p.h b/src/widgets/styles/qwindowsxpstyle_p_p.h index 8ee4d1a641..2838ee93e0 100644 --- a/src/widgets/styles/qwindowsxpstyle_p_p.h +++ b/src/widgets/styles/qwindowsxpstyle_p_p.h @@ -394,8 +394,8 @@ public: void setTransparency(QWidget *widget, XPThemeData &themeData); bool drawBackground(XPThemeData &themeData); - bool drawBackgroundThruNativeBuffer(XPThemeData &themeData, int aditionalDevicePixelRatio); - bool drawBackgroundDirectly(HDC dc, XPThemeData &themeData, int aditionalDevicePixelRatio); + bool drawBackgroundThruNativeBuffer(XPThemeData &themeData, qreal aditionalDevicePixelRatio); + bool drawBackgroundDirectly(HDC dc, XPThemeData &themeData, qreal aditionalDevicePixelRatio); bool hasAlphaChannel(const QRect &rect); bool fixAlphaChannel(const QRect &rect); |