From 6e1d70ae12baae4610356ec7b69635ad75a97b4e Mon Sep 17 00:00:00 2001 From: Volker Hilsheimer Date: Wed, 22 Jan 2020 13:51:01 +0100 Subject: QPushButton: only trigger button when click occurs within the bevel rect On the mac, the push button's bevel doesn't cover the entire widget rectangle, but is smaller to leave space for focus frame, shadow, and in general to meet style guidelines. Without this change, a click anywhere inside the widget would activate the button. QAbstractButton::hitButton can be reimplemented to limit the area in which the button is triggered. However, getting the rectangle also requires an addition to QStyle, so that we can query QStyle::subElementRect for the actual area the button's bevel covers. As a side effect, tests that use QPushButton and assume that it responds to clicks at position 0,0 have to be fixed so that they don't fail on mac. Change-Id: I01b60a763bccf39090aee5b2369af300f922d226 Fixes: QTBUG-81452 Reviewed-by: Richard Moe Gustavsen --- .../kernel/qmouseevent_modal/tst_qmouseevent_modal.cpp | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) (limited to 'tests/auto/gui') diff --git a/tests/auto/gui/kernel/qmouseevent_modal/tst_qmouseevent_modal.cpp b/tests/auto/gui/kernel/qmouseevent_modal/tst_qmouseevent_modal.cpp index 8e6ca486d5..758aeb42b9 100644 --- a/tests/auto/gui/kernel/qmouseevent_modal/tst_qmouseevent_modal.cpp +++ b/tests/auto/gui/kernel/qmouseevent_modal/tst_qmouseevent_modal.cpp @@ -42,6 +42,19 @@ class TstWidget; class TstDialog; QT_FORWARD_DECLARE_CLASS(QPushButton) +class TestButton : public QPushButton +{ +public: + TestButton(const QString &title, QWidget *parent = nullptr) + : QPushButton(title, parent) + {} +protected: + bool hitButton(const QPoint &pos) const override + { + return rect().contains(pos); + } +}; + class tst_qmouseevent_modal : public QObject { Q_OBJECT @@ -63,7 +76,7 @@ public: public slots: void buttonPressed(); public: - QPushButton *pb; + TestButton *pb; TstDialog *d; }; @@ -135,7 +148,7 @@ void tst_qmouseevent_modal::mousePressRelease() TstWidget::TstWidget() { - pb = new QPushButton( "Press me", this ); + pb = new TestButton( "Press me", this ); pb->setObjectName("testbutton"); QSize s = pb->sizeHint(); pb->setGeometry( 5, 5, s.width(), s.height() ); -- cgit v1.2.3 From 967e55a628fcddde38c67791665969e9a530d4d8 Mon Sep 17 00:00:00 2001 From: Allan Sandfeld Jensen Date: Thu, 12 Dec 2019 11:33:58 +0100 Subject: Allow creating a valid QColorSpace one value at a time The change to using setters left a quirk from the previous un-mutable design where you couldn't set values on an invalid color space and create a valid one. This changes that so it works as expected for an imperative API, but is also needed for the declarative QML bindings. Change-Id: I246cfc38b364b156238151c42c1df82a3f1cc9d3 Reviewed-by: Eirik Aavitsland --- tests/auto/gui/painting/qcolorspace/tst_qcolorspace.cpp | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'tests/auto/gui') diff --git a/tests/auto/gui/painting/qcolorspace/tst_qcolorspace.cpp b/tests/auto/gui/painting/qcolorspace/tst_qcolorspace.cpp index 945a4772f3..99fb3d3e72 100644 --- a/tests/auto/gui/painting/qcolorspace/tst_qcolorspace.cpp +++ b/tests/auto/gui/painting/qcolorspace/tst_qcolorspace.cpp @@ -413,6 +413,7 @@ void tst_QColorSpace::primaries2() void tst_QColorSpace::invalidPrimaries() { + QTest::ignoreMessage(QtWarningMsg, QRegularExpression("QColorSpace attempted constructed from invalid primaries")); QColorSpace custom(QPointF(), QPointF(), QPointF(), QPointF(), QColorSpace::TransferFunction::Linear); QVERIFY(!custom.isValid()); } @@ -444,8 +445,15 @@ void tst_QColorSpace::changeTransferFunction() QColorSpace undefined; QCOMPARE(undefined.withTransferFunction(QColorSpace::TransferFunction::Linear), undefined); - undefined.setTransferFunction(QColorSpace::TransferFunction::SRgb); - QCOMPARE(undefined, QColorSpace()); + + QColorSpace partial; + partial.setTransferFunction(QColorSpace::TransferFunction::SRgb); + QCOMPARE(partial.transferFunction(), QColorSpace::TransferFunction::SRgb); + QVERIFY(!partial.isValid()); + + partial.setPrimaries(QColorSpace::Primaries::SRgb); + QVERIFY(partial.isValid()); + QCOMPARE(partial, QColorSpace(QColorSpace::SRgb)); } void tst_QColorSpace::changePrimaries() -- cgit v1.2.3 From 2d265dce58d26047f196d79eabfe41edab45c799 Mon Sep 17 00:00:00 2001 From: Giuseppe D'Angelo Date: Fri, 31 Jan 2020 14:32:24 +0100 Subject: Markdown importer: properly set hyperlinks The "title" in markdown is the tooltip, not the name attribute of a link. Also, tell the char format that it's an anchor. Change-Id: I2978848ec6705fe16376d6fe17f31007cce4b801 Reviewed-by: Shawn Rutledge --- .../gui/text/qtextmarkdownwriter/data/links.md | 25 ++++++++++++++++++++++ .../tst_qtextmarkdownwriter.cpp | 1 + 2 files changed, 26 insertions(+) create mode 100644 tests/auto/gui/text/qtextmarkdownwriter/data/links.md (limited to 'tests/auto/gui') diff --git a/tests/auto/gui/text/qtextmarkdownwriter/data/links.md b/tests/auto/gui/text/qtextmarkdownwriter/data/links.md new file mode 100644 index 0000000000..33cdb2b3ab --- /dev/null +++ b/tests/auto/gui/text/qtextmarkdownwriter/data/links.md @@ -0,0 +1,25 @@ +A series of links. + +[link](/uri) + +[link]() + +[link](/uri "title") + +[link](/uri "àbcdè") + +[link](/uri "title title \" title title") + +[link](/url "title \""") + +[link](/url "title +title +title title +\"title\" title \" +title") + +* [link](/url "title") +* [link](/url) +* [link](/url "title +title title") +* nonlink diff --git a/tests/auto/gui/text/qtextmarkdownwriter/tst_qtextmarkdownwriter.cpp b/tests/auto/gui/text/qtextmarkdownwriter/tst_qtextmarkdownwriter.cpp index d15e856a20..31592c7f0f 100644 --- a/tests/auto/gui/text/qtextmarkdownwriter/tst_qtextmarkdownwriter.cpp +++ b/tests/auto/gui/text/qtextmarkdownwriter/tst_qtextmarkdownwriter.cpp @@ -368,6 +368,7 @@ void tst_QTextMarkdownWriter::rewriteDocument_data() QTest::newRow("example") << "example.md"; QTest::newRow("list items after headings") << "headingsAndLists.md"; QTest::newRow("word wrap") << "wordWrap.md"; + QTest::newRow("links") << "links.md"; } void tst_QTextMarkdownWriter::rewriteDocument() -- cgit v1.2.3