From b5eb553bf3bd6b9aad79241a65b9bebb40a848fd Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Fri, 1 Apr 2016 23:19:26 +0200 Subject: [PATCH 01/35] Fix UB (shift of negative number) in qHash(QModelIndex) Found by UBSan: itemmodels/qabstractitemmodel.h:426:28: runtime error: left shift of negative value -1 Fix by casting the lhs of the left-shift operator to uint before shifting. Since Qt assumes two's complement repre- sentation of signed integers, this should yield the same result as the old code, but without UBs. It is critically important that the result is identical to the old code (modulo the compiler exploiting the UB, which this patch aims to prevent even in future compilers), because the function is inline, and changing the hash value would mean changing the layout of a QHash between users compiled against the old and new libraries. Change-Id: I7b826a34fb78b02021e40c3f85fd11af398dbec4 Reviewed-by: Olivier Goffart (Woboq GmbH) --- src/corelib/itemmodels/qabstractitemmodel.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/corelib/itemmodels/qabstractitemmodel.h b/src/corelib/itemmodels/qabstractitemmodel.h index 096e67c5134..454134720d9 100644 --- a/src/corelib/itemmodels/qabstractitemmodel.h +++ b/src/corelib/itemmodels/qabstractitemmodel.h @@ -423,7 +423,7 @@ inline Qt::ItemFlags QModelIndex::flags() const { return m ? m->flags(*this) : Qt::ItemFlags(); } inline uint qHash(const QModelIndex &index) Q_DECL_NOTHROW -{ return uint((index.row() << 4) + index.column() + index.internalId()); } +{ return uint((uint(index.row()) << 4) + index.column() + index.internalId()); } QT_END_NAMESPACE From 284016c7e61ded0e3145b6f3e96748ddc1853051 Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Fri, 1 Apr 2016 23:25:51 +0200 Subject: [PATCH 02/35] network-settings.h: don't crash when running without the test server Don't access first() of a potentially-empty QList. Check for QHostInfo::error() first. Also change to constFirst() to prevent a detach. Change-Id: I91fa0bbfb21f62af29abdb23b4869a7f039b259e Reviewed-by: Lars Knoll --- tests/auto/network-settings.h | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/tests/auto/network-settings.h b/tests/auto/network-settings.h index 0e8cfd759e1..a90ea622776 100644 --- a/tests/auto/network-settings.h +++ b/tests/auto/network-settings.h @@ -71,7 +71,12 @@ public: #ifdef QT_NETWORK_LIB static QHostAddress serverIP() { - return QHostInfo::fromName(serverName()).addresses().first(); + const QHostInfo info = QHostInfo::fromName(serverName()); + if (info.error()) { + QTest::qFail(qPrintable(info.errorString()), __FILE__, __LINE__); + return QHostAddress(); + } + return info.addresses().constFirst(); } #endif From e8e09918c01f14e9d8a7019b16ab3cef9bc7f8cd Mon Sep 17 00:00:00 2001 From: Anton Kudryavtsev Date: Wed, 30 Mar 2016 17:18:24 +0300 Subject: [PATCH 03/35] QDir: use QString::splitRef on all platforms MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ... to avoid unnecessary allocations with both case sensitive and case insensitive paths. Optimize 4413254ff603fa19f4fa22d4936e69f4a6dbbc2b Change-Id: I4288831d641f7a0ee67f2efd2f5d4f023df0d39c Reviewed-by: Jędrzej Nowacki Reviewed-by: Marc Mutz Reviewed-by: Edward Welbourne Reviewed-by: Lars Knoll --- src/corelib/io/qdir.cpp | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/src/corelib/io/qdir.cpp b/src/corelib/io/qdir.cpp index 2c2bdd579eb..d0527282b5f 100644 --- a/src/corelib/io/qdir.cpp +++ b/src/corelib/io/qdir.cpp @@ -756,17 +756,13 @@ QString QDir::relativeFilePath(const QString &fileName) const #endif QString result; -#if defined(Q_OS_WIN) - QStringList dirElts = dir.split(QLatin1Char('/'), QString::SkipEmptyParts); - QStringList fileElts = file.split(QLatin1Char('/'), QString::SkipEmptyParts); -#else QVector dirElts = dir.splitRef(QLatin1Char('/'), QString::SkipEmptyParts); QVector fileElts = file.splitRef(QLatin1Char('/'), QString::SkipEmptyParts); -#endif + int i = 0; while (i < dirElts.size() && i < fileElts.size() && #if defined(Q_OS_WIN) - dirElts.at(i).toLower() == fileElts.at(i).toLower()) + dirElts.at(i).compare(fileElts.at(i), Qt::CaseInsensitive) == 0) #else dirElts.at(i) == fileElts.at(i)) #endif From 08a62af7c58927c37a92a5749bc87be1ae3d6d2d Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Fri, 1 Apr 2016 14:53:35 +0200 Subject: [PATCH 04/35] Windows QPA: Don't send geometry change after window creation for maximized/fullscreen. For these states, geometry change will be sent from the code called by setWindowState(); the geometry obtained immediately after window creation is then no longer valid. Task-number: QTBUG-52231 Change-Id: Ia7cbe95e73c5dd4126bb63d448b83f2cab6a53a1 Reviewed-by: Oliver Wolff --- src/plugins/platforms/windows/qwindowsintegration.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/plugins/platforms/windows/qwindowsintegration.cpp b/src/plugins/platforms/windows/qwindowsintegration.cpp index 27ec258f378..bf238c3e776 100644 --- a/src/plugins/platforms/windows/qwindowsintegration.cpp +++ b/src/plugins/platforms/windows/qwindowsintegration.cpp @@ -318,10 +318,14 @@ QPlatformWindow *QWindowsIntegration::createPlatformWindow(QWindow *window) cons if (requested.flags != obtained.flags) window->setFlags(obtained.flags); - // Trigger geometry/screen change signals of QWindow. + // Trigger geometry change (unless it has a special state in which case setWindowState() + // will send the message) and screen change signals of QWindow. if ((obtained.flags & Qt::Desktop) != Qt::Desktop) { - if (requested.geometry != obtained.geometry) + const Qt::WindowState state = window->windowState(); + if (state != Qt::WindowMaximized && state != Qt::WindowFullScreen + && requested.geometry != obtained.geometry) { QWindowSystemInterface::handleGeometryChange(window, obtained.geometry); + } QPlatformScreen *screen = result->screenForGeometry(obtained.geometry); if (screen && result->screen() != screen) QWindowSystemInterface::handleWindowScreenChanged(window, screen->screen()); From 8c3e671239c83238fc036f8a94dde04920c43871 Mon Sep 17 00:00:00 2001 From: Joni Poikelin Date: Fri, 1 Apr 2016 10:52:37 +0300 Subject: [PATCH 05/35] Fix assert with Meta modifier Meta modifier is not found in some configurations which triggers an assert. Instead of assert, ignore the modifier if it is not found. Task-number: QTBUG-52298 Change-Id: I258cee4014a30162afebb423eadaf07ef0ed6a1f Reviewed-by: Paul Olav Tvete --- src/plugins/platforms/xcb/qxcbkeyboard.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/plugins/platforms/xcb/qxcbkeyboard.cpp b/src/plugins/platforms/xcb/qxcbkeyboard.cpp index 631dd17908f..1eeb59a6657 100644 --- a/src/plugins/platforms/xcb/qxcbkeyboard.cpp +++ b/src/plugins/platforms/xcb/qxcbkeyboard.cpp @@ -996,7 +996,6 @@ QList QXcbKeyboard::possibleKeys(const QKeyEvent *event) const Q_ASSERT(shiftMod < 32); Q_ASSERT(altMod < 32); Q_ASSERT(controlMod < 32); - Q_ASSERT(metaMod < 32); xkb_mod_mask_t depressed; int qtKey = 0; @@ -1017,7 +1016,7 @@ QList QXcbKeyboard::possibleKeys(const QKeyEvent *event) const depressed |= (1 << shiftMod); if (neededMods & Qt::ControlModifier) depressed |= (1 << controlMod); - if (neededMods & Qt::MetaModifier) + if (metaMod < 32 && neededMods & Qt::MetaModifier) depressed |= (1 << metaMod); xkb_state_update_mask(kb_state, depressed, latchedMods, lockedMods, 0, 0, lockedLayout); sym = xkb_state_key_get_one_sym(kb_state, keycode); From 0e088bd22cb5b8565cae76592dbbe354de1b4f0d Mon Sep 17 00:00:00 2001 From: Topi Reinio Date: Tue, 29 Mar 2016 14:42:39 +0200 Subject: [PATCH 06/35] Doc: Simple offline CSS: Remove font-size declarations Remove the font-size declarations from the CSS, rely on the default sizes for each element. This solves two issues: - The user-configured font size (both in Assistant and Qt Creator Help) is correctly taken into use. Previously, adjusting the font size resulted in resizing fonts only for some of the text elements. - QTextBrowser backend seems to assume a DPI of 96 for all platforms, and font-sizes in 'pt' units are scaled accordingly. However, on OS X this resulted in font sizes too small to read. Change-Id: Iaab3ad07e387912ad7391df982d4bfe7047f0b20 Task-number: QTBUG-51709 Task-number: QTBUG-51885 Reviewed-by: Friedemann Kleint Reviewed-by: Leena Miettinen --- doc/global/template/style/offline-simple.css | 16 +--------------- 1 file changed, 1 insertion(+), 15 deletions(-) diff --git a/doc/global/template/style/offline-simple.css b/doc/global/template/style/offline-simple.css index 5d8ce5c37fd..84d206b2d0e 100644 --- a/doc/global/template/style/offline-simple.css +++ b/doc/global/template/style/offline-simple.css @@ -1,11 +1,6 @@ -body { - font-size: 10.5pt; -} - pre { background-color: #f0f0f0; font-family: Courier, monospace; - font-size: 11pt; font-weight: 600; vertical-align: top; margin: 15px 85px 15px 35px; @@ -41,7 +36,6 @@ a[href|="http://"], a[href|="https://"] { h1.title { margin-top: 30px; margin-left: 6px; - font-size: 24pt; padding: 6px; } @@ -52,7 +46,6 @@ h2, p.h2 { } h3 { - font-size: 12pt; margin: 30px 0px 30px 6px; } @@ -82,7 +75,6 @@ h3.fn, span.fn { padding: 5px; text-decoration: none; font-weight: 400; - font-size: 12pt; margin: 45px 0px 0px 6px; } @@ -107,7 +99,6 @@ table tr.odd { table.qmlname td { padding: 0px; margin-left: 6px; - font-size: 12pt; } table.qmlname p .name, @@ -124,13 +115,8 @@ h3.fn .name, h3.fn .type { margin-right: 6px; } -tr > td > pre { - font-size: 10.5pt; -} - code { font-family: Courier, monospace; - font-size: 12pt; font-weight: 400; } @@ -167,7 +153,7 @@ td#buildversion { .footer, .footer p { padding: 5px 0px 5px 0px; margin: 45px 15px 5px 15px; - font-size: 7.5pt; + font-size: 8.5pt; background-color: #cccccc; } From 670a9c00ef5ee4bbcbaaefa9482e39359180ac4f Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Fri, 4 Mar 2016 10:39:50 +0100 Subject: [PATCH 07/35] Windows XP style: Allow High DPI scaling to draw directly. Previously, the style defaulted to drawing via pixmaps when the device transformation of the QPainter was more complex than TxTranslate. Introduce an enumeration describing the transformation to be able to identify the scaling used by High DPI scaling and allow for direct drawing in that case as well. Add scale factors. Create pixmaps with device pixel ration in drawBackgroundThruNativeBuffer() if High DPI scaling is in effect. Issues: Borders may go missing due to the up-scaling/rounding. Code branches for DrawBackgroundEx==0 are not touched since it is assumed these old versions of Windows do not run in High DPI. Task-number: QTBUG-49374 Change-Id: Idfe1887e4fac3be2843438dc76cb4971a198ab2a Reviewed-by: Alessandro Portale --- src/widgets/styles/qwindowsxpstyle.cpp | 58 ++++++++++++++++++++---- src/widgets/styles/qwindowsxpstyle_p_p.h | 4 +- 2 files changed, 51 insertions(+), 11 deletions(-) diff --git a/src/widgets/styles/qwindowsxpstyle.cpp b/src/widgets/styles/qwindowsxpstyle.cpp index 5b01312dfb0..e68acdf5cf6 100644 --- a/src/widgets/styles/qwindowsxpstyle.cpp +++ b/src/widgets/styles/qwindowsxpstyle.cpp @@ -704,6 +704,19 @@ bool QWindowsXPStylePrivate::swapAlphaChannel(const QRect &rect, bool allPixels) return valueChange; } +enum TransformType { SimpleTransform, HighDpiScalingTransform, ComplexTransform }; + +static inline TransformType transformType(const QTransform &transform, qreal devicePixelRatio) +{ + if (transform.type() <= QTransform::TxTranslate) + return SimpleTransform; + if (transform.type() > QTransform::TxScale) + return ComplexTransform; + return qFuzzyCompare(transform.m11(), devicePixelRatio) + && qFuzzyCompare(transform.m22(), devicePixelRatio) + ? HighDpiScalingTransform : ComplexTransform; +} + /*! \internal Main theme drawing function. Determines the correct lowlevel drawing method depending on several @@ -727,21 +740,22 @@ bool QWindowsXPStylePrivate::drawBackground(XPThemeData &themeData) painter->save(); - bool complexXForm = painter->deviceTransform().type() > QTransform::TxTranslate; - // Access paintDevice via engine since the painter may // return the clip device which can still be a widget device in case of grabWidget(). bool translucentToplevel = false; const QPaintDevice *paintDevice = painter->device(); + const qreal aditionalDevicePixelRatio = themeData.widget ? themeData.widget->devicePixelRatio() : 1; if (paintDevice->devType() == QInternal::Widget) { const QWidget *window = static_cast(paintDevice)->window(); translucentToplevel = window->testAttribute(Qt::WA_TranslucentBackground); } + const TransformType tt = transformType(painter->deviceTransform(), aditionalDevicePixelRatio); + bool canDrawDirectly = false; if (themeData.widget && painter->opacity() == 1.0 && !themeData.rotate - && !complexXForm && !themeData.mirrorVertically + && tt != ComplexTransform && !themeData.mirrorVertically && (!themeData.mirrorHorizontally || pDrawThemeBackgroundEx) && !translucentToplevel) { // Draw on backing store DC only for real widgets or backing store images. @@ -759,17 +773,38 @@ bool QWindowsXPStylePrivate::drawBackground(XPThemeData &themeData) } const HDC dc = canDrawDirectly ? hdcForWidgetBackingStore(themeData.widget) : HDC(0); - const bool result = dc ? drawBackgroundDirectly(themeData) : drawBackgroundThruNativeBuffer(themeData); + const bool result = dc + ? drawBackgroundDirectly(themeData, qRound(aditionalDevicePixelRatio)) + : drawBackgroundThruNativeBuffer(themeData, qRound(aditionalDevicePixelRatio)); painter->restore(); return result; } +static inline QRect scaleRect(const QRect &r, int factor) +{ + return r.isValid() && factor > 1 + ? QRect(r.topLeft() * factor, r.size() * factor) + : r; +} + +static QRegion scaleRegion(const QRegion ®ion, int factor) +{ + if (region.isEmpty() || factor == 1) + return region; + if (region.rectCount() == 1) + return QRegion(scaleRect(region.boundingRect(), factor)); + QRegion result; + foreach (const QRect &rect, region.rects()) + result += QRect(rect.topLeft() * factor, rect.size() * factor); + return result; +} + /*! \internal This function draws the theme parts directly to the paintengines HDC. Do not use this if you need to perform other transformations on the resulting data. */ -bool QWindowsXPStylePrivate::drawBackgroundDirectly(XPThemeData &themeData) +bool QWindowsXPStylePrivate::drawBackgroundDirectly(XPThemeData &themeData, int additionalDevicePixelRatio) { QPainter *painter = themeData.painter; HDC dc = 0; @@ -778,7 +813,7 @@ bool QWindowsXPStylePrivate::drawBackgroundDirectly(XPThemeData &themeData) QPoint redirectionDelta(int(painter->deviceMatrix().dx()), int(painter->deviceMatrix().dy())); - QRect area = themeData.rect.translated(redirectionDelta); + QRect area = scaleRect(themeData.rect, additionalDevicePixelRatio).translated(redirectionDelta); QRegion sysRgn = painter->paintEngine()->systemClip(); if (sysRgn.isEmpty()) @@ -786,7 +821,7 @@ bool QWindowsXPStylePrivate::drawBackgroundDirectly(XPThemeData &themeData) else sysRgn &= area; if (painter->hasClipping()) - sysRgn &= painter->clipRegion().translated(redirectionDelta); + sysRgn &= scaleRegion(painter->clipRegion(), additionalDevicePixelRatio).translated(redirectionDelta); HRGN hrgn = qt_hrgn_from_qregion(sysRgn); SelectClipRgn(dc, hrgn); @@ -798,6 +833,7 @@ bool QWindowsXPStylePrivate::drawBackgroundDirectly(XPThemeData &themeData) RECT drawRECT = themeData.toRECT(area); DTBGOPTS drawOptions; + memset(&drawOptions, 0, sizeof(drawOptions)); drawOptions.dwSize = sizeof(drawOptions); drawOptions.rcClip = themeData.toRECT(sysRgn.boundingRect()); drawOptions.dwFlags = DTBG_CLIPRECT @@ -855,10 +891,11 @@ bool QWindowsXPStylePrivate::drawBackgroundDirectly(XPThemeData &themeData) flips (horizonal mirroring only, vertical are handled by the theme engine). */ -bool QWindowsXPStylePrivate::drawBackgroundThruNativeBuffer(XPThemeData &themeData) +bool QWindowsXPStylePrivate::drawBackgroundThruNativeBuffer(XPThemeData &themeData, + int additionalDevicePixelRatio) { QPainter *painter = themeData.painter; - QRect rect = themeData.rect; + QRect rect = scaleRect(themeData.rect, additionalDevicePixelRatio); if ((themeData.rotate + 90) % 180 == 0) { // Catch 90,270,etc.. degree flips. rect = QRect(0, 0, rect.height(), rect.width()); @@ -890,6 +927,8 @@ bool QWindowsXPStylePrivate::drawBackgroundThruNativeBuffer(XPThemeData &themeDa pixmapCacheKey.append(QLatin1Char('w')); pixmapCacheKey.append(QString::number(h)); pixmapCacheKey.append(QLatin1Char('h')); + pixmapCacheKey.append(QString::number(additionalDevicePixelRatio)); + pixmapCacheKey.append(QLatin1Char('d')); QPixmap cachedPixmap; ThemeMapKey key(themeData); @@ -1066,6 +1105,7 @@ bool QWindowsXPStylePrivate::drawBackgroundThruNativeBuffer(XPThemeData &themeDa printf("Image format is: %s\n", alphaType == RealAlpha ? "Real Alpha" : alphaType == MaskAlpha ? "Masked Alpha" : "No Alpha"); #endif img = QImage(bufferPixels, bufferW, bufferH, format); + img.setDevicePixelRatio(additionalDevicePixelRatio); } // Blitting backing store diff --git a/src/widgets/styles/qwindowsxpstyle_p_p.h b/src/widgets/styles/qwindowsxpstyle_p_p.h index e1e13698507..c2571b4a79c 100644 --- a/src/widgets/styles/qwindowsxpstyle_p_p.h +++ b/src/widgets/styles/qwindowsxpstyle_p_p.h @@ -387,8 +387,8 @@ public: void setTransparency(QWidget *widget, XPThemeData &themeData); bool drawBackground(XPThemeData &themeData); - bool drawBackgroundThruNativeBuffer(XPThemeData &themeData); - bool drawBackgroundDirectly(XPThemeData &themeData); + bool drawBackgroundThruNativeBuffer(XPThemeData &themeData, int aditionalDevicePixelRatio); + bool drawBackgroundDirectly(XPThemeData &themeData, int aditionalDevicePixelRatio); bool hasAlphaChannel(const QRect &rect); bool fixAlphaChannel(const QRect &rect); From 34a984c80739d034b6c0c9e0f29c73b03ddc5aa1 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Tue, 1 Mar 2016 15:40:52 +0100 Subject: [PATCH 08/35] Windows XP style: Change theme logic to use qreal. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Avoid rounding errors, thus preventing sizes becoming too small when High DPI scaling is in effect. Also fix division by zero crashes should a scale factor be below 1. Task-number: QTBUG-49374 Task-number: QTBUG-51552 Change-Id: I72718521bc3c7f6b0e42392ea2d2d3bbc61e2faa Reviewed-by: Marko Kangas Reviewed-by: Morten Johan Sørvig Reviewed-by: Alessandro Portale --- src/widgets/styles/qwindowsstyle.cpp | 10 ++--- src/widgets/styles/qwindowsstyle_p_p.h | 7 ++-- src/widgets/styles/qwindowsvistastyle.cpp | 47 ++++++++++++----------- src/widgets/styles/qwindowsxpstyle.cpp | 32 +++++++-------- src/widgets/styles/qwindowsxpstyle_p_p.h | 38 +++++++++--------- 5 files changed, 65 insertions(+), 69 deletions(-) diff --git a/src/widgets/styles/qwindowsstyle.cpp b/src/widgets/styles/qwindowsstyle.cpp index 5d02bc17aec..ab3c8df2569 100644 --- a/src/widgets/styles/qwindowsstyle.cpp +++ b/src/widgets/styles/qwindowsstyle.cpp @@ -111,8 +111,6 @@ enum QSliderDirection { SlUp, SlDown, SlLeft, SlRight }; \internal */ -int QWindowsStylePrivate::m_appDevicePixelRatio = 0; - QWindowsStylePrivate::QWindowsStylePrivate() : alt_down(false), menuBarTimer(0) { @@ -125,11 +123,9 @@ QWindowsStylePrivate::QWindowsStylePrivate() #endif } -int QWindowsStylePrivate::appDevicePixelRatio() +qreal QWindowsStylePrivate::appDevicePixelRatio() { - if (!QWindowsStylePrivate::m_appDevicePixelRatio) - QWindowsStylePrivate::m_appDevicePixelRatio = qRound(qApp->devicePixelRatio()); - return QWindowsStylePrivate::m_appDevicePixelRatio; + return qApp->devicePixelRatio(); } // Returns \c true if the toplevel parent of \a widget has seen the Alt-key @@ -406,7 +402,7 @@ int QWindowsStyle::pixelMetric(PixelMetric pm, const QStyleOption *opt, const QW { int ret = QWindowsStylePrivate::pixelMetricFromSystemDp(pm, opt, widget); if (ret != QWindowsStylePrivate::InvalidMetric) - return ret / QWindowsStylePrivate::devicePixelRatio(widget); + return qRound(qreal(ret) / QWindowsStylePrivate::devicePixelRatio(widget)); ret = QWindowsStylePrivate::fixedPixelMetric(pm); if (ret != QWindowsStylePrivate::InvalidMetric) diff --git a/src/widgets/styles/qwindowsstyle_p_p.h b/src/widgets/styles/qwindowsstyle_p_p.h index c8778cc9149..7971b849236 100644 --- a/src/widgets/styles/qwindowsstyle_p_p.h +++ b/src/widgets/styles/qwindowsstyle_p_p.h @@ -64,8 +64,8 @@ public: QWindowsStylePrivate(); static int pixelMetricFromSystemDp(QStyle::PixelMetric pm, const QStyleOption *option = 0, const QWidget *widget = 0); static int fixedPixelMetric(QStyle::PixelMetric pm); - static int devicePixelRatio(const QWidget *widget = 0) - { return widget ? int(widget->devicePixelRatioF()) : QWindowsStylePrivate::appDevicePixelRatio(); } + static qreal devicePixelRatio(const QWidget *widget = 0) + { return widget ? widget->devicePixelRatioF() : QWindowsStylePrivate::appDevicePixelRatio(); } bool hasSeenAlt(const QWidget *widget) const; bool altDown() const { return alt_down; } @@ -90,8 +90,7 @@ public: }; private: - static int appDevicePixelRatio(); - static int m_appDevicePixelRatio; + static qreal appDevicePixelRatio(); }; QT_END_NAMESPACE diff --git a/src/widgets/styles/qwindowsvistastyle.cpp b/src/widgets/styles/qwindowsvistastyle.cpp index d900e4d181b..2266c034847 100644 --- a/src/widgets/styles/qwindowsvistastyle.cpp +++ b/src/widgets/styles/qwindowsvistastyle.cpp @@ -419,8 +419,8 @@ void QWindowsVistaStyle::drawPrimitive(PrimitiveElement element, const QStyleOpt XPThemeData themeSize = theme; themeSize.partId = TVP_HOTGLYPH; themeSize.stateId = GLPS_OPENED; - const QSize size = themeSize.size() / QWindowsXPStylePrivate::devicePixelRatio(widget); - decoration_size = qMax(size.width(), size.height()); + const QSizeF size = themeSize.size() / QWindowsXPStylePrivate::devicePixelRatio(widget); + decoration_size = qRound(qMax(size.width(), size.height())); } int mid_h = option->rect.x() + option->rect.width() / 2; int mid_v = option->rect.y() + option->rect.height() / 2; @@ -985,10 +985,10 @@ void QWindowsVistaStyle::drawControl(ControlElement element, const QStyleOption XPThemeData theme(widget, 0, QWindowsXPStylePrivate::ToolBarTheme, TP_DROPDOWNBUTTON); if (theme.isValid()) { - const QSize size = theme.size() / QWindowsXPStylePrivate::devicePixelRatio(widget); + const QSizeF size = theme.size() / QWindowsXPStylePrivate::devicePixelRatio(widget); if (!size.isEmpty()) { - mbiw = size.width(); - mbih = size.height(); + mbiw = qRound(size.width()); + mbih = qRound(size.height()); } } QRect ir = subElementRect(SE_PushButtonContents, option, 0); @@ -1172,17 +1172,18 @@ void QWindowsVistaStyle::drawControl(ControlElement element, const QStyleOption case CE_MenuItem: if (const QStyleOptionMenuItem *menuitem = qstyleoption_cast(option)) { // windows always has a check column, regardless whether we have an icon or not - int checkcol = 25 / QWindowsXPStylePrivate::devicePixelRatio(widget); - const int gutterWidth = 3 / QWindowsXPStylePrivate::devicePixelRatio(widget); + const qreal devicePixelRatio = QWindowsXPStylePrivate::devicePixelRatio(widget); + int checkcol = qRound(qreal(25) / devicePixelRatio); + const int gutterWidth = qRound(qreal(3) / devicePixelRatio); { XPThemeData theme(widget, 0, QWindowsXPStylePrivate::MenuTheme, MENU_POPUPCHECKBACKGROUND, MBI_HOT); XPThemeData themeSize = theme; themeSize.partId = MENU_POPUPCHECK; themeSize.stateId = 0; - const QSize size = themeSize.size() / QWindowsXPStylePrivate::devicePixelRatio(widget); - const QMargins margins = themeSize.margins() / QWindowsXPStylePrivate::devicePixelRatio(widget); - checkcol = qMax(menuitem->maxIconWidth, gutterWidth + size.width() + margins.left() + margins.right()); + const QSizeF size = themeSize.size() / QWindowsXPStylePrivate::devicePixelRatio(widget); + const QMarginsF margins = themeSize.margins() / QWindowsXPStylePrivate::devicePixelRatio(widget); + checkcol = qMax(menuitem->maxIconWidth, qRound(gutterWidth + size.width() + margins.left() + margins.right())); } QRect rect = option->rect; @@ -1239,17 +1240,17 @@ void QWindowsVistaStyle::drawControl(ControlElement element, const QStyleOption XPThemeData themeSize = theme; themeSize.partId = MENU_POPUPCHECK; themeSize.stateId = 0; - const QSize size = themeSize.size() / QWindowsXPStylePrivate::devicePixelRatio(widget); - const QMargins margins = themeSize.margins() / QWindowsXPStylePrivate::devicePixelRatio(widget); - QRect checkRect(0, 0, size.width() + margins.left() + margins.right(), - size.height() + margins.bottom() + margins.top()); + const QSizeF size = themeSize.size() / QWindowsXPStylePrivate::devicePixelRatio(widget); + const QMarginsF margins = themeSize.margins() / QWindowsXPStylePrivate::devicePixelRatio(widget); + QRect checkRect(0, 0, qRound(size.width() + margins.left() + margins.right()), + qRound(size.height() + margins.bottom() + margins.top())); checkRect.moveCenter(vCheckRect.center()); theme.rect = checkRect; d->drawBackground(theme); if (menuitem->icon.isNull()) { - checkRect = QRect(QPoint(0, 0), size); + checkRect = QRect(QPoint(0, 0), size.toSize()); checkRect.moveCenter(theme.rect.center()); theme.rect = checkRect; @@ -1855,10 +1856,10 @@ QSize QWindowsVistaStyle::sizeFromContents(ContentsType type, const QStyleOption XPThemeData themeSize = theme; themeSize.partId = MENU_POPUPCHECK; themeSize.stateId = 0; - const QSize size = themeSize.size() / QWindowsXPStylePrivate::devicePixelRatio(widget); - const QMargins margins = themeSize.margins() / QWindowsXPStylePrivate::devicePixelRatio(widget); - minimumHeight = qMax(size.height() + margins.bottom() + margins.top(), sz.height()); - sz.rwidth() += size.width() + margins.left() + margins.right(); + const QSizeF size = themeSize.size() / QWindowsXPStylePrivate::devicePixelRatio(widget); + const QMarginsF margins = themeSize.margins() / QWindowsXPStylePrivate::devicePixelRatio(widget); + minimumHeight = qMax(qRound(size.height() + margins.bottom() + margins.top()), sz.height()); + sz.rwidth() += qRound(size.width() + margins.left() + margins.right()); } if (const QStyleOptionMenuItem *menuitem = qstyleoption_cast(option)) { @@ -1966,10 +1967,10 @@ QRect QWindowsVistaStyle::subElementRect(SubElement element, const QStyleOption int arrowWidth = 13; int arrowHeight = 5; if (theme.isValid()) { - const QSize size = theme.size() / QWindowsXPStylePrivate::devicePixelRatio(widget); + const QSizeF size = theme.size() / QWindowsXPStylePrivate::devicePixelRatio(widget); if (!size.isEmpty()) { - arrowWidth = size.width(); - arrowHeight = size.height(); + arrowWidth = qRound(size.width()); + arrowHeight = qRound(size.height()); } } if (option->state & State_Horizontal) { @@ -2510,7 +2511,7 @@ QIcon QWindowsVistaStyle::standardIcon(StandardPixmap standardIcon, QWindowsXPStylePrivate::ButtonTheme, BP_COMMANDLINKGLYPH, CMDLGS_NORMAL); if (theme.isValid()) { - const QSize size = theme.size() / QWindowsXPStylePrivate::devicePixelRatio(widget); + const QSize size = (theme.size() / QWindowsXPStylePrivate::devicePixelRatio(widget)).toSize(); QIcon linkGlyph; QPixmap pm(size); pm.fill(Qt::transparent); diff --git a/src/widgets/styles/qwindowsxpstyle.cpp b/src/widgets/styles/qwindowsxpstyle.cpp index e68acdf5cf6..88b1b41f151 100644 --- a/src/widgets/styles/qwindowsxpstyle.cpp +++ b/src/widgets/styles/qwindowsxpstyle.cpp @@ -423,7 +423,7 @@ const QPixmap *QWindowsXPStylePrivate::tabBody(QWidget *widget) { if (!tabbody) { XPThemeData theme(0, 0, QWindowsXPStylePrivate::TabTheme, TABP_BODY); - const QSize size = theme.size() / QWindowsXPStylePrivate::devicePixelRatio(widget); + const QSize size = (theme.size() / QWindowsXPStylePrivate::devicePixelRatio(widget)).toSize(); tabbody = new QPixmap(size.width(), QApplication::desktop()->screenGeometry().height()); QPainter painter(tabbody); @@ -2042,7 +2042,7 @@ void QWindowsXPStyle::drawControl(ControlElement element, const QStyleOption *op themeNumber = QWindowsXPStylePrivate::StatusTheme; partId = SP_GRIPPER; XPThemeData theme(0, p, themeNumber, partId, 0); - QSize size = theme.size() / QWindowsStylePrivate::devicePixelRatio(widget); + QSize size = (theme.size() / QWindowsStylePrivate::devicePixelRatio(widget)).toSize(); size.rheight()--; if (const QStyleOptionSizeGrip *sg = qstyleoption_cast(option)) { switch (sg->corner) { @@ -2113,7 +2113,7 @@ void QWindowsXPStyle::drawControl(ControlElement element, const QStyleOption *op QWindowsXPStylePrivate::ToolBarTheme, TP_SPLITBUTTONDROPDOWN); if (theme.isValid()) { - const QSize size = theme.size() / QWindowsStylePrivate::devicePixelRatio(widget); + const QSize size = (theme.size() / QWindowsStylePrivate::devicePixelRatio(widget)).toSize(); mbiw = size.width(); mbih = size.height(); } @@ -2576,10 +2576,10 @@ void QWindowsXPStyle::drawControl(ControlElement element, const QStyleOption *op QRect QWindowsXPStylePrivate::scrollBarGripperBounds(QStyle::State flags, const QWidget *widget, XPThemeData *theme) { const bool horizontal = flags & QStyle::State_Horizontal; - const QMargins contentsMargin = theme->margins(theme->rect, TMT_SIZINGMARGINS) - / QWindowsStylePrivate::devicePixelRatio(widget); + const QMargins contentsMargin = (theme->margins(theme->rect, TMT_SIZINGMARGINS) + / QWindowsStylePrivate::devicePixelRatio(widget)).toMargins(); theme->partId = horizontal ? SBP_GRIPPERHORZ : SBP_GRIPPERVERT; - const QSize size = theme->size() / QWindowsStylePrivate::devicePixelRatio(widget); + const QSize size = (theme->size() / QWindowsStylePrivate::devicePixelRatio(widget)).toSize(); const int hSpace = theme->rect.width() - size.width(); const int vSpace = theme->rect.height() - size.height(); @@ -3394,7 +3394,7 @@ int QWindowsXPStyle::pixelMetric(PixelMetric pm, const QStyleOption *option, con int res = QWindowsXPStylePrivate::pixelMetricFromSystemDp(pm, option, widget); if (res != QWindowsStylePrivate::InvalidMetric) - return res / QWindowsStylePrivate::devicePixelRatio(widget); + return qRound(qreal(res) / QWindowsStylePrivate::devicePixelRatio(widget)); res = 0; switch (pm) { @@ -3540,9 +3540,9 @@ QRect QWindowsXPStyle::subControlRect(ComplexControl cc, const QStyleOptionCompl const int height = tb->rect.height(); const int width = tb->rect.width(); const int buttonMargin = int(QStyleHelper::dpiScaled(4)); - int buttonHeight = GetSystemMetrics(SM_CYSIZE) / QWindowsStylePrivate::devicePixelRatio(widget) + int buttonHeight = qRound(qreal(GetSystemMetrics(SM_CYSIZE)) / QWindowsStylePrivate::devicePixelRatio(widget)) - buttonMargin; - int buttonWidth = GetSystemMetrics(SM_CXSIZE) / QWindowsStylePrivate::devicePixelRatio(widget) + int buttonWidth = qRound(qreal(GetSystemMetrics(SM_CXSIZE)) / QWindowsStylePrivate::devicePixelRatio(widget)) - buttonMargin; const int delta = buttonWidth + 2; int controlTop = option->rect.bottom() - buttonHeight - 2; @@ -3737,10 +3737,10 @@ QSize QWindowsXPStyle::sizeFromContents(ContentsType ct, const QStyleOption *opt { XPThemeData buttontheme(widget, 0, QWindowsXPStylePrivate::ButtonTheme, BP_PUSHBUTTON, PBS_NORMAL); if (buttontheme.isValid()) { - const QMargins borderSize = buttontheme.margins() / QWindowsXPStylePrivate::devicePixelRatio(widget); + const QMarginsF borderSize = buttontheme.margins() / QWindowsXPStylePrivate::devicePixelRatio(widget); if (!borderSize.isNull()) { - sz.rwidth() += borderSize.left() + borderSize.right() - 2; - sz.rheight() += borderSize.bottom() + borderSize.top() - 2; + sz.rwidth() += qRound(borderSize.left() + borderSize.right() - 2); + sz.rheight() += qRound(borderSize.bottom() + borderSize.top() - 2); } const int textMargins = 2*(proxy()->pixelMetric(PM_FocusFrameHMargin) + 1); sz += QSize(qMax(pixelMetric(QStyle::PM_ScrollBarExtent, option, widget) @@ -3910,7 +3910,7 @@ QPixmap QWindowsXPStyle::standardPixmap(StandardPixmap standardPixmap, const QSt if (widget && widget->isWindow()) { XPThemeData theme(widget, 0, QWindowsXPStylePrivate::WindowTheme, WP_SMALLCLOSEBUTTON, CBS_NORMAL); if (theme.isValid()) { - const QSize size = theme.size() / QWindowsXPStylePrivate::devicePixelRatio(widget); + const QSize size = (theme.size() / QWindowsXPStylePrivate::devicePixelRatio(widget)).toSize(); return QIcon(QWindowsStyle::standardPixmap(standardPixmap, option, widget)).pixmap(size); } } @@ -3944,7 +3944,7 @@ QIcon QWindowsXPStyle::standardIcon(StandardPixmap standardIcon, XPThemeData theme(0, 0, QWindowsXPStylePrivate::WindowTheme, WP_MAXBUTTON, MAXBS_NORMAL); if (theme.isValid()) { - const QSize size = themeSize.size() / QWindowsXPStylePrivate::devicePixelRatio(widget); + const QSize size = (themeSize.size() / QWindowsXPStylePrivate::devicePixelRatio(widget)).toSize(); QPixmap pm(size); pm.fill(Qt::transparent); QPainter p(&pm); @@ -3978,7 +3978,7 @@ QIcon QWindowsXPStyle::standardIcon(StandardPixmap standardIcon, XPThemeData theme(0, 0, QWindowsXPStylePrivate::WindowTheme, WP_SMALLCLOSEBUTTON, CBS_NORMAL); if (theme.isValid()) { - const QSize size = theme.size() / QWindowsXPStylePrivate::devicePixelRatio(widget); + const QSize size = (theme.size() / QWindowsXPStylePrivate::devicePixelRatio(widget)).toSize(); QPixmap pm(size); pm.fill(Qt::transparent); QPainter p(&pm); @@ -4014,7 +4014,7 @@ QIcon QWindowsXPStyle::standardIcon(StandardPixmap standardIcon, XPThemeData theme(0, 0, QWindowsXPStylePrivate::WindowTheme, WP_RESTOREBUTTON, RBS_NORMAL); if (theme.isValid()) { - const QSize size = themeSize.size() / QWindowsStylePrivate::devicePixelRatio(widget); + const QSize size = (themeSize.size() / QWindowsStylePrivate::devicePixelRatio(widget)).toSize(); QPixmap pm(size); pm.fill(Qt::transparent); QPainter p(&pm); diff --git a/src/widgets/styles/qwindowsxpstyle_p_p.h b/src/widgets/styles/qwindowsxpstyle_p_p.h index c2571b4a79c..240a338c3fe 100644 --- a/src/widgets/styles/qwindowsxpstyle_p_p.h +++ b/src/widgets/styles/qwindowsxpstyle_p_p.h @@ -202,15 +202,15 @@ public: static RECT toRECT(const QRect &qr); bool isValid(); - QSize size(); - QMargins margins(const QRect &rect, int propId = TMT_CONTENTMARGINS); - QMargins margins(int propId = TMT_CONTENTMARGINS); + QSizeF size(); + QMarginsF margins(const QRect &rect, int propId = TMT_CONTENTMARGINS); + QMarginsF margins(int propId = TMT_CONTENTMARGINS); - static QSize themeSize(const QWidget *w = 0, QPainter *p = 0, int themeIn = -1, int part = 0, int state = 0); - static QMargins themeMargins(const QRect &rect, const QWidget *w = 0, QPainter *p = 0, int themeIn = -1, - int part = 0, int state = 0, int propId = TMT_CONTENTMARGINS); - static QMargins themeMargins(const QWidget *w = 0, QPainter *p = 0, int themeIn = -1, - int part = 0, int state = 0, int propId = TMT_CONTENTMARGINS); + static QSizeF themeSize(const QWidget *w = 0, QPainter *p = 0, int themeIn = -1, int part = 0, int state = 0); + static QMarginsF themeMargins(const QRect &rect, const QWidget *w = 0, QPainter *p = 0, int themeIn = -1, + int part = 0, int state = 0, int propId = TMT_CONTENTMARGINS); + static QMarginsF themeMargins(const QWidget *w = 0, QPainter *p = 0, int themeIn = -1, + int part = 0, int state = 0, int propId = TMT_CONTENTMARGINS); const QWidget *widget; QPainter *painter; @@ -427,9 +427,9 @@ private: static HTHEME m_themes[NThemes]; }; -inline QSize XPThemeData::size() +inline QSizeF XPThemeData::size() { - QSize result(0, 0); + QSizeF result(0, 0); if (isValid()) { SIZE size; if (SUCCEEDED(QWindowsXPStylePrivate::pGetThemePartSize(handle(), 0, partId, stateId, 0, TS_TRUE, &size))) @@ -438,9 +438,9 @@ inline QSize XPThemeData::size() return result; } -inline QMargins XPThemeData::margins(const QRect &qRect, int propId) +inline QMarginsF XPThemeData::margins(const QRect &qRect, int propId) { - QMargins result(0, 0, 0 ,0); + QMarginsF result(0, 0, 0 ,0); if (isValid()) { MARGINS margins; RECT rect = XPThemeData::toRECT(qRect); @@ -450,9 +450,9 @@ inline QMargins XPThemeData::margins(const QRect &qRect, int propId) return result; } -inline QMargins XPThemeData::margins(int propId) +inline QMarginsF XPThemeData::margins(int propId) { - QMargins result(0, 0, 0 ,0); + QMarginsF result(0, 0, 0 ,0); if (isValid()) { MARGINS margins; if (SUCCEEDED(QWindowsXPStylePrivate::pGetThemeMargins(handle(), 0, partId, stateId, propId, NULL, &margins))) @@ -461,21 +461,21 @@ inline QMargins XPThemeData::margins(int propId) return result; } -inline QSize XPThemeData::themeSize(const QWidget *w, QPainter *p, int themeIn, int part, int state) +inline QSizeF XPThemeData::themeSize(const QWidget *w, QPainter *p, int themeIn, int part, int state) { XPThemeData theme(w, p, themeIn, part, state); return theme.size(); } -inline QMargins XPThemeData::themeMargins(const QRect &rect, const QWidget *w, QPainter *p, int themeIn, - int part, int state, int propId) +inline QMarginsF XPThemeData::themeMargins(const QRect &rect, const QWidget *w, QPainter *p, int themeIn, + int part, int state, int propId) { XPThemeData theme(w, p, themeIn, part, state); return theme.margins(rect, propId); } -inline QMargins XPThemeData::themeMargins(const QWidget *w, QPainter *p, int themeIn, - int part, int state, int propId) +inline QMarginsF XPThemeData::themeMargins(const QWidget *w, QPainter *p, int themeIn, + int part, int state, int propId) { XPThemeData theme(w, p, themeIn, part, state); return theme.margins(propId); From 16e7bcc4cddf31bb2d13d5c6dfbe9184b66d5b06 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Fri, 4 Mar 2016 15:55:35 +0100 Subject: [PATCH 09/35] Vista style animation: Create images with device pixel ratio. Change-Id: Ic404c8ac8b0e4c1b8d0dd7877611443e0afac270 Task-number: QTBUG-49374 Reviewed-by: Alessandro Portale --- src/widgets/styles/qstyleanimation.cpp | 1 + src/widgets/styles/qwindowsvistastyle.cpp | 34 +++++++++++------------ 2 files changed, 18 insertions(+), 17 deletions(-) diff --git a/src/widgets/styles/qstyleanimation.cpp b/src/widgets/styles/qstyleanimation.cpp index 922a1e5ffbd..eaaf923b258 100644 --- a/src/widgets/styles/qstyleanimation.cpp +++ b/src/widgets/styles/qstyleanimation.cpp @@ -267,6 +267,7 @@ static QImage blendedImage(const QImage &start, const QImage &end, float alpha) case 32: { blended = QImage(sw, sh, start.format()); + blended.setDevicePixelRatio(start.devicePixelRatio()); uchar *mixed_data = blended.bits(); const uchar *back_data = start.bits(); const uchar *front_data = end.bits(); diff --git a/src/widgets/styles/qwindowsvistastyle.cpp b/src/widgets/styles/qwindowsvistastyle.cpp index 2266c034847..70623a92502 100644 --- a/src/widgets/styles/qwindowsvistastyle.cpp +++ b/src/widgets/styles/qwindowsvistastyle.cpp @@ -102,6 +102,15 @@ bool canAnimate(const QStyleOption *option) { && !option->styleObject->property("_q_no_animation").toBool(); } +static inline QImage createAnimationBuffer(const QStyleOption *option, const QWidget *widget) +{ + const int devicePixelRatio = widget ? widget->devicePixelRatio() : 1; + QImage result(option->rect.size() * devicePixelRatio, QImage::Format_ARGB32_Premultiplied); + result.setDevicePixelRatio(devicePixelRatio); + result.fill(0); + return result; +} + /* \internal Used by animations to clone a styleoption and shift its offset */ @@ -314,12 +323,10 @@ void QWindowsVistaStyle::drawPrimitive(PrimitiveElement element, const QStyleOpt // We create separate images for the initial and final transition states and store them in the // Transition object. - QImage startImage(option->rect.size(), QImage::Format_ARGB32_Premultiplied); - startImage.fill(0); + QImage startImage = createAnimationBuffer(option, widget); QPainter startPainter(&startImage); - QImage endImage(option->rect.size(), QImage::Format_ARGB32_Premultiplied); - endImage.fill(0); + QImage endImage = createAnimationBuffer(option, widget); QPainter endPainter(&endImage); // If we have a running animation on the widget already, we will use that to paint the initial @@ -867,8 +874,7 @@ void QWindowsVistaStyle::drawControl(ControlElement element, const QStyleOption QStyleOption *styleOption = clonedAnimationStyleOption(option); styleOption->state = (QStyle::State)oldState; - QImage startImage(option->rect.size(), QImage::Format_ARGB32_Premultiplied); - startImage.fill(0); + QImage startImage = createAnimationBuffer(option, widget); QPainter startPainter(&startImage); // Use current state of existing animation if already one is running @@ -880,8 +886,7 @@ void QWindowsVistaStyle::drawControl(ControlElement element, const QStyleOption } t->setStartImage(startImage); - QImage endImage(option->rect.size(), QImage::Format_ARGB32_Premultiplied); - endImage.fill(0); + QImage endImage = createAnimationBuffer(option, widget); QPainter endPainter(&endImage); styleOption->state = option->state; proxy()->drawControl(element, styleOption, &endPainter, widget); @@ -943,10 +948,8 @@ void QWindowsVistaStyle::drawControl(ControlElement element, const QStyleOption QWindowsVistaAnimation *anim = qobject_cast(d->animation(styleObject(option))); if (!anim) { - QImage startImage(option->rect.size(), QImage::Format_ARGB32_Premultiplied); - startImage.fill(0); - QImage alternateImage(option->rect.size(), QImage::Format_ARGB32_Premultiplied); - alternateImage.fill(0); + QImage startImage = createAnimationBuffer(option, widget); + QImage alternateImage = createAnimationBuffer(option, widget); QWindowsVistaPulse *pulse = new QWindowsVistaPulse(styleObject(option)); @@ -1544,13 +1547,10 @@ void QWindowsVistaStyle::drawComplexControl(ComplexControl control, const QStyle } if (doTransition) { - - QImage startImage(option->rect.size(), QImage::Format_ARGB32_Premultiplied); - startImage.fill(0); + QImage startImage = createAnimationBuffer(option, widget); QPainter startPainter(&startImage); - QImage endImage(option->rect.size(), QImage::Format_ARGB32_Premultiplied); - endImage.fill(0); + QImage endImage = createAnimationBuffer(option, widget); QPainter endPainter(&endImage); QWindowsVistaAnimation *anim = qobject_cast(d->animation(styleObject)); From a7b0cb467ca5c4a9447d049910c9e3f0abc5897c Mon Sep 17 00:00:00 2001 From: Allan Sandfeld Jensen Date: Tue, 1 Mar 2016 11:17:58 +0100 Subject: [PATCH 10/35] Accept partial line scrolls QAbstractSlider might register and use small scroll events that would scroll less than a single line. Since we consume the scroll-event we should accept it, so it doesn't scroll other widgets too. Task-number: QTBUG-49549 Change-Id: I7c64c5f6cae46f02ba21058abbecb791fc3c88eb Reviewed-by: Simon Hausmann Reviewed-by: Shawn Rutledge --- src/widgets/widgets/qabstractslider.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/widgets/widgets/qabstractslider.cpp b/src/widgets/widgets/qabstractslider.cpp index 283cac80daa..92d2ffde2b3 100644 --- a/src/widgets/widgets/qabstractslider.cpp +++ b/src/widgets/widgets/qabstractslider.cpp @@ -720,8 +720,16 @@ bool QAbstractSliderPrivate::scrollByDelta(Qt::Orientation orientation, Qt::Keyb stepsToScroll = int(offset_accumulated); #endif offset_accumulated -= int(offset_accumulated); - if (stepsToScroll == 0) + if (stepsToScroll == 0) { + // We moved less than a line, but might still have accumulated partial scroll, + // unless we already are at one of the ends. + if (offset_accumulated > 0.f && value < maximum) + return true; + if (offset_accumulated < 0.f && value > minimum) + return true; + offset_accumulated = 0; return false; + } } if (invertedControls) From 4faadb3ad351b1654902ba9564df9789f727621e Mon Sep 17 00:00:00 2001 From: Giuseppe D'Angelo Date: Sat, 2 Apr 2016 20:48:43 +0200 Subject: [PATCH 11/35] QHeaderView::setStretchLastSection: make it a noop when setting the same value For some reason this setter wasn't protected against setting the same value again, and always did work (including resizing the last section when setting it to false). Change-Id: I044404eef95d52d165100254f3afd489997e0872 Task-number: QTBUG-52308 Reviewed-by: Marc Mutz --- src/widgets/itemviews/qheaderview.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/widgets/itemviews/qheaderview.cpp b/src/widgets/itemviews/qheaderview.cpp index 338627c79ff..f04d5800302 100644 --- a/src/widgets/itemviews/qheaderview.cpp +++ b/src/widgets/itemviews/qheaderview.cpp @@ -1473,6 +1473,8 @@ bool QHeaderView::stretchLastSection() const void QHeaderView::setStretchLastSection(bool stretch) { Q_D(QHeaderView); + if (d->stretchLastSection == stretch) + return; d->stretchLastSection = stretch; if (d->state != QHeaderViewPrivate::NoState) return; From 41a0be329c3f31345afc61b622e49fc4bc3bce08 Mon Sep 17 00:00:00 2001 From: Laszlo Agocs Date: Wed, 30 Mar 2016 07:32:51 +0200 Subject: [PATCH 12/35] Do not disconnect with nullptr when unplugging screens Task-number: QTBUG-42803 Change-Id: I080ec3f0cc2cb55b43a9b8792f03b002b2e0f982 Reviewed-by: Gunnar Sletta Reviewed-by: Shawn Rutledge --- src/gui/kernel/qopenglcontext.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/gui/kernel/qopenglcontext.cpp b/src/gui/kernel/qopenglcontext.cpp index 3c033ea39e1..7588c36c9b7 100644 --- a/src/gui/kernel/qopenglcontext.cpp +++ b/src/gui/kernel/qopenglcontext.cpp @@ -510,8 +510,10 @@ void QOpenGLContext::setScreen(QScreen *screen) void QOpenGLContextPrivate::_q_screenDestroyed(QObject *object) { Q_Q(QOpenGLContext); - if (object == static_cast(screen)) + if (object == static_cast(screen)) { + screen = 0; q->setScreen(0); + } } /*! From 17d17a5d72d4f98b692c8ab8a7037aa29b503dae Mon Sep 17 00:00:00 2001 From: Maurice Kalinowski Date: Tue, 5 Apr 2016 12:59:17 +0200 Subject: [PATCH 13/35] winrt: Change input panel behavior to platform default Native applications do open the native input pane when the touch release happens, not during press. Widget applications seem to not ask the theme, so it was acting like native there already. For Qt Quick applications the platform theme is queried, now returning true for SetFocusOnTouchRelease. As a side-effect this also fixes QTBUG-52295, as showInputPanel() at press time causes issues with focus handling, causing the input pane to disappear again. Task-number: QTBUG-52295 Change-Id: I6da6a0126f695233b7c8a399a1549a8b7c824af2 Reviewed-by: Friedemann Kleint Reviewed-by: Oliver Wolff --- src/plugins/platforms/winrt/qwinrttheme.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/plugins/platforms/winrt/qwinrttheme.cpp b/src/plugins/platforms/winrt/qwinrttheme.cpp index 7ef13fd0aa6..bc3ba210c94 100644 --- a/src/plugins/platforms/winrt/qwinrttheme.cpp +++ b/src/plugins/platforms/winrt/qwinrttheme.cpp @@ -355,7 +355,7 @@ QVariant QWinRTTheme::styleHint(QPlatformIntegration::StyleHint hint) case QPlatformIntegration::PasswordMaskCharacter: return defaultThemeHint(PasswordMaskCharacter); case QPlatformIntegration::SetFocusOnTouchRelease: - return false; + return true; case QPlatformIntegration::ShowIsMaximized: return true; case QPlatformIntegration::MousePressAndHoldInterval: From bebf89e1379d6948728a4ebd669de6b63dc3f426 Mon Sep 17 00:00:00 2001 From: Edward Welbourne Date: Mon, 4 Apr 2016 10:58:06 +0200 Subject: [PATCH 14/35] QDateTimeParser: Avoid repetition in sectionMaxSize The format to use was computed, every time round a loop, in both branches of a ?: choice, duplicating code and potentially computation. Pull it out into a const computed once before the loop. A conditional return 2 is pointless for the #if-branch which returns 2 unconditionally, so move it into the #else. Change-Id: Ia583e958e24f9f37b92cb3f2a173bc07e88bcd06 Reviewed-by: Marc Mutz --- src/corelib/tools/qdatetimeparser.cpp | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/corelib/tools/qdatetimeparser.cpp b/src/corelib/tools/qdatetimeparser.cpp index d4004098c55..8e3eaf70746 100644 --- a/src/corelib/tools/qdatetimeparser.cpp +++ b/src/corelib/tools/qdatetimeparser.cpp @@ -598,19 +598,20 @@ int QDateTimeParser::sectionMaxSize(Section s, int count) const // fall through #endif case MonthSection: - if (count <= 2) - return 2; - #ifdef QT_NO_TEXTDATE return 2; #else + if (count <= 2) + return 2; + { int ret = 0; const QLocale l = locale(); + const QLocale::FormatType format = count == 4 ? QLocale::LongFormat : QLocale::ShortFormat; for (int i=1; i<=mcount; ++i) { const QString str = (s == MonthSection - ? l.monthName(i, count == 4 ? QLocale::LongFormat : QLocale::ShortFormat) - : l.dayName(i, count == 4 ? QLocale::LongFormat : QLocale::ShortFormat)); + ? l.monthName(i, format) + : l.dayName(i, format)); ret = qMax(str.size(), ret); } return ret; From 65aff4dc422f53faa44e961850cb4f1e4501a8c7 Mon Sep 17 00:00:00 2001 From: Jason Haslam Date: Fri, 2 Oct 2015 11:56:29 -0600 Subject: [PATCH 15/35] Fix regression in scaled QLabel on hi-res display. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The change in bc1796f for QTBUG-42503 only works for scaling down pixel-doubled images. Smaller images scale up incorrectly. Fixed by setting the devicePixelRatio of the scaled pixmap to the devicePixelRatio of the label. Also, caching was broken by not accounting for scaling by devicePixelRatio in the condition. Change-Id: I6e1503652e61683a16312c74f46b79d28c880848 Task-number: QTBUG-46846 Reviewed-by: Morten Johan Sørvig --- src/widgets/widgets/qlabel.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/widgets/widgets/qlabel.cpp b/src/widgets/widgets/qlabel.cpp index 55e277026c6..a07a9645952 100644 --- a/src/widgets/widgets/qlabel.cpp +++ b/src/widgets/widgets/qlabel.cpp @@ -1091,14 +1091,16 @@ void QLabel::paintEvent(QPaintEvent *) if (d->pixmap && !d->pixmap->isNull()) { QPixmap pix; if (d->scaledcontents) { - if (!d->scaledpixmap || d->scaledpixmap->size() != cr.size()) { + QSize scaledSize = cr.size() * devicePixelRatioF(); + if (!d->scaledpixmap || d->scaledpixmap->size() != scaledSize) { if (!d->cachedimage) d->cachedimage = new QImage(d->pixmap->toImage()); delete d->scaledpixmap; QImage scaledImage = - d->cachedimage->scaled(cr.size() * devicePixelRatioF(), + d->cachedimage->scaled(scaledSize, Qt::IgnoreAspectRatio, Qt::SmoothTransformation); d->scaledpixmap = new QPixmap(QPixmap::fromImage(scaledImage)); + d->scaledpixmap->setDevicePixelRatio(devicePixelRatioF()); } pix = *d->scaledpixmap; } else From 1726352207273465c12852d027f97b99884b78e4 Mon Sep 17 00:00:00 2001 From: Hannah von Reth Date: Tue, 29 Mar 2016 09:50:50 +0200 Subject: [PATCH 16/35] Make sure QStyleOption is correctly initialized. Ensures that QStyleOption is correctly initialized. This prevents possible styling issues due to QStyleOption's reporting version 0, see qstyleoption_cast. This enables users to handle more cases in their QProxyStyle. For now the test is only used for QCommonStyle. Change-Id: I768db00b12b46890343fffe44e4f562762e9cf80 Reviewed-by: Marc Mutz --- src/widgets/styles/qcommonstyle.cpp | 10 +- .../auto/widgets/styles/qstyle/tst_qstyle.cpp | 107 ++++++++++++++++++ 2 files changed, 110 insertions(+), 7 deletions(-) diff --git a/src/widgets/styles/qcommonstyle.cpp b/src/widgets/styles/qcommonstyle.cpp index 4b6e3ac5c45..7b0d8eacd5c 100644 --- a/src/widgets/styles/qcommonstyle.cpp +++ b/src/widgets/styles/qcommonstyle.cpp @@ -784,10 +784,8 @@ static void drawArrow(const QStyle *style, const QStyleOptionToolButton *toolbut default: return; } - QStyleOption arrowOpt; + QStyleOption arrowOpt = *toolbutton; arrowOpt.rect = rect; - arrowOpt.palette = toolbutton->palette; - arrowOpt.state = toolbutton->state; style->drawPrimitive(pe, &arrowOpt, painter, widget); } #endif // QT_NO_TOOLBUTTON @@ -3309,8 +3307,7 @@ void QCommonStyle::drawComplexControl(ComplexControl cc, const QStyleOptionCompl mflags |= State_Sunken; } - QStyleOption tool(0); - tool.palette = toolbutton->palette; + QStyleOption tool = *toolbutton; if (toolbutton->subControls & SC_ToolButton) { if (bflags & (State_Sunken | State_On | State_Raised)) { tool.rect = button; @@ -3379,8 +3376,7 @@ void QCommonStyle::drawComplexControl(ComplexControl cc, const QStyleOptionCompl bool down = false; QPixmap pm; - QStyleOption tool(0); - tool.palette = tb->palette; + QStyleOption tool = *tb; if (tb->subControls & SC_TitleBarCloseButton && tb->titleBarFlags & Qt::WindowSystemMenuHint) { ir = proxy()->subControlRect(CC_TitleBar, tb, SC_TitleBarCloseButton, widget); down = tb->activeSubControls & SC_TitleBarCloseButton && (opt->state & State_Sunken); diff --git a/tests/auto/widgets/styles/qstyle/tst_qstyle.cpp b/tests/auto/widgets/styles/qstyle/tst_qstyle.cpp index dafa95fb25a..46b6fcca821 100644 --- a/tests/auto/widgets/styles/qstyle/tst_qstyle.cpp +++ b/tests/auto/widgets/styles/qstyle/tst_qstyle.cpp @@ -133,6 +133,7 @@ private slots: void testFrameOnlyAroundContents(); void testProxyCalled(); + void testStyleOptionInit(); private: void lineUpLayoutTest(QStyle *); QWidget *testWidget; @@ -856,5 +857,111 @@ void tst_QStyle::testProxyCalled() } } + +class TestStyleOptionInitProxy: public QProxyStyle +{ + Q_OBJECT +public: + mutable bool invalidOptionsDetected; + explicit TestStyleOptionInitProxy(QStyle *style = Q_NULLPTR) + : QProxyStyle(style), + invalidOptionsDetected(false) + {} + + void drawPrimitive(PrimitiveElement pe, const QStyleOption *opt, QPainter *p, const QWidget *w) const Q_DECL_OVERRIDE { + checkStyleEnum(pe, opt); + return QProxyStyle::drawPrimitive(pe, opt, p, w); + } + + void drawControl(ControlElement element, const QStyleOption *opt, QPainter *p, const QWidget *w) const Q_DECL_OVERRIDE { + checkStyleEnum(element, opt); + return QProxyStyle::drawControl(element, opt, p, w); + } + + QRect subElementRect(SubElement subElement, const QStyleOption *option, const QWidget *widget) const Q_DECL_OVERRIDE { + checkStyleEnum(subElement, option); + return QProxyStyle::subElementRect(subElement, option, widget); + } + + void drawComplexControl(ComplexControl cc, const QStyleOptionComplex *opt, QPainter *p, const QWidget *widget) const Q_DECL_OVERRIDE { + checkStyleEnum(cc, opt); + return QProxyStyle::drawComplexControl(cc, opt, p, widget); + } + + QRect subControlRect(ComplexControl cc, const QStyleOptionComplex *opt, SubControl sc, const QWidget *widget) const Q_DECL_OVERRIDE { + checkStyleEnum(cc, opt); + return QProxyStyle::subControlRect(cc, opt, sc, widget); + } + + int pixelMetric(PixelMetric metric, const QStyleOption *option, const QWidget *widget) const Q_DECL_OVERRIDE { + checkStyleEnum(metric, option); + return QProxyStyle::pixelMetric(metric, option, widget); + } + + QSize sizeFromContents(ContentsType ct, const QStyleOption *opt, const QSize &contentsSize, const QWidget *w) const Q_DECL_OVERRIDE { + checkStyleEnum(ct, opt); + return QProxyStyle::sizeFromContents(ct, opt, contentsSize, w); + } + + int styleHint(StyleHint stylehint, const QStyleOption *opt, const QWidget *widget, QStyleHintReturn *returnData) const Q_DECL_OVERRIDE { + checkStyleEnum(stylehint, opt); + return QProxyStyle::styleHint(stylehint, opt, widget, returnData); + } + + QPixmap standardPixmap(StandardPixmap standardPixmap, const QStyleOption *opt, const QWidget *widget) const Q_DECL_OVERRIDE { + checkStyleEnum(standardPixmap, opt); + return QProxyStyle::standardPixmap(standardPixmap, opt, widget); + } + + QIcon standardIcon(StandardPixmap standardIcon, const QStyleOption *option, const QWidget *widget) const Q_DECL_OVERRIDE { + checkStyleEnum(standardIcon, option); + return QProxyStyle::standardIcon(standardIcon, option, widget); + } + + QPixmap generatedIconPixmap(QIcon::Mode iconMode, const QPixmap &pixmap, const QStyleOption *opt) const Q_DECL_OVERRIDE { + checkStyle(QString::asprintf("QIcon::Mode(%i)", iconMode).toLatin1(), opt); + return QProxyStyle::generatedIconPixmap(iconMode, pixmap, opt); + } + + int layoutSpacing(QSizePolicy::ControlType control1, QSizePolicy::ControlType control2, Qt::Orientation orientation, const QStyleOption *option, const QWidget *widget) const Q_DECL_OVERRIDE { + checkStyle(QString::asprintf("QSizePolicy::ControlType(%i), QSizePolicy::ControlType(%i)", control1, control2).toLatin1(), option); + return QProxyStyle::layoutSpacing(control1, control2, orientation, option, widget); + } + +private: + void checkStyle(const QByteArray &info, const QStyleOption *opt) const { + if (opt && (opt->version == 0 || opt->styleObject == Q_NULLPTR) ) { + invalidOptionsDetected = true; + qWarning() << baseStyle()->metaObject()->className() + << "Invalid QStyleOption found for" + << info; + qWarning() << "Version:" << opt->version << "StyleObject:" << opt->styleObject; + } + } + + template + void checkStyleEnum(MEnum element, const QStyleOption *opt) const { + static QMetaEnum _enum = QMetaEnum::fromType(); + checkStyle(_enum.valueToKey(element), opt); + } +}; + +void tst_QStyle::testStyleOptionInit() +{ + QStringList keys = QStyleFactory::keys(); + QVector styles; + styles.reserve(keys.size() + 1); + + styles << new QCommonStyle(); + + Q_FOREACH (QStyle *style, styles) { + TestStyleOptionInitProxy testStyle; + testStyle.setBaseStyle(style); + testAllFunctions(style); + QVERIFY(!testStyle.invalidOptionsDetected); + delete style; + } +} + QTEST_MAIN(tst_QStyle) #include "tst_qstyle.moc" From 6a85b950a4af63c8f5213bd04d5e779213edfe81 Mon Sep 17 00:00:00 2001 From: Oliver Wolff Date: Mon, 21 Mar 2016 13:19:17 +0100 Subject: [PATCH 17/35] ANGLE: Do not use march=native That configuration causes gcc to create non portable code and thus should not be used. Task-number: QTBUG-51938 Change-Id: Ib134bd0b12811c15805943180c41af8f411e6453 Reviewed-by: Andrew Knight Reviewed-by: Friedemann Kleint --- src/angle/src/config.pri | 2 -- src/angle/src/libGLESv2/libGLESv2.pro | 2 +- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/src/angle/src/config.pri b/src/angle/src/config.pri index fddb395ab25..2c5b5ec615f 100644 --- a/src/angle/src/config.pri +++ b/src/angle/src/config.pri @@ -97,8 +97,6 @@ gcc { -Wno-strict-aliasing -Wno-type-limits -Wno-unused-local-typedefs QMAKE_CXXFLAGS_WARN_ON = $$QMAKE_CFLAGS_WARN_ON -Wno-reorder -Wno-conversion-null -Wno-delete-non-virtual-dtor - - sse2: QMAKE_CXXFLAGS += -march=native } QMAKE_CXXFLAGS_DEBUG = $$QMAKE_CFLAGS_DEBUG diff --git a/src/angle/src/libGLESv2/libGLESv2.pro b/src/angle/src/libGLESv2/libGLESv2.pro index 1da079fd400..c90f3d326e5 100644 --- a/src/angle/src/libGLESv2/libGLESv2.pro +++ b/src/angle/src/libGLESv2/libGLESv2.pro @@ -205,7 +205,6 @@ SOURCES += \ $$ANGLE_DIR/src/libANGLE/renderer/d3d/IndexBuffer.cpp \ $$ANGLE_DIR/src/libANGLE/renderer/d3d/IndexDataManager.cpp \ $$ANGLE_DIR/src/libANGLE/renderer/d3d/loadimage.cpp \ - $$ANGLE_DIR/src/libANGLE/renderer/d3d/loadimageSSE2.cpp \ $$ANGLE_DIR/src/libANGLE/renderer/d3d/ProgramD3D.cpp \ $$ANGLE_DIR/src/libANGLE/renderer/d3d/RenderbufferD3D.cpp \ $$ANGLE_DIR/src/libANGLE/renderer/d3d/RendererD3D.cpp \ @@ -227,6 +226,7 @@ SOURCES += \ $$ANGLE_DIR/src/libGLESv2/global_state.cpp \ $$ANGLE_DIR/src/libGLESv2/libGLESv2.cpp +SSE2_SOURCES += $$ANGLE_DIR/src/libANGLE/renderer/d3d/loadimageSSE2.cpp angle_d3d11 { HEADERS += \ From db226096424a89fd85d713379656dfc180fff2c6 Mon Sep 17 00:00:00 2001 From: Alexander Volkov Date: Tue, 5 Apr 2016 13:24:43 +0300 Subject: [PATCH 18/35] QListView: propagate the source of wheel events Change-Id: I3ff5dd1f7e02a8a6a0610d71707c26fd5ea74650 Reviewed-by: Gabriel de Dietrich --- src/widgets/itemviews/qlistview.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/widgets/itemviews/qlistview.cpp b/src/widgets/itemviews/qlistview.cpp index 7cba60cd813..814f0f49851 100644 --- a/src/widgets/itemviews/qlistview.cpp +++ b/src/widgets/itemviews/qlistview.cpp @@ -812,7 +812,7 @@ void QListView::wheelEvent(QWheelEvent *e) QPoint pixelDelta(e->pixelDelta().y(), e->pixelDelta().x()); QPoint angleDelta(e->angleDelta().y(), e->angleDelta().x()); QWheelEvent hwe(e->pos(), e->globalPos(), pixelDelta, angleDelta, e->delta(), - Qt::Horizontal, e->buttons(), e->modifiers(), e->phase()); + Qt::Horizontal, e->buttons(), e->modifiers(), e->phase(), e->source()); if (e->spontaneous()) qt_sendSpontaneousEvent(d->hbar, &hwe); else From 7bd08f4bfd31dfc1e2b9d9c5fff5cc4c79c03041 Mon Sep 17 00:00:00 2001 From: Giuseppe D'Angelo Date: Sat, 2 Apr 2016 20:45:20 +0200 Subject: [PATCH 19/35] QToolButton: always restart the menu popup timer The logic for activating a delayed popup menu on QToolButton is a bit cumbersome: when the button is pressed, a timer is started. This timer however doesn't get reset if the button is released before the timer expires. Instead, the function triggered by the timer checks if the button is pressed at that time. If so, the popup menu is shown. This logic allows the user to press-release a QToolButton many times and suddenly get a popup menu appear way before the expected timeout for the popup expired. That's because the first press started the timer, and then the button happened to be down when the timer expired. Instead, always *re*start the timer on a button press, and cancel the timer when the button is released. Change-Id: I3e0849264fdb6f670d018ebb5012eb15fa699cfb Task-number: QTBUG-48906 Reviewed-by: Friedemann Kleint Reviewed-by: Olivier Goffart (Woboq GmbH) Reviewed-by: Marc Mutz --- src/widgets/widgets/qtoolbutton.cpp | 9 ++++++++- src/widgets/widgets/qtoolbutton.h | 1 + 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/widgets/widgets/qtoolbutton.cpp b/src/widgets/widgets/qtoolbutton.cpp index f866fe8bdae..375eff7ae8d 100644 --- a/src/widgets/widgets/qtoolbutton.cpp +++ b/src/widgets/widgets/qtoolbutton.cpp @@ -62,6 +62,7 @@ public: void init(); #ifndef QT_NO_MENU void _q_buttonPressed(); + void _q_buttonReleased(); void popupTimerDone(); void _q_updateButtonDown(); void _q_menuTriggered(QAction *); @@ -211,6 +212,7 @@ void QToolButtonPrivate::init() #ifndef QT_NO_MENU QObject::connect(q, SIGNAL(pressed()), q, SLOT(_q_buttonPressed())); + QObject::connect(q, SIGNAL(released()), q, SLOT(_q_buttonReleased())); #endif setLayoutItemMargins(QStyle::SE_ToolButtonLayoutItem); @@ -698,12 +700,17 @@ void QToolButtonPrivate::_q_buttonPressed() return; // no menu to show if (popupMode == QToolButton::MenuButtonPopup) return; - else if (delay > 0 && !popupTimer.isActive() && popupMode == QToolButton::DelayedPopup) + else if (delay > 0 && popupMode == QToolButton::DelayedPopup) popupTimer.start(delay, q); else if (delay == 0 || popupMode == QToolButton::InstantPopup) q->showMenu(); } +void QToolButtonPrivate::_q_buttonReleased() +{ + popupTimer.stop(); +} + void QToolButtonPrivate::popupTimerDone() { Q_Q(QToolButton); diff --git a/src/widgets/widgets/qtoolbutton.h b/src/widgets/widgets/qtoolbutton.h index c76f58577b6..d17338454dc 100644 --- a/src/widgets/widgets/qtoolbutton.h +++ b/src/widgets/widgets/qtoolbutton.h @@ -119,6 +119,7 @@ private: Q_DECLARE_PRIVATE(QToolButton) #ifndef QT_NO_MENU Q_PRIVATE_SLOT(d_func(), void _q_buttonPressed()) + Q_PRIVATE_SLOT(d_func(), void _q_buttonReleased()) Q_PRIVATE_SLOT(d_func(), void _q_updateButtonDown()) Q_PRIVATE_SLOT(d_func(), void _q_menuTriggered(QAction*)) #endif From 58c23ae1619fb4afaae9c8eb2527c0906baef97b Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Wed, 6 Apr 2016 09:57:43 +0200 Subject: [PATCH 20/35] Windows QPA: Check QWindowsStaticOpenGLContext in nativeResourceForIntegration(). The instance of QWindowsStaticOpenGLContext has been observed to be 0. Task-number: QTBUG-52387 Change-Id: I1ca97c6df0d96e732ae62354e03f465cd461bcb4 Reviewed-by: Joerg Bornemann --- src/plugins/platforms/windows/qwindowsnativeinterface.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/plugins/platforms/windows/qwindowsnativeinterface.cpp b/src/plugins/platforms/windows/qwindowsnativeinterface.cpp index 659ef79c187..add6d6b1f0b 100644 --- a/src/plugins/platforms/windows/qwindowsnativeinterface.cpp +++ b/src/plugins/platforms/windows/qwindowsnativeinterface.cpp @@ -138,8 +138,10 @@ void *QWindowsNativeInterface::nativeResourceForIntegration(const QByteArray &re #ifdef QT_NO_OPENGL Q_UNUSED(resource) #else - if (resourceType(resource) == GlHandleType) - return QWindowsIntegration::staticOpenGLContext()->moduleHandle(); + if (resourceType(resource) == GlHandleType) { + if (const QWindowsStaticOpenGLContext *sc = QWindowsIntegration::staticOpenGLContext()) + return sc->moduleHandle(); + } #endif return 0; From 6c54e10144e7af02f4c35e20e5f375a0cf280b8b Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Tue, 8 Mar 2016 11:07:53 +0100 Subject: [PATCH 21/35] Qt Meta macros: Allow tools to define annotations MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This might be useful for IDE or other tools to be made aware of Qt macros. This is inspired to what QtCreator[1] and moc-ng[2] does. But they are forced to redefine or inject code at precise location which might be difficult. This is going to make it easier to use libclang in qdoc. With this change, the tooling can just predefine the macro QT_ANNOTATE_FUNCTION and QT_ANNOTATE_CLASS to get what they need. Example with libclang: "-DQT_ANNOTATE_CLASS(type,...)=static_assert(sizeof(#__VA_ARGS__),#type);" "-DQT_ANNOTATE_CLASS2(type,a1,a2)=static_assert(sizeof(#a1,#a2),#type);" "-DQT_ANNOTATE_FUNCTION(a)=__attribute__((annotate(#a)))" "-DQT_ANNOTATE_ACCESS_SPECIFIER(a)=__attribute__((annotate(#a)))" "-DQ_CLASSINFO(name,value)=static_assert(sizeof(name,value),\"qt_classinfo\");" "-DQ_REVISION(v)=__attribute__((annotate(\"qt_revision:\" QT_STRINGIFY2(v))))" [1] qt-creator/cplusplus/wrappedQtHeaders/QtCore/qobjectdefs.h [2] https://code.woboq.org/mocng/src/qobjectdefs-injected.h.html Change-Id: I88fcb28f1dbb3d26ea82f10e9948e68a18c795e9 Reviewed-by: Nikolai Kosjar Reviewed-by: Kevin Funk Reviewed-by: Milian Wolff Reviewed-by: Thiago Macieira Reviewed-by: Jędrzej Nowacki --- src/corelib/global/qglobal.h | 2 - src/corelib/kernel/qobjectdefs.h | 77 +++++++++++++++++++++----------- 2 files changed, 52 insertions(+), 27 deletions(-) diff --git a/src/corelib/global/qglobal.h b/src/corelib/global/qglobal.h index 2551dcb5d3f..98c9902674f 100644 --- a/src/corelib/global/qglobal.h +++ b/src/corelib/global/qglobal.h @@ -1050,8 +1050,6 @@ Q_CORE_EXPORT QString qtTrId(const char *id, int n = -1); #endif // QT_NO_TRANSLATION -#define QDOC_PROPERTY(text) - /* When RTTI is not available, define this macro to force any uses of dynamic_cast to cause a compile failure. diff --git a/src/corelib/kernel/qobjectdefs.h b/src/corelib/kernel/qobjectdefs.h index 2e9ed4fb5fb..8d32795af26 100644 --- a/src/corelib/kernel/qobjectdefs.h +++ b/src/corelib/kernel/qobjectdefs.h @@ -55,6 +55,25 @@ class QString; #define Q_MOC_OUTPUT_REVISION 67 #endif +// The following macros can be defined by tools that understand Qt +// to have the information from the macro. +#ifndef QT_ANNOTATE_CLASS +# ifndef Q_COMPILER_VARIADIC_MACROS +# define QT_ANNOTATE_CLASS(type, x) +# else +# define QT_ANNOTATE_CLASS(type, ...) +# endif +#endif +#ifndef QT_ANNOTATE_CLASS2 +# define QT_ANNOTATE_CLASS2(type, a1, a2) +#endif +#ifndef QT_ANNOTATE_FUNCTION +# define QT_ANNOTATE_FUNCTION(x) +#endif +#ifndef QT_ANNOTATE_ACCESS_SPECIFIER +# define QT_ANNOTATE_ACCESS_SPECIFIER(x) +#endif + // The following macros are our "extensions" to C++ // They are used, strictly speaking, only by the moc. @@ -64,38 +83,44 @@ class QString; # define QT_NO_EMIT # else # ifndef QT_NO_SIGNALS_SLOTS_KEYWORDS -# define slots -# define signals public +# define slots Q_SLOTS +# define signals Q_SIGNALS # endif # endif -# define Q_SLOTS -# define Q_SIGNALS public -# define Q_PRIVATE_SLOT(d, signature) +# define Q_SLOTS QT_ANNOTATE_ACCESS_SPECIFIER(qt_slot) +# define Q_SIGNALS public QT_ANNOTATE_ACCESS_SPECIFIER(qt_signal) +# define Q_PRIVATE_SLOT(d, signature) QT_ANNOTATE_CLASS2(qt_private_slot, d, signature) # define Q_EMIT #ifndef QT_NO_EMIT # define emit #endif -#define Q_CLASSINFO(name, value) -#define Q_PLUGIN_METADATA(x) -#define Q_INTERFACES(x) -#ifdef Q_COMPILER_VARIADIC_MACROS -#define Q_PROPERTY(...) -#else -#define Q_PROPERTY(text) +#ifndef Q_CLASSINFO +# define Q_CLASSINFO(name, value) #endif -#define Q_PRIVATE_PROPERTY(d, text) -#define Q_REVISION(v) -#define Q_OVERRIDE(text) -#define Q_ENUMS(x) -#define Q_FLAGS(x) -#define Q_ENUM(ENUM) \ +#define Q_PLUGIN_METADATA(x) QT_ANNOTATE_CLASS(qt_plugin_metadata, x) +#define Q_INTERFACES(x) QT_ANNOTATE_CLASS(qt_interfaces, x) +#ifdef Q_COMPILER_VARIADIC_MACROS +# define Q_PROPERTY(...) QT_ANNOTATE_CLASS(qt_property, __VA_ARGS__) +#else +# define Q_PROPERTY(text) QT_ANNOTATE_CLASS(qt_property, text) +#endif +#define Q_PRIVATE_PROPERTY(d, text) QT_ANNOTATE_CLASS2(qt_private_property, d, text) +#ifndef Q_REVISION +# define Q_REVISION(v) +#endif +#define Q_OVERRIDE(text) QT_ANNOTATE_CLASS(qt_override, text) +#define QDOC_PROPERTY(text) QT_ANNOTATE_CLASS(qt_qdoc_property, text) +#define Q_ENUMS(x) QT_ANNOTATE_CLASS(qt_enums, x) +#define Q_FLAGS(x) QT_ANNOTATE_CLASS(qt_enums, x) +#define Q_ENUM_IMPL(ENUM) \ friend Q_DECL_CONSTEXPR const QMetaObject *qt_getEnumMetaObject(ENUM) Q_DECL_NOEXCEPT { return &staticMetaObject; } \ friend Q_DECL_CONSTEXPR const char *qt_getEnumName(ENUM) Q_DECL_NOEXCEPT { return #ENUM; } -#define Q_FLAG(ENUM) Q_ENUM(ENUM) -#define Q_SCRIPTABLE -#define Q_INVOKABLE -#define Q_SIGNAL -#define Q_SLOT +#define Q_ENUM(x) Q_ENUMS(x) Q_ENUM_IMPL(x) +#define Q_FLAG(x) Q_FLAGS(x) Q_ENUM_IMPL(x) +#define Q_SCRIPTABLE QT_ANNOTATE_FUNCTION(qt_scriptable) +#define Q_INVOKABLE QT_ANNOTATE_FUNCTION(qt_invokable) +#define Q_SIGNAL QT_ANNOTATE_FUNCTION(qt_signal) +#define Q_SLOT QT_ANNOTATE_FUNCTION(qt_slot) #endif // QT_NO_META_MACROS #ifndef QT_NO_TRANSLATION @@ -173,10 +198,11 @@ private: \ Q_OBJECT_NO_ATTRIBUTES_WARNING \ Q_DECL_HIDDEN_STATIC_METACALL static void qt_static_metacall(QObject *, QMetaObject::Call, int, void **); \ QT_WARNING_POP \ - struct QPrivateSignal {}; + struct QPrivateSignal {}; \ + QT_ANNOTATE_CLASS(qt_qobject, "") /* qmake ignore Q_OBJECT */ -#define Q_OBJECT_FAKE Q_OBJECT +#define Q_OBJECT_FAKE Q_OBJECT QT_ANNOTATE_CLASS(qt_fake, "") #ifndef QT_NO_META_MACROS /* qmake ignore Q_GADGET */ @@ -190,6 +216,7 @@ private: \ Q_OBJECT_NO_ATTRIBUTES_WARNING \ Q_DECL_HIDDEN_STATIC_METACALL static void qt_static_metacall(QObject *, QMetaObject::Call, int, void **); \ QT_WARNING_POP \ + QT_ANNOTATE_CLASS(qt_qgadget, "") \ /*end*/ #endif // QT_NO_META_MACROS From 181e861625e9e7f4d617551aa1d4cec4a5bcd05c Mon Sep 17 00:00:00 2001 From: Joerg Bornemann Date: Wed, 6 Apr 2016 16:31:22 +0200 Subject: [PATCH 22/35] Remove superfluous includes from qlocalsocket_win.cpp Change-Id: I4f641966af3443d0c487df95d2e565182a945bf3 Reviewed-by: Friedemann Kleint --- src/network/socket/qlocalsocket_win.cpp | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/network/socket/qlocalsocket_win.cpp b/src/network/socket/qlocalsocket_win.cpp index d477de9c47d..4507c988351 100644 --- a/src/network/socket/qlocalsocket_win.cpp +++ b/src/network/socket/qlocalsocket_win.cpp @@ -33,10 +33,6 @@ #include "qlocalsocket_p.h" -#include -#include -#include - QT_BEGIN_NAMESPACE void QLocalSocketPrivate::init() From 2050e32b5f232317593f68916b31ced64e79183d Mon Sep 17 00:00:00 2001 From: Joerg Bornemann Date: Tue, 5 Apr 2016 15:29:49 +0200 Subject: [PATCH 23/35] Fix abuse of assignment-in-conditional (and the resulting warning) Change-Id: I2025e3360151c76982c45764cbee332855409dd0 Reviewed-by: Oswald Buddenhagen --- qmake/generators/win32/msvc_vcproj.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/qmake/generators/win32/msvc_vcproj.cpp b/qmake/generators/win32/msvc_vcproj.cpp index 6206b2c8f1e..1d4f722e51e 100644 --- a/qmake/generators/win32/msvc_vcproj.cpp +++ b/qmake/generators/win32/msvc_vcproj.cpp @@ -1318,8 +1318,8 @@ void VcprojGenerator::initDeploymentTool() + "|0;"; if (!qpaPluginDeployed) { QChar debugInfixChar; - bool foundGuid = false; - if (foundGuid = dllName.contains(QLatin1String("Guid"))) + bool foundGuid = dllName.contains(QLatin1String("Guid")); + if (foundGuid) debugInfixChar = QLatin1Char('d'); if (foundGuid || dllName.contains(QLatin1String("Gui"))) { From 6fae048af52622db99221a98fd721b59a1bca260 Mon Sep 17 00:00:00 2001 From: hjk Date: Wed, 6 Apr 2016 08:45:51 +0200 Subject: [PATCH 24/35] Add some QChar::unicode() calls to brush over deprecation warning Change-Id: I16383254373289584818cd2b590d51d9e4a649c5 Reviewed-by: Marc Mutz --- src/widgets/widgets/qwidgetlinecontrol.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/widgets/widgets/qwidgetlinecontrol.cpp b/src/widgets/widgets/qwidgetlinecontrol.cpp index 0ff55f7c375..9097ad01a86 100644 --- a/src/widgets/widgets/qwidgetlinecontrol.cpp +++ b/src/widgets/widgets/qwidgetlinecontrol.cpp @@ -112,7 +112,7 @@ void QWidgetLineControl::updateDisplayText(bool forceUpdate) // characters) QChar* uc = str.data(); for (int i = 0; i < (int)str.length(); ++i) { - if ((uc[i] < 0x20 && uc[i] != 0x09) + if ((uc[i].unicode() < 0x20 && uc[i].unicode() != 0x09) || uc[i] == QChar::LineSeparator || uc[i] == QChar::ParagraphSeparator || uc[i] == QChar::ObjectReplacementCharacter) From 6a7f5dab0d6e86950f87123c69724018aa140770 Mon Sep 17 00:00:00 2001 From: Edward Welbourne Date: Mon, 18 Jan 2016 13:03:49 +0100 Subject: [PATCH 25/35] Explain QTimeZonePrivate::isValidId a bit more carefully. Its "rules" are actually guidelines, its suggested regex was wrong, its actual implementation was fuzzier than its documentation suggested and the exception it tacitly permitted should be distinguished from the stricter rules it otherwise appears to implement. There was also a redundant check ('-' had been handled earlier in the chained if). Explain why the situation is tricky, fix the regex mentioned (making it more readable, too) and note what might be worth doing a little more fussily, without actually changing code behavior. Change-Id: I93fa0da0640a134e5d84011b435a186576824063 Reviewed-by: Marc Mutz --- src/corelib/tools/qtimezoneprivate.cpp | 53 ++++++++++++++++++-------- 1 file changed, 38 insertions(+), 15 deletions(-) diff --git a/src/corelib/tools/qtimezoneprivate.cpp b/src/corelib/tools/qtimezoneprivate.cpp index ab8332aea35..be53a075919 100644 --- a/src/corelib/tools/qtimezoneprivate.cpp +++ b/src/corelib/tools/qtimezoneprivate.cpp @@ -441,22 +441,45 @@ QTimeZone::OffsetData QTimeZonePrivate::toOffsetData(const QTimeZonePrivate::Dat return offsetData; } -// If the format of the ID is valid +// Is the format of the ID valid ? bool QTimeZonePrivate::isValidId(const QByteArray &ianaId) { - // Rules for defining TZ/IANA names as per ftp://ftp.iana.org/tz/code/Theory - // 1. Use only valid POSIX file name components - // 2. Within a file name component, use only ASCII letters, `.', `-' and `_'. - // 3. Do not use digits - // 4. A file name component must not exceed 14 characters or start with `-' - // Aliases such as "Etc/GMT+7" and "SystemV/EST5EDT" are valid so we need to accept digits, ':', and '+'. + /* + Main rules for defining TZ/IANA names as per ftp://ftp.iana.org/tz/code/Theory + 1. Use only valid POSIX file name components + 2. Within a file name component, use only ASCII letters, `.', `-' and `_'. + 3. Do not use digits (except in a [+-]\d+ suffix, when used). + 4. A file name component must not exceed 14 characters or start with `-' + However, the rules are really guidelines - a later one says + - Do not change established names if they only marginally violate the + above rules. + We may, therefore, need to be a bit slack in our check here, if we hit + legitimate exceptions in real time-zone databases. - // The following would be preferable if QRegExp would work on QByteArrays directly: - // const QRegExp rx(QStringLiteral("[a-z0-9:+._][a-z0-9:+._-]{,13}(?:/[a-z0-9:+._][a-z0-9:+._-]{,13})*"), - // Qt::CaseInsensitive); - // return rx.exactMatch(ianaId); + In particular, aliases such as "Etc/GMT+7" and "SystemV/EST5EDT" are valid + so we need to accept digits, ':', and '+'; aliases typically have the form + of POSIX TZ strings, which allow a suffix to a proper IANA name. A POSIX + suffix starts with an offset (as in GMT+7) and may continue with another + name (as in EST5EDT, giving the DST name of the zone); a further offset is + allowed (for DST). The ("hard to describe and [...] error-prone in + practice") POSIX form even allows a suffix giving the dates (and + optionally times) of the annual DST transitions. Hopefully, no TZ aliases + go that far, but we at least need to accept an offset and (single + fragment) DST-name. - // hand-rolled version: + But for the legacy complications, the following would be preferable if + QRegExp would work on QByteArrays directly: + const QRegExp rx(QStringLiteral("[a-z+._][a-z+._-]{,13}" + "(?:/[a-z+._][a-z+._-]{,13})*" + // Optional suffix: + "(?:[+-]?\d{1,2}(?::\d{1,2}){,2}" // offset + // one name fragment (DST): + "(?:[a-z+._][a-z+._-]{,13})?)"), + Qt::CaseInsensitive); + return rx.exactMatch(ianaId); + */ + + // Somewhat slack hand-rolled version: const int MinSectionLength = 1; const int MaxSectionLength = 14; int sectionLength = 0; @@ -472,11 +495,11 @@ bool QTimeZonePrivate::isValidId(const QByteArray &ianaId) } else if (!(ch >= 'a' && ch <= 'z') && !(ch >= 'A' && ch <= 'Z') && !(ch == '_') + && !(ch == '.') + // Should ideally check these only happen as an offset: && !(ch >= '0' && ch <= '9') - && !(ch == '-') && !(ch == '+') - && !(ch == ':') - && !(ch == '.')) { + && !(ch == ':')) { return false; // violates (2) } } From c7ec317822258e652e74af4449b1237a4755688f Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Wed, 6 Apr 2016 13:22:57 +0200 Subject: [PATCH 26/35] Direct2D QPA: Fix build with clang-cl. Remove overzealous constexpr triggering errors like: in file included from .\qwindowsdirect2dpaintengine.cpp:44: ./qwindowsdirect2dhelpers.h(58,37) : error: constexpr function never produces a constant expression [-Winvalid-constexpr] Q_DECL_CONSTEXPR inline D2D1_RECT_F to_d2d_rect_f(const QRectF &qrect) ^ ./qwindowsdirect2dhelpers.h(60,12) : note: non-constexpr function 'RectF' cannot be used in a constant expression return D2D1::RectF(qrect.x(), qrect.y(), qrect.x() + qrect.width(), qrect.y() + qrect.height()); ^ C:\Program Files (x86)\Windows Kits\10\include\10.0.10586.0\um\d2d1helper.h(160,5) : note: declared here RectF( ^ Task-number: QTBUG-50860 Change-Id: I0bb4d17b7a7db69c5cc7e286ef0b8ff104f72b2e Reviewed-by: Joerg Bornemann --- .../platforms/direct2d/qwindowsdirect2dhelpers.h | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/plugins/platforms/direct2d/qwindowsdirect2dhelpers.h b/src/plugins/platforms/direct2d/qwindowsdirect2dhelpers.h index 08886854ee2..228c60aaf60 100644 --- a/src/plugins/platforms/direct2d/qwindowsdirect2dhelpers.h +++ b/src/plugins/platforms/direct2d/qwindowsdirect2dhelpers.h @@ -44,37 +44,37 @@ QT_BEGIN_NAMESPACE -Q_DECL_CONSTEXPR inline D2D1_RECT_U to_d2d_rect_u(const QRect &qrect) +inline D2D1_RECT_U to_d2d_rect_u(const QRect &qrect) { return D2D1::RectU(qrect.x(), qrect.y(), qrect.x() + qrect.width(), qrect.y() + qrect.height()); } -Q_DECL_CONSTEXPR inline D2D1_RECT_F to_d2d_rect_f(const QRectF &qrect) +inline D2D1_RECT_F to_d2d_rect_f(const QRectF &qrect) { return D2D1::RectF(qrect.x(), qrect.y(), qrect.x() + qrect.width(), qrect.y() + qrect.height()); } -Q_DECL_CONSTEXPR inline D2D1_SIZE_U to_d2d_size_u(const QSizeF &qsize) +inline D2D1_SIZE_U to_d2d_size_u(const QSizeF &qsize) { return D2D1::SizeU(qsize.width(), qsize.height()); } -Q_DECL_CONSTEXPR inline D2D1_SIZE_U to_d2d_size_u(const QSize &qsize) +inline D2D1_SIZE_U to_d2d_size_u(const QSize &qsize) { return D2D1::SizeU(qsize.width(), qsize.height()); } -Q_DECL_CONSTEXPR inline D2D1_POINT_2F to_d2d_point_2f(const QPointF &qpoint) +inline D2D1_POINT_2F to_d2d_point_2f(const QPointF &qpoint) { return D2D1::Point2F(qpoint.x(), qpoint.y()); } -Q_DECL_CONSTEXPR inline D2D1::ColorF to_d2d_color_f(const QColor &c) +inline D2D1::ColorF to_d2d_color_f(const QColor &c) { return D2D1::ColorF(c.redF(), c.greenF(), c.blueF(), c.alphaF()); } -Q_DECL_CONSTEXPR inline D2D1_MATRIX_3X2_F to_d2d_matrix_3x2_f(const QTransform &transform) +inline D2D1_MATRIX_3X2_F to_d2d_matrix_3x2_f(const QTransform &transform) { return D2D1::Matrix3x2F(transform.m11(), transform.m12(), transform.m21(), transform.m22(), From dd9cf15005313f0da378641f2f4191dc58e0d993 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Tue, 5 Apr 2016 16:27:43 +0200 Subject: [PATCH 27/35] QtXml/htmlnfo example: Remove Nokia-related HTML demo file. Change-Id: I0b0ebcf20747a607ad9eed130d7b4fe810a1f2e1 Reviewed-by: Mitch Curtis --- examples/xml/htmlinfo/nokia_com.html | 215 --------------------------- examples/xml/htmlinfo/resources.qrc | 1 - 2 files changed, 216 deletions(-) delete mode 100644 examples/xml/htmlinfo/nokia_com.html diff --git a/examples/xml/htmlinfo/nokia_com.html b/examples/xml/htmlinfo/nokia_com.html deleted file mode 100644 index 46d4c95ee64..00000000000 --- a/examples/xml/htmlinfo/nokia_com.html +++ /dev/null @@ -1,215 +0,0 @@ - - - - - - - - - - Nokia - Nokia on the Web - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - -
-
- Nokia - Connecting people - -
- -
- - -
-

