From d866617ea68534c11d4983486609bc01e4d78e33 Mon Sep 17 00:00:00 2001 From: Allan Sandfeld Jensen Date: Tue, 4 Jul 2017 17:24:04 +0200 Subject: [PATCH 01/63] Fix polygon stroking with cosmetic pen Fix a number of issues that caused polygons to not always be drawn fully connected. Ensures the original lastPixel is set when drawing closed polygons, ensure we don't round away from the original starting point, and add handling of edges that need to be rounded half a pixel sideways to line up with endpoints. Task-number: QTBUG-27053 Change-Id: Ib51ee5623a629996af51a0967096383f04e91e2f Reviewed-by: Eirik Aavitsland --- src/gui/painting/qcosmeticstroker.cpp | 56 ++++++--- .../gui/painting/qpainter/tst_qpainter.cpp | 108 ++++++++++++++++++ 2 files changed, 151 insertions(+), 13 deletions(-) diff --git a/src/gui/painting/qcosmeticstroker.cpp b/src/gui/painting/qcosmeticstroker.cpp index 4965762d741..bcb243db6a7 100644 --- a/src/gui/painting/qcosmeticstroker.cpp +++ b/src/gui/painting/qcosmeticstroker.cpp @@ -304,8 +304,8 @@ void QCosmeticStroker::setup() ymin = deviceRect.top() - 1; ymax = deviceRect.bottom() + 2; - lastPixel.x = -1; - lastPixel.y = -1; + lastPixel.x = INT_MIN; + lastPixel.y = INT_MIN; } // returns true if the whole line gets clipped away @@ -325,11 +325,11 @@ bool QCosmeticStroker::clipLine(qreal &x1, qreal &y1, qreal &x2, qreal &y2) x1 = xmax; } if (x2 < xmin) { - lastPixel.x = -1; + lastPixel.x = INT_MIN; y2 += (y2 - y1)/(x2 - x1) * (xmin - x2); x2 = xmin; } else if (x2 > xmax) { - lastPixel.x = -1; + lastPixel.x = INT_MIN; y2 += (y2 - y1)/(x2 - x1) * (xmax - x2); x2 = xmax; } @@ -346,11 +346,11 @@ bool QCosmeticStroker::clipLine(qreal &x1, qreal &y1, qreal &x2, qreal &y2) y1 = ymax; } if (y2 < ymin) { - lastPixel.x = -1; + lastPixel.x = INT_MIN; x2 += (x2 - x1)/(y2 - y1) * (ymin - y2); y2 = ymin; } else if (y2 > ymax) { - lastPixel.x = -1; + lastPixel.x = INT_MIN; x2 += (x2 - x1)/(y2 - y1) * (ymax - y2); y2 = ymax; } @@ -358,7 +358,7 @@ bool QCosmeticStroker::clipLine(qreal &x1, qreal &y1, qreal &x2, qreal &y2) return false; clipped: - lastPixel.x = -1; + lastPixel.x = INT_MIN; return true; } @@ -374,7 +374,7 @@ void QCosmeticStroker::drawLine(const QPointF &p1, const QPointF &p2) QPointF end = p2 * state->matrix; patternOffset = state->lastPen.dashOffset()*64; - lastPixel.x = -1; + lastPixel.x = INT_MIN; stroke(this, start.x(), start.y(), end.x(), end.y(), drawCaps ? CapBegin|CapEnd : 0); @@ -417,8 +417,8 @@ void QCosmeticStroker::calculateLastPoint(qreal rx1, qreal ry1, qreal rx2, qreal // by calculating the direction and last pixel of the last segment in the contour. // the info is then used to perform dropout control when drawing the first line segment // of the contour - lastPixel.x = -1; - lastPixel.y = -1; + lastPixel.x = INT_MIN; + lastPixel.y = INT_MIN; if (clipLine(rx1, ry1, rx2, ry2)) return; @@ -599,7 +599,11 @@ void QCosmeticStroker::drawPath(const QVectorPath &path) bool closed = path.hasImplicitClose() || (points[0] == end[-2] && points[1] == end[-1]); int caps = (!closed && drawCaps) ? CapBegin : NoCaps; if (closed) { - QPointF p2 = QPointF(end[-2], end[-1]) * state->matrix; + QPointF p2; + if (points[0] == end[-2] && points[1] == end[-1] && path.elementCount() > 2) + p2 = QPointF(end[-4], end[-3]) * state->matrix; + else + p2 = QPointF(end[-2], end[-1]) * state->matrix; calculateLastPoint(p2.x(), p2.y(), p.x(), p.y()); } @@ -770,6 +774,11 @@ static bool drawLine(QCosmeticStroker *stroker, qreal rx1, qreal ry1, qreal rx2, int ys = (y2 + 32) >> 6; int round = (xinc > 0) ? 32 : 0; + // If capAdjust made us round away from what calculateLastPoint gave us, + // round back the other way so we start and end on the right point. + if ((caps & QCosmeticStroker::CapBegin) && stroker->lastPixel.y == y + 1) + y++; + if (y != ys) { x += ((y * (1<<6)) + round - y1) * xinc >> 6; @@ -783,7 +792,7 @@ static bool drawLine(QCosmeticStroker *stroker, qreal rx1, qreal ry1, qreal rx2, qSwap(first, last); bool axisAligned = qAbs(xinc) < (1 << 14); - if (stroker->lastPixel.x >= 0) { + if (stroker->lastPixel.x > INT_MIN) { if (first.x == stroker->lastPixel.x && first.y == stroker->lastPixel.y) { // remove duplicated pixel @@ -805,6 +814,14 @@ static bool drawLine(QCosmeticStroker *stroker, qreal rx1, qreal ry1, qreal rx2, --y; x -= xinc; } + } else if (stroker->lastDir == dir && + ((qAbs(stroker->lastPixel.x - first.x) <= 1 && + qAbs(stroker->lastPixel.y - first.y) > 1))) { + x += xinc >> 1; + if (swapped) + last.x = (x >> 16); + else + last.x = (x + (ys - y - 1)*xinc) >> 16; } } stroker->lastDir = dir; @@ -847,6 +864,11 @@ static bool drawLine(QCosmeticStroker *stroker, qreal rx1, qreal ry1, qreal rx2, int xs = (x2 + 32) >> 6; int round = (yinc > 0) ? 32 : 0; + // If capAdjust made us round away from what calculateLastPoint gave us, + // round back the other way so we start and end on the right point. + if ((caps & QCosmeticStroker::CapBegin) && stroker->lastPixel.x == x + 1) + x++; + if (x != xs) { y += ((x * (1<<6)) + round - x1) * yinc >> 6; @@ -860,7 +882,7 @@ static bool drawLine(QCosmeticStroker *stroker, qreal rx1, qreal ry1, qreal rx2, qSwap(first, last); bool axisAligned = qAbs(yinc) < (1 << 14); - if (stroker->lastPixel.x >= 0) { + if (stroker->lastPixel.x > INT_MIN) { if (first.x == stroker->lastPixel.x && first.y == stroker->lastPixel.y) { // remove duplicated pixel if (swapped) { @@ -881,6 +903,14 @@ static bool drawLine(QCosmeticStroker *stroker, qreal rx1, qreal ry1, qreal rx2, --x; y -= yinc; } + } else if (stroker->lastDir == dir && + ((qAbs(stroker->lastPixel.x - first.x) <= 1 && + qAbs(stroker->lastPixel.y - first.y) > 1))) { + y += yinc >> 1; + if (swapped) + last.y = (y >> 16); + else + last.y = (y + (xs - x - 1)*yinc) >> 16; } } stroker->lastDir = dir; diff --git a/tests/auto/gui/painting/qpainter/tst_qpainter.cpp b/tests/auto/gui/painting/qpainter/tst_qpainter.cpp index 8db4489ec17..6b6869c2baf 100644 --- a/tests/auto/gui/painting/qpainter/tst_qpainter.cpp +++ b/tests/auto/gui/painting/qpainter/tst_qpainter.cpp @@ -303,6 +303,8 @@ private slots: void blendNullRGB32(); void toRGB64(); + void fillPolygon(); + private: void fillData(); void setPenColor(QPainter& p); @@ -5191,6 +5193,112 @@ void tst_QPainter::toRGB64() } } +void tst_QPainter::fillPolygon() +{ + QImage image(50, 50, QImage::Format_RGB32); + image.fill(Qt::white); + + QPainter painter(&image); + QBrush brush(Qt::black, Qt::SolidPattern); + painter.setBrush(brush); + + QPen pen(Qt::red, 0, Qt::SolidLine, Qt::FlatCap, Qt::MiterJoin); + painter.setPen(pen); + + const QPoint diamondpoints[5] = { + QPoint(-15, 0), + QPoint(0, -15), + QPoint(15, 0), + QPoint(0, 15), + QPoint(-15, 0) + }; + enum { Outside1, Border1, Inside, Border2, Outside2 } state; + + for (int i = 0; i < 16 ; i++) + { + for (int j = 0; j < 16 ; j++) + { + image.fill(Qt::white); + painter.resetTransform(); + painter.translate(25 + i/16., 25 + j/16.); + painter.drawPolygon(diamondpoints, 5); + + for (int x = 0; x < 50; x++) { + state = Outside1; + for (int y = 0; y < 50; y++) { + QRgb c = image.pixel(x, y); + switch (state) { + case Outside1: + if (c == QColor(Qt::red).rgb()) + state = Border1; + else + QCOMPARE(c, QColor(Qt::white).rgb()); + break; + case Border1: + if (c == QColor(Qt::black).rgb()) + state = Inside; + else if (c == QColor(Qt::white).rgb()) + state = Outside2; + else + QCOMPARE(c, QColor(Qt::red).rgb()); + break; + case Inside: + if (c == QColor(Qt::red).rgb()) + state = Border2; + else + QCOMPARE(c, QColor(Qt::black).rgb()); + break; + case Border2: + if (c == QColor(Qt::white).rgb()) + state = Outside2; + else + QCOMPARE(c, QColor(Qt::red).rgb()); + break; + case Outside2: + QCOMPARE(c, QColor(Qt::white).rgb()); + } + } + } + for (int y = 0; y < 50; y++) { + state = Outside1; + for (int x = 0; x < 50; x++) { + QRgb c = image.pixel(x, y); + switch (state) { + case Outside1: + if (c == QColor(Qt::red).rgb()) + state = Border1; + else + QCOMPARE(c, QColor(Qt::white).rgb()); + break; + case Border1: + if (c == QColor(Qt::black).rgb()) + state = Inside; + else if (c == QColor(Qt::white).rgb()) + state = Outside2; + else + QCOMPARE(c, QColor(Qt::red).rgb()); + break; + case Inside: + if (c == QColor(Qt::red).rgb()) + state = Border2; + else + QCOMPARE(c, QColor(Qt::black).rgb()); + break; + case Border2: + if (c == QColor(Qt::white).rgb()) + state = Outside2; + else + QCOMPARE(c, QColor(Qt::red).rgb()); + break; + case Outside2: + QCOMPARE(c, QColor(Qt::white).rgb()); + } + } + } + } + } +} + QTEST_MAIN(tst_QPainter) #include "tst_qpainter.moc" From d3d5c22ccbaae18ba9722994d586b46685b77450 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Tue, 4 Jul 2017 08:14:27 +0200 Subject: [PATCH 02/63] tst_QProcess/tst_QFile: Extend blacklisting to MSVC2017 Extend the blacklisting introduced by 0ebebeb983d381010fae710aee60d8550d9be4f3. Task-number: QTBUG-48455 Task-number: QTBUG-48504 Change-Id: Idf44948a5ede433435a8d0b61fef6413bb0b69bc Reviewed-by: Simon Hausmann --- tests/auto/corelib/io/qfile/BLACKLIST | 6 ++++-- tests/auto/corelib/io/qprocess/BLACKLIST | 3 ++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/tests/auto/corelib/io/qfile/BLACKLIST b/tests/auto/corelib/io/qfile/BLACKLIST index e3bc093c833..8d636d40b88 100644 --- a/tests/auto/corelib/io/qfile/BLACKLIST +++ b/tests/auto/corelib/io/qfile/BLACKLIST @@ -1,8 +1,10 @@ # QTBUG-48455 [readLineStdin] -msvc-2015 +msvc-2015 ci +msvc-2017 ci [readLineStdin_lineByLine] -msvc-2015 +msvc-2015 ci +msvc-2017 ci [openStandardStreamsFileDescriptors] osx [openStandardStreamsBufferedStreams] diff --git a/tests/auto/corelib/io/qprocess/BLACKLIST b/tests/auto/corelib/io/qprocess/BLACKLIST index 216faa7fb4e..a278af12d38 100644 --- a/tests/auto/corelib/io/qprocess/BLACKLIST +++ b/tests/auto/corelib/io/qprocess/BLACKLIST @@ -2,4 +2,5 @@ redhatenterpriselinuxworkstation-6.6 # QTBUG-48455 [fileWriterProcess] -msvc-2015 +msvc-2015 ci +msvc-2017 ci From 313c3cabe41001c19fa1db725db605ec95781cd4 Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Wed, 5 Jul 2017 13:33:13 +0200 Subject: [PATCH 03/63] Prevent qmake to run moc on qobjectdefs.h Change-Id: Ic453c88c36cbeb24f3dc4fa6b6b20aabe5d24e09 Reviewed-by: Oswald Buddenhagen --- src/corelib/kernel/qobjectdefs.h | 1 + 1 file changed, 1 insertion(+) diff --git a/src/corelib/kernel/qobjectdefs.h b/src/corelib/kernel/qobjectdefs.h index ea4046df550..cec822ad147 100644 --- a/src/corelib/kernel/qobjectdefs.h +++ b/src/corelib/kernel/qobjectdefs.h @@ -206,6 +206,7 @@ private: \ QT_ANNOTATE_CLASS(qt_qgadget, "") \ /*end*/ +/* qmake ignore Q_NAMESPACE */ #define Q_NAMESPACE \ extern const QMetaObject staticMetaObject; \ QT_ANNOTATE_CLASS(qt_qnamespace, "") \ From d78fd6a1e5128756d1bfb05c0402dae0da8c172e Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Sun, 2 Jul 2017 01:28:11 -0700 Subject: [PATCH 04/63] QWinRTFileEngine: Property ItemDate is not the file's last access The MSDN documentation says that it's a date that reflects the item type, giving an example the date a photo was taken (probably as stored in the EXIF metadata). Change-Id: I8d96dea9955d4c749b99fffd14cd7616cc0da545 Reviewed-by: Maurice Kalinowski --- src/plugins/platforms/winrt/qwinrtfileengine.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/plugins/platforms/winrt/qwinrtfileengine.cpp b/src/plugins/platforms/winrt/qwinrtfileengine.cpp index dab2482ab37..58375d331c3 100644 --- a/src/plugins/platforms/winrt/qwinrtfileengine.cpp +++ b/src/plugins/platforms/winrt/qwinrtfileengine.cpp @@ -426,8 +426,7 @@ QDateTime QWinRTFileEngine::fileTime(FileTime type) const ComPtr properties; hr = QWinRTFunctions::await(op, properties.GetAddressOf()); RETURN_IF_FAILED("Failed to get file properties", return QDateTime()); - hr = type == ModificationTime ? properties->get_DateModified(&dateTime) - : properties->get_ItemDate(&dateTime); + hr = properties->get_DateModified(&dateTime); RETURN_IF_FAILED("Failed to get file date", return QDateTime()); } break; From 594fe5c4636cb783bb7840efff4171e772ae906a Mon Sep 17 00:00:00 2001 From: Timur Pocheptsov Date: Wed, 28 Jun 2017 12:53:40 +0200 Subject: [PATCH 05/63] Convert features.localserver to QT_[REQUIRE_]CONFIG Move all the logic into socket.pri and clean-up source code. Build local socket/server only if feature 'localserver' was enabled. Task-number: QTBUG-61672 Change-Id: I9f9d1a262df4bb020c8706c7cb5a66b926e0240f Reviewed-by: Oswald Buddenhagen --- src/network/socket/qlocalserver.cpp | 4 -- src/network/socket/qlocalserver.h | 7 +-- src/network/socket/qlocalserver_p.h | 6 +-- src/network/socket/qlocalserver_unix.cpp | 4 -- src/network/socket/qlocalsocket.cpp | 4 -- src/network/socket/qlocalsocket.h | 7 +-- src/network/socket/qlocalsocket_p.h | 6 +-- src/network/socket/qlocalsocket_unix.cpp | 4 -- src/network/socket/socket.pri | 54 +++++++++++------------- 9 files changed, 32 insertions(+), 64 deletions(-) diff --git a/src/network/socket/qlocalserver.cpp b/src/network/socket/qlocalserver.cpp index 94143c2dc0a..3fcec954e7d 100644 --- a/src/network/socket/qlocalserver.cpp +++ b/src/network/socket/qlocalserver.cpp @@ -43,8 +43,6 @@ QT_BEGIN_NAMESPACE -#ifndef QT_NO_LOCALSERVER - /*! \class QLocalServer \since 4.4 @@ -496,8 +494,6 @@ bool QLocalServer::waitForNewConnection(int msec, bool *timedOut) return !d->pendingConnections.isEmpty(); } -#endif - QT_END_NAMESPACE #include "moc_qlocalserver.cpp" diff --git a/src/network/socket/qlocalserver.h b/src/network/socket/qlocalserver.h index 52c533141f2..9bd2990389f 100644 --- a/src/network/socket/qlocalserver.h +++ b/src/network/socket/qlocalserver.h @@ -43,11 +43,10 @@ #include #include +QT_REQUIRE_CONFIG(localserver); + QT_BEGIN_NAMESPACE - -#ifndef QT_NO_LOCALSERVER - class QLocalSocket; class QLocalServerPrivate; @@ -103,8 +102,6 @@ private: Q_DECLARE_OPERATORS_FOR_FLAGS(QLocalServer::SocketOptions) -#endif // QT_NO_LOCALSERVER - QT_END_NAMESPACE #endif // QLOCALSERVER_H diff --git a/src/network/socket/qlocalserver_p.h b/src/network/socket/qlocalserver_p.h index 988140c1a45..2c073908cbc 100644 --- a/src/network/socket/qlocalserver_p.h +++ b/src/network/socket/qlocalserver_p.h @@ -53,12 +53,12 @@ #include -#ifndef QT_NO_LOCALSERVER - #include "qlocalserver.h" #include "private/qobject_p.h" #include +QT_REQUIRE_CONFIG(localserver); + #if defined(QT_LOCALSOCKET_TCP) # include #elif defined(Q_OS_WIN) @@ -128,7 +128,5 @@ public: QT_END_NAMESPACE -#endif // QT_NO_LOCALSERVER - #endif // QLOCALSERVER_P_H diff --git a/src/network/socket/qlocalserver_unix.cpp b/src/network/socket/qlocalserver_unix.cpp index ba987007d3b..516fac681c5 100644 --- a/src/network/socket/qlocalserver_unix.cpp +++ b/src/network/socket/qlocalserver_unix.cpp @@ -44,8 +44,6 @@ #include "qnet_unix_p.h" #include "qtemporarydir.h" -#ifndef QT_NO_LOCALSERVER - #include #include @@ -341,5 +339,3 @@ void QLocalServerPrivate::setError(const QString &function) } QT_END_NAMESPACE - -#endif // QT_NO_LOCALSERVER diff --git a/src/network/socket/qlocalsocket.cpp b/src/network/socket/qlocalsocket.cpp index 91d2137ce6e..090a9e98c60 100644 --- a/src/network/socket/qlocalsocket.cpp +++ b/src/network/socket/qlocalsocket.cpp @@ -40,8 +40,6 @@ #include "qlocalsocket.h" #include "qlocalsocket_p.h" -#ifndef QT_NO_LOCALSOCKET - QT_BEGIN_NAMESPACE /*! @@ -560,6 +558,4 @@ QDebug operator<<(QDebug debug, QLocalSocket::LocalSocketState state) QT_END_NAMESPACE -#endif - #include "moc_qlocalsocket.cpp" diff --git a/src/network/socket/qlocalsocket.h b/src/network/socket/qlocalsocket.h index ea074db90ee..9905d3a86c2 100644 --- a/src/network/socket/qlocalsocket.h +++ b/src/network/socket/qlocalsocket.h @@ -44,11 +44,10 @@ #include #include +QT_REQUIRE_CONFIG(localserver); + QT_BEGIN_NAMESPACE - -#ifndef QT_NO_LOCALSOCKET - class QLocalSocketPrivate; class Q_NETWORK_EXPORT QLocalSocket : public QIODevice @@ -148,8 +147,6 @@ Q_NETWORK_EXPORT QDebug operator<<(QDebug, QLocalSocket::LocalSocketError); Q_NETWORK_EXPORT QDebug operator<<(QDebug, QLocalSocket::LocalSocketState); #endif -#endif // QT_NO_LOCALSOCKET - QT_END_NAMESPACE #endif // QLOCALSOCKET_H diff --git a/src/network/socket/qlocalsocket_p.h b/src/network/socket/qlocalsocket_p.h index 9da37d2af3e..eb59af55776 100644 --- a/src/network/socket/qlocalsocket_p.h +++ b/src/network/socket/qlocalsocket_p.h @@ -53,13 +53,13 @@ #include -#ifndef QT_NO_LOCALSOCKET - #include "qlocalsocket.h" #include "private/qiodevice_p.h" #include +QT_REQUIRE_CONFIG(localserver); + #if defined(QT_LOCALSOCKET_TCP) # include "qtcpsocket.h" #elif defined(Q_OS_WIN) @@ -161,7 +161,5 @@ public: QT_END_NAMESPACE -#endif // QT_NO_LOCALSOCKET - #endif // QLOCALSOCKET_P_H diff --git a/src/network/socket/qlocalsocket_unix.cpp b/src/network/socket/qlocalsocket_unix.cpp index c7997091a7b..c1d79e8137b 100644 --- a/src/network/socket/qlocalsocket_unix.cpp +++ b/src/network/socket/qlocalsocket_unix.cpp @@ -41,8 +41,6 @@ #include "qlocalsocket_p.h" #include "qnet_unix_p.h" -#ifndef QT_NO_LOCALSOCKET - #include #include #include @@ -555,5 +553,3 @@ bool QLocalSocket::waitForReadyRead(int msecs) } QT_END_NAMESPACE - -#endif diff --git a/src/network/socket/socket.pri b/src/network/socket/socket.pri index 18a8153f56d..b2ee1a8054a 100644 --- a/src/network/socket/socket.pri +++ b/src/network/socket/socket.pri @@ -8,10 +8,6 @@ HEADERS += socket/qabstractsocketengine_p.h \ socket/qudpsocket.h \ socket/qtcpserver.h \ socket/qtcpsocket_p.h \ - socket/qlocalserver.h \ - socket/qlocalserver_p.h \ - socket/qlocalsocket.h \ - socket/qlocalsocket_p.h \ socket/qtcpserver_p.h SOURCES += socket/qabstractsocketengine.cpp \ @@ -19,9 +15,7 @@ SOURCES += socket/qabstractsocketengine.cpp \ socket/qabstractsocket.cpp \ socket/qtcpsocket.cpp \ socket/qudpsocket.cpp \ - socket/qtcpserver.cpp \ - socket/qlocalsocket.cpp \ - socket/qlocalserver.cpp + socket/qtcpserver.cpp # SOCK5 support. @@ -49,42 +43,42 @@ qtConfig(sctp) { HEADERS += socket/qnativesocketengine_p.h } -unix: { - SOURCES += socket/qnativesocketengine_unix.cpp \ - socket/qlocalsocket_unix.cpp \ - socket/qlocalserver_unix.cpp +unix { + SOURCES += socket/qnativesocketengine_unix.cpp + HEADERS += socket/qnet_unix_p.h } -unix:HEADERS += \ - socket/qnet_unix_p.h - # Suppress deprecation warnings with moc because MS headers have # invalid C/C++ code otherwise. msvc: QMAKE_MOC_OPTIONS += -D_WINSOCK_DEPRECATED_NO_WARNINGS -win32:!winrt:SOURCES += socket/qnativesocketengine_win.cpp \ - socket/qlocalsocket_win.cpp \ - socket/qlocalserver_win.cpp - +win32:!winrt:SOURCES += socket/qnativesocketengine_win.cpp win32:!winrt:LIBS_PRIVATE += -ladvapi32 winrt { - SOURCES += socket/qnativesocketengine_winrt.cpp \ - socket/qlocalsocket_tcp.cpp \ - socket/qlocalserver_tcp.cpp + SOURCES += socket/qnativesocketengine_winrt.cpp HEADERS += socket/qnativesocketengine_winrt_p.h - - DEFINES += QT_LOCALSOCKET_TCP } -integrity: { - SOURCES -= socket/qlocalsocket_unix.cpp \ - socket/qlocalserver_unix.cpp - SOURCES += socket/qlocalsocket_tcp.cpp \ - socket/qlocalserver_tcp.cpp \ - socket/qnativesocketengine_unix.cpp +qtConfig(localserver) { + HEADERS += socket/qlocalserver.h \ + socket/qlocalserver_p.h \ + socket/qlocalsocket.h \ + socket/qlocalsocket_p.h + SOURCES += socket/qlocalsocket.cpp \ + socket/qlocalserver.cpp - DEFINES += QT_LOCALSOCKET_TCP + intergrity|winrt { + SOURCES += socket/qlocalsocket_tcp.cpp \ + socket/qlocalserver_tcp.cpp + DEFINES += QT_LOCALSOCKET_TCP + } else: unix { + SOURCES += socket/qlocalsocket_unix.cpp \ + socket/qlocalserver_unix.cpp + } else: win32 { + SOURCES += socket/qlocalsocket_win.cpp \ + socket/qlocalserver_win.cpp + } } qtConfig(system-proxies) { From 7d42293d2fcf466ebf2c99f49b4d15a73947691e Mon Sep 17 00:00:00 2001 From: Michael Winkelmann Date: Wed, 5 Jul 2017 14:43:30 +0200 Subject: [PATCH 06/63] QVariant: Print a warning when deserialized user type is unknown MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The deserialized user type is now shown to the user to figure which QMetaType registration is missing. Change-Id: I4b7624827e479b1bea67065ce3542183b7355165 Reviewed-by: Jędrzej Nowacki --- src/corelib/kernel/qvariant.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/corelib/kernel/qvariant.cpp b/src/corelib/kernel/qvariant.cpp index 17c94e4e9dd..f114a84d22e 100644 --- a/src/corelib/kernel/qvariant.cpp +++ b/src/corelib/kernel/qvariant.cpp @@ -2070,6 +2070,7 @@ void QVariant::load(QDataStream &s) typeId = QMetaType::type(name.constData()); if (typeId == QMetaType::UnknownType) { s.setStatus(QDataStream::ReadCorruptData); + qWarning("QVariant::load: unknown user type with name %s.", name.constData()); return; } } From 6a1046e17691c6e35c7384590ba241edb4082707 Mon Sep 17 00:00:00 2001 From: Stephan Binner Date: Tue, 4 Jul 2017 19:08:55 +0200 Subject: [PATCH 07/63] Fix macOS build for -no-widgets Task-number: QTBUG-61780 Change-Id: Icb337c4daeb976a6616dc289a5ffd0ec9345834f Reviewed-by: Oswald Buddenhagen --- src/plugins/platforms/cocoa/qcocoatheme.mm | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/plugins/platforms/cocoa/qcocoatheme.mm b/src/plugins/platforms/cocoa/qcocoatheme.mm index faa3df39a03..66182e25809 100644 --- a/src/plugins/platforms/cocoa/qcocoatheme.mm +++ b/src/plugins/platforms/cocoa/qcocoatheme.mm @@ -44,7 +44,6 @@ #include -#include "qcocoacolordialoghelper.h" #include "qcocoafontdialoghelper.h" #include "qcocoasystemsettings.h" #include "qcocoasystemtrayicon.h" @@ -64,6 +63,9 @@ #ifdef QT_WIDGETS_LIB #include +#if QT_CONFIG(colordialog) +#include "qcocoacolordialoghelper.h" +#endif #if QT_CONFIG(filedialog) #include "qcocoafiledialoghelper.h" #endif From f065d0f128a09b3faec2a4d3ee6b0952b486e471 Mon Sep 17 00:00:00 2001 From: Stephan Binner Date: Tue, 4 Jul 2017 19:21:36 +0200 Subject: [PATCH 08/63] Fix Windows build without features.filesytemiterator Task-number: QTBUG-61671 Change-Id: I65a96ca51efee303602c836e5b0177b1a63d1a7a Reviewed-by: Oswald Buddenhagen --- src/corelib/io/io.pri | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/corelib/io/io.pri b/src/corelib/io/io.pri index b0cac59f42b..d24c2905083 100644 --- a/src/corelib/io/io.pri +++ b/src/corelib/io/io.pri @@ -113,7 +113,10 @@ win32 { SOURCES += io/qfilesystemwatcher_win.cpp HEADERS += io/qfilesystemwatcher_win_p.h SOURCES += io/qfilesystemengine_win.cpp - SOURCES += io/qfilesystemiterator_win.cpp + + qtConfig(filesystemiterator) { + SOURCES += io/qfilesystemiterator_win.cpp + } !winrt { HEADERS += \ From fb13510681952abaf475b5188dd3333503501369 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Sun, 2 Jul 2017 15:45:02 -0700 Subject: [PATCH 09/63] QFileSystemEngine::fillMetaData: fix apparent use of dangling pointer It's not dangling only because of QFileSystemMetaData's construction: the nativeFilePath() function returns a member variable. Since QByteArray COWs, the pointer that we stored would not be freed. But this was dangerous, since any change to the "entry" variable could cause it to invalidate the member variable and the pointer to become dangling. This line is only as old as this entire file is. Change-Id: I8d96dea9955d4c749b99fffd14cda4d8e2cc5e5b Reviewed-by: Lars Knoll --- src/corelib/io/qfilesystemengine_unix.cpp | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/src/corelib/io/qfilesystemengine_unix.cpp b/src/corelib/io/qfilesystemengine_unix.cpp index e195afdae9a..4ffa6b89729 100644 --- a/src/corelib/io/qfilesystemengine_unix.cpp +++ b/src/corelib/io/qfilesystemengine_unix.cpp @@ -449,15 +449,7 @@ bool QFileSystemEngine::fillMetaData(const QFileSystemEntry &entry, QFileSystemM data.entryFlags &= ~what; - const char * nativeFilePath; - int nativeFilePathLength; - { - const QByteArray &path = entry.nativeFilePath(); - nativeFilePath = path.constData(); - nativeFilePathLength = path.size(); - Q_UNUSED(nativeFilePathLength); - } - + const QByteArray nativeFilePath = entry.nativeFilePath(); bool entryExists = true; // innocent until proven otherwise QT_STATBUF statBuffer; From 08a39ecf332e96444ce6b2fb0502c569935fad6a Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Thu, 29 Jun 2017 10:38:13 -0700 Subject: [PATCH 10/63] QFileSystemEngine/Unix: use fchmod(2) if the file is open This protects against the file having been renamed or deleted. We'll still operate on the open file, regardless the name it may have on the filesystem. Change-Id: I1eba2b016de74620bfc8fffd14cca85cfd672e6d Reviewed-by: Lars Knoll --- src/corelib/io/qfilesystemengine_p.h | 2 ++ src/corelib/io/qfilesystemengine_unix.cpp | 26 +++++++++++++++++++++-- src/corelib/io/qfsfileengine_unix.cpp | 7 +++++- 3 files changed, 32 insertions(+), 3 deletions(-) diff --git a/src/corelib/io/qfilesystemengine_p.h b/src/corelib/io/qfilesystemengine_p.h index de18c997dfb..196ed8df698 100644 --- a/src/corelib/io/qfilesystemengine_p.h +++ b/src/corelib/io/qfilesystemengine_p.h @@ -92,6 +92,8 @@ public: QFileSystemMetaData::MetaDataFlags what); #if defined(Q_OS_UNIX) static bool fillMetaData(int fd, QFileSystemMetaData &data); // what = PosixStatFlags + static bool setPermissions(int fd, QFile::Permissions permissions, QSystemError &error, + QFileSystemMetaData *data = nullptr); #endif #if defined(Q_OS_WIN) diff --git a/src/corelib/io/qfilesystemengine_unix.cpp b/src/corelib/io/qfilesystemengine_unix.cpp index 4ffa6b89729..b26ab2c903f 100644 --- a/src/corelib/io/qfilesystemengine_unix.cpp +++ b/src/corelib/io/qfilesystemengine_unix.cpp @@ -659,8 +659,7 @@ bool QFileSystemEngine::removeFile(const QFileSystemEntry &entry, QSystemError & } -//static -bool QFileSystemEngine::setPermissions(const QFileSystemEntry &entry, QFile::Permissions permissions, QSystemError &error, QFileSystemMetaData *data) +static mode_t toMode_t(QFile::Permissions permissions) { mode_t mode = 0; if (permissions & (QFile::ReadOwner | QFile::ReadUser)) @@ -681,6 +680,13 @@ bool QFileSystemEngine::setPermissions(const QFileSystemEntry &entry, QFile::Per mode |= S_IWOTH; if (permissions & QFile::ExeOther) mode |= S_IXOTH; + return mode; +} + +//static +bool QFileSystemEngine::setPermissions(const QFileSystemEntry &entry, QFile::Permissions permissions, QSystemError &error, QFileSystemMetaData *data) +{ + mode_t mode = toMode_t(permissions); bool success = ::chmod(entry.nativeFilePath().constData(), mode) == 0; if (success && data) { @@ -693,6 +699,22 @@ bool QFileSystemEngine::setPermissions(const QFileSystemEntry &entry, QFile::Per return success; } +//static +bool QFileSystemEngine::setPermissions(int fd, QFile::Permissions permissions, QSystemError &error, QFileSystemMetaData *data) +{ + mode_t mode = toMode_t(permissions); + + bool success = ::fchmod(fd, mode) == 0; + if (success && data) { + data->entryFlags &= ~QFileSystemMetaData::Permissions; + data->entryFlags |= QFileSystemMetaData::MetaDataFlag(uint(permissions)); + data->knownFlagsMask |= QFileSystemMetaData::Permissions; + } + if (!success) + error = QSystemError(errno, QSystemError::StandardLibraryError); + return success; +} + QString QFileSystemEngine::homePath() { QString home = QFile::decodeName(qgetenv("HOME")); diff --git a/src/corelib/io/qfsfileengine_unix.cpp b/src/corelib/io/qfsfileengine_unix.cpp index e152b035e20..3f4f593d811 100644 --- a/src/corelib/io/qfsfileengine_unix.cpp +++ b/src/corelib/io/qfsfileengine_unix.cpp @@ -654,7 +654,12 @@ bool QFSFileEngine::setPermissions(uint perms) { Q_D(QFSFileEngine); QSystemError error; - if (!QFileSystemEngine::setPermissions(d->fileEntry, QFile::Permissions(perms), error, 0)) { + bool ok; + if (d->fd != -1) + ok = QFileSystemEngine::setPermissions(d->fd, QFile::Permissions(perms), error, 0); + else + ok = QFileSystemEngine::setPermissions(d->fileEntry, QFile::Permissions(perms), error, 0); + if (!ok) { setError(QFile::PermissionsError, error.toString()); return false; } From f6ac7379ae0b593a2594d3c06f784109b94a28f0 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Thu, 29 Jun 2017 11:17:23 -0700 Subject: [PATCH 11/63] QFileSystemEngine::id: use the proper QT_STATBUF/QT_STAT Just in case. Change-Id: I1eba2b016de74620bfc8fffd14ccaa801805ae02 Reviewed-by: Lars Knoll --- src/corelib/io/qfilesystemengine_unix.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/corelib/io/qfilesystemengine_unix.cpp b/src/corelib/io/qfilesystemengine_unix.cpp index b26ab2c903f..90e4faaf50a 100644 --- a/src/corelib/io/qfilesystemengine_unix.cpp +++ b/src/corelib/io/qfilesystemengine_unix.cpp @@ -336,8 +336,8 @@ QFileSystemEntry QFileSystemEngine::absoluteName(const QFileSystemEntry &entry) //static QByteArray QFileSystemEngine::id(const QFileSystemEntry &entry) { - struct stat statResult; - if (stat(entry.nativeFilePath().constData(), &statResult)) { + QT_STATBUF statResult; + if (QT_STAT(entry.nativeFilePath().constData(), &statResult)) { qErrnoWarning("stat() failed for '%s'", entry.nativeFilePath().constData()); return QByteArray(); } From 5ed446102a74fc22a0d6d26f7112ca1c3721b43a Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Fri, 23 Jun 2017 13:32:18 +0200 Subject: [PATCH 12/63] Windows QPA: Take hasBorderInFullScreen into account when checking for fullscreen Add a margin to the window geometry. Task-number: QTBUG-61595 Change-Id: I12c557d7cfb1fe954a9845848c0777817c4cbf27 Reviewed-by: Thomas Sondergaard Reviewed-by: Oliver Wolff --- src/plugins/platforms/windows/qwindowswindow.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/plugins/platforms/windows/qwindowswindow.cpp b/src/plugins/platforms/windows/qwindowswindow.cpp index 997598496c3..ff362928b6f 100644 --- a/src/plugins/platforms/windows/qwindowswindow.cpp +++ b/src/plugins/platforms/windows/qwindowswindow.cpp @@ -1758,6 +1758,8 @@ bool QWindowsWindow::isFullScreen_sys() const if (!w->isTopLevel()) return false; QRect geometry = geometry_sys(); + if (testFlag(HasBorderInFullScreen)) + geometry += QMargins(1, 1, 1, 1); QPlatformScreen *screen = screenForGeometry(geometry); return screen && geometry == QHighDpi::toNativePixels(screen->geometry(), screen); } From c8602f45cc13c3c900e6db9f09b38365d00cdccc Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Tue, 20 Jun 2017 14:20:36 +0200 Subject: [PATCH 13/63] Remove WinCE-specific sipdialog example MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Task-number: QTBUG-52590 Task-number: QTBUG-60635 Change-Id: Ie6d59d1431645faf93d1538fe9f5bf1bea9f3014 Reviewed-by: Topi Reiniö --- examples/widgets/dialogs/sipdialog/dialog.cpp | 131 ------------------ examples/widgets/dialogs/sipdialog/dialog.h | 73 ---------- examples/widgets/dialogs/sipdialog/main.cpp | 62 --------- .../widgets/dialogs/sipdialog/sipdialog.pro | 11 -- examples/widgets/doc/src/sipdialog.qdoc | 127 ----------------- 5 files changed, 404 deletions(-) delete mode 100644 examples/widgets/dialogs/sipdialog/dialog.cpp delete mode 100644 examples/widgets/dialogs/sipdialog/dialog.h delete mode 100644 examples/widgets/dialogs/sipdialog/main.cpp delete mode 100644 examples/widgets/dialogs/sipdialog/sipdialog.pro delete mode 100644 examples/widgets/doc/src/sipdialog.qdoc diff --git a/examples/widgets/dialogs/sipdialog/dialog.cpp b/examples/widgets/dialogs/sipdialog/dialog.cpp deleted file mode 100644 index e483b09da91..00000000000 --- a/examples/widgets/dialogs/sipdialog/dialog.cpp +++ /dev/null @@ -1,131 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** BSD License Usage -** Alternatively, you may use this file under the terms of the BSD license -** as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of The Qt Company Ltd nor the names of its -** contributors may be used to endorse or promote products derived -** from this software without specific prior written permission. -** -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include - -#include "dialog.h" - -//! [Dialog constructor part1] -Dialog::Dialog() -{ - desktopGeometry = QApplication::desktop()->availableGeometry(0); - - setWindowTitle(tr("SIP Dialog Example")); - QScrollArea *scrollArea = new QScrollArea(this); - QGroupBox *groupBox = new QGroupBox(scrollArea); - groupBox->setTitle(tr("SIP Dialog Example")); - QGridLayout *gridLayout = new QGridLayout(groupBox); - groupBox->setLayout(gridLayout); -//! [Dialog constructor part1] - -//! [Dialog constructor part2] - QLineEdit* lineEdit = new QLineEdit(groupBox); - lineEdit->setText(tr("Open and close the SIP")); - lineEdit->setMinimumWidth(220); - - QLabel* label = new QLabel(groupBox); - label->setText(tr("This dialog resizes if the SIP is opened")); - label->setMinimumWidth(220); - - QPushButton* button = new QPushButton(groupBox); - button->setText(tr("Close Dialog")); - button->setMinimumWidth(220); -//! [Dialog constructor part2] - -//! [Dialog constructor part3] - if (desktopGeometry.height() < 400) - gridLayout->setVerticalSpacing(80); - else - gridLayout->setVerticalSpacing(150); - - gridLayout->addWidget(label); - gridLayout->addWidget(lineEdit); - gridLayout->addWidget(button); -//! [Dialog constructor part3] - -//! [Dialog constructor part4] - scrollArea->setWidget(groupBox); - QHBoxLayout* layout = new QHBoxLayout(); - layout->addWidget(scrollArea); - setLayout(layout); - scrollArea->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); -//! [Dialog constructor part4] - -//! [Dialog constructor part5] - connect(button, &QAbstractButton::clicked, qApp, &QApplication::closeAllWindows); - connect(QApplication::desktop(), &QDesktopWidget::workAreaResized, - this, &Dialog::desktopResized); -} -//! [Dialog constructor part5] - -//! [desktopResized() function] -void Dialog::desktopResized(int screen) -{ - if (screen != 0) - return; - reactToSIP(); -} -//! [desktopResized() function] - -//! [reactToSIP() function] -void Dialog::reactToSIP() -{ - QRect availableGeometry = QApplication::desktop()->availableGeometry(0); - - if (desktopGeometry != availableGeometry) { - if (windowState() | Qt::WindowMaximized) - setWindowState(windowState() & ~Qt::WindowMaximized); - - setGeometry(availableGeometry); - } - - desktopGeometry = availableGeometry; -} -//! [reactToSIP() function] diff --git a/examples/widgets/dialogs/sipdialog/dialog.h b/examples/widgets/dialogs/sipdialog/dialog.h deleted file mode 100644 index e50baf0d005..00000000000 --- a/examples/widgets/dialogs/sipdialog/dialog.h +++ /dev/null @@ -1,73 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** BSD License Usage -** Alternatively, you may use this file under the terms of the BSD license -** as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of The Qt Company Ltd nor the names of its -** contributors may be used to endorse or promote products derived -** from this software without specific prior written permission. -** -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef DIALOG_H -#define DIALOG_H - -#include - -//! [Dialog header] -class Dialog : public QDialog -{ - Q_OBJECT - -public: - Dialog(); - void reactToSIP(); - -private: - QRect desktopGeometry; - -public slots: - void desktopResized(int screen); -}; -//! [Dialog header] - -#endif diff --git a/examples/widgets/dialogs/sipdialog/main.cpp b/examples/widgets/dialogs/sipdialog/main.cpp deleted file mode 100644 index 55d4003e620..00000000000 --- a/examples/widgets/dialogs/sipdialog/main.cpp +++ /dev/null @@ -1,62 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** BSD License Usage -** Alternatively, you may use this file under the terms of the BSD license -** as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of The Qt Company Ltd nor the names of its -** contributors may be used to endorse or promote products derived -** from this software without specific prior written permission. -** -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include - -#include "dialog.h" - -//! [main() function] -int main(int argc, char *argv[]) -{ - QApplication app(argc, argv); - Dialog dialog; - return dialog.exec(); -} -//! [main() function] diff --git a/examples/widgets/dialogs/sipdialog/sipdialog.pro b/examples/widgets/dialogs/sipdialog/sipdialog.pro deleted file mode 100644 index aa3dfacf0c1..00000000000 --- a/examples/widgets/dialogs/sipdialog/sipdialog.pro +++ /dev/null @@ -1,11 +0,0 @@ -QT += widgets - -HEADERS = dialog.h -SOURCES = main.cpp \ - dialog.cpp - -# install -target.path = $$[QT_INSTALL_EXAMPLES]/widgets/dialogs/sipdialog -INSTALLS += target - -wince50standard-x86-msvc2005: LIBS += libcmt.lib corelibc.lib ole32.lib oleaut32.lib uuid.lib commctrl.lib coredll.lib winsock.lib ws2.lib diff --git a/examples/widgets/doc/src/sipdialog.qdoc b/examples/widgets/doc/src/sipdialog.qdoc deleted file mode 100644 index 3443324b5ab..00000000000 --- a/examples/widgets/doc/src/sipdialog.qdoc +++ /dev/null @@ -1,127 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:FDL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Free Documentation License Usage -** Alternatively, this file may be used under the terms of the GNU Free -** Documentation License version 1.3 as published by the Free Software -** Foundation and appearing in the file included in the packaging of -** this file. Please review the following information to ensure -** the GNU Free Documentation License version 1.3 requirements -** will be met: https://www.gnu.org/licenses/fdl-1.3.html. -** $QT_END_LICENSE$ -** -****************************************************************************/ - -/*! - \example dialogs/sipdialog - \title SIP Dialog Example - \ingroup qtce - - \brief The SIP Dialog example shows how to create a dialog that is aware of - the Windows Mobile SIP (Software Input Panel) and reacts to it. - - \table - \row \li \inlineimage sipdialog-closed.png - \li \inlineimage sipdialog-opened.png - \endtable - - Sometimes it is necessary for a dialog to take the SIP into account, - as the SIP may hide important input widgets. The SIP Dialog Example - shows how a \c Dialog object, \c dialog, can be resized accordingly - if the SIP is opened, by embedding the contents of \c dialog in a - QScrollArea. - - \section1 Dialog Class Definition - - The \c Dialog class is a subclass of QDialog that implements a public - slot, \c desktopResized(), and a public function, \c reactToSIP(). Also, - it holds a private instance of QRect, \c desktopGeometry. - - \snippet dialogs/sipdialog/dialog.h Dialog header - - \section1 Dialog Class Implementation - - In the constructor of \c Dialog, we start by obtaining the - available geometry of the screen with - \l{QDesktopWidget::availableGeometry()}{availableGeometry()}. The - parameter used is \c 0 to indicate that we require the primary screen. - - \snippet dialogs/sipdialog/dialog.cpp Dialog constructor part1 - - We set the window's title to "SIP Dialog Example" and declare a QScrollArea - object, \c scrollArea. Next we instantiate a QGroupBox, \c groupBox, with - \c scrollArea as its parent. The title of \c groupBox is also set to - "SIP Dialog Example". A QGridLayout object, \c gridLayout, is then used - as \c{groupBox}'s layout. - - We create a QLineEdit, a QLabel and a QPushButton and we set the - \l{QWidget::setMinimumWidth()}{minimumWidth} property to 220 pixels, - respectively. - - \snippet dialogs/sipdialog/dialog.cpp Dialog constructor part2 - - Also, all three widgets' text are set accordingly. The - \l{QGridLayout::setVerticalSpacing()}{verticalSpacing} property of - \c gridLayout is set based on the height of \c desktopGeometry. This - is to adapt to the different form factors of Windows Mobile. Then, we - add our widgets to the layout. - - \snippet dialogs/sipdialog/dialog.cpp Dialog constructor part3 - - The \c{scrollArea}'s widget is set to \c groupBox. We use a QHBoxLayout - object, \c layout, to contain \c scrollArea. The \c{Dialog}'s layout - is set to \c layout and the scroll area's horizontal scroll bar is turned - off. - - \snippet dialogs/sipdialog/dialog.cpp Dialog constructor part4 - - The following signals are connected to their respective slots: - \list - \li \c{button}'s \l{QPushButton::pressed()}{pressed()} signal to - \l{QApplication}'s \l{QApplication::closeAllWindows()} - {closeAllWindows()} slot, - \li \l{QDesktopWidget}'s \l{QDesktopWidget::workAreaResized()} - {workAreaResized()} signal to \c{dialog}'s \c desktopResized() slot. - \endlist - - \snippet dialogs/sipdialog/dialog.cpp Dialog constructor part5 - - The \c desktopResized() function accepts an integer, \a screen, - corresponding to the screen's index. We only invoke \c reactToSIP() - if \a screen is the primary screen (e.g. index = 0). - - \snippet dialogs/sipdialog/dialog.cpp desktopResized() function - - The \c reactToSIP() function resizes \c dialog accordingly if the - desktop's available geometry changed vertically, as this change signifies - that the SIP may have been opened or closed. - - \snippet dialogs/sipdialog/dialog.cpp reactToSIP() function - - If the height has decreased, we unset the maximized window state. - Otherwise, we set the maximized window state. Lastly, we update - \c desktopGeometry to the desktop's available geometry. - - \section1 The \c main() function - - The \c main() function for the SIP Dialog example instantiates \c Dialog - and invokes its \l{QDialog::exec()}{exec()} function. - - \snippet dialogs/sipdialog/main.cpp main() function - - \note Although this example uses a dialog, the techniques used here apply to - all top-level widgets respectively. -*/ From f7aaff01de9d5555e333cedcbbc07236cd653d0a Mon Sep 17 00:00:00 2001 From: David Faure Date: Sun, 2 Jul 2017 18:10:39 +0200 Subject: [PATCH 14/63] Fix Qt5DBusMacros.cmake for CMake 3.9 CMake gained support for running AUTOMOC on generated headers, so we need to mark them with SKIP_AUTOMOC since we're generating moc files for those already. Otherwise we get duplicated symbols. Change-Id: Iabd387832cfc74809fc5e6ff4782f4fc83cc07d8 Reviewed-by: Thiago Macieira Reviewed-by: Rolf Eike Beer Reviewed-by: Kevin Funk Reviewed-by: Stephen Kelly --- src/dbus/Qt5DBusMacros.cmake | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/dbus/Qt5DBusMacros.cmake b/src/dbus/Qt5DBusMacros.cmake index ef3eb73276f..0bd7364637b 100644 --- a/src/dbus/Qt5DBusMacros.cmake +++ b/src/dbus/Qt5DBusMacros.cmake @@ -62,6 +62,7 @@ function(QT5_ADD_DBUS_INTERFACE _sources _interface _basename) DEPENDS ${_infile} VERBATIM) set_source_files_properties("${_impl}" PROPERTIES SKIP_AUTOMOC TRUE) + set_source_files_properties("${_header}" PROPERTIES SKIP_AUTOMOC TRUE) qt5_generate_moc("${_header}" "${_moc}") @@ -147,6 +148,7 @@ function(QT5_ADD_DBUS_ADAPTOR _sources _xml_file _include _parentClass) # _optio qt5_generate_moc("${_header}" "${_moc}") set_source_files_properties("${_impl}" PROPERTIES SKIP_AUTOMOC TRUE) + set_source_files_properties("${_header}" PROPERTIES SKIP_AUTOMOC TRUE) macro_add_file_dependencies("${_impl}" "${_moc}") list(APPEND ${_sources} "${_impl}" "${_header}" "${_moc}") From eaa54a8f9884652513c7c3ab489f31ff1e5d712c Mon Sep 17 00:00:00 2001 From: Gabriel de Dietrich Date: Tue, 27 Jun 2017 14:36:01 -0700 Subject: [PATCH 15/63] QMacStyle: Properly polish and unpolish QTabBar MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Task-number: QTBUG-61092 Change-Id: Id8b6caef264c61936a425757c6d8fac63142d5ec Reviewed-by: Tor Arne Vestbø --- src/widgets/styles/qmacstyle_mac.mm | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/widgets/styles/qmacstyle_mac.mm b/src/widgets/styles/qmacstyle_mac.mm index 147b2027bfc..978810572b5 100644 --- a/src/widgets/styles/qmacstyle_mac.mm +++ b/src/widgets/styles/qmacstyle_mac.mm @@ -2262,6 +2262,8 @@ void QMacStyle::polish(QWidget* w) QPalette p = w->palette(); p.setColor(QPalette::WindowText, QColor(17, 17, 17)); w->setPalette(p); + w->setAttribute(Qt::WA_SetPalette, false); + w->setAttribute(Qt::WA_SetFont, false); } } #endif @@ -2304,6 +2306,15 @@ void QMacStyle::unpolish(QWidget* w) } #endif +#ifndef QT_NO_TABBAR + if (QTabBar *tb = qobject_cast(w)) { + if (!w->testAttribute(Qt::WA_SetFont)) + w->setFont(qApp->font(w)); + if (!w->testAttribute(Qt::WA_SetPalette)) + w->setPalette(qApp->palette(w)); + } +#endif + if (QRubberBand *rubber = qobject_cast(w)) { rubber->setWindowOpacity(1.0); rubber->setAttribute(Qt::WA_PaintOnScreen, true); From 462d26f265d516fc77ff28f975e4801722c6b703 Mon Sep 17 00:00:00 2001 From: Gabriel de Dietrich Date: Tue, 27 Jun 2017 14:41:25 -0700 Subject: [PATCH 16/63] qtabbar manual test: Improve usability MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Covers non-document mode, tab icon, and adds a more useable interface. Some parts are still missing, like tab orientation and long tab titles. Task-number: QTBUG-61092 Change-Id: Idbda84f513e3ff7f87fa04ae4476b11bd8bb6bf2 Reviewed-by: Tor Arne Vestbø --- tests/manual/qtabbar/main.cpp | 74 +++++++++-- tests/manual/qtabbar/qtabbar.pro | 4 +- tests/manual/qtabbar/tabbarform.cpp | 13 ++ tests/manual/qtabbar/tabbarform.h | 22 ++++ tests/manual/qtabbar/tabbarform.ui | 182 ++++++++++++++++++++++++++++ 5 files changed, 287 insertions(+), 8 deletions(-) create mode 100644 tests/manual/qtabbar/tabbarform.cpp create mode 100644 tests/manual/qtabbar/tabbarform.h create mode 100644 tests/manual/qtabbar/tabbarform.ui diff --git a/tests/manual/qtabbar/main.cpp b/tests/manual/qtabbar/main.cpp index 5a1a558c10a..466a7e20fc7 100644 --- a/tests/manual/qtabbar/main.cpp +++ b/tests/manual/qtabbar/main.cpp @@ -57,19 +57,25 @@ #include #include #include +#include +#include "tabbarform.h" -class MyProxyStyle : public QProxyStyle +class TabBarProxyStyle : public QProxyStyle { public: + TabBarProxyStyle() : QProxyStyle(), alignment(Qt::AlignLeft) + { } + int styleHint(StyleHint hint, const QStyleOption *option = 0, const QWidget *widget = 0, QStyleHintReturn *returnData = 0) const { if (hint == QStyle::SH_TabBar_Alignment) - return Qt::AlignLeft; -// return Qt::AlignRight; -// return Qt::AlignCenter; + return alignment; + return QProxyStyle::styleHint(hint, option, widget, returnData); } + + Qt::Alignment alignment; }; const int TabCount = 5; @@ -77,7 +83,8 @@ const int TabCount = 5; int main(int argc, char *argv[]) { QApplication app(argc, argv); - app.setStyle(new MyProxyStyle); + auto *proxyStyle = new TabBarProxyStyle; + app.setStyle(proxyStyle); QWidget widget; QStackedWidget stackedWidget; @@ -161,8 +168,61 @@ int main(int argc, char *argv[]) break; } - layout->setMargin(0); - widget.resize(QApplication::desktop()->screenGeometry(&widget).size() * 0.5); + TabBarForm form; + layout->addWidget(&form); + layout->setAlignment(&form, Qt::AlignHCenter); + + form.ui->documentModeButton->setChecked(tabBar.documentMode()); + QObject::connect(form.ui->documentModeButton, &QCheckBox::toggled, [&] { + tabBar.setDocumentMode(form.ui->documentModeButton->isChecked()); + // QMacStyle (and maybe other styles) requires a re-polish to get the right font + QApplication::sendEvent(&tabBar, new QEvent(QEvent::ThemeChange)); + }); + + form.ui->movableTabsButton->setChecked(tabBar.isMovable()); + QObject::connect(form.ui->movableTabsButton, &QCheckBox::toggled, [&] { + tabBar.setMovable(form.ui->movableTabsButton->isChecked()); + tabBar.update(); + }); + + form.ui->closableTabsButton->setChecked(tabBar.tabsClosable()); + QObject::connect(form.ui->closableTabsButton, &QCheckBox::toggled, [&] { + tabBar.setTabsClosable(form.ui->closableTabsButton->isChecked()); + tabBar.update(); + }); + + form.ui->expandingTabsButton->setChecked(tabBar.expanding()); + QObject::connect(form.ui->expandingTabsButton, &QCheckBox::toggled, [&] { + tabBar.setExpanding(form.ui->expandingTabsButton->isChecked()); + tabBar.update(); + }); + + form.ui->displayIconButton->setChecked(!tabBar.tabIcon(0).isNull()); + QObject::connect(form.ui->displayIconButton, &QCheckBox::toggled, [&] { + const auto icon = form.ui->displayIconButton->isChecked() ? + tabBar.style()->standardIcon(QStyle::SP_ComputerIcon) : QIcon(); + for (int i = 0; i < tabBar.count(); i++) + tabBar.setTabIcon(i, icon); + }); + + QObject::connect(form.ui->shapeComboBox, QOverload::of(&QComboBox::currentIndexChanged), [&](int index) { + Q_UNUSED(index); + // TODO + }); + + if (proxyStyle->alignment == Qt::AlignLeft) + form.ui->leftAlignedButton->setChecked(true); + else if (proxyStyle->alignment == Qt::AlignRight) + form.ui->rightAlignedButton->setChecked(true); + else + form.ui->centeredButton->setChecked(true); + QObject::connect(form.ui->textAlignmentGroup, QOverload::of(&QButtonGroup::buttonClicked), [&](QAbstractButton *b) { + proxyStyle->alignment = b == form.ui->leftAlignedButton ? Qt::AlignLeft : + b == form.ui->rightAlignedButton ? Qt::AlignRight : Qt::AlignCenter; + QApplication::sendEvent(&tabBar, new QEvent(QEvent::StyleChange)); + }); + + layout->setMargin(12); widget.show(); return app.exec(); diff --git a/tests/manual/qtabbar/qtabbar.pro b/tests/manual/qtabbar/qtabbar.pro index a63da72158e..867e06735e0 100644 --- a/tests/manual/qtabbar/qtabbar.pro +++ b/tests/manual/qtabbar/qtabbar.pro @@ -1,4 +1,6 @@ TARGET = qtabbar TEMPLATE = app QT = core gui widgets -SOURCES = main.cpp +SOURCES = main.cpp tabbarform.cpp +HEADERS = tabbarform.h +FORMS = tabbarform.ui diff --git a/tests/manual/qtabbar/tabbarform.cpp b/tests/manual/qtabbar/tabbarform.cpp new file mode 100644 index 00000000000..51271f73736 --- /dev/null +++ b/tests/manual/qtabbar/tabbarform.cpp @@ -0,0 +1,13 @@ +#include "tabbarform.h" + +TabBarForm::TabBarForm(QWidget *parent) : + QWidget(parent), + ui(new Ui::TabBarForm) +{ + ui->setupUi(this); +} + +TabBarForm::~TabBarForm() +{ + delete ui; +} diff --git a/tests/manual/qtabbar/tabbarform.h b/tests/manual/qtabbar/tabbarform.h new file mode 100644 index 00000000000..7db3f71fa55 --- /dev/null +++ b/tests/manual/qtabbar/tabbarform.h @@ -0,0 +1,22 @@ +#ifndef TABBARFORM_H +#define TABBARFORM_H + +#include +#include "ui_tabbarform.h" + +namespace Ui { +class TabBarForm; +} + +class TabBarForm : public QWidget +{ + Q_OBJECT + +public: + explicit TabBarForm(QWidget *parent = 0); + ~TabBarForm(); + + Ui::TabBarForm *ui; +}; + +#endif // TABBARFORM_H diff --git a/tests/manual/qtabbar/tabbarform.ui b/tests/manual/qtabbar/tabbarform.ui new file mode 100644 index 00000000000..17100b3b62e --- /dev/null +++ b/tests/manual/qtabbar/tabbarform.ui @@ -0,0 +1,182 @@ + + + TabBarForm + + + + 0 + 0 + 308 + 260 + + + + + 0 + 0 + + + + Form + + + + + + + + Right aligned + + + textAlignmentGroup + + + + + + + Left aligned + + + textAlignmentGroup + + + + + + + Closable tabs + + + + + + + Tabs alignment: + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + Movable tabs + + + + + + + Document mode + + + + + + + Expanding + + + + + + + false + + + + North + + + + + South + + + + + West + + + + + East + + + + + + + + Qt::Vertical + + + + 20 + 12 + + + + + + + + Qt::Vertical + + + + 20 + 12 + + + + + + + + Tab bar options: + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + Centered + + + textAlignmentGroup + + + + + + + Tab shape (TODO): + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + Display icon + + + + + + + + + + + + + From e4c39d5e1e7ee8c2bba273e6d613ec519b7fa9c2 Mon Sep 17 00:00:00 2001 From: Gabriel de Dietrich Date: Fri, 30 Jun 2017 11:28:23 -0700 Subject: [PATCH 17/63] QMacStyle: Bring back always visible close button in non-document QTabBar MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This case is not supported by the Mac HIG, so we need to improvise some colors that look better than those used in document mode. Change-Id: I9858be468680303fdf65e17aa10ca1f90718b236 Task-number: QTBUG-61092 Reviewed-by: Tor Arne Vestbø --- src/widgets/styles/qmacstyle_mac.mm | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/src/widgets/styles/qmacstyle_mac.mm b/src/widgets/styles/qmacstyle_mac.mm index 978810572b5..906bc85fa69 100644 --- a/src/widgets/styles/qmacstyle_mac.mm +++ b/src/widgets/styles/qmacstyle_mac.mm @@ -242,7 +242,7 @@ static bool isInMacUnifiedToolbarArea(QWindow *window, int windowY) } -void drawTabCloseButton(QPainter *p, bool hover, bool selected, bool pressed) +static void drawTabCloseButton(QPainter *p, bool hover, bool selected, bool pressed, bool documentMode) { p->setRenderHints(QPainter::Antialiasing); QRect rect(0, 0, closeButtonSize, closeButtonSize); @@ -253,10 +253,16 @@ void drawTabCloseButton(QPainter *p, bool hover, bool selected, bool pressed) // draw background circle QColor background; if (selected) { - background = pressed ? tabBarCloseButtonBackgroundSelectedPressed : tabBarCloseButtonBackgroundSelectedHovered; + if (documentMode) + background = pressed ? tabBarCloseButtonBackgroundSelectedPressed : tabBarCloseButtonBackgroundSelectedHovered; + else + background = QColor(255, 255, 255, pressed ? 150 : 100); // Translucent white } else { background = pressed ? tabBarCloseButtonBackgroundPressed : tabBarCloseButtonBackgroundHovered; + if (!documentMode) + background = background.lighter(pressed ? 135 : 140); // Lighter tab background, lighter color } + p->setPen(Qt::transparent); p->setBrush(background); p->drawRoundedRect(rect, closeButtonCornerRadius, closeButtonCornerRadius); @@ -265,7 +271,7 @@ void drawTabCloseButton(QPainter *p, bool hover, bool selected, bool pressed) // draw cross const int margin = 3; QPen crossPen; - crossPen.setColor(selected ? tabBarCloseButtonCrossSelected : tabBarCloseButtonCross); + crossPen.setColor(selected ? (documentMode ? tabBarCloseButtonCrossSelected : Qt::white) : tabBarCloseButtonCross); crossPen.setWidthF(1.1); crossPen.setCapStyle(Qt::FlatCap); p->setPen(crossPen); @@ -3551,14 +3557,16 @@ void QMacStyle::drawPrimitive(PrimitiveElement pe, const QStyleOption *opt, QPai case PE_IndicatorTabClose: { // Make close button visible only on the hovered tab. if (QTabBar *tabBar = qobject_cast(w->parentWidget())) { + const bool documentMode = tabBar->documentMode(); const QTabBarPrivate *tabBarPrivate = static_cast(QObjectPrivate::get(tabBar)); const int hoveredTabIndex = tabBarPrivate->hoveredTabIndex(); - if (hoveredTabIndex != -1 && ((w == tabBar->tabButton(hoveredTabIndex, QTabBar::LeftSide)) || - (w == tabBar->tabButton(hoveredTabIndex, QTabBar::RightSide)))) { + if (!documentMode || + (hoveredTabIndex != -1 && ((w == tabBar->tabButton(hoveredTabIndex, QTabBar::LeftSide)) || + (w == tabBar->tabButton(hoveredTabIndex, QTabBar::RightSide))))) { const bool hover = (opt->state & State_MouseOver); const bool selected = (opt->state & State_Selected); const bool pressed = (opt->state & State_Sunken); - drawTabCloseButton(p, hover, selected, pressed); + drawTabCloseButton(p, hover, selected, pressed, documentMode); } } } break; From 7beb2bc02bff9fa591eb60b978ed97d0601bedfd Mon Sep 17 00:00:00 2001 From: Alexandru Croitor Date: Tue, 4 Jul 2017 17:13:38 +0200 Subject: [PATCH 18/63] [Windows] Update hMonitor handles when a display is turned off In a multi-monitor setup, when the main display is turned off or disconnected, all remaining monitors have their hMonitor handle changed. Qt did not store these updated handles, which led to not posting the WindowScreenChanged event when a window was moved to a different DPI-scaled display, leading to e.g. improperly scaled popup menus. The fix consists in updating the hMonitor handles whenever a new monitor is connected or disconnected. Change-Id: Id2ca2c128510d9ff3e9746eb33e86dce8f6c4c83 Reviewed-by: Friedemann Kleint --- src/plugins/platforms/windows/qwindowsscreen.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/plugins/platforms/windows/qwindowsscreen.cpp b/src/plugins/platforms/windows/qwindowsscreen.cpp index 24fb12d27ab..3a4793efcda 100644 --- a/src/plugins/platforms/windows/qwindowsscreen.cpp +++ b/src/plugins/platforms/windows/qwindowsscreen.cpp @@ -153,7 +153,8 @@ static QDebug operator<<(QDebug dbg, const QWindowsScreenData &d) << d.availableGeometry.width() << 'x' << d.availableGeometry.height() << '+' << d.availableGeometry.x() << '+' << d.availableGeometry.y() << " physical: " << d.physicalSizeMM.width() << 'x' << d.physicalSizeMM.height() << " DPI: " << d.dpi.first << 'x' << d.dpi.second << " Depth: " << d.depth - << " Format: " << d.format; + << " Format: " << d.format + << " hMonitor: " << d.hMonitor; if (d.flags & QWindowsScreenData::PrimaryScreen) dbg << " primary"; if (d.flags & QWindowsScreenData::VirtualDesktop) @@ -290,6 +291,13 @@ void QWindowsScreen::handleChanges(const QWindowsScreenData &newData) { m_data.physicalSizeMM = newData.physicalSizeMM; + if (m_data.hMonitor != newData.hMonitor) { + qCDebug(lcQpaWindows) << "Monitor" << m_data.name + << "has had its hMonitor handle changed from" + << m_data.hMonitor << "to" << newData.hMonitor; + m_data.hMonitor = newData.hMonitor; + } + if (m_data.geometry != newData.geometry || m_data.availableGeometry != newData.availableGeometry) { m_data.geometry = newData.geometry; m_data.availableGeometry = newData.availableGeometry; From e1d7f7dfbc0191f585fde8695d315e3ffb98ccc5 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Thu, 6 Jul 2017 12:38:31 +0200 Subject: [PATCH 19/63] QFileSystemWatcher/Windows: Recreate handle for files QWindowsFileSystemWatcherEngine uses one change notification per directory to watch directories or files within that directory. Adding files and their directories in a sequence caused the value in QWindowsFileSystemWatcherEngineThread::HandleForDirHash to be overwritten. Relax the check for the flags (watcher attributes) to use >= and recreate the change notification of a directory should its flags be insufficient. This triggers when a file is added after its directory since files require more attributes. Task-number: QTBUG-61792 Change-Id: I371a72f1934fa82c53aaf84beb907825031f1c81 Reviewed-by: Thiago Macieira --- src/corelib/io/qfilesystemwatcher_win.cpp | 47 +++++++++++++++---- .../tst_qfilesystemwatcher.cpp | 4 ++ 2 files changed, 42 insertions(+), 9 deletions(-) diff --git a/src/corelib/io/qfilesystemwatcher_win.cpp b/src/corelib/io/qfilesystemwatcher_win.cpp index c385a82fc50..ff0d45935c9 100644 --- a/src/corelib/io/qfilesystemwatcher_win.cpp +++ b/src/corelib/io/qfilesystemwatcher_win.cpp @@ -71,6 +71,19 @@ QT_BEGIN_NAMESPACE # define DEBUG if (false) qDebug #endif +static Qt::HANDLE createChangeNotification(const QString &path, uint flags) +{ + // Volume and folder paths need a trailing slash for proper notification + // (e.g. "c:" -> "c:/"). + QString nativePath = QDir::toNativeSeparators(path); + if ((flags & FILE_NOTIFY_CHANGE_ATTRIBUTES) == 0 && !nativePath.endsWith(QLatin1Char('\\'))) + nativePath.append(QLatin1Char('\\')); + const HANDLE result = FindFirstChangeNotification(reinterpret_cast(nativePath.utf16()), + FALSE, flags); + DEBUG() << __FUNCTION__ << nativePath << hex <mutex)); - handle = thread->handleForDir.value(QFileSystemWatcherPathKey(absolutePath)); - if (handle.handle != INVALID_HANDLE_VALUE && handle.flags == flags) { + const auto hit = thread->handleForDir.find(QFileSystemWatcherPathKey(absolutePath)); + if (hit != thread->handleForDir.end() && hit.value().flags < flags) { + // Requesting to add a file whose directory has been added previously. + // Recreate the notification handle to add the missing notification attributes + // for files (FILE_NOTIFY_CHANGE_ATTRIBUTES...) + DEBUG() << "recreating" << absolutePath << hex << showbase << hit.value().flags + << "->" << flags; + const Qt::HANDLE fileHandle = createChangeNotification(absolutePath, flags); + if (fileHandle != INVALID_HANDLE_VALUE) { + const int index = thread->handles.indexOf(hit.value().handle); + const auto pit = thread->pathInfoForHandle.find(hit.value().handle); + Q_ASSERT(index != -1); + Q_ASSERT(pit != thread->pathInfoForHandle.end()); + FindCloseChangeNotification(hit.value().handle); + thread->handles[index] = hit.value().handle = fileHandle; + hit.value().flags = flags; + thread->pathInfoForHandle.insert(fileHandle, pit.value()); + thread->pathInfoForHandle.erase(pit); + } + } + // In addition, check on flags for sufficient notification attributes + if (hit != thread->handleForDir.end() && hit.value().flags >= flags) { + handle = hit.value(); // found a thread now insert... DEBUG() << "Found a thread" << thread; @@ -426,14 +460,9 @@ QStringList QWindowsFileSystemWatcherEngine::addPaths(const QStringList &paths, } // no thread found, first create a handle - if (handle.handle == INVALID_HANDLE_VALUE || handle.flags != flags) { + if (handle.handle == INVALID_HANDLE_VALUE) { DEBUG() << "No thread found"; - // Volume and folder paths need a trailing slash for proper notification - // (e.g. "c:" -> "c:/"). - const QString effectiveAbsolutePath = - isDir ? (absolutePath + QLatin1Char('/')) : absolutePath; - - handle.handle = FindFirstChangeNotification((wchar_t*) QDir::toNativeSeparators(effectiveAbsolutePath).utf16(), false, flags); + handle.handle = createChangeNotification(absolutePath, flags); handle.flags = flags; if (handle.handle == INVALID_HANDLE_VALUE) continue; diff --git a/tests/auto/corelib/io/qfilesystemwatcher/tst_qfilesystemwatcher.cpp b/tests/auto/corelib/io/qfilesystemwatcher/tst_qfilesystemwatcher.cpp index 0ee7599b2c6..154c7ec5bfa 100644 --- a/tests/auto/corelib/io/qfilesystemwatcher/tst_qfilesystemwatcher.cpp +++ b/tests/auto/corelib/io/qfilesystemwatcher/tst_qfilesystemwatcher.cpp @@ -568,6 +568,10 @@ void tst_QFileSystemWatcher::watchFileAndItsDirectory() QCOMPARE(fileChangedSpy.count(), 0); QCOMPARE(dirChangedSpy.count(), 1); + // QTBUG-61792, removal should succeed (bug on Windows which uses one change + // notification per directory). + QVERIFY(watcher.removePath(testDir.absolutePath())); + QVERIFY(temporaryDir.rmdir(testDirName)); } From bcd19b723a4adad4d5f1dbbd35079cc24331dfa8 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Fri, 30 Sep 2016 11:18:05 -0700 Subject: [PATCH 20/63] QLocale: fix handling of milliseconds in string format and document [ChangeLog][QtCore][QLocale] Fixed the conversion of QTime to string form and parsing from string form to always treat the value as the decimal fraction of the seconds component. That is, the string format ".z" produces/parses ".2" for 200 milliseconds and ".002" for 2 milliseconds. Use of "z" or "zzz" is discouraged outside decimal fractions to avoid surprises. Task-number: QTBUG-53565 Change-Id: Ia19de85ad35e4eb7bb95fffd14792caf9b4a5156 Reviewed-by: Edward Welbourne --- src/corelib/tools/qdatetime.cpp | 53 ++++++++++++------- src/corelib/tools/qlocale.cpp | 17 +++--- .../corelib/tools/qlocale/tst_qlocale.cpp | 19 ++++--- tests/auto/corelib/tools/qtime/tst_qtime.cpp | 15 +++--- 4 files changed, 65 insertions(+), 39 deletions(-) diff --git a/src/corelib/tools/qdatetime.cpp b/src/corelib/tools/qdatetime.cpp index bcdbc5af2a7..11c023f7622 100644 --- a/src/corelib/tools/qdatetime.cpp +++ b/src/corelib/tools/qdatetime.cpp @@ -1642,10 +1642,14 @@ QString QTime::toString(Qt::DateFormat format) const \li the hour with a leading zero (00 to 23, even with AM/PM display) \row \li m \li the minute without a leading zero (0 to 59) \row \li mm \li the minute with a leading zero (00 to 59) - \row \li s \li the second without a leading zero (0 to 59) - \row \li ss \li the second with a leading zero (00 to 59) - \row \li z \li the milliseconds without leading zeroes (0 to 999) - \row \li zzz \li the milliseconds with leading zeroes (000 to 999) + \row \li s \li the whole second, without any leading zero (0 to 59) + \row \li ss \li the whole second, with a leading zero where applicable (00 to 59) + \row \li z \li the fractional part of the second, to go after a decimal + point, without trailing zeroes (0 to 999). Thus "\c{s.z}" + reports the seconds to full available (millisecond) precision + without trailing zeroes. + \row \li zzz \li the fractional part of the second, to millisecond + precision, including trailing zeroes where applicable (000 to 999). \row \li AP or A \li use AM/PM display. \e A/AP will be replaced by either QLocale::amText() or QLocale::pmText(). @@ -1991,10 +1995,14 @@ QTime QTime::fromString(const QString& string, Qt::DateFormat format) \li the hour with a leading zero (00 to 23 or 01 to 12 if AM/PM display) \row \li m \li the minute without a leading zero (0 to 59) \row \li mm \li the minute with a leading zero (00 to 59) - \row \li s \li the second without a leading zero (0 to 59) - \row \li ss \li the second with a leading zero (00 to 59) - \row \li z \li the milliseconds without leading zeroes (0 to 999) - \row \li zzz \li the milliseconds with leading zeroes (000 to 999) + \row \li s \li the whole second, without any leading zero (0 to 59) + \row \li ss \li the whole second, with a leading zero where applicable (00 to 59) + \row \li z \li the fractional part of the second, to go after a decimal + point, without trailing zeroes (0 to 999). Thus "\c{s.z}" + reports the seconds to full available (millisecond) precision + without trailing zeroes. + \row \li zzz \li the fractional part of the second, to millisecond + precision, including trailing zeroes where applicable (000 to 999). \row \li AP \li interpret as an AM/PM time. \e AP must be either "AM" or "PM". \row \li ap @@ -3895,10 +3903,14 @@ QString QDateTime::toString(Qt::DateFormat format) const \li the hour with a leading zero (00 to 23, even with AM/PM display) \row \li m \li the minute without a leading zero (0 to 59) \row \li mm \li the minute with a leading zero (00 to 59) - \row \li s \li the second without a leading zero (0 to 59) - \row \li ss \li the second with a leading zero (00 to 59) - \row \li z \li the milliseconds without leading zeroes (0 to 999) - \row \li zzz \li the milliseconds with leading zeroes (000 to 999) + \row \li s \li the whole second without a leading zero (0 to 59) + \row \li ss \li the whole second with a leading zero where applicable (00 to 59) + \row \li z \li the fractional part of the second, to go after a decimal + point, without trailing zeroes (0 to 999). Thus "\c{s.z}" + reports the seconds to full available (millisecond) precision + without trailing zeroes. + \row \li zzz \li the fractional part of the second, to millisecond + precision, including trailing zeroes where applicable (000 to 999). \row \li AP or A \li use AM/PM display. \e A/AP will be replaced by either "AM" or "PM". \row \li ap or a @@ -3912,13 +3924,14 @@ QString QDateTime::toString(Qt::DateFormat format) const in the output. Formats without separators (e.g. "HHmm") are currently not supported. Example format strings (assumed that the QDateTime is 21 May 2001 - 14:13:09): + 14:13:09.120): \table \header \li Format \li Result \row \li dd.MM.yyyy \li 21.05.2001 \row \li ddd MMMM d yy \li Tue May 21 01 - \row \li hh:mm:ss.zzz \li 14:13:09.042 + \row \li hh:mm:ss.zzz \li 14:13:09.120 + \row \li hh:mm:ss.z \li 14:13:09.12 \row \li h:m:s ap \li 2:13:9 pm \endtable @@ -4918,10 +4931,14 @@ QDateTime QDateTime::fromString(const QString& string, Qt::DateFormat format) \li the hour with a leading zero (00 to 23, even with AM/PM display) \row \li m \li the minute without a leading zero (0 to 59) \row \li mm \li the minute with a leading zero (00 to 59) - \row \li s \li the second without a leading zero (0 to 59) - \row \li ss \li the second with a leading zero (00 to 59) - \row \li z \li the milliseconds without leading zeroes (0 to 999) - \row \li zzz \li the milliseconds with leading zeroes (000 to 999) + \row \li s \li the whole second without a leading zero (0 to 59) + \row \li ss \li the whole second with a leading zero where applicable (00 to 59) + \row \li z \li the fractional part of the second, to go after a decimal + point, without trailing zeroes (0 to 999). Thus "\c{s.z}" + reports the seconds to full available (millisecond) precision + without trailing zeroes. + \row \li zzz \li the fractional part of the second, to millisecond + precision, including trailing zeroes where applicable (000 to 999). \row \li AP or A \li interpret as an AM/PM time. \e AP must be either "AM" or "PM". \row \li ap or a diff --git a/src/corelib/tools/qlocale.cpp b/src/corelib/tools/qlocale.cpp index dcdf6b5ed74..ab95f601158 100644 --- a/src/corelib/tools/qlocale.cpp +++ b/src/corelib/tools/qlocale.cpp @@ -2742,14 +2742,17 @@ QString QLocalePrivate::dateTimeToString(const QString &format, const QDateTime } else { repeat = 1; } - switch (repeat) { - case 1: - result.append(m_data->longLongToString(time.msec())); - break; - case 3: - result.append(m_data->longLongToString(time.msec(), -1, 10, 3, QLocaleData::ZeroPadded)); - break; + + // note: the millisecond component is treated like the decimal part of the seconds + // so ms == 2 is always printed as "002", but ms == 200 can be either "2" or "200" + result.append(m_data->longLongToString(time.msec(), -1, 10, 3, QLocaleData::ZeroPadded)); + if (repeat == 1) { + if (result.endsWith(zero())) + result.chop(1); + if (result.endsWith(zero())) + result.chop(1); } + break; case 't': diff --git a/tests/auto/corelib/tools/qlocale/tst_qlocale.cpp b/tests/auto/corelib/tools/qlocale/tst_qlocale.cpp index 9ca8766592f..f278a7470b4 100644 --- a/tests/auto/corelib/tools/qlocale/tst_qlocale.cpp +++ b/tests/auto/corelib/tools/qlocale/tst_qlocale.cpp @@ -1302,10 +1302,11 @@ void tst_QLocale::formatTime_data() QTest::newRow("28") << QTime(1, 2, 3, 456) << "H:m:s.z" << "1:2:3.456"; QTest::newRow("29") << QTime(1, 2, 3, 456) << "H:m:s.zz" << "1:2:3.456456"; QTest::newRow("30") << QTime(1, 2, 3, 456) << "H:m:s.zzz" << "1:2:3.456"; - QTest::newRow("31") << QTime(1, 2, 3, 4) << "H:m:s.z" << "1:2:3.4"; - QTest::newRow("32") << QTime(1, 2, 3, 4) << "H:m:s.zzz" << "1:2:3.004"; - QTest::newRow("33") << QTime() << "H:m:s.zzz" << ""; - QTest::newRow("34") << QTime(1, 2, 3, 4) << "dd MM yyyy H:m:s.zzz" << "dd MM yyyy 1:2:3.004"; + QTest::newRow("31") << QTime(1, 2, 3, 400) << "H:m:s.z" << "1:2:3.4"; + QTest::newRow("32") << QTime(1, 2, 3, 4) << "H:m:s.z" << "1:2:3.004"; + QTest::newRow("33") << QTime(1, 2, 3, 4) << "H:m:s.zzz" << "1:2:3.004"; + QTest::newRow("34") << QTime() << "H:m:s.zzz" << ""; + QTest::newRow("35") << QTime(1, 2, 3, 4) << "dd MM yyyy H:m:s.zzz" << "dd MM yyyy 1:2:3.004"; } void tst_QLocale::formatTime() @@ -1542,10 +1543,12 @@ void tst_QLocale::toDateTime_data() << "d/M/yyyy hh:h:mm" << "1/12/1974 05:5:14"; QTest::newRow("2C") << "C" << QDateTime(QDate(1974, 12, 1), QTime(15, 0, 0)) << "d/M/yyyyy h" << "1/12/1974y 15"; - QTest::newRow("4C") << "C" << QDateTime(QDate(1974, 1, 1), QTime(0, 0, 0)) - << "d/M/yyyy zzz" << "1/1/1974 000"; - QTest::newRow("5C") << "C" << QDateTime(QDate(1974, 1, 1), QTime(0, 0, 0)) - << "dd/MM/yyy z" << "01/01/74y 0"; + QTest::newRow("4C") << "C" << QDateTime(QDate(1974, 1, 1), QTime(0, 0, 0, 1)) + << "d/M/yyyy zzz" << "1/1/1974 001"; + QTest::newRow("5C") << "C" << QDateTime(QDate(1974, 1, 1), QTime(0, 0, 0, 1)) + << "dd/MM/yyy z" << "01/01/74y 001"; + QTest::newRow("5Cbis") << "C" << QDateTime(QDate(1974, 1, 1), QTime(0, 0, 0, 100)) + << "dd/MM/yyy z" << "01/01/74y 1"; QTest::newRow("8C") << "C" << QDateTime(QDate(1974, 12, 2), QTime(0, 0, 13)) << "ddddd/MMMMM/yy ss" << "Monday2/December12/74 13"; QTest::newRow("9C") << "C" << QDateTime(QDate(1974, 12, 1), QTime(0, 0, 13)) diff --git a/tests/auto/corelib/tools/qtime/tst_qtime.cpp b/tests/auto/corelib/tools/qtime/tst_qtime.cpp index 71bf39fc4e9..162047b5371 100644 --- a/tests/auto/corelib/tools/qtime/tst_qtime.cpp +++ b/tests/auto/corelib/tools/qtime/tst_qtime.cpp @@ -560,6 +560,8 @@ void tst_QTime::fromStringFormat_data() QTest::newRow("data9") << QString("2221") << QString("hhhh") << invalidTime(); QTest::newRow("data10") << QString("02:23PM") << QString("hh:mmAP") << QTime(14,23,0,0); QTest::newRow("data11") << QString("02:23pm") << QString("hh:mmap") << QTime(14,23,0,0); + QTest::newRow("short-msecs-lt100") << QString("10:12:34:045") << QString("hh:m:ss:z") << QTime(10,12,34,45); + QTest::newRow("short-msecs-gt100") << QString("10:12:34:45") << QString("hh:m:ss:z") << QTime(10,12,34,450); } void tst_QTime::fromStringFormat() @@ -711,12 +713,13 @@ void tst_QTime::toStringFormat_data() QTest::addColumn("format"); QTest::addColumn("str"); - QTest::newRow( "data0" ) << QTime(0,0,0,0) << QString("h:m:s:z") << QString("0:0:0:0"); - QTest::newRow( "data1" ) << QTime(10,12,34,53) << QString("hh:mm:ss:zzz") << QString("10:12:34:053"); - QTest::newRow( "data2" ) << QTime(10,12,34,45) << QString("hh:m:ss:z") << QString("10:12:34:45"); - QTest::newRow( "data3" ) << QTime(10,12,34,45) << QString("hh:ss ap") << QString("10:34 am"); - QTest::newRow( "data4" ) << QTime(22,12,34,45) << QString("hh:zzz AP") << QString("10:045 PM"); - QTest::newRow( "data5" ) << QTime(230,230,230,230) << QString("hh:mm:ss") << QString(); + QTest::newRow( "midnight" ) << QTime(0,0,0,0) << QString("h:m:s:z") << QString("0:0:0:0"); + QTest::newRow( "full" ) << QTime(10,12,34,53) << QString("hh:mm:ss:zzz") << QString("10:12:34:053"); + QTest::newRow( "short-msecs-lt100" ) << QTime(10,12,34,45) << QString("hh:m:ss:z") << QString("10:12:34:045"); + QTest::newRow( "short-msecs-gt100" ) << QTime(10,12,34,450) << QString("hh:m:ss:z") << QString("10:12:34:45"); + QTest::newRow( "am-pm" ) << QTime(10,12,34,45) << QString("hh:ss ap") << QString("10:34 am"); + QTest::newRow( "AM-PM" ) << QTime(22,12,34,45) << QString("hh:zzz AP") << QString("10:045 PM"); + QTest::newRow( "invalid" ) << QTime(230,230,230,230) << QString("hh:mm:ss") << QString(); } void tst_QTime::toStringFormat() From 35096261282bfb2d66373d290dfa35b993158bb8 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Wed, 5 Jul 2017 21:52:52 -0700 Subject: [PATCH 21/63] QDeadlineTimer: round milliseconds up instead of down Code like: QElapsedTimer timer; timer.start(); QTest::qWait(30); QVERIFY(timer.elapsed() >= 30); is failing, because qWait sleeps in increments of 10 ms and the last chunk may be off by less than one millisecond, so we end up sleeping too little and thus returning before 30 ms have elapsed. This matches the QElapsedTimer::elapsed() code that rounds down: return nsecsElapsed() / Q_INT64_C(1000000); Task-number: QTBUG-61741 Change-Id: Ic3a088f9f08a4fd7ae91fffd14cea4a91d3f51a8 Reviewed-by: Allan Sandfeld Jensen --- src/corelib/kernel/qdeadlinetimer.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/corelib/kernel/qdeadlinetimer.cpp b/src/corelib/kernel/qdeadlinetimer.cpp index a2ec813f11b..ae4ffdcefce 100644 --- a/src/corelib/kernel/qdeadlinetimer.cpp +++ b/src/corelib/kernel/qdeadlinetimer.cpp @@ -420,7 +420,7 @@ void QDeadlineTimer::setTimerType(Qt::TimerType timerType) qint64 QDeadlineTimer::remainingTime() const Q_DECL_NOTHROW { qint64 ns = remainingTimeNSecs(); - return ns <= 0 ? ns : ns / (1000 * 1000); + return ns <= 0 ? ns : (ns + 999999) / (1000 * 1000); } /*! From c7ea60d1abd65d5c85fc5e690a28935c9b4a2dec Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Wed, 14 Jun 2017 10:41:42 -0700 Subject: [PATCH 22/63] QWizard: Fix null pointer dereference if no pixmap was set The pixmap may be set in QWizardPrivate::updateLayout() if there's a side widget or a watermark. If neither exists, then no pixmap is set and this would cause a crash. Task-number: QTBUG-61423 Change-Id: Ia53158e207a94bf49489fffd14c80dd93415dd0f Reviewed-by: Timur Pocheptsov --- src/widgets/dialogs/qwizard.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/widgets/dialogs/qwizard.cpp b/src/widgets/dialogs/qwizard.cpp index 432b6f18797..4d89cd99362 100644 --- a/src/widgets/dialogs/qwizard.cpp +++ b/src/widgets/dialogs/qwizard.cpp @@ -450,7 +450,7 @@ public: } QSize minimumSizeHint() const Q_DECL_OVERRIDE { - if (!pixmap() && !pixmap()->isNull()) + if (pixmap() && !pixmap()->isNull()) return pixmap()->size(); return QFrame::minimumSizeHint(); } From 9bec818ccc0c0eddd3029540f65e3be26eae29db Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Tue, 13 Jun 2017 09:44:46 -0700 Subject: [PATCH 23/63] Use the namespace-mangled symbol for the qt_version_tag group name Doesn't affect our current builds since it's just a marker for the linker on what sections should be merged. Unless you're mixing namespaced and non-namespaced static builds into one executable. Change-Id: Ia53158e207a94bf49489fffd14c7bc294fccf8f9 Reviewed-by: Oswald Buddenhagen Reviewed-by: Thiago Macieira --- src/corelib/global/qversiontagging.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/corelib/global/qversiontagging.h b/src/corelib/global/qversiontagging.h index 3ed02c7376a..75c2e9df7ef 100644 --- a/src/corelib/global/qversiontagging.h +++ b/src/corelib/global/qversiontagging.h @@ -71,7 +71,7 @@ QT_BEGIN_NAMESPACE # endif # define QT_VERSION_TAG(sym) \ asm ( \ - ".section .qtversion, \"aG\", @progbits, qt_version_tag, comdat\n" \ + ".section .qtversion, \"aG\", @progbits, " QT_STRINGIFY(QT_MANGLE_NAMESPACE(sym)) ", comdat\n" \ ".align 8\n" \ QT_VERSION_TAG_RELOC(sym) \ ".long " QT_STRINGIFY(QT_VERSION) "\n" \ From db404fea64074b353b2f1766dffd26aa24bdbd50 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Mon, 19 Jun 2017 16:35:52 +0200 Subject: [PATCH 24/63] QListView: Fix viewport size when checking scroll bar visibility Subtract the viewport margins from the contentsRect in QCommonListViewBase::updateHorizontal/VerticalScrollBar(). This affects list views in icon mode and list mode / ScrollPerPixel. Task-number: QTBUG-61383 Change-Id: I6f2f7951ac9344ac21cef1eba061780d130e2467 Reviewed-by: David Faure --- src/widgets/itemviews/qlistview.cpp | 9 +- src/widgets/itemviews/qlistview_p.h | 1 + .../itemviews/qlistview/tst_qlistview.cpp | 83 ++++++++++++++++--- 3 files changed, 81 insertions(+), 12 deletions(-) diff --git a/src/widgets/itemviews/qlistview.cpp b/src/widgets/itemviews/qlistview.cpp index 93b2b0b5e0e..396d84de9cd 100644 --- a/src/widgets/itemviews/qlistview.cpp +++ b/src/widgets/itemviews/qlistview.cpp @@ -1871,6 +1871,11 @@ void QCommonListViewBase::paintDragDrop(QPainter *painter) } #endif +QSize QListModeViewBase::viewportSize(const QAbstractItemView *v) +{ + return v->contentsRect().marginsRemoved(v->viewportMargins()).size(); +} + void QCommonListViewBase::updateHorizontalScrollBar(const QSize &step) { horizontalScrollBar()->d_func()->itemviewChangeSingleStep(step.width() + spacing()); @@ -1883,7 +1888,7 @@ void QCommonListViewBase::updateHorizontalScrollBar(const QSize &step) const bool bothScrollBarsAuto = qq->verticalScrollBarPolicy() == Qt::ScrollBarAsNeeded && qq->horizontalScrollBarPolicy() == Qt::ScrollBarAsNeeded; - const QSize viewportSize = qq->contentsRect().size(); + const QSize viewportSize = QListModeViewBase::viewportSize(qq); bool verticalWantsToShow = contentsSize.height() > viewportSize.height(); bool horizontalWantsToShow; @@ -1913,7 +1918,7 @@ void QCommonListViewBase::updateVerticalScrollBar(const QSize &step) const bool bothScrollBarsAuto = qq->verticalScrollBarPolicy() == Qt::ScrollBarAsNeeded && qq->horizontalScrollBarPolicy() == Qt::ScrollBarAsNeeded; - const QSize viewportSize = qq->contentsRect().size(); + const QSize viewportSize = QListModeViewBase::viewportSize(qq); bool horizontalWantsToShow = contentsSize.width() > viewportSize.width(); bool verticalWantsToShow; diff --git a/src/widgets/itemviews/qlistview_p.h b/src/widgets/itemviews/qlistview_p.h index 47effcdfd99..5b674b3eca0 100644 --- a/src/widgets/itemviews/qlistview_p.h +++ b/src/widgets/itemviews/qlistview_p.h @@ -225,6 +225,7 @@ public: QRect mapToViewport(const QRect &rect) const override; int horizontalOffset() const override; int verticalOffset() const override; + inline static QSize viewportSize(const QAbstractItemView *v); void updateHorizontalScrollBar(const QSize &step) override; void updateVerticalScrollBar(const QSize &step) override; diff --git a/tests/auto/widgets/itemviews/qlistview/tst_qlistview.cpp b/tests/auto/widgets/itemviews/qlistview/tst_qlistview.cpp index a89f8f3c8ae..b9785c35ac9 100644 --- a/tests/auto/widgets/itemviews/qlistview/tst_qlistview.cpp +++ b/tests/auto/widgets/itemviews/qlistview/tst_qlistview.cpp @@ -60,6 +60,10 @@ static inline HWND getHWNDForWidget(const QWidget *widget) } #endif // Q_OS_WIN +Q_DECLARE_METATYPE(QAbstractItemView::ScrollMode) +Q_DECLARE_METATYPE(QMargins) +Q_DECLARE_METATYPE(QSize) + // Make a widget frameless to prevent size constraints of title bars // from interfering (Windows). static inline void setFrameless(QWidget *w) @@ -902,10 +906,11 @@ class PublicListView : public QListView class TestDelegate : public QItemDelegate { public: - TestDelegate(QObject *parent) : QItemDelegate(parent), m_sizeHint(50,50) {} + explicit TestDelegate(QObject *parent, const QSize &sizeHint = QSize(50,50)) + : QItemDelegate(parent), m_sizeHint(sizeHint) {} QSize sizeHint(const QStyleOptionViewItem &, const QModelIndex &) const { return m_sizeHint; } - QSize m_sizeHint; + const QSize m_sizeHint; }; typedef QList IntList; @@ -1250,9 +1255,7 @@ void tst_QListView::scrollBarRanges() lv.setModel(&model); lv.resize(250, 130); - TestDelegate *delegate = new TestDelegate(&lv); - delegate->m_sizeHint = QSize(100, rowHeight); - lv.setItemDelegate(delegate); + lv.setItemDelegate(new TestDelegate(&lv, QSize(100, rowHeight))); topLevel.show(); for (int h = 30; h <= 210; ++h) { @@ -1268,14 +1271,18 @@ void tst_QListView::scrollBarAsNeeded_data() { QTest::addColumn("size"); QTest::addColumn("itemCount"); + QTest::addColumn("verticalScrollMode"); + QTest::addColumn("viewportMargins"); + QTest::addColumn("delegateSize"); QTest::addColumn("flow"); QTest::addColumn("horizontalScrollBarVisible"); QTest::addColumn("verticalScrollBarVisible"); - QTest::newRow("TopToBottom, count:0") << QSize(200, 100) << 0 + << QListView::ScrollPerItem + << QMargins() << QSize() << int(QListView::TopToBottom) << false << false; @@ -1283,6 +1290,8 @@ void tst_QListView::scrollBarAsNeeded_data() QTest::newRow("TopToBottom, count:1") << QSize(200, 100) << 1 + << QListView::ScrollPerItem + << QMargins() << QSize() << int(QListView::TopToBottom) << false << false; @@ -1290,13 +1299,46 @@ void tst_QListView::scrollBarAsNeeded_data() QTest::newRow("TopToBottom, count:20") << QSize(200, 100) << 20 + << QListView::ScrollPerItem + << QMargins() << QSize() << int(QListView::TopToBottom) << false << true; + QTest::newRow("TopToBottom, fixed size, count:4") + << QSize(200, 200) + << 4 + << QListView::ScrollPerPixel + << QMargins() << QSize(40, 40) + << int(QListView::TopToBottom) + << false + << false; + + // QTBUG-61383, vertical case: take viewport margins into account + QTest::newRow("TopToBottom, fixed size, vertical margins, count:4") + << QSize(200, 200) + << 4 + << QListView::ScrollPerPixel + << QMargins(0, 50, 0, 50) << QSize(40, 40) + << int(QListView::TopToBottom) + << false + << true; + + // QTBUG-61383, horizontal case: take viewport margins into account + QTest::newRow("TopToBottom, fixed size, horizontal margins, count:4") + << QSize(200, 200) + << 4 + << QListView::ScrollPerPixel + << QMargins(50, 0, 50, 0) << QSize(120, 40) + << int(QListView::TopToBottom) + << true + << false; + QTest::newRow("LeftToRight, count:0") << QSize(200, 100) << 0 + << QListView::ScrollPerItem + << QMargins() << QSize() << int(QListView::LeftToRight) << false << false; @@ -1304,6 +1346,8 @@ void tst_QListView::scrollBarAsNeeded_data() QTest::newRow("LeftToRight, count:1") << QSize(200, 100) << 1 + << QListView::ScrollPerItem + << QMargins() << QSize() << int(QListView::LeftToRight) << false << false; @@ -1311,17 +1355,31 @@ void tst_QListView::scrollBarAsNeeded_data() QTest::newRow("LeftToRight, count:20") << QSize(200, 100) << 20 + << QListView::ScrollPerItem + << QMargins() << QSize() << int(QListView::LeftToRight) << true << false; } + +class ScrollBarTestListView : public QListView +{ + public: + explicit ScrollBarTestListView(QWidget *p) : QListView(p) {} + + using QAbstractScrollArea::setViewportMargins; +}; + void tst_QListView::scrollBarAsNeeded() { QFETCH(QSize, size); QFETCH(int, itemCount); + QFETCH(QAbstractItemView::ScrollMode, verticalScrollMode); + QFETCH(QMargins, viewportMargins); + QFETCH(QSize, delegateSize); QFETCH(int, flow); QFETCH(bool, horizontalScrollBarVisible); QFETCH(bool, verticalScrollBarVisible); @@ -1330,10 +1388,17 @@ void tst_QListView::scrollBarAsNeeded() const int rowCounts[3] = {0, 1, 20}; QWidget topLevel; - QListView lv(&topLevel); + topLevel.setWindowTitle(QLatin1String(QTest::currentTestFunction()) + QStringLiteral("::") + + QLatin1String(QTest::currentDataTag())); + ScrollBarTestListView lv(&topLevel); lv.setVerticalScrollBarPolicy(Qt::ScrollBarAsNeeded); lv.setHorizontalScrollBarPolicy(Qt::ScrollBarAsNeeded); + lv.setVerticalScrollMode(verticalScrollMode); + lv.setViewportMargins(viewportMargins); lv.setFlow((QListView::Flow)flow); + if (!delegateSize.isEmpty()) + lv.setItemDelegate(new TestDelegate(&lv, delegateSize)); + QStringListModel model(&lv); lv.setModel(&model); lv.resize(size); @@ -2380,9 +2445,7 @@ void tst_QListView::horizontalScrollingByVerticalWheelEvents() QListView lv; lv.setWrapping(true); - TestDelegate *delegate = new TestDelegate(&lv); - delegate->m_sizeHint = QSize(100, 100); - lv.setItemDelegate(delegate); + lv.setItemDelegate(new TestDelegate(&lv, QSize(100, 100))); QtTestModel model; model.colCount = 1; From e10be52e2144e27d1f9df334de81abf9c57b0af8 Mon Sep 17 00:00:00 2001 From: Orgad Shaneh Date: Thu, 22 Jun 2017 10:49:34 +0300 Subject: [PATCH 25/63] qmake: Separate object_script by Makefile name If several Makefiles are used in the same directory (for example, for multiple projects in the same directory or different build configurations), they all reference the same object_script, which is obviously wrong. Change-Id: I9b499ceb6b6bd6058f54b452fa44bfb2313eec26 Reviewed-by: Oswald Buddenhagen --- qmake/generators/win32/mingw_make.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/qmake/generators/win32/mingw_make.cpp b/qmake/generators/win32/mingw_make.cpp index b9895fb10dc..c3b876531c4 100644 --- a/qmake/generators/win32/mingw_make.cpp +++ b/qmake/generators/win32/mingw_make.cpp @@ -292,6 +292,8 @@ void MingwMakefileGenerator::writeObjectsPart(QTextStream &t) if (!var("BUILD_NAME").isEmpty()) { ar_script_file += "." + var("BUILD_NAME"); } + if (!var("MAKEFILE").isEmpty()) + ar_script_file += "." + var("MAKEFILE"); // QMAKE_LIB is used for win32, including mingw, whereas QMAKE_AR is used on Unix. // Strip off any options since the ar commands will be read from file. QString ar_cmd = var("QMAKE_LIB").section(" ", 0, 0); @@ -304,6 +306,8 @@ void MingwMakefileGenerator::writeObjectsPart(QTextStream &t) if (!var("BUILD_NAME").isEmpty()) { ld_script_file += "." + var("BUILD_NAME"); } + if (!var("MAKEFILE").isEmpty()) + ld_script_file += "." + var("MAKEFILE"); createLdObjectScriptFile(ld_script_file, project->values("OBJECTS")); objectsLinkLine = escapeFilePath(ld_script_file); } From 5772cac426d617ca1c6e27ab54b3c2e3f4cb046a Mon Sep 17 00:00:00 2001 From: Orgad Shaneh Date: Fri, 16 Jun 2017 15:10:16 +0300 Subject: [PATCH 26/63] qmake: Do not default to -pipe on Windows It is considered slightly faster than the default mode[1], but on Windows it causes trouble when aborting the build, it leaves behind zero-sized object files which cause link error. See discussion in the bug-make mailing list[2]. [1] https://stackoverflow.com/a/1512947/764870 [2] http://lists.gnu.org/archive/html/bug-make/2017-06/msg00066.html Change-Id: I7aa0b328a8c743fdfe9b0aece02b329066515076 Reviewed-by: Oswald Buddenhagen --- mkspecs/common/gcc-base.conf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mkspecs/common/gcc-base.conf b/mkspecs/common/gcc-base.conf index e7e6ee1815a..6a2fa4f5062 100644 --- a/mkspecs/common/gcc-base.conf +++ b/mkspecs/common/gcc-base.conf @@ -36,7 +36,7 @@ QMAKE_CFLAGS_OPTIMIZE_FULL = -O3 QMAKE_CFLAGS_OPTIMIZE_DEBUG = -Og QMAKE_CFLAGS_OPTIMIZE_SIZE = -Os -QMAKE_CFLAGS += -pipe +!equals(QMAKE_HOST.os, Windows): QMAKE_CFLAGS += -pipe QMAKE_CFLAGS_DEPS += -M QMAKE_CFLAGS_WARN_ON += -Wall -W QMAKE_CFLAGS_WARN_OFF += -w From e53a57d25421cfbb8cbbd1d1a8201d4a02ef3d67 Mon Sep 17 00:00:00 2001 From: Berthold Krevert Date: Thu, 6 Jul 2017 22:27:42 +0200 Subject: [PATCH 27/63] Add Q_FALLTHROUGH Change-Id: I14efe4dbffb5808f3f9b763f7dae38301a1f6e5c Reviewed-by: Timur Pocheptsov --- src/plugins/sqldrivers/ibase/qsql_ibase.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/plugins/sqldrivers/ibase/qsql_ibase.cpp b/src/plugins/sqldrivers/ibase/qsql_ibase.cpp index 6fd91b6b766..2b75f3c9640 100644 --- a/src/plugins/sqldrivers/ibase/qsql_ibase.cpp +++ b/src/plugins/sqldrivers/ibase/qsql_ibase.cpp @@ -544,6 +544,7 @@ static char* readArrayBuffer(QList& list, char *buffer, short curDim, case blr_varying: case blr_varying2: strLen += 2; // for the two terminating null values + Q_FALLTHROUGH(); case blr_text: case blr_text2: { int o; From d7bfbf3a13029e26145c64acfe2e5e09f6faba3f Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Thu, 6 Jul 2017 14:00:48 +0200 Subject: [PATCH 28/63] Windows QPA: Further restrict windows for WM_DPICHANGED Exclude popups among other non-applicable windows types from resizing in WM_DPICHANGED. When resizing was enabled for non-fixed size windows by c854fc5a6be1e94d2ea313a1d0ef637bc3df178f it turned out that context menus were truncated when moving an application from a high resolution to a low resolution monitor. Factor out a function to check for the applicable window types. Amends 886ce572d628e7cd98cc39edcc930ffae951e95e, c854fc5a6be1e94d2ea313a1d0ef637bc3df178f. Task-number: QTBUG-55510 Change-Id: I16fee07f3e11828848ec71cdceadff958cedb13a Reviewed-by: Alexandru Croitor --- .../platforms/windows/qwindowscontext.cpp | 26 ++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) diff --git a/src/plugins/platforms/windows/qwindowscontext.cpp b/src/plugins/platforms/windows/qwindowscontext.cpp index a042212dd37..7115d074c9d 100644 --- a/src/plugins/platforms/windows/qwindowscontext.cpp +++ b/src/plugins/platforms/windows/qwindowscontext.cpp @@ -824,6 +824,27 @@ static inline QWindowsInputContext *windowsInputContext() return qobject_cast(QWindowsIntegration::instance()->inputContext()); } + +// Child windows, fixed-size windows or pop-ups and similar should not be resized +static inline bool resizeOnDpiChanged(const QWindow *w) +{ + bool result = false; + if (w->isTopLevel()) { + switch (w->type()) { + case Qt::Window: + case Qt::Dialog: + case Qt::Sheet: + case Qt::Drawer: + case Qt::Tool: + result = !w->flags().testFlag(Qt::MSWindowsFixedSizeDialogHint); + break; + default: + break; + } + } + return result; +} + /*! \brief Main windows procedure registered for windows. @@ -1106,9 +1127,8 @@ bool QWindowsContext::windowsProc(HWND hwnd, UINT message, #endif } break; case QtWindows::DpiChangedEvent: { - if (platformWindow->window()->flags().testFlag(Qt::MSWindowsFixedSizeDialogHint)) - return false; // Fixed-size window should not be resized - + if (!resizeOnDpiChanged(platformWindow->window())) + return false; platformWindow->setFlag(QWindowsWindow::WithinDpiChanged); const RECT *prcNewWindow = reinterpret_cast(lParam); SetWindowPos(hwnd, NULL, prcNewWindow->left, prcNewWindow->top, From 3fb08520914e6d2ff125e54ebccf0c9a77a0034c Mon Sep 17 00:00:00 2001 From: Simon Hausmann Date: Fri, 7 Jul 2017 10:41:15 +0200 Subject: [PATCH 29/63] Skip the dbus abstract adaptor test on OpenSuSE 42.1 It has been crashing for months... Change-Id: I1d6077f949d642465771c4d618babc64ebc340f6 Reviewed-by: Friedemann Kleint --- .../dbus/qdbusabstractadaptor/tst_qdbusabstractadaptor.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/tests/auto/dbus/qdbusabstractadaptor/tst_qdbusabstractadaptor.cpp b/tests/auto/dbus/qdbusabstractadaptor/tst_qdbusabstractadaptor.cpp index 0edc5a92ea1..20cd8caad34 100644 --- a/tests/auto/dbus/qdbusabstractadaptor/tst_qdbusabstractadaptor.cpp +++ b/tests/auto/dbus/qdbusabstractadaptor/tst_qdbusabstractadaptor.cpp @@ -1083,6 +1083,11 @@ void tst_QDBusAbstractAdaptor::methodCallsPeer_data() void tst_QDBusAbstractAdaptor::methodCallsPeer() { + if (QSysInfo::productType().compare("opensuse", Qt::CaseInsensitive) == 0 + && QSysInfo::productVersion() == QLatin1String("42.1") + && qgetenv("QTEST_ENVIRONMENT").split(' ').contains("ci")) { + QSKIP("This test is occasionally hanging in the CI"); + } QDBusConnection con("peer"); QVERIFY(con.isConnected()); From 9d3cd2268ce3beafcf6fa886bb70d8463260d602 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= Date: Thu, 6 Jul 2017 17:03:41 +0200 Subject: [PATCH 30/63] macOS: Account for fullscreen geometry bug in AppKit on OS X 10.10 Task-number: QTBUG-61776 Change-Id: Ifac502cf422088eafe9211d759f2f5cd9769d0d3 Reviewed-by: Gabriel de Dietrich --- src/plugins/platforms/cocoa/qnswindowdelegate.mm | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/plugins/platforms/cocoa/qnswindowdelegate.mm b/src/plugins/platforms/cocoa/qnswindowdelegate.mm index ce74aa99739..a18fe693fa5 100644 --- a/src/plugins/platforms/cocoa/qnswindowdelegate.mm +++ b/src/plugins/platforms/cocoa/qnswindowdelegate.mm @@ -78,6 +78,21 @@ return m_cocoaWindow->screen()->availableGeometry().toCGRect(); } +#if QT_MACOS_DEPLOYMENT_TARGET_BELOW(__MAC_10_11) +/* + AppKit on OS X 10.10 wrongly calls windowWillUseStandardFrame:defaultFrame + from -[NSWindow _frameForFullScreenMode] when going into fullscreen, resulting + in black bars on top and bottom of the window. By implementing the following + method, AppKit will choose that instead, and resolve the right fullscreen + geometry. +*/ +- (NSSize)window:(NSWindow *)window willUseFullScreenContentSize:(NSSize)proposedSize +{ + Q_ASSERT(NSEqualSizes(m_cocoaWindow->screen()->geometry().size().toCGSize(), proposedSize)); + return proposedSize; +} +#endif + - (BOOL)window:(NSWindow *)window shouldPopUpDocumentPathMenu:(NSMenu *)menu { Q_UNUSED(window); From b6d5026b1f8d7ed6424f9a395d47fc4c62d4751b Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Fri, 7 Jul 2017 14:01:29 +0200 Subject: [PATCH 31/63] QWidgets/drawutils: Handle device pixel ratio != 1 The panel drawing helpers have code drawing shadows that relies on working with integer coordinates and one pixel lines, which causes artifacts when Qt High DPI scaling is in effect. Add code that checks for device pixel ratio != 1 and in that case reverts out the Qt High DPI scaling transformation and scales the parameters so that the drawing code used device pixels. Task-number: QTBUG-58611 Task-number: QTBUG-59116 Change-Id: I8402044f3fd4dfcd349b31c573dcad12ae1f609f Reviewed-by: Alessandro Portale --- src/widgets/styles/qdrawutil.cpp | 85 ++++++++++++++++++++++++++++++++ 1 file changed, 85 insertions(+) diff --git a/src/widgets/styles/qdrawutil.cpp b/src/widgets/styles/qdrawutil.cpp index 0b0583ea941..299dbb9f823 100644 --- a/src/widgets/styles/qdrawutil.cpp +++ b/src/widgets/styles/qdrawutil.cpp @@ -49,6 +49,35 @@ QT_BEGIN_NAMESPACE +namespace { +class PainterStateGuard { + Q_DISABLE_COPY(PainterStateGuard) +public: + explicit PainterStateGuard(QPainter *p) : m_painter(p) {} + ~PainterStateGuard() + { + for ( ; m_level > 0; --m_level) + m_painter->restore(); + } + + void save() + { + m_painter->save(); + ++m_level; + } + + void restore() + { + m_painter->restore(); + --m_level; + } + +private: + QPainter *m_painter; + int m_level= 0; +}; +} // namespace + /*! \headerfile \title Drawing Utility Functions @@ -213,6 +242,21 @@ void qDrawShadeRect(QPainter *p, int x, int y, int w, int h, qWarning("qDrawShadeRect: Invalid parameters"); return; } + + PainterStateGuard painterGuard(p); + const qreal devicePixelRatio = p->device()->devicePixelRatioF(); + if (!qFuzzyCompare(devicePixelRatio, qreal(1))) { + painterGuard.save(); + const qreal inverseScale = qreal(1) / devicePixelRatio; + p->scale(inverseScale, inverseScale); + x = qRound(devicePixelRatio * x); + y = qRound(devicePixelRatio * y); + w = qRound(devicePixelRatio * w); + h = qRound(devicePixelRatio * h); + lineWidth = qRound(devicePixelRatio * lineWidth); + midLineWidth = qRound(devicePixelRatio * midLineWidth); + } + QPen oldPen = p->pen(); if (sunken) p->setPen(pal.dark().color()); @@ -312,6 +356,20 @@ void qDrawShadePanel(QPainter *p, int x, int y, int w, int h, if (Q_UNLIKELY(w < 0 || h < 0 || lineWidth < 0)) { qWarning("qDrawShadePanel: Invalid parameters"); } + + PainterStateGuard painterGuard(p); + const qreal devicePixelRatio = p->device()->devicePixelRatioF(); + if (!qFuzzyCompare(devicePixelRatio, qreal(1))) { + painterGuard.save(); + const qreal inverseScale = qreal(1) / devicePixelRatio; + p->scale(inverseScale, inverseScale); + x = qRound(devicePixelRatio * x); + y = qRound(devicePixelRatio * y); + w = qRound(devicePixelRatio * w); + h = qRound(devicePixelRatio * h); + lineWidth = qRound(devicePixelRatio * lineWidth); + } + QColor shade = pal.dark().color(); QColor light = pal.light().color(); if (fill) { @@ -389,6 +447,19 @@ static void qDrawWinShades(QPainter *p, { if (w < 2 || h < 2) // can't do anything with that return; + + PainterStateGuard painterGuard(p); + const qreal devicePixelRatio = p->device()->devicePixelRatioF(); + if (!qFuzzyCompare(devicePixelRatio, qreal(1))) { + painterGuard.save(); + const qreal inverseScale = qreal(1) / devicePixelRatio; + p->scale(inverseScale, inverseScale); + x = qRound(devicePixelRatio * x); + y = qRound(devicePixelRatio * y); + w = qRound(devicePixelRatio * w); + h = qRound(devicePixelRatio * h); + } + QPen oldPen = p->pen(); QPoint a[3] = { QPoint(x, y+h-2), QPoint(x, y), QPoint(x+w-2, y) }; p->setPen(c1); @@ -518,6 +589,20 @@ void qDrawPlainRect(QPainter *p, int x, int y, int w, int h, const QColor &c, if (Q_UNLIKELY(w < 0 || h < 0 || lineWidth < 0)) { qWarning("qDrawPlainRect: Invalid parameters"); } + + PainterStateGuard painterGuard(p); + const qreal devicePixelRatio = p->device()->devicePixelRatioF(); + if (!qFuzzyCompare(devicePixelRatio, qreal(1))) { + painterGuard.save(); + const qreal inverseScale = qreal(1) / devicePixelRatio; + p->scale(inverseScale, inverseScale); + x = qRound(devicePixelRatio * x); + y = qRound(devicePixelRatio * y); + w = qRound(devicePixelRatio * w); + h = qRound(devicePixelRatio * h); + lineWidth = qRound(devicePixelRatio * lineWidth); + } + QPen oldPen = p->pen(); QBrush oldBrush = p->brush(); p->setPen(c); From f2db946fa4d660d4e4fbddb777a8ef7df05d2282 Mon Sep 17 00:00:00 2001 From: Alessandro Portale Date: Fri, 7 Jul 2017 14:10:15 +0200 Subject: [PATCH 32/63] QWidgets/FusionStyle: Fix menu drawing under HighDPI Delegating the border painting to qDrawPlainRect ensures that there are no off-by-one pixel issues. Task-number: QTBUG-61845 Change-Id: I732795e048cbc2e5b279782e9a19700884f8bc40 Reviewed-by: Friedemann Kleint --- src/widgets/styles/qfusionstyle.cpp | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/widgets/styles/qfusionstyle.cpp b/src/widgets/styles/qfusionstyle.cpp index 983413d149d..dd8b1b1d69a 100644 --- a/src/widgets/styles/qfusionstyle.cpp +++ b/src/widgets/styles/qfusionstyle.cpp @@ -990,11 +990,9 @@ void QFusionStyle::drawPrimitive(PrimitiveElement elem, break; case PE_PanelMenu: { painter->save(); - QColor menuBackground = option->palette.base().color().lighter(108); + const QBrush menuBackground = option->palette.base().color().lighter(108); QColor borderColor = option->palette.background().color().darker(160); - painter->setPen(borderColor); - painter->setBrush(menuBackground); - painter->drawRect(option->rect.adjusted(0, 0, -1, -1)); + qDrawPlainRect(painter, option->rect, borderColor, 1, &menuBackground); painter->restore(); } break; From 353fb118c3d92bac2bfdd88922320d0d3e8563c2 Mon Sep 17 00:00:00 2001 From: Giuseppe D'Angelo Date: Tue, 4 Jul 2017 00:56:38 +0200 Subject: [PATCH 33/63] Fix detection of QMAKE_DEFAULT_LIBDIRS with Clang under Linux With 4183475080d334d7d17d02e6ad4eb53c01205c54, Qt fails to build if qmake is unable to detect the compiler's default include and library search paths. Clang on non-Darwin systems was missing working code for the detection. Unlike GCC, Clang on its own does not print the library search paths when called with the -v option. On Darwin, the -Wl,-v option will reach ld64, which will print those paths. However, neither GNU ld nor gold will print anything useful with just -v. GNU ld has a --verbose option that does print some search paths, but those are not the ones used when ld is invoked (via collect2) by GCC or Clang, so it can't be used. To make Clang print its library search paths one can use -print-search-dirs, which however doesn't print include search paths. So amend the existing code in order to make a second call to clang on non-Darwin systems. This second call is used for library path detection, and fixes the build on non-Darwin (tested on Linux). Change-Id: Ic858f908ee1a2e0eb307abb074daee0ded38abd5 Reviewed-by: Oswald Buddenhagen --- mkspecs/features/toolchain.prf | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/mkspecs/features/toolchain.prf b/mkspecs/features/toolchain.prf index eb7b1385f23..b3726a11606 100644 --- a/mkspecs/features/toolchain.prf +++ b/mkspecs/features/toolchain.prf @@ -111,6 +111,26 @@ isEmpty($${target_prefix}.INCDIRS) { } } } + !darwin:clang { + # Clang on a non-Apple system (that is, a system without ld64 -- say, with GNU ld + # or gold under Linux) will not print any library search path. Need to use another + # invocation with different options (which in turn doesn't print include search + # paths, so it can't just be used in place of the above code). + # What's more, -print-search-dirs can't be used on clang on Apple because it + # won't print all the library paths (only the clang-internal ones). + output = $$system("$$cmd_prefix $$QMAKE_CXX -print-search-dirs", lines, ec) + !equals(ec, 0): \ + error("Cannot run compiler '$$QMAKE_CXX'. Maybe you forgot to setup the environment?") + + for (line, output) { + contains(line, "^libraries: .*") { + line ~= s,^libraries: ,, + paths = $$split(line, $$QMAKE_DIRLIST_SEP) + for (path, paths): \ + QMAKE_DEFAULT_LIBDIRS += $$clean_path($$replace(path, ^=, $$[SYSROOT])) + } + } + } isEmpty(QMAKE_DEFAULT_LIBDIRS)|isEmpty(QMAKE_DEFAULT_INCDIRS): \ !integrity: \ error("failed to parse default search paths from compiler output") From fd95ef765afa3b0fd9996a31546d098465b927fe Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Thu, 29 Jun 2017 12:35:01 -0700 Subject: [PATCH 34/63] QFile::rename: avoid two stat(2)/CreateFile in a row MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit QFileSystemEngine::id() will stat(2)/CreateFile in order to get the ID of the file anyway, so we don't need to use QFile::exists() to check if the destination exists. Instead, rely on id() returning a null value to indicate error. On Windows, it's possible that the calls to either GetFileInformationByHandle or GetFileInformationByHandleEx might fail, but we ignore those. Change-Id: I1eba2b016de74620bfc8fffd14ccaebcbed64419 Reviewed-by: Jędrzej Nowacki --- src/corelib/io/qfile.cpp | 8 +++++--- src/corelib/io/qfilesystemengine_unix.cpp | 3 ++- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/corelib/io/qfile.cpp b/src/corelib/io/qfile.cpp index 06d706b9150..a8403071452 100644 --- a/src/corelib/io/qfile.cpp +++ b/src/corelib/io/qfile.cpp @@ -567,9 +567,11 @@ QFile::rename(const QString &newName) } // If the file exists and it is a case-changing rename ("foo" -> "Foo"), // compare Ids to make sure it really is a different file. - if (QFile::exists(newName)) { - if (d->fileName.compare(newName, Qt::CaseInsensitive) - || QFileSystemEngine::id(QFileSystemEntry(d->fileName)) != QFileSystemEngine::id(QFileSystemEntry(newName))) { + // Note: this does not take file engines into account. + QByteArray targetId = QFileSystemEngine::id(QFileSystemEntry(newName)); + if (!targetId.isNull()) { + QByteArray fileId = QFileSystemEngine::id(QFileSystemEntry(d->fileName)); + if (fileId != targetId || d->fileName.compare(newName, Qt::CaseInsensitive)) { // ### Race condition. If a file is moved in after this, it /will/ be // overwritten. On Unix, the proper solution is to use hardlinks: // return ::link(old, new) && ::remove(old); diff --git a/src/corelib/io/qfilesystemengine_unix.cpp b/src/corelib/io/qfilesystemengine_unix.cpp index 90e4faaf50a..c3906c3207e 100644 --- a/src/corelib/io/qfilesystemengine_unix.cpp +++ b/src/corelib/io/qfilesystemengine_unix.cpp @@ -338,7 +338,8 @@ QByteArray QFileSystemEngine::id(const QFileSystemEntry &entry) { QT_STATBUF statResult; if (QT_STAT(entry.nativeFilePath().constData(), &statResult)) { - qErrnoWarning("stat() failed for '%s'", entry.nativeFilePath().constData()); + if (errno != ENOENT) + qErrnoWarning("stat() failed for '%s'", entry.nativeFilePath().constData()); return QByteArray(); } QByteArray result = QByteArray::number(quint64(statResult.st_dev), 16); From 8d542154a82e4a7b14cffbe46ae493085b9eb4f6 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Wed, 5 Jul 2017 14:41:11 -0700 Subject: [PATCH 35/63] Avoid sharing violation in QFileSystemEngine::id on Windows We can't open a file for reading if the file is open by another process (or by ourselves) without sharing permitted. So ask for no access just so we can get a handle to it. Change-Id: I998653739e1cec2a58a07a6593b6ff87c1d59dd1 Reviewed-by: Thiago Macieira --- src/corelib/io/qfilesystemengine_win.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/corelib/io/qfilesystemengine_win.cpp b/src/corelib/io/qfilesystemengine_win.cpp index b1e218de9cd..e4a7ea48918 100644 --- a/src/corelib/io/qfilesystemengine_win.cpp +++ b/src/corelib/io/qfilesystemengine_win.cpp @@ -612,13 +612,13 @@ QByteArray QFileSystemEngine::id(const QFileSystemEntry &entry) QByteArray result; const HANDLE handle = #ifndef Q_OS_WINRT - CreateFile((wchar_t*)entry.nativeFilePath().utf16(), GENERIC_READ, + CreateFile((wchar_t*)entry.nativeFilePath().utf16(), 0, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); #else // !Q_OS_WINRT - CreateFile2((const wchar_t*)entry.nativeFilePath().utf16(), GENERIC_READ, + CreateFile2((const wchar_t*)entry.nativeFilePath().utf16(), 0, FILE_SHARE_READ, OPEN_EXISTING, NULL); #endif // Q_OS_WINRT - if (handle) { + if (handle != INVALID_HANDLE_VALUE) { result = QOperatingSystemVersion::current() >= QOperatingSystemVersion::Windows8 ? fileIdWin8(handle) : fileId(handle); CloseHandle(handle); From 05fd45ac8d57513353e1d7160a67f515a5209eee Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Thu, 6 Jul 2017 08:37:31 +0200 Subject: [PATCH 36/63] QIntegrityHIDManager: Fix syncqt warnings QtInputSupport: WARNING: qtbase/src/platformsupport/input/integrityhid/qintegrityhidmanager.h includes QObject when it should include QtCore/QObject QtInputSupport: WARNING: qtbase/src/platformsupport/input/integrityhid/qintegrityhidmanager.h includes QList when it should include QtCore/QList QtInputSupport: WARNING: qtbase/src/platformsupport/input/integrityhid/qintegrityhidmanager.h includes QList when it should include QtGui/QList QtInputSupport: WARNING: qtbase/src/platformsupport/input/integrityhid/qintegrityhidmanager.h includes QThread when it should include QtCore/QThread Amends 88f30250eb15b520415658c6c32f48fda111b6bf. Change-Id: Ia56fdd87871fdeae8fe34752c61a66195100ceb7 Reviewed-by: Kimmo Ollila Reviewed-by: Rolland Dudemaine Reviewed-by: Oswald Buddenhagen --- .../input/integrityhid/qintegrityhidmanager.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/platformsupport/input/integrityhid/qintegrityhidmanager.h b/src/platformsupport/input/integrityhid/qintegrityhidmanager.h index c8780b2dc20..36d75874578 100644 --- a/src/platformsupport/input/integrityhid/qintegrityhidmanager.h +++ b/src/platformsupport/input/integrityhid/qintegrityhidmanager.h @@ -40,9 +40,9 @@ #ifndef QINTEGRITYHIDMANAGER_P_H #define QINTEGRITYHIDMANAGER_P_H -#include -#include -#include +#include +#include +#include QT_BEGIN_NAMESPACE From fb78adf8df3cfb05e419ae248def1da6ad59c15a Mon Sep 17 00:00:00 2001 From: Gatis Paeglis Date: Mon, 3 Jul 2017 14:41:31 +0200 Subject: [PATCH 37/63] xcb: cleanup gl_integrations_plugin_base.pri The original version (8758f532ae6209bcf9447e27edc4fd412c0f173d) of this file was full of things that are irrelevant for XCB GL plugins. Most of this has been cleaned out as side effect of porting to the new configure system. This patch cleans up the remaining pieces. It does not matter for XCB GL plugins if Qt was configured with -qt-xcb or -system-xcb as those are dependencies of xcb_qpa_lib-private and are not used directly by these plugins. The only XCB dependencies that are directly used by these plugins are libxcb-glx and libxcb, which are managed directly in xcb_glx.pro: qtConfig(xcb-glx): QMAKE_USE += xcb_glx Change-Id: I2175185902bb028de142c8ff6e0b0a3b76a09703 Reviewed-by: Oswald Buddenhagen --- .../xcb/gl_integrations/gl_integrations_plugin_base.pri | 7 ------- 1 file changed, 7 deletions(-) diff --git a/src/plugins/platforms/xcb/gl_integrations/gl_integrations_plugin_base.pri b/src/plugins/platforms/xcb/gl_integrations/gl_integrations_plugin_base.pri index df471f1105d..98e48b706f2 100644 --- a/src/plugins/platforms/xcb/gl_integrations/gl_integrations_plugin_base.pri +++ b/src/plugins/platforms/xcb/gl_integrations/gl_integrations_plugin_base.pri @@ -5,10 +5,3 @@ INCLUDEPATH += $$PWD/../ load(qt_build_paths) -!qtConfig(system-xcb) { - QMAKE_USE += xcb-static xcb -} else { - qtConfig(xkb): QMAKE_USE += xcb_xkb - qtConfig(xcb-render): QMAKE_USE += xcb_render - QMAKE_USE += xcb_syslibs -} From 2300629df599938d67c13ed134e788db0fe8b21a Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Wed, 3 May 2017 10:46:38 +0200 Subject: [PATCH 38/63] QWindowsFileIconEngine::filePixmap(): Handle non-existent files Pass SHGFI_USEFILEATTRIBUTES/FILE_ATTRIBUTE_NORMAL to ShGetFileInfo() in case a file does not exist to obtain an icon. SHGFI_USEFILEATTRIBUTES cannot be used unconditionally as it breaks custom directory icons. The functionality is then on par with XCB which obtains icons via QMimeDatabase look-up. Task-number: QTBUG-25319 Change-Id: Icd894d97fd8d1a2c4d5d39e86afe89843e6720c4 Reviewed-by: Gabriel de Dietrich --- .../platforms/windows/qwindowstheme.cpp | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/src/plugins/platforms/windows/qwindowstheme.cpp b/src/plugins/platforms/windows/qwindowstheme.cpp index 3e2cb5e9e90..79162112195 100644 --- a/src/plugins/platforms/windows/qwindowstheme.cpp +++ b/src/plugins/platforms/windows/qwindowstheme.cpp @@ -864,12 +864,18 @@ QPixmap QWindowsFileIconEngine::filePixmap(const QSize &size, QIcon::Mode, QIcon } SHFILEINFO info; - const unsigned int flags = - SHGFI_ICON|iconSize|SHGFI_SYSICONINDEX|SHGFI_ADDOVERLAYS|SHGFI_OVERLAYINDEX; - - const bool val = cacheableDirIcon && useDefaultFolderIcon - ? shGetFileInfoBackground(QString::fromWCharArray(L"dummy"), FILE_ATTRIBUTE_DIRECTORY, &info, flags | SHGFI_USEFILEATTRIBUTES) - : shGetFileInfoBackground(filePath, 0, &info, flags); + unsigned int flags = SHGFI_ICON | iconSize | SHGFI_SYSICONINDEX | SHGFI_ADDOVERLAYS | SHGFI_OVERLAYINDEX; + DWORD attributes = 0; + QString path = filePath; + if (cacheableDirIcon && useDefaultFolderIcon) { + flags |= SHGFI_USEFILEATTRIBUTES; + attributes |= FILE_ATTRIBUTE_DIRECTORY; + path = QStringLiteral("dummy"); + } else if (!fileInfo().exists()) { + flags |= SHGFI_USEFILEATTRIBUTES; + attributes |= FILE_ATTRIBUTE_NORMAL; + } + const bool val = shGetFileInfoBackground(path, attributes, &info, flags); // Even if GetFileInfo returns a valid result, hIcon can be empty in some cases if (val && info.hIcon) { From 9db09b47000301bc3589278b076abdc111276304 Mon Sep 17 00:00:00 2001 From: Kevin Funk Date: Tue, 4 Jul 2017 11:36:34 +0200 Subject: [PATCH 39/63] Fix modernize-use-bool-literals issues Reported by clang-tidy. Skipped fixes in implementation files, only changed headers. Change-Id: I5cfd266b3d4046f90baebc0c538b1b6ab03a02d2 Reviewed-by: Volker Krause Reviewed-by: Olivier Goffart (Woboq GmbH) Reviewed-by: Marc Mutz Reviewed-by: Thiago Macieira --- src/corelib/global/qcompilerdetection.h | 4 ++-- src/corelib/global/qglobal.h | 14 +++++++------- src/dbus/qdbusthreaddebug_p.h | 4 ++-- src/gui/painting/qdrawhelper_p.h | 4 ++-- src/testlib/qtestassert.h | 4 ++-- src/testlib/qtestcase.h | 22 +++++++++++----------- src/widgets/styles/qmacstyle_mac_p_p.h | 2 +- 7 files changed, 27 insertions(+), 27 deletions(-) diff --git a/src/corelib/global/qcompilerdetection.h b/src/corelib/global/qcompilerdetection.h index 9ffd164b616..05e3f6c45a5 100644 --- a/src/corelib/global/qcompilerdetection.h +++ b/src/corelib/global/qcompilerdetection.h @@ -1336,14 +1336,14 @@ do {\ Q_ASSERT_X(false, "Q_UNREACHABLE()", "Q_UNREACHABLE was reached");\ Q_UNREACHABLE_IMPL();\ - } while (0) + } while (false) #define Q_ASSUME(Expr) \ do {\ const bool valueOfExpression = Expr;\ Q_ASSERT_X(valueOfExpression, "Q_ASSUME()", "Assumption in Q_ASSUME(\"" #Expr "\") was not correct");\ Q_ASSUME_IMPL(valueOfExpression);\ - } while (0) + } while (false) #if defined(__cplusplus) #if QT_HAS_CPP_ATTRIBUTE(fallthrough) diff --git a/src/corelib/global/qglobal.h b/src/corelib/global/qglobal.h index 0c74ed4a3e7..6023cc85641 100644 --- a/src/corelib/global/qglobal.h +++ b/src/corelib/global/qglobal.h @@ -339,10 +339,10 @@ typedef double qreal; #define Q_INIT_RESOURCE(name) \ do { extern int QT_MANGLE_NAMESPACE(qInitResources_ ## name) (); \ - QT_MANGLE_NAMESPACE(qInitResources_ ## name) (); } while (0) + QT_MANGLE_NAMESPACE(qInitResources_ ## name) (); } while (false) #define Q_CLEANUP_RESOURCE(name) \ do { extern int QT_MANGLE_NAMESPACE(qCleanupResources_ ## name) (); \ - QT_MANGLE_NAMESPACE(qCleanupResources_ ## name) (); } while (0) + QT_MANGLE_NAMESPACE(qCleanupResources_ ## name) (); } while (false) /* * If we're compiling C++ code: @@ -646,7 +646,7 @@ inline void qt_noop(void) {} # define QT_CATCH(A) else # define QT_THROW(A) qt_noop() # define QT_RETHROW qt_noop() -# define QT_TERMINATE_ON_EXCEPTION(expr) do { expr; } while (0) +# define QT_TERMINATE_ON_EXCEPTION(expr) do { expr; } while (false) #else # define QT_TRY try # define QT_CATCH(A) catch (A) @@ -654,9 +654,9 @@ inline void qt_noop(void) {} # define QT_RETHROW throw Q_NORETURN Q_CORE_EXPORT void qTerminate() Q_DECL_NOTHROW; # ifdef Q_COMPILER_NOEXCEPT -# define QT_TERMINATE_ON_EXCEPTION(expr) do { expr; } while (0) +# define QT_TERMINATE_ON_EXCEPTION(expr) do { expr; } while (false) # else -# define QT_TERMINATE_ON_EXCEPTION(expr) do { try { expr; } catch (...) { qTerminate(); } } while (0) +# define QT_TERMINATE_ON_EXCEPTION(expr) do { try { expr; } catch (...) { qTerminate(); } } while (false) # endif #endif @@ -760,10 +760,10 @@ Q_CORE_EXPORT void qBadAlloc(); # if defined(QT_NO_DEBUG) && !defined(QT_FORCE_ASSERTS) # define Q_CHECK_PTR(p) qt_noop() # else -# define Q_CHECK_PTR(p) do {if(!(p))qt_check_pointer(__FILE__,__LINE__);} while (0) +# define Q_CHECK_PTR(p) do {if (!(p)) qt_check_pointer(__FILE__,__LINE__);} while (false) # endif #else -# define Q_CHECK_PTR(p) do { if (!(p)) qBadAlloc(); } while (0) +# define Q_CHECK_PTR(p) do { if (!(p)) qBadAlloc(); } while (false) #endif template diff --git a/src/dbus/qdbusthreaddebug_p.h b/src/dbus/qdbusthreaddebug_p.h index 866e777be60..96f389fa493 100644 --- a/src/dbus/qdbusthreaddebug_p.h +++ b/src/dbus/qdbusthreaddebug_p.h @@ -211,14 +211,14 @@ struct QDBusDispatchLocker: QDBusMutexLocker QDBusLockerBase::reportThreadAction(action, QDBusLockerBase::BeforeAcquire, this); \ sem.acquire(); \ QDBusLockerBase::reportThreadAction(action, QDBusLockerBase::AfterAcquire, this); \ - } while (0) + } while (false) # define SEM_RELEASE(action, sem) \ do { \ QDBusLockerBase::reportThreadAction(action, QDBusLockerBase::BeforeRelease, that); \ sem.release(); \ QDBusLockerBase::reportThreadAction(action, QDBusLockerBase::AfterRelease, that); \ - } while (0) + } while (false) #else # define SEM_ACQUIRE(action, sem) sem.acquire() diff --git a/src/gui/painting/qdrawhelper_p.h b/src/gui/painting/qdrawhelper_p.h index 1f976211710..ccfc9a2889a 100644 --- a/src/gui/painting/qdrawhelper_p.h +++ b/src/gui/painting/qdrawhelper_p.h @@ -885,7 +885,7 @@ do { \ case 1: *--_d = *--_s; \ } while (--n > 0); \ } \ -} while (0) +} while (false) #define QT_MEMCPY_USHORT(dest, src, length) \ do { \ @@ -905,7 +905,7 @@ do { \ case 1: *_d++ = *_s++; \ } while (--n > 0); \ } \ -} while (0) +} while (false) inline ushort qConvertRgb32To16(uint c) { diff --git a/src/testlib/qtestassert.h b/src/testlib/qtestassert.h index 21d3ffaef84..6498ea84eff 100644 --- a/src/testlib/qtestassert.h +++ b/src/testlib/qtestassert.h @@ -45,9 +45,9 @@ QT_BEGIN_NAMESPACE -#define QTEST_ASSERT(cond) do { if (!(cond)) qt_assert(#cond,__FILE__,__LINE__); } while (0) +#define QTEST_ASSERT(cond) do { if (!(cond)) qt_assert(#cond,__FILE__,__LINE__); } while (false) -#define QTEST_ASSERT_X(cond, where, what) do { if (!(cond)) qt_assert_x(where, what,__FILE__,__LINE__); } while (0) +#define QTEST_ASSERT_X(cond, where, what) do { if (!(cond)) qt_assert_x(where, what,__FILE__,__LINE__); } while (false) QT_END_NAMESPACE diff --git a/src/testlib/qtestcase.h b/src/testlib/qtestcase.h index a7e825396a7..a59eb4ecb30 100644 --- a/src/testlib/qtestcase.h +++ b/src/testlib/qtestcase.h @@ -63,13 +63,13 @@ class QRegularExpression; do {\ if (!QTest::qVerify(static_cast(statement), #statement, "", __FILE__, __LINE__))\ return;\ -} while (0) +} while (false) #define QFAIL(message) \ do {\ QTest::qFail(message, __FILE__, __LINE__);\ return;\ -} while (0) +} while (false) #define QVERIFY2(statement, description) \ do {\ @@ -80,13 +80,13 @@ do {\ if (!QTest::qVerify(false, #statement, (description), __FILE__, __LINE__))\ return;\ }\ -} while (0) +} while (false) #define QCOMPARE(actual, expected) \ do {\ if (!QTest::qCompare(actual, expected, #actual, #expected, __FILE__, __LINE__))\ return;\ -} while (0) +} while (false) #ifndef QT_NO_EXCEPTIONS @@ -111,7 +111,7 @@ do {\ " but unknown exception caught", __FILE__, __LINE__);\ return;\ }\ - } while (0) + } while (false) #else // QT_NO_EXCEPTIONS @@ -158,7 +158,7 @@ do {\ do { \ QTRY_IMPL((expr), timeout);\ QVERIFY(expr); \ -} while (0) +} while (false) #define QTRY_VERIFY(expr) QTRY_VERIFY_WITH_TIMEOUT((expr), 5000) @@ -167,7 +167,7 @@ do { \ do { \ QTRY_IMPL((expr), timeout);\ QVERIFY2(expr, messageExpression); \ -} while (0) +} while (false) #define QTRY_VERIFY2(expr, messageExpression) QTRY_VERIFY2_WITH_TIMEOUT((expr), (messageExpression), 5000) @@ -176,7 +176,7 @@ do { \ do { \ QTRY_IMPL(((expr) == (expected)), timeout);\ QCOMPARE((expr), expected); \ -} while (0) +} while (false) #define QTRY_COMPARE(expr, expected) QTRY_COMPARE_WITH_TIMEOUT((expr), expected, 5000) @@ -184,7 +184,7 @@ do { \ do {\ QTest::qSkip(statement, __FILE__, __LINE__);\ return;\ -} while (0) +} while (false) #ifdef Q_COMPILER_VARIADIC_MACROS @@ -200,7 +200,7 @@ do {\ do {\ if (!QTest::qExpectFail(dataIndex, comment, QTest::mode, __FILE__, __LINE__))\ return;\ -} while (0) +} while (false) #define QFETCH(Type, name)\ Type name = *static_cast(QTest::qData(#name, ::qMetaTypeId::type>())) @@ -212,7 +212,7 @@ do {\ do {\ if (!QTest::qTest(actual, testElement, #actual, #testElement, __FILE__, __LINE__))\ return;\ -} while (0) +} while (false) #define QWARN(msg)\ QTest::qWarn(msg, __FILE__, __LINE__) diff --git a/src/widgets/styles/qmacstyle_mac_p_p.h b/src/widgets/styles/qmacstyle_mac_p_p.h index e16f17c67f9..1201ae3955c 100644 --- a/src/widgets/styles/qmacstyle_mac_p_p.h +++ b/src/widgets/styles/qmacstyle_mac_p_p.h @@ -159,7 +159,7 @@ typedef void (^QCocoaDrawRectBlock)(NSRect, CGContextRef); do { \ static const int sizes[] = { (large), (small), (mini) }; \ return sizes[controlSize]; \ - } while (0) + } while (false) #if QT_CONFIG(pushbutton) bool qt_mac_buttonIsRenderedFlat(const QPushButton *pushButton, const QStyleOptionButton *option); From 16799ba394e0684cee8ca921432e418e1e0f6c63 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= Date: Fri, 7 Jul 2017 13:48:21 +0200 Subject: [PATCH 40/63] Only try to resolve library paths via linker for Drawin clang Task-number: QTBUG-61735 Change-Id: Ia8e777928aa0cff44f092968eac14d32501a5d73 Reviewed-by: Oswald Buddenhagen --- mkspecs/features/toolchain.prf | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mkspecs/features/toolchain.prf b/mkspecs/features/toolchain.prf index b3726a11606..813dbffbd47 100644 --- a/mkspecs/features/toolchain.prf +++ b/mkspecs/features/toolchain.prf @@ -50,11 +50,11 @@ isEmpty($${target_prefix}.INCDIRS) { rim_qcc: \ # Need the cc1plus and ld command lines to pick up the paths cxx_flags += $$QMAKE_LFLAGS_SHLIB -o $$null_file -v - else: clang: \ + else: darwin:clang: \ # Need to link to pick up library paths cxx_flags += $$QMAKE_LFLAGS_SHLIB -o /dev/null -v -Wl,-v else: \ - # gcc is fine with just preprocessing + # Just preprocess, might not pick up library paths cxx_flags += -E -v output = $$system("$$cmd_prefix $$QMAKE_CXX $$qtMakeExpand($$cxx_flags) -xc++ - 2>&1 $$cmd_suffix", lines, ec) From 6e861d8412b28472571d675e6a600f4a6dcbb4b7 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Tue, 20 Jun 2017 14:32:27 +0200 Subject: [PATCH 41/63] pathstroke example: Add Q_FALLTHROUGH to unmarked fallthrough seen by GCC 7 Task-number: QTBUG-60635 Change-Id: I10695f96122f1b0859bbe7fadb349efb3c7277a6 Reviewed-by: Shawn Rutledge --- examples/widgets/painting/pathstroke/pathstroke.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/examples/widgets/painting/pathstroke/pathstroke.cpp b/examples/widgets/painting/pathstroke/pathstroke.cpp index dc10457d279..1e2f75b2a51 100644 --- a/examples/widgets/painting/pathstroke/pathstroke.cpp +++ b/examples/widgets/painting/pathstroke/pathstroke.cpp @@ -600,6 +600,7 @@ bool PathStrokeRenderer::event(QEvent *e) switch (e->type()) { case QEvent::TouchBegin: touchBegin = true; + Q_FALLTHROUGH(); case QEvent::TouchUpdate: { const QTouchEvent *const event = static_cast(e); From 1bc5f619ea1cae8cfec2ac53a8206ceb28845c8f Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Tue, 13 Jun 2017 11:45:59 +0200 Subject: [PATCH 42/63] QStorageInfo/Windows: Improve error handling Bail out of QStorageInfoPrivate::doStats() should an error occur and set the ready/valid flags accordingly. Task-number: QTBUG-6039 Change-Id: Id5354b31329d951599ae991aa7edde0515c90514 Reviewed-by: Thiago Macieira --- src/corelib/io/qstorageinfo_win.cpp | 52 +++++++++++++++++++---------- 1 file changed, 34 insertions(+), 18 deletions(-) diff --git a/src/corelib/io/qstorageinfo_win.cpp b/src/corelib/io/qstorageinfo_win.cpp index f02e46f0951..3830c5480c5 100644 --- a/src/corelib/io/qstorageinfo_win.cpp +++ b/src/corelib/io/qstorageinfo_win.cpp @@ -43,36 +43,52 @@ #include #include +#include "qfilesystementry_p.h" + #include QT_BEGIN_NAMESPACE static const int defaultBufferSize = MAX_PATH + 1; -void QStorageInfoPrivate::initRootPath() +static QString canonicalPath(const QString &rootPath) { - rootPath = QFileInfo(rootPath).canonicalFilePath(); - - if (rootPath.isEmpty()) - return; - - QString path = QDir::toNativeSeparators(rootPath); - rootPath.clear(); + QString path = QDir::toNativeSeparators(QFileInfo(rootPath).canonicalFilePath()); + if (path.isEmpty()) + return path; if (path.startsWith(QLatin1String("\\\\?\\"))) path.remove(0, 4); if (path.length() < 2 || path.at(1) != QLatin1Char(':')) - return; + return QString(); + path[0] = path[0].toUpper(); if (!(path.at(0).unicode() >= 'A' && path.at(0).unicode() <= 'Z')) - return; + return QString(); if (!path.endsWith(QLatin1Char('\\'))) path.append(QLatin1Char('\\')); + return path; +} + +void QStorageInfoPrivate::initRootPath() +{ + // Do not unnecessarily call QFileInfo::canonicalFilePath() if the path is + // already a drive root since it may hang on network drives. + const QString path = QFileSystemEntry::isDriveRootPath(rootPath) + ? QDir::toNativeSeparators(rootPath) + : canonicalPath(rootPath); + + if (path.isEmpty()) { + valid = ready = false; + return; + } // ### test if disk mounted to folder on other disk wchar_t buffer[defaultBufferSize]; if (::GetVolumePathName(reinterpret_cast(path.utf16()), buffer, defaultBufferSize)) rootPath = QDir::fromNativeSeparators(QString::fromWCharArray(buffer)); + else + valid = ready = false; } static inline QByteArray getDevice(const QString &rootPath) @@ -108,11 +124,14 @@ static inline QByteArray getDevice(const QString &rootPath) void QStorageInfoPrivate::doStat() { + valid = ready = true; initRootPath(); - if (rootPath.isEmpty()) + if (!valid || !ready) return; retrieveVolumeInfo(); + if (!valid || !ready) + return; device = getDevice(rootPath); retrieveDiskFreeSpace(); } @@ -137,9 +156,6 @@ void QStorageInfoPrivate::retrieveVolumeInfo() ready = false; valid = ::GetLastError() == ERROR_NOT_READY; } else { - ready = true; - valid = true; - fileSystemType = QString::fromWCharArray(fileSystemTypeBuffer).toLatin1(); name = QString::fromWCharArray(nameBuffer); @@ -154,10 +170,10 @@ void QStorageInfoPrivate::retrieveDiskFreeSpace() const UINT oldmode = ::SetErrorMode(SEM_FAILCRITICALERRORS | SEM_NOOPENFILEERRORBOX); const QString path = QDir::toNativeSeparators(rootPath); - ::GetDiskFreeSpaceEx(reinterpret_cast(path.utf16()), - PULARGE_INTEGER(&bytesAvailable), - PULARGE_INTEGER(&bytesTotal), - PULARGE_INTEGER(&bytesFree)); + ready = ::GetDiskFreeSpaceEx(reinterpret_cast(path.utf16()), + PULARGE_INTEGER(&bytesAvailable), + PULARGE_INTEGER(&bytesTotal), + PULARGE_INTEGER(&bytesFree)); ::SetErrorMode(oldmode); } From 70b976ece1ad36b1e59d2b67f6cda8ff6b86017c Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Mon, 10 Jul 2017 08:51:12 +0200 Subject: [PATCH 43/63] QtTest: Add msvc2017 detection and keyword to blacklisting Change-Id: I71162fc7dff0f29a24fd78e1188f8d86c2834d3c Reviewed-by: Simon Hausmann --- src/testlib/qtestblacklist.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/testlib/qtestblacklist.cpp b/src/testlib/qtestblacklist.cpp index 0ebc800fe1a..75186d93aed 100644 --- a/src/testlib/qtestblacklist.cpp +++ b/src/testlib/qtestblacklist.cpp @@ -136,7 +136,9 @@ static QSet keywords() #ifdef Q_CC_MSVC << "msvc" #ifdef _MSC_VER - #if _MSC_VER == 1900 + #if _MSC_VER == 1910 + << "msvc-2017" + #elif _MSC_VER == 1900 << "msvc-2015" #elif _MSC_VER == 1800 << "msvc-2013" From 333a27a8b67ec8bef2f435e2dc8cc233e31a1721 Mon Sep 17 00:00:00 2001 From: Stephan Binner Date: Fri, 7 Jul 2017 21:59:24 +0200 Subject: [PATCH 44/63] Fix macOS build for -no-widgets, take 2 Task-number: QTBUG-61780 Change-Id: Ic67074b19b3b5c409c0f1254be77ba122ad61a85 Reviewed-by: Oswald Buddenhagen --- src/plugins/platforms/cocoa/qcocoatheme.mm | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/plugins/platforms/cocoa/qcocoatheme.mm b/src/plugins/platforms/cocoa/qcocoatheme.mm index 66182e25809..08f41cddc2f 100644 --- a/src/plugins/platforms/cocoa/qcocoatheme.mm +++ b/src/plugins/platforms/cocoa/qcocoatheme.mm @@ -132,7 +132,7 @@ bool QCocoaTheme::usePlatformNativeDialog(DialogType dialogType) const { if (dialogType == QPlatformTheme::FileDialog) return true; -#if QT_CONFIG(colordialog) +#if defined(QT_WIDGETS_LIB) && QT_CONFIG(colordialog) if (dialogType == QPlatformTheme::ColorDialog) return true; #endif @@ -150,7 +150,7 @@ QPlatformDialogHelper * QCocoaTheme::createPlatformDialogHelper(DialogType dialo case QPlatformTheme::FileDialog: return new QCocoaFileDialogHelper(); #endif -#if QT_CONFIG(colordialog) +#if defined(QT_WIDGETS_LIB) && QT_CONFIG(colordialog) case QPlatformTheme::ColorDialog: return new QCocoaColorDialogHelper(); #endif From c12072c685f7e93d5b84e289ca23106482379eff Mon Sep 17 00:00:00 2001 From: Gabriel de Dietrich Date: Wed, 5 Jul 2017 12:27:24 -0700 Subject: [PATCH 45/63] QMacStyle: Add back icon logic in tab layout MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This was accidentally removed when we revamped the document mode tabs appearance. In retrospect, we should also consider adding CE_TabBarTabIcon so that we can set the relative position of the icon w.r.t. the tab title. Change-Id: Ic8c3a69c31837018bfdd60f8084120cae47e91f8 Task-number: QTBUG-61092 Task-number: QTBUG-61742 Reviewed-by: Tor Arne Vestbø --- src/widgets/styles/qmacstyle_mac.mm | 26 ++++++++++++++++++++++++-- src/widgets/styles/qmacstyle_mac_p_p.h | 2 +- 2 files changed, 25 insertions(+), 3 deletions(-) diff --git a/src/widgets/styles/qmacstyle_mac.mm b/src/widgets/styles/qmacstyle_mac.mm index 906bc85fa69..fafe9c9e2c8 100644 --- a/src/widgets/styles/qmacstyle_mac.mm +++ b/src/widgets/styles/qmacstyle_mac.mm @@ -1066,9 +1066,10 @@ void QMacStylePrivate::drawFocusRing(QPainter *p, const QRect &targetRect, int h } #ifndef QT_NO_TABBAR -void QMacStylePrivate::tabLayout(const QStyleOptionTab *opt, const QWidget *widget, QRect *textRect) const +void QMacStylePrivate::tabLayout(const QStyleOptionTab *opt, const QWidget *widget, QRect *textRect, QRect *iconRect) const { Q_ASSERT(textRect); + Q_ASSERT(iconRect); QRect tr = opt->rect; const bool verticalTabs = opt->shape == QTabBar::RoundedEast || opt->shape == QTabBar::RoundedWest @@ -1102,6 +1103,26 @@ void QMacStylePrivate::tabLayout(const QStyleOptionTab *opt, const QWidget *widg tr.setLeft(tr.left() + 4 + buttonSize); } + // icon + if (!opt->icon.isNull()) { + QSize iconSize = opt->iconSize; + if (!iconSize.isValid()) { + int iconExtent = proxyStyle->pixelMetric(QStyle::PM_SmallIconSize); + iconSize = QSize(iconExtent, iconExtent); + } + QSize tabIconSize = opt->icon.actualSize(iconSize, + (opt->state & QStyle::State_Enabled) ? QIcon::Normal : QIcon::Disabled, + (opt->state & QStyle::State_Selected) ? QIcon::On : QIcon::Off); + // High-dpi icons do not need adjustment; make sure tabIconSize is not larger than iconSize + tabIconSize = QSize(qMin(tabIconSize.width(), iconSize.width()), qMin(tabIconSize.height(), iconSize.height())); + + *iconRect = QRect(tr.left(), tr.center().y() - tabIconSize.height() / 2, + tabIconSize.width(), tabIconSize.height()); + if (!verticalTabs) + *iconRect = proxyStyle->visualRect(opt->direction, opt->rect, *iconRect); + tr.setLeft(tr.left() + tabIconSize.width() + 4); + } + if (!verticalTabs) tr = proxyStyle->visualRect(opt->direction, opt->rect, tr); @@ -4967,7 +4988,8 @@ QRect QMacStyle::subElementRect(SubElement sr, const QStyleOption *opt, break; case SE_TabBarTabText: if (const QStyleOptionTab *tab = qstyleoption_cast(opt)) { - d->tabLayout(tab, widget, &rect); + QRect dummyIconRect; + d->tabLayout(tab, widget, &rect, &dummyIconRect); } break; case SE_TabBarTabLeftButton: diff --git a/src/widgets/styles/qmacstyle_mac_p_p.h b/src/widgets/styles/qmacstyle_mac_p_p.h index 1201ae3955c..2b388091a69 100644 --- a/src/widgets/styles/qmacstyle_mac_p_p.h +++ b/src/widgets/styles/qmacstyle_mac_p_p.h @@ -231,7 +231,7 @@ public: void drawFocusRing(QPainter *p, const QRect &targetRect, int hMargin, int vMargin, qreal radius = 0) const; #ifndef QT_NO_TABBAR - void tabLayout(const QStyleOptionTab *opt, const QWidget *widget, QRect *textRect) const; + void tabLayout(const QStyleOptionTab *opt, const QWidget *widget, QRect *textRect, QRect *iconRect) const; #endif public: From c3cd0f6e192da887d62db8ff78e567d8522e4d58 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Thu, 6 Jul 2017 20:25:10 -0700 Subject: [PATCH 46/63] configure: Remove test for unused feature "mremap" MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit It's a Linux-specific call that was added to the kernel in pre historical times (before Git). Sqlite3 uses mremap(2) but it has its own checking. Nothing else in Qt uses this. Looks like the last user was the QPF font engine, removed in commit d7e424ee6686f663f5134666e09c2875bb3e42b6 almost four years ago. And that's considering that the QPF font engine wasn't in use since Qt 5.0 because QWS was no more... Change-Id: Idaa189413f404cffb1eafffd14ceee7488514c1d Reviewed-by: Tor Arne Vestbø Reviewed-by: Oswald Buddenhagen --- config.tests/unix/mremap/mremap.cpp | 49 ----------------------------- config.tests/unix/mremap/mremap.pro | 2 -- configure.json | 10 ------ 3 files changed, 61 deletions(-) delete mode 100644 config.tests/unix/mremap/mremap.cpp delete mode 100644 config.tests/unix/mremap/mremap.pro diff --git a/config.tests/unix/mremap/mremap.cpp b/config.tests/unix/mremap/mremap.cpp deleted file mode 100644 index 0b8743e3400..00000000000 --- a/config.tests/unix/mremap/mremap.cpp +++ /dev/null @@ -1,49 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the config.tests of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include -#include - -int main(int, char **) -{ - (void) ::mremap(static_cast(0), size_t(0), size_t(42), MREMAP_MAYMOVE); - - return 0; -} - diff --git a/config.tests/unix/mremap/mremap.pro b/config.tests/unix/mremap/mremap.pro deleted file mode 100644 index 1dbd3b7a7e2..00000000000 --- a/config.tests/unix/mremap/mremap.pro +++ /dev/null @@ -1,2 +0,0 @@ -SOURCES = mremap.cpp -CONFIG -= qt dylib diff --git a/configure.json b/configure.json index b572a3d1f5f..b7f767e2ec6 100644 --- a/configure.json +++ b/configure.json @@ -396,11 +396,6 @@ "subarch": "neon" }, - "mremap": { - "label": "mremap()", - "type": "compile", - "test": "unix/mremap" - }, "posix_fallocate": { "label": "POSIX fallocate()", "type": "compile", @@ -902,11 +897,6 @@ { "type": "define", "name": "QT_COMPILER_SUPPORTS_NEON", "value": 1 } ] }, - "mremap": { - "label": "mremap()", - "condition": "tests.mremap", - "output": [ "feature" ] - }, "posix_fallocate": { "label": "POSIX fallocate()", "condition": "tests.posix_fallocate", From bb1e5675a5628b72edd32b975e78b7feba366ff9 Mon Sep 17 00:00:00 2001 From: Ben Boeckel Date: Thu, 9 Feb 2017 12:12:28 -0500 Subject: [PATCH 47/63] cmake: avoid `@var@` expansion in older CMake versions Older versions of CMake expanded `@var@` in CMake code, so this could be expanded at this location rather than the `string(CONFIGURE)` call if `module` were set inadvertently. Instead, hide the literal `@` symbol from CMake, but not from the string. This avoids a CMP0053 warning for projects using Qt5 with a minimum version set lower than 3.1 and silent bugs with projects explicitly setting CMP0053 to OLD. Change-Id: I0e4a86469fdf69b8706387799ab9b17498b8d1ca Reviewed-by: Stephen Kelly Reviewed-by: Oswald Buddenhagen --- src/corelib/Qt5ModuleLocationForInstall.cmake.in | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/corelib/Qt5ModuleLocationForInstall.cmake.in b/src/corelib/Qt5ModuleLocationForInstall.cmake.in index e401b1fe340..8751e4acbce 100644 --- a/src/corelib/Qt5ModuleLocationForInstall.cmake.in +++ b/src/corelib/Qt5ModuleLocationForInstall.cmake.in @@ -1,4 +1,6 @@ set(_qt5_root_dir ${_qt5_install_prefix}) set(_qt5_module_paths ${_qt5_install_prefix}) -set(_qt5_module_location_template ${_qt5_install_prefix}/Qt5@module@/Qt5@module@Config.cmake) +set(_qt5_at "@") +set(_qt5_module_location_template ${_qt5_install_prefix}/Qt5${_qt5_at}module${_qt5_at}/Qt5${_qt5_at}module${_qt5_at}Config.cmake) +unset(_qt5_at) From 93dc459f488f866db79ede1f27ef739a243764e4 Mon Sep 17 00:00:00 2001 From: Stephan Binner Date: Sun, 9 Jul 2017 08:47:10 +0200 Subject: [PATCH 48/63] Convert features.graphicseffect to QT_[REQUIRE_]CONFIG Change-Id: I1bb96088b2e9f2a2cfab5fceeebebe94fa6bb3a6 Reviewed-by: Oswald Buddenhagen --- src/opengl/opengl.pro | 7 +++- src/opengl/qgraphicsshadereffect.cpp | 4 -- src/opengl/qgraphicsshadereffect_p.h | 7 +--- src/widgets/effects/qgraphicseffect.cpp | 3 -- src/widgets/effects/qgraphicseffect.h | 6 +-- src/widgets/effects/qgraphicseffect_p.h | 5 +-- src/widgets/effects/qpixmapfilter.cpp | 3 -- src/widgets/effects/qpixmapfilter_p.h | 5 +-- src/widgets/graphicsview/qgraphicsitem.cpp | 42 +++++++++++---------- src/widgets/graphicsview/qgraphicsitem.h | 6 +-- src/widgets/graphicsview/qgraphicsitem_p.h | 15 +++----- src/widgets/graphicsview/qgraphicsscene.cpp | 7 ++-- src/widgets/graphicsview/qgraphicsscene_p.h | 8 ++-- src/widgets/kernel/qapplication.cpp | 1 + src/widgets/kernel/qwidget.cpp | 34 +++++++++-------- src/widgets/kernel/qwidget.h | 4 +- src/widgets/kernel/qwidget_p.h | 14 ++++--- src/widgets/kernel/qwidgetbackingstore.cpp | 18 +++++---- src/widgets/kernel/qwidgetbackingstore_p.h | 4 +- src/widgets/widgets.pro | 4 +- 20 files changed, 96 insertions(+), 101 deletions(-) diff --git a/src/opengl/opengl.pro b/src/opengl/opengl.pro index 718a8868099..016db46405c 100644 --- a/src/opengl/opengl.pro +++ b/src/opengl/opengl.pro @@ -33,7 +33,6 @@ SOURCES += qgl.cpp \ qglbuffer.cpp \ HEADERS += qglshaderprogram.h \ - qgraphicsshadereffect_p.h \ gl2paintengineex/qglgradientcache_p.h \ gl2paintengineex/qglengineshadermanager_p.h \ gl2paintengineex/qgl2pexvertexarray_p.h \ @@ -44,7 +43,6 @@ HEADERS += qglshaderprogram.h \ gl2paintengineex/qglshadercache_p.h SOURCES += qglshaderprogram.cpp \ - qgraphicsshadereffect.cpp \ gl2paintengineex/qglgradientcache.cpp \ gl2paintengineex/qglengineshadermanager.cpp \ gl2paintengineex/qgl2pexvertexarray.cpp \ @@ -52,4 +50,9 @@ SOURCES += qglshaderprogram.cpp \ gl2paintengineex/qglcustomshaderstage.cpp \ gl2paintengineex/qtextureglyphcache_gl.cpp +qtConfig(graphicseffect) { + HEADERS += qgraphicsshadereffect_p.h + SOURCES += qgraphicsshadereffect.cpp +} + load(qt_module) diff --git a/src/opengl/qgraphicsshadereffect.cpp b/src/opengl/qgraphicsshadereffect.cpp index d5ee281c2f3..218f4af8660 100644 --- a/src/opengl/qgraphicsshadereffect.cpp +++ b/src/opengl/qgraphicsshadereffect.cpp @@ -39,8 +39,6 @@ #include "qgraphicsshadereffect_p.h" -#ifndef QT_NO_GRAPHICSEFFECT - #include "qglshaderprogram.h" #include "gl2paintengineex/qglcustomshaderstage_p.h" #define QGL_HAVE_CUSTOM_SHADERS 1 @@ -312,5 +310,3 @@ void QGraphicsShaderEffect::setUniforms(QGLShaderProgram *program) } QT_END_NAMESPACE - -#endif // QT_NO_GRAPHICSEFFECT diff --git a/src/opengl/qgraphicsshadereffect_p.h b/src/opengl/qgraphicsshadereffect_p.h index 57326fdaf28..d7e0ec51d42 100644 --- a/src/opengl/qgraphicsshadereffect_p.h +++ b/src/opengl/qgraphicsshadereffect_p.h @@ -53,12 +53,11 @@ #include -#ifndef QT_NO_GRAPHICSEFFECT - #include -QT_BEGIN_NAMESPACE +QT_REQUIRE_CONFIG(graphicseffect); +QT_BEGIN_NAMESPACE class QGLShaderProgram; class QGLCustomShaderEffectStage; @@ -88,6 +87,4 @@ private: QT_END_NAMESPACE -#endif // QT_NO_GRAPHICSEFFECT - #endif // QGRAPHICSSHADEREFFECT_P_H diff --git a/src/widgets/effects/qgraphicseffect.cpp b/src/widgets/effects/qgraphicseffect.cpp index 4d1d1e98965..028010d3ddd 100644 --- a/src/widgets/effects/qgraphicseffect.cpp +++ b/src/widgets/effects/qgraphicseffect.cpp @@ -114,7 +114,6 @@ #include #include -#ifndef QT_NO_GRAPHICSEFFECT QT_BEGIN_NAMESPACE QGraphicsEffectPrivate::~QGraphicsEffectPrivate() @@ -1237,5 +1236,3 @@ QT_END_NAMESPACE #include "moc_qgraphicseffect.cpp" #include "moc_qgraphicseffect_p.cpp" - -#endif //QT_NO_GRAPHICSEFFECT diff --git a/src/widgets/effects/qgraphicseffect.h b/src/widgets/effects/qgraphicseffect.h index 8e07e51dcac..78d025ded5b 100644 --- a/src/widgets/effects/qgraphicseffect.h +++ b/src/widgets/effects/qgraphicseffect.h @@ -47,9 +47,9 @@ #include #include -#ifndef QT_NO_GRAPHICSEFFECT -QT_BEGIN_NAMESPACE +QT_REQUIRE_CONFIG(graphicseffect); +QT_BEGIN_NAMESPACE class QGraphicsItem; class QStyleOption; @@ -279,7 +279,5 @@ private: QT_END_NAMESPACE -#endif //QT_NO_GRAPHICSEFFECT - #endif // QGRAPHICSEFFECT_H diff --git a/src/widgets/effects/qgraphicseffect_p.h b/src/widgets/effects/qgraphicseffect_p.h index 12bdbfe6fc6..c5c7ff5900f 100644 --- a/src/widgets/effects/qgraphicseffect_p.h +++ b/src/widgets/effects/qgraphicseffect_p.h @@ -59,7 +59,8 @@ #include #include -#ifndef QT_NO_GRAPHICSEFFECT +QT_REQUIRE_CONFIG(graphicseffect); + QT_BEGIN_NAMESPACE class QGraphicsEffectSourcePrivate; @@ -226,6 +227,4 @@ public: QT_END_NAMESPACE -#endif //QT_NO_GRAPHICSEFFECT #endif // QGRAPHICSEFFECT_P_H - diff --git a/src/widgets/effects/qpixmapfilter.cpp b/src/widgets/effects/qpixmapfilter.cpp index 999e551af47..9d70825b0ee 100644 --- a/src/widgets/effects/qpixmapfilter.cpp +++ b/src/widgets/effects/qpixmapfilter.cpp @@ -54,7 +54,6 @@ #include "private/qmemrotate_p.h" #include "private/qdrawhelper_p.h" -#ifndef QT_NO_GRAPHICSEFFECT QT_BEGIN_NAMESPACE class QPixmapFilterPrivate : public QObjectPrivate @@ -1353,5 +1352,3 @@ void QPixmapDropShadowFilter::draw(QPainter *p, QT_END_NAMESPACE #include "moc_qpixmapfilter_p.cpp" - -#endif //QT_NO_GRAPHICSEFFECT diff --git a/src/widgets/effects/qpixmapfilter_p.h b/src/widgets/effects/qpixmapfilter_p.h index b9af3ae916c..399a8351423 100644 --- a/src/widgets/effects/qpixmapfilter_p.h +++ b/src/widgets/effects/qpixmapfilter_p.h @@ -56,9 +56,9 @@ #include #include -#ifndef QT_NO_GRAPHICSEFFECT -QT_BEGIN_NAMESPACE +QT_REQUIRE_CONFIG(graphicseffect); +QT_BEGIN_NAMESPACE class QPainter; class QPlatformPixmap; @@ -187,5 +187,4 @@ public: QT_END_NAMESPACE -#endif //QT_NO_GRAPHICSEFFECT #endif // QPIXMAPFILTER_H diff --git a/src/widgets/graphicsview/qgraphicsitem.cpp b/src/widgets/graphicsview/qgraphicsitem.cpp index 3ce9c835db9..239a110119b 100644 --- a/src/widgets/graphicsview/qgraphicsitem.cpp +++ b/src/widgets/graphicsview/qgraphicsitem.cpp @@ -756,7 +756,9 @@ #include #include #include +#if QT_CONFIG(graphicseffect) #include +#endif #include #include @@ -1558,9 +1560,9 @@ QGraphicsItem::~QGraphicsItem() setParentItem(0); } -#ifndef QT_NO_GRAPHICSEFFECT +#if QT_CONFIG(graphicseffect) delete d_ptr->graphicsEffect; -#endif //QT_NO_GRAPHICSEFFECT +#endif // QT_CONFIG(graphicseffect) if (d_ptr->transformData) { for(int i = 0; i < d_ptr->transformData->graphicsTransforms.size(); ++i) { QGraphicsTransform *t = d_ptr->transformData->graphicsTransforms.at(i); @@ -2383,9 +2385,9 @@ void QGraphicsItemPrivate::setVisibleHelper(bool newVisible, bool explicitly, if (c) c->purge(); if (scene) { -#ifndef QT_NO_GRAPHICSEFFECT +#if QT_CONFIG(graphicseffect) invalidateParentGraphicsEffectsRecursively(); -#endif //QT_NO_GRAPHICSEFFECT +#endif // QT_CONFIG(graphicseffect) scene->d_func()->markDirty(q_ptr, QRectF(), /*invalidateChildren=*/false, /*force=*/true); } } @@ -2832,11 +2834,11 @@ void QGraphicsItem::setOpacity(qreal opacity) // Update. if (d_ptr->scene) { -#ifndef QT_NO_GRAPHICSEFFECT +#if QT_CONFIG(graphicseffect) d_ptr->invalidateParentGraphicsEffectsRecursively(); if (!(d_ptr->flags & ItemDoesntPropagateOpacityToChildren)) d_ptr->invalidateChildGraphicsEffectsRecursively(QGraphicsItemPrivate::OpacityChanged); -#endif //QT_NO_GRAPHICSEFFECT +#endif // QT_CONFIG(graphicseffect) d_ptr->scene->d_func()->markDirty(this, QRectF(), /*invalidateChildren=*/true, /*force=*/false, @@ -2854,7 +2856,7 @@ void QGraphicsItem::setOpacity(qreal opacity) \since 4.6 */ -#ifndef QT_NO_GRAPHICSEFFECT +#if QT_CONFIG(graphicseffect) QGraphicsEffect *QGraphicsItem::graphicsEffect() const { return d_ptr->graphicsEffect; @@ -2896,11 +2898,11 @@ void QGraphicsItem::setGraphicsEffect(QGraphicsEffect *effect) prepareGeometryChange(); } } -#endif //QT_NO_GRAPHICSEFFECT +#endif // QT_CONFIG(graphicseffect) void QGraphicsItemPrivate::updateChildWithGraphicsEffectFlagRecursively() { -#ifndef QT_NO_GRAPHICSEFFECT +#if QT_CONFIG(graphicseffect) QGraphicsItemPrivate *itemPrivate = this; do { // parent chain already notified? @@ -2923,7 +2925,7 @@ void QGraphicsItemPrivate::updateChildWithGraphicsEffectFlagRecursively() */ QRectF QGraphicsItemPrivate::effectiveBoundingRect(const QRectF &rect) const { -#ifndef QT_NO_GRAPHICSEFFECT +#if QT_CONFIG(graphicseffect) Q_Q(const QGraphicsItem); QGraphicsEffect *effect = graphicsEffect; if (scene && effect && effect->isEnabled()) { @@ -2939,7 +2941,7 @@ QRectF QGraphicsItemPrivate::effectiveBoundingRect(const QRectF &rect) const } return q->mapRectFromScene(sceneEffectRect); } -#endif //QT_NO_GRAPHICSEFFECT +#endif // QT_CONFIG(graphicseffect) return rect; } @@ -2955,7 +2957,7 @@ QRectF QGraphicsItemPrivate::effectiveBoundingRect(const QRectF &rect) const */ QRectF QGraphicsItemPrivate::effectiveBoundingRect(QGraphicsItem *topMostEffectItem) const { -#ifndef QT_NO_GRAPHICSEFFECT +#if QT_CONFIG(graphicseffect) Q_Q(const QGraphicsItem); QRectF brect = effectiveBoundingRect(q_ptr->boundingRect()); if (ancestorFlags & QGraphicsItemPrivate::AncestorClipsChildren @@ -2980,10 +2982,10 @@ QRectF QGraphicsItemPrivate::effectiveBoundingRect(QGraphicsItem *topMostEffectI } return brect; -#else //QT_NO_GRAPHICSEFFECT +#else //QT_CONFIG(graphicseffect) Q_UNUSED(topMostEffectItem); return q_ptr->boundingRect(); -#endif //QT_NO_GRAPHICSEFFECT +#endif // QT_CONFIG(graphicseffect) } @@ -5485,7 +5487,7 @@ int QGraphicsItemPrivate::depth() const /*! \internal */ -#ifndef QT_NO_GRAPHICSEFFECT +#if QT_CONFIG(graphicseffect) void QGraphicsItemPrivate::invalidateParentGraphicsEffectsRecursively() { QGraphicsItemPrivate *itemPrivate = this; @@ -5516,7 +5518,7 @@ void QGraphicsItemPrivate::invalidateChildGraphicsEffectsRecursively(QGraphicsIt childPrivate->invalidateChildGraphicsEffectsRecursively(reason); } } -#endif //QT_NO_GRAPHICSEFFECT +#endif // QT_CONFIG(graphicseffect) /*! \internal @@ -5798,9 +5800,9 @@ void QGraphicsItem::update(const QRectF &rect) return; // Make sure we notify effects about invalidated source. -#ifndef QT_NO_GRAPHICSEFFECT +#if QT_CONFIG(graphicseffect) d_ptr->invalidateParentGraphicsEffectsRecursively(); -#endif //QT_NO_GRAPHICSEFFECT +#endif // QT_CONFIG(graphicseffect) if (CacheMode(d_ptr->cacheMode) != NoCache) { // Invalidate cache. @@ -11225,7 +11227,7 @@ int QGraphicsItemGroup::type() const return Type; } -#ifndef QT_NO_GRAPHICSEFFECT +#if QT_CONFIG(graphicseffect) QRectF QGraphicsItemEffectSourcePrivate::boundingRect(Qt::CoordinateSystem system) const { const bool deviceCoordinates = (system == Qt::DeviceCoordinates); @@ -11366,7 +11368,7 @@ QPixmap QGraphicsItemEffectSourcePrivate::pixmap(Qt::CoordinateSystem system, QP return pixmap; } -#endif //QT_NO_GRAPHICSEFFECT +#endif // QT_CONFIG(graphicseffect) #ifndef QT_NO_DEBUG_STREAM static void formatGraphicsItemHelper(QDebug debug, const QGraphicsItem *item) diff --git a/src/widgets/graphicsview/qgraphicsitem.h b/src/widgets/graphicsview/qgraphicsitem.h index 36f8aac124d..35e3d544e97 100644 --- a/src/widgets/graphicsview/qgraphicsitem.h +++ b/src/widgets/graphicsview/qgraphicsitem.h @@ -228,11 +228,11 @@ public: qreal effectiveOpacity() const; void setOpacity(qreal opacity); -#ifndef QT_NO_GRAPHICSEFFECT +#if QT_CONFIG(graphicseffect) // Effect QGraphicsEffect *graphicsEffect() const; void setGraphicsEffect(QGraphicsEffect *effect); -#endif //QT_NO_GRAPHICSEFFECT +#endif // QT_CONFIG(graphicseffect) Qt::MouseButtons acceptedMouseButtons() const; void setAcceptedMouseButtons(Qt::MouseButtons buttons); @@ -550,7 +550,7 @@ class Q_WIDGETS_EXPORT QGraphicsObject : public QObject, public QGraphicsItem Q_PROPERTY(qreal rotation READ rotation WRITE setRotation NOTIFY rotationChanged) Q_PROPERTY(qreal scale READ scale WRITE setScale NOTIFY scaleChanged) Q_PROPERTY(QPointF transformOriginPoint READ transformOriginPoint WRITE setTransformOriginPoint) -#ifndef QT_NO_GRAPHICSEFFECT +#if QT_CONFIG(graphicseffect) Q_PROPERTY(QGraphicsEffect *effect READ graphicsEffect WRITE setGraphicsEffect) #endif Q_PRIVATE_PROPERTY(QGraphicsItem::d_func(), QDeclarativeListProperty children READ childrenList DESIGNABLE false NOTIFY childrenChanged) diff --git a/src/widgets/graphicsview/qgraphicsitem_p.h b/src/widgets/graphicsview/qgraphicsitem_p.h index c88236d6e87..5c4523f9ed1 100644 --- a/src/widgets/graphicsview/qgraphicsitem_p.h +++ b/src/widgets/graphicsview/qgraphicsitem_p.h @@ -59,9 +59,6 @@ #include "qgraphicstransform.h" #include -#include -#include - #include #if !defined(QT_NO_GRAPHICSVIEW) @@ -217,13 +214,13 @@ public: bool ignoreDirtyBit = false, bool ignoreOpacity = false) const; virtual void transformChanged() {} int depth() const; -#ifndef QT_NO_GRAPHICSEFFECT +#if QT_CONFIG(graphicseffect) enum InvalidateReason { OpacityChanged }; void invalidateParentGraphicsEffectsRecursively(); void invalidateChildGraphicsEffectsRecursively(InvalidateReason reason); -#endif //QT_NO_GRAPHICSEFFECT +#endif // QT_CONFIG(graphicseffect) void invalidateDepthRecursively(); void resolveDepth(); void addChild(QGraphicsItem *child); @@ -590,7 +587,7 @@ struct QGraphicsItemPaintInfo quint32 drawItem : 1; }; -#ifndef QT_NO_GRAPHICSEFFECT +#if QT_CONFIG(graphicseffect) class QGraphicsItemEffectSourcePrivate : public QGraphicsEffectSourcePrivate { public: @@ -650,7 +647,7 @@ public: QGraphicsItemPaintInfo *info; QTransform lastEffectTransform; }; -#endif //QT_NO_GRAPHICSEFFECT +#endif // QT_CONFIG(graphicseffect) /*! Returns \c true if \a item1 is on top of \a item2. @@ -784,7 +781,7 @@ inline bool QGraphicsItemPrivate::insertionOrder(QGraphicsItem *a, QGraphicsItem inline void QGraphicsItemPrivate::markParentDirty(bool updateBoundingRect) { QGraphicsItemPrivate *parentp = this; -#ifndef QT_NO_GRAPHICSEFFECT +#if QT_CONFIG(graphicseffect) if (updateBoundingRect && parentp->graphicsEffect && !parentp->inSetPosHelper) { parentp->notifyInvalidated = 1; static_cast(parentp->graphicsEffect->d_func() @@ -800,7 +797,7 @@ inline void QGraphicsItemPrivate::markParentDirty(bool updateBoundingRect) // ### Only do this if the parent's effect applies to the entire subtree. parentp->notifyBoundingRectChanged = 1; } -#ifndef QT_NO_GRAPHICSEFFECT +#if QT_CONFIG(graphicseffect) if (parentp->graphicsEffect) { if (updateBoundingRect) { static_cast(parentp->graphicsEffect->d_func() diff --git a/src/widgets/graphicsview/qgraphicsscene.cpp b/src/widgets/graphicsview/qgraphicsscene.cpp index 35f6298a8a1..db41fc3eb96 100644 --- a/src/widgets/graphicsview/qgraphicsscene.cpp +++ b/src/widgets/graphicsview/qgraphicsscene.cpp @@ -243,10 +243,11 @@ #include #include #include -#include #include #include +#if QT_CONFIG(graphicseffect) #include +#endif #include #include @@ -4810,7 +4811,7 @@ void QGraphicsScenePrivate::drawSubtreeRecursive(QGraphicsItem *item, QPainter * if (itemHasChildren && itemClipsChildrenToShape) ENSURE_TRANSFORM_PTR; -#ifndef QT_NO_GRAPHICSEFFECT +#if QT_CONFIG(graphicseffect) if (item->d_ptr->graphicsEffect && item->d_ptr->graphicsEffect->isEnabled()) { ENSURE_TRANSFORM_PTR; QGraphicsItemPaintInfo info(viewTransform, transformPtr, effectTransform, exposedRegion, widget, &styleOptionTmp, @@ -4847,7 +4848,7 @@ void QGraphicsScenePrivate::drawSubtreeRecursive(QGraphicsItem *item, QPainter * painter->setWorldTransform(restoreTransform); sourced->info = 0; } else -#endif //QT_NO_GRAPHICSEFFECT +#endif // QT_CONFIG(graphicseffect) { draw(item, painter, viewTransform, transformPtr, exposedRegion, widget, opacity, effectTransform, wasDirtyParentSceneTransform, drawItem); diff --git a/src/widgets/graphicsview/qgraphicsscene_p.h b/src/widgets/graphicsview/qgraphicsscene_p.h index 795676878b0..c52770501f9 100644 --- a/src/widgets/graphicsview/qgraphicsscene_p.h +++ b/src/widgets/graphicsview/qgraphicsscene_p.h @@ -249,7 +249,7 @@ public: item->d_ptr->fullUpdatePending = 0; item->d_ptr->ignoreVisible = 0; item->d_ptr->ignoreOpacity = 0; -#ifndef QT_NO_GRAPHICSEFFECT +#if QT_CONFIG(graphicseffect) QGraphicsEffect::ChangeFlags flags; if (item->d_ptr->notifyBoundingRectChanged) { flags |= QGraphicsEffect::SourceBoundingRectChanged; @@ -259,15 +259,15 @@ public: flags |= QGraphicsEffect::SourceInvalidated; item->d_ptr->notifyInvalidated = 0; } -#endif //QT_NO_GRAPHICSEFFECT +#endif // QT_CONFIG(graphicseffect) if (recursive) { for (int i = 0; i < item->d_ptr->children.size(); ++i) resetDirtyItem(item->d_ptr->children.at(i), recursive); } -#ifndef QT_NO_GRAPHICSEFFECT +#if QT_CONFIG(graphicseffect) if (flags && item->d_ptr->graphicsEffect) item->d_ptr->graphicsEffect->sourceChanged(flags); -#endif //QT_NO_GRAPHICSEFFECT +#endif // QT_CONFIG(graphicseffect) } inline void ensureSortedTopLevelItems() diff --git a/src/widgets/kernel/qapplication.cpp b/src/widgets/kernel/qapplication.cpp index 6536da4e90c..d2f41612974 100644 --- a/src/widgets/kernel/qapplication.cpp +++ b/src/widgets/kernel/qapplication.cpp @@ -51,6 +51,7 @@ #include "qhash.h" #include "qset.h" #include "qlayout.h" +#include "qpixmapcache.h" #include "qstyle.h" #include "qstyleoption.h" #include "qstylefactory.h" diff --git a/src/widgets/kernel/qwidget.cpp b/src/widgets/kernel/qwidget.cpp index f1319d9cdab..6440ed01732 100644 --- a/src/widgets/kernel/qwidget.cpp +++ b/src/widgets/kernel/qwidget.cpp @@ -84,7 +84,9 @@ #include #include +#if QT_CONFIG(graphicseffect) #include +#endif #include #include #if 0 // Used to be included in Qt4 for Q_WS_MAC @@ -2115,7 +2117,7 @@ void QWidgetPrivate::setSystemClip(QPaintDevice *paintDevice, const QRegion ® paintEngine->d_func()->systemClip = scaleTransform.map(region); } -#ifndef QT_NO_GRAPHICSEFFECT +#if QT_CONFIG(graphicseffect) void QWidgetPrivate::invalidateGraphicsEffectsRecursively() { Q_Q(QWidget); @@ -2130,7 +2132,7 @@ void QWidgetPrivate::invalidateGraphicsEffectsRecursively() w = w->parentWidget(); } while (w); } -#endif //QT_NO_GRAPHICSEFFECT +#endif // QT_CONFIG(graphicseffect) void QWidgetPrivate::setDirtyOpaqueRegion() { @@ -2138,9 +2140,9 @@ void QWidgetPrivate::setDirtyOpaqueRegion() dirtyOpaqueChildren = true; -#ifndef QT_NO_GRAPHICSEFFECT +#if QT_CONFIG(graphicseffect) invalidateGraphicsEffectsRecursively(); -#endif //QT_NO_GRAPHICSEFFECT +#endif // QT_CONFIG(graphicseffect) if (q->isWindow()) return; @@ -2294,12 +2296,12 @@ void QWidgetPrivate::clipToEffectiveMask(QRegion ®ion) const const QWidget *w = q; QPoint offset; -#ifndef QT_NO_GRAPHICSEFFECT +#if QT_CONFIG(graphicseffect) if (graphicsEffect) { w = q->parentWidget(); offset -= data.crect.topLeft(); } -#endif //QT_NO_GRAPHICSEFFECT +#endif // QT_CONFIG(graphicseffect) while (w) { const QWidgetPrivate *wd = w->d_func(); @@ -2332,13 +2334,13 @@ void QWidgetPrivate::updateIsOpaque() // hw: todo: only needed if opacity actually changed setDirtyOpaqueRegion(); -#ifndef QT_NO_GRAPHICSEFFECT +#if QT_CONFIG(graphicseffect) if (graphicsEffect) { // ### We should probably add QGraphicsEffect::isOpaque at some point. setOpaque(false); return; } -#endif //QT_NO_GRAPHICSEFFECT +#endif // QT_CONFIG(graphicseffect) Q_Q(QWidget); #if 0 // Used to be included in Qt4 for Q_WS_X11 @@ -5299,13 +5301,13 @@ QPixmap QWidget::grab(const QRect &rectangle) \sa setGraphicsEffect() */ -#ifndef QT_NO_GRAPHICSEFFECT +#if QT_CONFIG(graphicseffect) QGraphicsEffect *QWidget::graphicsEffect() const { Q_D(const QWidget); return d->graphicsEffect; } -#endif //QT_NO_GRAPHICSEFFECT +#endif // QT_CONFIG(graphicseffect) /*! @@ -5329,7 +5331,7 @@ QGraphicsEffect *QWidget::graphicsEffect() const \sa graphicsEffect() */ -#ifndef QT_NO_GRAPHICSEFFECT +#if QT_CONFIG(graphicseffect) void QWidget::setGraphicsEffect(QGraphicsEffect *effect) { Q_D(QWidget); @@ -5353,7 +5355,7 @@ void QWidget::setGraphicsEffect(QGraphicsEffect *effect) d->updateIsOpaque(); } -#endif //QT_NO_GRAPHICSEFFECT +#endif // QT_CONFIG(graphicseffect) bool QWidgetPrivate::isAboutToShow() const { @@ -5505,7 +5507,7 @@ void QWidgetPrivate::drawWidget(QPaintDevice *pdev, const QRegion &rgn, const QP bool onScreen = paintOnScreen(); Q_Q(QWidget); -#ifndef QT_NO_GRAPHICSEFFECT +#if QT_CONFIG(graphicseffect) if (graphicsEffect && graphicsEffect->isEnabled()) { QGraphicsEffectSource *source = graphicsEffect->d_func()->source; QWidgetEffectSourcePrivate *sourced = static_cast @@ -5541,7 +5543,7 @@ void QWidgetPrivate::drawWidget(QPaintDevice *pdev, const QRegion &rgn, const QP return; } } -#endif //QT_NO_GRAPHICSEFFECT +#endif // QT_CONFIG(graphicseffect) const bool alsoOnScreen = flags & DrawPaintOnScreen; const bool recursive = flags & DrawRecursive; @@ -5848,7 +5850,7 @@ void QWidgetPrivate::paintSiblingsRecursive(QPaintDevice *pdev, const QObjectLis } } -#ifndef QT_NO_GRAPHICSEFFECT +#if QT_CONFIG(graphicseffect) QRectF QWidgetEffectSourcePrivate::boundingRect(Qt::CoordinateSystem system) const { if (system != Qt::DeviceCoordinates) @@ -5923,7 +5925,7 @@ QPixmap QWidgetEffectSourcePrivate::pixmap(Qt::CoordinateSystem system, QPoint * m_widget->render(&pixmap, pixmapOffset, QRegion(), QWidget::DrawChildren); return pixmap; } -#endif //QT_NO_GRAPHICSEFFECT +#endif // QT_CONFIG(graphicseffect) #ifndef QT_NO_GRAPHICSVIEW /*! diff --git a/src/widgets/kernel/qwidget.h b/src/widgets/kernel/qwidget.h index 87a841c7295..3b0678d349c 100644 --- a/src/widgets/kernel/qwidget.h +++ b/src/widgets/kernel/qwidget.h @@ -347,10 +347,10 @@ public: Q_INVOKABLE QPixmap grab(const QRect &rectangle = QRect(QPoint(0, 0), QSize(-1, -1))); -#ifndef QT_NO_GRAPHICSEFFECT +#if QT_CONFIG(graphicseffect) QGraphicsEffect *graphicsEffect() const; void setGraphicsEffect(QGraphicsEffect *effect); -#endif //QT_NO_GRAPHICSEFFECT +#endif // QT_CONFIG(graphicseffect) #ifndef QT_NO_GESTURES void grabGesture(Qt::GestureType type, Qt::GestureFlags flags = Qt::GestureFlags()); diff --git a/src/widgets/kernel/qwidget_p.h b/src/widgets/kernel/qwidget_p.h index da3e9bd2f68..e2affa802cf 100644 --- a/src/widgets/kernel/qwidget_p.h +++ b/src/widgets/kernel/qwidget_p.h @@ -64,7 +64,9 @@ #include "QtWidgets/qsizepolicy.h" #include "QtWidgets/qstyle.h" #include "QtWidgets/qapplication.h" +#if QT_CONFIG(graphicseffect) #include +#endif #include "QtWidgets/qgraphicsproxywidget.h" #include "QtWidgets/qgraphicsscene.h" #include "QtWidgets/qgraphicsview.h" @@ -418,9 +420,9 @@ public: void setOpaque(bool opaque); void updateIsTranslucent(); bool paintOnScreen() const; -#ifndef QT_NO_GRAPHICSEFFECT +#if QT_CONFIG(graphicseffect) void invalidateGraphicsEffectsRecursively(); -#endif //QT_NO_GRAPHICSEFFECT +#endif // QT_CONFIG(graphicseffect) const QRegion &getOpaqueChildren() const; void setDirtyOpaqueRegion(); @@ -589,10 +591,10 @@ public: inline QRect effectiveRectFor(const QRect &rect) const { -#ifndef QT_NO_GRAPHICSEFFECT +#if QT_CONFIG(graphicseffect) if (graphicsEffect && graphicsEffect->isEnabled()) return graphicsEffect->boundingRectFor(rect).toAlignedRect(); -#endif //QT_NO_GRAPHICSEFFECT +#endif // QT_CONFIG(graphicseffect) return rect; } @@ -882,7 +884,7 @@ struct QWidgetPaintContext QPainter *painter; }; -#ifndef QT_NO_GRAPHICSEFFECT +#if QT_CONFIG(graphicseffect) class QWidgetEffectSourcePrivate : public QGraphicsEffectSourcePrivate { public: @@ -935,7 +937,7 @@ public: QTransform lastEffectTransform; bool updateDueToGraphicsEffect; }; -#endif //QT_NO_GRAPHICSEFFECT +#endif // QT_CONFIG(graphicseffect) inline QWExtra *QWidgetPrivate::extraData() const { diff --git a/src/widgets/kernel/qwidgetbackingstore.cpp b/src/widgets/kernel/qwidgetbackingstore.cpp index 781ad9600d7..2f4bcd63707 100644 --- a/src/widgets/kernel/qwidgetbackingstore.cpp +++ b/src/widgets/kernel/qwidgetbackingstore.cpp @@ -53,7 +53,9 @@ #include #include #include +#if QT_CONFIG(graphicseffect) #include +#endif #include #include @@ -522,9 +524,9 @@ void QWidgetBackingStore::markDirty(const QRegion &rgn, QWidget *widget, Q_ASSERT(widget->window() == tlw); Q_ASSERT(!rgn.isEmpty()); -#ifndef QT_NO_GRAPHICSEFFECT +#if QT_CONFIG(graphicseffect) widget->d_func()->invalidateGraphicsEffectsRecursively(); -#endif //QT_NO_GRAPHICSEFFECT +#endif // QT_CONFIG(graphicseffect) if (widget->d_func()->paintOnScreen()) { if (widget->d_func()->dirty.isEmpty()) { @@ -563,11 +565,11 @@ void QWidgetBackingStore::markDirty(const QRegion &rgn, QWidget *widget, if (bufferState == BufferInvalid) { const bool eventAlreadyPosted = !dirty.isEmpty() || updateRequestSent; -#ifndef QT_NO_GRAPHICSEFFECT +#if QT_CONFIG(graphicseffect) if (widget->d_func()->graphicsEffect) dirty += widget->d_func()->effectiveRectFor(rgn.boundingRect()).translated(offset); else -#endif //QT_NO_GRAPHICSEFFECT +#endif // QT_CONFIG(graphicseffect) dirty += rgn.translated(offset); if (!eventAlreadyPosted || updateTime == UpdateNow) sendUpdateRequest(tlw, updateTime); @@ -582,11 +584,11 @@ void QWidgetBackingStore::markDirty(const QRegion &rgn, QWidget *widget, if (widget->d_func()->inDirtyList) { if (!qt_region_strictContains(widget->d_func()->dirty, widgetRect)) { -#ifndef QT_NO_GRAPHICSEFFECT +#if QT_CONFIG(graphicseffect) if (widget->d_func()->graphicsEffect) widget->d_func()->dirty += widget->d_func()->effectiveRectFor(rgn.boundingRect()); else -#endif //QT_NO_GRAPHICSEFFECT +#endif // QT_CONFIG(graphicseffect) widget->d_func()->dirty += rgn; } } else { @@ -614,9 +616,9 @@ void QWidgetBackingStore::markDirty(const QRect &rect, QWidget *widget, Q_ASSERT(widget->window() == tlw); Q_ASSERT(!rect.isEmpty()); -#ifndef QT_NO_GRAPHICSEFFECT +#if QT_CONFIG(graphicseffect) widget->d_func()->invalidateGraphicsEffectsRecursively(); -#endif //QT_NO_GRAPHICSEFFECT +#endif // QT_CONFIG(graphicseffect) if (widget->d_func()->paintOnScreen()) { if (widget->d_func()->dirty.isEmpty()) { diff --git a/src/widgets/kernel/qwidgetbackingstore_p.h b/src/widgets/kernel/qwidgetbackingstore_p.h index 16b36423a6c..fa51cb71de9 100644 --- a/src/widgets/kernel/qwidgetbackingstore_p.h +++ b/src/widgets/kernel/qwidgetbackingstore_p.h @@ -176,11 +176,11 @@ private: { if (widget && !widget->d_func()->inDirtyList && !widget->data->in_destructor) { QWidgetPrivate *widgetPrivate = widget->d_func(); -#ifndef QT_NO_GRAPHICSEFFECT +#if QT_CONFIG(graphicseffect) if (widgetPrivate->graphicsEffect) widgetPrivate->dirty = widgetPrivate->effectiveRectFor(rgn.boundingRect()); else -#endif //QT_NO_GRAPHICSEFFECT +#endif // QT_CONFIG(graphicseffect) widgetPrivate->dirty = rgn; dirtyWidgets.append(widget); widgetPrivate->inDirtyList = true; diff --git a/src/widgets/widgets.pro b/src/widgets/widgets.pro index e4f7640a107..22bdf084080 100644 --- a/src/widgets/widgets.pro +++ b/src/widgets/widgets.pro @@ -23,8 +23,10 @@ include(itemviews/itemviews.pri) include(graphicsview/graphicsview.pri) include(util/util.pri) include(statemachine/statemachine.pri) -include(effects/effects.pri) +qtConfig(graphicseffect) { + include(effects/effects.pri) +} QMAKE_LIBS += $$QMAKE_LIBS_GUI From 3906043f05d2ffccede47f845561cca95548ac5a Mon Sep 17 00:00:00 2001 From: Stephan Binner Date: Sun, 9 Jul 2017 10:29:12 +0200 Subject: [PATCH 49/63] Convert features.fontdialog to QT_[REQUIRE_]CONFIG Change-Id: Iebc091ffd023595278fa177b7f205b6e0cd7ec52 Reviewed-by: Oswald Buddenhagen --- src/plugins/platforms/cocoa/cocoa.pro | 7 +++++-- .../platforms/cocoa/qcocoafontdialoghelper.h | 3 +++ .../platforms/cocoa/qcocoafontdialoghelper.mm | 4 ---- src/plugins/platforms/cocoa/qcocoatheme.mm | 8 +++++--- src/widgets/dialogs/dialogs.pri | 14 ++++++++------ src/widgets/dialogs/qdialog.cpp | 4 +++- src/widgets/dialogs/qfontdialog.cpp | 4 ---- src/widgets/dialogs/qfontdialog.h | 7 ++----- src/widgets/dialogs/qfontdialog_p.h | 4 +--- 9 files changed, 27 insertions(+), 28 deletions(-) diff --git a/src/plugins/platforms/cocoa/cocoa.pro b/src/plugins/platforms/cocoa/cocoa.pro index 23a049bebc6..13e59906ca8 100644 --- a/src/plugins/platforms/cocoa/cocoa.pro +++ b/src/plugins/platforms/cocoa/cocoa.pro @@ -20,7 +20,6 @@ OBJECTIVE_SOURCES += main.mm \ qmultitouch_mac.mm \ qcocoaaccessibilityelement.mm \ qcocoaaccessibility.mm \ - qcocoafontdialoghelper.mm \ qcocoacursor.mm \ qcocoaclipboard.mm \ qcocoadrag.mm \ @@ -53,7 +52,6 @@ HEADERS += qcocoaintegration.h \ qmultitouch_mac_p.h \ qcocoaaccessibilityelement.h \ qcocoaaccessibility.h \ - qcocoafontdialoghelper.h \ qcocoacursor.h \ qcocoaclipboard.h \ qcocoadrag.h \ @@ -109,6 +107,11 @@ qtHaveModule(widgets) { HEADERS += qcocoafiledialoghelper.h } + qtConfig(fontdialog) { + SOURCES += qcocoafontdialoghelper.mm + HEADERS += qcocoafontdialoghelper.h + } + QT += widgets-private printsupport-private } diff --git a/src/plugins/platforms/cocoa/qcocoafontdialoghelper.h b/src/plugins/platforms/cocoa/qcocoafontdialoghelper.h index 8b05cb79337..c3fad7cfd6a 100644 --- a/src/plugins/platforms/cocoa/qcocoafontdialoghelper.h +++ b/src/plugins/platforms/cocoa/qcocoafontdialoghelper.h @@ -41,8 +41,11 @@ #define QCOCOAFONTDIALOGHELPER_H #include +#include #include +QT_REQUIRE_CONFIG(fontdialog); + QT_BEGIN_NAMESPACE class QCocoaFontDialogHelper : public QPlatformFontDialogHelper diff --git a/src/plugins/platforms/cocoa/qcocoafontdialoghelper.mm b/src/plugins/platforms/cocoa/qcocoafontdialoghelper.mm index e4b796dcde5..dbd7e90dbab 100644 --- a/src/plugins/platforms/cocoa/qcocoafontdialoghelper.mm +++ b/src/plugins/platforms/cocoa/qcocoafontdialoghelper.mm @@ -37,8 +37,6 @@ ** ****************************************************************************/ -#ifndef QT_NO_FONTDIALOG - #include #include #include @@ -402,5 +400,3 @@ QFont QCocoaFontDialogHelper::currentFont() const } QT_END_NAMESPACE - -#endif // QT_NO_FONTDIALOG diff --git a/src/plugins/platforms/cocoa/qcocoatheme.mm b/src/plugins/platforms/cocoa/qcocoatheme.mm index 08f41cddc2f..2f4a1e3e4c5 100644 --- a/src/plugins/platforms/cocoa/qcocoatheme.mm +++ b/src/plugins/platforms/cocoa/qcocoatheme.mm @@ -44,7 +44,6 @@ #include -#include "qcocoafontdialoghelper.h" #include "qcocoasystemsettings.h" #include "qcocoasystemtrayicon.h" #include "qcocoamenuitem.h" @@ -69,6 +68,9 @@ #if QT_CONFIG(filedialog) #include "qcocoafiledialoghelper.h" #endif +#if QT_CONFIG(fontdialog) +#include "qcocoafontdialoghelper.h" +#endif #endif #include @@ -136,7 +138,7 @@ bool QCocoaTheme::usePlatformNativeDialog(DialogType dialogType) const if (dialogType == QPlatformTheme::ColorDialog) return true; #endif -#ifndef QT_NO_FONTDIALOG +#if defined(QT_WIDGETS_LIB) && QT_CONFIG(fontdialog) if (dialogType == QPlatformTheme::FontDialog) return true; #endif @@ -154,7 +156,7 @@ QPlatformDialogHelper * QCocoaTheme::createPlatformDialogHelper(DialogType dialo case QPlatformTheme::ColorDialog: return new QCocoaColorDialogHelper(); #endif -#ifndef QT_NO_FONTDIALOG +#if defined(QT_WIDGETS_LIB) && QT_CONFIG(fontdialog) case QPlatformTheme::FontDialog: return new QCocoaFontDialogHelper(); #endif diff --git a/src/widgets/dialogs/dialogs.pri b/src/widgets/dialogs/dialogs.pri index c2625ec1f4e..a6a6b2d3523 100644 --- a/src/widgets/dialogs/dialogs.pri +++ b/src/widgets/dialogs/dialogs.pri @@ -1,12 +1,6 @@ # Qt dialogs module -HEADERS += \ - dialogs/qfontdialog.h \ - dialogs/qfontdialog_p.h - INCLUDEPATH += $$PWD -SOURCES += \ - dialogs/qfontdialog.cpp qtConfig(colordialog) { HEADERS += dialogs/qcolordialog.h @@ -51,6 +45,14 @@ qtConfig(filesystemmodel) { dialogs/qfileinfogatherer.cpp } +qtConfig(fontdialog) { + HEADERS += \ + dialogs/qfontdialog.h \ + dialogs/qfontdialog_p.h + + SOURCES += dialogs/qfontdialog.cpp +} + qtConfig(fscompleter) { HEADERS += dialogs/qfscompleter_p.h } diff --git a/src/widgets/dialogs/qdialog.cpp b/src/widgets/dialogs/qdialog.cpp index 7cb24d65fc8..1cd587b78d3 100644 --- a/src/widgets/dialogs/qdialog.cpp +++ b/src/widgets/dialogs/qdialog.cpp @@ -41,7 +41,9 @@ #if QT_CONFIG(colordialog) #include "qcolordialog.h" #endif +#if QT_CONFIG(fontdialog) #include "qfontdialog.h" +#endif #if QT_CONFIG(filedialog) #include "qfiledialog.h" #endif @@ -81,7 +83,7 @@ static inline int themeDialogType(const QDialog *dialog) if (qobject_cast(dialog)) return QPlatformTheme::ColorDialog; #endif -#ifndef QT_NO_FONTDIALOG +#if QT_CONFIG(fontdialog) if (qobject_cast(dialog)) return QPlatformTheme::FontDialog; #endif diff --git a/src/widgets/dialogs/qfontdialog.cpp b/src/widgets/dialogs/qfontdialog.cpp index b20a1449eb4..587e31d8c5e 100644 --- a/src/widgets/dialogs/qfontdialog.cpp +++ b/src/widgets/dialogs/qfontdialog.cpp @@ -40,8 +40,6 @@ #include "qwindowdefs.h" #include "qfontdialog.h" -#if QT_CONFIG(fontdialog) - #include "qfontdialog_p.h" #include @@ -1049,5 +1047,3 @@ QT_END_NAMESPACE #include "qfontdialog.moc" #include "moc_qfontdialog.cpp" - -#endif // QT_CONFIG(fontdialog) diff --git a/src/widgets/dialogs/qfontdialog.h b/src/widgets/dialogs/qfontdialog.h index da13a5ab997..3fb3997b856 100644 --- a/src/widgets/dialogs/qfontdialog.h +++ b/src/widgets/dialogs/qfontdialog.h @@ -44,12 +44,11 @@ #include #include -#ifndef QT_NO_FONTDIALOG - #include -QT_BEGIN_NAMESPACE +QT_REQUIRE_CONFIG(fontdialog); +QT_BEGIN_NAMESPACE class QFontDialogPrivate; @@ -120,6 +119,4 @@ Q_DECLARE_OPERATORS_FOR_FLAGS(QFontDialog::FontDialogOptions) QT_END_NAMESPACE -#endif // QT_NO_FONTDIALOG - #endif // QFONTDIALOG_H diff --git a/src/widgets/dialogs/qfontdialog_p.h b/src/widgets/dialogs/qfontdialog_p.h index 033f5a2be8b..ae923d94edf 100644 --- a/src/widgets/dialogs/qfontdialog_p.h +++ b/src/widgets/dialogs/qfontdialog_p.h @@ -59,7 +59,7 @@ #include #include "qsharedpointer.h" -#ifndef QT_NO_FONTDIALOG +QT_REQUIRE_CONFIG(fontdialog); QT_BEGIN_NAMESPACE @@ -149,8 +149,6 @@ private: virtual void helperPrepareShow(QPlatformDialogHelper *) Q_DECL_OVERRIDE; }; -#endif // QT_NO_FONTDIALOG - QT_END_NAMESPACE #endif // QFONTDIALOG_P_H From 3835194d340f8756d2ac7a5f9ae2a3519cb891b9 Mon Sep 17 00:00:00 2001 From: Stephan Binner Date: Sun, 9 Jul 2017 11:04:38 +0200 Subject: [PATCH 50/63] Convert features.rubberband to QT_[REQUIRE_]CONFIG Change-Id: I6d634bafa6d26c1e78069fddd412e6de24f5775c Reviewed-by: Oswald Buddenhagen --- src/widgets/accessible/qaccessiblewidget.cpp | 2 ++ .../accessible/qaccessiblewidgetfactory.cpp | 2 +- src/widgets/accessible/qaccessiblewidgets.cpp | 2 ++ src/widgets/graphicsview/qgraphicsview.cpp | 18 +++++------ src/widgets/graphicsview/qgraphicsview.h | 6 ++-- src/widgets/graphicsview/qgraphicsview_p.h | 2 +- src/widgets/itemviews/qlistview.cpp | 4 ++- src/widgets/itemviews/qlistview_p.h | 1 - src/widgets/styles/qcommonstyle.cpp | 10 ++++--- src/widgets/styles/qmacstyle_mac.mm | 2 ++ src/widgets/styles/qmacstyle_mac_p_p.h | 2 ++ src/widgets/styles/qstyleoption.cpp | 4 +-- src/widgets/styles/qstyleoption.h | 6 ++-- src/widgets/styles/qwindowsstyle.cpp | 10 ++++--- src/widgets/styles/qwindowsxpstyle.cpp | 12 ++++---- src/widgets/widgets/qmainwindowlayout.cpp | 6 ++-- src/widgets/widgets/qmainwindowlayout_p.h | 2 +- src/widgets/widgets/qmdiarea.cpp | 16 +++++----- src/widgets/widgets/qmdiarea_p.h | 6 ++-- src/widgets/widgets/qmdisubwindow.cpp | 30 +++++++++---------- src/widgets/widgets/qmdisubwindow_p.h | 8 ++--- src/widgets/widgets/qrubberband.cpp | 4 --- src/widgets/widgets/qrubberband.h | 7 ++--- src/widgets/widgets/qsplitter.cpp | 2 ++ src/widgets/widgets/qsplitter_p.h | 1 - src/widgets/widgets/qtoolbar.cpp | 2 ++ src/widgets/widgets/widgets.pri | 7 +++-- 27 files changed, 95 insertions(+), 79 deletions(-) diff --git a/src/widgets/accessible/qaccessiblewidget.cpp b/src/widgets/accessible/qaccessiblewidget.cpp index f18930f2732..3bc0f7e77bf 100644 --- a/src/widgets/accessible/qaccessiblewidget.cpp +++ b/src/widgets/accessible/qaccessiblewidget.cpp @@ -54,7 +54,9 @@ #include "qwidget.h" #include "qdebug.h" #include +#if QT_CONFIG(rubberband) #include +#endif #include #include #include diff --git a/src/widgets/accessible/qaccessiblewidgetfactory.cpp b/src/widgets/accessible/qaccessiblewidgetfactory.cpp index e7db53c251f..ccd176cd044 100644 --- a/src/widgets/accessible/qaccessiblewidgetfactory.cpp +++ b/src/widgets/accessible/qaccessiblewidgetfactory.cpp @@ -193,7 +193,7 @@ QAccessibleInterface *qAccessibleFactory(const QString &classname, QObject *obje } else if (classname == QLatin1String("QDial")) { iface = new QAccessibleDial(widget); #endif -#ifndef QT_NO_RUBBERBAND +#if QT_CONFIG(rubberband) } else if (classname == QLatin1String("QRubberBand")) { iface = new QAccessibleWidget(widget, QAccessible::Border); #endif diff --git a/src/widgets/accessible/qaccessiblewidgets.cpp b/src/widgets/accessible/qaccessiblewidgets.cpp index 7f77f7c5247..60f489d4871 100644 --- a/src/widgets/accessible/qaccessiblewidgets.cpp +++ b/src/widgets/accessible/qaccessiblewidgets.cpp @@ -58,7 +58,9 @@ #include #endif #include +#if QT_CONFIG(rubberband) #include +#endif #include #include #include diff --git a/src/widgets/graphicsview/qgraphicsview.cpp b/src/widgets/graphicsview/qgraphicsview.cpp index f5f24649c23..a00156ef01e 100644 --- a/src/widgets/graphicsview/qgraphicsview.cpp +++ b/src/widgets/graphicsview/qgraphicsview.cpp @@ -353,7 +353,7 @@ QGraphicsViewPrivate::QGraphicsViewPrivate() viewportUpdateMode(QGraphicsView::MinimalViewportUpdate), optimizationFlags(0), scene(0), -#ifndef QT_NO_RUBBERBAND +#if QT_CONFIG(rubberband) rubberBanding(false), rubberBandSelectionMode(Qt::IntersectsItemShape), rubberBandSelectionOperation(Qt::ReplaceSelection), @@ -633,7 +633,7 @@ void QGraphicsViewPrivate::mouseMoveEventHandler(QMouseEvent *event) { Q_Q(QGraphicsView); -#ifndef QT_NO_RUBBERBAND +#if QT_CONFIG(rubberband) updateRubberBand(event); #endif @@ -708,7 +708,7 @@ void QGraphicsViewPrivate::mouseMoveEventHandler(QMouseEvent *event) /*! \internal */ -#ifndef QT_NO_RUBBERBAND +#if QT_CONFIG(rubberband) QRegion QGraphicsViewPrivate::rubberBandRegion(const QWidget *widget, const QRect &rect) const { QStyleHintReturnMask mask; @@ -1508,7 +1508,7 @@ void QGraphicsView::setDragMode(DragMode mode) #endif } -#ifndef QT_NO_RUBBERBAND +#if QT_CONFIG(rubberband) /*! \property QGraphicsView::rubberBandSelectionMode \brief the behavior for selecting items with a rubber band selection rectangle. @@ -3274,7 +3274,7 @@ void QGraphicsView::mousePressEvent(QMouseEvent *event) } } -#ifndef QT_NO_RUBBERBAND +#if QT_CONFIG(rubberband) if (d->dragMode == QGraphicsView::RubberBandDrag && !d->rubberBanding) { if (d->sceneInteractionAllowed) { // Rubberbanding is only allowed in interactive mode. @@ -3336,7 +3336,7 @@ void QGraphicsView::mouseReleaseEvent(QMouseEvent *event) { Q_D(QGraphicsView); -#ifndef QT_NO_RUBBERBAND +#if QT_CONFIG(rubberband) if (d->dragMode == QGraphicsView::RubberBandDrag && d->sceneInteractionAllowed && !event->buttons()) { if (d->rubberBanding) { if (d->viewportUpdateMode != QGraphicsView::NoViewportUpdate){ @@ -3459,7 +3459,7 @@ void QGraphicsView::paintEvent(QPaintEvent *event) // Set up the painter QPainter painter(viewport()); -#ifndef QT_NO_RUBBERBAND +#if QT_CONFIG(rubberband) if (d->rubberBanding && !d->rubberBandRect.isEmpty()) painter.save(); #endif @@ -3583,7 +3583,7 @@ void QGraphicsView::paintEvent(QPaintEvent *event) // Foreground drawForeground(&painter, exposedSceneRect); -#ifndef QT_NO_RUBBERBAND +#if QT_CONFIG(rubberband) // Rubberband if (d->rubberBanding && !d->rubberBandRect.isEmpty()) { painter.restore(); @@ -3651,7 +3651,7 @@ void QGraphicsView::scrollContentsBy(int dx, int dy) if (d->viewportUpdateMode != QGraphicsView::NoViewportUpdate) { if (d->viewportUpdateMode != QGraphicsView::FullViewportUpdate) { if (d->accelerateScrolling) { -#ifndef QT_NO_RUBBERBAND +#if QT_CONFIG(rubberband) // Update new and old rubberband regions if (!d->rubberBandRect.isEmpty()) { QRegion rubberBandRegion(d->rubberBandRegion(viewport(), d->rubberBandRect)); diff --git a/src/widgets/graphicsview/qgraphicsview.h b/src/widgets/graphicsview/qgraphicsview.h index fb975b9d71e..d70ce6cf1ca 100644 --- a/src/widgets/graphicsview/qgraphicsview.h +++ b/src/widgets/graphicsview/qgraphicsview.h @@ -72,7 +72,7 @@ class Q_WIDGETS_EXPORT QGraphicsView : public QAbstractScrollArea Q_PROPERTY(ViewportAnchor transformationAnchor READ transformationAnchor WRITE setTransformationAnchor) Q_PROPERTY(ViewportAnchor resizeAnchor READ resizeAnchor WRITE setResizeAnchor) Q_PROPERTY(ViewportUpdateMode viewportUpdateMode READ viewportUpdateMode WRITE setViewportUpdateMode) -#ifndef QT_NO_RUBBERBAND +#if QT_CONFIG(rubberband) Q_PROPERTY(Qt::ItemSelectionMode rubberBandSelectionMode READ rubberBandSelectionMode WRITE setRubberBandSelectionMode) #endif Q_PROPERTY(OptimizationFlags optimizationFlags READ optimizationFlags WRITE setOptimizationFlags) @@ -144,7 +144,7 @@ public: DragMode dragMode() const; void setDragMode(DragMode mode); -#ifndef QT_NO_RUBBERBAND +#if QT_CONFIG(rubberband) Qt::ItemSelectionMode rubberBandSelectionMode() const; void setRubberBandSelectionMode(Qt::ItemSelectionMode mode); QRect rubberBandRect() const; @@ -228,7 +228,7 @@ public Q_SLOTS: void invalidateScene(const QRectF &rect = QRectF(), QGraphicsScene::SceneLayers layers = QGraphicsScene::AllLayers); void updateSceneRect(const QRectF &rect); -#ifndef QT_NO_RUBBERBAND +#if QT_CONFIG(rubberband) Q_SIGNALS: void rubberBandChanged(QRect viewportRect, QPointF fromScenePoint, QPointF toScenePoint); #endif diff --git a/src/widgets/graphicsview/qgraphicsview_p.h b/src/widgets/graphicsview/qgraphicsview_p.h index 10103a18096..b34be77f117 100644 --- a/src/widgets/graphicsview/qgraphicsview_p.h +++ b/src/widgets/graphicsview/qgraphicsview_p.h @@ -136,7 +136,7 @@ public: QGraphicsView::OptimizationFlags optimizationFlags; QPointer scene; -#ifndef QT_NO_RUBBERBAND +#if QT_CONFIG(rubberband) QRect rubberBandRect; QRegion rubberBandRegion(const QWidget *widget, const QRect &rect) const; void updateRubberBand(const QMouseEvent *event); diff --git a/src/widgets/itemviews/qlistview.cpp b/src/widgets/itemviews/qlistview.cpp index 396d84de9cd..ca416d9c044 100644 --- a/src/widgets/itemviews/qlistview.cpp +++ b/src/widgets/itemviews/qlistview.cpp @@ -50,7 +50,9 @@ #include #include #include +#if QT_CONFIG(rubberband) #include +#endif #include #include #include @@ -1043,7 +1045,7 @@ void QListView::paintEvent(QPaintEvent *e) d->commonListView->paintDragDrop(&painter); #endif -#ifndef QT_NO_RUBBERBAND +#if QT_CONFIG(rubberband) // #### move this implementation into a dynamic class if (d->showElasticBand && d->elasticBand.isValid()) { QStyleOptionRubberBand opt; diff --git a/src/widgets/itemviews/qlistview_p.h b/src/widgets/itemviews/qlistview_p.h index 5b674b3eca0..6c0e470a931 100644 --- a/src/widgets/itemviews/qlistview_p.h +++ b/src/widgets/itemviews/qlistview_p.h @@ -53,7 +53,6 @@ #include #include "private/qabstractitemview_p.h" -#include "qrubberband.h" #include "qbitarray.h" #include "qbsptree_p.h" #include diff --git a/src/widgets/styles/qcommonstyle.cpp b/src/widgets/styles/qcommonstyle.cpp index ad3ba88756b..56f9bfb3e7d 100644 --- a/src/widgets/styles/qcommonstyle.cpp +++ b/src/widgets/styles/qcommonstyle.cpp @@ -68,7 +68,9 @@ #include #include #include +#if QT_CONFIG(rubberband) #include +#endif #include "qtreeview.h" #include #include @@ -2002,7 +2004,7 @@ void QCommonStyle::drawControl(ControlElement element, const QStyleOption *opt, p->restore(); break; } #endif // QT_NO_SIZEGRIP -#ifndef QT_NO_RUBBERBAND +#if QT_CONFIG(rubberband) case CE_RubberBand: { if (const QStyleOptionRubberBand *rbOpt = qstyleoption_cast(opt)) { QPixmap tiledPixmap(16, 16); @@ -2030,7 +2032,7 @@ void QCommonStyle::drawControl(ControlElement element, const QStyleOption *opt, p->restore(); } break; } -#endif // QT_NO_RUBBERBAND +#endif // QT_CONFIG(rubberband) #ifndef QT_NO_DOCKWIDGET case CE_DockWidgetTitle: if (const QStyleOptionDockWidget *dwOpt = qstyleoption_cast(opt)) { @@ -5093,7 +5095,7 @@ int QCommonStyle::styleHint(StyleHint sh, const QStyleOption *opt, const QWidget } } break; -#ifndef QT_NO_RUBBERBAND +#if QT_CONFIG(rubberband) case SH_RubberBand_Mask: if (const QStyleOptionRubberBand *rbOpt = qstyleoption_cast(opt)) { ret = 0; @@ -5107,7 +5109,7 @@ int QCommonStyle::styleHint(StyleHint sh, const QStyleOption *opt, const QWidget } } break; -#endif // QT_NO_RUBBERBAND +#endif // QT_CONFIG(rubberband) case SH_SpinControls_DisableOnBounds: ret = 1; break; diff --git a/src/widgets/styles/qmacstyle_mac.mm b/src/widgets/styles/qmacstyle_mac.mm index fafe9c9e2c8..423ab6be5e2 100644 --- a/src/widgets/styles/qmacstyle_mac.mm +++ b/src/widgets/styles/qmacstyle_mac.mm @@ -80,7 +80,9 @@ #include #endif #include +#if QT_CONFIG(rubberband) #include +#endif #include #include #include diff --git a/src/widgets/styles/qmacstyle_mac_p_p.h b/src/widgets/styles/qmacstyle_mac_p_p.h index 2b388091a69..f6bb2fdddd8 100644 --- a/src/widgets/styles/qmacstyle_mac_p_p.h +++ b/src/widgets/styles/qmacstyle_mac_p_p.h @@ -82,7 +82,9 @@ #include #endif #include +#if QT_CONFIG(rubberband) #include +#endif #include #include #include diff --git a/src/widgets/styles/qstyleoption.cpp b/src/widgets/styles/qstyleoption.cpp index c12b3285f12..452f1121179 100644 --- a/src/widgets/styles/qstyleoption.cpp +++ b/src/widgets/styles/qstyleoption.cpp @@ -2797,7 +2797,7 @@ QStyleOptionToolBox::QStyleOptionToolBox(int version) a selected tab nor is it the selected tab. */ -#ifndef QT_NO_RUBBERBAND +#if QT_CONFIG(rubberband) /*! \class QStyleOptionRubberBand \brief The QStyleOptionRubberBand class is used to describe the @@ -2887,7 +2887,7 @@ QStyleOptionRubberBand::QStyleOptionRubberBand(int version) The default value is true. */ -#endif // QT_NO_RUBBERBAND +#endif // QT_CONFIG(rubberband) /*! \class QStyleOptionTitleBar diff --git a/src/widgets/styles/qstyleoption.h b/src/widgets/styles/qstyleoption.h index 0e76d53eeac..a3ed35c7620 100644 --- a/src/widgets/styles/qstyleoption.h +++ b/src/widgets/styles/qstyleoption.h @@ -49,7 +49,9 @@ #include #include #include +#if QT_CONFIG(rubberband) #include +#endif #include #ifndef QT_NO_ITEMVIEWS # include @@ -467,7 +469,7 @@ protected: typedef Q_DECL_DEPRECATED QStyleOptionToolBox QStyleOptionToolBoxV2; -#ifndef QT_NO_RUBBERBAND +#if QT_CONFIG(rubberband) class Q_WIDGETS_EXPORT QStyleOptionRubberBand : public QStyleOption { public: @@ -483,7 +485,7 @@ public: protected: QStyleOptionRubberBand(int version); }; -#endif // QT_NO_RUBBERBAND +#endif // QT_CONFIG(rubberband) // -------------------------- Complex style options ------------------------------- class Q_WIDGETS_EXPORT QStyleOptionComplex : public QStyleOption diff --git a/src/widgets/styles/qwindowsstyle.cpp b/src/widgets/styles/qwindowsstyle.cpp index efbb972a060..f805e29db10 100644 --- a/src/widgets/styles/qwindowsstyle.cpp +++ b/src/widgets/styles/qwindowsstyle.cpp @@ -51,7 +51,9 @@ #include #include "qpaintengine.h" #include "qpainter.h" +#if QT_CONFIG(rubberband) #include "qrubberband.h" +#endif #include "qstyleoption.h" #include "qtabbar.h" #include "qwidget.h" @@ -606,7 +608,7 @@ int QWindowsStyle::styleHint(StyleHint hint, const QStyleOption *opt, const QWid ret = 400; break; } -#ifndef QT_NO_RUBBERBAND +#if QT_CONFIG(rubberband) case SH_RubberBand_Mask: if (const QStyleOptionRubberBand *rbOpt = qstyleoption_cast(opt)) { ret = 0; @@ -622,7 +624,7 @@ int QWindowsStyle::styleHint(StyleHint hint, const QStyleOption *opt, const QWid } } break; -#endif // QT_NO_RUBBERBAND +#endif // QT_CONFIG(rubberband) #if QT_CONFIG(wizard) case SH_WizardStyle: ret = QWizard::ModernStyle; @@ -1080,7 +1082,7 @@ void QWindowsStyle::drawControl(ControlElement ce, const QStyleOption *opt, QPai const QWidget *widget) const { switch (ce) { -#ifndef QT_NO_RUBBERBAND +#if QT_CONFIG(rubberband) case CE_RubberBand: if (qstyleoption_cast(opt)) { // ### workaround for slow general painter path @@ -1103,7 +1105,7 @@ void QWindowsStyle::drawControl(ControlElement ce, const QStyleOption *opt, QPai return; } break; -#endif // QT_NO_RUBBERBAND +#endif // QT_CONFIG(rubberband) #if !defined(QT_NO_MENU) && !defined(QT_NO_MAINWINDOW) case CE_MenuBarEmptyArea: diff --git a/src/widgets/styles/qwindowsxpstyle.cpp b/src/widgets/styles/qwindowsxpstyle.cpp index 25321559b3c..87ac2ee4ae6 100644 --- a/src/widgets/styles/qwindowsxpstyle.cpp +++ b/src/widgets/styles/qwindowsxpstyle.cpp @@ -1159,7 +1159,7 @@ void QWindowsXPStyle::polish(QWidget *widget) widget->setAttribute(Qt::WA_Hover); } -#ifndef QT_NO_RUBBERBAND +#if QT_CONFIG(rubberband) if (qobject_cast(widget)) { widget->setWindowOpacity(0.6); } @@ -1194,7 +1194,7 @@ void QWindowsXPStyle::polish(QPalette &pal) /*! \reimp */ void QWindowsXPStyle::unpolish(QWidget *widget) { -#ifndef QT_NO_RUBBERBAND +#if QT_CONFIG(rubberband) if (qobject_cast(widget)) { widget->setWindowOpacity(1.0); } @@ -2412,7 +2412,7 @@ void QWindowsXPStyle::drawControl(ControlElement element, const QStyleOption *op } break; #endif // QT_NO_DOCKWIDGET -#ifndef QT_NO_RUBBERBAND +#if QT_CONFIG(rubberband) case CE_RubberBand: if (qstyleoption_cast(option)) { QColor highlight = option->palette.color(QPalette::Active, QPalette::Highlight); @@ -2428,7 +2428,7 @@ void QWindowsXPStyle::drawControl(ControlElement element, const QStyleOption *op return; } break; -#endif // QT_NO_RUBBERBAND +#endif // QT_CONFIG(rubberband) case CE_HeaderEmptyArea: if (option->state & State_Horizontal) { @@ -3752,12 +3752,12 @@ int QWindowsXPStyle::styleHint(StyleHint hint, const QStyleOption *option, const } } break; -#ifndef QT_NO_RUBBERBAND +#if QT_CONFIG(rubberband) case SH_RubberBand_Mask: if (qstyleoption_cast(option)) res = 0; break; -#endif // QT_NO_RUBBERBAND +#endif // QT_CONFIG(rubberband) case SH_ItemView_DrawDelegateFrame: res = 1; diff --git a/src/widgets/widgets/qmainwindowlayout.cpp b/src/widgets/widgets/qmainwindowlayout.cpp index d31fa3ddfab..1393294f0a9 100644 --- a/src/widgets/widgets/qmainwindowlayout.cpp +++ b/src/widgets/widgets/qmainwindowlayout.cpp @@ -49,7 +49,9 @@ #include "qtoolbar.h" #include "qtoolbarlayout_p.h" #include "qwidgetanimator_p.h" +#if QT_CONFIG(rubberband) #include "qrubberband.h" +#endif #include "qtabbar_p.h" #include @@ -2449,7 +2451,7 @@ QLayoutItem *QMainWindowLayout::unplug(QWidget *widget, bool group) void QMainWindowLayout::updateGapIndicator() { -#ifndef QT_NO_RUBBERBAND +#if QT_CONFIG(rubberband) if ((!widgetAnimator.animating() && !currentGapPos.isEmpty()) #if QT_CONFIG(dockwidget) || currentHoveredFloat @@ -2477,7 +2479,7 @@ void QMainWindowLayout::updateGapIndicator() } else if (gapIndicator) { gapIndicator->hide(); } -#endif //QT_NO_RUBBERBAND +#endif // QT_CONFIG(rubberband) } void QMainWindowLayout::hover(QLayoutItem *widgetItem, const QPoint &mousePos) diff --git a/src/widgets/widgets/qmainwindowlayout_p.h b/src/widgets/widgets/qmainwindowlayout_p.h index ed8da61bc34..5544730c30f 100644 --- a/src/widgets/widgets/qmainwindowlayout_p.h +++ b/src/widgets/widgets/qmainwindowlayout_p.h @@ -301,7 +301,7 @@ public: QList currentGapPos; QRect currentGapRect; QWidget *pluggingWidget; -#ifndef QT_NO_RUBBERBAND +#if QT_CONFIG(rubberband) QPointer gapIndicator; #endif #ifndef QT_NO_DOCKWIDGET diff --git a/src/widgets/widgets/qmdiarea.cpp b/src/widgets/widgets/qmdiarea.cpp index 18cb8237029..e25b454409b 100644 --- a/src/widgets/widgets/qmdiarea.cpp +++ b/src/widgets/widgets/qmdiarea.cpp @@ -672,7 +672,7 @@ QMdiAreaPrivate::QMdiAreaPrivate() regularTiler(0), iconTiler(0), placer(0), -#ifndef QT_NO_RUBBERBAND +#if QT_CONFIG(rubberband) rubberBand(0), #endif #ifndef QT_NO_TABBAR @@ -1036,7 +1036,7 @@ void QMdiAreaPrivate::activateHighlightedWindow() activateWindow(nextVisibleSubWindow(-1, QMdiArea::ActivationHistoryOrder)); else activateWindow(childWindows.at(indexToHighlighted)); -#ifndef QT_NO_RUBBERBAND +#if QT_CONFIG(rubberband) hideRubberBand(); #endif } @@ -1140,7 +1140,7 @@ void QMdiAreaPrivate::updateActiveWindow(int removedIndex, bool activeRemoved) } if (indexToHighlighted >= 0) { -#ifndef QT_NO_RUBBERBAND +#if QT_CONFIG(rubberband) // Hide rubber band if highlighted window is removed. if (indexToHighlighted == removedIndex) hideRubberBand(); @@ -1514,7 +1514,7 @@ void QMdiAreaPrivate::highlightNextSubWindow(int increaseFactor) if (!highlight) return; -#ifndef QT_NO_RUBBERBAND +#if QT_CONFIG(rubberband) if (!rubberBand) { rubberBand = new QRubberBand(QRubberBand::Rectangle, q); // For accessibility to identify this special widget. @@ -1524,7 +1524,7 @@ void QMdiAreaPrivate::highlightNextSubWindow(int increaseFactor) #endif // Only highlight if we're not switching back to the previously active window (Ctrl-Tab once). -#ifndef QT_NO_RUBBERBAND +#if QT_CONFIG(rubberband) if (tabToPreviousTimerId == -1) showRubberBandFor(highlight); #endif @@ -2351,7 +2351,7 @@ void QMdiArea::timerEvent(QTimerEvent *timerEvent) d->tabToPreviousTimerId = -1; if (d->indexToHighlighted < 0) return; -#ifndef QT_NO_RUBBERBAND +#if QT_CONFIG(rubberband) // We're not doing a "quick switch" ... show rubber band. Q_ASSERT(d->indexToHighlighted < d->childWindows.size()); Q_ASSERT(d->rubberBand); @@ -2594,7 +2594,7 @@ bool QMdiArea::eventFilter(QObject *object, QEvent *event) if (keyPress) area->d_func()->highlightNextSubWindow(keyEvent->key() == Qt::Key_Tab ? 1 : -1); return true; -#ifndef QT_NO_RUBBERBAND +#if QT_CONFIG(rubberband) case Qt::Key_Escape: area->d_func()->hideRubberBand(); break; @@ -2643,7 +2643,7 @@ bool QMdiArea::eventFilter(QObject *object, QEvent *event) case QEvent::Hide: d->isSubWindowsTiled = false; break; -#ifndef QT_NO_RUBBERBAND +#if QT_CONFIG(rubberband) case QEvent::Close: if (d->childWindows.indexOf(subWindow) == d->indexToHighlighted) d->hideRubberBand(); diff --git a/src/widgets/widgets/qmdiarea_p.h b/src/widgets/widgets/qmdiarea_p.h index 353144a6ab6..b77f3f63ea1 100644 --- a/src/widgets/widgets/qmdiarea_p.h +++ b/src/widgets/widgets/qmdiarea_p.h @@ -144,7 +144,7 @@ public: QMdi::Rearranger *regularTiler; QMdi::Rearranger *iconTiler; QMdi::Placer *placer; -#ifndef QT_NO_RUBBERBAND +#if QT_CONFIG(rubberband) QRubberBand *rubberBand; #endif QMdiAreaTabBar *tabBar; @@ -254,7 +254,7 @@ public: subWindow->d_func()->setActive(active, changeFocus); } -#ifndef QT_NO_RUBBERBAND +#if QT_CONFIG(rubberband) void showRubberBandFor(QMdiSubWindow *subWindow); inline void hideRubberBand() @@ -263,7 +263,7 @@ public: rubberBand->hide(); indexToHighlighted = -1; } -#endif // QT_NO_RUBBERBAND +#endif // QT_CONFIG(rubberband) }; #endif // QT_NO_MDIAREA diff --git a/src/widgets/widgets/qmdisubwindow.cpp b/src/widgets/widgets/qmdisubwindow.cpp index b4f2c97e049..663572802cd 100644 --- a/src/widgets/widgets/qmdisubwindow.cpp +++ b/src/widgets/widgets/qmdisubwindow.cpp @@ -864,14 +864,14 @@ QMdiSubWindowPrivate::QMdiSubWindowPrivate() #ifndef QT_NO_SIZEGRIP sizeGrip(0), #endif -#ifndef QT_NO_RUBBERBAND +#if QT_CONFIG(rubberband) rubberBand(0), #endif userMinimumSize(0,0), resizeEnabled(true), moveEnabled(true), isInInteractiveMode(false), -#ifndef QT_NO_RUBBERBAND +#if QT_CONFIG(rubberband) isInRubberBandMode(false), #endif isShadeMode(false), @@ -945,13 +945,13 @@ void QMdiSubWindowPrivate::_q_enterInteractiveMode() oldGeometry = q->geometry(); isInInteractiveMode = true; q->setFocus(); -#ifndef QT_NO_RUBBERBAND +#if QT_CONFIG(rubberband) if ((q->testOption(QMdiSubWindow::RubberBandResize) && (currentOperation == BottomRightResize || currentOperation == BottomLeftResize)) || (q->testOption(QMdiSubWindow::RubberBandMove) && currentOperation == Move)) { enterRubberBandMode(); } else -#endif // QT_NO_RUBBERBAND +#endif // QT_CONFIG(rubberband) { q->grabMouse(); } @@ -978,7 +978,7 @@ void QMdiSubWindowPrivate::_q_processFocusChanged(QWidget *old, QWidget *now) void QMdiSubWindowPrivate::leaveInteractiveMode() { Q_Q(QMdiSubWindow); -#ifndef QT_NO_RUBBERBAND +#if QT_CONFIG(rubberband) if (isInRubberBandMode) leaveRubberBandMode(); else @@ -1893,7 +1893,7 @@ void QMdiSubWindowPrivate::updateWindowTitle(bool isRequestFromChild) ignoreWindowTitleChange = false; } -#ifndef QT_NO_RUBBERBAND +#if QT_CONFIG(rubberband) void QMdiSubWindowPrivate::enterRubberBandMode() { Q_Q(QMdiSubWindow); @@ -1925,7 +1925,7 @@ void QMdiSubWindowPrivate::leaveRubberBandMode() rubberBand->hide(); currentOperation = None; } -#endif // QT_NO_RUBBERBAND +#endif // QT_CONFIG(rubberband) // Taken from the old QWorkspace (::readColors()) QPalette QMdiSubWindowPrivate::desktopPalette() const @@ -2424,7 +2424,7 @@ void QMdiSubWindow::setOption(SubWindowOption option, bool on) Q_D(QMdiSubWindow); d->options.setFlag(option, on); -#ifndef QT_NO_RUBBERBAND +#if QT_CONFIG(rubberband) if ((option & (RubberBandResize | RubberBandMove)) && !on && d->isInRubberBandMode) d->leaveRubberBandMode(); #endif @@ -2723,7 +2723,7 @@ bool QMdiSubWindow::eventFilter(QObject *object, QEvent *event) d->oldGeometry = geometry(); d->currentOperation = isLeftToRight() ? QMdiSubWindowPrivate::BottomRightResize : QMdiSubWindowPrivate::BottomLeftResize; -#ifndef QT_NO_RUBBERBAND +#if QT_CONFIG(rubberband) d->enterRubberBandMode(); #endif return true; @@ -2837,7 +2837,7 @@ bool QMdiSubWindow::event(QEvent *event) d->currentOperation = QMdiSubWindowPrivate::None; d->activeSubControl = QStyle::SC_None; d->hoveredSubControl = QStyle::SC_None; -#ifndef QT_NO_RUBBERBAND +#if QT_CONFIG(rubberband) if (d->isInRubberBandMode) d->leaveRubberBandMode(); #endif @@ -3196,7 +3196,7 @@ void QMdiSubWindow::mousePressEvent(QMouseEvent *mouseEvent) Q_D(QMdiSubWindow); if (d->isInInteractiveMode) d->leaveInteractiveMode(); -#ifndef QT_NO_RUBBERBAND +#if QT_CONFIG(rubberband) if (d->isInRubberBandMode) d->leaveRubberBandMode(); #endif @@ -3211,7 +3211,7 @@ void QMdiSubWindow::mousePressEvent(QMouseEvent *mouseEvent) d->mousePressPosition = mapToParent(mouseEvent->pos()); if (d->resizeEnabled || d->moveEnabled) d->oldGeometry = geometry(); -#ifndef QT_NO_RUBBERBAND +#if QT_CONFIG(rubberband) if ((testOption(QMdiSubWindow::RubberBandResize) && d->isResizeOperation()) || (testOption(QMdiSubWindow::RubberBandMove) && d->isMoveOperation())) { d->enterRubberBandMode(); @@ -3291,7 +3291,7 @@ void QMdiSubWindow::mouseReleaseEvent(QMouseEvent *mouseEvent) Q_D(QMdiSubWindow); if (d->currentOperation != QMdiSubWindowPrivate::None) { -#ifndef QT_NO_RUBBERBAND +#if QT_CONFIG(rubberband) if (d->isInRubberBandMode && !d->isInInteractiveMode) d->leaveRubberBandMode(); #endif @@ -3406,13 +3406,13 @@ void QMdiSubWindow::keyPressEvent(QKeyEvent *keyEvent) #ifndef QT_NO_CURSOR QPoint newPosition = parentWidget()->mapFromGlobal(cursor().pos() + delta); QRect oldGeometry = -#ifndef QT_NO_RUBBERBAND +#if QT_CONFIG(rubberband) d->isInRubberBandMode ? d->rubberBand->geometry() : #endif geometry(); d->setNewGeometry(newPosition); QRect currentGeometry = -#ifndef QT_NO_RUBBERBAND +#if QT_CONFIG(rubberband) d->isInRubberBandMode ? d->rubberBand->geometry() : #endif geometry(); diff --git a/src/widgets/widgets/qmdisubwindow_p.h b/src/widgets/widgets/qmdisubwindow_p.h index 33fa73eb0d2..71fcc38378c 100644 --- a/src/widgets/widgets/qmdisubwindow_p.h +++ b/src/widgets/widgets/qmdisubwindow_p.h @@ -179,7 +179,7 @@ public: #ifndef QT_NO_SIZEGRIP QPointer sizeGrip; #endif -#ifndef QT_NO_RUBBERBAND +#if QT_CONFIG(rubberband) QRubberBand *rubberBand; #endif QPoint mousePressPosition; @@ -190,7 +190,7 @@ public: bool resizeEnabled; bool moveEnabled; bool isInInteractiveMode; -#ifndef QT_NO_RUBBERBAND +#if QT_CONFIG(rubberband) bool isInRubberBandMode; #endif bool isShadeMode; @@ -258,7 +258,7 @@ public: void removeButtonsFromMenuBar(); #endif void updateWindowTitle(bool requestFromChild); -#ifndef QT_NO_RUBBERBAND +#if QT_CONFIG(rubberband) void enterRubberBandMode(); void leaveRubberBandMode(); #endif @@ -310,7 +310,7 @@ public: Q_Q(QMdiSubWindow); Q_ASSERT(parent); geometry->setSize(geometry->size().expandedTo(internalMinimumSize)); -#ifndef QT_NO_RUBBERBAND +#if QT_CONFIG(rubberband) if (isInRubberBandMode) rubberBand->setGeometry(*geometry); else diff --git a/src/widgets/widgets/qrubberband.cpp b/src/widgets/widgets/qrubberband.cpp index c91f8370938..ade8675db8c 100644 --- a/src/widgets/widgets/qrubberband.cpp +++ b/src/widgets/widgets/qrubberband.cpp @@ -43,8 +43,6 @@ #include "qrubberband.h" #include "qtimer.h" -#ifndef QT_NO_RUBBERBAND - #include "qstyle.h" #include "qstyleoption.h" #if 0 // Used to be included in Qt4 for Q_WS_MAC @@ -334,5 +332,3 @@ bool QRubberBand::event(QEvent *e) QT_END_NAMESPACE #include "moc_qrubberband.cpp" - -#endif // QT_NO_RUBBERBAND diff --git a/src/widgets/widgets/qrubberband.h b/src/widgets/widgets/qrubberband.h index 217261bf75a..a05eb0d5436 100644 --- a/src/widgets/widgets/qrubberband.h +++ b/src/widgets/widgets/qrubberband.h @@ -43,11 +43,10 @@ #include #include +QT_REQUIRE_CONFIG(rubberband); + QT_BEGIN_NAMESPACE - -#ifndef QT_NO_RUBBERBAND - class QRubberBandPrivate; class QStyleOptionRubberBand; @@ -91,8 +90,6 @@ inline void QRubberBand::setGeometry(int ax, int ay, int aw, int ah) inline void QRubberBand::move(int ax, int ay) { setGeometry(ax, ay, width(), height()); } -#endif // QT_NO_RUBBERBAND - QT_END_NAMESPACE #endif // QRUBBERBAND_H diff --git a/src/widgets/widgets/qsplitter.cpp b/src/widgets/widgets/qsplitter.cpp index 0c98c3875a1..7d507aa7f42 100644 --- a/src/widgets/widgets/qsplitter.cpp +++ b/src/widgets/widgets/qsplitter.cpp @@ -47,7 +47,9 @@ #include "qlayout.h" #include "qlist.h" #include "qpainter.h" +#if QT_CONFIG(rubberband) #include "qrubberband.h" +#endif #include "qstyle.h" #include "qstyleoption.h" #include "qtextstream.h" diff --git a/src/widgets/widgets/qsplitter_p.h b/src/widgets/widgets/qsplitter_p.h index 0730fab824a..34ae34121ee 100644 --- a/src/widgets/widgets/qsplitter_p.h +++ b/src/widgets/widgets/qsplitter_p.h @@ -53,7 +53,6 @@ #include #include "private/qframe_p.h" -#include "qrubberband.h" QT_BEGIN_NAMESPACE diff --git a/src/widgets/widgets/qtoolbar.cpp b/src/widgets/widgets/qtoolbar.cpp index 48fa88b7a02..bdb17f10d39 100644 --- a/src/widgets/widgets/qtoolbar.cpp +++ b/src/widgets/widgets/qtoolbar.cpp @@ -48,7 +48,9 @@ #include #include #include +#if QT_CONFIG(rubberband) #include +#endif #include #include #include diff --git a/src/widgets/widgets/widgets.pri b/src/widgets/widgets/widgets.pri index 726235ef4e5..b142be80413 100644 --- a/src/widgets/widgets/widgets.pri +++ b/src/widgets/widgets/widgets.pri @@ -32,7 +32,6 @@ HEADERS += \ widgets/qmenubar.h \ widgets/qmenubar_p.h \ widgets/qprogressbar.h \ - widgets/qrubberband.h \ widgets/qscrollbar.h \ widgets/qscrollbar_p.h \ widgets/qscrollarea_p.h \ @@ -89,7 +88,6 @@ SOURCES += \ widgets/qmenu.cpp \ widgets/qmenubar.cpp \ widgets/qprogressbar.cpp \ - widgets/qrubberband.cpp \ widgets/qscrollbar.cpp \ widgets/qsizegrip.cpp \ widgets/qslider.cpp \ @@ -197,6 +195,11 @@ qtConfig(dialogbuttonbox) { widgets/qdialogbuttonbox.cpp } +qtConfig(rubberband) { + HEADERS += widgets/qrubberband.h + SOURCES += widgets/qrubberband.cpp +} + qtConfig(splashscreen) { HEADERS += \ widgets/qsplashscreen.h From 6cd46c9a61c3493b975416ec4309af75db5dafaf Mon Sep 17 00:00:00 2001 From: Stephan Binner Date: Sun, 9 Jul 2017 11:37:40 +0200 Subject: [PATCH 51/63] Convert features.datetimeedit to QT_[REQUIRE_]CONFIG Change-Id: I083cd565fab8c33dc3633b71f962de099c2b3481 Reviewed-by: Oswald Buddenhagen --- src/widgets/itemviews/qitemeditorfactory.cpp | 6 ++++-- src/widgets/styles/qmacstyle_mac.mm | 4 +++- src/widgets/styles/qmacstyle_mac_p_p.h | 2 ++ src/widgets/widgets/qabstractspinbox.cpp | 2 ++ src/widgets/widgets/qdatetimeedit.cpp | 4 ---- src/widgets/widgets/qdatetimeedit.h | 7 ++----- src/widgets/widgets/qdatetimeedit_p.h | 4 ---- src/widgets/widgets/widgets.pri | 12 +++++++++--- 8 files changed, 22 insertions(+), 19 deletions(-) diff --git a/src/widgets/itemviews/qitemeditorfactory.cpp b/src/widgets/itemviews/qitemeditorfactory.cpp index c535cf5f9e6..a31689e0b56 100644 --- a/src/widgets/itemviews/qitemeditorfactory.cpp +++ b/src/widgets/itemviews/qitemeditorfactory.cpp @@ -44,7 +44,9 @@ #ifndef QT_NO_ITEMVIEWS #include +#if QT_CONFIG(datetimeedit) #include +#endif #if QT_CONFIG(label) #include #endif @@ -252,7 +254,7 @@ QWidget *QDefaultItemEditorFactory::createEditor(int userType, QWidget *parent) sb->setMaximum(INT_MAX); return sb; } #endif -#ifndef QT_NO_DATETIMEEDIT +#if QT_CONFIG(datetimeedit) case QVariant::Date: { QDateTimeEdit *ed = new QDateEdit(parent); ed->setFrame(false); @@ -308,7 +310,7 @@ QByteArray QDefaultItemEditorFactory::valuePropertyName(int userType) const case QVariant::Double: return "value"; #endif -#ifndef QT_NO_DATETIMEEDIT +#if QT_CONFIG(datetimeedit) case QVariant::Date: return "date"; case QVariant::Time: diff --git a/src/widgets/styles/qmacstyle_mac.mm b/src/widgets/styles/qmacstyle_mac.mm index 423ab6be5e2..134df0cd722 100644 --- a/src/widgets/styles/qmacstyle_mac.mm +++ b/src/widgets/styles/qmacstyle_mac.mm @@ -96,7 +96,9 @@ #endif #include #include +#if QT_CONFIG(datetimeedit) #include +#endif #include #include #include @@ -1391,7 +1393,7 @@ void QMacStylePrivate::initComboboxBdi(const QStyleOptionComboBox *combo, HIThem // an extra check here before using the mini and small buttons. int h = combo->rect.size().height(); if (combo->editable){ -#ifndef QT_NO_DATETIMEEDIT +#if QT_CONFIG(datetimeedit) if (qobject_cast(widget)) { // Except when, you know, we get a QDateTimeEdit with calendarPopup // enabled. And then things get weird, basically because it's a diff --git a/src/widgets/styles/qmacstyle_mac_p_p.h b/src/widgets/styles/qmacstyle_mac_p_p.h index f6bb2fdddd8..4963e3692ca 100644 --- a/src/widgets/styles/qmacstyle_mac_p_p.h +++ b/src/widgets/styles/qmacstyle_mac_p_p.h @@ -96,7 +96,9 @@ #include #include #include +#if QT_CONFIG(datetimeedit) #include +#endif #include #include #include diff --git a/src/widgets/widgets/qabstractspinbox.cpp b/src/widgets/widgets/qabstractspinbox.cpp index 4a3abe0c321..22f3745b267 100644 --- a/src/widgets/widgets/qabstractspinbox.cpp +++ b/src/widgets/widgets/qabstractspinbox.cpp @@ -49,7 +49,9 @@ #include #include #include +#if QT_CONFIG(datetimeedit) #include +#endif #include #include #include diff --git a/src/widgets/widgets/qdatetimeedit.cpp b/src/widgets/widgets/qdatetimeedit.cpp index e136363b170..053b1842268 100644 --- a/src/widgets/widgets/qdatetimeedit.cpp +++ b/src/widgets/widgets/qdatetimeedit.cpp @@ -54,8 +54,6 @@ #include -#ifndef QT_NO_DATETIMEEDIT - //#define QDATETIMEEDIT_QDTEDEBUG #ifdef QDATETIMEEDIT_QDTEDEBUG # define QDTEDEBUG qDebug() << QString::fromLatin1("%1:%2").arg(__FILE__).arg(__LINE__) @@ -2674,5 +2672,3 @@ void QCalendarPopup::hideEvent(QHideEvent *) QT_END_NAMESPACE #include "moc_qdatetimeedit.cpp" #include "moc_qdatetimeedit_p.cpp" - -#endif // QT_NO_DATETIMEEDIT diff --git a/src/widgets/widgets/qdatetimeedit.h b/src/widgets/widgets/qdatetimeedit.h index 30e4a58bb30..b46434c1a40 100644 --- a/src/widgets/widgets/qdatetimeedit.h +++ b/src/widgets/widgets/qdatetimeedit.h @@ -45,11 +45,10 @@ #include #include +QT_REQUIRE_CONFIG(datetimeedit); + QT_BEGIN_NAMESPACE - -#ifndef QT_NO_DATETIMEEDIT - class QDateTimeEditPrivate; class QStyleOptionSpinBox; class QCalendarWidget; @@ -228,8 +227,6 @@ Q_SIGNALS: Q_DECLARE_OPERATORS_FOR_FLAGS(QDateTimeEdit::Sections) -#endif // QT_NO_DATETIMEEDIT - QT_END_NAMESPACE #endif // QDATETIMEEDIT_H diff --git a/src/widgets/widgets/qdatetimeedit_p.h b/src/widgets/widgets/qdatetimeedit_p.h index 5302d6d9a74..bc70780de92 100644 --- a/src/widgets/widgets/qdatetimeedit_p.h +++ b/src/widgets/widgets/qdatetimeedit_p.h @@ -63,8 +63,6 @@ #include "qdebug.h" -#ifndef QT_NO_DATETIMEEDIT - QT_BEGIN_NAMESPACE class QCalendarPopup; @@ -181,6 +179,4 @@ private: QT_END_NAMESPACE -#endif // QT_NO_DATETIMEEDIT - #endif // QDATETIMEEDIT_P_H diff --git a/src/widgets/widgets/widgets.pri b/src/widgets/widgets/widgets.pri index b142be80413..610932c6ce5 100644 --- a/src/widgets/widgets/widgets.pri +++ b/src/widgets/widgets/widgets.pri @@ -8,8 +8,6 @@ HEADERS += \ widgets/qcalendarwidget.h \ widgets/qcombobox.h \ widgets/qcombobox_p.h \ - widgets/qdatetimeedit.h \ - widgets/qdatetimeedit_p.h \ widgets/qdial.h \ widgets/qdockwidget.h \ widgets/qdockwidget_p.h \ @@ -71,7 +69,6 @@ SOURCES += \ widgets/qabstractspinbox.cpp \ widgets/qcalendarwidget.cpp \ widgets/qcombobox.cpp \ - widgets/qdatetimeedit.cpp \ widgets/qdial.cpp \ widgets/qdockwidget.cpp \ widgets/qdockarealayout.cpp \ @@ -148,6 +145,15 @@ qtConfig(commandlinkbutton) { widgets/qcommandlinkbutton.cpp } +qtConfig(datetimeedit) { + HEADERS += \ + widgets/qdatetimeedit.h \ + widgets/qdatetimeedit_p.h + + SOURCES += \ + widgets/qdatetimeedit.cpp +} + qtConfig(fontcombobox) { HEADERS += widgets/qfontcombobox.h SOURCES += widgets/qfontcombobox.cpp From 01703d026420cd0964bec872f7af54fd077b82ad Mon Sep 17 00:00:00 2001 From: Stephan Binner Date: Sun, 9 Jul 2017 16:53:58 +0200 Subject: [PATCH 52/63] Convert features.tableview to QT_[REQUIRE_]CONFIG Change-Id: I7ab479deff7bbf3083d1efa196e0480b181548c5 Reviewed-by: Oswald Buddenhagen --- src/widgets/accessible/complexwidgets.cpp | 1 - src/widgets/accessible/itemviews.cpp | 16 +++++++++------- src/widgets/itemviews/itemviews.pri | 11 ++++++++--- src/widgets/itemviews/qabstractitemview.cpp | 1 - src/widgets/itemviews/qstyleditemdelegate.cpp | 4 +++- src/widgets/itemviews/qtableview.cpp | 3 --- src/widgets/itemviews/qtableview.h | 7 ++----- src/widgets/itemviews/qtableview_p.h | 4 +--- src/widgets/styles/qmacstyle_mac.mm | 4 +++- src/widgets/styles/qmacstyle_mac_p_p.h | 2 ++ src/widgets/styles/qwindowsvistastyle_p_p.h | 2 ++ src/widgets/widgets/qcombobox.cpp | 6 ++++-- 12 files changed, 34 insertions(+), 27 deletions(-) diff --git a/src/widgets/accessible/complexwidgets.cpp b/src/widgets/accessible/complexwidgets.cpp index 4770c513cf7..dd9bea1aec0 100644 --- a/src/widgets/accessible/complexwidgets.cpp +++ b/src/widgets/accessible/complexwidgets.cpp @@ -46,7 +46,6 @@ #include #include #include -#include #include #include #include diff --git a/src/widgets/accessible/itemviews.cpp b/src/widgets/accessible/itemviews.cpp index 3cef5647818..87c0a595634 100644 --- a/src/widgets/accessible/itemviews.cpp +++ b/src/widgets/accessible/itemviews.cpp @@ -40,7 +40,9 @@ #include "itemviews_p.h" #include +#if QT_CONFIG(tableview) #include +#endif #include #include #include @@ -81,7 +83,7 @@ QAccessibleTable::QAccessibleTable(QWidget *w) { Q_ASSERT(view()); -#ifndef QT_NO_TABLEVIEW +#if QT_CONFIG(tableview) if (qobject_cast(view())) { m_role = QAccessible::Table; } else @@ -117,7 +119,7 @@ QHeaderView *QAccessibleTable::horizontalHeader() const { QHeaderView *header = 0; if (false) { -#ifndef QT_NO_TABLEVIEW +#if QT_CONFIG(tableview) } else if (const QTableView *tv = qobject_cast(view())) { header = tv->horizontalHeader(); #endif @@ -133,7 +135,7 @@ QHeaderView *QAccessibleTable::verticalHeader() const { QHeaderView *header = 0; if (false) { -#ifndef QT_NO_TABLEVIEW +#if QT_CONFIG(tableview) } else if (const QTableView *tv = qobject_cast(view())) { header = tv->verticalHeader(); #endif @@ -866,7 +868,7 @@ QHeaderView *QAccessibleTableCell::horizontalHeader() const QHeaderView *header = 0; if (false) { -#ifndef QT_NO_TABLEVIEW +#if QT_CONFIG(tableview) } else if (const QTableView *tv = qobject_cast(view)) { header = tv->horizontalHeader(); #endif @@ -882,7 +884,7 @@ QHeaderView *QAccessibleTableCell::horizontalHeader() const QHeaderView *QAccessibleTableCell::verticalHeader() const { QHeaderView *header = 0; -#ifndef QT_NO_TABLEVIEW +#if QT_CONFIG(tableview) if (const QTableView *tv = qobject_cast(view)) header = tv->verticalHeader(); #endif @@ -1125,7 +1127,7 @@ QRect QAccessibleTableHeaderCell::rect() const { QHeaderView *header = 0; if (false) { -#ifndef QT_NO_TABLEVIEW +#if QT_CONFIG(tableview) } else if (const QTableView *tv = qobject_cast(view)) { if (orientation == Qt::Horizontal) { header = tv->horizontalHeader(); @@ -1192,7 +1194,7 @@ QHeaderView *QAccessibleTableHeaderCell::headerView() const { QHeaderView *header = 0; if (false) { -#ifndef QT_NO_TABLEVIEW +#if QT_CONFIG(tableview) } else if (const QTableView *tv = qobject_cast(view)) { if (orientation == Qt::Horizontal) { header = tv->horizontalHeader(); diff --git a/src/widgets/itemviews/itemviews.pri b/src/widgets/itemviews/itemviews.pri index af0a6f68981..4101be56310 100644 --- a/src/widgets/itemviews/itemviews.pri +++ b/src/widgets/itemviews/itemviews.pri @@ -9,8 +9,6 @@ HEADERS += \ itemviews/qlistview.h \ itemviews/qlistview_p.h \ itemviews/qbsptree_p.h \ - itemviews/qtableview.h \ - itemviews/qtableview_p.h \ itemviews/qtreeview.h \ itemviews/qtreeview_p.h \ itemviews/qabstractitemdelegate.h \ @@ -28,7 +26,6 @@ SOURCES += \ itemviews/qheaderview.cpp \ itemviews/qlistview.cpp \ itemviews/qbsptree.cpp \ - itemviews/qtableview.cpp \ itemviews/qtreeview.cpp \ itemviews/qabstractitemdelegate.cpp \ itemviews/qitemdelegate.cpp \ @@ -57,6 +54,14 @@ qtConfig(listwidget) { SOURCES += itemviews/qlistwidget.cpp } +qtConfig(tableview) { + HEADERS += \ + itemviews/qtableview.h \ + itemviews/qtableview_p.h + + SOURCES += itemviews/qtableview.cpp +} + qtConfig(tablewidget) { HEADERS += \ itemviews/qtablewidget.h \ diff --git a/src/widgets/itemviews/qabstractitemview.cpp b/src/widgets/itemviews/qabstractitemview.cpp index c8fdf06d64f..f96bafdb57d 100644 --- a/src/widgets/itemviews/qabstractitemview.cpp +++ b/src/widgets/itemviews/qabstractitemview.cpp @@ -53,7 +53,6 @@ #include #include #include -#include #include #include #include diff --git a/src/widgets/itemviews/qstyleditemdelegate.cpp b/src/widgets/itemviews/qstyleditemdelegate.cpp index 4149d3ac3ab..0b8019c21cc 100644 --- a/src/widgets/itemviews/qstyleditemdelegate.cpp +++ b/src/widgets/itemviews/qstyleditemdelegate.cpp @@ -67,7 +67,9 @@ #include #include #include +#if QT_CONFIG(tableview) #include +#endif #include @@ -500,7 +502,7 @@ void QStyledItemDelegate::updateEditorGeometry(QWidget *editor, // let the editor take up all available space //if the editor is not a QLineEdit //or it is in a QTableView -#if !defined(QT_NO_TABLEVIEW) && !defined(QT_NO_LINEEDIT) +#if QT_CONFIG(tableview) && !defined(QT_NO_LINEEDIT) if (qobject_cast(editor) && !qobject_cast(widget)) opt.showDecorationSelected = editor->style()->styleHint(QStyle::SH_ItemView_ShowDecorationSelected, 0, editor); else diff --git a/src/widgets/itemviews/qtableview.cpp b/src/widgets/itemviews/qtableview.cpp index b79932327bc..2d5813198c2 100644 --- a/src/widgets/itemviews/qtableview.cpp +++ b/src/widgets/itemviews/qtableview.cpp @@ -39,7 +39,6 @@ #include "qtableview.h" -#ifndef QT_NO_TABLEVIEW #include #include #include @@ -3352,5 +3351,3 @@ QT_END_NAMESPACE #include "qtableview.moc" #include "moc_qtableview.cpp" - -#endif // QT_NO_TABLEVIEW diff --git a/src/widgets/itemviews/qtableview.h b/src/widgets/itemviews/qtableview.h index b1c38d521f7..75f2e7b44c6 100644 --- a/src/widgets/itemviews/qtableview.h +++ b/src/widgets/itemviews/qtableview.h @@ -43,11 +43,10 @@ #include #include +QT_REQUIRE_CONFIG(tableview); + QT_BEGIN_NAMESPACE - -#ifndef QT_NO_TABLEVIEW - class QHeaderView; class QTableViewPrivate; @@ -191,8 +190,6 @@ private: Q_PRIVATE_SLOT(d_func(), void _q_updateSpanRemovedColumns(QModelIndex,int,int)) }; -#endif // QT_NO_TABLEVIEW - QT_END_NAMESPACE #endif // QTABLEVIEW_H diff --git a/src/widgets/itemviews/qtableview_p.h b/src/widgets/itemviews/qtableview_p.h index d2f45d557d5..1a0fef9017a 100644 --- a/src/widgets/itemviews/qtableview_p.h +++ b/src/widgets/itemviews/qtableview_p.h @@ -59,7 +59,7 @@ #include #include "private/qabstractitemview_p.h" -#ifndef QT_NO_TABLEVIEW +QT_REQUIRE_CONFIG(tableview); QT_BEGIN_NAMESPACE @@ -261,6 +261,4 @@ public: QT_END_NAMESPACE -#endif // QT_NO_TABLEVIEW - #endif // QTABLEVIEW_P_H diff --git a/src/widgets/styles/qmacstyle_mac.mm b/src/widgets/styles/qmacstyle_mac.mm index 134df0cd722..b0176e1a497 100644 --- a/src/widgets/styles/qmacstyle_mac.mm +++ b/src/widgets/styles/qmacstyle_mac.mm @@ -89,7 +89,9 @@ #include #include #include +#if QT_CONFIG(tableview) #include +#endif #include #if QT_CONFIG(wizard) #include @@ -3722,7 +3724,7 @@ void QMacStyle::drawControl(ControlElement ce, const QStyleOption *opt, QPainter HIRect bounds = qt_hirectForQRect(ir); bool noVerticalHeader = true; -#ifndef QT_NO_TABLEVIEW +#if QT_CONFIG(tableview) if (w) if (const QTableView *table = qobject_cast(w->parentWidget())) noVerticalHeader = !table->verticalHeader()->isVisible(); diff --git a/src/widgets/styles/qmacstyle_mac_p_p.h b/src/widgets/styles/qmacstyle_mac_p_p.h index 4963e3692ca..514cc8a14e2 100644 --- a/src/widgets/styles/qmacstyle_mac_p_p.h +++ b/src/widgets/styles/qmacstyle_mac_p_p.h @@ -94,7 +94,9 @@ #include #include #include +#if QT_CONFIG(tableview) #include +#endif #include #if QT_CONFIG(datetimeedit) #include diff --git a/src/widgets/styles/qwindowsvistastyle_p_p.h b/src/widgets/styles/qwindowsvistastyle_p_p.h index db358e6f6cd..01fe32c1c67 100644 --- a/src/widgets/styles/qwindowsvistastyle_p_p.h +++ b/src/widgets/styles/qwindowsvistastyle_p_p.h @@ -84,7 +84,9 @@ #include #endif #include +#if QT_CONFIG(tableview) #include +#endif #include #include diff --git a/src/widgets/widgets/qcombobox.cpp b/src/widgets/widgets/qcombobox.cpp index 5520e9d28fd..84d81fa0892 100644 --- a/src/widgets/widgets/qcombobox.cpp +++ b/src/widgets/widgets/qcombobox.cpp @@ -47,7 +47,9 @@ #include #include #include +#if QT_CONFIG(tableview) #include +#endif #include #include #include @@ -598,7 +600,7 @@ int QComboBoxPrivateContainer::topMargin() const { if (const QListView *lview = qobject_cast(view)) return lview->spacing(); -#ifndef QT_NO_TABLEVIEW +#if QT_CONFIG(tableview) if (const QTableView *tview = qobject_cast(view)) return tview->showGrid() ? 1 : 0; #endif @@ -613,7 +615,7 @@ int QComboBoxPrivateContainer::spacing() const QListView *lview = qobject_cast(view); if (lview) return 2 * lview->spacing(); // QListView::spacing is the padding around the item. -#ifndef QT_NO_TABLEVIEW +#if QT_CONFIG(tableview) QTableView *tview = qobject_cast(view); if (tview) return tview->showGrid() ? 1 : 0; From b1708efeeb31242a4a0d932f42caf3808b00bc28 Mon Sep 17 00:00:00 2001 From: Andy Shaw Date: Mon, 10 Jul 2017 07:57:17 +0200 Subject: [PATCH 53/63] Windows: Fallback to d3d9 when in a VM on VMWare Workstation 12 On VMWare Workstation 12 it will indicate OpenGL 2.1 support but it is not sufficient enough as it is lacking things needed to use QtWebEngine without crashing. Falling back to d3d9 works fine in this case as d3d11 also crashes. Change-Id: I404867045a74f37d3ecc7e04e669dd305570deeb Reviewed-by: Friedemann Kleint --- .../platforms/windows/openglblacklists/default.json | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/plugins/platforms/windows/openglblacklists/default.json b/src/plugins/platforms/windows/openglblacklists/default.json index 69f4a54d056..6515f028306 100644 --- a/src/plugins/platforms/windows/openglblacklists/default.json +++ b/src/plugins/platforms/windows/openglblacklists/default.json @@ -126,6 +126,18 @@ "features": [ "disable_desktopgl" ] + }, + { + "id": 11, + "description": "VMWare Workstation Player 12 has insufficient support for OpenGL", + "vendor_id": "0x15AD", + "device_id": [ "0x0405" ], + "os": { + "type": "win" + }, + "features": [ + "disable_desktopgl", "disable_d3d11" + ] } ] } From ba87cfd774f0ff32d59cb9a33d9d2da4adcc60b3 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Tue, 11 Jul 2017 15:10:32 +0200 Subject: [PATCH 54/63] iaccessible2.pri: Fix architecture detection Use QT_ARCH instead of legacy QMAKE_TARGET.arch, which is not defined for MinGW. Change-Id: I5a1298321f696cf1bc30613283174ecfa0139600 Reviewed-by: Joerg Bornemann --- src/3rdparty/iaccessible2/iaccessible2.pri | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/src/3rdparty/iaccessible2/iaccessible2.pri b/src/3rdparty/iaccessible2/iaccessible2.pri index 367980a0d2b..f60e67681df 100644 --- a/src/3rdparty/iaccessible2/iaccessible2.pri +++ b/src/3rdparty/iaccessible2/iaccessible2.pri @@ -1,10 +1,6 @@ ARCH_SUBDIR=x86 -contains(QMAKE_TARGET.arch, x86_64): { - ARCH_SUBDIR=amd64 -} else { - !contains(QMAKE_TARGET.arch, x86): message("ERROR: Could not detect architecture from QMAKE_TARGET.arch") -} +contains(QT_ARCH, x86_64): ARCH_SUBDIR = amd64 MIDL_GENERATED = $$PWD/generated/$${ARCH_SUBDIR} From 4970ef5574017e88bf656a5aaa8a35920c71e405 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Tue, 11 Jul 2017 12:46:28 +0200 Subject: [PATCH 55/63] Windows QPA: Fix build with draganddrop disabled Task-number: QTBUG-61885 Change-Id: Ibb4a7ac43785dcdb46afcd5c2081e43df7d9e9a5 Reviewed-by: Oliver Wolff --- src/plugins/platforms/windows/qwindowswindow.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/plugins/platforms/windows/qwindowswindow.cpp b/src/plugins/platforms/windows/qwindowswindow.cpp index ff362928b6f..3a5baf40f05 100644 --- a/src/plugins/platforms/windows/qwindowswindow.cpp +++ b/src/plugins/platforms/windows/qwindowswindow.cpp @@ -39,7 +39,9 @@ #include "qwindowswindow.h" #include "qwindowscontext.h" -#include "qwindowsdrag.h" +#if QT_CONFIG(draganddrop) +# include "qwindowsdrag.h" +#endif #include "qwindowsscreen.h" #include "qwindowsintegration.h" #include "qwindowsnativeinterface.h" From 69c5ddf29570172c1207b54d545a14446c8044a4 Mon Sep 17 00:00:00 2001 From: Allan Sandfeld Jensen Date: Tue, 11 Jul 2017 15:17:01 +0200 Subject: [PATCH 56/63] Fix buffer overflow in text blending Clip buffers being converted to those being worked on so we don't write outside the lines. Task-number: QTBUG-61863 Change-Id: Icc7c6c0946fa522b5afeca0663fc2b45151b1897 Reviewed-by: Eskil Abrahamsen Blomfeldt --- src/gui/painting/qdrawhelper.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/gui/painting/qdrawhelper.cpp b/src/gui/painting/qdrawhelper.cpp index 82aceb93c73..aca31cf3e80 100644 --- a/src/gui/painting/qdrawhelper.cpp +++ b/src/gui/painting/qdrawhelper.cpp @@ -5625,13 +5625,13 @@ static void qt_alphamapblit_generic(QRasterBuffer *rasterBuffer, int start = qMax(x, clip.x); int end = qMin(x + mapWidth, clip.x + clip.len); Q_ASSERT(clip.len <= buffer_size); - QRgba64 *dest = destFetch64((QRgba64*)buffer, rasterBuffer, start, clip.y, clip.len); + QRgba64 *dest = destFetch64((QRgba64*)buffer, rasterBuffer, start, clip.y, end - start); for (int xp=start; xp line.count) map += mapStride; } // for (yp -> bottom) @@ -5898,13 +5898,13 @@ static void qt_alphargbblit_generic(QRasterBuffer *rasterBuffer, int start = qMax(x, clip.x); int end = qMin(x + mapWidth, clip.x + clip.len); Q_ASSERT(clip.len <= buffer_size); - QRgba64 *dest = destFetch64((QRgba64*)buffer, rasterBuffer, start, clip.y, clip.len); + QRgba64 *dest = destFetch64((QRgba64*)buffer, rasterBuffer, start, clip.y, end - start); for (int xp=start; xp line.count) src += srcStride; } // for (yp -> bottom) From b783c03d19d892c5e92c859ff0265061106cfa77 Mon Sep 17 00:00:00 2001 From: Mitch Curtis Date: Mon, 10 Jul 2017 16:34:15 +0200 Subject: [PATCH 57/63] Doc: fix paintEvent() function casing Change-Id: I66ef1c25259499147100413753fdc80b01dc49f6 Reviewed-by: J-P Nurmi --- src/widgets/kernel/qwidget.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/widgets/kernel/qwidget.cpp b/src/widgets/kernel/qwidget.cpp index 6440ed01732..79b4d67fdc0 100644 --- a/src/widgets/kernel/qwidget.cpp +++ b/src/widgets/kernel/qwidget.cpp @@ -9664,7 +9664,7 @@ void QWidget::leaveEvent(QEvent *) \note Generally, you should refrain from calling update() or repaint() \b{inside} a paintEvent(). For example, calling update() or repaint() on - children inside a paintevent() results in undefined behavior; the child may + children inside a paintEvent() results in undefined behavior; the child may or may not get a paint event. \warning If you are using a custom paint engine without Qt's backingstore, From b3f7bea10525a0b05a61f151f684b63d66488193 Mon Sep 17 00:00:00 2001 From: Allan Sandfeld Jensen Date: Mon, 10 Jul 2017 14:25:48 +0200 Subject: [PATCH 58/63] Handle conversion and comparison between qvarianthash and qvariantmap QVariant claims to be able to QVariantHash and QVariantMap, but the actual conversion implementation is missing. Task-number: QTBUG-61471 Change-Id: I0cba74642aa77dc423effed289bc7619922a89eb Reviewed-by: Thiago Macieira --- src/corelib/kernel/qvariant.cpp | 12 ++++++++++++ tests/auto/corelib/kernel/qvariant/tst_qvariant.cpp | 8 ++++++++ 2 files changed, 20 insertions(+) diff --git a/src/corelib/kernel/qvariant.cpp b/src/corelib/kernel/qvariant.cpp index f114a84d22e..e6262124fb7 100644 --- a/src/corelib/kernel/qvariant.cpp +++ b/src/corelib/kernel/qvariant.cpp @@ -855,6 +855,12 @@ static bool convert(const QVariant::Private *d, int t, void *result, bool *ok) if (qstrcmp(QMetaType::typeName(d->type), "QMap") == 0) { *static_cast(result) = *static_cast *>(d->data.shared->ptr); + } else if (d->type == QVariant::Hash) { + QVariantMap *map = static_cast(result); + const QVariantHash *hash = v_cast(d); + const auto end = hash->end(); + for (auto it = hash->begin(); it != end; ++it) + map->insertMulti(it.key(), it.value()); #ifndef QT_BOOTSTRAPPED } else if (d->type == QMetaType::QJsonValue) { if (!v_cast(d)->isObject()) @@ -871,6 +877,12 @@ static bool convert(const QVariant::Private *d, int t, void *result, bool *ok) if (qstrcmp(QMetaType::typeName(d->type), "QHash") == 0) { *static_cast(result) = *static_cast *>(d->data.shared->ptr); + } else if (d->type == QVariant::Map) { + QVariantHash *hash = static_cast(result); + const QVariantMap *map = v_cast(d); + const auto end = map->end(); + for (auto it = map->begin(); it != end; ++it) + hash->insertMulti(it.key(), it.value()); #ifndef QT_BOOTSTRAPPED } else if (d->type == QMetaType::QJsonValue) { if (!v_cast(d)->isObject()) diff --git a/tests/auto/corelib/kernel/qvariant/tst_qvariant.cpp b/tests/auto/corelib/kernel/qvariant/tst_qvariant.cpp index d16948fd5d8..e43b7acfb81 100644 --- a/tests/auto/corelib/kernel/qvariant/tst_qvariant.cpp +++ b/tests/auto/corelib/kernel/qvariant/tst_qvariant.cpp @@ -2558,6 +2558,8 @@ void tst_QVariant::variantMap() QVariant v3 = QVariant(QMetaType::type("QMap"), &map); QCOMPARE(qvariant_cast(v3).value("test").toInt(), 42); + QCOMPARE(v, QVariant(v.toHash())); + // multi-keys map.insertMulti("test", 47); v = map; @@ -2565,6 +2567,8 @@ void tst_QVariant::variantMap() QCOMPARE(map2, map); map2 = v.toMap(); QCOMPARE(map2, map); + + QCOMPARE(v, QVariant(v.toHash())); } void tst_QVariant::variantHash() @@ -2587,6 +2591,8 @@ void tst_QVariant::variantHash() QVariant v3 = QVariant(QMetaType::type("QHash"), &hash); QCOMPARE(qvariant_cast(v3).value("test").toInt(), 42); + QCOMPARE(v, QVariant(v.toMap())); + // multi-keys hash.insertMulti("test", 47); v = hash; @@ -2594,6 +2600,8 @@ void tst_QVariant::variantHash() QCOMPARE(hash2, hash); hash2 = v.toHash(); QCOMPARE(hash2, hash); + + QCOMPARE(v, QVariant(v.toMap())); } class CustomQObject : public QObject { From 9ec73b85aa3e99d6d09412da74e243343f258418 Mon Sep 17 00:00:00 2001 From: Gabriel de Dietrich Date: Wed, 12 Jul 2017 10:23:57 -0700 Subject: [PATCH 59/63] QMacStyle: Remove unused variable warning MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: Id6116ad110ac39898e9c44ae41c6d7eec96f58d7 Reviewed-by: Tor Arne Vestbø --- src/widgets/styles/qmacstyle_mac.mm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/widgets/styles/qmacstyle_mac.mm b/src/widgets/styles/qmacstyle_mac.mm index b0176e1a497..8a6e32105a1 100644 --- a/src/widgets/styles/qmacstyle_mac.mm +++ b/src/widgets/styles/qmacstyle_mac.mm @@ -2340,7 +2340,7 @@ void QMacStyle::unpolish(QWidget* w) #endif #ifndef QT_NO_TABBAR - if (QTabBar *tb = qobject_cast(w)) { + if (qobject_cast(w)) { if (!w->testAttribute(Qt::WA_SetFont)) w->setFont(qApp->font(w)); if (!w->testAttribute(Qt::WA_SetPalette)) From 58ab25004e8c53953319d3d1b2c859d92587d5a7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= Date: Wed, 12 Jul 2017 14:28:09 +0200 Subject: [PATCH 60/63] macOS: Fix unused variable in window:willUseFullScreenContentSize: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: I419f884f4145dbe2b60751bf6cde3968cf34fe4a Reviewed-by: Timur Pocheptsov Reviewed-by: Tor Arne Vestbø --- src/plugins/platforms/cocoa/qnswindowdelegate.mm | 1 + 1 file changed, 1 insertion(+) diff --git a/src/plugins/platforms/cocoa/qnswindowdelegate.mm b/src/plugins/platforms/cocoa/qnswindowdelegate.mm index a18fe693fa5..e5041fb8634 100644 --- a/src/plugins/platforms/cocoa/qnswindowdelegate.mm +++ b/src/plugins/platforms/cocoa/qnswindowdelegate.mm @@ -88,6 +88,7 @@ */ - (NSSize)window:(NSWindow *)window willUseFullScreenContentSize:(NSSize)proposedSize { + Q_UNUSED(window); Q_ASSERT(NSEqualSizes(m_cocoaWindow->screen()->geometry().size().toCGSize(), proposedSize)); return proposedSize; } From bdca35e8154d6a8cb2232bd32c64c9e0ba3775c4 Mon Sep 17 00:00:00 2001 From: Simon Hausmann Date: Wed, 12 Jul 2017 16:00:05 +0200 Subject: [PATCH 61/63] Fix documentation of QEvent::LanguageChange propagation The documentation claims that QGuiApplication forwards the top-level windows. However this appears to be a search & replace mistake from the QApplication <> QGuiApplication separation times. Only QApplication forwards the event to top-level widgets and changeEvent() is a virtual method of QWidget. Nothing is implemented for plain QGuiApplication and QWindow. Change-Id: I71b05ecebc90f7c28e150590764438ebaa90e88f Reviewed-by: Michael Brasser --- src/corelib/kernel/qcoreapplication.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/corelib/kernel/qcoreapplication.cpp b/src/corelib/kernel/qcoreapplication.cpp index 39e7c71a9c8..cba279c184b 100644 --- a/src/corelib/kernel/qcoreapplication.cpp +++ b/src/corelib/kernel/qcoreapplication.cpp @@ -1896,8 +1896,8 @@ void QCoreApplication::quit() Installing or removing a QTranslator, or changing an installed QTranslator generates a \l{QEvent::LanguageChange}{LanguageChange} event for the - QCoreApplication instance. A QGuiApplication instance will propagate the event - to all toplevel windows, where a reimplementation of changeEvent can + QCoreApplication instance. A QApplication instance will propagate the event + to all toplevel widgets, where a reimplementation of changeEvent can re-translate the user interface by passing user-visible strings via the tr() function to the respective property setters. User-interface classes generated by Qt Designer provide a \c retranslateUi() function that can be From 70515726181a7e97e1a7096f6b63d4320581d5c1 Mon Sep 17 00:00:00 2001 From: Daniel Teske Date: Tue, 27 Jun 2017 15:10:35 +0200 Subject: [PATCH 62/63] QLineEdit: Fix length calculation for input mask "\\\\" Consider the raw string \\\\. The previous algorithm would consider the last 3 \ to be escaped because the previous character is a \ and thus calculating a maxLength of 3. But this should be treated as two escaped \ with a maxLength of 2. Change-Id: I6c4b8d090a2e1c6e85195d5920ce8b80aea1bc2d Reviewed-by: Marc Mutz --- src/widgets/widgets/qwidgetlinecontrol.cpp | 14 +++++++++++--- .../widgets/widgets/qlineedit/tst_qlineedit.cpp | 11 ++++++++++- 2 files changed, 21 insertions(+), 4 deletions(-) diff --git a/src/widgets/widgets/qwidgetlinecontrol.cpp b/src/widgets/widgets/qwidgetlinecontrol.cpp index 905bc0f586c..97df3427b09 100644 --- a/src/widgets/widgets/qwidgetlinecontrol.cpp +++ b/src/widgets/widgets/qwidgetlinecontrol.cpp @@ -973,12 +973,20 @@ void QWidgetLineControl::parseInputMask(const QString &maskFields) // calculate m_maxLength / m_maskData length m_maxLength = 0; QChar c = 0; + bool escaped = false; for (int i=0; i 0 && m_inputMask.at(i-1) == QLatin1Char('\\')) { - m_maxLength++; - continue; + if (escaped) { + ++m_maxLength; + escaped = false; + continue; } + + if (c == '\\') { + escaped = true; + continue; + } + if (c != QLatin1Char('\\') && c != QLatin1Char('!') && c != QLatin1Char('<') && c != QLatin1Char('>') && c != QLatin1Char('{') && c != QLatin1Char('}') && diff --git a/tests/auto/widgets/widgets/qlineedit/tst_qlineedit.cpp b/tests/auto/widgets/widgets/qlineedit/tst_qlineedit.cpp index a0ba91ba4a1..3f7fdd6f6f9 100644 --- a/tests/auto/widgets/widgets/qlineedit/tst_qlineedit.cpp +++ b/tests/auto/widgets/widgets/qlineedit/tst_qlineedit.cpp @@ -3106,7 +3106,6 @@ void tst_QLineEdit::inputMaskAndValidator() void tst_QLineEdit::maxLengthAndInputMask() { - // Really a test for #30447 QLineEdit *testWidget = ensureTestWidget(); QVERIFY(testWidget->inputMask().isNull()); testWidget->setMaxLength(10); @@ -3114,6 +3113,16 @@ void tst_QLineEdit::maxLengthAndInputMask() testWidget->setInputMask(QString()); QVERIFY(testWidget->inputMask().isNull()); QCOMPARE(testWidget->maxLength(), 10); + + testWidget->setInputMask("XXXX"); + QCOMPARE(testWidget->maxLength(), 4); + + testWidget->setMaxLength(15); + QCOMPARE(testWidget->maxLength(), 4); + + // 8 \ => raw string with 4 \ => input mask with 2 \ => maxLength = 2 + testWidget->setInputMask("\\\\\\\\"); + QCOMPARE(testWidget->maxLength(), 2); } From 627f0a7f7d775ecd263b95dd07fca44bfcb0c5cf Mon Sep 17 00:00:00 2001 From: Kai Koehne Date: Mon, 3 Jul 2017 13:08:47 +0200 Subject: [PATCH 63/63] Doc: Improve documentation about append, prepend The references to the this pointer look somewhat alien in the documentation, because it isn't part of the signature. Rather make the relationship explicit. Change-Id: I6de516e165ea6e9c4ee2898836e9490fbaf4545c Reviewed-by: Thiago Macieira --- src/corelib/tools/qbytearray.cpp | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/src/corelib/tools/qbytearray.cpp b/src/corelib/tools/qbytearray.cpp index 38df38a32f9..0e7365c32b7 100644 --- a/src/corelib/tools/qbytearray.cpp +++ b/src/corelib/tools/qbytearray.cpp @@ -1516,13 +1516,13 @@ void QByteArray::chop(int n) \snippet code/src_corelib_tools_qbytearray.cpp 12 Note: QByteArray is an \l{implicitly shared} class. Consequently, - if \e this is an empty QByteArray, then \e this will just share - the data held in \a ba. In this case, no copying of data is done, + if you append to an empty byte array, then the byte array will just + share the data held in \a ba. In this case, no copying of data is done, taking \l{constant time}. If a shared instance is modified, it will be copied (copy-on-write), taking \l{linear time}. - If \e this is not an empty QByteArray, a deep copy of the data is - performed, taking \l{linear time}. + If the byte array being appended to is not empty, a deep copy of the + data is performed, taking \l{linear time}. This operation typically does not suffer from allocation overhead, because QByteArray preallocates extra space at the end of the data @@ -1781,13 +1781,13 @@ QByteArray QByteArray::nulTerminated() const This is the same as insert(0, \a ba). Note: QByteArray is an \l{implicitly shared} class. Consequently, - if \e this is an empty QByteArray, then \e this will just share - the data held in \a ba. In this case, no copying of data is done, + if you prepend to an empty byte array, then the byte array will just + share the data held in \a ba. In this case, no copying of data is done, taking \l{constant time}. If a shared instance is modified, it will be copied (copy-on-write), taking \l{linear time}. - If \e this is not an empty QByteArray, a deep copy of the data is - performed, taking \l{linear time}. + If the byte array being prepended to is not empty, a deep copy of the + data is performed, taking \l{linear time}. \sa append(), insert() */ @@ -1869,13 +1869,13 @@ QByteArray &QByteArray::prepend(char ch) This is the same as insert(size(), \a ba). Note: QByteArray is an \l{implicitly shared} class. Consequently, - if \e this is an empty QByteArray, then \e this will just share - the data held in \a ba. In this case, no copying of data is done, + if you append to an empty byte array, then the byte array will just + share the data held in \a ba. In this case, no copying of data is done, taking \l{constant time}. If a shared instance is modified, it will be copied (copy-on-write), taking \l{linear time}. - If \e this is not an empty QByteArray, a deep copy of the data is - performed, taking \l{linear time}. + If the byte array being appended to is not empty, a deep copy of the + data is performed, taking \l{linear time}. This operation typically does not suffer from allocation overhead, because QByteArray preallocates extra space at the end of the data