From 18e06c37e10943f4b4f6d57b7044b9bce3a23202 Mon Sep 17 00:00:00 2001 From: Alexandra Cherdantseva Date: Mon, 30 Dec 2019 14:40:03 +0300 Subject: wasm: do not get canvas as property of js global object You cannot be sure that property with specified key in a global object is really a canvas. Should use `document.getElementById`. Change-Id: Ife55adaad5517aed64122b0c9bff32489cf19a2f Reviewed-by: Lorn Potter --- src/plugins/platforms/wasm/qwasmclipboard.cpp | 4 +++- src/plugins/platforms/wasm/qwasmcursor.cpp | 8 ++++++-- src/plugins/platforms/wasm/qwasmeventtranslator.cpp | 12 +++++++----- src/plugins/platforms/wasm/qwasmopenglcontext.cpp | 2 +- src/plugins/platforms/wasm/qwasmscreen.cpp | 9 ++++++--- 5 files changed, 23 insertions(+), 12 deletions(-) diff --git a/src/plugins/platforms/wasm/qwasmclipboard.cpp b/src/plugins/platforms/wasm/qwasmclipboard.cpp index d4a1e4dd50..fb46f1534f 100644 --- a/src/plugins/platforms/wasm/qwasmclipboard.cpp +++ b/src/plugins/platforms/wasm/qwasmclipboard.cpp @@ -198,7 +198,9 @@ void QWasmClipboard::installEventHandlers(const QString &canvasId) return; // Fallback path for browsers which do not support direct clipboard access - val canvas = val::global(canvasId.toUtf8().constData()); + val document = val::global("document"); + val canvas = document.call("getElementById", val(canvasId.toUtf8().constData())); + canvas.call("addEventListener", std::string("cut"), val::module_property("qtClipboardCutTo")); canvas.call("addEventListener", std::string("copy"), diff --git a/src/plugins/platforms/wasm/qwasmcursor.cpp b/src/plugins/platforms/wasm/qwasmcursor.cpp index 28ec3b58dd..c04fa6441a 100644 --- a/src/plugins/platforms/wasm/qwasmcursor.cpp +++ b/src/plugins/platforms/wasm/qwasmcursor.cpp @@ -36,6 +36,8 @@ #include #include +using namespace emscripten; + void QWasmCursor::changeCursor(QCursor *windowCursor, QWindow *window) { if (!windowCursor || !window) @@ -54,8 +56,10 @@ void QWasmCursor::changeCursor(QCursor *windowCursor, QWindow *window) htmlCursorName = "auto"; // Set cursor on the canvas - QString canvasId = QWasmScreen::get(screen)->canvasId(); - emscripten::val canvasStyle = emscripten::val::global(canvasId.toUtf8().constData())["style"]; + QByteArray canvasId = QWasmScreen::get(screen)->canvasId().toUtf8(); + val document = val::global("document"); + val canvas = document.call("getElementById", val(canvasId.constData())); + val canvasStyle = canvas["style"]; canvasStyle.set("cursor", emscripten::val(htmlCursorName.constData())); } diff --git a/src/plugins/platforms/wasm/qwasmeventtranslator.cpp b/src/plugins/platforms/wasm/qwasmeventtranslator.cpp index ad94ba9c77..8b7d00082f 100644 --- a/src/plugins/platforms/wasm/qwasmeventtranslator.cpp +++ b/src/plugins/platforms/wasm/qwasmeventtranslator.cpp @@ -47,9 +47,10 @@ #include -QT_BEGIN_NAMESPACE using namespace emscripten; +QT_BEGIN_NAMESPACE + typedef struct emkb2qt { const char *em; unsigned int qt; @@ -353,10 +354,11 @@ void QWasmEventTranslator::initEventHandlers() g_useNaturalScrolling = false; // make this !default on macOS if (emscripten::val::global("window")["safari"].isUndefined()) { - - emscripten::val::global(canvasId).call("addEventListener", - std::string("wheel"), - val::module_property("qtMouseWheelEvent")); + val document = val::global("document"); + val canvas = document.call("getElementById", val(canvasId)); + canvas.call("addEventListener", + std::string("wheel"), + val::module_property("qtMouseWheelEvent")); } } diff --git a/src/plugins/platforms/wasm/qwasmopenglcontext.cpp b/src/plugins/platforms/wasm/qwasmopenglcontext.cpp index 0532b7e726..501ab99116 100644 --- a/src/plugins/platforms/wasm/qwasmopenglcontext.cpp +++ b/src/plugins/platforms/wasm/qwasmopenglcontext.cpp @@ -106,7 +106,7 @@ EMSCRIPTEN_WEBGL_CONTEXT_HANDLE QWasmOpenGLContext::createEmscriptenContext(cons attributes.depth = useDepthStencil; attributes.stencil = useDepthStencil; - EMSCRIPTEN_WEBGL_CONTEXT_HANDLE context = emscripten_webgl_create_context(canvasId.toLocal8Bit().constData(), &attributes); + EMSCRIPTEN_WEBGL_CONTEXT_HANDLE context = emscripten_webgl_create_context(canvasId.toUtf8().constData(), &attributes); return context; } diff --git a/src/plugins/platforms/wasm/qwasmscreen.cpp b/src/plugins/platforms/wasm/qwasmscreen.cpp index 37f1ea832a..fe44fdb096 100644 --- a/src/plugins/platforms/wasm/qwasmscreen.cpp +++ b/src/plugins/platforms/wasm/qwasmscreen.cpp @@ -44,6 +44,7 @@ #include #include +using namespace emscripten; QT_BEGIN_NAMESPACE @@ -182,13 +183,15 @@ void QWasmScreen::updateQScreenAndCanvasRenderSize() QSizeF cssSize(css_width, css_height); QSizeF canvasSize = cssSize * devicePixelRatio(); - emscripten::val canvas = emscripten::val::global(canvasId.constData()); + val document = val::global("document"); + val canvas = document.call("getElementById", val(canvasId.constData())); + canvas.set("width", canvasSize.width()); canvas.set("height", canvasSize.height()); QPoint offset; - offset.setX(emscripten::val::global(canvasId.constData())["offsetTop"].as()); - offset.setY(emscripten::val::global(canvasId.constData())["offsetLeft"].as()); + offset.setX(canvas["offsetTop"].as()); + offset.setY(canvas["offsetLeft"].as()); emscripten::val rect = canvas.call("getBoundingClientRect"); QPoint position(rect["left"].as() - offset.x(), rect["top"].as() - offset.y()); -- cgit v1.2.3 From 76fbe75abee7d77911467d56630176f777e8ed78 Mon Sep 17 00:00:00 2001 From: Rainer Keller Date: Tue, 7 Jan 2020 09:13:21 +0100 Subject: Remove empty block at beginning of imported markdown An empty QTextDocument already contains a block; so when the formatting is fully determined, if the document is still empty, then instead of inserting a new block, we can set formatting on the cursor, which affects the pre-existing block, before inserting text. This avoids leaving a blank line (the default block) above the inserted content. Fixes: QTBUG-81060 Change-Id: I14e45e300a602493aa59680417d74d4c2b25862d Reviewed-by: Shawn Rutledge --- src/gui/text/qtextmarkdownimporter.cpp | 14 +++++++-- .../tst_qtextmarkdownimporter.cpp | 36 +++++++++++++++++++++- 2 files changed, 47 insertions(+), 3 deletions(-) diff --git a/src/gui/text/qtextmarkdownimporter.cpp b/src/gui/text/qtextmarkdownimporter.cpp index 78d18a714b..88965046ce 100644 --- a/src/gui/text/qtextmarkdownimporter.cpp +++ b/src/gui/text/qtextmarkdownimporter.cpp @@ -207,7 +207,12 @@ int QTextMarkdownImporter::cbEnterBlock(int blockType, void *det) charFmt.setFontWeight(QFont::Bold); blockFmt.setHeadingLevel(int(detail->level)); m_needsInsertBlock = false; - m_cursor->insertBlock(blockFmt, charFmt); + if (m_doc->isEmpty()) { + m_cursor->setBlockFormat(blockFmt); + m_cursor->setCharFormat(charFmt); + } else { + m_cursor->insertBlock(blockFmt, charFmt); + } qCDebug(lcMD, "H%d", detail->level); } break; case MD_BLOCK_LI: { @@ -592,7 +597,12 @@ void QTextMarkdownImporter::insertBlock() blockFormat.setMarker(m_markerType); if (!m_listStack.isEmpty()) blockFormat.setIndent(m_listStack.count()); - m_cursor->insertBlock(blockFormat, charFormat); + if (m_doc->isEmpty()) { + m_cursor->setBlockFormat(blockFormat); + m_cursor->setCharFormat(charFormat); + } else { + m_cursor->insertBlock(blockFormat, charFormat); + } if (m_needsInsertList) { m_listStack.push(m_cursor->createList(m_listFormat)); } else if (!m_listStack.isEmpty() && m_listItem) { diff --git a/tests/auto/gui/text/qtextmarkdownimporter/tst_qtextmarkdownimporter.cpp b/tests/auto/gui/text/qtextmarkdownimporter/tst_qtextmarkdownimporter.cpp index 2f0b877799..39a1370f6f 100644 --- a/tests/auto/gui/text/qtextmarkdownimporter/tst_qtextmarkdownimporter.cpp +++ b/tests/auto/gui/text/qtextmarkdownimporter/tst_qtextmarkdownimporter.cpp @@ -55,12 +55,13 @@ private slots: void thematicBreaks(); void lists_data(); void lists(); + void avoidBlankLineAtBeginning_data(); + void avoidBlankLineAtBeginning(); }; void tst_QTextMarkdownImporter::headingBulletsContinuations() { const QStringList expectedBlocks = QStringList() << - "" << // we could do without this blank line before the heading, but currently it happens "heading" << "bullet 1 continuation line 1, indented via tab" << "bullet 2 continuation line 2, indented via 4 spaces" << @@ -222,5 +223,38 @@ void tst_QTextMarkdownImporter::lists() QCOMPARE(doc.toMarkdown(), rewrite); } +void tst_QTextMarkdownImporter::avoidBlankLineAtBeginning_data() +{ + QTest::addColumn("input"); + QTest::addColumn("expectedNumberOfParagraphs"); + + QTest::newRow("Text block") << QString("Markdown text") << 1; + QTest::newRow("Headline") << QString("Markdown text\n============") << 1; + QTest::newRow("Code block") << QString(" Markdown text") << 2; + QTest::newRow("Unordered list") << QString("* Markdown text") << 1; + QTest::newRow("Ordered list") << QString("1. Markdown text") << 1; + QTest::newRow("Blockquote") << QString("> Markdown text") << 1; +} + +void tst_QTextMarkdownImporter::avoidBlankLineAtBeginning() // QTBUG-81060 +{ + QFETCH(QString, input); + QFETCH(int, expectedNumberOfParagraphs); + + QTextDocument doc; + QTextMarkdownImporter(QTextMarkdownImporter::DialectGitHub).import(&doc, input); + QTextFrame::iterator iterator = doc.rootFrame()->begin(); + int i = 0; + while (!iterator.atEnd()) { + QTextBlock block = iterator.currentBlock(); + // Make sure there is no empty paragraph at the beginning of the document + if (i == 0) + QVERIFY(!block.text().isEmpty()); + ++iterator; + ++i; + } + QCOMPARE(i, expectedNumberOfParagraphs); +} + QTEST_MAIN(tst_QTextMarkdownImporter) #include "tst_qtextmarkdownimporter.moc" -- cgit v1.2.3 From f936ca4f86e359cb919be9d21ad239618a878559 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Sun, 12 Jan 2020 11:32:06 -0800 Subject: qglobal.h: remove non-ASCII quotes from comment Because MSVC warns. Added by me on commit. c496fee2a5b65fd1b0672923293db058486e350e Fixes: QTBUG-81310 Change-Id: I596aec77785a4e4e84d5fffd15e93a8e367e035e Reviewed-by: Allan Sandfeld Jensen Reviewed-by: Edward Welbourne --- src/corelib/global/qglobal.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/corelib/global/qglobal.h b/src/corelib/global/qglobal.h index e636a7cf8f..fe8e8e8bc8 100644 --- a/src/corelib/global/qglobal.h +++ b/src/corelib/global/qglobal.h @@ -945,7 +945,7 @@ QT_WARNING_POP #endif QT_WARNING_PUSH -// warning: noexcept-expression evaluates to ‘false’ because of a call to ‘void swap(..., ...)' +// warning: noexcept-expression evaluates to 'false' because of a call to 'void swap(..., ...)' QT_WARNING_DISABLE_GCC("-Wnoexcept") namespace QtPrivate -- cgit v1.2.3 From caab0ad35799df3b2059bd3707b727dc0b5671aa Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Mon, 13 Jan 2020 11:20:14 +0100 Subject: Fix Mandelbrot Example documentation with regards to qRegisterMetaType() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The call to qRegisterMetaType() has been removed since the type is registered as a meta type in Qt 5. Assert on the meta type id instead. Adapt the documentation accordingly. Fixes: QTBUG-81254 Change-Id: I0cb459d0dda7a82fc37871605ff634004af0f9f9 Reviewed-by: Paul Wicking Reviewed-by: Mårten Nordheim --- examples/corelib/threads/doc/src/mandelbrot.qdoc | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/examples/corelib/threads/doc/src/mandelbrot.qdoc b/examples/corelib/threads/doc/src/mandelbrot.qdoc index 9e3fdc1dfe..b32fa097b3 100644 --- a/examples/corelib/threads/doc/src/mandelbrot.qdoc +++ b/examples/corelib/threads/doc/src/mandelbrot.qdoc @@ -238,8 +238,7 @@ \snippet threads/mandelbrot/mandelbrotwidget.cpp 1 The interesting part of the constructor is the - qRegisterMetaType() and QObject::connect() calls. Let's start - with the \l{QObject::connect()}{connect()} call. + QObject::connect() call. Although it looks like a standard signal-slot connection between two \l{QObject}s, because the signal is emitted in a different @@ -254,9 +253,10 @@ With queued connections, Qt must store a copy of the arguments that were passed to the signal so that it can pass them to the slot later on. Qt knows how to take of copy of many C++ and Qt - types, but QImage isn't one of them. We must therefore call the - template function qRegisterMetaType() before we can use QImage - as a parameter in queued connections. + types, so, no further action is needed for QImage. + If a custom type was used, a call to the template function + qRegisterMetaType() would be required before the type + could be used as a parameter in queued connections. \snippet threads/mandelbrot/mandelbrotwidget.cpp 2 \snippet threads/mandelbrot/mandelbrotwidget.cpp 3 -- cgit v1.2.3 From 04f6073da2eb9af1d0728aa688c906b682a44801 Mon Sep 17 00:00:00 2001 From: Edward Welbourne Date: Thu, 9 Jan 2020 10:35:12 +0100 Subject: ICC compile-fix for __builtin_add_overflow()'s parameter type Based on Glen Johnson's patch, but rearranged to avoid repetition. Fixes: QTBUG-81248 Change-Id: I9c23ab233ebd5514bc05fd155999597ada7295ef Reviewed-by: Thiago Macieira --- src/corelib/global/qnumeric_p.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/corelib/global/qnumeric_p.h b/src/corelib/global/qnumeric_p.h index fdfcbda6ca..7418579fe0 100644 --- a/src/corelib/global/qnumeric_p.h +++ b/src/corelib/global/qnumeric_p.h @@ -249,7 +249,8 @@ QT_WARNING_POP // size_t. Implementations for 8- and 16-bit types will work but may not be as // efficient. Implementations for 64-bit may be missing on 32-bit platforms. -#if (defined(Q_CC_GNU) && (Q_CC_GNU >= 500) || (defined(Q_CC_INTEL) && !defined(Q_OS_WIN))) || __has_builtin(__builtin_add_overflow) +#if ((defined(Q_CC_INTEL) ? (Q_CC_INTEL >= 1800 && !defined(Q_OS_WIN)) : defined(Q_CC_GNU)) \ + && Q_CC_GNU >= 500) || __has_builtin(__builtin_add_overflow) // GCC 5, ICC 18, and Clang 3.8 have builtins to detect overflows template inline -- cgit v1.2.3 From 41b44c6f21442892e2c0749940f716dc91c74b1f Mon Sep 17 00:00:00 2001 From: Shawn Rutledge Date: Wed, 1 Jan 2020 06:24:26 +0100 Subject: doc: explain QWheelEvent::angleDelta() more thoroughly It has been a QPoint for a long time now, to support both the usual vertical mouse wheel and also the wheel tilt for horizontal scrolling, or the actual horizontal wheel if the mouse has one, or the simulation of a horizontal wheel via touchpad gestures; but the docs continued to read as if it was just one value. Task-number: QTBUG-71575 Change-Id: I3efa686ace4f09c7f237f72bf0500fbfbd3213cb Reviewed-by: Richard Moe Gustavsen --- src/gui/kernel/qevent.cpp | 28 +++++++++++++++++++--------- 1 file changed, 19 insertions(+), 9 deletions(-) diff --git a/src/gui/kernel/qevent.cpp b/src/gui/kernel/qevent.cpp index f555f4dc05..0706ae3e90 100644 --- a/src/gui/kernel/qevent.cpp +++ b/src/gui/kernel/qevent.cpp @@ -667,9 +667,9 @@ QHoverEvent::~QHoverEvent() if that widget does not handle the event they are sent to the focus widget. Wheel events are generated for both mouse wheels and trackpad scroll gestures. There are two ways to read the - wheel event delta: angleDelta() returns the delta in wheel - degrees. This value is always provided. pixelDelta() returns - the delta in screen pixels and is available on platforms that + wheel event delta: angleDelta() returns the deltas in wheel + degrees. These values are always provided. pixelDelta() returns + the deltas in screen pixels, and is available on platforms that have high-resolution trackpads, such as \macos. If that is the case, source() will return Qt::MouseEventSynthesizedBySystem. @@ -852,7 +852,7 @@ QWheelEvent::QWheelEvent(const QPointF &pos, const QPointF& globalPos, by \a globalPos. \a pixelDelta contains the scrolling distance in pixels on screen, while - \a angleDelta contains the wheel rotation distance. \a pixelDelta is + \a angleDelta contains the wheel rotation angle. \a pixelDelta is optional and can be null. The mouse and keyboard states at the time of the event are specified by @@ -914,10 +914,16 @@ QWheelEvent::~QWheelEvent() /*! \fn QPoint QWheelEvent::angleDelta() const - Returns the distance that the wheel is rotated, in eighths of a - degree. A positive value indicates that the wheel was rotated - forwards away from the user; a negative value indicates that the - wheel was rotated backwards toward the user. + Returns the relative amount that the wheel was rotated, in eighths of a + degree. A positive value indicates that the wheel was rotated forwards away + from the user; a negative value indicates that the wheel was rotated + backwards toward the user. \c angleDelta().y() provides the angle through + which the common vertical mouse wheel was rotated since the previous event. + \c angleDelta().x() provides the angle through which the horizontal mouse + wheel was rotated, if the mouse has a horizontal wheel; otherwise it stays + at zero. Some mice allow the user to tilt the wheel to perform horizontal + scrolling, and some touchpads support a horizontal scrolling gesture; that + will also appear in \c angleDelta().x(). Most mouse types work in steps of 15 degrees, in which case the delta value is a multiple of 120; i.e., 120 units * 1/8 = 15 degrees. @@ -926,7 +932,9 @@ QWheelEvent::~QWheelEvent() that are less than 120 units (less than 15 degrees). To support this possibility, you can either cumulatively add the delta values from events until the value of 120 is reached, then scroll the widget, or you can - partially scroll the widget in response to each wheel event. + partially scroll the widget in response to each wheel event. But to + provide a more native feel, you should prefer \l pixelDelta() on platforms + where it's available. Example: @@ -937,6 +945,8 @@ QWheelEvent::~QWheelEvent() \li scrolling is about to begin, but the distance did not yet change (Qt::ScrollBegin), \li or scrolling has ended and the distance did not change anymore (Qt::ScrollEnd). \endlist + + \see pixelDelta() */ /*! -- cgit v1.2.3 From 9233ffa2d10094faeea05b48c9779ad73942e6a1 Mon Sep 17 00:00:00 2001 From: Paul Wicking Date: Mon, 13 Jan 2020 11:48:21 +0100 Subject: Doc: Don't document QTextStreamManipulator MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixes: QTBUG-81002 Change-Id: Ic7d0516a25a8a6e63e1a305ca87498948d41013c Reviewed-by: Topi Reiniö --- src/corelib/doc/src/dontdocument.qdoc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/corelib/doc/src/dontdocument.qdoc b/src/corelib/doc/src/dontdocument.qdoc index 19ca7db299..ff0aa98709 100644 --- a/src/corelib/doc/src/dontdocument.qdoc +++ b/src/corelib/doc/src/dontdocument.qdoc @@ -37,5 +37,5 @@ QCborValueRef qfloat16 QDeferredDeleteEvent QSpecialInteger QLittleEndianStorageType QBigEndianStorageType QFactoryInterface QFutureWatcherBase QJsonValuePtr QJsonValueRefPtr QLinkedListNode QAbstractConcatenable QStringBuilderCommon - QTextCodec::ConverterState QThreadStorageData) + QTextCodec::ConverterState QThreadStorageData QTextStreamManipulator) */ -- cgit v1.2.3 From 95d5a8e74fd9c861aa71492ec97f1cf819d84784 Mon Sep 17 00:00:00 2001 From: Michal Klocek Date: Fri, 10 Jan 2020 13:10:37 +0100 Subject: Report error when qt ios is built with debug only MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Doing only debug build is not supported at the moment. Add error to configure. Task-number: QTBUG-71990 Change-Id: If35d00c3f09d733efe63d5ea66d07e4a3ec922cc Reviewed-by: Tor Arne Vestbø --- configure.json | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/configure.json b/configure.json index 1ae09ef386..62d78f8dc6 100644 --- a/configure.json +++ b/configure.json @@ -1457,6 +1457,11 @@ Configure with '-qreal float' to create a build that is binary-compatible with 5 { "type": "emccVersion", "condition": "config.wasm" + }, + { + "type": "error", + "condition": "config.ios && features.debug && !features.debug_and_release", + "message": "Debug build wihtout Release build is not currently supported on ios see QTBUG-71990. Use -debug-and-release." } ], -- cgit v1.2.3 From 7d7ba311e01f915c32df53d6a6c4ca982efc24e1 Mon Sep 17 00:00:00 2001 From: Michal Klocek Date: Mon, 13 Jan 2020 13:23:52 +0100 Subject: Fix isysroot for simulator only builds on ios MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When not doing fat builds, QMAKE_MAC_SDK_PATH defaults to iphoneos sysroot, which breaks compilation. This fixes compilation when user sets also CONFIG-=device Change-Id: I1d18269946cd2a5608e26d943159c824f31db09a Reviewed-by: Tor Arne Vestbø --- mkspecs/features/mac/default_post.prf | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/mkspecs/features/mac/default_post.prf b/mkspecs/features/mac/default_post.prf index 03084c7f07..ba163efc18 100644 --- a/mkspecs/features/mac/default_post.prf +++ b/mkspecs/features/mac/default_post.prf @@ -212,14 +212,17 @@ macx-xcode { QMAKE_CXXFLAGS += $(EXPORT_QMAKE_XARCH_CFLAGS) QMAKE_LFLAGS += $(EXPORT_QMAKE_XARCH_LFLAGS) } else { - simulator: \ + simulator { version_identifier = $$simulator.deployment_identifier - else: \ + sysroot_path = $$xcodeSDKInfo(Path, $$simulator.sdk) + } else { version_identifier = $$device.deployment_identifier + sysroot_path = $$xcodeSDKInfo(Path, $$device.sdk) + } version_min_flag = -m$${version_identifier}-version-min=$$deployment_target - QMAKE_CFLAGS += -isysroot $$QMAKE_MAC_SDK_PATH $$version_min_flag - QMAKE_CXXFLAGS += -isysroot $$QMAKE_MAC_SDK_PATH $$version_min_flag - QMAKE_LFLAGS += -Wl,-syslibroot,$$QMAKE_MAC_SDK_PATH $$version_min_flag + QMAKE_CFLAGS += -isysroot $$sysroot_path $$version_min_flag + QMAKE_CXXFLAGS += -isysroot $$sysroot_path $$version_min_flag + QMAKE_LFLAGS += -Wl,-syslibroot,$$sysroot_path $$version_min_flag } # Enable precompiled headers for multiple architectures -- cgit v1.2.3 From 9dcbf2cf5cbdfe35637ff323fd44729badaae811 Mon Sep 17 00:00:00 2001 From: Christian Ehrlicher Date: Sun, 29 Dec 2019 16:27:29 +0100 Subject: QScrollBar: allow scrolling any scrollbar with any mouse wheel The most common mouse wheel movement corresponds to angleDelta().y(). We have previously allowed the user to use either wheel to scroll either a horizontal or a vertical scrollbar when the mouse is hovering over it; but 7d29807296cb7ccc7f3459e106d74f93a321c493 changed it so that the vertical mouse wheel could no longer scroll a horizontal scrollbar. The behavior is now restored as it was in 59cc316620a2169d48e00822c97a96bd03079eed. Task-number: QTBUG-81007 Change-Id: Ieacdce539d5311499a86af645bbe0d5098e16be6 Reviewed-by: Christian Ehrlicher Reviewed-by: Shawn Rutledge --- src/widgets/widgets/qscrollbar.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/widgets/widgets/qscrollbar.cpp b/src/widgets/widgets/qscrollbar.cpp index 08d771a27a..4606f57fb8 100644 --- a/src/widgets/widgets/qscrollbar.cpp +++ b/src/widgets/widgets/qscrollbar.cpp @@ -497,14 +497,20 @@ bool QScrollBar::event(QEvent *event) void QScrollBar::wheelEvent(QWheelEvent *event) { event->ignore(); + bool horizontal = qAbs(event->angleDelta().x()) > qAbs(event->angleDelta().y()); + // The vertical wheel can be used to scroll a horizontal scrollbar, but only if + // there is no simultaneous horizontal wheel movement. This is to avoid chaotic + // scrolling on touchpads. + if (!horizontal && event->angleDelta().x() != 0 && orientation() == Qt::Horizontal) + return; // scrollbar is a special case - in vertical mode it reaches minimum // value in the upper position, however QSlider's minimum value is on // the bottom. So we need to invert the value, but since the scrollbar is // inverted by default, we need to invert the delta value only for the // horizontal orientation. - int delta = (orientation() == Qt::Horizontal ? -event->angleDelta().x() : event->angleDelta().y()); + int delta = horizontal ? -event->angleDelta().x() : event->angleDelta().y(); Q_D(QScrollBar); - if (d->scrollByDelta(orientation(), event->modifiers(), delta)) + if (d->scrollByDelta(horizontal ? Qt::Horizontal : Qt::Vertical, event->modifiers(), delta)) event->accept(); if (event->phase() == Qt::ScrollBegin) -- cgit v1.2.3 From eb2a7738a431a7510cdcc69250a4713c1d3cd490 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= Date: Mon, 13 Jan 2020 16:47:15 +0100 Subject: Skip instead of fail tests when test server is not available We were being inconsistent in how we handled this, some tests skipping while others using QVERIFY. It makes more sense to skip the tests, since the problem is a missing pre-condition of the test, not the test itself being bad or exposing real failures in the implementation. Change-Id: I20eacfe12dbce0b0d926e48cbe2d2772819fa4a5 Reviewed-by: Timur Pocheptsov --- tests/auto/network/access/qftp/tst_qftp.cpp | 3 +- .../tst_qhttpnetworkconnection.cpp | 3 +- tests/auto/network/access/spdy/tst_spdy.cpp | 3 +- tests/auto/network/network.pro | 1 + tests/auto/network/selftest/selftest.pro | 6 +++ .../auto/network/selftest/tst_networkselftest.cpp | 55 ++++++++++++++++++++++ .../tst_platformsocketengine.cpp | 3 +- .../qhttpsocketengine/tst_qhttpsocketengine.cpp | 3 +- .../tst_qsocks5socketengine.cpp | 3 +- .../network/socket/qtcpsocket/tst_qtcpsocket.cpp | 3 +- .../auto/network/ssl/qsslsocket/tst_qsslsocket.cpp | 3 +- .../tst_qsslsocket_onDemandCertificates_member.cpp | 3 +- .../tst_qsslsocket_onDemandCertificates_static.cpp | 3 +- .../access/qnetworkreply/tst_qnetworkreply.cpp | 3 +- .../network/socket/qtcpserver/tst_qtcpserver.cpp | 3 +- .../network/ssl/qsslsocket/tst_qsslsocket.cpp | 3 +- .../network_stresstest/tst_network_stresstest.cpp | 3 +- tests/manual/qnetworkreply/main.cpp | 3 +- 18 files changed, 92 insertions(+), 15 deletions(-) create mode 100644 tests/auto/network/selftest/selftest.pro create mode 100644 tests/auto/network/selftest/tst_networkselftest.cpp diff --git a/tests/auto/network/access/qftp/tst_qftp.cpp b/tests/auto/network/access/qftp/tst_qftp.cpp index 2068738a67..60acb70af4 100644 --- a/tests/auto/network/access/qftp/tst_qftp.cpp +++ b/tests/auto/network/access/qftp/tst_qftp.cpp @@ -215,7 +215,8 @@ void tst_QFtp::initTestCase() QVERIFY(QtNetworkSettings::verifyConnection(QtNetworkSettings::socksProxyServerName(), 1080)); QVERIFY(QtNetworkSettings::verifyConnection(QtNetworkSettings::httpProxyServerName(), 3128)); #else - QVERIFY(QtNetworkSettings::verifyTestNetworkSettings()); + if (!QtNetworkSettings::verifyTestNetworkSettings()) + QSKIP("No network test server available"); #endif #ifndef QT_NO_BEARERMANAGEMENT QNetworkConfigurationManager manager; diff --git a/tests/auto/network/access/qhttpnetworkconnection/tst_qhttpnetworkconnection.cpp b/tests/auto/network/access/qhttpnetworkconnection/tst_qhttpnetworkconnection.cpp index 0a9320118d..57fa5a613c 100644 --- a/tests/auto/network/access/qhttpnetworkconnection/tst_qhttpnetworkconnection.cpp +++ b/tests/auto/network/access/qhttpnetworkconnection/tst_qhttpnetworkconnection.cpp @@ -105,7 +105,8 @@ void tst_QHttpNetworkConnection::initTestCase() #if defined(QT_TEST_SERVER) QVERIFY(QtNetworkSettings::verifyConnection(httpServerName(), 80)); #else - QVERIFY(QtNetworkSettings::verifyTestNetworkSettings()); + if (!QtNetworkSettings::verifyTestNetworkSettings()) + QSKIP("No network test server available"); #endif } diff --git a/tests/auto/network/access/spdy/tst_spdy.cpp b/tests/auto/network/access/spdy/tst_spdy.cpp index f4a5976558..5701f4911c 100644 --- a/tests/auto/network/access/spdy/tst_spdy.cpp +++ b/tests/auto/network/access/spdy/tst_spdy.cpp @@ -100,7 +100,8 @@ tst_Spdy::~tst_Spdy() void tst_Spdy::initTestCase() { QVERIFY(!m_rfc3252FilePath.isEmpty()); - QVERIFY(QtNetworkSettings::verifyTestNetworkSettings()); + if (!QtNetworkSettings::verifyTestNetworkSettings()) + QSKIP("No network test server available"); } void tst_Spdy::settingsAndNegotiation_data() diff --git a/tests/auto/network/network.pro b/tests/auto/network/network.pro index 64262a8632..9a3ababe61 100644 --- a/tests/auto/network/network.pro +++ b/tests/auto/network/network.pro @@ -1,5 +1,6 @@ TEMPLATE=subdirs SUBDIRS=\ + selftest \ access \ bearer \ kernel \ diff --git a/tests/auto/network/selftest/selftest.pro b/tests/auto/network/selftest/selftest.pro new file mode 100644 index 0000000000..e8312032c3 --- /dev/null +++ b/tests/auto/network/selftest/selftest.pro @@ -0,0 +1,6 @@ +CONFIG += testcase +TARGET = tst_networkselftest +SOURCES += tst_networkselftest.cpp + +requires(qtConfig(private_tests)) +QT = core network network-private testlib diff --git a/tests/auto/network/selftest/tst_networkselftest.cpp b/tests/auto/network/selftest/tst_networkselftest.cpp new file mode 100644 index 0000000000..a540e18f48 --- /dev/null +++ b/tests/auto/network/selftest/tst_networkselftest.cpp @@ -0,0 +1,55 @@ +/**************************************************************************** +** +** Copyright (C) 2020 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:GPL-EXCEPT$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 as published by the Free Software +** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + + +#include + +#include "../../network-settings.h" + +class tst_NetworkSelftest : public QObject +{ + Q_OBJECT + +private slots: + void testServerIsAvailableInCI(); +}; + +void tst_NetworkSelftest::testServerIsAvailableInCI() +{ + if (!qEnvironmentVariable("QTEST_ENVIRONMENT").split(' ').contains("ci")) + QSKIP("Not running in the CI"); + +#if !defined(QT_TEST_SERVER) + QVERIFY2(QtNetworkSettings::verifyTestNetworkSettings(), + "Test server must be available when running in the CI"); +#endif +} + +QTEST_MAIN(tst_NetworkSelftest) + +#include "tst_networkselftest.moc" diff --git a/tests/auto/network/socket/platformsocketengine/tst_platformsocketengine.cpp b/tests/auto/network/socket/platformsocketengine/tst_platformsocketengine.cpp index ffc63ee46a..5be00630ca 100644 --- a/tests/auto/network/socket/platformsocketengine/tst_platformsocketengine.cpp +++ b/tests/auto/network/socket/platformsocketengine/tst_platformsocketengine.cpp @@ -87,7 +87,8 @@ private slots: void tst_PlatformSocketEngine::initTestCase() { - QVERIFY(QtNetworkSettings::verifyTestNetworkSettings()); + if (!QtNetworkSettings::verifyTestNetworkSettings()) + QSKIP("No network test server available"); } //--------------------------------------------------------------------------- diff --git a/tests/auto/network/socket/qhttpsocketengine/tst_qhttpsocketengine.cpp b/tests/auto/network/socket/qhttpsocketengine/tst_qhttpsocketengine.cpp index 64241014d7..7644a06380 100644 --- a/tests/auto/network/socket/qhttpsocketengine/tst_qhttpsocketengine.cpp +++ b/tests/auto/network/socket/qhttpsocketengine/tst_qhttpsocketengine.cpp @@ -129,7 +129,8 @@ void tst_QHttpSocketEngine::initTestCase() QVERIFY(QtNetworkSettings::verifyConnection(QtNetworkSettings::httpServerName(), 80)); QVERIFY(QtNetworkSettings::verifyConnection(QtNetworkSettings::imapServerName(), 143)); #else - QVERIFY(QtNetworkSettings::verifyTestNetworkSettings()); + if (!QtNetworkSettings::verifyTestNetworkSettings()) + QSKIP("No network test server available"); #endif } diff --git a/tests/auto/network/socket/qsocks5socketengine/tst_qsocks5socketengine.cpp b/tests/auto/network/socket/qsocks5socketengine/tst_qsocks5socketengine.cpp index 464054f8a6..44b5a02af4 100644 --- a/tests/auto/network/socket/qsocks5socketengine/tst_qsocks5socketengine.cpp +++ b/tests/auto/network/socket/qsocks5socketengine/tst_qsocks5socketengine.cpp @@ -142,7 +142,8 @@ void tst_QSocks5SocketEngine::initTestCase() QVERIFY(QtNetworkSettings::verifyConnection(QtNetworkSettings::httpServerName(), 80)); QVERIFY(QtNetworkSettings::verifyConnection(QtNetworkSettings::imapServerName(), 143)); #else - QVERIFY(QtNetworkSettings::verifyTestNetworkSettings()); + if (!QtNetworkSettings::verifyTestNetworkSettings()) + QSKIP("No network test server available"); #endif } diff --git a/tests/auto/network/socket/qtcpsocket/tst_qtcpsocket.cpp b/tests/auto/network/socket/qtcpsocket/tst_qtcpsocket.cpp index 75b9b23259..0546c6ba7d 100644 --- a/tests/auto/network/socket/qtcpsocket/tst_qtcpsocket.cpp +++ b/tests/auto/network/socket/qtcpsocket/tst_qtcpsocket.cpp @@ -358,7 +358,8 @@ void tst_QTcpSocket::initTestCase() QVERIFY(QtNetworkSettings::verifyConnection(QtNetworkSettings::ftpServerName(), 21)); QVERIFY(QtNetworkSettings::verifyConnection(QtNetworkSettings::ftpProxyServerName(), 2121)); #else - QVERIFY(QtNetworkSettings::verifyTestNetworkSettings()); + if (!QtNetworkSettings::verifyTestNetworkSettings()) + QSKIP("No network test server available"); #endif } diff --git a/tests/auto/network/ssl/qsslsocket/tst_qsslsocket.cpp b/tests/auto/network/ssl/qsslsocket/tst_qsslsocket.cpp index e599ebf199..8e2dc13cfc 100644 --- a/tests/auto/network/ssl/qsslsocket/tst_qsslsocket.cpp +++ b/tests/auto/network/ssl/qsslsocket/tst_qsslsocket.cpp @@ -391,7 +391,8 @@ void tst_QSslSocket::initTestCase() QVERIFY(QtNetworkSettings::verifyConnection(QtNetworkSettings::imapServerName(), 993)); QVERIFY(QtNetworkSettings::verifyConnection(QtNetworkSettings::echoServerName(), 13)); #else - QVERIFY(QtNetworkSettings::verifyTestNetworkSettings()); + if (!QtNetworkSettings::verifyTestNetworkSettings()) + QSKIP("No network test server available"); #endif // QT_TEST_SERVER #endif // QT_NO_SSL } diff --git a/tests/auto/network/ssl/qsslsocket_onDemandCertificates_member/tst_qsslsocket_onDemandCertificates_member.cpp b/tests/auto/network/ssl/qsslsocket_onDemandCertificates_member/tst_qsslsocket_onDemandCertificates_member.cpp index 3b28e7a803..ad9554c7a5 100644 --- a/tests/auto/network/ssl/qsslsocket_onDemandCertificates_member/tst_qsslsocket_onDemandCertificates_member.cpp +++ b/tests/auto/network/ssl/qsslsocket_onDemandCertificates_member/tst_qsslsocket_onDemandCertificates_member.cpp @@ -109,7 +109,8 @@ void tst_QSslSocket_onDemandCertificates_member::initTestCase() QVERIFY(QtNetworkSettings::verifyConnection(QtNetworkSettings::httpProxyServerName(), 3129)); QVERIFY(QtNetworkSettings::verifyConnection(QtNetworkSettings::httpProxyServerName(), 3130)); #else - QVERIFY(QtNetworkSettings::verifyTestNetworkSettings()); + if (!QtNetworkSettings::verifyTestNetworkSettings()) + QSKIP("No network test server available"); #endif // QT_TEST_SERVER } diff --git a/tests/auto/network/ssl/qsslsocket_onDemandCertificates_static/tst_qsslsocket_onDemandCertificates_static.cpp b/tests/auto/network/ssl/qsslsocket_onDemandCertificates_static/tst_qsslsocket_onDemandCertificates_static.cpp index a441d13619..b4a41b57e6 100644 --- a/tests/auto/network/ssl/qsslsocket_onDemandCertificates_static/tst_qsslsocket_onDemandCertificates_static.cpp +++ b/tests/auto/network/ssl/qsslsocket_onDemandCertificates_static/tst_qsslsocket_onDemandCertificates_static.cpp @@ -105,7 +105,8 @@ void tst_QSslSocket_onDemandCertificates_static::initTestCase() QVERIFY(QtNetworkSettings::verifyConnection(QtNetworkSettings::httpProxyServerName(), 3129)); QVERIFY(QtNetworkSettings::verifyConnection(QtNetworkSettings::httpProxyServerName(), 3130)); #else - QVERIFY(QtNetworkSettings::verifyTestNetworkSettings()); + if (!QtNetworkSettings::verifyTestNetworkSettings()) + QSKIP("No network test server available"); #endif // QT_TEST_SERVER } diff --git a/tests/benchmarks/network/access/qnetworkreply/tst_qnetworkreply.cpp b/tests/benchmarks/network/access/qnetworkreply/tst_qnetworkreply.cpp index c182ef7ebf..bcd354ebee 100644 --- a/tests/benchmarks/network/access/qnetworkreply/tst_qnetworkreply.cpp +++ b/tests/benchmarks/network/access/qnetworkreply/tst_qnetworkreply.cpp @@ -479,7 +479,8 @@ private: void tst_qnetworkreply::initTestCase() { - QVERIFY(QtNetworkSettings::verifyTestNetworkSettings()); + if (!QtNetworkSettings::verifyTestNetworkSettings()) + QSKIP("No network test server available"); } void tst_qnetworkreply::httpLatency() diff --git a/tests/benchmarks/network/socket/qtcpserver/tst_qtcpserver.cpp b/tests/benchmarks/network/socket/qtcpserver/tst_qtcpserver.cpp index 109126790b..a9f8634129 100644 --- a/tests/benchmarks/network/socket/qtcpserver/tst_qtcpserver.cpp +++ b/tests/benchmarks/network/socket/qtcpserver/tst_qtcpserver.cpp @@ -81,7 +81,8 @@ void tst_QTcpServer::initTestCase_data() void tst_QTcpServer::initTestCase() { - QVERIFY(QtNetworkSettings::verifyTestNetworkSettings()); + if (!QtNetworkSettings::verifyTestNetworkSettings()) + QSKIP("No network test server available"); } void tst_QTcpServer::init() diff --git a/tests/benchmarks/network/ssl/qsslsocket/tst_qsslsocket.cpp b/tests/benchmarks/network/ssl/qsslsocket/tst_qsslsocket.cpp index c01c673604..afd0c720a2 100644 --- a/tests/benchmarks/network/ssl/qsslsocket/tst_qsslsocket.cpp +++ b/tests/benchmarks/network/ssl/qsslsocket/tst_qsslsocket.cpp @@ -63,7 +63,8 @@ tst_QSslSocket::~tst_QSslSocket() void tst_QSslSocket::initTestCase() { - QVERIFY(QtNetworkSettings::verifyTestNetworkSettings()); + if (!QtNetworkSettings::verifyTestNetworkSettings()) + QSKIP("No network test server available"); } void tst_QSslSocket::init() diff --git a/tests/manual/network_stresstest/tst_network_stresstest.cpp b/tests/manual/network_stresstest/tst_network_stresstest.cpp index 03df1633d5..5f2fd2b24e 100644 --- a/tests/manual/network_stresstest/tst_network_stresstest.cpp +++ b/tests/manual/network_stresstest/tst_network_stresstest.cpp @@ -123,7 +123,8 @@ void tst_NetworkStressTest::initTestCase_data() void tst_NetworkStressTest::initTestCase() { - QVERIFY(QtNetworkSettings::verifyTestNetworkSettings()); + if (!QtNetworkSettings::verifyTestNetworkSettings()) + QSKIP("No network test server available"); } void tst_NetworkStressTest::init() diff --git a/tests/manual/qnetworkreply/main.cpp b/tests/manual/qnetworkreply/main.cpp index afac7a7095..762bfe7b83 100644 --- a/tests/manual/qnetworkreply/main.cpp +++ b/tests/manual/qnetworkreply/main.cpp @@ -108,7 +108,8 @@ protected: void tst_qnetworkreply::initTestCase() { qRegisterMetaType(); // for QSignalSpy - QVERIFY(QtNetworkSettings::verifyTestNetworkSettings()); + if (!QtNetworkSettings::verifyTestNetworkSettings()) + QSKIP("No network test server available"); } void tst_qnetworkreply::limiting_data() -- cgit v1.2.3 From b7a56ea3ee69241ff5d71a845f4e48dcb93e8073 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= Date: Mon, 13 Jan 2020 16:23:28 +0100 Subject: Skip tst_QMenu::pushButtonPopulateOnAboutToShow on macOS The combobox popup can overlap a little with the button, and that's the expected behavior. Change-Id: I245bfce85cb5ee661ceb51dbe0d844492878a2bc Reviewed-by: Simon Hausmann --- tests/auto/widgets/widgets/qmenu/tst_qmenu.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tests/auto/widgets/widgets/qmenu/tst_qmenu.cpp b/tests/auto/widgets/widgets/qmenu/tst_qmenu.cpp index 9c40c0bd57..727d1c2a16 100644 --- a/tests/auto/widgets/widgets/qmenu/tst_qmenu.cpp +++ b/tests/auto/widgets/widgets/qmenu/tst_qmenu.cpp @@ -1066,6 +1066,10 @@ static inline QByteArray msgGeometryIntersects(const QRect &r1, const QRect &r2) void tst_QMenu::pushButtonPopulateOnAboutToShow() { +#ifdef Q_OS_MACOS + QSKIP("Popup menus may partially overlap the button on macOS, and that's okey"); +#endif + QPushButton b("Test PushButton"); b.setWindowFlags(Qt::FramelessWindowHint | Qt::X11BypassWindowManagerHint); -- cgit v1.2.3 From 3be91a89afda540f1df6a7e8e3dadcb47615a0bc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= Date: Mon, 13 Jan 2020 18:39:23 +0100 Subject: Blacklist tst_QStyleSheetStyle::widgetStylePropagation on macOS It's not clear why this is failing, but we need to blacklist it so that we can move over to testing macOS 10.14 and 10.15 in the CI. Task-number: QTBUG-75786 Change-Id: I208d5af92406c5da8d0210e0188568466b78b2a9 Reviewed-by: Simon Hausmann --- tests/auto/widgets/styles/qstylesheetstyle/BLACKLIST | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/auto/widgets/styles/qstylesheetstyle/BLACKLIST b/tests/auto/widgets/styles/qstylesheetstyle/BLACKLIST index 6b2e4f3fb2..616cd650b3 100644 --- a/tests/auto/widgets/styles/qstylesheetstyle/BLACKLIST +++ b/tests/auto/widgets/styles/qstylesheetstyle/BLACKLIST @@ -1,2 +1,4 @@ [task232085_spinBoxLineEditBg] osx +[widgetStylePropagation] +macos # QTBUG-75786 -- cgit v1.2.3 From e1dbb737012e3e7aa818b45bf2804b866f4b7d9e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= Date: Mon, 13 Jan 2020 18:35:08 +0100 Subject: Blacklist tst_QTableView::mouseWheel on macOS There's a timing issue that affects the position of the vertical scrollbar when scrolling by pixels. Change-Id: I29d73574785be539a5870b498a902b1aba887e9c Reviewed-by: Simon Hausmann --- tests/auto/widgets/itemviews/qtableview/BLACKLIST | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/auto/widgets/itemviews/qtableview/BLACKLIST b/tests/auto/widgets/itemviews/qtableview/BLACKLIST index 9648cef3de..ff870915be 100644 --- a/tests/auto/widgets/itemviews/qtableview/BLACKLIST +++ b/tests/auto/widgets/itemviews/qtableview/BLACKLIST @@ -1,3 +1,5 @@ [moveCursorBiggerJump] osx +[mouseWheel:scroll down per pixel] +macos -- cgit v1.2.3 From 6ae9cc7cb99f156de296f66a2b85c5be7674b916 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= Date: Mon, 13 Jan 2020 18:33:07 +0100 Subject: Blacklist tests on macOS that rely on moving the cursor Task-number: QTBUG-76312 Change-Id: Ibb29231141017ed608beaa12255cdd083317433c Reviewed-by: Simon Hausmann --- tests/auto/widgets/kernel/qwidget/BLACKLIST | 4 ++++ tests/auto/widgets/widgets/qmenu/BLACKLIST | 2 ++ 2 files changed, 6 insertions(+) diff --git a/tests/auto/widgets/kernel/qwidget/BLACKLIST b/tests/auto/widgets/kernel/qwidget/BLACKLIST index 26f9ce1b85..38e04043bd 100644 --- a/tests/auto/widgets/kernel/qwidget/BLACKLIST +++ b/tests/auto/widgets/kernel/qwidget/BLACKLIST @@ -49,3 +49,7 @@ ubuntu # QTBUG-75270 winrt +[syntheticEnterLeave] +macos # Can't move cursor (QTBUG-76312) +[taskQTBUG_4055_sendSyntheticEnterLeave] +macos # Can't move cursor (QTBUG-76312) diff --git a/tests/auto/widgets/widgets/qmenu/BLACKLIST b/tests/auto/widgets/widgets/qmenu/BLACKLIST index ad6d2f340c..ba9c184a67 100644 --- a/tests/auto/widgets/widgets/qmenu/BLACKLIST +++ b/tests/auto/widgets/widgets/qmenu/BLACKLIST @@ -11,3 +11,5 @@ osx-10.13 osx-10.14 [activeSubMenuPosition] winrt +[submenuTearOffDontClose] +macos # Can't move cursor (QTBUG-76312) -- cgit v1.2.3 From 0617afb2d3808c0dc6a4edeb6c580ff9ce3df7eb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= Date: Mon, 13 Jan 2020 18:31:07 +0100 Subject: Extend blacklisting of tst_QWidget::showMinimizedKeepsFocus to all macOS versions For some reason the firstChild gets the focus when clearing the focus. This seems to be timing dependent, as removing the 30ms qWait 'fixes' the issue. So does a processEvent call before minimzing. Both of these require further investigation. Change-Id: I62833a5541712f97dc24bc63384fa4c051096537 Reviewed-by: Simon Hausmann --- tests/auto/widgets/kernel/qwidget/BLACKLIST | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/tests/auto/widgets/kernel/qwidget/BLACKLIST b/tests/auto/widgets/kernel/qwidget/BLACKLIST index 38e04043bd..e1038572a7 100644 --- a/tests/auto/widgets/kernel/qwidget/BLACKLIST +++ b/tests/auto/widgets/kernel/qwidget/BLACKLIST @@ -34,8 +34,7 @@ osx [render_systemClip] osx [showMinimizedKeepsFocus] -osx-10.12 ci -osx-10.13 ci +macos [maskedUpdate] opensuse opensuse-leap -- cgit v1.2.3 From d8897e0b08974a687b7ba9099732afe94400fef3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= Date: Mon, 13 Jan 2020 18:27:50 +0100 Subject: Clarify blacklisting of tst_QWidget::childEvents on macOS The test expects a very explicit list of events during show, but on macOS we also get an InputMethodQuery event as a result of the window becoming active. The test needs to be written significantly to support these kind of platform differences. Change-Id: I395c1e9e4e9baf7d9f88f0d067586fc15afb9a16 Reviewed-by: Simon Hausmann --- tests/auto/widgets/kernel/qwidget/BLACKLIST | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/auto/widgets/kernel/qwidget/BLACKLIST b/tests/auto/widgets/kernel/qwidget/BLACKLIST index e1038572a7..be19d8fd0b 100644 --- a/tests/auto/widgets/kernel/qwidget/BLACKLIST +++ b/tests/auto/widgets/kernel/qwidget/BLACKLIST @@ -22,7 +22,7 @@ opensuse-leap # QTBUG-68175 opensuse-42.3 [childEvents] -osx ci +macos [renderInvisible] osx-10.12 osx-10.11 -- cgit v1.2.3 From 99b396631999d7fc4e5e95b90a83858a5cb5a941 Mon Sep 17 00:00:00 2001 From: Paul Wicking Date: Mon, 13 Jan 2020 14:43:34 +0100 Subject: Doc: Add note about mac-specific behavior for setWindowIcon MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixes: QTBUG-74985 Change-Id: I7379865ab9564301c1e636ba1fda40cbb9e04c61 Reviewed-by: Tor Arne Vestbø --- src/widgets/kernel/qwidget.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/widgets/kernel/qwidget.cpp b/src/widgets/kernel/qwidget.cpp index dcc694efe4..c389c4ab4d 100644 --- a/src/widgets/kernel/qwidget.cpp +++ b/src/widgets/kernel/qwidget.cpp @@ -5955,7 +5955,11 @@ void QWidget::setWindowTitle(const QString &title) has been set, windowIcon() returns the application icon (QApplication::windowIcon()). - \sa windowTitle + \note On \macos, window icons represent the active document, + and will not be displayed unless a file path has also been + set using setFilePath. + + \sa windowTitle, setFilePath */ QIcon QWidget::windowIcon() const { -- cgit v1.2.3 From 44fd33e05c6b2b8f36bde894164480024d3c92ab Mon Sep 17 00:00:00 2001 From: Samuel Gaist Date: Thu, 9 Jan 2020 08:36:20 +0100 Subject: doc: improve SUBDIRS documentation for dependency handling The use of the 'ordered' CONFIG option is known to not be efficient for multi-core builds. This patch updates the documentation with an example using the .depends modifier as well a discourage the use of 'ordered'. Change-Id: I3575243a7c4138f0671d171441c932c3ad89a411 Reviewed-by: Paul Wicking Reviewed-by: Sze Howe Koh --- qmake/doc/snippets/code/doc_src_qmake-manual.pro | 4 +++- qmake/doc/src/qmake-manual.qdoc | 30 ++++++++++++++++++------ 2 files changed, 26 insertions(+), 8 deletions(-) diff --git a/qmake/doc/snippets/code/doc_src_qmake-manual.pro b/qmake/doc/snippets/code/doc_src_qmake-manual.pro index 8ba0aa0713..d36d926b66 100644 --- a/qmake/doc/snippets/code/doc_src_qmake-manual.pro +++ b/qmake/doc/snippets/code/doc_src_qmake-manual.pro @@ -303,7 +303,9 @@ SUBDIRS = kernel \ #! [51] -CONFIG += ordered +SUBDIRS += my_executable my_library tests doc +my_executable.depends = my_library +tests.depends = my_executable #! [51] diff --git a/qmake/doc/src/qmake-manual.qdoc b/qmake/doc/src/qmake-manual.qdoc index 64c5f0a14e..bb7ad31f8d 100644 --- a/qmake/doc/src/qmake-manual.qdoc +++ b/qmake/doc/src/qmake-manual.qdoc @@ -936,7 +936,9 @@ file. \row \li ordered \li When using the \c subdirs template, this option specifies that the directories listed should be processed in the - order in which they are given. + order in which they are given. \note The use of this option is discouraged. + Specify dependencies as described in the \l{#SUBDIRS}{SUBDIRS} + variable documentation. \row \li precompile_header \li Enables support for the use of \l{Using Precompiled Headers}{precompiled headers} in projects. \row \li precompile_header_c (MSVC only) \li Enables support for the use of @@ -2730,21 +2732,35 @@ \snippet code/doc_src_qmake-manual.pro 50 - If you need to ensure that the subdirectories are built in the order in - which they are specified, update the \l{#CONFIG}{CONFIG} variable to - include the \c ordered option: + If you need to ensure that the subdirectories are built in a particular + order, use the \c .depends modifier on the relevant \c SUBDIRS elements. + + For example: \snippet code/doc_src_qmake-manual.pro 51 - It is possible to modify this default behavior of \c SUBDIRS by giving - additional modifiers to \c SUBDIRS elements. Supported modifiers are: + The configuration above ensures that \c{my_library} is built before + \c{my_executable} and that \c{my_executable} is built before \c{tests}. + However, \c{doc} can be built in parallel with the other subdirectories, + thus speeding up the build process. + + \note Multiple dependencies can be listed and they will all be built before + the target that depends on them. + + \note Using \l{#CONFIG}{CONFIG += ordered} is discouraged as it can slow down + multi-core builds. Unlike the example shown above, all builds will happen + sequentially even if they don't have dependencies. + + Beside defining the build order, it is possible to modify the default behavior + of \c SUBDIRS by giving additional modifiers to \c SUBDIRS elements. + Supported modifiers are: \table \header \li Modifier \li Effect \row \li .subdir \li Use the specified subdirectory instead of \c SUBDIRS value. \row \li .file \li Specify the subproject \c pro file explicitly. Cannot be used in conjunction with \c .subdir modifier. - \row \li .depends \li This subproject depends on specified subproject. + \row \li .depends \li This subproject depends on specified subproject(s). \row \li .makefile \li The makefile of subproject. Available only on platforms that use makefiles. \row \li .target \li Base string used for makefile targets related to this -- cgit v1.2.3 From 6d545dedad6248d9ab2f28782940fc5709504315 Mon Sep 17 00:00:00 2001 From: Joerg Bornemann Date: Fri, 10 Jan 2020 15:43:45 +0100 Subject: Fix mkdir warning for object_parallel_to_source projects Source files that are right next to the project file result in an empty "object subdirectory" if object_parallel_to_source is set. We must not attempt to create empty directories. Fixes: QTBUG-81271 Change-Id: I431f9fbe46f50fbbaa5d6a59966bfb059418036c Reviewed-by: Kai Koehne --- qmake/generators/makefile.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/qmake/generators/makefile.cpp b/qmake/generators/makefile.cpp index dcb44239a0..7e471f126c 100644 --- a/qmake/generators/makefile.cpp +++ b/qmake/generators/makefile.cpp @@ -1520,7 +1520,7 @@ MakefileGenerator::createObjectList(const ProStringList &sources) if (!noIO()) { // Ensure that the final output directory of each object exists QString outRelativePath = fileFixify(dir, FileFixifyBackwards); - if (!mkdir(outRelativePath)) + if (!outRelativePath.isEmpty() && !mkdir(outRelativePath)) warn_msg(WarnLogic, "Cannot create directory '%s'", outRelativePath.toLatin1().constData()); } } else { -- cgit v1.2.3 From 3f6275960c4da87a18f3740bc3fef68dcf8a65d1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cristi=C3=A1n=20Maureira-Fredes?= Date: Wed, 18 Dec 2019 17:56:23 +0100 Subject: uic: add customwidget imports support for python Fixes: QTBUG-81073 Change-Id: I29659481b14927ffcb8f2cb1829b577a67e4b937 Reviewed-by: Friedemann Kleint --- src/tools/uic/python/pythonwriteimports.cpp | 26 ++++++++++++++++++++++---- tests/auto/tools/uic/baseline/config.ui.py | 2 +- 2 files changed, 23 insertions(+), 5 deletions(-) diff --git a/src/tools/uic/python/pythonwriteimports.cpp b/src/tools/uic/python/pythonwriteimports.cpp index be55696683..ce1df2284e 100644 --- a/src/tools/uic/python/pythonwriteimports.cpp +++ b/src/tools/uic/python/pythonwriteimports.cpp @@ -114,11 +114,29 @@ void WriteImports::acceptCustomWidget(DomCustomWidget *node) const auto &className = node->elementClass(); if (className.contains(QLatin1String("::"))) return; // Exclude namespaced names (just to make tests pass). - const QString &qtModule = qtModuleOf(node); + const QString &importModule = qtModuleOf(node); auto &output = m_uic->output(); - if (!qtModule.isEmpty()) - output << "from PySide2." << qtModule << ' '; - output << "import " << className << '\n'; + // For starting importing PySide2 modules + if (!importModule.isEmpty()) { + output << "from "; + if (importModule.startsWith(QLatin1String("Qt"))) + output << "PySide2."; + output << importModule; + if (!className.isEmpty()) + output << " import " << className << "\n\n"; + } else { + // When the elementHeader is not set, we know it's the continuation + // of a PySide2 import or a normal import of another module. + if (!node->elementHeader() || node->elementHeader()->text().isEmpty()) { + output << "import " << className << '\n'; + } else { // When we do have elementHeader, we know it's a relative import. + QString modulePath = node->elementHeader()->text(); + // '.h' is added by default on headers for + if (modulePath.endsWith(QLatin1String(".h"))) + modulePath.chop(2); + output << "from " << modulePath << " import " << className << '\n'; + } + } } } // namespace Python diff --git a/tests/auto/tools/uic/baseline/config.ui.py b/tests/auto/tools/uic/baseline/config.ui.py index f7e1ffc773..8be5eae39f 100644 --- a/tests/auto/tools/uic/baseline/config.ui.py +++ b/tests/auto/tools/uic/baseline/config.ui.py @@ -43,7 +43,7 @@ from PySide2.QtGui import (QBrush, QColor, QConicalGradient, QFont, QRadialGradient) from PySide2.QtWidgets import * -import GammaView +from gammaview import GammaView class Ui_Config(object): -- cgit v1.2.3 From 2f366a63b20a943ae3099605c2cdb34009ca5602 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Mon, 13 Jan 2020 15:58:14 +0100 Subject: Windows QPA: Fix message box and other system sounds Re-add the code hooking into QWindowsUiaAccessibility::notifyAccessibilityUpdate() which was removed by 0cf6297c15be45d852be98c862bd0211e6de1aa2. Fixes: QTBUG-81342 Change-Id: Ie97d7cca5b774196d53b675c92d84f4ce208f987 Reviewed-by: Oliver Wolff --- .../uiautomation/qwindowsuiaaccessibility.cpp | 53 ++++++++++++++++++++++ 1 file changed, 53 insertions(+) diff --git a/src/plugins/platforms/windows/uiautomation/qwindowsuiaaccessibility.cpp b/src/plugins/platforms/windows/uiautomation/qwindowsuiaaccessibility.cpp index c7c0deab3f..32a57473ad 100644 --- a/src/plugins/platforms/windows/uiautomation/qwindowsuiaaccessibility.cpp +++ b/src/plugins/platforms/windows/uiautomation/qwindowsuiaaccessibility.cpp @@ -52,6 +52,8 @@ #include #include +#include + QT_BEGIN_NAMESPACE using namespace QWindowsUiAutomation; @@ -85,12 +87,63 @@ bool QWindowsUiaAccessibility::handleWmGetObject(HWND hwnd, WPARAM wParam, LPARA return false; } +// Retrieve sound name by checking the icon property of a message box +// should it be the event object. +static QString alertSound(const QObject *object) +{ + if (object->inherits("QMessageBox")) { + enum MessageBoxIcon { // Keep in sync with QMessageBox::Icon + Information = 1, + Warning = 2, + Critical = 3 + }; + switch (object->property("icon").toInt()) { + case Information: + return QStringLiteral("SystemAsterisk"); + case Warning: + return QStringLiteral("SystemExclamation"); + case Critical: + return QStringLiteral("SystemHand"); + } + } + return QStringLiteral("SystemAsterisk"); +} + +static QString soundFileName(const QString &soundName) +{ + const QString key = QStringLiteral("AppEvents\\Schemes\\Apps\\.Default\\") + + soundName + QStringLiteral("\\.Current"); + return QWinRegistryKey(HKEY_CURRENT_USER, key).stringValue(L""); +} + +static void playSystemSound(const QString &soundName) +{ + if (!soundName.isEmpty() && !soundFileName(soundName).isEmpty()) { + PlaySound(reinterpret_cast(soundName.utf16()), nullptr, + SND_ALIAS | SND_ASYNC | SND_NODEFAULT | SND_NOWAIT); + } +} + // Handles accessibility update notifications. void QWindowsUiaAccessibility::notifyAccessibilityUpdate(QAccessibleEvent *event) { if (!event) return; + switch (event->type()) { + case QAccessible::PopupMenuStart: + playSystemSound(QStringLiteral("MenuPopup")); + break; + case QAccessible::MenuCommand: + playSystemSound(QStringLiteral("MenuCommand")); + break; + case QAccessible::Alert: + playSystemSound(alertSound(event->object())); + break; + default: + break; + } + QAccessibleInterface *accessible = event->accessibleInterface(); if (!isActive() || !accessible || !accessible->isValid()) return; -- cgit v1.2.3 From 01d24eea09e1312e9fa7eee98e98ce22ed504aba Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Tue, 14 Jan 2020 09:26:46 +0100 Subject: Windows QPA: Fix co-existence of several Qt versions in an application Change qtbase/ef54abae43db79792b40dfdca30ac0fa1b582354 added a new dummy message window for power notification. This causes the static class name conflict check to assume there is no conflict since it does not exist in previous Qt versions. Change it to perform the for each class name. Fixes: QTBUG-81347 Change-Id: I290806d021ac7de130a41e996d03b8fb4eb2c437 Reviewed-by: Oliver Wolff --- src/plugins/platforms/windows/qwindowscontext.cpp | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/src/plugins/platforms/windows/qwindowscontext.cpp b/src/plugins/platforms/windows/qwindowscontext.cpp index a2dd25f8cc..d31352b854 100644 --- a/src/plugins/platforms/windows/qwindowscontext.cpp +++ b/src/plugins/platforms/windows/qwindowscontext.cpp @@ -604,15 +604,12 @@ QString QWindowsContext::registerWindowClass(QString cname, // each one has to have window class names with a unique name // The first instance gets the unmodified name; if the class // has already been registered by another instance of Qt then - // add a UUID. - static int classExists = -1; - + // add a UUID. The check needs to be performed for each name + // in case new message windows are added (QTBUG-81347). const auto appInstance = static_cast(GetModuleHandle(nullptr)); - if (classExists == -1) { - WNDCLASS wcinfo; - classExists = GetClassInfo(appInstance, reinterpret_cast(cname.utf16()), &wcinfo); - classExists = classExists && wcinfo.lpfnWndProc != proc; - } + WNDCLASS wcinfo; + const bool classExists = GetClassInfo(appInstance, reinterpret_cast(cname.utf16()), &wcinfo) == TRUE + && wcinfo.lpfnWndProc != proc; if (classExists) cname += QUuid::createUuid().toString(); -- cgit v1.2.3 From 7b3d0abfa25676c34808e714d4f0cccc6b6bb885 Mon Sep 17 00:00:00 2001 From: Edward Welbourne Date: Tue, 3 Dec 2019 15:48:21 +0100 Subject: Do fewer calendrical calculations in QDateTimeParser::setDigit() It was calling a QDate's year(), month() and day() methods, each of which repeats most of the same calendrical calculations; and the same results can be obtained from the calendar's partsFromDate() all in one go. This also reduces the number of local variables needed. Change-Id: I8f84e66a5f677f55cb2113c56ebbdf7c2517e828 Reviewed-by: Qt CI Bot Reviewed-by: Thiago Macieira --- src/corelib/time/qdatetimeparser.cpp | 29 ++++++++++++++--------------- 1 file changed, 14 insertions(+), 15 deletions(-) diff --git a/src/corelib/time/qdatetimeparser.cpp b/src/corelib/time/qdatetimeparser.cpp index 61214b0c7e..2636928e69 100644 --- a/src/corelib/time/qdatetimeparser.cpp +++ b/src/corelib/time/qdatetimeparser.cpp @@ -137,13 +137,12 @@ bool QDateTimeParser::setDigit(QDateTime &v, int index, int newVal) const #endif return false; } - const SectionNode &node = sectionNodes.at(index); - const QDate date = v.date(); + QCalendar::YearMonthDay date = calendar.partsFromDate(v.date()); + if (!date.isValid()) + return false; + const QTime time = v.time(); - int year = date.year(calendar); - int month = date.month(calendar); - int day = date.day(calendar); int hour = time.hour(); int minute = time.minute(); int second = time.second(); @@ -152,14 +151,15 @@ bool QDateTimeParser::setDigit(QDateTime &v, int index, int newVal) const // Only offset from UTC is amenable to setting an int value: int offset = tspec == Qt::OffsetFromUTC ? v.offsetFromUtc() : 0; + const SectionNode &node = sectionNodes.at(index); switch (node.type) { case Hour24Section: case Hour12Section: hour = newVal; break; case MinuteSection: minute = newVal; break; case SecondSection: second = newVal; break; case MSecSection: msec = newVal; break; case YearSection2Digits: - case YearSection: year = newVal; break; - case MonthSection: month = newVal; break; + case YearSection: date.year = newVal; break; + case MonthSection: date.month = newVal; break; case DaySection: case DayOfWeekSectionShort: case DayOfWeekSectionLong: @@ -169,7 +169,7 @@ bool QDateTimeParser::setDigit(QDateTime &v, int index, int newVal) const // to 31 for february should return true return false; } - day = newVal; + date.day = newVal; break; case TimeZoneSection: if (newVal < absoluteMin(index) || newVal > absoluteMax(index)) @@ -185,15 +185,14 @@ bool QDateTimeParser::setDigit(QDateTime &v, int index, int newVal) const } if (!(node.type & DaySectionMask)) { - if (day < cachedDay) - day = cachedDay; - const int max = calendar.daysInMonth(month, year); - if (day > max) { - day = max; - } + if (date.day < cachedDay) + date.day = cachedDay; + const int max = calendar.daysInMonth(date.month, date.year); + if (date.day > max) + date.day = max; } - const QDate newDate(year, month, day, calendar); + const QDate newDate = calendar.dateFromParts(date); const QTime newTime(hour, minute, second, msec); if (!newDate.isValid() || !newTime.isValid()) return false; -- cgit v1.2.3 From e0be3ab28ed5ce028555ed7ef2f25d2964dc81a5 Mon Sep 17 00:00:00 2001 From: Edward Welbourne Date: Thu, 9 Jan 2020 11:40:50 +0100 Subject: Combine negativeYear() and printNegativeYear() They overlapped and the latter had duplicated code, so make them into a single data-driven test. At the same time, replace the '-' at the start of the expected string with QLocale::negativeSign(), since the test fails otherwise when LC_NUMERIC=nb_NO on Linux (Debian/testing). Change-Id: I051c75abff16b2e6f8278fcb152b6bde14c71f9a Reviewed-by: Thiago Macieira --- tests/auto/corelib/time/qdate/tst_qdate.cpp | 39 +++++++++++++---------------- 1 file changed, 17 insertions(+), 22 deletions(-) diff --git a/tests/auto/corelib/time/qdate/tst_qdate.cpp b/tests/auto/corelib/time/qdate/tst_qdate.cpp index dd2cb3eea8..567209dcf6 100644 --- a/tests/auto/corelib/time/qdate/tst_qdate.cpp +++ b/tests/auto/corelib/time/qdate/tst_qdate.cpp @@ -88,7 +88,7 @@ private slots: void toStringDateFormat(); void isLeapYear(); void yearsZeroToNinetyNine(); - void negativeYear() const; + void printNegativeYear_data() const; void printNegativeYear() const; void roundtripGermanLocale() const; #if QT_CONFIG(textdate) && QT_DEPRECATED_SINCE(5, 10) @@ -1458,33 +1458,28 @@ void tst_QDate::yearsZeroToNinetyNine() } } - -void tst_QDate::negativeYear() const +void tst_QDate::printNegativeYear_data() const { - QDate y(-20, 3, 4); - QVERIFY(y.isValid()); - QCOMPARE(y.year(), -20); + QTest::addColumn("year"); + QTest::addColumn("expect"); + QTest::newRow("millennium") << -1000 << QStringLiteral("-1000"); + QTest::newRow("century") << -500 << QStringLiteral("-0500"); + QTest::newRow("decade") << -20 << QStringLiteral("-0020"); + QTest::newRow("year") << -7 << QStringLiteral("-0007"); } void tst_QDate::printNegativeYear() const { - { - QDate date(-500, 3, 4); - QVERIFY(date.isValid()); - QCOMPARE(date.toString(QLatin1String("yyyy")), QString::fromLatin1("-0500")); - } - - { - QDate date(-10, 3, 4); - QVERIFY(date.isValid()); - QCOMPARE(date.toString(QLatin1String("yyyy")), QString::fromLatin1("-0010")); - } + QFETCH(int, year); + QFETCH(QString, expect); +#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) + expect.replace(QLatin1Char('-'), QLocale().negativeSign()); +#endif - { - QDate date(-2, 3, 4); - QVERIFY(date.isValid()); - QCOMPARE(date.toString(QLatin1String("yyyy")), QString::fromLatin1("-0002")); - } + QDate date(year, 3, 4); + QVERIFY(date.isValid()); + QCOMPARE(date.year(), year); + QCOMPARE(date.toString(QLatin1String("yyyy")), expect); } void tst_QDate::roundtripGermanLocale() const -- cgit v1.2.3 From 21a14767b30f6f8d27b06e609ec8eaa5ddffb324 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Tue, 14 Jan 2020 13:56:54 +0100 Subject: uic/Python: Fix missing QCursor import Fixes: PYSIDE-1182 Change-Id: I1ccc524a152ea75508166f3d2c0c60f8d829cd8f Reviewed-by: Cristian Maureira-Fredes --- src/tools/uic/python/pythonwriteimports.cpp | 2 +- tests/auto/tools/uic/baseline/config.ui.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/tools/uic/python/pythonwriteimports.cpp b/src/tools/uic/python/pythonwriteimports.cpp index ce1df2284e..963244d450 100644 --- a/src/tools/uic/python/pythonwriteimports.cpp +++ b/src/tools/uic/python/pythonwriteimports.cpp @@ -41,7 +41,7 @@ QT_BEGIN_NAMESPACE static const char *standardImports = R"I(from PySide2.QtCore import (QCoreApplication, QMetaObject, QObject, QPoint, QRect, QSize, QUrl, Qt) -from PySide2.QtGui import (QBrush, QColor, QConicalGradient, QFont, +from PySide2.QtGui import (QBrush, QColor, QConicalGradient, QCursor, QFont, QFontDatabase, QIcon, QLinearGradient, QPalette, QPainter, QPixmap, QRadialGradient) from PySide2.QtWidgets import * diff --git a/tests/auto/tools/uic/baseline/config.ui.py b/tests/auto/tools/uic/baseline/config.ui.py index 8be5eae39f..5fd558bb01 100644 --- a/tests/auto/tools/uic/baseline/config.ui.py +++ b/tests/auto/tools/uic/baseline/config.ui.py @@ -38,7 +38,7 @@ from PySide2.QtCore import (QCoreApplication, QMetaObject, QObject, QPoint, QRect, QSize, QUrl, Qt) -from PySide2.QtGui import (QBrush, QColor, QConicalGradient, QFont, +from PySide2.QtGui import (QBrush, QColor, QConicalGradient, QCursor, QFont, QFontDatabase, QIcon, QLinearGradient, QPalette, QPainter, QPixmap, QRadialGradient) from PySide2.QtWidgets import * -- cgit v1.2.3 From 8298118c527ae427ea2e8718122e1a65f4bb8bbb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= Date: Tue, 7 Jan 2020 16:18:10 +0100 Subject: macOS: Move palette setup into platform theme MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The theme was the only client, so there's no point in keeping it separate from its only call site. Change-Id: I4783c5db6975ad2daaede704ab5855c57f190344 Reviewed-by: Morten Johan Sørvig --- src/plugins/platforms/cocoa/cocoa.pro | 2 - src/plugins/platforms/cocoa/qcocoasystemsettings.h | 54 ----- .../platforms/cocoa/qcocoasystemsettings.mm | 245 --------------------- src/plugins/platforms/cocoa/qcocoatheme.mm | 196 ++++++++++++++++- 4 files changed, 195 insertions(+), 302 deletions(-) delete mode 100644 src/plugins/platforms/cocoa/qcocoasystemsettings.h delete mode 100644 src/plugins/platforms/cocoa/qcocoasystemsettings.mm diff --git a/src/plugins/platforms/cocoa/cocoa.pro b/src/plugins/platforms/cocoa/cocoa.pro index 4cf9e64447..6645b6c90a 100644 --- a/src/plugins/platforms/cocoa/cocoa.pro +++ b/src/plugins/platforms/cocoa/cocoa.pro @@ -25,7 +25,6 @@ SOURCES += main.mm \ qcocoaclipboard.mm \ qcocoadrag.mm \ qmacclipboard.mm \ - qcocoasystemsettings.mm \ qcocoainputcontext.mm \ qcocoaservices.mm \ qcocoasystemtrayicon.mm \ @@ -59,7 +58,6 @@ HEADERS += qcocoaintegration.h \ qcocoaclipboard.h \ qcocoadrag.h \ qmacclipboard.h \ - qcocoasystemsettings.h \ qcocoainputcontext.h \ qcocoaservices.h \ qcocoasystemtrayicon.h \ diff --git a/src/plugins/platforms/cocoa/qcocoasystemsettings.h b/src/plugins/platforms/cocoa/qcocoasystemsettings.h deleted file mode 100644 index cf5688bbed..0000000000 --- a/src/plugins/platforms/cocoa/qcocoasystemsettings.h +++ /dev/null @@ -1,54 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the plugins of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QCOCOASYSTEMSETTINGS_H -#define QCOCOASYSTEMSETTINGS_H - -#include -#include -#include - -QT_BEGIN_NAMESPACE - -QPalette * qt_mac_createSystemPalette(); -QHash qt_mac_createRolePalettes(); - -QT_END_NAMESPACE - -#endif diff --git a/src/plugins/platforms/cocoa/qcocoasystemsettings.mm b/src/plugins/platforms/cocoa/qcocoasystemsettings.mm deleted file mode 100644 index cb25bd7d81..0000000000 --- a/src/plugins/platforms/cocoa/qcocoasystemsettings.mm +++ /dev/null @@ -1,245 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2019 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the plugins of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qcocoasystemsettings.h" - -#include "qcocoahelpers.h" - -#include -#include -#include - -#if !QT_MACOS_PLATFORM_SDK_EQUAL_OR_ABOVE(__MAC_10_14) -@interface NSColor (MojaveForwardDeclarations) -@property (class, strong, readonly) NSColor *selectedContentBackgroundColor NS_AVAILABLE_MAC(10_14); -@property (class, strong, readonly) NSColor *unemphasizedSelectedTextBackgroundColor NS_AVAILABLE_MAC(10_14); -@property (class, strong, readonly) NSColor *unemphasizedSelectedTextColor NS_AVAILABLE_MAC(10_14); -@property (class, strong, readonly) NSColor *unemphasizedSelectedContentBackgroundColor NS_AVAILABLE_MAC(10_14); -@property (class, strong, readonly) NSArray *alternatingContentBackgroundColors NS_AVAILABLE_MAC(10_14); -// Missing from non-Mojave SDKs, even if introduced in 10.10 -@property (class, strong, readonly) NSColor *linkColor NS_AVAILABLE_MAC(10_10); -@end -#endif - -QT_BEGIN_NAMESPACE - -QPalette * qt_mac_createSystemPalette() -{ - QColor qc; - - // Standard palette initialization (copied from Qt 4 styles) - QBrush backgroundBrush = qt_mac_toQBrush([NSColor windowBackgroundColor]); - QColor background = backgroundBrush.color(); - QColor light(background.lighter(110)); - QColor dark(background.darker(160)); - QColor mid(background.darker(140)); - QPalette *palette = new QPalette(Qt::black, background, light, dark, mid, Qt::black, Qt::white); - - palette->setBrush(QPalette::Window, backgroundBrush); - - palette->setBrush(QPalette::Disabled, QPalette::WindowText, dark); - palette->setBrush(QPalette::Disabled, QPalette::Text, dark); - palette->setBrush(QPalette::Disabled, QPalette::ButtonText, dark); - palette->setBrush(QPalette::Disabled, QPalette::Base, backgroundBrush); - QBrush textBackgroundBrush = qt_mac_toQBrush([NSColor textBackgroundColor]); - palette->setBrush(QPalette::Active, QPalette::Base, textBackgroundBrush); - palette->setBrush(QPalette::Inactive, QPalette::Base, textBackgroundBrush); - palette->setColor(QPalette::Disabled, QPalette::Dark, QColor(191, 191, 191)); - palette->setColor(QPalette::Active, QPalette::Dark, QColor(191, 191, 191)); - palette->setColor(QPalette::Inactive, QPalette::Dark, QColor(191, 191, 191)); - - // System palette initialization: - QBrush br = qt_mac_toQBrush([NSColor selectedControlColor]); - palette->setBrush(QPalette::Active, QPalette::Highlight, br); - if (__builtin_available(macOS 10.14, *)) { - const auto inactiveHighlight = qt_mac_toQBrush([NSColor unemphasizedSelectedContentBackgroundColor]); - palette->setBrush(QPalette::Inactive, QPalette::Highlight, inactiveHighlight); - palette->setBrush(QPalette::Disabled, QPalette::Highlight, inactiveHighlight); - } else { - palette->setBrush(QPalette::Inactive, QPalette::Highlight, br); - palette->setBrush(QPalette::Disabled, QPalette::Highlight, br); - } - - palette->setBrush(QPalette::Shadow, qt_mac_toQColor([NSColor shadowColor])); - - qc = qt_mac_toQColor([NSColor controlTextColor]); - palette->setColor(QPalette::Active, QPalette::Text, qc); - palette->setColor(QPalette::Active, QPalette::WindowText, qc); - palette->setColor(QPalette::Active, QPalette::HighlightedText, qc); - palette->setColor(QPalette::Inactive, QPalette::Text, qc); - palette->setColor(QPalette::Inactive, QPalette::WindowText, qc); - palette->setColor(QPalette::Inactive, QPalette::HighlightedText, qc); - - qc = qt_mac_toQColor([NSColor disabledControlTextColor]); - palette->setColor(QPalette::Disabled, QPalette::Text, qc); - palette->setColor(QPalette::Disabled, QPalette::WindowText, qc); - palette->setColor(QPalette::Disabled, QPalette::HighlightedText, qc); - - palette->setBrush(QPalette::ToolTipBase, qt_mac_toQBrush([NSColor controlColor])); - - palette->setColor(QPalette::Normal, QPalette::Link, qt_mac_toQColor([NSColor linkColor])); - - return palette; -} - -struct QMacPaletteMap { - inline QMacPaletteMap(QPlatformTheme::Palette p, NSColor *a, NSColor *i) : - active(a), inactive(i), paletteRole(p) { } - - NSColor *active; - NSColor *inactive; - QPlatformTheme::Palette paletteRole; -}; - -#define MAC_PALETTE_ENTRY(pal, active, inactive) \ - QMacPaletteMap(pal, [NSColor active], [NSColor inactive]) -static QMacPaletteMap mac_widget_colors[] = { - MAC_PALETTE_ENTRY(QPlatformTheme::ToolButtonPalette, controlTextColor, disabledControlTextColor), - MAC_PALETTE_ENTRY(QPlatformTheme::ButtonPalette, controlTextColor, disabledControlTextColor), - MAC_PALETTE_ENTRY(QPlatformTheme::HeaderPalette, headerTextColor, disabledControlTextColor), - MAC_PALETTE_ENTRY(QPlatformTheme::ComboBoxPalette, controlTextColor, disabledControlTextColor), - MAC_PALETTE_ENTRY(QPlatformTheme::ItemViewPalette, textColor, disabledControlTextColor), - MAC_PALETTE_ENTRY(QPlatformTheme::MessageBoxLabelPalette, textColor, disabledControlTextColor), - MAC_PALETTE_ENTRY(QPlatformTheme::TabBarPalette, controlTextColor, disabledControlTextColor), - MAC_PALETTE_ENTRY(QPlatformTheme::LabelPalette, textColor, disabledControlTextColor), - MAC_PALETTE_ENTRY(QPlatformTheme::GroupBoxPalette, textColor, disabledControlTextColor), - MAC_PALETTE_ENTRY(QPlatformTheme::MenuPalette, controlTextColor, disabledControlTextColor), - MAC_PALETTE_ENTRY(QPlatformTheme::MenuBarPalette, controlTextColor, disabledControlTextColor), - MAC_PALETTE_ENTRY(QPlatformTheme::TextEditPalette, textColor, disabledControlTextColor), - MAC_PALETTE_ENTRY(QPlatformTheme::TextLineEditPalette, textColor, disabledControlTextColor) -}; -#undef MAC_PALETTE_ENTRY - -static const int mac_widget_colors_count = sizeof(mac_widget_colors) / sizeof(mac_widget_colors[0]); - -QHash qt_mac_createRolePalettes() -{ - QHash palettes; - QColor qc; - for (int i = 0; i < mac_widget_colors_count; i++) { - QPalette &pal = *qt_mac_createSystemPalette(); - if (mac_widget_colors[i].active) { - qc = qt_mac_toQColor(mac_widget_colors[i].active); - pal.setColor(QPalette::Active, QPalette::Text, qc); - pal.setColor(QPalette::Inactive, QPalette::Text, qc); - pal.setColor(QPalette::Active, QPalette::WindowText, qc); - pal.setColor(QPalette::Inactive, QPalette::WindowText, qc); - pal.setColor(QPalette::Active, QPalette::HighlightedText, qc); - pal.setColor(QPalette::Inactive, QPalette::HighlightedText, qc); - pal.setColor(QPalette::Active, QPalette::ButtonText, qc); - pal.setColor(QPalette::Inactive, QPalette::ButtonText, qc); - qc = qt_mac_toQColor(mac_widget_colors[i].inactive); - pal.setColor(QPalette::Disabled, QPalette::Text, qc); - pal.setColor(QPalette::Disabled, QPalette::WindowText, qc); - pal.setColor(QPalette::Disabled, QPalette::HighlightedText, qc); - pal.setColor(QPalette::Disabled, QPalette::ButtonText, qc); - } - if (mac_widget_colors[i].paletteRole == QPlatformTheme::MenuPalette - || mac_widget_colors[i].paletteRole == QPlatformTheme::MenuBarPalette) { - NSColor *selectedMenuItemColor = nil; - if (__builtin_available(macOS 10.14, *)) { - // Cheap approximation for NSVisualEffectView (see deprecation note for selectedMenuItemTextColor) - selectedMenuItemColor = [[NSColor selectedContentBackgroundColor] highlightWithLevel:0.4]; - } else { - // selectedMenuItemColor would presumably be the correct color to use as the background - // for selected menu items. But that color is always blue, and doesn't follow the - // appearance color in system preferences. So we therefore deliberatly choose to use - // keyboardFocusIndicatorColor instead, which appears to have the same color value. - selectedMenuItemColor = [NSColor keyboardFocusIndicatorColor]; - } - pal.setBrush(QPalette::Highlight, qt_mac_toQColor(selectedMenuItemColor)); - qc = qt_mac_toQColor([NSColor labelColor]); - pal.setBrush(QPalette::ButtonText, qc); - pal.setBrush(QPalette::Text, qc); - qc = qt_mac_toQColor([NSColor selectedMenuItemTextColor]); - pal.setBrush(QPalette::HighlightedText, qc); - qc = qt_mac_toQColor([NSColor disabledControlTextColor]); - pal.setBrush(QPalette::Disabled, QPalette::Text, qc); - } else if ((mac_widget_colors[i].paletteRole == QPlatformTheme::ButtonPalette) - || (mac_widget_colors[i].paletteRole == QPlatformTheme::HeaderPalette) - || (mac_widget_colors[i].paletteRole == QPlatformTheme::TabBarPalette)) { - pal.setColor(QPalette::Disabled, QPalette::ButtonText, - pal.color(QPalette::Disabled, QPalette::Text)); - pal.setColor(QPalette::Inactive, QPalette::ButtonText, - pal.color(QPalette::Inactive, QPalette::Text)); - pal.setColor(QPalette::Active, QPalette::ButtonText, - pal.color(QPalette::Active, QPalette::Text)); - } else if (mac_widget_colors[i].paletteRole == QPlatformTheme::ItemViewPalette) { - NSArray *baseColors = nil; - NSColor *activeHighlightColor = nil; - if (__builtin_available(macOS 10.14, *)) { - baseColors = [NSColor alternatingContentBackgroundColors]; - activeHighlightColor = [NSColor selectedContentBackgroundColor]; - pal.setBrush(QPalette::Inactive, QPalette::HighlightedText, - qt_mac_toQBrush([NSColor unemphasizedSelectedTextColor])); - } else { - baseColors = [NSColor controlAlternatingRowBackgroundColors]; - activeHighlightColor = [NSColor alternateSelectedControlColor]; - pal.setBrush(QPalette::Inactive, QPalette::HighlightedText, - pal.brush(QPalette::Active, QPalette::Text)); - } - pal.setBrush(QPalette::Base, qt_mac_toQBrush(baseColors[0])); - pal.setBrush(QPalette::AlternateBase, qt_mac_toQBrush(baseColors[1])); - pal.setBrush(QPalette::Active, QPalette::Highlight, - qt_mac_toQBrush(activeHighlightColor)); - pal.setBrush(QPalette::Active, QPalette::HighlightedText, - qt_mac_toQBrush([NSColor alternateSelectedControlTextColor])); - pal.setBrush(QPalette::Inactive, QPalette::Text, - pal.brush(QPalette::Active, QPalette::Text)); - } else if (mac_widget_colors[i].paletteRole == QPlatformTheme::TextEditPalette) { - pal.setBrush(QPalette::Active, QPalette::Base, qt_mac_toQColor([NSColor textBackgroundColor])); - pal.setBrush(QPalette::Inactive, QPalette::Text, - pal.brush(QPalette::Active, QPalette::Text)); - pal.setBrush(QPalette::Inactive, QPalette::HighlightedText, - pal.brush(QPalette::Active, QPalette::Text)); - } else if (mac_widget_colors[i].paletteRole == QPlatformTheme::TextLineEditPalette - || mac_widget_colors[i].paletteRole == QPlatformTheme::ComboBoxPalette) { - pal.setBrush(QPalette::Active, QPalette::Base, qt_mac_toQColor([NSColor textBackgroundColor])); - pal.setBrush(QPalette::Disabled, QPalette::Base, - pal.brush(QPalette::Active, QPalette::Base)); - } else if (mac_widget_colors[i].paletteRole == QPlatformTheme::LabelPalette) { - qc = qt_mac_toQColor([NSColor labelColor]); - pal.setBrush(QPalette::Inactive, QPalette::ToolTipText, qc); - } - palettes.insert(mac_widget_colors[i].paletteRole, &pal); - } - return palettes; -} - -QT_END_NAMESPACE diff --git a/src/plugins/platforms/cocoa/qcocoatheme.mm b/src/plugins/platforms/cocoa/qcocoatheme.mm index 387df65721..a76ba300e9 100644 --- a/src/plugins/platforms/cocoa/qcocoatheme.mm +++ b/src/plugins/platforms/cocoa/qcocoatheme.mm @@ -45,7 +45,6 @@ #include #include -#include "qcocoasystemsettings.h" #include "qcocoasystemtrayicon.h" #include "qcocoamenuitem.h" #include "qcocoamenu.h" @@ -80,8 +79,203 @@ #include +#if !QT_MACOS_PLATFORM_SDK_EQUAL_OR_ABOVE(__MAC_10_14) +@interface NSColor (MojaveForwardDeclarations) +@property (class, strong, readonly) NSColor *selectedContentBackgroundColor NS_AVAILABLE_MAC(10_14); +@property (class, strong, readonly) NSColor *unemphasizedSelectedTextBackgroundColor NS_AVAILABLE_MAC(10_14); +@property (class, strong, readonly) NSColor *unemphasizedSelectedTextColor NS_AVAILABLE_MAC(10_14); +@property (class, strong, readonly) NSColor *unemphasizedSelectedContentBackgroundColor NS_AVAILABLE_MAC(10_14); +@property (class, strong, readonly) NSArray *alternatingContentBackgroundColors NS_AVAILABLE_MAC(10_14); +// Missing from non-Mojave SDKs, even if introduced in 10.10 +@property (class, strong, readonly) NSColor *linkColor NS_AVAILABLE_MAC(10_10); +@end +#endif + QT_BEGIN_NAMESPACE +static QPalette *qt_mac_createSystemPalette() +{ + QColor qc; + + // Standard palette initialization (copied from Qt 4 styles) + QBrush backgroundBrush = qt_mac_toQBrush([NSColor windowBackgroundColor]); + QColor background = backgroundBrush.color(); + QColor light(background.lighter(110)); + QColor dark(background.darker(160)); + QColor mid(background.darker(140)); + QPalette *palette = new QPalette(Qt::black, background, light, dark, mid, Qt::black, Qt::white); + + palette->setBrush(QPalette::Window, backgroundBrush); + + palette->setBrush(QPalette::Disabled, QPalette::WindowText, dark); + palette->setBrush(QPalette::Disabled, QPalette::Text, dark); + palette->setBrush(QPalette::Disabled, QPalette::ButtonText, dark); + palette->setBrush(QPalette::Disabled, QPalette::Base, backgroundBrush); + QBrush textBackgroundBrush = qt_mac_toQBrush([NSColor textBackgroundColor]); + palette->setBrush(QPalette::Active, QPalette::Base, textBackgroundBrush); + palette->setBrush(QPalette::Inactive, QPalette::Base, textBackgroundBrush); + palette->setColor(QPalette::Disabled, QPalette::Dark, QColor(191, 191, 191)); + palette->setColor(QPalette::Active, QPalette::Dark, QColor(191, 191, 191)); + palette->setColor(QPalette::Inactive, QPalette::Dark, QColor(191, 191, 191)); + + // System palette initialization: + QBrush br = qt_mac_toQBrush([NSColor selectedControlColor]); + palette->setBrush(QPalette::Active, QPalette::Highlight, br); + if (__builtin_available(macOS 10.14, *)) { + const auto inactiveHighlight = qt_mac_toQBrush([NSColor unemphasizedSelectedContentBackgroundColor]); + palette->setBrush(QPalette::Inactive, QPalette::Highlight, inactiveHighlight); + palette->setBrush(QPalette::Disabled, QPalette::Highlight, inactiveHighlight); + } else { + palette->setBrush(QPalette::Inactive, QPalette::Highlight, br); + palette->setBrush(QPalette::Disabled, QPalette::Highlight, br); + } + + palette->setBrush(QPalette::Shadow, qt_mac_toQColor([NSColor shadowColor])); + + qc = qt_mac_toQColor([NSColor controlTextColor]); + palette->setColor(QPalette::Active, QPalette::Text, qc); + palette->setColor(QPalette::Active, QPalette::WindowText, qc); + palette->setColor(QPalette::Active, QPalette::HighlightedText, qc); + palette->setColor(QPalette::Inactive, QPalette::Text, qc); + palette->setColor(QPalette::Inactive, QPalette::WindowText, qc); + palette->setColor(QPalette::Inactive, QPalette::HighlightedText, qc); + + qc = qt_mac_toQColor([NSColor disabledControlTextColor]); + palette->setColor(QPalette::Disabled, QPalette::Text, qc); + palette->setColor(QPalette::Disabled, QPalette::WindowText, qc); + palette->setColor(QPalette::Disabled, QPalette::HighlightedText, qc); + + palette->setBrush(QPalette::ToolTipBase, qt_mac_toQBrush([NSColor controlColor])); + + palette->setColor(QPalette::Normal, QPalette::Link, qt_mac_toQColor([NSColor linkColor])); + + return palette; +} + +struct QMacPaletteMap { + inline QMacPaletteMap(QPlatformTheme::Palette p, NSColor *a, NSColor *i) : + active(a), inactive(i), paletteRole(p) { } + + NSColor *active; + NSColor *inactive; + QPlatformTheme::Palette paletteRole; +}; + +#define MAC_PALETTE_ENTRY(pal, active, inactive) \ + QMacPaletteMap(pal, [NSColor active], [NSColor inactive]) +static QMacPaletteMap mac_widget_colors[] = { + MAC_PALETTE_ENTRY(QPlatformTheme::ToolButtonPalette, controlTextColor, disabledControlTextColor), + MAC_PALETTE_ENTRY(QPlatformTheme::ButtonPalette, controlTextColor, disabledControlTextColor), + MAC_PALETTE_ENTRY(QPlatformTheme::HeaderPalette, headerTextColor, disabledControlTextColor), + MAC_PALETTE_ENTRY(QPlatformTheme::ComboBoxPalette, controlTextColor, disabledControlTextColor), + MAC_PALETTE_ENTRY(QPlatformTheme::ItemViewPalette, textColor, disabledControlTextColor), + MAC_PALETTE_ENTRY(QPlatformTheme::MessageBoxLabelPalette, textColor, disabledControlTextColor), + MAC_PALETTE_ENTRY(QPlatformTheme::TabBarPalette, controlTextColor, disabledControlTextColor), + MAC_PALETTE_ENTRY(QPlatformTheme::LabelPalette, textColor, disabledControlTextColor), + MAC_PALETTE_ENTRY(QPlatformTheme::GroupBoxPalette, textColor, disabledControlTextColor), + MAC_PALETTE_ENTRY(QPlatformTheme::MenuPalette, controlTextColor, disabledControlTextColor), + MAC_PALETTE_ENTRY(QPlatformTheme::MenuBarPalette, controlTextColor, disabledControlTextColor), + MAC_PALETTE_ENTRY(QPlatformTheme::TextEditPalette, textColor, disabledControlTextColor), + MAC_PALETTE_ENTRY(QPlatformTheme::TextLineEditPalette, textColor, disabledControlTextColor) +}; +#undef MAC_PALETTE_ENTRY + +static const int mac_widget_colors_count = sizeof(mac_widget_colors) / sizeof(mac_widget_colors[0]); + +static QHash qt_mac_createRolePalettes() +{ + QHash palettes; + QColor qc; + for (int i = 0; i < mac_widget_colors_count; i++) { + QPalette &pal = *qt_mac_createSystemPalette(); + if (mac_widget_colors[i].active) { + qc = qt_mac_toQColor(mac_widget_colors[i].active); + pal.setColor(QPalette::Active, QPalette::Text, qc); + pal.setColor(QPalette::Inactive, QPalette::Text, qc); + pal.setColor(QPalette::Active, QPalette::WindowText, qc); + pal.setColor(QPalette::Inactive, QPalette::WindowText, qc); + pal.setColor(QPalette::Active, QPalette::HighlightedText, qc); + pal.setColor(QPalette::Inactive, QPalette::HighlightedText, qc); + pal.setColor(QPalette::Active, QPalette::ButtonText, qc); + pal.setColor(QPalette::Inactive, QPalette::ButtonText, qc); + qc = qt_mac_toQColor(mac_widget_colors[i].inactive); + pal.setColor(QPalette::Disabled, QPalette::Text, qc); + pal.setColor(QPalette::Disabled, QPalette::WindowText, qc); + pal.setColor(QPalette::Disabled, QPalette::HighlightedText, qc); + pal.setColor(QPalette::Disabled, QPalette::ButtonText, qc); + } + if (mac_widget_colors[i].paletteRole == QPlatformTheme::MenuPalette + || mac_widget_colors[i].paletteRole == QPlatformTheme::MenuBarPalette) { + NSColor *selectedMenuItemColor = nil; + if (__builtin_available(macOS 10.14, *)) { + // Cheap approximation for NSVisualEffectView (see deprecation note for selectedMenuItemTextColor) + selectedMenuItemColor = [[NSColor selectedContentBackgroundColor] highlightWithLevel:0.4]; + } else { + // selectedMenuItemColor would presumably be the correct color to use as the background + // for selected menu items. But that color is always blue, and doesn't follow the + // appearance color in system preferences. So we therefore deliberatly choose to use + // keyboardFocusIndicatorColor instead, which appears to have the same color value. + selectedMenuItemColor = [NSColor keyboardFocusIndicatorColor]; + } + pal.setBrush(QPalette::Highlight, qt_mac_toQColor(selectedMenuItemColor)); + qc = qt_mac_toQColor([NSColor labelColor]); + pal.setBrush(QPalette::ButtonText, qc); + pal.setBrush(QPalette::Text, qc); + qc = qt_mac_toQColor([NSColor selectedMenuItemTextColor]); + pal.setBrush(QPalette::HighlightedText, qc); + qc = qt_mac_toQColor([NSColor disabledControlTextColor]); + pal.setBrush(QPalette::Disabled, QPalette::Text, qc); + } else if ((mac_widget_colors[i].paletteRole == QPlatformTheme::ButtonPalette) + || (mac_widget_colors[i].paletteRole == QPlatformTheme::HeaderPalette) + || (mac_widget_colors[i].paletteRole == QPlatformTheme::TabBarPalette)) { + pal.setColor(QPalette::Disabled, QPalette::ButtonText, + pal.color(QPalette::Disabled, QPalette::Text)); + pal.setColor(QPalette::Inactive, QPalette::ButtonText, + pal.color(QPalette::Inactive, QPalette::Text)); + pal.setColor(QPalette::Active, QPalette::ButtonText, + pal.color(QPalette::Active, QPalette::Text)); + } else if (mac_widget_colors[i].paletteRole == QPlatformTheme::ItemViewPalette) { + NSArray *baseColors = nil; + NSColor *activeHighlightColor = nil; + if (__builtin_available(macOS 10.14, *)) { + baseColors = [NSColor alternatingContentBackgroundColors]; + activeHighlightColor = [NSColor selectedContentBackgroundColor]; + pal.setBrush(QPalette::Inactive, QPalette::HighlightedText, + qt_mac_toQBrush([NSColor unemphasizedSelectedTextColor])); + } else { + baseColors = [NSColor controlAlternatingRowBackgroundColors]; + activeHighlightColor = [NSColor alternateSelectedControlColor]; + pal.setBrush(QPalette::Inactive, QPalette::HighlightedText, + pal.brush(QPalette::Active, QPalette::Text)); + } + pal.setBrush(QPalette::Base, qt_mac_toQBrush(baseColors[0])); + pal.setBrush(QPalette::AlternateBase, qt_mac_toQBrush(baseColors[1])); + pal.setBrush(QPalette::Active, QPalette::Highlight, + qt_mac_toQBrush(activeHighlightColor)); + pal.setBrush(QPalette::Active, QPalette::HighlightedText, + qt_mac_toQBrush([NSColor alternateSelectedControlTextColor])); + pal.setBrush(QPalette::Inactive, QPalette::Text, + pal.brush(QPalette::Active, QPalette::Text)); + } else if (mac_widget_colors[i].paletteRole == QPlatformTheme::TextEditPalette) { + pal.setBrush(QPalette::Active, QPalette::Base, qt_mac_toQColor([NSColor textBackgroundColor])); + pal.setBrush(QPalette::Inactive, QPalette::Text, + pal.brush(QPalette::Active, QPalette::Text)); + pal.setBrush(QPalette::Inactive, QPalette::HighlightedText, + pal.brush(QPalette::Active, QPalette::Text)); + } else if (mac_widget_colors[i].paletteRole == QPlatformTheme::TextLineEditPalette + || mac_widget_colors[i].paletteRole == QPlatformTheme::ComboBoxPalette) { + pal.setBrush(QPalette::Active, QPalette::Base, qt_mac_toQColor([NSColor textBackgroundColor])); + pal.setBrush(QPalette::Disabled, QPalette::Base, + pal.brush(QPalette::Active, QPalette::Base)); + } else if (mac_widget_colors[i].paletteRole == QPlatformTheme::LabelPalette) { + qc = qt_mac_toQColor([NSColor labelColor]); + pal.setBrush(QPalette::Inactive, QPalette::ToolTipText, qc); + } + palettes.insert(mac_widget_colors[i].paletteRole, &pal); + } + return palettes; +} + const char *QCocoaTheme::name = "cocoa"; QCocoaTheme::QCocoaTheme() -- cgit v1.2.3 From 7a59d6f138ff8799170cc03d709525ab965d703a Mon Sep 17 00:00:00 2001 From: Nico Vertriest Date: Wed, 8 Jan 2020 14:46:12 +0100 Subject: Doc: Correct non-link related qdoc compilation errors Task-number: QTBUG-79824 Change-Id: I94dc566c9fb11bc8c598c0d5c043b6f388ebdc80 Reviewed-by: Paul Wicking --- src/corelib/io/qprocess.cpp | 4 +++- src/corelib/itemmodels/qstringlistmodel.cpp | 5 +++++ src/corelib/tools/qline.cpp | 2 +- src/corelib/tools/qscopeguard.qdoc | 8 ++++---- src/corelib/tools/qsharedpointer.cpp | 2 ++ src/testlib/qsignalspy.qdoc | 6 +++--- src/widgets/dialogs/qfiledialog.cpp | 3 ++- src/widgets/dialogs/qfilesystemmodel.cpp | 3 ++- src/widgets/kernel/qshortcut.cpp | 2 +- 9 files changed, 23 insertions(+), 12 deletions(-) diff --git a/src/corelib/io/qprocess.cpp b/src/corelib/io/qprocess.cpp index 3a77242d7c..49e0847d44 100644 --- a/src/corelib/io/qprocess.cpp +++ b/src/corelib/io/qprocess.cpp @@ -1004,7 +1004,7 @@ QT_WARNING_POP /*! \internal - Returns true if we emitted readyRead(). + Returns \c true if we emitted readyRead(). */ bool QProcessPrivate::tryReadFromChannel(Channel *channel) { @@ -2187,6 +2187,8 @@ bool QProcess::startDetached(qint64 *pid) This method is an alias for start(), and exists only to fully implement the interface defined by QIODevice. + Returns \c true if the program has been started. + \sa start(), setProgram(), setArguments() */ bool QProcess::open(OpenMode mode) diff --git a/src/corelib/itemmodels/qstringlistmodel.cpp b/src/corelib/itemmodels/qstringlistmodel.cpp index a248cdcd38..4c7616a126 100644 --- a/src/corelib/itemmodels/qstringlistmodel.cpp +++ b/src/corelib/itemmodels/qstringlistmodel.cpp @@ -212,6 +212,7 @@ Qt::ItemFlags QStringListModel::flags(const QModelIndex &index) const \a index in the model, to the provided \a value. The dataChanged() signal is emitted if the item is changed. + Returns \c true after emitting the dataChanged() signal. \sa Qt::ItemDataRole, data() */ @@ -249,6 +250,8 @@ bool QStringListModel::clearItemData(const QModelIndex &index) specified, indicating that the rows are inserted in the top level of the model. + Returns \c true if the insertion was successful. + \sa QAbstractItemModel::insertRows() */ @@ -275,6 +278,8 @@ bool QStringListModel::insertRows(int row, int count, const QModelIndex &parent) specified, indicating that the rows are removed in the top level of the model. + Returns \c true if the row removal was successful. + \sa QAbstractItemModel::removeRows() */ diff --git a/src/corelib/tools/qline.cpp b/src/corelib/tools/qline.cpp index 3afd23d76b..dde66ed093 100644 --- a/src/corelib/tools/qline.cpp +++ b/src/corelib/tools/qline.cpp @@ -374,7 +374,7 @@ QDataStream &operator>>(QDataStream &stream, QLine &line) */ /*! - \enum QLineF::IntersectionType + \enum QLineF::IntersectType Describes the intersection between two lines. diff --git a/src/corelib/tools/qscopeguard.qdoc b/src/corelib/tools/qscopeguard.qdoc index 5a9b7fd210..6b3c942e84 100644 --- a/src/corelib/tools/qscopeguard.qdoc +++ b/src/corelib/tools/qscopeguard.qdoc @@ -51,10 +51,10 @@ QT_BEGIN_NAMESPACE of the scope. \ingroup misc - QScopeGuard is a class which sole purpose is to run a function \e F in - its destructor. This is useful for guaranteeing your cleanup code is - executed, whether the function is exited normally, exited early by a return - statement, or exited by an exception. + QScopeGuard is a class of which the sole purpose is to run the function + \a f in its destructor. This is useful for guaranteeing + your cleanup code is executed, whether the function is exited normally, + exited early by a return statement, or exited by an exception. If \e F is a lambda then you cannot instantiate the template directly, therefore the qScopeGuard() helper is provided and QScopeGuard is made a diff --git a/src/corelib/tools/qsharedpointer.cpp b/src/corelib/tools/qsharedpointer.cpp index f185d2f23f..0576fb2bd0 100644 --- a/src/corelib/tools/qsharedpointer.cpp +++ b/src/corelib/tools/qsharedpointer.cpp @@ -1285,6 +1285,8 @@ \relates QSharedPointer \since 5.14 + Returns a shared pointer to the pointer held by \a src. + Same as qSharedPointerObjectCast(). This function is provided for STL compatibility. */ diff --git a/src/testlib/qsignalspy.qdoc b/src/testlib/qsignalspy.qdoc index d40c84907c..42e02ed601 100644 --- a/src/testlib/qsignalspy.qdoc +++ b/src/testlib/qsignalspy.qdoc @@ -102,9 +102,9 @@ \since 5.14 Constructs a new QSignalSpy that listens for emissions of the \a signal - from the QObject \a object. If QSignalSpy is not able to listen for a - valid signal (for example, because \a object is \nullptr or \a signal does - not denote a valid signal of \a object), an explanatory warning message + from the QObject \a obj. If QSignalSpy is not able to listen for a + valid signal (for example, because \a obj is \nullptr or \a signal does + not denote a valid signal of \a obj), an explanatory warning message will be output using qWarning() and subsequent calls to \c isValid() will return false. diff --git a/src/widgets/dialogs/qfiledialog.cpp b/src/widgets/dialogs/qfiledialog.cpp index a1b9003c1c..787c0e6511 100644 --- a/src/widgets/dialogs/qfiledialog.cpp +++ b/src/widgets/dialogs/qfiledialog.cpp @@ -2374,7 +2374,8 @@ QList QFileDialog::getOpenFileUrls(QWidget *parent, This function is used to access local files on Qt for WebAssembly, where the web sandbox places restrictions on how such access may happen. Its implementation will - make the browser display a native file dialog, where the user makes the file selection. + make the browser display a native file dialog, where the user makes the file selection + based on the parameter \a nameFilter. It can also be used on other platforms, where it will fall back to using QFileDialog. diff --git a/src/widgets/dialogs/qfilesystemmodel.cpp b/src/widgets/dialogs/qfilesystemmodel.cpp index a04189513a..86afb27719 100644 --- a/src/widgets/dialogs/qfilesystemmodel.cpp +++ b/src/widgets/dialogs/qfilesystemmodel.cpp @@ -1214,7 +1214,8 @@ QMimeData *QFileSystemModel::mimeData(const QModelIndexList &indexes) const /*! Handles the \a data supplied by a drag and drop operation that ended with the given \a action over the row in the model specified by the \a row and - \a column and by the \a parent index. + \a column and by the \a parent index. Returns true if the operation was + successful. \sa supportedDropActions() */ diff --git a/src/widgets/kernel/qshortcut.cpp b/src/widgets/kernel/qshortcut.cpp index f157ba2943..eec65c8625 100644 --- a/src/widgets/kernel/qshortcut.cpp +++ b/src/widgets/kernel/qshortcut.cpp @@ -475,7 +475,7 @@ QShortcut::QShortcut(QWidget *parent) match the \a key sequence. Depending on the ambiguity of the event, the shortcut will call the \a member function, or the \a ambiguousMember function, if the key press was in the shortcut's - \a shortcutContext. + \a context. */ QShortcut::QShortcut(const QKeySequence &key, QWidget *parent, const char *member, const char *ambiguousMember, -- cgit v1.2.3