Welcome to Nokia

-
-

Where would you like to go?

- -
- -
- - - -
- - -
- - - - - - - - - - - - - -
- - - - - diff --git a/examples/xml/htmlinfo/resources.qrc b/examples/xml/htmlinfo/resources.qrc index a8cf88d57b7..f427d9db100 100644 --- a/examples/xml/htmlinfo/resources.qrc +++ b/examples/xml/htmlinfo/resources.qrc @@ -1,7 +1,6 @@ apache_org.html - nokia_com.html simpleexample.html trolltech_com.html w3c_org.html From 2a282551ac7735538d9627537941c58de266f2c4 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Tue, 5 Apr 2016 16:23:50 +0200 Subject: [PATCH 28/35] Remove empty first lines of files. They might upset licensing related tools. Change-Id: I858d21fc418ba16959c88847b559b11bea29ed6b Reviewed-by: Oswald Buddenhagen --- examples/widgets/gestures/imagegestures/imagewidget.cpp | 1 - src/corelib/tools/qhash.cpp | 1 - src/tools/qlalr/recognizer.cpp | 1 - src/tools/qlalr/recognizer.h | 1 - .../qgraphicslinearlayout/tst_qgraphicslinearlayout.cpp | 1 - 5 files changed, 5 deletions(-) diff --git a/examples/widgets/gestures/imagegestures/imagewidget.cpp b/examples/widgets/gestures/imagegestures/imagewidget.cpp index 28c715c688c..81ec33a1d01 100644 --- a/examples/widgets/gestures/imagegestures/imagewidget.cpp +++ b/examples/widgets/gestures/imagegestures/imagewidget.cpp @@ -1,4 +1,3 @@ - /**************************************************************************** ** ** Copyright (C) 2015 The Qt Company Ltd. diff --git a/src/corelib/tools/qhash.cpp b/src/corelib/tools/qhash.cpp index ac9e08de8bd..d40570d347e 100644 --- a/src/corelib/tools/qhash.cpp +++ b/src/corelib/tools/qhash.cpp @@ -1,4 +1,3 @@ - /**************************************************************************** ** ** Copyright (C) 2015 The Qt Company Ltd. diff --git a/src/tools/qlalr/recognizer.cpp b/src/tools/qlalr/recognizer.cpp index 14b92dd434e..ec1f6d5dd77 100644 --- a/src/tools/qlalr/recognizer.cpp +++ b/src/tools/qlalr/recognizer.cpp @@ -1,4 +1,3 @@ - /**************************************************************************** ** ** Copyright (C) 2015 The Qt Company Ltd. diff --git a/src/tools/qlalr/recognizer.h b/src/tools/qlalr/recognizer.h index 3676e20ca34..499b415d17a 100644 --- a/src/tools/qlalr/recognizer.h +++ b/src/tools/qlalr/recognizer.h @@ -1,4 +1,3 @@ - /**************************************************************************** ** ** Copyright (C) 2015 The Qt Company Ltd. diff --git a/tests/auto/widgets/graphicsview/qgraphicslinearlayout/tst_qgraphicslinearlayout.cpp b/tests/auto/widgets/graphicsview/qgraphicslinearlayout/tst_qgraphicslinearlayout.cpp index 8bebd4edddf..7b2b301b80e 100644 --- a/tests/auto/widgets/graphicsview/qgraphicslinearlayout/tst_qgraphicslinearlayout.cpp +++ b/tests/auto/widgets/graphicsview/qgraphicslinearlayout/tst_qgraphicslinearlayout.cpp @@ -1,4 +1,3 @@ - /**************************************************************************** ** ** Copyright (C) 2015 The Qt Company Ltd. From e4e62496ac62deab0e8f6ae9f064cf153b31d2fa Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Fri, 1 Apr 2016 15:31:16 +0200 Subject: [PATCH 29/35] Windows QPA: Scale hotspot of custom cursors correctly. Separate factors in QWindowsCursor::createPixmapCursor() and apply factor to the hotspot. Task-number: QTBUG-52276 Change-Id: Ia5a5db39ddc2bc4215a23ff8625431af9b4a76d8 Reviewed-by: Adam Light Reviewed-by: Oliver Wolff --- src/plugins/platforms/windows/qwindowscursor.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/plugins/platforms/windows/qwindowscursor.cpp b/src/plugins/platforms/windows/qwindowscursor.cpp index cda741c2261..844fe235170 100644 --- a/src/plugins/platforms/windows/qwindowscursor.cpp +++ b/src/plugins/platforms/windows/qwindowscursor.cpp @@ -97,9 +97,9 @@ QWindowsPixmapCursorCacheKey::QWindowsPixmapCursorCacheKey(const QCursor &c) HCURSOR QWindowsCursor::createPixmapCursor(QPixmap pixmap, const QPoint &hotSpot, qreal scaleFactor) { HCURSOR cur = 0; - scaleFactor /= pixmap.devicePixelRatioF(); - if (!qFuzzyCompare(scaleFactor, 1)) { - pixmap = pixmap.scaled((scaleFactor * QSizeF(pixmap.size())).toSize(), + const qreal pixmapScaleFactor = scaleFactor / pixmap.devicePixelRatioF(); + if (!qFuzzyCompare(pixmapScaleFactor, 1)) { + pixmap = pixmap.scaled((pixmapScaleFactor * QSizeF(pixmap.size())).toSize(), Qt::KeepAspectRatio, Qt::SmoothTransformation); } QBitmap mask = pixmap.mask(); @@ -113,8 +113,8 @@ HCURSOR QWindowsCursor::createPixmapCursor(QPixmap pixmap, const QPoint &hotSpot ICONINFO ii; ii.fIcon = 0; - ii.xHotspot = DWORD(hotSpot.x()); - ii.yHotspot = DWORD(hotSpot.y()); + ii.xHotspot = DWORD(qRound(hotSpot.x() * scaleFactor)); + ii.yHotspot = DWORD(qRound(hotSpot.y() * scaleFactor)); ii.hbmMask = im; ii.hbmColor = ic; From 1e69d4e3ac4263776ae13095dec213b24c51e22f Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Wed, 6 Apr 2016 09:41:54 +0200 Subject: [PATCH 30/35] Refactor QWindowsXPStylePrivate::drawBackground() and helpers. Pass the DC obtained drawBackground() to drawBackgroundDirectly(), saving a call to hdcForWidgetBackingStore() to find it. Pass the error code from the Win32 API DrawThemeBackground() to the calling functions. Change-Id: I1c25241f53d87e4429ad924f7b2e29da215d7e4f Reviewed-by: Oliver Wolff --- src/widgets/styles/qwindowsxpstyle.cpp | 14 ++++++-------- src/widgets/styles/qwindowsxpstyle_p_p.h | 2 +- 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/src/widgets/styles/qwindowsxpstyle.cpp b/src/widgets/styles/qwindowsxpstyle.cpp index 88b1b41f151..2c98ebb740a 100644 --- a/src/widgets/styles/qwindowsxpstyle.cpp +++ b/src/widgets/styles/qwindowsxpstyle.cpp @@ -774,7 +774,7 @@ bool QWindowsXPStylePrivate::drawBackground(XPThemeData &themeData) const HDC dc = canDrawDirectly ? hdcForWidgetBackingStore(themeData.widget) : HDC(0); const bool result = dc - ? drawBackgroundDirectly(themeData, qRound(aditionalDevicePixelRatio)) + ? drawBackgroundDirectly(dc, themeData, qRound(aditionalDevicePixelRatio)) : drawBackgroundThruNativeBuffer(themeData, qRound(aditionalDevicePixelRatio)); painter->restore(); return result; @@ -804,12 +804,9 @@ 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(XPThemeData &themeData, int additionalDevicePixelRatio) +bool QWindowsXPStylePrivate::drawBackgroundDirectly(HDC dc, XPThemeData &themeData, int additionalDevicePixelRatio) { QPainter *painter = themeData.painter; - HDC dc = 0; - if (themeData.widget) - dc = hdcForWidgetBackingStore(themeData.widget); QPoint redirectionDelta(int(painter->deviceMatrix().dx()), int(painter->deviceMatrix().dy())); @@ -841,8 +838,9 @@ bool QWindowsXPStylePrivate::drawBackgroundDirectly(XPThemeData &themeData, int | (themeData.noContent ? DTBG_OMITCONTENT : 0) | (themeData.mirrorHorizontally ? DTBG_MIRRORDC : 0); + HRESULT result = S_FALSE; if (pDrawThemeBackgroundEx != 0) { - pDrawThemeBackgroundEx(themeData.handle(), dc, themeData.partId, themeData.stateId, &(drawRECT), &drawOptions); + result = pDrawThemeBackgroundEx(themeData.handle(), dc, themeData.partId, themeData.stateId, &(drawRECT), &drawOptions); } else { // We are running on a system where the uxtheme.dll does not have // the DrawThemeBackgroundEx function, so we need to clip away @@ -876,11 +874,11 @@ bool QWindowsXPStylePrivate::drawBackgroundDirectly(XPThemeData &themeData, int } } - pDrawThemeBackground(themeData.handle(), dc, themeData.partId, themeData.stateId, &(drawRECT), &(drawOptions.rcClip)); + result = pDrawThemeBackground(themeData.handle(), dc, themeData.partId, themeData.stateId, &(drawRECT), &(drawOptions.rcClip)); } SelectClipRgn(dc, 0); DeleteObject(hrgn); - return true; + return SUCCEEDED(result); } /*! \internal diff --git a/src/widgets/styles/qwindowsxpstyle_p_p.h b/src/widgets/styles/qwindowsxpstyle_p_p.h index 240a338c3fe..d75c064369b 100644 --- a/src/widgets/styles/qwindowsxpstyle_p_p.h +++ b/src/widgets/styles/qwindowsxpstyle_p_p.h @@ -388,7 +388,7 @@ public: void setTransparency(QWidget *widget, XPThemeData &themeData); bool drawBackground(XPThemeData &themeData); bool drawBackgroundThruNativeBuffer(XPThemeData &themeData, int aditionalDevicePixelRatio); - bool drawBackgroundDirectly(XPThemeData &themeData, int aditionalDevicePixelRatio); + bool drawBackgroundDirectly(HDC dc, XPThemeData &themeData, int aditionalDevicePixelRatio); bool hasAlphaChannel(const QRect &rect); bool fixAlphaChannel(const QRect &rect); From 5f8bd44adaab322a7564855a089edf7b3247ad1b Mon Sep 17 00:00:00 2001 From: Gabriel de Dietrich Date: Tue, 5 Apr 2016 18:03:38 -0700 Subject: [PATCH 31/35] Avoid unnecessary allocation in QClipData::setClipRegion() Change-Id: I1280a496478ec6839ac432ffd63ecea28dbb972a Reviewed-by: Marc Mutz --- src/gui/painting/qpaintengine_raster.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gui/painting/qpaintengine_raster.cpp b/src/gui/painting/qpaintengine_raster.cpp index f70bef72d84..278d7bb99ef 100644 --- a/src/gui/painting/qpaintengine_raster.cpp +++ b/src/gui/painting/qpaintengine_raster.cpp @@ -3887,7 +3887,7 @@ void QClipData::setClipRect(const QRect &rect) void QClipData::setClipRegion(const QRegion ®ion) { if (region.rectCount() == 1) { - setClipRect(region.rects().at(0)); + setClipRect(region.boundingRect()); return; } From aee197da01b6fd6b5bd56e203388c60ca64ed6a6 Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Wed, 6 Apr 2016 12:11:40 +0200 Subject: [PATCH 32/35] QStringRef: fix some QStringRef <> const char * relational operators Their implementations were swapped. Found while extending tst_qstringapisymmetry, which only exists in dev, so test will be added to dev once this change has merged up. [ChangeLog][QtCore][QStringRef] Fixed relational operators against (const char*) to return the correct result. Change-Id: I3f331037571b9a543a6885802836b768143d1c1a Reviewed-by: Konstantin Ritt --- src/corelib/tools/qstring.h | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/corelib/tools/qstring.h b/src/corelib/tools/qstring.h index 1fbcff35d1a..886973fe10a 100644 --- a/src/corelib/tools/qstring.h +++ b/src/corelib/tools/qstring.h @@ -1535,9 +1535,9 @@ inline QT_ASCII_CAST_WARN bool QStringRef::operator!=(const char *s) const inline QT_ASCII_CAST_WARN bool QStringRef::operator<(const char *s) const { return QString::compare_helper(constData(), size(), s, -1) < 0; } inline QT_ASCII_CAST_WARN bool QStringRef::operator<=(const char *s) const -{ return QString::compare_helper(constData(), size(), s, -1) > 0; } -inline QT_ASCII_CAST_WARN bool QStringRef::operator>(const char *s) const { return QString::compare_helper(constData(), size(), s, -1) <= 0; } +inline QT_ASCII_CAST_WARN bool QStringRef::operator>(const char *s) const +{ return QString::compare_helper(constData(), size(), s, -1) > 0; } inline QT_ASCII_CAST_WARN bool QStringRef::operator>=(const char *s) const { return QString::compare_helper(constData(), size(), s, -1) >= 0; } @@ -1546,13 +1546,13 @@ inline QT_ASCII_CAST_WARN bool operator==(const char *s1, const QStringRef &s2) inline QT_ASCII_CAST_WARN bool operator!=(const char *s1, const QStringRef &s2) { return QString::compare_helper(s2.constData(), s2.size(), s1, -1) != 0; } inline QT_ASCII_CAST_WARN bool operator<(const char *s1, const QStringRef &s2) -{ return QString::compare_helper(s2.constData(), s2.size(), s1, -1) < 0; } -inline QT_ASCII_CAST_WARN bool operator<=(const char *s1, const QStringRef &s2) { return QString::compare_helper(s2.constData(), s2.size(), s1, -1) > 0; } -inline QT_ASCII_CAST_WARN bool operator>(const char *s1, const QStringRef &s2) -{ return QString::compare_helper(s2.constData(), s2.size(), s1, -1) <= 0; } -inline QT_ASCII_CAST_WARN bool operator>=(const char *s1, const QStringRef &s2) +inline QT_ASCII_CAST_WARN bool operator<=(const char *s1, const QStringRef &s2) { return QString::compare_helper(s2.constData(), s2.size(), s1, -1) >= 0; } +inline QT_ASCII_CAST_WARN bool operator>(const char *s1, const QStringRef &s2) +{ return QString::compare_helper(s2.constData(), s2.size(), s1, -1) < 0; } +inline QT_ASCII_CAST_WARN bool operator>=(const char *s1, const QStringRef &s2) +{ return QString::compare_helper(s2.constData(), s2.size(), s1, -1) <= 0; } #endif // !defined(QT_NO_CAST_FROM_ASCII) && !defined(QT_RESTRICTED_CAST_FROM_ASCII) inline int QString::compare(const QStringRef &s, Qt::CaseSensitivity cs) const From 140a273b3c01e8eb3664f14410539339454527d8 Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Tue, 5 Apr 2016 17:00:44 +0200 Subject: [PATCH 33/35] QFontDialog: re-enable X close button in window decoration Change-Id: Id8d9dab7a0e4cf22abefd9bdc7bf2fd4cba1f445 Task-number: QTBUG-32240 Reviewed-by: Friedemann Kleint --- src/widgets/dialogs/qfontdialog.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/widgets/dialogs/qfontdialog.cpp b/src/widgets/dialogs/qfontdialog.cpp index d0177941f7e..6644f26ad0d 100644 --- a/src/widgets/dialogs/qfontdialog.cpp +++ b/src/widgets/dialogs/qfontdialog.cpp @@ -100,7 +100,7 @@ QFontListView::QFontListView(QWidget *parent) } static const Qt::WindowFlags DefaultWindowFlags = - Qt::Dialog | Qt::WindowSystemMenuHint; + Qt::Dialog | Qt::WindowSystemMenuHint | Qt::WindowCloseButtonHint; QFontDialogPrivate::QFontDialogPrivate() : writingSystem(QFontDatabase::Any), From 3ddb2c325e832afc7deef7a48c130408130f0d9e Mon Sep 17 00:00:00 2001 From: Jake Petroules Date: Tue, 5 Apr 2016 16:52:11 -0700 Subject: [PATCH 34/35] Fix QPrinter PDF output using fonts with spaces in the PostScript name. Task-number: QTBUG-52352 Done-with: Andy Shaw Change-Id: Id8dcb4a57520c2cc53483672f6578e5ab0bb5de5 Reviewed-by: Lars Knoll --- src/gui/painting/qpdf.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/gui/painting/qpdf.cpp b/src/gui/painting/qpdf.cpp index d68d719c392..22a387bd283 100644 --- a/src/gui/painting/qpdf.cpp +++ b/src/gui/painting/qpdf.cpp @@ -1556,6 +1556,7 @@ void QPdfEnginePrivate::embedFont(QFontSubset *font) int toUnicode = requestObject(); QFontEngine::Properties properties = font->fontEngine->properties(); + QByteArray postscriptName = properties.postscriptName.replace(' ', '_'); { qreal scale = 1000/properties.emSquare.toReal(); @@ -1569,7 +1570,7 @@ void QPdfEnginePrivate::embedFont(QFontSubset *font) s << (char)('A' + (tag % 26)); tag /= 26; } - s << '+' << properties.postscriptName << "\n" + s << '+' << postscriptName << "\n" "/Flags " << 4 << "\n" "/FontBBox [" << properties.boundingBox.x()*scale @@ -1612,7 +1613,7 @@ void QPdfEnginePrivate::embedFont(QFontSubset *font) QPdf::ByteStream s(&cid); s << "<< /Type /Font\n" "/Subtype /CIDFontType2\n" - "/BaseFont /" << properties.postscriptName << "\n" + "/BaseFont /" << postscriptName << "\n" "/CIDSystemInfo << /Registry (Adobe) /Ordering (Identity) /Supplement 0 >>\n" "/FontDescriptor " << fontDescriptor << "0 R\n" "/CIDToGIDMap /Identity\n" @@ -1636,7 +1637,7 @@ void QPdfEnginePrivate::embedFont(QFontSubset *font) QPdf::ByteStream s(&font); s << "<< /Type /Font\n" "/Subtype /Type0\n" - "/BaseFont /" << properties.postscriptName << "\n" + "/BaseFont /" << postscriptName << "\n" "/Encoding /Identity-H\n" "/DescendantFonts [" << cidfont << "0 R]\n" "/ToUnicode " << toUnicode << "0 R" From d37239aa419ee4adff4b0a8d5c1403cadff72319 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Wed, 6 Apr 2016 09:06:12 +0200 Subject: [PATCH 35/35] QFtp: Use UTF-8 encoding. According to RFC 2640, FTP uses UTF-8 encoding. Fix the conversions accordingly. Task-number: QTBUG-52303 Change-Id: I615199b3d074fc3861f25df113dda672525766b6 Reviewed-by: Edward Welbourne Reviewed-by: Richard J. Moore --- src/network/access/qftp.cpp | 10 +++++----- tests/auto/network/access/qftp/tst_qftp.cpp | 5 +++-- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/src/network/access/qftp.cpp b/src/network/access/qftp.cpp index 74c95ecd5e8..30bb04b7688 100644 --- a/src/network/access/qftp.cpp +++ b/src/network/access/qftp.cpp @@ -611,7 +611,7 @@ bool QFtpDTP::parseDir(const QByteArray &buffer, const QString &userName, QUrlIn if (buffer.isEmpty()) return false; - QString bufferStr = QString::fromLatin1(buffer).trimmed(); + QString bufferStr = QString::fromUtf8(buffer).trimmed(); // Unix style FTP servers QRegExp unixPattern(QLatin1String("^([\\-dl])([a-zA-Z\\-]{9,9})\\s+\\d+\\s+(\\S*)\\s+" @@ -676,7 +676,7 @@ void QFtpDTP::socketReadyRead() // does not exist, but rather write a text to the data socket // -- try to catch these cases if (line.endsWith("No such file or directory\r\n")) - err = QString::fromLatin1(line); + err = QString::fromUtf8(line); } } } else { @@ -932,7 +932,7 @@ void QFtpPI::readyRead() while (commandSocket.canReadLine()) { // read line with respect to line continuation - QString line = QString::fromLatin1(commandSocket.readLine()); + QString line = QString::fromUtf8(commandSocket.readLine()); if (replyText.isEmpty()) { if (line.length() < 3) { // protocol error @@ -964,7 +964,7 @@ void QFtpPI::readyRead() replyText += line; if (!commandSocket.canReadLine()) return; - line = QString::fromLatin1(commandSocket.readLine()); + line = QString::fromUtf8(commandSocket.readLine()); lineLeft4 = line.left(4); } replyText += line.mid(4); // strip reply code 'xyz ' @@ -1215,7 +1215,7 @@ bool QFtpPI::startNextCmd() qDebug("QFtpPI send: %s", currentCmd.left(currentCmd.length()-2).toLatin1().constData()); #endif state = Waiting; - commandSocket.write(currentCmd.toLatin1()); + commandSocket.write(currentCmd.toUtf8()); return true; } diff --git a/tests/auto/network/access/qftp/tst_qftp.cpp b/tests/auto/network/access/qftp/tst_qftp.cpp index 795548ccc8f..bfc5a73cd85 100644 --- a/tests/auto/network/access/qftp/tst_qftp.cpp +++ b/tests/auto/network/access/qftp/tst_qftp.cpp @@ -732,10 +732,11 @@ void tst_QFtp::put_data() QByteArray bigData( 10*1024*1024, 0 ); bigData.fill( 'A' ); - // test the two put() overloads in one routine + // test the two put() overloads in one routine with a file name containing + // U+0x00FC (latin small letter u with diaeresis) for QTBUG-52303, testing UTF-8 for ( int i=0; i<2; i++ ) { QTest::newRow( QString("relPath01_%1").arg(i).toLatin1().constData() ) << QtNetworkSettings::serverName() << (uint)21 << QString() << QString() - << QString("qtest/upload/rel01_%1") << rfc3252 + << (QLatin1String("qtest/upload/rel01_") + QChar(0xfc) + QLatin1String("%1")) << rfc3252 << (bool)(i==1) << 1; /* QTest::newRow( QString("relPath02_%1").arg(i).toLatin1().constData() ) << QtNetworkSettings::serverName() << (uint)21 << QString("ftptest") << QString("password")