From c127fc83adef427f62cc38f3e1afc0041ac9dfe5 Mon Sep 17 00:00:00 2001 From: Frederik Christiani Date: Wed, 25 Apr 2018 14:28:45 +0200 Subject: [PATCH 01/23] Show high DPI custom cursor on macOS MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Set the devicePixelRatio to 1 on the scaled down pixmap. A scaled down version of the high DPI pixmap is added to the NSCursor in addition to the high DPI one, but the devicePixelRatio must be set correctly on the smaller of the two for macOS to pick the right image to use on a high resolution display (retina). This change also fixes the problem that only a high DPI custom cursor with a hotspot in the upper left quadrant is applied by macOS. I suspect that the NSCursor was discarded by macOS, because the hotspot was outside the device independent bounds of the smaller scaled image. Task-number: QTBUG-52211 Change-Id: I7e552e8f62f5255dd3786da44b2f619f6790c37a Reviewed-by: Morten Johan Sørvig --- src/plugins/platforms/cocoa/qcocoacursor.mm | 1 + 1 file changed, 1 insertion(+) diff --git a/src/plugins/platforms/cocoa/qcocoacursor.mm b/src/plugins/platforms/cocoa/qcocoacursor.mm index c021128e4c..8c98dc69f7 100644 --- a/src/plugins/platforms/cocoa/qcocoacursor.mm +++ b/src/plugins/platforms/cocoa/qcocoacursor.mm @@ -314,6 +314,7 @@ NSCursor *QCocoaCursor::createCursorFromPixmap(const QPixmap pixmap, const QPoin if (pixmap.devicePixelRatio() > 1.0) { QSize layoutSize = pixmap.size() / pixmap.devicePixelRatio(); QPixmap scaledPixmap = pixmap.scaled(layoutSize, Qt::IgnoreAspectRatio, Qt::SmoothTransformation); + scaledPixmap.setDevicePixelRatio(1.0); nsimage = static_cast(qt_mac_create_nsimage(scaledPixmap)); CGImageRef cgImage = qt_mac_toCGImage(pixmap.toImage()); NSBitmapImageRep *imageRep = [[NSBitmapImageRep alloc] initWithCGImage:cgImage]; From 7c3053b301a70b04f5ab4ed9c3f3a6c84cb89616 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= Date: Mon, 23 Apr 2018 16:00:34 +0200 Subject: [PATCH 02/23] qmake: Don't map Xcode SYMROOT to output directory The output directory may be the same as the source directory in the case of an in-source build, but Xcode treats the SYMROOT as a build directory, and automatically excludes it from Time Machine backups, which may result in not backing up sources. Instead we map SYMROOT to an .xcode subdirectory of the output directory, and then use CONFIGURATION_BUILD_DIR to make sure the final build targets end up where they used to. Task-number: QTBUG-52474 Change-Id: I3852ca9088e75ca62fca4c1217b5485175d9436f Reviewed-by: Oswald Buddenhagen Reviewed-by: Alexandru Croitor --- qmake/generators/mac/pbuilder_pbx.cpp | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/qmake/generators/mac/pbuilder_pbx.cpp b/qmake/generators/mac/pbuilder_pbx.cpp index 3b1f904253..18b62c5135 100644 --- a/qmake/generators/mac/pbuilder_pbx.cpp +++ b/qmake/generators/mac/pbuilder_pbx.cpp @@ -1603,7 +1603,17 @@ ProjectBuilderMakefileGenerator::writeMakeParts(QTextStream &t) } } - t << "\t\t\t\t" << writeSettings("SYMROOT", Option::output_dir) << ";\n"; + // The symroot is marked by xcodebuild as excluded from Time Machine + // backups, as it's a temporary build dir, so we don't want it to be + // the same as the possibe in-source dir, as that would leave out + // sources from being backed up. + t << "\t\t\t\t" << writeSettings("SYMROOT", + Option::output_dir + Option::dir_sep + ".xcode") << ";\n"; + + // The configuration build dir however is not treated as excluded, + // so we can safely point it to the root output dir. + t << "\t\t\t\t" << writeSettings("CONFIGURATION_BUILD_DIR", + Option::output_dir + Option::dir_sep + "$(CONFIGURATION)") << ";\n"; if (!project->isEmpty("DESTDIR")) { ProString dir = project->first("DESTDIR"); From 26e3dfd4ab25f578a988703e693d7cd073277bd6 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Wed, 25 Apr 2018 22:23:14 -0700 Subject: [PATCH 03/23] Improve padding hole issues in QAbstractPrintDialogPrivate Placing a boolean between two pointers means we'll have a 7-byte padding hole (64-bit). So move it to the bottom of the class, consuming the tail padding that needs to be there anyway on 64-bit systems. On 32-bit Unix systems, the better place would be at the top, as the parent class (QDialogPrivate) has a 3-byte tail padding. But that's fragile, as QDialogPrivate can change, doesn't apply to MSVC's ABI and doesn't gain us anything on 64-bit. Change-Id: I3840d727dee443318644fffd1528e4f05f4142bd Reviewed-by: Lars Knoll --- src/printsupport/dialogs/qabstractprintdialog_p.h | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/printsupport/dialogs/qabstractprintdialog_p.h b/src/printsupport/dialogs/qabstractprintdialog_p.h index a17a28f564..b646b74f34 100644 --- a/src/printsupport/dialogs/qabstractprintdialog_p.h +++ b/src/printsupport/dialogs/qabstractprintdialog_p.h @@ -69,16 +69,15 @@ class QAbstractPrintDialogPrivate : public QDialogPrivate public: QAbstractPrintDialogPrivate() - : printer(nullptr), pd(nullptr), ownsPrinter(false) + : printer(nullptr), pd(nullptr) , options(QAbstractPrintDialog::PrintToFile | QAbstractPrintDialog::PrintPageRange | QAbstractPrintDialog::PrintCollateCopies | QAbstractPrintDialog::PrintShowPageSize), - minPage(0), maxPage(INT_MAX) + minPage(0), maxPage(INT_MAX), ownsPrinter(false) { } QPrinter *printer; QPrinterPrivate *pd; - bool ownsPrinter; QPointer receiverToDisconnectOnClose; QByteArray memberToDisconnectOnClose; @@ -88,6 +87,8 @@ public: void setPrinter(QPrinter *newPrinter); int minPage; int maxPage; + + bool ownsPrinter; }; QT_END_NAMESPACE From 2660aefdbc52c5f2ef1ec96216c7ab82aa0c7324 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Wed, 25 Apr 2018 21:46:02 -0700 Subject: [PATCH 04/23] Remove hack that violates ODR MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit GCC with LTO sees through our hack: qprintdialog_unix.cpp:212:7: warning: type ‘struct QPrintDialogPrivate’ violates the C++ One Definition Rule [-Wodr] qabstractprintdialog.cpp:49:7: note: a different type is defined in another translation unit This hack was there so that the QPrintDialog functions in qabstractprintdialog.cpp could use the d pointer. So instead of hacking around the issue, just use the class that this file has access to: QAbstractPrintDialogPrivate. Change-Id: I3840d727dee443318644fffd1528e2e8b814e983 Reviewed-by: Olivier Goffart (Woboq GmbH) --- .../dialogs/qabstractprintdialog.cpp | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/src/printsupport/dialogs/qabstractprintdialog.cpp b/src/printsupport/dialogs/qabstractprintdialog.cpp index 71b5500bab..1a2aa7afac 100644 --- a/src/printsupport/dialogs/qabstractprintdialog.cpp +++ b/src/printsupport/dialogs/qabstractprintdialog.cpp @@ -45,11 +45,6 @@ QT_BEGIN_NAMESPACE -// hack -class QPrintDialogPrivate : public QAbstractPrintDialogPrivate -{ -}; - /*! \class QAbstractPrintDialog \brief The QAbstractPrintDialog class provides a base implementation for @@ -145,7 +140,7 @@ QAbstractPrintDialog::~QAbstractPrintDialog() */ void QPrintDialog::setOption(PrintDialogOption option, bool on) { - Q_D(QPrintDialog); + auto *d = static_cast(d_ptr.data()); if (!(d->options & option) != !on) setOptions(d->options ^ option); } @@ -158,7 +153,7 @@ void QPrintDialog::setOption(PrintDialogOption option, bool on) */ bool QPrintDialog::testOption(PrintDialogOption option) const { - Q_D(const QPrintDialog); + auto *d = static_cast(d_ptr.data()); return (d->options & option) != 0; } @@ -177,7 +172,7 @@ bool QPrintDialog::testOption(PrintDialogOption option) const */ void QPrintDialog::setOptions(PrintDialogOptions options) { - Q_D(QPrintDialog); + auto *d = static_cast(d_ptr.data()); PrintDialogOptions changed = (options ^ d->options); if (!changed) @@ -188,7 +183,7 @@ void QPrintDialog::setOptions(PrintDialogOptions options) QPrintDialog::PrintDialogOptions QPrintDialog::options() const { - Q_D(const QPrintDialog); + auto *d = static_cast(d_ptr.data()); return d->options; } @@ -464,7 +459,7 @@ void QAbstractPrintDialog::setOptionTabs(const QList &tabs) */ void QPrintDialog::done(int result) { - Q_D(QPrintDialog); + auto *d = static_cast(d_ptr.data()); QDialog::done(result); if (result == Accepted) emit accepted(printer()); @@ -487,7 +482,7 @@ void QPrintDialog::done(int result) */ void QPrintDialog::open(QObject *receiver, const char *member) { - Q_D(QPrintDialog); + auto *d = static_cast(d_ptr.data()); connect(this, SIGNAL(accepted(QPrinter*)), receiver, member); d->receiverToDisconnectOnClose = receiver; d->memberToDisconnectOnClose = member; From e69b6d2dbc9166f07ff3ee1e588f39d244c0b692 Mon Sep 17 00:00:00 2001 From: Kari Oikarinen Date: Wed, 11 Apr 2018 09:27:32 +0300 Subject: [PATCH 05/23] tst_Gestures: Use QTest::qWaitForWindowExposed() Instead of a local wrapper for it. Change-Id: I0708dfad44b3db0c7a13e75ba5b4193ab50ac315 Reviewed-by: Qt CI Bot Reviewed-by: Gatis Paeglis --- tests/auto/other/gestures/tst_gestures.cpp | 56 ++++++++-------------- 1 file changed, 19 insertions(+), 37 deletions(-) diff --git a/tests/auto/other/gestures/tst_gestures.cpp b/tests/auto/other/gestures/tst_gestures.cpp index d153146574..0767efb817 100644 --- a/tests/auto/other/gestures/tst_gestures.cpp +++ b/tests/auto/other/gestures/tst_gestures.cpp @@ -43,24 +43,6 @@ #include -static bool waitForWindowExposed(QWindow *window) -{ - if (!window) - return false; -#ifdef Q_OS_OSX - QTest::qWait(100); - return window->isExposed(); -#endif - return QTest::qWaitForWindowExposed(window); -} - -static bool waitForWindowExposed(QWidget *widget) -{ - if (!widget) - return false; - return waitForWindowExposed(widget->windowHandle()); -} - static QPointF mapToGlobal(const QPointF &pt, QGraphicsItem *item, QGraphicsView *view) { return view->viewport()->mapToGlobal(view->mapFromScene(item->mapToScene(pt))); @@ -376,7 +358,7 @@ void tst_Gestures::customGesture() GestureWidget widget; widget.grabGesture(CustomGesture::GestureType, Qt::DontStartGestureOnChildren); widget.show(); - QVERIFY(waitForWindowExposed(&widget)); + QVERIFY(QTest::qWaitForWindowExposed(&widget)); CustomEvent event; event.hotSpot = widget.mapToGlobal(QPoint(5,5)); @@ -845,7 +827,7 @@ void tst_Gestures::graphicsItemGesture() item->setPos(100, 100); view.show(); - QVERIFY(waitForWindowExposed(&view)); + QVERIFY(QTest::qWaitForWindowExposed(&view)); view.ensureVisible(scene.sceneRect()); item->grabGesture(CustomGesture::GestureType); @@ -907,7 +889,7 @@ void tst_Gestures::graphicsView() item->setPos(100, 100); view.show(); - QVERIFY(waitForWindowExposed(&view)); + QVERIFY(QTest::qWaitForWindowExposed(&view)); view.ensureVisible(scene.sceneRect()); item->grabGesture(CustomGesture::GestureType); @@ -983,7 +965,7 @@ void tst_Gestures::graphicsItemTreeGesture() item1_child2->setParentItem(item1); view.show(); - QVERIFY(waitForWindowExposed(&view)); + QVERIFY(QTest::qWaitForWindowExposed(&view)); view.ensureVisible(scene.sceneRect()); item1->grabGesture(CustomGesture::GestureType); @@ -1040,7 +1022,7 @@ void tst_Gestures::explicitGraphicsObjectTarget() item2_child1->setPos(10, 10); view.show(); - QVERIFY(waitForWindowExposed(&view)); + QVERIFY(QTest::qWaitForWindowExposed(&view)); view.ensureVisible(scene.sceneRect()); item1->grabGesture(CustomGesture::GestureType, Qt::DontStartGestureOnChildren); @@ -1099,7 +1081,7 @@ void tst_Gestures::gestureOverChildGraphicsItem() item2_child1->setPos(0, 0); view.show(); - QVERIFY(waitForWindowExposed(&view)); + QVERIFY(QTest::qWaitForWindowExposed(&view)); view.ensureVisible(scene.sceneRect()); item1->grabGesture(CustomGesture::GestureType); @@ -1397,7 +1379,7 @@ void tst_Gestures::testMapToScene() item0->setPos(14, 16); view.show(); // need to show to give it a global coordinate - QVERIFY(waitForWindowExposed(&view)); + QVERIFY(QTest::qWaitForWindowExposed(&view)); view.ensureVisible(scene.sceneRect()); QPoint origin = view.mapToGlobal(QPoint()); @@ -1523,7 +1505,7 @@ void tst_Gestures::autoCancelGestures() parent.grabGesture(CustomGesture::GestureType); child->grabGesture(secondGesture); parent.show(); - QVERIFY(waitForWindowExposed(&parent)); + QVERIFY(QTest::qWaitForWindowExposed(&parent)); /* An event is sent to both the child and the parent, when the child gets it a gesture is triggered @@ -1582,7 +1564,7 @@ void tst_Gestures::autoCancelGestures2() child->grabGesture(secondGesture); view.show(); - QVERIFY(waitForWindowExposed(&view)); + QVERIFY(QTest::qWaitForWindowExposed(&view)); view.ensureVisible(scene.sceneRect()); CustomEvent event; @@ -1628,7 +1610,7 @@ void tst_Gestures::graphicsViewParentPropagation() item1_c1_c1->setPos(0, 0); view.show(); - QVERIFY(waitForWindowExposed(&view)); + QVERIFY(QTest::qWaitForWindowExposed(&view)); view.ensureVisible(scene.sceneRect()); item0->grabGesture(CustomGesture::GestureType, Qt::ReceivePartialGestures | Qt::IgnoredGesturesPropagateToParent); @@ -1698,7 +1680,7 @@ void tst_Gestures::panelPropagation() item1_child1_child1->setZValue(10); view.show(); - QVERIFY(waitForWindowExposed(&view)); + QVERIFY(QTest::qWaitForWindowExposed(&view)); view.ensureVisible(scene.sceneRect()); static const int TotalGestureEventsCount = CustomGesture::SerialFinishedThreshold - CustomGesture::SerialStartedThreshold + 1; @@ -1809,7 +1791,7 @@ void tst_Gestures::panelStacksBehindParent() panel->setZValue(5); view.show(); - QVERIFY(waitForWindowExposed(&view)); + QVERIFY(QTest::qWaitForWindowExposed(&view)); view.ensureVisible(scene.sceneRect()); static const int TotalGestureEventsCount = CustomGesture::SerialFinishedThreshold - CustomGesture::SerialStartedThreshold + 1; @@ -1893,7 +1875,7 @@ void tst_Gestures::deleteGestureTargetItem() items.insert(item2->objectName(), item2); view.show(); - QVERIFY(waitForWindowExposed(&view)); + QVERIFY(QTest::qWaitForWindowExposed(&view)); view.ensureVisible(scene.sceneRect()); if (propagateUpdateGesture) @@ -1938,7 +1920,7 @@ void tst_Gestures::viewportCoordinates() scene.addItem(item1); view.show(); - QVERIFY(waitForWindowExposed(&view)); + QVERIFY(QTest::qWaitForWindowExposed(&view)); view.ensureVisible(scene.sceneRect()); CustomEvent event; @@ -1975,7 +1957,7 @@ void tst_Gestures::partialGesturePropagation() scene.addItem(item4); view.show(); - QVERIFY(waitForWindowExposed(&view)); + QVERIFY(QTest::qWaitForWindowExposed(&view)); view.ensureVisible(scene.sceneRect()); item1->ignoredUpdatedGestures << CustomGesture::GestureType; @@ -2063,7 +2045,7 @@ void tst_Gestures::testQGestureRecognizerCleanup() //QGestureRecognizer::registerRecognizer(new PanRecognizer(PanRecognizer::Custom)); w->show(); - QVERIFY(waitForWindowExposed(w)); + QVERIFY(QTest::qWaitForWindowExposed(w)); delete w; } @@ -2184,7 +2166,7 @@ void tst_Gestures::testReuseCanceledGestures() gv->viewport()->grabGesture(tapGestureTypeId); mw.show(); - QVERIFY(waitForWindowExposed(&mw)); + QVERIFY(QTest::qWaitForWindowExposed(&mw)); QPoint targetPos(gv->mapFromScene(target->mapToScene(target->rect().center()))); targetPos = gv->viewport()->mapFromParent(targetPos); @@ -2250,7 +2232,7 @@ void tst_Gestures::conflictingGesturesInGraphicsView() scene.addItem(item2); view.show(); - QVERIFY(waitForWindowExposed(&view)); + QVERIFY(QTest::qWaitForWindowExposed(&view)); view.ensureVisible(scene.sceneRect()); static const int TotalGestureEventsCount = CustomGesture::SerialFinishedThreshold - CustomGesture::SerialStartedThreshold + 1; @@ -2315,7 +2297,7 @@ void tst_Gestures::bug_13501_gesture_not_accepted() NoConsumeWidgetBug13501 w; w.grabGesture(Qt::TapGesture); w.show(); - QVERIFY(waitForWindowExposed(&w)); + QVERIFY(QTest::qWaitForWindowExposed(&w)); //QTest::mousePress(&ignoreEvent, Qt::LeftButton); QTouchDevice *device = QTest::createTouchDevice(); QTest::touchEvent(&w, device).press(0, QPoint(10, 10), &w); From e0b5ff4ad583befbecbcbe462998e3ed80899531 Mon Sep 17 00:00:00 2001 From: Ulf Hermann Date: Tue, 24 Apr 2018 19:17:45 +0200 Subject: [PATCH 06/23] QWidgetWindow: Immediately forward close events to QWindow MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This way the platform window is destroyed in a timely manner, preventing redundant close events from the window system. Task-number: QTBUG-43344 Change-Id: Ifdfca59ceacef54405f1c227c493dc514a1b27ea Reviewed-by: Morten Johan Sørvig --- src/widgets/kernel/qwidgetwindow.cpp | 1 + .../widgets/kernel/qwidget/tst_qwidget.cpp | 28 +++++++++++++++++++ 2 files changed, 29 insertions(+) diff --git a/src/widgets/kernel/qwidgetwindow.cpp b/src/widgets/kernel/qwidgetwindow.cpp index 1078652234..949076b260 100644 --- a/src/widgets/kernel/qwidgetwindow.cpp +++ b/src/widgets/kernel/qwidgetwindow.cpp @@ -237,6 +237,7 @@ bool QWidgetWindow::event(QEvent *event) switch (event->type()) { case QEvent::Close: handleCloseEvent(static_cast(event)); + QWindow::event(event); return true; case QEvent::Enter: diff --git a/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp b/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp index 823a52ce70..47ffee1501 100644 --- a/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp +++ b/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp @@ -401,6 +401,8 @@ private slots: void tabletTracking(); + void closeEvent(); + private: bool ensureScreenSize(int width, int height); @@ -10798,5 +10800,31 @@ void tst_QWidget::tabletTracking() QTRY_COMPARE(widget.moveEventCount, 3); } +class CloseCountingWidget : public QWidget +{ +public: + int closeCount = 0; + void closeEvent(QCloseEvent *ev) override; +}; + +void CloseCountingWidget::closeEvent(QCloseEvent *ev) +{ + ++closeCount; + ev->accept(); +} + +void tst_QWidget::closeEvent() +{ + CloseCountingWidget widget; + widget.show(); + QVERIFY(QTest::qWaitForWindowExposed(&widget)); + // Yes we call the close() function twice. This mimics the behavior of QTBUG-43344 where + // QApplication first closes all windows and then QCocoaApplication flushes window system + // events, triggering more close events. + widget.windowHandle()->close(); + widget.windowHandle()->close(); + QCOMPARE(widget.closeCount, 1); +} + QTEST_MAIN(tst_QWidget) #include "tst_qwidget.moc" From ff029a9ca8be1441d817380d61a296e21355baf1 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Thu, 26 Apr 2018 14:55:47 -0700 Subject: [PATCH 07/23] tst_QString: remove old HP aCC workaround Change-Id: I3840d727dee443318644fffd15291b1d77dca2fc Reviewed-by: Olivier Goffart (Woboq GmbH) --- tests/auto/corelib/tools/qstring/tst_qstring.cpp | 8 -------- 1 file changed, 8 deletions(-) diff --git a/tests/auto/corelib/tools/qstring/tst_qstring.cpp b/tests/auto/corelib/tools/qstring/tst_qstring.cpp index 86cc2cd02f..28014840a3 100644 --- a/tests/auto/corelib/tools/qstring/tst_qstring.cpp +++ b/tests/auto/corelib/tools/qstring/tst_qstring.cpp @@ -324,10 +324,8 @@ public: public slots: void cleanup(); private slots: -#ifndef Q_CC_HPACC void fromStdString(); void toStdString(); -#endif void check_QTextIOStream(); void check_QTextStream(); void check_QDataStream(); @@ -4056,8 +4054,6 @@ void tst_QString::setRawData() QVERIFY(cstr.data_ptr() != csd); } -#ifndef Q_CC_HPACC -// This test crashes on HP-UX with aCC (not supported) void tst_QString::fromStdString() { std::string stroustrup = "foo"; @@ -4068,10 +4064,7 @@ void tst_QString::fromStdString() QString qtnull = QString::fromStdString( stdnull ); QCOMPARE( qtnull.size(), int(stdnull.size()) ); } -#endif -#ifndef Q_CC_HPACC -// This test crashes on HP-UX with aCC (not supported) void tst_QString::toStdString() { QString nord = "foo"; @@ -4088,7 +4081,6 @@ void tst_QString::toStdString() std::string stdnull = qtnull.toStdString(); QCOMPARE( int(stdnull.size()), qtnull.size() ); } -#endif void tst_QString::utf8() { From 67aa365d41ebfe082b4efcfd725e4d5f08be678c Mon Sep 17 00:00:00 2001 From: Ulf Hermann Date: Wed, 25 Apr 2018 12:48:21 +0200 Subject: [PATCH 08/23] Do emit CMake declarations for existing private headers We need to make sure we don't emit CMake declarations for private headers if those headers are absent. However, most of the time we have private headers and should add them. Task-number: QTBUG-37417 Change-Id: I639eb93d008de27928dedac540894af70c1883b9 Reviewed-by: Oswald Buddenhagen --- mkspecs/features/create_cmake.prf | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/mkspecs/features/create_cmake.prf b/mkspecs/features/create_cmake.prf index 66acedef55..2ed708e085 100644 --- a/mkspecs/features/create_cmake.prf +++ b/mkspecs/features/create_cmake.prf @@ -28,9 +28,13 @@ CMAKE_OUT_DIR = $$MODULE_BASE_OUTDIR/lib/cmake CMAKE_MODULE_NAME = $$cmakeModuleName($${MODULE}) +!generated_privates { + isEmpty(SYNCQT.INJECTED_PRIVATE_HEADER_FILES):isEmpty(SYNCQT.PRIVATE_HEADER_FILES): \ + CMAKE_NO_PRIVATE_INCLUDES = true +} + split_incpath { CMAKE_ADD_SOURCE_INCLUDE_DIRS = true - CMAKE_NO_PRIVATE_INCLUDES = true # Don't add private includes in the build dir which don't exist CMAKE_SOURCE_INCLUDES = \ $$cmakeTargetPaths($$QT_MODULE_INCLUDE_BASE $$QT_MODULE_INCLUDE_BASE/Qt$${CMAKE_MODULE_NAME}) CMAKE_SOURCE_PRIVATE_INCLUDES = \ @@ -53,10 +57,6 @@ contains(CMAKE_INCLUDE_DIR, "^\\.\\./.*") { CMAKE_INCLUDE_DIR_IS_ABSOLUTE = True } -isEmpty(QT.$${MODULE}_private.includes)| \ - !exists($$first(QT.$${MODULE}_private.includes)): \ - CMAKE_NO_PRIVATE_INCLUDES = true - CMAKE_LIB_DIR = $$cmakeRelativePath($$[QT_INSTALL_LIBS], $$[QT_INSTALL_PREFIX]) contains(CMAKE_LIB_DIR,"^\\.\\./.*") { CMAKE_LIB_DIR = $$[QT_INSTALL_LIBS]/ From b7d810a7ccea3bc75663d5df9410d95834a0b2bf Mon Sep 17 00:00:00 2001 From: Kari Oikarinen Date: Thu, 12 Apr 2018 11:38:42 +0300 Subject: [PATCH 09/23] tst_QFocusEvent: Add qWaitForWindowActive() to checkReason_focusWidget() checkReason_ActiveWindow() started failing on Windows when run together with other tests, but still passed on its own. The offending tests was checkReason_focusWidget(), which showed a window but did not wait for it to be active. After adding this wait the whole test executable passes on Windows as well. Amends fd87c8da82b4bf52d395a5f9a2687e4eb7a22221. Change-Id: I384bc45176fcd7bf6f491a4f39b46464ba45693b Reviewed-by: Friedemann Kleint --- tests/auto/other/qfocusevent/tst_qfocusevent.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/auto/other/qfocusevent/tst_qfocusevent.cpp b/tests/auto/other/qfocusevent/tst_qfocusevent.cpp index 37521a64aa..e82327bbb1 100644 --- a/tests/auto/other/qfocusevent/tst_qfocusevent.cpp +++ b/tests/auto/other/qfocusevent/tst_qfocusevent.cpp @@ -304,6 +304,7 @@ void tst_QFocusEvent::checkReason_focusWidget() frame1.setLayout(&leftLayout); frame2.setLayout(&rightLayout); window1.show(); + QVERIFY(QTest::qWaitForWindowActive(&window1)); edit1.setFocus(); QTRY_VERIFY(edit1.hasFocus()); From 8d7af27e42e28fc5ebcbcf023b75444899dba2ca Mon Sep 17 00:00:00 2001 From: David Faure Date: Thu, 26 Apr 2018 19:16:53 +0200 Subject: [PATCH 10/23] QMimeDatabase: check 128 bytes rather than 32, for text vs binary As per today's change in the MIME spec. https://bugs.freedesktop.org/show_bug.cgi?id=97372 Change-Id: Iba4fdd95c3ebec8a042404956db3466a46c97f1d Reviewed-by: Thiago Macieira --- src/corelib/mimetypes/qmimedatabase.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/corelib/mimetypes/qmimedatabase.cpp b/src/corelib/mimetypes/qmimedatabase.cpp index 7d529372c4..68e3c8f10d 100644 --- a/src/corelib/mimetypes/qmimedatabase.cpp +++ b/src/corelib/mimetypes/qmimedatabase.cpp @@ -311,9 +311,9 @@ static inline bool isTextFile(const QByteArray &data) if (data.startsWith(bigEndianBOM) || data.startsWith(littleEndianBOM)) return true; - // Check the first 32 bytes (see shared-mime spec) + // Check the first 128 bytes (see shared-mime spec) const char *p = data.constData(); - const char *e = p + qMin(32, data.size()); + const char *e = p + qMin(128, data.size()); for ( ; p < e; ++p) { if ((unsigned char)(*p) < 32 && *p != 9 && *p !=10 && *p != 13) return false; From 6cece0f43a18dc8c9dbf5bc49ce515714f090725 Mon Sep 17 00:00:00 2001 From: Paul Olav Tvete Date: Thu, 26 Apr 2018 13:43:45 +0200 Subject: [PATCH 11/23] Fix for input method commit that ends with newline If the input method event contains a commit text that ends with a newline, text, the commit string is inserted first. This changes the current block. This change makes sure that we apply the formatting changes (including removing the old preedit text) to the old block in this specific case. Task-number: QTBUG-67836 Change-Id: Ia83963780fb14b3c571dbbe3eb81fbbe20fbf412 Reviewed-by: Eskil Abrahamsen Blomfeldt --- src/widgets/widgets/qwidgettextcontrol.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/widgets/widgets/qwidgettextcontrol.cpp b/src/widgets/widgets/qwidgettextcontrol.cpp index d3203e180b..43c1c3e365 100644 --- a/src/widgets/widgets/qwidgettextcontrol.cpp +++ b/src/widgets/widgets/qwidgettextcontrol.cpp @@ -1977,8 +1977,12 @@ void QWidgetTextControlPrivate::inputMethodEvent(QInputMethodEvent *e) cursor.removeSelectedText(); } + QTextBlock block; + // insert commit string if (!e->commitString().isEmpty() || e->replacementLength()) { + if (e->commitString().endsWith(QChar::LineFeed)) + block = cursor.block(); // Remember the block where the preedit text is QTextCursor c = cursor; c.setPosition(c.position() + e->replacementStart()); c.setPosition(c.position() + e->replacementLength(), QTextCursor::KeepAnchor); @@ -1997,7 +2001,8 @@ void QWidgetTextControlPrivate::inputMethodEvent(QInputMethodEvent *e) } } - QTextBlock block = cursor.block(); + if (!block.isValid()) + block = cursor.block(); QTextLayout *layout = block.layout(); if (isGettingInput) layout->setPreeditArea(cursor.position() - block.position(), e->preeditString()); From 9fdbd9dce917e90f0e644bedd8dca183f88304d6 Mon Sep 17 00:00:00 2001 From: Jussi Witick Date: Wed, 25 Apr 2018 11:22:13 +0300 Subject: [PATCH 12/23] Specify that you need an instance of QNetworkAccessManager per thread MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The class is not thread safe, so one instance is not enough for whole application. Mention that QNetworkAccessManager instance can only be used from the thread it belongs to because it is a QObject. Change-Id: I56184e4f8fbd36aca3f6677310431eab88346e6e Reviewed-by: Mårten Nordheim Reviewed-by: Timur Pocheptsov --- src/network/access/qnetworkaccessmanager.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/network/access/qnetworkaccessmanager.cpp b/src/network/access/qnetworkaccessmanager.cpp index 07644b869f..35e79a69f2 100644 --- a/src/network/access/qnetworkaccessmanager.cpp +++ b/src/network/access/qnetworkaccessmanager.cpp @@ -178,7 +178,9 @@ static void ensureInitialized() it sends. It contains the proxy and cache configuration, as well as the signals related to such issues, and reply signals that can be used to monitor the progress of a network operation. One QNetworkAccessManager - should be enough for the whole Qt application. + instance should be enough for the whole Qt application. Since + QNetworkAccessManager is based on QObject, it can only be used from the + thread it belongs to. Once a QNetworkAccessManager object has been created, the application can use it to send requests over the network. A group of standard functions From 9ac9bea16c502b26fb99448b118960f43272b335 Mon Sep 17 00:00:00 2001 From: Volker Krause Date: Fri, 27 Apr 2018 19:04:33 +0200 Subject: [PATCH 13/23] Fix handling of QDBusMessage in qdbuscpp2xml in bootstrapped mode In bootstrapped mode QDBusMessage isn't available, so looking up the type via QMetaType wont work. QDBusMetaTypeId has this special-cased, but that alone isn't enough for qdbuscpp2xml to produce the same result as in non- bootstrapped mode. The effect of this has also been described here before in detail: http://lists.qt-project.org/pipermail/development/2017-February/028756.html Change-Id: Id309a3a910f971c6150cdc6d06f2b48f1b95c787 Reviewed-by: Thiago Macieira --- src/dbus/qdbusmisc.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/dbus/qdbusmisc.cpp b/src/dbus/qdbusmisc.cpp index 930c3bd2da..eb8f61c783 100644 --- a/src/dbus/qdbusmisc.cpp +++ b/src/dbus/qdbusmisc.cpp @@ -181,6 +181,13 @@ int qDBusParametersForMethod(const QList ¶meterTypes, QVector Date: Tue, 17 Apr 2018 10:05:55 +0300 Subject: [PATCH 14/23] tests: Include qglobal.h in EmulationDetector Checking for Q_OS_LINUX, Q_PROCESSOR_ARM and use of QT_CONFIG() checks should only happen after qglobal.h is included. Otherwise the header will be broken if included before something that uses qglobal.h Change-Id: I052e46784f7b174e74e8894e1b7c5b7528420f5d Reviewed-by: Simon Hausmann --- tests/shared/emulationdetector.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/shared/emulationdetector.h b/tests/shared/emulationdetector.h index cca11be695..2b04a1061e 100644 --- a/tests/shared/emulationdetector.h +++ b/tests/shared/emulationdetector.h @@ -29,6 +29,8 @@ #ifndef EMULATIONDETECTOR_H #define EMULATIONDETECTOR_H +#include + #if defined(Q_OS_LINUX) && defined(Q_PROCESSOR_ARM) #define SHOULD_CHECK_ARM_ON_X86 From 2677ad78e6a283734aef733581a4ae07f7294ec8 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Fri, 27 Apr 2018 15:31:17 +0200 Subject: [PATCH 15/23] Vulkan Examples: Fix Clang warnings about initialization of VkClearColorValue hellovulkanwindow.cpp(97,38): warning: suggest braces around initialization of subobject [-Wmissing-braces] VkClearColorValue clearColor = { 0.0f, m_green, 0.0f, 1.0f }; hellovulkantexture.cpp(771,38): warning: suggest braces around initialization of subobject [-Wmissing-braces] VkClearColorValue clearColor = { 0, 0, 0, 1 }; ..\shared\trianglerenderer.cpp(455,38): warning: suggest braces around initialization of subobject [-Wmissing-braces] VkClearColorValue clearColor = { 0, 0, 0, 1 }; renderer.cpp(896,38): warning: suggest braces around initialization of subobject [-Wmissing-braces] VkClearColorValue clearColor = { 0.67f, 0.84f, 0.9f, 1.0f }; Change-Id: I3c2403699059dac2f88541f2a2102b774db0c887 Reviewed-by: Laszlo Agocs --- examples/vulkan/hellovulkancubes/renderer.cpp | 2 +- examples/vulkan/hellovulkantexture/hellovulkantexture.cpp | 2 +- examples/vulkan/hellovulkanwindow/hellovulkanwindow.cpp | 2 +- examples/vulkan/shared/trianglerenderer.cpp | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/examples/vulkan/hellovulkancubes/renderer.cpp b/examples/vulkan/hellovulkancubes/renderer.cpp index 523511337d..2e913bcae8 100644 --- a/examples/vulkan/hellovulkancubes/renderer.cpp +++ b/examples/vulkan/hellovulkancubes/renderer.cpp @@ -893,7 +893,7 @@ void Renderer::buildFrame() VkCommandBuffer cb = m_window->currentCommandBuffer(); const QSize sz = m_window->swapChainImageSize(); - VkClearColorValue clearColor = { 0.67f, 0.84f, 0.9f, 1.0f }; + VkClearColorValue clearColor = {{ 0.67f, 0.84f, 0.9f, 1.0f }}; VkClearDepthStencilValue clearDS = { 1, 0 }; VkClearValue clearValues[3]; memset(clearValues, 0, sizeof(clearValues)); diff --git a/examples/vulkan/hellovulkantexture/hellovulkantexture.cpp b/examples/vulkan/hellovulkantexture/hellovulkantexture.cpp index 543eb7884a..ffe1a31442 100644 --- a/examples/vulkan/hellovulkantexture/hellovulkantexture.cpp +++ b/examples/vulkan/hellovulkantexture/hellovulkantexture.cpp @@ -768,7 +768,7 @@ void VulkanRenderer::startNextFrame() // Add the necessary barriers and do the host-linear -> device-optimal copy, if not yet done. ensureTexture(); - VkClearColorValue clearColor = { 0, 0, 0, 1 }; + VkClearColorValue clearColor = {{ 0, 0, 0, 1 }}; VkClearDepthStencilValue clearDS = { 1, 0 }; VkClearValue clearValues[2]; memset(clearValues, 0, sizeof(clearValues)); diff --git a/examples/vulkan/hellovulkanwindow/hellovulkanwindow.cpp b/examples/vulkan/hellovulkanwindow/hellovulkanwindow.cpp index 0a7d1d4174..31d32307a9 100644 --- a/examples/vulkan/hellovulkanwindow/hellovulkanwindow.cpp +++ b/examples/vulkan/hellovulkanwindow/hellovulkanwindow.cpp @@ -94,7 +94,7 @@ void VulkanRenderer::startNextFrame() if (m_green > 1.0f) m_green = 0.0f; - VkClearColorValue clearColor = { 0.0f, m_green, 0.0f, 1.0f }; + VkClearColorValue clearColor = {{ 0.0f, m_green, 0.0f, 1.0f }}; VkClearDepthStencilValue clearDS = { 1.0f, 0 }; VkClearValue clearValues[2]; memset(clearValues, 0, sizeof(clearValues)); diff --git a/examples/vulkan/shared/trianglerenderer.cpp b/examples/vulkan/shared/trianglerenderer.cpp index f346f90c89..6ed7e65ff9 100644 --- a/examples/vulkan/shared/trianglerenderer.cpp +++ b/examples/vulkan/shared/trianglerenderer.cpp @@ -452,7 +452,7 @@ void TriangleRenderer::startNextFrame() VkCommandBuffer cb = m_window->currentCommandBuffer(); const QSize sz = m_window->swapChainImageSize(); - VkClearColorValue clearColor = { 0, 0, 0, 1 }; + VkClearColorValue clearColor = {{ 0, 0, 0, 1 }}; VkClearDepthStencilValue clearDS = { 1, 0 }; VkClearValue clearValues[3]; memset(clearValues, 0, sizeof(clearValues)); From 51e14787d5c31a6397dbc43a134397f9bec8c6b3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A5rten=20Nordheim?= Date: Thu, 14 Dec 2017 11:49:19 +0100 Subject: [PATCH 16/23] Stop rejecting cookies which have a domain that matches a TLD ... but only if the host it came from is an EXACT match. Also only apply the cookie if the url is an EXACT match. [ChangeLog][QtNetwork][QNetworkCookieJar] Cookies will no longer be rejected when the domain matches a TLD. However (to avoid problems with TLDs), such cookies are only accepted, or sent, when the host name matches exactly. Task-number: QTBUG-52040 Change-Id: Ic2ebd9211c48891beb669032591234b57713c31d Reviewed-by: Edward Welbourne --- src/network/access/qnetworkcookiejar.cpp | 16 +++++++++ .../tst_qnetworkcookiejar.cpp | 33 ++++++++++++++++++- 2 files changed, 48 insertions(+), 1 deletion(-) diff --git a/src/network/access/qnetworkcookiejar.cpp b/src/network/access/qnetworkcookiejar.cpp index f62a03b11d..2ec4acf26c 100644 --- a/src/network/access/qnetworkcookiejar.cpp +++ b/src/network/access/qnetworkcookiejar.cpp @@ -241,6 +241,17 @@ QList QNetworkCookieJar::cookiesForUrl(const QUrl &url) const if ((*it).isSecure() && !isEncrypted) continue; + QString domain = it->domain(); + if (domain.startsWith(QLatin1Char('.'))) /// Qt6?: remove when compliant with RFC6265 + domain = domain.mid(1); +#if QT_CONFIG(topleveldomain) + if (qIsEffectiveTLD(domain) && url.host() != domain) + continue; +#else + if (!domain.contains(QLatin1Char('.')) && url.host() != domain) + continue; +#endif // topleveldomain + // insert this cookie into result, sorted by path QList::Iterator insertIt = result.begin(); while (insertIt != result.end()) { @@ -340,6 +351,11 @@ bool QNetworkCookieJar::validateCookie(const QNetworkCookie &cookie, const QUrl if (domain.startsWith(QLatin1Char('.'))) domain = domain.mid(1); + // We shouldn't reject if: + // "[...] the domain-attribute is identical to the canonicalized request-host" + // https://tools.ietf.org/html/rfc6265#section-5.3 step 5 + if (host == domain) + return true; #if QT_CONFIG(topleveldomain) // the check for effective TLDs makes the "embedded dot" rule from RFC 2109 section 4.3.2 // redundant; the "leading dot" rule has been relaxed anyway, see QNetworkCookie::normalize() diff --git a/tests/auto/network/access/qnetworkcookiejar/tst_qnetworkcookiejar.cpp b/tests/auto/network/access/qnetworkcookiejar/tst_qnetworkcookiejar.cpp index ed5d0c69a0..8b49679042 100644 --- a/tests/auto/network/access/qnetworkcookiejar/tst_qnetworkcookiejar.cpp +++ b/tests/auto/network/access/qnetworkcookiejar/tst_qnetworkcookiejar.cpp @@ -164,7 +164,9 @@ void tst_QNetworkCookieJar::setCookiesFromUrl_data() result.clear(); preset.clear(); cookie.setDomain(".foo.ck"); - QTest::newRow("effective-tld2-denied") << preset << cookie << "http://foo.ck" << result << false; + result += cookie; + QTest::newRow("effective-tld2-accepted2") << preset << cookie << "http://foo.ck" << result << true; + result.clear(); QTest::newRow("effective-tld2-denied2") << preset << cookie << "http://www.foo.ck" << result << false; QTest::newRow("effective-tld2-denied3") << preset << cookie << "http://www.anything.foo.ck" << result << false; cookie.setDomain(".www.ck"); @@ -208,6 +210,22 @@ void tst_QNetworkCookieJar::setCookiesFromUrl_data() preset.clear(); cookie.setDomain(".com."); QTest::newRow("rfc2109-4.3.2-ex3-2") << preset << cookie << "http://x.foo.com" << result << false; + + // When using a TLD as a hostname the hostname should still get cookies (QTBUG-52040) + // ... and nothing else should get the cookies. + result.clear(); + preset.clear(); + cookie.setPath("/"); + cookie.setDomain(".support"); + result += cookie; + QTest::newRow("TLD-as-domain-accepted") << preset << cookie << "http://support" << result << true; + result.clear(); + QTest::newRow("TLD-as-domain-rejected") << preset << cookie << "http://a.support" << result << false; + // Now test with no domain in the cookie, use the domain from the url (matching TLD) + cookie.setDomain("support"); + result += cookie; + cookie.setDomain(""); + QTest::newRow("TLD-as-domain-accepted2") << preset << cookie << "http://support" << result << true; } void tst_QNetworkCookieJar::setCookiesFromUrl() @@ -351,6 +369,19 @@ void tst_QNetworkCookieJar::cookiesForUrl_data() result.clear(); result += rootCookie; QTest::newRow("root-path-match") << allCookies << "http://qt-project.org" << result; + + // Domain in cookie happens to match a TLD + allCookies.clear(); + QNetworkCookie tldCookie; + tldCookie.setDomain(".support"); + tldCookie.setName("a"); + tldCookie.setValue("b"); + allCookies += tldCookie; + result.clear(); + result += tldCookie; + QTest::newRow("tld-cookie-match") << allCookies << "http://support/" << result; + result.clear(); + QTest::newRow("tld-cookie-no-match") << allCookies << "http://a.support/" << result; } void tst_QNetworkCookieJar::cookiesForUrl() From dbc0a5ba70558ecab51debb2a3f4f4c6fc2e4153 Mon Sep 17 00:00:00 2001 From: Sergio Martins Date: Fri, 27 Apr 2018 10:36:29 +0100 Subject: [PATCH 17/23] Remove assert from QFormLayout::takeRow() Having rows without fields is a supported use case so it shouldn't assert. Code works quite well in release mode, but crashes in debug mode. Change-Id: I1c4f736318489bae09780fcdb56136181afcac17 Reviewed-by: Samuel Gaist Reviewed-by: Friedemann Kleint --- src/widgets/kernel/qformlayout.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/widgets/kernel/qformlayout.cpp b/src/widgets/kernel/qformlayout.cpp index 8a5b863bb5..595ff3eb6e 100644 --- a/src/widgets/kernel/qformlayout.cpp +++ b/src/widgets/kernel/qformlayout.cpp @@ -1559,8 +1559,6 @@ QFormLayout::TakeRowResult QFormLayout::takeRow(int row) QFormLayoutItem *label = d->m_matrix(row, 0); QFormLayoutItem *field = d->m_matrix(row, 1); - Q_ASSERT(field); - d->m_things.removeOne(label); d->m_things.removeOne(field); d->m_matrix.removeRow(row); From 578c96f0bbe281f710248f0015ec133fa0083b48 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Mon, 23 Apr 2018 10:55:33 +0200 Subject: [PATCH 18/23] Polish the manual touch test Introduce C++11, nullptr, for, port to Qt 5 connection syntax. Change-Id: I2d233ccd68bad533af8d4674d91236b2c049e997 Reviewed-by: Andy Shaw --- tests/manual/touch/main.cpp | 30 ++++++++++++++++-------------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/tests/manual/touch/main.cpp b/tests/manual/touch/main.cpp index d3c6079c7d..9f2dcb3842 100644 --- a/tests/manual/touch/main.cpp +++ b/tests/manual/touch/main.cpp @@ -47,8 +47,8 @@ #include #include -bool optIgnoreTouch = false; -QVector optGestures; +static bool optIgnoreTouch = false; +static QVector optGestures; static inline void drawEllipse(const QPointF ¢er, qreal hDiameter, qreal vDiameter, const QColor &color, QPainter &painter) { @@ -275,10 +275,10 @@ class TouchTestWidget : public QWidget { Q_OBJECT Q_PROPERTY(bool drawPoints READ drawPoints WRITE setDrawPoints) public: - explicit TouchTestWidget(QWidget *parent = 0) : QWidget(parent), m_drawPoints(true) + explicit TouchTestWidget(QWidget *parent = nullptr) : QWidget(parent), m_drawPoints(true) { setAttribute(Qt::WA_AcceptTouchEvents); - foreach (Qt::GestureType t, optGestures) + for (Qt::GestureType t : optGestures) grabGesture(t); } @@ -337,10 +337,11 @@ bool TouchTestWidget::event(QEvent *event) case QEvent::TouchBegin: case QEvent::TouchUpdate: if (m_drawPoints) { - foreach (const QTouchEvent::TouchPoint &p, static_cast(event)->touchPoints()) + for (const QTouchEvent::TouchPoint &p : static_cast(event)->touchPoints()) m_points.append(Point(p.pos(), TouchPoint, Qt::MouseEventNotSynthesized, p.ellipseDiameters())); update(); } + Q_FALLTHROUGH(); case QEvent::TouchEnd: if (optIgnoreTouch) event->ignore(); @@ -358,7 +359,8 @@ bool TouchTestWidget::event(QEvent *event) void TouchTestWidget::handleGestureEvent(QGestureEvent *gestureEvent) { - foreach (QGesture *gesture, gestureEvent->gestures()) { + const auto gestures = gestureEvent->gestures(); + for (QGesture *gesture : gestures) { if (optGestures.contains(gesture->gestureType())) { switch (gesture->state()) { case Qt::NoGesture: @@ -389,7 +391,7 @@ void TouchTestWidget::paintEvent(QPaintEvent *) const QRectF geom = QRectF(QPointF(0, 0), QSizeF(size())); painter.fillRect(geom, Qt::white); painter.drawRect(QRectF(geom.topLeft(), geom.bottomRight() - QPointF(1, 1))); - foreach (const Point &point, m_points) { + for (const Point &point : qAsConst(m_points)) { if (geom.contains(point.pos)) { if (point.type == MouseRelease) drawEllipse(point.pos, point.horizontalDiameter, point.verticalDiameter, point.color(), painter); @@ -397,7 +399,7 @@ void TouchTestWidget::paintEvent(QPaintEvent *) fillEllipse(point.pos, point.horizontalDiameter, point.verticalDiameter, point.color(), painter); } } - foreach (const GesturePtr &gp, m_gestures) + for (const GesturePtr &gp : qAsConst(m_gestures)) gp->draw(geom, painter); } @@ -429,24 +431,24 @@ MainWindow::MainWindow() QMenu *fileMenu = menuBar()->addMenu("File"); QAction *dumpDeviceAction = fileMenu->addAction(QStringLiteral("Dump devices")); dumpDeviceAction->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_D)); - connect(dumpDeviceAction, SIGNAL(triggered()), this, SLOT(dumpTouchDevices())); + connect(dumpDeviceAction, &QAction::triggered, this, &MainWindow::dumpTouchDevices); toolBar->addAction(dumpDeviceAction); QAction *clearLogAction = fileMenu->addAction(QStringLiteral("Clear Log")); clearLogAction->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_L)); - connect(clearLogAction, SIGNAL(triggered()), m_logTextEdit, SLOT(clear())); + connect(clearLogAction, &QAction::triggered, m_logTextEdit, &QPlainTextEdit::clear); toolBar->addAction(clearLogAction); QAction *toggleDrawPointAction = fileMenu->addAction(QStringLiteral("Draw Points")); toggleDrawPointAction->setCheckable(true); toggleDrawPointAction->setChecked(m_touchWidget->drawPoints()); - connect(toggleDrawPointAction, SIGNAL(toggled(bool)), m_touchWidget, SLOT(setDrawPoints(bool))); + connect(toggleDrawPointAction, &QAction::toggled, m_touchWidget, &TouchTestWidget::setDrawPoints); toolBar->addAction(toggleDrawPointAction); QAction *clearPointAction = fileMenu->addAction(QStringLiteral("Clear Points")); clearPointAction->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_P)); - connect(clearPointAction, SIGNAL(triggered()), m_touchWidget, SLOT(clearPoints())); + connect(clearPointAction, &QAction::triggered, m_touchWidget, &TouchTestWidget::clearPoints); toolBar->addAction(clearPointAction); QAction *quitAction = fileMenu->addAction(QStringLiteral("Quit")); quitAction->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_Q)); - connect(quitAction, SIGNAL(triggered()), this, SLOT(close())); + connect(quitAction, &QAction::triggered, qApp, &QCoreApplication::quit); toolBar->addAction(quitAction); QSplitter *mainSplitter = new QSplitter(Qt::Vertical, this); @@ -541,7 +543,7 @@ int main(int argc, char *argv[]) : static_cast(w.touchWidget()); EventFilter *filter = new EventFilter(eventTypes, filterTarget); filterTarget->installEventFilter(filter); - QObject::connect(filter, SIGNAL(eventReceived(QString)), &w, SLOT(appendToLog(QString))); + QObject::connect(filter, &EventFilter::eventReceived, &w, &MainWindow::appendToLog); return a.exec(); } From d6b9cba812ffc6c191edcc9d578067b374b169af Mon Sep 17 00:00:00 2001 From: Daniel Teske Date: Thu, 13 Jul 2017 16:32:53 +0200 Subject: [PATCH 19/23] tst_QLineEdit: Use correct keys to move to Start/End of Line Home/End don't actually work on macOS. The "select all and delete" key was not actually testing anything at all. Change-Id: I44d3e9dd27da418afd699bf8720d5369325d20df Reviewed-by: Friedemann Kleint Reviewed-by: Andy Shaw --- .../widgets/qlineedit/tst_qlineedit.cpp | 24 +++++++++++++------ 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/tests/auto/widgets/widgets/qlineedit/tst_qlineedit.cpp b/tests/auto/widgets/widgets/qlineedit/tst_qlineedit.cpp index 23e52a8bf9..17462a5f86 100644 --- a/tests/auto/widgets/widgets/qlineedit/tst_qlineedit.cpp +++ b/tests/auto/widgets/widgets/qlineedit/tst_qlineedit.cpp @@ -319,6 +319,7 @@ private: void psKeyClick(QWidget *target, Qt::Key key, Qt::KeyboardModifiers pressState = 0); void psKeyClick(QTestEventList &keys, Qt::Key key, Qt::KeyboardModifiers pressState = 0); bool unselectingWithLeftOrRightChangesCursorPosition(); + void addKeySequenceStandardKey(QTestEventList &keys, QKeySequence::StandardKey); QLineEdit *ensureTestWidget(); bool validInput; @@ -724,7 +725,7 @@ void tst_QLineEdit::keypress_inputMask_data() { QTestEventList keys; // inserting 'A1.2B' - keys.addKeyClick(Qt::Key_Home); + addKeySequenceStandardKey(keys, QKeySequence::MoveToStartOfLine); keys.addKeyClick(Qt::Key_A); keys.addKeyClick(Qt::Key_1); keys.addKeyClick(Qt::Key_Period); @@ -735,7 +736,7 @@ void tst_QLineEdit::keypress_inputMask_data() { QTestEventList keys; // inserting 'A1.2B' - keys.addKeyClick(Qt::Key_Home); + addKeySequenceStandardKey(keys, QKeySequence::MoveToStartOfLine); keys.addKeyClick(Qt::Key_0); keys.addKeyClick(Qt::Key_Exclam); keys.addKeyClick('P'); @@ -745,22 +746,24 @@ void tst_QLineEdit::keypress_inputMask_data() { QTestEventList keys; // pressing delete - keys.addKeyClick(Qt::Key_Home); + addKeySequenceStandardKey(keys, QKeySequence::MoveToStartOfLine); keys.addKeyClick(Qt::Key_Delete); QTest::newRow("delete") << QString("000.000;_") << keys << QString(".") << QString("___.___"); } { QTestEventList keys; // selecting all and delete - keys.addKeyClick(Qt::Key_Home); - keys.addKeyClick(Qt::Key_End, Qt::ShiftModifier); + keys.addKeyClick(Qt::Key_1); + keys.addKeyClick(Qt::Key_2); + addKeySequenceStandardKey(keys, QKeySequence::MoveToStartOfLine); + addKeySequenceStandardKey(keys, QKeySequence::SelectEndOfLine); keys.addKeyClick(Qt::Key_Delete); QTest::newRow("deleting all") << QString("000.000;_") << keys << QString(".") << QString("___.___"); } { QTestEventList keys; // inserting '12.12' then two backspaces - keys.addKeyClick(Qt::Key_Home); + addKeySequenceStandardKey(keys, QKeySequence::MoveToStartOfLine); keys.addKeyClick(Qt::Key_1); keys.addKeyClick(Qt::Key_2); keys.addKeyClick(Qt::Key_Period); @@ -773,7 +776,7 @@ void tst_QLineEdit::keypress_inputMask_data() { QTestEventList keys; // inserting '12ab' - keys.addKeyClick(Qt::Key_Home); + addKeySequenceStandardKey(keys, QKeySequence::MoveToStartOfLine); keys.addKeyClick(Qt::Key_1); keys.addKeyClick(Qt::Key_2); keys.addKeyClick(Qt::Key_A); @@ -1971,6 +1974,13 @@ void tst_QLineEdit::psKeyClick(QTestEventList &keys, Qt::Key key, Qt::KeyboardMo keys.addKeyClick(key, pressState); } +void tst_QLineEdit::addKeySequenceStandardKey(QTestEventList &keys, QKeySequence::StandardKey key) +{ + QKeySequence keyseq = QKeySequence(key); + for (int i = 0; i < keyseq.count(); ++i) + keys.addKeyClick( Qt::Key( keyseq[i] & ~Qt::KeyboardModifierMask), Qt::KeyboardModifier(keyseq[i] & Qt::KeyboardModifierMask) ); +} + void tst_QLineEdit::cursorPosition() { QLineEdit *testWidget = ensureTestWidget(); From edf6debbabe997dee9e636a831ccff73d184b6c1 Mon Sep 17 00:00:00 2001 From: Daniel Teske Date: Fri, 3 Nov 2017 13:24:18 +0100 Subject: [PATCH 20/23] QitemSelectionModel: Fix a bug in isColumnSelected Previously the code for isColumnSelected and isRowSelected differed slightly, in how unselectable indexes would be treated. This made isColumnSelected return false for a column, which mixed unselectable indexes and selected indexes. Thus in some situations, the user could not deselect a column via a QTableView header. By copying the isRowSelected code to isColumnSelected, rows and columns behave identical. Task-number: QTBUG-18001 Change-Id: I6ca85ac64b31a481fafeaa3bec958b18283eed8d Reviewed-by: Richard Moe Gustavsen --- src/corelib/itemmodels/qitemselectionmodel.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/corelib/itemmodels/qitemselectionmodel.cpp b/src/corelib/itemmodels/qitemselectionmodel.cpp index 9af4fd9133..ceec0e4c94 100644 --- a/src/corelib/itemmodels/qitemselectionmodel.cpp +++ b/src/corelib/itemmodels/qitemselectionmodel.cpp @@ -1577,8 +1577,12 @@ bool QItemSelectionModel::isColumnSelected(int column, const QModelIndex &parent for (int row = 0; row < rowCount; ++row) { for (it = joined.constBegin(); it != joined.constEnd(); ++it) { if ((*it).contains(row, column, parent)) { - Qt::ItemFlags flags = d->model->index(row, column, parent).flags(); - if ((flags & Qt::ItemIsSelectable) && (flags & Qt::ItemIsEnabled)) { + bool selectable = false; + for (int i = row; !selectable && i <= (*it).bottom(); ++i) { + Qt::ItemFlags flags = d->model->index(i, column, parent).flags(); + selectable = flags & Qt::ItemIsSelectable; + } + if (selectable){ row = qMax(row, (*it).bottom()); break; } From 259648f876b2092f7d28925ba4569ac8a5612ca8 Mon Sep 17 00:00:00 2001 From: Daniel Teske Date: Mon, 6 Nov 2017 14:44:42 +0100 Subject: [PATCH 21/23] QItemSelectionModel: More fixes for is(Column/Row)Selected Replace the code for isRowSelected and isColumnSelected with a much simpler algorithm for deciding if a row/column is selected. In a model with a cross-hatch of unselectable indexes, the return values of is(Column/Row)Selected would depend on the order in which the selections were done. Task-number: QTBUG-18001 Change-Id: I6aa4b1df7c07fae469a686041927fa8c42bc9b16 Reviewed-by: Oswald Buddenhagen Reviewed-by: Richard Moe Gustavsen --- .../itemmodels/qitemselectionmodel.cpp | 73 ++++++++------ .../tst_qitemselectionmodel.cpp | 96 +++++++++++++++++++ 2 files changed, 142 insertions(+), 27 deletions(-) diff --git a/src/corelib/itemmodels/qitemselectionmodel.cpp b/src/corelib/itemmodels/qitemselectionmodel.cpp index ceec0e4c94..edb9bb9098 100644 --- a/src/corelib/itemmodels/qitemselectionmodel.cpp +++ b/src/corelib/itemmodels/qitemselectionmodel.cpp @@ -1502,30 +1502,40 @@ bool QItemSelectionModel::isRowSelected(int row, const QModelIndex &parent) cons && d->currentSelection.at(i).intersected(d->ranges.at(j)).isValid()) return false; } + + auto isSelectable = [&](int row, int column) { + Qt::ItemFlags flags = d->model->index(row, column, parent).flags(); + return (flags & Qt::ItemIsSelectable); + }; + + const int colCount = d->model->columnCount(parent); + int unselectable = 0; // add ranges and currentSelection and check through them all QList::const_iterator it; QList joined = d->ranges; if (d->currentSelection.count()) joined += d->currentSelection; - int colCount = d->model->columnCount(parent); for (int column = 0; column < colCount; ++column) { + if (!isSelectable(row, column)) { + ++unselectable; + continue; + } + for (it = joined.constBegin(); it != joined.constEnd(); ++it) { if ((*it).contains(row, column, parent)) { - bool selectable = false; - for (int i = column; !selectable && i <= (*it).right(); ++i) { - Qt::ItemFlags flags = d->model->index(row, i, parent).flags(); - selectable = flags & Qt::ItemIsSelectable; - } - if (selectable){ - column = qMax(column, (*it).right()); - break; + for (int i = column; i <= (*it).right(); ++i) { + if (!isSelectable(row, i)) + ++unselectable; } + + column = qMax(column, (*it).right()); + break; } } if (it == joined.constEnd()) return false; } - return colCount > 0; // no columns means no selected items + return unselectable < colCount; } /*! @@ -1568,30 +1578,39 @@ bool QItemSelectionModel::isColumnSelected(int column, const QModelIndex &parent } } } + + auto isSelectable = [&](int row, int column) { + Qt::ItemFlags flags = d->model->index(row, column, parent).flags(); + return (flags & Qt::ItemIsSelectable); + }; + const int rowCount = d->model->rowCount(parent); + int unselectable = 0; + // add ranges and currentSelection and check through them all QList::const_iterator it; QList joined = d->ranges; if (d->currentSelection.count()) joined += d->currentSelection; - int rowCount = d->model->rowCount(parent); for (int row = 0; row < rowCount; ++row) { - for (it = joined.constBegin(); it != joined.constEnd(); ++it) { - if ((*it).contains(row, column, parent)) { - bool selectable = false; - for (int i = row; !selectable && i <= (*it).bottom(); ++i) { - Qt::ItemFlags flags = d->model->index(i, column, parent).flags(); - selectable = flags & Qt::ItemIsSelectable; - } - if (selectable){ - row = qMax(row, (*it).bottom()); - break; - } - } - } - if (it == joined.constEnd()) - return false; + if (!isSelectable(row, column)) { + ++unselectable; + continue; + } + for (it = joined.constBegin(); it != joined.constEnd(); ++it) { + if ((*it).contains(row, column, parent)) { + for (int i = row; i <= (*it).bottom(); ++i) { + if (!isSelectable(i, column)) { + ++unselectable; + } + } + row = qMax(row, (*it).bottom()); + break; + } + } + if (it == joined.constEnd()) + return false; } - return rowCount > 0; // no rows means no selected items + return unselectable < rowCount; } /*! diff --git a/tests/auto/corelib/itemmodels/qitemselectionmodel/tst_qitemselectionmodel.cpp b/tests/auto/corelib/itemmodels/qitemselectionmodel/tst_qitemselectionmodel.cpp index b05e3968ea..6fbaa28d69 100644 --- a/tests/auto/corelib/itemmodels/qitemselectionmodel/tst_qitemselectionmodel.cpp +++ b/tests/auto/corelib/itemmodels/qitemselectionmodel/tst_qitemselectionmodel.cpp @@ -95,6 +95,9 @@ private slots: void QTBUG58851_data(); void QTBUG58851(); + void QTBUG18001_data(); + void QTBUG18001(); + private: QAbstractItemModel *model; QItemSelectionModel *selection; @@ -2922,5 +2925,98 @@ void tst_QItemSelectionModel::QTBUG58851() } } +void tst_QItemSelectionModel::QTBUG18001_data() +{ + using IntPair = std::pair; + using IntPairList = QList; + using IntList = QList; + using BoolList = QList; + + QTest::addColumn("indexesToSelect"); + QTest::addColumn("selectionCommands"); + QTest::addColumn("expectedSelectedRows"); + QTest::addColumn("expectedSelectedColums"); + + int colSelect = QItemSelectionModel::Select | QItemSelectionModel::Columns; + int rowSelect = QItemSelectionModel::Select | QItemSelectionModel::Rows; + + QTest::newRow("Select column 1") + << IntPairList { {0, 1} } + << IntList{ colSelect } + << BoolList{ false, false, false, false, false } + << BoolList{ false, true, false, false, false }; + + QTest::newRow("Select row 1") + << IntPairList { {1, 0} } + << IntList{ rowSelect } + << BoolList{ false, true, false, false, false } + << BoolList{ false, false, false, false, false }; + + QTest::newRow("Select column 1+2, row 1+2") + << IntPairList { {0, 1}, {0, 2}, {1, 0}, {2, 0} } + << IntList{ colSelect, colSelect, rowSelect, rowSelect } + << BoolList{ false, true, true, false, false } + << BoolList{ false, true, true, false, false }; + + QTest::newRow("Select row 1+2, col 1+2") + << IntPairList { {1, 0}, {2, 0}, {0, 1}, {0, 2} } + << IntList{ rowSelect, rowSelect, colSelect, colSelect } + << BoolList{ false, true, true, false, false } + << BoolList{ false, true, true, false, false }; +} + +void tst_QItemSelectionModel::QTBUG18001() +{ + using IntPair = std::pair; + using IntPairList = QList; + using IntList = QList; + using BoolList = QList; + + QFETCH(IntPairList, indexesToSelect); + QFETCH(IntList, selectionCommands); + QFETCH(BoolList, expectedSelectedRows); + QFETCH(BoolList, expectedSelectedColums); + + QStandardItemModel model(5, 5); + for (int row = 0; row < model.rowCount(); ++row) { + for (int column = 0; column < model.columnCount(); ++column) { + QStandardItem *item = new QStandardItem(QString("%0x%1").arg(row).arg(column)); + model.setItem(row, column, item); + + const bool oddRow = row % 2; + const bool oddCol = column % 2; + + if (oddRow == oddCol) + item->setSelectable(false); + } + } + + QItemSelectionModel selectionModel(&model); + + for (int i = 0; i < indexesToSelect.count(); ++i) { + QModelIndex idx = model.index( indexesToSelect.at(i).first, indexesToSelect.at(i).second ); + selectionModel.select(idx, QItemSelectionModel::SelectionFlag(selectionCommands.at(i))); + } + + for (int i = 0; i < expectedSelectedRows.count(); ++i) { + const bool expected = expectedSelectedRows.at(i); + const bool actual = selectionModel.isRowSelected(i, QModelIndex()); + QByteArray description = QByteArray("Row ") + QByteArray::number(i) + + " Expected " + QByteArray::number(expected) + + " Actual " + QByteArray::number(actual); + QVERIFY2(expected == actual, description.data()); + } + + for (int i = 0; i < expectedSelectedColums.count(); ++i) { + const bool expected = expectedSelectedColums.at(i); + const bool actual = selectionModel.isColumnSelected(i, QModelIndex()); + QByteArray description = QByteArray("Col ") + QByteArray::number(i) + + " Expected " + QByteArray::number(expected) + + " Actual " + QByteArray::number(actual); + QVERIFY2(expected == actual, description.data()); + } + +} + QTEST_MAIN(tst_QItemSelectionModel) #include "tst_qitemselectionmodel.moc" From 3761d99512244ae167a66e6894c75eb2ef1cca48 Mon Sep 17 00:00:00 2001 From: Kari Oikarinen Date: Wed, 2 May 2018 11:24:31 +0300 Subject: [PATCH 22/23] tst_QTabWidget: Add unconditional qWait() back paintEventCount() is currently flaky on macOS. It gets extra paint events after qWaitForWindowExposed() returns, which causes the following assertions to fail. Add the wait that was removed in 0cb940b1d3b9a1ba50f2d1973fca411706da266d back to fix those failures. Task-number: QTBUG-68032 Change-Id: I68e0b6008de40922ec740291dfdd1842e0f62f89 Reviewed-by: Sami Nurmenniemi Reviewed-by: Richard Moe Gustavsen Reviewed-by: Ville Voutilainen --- tests/auto/widgets/widgets/qtabwidget/tst_qtabwidget.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tests/auto/widgets/widgets/qtabwidget/tst_qtabwidget.cpp b/tests/auto/widgets/widgets/qtabwidget/tst_qtabwidget.cpp index cd7fe3710d..cbf5196bb9 100644 --- a/tests/auto/widgets/widgets/qtabwidget/tst_qtabwidget.cpp +++ b/tests/auto/widgets/widgets/qtabwidget/tst_qtabwidget.cpp @@ -549,7 +549,9 @@ void tst_QTabWidget::paintEventCount() QCOMPARE(tw->currentIndex(), 0); tw->show(); - QVERIFY(QTest::qWaitForWindowActive(tw)); + QVERIFY(QTest::qWaitForWindowExposed(tw)); + // Wait for extra paint events that happen at least on macOS + QTest::qWait(1000); // Mac, Windows and Windows CE get multiple repaints on the first show, so use those as a starting point. static const int MaxInitialPaintCount = From 364bd6ca74b059ffe8ae367e1562645a3ed0855e Mon Sep 17 00:00:00 2001 From: Stephan Binner Date: Sun, 27 Aug 2017 19:07:31 +0200 Subject: [PATCH 23/23] Convert features.toolbar to QT_[REQUIRE_]CONFIG Move declaration of pick/perp helpers up the dependency chain Change-Id: I7084ed829a057a0c45d60445c416fb07f2cb5624 Reviewed-by: Paul Olav Tvete Reviewed-by: Oswald Buddenhagen --- src/plugins/styles/mac/qmacstyle_mac_p_p.h | 2 + .../windowsvista/qwindowsvistastyle_p_p.h | 2 + .../styles/windowsvista/qwindowsxpstyle.cpp | 6 +- src/widgets/kernel/qlayout.cpp | 2 + src/widgets/kernel/qlayoutitem.cpp | 2 + src/widgets/statemachine/qguistatemachine.cpp | 4 +- src/widgets/styles/qcommonstyle.cpp | 22 +++--- src/widgets/styles/qstyleoption.cpp | 2 +- src/widgets/styles/qstyleoption.h | 4 +- src/widgets/styles/qstylesheetstyle.cpp | 14 ++-- src/widgets/styles/qwindowsstyle.cpp | 8 +- src/widgets/widgets/qdockarealayout.cpp | 1 + src/widgets/widgets/qmainwindow.cpp | 18 +++-- src/widgets/widgets/qmainwindow.h | 6 +- src/widgets/widgets/qmainwindowlayout.cpp | 77 ++++++++++--------- src/widgets/widgets/qmainwindowlayout_p.h | 6 +- src/widgets/widgets/qmenu_p.h | 27 +++++++ src/widgets/widgets/qmenubar.cpp | 2 + src/widgets/widgets/qpushbutton.cpp | 4 +- src/widgets/widgets/qtoolbar.cpp | 4 - src/widgets/widgets/qtoolbar.h | 7 +- src/widgets/widgets/qtoolbar_p.h | 6 +- src/widgets/widgets/qtoolbararealayout.cpp | 4 - src/widgets/widgets/qtoolbararealayout_p.h | 35 +-------- src/widgets/widgets/qtoolbarlayout.cpp | 4 - src/widgets/widgets/qtoolbarlayout_p.h | 6 +- src/widgets/widgets/qtoolbarseparator.cpp | 4 - src/widgets/widgets/qtoolbarseparator_p.h | 6 +- src/widgets/widgets/qtoolbutton.cpp | 12 +-- src/widgets/widgets/widgets.pri | 28 ++++--- 30 files changed, 168 insertions(+), 157 deletions(-) diff --git a/src/plugins/styles/mac/qmacstyle_mac_p_p.h b/src/plugins/styles/mac/qmacstyle_mac_p_p.h index 4eac0a59d6..8c712e838a 100644 --- a/src/plugins/styles/mac/qmacstyle_mac_p_p.h +++ b/src/plugins/styles/mac/qmacstyle_mac_p_p.h @@ -110,7 +110,9 @@ #include #include #include +#if QT_CONFIG(toolbar) #include +#endif #if QT_CONFIG(toolbutton) #include #endif diff --git a/src/plugins/styles/windowsvista/qwindowsvistastyle_p_p.h b/src/plugins/styles/windowsvista/qwindowsvistastyle_p_p.h index b649426811..d66b17e9f8 100644 --- a/src/plugins/styles/windowsvista/qwindowsvistastyle_p_p.h +++ b/src/plugins/styles/windowsvista/qwindowsvistastyle_p_p.h @@ -75,7 +75,9 @@ #if QT_CONFIG(spinbox) #include #endif +#if QT_CONFIG(toolbar) #include +#endif #if QT_CONFIG(combobox) #include #endif diff --git a/src/plugins/styles/windowsvista/qwindowsxpstyle.cpp b/src/plugins/styles/windowsvista/qwindowsxpstyle.cpp index 733b3a9e9c..9d2e770191 100644 --- a/src/plugins/styles/windowsvista/qwindowsxpstyle.cpp +++ b/src/plugins/styles/windowsvista/qwindowsxpstyle.cpp @@ -79,7 +79,9 @@ #if QT_CONFIG(pushbutton) #include #endif +#if QT_CONFIG(toolbar) #include +#endif #include #include #include @@ -3311,12 +3313,12 @@ int QWindowsXPStyle::pixelMetric(PixelMetric pm, const QStyleOption *option, con res = 160; break; -#ifndef QT_NO_TOOLBAR +#if QT_CONFIG(toolbar) case PM_ToolBarHandleExtent: res = int(QStyleHelper::dpiScaled(8.)); break; -#endif // QT_NO_TOOLBAR +#endif // QT_CONFIG(toolbar) case PM_DockWidgetSeparatorExtent: case PM_DockWidgetTitleMargin: res = int(QStyleHelper::dpiScaled(4.)); diff --git a/src/widgets/kernel/qlayout.cpp b/src/widgets/kernel/qlayout.cpp index f3db4f4e2d..9ce1c1c2d4 100644 --- a/src/widgets/kernel/qlayout.cpp +++ b/src/widgets/kernel/qlayout.cpp @@ -44,7 +44,9 @@ #if QT_CONFIG(menubar) #include "qmenubar.h" #endif +#if QT_CONFIG(toolbar) #include "qtoolbar.h" +#endif #if QT_CONFIG(sizegrip) #include "qsizegrip.h" #endif diff --git a/src/widgets/kernel/qlayoutitem.cpp b/src/widgets/kernel/qlayoutitem.cpp index 52640daf55..25890e888b 100644 --- a/src/widgets/kernel/qlayoutitem.cpp +++ b/src/widgets/kernel/qlayoutitem.cpp @@ -44,7 +44,9 @@ #if QT_CONFIG(menubar) #include "qmenubar.h" #endif +#if QT_CONFIG(toolbar) #include "qtoolbar.h" +#endif #include "qevent.h" #include "qstyle.h" #include "qvariant.h" diff --git a/src/widgets/statemachine/qguistatemachine.cpp b/src/widgets/statemachine/qguistatemachine.cpp index b452c63551..130260704f 100644 --- a/src/widgets/statemachine/qguistatemachine.cpp +++ b/src/widgets/statemachine/qguistatemachine.cpp @@ -251,10 +251,10 @@ static QEvent *cloneEvent(QEvent *e) return new QWhatsThisClickedEvent(*static_cast(e)); #endif // QT_CONFIG(whatsthis) -#ifndef QT_NO_TOOLBAR +#if QT_CONFIG(toolbar) case QEvent::ToolBarChange: return new QToolBarChangeEvent(*static_cast(e)); -#endif //QT_NO_TOOLBAR +#endif // QT_CONFIG(toolbar) case QEvent::ApplicationActivate: return new QEvent(*e); diff --git a/src/widgets/styles/qcommonstyle.cpp b/src/widgets/styles/qcommonstyle.cpp index 557277b9e0..7420bfb3f7 100644 --- a/src/widgets/styles/qcommonstyle.cpp +++ b/src/widgets/styles/qcommonstyle.cpp @@ -81,7 +81,9 @@ #if QT_CONFIG(tabwidget) #include #endif +#if QT_CONFIG(toolbar) #include +#endif #if QT_CONFIG(toolbutton) #include #endif @@ -276,7 +278,7 @@ void QCommonStyle::drawPrimitive(PrimitiveElement pe, const QStyleOption *opt, Q } } break; -#ifndef QT_NO_TOOLBAR +#if QT_CONFIG(toolbar) case PE_PanelMenuBar: if (widget && qobject_cast(widget->parentWidget())) break; @@ -295,7 +297,7 @@ void QCommonStyle::drawPrimitive(PrimitiveElement pe, const QStyleOption *opt, Q break; case PE_PanelToolBar: break; -#endif // QT_NO_TOOLBAR +#endif // QT_CONFIG(toolbar) #if QT_CONFIG(progressbar) case PE_IndicatorProgressChunk: { @@ -477,7 +479,7 @@ void QCommonStyle::drawPrimitive(PrimitiveElement pe, const QStyleOption *opt, Q } break; #endif // QT_CONFIG(dockwidget) -#ifndef QT_NO_TOOLBAR +#if QT_CONFIG(toolbar) case PE_IndicatorToolBarHandle: p->save(); p->translate(opt->rect.x(), opt->rect.y()); @@ -515,7 +517,7 @@ void QCommonStyle::drawPrimitive(PrimitiveElement pe, const QStyleOption *opt, Q qDrawShadeLine(p, p1, p2, opt->palette, 1, 1, 0); break; } -#endif // QT_NO_TOOLBAR +#endif // QT_CONFIG(toolbar) #if QT_CONFIG(spinbox) case PE_IndicatorSpinPlus: case PE_IndicatorSpinMinus: { @@ -2153,7 +2155,7 @@ void QCommonStyle::drawControl(ControlElement element, const QStyleOption *opt, } break; #endif // QT_CONFIG(combobox) -#ifndef QT_NO_TOOLBAR +#if QT_CONFIG(toolbar) case CE_ToolBar: if (const QStyleOptionToolBar *toolBar = qstyleoption_cast(opt)) { // Compatibility with styles that use PE_PanelToolBar @@ -2169,7 +2171,7 @@ void QCommonStyle::drawControl(ControlElement element, const QStyleOption *opt, &toolBar->palette.brush(QPalette::Button)); } break; -#endif // QT_NO_TOOLBAR +#endif // QT_CONFIG(toolbar) case CE_ColumnViewGrip: { // draw background gradients QLinearGradient g(0, 0, opt->rect.width(), 0); @@ -3072,7 +3074,7 @@ QRect QCommonStyle::subElementRect(SubElement sr, const QStyleOption *opt, } break; #endif // QT_CONFIG(itemviews) -#ifndef QT_NO_TOOLBAR +#if QT_CONFIG(toolbar) case SE_ToolBarHandle: if (const QStyleOptionToolBar *tbopt = qstyleoption_cast(opt)) { if (tbopt->features & QStyleOptionToolBar::Movable) { @@ -3090,7 +3092,7 @@ QRect QCommonStyle::subElementRect(SubElement sr, const QStyleOption *opt, } } break; -#endif //QT_NO_TOOLBAR +#endif // QT_CONFIG(toolbar) default: break; } @@ -4570,7 +4572,7 @@ int QCommonStyle::pixelMetric(PixelMetric m, const QStyleOption *opt, const QWid ret = 0; break; -#ifndef QT_NO_TOOLBAR +#if QT_CONFIG(toolbar) case PM_ToolBarFrameWidth: ret = 1; break; @@ -4594,7 +4596,7 @@ int QCommonStyle::pixelMetric(PixelMetric m, const QStyleOption *opt, const QWid case PM_ToolBarExtensionExtent: ret = int(QStyleHelper::dpiScaled(12.)); break; -#endif // QT_NO_TOOLBAR +#endif // QT_CONFIG(toolbar) #if QT_CONFIG(tabbar) case PM_TabBarTabOverlap: diff --git a/src/widgets/styles/qstyleoption.cpp b/src/widgets/styles/qstyleoption.cpp index 3666bce205..e7fa26e2d4 100644 --- a/src/widgets/styles/qstyleoption.cpp +++ b/src/widgets/styles/qstyleoption.cpp @@ -1040,7 +1040,7 @@ QStyleOptionButton::QStyleOptionButton(int version) */ -#ifndef QT_NO_TOOLBAR +#if QT_CONFIG(toolbar) /*! \class QStyleOptionToolBar \brief The QStyleOptionToolBar class is used to describe the diff --git a/src/widgets/styles/qstyleoption.h b/src/widgets/styles/qstyleoption.h index 2880917510..9fbaf34a86 100644 --- a/src/widgets/styles/qstyleoption.h +++ b/src/widgets/styles/qstyleoption.h @@ -296,7 +296,7 @@ typedef Q_DECL_DEPRECATED QStyleOptionTab QStyleOptionTabV3; #endif // QT_CONFIG(tabbar) -#ifndef QT_NO_TOOLBAR +#if QT_CONFIG(toolbar) class Q_WIDGETS_EXPORT QStyleOptionToolBar : public QStyleOption { @@ -321,7 +321,7 @@ protected: Q_DECLARE_OPERATORS_FOR_FLAGS(QStyleOptionToolBar::ToolBarFeatures) -#endif // QT_NO_TOOLBAR +#endif // QT_CONFIG(toolbar) class Q_WIDGETS_EXPORT QStyleOptionProgressBar : public QStyleOption { diff --git a/src/widgets/styles/qstylesheetstyle.cpp b/src/widgets/styles/qstylesheetstyle.cpp index cdeb6a5768..94509f621e 100644 --- a/src/widgets/styles/qstylesheetstyle.cpp +++ b/src/widgets/styles/qstylesheetstyle.cpp @@ -111,7 +111,9 @@ #include "qdrawutil.h" #include +#if QT_CONFIG(toolbar) #include +#endif QT_BEGIN_NAMESPACE @@ -1979,7 +1981,7 @@ QRenderRule QStyleSheetStyle::renderRule(const QObject *obj, const QStyleOption if (frm->features & QStyleOptionFrame::Flat) extraClass |= PseudoClass_Flat; } -#ifndef QT_NO_TOOLBAR +#if QT_CONFIG(toolbar) else if (const QStyleOptionToolBar *tb = qstyleoption_cast(opt)) { if (tb->toolBarArea == Qt::LeftToolBarArea) extraClass |= PseudoClass_Left; @@ -1999,7 +2001,7 @@ QRenderRule QStyleSheetStyle::renderRule(const QObject *obj, const QStyleOption else if (tb->positionWithinLine == QStyleOptionToolBar::OnlyOne) extraClass |= PseudoClass_OnlyOne; } -#endif // QT_NO_TOOLBAR +#endif // QT_CONFIG(toolbar) #if QT_CONFIG(toolbox) else if (const QStyleOptionToolBox *tb = qstyleoption_cast(opt)) { if (tb->position == QStyleOptionToolBox::OnlyOneTab) @@ -3594,13 +3596,13 @@ void QStyleSheetStyle::drawControl(ControlElement ce, const QStyleOption *opt, Q if (rule.hasBorder()) { rule.drawBorder(p, rule.borderRect(opt->rect)); } else { -#ifndef QT_NO_TOOLBAR +#if QT_CONFIG(toolbar) if (const QStyleOptionToolBar *tb = qstyleoption_cast(opt)) { QStyleOptionToolBar newTb(*tb); newTb.rect = rule.borderRect(opt->rect); baseStyle()->drawControl(ce, &newTb, p, w); } -#endif // QT_NO_TOOLBAR +#endif // QT_CONFIG(toolbar) } return; @@ -5923,12 +5925,12 @@ QRect QStyleSheetStyle::subElementRect(SubElement se, const QStyleOption *opt, c return positionRect(w, subRule, subRule2, pe, opt->rect, opt->direction); } -#ifndef QT_NO_TOOLBAR +#if QT_CONFIG(toolbar) case SE_ToolBarHandle: if (hasStyleRule(w, PseudoElement_ToolBarHandle)) return ParentStyle::subElementRect(se, opt, w); break; -#endif //QT_NO_TOOLBAR +#endif // QT_CONFIG(toolbar) // On mac we make pixel adjustments to layouts which are not // desireable when you have custom style sheets on them diff --git a/src/widgets/styles/qwindowsstyle.cpp b/src/widgets/styles/qwindowsstyle.cpp index 89011350ec..7c9d917784 100644 --- a/src/widgets/styles/qwindowsstyle.cpp +++ b/src/widgets/styles/qwindowsstyle.cpp @@ -661,7 +661,7 @@ void QWindowsStyle::drawPrimitive(PrimitiveElement pe, const QStyleOption *opt, bool doRestore = false; switch (pe) { -#ifndef QT_NO_TOOLBAR +#if QT_CONFIG(toolbar) case PE_IndicatorToolBarSeparator: { QRect rect = opt->rect; @@ -721,7 +721,7 @@ void QWindowsStyle::drawPrimitive(PrimitiveElement pe, const QStyleOption *opt, p->restore(); break; -#endif // QT_NO_TOOLBAR +#endif // QT_CONFIG(toolbar) case PE_FrameButtonTool: case PE_PanelButtonTool: { QPen oldPen = p->pen(); @@ -1572,7 +1572,7 @@ void QWindowsStyle::drawControl(ControlElement ce, const QStyleOption *opt, QPai p->fillRect(opt->rect, fill); } break; } -#ifndef QT_NO_TOOLBAR +#if QT_CONFIG(toolbar) case CE_ToolBar: if (const QStyleOptionToolBar *toolbar = qstyleoption_cast(opt)) { // Reserve the beveled appearance only for mainwindow toolbars @@ -1673,7 +1673,7 @@ void QWindowsStyle::drawControl(ControlElement ce, const QStyleOption *opt, QPai break; -#endif // QT_NO_TOOLBAR +#endif // QT_CONFIG(toolbar) case CE_ProgressBarContents: if (const QStyleOptionProgressBar *pb = qstyleoption_cast(opt)) { diff --git a/src/widgets/widgets/qdockarealayout.cpp b/src/widgets/widgets/qdockarealayout.cpp index 71726eaeee..75289e9d1f 100644 --- a/src/widgets/widgets/qdockarealayout.cpp +++ b/src/widgets/widgets/qdockarealayout.cpp @@ -53,6 +53,7 @@ #include "qmainwindow.h" #include "qwidgetanimator_p.h" #include "qmainwindowlayout_p.h" +#include "qmenu_p.h" #include "qdockwidget_p.h" #include diff --git a/src/widgets/widgets/qmainwindow.cpp b/src/widgets/widgets/qmainwindow.cpp index bf0a88e7fb..2014bdabf3 100644 --- a/src/widgets/widgets/qmainwindow.cpp +++ b/src/widgets/widgets/qmainwindow.cpp @@ -45,7 +45,9 @@ #if QT_CONFIG(dockwidget) #include "qdockwidget.h" #endif +#if QT_CONFIG(toolbar) #include "qtoolbar.h" +#endif #include #include @@ -61,7 +63,9 @@ #include #include +#if QT_CONFIG(toolbar) #include "qtoolbar_p.h" +#endif #include "qwidgetanimator_p.h" #ifdef Q_OS_OSX #include @@ -706,7 +710,7 @@ Qt::DockWidgetArea QMainWindow::corner(Qt::Corner corner) const { return d_func()->layout->corner(corner); } #endif -#ifndef QT_NO_TOOLBAR +#if QT_CONFIG(toolbar) static bool checkToolBarArea(Qt::ToolBarArea area, const char *where) { @@ -874,7 +878,7 @@ bool QMainWindow::toolBarBreak(QToolBar *toolbar) const return d_func()->layout->toolBarBreak(toolbar); } -#endif // QT_NO_TOOLBAR +#endif // QT_CONFIG(toolbar) #if QT_CONFIG(dockwidget) @@ -1312,7 +1316,7 @@ bool QMainWindow::event(QEvent *event) return true; switch (event->type()) { -#ifndef QT_NO_TOOLBAR +#if QT_CONFIG(toolbar) case QEvent::ToolBarChange: { d->layout->toggleToolBarsVisible(); return true; @@ -1344,7 +1348,7 @@ bool QMainWindow::event(QEvent *event) return QWidget::event(event); } -#ifndef QT_NO_TOOLBAR +#if QT_CONFIG(toolbar) /*! \property QMainWindow::unifiedTitleAndToolBarOnMac @@ -1389,7 +1393,7 @@ bool QMainWindow::unifiedTitleAndToolBarOnMac() const return false; } -#endif // QT_NO_TOOLBAR +#endif // QT_CONFIG(toolbar) /*! \internal @@ -1435,7 +1439,7 @@ void QMainWindow::contextMenuEvent(QContextMenuEvent *event) break; } #endif // QT_CONFIG(dockwidget) -#ifndef QT_NO_TOOLBAR +#if QT_CONFIG(toolbar) if (QToolBar *tb = qobject_cast(child)) { if (tb->parentWidget() != this) return; @@ -1506,7 +1510,7 @@ QMenu *QMainWindow::createPopupMenu() menu->addSeparator(); } #endif // QT_CONFIG(dockwidget) -#ifndef QT_NO_TOOLBAR +#if QT_CONFIG(toolbar) QList toolbars = findChildren(); if (toolbars.size()) { if (!menu) diff --git a/src/widgets/widgets/qmainwindow.h b/src/widgets/widgets/qmainwindow.h index 069683d4ac..8f2a192446 100644 --- a/src/widgets/widgets/qmainwindow.h +++ b/src/widgets/widgets/qmainwindow.h @@ -74,7 +74,7 @@ class Q_WIDGETS_EXPORT QMainWindow : public QWidget Q_PROPERTY(bool dockNestingEnabled READ isDockNestingEnabled WRITE setDockNestingEnabled) #endif // QT_CONFIG(dockwidget) Q_PROPERTY(DockOptions dockOptions READ dockOptions WRITE setDockOptions) -#ifndef QT_NO_TOOLBAR +#if QT_CONFIG(toolbar) Q_PROPERTY(bool unifiedTitleAndToolBarOnMac READ unifiedTitleAndToolBarOnMac WRITE setUnifiedTitleAndToolBarOnMac) #endif @@ -145,7 +145,7 @@ public: Qt::DockWidgetArea corner(Qt::Corner corner) const; #endif -#ifndef QT_NO_TOOLBAR +#if QT_CONFIG(toolbar) void addToolBarBreak(Qt::ToolBarArea area = Qt::TopToolBarArea); void insertToolBarBreak(QToolBar *before); @@ -190,7 +190,7 @@ public Q_SLOTS: void setAnimated(bool enabled); void setDockNestingEnabled(bool enabled); #endif -#ifndef QT_NO_TOOLBAR +#if QT_CONFIG(toolbar) void setUnifiedTitleAndToolBarOnMac(bool set); #endif diff --git a/src/widgets/widgets/qmainwindowlayout.cpp b/src/widgets/widgets/qmainwindowlayout.cpp index d4ce0ffa4c..43c22910f9 100644 --- a/src/widgets/widgets/qmainwindowlayout.cpp +++ b/src/widgets/widgets/qmainwindowlayout.cpp @@ -45,10 +45,12 @@ #include "qdockwidget.h" #include "qdockwidget_p.h" #endif +#if QT_CONFIG(toolbar) #include "qtoolbar_p.h" -#include "qmainwindow.h" #include "qtoolbar.h" #include "qtoolbarlayout_p.h" +#endif +#include "qmainwindow.h" #include "qwidgetanimator_p.h" #if QT_CONFIG(rubberband) #include "qrubberband.h" @@ -75,6 +77,7 @@ # include #endif +#include #include #include #include @@ -604,7 +607,7 @@ void QDockWidgetGroupWindow::apply() QMainWindowLayoutState::QMainWindowLayoutState(QMainWindow *win) : -#ifndef QT_NO_TOOLBAR +#if QT_CONFIG(toolbar) toolBarAreaLayout(win), #endif #if QT_CONFIG(dockwidget) @@ -629,9 +632,9 @@ QSize QMainWindowLayoutState::sizeHint() const result = centralWidgetItem->sizeHint(); #endif -#ifndef QT_NO_TOOLBAR +#if QT_CONFIG(toolbar) result = toolBarAreaLayout.sizeHint(result); -#endif // QT_NO_TOOLBAR +#endif // QT_CONFIG(toolbar) return result; } @@ -647,16 +650,16 @@ QSize QMainWindowLayoutState::minimumSize() const result = centralWidgetItem->minimumSize(); #endif -#ifndef QT_NO_TOOLBAR +#if QT_CONFIG(toolbar) result = toolBarAreaLayout.minimumSize(result); -#endif // QT_NO_TOOLBAR +#endif // QT_CONFIG(toolbar) return result; } void QMainWindowLayoutState::apply(bool animated) { -#ifndef QT_NO_TOOLBAR +#if QT_CONFIG(toolbar) toolBarAreaLayout.apply(animated); #endif @@ -675,12 +678,12 @@ void QMainWindowLayoutState::apply(bool animated) void QMainWindowLayoutState::fitLayout() { QRect r; -#ifdef QT_NO_TOOLBAR +#if !QT_CONFIG(toolbar) r = rect; #else toolBarAreaLayout.rect = rect; r = toolBarAreaLayout.fitLayout(); -#endif // QT_NO_TOOLBAR +#endif // QT_CONFIG(toolbar) #if QT_CONFIG(dockwidget) dockAreaLayout.rect = r; @@ -692,7 +695,7 @@ void QMainWindowLayoutState::fitLayout() void QMainWindowLayoutState::deleteAllLayoutItems() { -#ifndef QT_NO_TOOLBAR +#if QT_CONFIG(toolbar) toolBarAreaLayout.deleteAllLayoutItems(); #endif @@ -714,7 +717,7 @@ void QMainWindowLayoutState::deleteCentralWidgetItem() QLayoutItem *QMainWindowLayoutState::itemAt(int index, int *x) const { -#ifndef QT_NO_TOOLBAR +#if QT_CONFIG(toolbar) if (QLayoutItem *ret = toolBarAreaLayout.itemAt(x, index)) return ret; #endif @@ -732,7 +735,7 @@ QLayoutItem *QMainWindowLayoutState::itemAt(int index, int *x) const QLayoutItem *QMainWindowLayoutState::takeAt(int index, int *x) { -#ifndef QT_NO_TOOLBAR +#if QT_CONFIG(toolbar) if (QLayoutItem *ret = toolBarAreaLayout.takeAt(x, index)) return ret; #endif @@ -755,7 +758,7 @@ QList QMainWindowLayoutState::indexOf(QWidget *widget) const { QList result; -#ifndef QT_NO_TOOLBAR +#if QT_CONFIG(toolbar) // is it a toolbar? if (QToolBar *toolBar = qobject_cast(widget)) { result = toolBarAreaLayout.indexOf(toolBar); @@ -790,7 +793,7 @@ bool QMainWindowLayoutState::contains(QWidget *widget) const return true; #endif -#ifndef QT_NO_TOOLBAR +#if QT_CONFIG(toolbar) if (!toolBarAreaLayout.indexOf(widget).isEmpty()) return true; #endif @@ -833,7 +836,7 @@ QList QMainWindowLayoutState::gapIndex(QWidget *widget, { QList result; -#ifndef QT_NO_TOOLBAR +#if QT_CONFIG(toolbar) // is it a toolbar? if (qobject_cast(widget) != 0) { result = toolBarAreaLayout.gapIndex(pos); @@ -871,7 +874,7 @@ bool QMainWindowLayoutState::insertGap(const QList &path, QLayoutItem *item int i = path.first(); -#ifndef QT_NO_TOOLBAR +#if QT_CONFIG(toolbar) if (i == 0) { Q_ASSERT(qobject_cast(item->widget()) != 0); return toolBarAreaLayout.insertGap(path.mid(1), item); @@ -892,7 +895,7 @@ void QMainWindowLayoutState::remove(const QList &path) { int i = path.first(); -#ifndef QT_NO_TOOLBAR +#if QT_CONFIG(toolbar) if (i == 0) toolBarAreaLayout.remove(path.mid(1)); #endif @@ -905,7 +908,7 @@ void QMainWindowLayoutState::remove(const QList &path) void QMainWindowLayoutState::remove(QLayoutItem *item) { -#ifndef QT_NO_TOOLBAR +#if QT_CONFIG(toolbar) toolBarAreaLayout.remove(item); #endif @@ -921,7 +924,7 @@ void QMainWindowLayoutState::remove(QLayoutItem *item) void QMainWindowLayoutState::clear() { -#ifndef QT_NO_TOOLBAR +#if QT_CONFIG(toolbar) toolBarAreaLayout.clear(); #endif @@ -943,7 +946,7 @@ QLayoutItem *QMainWindowLayoutState::item(const QList &path) { int i = path.first(); -#ifndef QT_NO_TOOLBAR +#if QT_CONFIG(toolbar) if (i == 0) { const QToolBarAreaLayoutItem *tbItem = toolBarAreaLayout.item(path.mid(1)); Q_ASSERT(tbItem); @@ -963,7 +966,7 @@ QRect QMainWindowLayoutState::itemRect(const QList &path) const { int i = path.first(); -#ifndef QT_NO_TOOLBAR +#if QT_CONFIG(toolbar) if (i == 0) return toolBarAreaLayout.itemRect(path.mid(1)); #endif @@ -980,7 +983,7 @@ QRect QMainWindowLayoutState::gapRect(const QList &path) const { int i = path.first(); -#ifndef QT_NO_TOOLBAR +#if QT_CONFIG(toolbar) if (i == 0) return toolBarAreaLayout.itemRect(path.mid(1)); #endif @@ -997,7 +1000,7 @@ QLayoutItem *QMainWindowLayoutState::plug(const QList &path) { int i = path.first(); -#ifndef QT_NO_TOOLBAR +#if QT_CONFIG(toolbar) if (i == 0) return toolBarAreaLayout.plug(path.mid(1)); #endif @@ -1014,7 +1017,7 @@ QLayoutItem *QMainWindowLayoutState::unplug(const QList &path, QMainWindowL { int i = path.first(); -#ifdef QT_NO_TOOLBAR +#if !QT_CONFIG(toolbar) Q_UNUSED(other); #else if (i == 0) @@ -1045,7 +1048,7 @@ void QMainWindowLayoutState::saveState(QDataStream &stream) const } #endif #endif -#ifndef QT_NO_TOOLBAR +#if QT_CONFIG(toolbar) toolBarAreaLayout.saveState(stream); #endif } @@ -1092,7 +1095,7 @@ bool QMainWindowLayoutState::checkFormat(QDataStream &stream) stream >> marker; switch(marker) { -#ifndef QT_NO_TOOLBAR +#if QT_CONFIG(toolbar) case QToolBarAreaLayout::ToolBarStateMarker: case QToolBarAreaLayout::ToolBarStateMarkerEx: { @@ -1102,7 +1105,7 @@ bool QMainWindowLayoutState::checkFormat(QDataStream &stream) } } break; -#endif // QT_NO_TOOLBAR +#endif // QT_CONFIG(toolbar) #if QT_CONFIG(dockwidget) case QDockAreaLayout::DockWidgetStateMarker: @@ -1211,7 +1214,7 @@ bool QMainWindowLayoutState::restoreState(QDataStream &_stream, #endif // QT_CONFIG(tabwidget) #endif // QT_CONFIG(dockwidget) -#ifndef QT_NO_TOOLBAR +#if QT_CONFIG(toolbar) case QToolBarAreaLayout::ToolBarStateMarker: case QToolBarAreaLayout::ToolBarStateMarkerEx: { @@ -1232,7 +1235,7 @@ bool QMainWindowLayoutState::restoreState(QDataStream &_stream, } } break; -#endif //QT_NO_TOOLBAR +#endif // QT_CONFIG(toolbar) default: return false; }// switch @@ -1246,7 +1249,7 @@ bool QMainWindowLayoutState::restoreState(QDataStream &_stream, ** QMainWindowLayoutState - toolbars */ -#ifndef QT_NO_TOOLBAR +#if QT_CONFIG(toolbar) static inline void validateToolBarArea(Qt::ToolBarArea &area) { @@ -1421,7 +1424,7 @@ void QMainWindowLayout::toggleToolBarsVisible() } } -#endif // QT_NO_TOOLBAR +#endif // QT_CONFIG(toolbar) /****************************************************************************** ** QMainWindowLayoutState - dock areas @@ -1904,7 +1907,7 @@ QLayoutItem *QMainWindowLayout::takeAt(int index) layoutState.remove(ret); } -#ifndef QT_NO_TOOLBAR +#if QT_CONFIG(toolbar) if (!currentGapPos.isEmpty() && currentGapPos.constFirst() == 0) { currentGapPos = layoutState.toolBarAreaLayout.currentGapIndex(); if (!currentGapPos.isEmpty()) { @@ -2016,7 +2019,7 @@ void QMainWindowLayout::setCurrentHoveredFloat(QDockWidgetGroupWindow *w) static void fixToolBarOrientation(QLayoutItem *item, int dockPos) { -#ifndef QT_NO_TOOLBAR +#if QT_CONFIG(toolbar) QToolBar *toolBar = qobject_cast(item->widget()); if (toolBar == 0) return; @@ -2143,7 +2146,7 @@ void QMainWindowLayout::animationFinished(QWidget *widget) { //this function is called from within the Widget Animator whenever an animation is finished //on a certain widget -#ifndef QT_NO_TOOLBAR +#if QT_CONFIG(toolbar) if (QToolBar *tb = qobject_cast(widget)) { QToolBarLayout *tbl = qobject_cast(tb->layout()); if (tbl->animating) { @@ -2214,7 +2217,7 @@ void QMainWindowLayout::animationFinished(QWidget *widget) dw->d_func()->plug(currentGapRect); } #endif -#ifndef QT_NO_TOOLBAR +#if QT_CONFIG(toolbar) if (QToolBar *tb = qobject_cast(widget)) tb->d_func()->plug(currentGapRect); #endif @@ -2460,7 +2463,7 @@ QLayoutItem *QMainWindowLayout::unplug(QWidget *widget, bool group) } } #endif // QT_CONFIG(dockwidget) -#ifndef QT_NO_TOOLBAR +#if QT_CONFIG(toolbar) if (QToolBar *tb = qobject_cast(widget)) { tb->d_func()->unplug(r); } @@ -2606,7 +2609,7 @@ void QMainWindowLayout::hover(QLayoutItem *widgetItem, const QPoint &mousePos) if (qobject_cast(widget)) allowed = true; #endif -#ifndef QT_NO_TOOLBAR +#if QT_CONFIG(toolbar) if (QToolBar *tb = qobject_cast(widget)) allowed = tb->isAreaAllowed(toToolBarArea(path.at(1))); #endif diff --git a/src/widgets/widgets/qmainwindowlayout_p.h b/src/widgets/widgets/qmainwindowlayout_p.h index 53e045aaae..aa446cf05b 100644 --- a/src/widgets/widgets/qmainwindowlayout_p.h +++ b/src/widgets/widgets/qmainwindowlayout_p.h @@ -69,7 +69,9 @@ #if QT_CONFIG(dockwidget) #include "qdockarealayout_p.h" #endif +#if QT_CONFIG(toolbar) #include "qtoolbararealayout_p.h" +#endif QT_REQUIRE_CONFIG(mainwindow); @@ -385,7 +387,7 @@ public: QMainWindowLayoutState(QMainWindow *win); -#ifndef QT_NO_TOOLBAR +#if QT_CONFIG(toolbar) QToolBarAreaLayout toolBarAreaLayout; #endif @@ -462,7 +464,7 @@ public: // toolbars -#ifndef QT_NO_TOOLBAR +#if QT_CONFIG(toolbar) void addToolBarBreak(Qt::ToolBarArea area); void insertToolBarBreak(QToolBar *before); void removeToolBarBreak(QToolBar *before); diff --git a/src/widgets/widgets/qmenu_p.h b/src/widgets/widgets/qmenu_p.h index b6afb05e3a..721a35bf90 100644 --- a/src/widgets/widgets/qmenu_p.h +++ b/src/widgets/widgets/qmenu_p.h @@ -68,6 +68,33 @@ QT_REQUIRE_CONFIG(menu); QT_BEGIN_NAMESPACE +static inline int pick(Qt::Orientation o, const QPoint &pos) +{ return o == Qt::Horizontal ? pos.x() : pos.y(); } + +static inline int pick(Qt::Orientation o, const QSize &size) +{ return o == Qt::Horizontal ? size.width() : size.height(); } + +static inline int &rpick(Qt::Orientation o, QPoint &pos) +{ return o == Qt::Horizontal ? pos.rx() : pos.ry(); } + +static inline int &rpick(Qt::Orientation o, QSize &size) +{ return o == Qt::Horizontal ? size.rwidth() : size.rheight(); } + +static inline QSizePolicy::Policy pick(Qt::Orientation o, const QSizePolicy &policy) +{ return o == Qt::Horizontal ? policy.horizontalPolicy() : policy.verticalPolicy(); } + +static inline int perp(Qt::Orientation o, const QPoint &pos) +{ return o == Qt::Vertical ? pos.x() : pos.y(); } + +static inline int perp(Qt::Orientation o, const QSize &size) +{ return o == Qt::Vertical ? size.width() : size.height(); } + +static inline int &rperp(Qt::Orientation o, QPoint &pos) +{ return o == Qt::Vertical ? pos.rx() : pos.ry(); } + +static inline int &rperp(Qt::Orientation o, QSize &size) +{ return o == Qt::Vertical ? size.rwidth() : size.rheight(); } + class QTornOffMenu; class QEventLoop; diff --git a/src/widgets/widgets/qmenubar.cpp b/src/widgets/widgets/qmenubar.cpp index b0a75288e8..4758f64c8c 100644 --- a/src/widgets/widgets/qmenubar.cpp +++ b/src/widgets/widgets/qmenubar.cpp @@ -52,7 +52,9 @@ #if QT_CONFIG(mainwindow) #include #endif +#if QT_CONFIG(toolbar) #include +#endif #if QT_CONFIG(toolbutton) #include #endif diff --git a/src/widgets/widgets/qpushbutton.cpp b/src/widgets/widgets/qpushbutton.cpp index afb17f533b..8f7271c2dc 100644 --- a/src/widgets/widgets/qpushbutton.cpp +++ b/src/widgets/widgets/qpushbutton.cpp @@ -53,7 +53,9 @@ #include "qpushbutton.h" #include "qstyle.h" #include "qstyleoption.h" +#if QT_CONFIG(toolbar) #include "qtoolbar.h" +#endif #include "qdebug.h" #include "qlayoutitem.h" #if QT_CONFIG(dialogbuttonbox) @@ -596,7 +598,7 @@ QPoint QPushButtonPrivate::adjustedMenuPosition() Q_Q(QPushButton); bool horizontal = true; -#if !defined(QT_NO_TOOLBAR) +#if QT_CONFIG(toolbar) QToolBar *tb = qobject_cast(parent); if (tb && tb->orientation() == Qt::Vertical) horizontal = false; diff --git a/src/widgets/widgets/qtoolbar.cpp b/src/widgets/widgets/qtoolbar.cpp index 7b6a2a329f..4e90bce69d 100644 --- a/src/widgets/widgets/qtoolbar.cpp +++ b/src/widgets/widgets/qtoolbar.cpp @@ -39,8 +39,6 @@ #include "qtoolbar.h" -#ifndef QT_NO_TOOLBAR - #include #if QT_CONFIG(combobox) #include @@ -1288,5 +1286,3 @@ void QToolBar::initStyleOption(QStyleOptionToolBar *option) const QT_END_NAMESPACE #include "moc_qtoolbar.cpp" - -#endif // QT_NO_TOOLBAR diff --git a/src/widgets/widgets/qtoolbar.h b/src/widgets/widgets/qtoolbar.h index 0253541a2e..4ae83190d1 100644 --- a/src/widgets/widgets/qtoolbar.h +++ b/src/widgets/widgets/qtoolbar.h @@ -44,11 +44,10 @@ #include #include +QT_REQUIRE_CONFIG(toolbar); + QT_BEGIN_NAMESPACE - -#ifndef QT_NO_TOOLBAR - class QToolBarPrivate; class QAction; @@ -211,8 +210,6 @@ private: inline QAction *QToolBar::actionAt(int ax, int ay) const { return actionAt(QPoint(ax, ay)); } -#endif // QT_NO_TOOLBAR - QT_END_NAMESPACE #endif // QDYNAMICTOOLBAR_H diff --git a/src/widgets/widgets/qtoolbar_p.h b/src/widgets/widgets/qtoolbar_p.h index 616f53f717..4db75762c8 100644 --- a/src/widgets/widgets/qtoolbar_p.h +++ b/src/widgets/widgets/qtoolbar_p.h @@ -57,9 +57,9 @@ #include "private/qwidget_p.h" #include -QT_BEGIN_NAMESPACE +QT_REQUIRE_CONFIG(toolbar); -#ifndef QT_NO_TOOLBAR +QT_BEGIN_NAMESPACE class QToolBarLayout; class QTimer; @@ -127,8 +127,6 @@ public: QBasicTimer waitForPopupTimer; }; -#endif // QT_NO_TOOLBAR - QT_END_NAMESPACE #endif // QDYNAMICTOOLBAR_P_H diff --git a/src/widgets/widgets/qtoolbararealayout.cpp b/src/widgets/widgets/qtoolbararealayout.cpp index 0c57d9251d..edf497111b 100644 --- a/src/widgets/widgets/qtoolbararealayout.cpp +++ b/src/widgets/widgets/qtoolbararealayout.cpp @@ -53,8 +53,6 @@ ** QToolBarAreaLayoutItem */ -#ifndef QT_NO_TOOLBAR - QT_BEGIN_NAMESPACE // qmainwindow.cpp @@ -1391,5 +1389,3 @@ bool QToolBarAreaLayout::isEmpty() const } QT_END_NAMESPACE - -#endif // QT_NO_TOOLBAR diff --git a/src/widgets/widgets/qtoolbararealayout_p.h b/src/widgets/widgets/qtoolbararealayout_p.h index 901f04cf14..dffbab1f21 100644 --- a/src/widgets/widgets/qtoolbararealayout_p.h +++ b/src/widgets/widgets/qtoolbararealayout_p.h @@ -52,41 +52,15 @@ // #include +#include "qmenu_p.h" #include #include #include +QT_REQUIRE_CONFIG(toolbar); + QT_BEGIN_NAMESPACE -static inline int pick(Qt::Orientation o, const QPoint &pos) -{ return o == Qt::Horizontal ? pos.x() : pos.y(); } - -static inline int pick(Qt::Orientation o, const QSize &size) -{ return o == Qt::Horizontal ? size.width() : size.height(); } - -static inline int &rpick(Qt::Orientation o, QPoint &pos) -{ return o == Qt::Horizontal ? pos.rx() : pos.ry(); } - -static inline int &rpick(Qt::Orientation o, QSize &size) -{ return o == Qt::Horizontal ? size.rwidth() : size.rheight(); } - -static inline QSizePolicy::Policy pick(Qt::Orientation o, const QSizePolicy &policy) -{ return o == Qt::Horizontal ? policy.horizontalPolicy() : policy.verticalPolicy(); } - -static inline int perp(Qt::Orientation o, const QPoint &pos) -{ return o == Qt::Vertical ? pos.x() : pos.y(); } - -static inline int perp(Qt::Orientation o, const QSize &size) -{ return o == Qt::Vertical ? size.width() : size.height(); } - -static inline int &rperp(Qt::Orientation o, QPoint &pos) -{ return o == Qt::Vertical ? pos.rx() : pos.ry(); } - -static inline int &rperp(Qt::Orientation o, QSize &size) -{ return o == Qt::Vertical ? size.rwidth() : size.rheight(); } - -#ifndef QT_NO_TOOLBAR - class QToolBar; class QLayoutItem; class QMainWindow; @@ -244,7 +218,6 @@ public: bool isEmpty() const; }; - QT_END_NAMESPACE -#endif // QT_NO_TOOLBAR + #endif // QTOOLBARAREALAYOUT_P_H diff --git a/src/widgets/widgets/qtoolbarlayout.cpp b/src/widgets/widgets/qtoolbarlayout.cpp index 118cb2ae61..f2d329d59d 100644 --- a/src/widgets/widgets/qtoolbarlayout.cpp +++ b/src/widgets/widgets/qtoolbarlayout.cpp @@ -59,8 +59,6 @@ #include "qtoolbarlayout_p.h" #include "qtoolbarseparator_p.h" -#ifndef QT_NO_TOOLBAR - QT_BEGIN_NAMESPACE // qmainwindow.cpp @@ -753,5 +751,3 @@ QToolBarItem *QToolBarLayout::createItem(QAction *action) QT_END_NAMESPACE #include "moc_qtoolbarlayout_p.cpp" - -#endif // QT_NO_TOOLBAR diff --git a/src/widgets/widgets/qtoolbarlayout_p.h b/src/widgets/widgets/qtoolbarlayout_p.h index 8c60164439..b813cd5e2c 100644 --- a/src/widgets/widgets/qtoolbarlayout_p.h +++ b/src/widgets/widgets/qtoolbarlayout_p.h @@ -56,9 +56,9 @@ #include #include -QT_BEGIN_NAMESPACE +QT_REQUIRE_CONFIG(toolbar); -#ifndef QT_NO_TOOLBAR +QT_BEGIN_NAMESPACE class QAction; class QToolBarExtension; @@ -127,8 +127,6 @@ private: QMenu *popupMenu; }; -#endif // QT_NO_TOOLBAR - QT_END_NAMESPACE #endif // QTOOLBARLAYOUT_P_H diff --git a/src/widgets/widgets/qtoolbarseparator.cpp b/src/widgets/widgets/qtoolbarseparator.cpp index c99a8bcc4c..92cd08317a 100644 --- a/src/widgets/widgets/qtoolbarseparator.cpp +++ b/src/widgets/widgets/qtoolbarseparator.cpp @@ -39,8 +39,6 @@ #include "qtoolbarseparator_p.h" -#ifndef QT_NO_TOOLBAR - #include #include #include @@ -87,5 +85,3 @@ void QToolBarSeparator::paintEvent(QPaintEvent *) QT_END_NAMESPACE #include "moc_qtoolbarseparator_p.cpp" - -#endif // QT_NO_TOOLBAR diff --git a/src/widgets/widgets/qtoolbarseparator_p.h b/src/widgets/widgets/qtoolbarseparator_p.h index d52b4fa6ae..60b51a28cb 100644 --- a/src/widgets/widgets/qtoolbarseparator_p.h +++ b/src/widgets/widgets/qtoolbarseparator_p.h @@ -54,9 +54,9 @@ #include #include "QtWidgets/qwidget.h" -QT_BEGIN_NAMESPACE +QT_REQUIRE_CONFIG(toolbar); -#ifndef QT_NO_TOOLBAR +QT_BEGIN_NAMESPACE class QStyleOption; class QToolBar; @@ -80,8 +80,6 @@ public Q_SLOTS: void setOrientation(Qt::Orientation orientation); }; -#endif // QT_NO_TOOLBAR - QT_END_NAMESPACE #endif // QDYNAMICTOOLBARSEPARATOR_P_H diff --git a/src/widgets/widgets/qtoolbutton.cpp b/src/widgets/widgets/qtoolbutton.cpp index c2bf13a3e9..c94c10574f 100644 --- a/src/widgets/widgets/qtoolbutton.cpp +++ b/src/widgets/widgets/qtoolbutton.cpp @@ -53,7 +53,9 @@ #if QT_CONFIG(mainwindow) #include #endif +#if QT_CONFIG(toolbar) #include +#endif #include #include #include @@ -201,7 +203,7 @@ void QToolButtonPrivate::init() { Q_Q(QToolButton); defaultAction = 0; -#ifndef QT_NO_TOOLBAR +#if QT_CONFIG(toolbar) if (qobject_cast(parent)) autoRaise = true; else @@ -245,13 +247,13 @@ void QToolButton::initStyleOption(QStyleOptionToolButton *option) const bool forceNoText = false; option->iconSize = iconSize(); //default value -#ifndef QT_NO_TOOLBAR +#if QT_CONFIG(toolbar) if (parentWidget()) { if (QToolBar *toolBar = qobject_cast(parentWidget())) { option->iconSize = toolBar->iconSize(); } } -#endif // QT_NO_TOOLBAR +#endif // QT_CONFIG(toolbar) if (!forceNoText) option->text = d->text; @@ -571,7 +573,7 @@ void QToolButton::timerEvent(QTimerEvent *e) */ void QToolButton::changeEvent(QEvent *e) { -#ifndef QT_NO_TOOLBAR +#if QT_CONFIG(toolbar) Q_D(QToolButton); if (e->type() == QEvent::ParentChange) { if (qobject_cast(parentWidget())) @@ -743,7 +745,7 @@ void QToolButtonPrivate::popupTimerDone() repeat = q->autoRepeat(); q->setAutoRepeat(false); bool horizontal = true; -#if !defined(QT_NO_TOOLBAR) +#if QT_CONFIG(toolbar) QToolBar *tb = qobject_cast(parent); if (tb && tb->orientation() == Qt::Vertical) horizontal = false; diff --git a/src/widgets/widgets/widgets.pri b/src/widgets/widgets/widgets.pri index a197c41b95..55804c5aaf 100644 --- a/src/widgets/widgets/widgets.pri +++ b/src/widgets/widgets/widgets.pri @@ -3,25 +3,16 @@ HEADERS += \ widgets/qframe.h \ widgets/qframe_p.h \ - widgets/qtoolbar.h \ - widgets/qtoolbar_p.h \ - widgets/qtoolbarlayout_p.h \ - widgets/qtoolbarseparator_p.h \ widgets/qabstractscrollarea.h \ widgets/qabstractscrollarea_p.h \ widgets/qfocusframe.h \ - widgets/qwidgetanimator_p.h \ - widgets/qtoolbararealayout_p.h + widgets/qwidgetanimator_p.h SOURCES += \ widgets/qframe.cpp \ - widgets/qtoolbar.cpp \ - widgets/qtoolbarlayout.cpp \ - widgets/qtoolbarseparator.cpp \ widgets/qabstractscrollarea.cpp \ widgets/qfocusframe.cpp \ - widgets/qwidgetanimator.cpp \ - widgets/qtoolbararealayout.cpp + widgets/qwidgetanimator.cpp qtConfig(abstractbutton) { HEADERS += \ @@ -326,6 +317,21 @@ qtConfig(tabwidget) { SOURCES += widgets/qtabwidget.cpp } +qtConfig(toolbar) { + HEADERS += \ + widgets/qtoolbar.h \ + widgets/qtoolbar_p.h \ + widgets/qtoolbararealayout_p.h \ + widgets/qtoolbarlayout_p.h \ + widgets/qtoolbarseparator_p.h + + SOURCES += \ + widgets/qtoolbar.cpp \ + widgets/qtoolbarlayout.cpp \ + widgets/qtoolbararealayout.cpp \ + widgets/qtoolbarseparator.cpp +} + qtConfig(toolbox) { HEADERS += widgets/qtoolbox.h SOURCES += widgets/qtoolbox.cpp