From dcf711bdce97778874e6a9bb59b00a0b7d9d84a0 Mon Sep 17 00:00:00 2001 From: J-P Nurmi Date: Wed, 31 May 2017 09:11:56 +0200 Subject: Add missing QQuickMenu::defaultFont() Change-Id: I74e512074cbc66378ffd71f8040ae8977a3ffeac Reviewed-by: Mitch Curtis --- src/quicktemplates2/qquickmenu.cpp | 6 ++++++ src/quicktemplates2/qquickmenu_p.h | 2 ++ 2 files changed, 8 insertions(+) diff --git a/src/quicktemplates2/qquickmenu.cpp b/src/quicktemplates2/qquickmenu.cpp index 04305cea..e6f22e2b 100644 --- a/src/quicktemplates2/qquickmenu.cpp +++ b/src/quicktemplates2/qquickmenu.cpp @@ -37,6 +37,7 @@ #include "qquickmenu_p.h" #include "qquickmenu_p_p.h" #include "qquickmenuitem_p.h" +#include "qquickcontrol_p_p.h" #include #include @@ -525,6 +526,11 @@ void QQuickMenu::keyReleaseEvent(QKeyEvent *event) item->forceActiveFocus(); } +QFont QQuickMenu::defaultFont() const +{ + return QQuickControlPrivate::themeFont(QPlatformTheme::MenuFont); +} + #if QT_CONFIG(accessibility) QAccessible::Role QQuickMenu::accessibleRole() const { diff --git a/src/quicktemplates2/qquickmenu_p.h b/src/quicktemplates2/qquickmenu_p.h index a899fe51..6d1a4985 100644 --- a/src/quicktemplates2/qquickmenu_p.h +++ b/src/quicktemplates2/qquickmenu_p.h @@ -91,6 +91,8 @@ Q_SIGNALS: void titleChanged(); protected: + QFont defaultFont() const override; + #if QT_CONFIG(accessibility) QAccessible::Role accessibleRole() const override; #endif -- cgit v1.2.3 From a4a570e813c72e308dd0897bcf256d19fee471a3 Mon Sep 17 00:00:00 2001 From: J-P Nurmi Date: Tue, 23 May 2017 15:18:14 +0200 Subject: Fix QQuickStyle::availableStyles() Filter out macOS debug symbol (.dSYM) directories from the list of available styles. Task-number: QTBUG-60973 Change-Id: I5b9c3f4af946d44b1601f32bf7da699c29a86689 Reviewed-by: Mitch Curtis --- src/quickcontrols2/qquickstyle.cpp | 9 ++++++--- tests/auto/qquickstyle/data/DummyStyle/Button.qml | 2 ++ tests/auto/qquickstyle/data/designer/ButtonSpecifics.qml | 3 +++ tests/auto/qquickstyle/data/dummy.dSYM/empty | 0 tests/auto/qquickstyle/qquickstyle.pro | 2 ++ tests/auto/qquickstyle/tst_qquickstyle.cpp | 15 ++++++++++++++- 6 files changed, 27 insertions(+), 4 deletions(-) create mode 100644 tests/auto/qquickstyle/data/DummyStyle/Button.qml create mode 100644 tests/auto/qquickstyle/data/designer/ButtonSpecifics.qml create mode 100644 tests/auto/qquickstyle/data/dummy.dSYM/empty diff --git a/src/quickcontrols2/qquickstyle.cpp b/src/quickcontrols2/qquickstyle.cpp index 184cbfc7..80ed5ea9 100644 --- a/src/quickcontrols2/qquickstyle.cpp +++ b/src/quickcontrols2/qquickstyle.cpp @@ -392,9 +392,12 @@ QStringList QQuickStyle::availableStyles() const QStringList stylePaths = QQuickStylePrivate::stylePaths(); for (const QString &path : stylePaths) { - QDir dir(path); - styles += dir.entryList(QStringList(), QDir::Dirs | QDir::NoDotAndDotDot); - styles.removeAll(QStringLiteral("designer")); + const QList entries = QDir(path).entryInfoList(QDir::Dirs | QDir::NoDotAndDotDot); + for (const QFileInfo &entry : entries) { + const QString name = entry.fileName(); + if (!name.endsWith(QLatin1String(".dSYM")) && name != QLatin1String("designer")) + styles += name; + } } styles.prepend(QStringLiteral("Default")); styles.removeDuplicates(); diff --git a/tests/auto/qquickstyle/data/DummyStyle/Button.qml b/tests/auto/qquickstyle/data/DummyStyle/Button.qml new file mode 100644 index 00000000..5b08222c --- /dev/null +++ b/tests/auto/qquickstyle/data/DummyStyle/Button.qml @@ -0,0 +1,2 @@ +import QtQuick.Templates 2.0 as T +T.Button { } diff --git a/tests/auto/qquickstyle/data/designer/ButtonSpecifics.qml b/tests/auto/qquickstyle/data/designer/ButtonSpecifics.qml new file mode 100644 index 00000000..9faaa8b7 --- /dev/null +++ b/tests/auto/qquickstyle/data/designer/ButtonSpecifics.qml @@ -0,0 +1,3 @@ +import HelperWidgets 2.0 + +ButtonSection { } diff --git a/tests/auto/qquickstyle/data/dummy.dSYM/empty b/tests/auto/qquickstyle/data/dummy.dSYM/empty new file mode 100644 index 00000000..e69de29b diff --git a/tests/auto/qquickstyle/qquickstyle.pro b/tests/auto/qquickstyle/qquickstyle.pro index 10ca8500..e56ee854 100644 --- a/tests/auto/qquickstyle/qquickstyle.pro +++ b/tests/auto/qquickstyle/qquickstyle.pro @@ -6,3 +6,5 @@ macos:CONFIG -= app_bundle QT += quickcontrols2 testlib QT_PRIVATE += core-private gui-private quickcontrols2-private + +TESTDATA = $$PWD/data/* diff --git a/tests/auto/qquickstyle/tst_qquickstyle.cpp b/tests/auto/qquickstyle/tst_qquickstyle.cpp index 3487a21e..1ce2a034 100644 --- a/tests/auto/qquickstyle/tst_qquickstyle.cpp +++ b/tests/auto/qquickstyle/tst_qquickstyle.cpp @@ -97,9 +97,22 @@ void tst_QQuickStyle::environmentVariables() void tst_QQuickStyle::availableStyles() { - QStringList styles = QQuickStyle::availableStyles(); + QString path = QFINDTESTDATA("data"); + QVERIFY(!path.isEmpty()); + qputenv("QT_QUICK_CONTROLS_STYLE_PATH", path.toLocal8Bit()); + + QStringList paths = QQuickStylePrivate::stylePaths(); + QVERIFY(paths.contains(path)); + + const QStringList styles = QQuickStyle::availableStyles(); QVERIFY(!styles.isEmpty()); QCOMPARE(styles.first(), QString("Default")); + QVERIFY(!styles.contains("designer")); + + // QTBUG-60973 + for (const QString &style : styles) { + QVERIFY2(!style.endsWith(".dSYM"), qPrintable(style)); + } } QTEST_MAIN(tst_QQuickStyle) -- cgit v1.2.3 From 038d5651940cfcd9fad017e6a4df00389b997da3 Mon Sep 17 00:00:00 2001 From: J-P Nurmi Date: Thu, 1 Jun 2017 21:38:16 +0200 Subject: Let users disable the multi-touch support The newly added multi-touch support can create issues, especially together with Flickable that is unfortunately still not properly touch-compatible. The implementation is still based on synthesized mouse events, so things like Flickable::pressDelay that intercepts mouse presses and re-sends sends them after a delay, does not play well with touch-enabled controls. The easiest way we can disable the whole thing is to make multi- touch support a configurable feature, the same way hover support is. ./configure -no-feature-quicktemplates2-multitouch [...] Qt Quick Templates 2: Hover support .......................... yes Multi-touch support .................... no [ChangeLog][Templates] Added a configure feature for disabling multi- touch support (configure -no-feature-quicktemplates2-multitouch). Task-number: QTBUG-61144 Change-Id: I0003ae925c2a499ecb3e2a5b720088bd963d9ad3 Reviewed-by: Mitch Curtis --- src/quicktemplates2/configure.json | 9 ++++++++- src/quicktemplates2/qquickcontrol.cpp | 4 ++++ src/quicktemplates2/qquickcontrol_p.h | 2 ++ src/quicktemplates2/qquickcontrol_p_p.h | 2 ++ src/quicktemplates2/qquickdial.cpp | 2 ++ src/quicktemplates2/qquickdial_p.h | 2 ++ src/quicktemplates2/qquickdrawer.cpp | 10 ++++++++++ src/quicktemplates2/qquickdrawer_p.h | 2 ++ src/quicktemplates2/qquickdrawer_p_p.h | 2 ++ src/quicktemplates2/qquickoverlay.cpp | 12 ++++++++++++ src/quicktemplates2/qquickoverlay_p.h | 2 ++ src/quicktemplates2/qquickoverlay_p_p.h | 2 ++ src/quicktemplates2/qquickpopup.cpp | 8 ++++++++ src/quicktemplates2/qquickpopup_p.h | 2 ++ src/quicktemplates2/qquickpopup_p_p.h | 4 ++++ src/quicktemplates2/qquickpopupitem.cpp | 2 ++ src/quicktemplates2/qquickpopupitem_p_p.h | 2 ++ src/quicktemplates2/qquickrangeslider.cpp | 6 ++++++ src/quicktemplates2/qquickrangeslider_p.h | 2 ++ src/quicktemplates2/qquickslider.cpp | 2 ++ src/quicktemplates2/qquickslider_p.h | 2 ++ src/quicktemplates2/qquickswitch.cpp | 2 ++ src/quicktemplates2/qquickswitch_p.h | 2 ++ src/quicktemplates2/qquickswitchdelegate.cpp | 2 ++ src/quicktemplates2/qquickswitchdelegate_p.h | 2 ++ 25 files changed, 88 insertions(+), 1 deletion(-) diff --git a/src/quicktemplates2/configure.json b/src/quicktemplates2/configure.json index 45899e1f..030e668b 100644 --- a/src/quicktemplates2/configure.json +++ b/src/quicktemplates2/configure.json @@ -7,6 +7,12 @@ "purpose": "Provides support for hover effects.", "section": "Quick Templates 2", "output": [ "privateFeature" ] + }, + "quicktemplates2-multitouch": { + "label": "Multi-touch support", + "purpose": "Provides support for multi-touch.", + "section": "Quick Templates 2", + "output": [ "privateFeature" ] } }, @@ -14,7 +20,8 @@ { "section": "Qt Quick Templates 2", "entries": [ - "quicktemplates2-hover" + "quicktemplates2-hover", + "quicktemplates2-multitouch" ] } ] diff --git a/src/quicktemplates2/qquickcontrol.cpp b/src/quicktemplates2/qquickcontrol.cpp index a2b16a10..fb6c17f7 100644 --- a/src/quicktemplates2/qquickcontrol.cpp +++ b/src/quicktemplates2/qquickcontrol.cpp @@ -145,6 +145,7 @@ QQuickControlPrivate::~QQuickControlPrivate() #endif } +#if QT_CONFIG(quicktemplates2_multitouch) bool QQuickControlPrivate::acceptTouch(const QTouchEvent::TouchPoint &point) { if (point.id() == touchId) @@ -157,6 +158,7 @@ bool QQuickControlPrivate::acceptTouch(const QTouchEvent::TouchPoint &point) return false; } +#endif void QQuickControlPrivate::handlePress(const QPointF &) { @@ -1366,6 +1368,7 @@ void QQuickControl::mouseUngrabEvent() d->handleUngrab(); } +#if QT_CONFIG(quicktemplates2_multitouch) void QQuickControl::touchEvent(QTouchEvent *event) { Q_D(QQuickControl); @@ -1420,6 +1423,7 @@ void QQuickControl::touchUngrabEvent() Q_D(QQuickControl); d->handleUngrab(); } +#endif #if QT_CONFIG(wheelevent) void QQuickControl::wheelEvent(QWheelEvent *event) diff --git a/src/quicktemplates2/qquickcontrol_p.h b/src/quicktemplates2/qquickcontrol_p.h index 6ad89376..8b52bd02 100644 --- a/src/quicktemplates2/qquickcontrol_p.h +++ b/src/quicktemplates2/qquickcontrol_p.h @@ -185,8 +185,10 @@ protected: void mouseMoveEvent(QMouseEvent *event) override; void mouseReleaseEvent(QMouseEvent *event) override; void mouseUngrabEvent() override; +#if QT_CONFIG(quicktemplates2_multitouch) void touchEvent(QTouchEvent *event) override; void touchUngrabEvent() override; +#endif #if QT_CONFIG(wheelevent) void wheelEvent(QWheelEvent *event) override; #endif diff --git a/src/quicktemplates2/qquickcontrol_p_p.h b/src/quicktemplates2/qquickcontrol_p_p.h index 42924875..73e1b44c 100644 --- a/src/quicktemplates2/qquickcontrol_p_p.h +++ b/src/quicktemplates2/qquickcontrol_p_p.h @@ -78,7 +78,9 @@ public: return control->d_func(); } +#if QT_CONFIG(quicktemplates2_multitouch) virtual bool acceptTouch(const QTouchEvent::TouchPoint &point); +#endif virtual void handlePress(const QPointF &point); virtual void handleMove(const QPointF &point); virtual void handleRelease(const QPointF &point); diff --git a/src/quicktemplates2/qquickdial.cpp b/src/quicktemplates2/qquickdial.cpp index 7e740ade..bdbfb22d 100644 --- a/src/quicktemplates2/qquickdial.cpp +++ b/src/quicktemplates2/qquickdial.cpp @@ -666,6 +666,7 @@ void QQuickDial::mouseMoveEvent(QMouseEvent *event) QQuickControl::mouseMoveEvent(event); } +#if QT_CONFIG(quicktemplates2_multitouch) void QQuickDial::touchEvent(QTouchEvent *event) { Q_D(QQuickDial); @@ -702,6 +703,7 @@ void QQuickDial::touchEvent(QTouchEvent *event) break; } } +#endif #if QT_CONFIG(wheelevent) void QQuickDial::wheelEvent(QWheelEvent *event) diff --git a/src/quicktemplates2/qquickdial_p.h b/src/quicktemplates2/qquickdial_p.h index 1a6d70fd..959cb154 100644 --- a/src/quicktemplates2/qquickdial_p.h +++ b/src/quicktemplates2/qquickdial_p.h @@ -136,7 +136,9 @@ protected: void keyReleaseEvent(QKeyEvent *event) override; void mousePressEvent(QMouseEvent *event) override; void mouseMoveEvent(QMouseEvent *event) override; +#if QT_CONFIG(quicktemplates2_multitouch) void touchEvent(QTouchEvent *event) override; +#endif #if QT_CONFIG(wheelevent) void wheelEvent(QWheelEvent *event) override; #endif diff --git a/src/quicktemplates2/qquickdrawer.cpp b/src/quicktemplates2/qquickdrawer.cpp index 8159f05e..66c84ea2 100644 --- a/src/quicktemplates2/qquickdrawer.cpp +++ b/src/quicktemplates2/qquickdrawer.cpp @@ -278,6 +278,7 @@ bool QQuickDrawerPrivate::startDrag(QEvent *event) } break; +#if QT_CONFIG(quicktemplates2_multitouch) case QEvent::TouchBegin: case QEvent::TouchUpdate: for (const QTouchEvent::TouchPoint &point : static_cast(event)->touchPoints()) { @@ -288,6 +289,7 @@ bool QQuickDrawerPrivate::startDrag(QEvent *event) } } break; +#endif default: break; @@ -340,6 +342,7 @@ bool QQuickDrawerPrivate::grabMouse(QQuickItem *item, QMouseEvent *event) return overThreshold; } +#if QT_CONFIG(quicktemplates2_multitouch) bool QQuickDrawerPrivate::grabTouch(QQuickItem *item, QTouchEvent *event) { Q_Q(QQuickDrawer); @@ -385,6 +388,7 @@ bool QQuickDrawerPrivate::grabTouch(QQuickItem *item, QTouchEvent *event) return overThreshold; } +#endif static const qreal openCloseVelocityThreshold = 300; @@ -672,8 +676,10 @@ bool QQuickDrawer::childMouseEventFilter(QQuickItem *child, QEvent *event) { Q_D(QQuickDrawer); switch (event->type()) { +#if QT_CONFIG(quicktemplates2_multitouch) case QEvent::TouchUpdate: return d->grabTouch(child, static_cast(event)); +#endif case QEvent::MouseMove: return d->grabMouse(child, static_cast(event)); case QEvent::MouseButtonPress: @@ -695,8 +701,10 @@ bool QQuickDrawer::overlayEvent(QQuickItem *item, QEvent *event) { Q_D(QQuickDrawer); switch (event->type()) { +#if QT_CONFIG(quicktemplates2_multitouch) case QEvent::TouchUpdate: return d->grabTouch(item, static_cast(event)); +#endif case QEvent::MouseMove: return d->grabMouse(item, static_cast(event)); default: @@ -705,11 +713,13 @@ bool QQuickDrawer::overlayEvent(QQuickItem *item, QEvent *event) return QQuickPopup::overlayEvent(item, event); } +#if QT_CONFIG(quicktemplates2_multitouch) void QQuickDrawer::touchEvent(QTouchEvent *event) { Q_D(QQuickDrawer); d->grabTouch(d->popupItem, event); } +#endif void QQuickDrawer::geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry) { diff --git a/src/quicktemplates2/qquickdrawer_p.h b/src/quicktemplates2/qquickdrawer_p.h index 9ab1c4ef..3ec007df 100644 --- a/src/quicktemplates2/qquickdrawer_p.h +++ b/src/quicktemplates2/qquickdrawer_p.h @@ -88,7 +88,9 @@ protected: bool childMouseEventFilter(QQuickItem *child, QEvent *event) override; void mouseMoveEvent(QMouseEvent *event) override; bool overlayEvent(QQuickItem *item, QEvent *event) override; +#if QT_CONFIG(quicktemplates2_multitouch) void touchEvent(QTouchEvent *event) override; +#endif void geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry) override; diff --git a/src/quicktemplates2/qquickdrawer_p_p.h b/src/quicktemplates2/qquickdrawer_p_p.h index bc4f91eb..8547bce5 100644 --- a/src/quicktemplates2/qquickdrawer_p_p.h +++ b/src/quicktemplates2/qquickdrawer_p_p.h @@ -74,7 +74,9 @@ public: bool startDrag(QEvent *event); bool grabMouse(QQuickItem *item, QMouseEvent *event); +#if QT_CONFIG(quicktemplates2_multitouch) bool grabTouch(QQuickItem *item, QTouchEvent *event); +#endif bool handlePress(QQuickItem* item, const QPointF &point, ulong timestamp) override; bool handleMove(QQuickItem* item, const QPointF &point, ulong timestamp) override; diff --git a/src/quicktemplates2/qquickoverlay.cpp b/src/quicktemplates2/qquickoverlay.cpp index 15104808..a4aaa60d 100644 --- a/src/quicktemplates2/qquickoverlay.cpp +++ b/src/quicktemplates2/qquickoverlay.cpp @@ -276,6 +276,7 @@ bool QQuickOverlayPrivate::handleMouseEvent(QQuickItem *source, QMouseEvent *eve return false; } +#if QT_CONFIG(quicktemplates2_multitouch) bool QQuickOverlayPrivate::handleTouchEvent(QQuickItem *source, QTouchEvent *event, QQuickPopup *target) { bool handled = false; @@ -309,6 +310,7 @@ bool QQuickOverlayPrivate::handleTouchEvent(QQuickItem *source, QTouchEvent *eve return handled; } +#endif void QQuickOverlayPrivate::addPopup(QQuickPopup *popup) { @@ -475,11 +477,13 @@ void QQuickOverlay::mouseReleaseEvent(QMouseEvent *event) d->handleMouseEvent(this, event); } +#if QT_CONFIG(quicktemplates2_multitouch) void QQuickOverlay::touchEvent(QTouchEvent *event) { Q_D(QQuickOverlay); d->handleTouchEvent(this, event); } +#endif #if QT_CONFIG(wheelevent) void QQuickOverlay::wheelEvent(QWheelEvent *event) @@ -516,10 +520,12 @@ bool QQuickOverlay::childMouseEventFilter(QQuickItem *item, QEvent *event) // does not have background dimming. if (item == p->dimmer || !p->popupItem->isAncestorOf(item)) { switch (event->type()) { +#if QT_CONFIG(quicktemplates2_multitouch) case QEvent::TouchBegin: case QEvent::TouchUpdate: case QEvent::TouchEnd: return d->handleTouchEvent(item, static_cast(event), popup); +#endif case QEvent::MouseButtonPress: case QEvent::MouseMove: @@ -541,6 +547,7 @@ bool QQuickOverlay::eventFilter(QObject *object, QEvent *event) return false; switch (event->type()) { +#if QT_CONFIG(quicktemplates2_multitouch) case QEvent::TouchBegin: case QEvent::TouchUpdate: case QEvent::TouchEnd: @@ -567,10 +574,13 @@ bool QQuickOverlay::eventFilter(QObject *object, QEvent *event) // touch events, to be able to close non-modal popups on release outside. event->accept(); return true; +#endif case QEvent::MouseButtonPress: +#if QT_CONFIG(quicktemplates2_multitouch) // do not emit pressed() twice when mouse events have been synthesized from touch events if (static_cast(event)->source() == Qt::MouseEventNotSynthesized) +#endif emit pressed(); QQuickWindowPrivate::get(d->window)->handleMouseEvent(static_cast(event)); @@ -583,8 +593,10 @@ bool QQuickOverlay::eventFilter(QObject *object, QEvent *event) return true; case QEvent::MouseButtonRelease: +#if QT_CONFIG(quicktemplates2_multitouch) // do not emit released() twice when mouse events have been synthesized from touch events if (static_cast(event)->source() == Qt::MouseEventNotSynthesized) +#endif emit released(); // allow non-modal popups to close on mouse release outside diff --git a/src/quicktemplates2/qquickoverlay_p.h b/src/quicktemplates2/qquickoverlay_p.h index 7d1ff143..ba61c9c9 100644 --- a/src/quicktemplates2/qquickoverlay_p.h +++ b/src/quicktemplates2/qquickoverlay_p.h @@ -87,7 +87,9 @@ protected: void mousePressEvent(QMouseEvent *event) override; void mouseMoveEvent(QMouseEvent *event) override; void mouseReleaseEvent(QMouseEvent *event) override; +#if QT_CONFIG(quicktemplates2_multitouch) void touchEvent(QTouchEvent *event) override; +#endif #if QT_CONFIG(wheelevent) void wheelEvent(QWheelEvent *event) override; #endif diff --git a/src/quicktemplates2/qquickoverlay_p_p.h b/src/quicktemplates2/qquickoverlay_p_p.h index 5553bda8..5008aa09 100644 --- a/src/quicktemplates2/qquickoverlay_p_p.h +++ b/src/quicktemplates2/qquickoverlay_p_p.h @@ -76,7 +76,9 @@ public: bool handleRelease(QQuickItem *source, QEvent *event, QQuickPopup *target); bool handleMouseEvent(QQuickItem *source, QMouseEvent *event, QQuickPopup *target = nullptr); +#if QT_CONFIG(quicktemplates2_multitouch) bool handleTouchEvent(QQuickItem *source, QTouchEvent *event, QQuickPopup *target = nullptr); +#endif void addPopup(QQuickPopup *popup); void removePopup(QQuickPopup *popup); diff --git a/src/quicktemplates2/qquickpopup.cpp b/src/quicktemplates2/qquickpopup.cpp index e6d83350..a3db2484 100644 --- a/src/quicktemplates2/qquickpopup.cpp +++ b/src/quicktemplates2/qquickpopup.cpp @@ -299,6 +299,7 @@ bool QQuickPopupPrivate::contains(const QPointF &scenePos) const return popupItem->contains(popupItem->mapFromScene(scenePos)); } +#if QT_CONFIG(quicktemplates2_multitouch) bool QQuickPopupPrivate::acceptTouch(const QTouchEvent::TouchPoint &point) { if (point.id() == touchId) @@ -311,6 +312,7 @@ bool QQuickPopupPrivate::acceptTouch(const QTouchEvent::TouchPoint &point) return false; } +#endif bool QQuickPopupPrivate::blockInput(QQuickItem *item, const QPointF &point) const { @@ -373,6 +375,7 @@ bool QQuickPopupPrivate::handleMouseEvent(QQuickItem *item, QMouseEvent *event) } } +#if QT_CONFIG(quicktemplates2_multitouch) bool QQuickPopupPrivate::handleTouchEvent(QQuickItem *item, QTouchEvent *event) { switch (event->type()) { @@ -418,6 +421,7 @@ bool QQuickPopupPrivate::handleTouchEvent(QQuickItem *item, QTouchEvent *event) return false; } +#endif bool QQuickPopupPrivate::prepareEnterTransition() { @@ -1987,10 +1991,12 @@ bool QQuickPopup::overlayEvent(QQuickItem *item, QEvent *event) event->accept(); return d->modal; +#if QT_CONFIG(quicktemplates2_multitouch) case QEvent::TouchBegin: case QEvent::TouchUpdate: case QEvent::TouchEnd: return d->handleTouchEvent(item, static_cast(event)); +#endif case QEvent::MouseButtonPress: case QEvent::MouseButtonRelease: @@ -2001,6 +2007,7 @@ bool QQuickPopup::overlayEvent(QQuickItem *item, QEvent *event) } } +#if QT_CONFIG(quicktemplates2_multitouch) void QQuickPopup::touchEvent(QTouchEvent *event) { Q_D(QQuickPopup); @@ -2012,6 +2019,7 @@ void QQuickPopup::touchUngrabEvent() Q_D(QQuickPopup); d->handleUngrab(); } +#endif #if QT_CONFIG(wheelevent) void QQuickPopup::wheelEvent(QWheelEvent *event) diff --git a/src/quicktemplates2/qquickpopup_p.h b/src/quicktemplates2/qquickpopup_p.h index 12bbe91d..04179f08 100644 --- a/src/quicktemplates2/qquickpopup_p.h +++ b/src/quicktemplates2/qquickpopup_p.h @@ -351,8 +351,10 @@ protected: virtual void mouseDoubleClickEvent(QMouseEvent *event); virtual void mouseUngrabEvent(); virtual bool overlayEvent(QQuickItem *item, QEvent *event); +#if QT_CONFIG(quicktemplates2_multitouch) virtual void touchEvent(QTouchEvent *event); virtual void touchUngrabEvent(); +#endif #if QT_CONFIG(wheelevent) virtual void wheelEvent(QWheelEvent *event); #endif diff --git a/src/quicktemplates2/qquickpopup_p_p.h b/src/quicktemplates2/qquickpopup_p_p.h index 316ea5bd..ce64d49e 100644 --- a/src/quicktemplates2/qquickpopup_p_p.h +++ b/src/quicktemplates2/qquickpopup_p_p.h @@ -99,7 +99,9 @@ public: bool contains(const QPointF &scenePos) const; +#if QT_CONFIG(quicktemplates2_multitouch) virtual bool acceptTouch(const QTouchEvent::TouchPoint &point); +#endif virtual bool blockInput(QQuickItem *item, const QPointF &point) const; virtual bool handlePress(QQuickItem* item, const QPointF &point, ulong timestamp); @@ -108,7 +110,9 @@ public: virtual void handleUngrab(); bool handleMouseEvent(QQuickItem *item, QMouseEvent *event); +#if QT_CONFIG(quicktemplates2_multitouch) bool handleTouchEvent(QQuickItem *item, QTouchEvent *event); +#endif virtual void reposition(); virtual void resizeOverlay(); diff --git a/src/quicktemplates2/qquickpopupitem.cpp b/src/quicktemplates2/qquickpopupitem.cpp index 3a770bf7..6ccfd6ab 100644 --- a/src/quicktemplates2/qquickpopupitem.cpp +++ b/src/quicktemplates2/qquickpopupitem.cpp @@ -228,6 +228,7 @@ void QQuickPopupItem::mouseUngrabEvent() d->popup->mouseUngrabEvent(); } +#if QT_CONFIG(quicktemplates2_multitouch) void QQuickPopupItem::touchEvent(QTouchEvent *event) { Q_D(QQuickPopupItem); @@ -239,6 +240,7 @@ void QQuickPopupItem::touchUngrabEvent() Q_D(QQuickPopupItem); d->popup->touchUngrabEvent(); } +#endif #if QT_CONFIG(wheelevent) void QQuickPopupItem::wheelEvent(QWheelEvent *event) diff --git a/src/quicktemplates2/qquickpopupitem_p_p.h b/src/quicktemplates2/qquickpopupitem_p_p.h index 16321feb..d5447383 100644 --- a/src/quicktemplates2/qquickpopupitem_p_p.h +++ b/src/quicktemplates2/qquickpopupitem_p_p.h @@ -79,8 +79,10 @@ protected: void mouseReleaseEvent(QMouseEvent *event) override; void mouseDoubleClickEvent(QMouseEvent *event) override; void mouseUngrabEvent() override; +#if QT_CONFIG(quicktemplates2_multitouch) void touchEvent(QTouchEvent *event) override; void touchUngrabEvent() override; +#endif #if QT_CONFIG(wheelevent) void wheelEvent(QWheelEvent *event) override; #endif diff --git a/src/quicktemplates2/qquickrangeslider.cpp b/src/quicktemplates2/qquickrangeslider.cpp index 3d767ed7..276e8d0c 100644 --- a/src/quicktemplates2/qquickrangeslider.cpp +++ b/src/quicktemplates2/qquickrangeslider.cpp @@ -328,7 +328,9 @@ public: QQuickRangeSliderNode *pressedNode(int touchId = -1) const; +#if QT_CONFIG(quicktemplates2_multitouch) bool acceptTouch(const QTouchEvent::TouchPoint &point) override; +#endif void handlePress(const QPointF &point) override; void handleMove(const QPointF &point) override; void handleRelease(const QPointF &point) override; @@ -397,6 +399,7 @@ QQuickRangeSliderNode *QQuickRangeSliderPrivate::pressedNode(int touchId) const return nullptr; } +#if QT_CONFIG(quicktemplates2_multitouch) bool QQuickRangeSliderPrivate::acceptTouch(const QTouchEvent::TouchPoint &point) { int firstId = QQuickRangeSliderNodePrivate::get(first)->touchId; @@ -409,6 +412,7 @@ bool QQuickRangeSliderPrivate::acceptTouch(const QTouchEvent::TouchPoint &point) return false; } +#endif void QQuickRangeSliderPrivate::handlePress(const QPointF &point) { @@ -986,6 +990,7 @@ void QQuickRangeSlider::mouseMoveEvent(QMouseEvent *event) QQuickControl::mouseMoveEvent(event); } +#if QT_CONFIG(quicktemplates2_multitouch) void QQuickRangeSlider::touchEvent(QTouchEvent *event) { Q_D(QQuickRangeSlider); @@ -1023,6 +1028,7 @@ void QQuickRangeSlider::touchEvent(QTouchEvent *event) break; } } +#endif void QQuickRangeSlider::mirrorChange() { diff --git a/src/quicktemplates2/qquickrangeslider_p.h b/src/quicktemplates2/qquickrangeslider_p.h index c4bc52ff..439a0d45 100644 --- a/src/quicktemplates2/qquickrangeslider_p.h +++ b/src/quicktemplates2/qquickrangeslider_p.h @@ -117,7 +117,9 @@ protected: void keyReleaseEvent(QKeyEvent *event) override; void mousePressEvent(QMouseEvent *event) override; void mouseMoveEvent(QMouseEvent *event) override; +#if QT_CONFIG(quicktemplates2_multitouch) void touchEvent(QTouchEvent *event) override; +#endif void mirrorChange() override; void componentComplete() override; diff --git a/src/quicktemplates2/qquickslider.cpp b/src/quicktemplates2/qquickslider.cpp index 91607853..27b4a981 100644 --- a/src/quicktemplates2/qquickslider.cpp +++ b/src/quicktemplates2/qquickslider.cpp @@ -633,6 +633,7 @@ void QQuickSlider::mouseMoveEvent(QMouseEvent *event) QQuickControl::mouseMoveEvent(event); } +#if QT_CONFIG(quicktemplates2_multitouch) void QQuickSlider::touchEvent(QTouchEvent *event) { Q_D(QQuickSlider); @@ -670,6 +671,7 @@ void QQuickSlider::touchEvent(QTouchEvent *event) break; } } +#endif #if QT_CONFIG(wheelevent) void QQuickSlider::wheelEvent(QWheelEvent *event) diff --git a/src/quicktemplates2/qquickslider_p.h b/src/quicktemplates2/qquickslider_p.h index 6f0e6fc6..865902ab 100644 --- a/src/quicktemplates2/qquickslider_p.h +++ b/src/quicktemplates2/qquickslider_p.h @@ -134,7 +134,9 @@ protected: void keyReleaseEvent(QKeyEvent *event) override; void mousePressEvent(QMouseEvent *event) override; void mouseMoveEvent(QMouseEvent *event) override; +#if QT_CONFIG(quicktemplates2_multitouch) void touchEvent(QTouchEvent *event) override; +#endif #if QT_CONFIG(wheelevent) void wheelEvent(QWheelEvent *event) override; #endif diff --git a/src/quicktemplates2/qquickswitch.cpp b/src/quicktemplates2/qquickswitch.cpp index ece9802d..f9bbff25 100644 --- a/src/quicktemplates2/qquickswitch.cpp +++ b/src/quicktemplates2/qquickswitch.cpp @@ -187,6 +187,7 @@ void QQuickSwitch::mouseMoveEvent(QMouseEvent *event) QQuickAbstractButton::mouseMoveEvent(event); } +#if QT_CONFIG(quicktemplates2_multitouch) void QQuickSwitch::touchEvent(QTouchEvent *event) { Q_D(QQuickSwitch); @@ -200,6 +201,7 @@ void QQuickSwitch::touchEvent(QTouchEvent *event) } QQuickAbstractButton::touchEvent(event); } +#endif void QQuickSwitch::mirrorChange() { diff --git a/src/quicktemplates2/qquickswitch_p.h b/src/quicktemplates2/qquickswitch_p.h index 5b93cd32..12e20bde 100644 --- a/src/quicktemplates2/qquickswitch_p.h +++ b/src/quicktemplates2/qquickswitch_p.h @@ -74,7 +74,9 @@ Q_SIGNALS: protected: void mouseMoveEvent(QMouseEvent *event) override; +#if QT_CONFIG(quicktemplates2_multitouch) void touchEvent(QTouchEvent *event) override; +#endif void mirrorChange() override; diff --git a/src/quicktemplates2/qquickswitchdelegate.cpp b/src/quicktemplates2/qquickswitchdelegate.cpp index 9bce76db..d8ce8096 100644 --- a/src/quicktemplates2/qquickswitchdelegate.cpp +++ b/src/quicktemplates2/qquickswitchdelegate.cpp @@ -184,6 +184,7 @@ void QQuickSwitchDelegate::mouseMoveEvent(QMouseEvent *event) QQuickItemDelegate::mouseMoveEvent(event); } +#if QT_CONFIG(quicktemplates2_multitouch) void QQuickSwitchDelegate::touchEvent(QTouchEvent *event) { Q_D(QQuickSwitchDelegate); @@ -197,6 +198,7 @@ void QQuickSwitchDelegate::touchEvent(QTouchEvent *event) } QQuickItemDelegate::touchEvent(event); } +#endif QFont QQuickSwitchDelegate::defaultFont() const { diff --git a/src/quicktemplates2/qquickswitchdelegate_p.h b/src/quicktemplates2/qquickswitchdelegate_p.h index e3e0804a..973ec21d 100644 --- a/src/quicktemplates2/qquickswitchdelegate_p.h +++ b/src/quicktemplates2/qquickswitchdelegate_p.h @@ -74,7 +74,9 @@ Q_SIGNALS: protected: void mouseMoveEvent(QMouseEvent *event) override; +#if QT_CONFIG(quicktemplates2_multitouch) void touchEvent(QTouchEvent *event) override; +#endif QFont defaultFont() const override; void mirrorChange() override; -- cgit v1.2.3 From 9b201572e518c976dee95f4c3146b4feedbb2e70 Mon Sep 17 00:00:00 2001 From: J-P Nurmi Date: Wed, 31 May 2017 09:05:20 +0200 Subject: Fix font inheritance for popups 1) First of all, Popup's QObject-parent depends on the way the Popup is declared in QML, or what is passed as a parent to createObject() when creating dynamic instances. For example: - Popup becomes a QObject child of of the contentItem: ApplicationWindow { Popup { } } - Popup becomes a QObject child of the window: ApplicationWindow { Item { Popup { } } } - Popup becomes a QObject child of the specified parent: ApplicationWindow { Component { id: component Popup { } } Component.onComplete: component.createObject(overlay) } Since QQuickWindow and QQuickView did not set the QObject-parent of their contentItem and rootObject, respectively, we had troubles finding popup instances, because window->findChildren() and window->contentItem()->findChildren() would produce inconsistent results. This has been fixed in qtdeclarative commit af6655885, so now we can use window->findChildren() reliably. 2) Popups inherit font from the associated window, not the parent item. It was wrong to call resolveFont() in setParentItem(), because the parent item might not change even though the associated window does. The piece of code was moved to setWindow() instead. 3) QQuickPopupItemPrivate::resolveFont() did not propagate the default font at all when the font was resolved before being associated to a window. 4) After the above fixes had been applied, to ensure that popups always inherit fonts and propagate them down to children as appropriate, we got a new test failure in tst_controls::Popup::test_font() indicating that there were extra font change notifiers triggered at creation time. This was fixed by associating "top-level" popups with the window as soon as they are appended to ApplicationWindow's default property, instead of waiting until the popup is complete and then doing a lookup in the parent hierarchy. Task-number: QTBUG-61114 Change-Id: I6185c76d50835cb7a06b03db0a3ac9ddad64bdd3 Reviewed-by: Mitch Curtis --- .gitignore | 1 + src/quicktemplates2/qquickapplicationwindow.cpp | 20 +- src/quicktemplates2/qquickpopup.cpp | 13 +- src/quicktemplates2/qquickpopupitem.cpp | 2 + tests/auto/auto.pro | 3 +- tests/auto/font/data/font-appwindow-custom.qml | 62 +++++ tests/auto/font/data/font-appwindow-default.qml | 55 ++++ tests/auto/font/data/font-control-custom.qml | 62 +++++ tests/auto/font/data/font-control-default.qml | 55 ++++ tests/auto/font/data/font-popup-custom.qml | 62 +++++ tests/auto/font/data/font-popup-default.qml | 55 ++++ tests/auto/font/data/inheritance-childcontrol.qml | 76 ++++++ tests/auto/font/data/inheritance-childpopup.qml | 76 ++++++ tests/auto/font/data/inheritance-control.qml | 74 ++++++ .../font/data/inheritance-dynamicchildcontrol.qml | 75 ++++++ .../font/data/inheritance-dynamicchildpopup.qml | 80 ++++++ .../auto/font/data/inheritance-dynamiccontrol.qml | 71 +++++ tests/auto/font/data/inheritance-dynamicpopup.qml | 76 ++++++ tests/auto/font/data/inheritance-popup.qml | 74 ++++++ tests/auto/font/font.pro | 14 + tests/auto/font/tst_font.cpp | 289 +++++++++++++++++++++ 21 files changed, 1285 insertions(+), 10 deletions(-) create mode 100644 tests/auto/font/data/font-appwindow-custom.qml create mode 100644 tests/auto/font/data/font-appwindow-default.qml create mode 100644 tests/auto/font/data/font-control-custom.qml create mode 100644 tests/auto/font/data/font-control-default.qml create mode 100644 tests/auto/font/data/font-popup-custom.qml create mode 100644 tests/auto/font/data/font-popup-default.qml create mode 100644 tests/auto/font/data/inheritance-childcontrol.qml create mode 100644 tests/auto/font/data/inheritance-childpopup.qml create mode 100644 tests/auto/font/data/inheritance-control.qml create mode 100644 tests/auto/font/data/inheritance-dynamicchildcontrol.qml create mode 100644 tests/auto/font/data/inheritance-dynamicchildpopup.qml create mode 100644 tests/auto/font/data/inheritance-dynamiccontrol.qml create mode 100644 tests/auto/font/data/inheritance-dynamicpopup.qml create mode 100644 tests/auto/font/data/inheritance-popup.qml create mode 100644 tests/auto/font/font.pro create mode 100644 tests/auto/font/tst_font.cpp diff --git a/.gitignore b/.gitignore index 3d119373..7c3a004b 100644 --- a/.gitignore +++ b/.gitignore @@ -35,6 +35,7 @@ /tests/auto/cursor/tst_cursor /tests/auto/drawer/tst_drawer /tests/auto/focus/tst_focus +/tests/auto/font/tst_font /tests/auto/menu/tst_menu /tests/auto/platform/tst_platform /tests/auto/popup/tst_popup diff --git a/src/quicktemplates2/qquickapplicationwindow.cpp b/src/quicktemplates2/qquickapplicationwindow.cpp index 0cd78502..e3f16d55 100644 --- a/src/quicktemplates2/qquickapplicationwindow.cpp +++ b/src/quicktemplates2/qquickapplicationwindow.cpp @@ -36,7 +36,7 @@ #include "qquickapplicationwindow_p.h" #include "qquickoverlay_p.h" -#include "qquickpopup_p.h" +#include "qquickpopup_p_p.h" #include "qquickcontrol_p_p.h" #include "qquicktextarea_p.h" #include "qquicktextfield_p.h" @@ -171,6 +171,8 @@ public: void _q_updateActiveFocus(); void setActiveFocusControl(QQuickItem *item); + static void contentData_append(QQmlListProperty *prop, QObject *obj); + bool complete; QQuickItem *background; QQuickItem *contentItem; @@ -284,6 +286,15 @@ void QQuickApplicationWindowPrivate::setActiveFocusControl(QQuickItem *control) } } +void QQuickApplicationWindowPrivate::contentData_append(QQmlListProperty *prop, QObject *obj) +{ + QQuickItemPrivate::data_append(prop, obj); + + // associate "top-level" popups with the window as soon as they are added to the default property + if (QQuickPopup *popup = qobject_cast(obj)) + QQuickPopupPrivate::get(popup)->setWindow(static_cast(prop->data)); +} + QQuickApplicationWindow::QQuickApplicationWindow(QWindow *parent) : QQuickWindowQmlImpl(parent), d_ptr(new QQuickApplicationWindowPrivate) { @@ -483,7 +494,11 @@ void QQuickApplicationWindow::setFooter(QQuickItem *footer) */ QQmlListProperty QQuickApplicationWindow::contentData() { - return QQuickItemPrivate::get(contentItem())->data(); + return QQmlListProperty(contentItem(), this, + QQuickApplicationWindowPrivate::contentData_append, + QQuickItemPrivate::data_count, + QQuickItemPrivate::data_at, + QQuickItemPrivate::data_clear); } /*! @@ -628,7 +643,6 @@ void QQuickApplicationWindowPrivate::updateFont(const QFont &f) QQuickControlPrivate::updateFontRecur(q->QQuickWindow::contentItem(), f); - // TODO: internal QQuickPopupManager that provides reliable access to all QQuickPopup instances const QList popups = q->findChildren(); for (QQuickPopup *popup : popups) QQuickControlPrivate::get(static_cast(popup->popupItem()))->inheritFont(f); diff --git a/src/quicktemplates2/qquickpopup.cpp b/src/quicktemplates2/qquickpopup.cpp index a3db2484..54f45767 100644 --- a/src/quicktemplates2/qquickpopup.cpp +++ b/src/quicktemplates2/qquickpopup.cpp @@ -568,13 +568,19 @@ void QQuickPopupPrivate::setWindow(QQuickWindow *newWindow) QQuickOverlayPrivate::get(overlay)->removePopup(q); } + window = newWindow; + if (newWindow) { QQuickOverlay *overlay = QQuickOverlay::overlay(newWindow); if (overlay) QQuickOverlayPrivate::get(overlay)->addPopup(q); + + QQuickControlPrivate *p = QQuickControlPrivate::get(popupItem); + p->resolveFont(); + if (QQuickApplicationWindow *appWindow = qobject_cast(newWindow)) + p->updateLocale(appWindow->locale(), false); // explicit=false } - window = newWindow; emit q->windowChanged(newWindow); if (complete && visible && window) @@ -1394,11 +1400,6 @@ void QQuickPopup::setParentItem(QQuickItem *parent) if (parent) { QObjectPrivate::connect(parent, &QQuickItem::windowChanged, d, &QQuickPopupPrivate::setWindow); QQuickItemPrivate::get(d->parentItem)->addItemChangeListener(d, QQuickItemPrivate::Destroyed); - - QQuickControlPrivate *p = QQuickControlPrivate::get(d->popupItem); - p->resolveFont(); - if (QQuickApplicationWindow *window = qobject_cast(parent->window())) - p->updateLocale(window->locale(), false); // explicit=false } else { close(); } diff --git a/src/quicktemplates2/qquickpopupitem.cpp b/src/quicktemplates2/qquickpopupitem.cpp index 6ccfd6ab..952c2db6 100644 --- a/src/quicktemplates2/qquickpopupitem.cpp +++ b/src/quicktemplates2/qquickpopupitem.cpp @@ -88,6 +88,8 @@ void QQuickPopupItemPrivate::resolveFont() { if (QQuickApplicationWindow *window = qobject_cast(popup->window())) inheritFont(window->font()); + else + inheritFont(themeFont(QPlatformTheme::SystemFont)); } QQuickItem *QQuickPopupItemPrivate::getContentItem() diff --git a/tests/auto/auto.pro b/tests/auto/auto.pro index ebc0b337..048eabed 100644 --- a/tests/auto/auto.pro +++ b/tests/auto/auto.pro @@ -7,6 +7,7 @@ SUBDIRS += \ cursor \ drawer \ focus \ + font \ menu \ platform \ popup \ @@ -23,6 +24,6 @@ SUBDIRS += \ # QTBUG-60268 boot2qt: SUBDIRS -= applicationwindow calendar controls cursor \ - drawer focus menu platform popup qquickmaterialstyle \ + drawer focus font menu platform popup qquickmaterialstyle \ qquickmaterialstyleconf qquickuniversalstyle \ qquickuniversalstyleconf snippets diff --git a/tests/auto/font/data/font-appwindow-custom.qml b/tests/auto/font/data/font-appwindow-custom.qml new file mode 100644 index 00000000..3d06f64a --- /dev/null +++ b/tests/auto/font/data/font-appwindow-custom.qml @@ -0,0 +1,62 @@ +/**************************************************************************** +** +** Copyright (C) 2017 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:BSD$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, you may use this file under the terms of the BSD license +** as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of The Qt Company Ltd nor the names of its +** contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.9 +import QtQuick.Controls 2.2 + +ApplicationWindow { + font.capitalization: Font.AllUppercase + font.family: "Courier" + font.italic: true + font.pixelSize: 60 + font.strikeout: true + font.underline: true + font.weight: Font.DemiBold +} diff --git a/tests/auto/font/data/font-appwindow-default.qml b/tests/auto/font/data/font-appwindow-default.qml new file mode 100644 index 00000000..02643c77 --- /dev/null +++ b/tests/auto/font/data/font-appwindow-default.qml @@ -0,0 +1,55 @@ +/**************************************************************************** +** +** Copyright (C) 2017 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:BSD$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, you may use this file under the terms of the BSD license +** as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of The Qt Company Ltd nor the names of its +** contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.9 +import QtQuick.Controls 2.2 + +ApplicationWindow { +} diff --git a/tests/auto/font/data/font-control-custom.qml b/tests/auto/font/data/font-control-custom.qml new file mode 100644 index 00000000..92136e86 --- /dev/null +++ b/tests/auto/font/data/font-control-custom.qml @@ -0,0 +1,62 @@ +/**************************************************************************** +** +** Copyright (C) 2017 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:BSD$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, you may use this file under the terms of the BSD license +** as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of The Qt Company Ltd nor the names of its +** contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.9 +import QtQuick.Controls 2.2 + +Control { + font.capitalization: Font.AllUppercase + font.family: "Courier" + font.italic: true + font.pixelSize: 60 + font.strikeout: true + font.underline: true + font.weight: Font.DemiBold +} diff --git a/tests/auto/font/data/font-control-default.qml b/tests/auto/font/data/font-control-default.qml new file mode 100644 index 00000000..552c77d8 --- /dev/null +++ b/tests/auto/font/data/font-control-default.qml @@ -0,0 +1,55 @@ +/**************************************************************************** +** +** Copyright (C) 2017 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:BSD$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, you may use this file under the terms of the BSD license +** as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of The Qt Company Ltd nor the names of its +** contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.9 +import QtQuick.Controls 2.2 + +Control { +} diff --git a/tests/auto/font/data/font-popup-custom.qml b/tests/auto/font/data/font-popup-custom.qml new file mode 100644 index 00000000..e8363a81 --- /dev/null +++ b/tests/auto/font/data/font-popup-custom.qml @@ -0,0 +1,62 @@ +/**************************************************************************** +** +** Copyright (C) 2017 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:BSD$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, you may use this file under the terms of the BSD license +** as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of The Qt Company Ltd nor the names of its +** contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.9 +import QtQuick.Controls 2.2 + +Popup { + font.capitalization: Font.AllUppercase + font.family: "Courier" + font.italic: true + font.pixelSize: 60 + font.strikeout: true + font.underline: true + font.weight: Font.DemiBold +} diff --git a/tests/auto/font/data/font-popup-default.qml b/tests/auto/font/data/font-popup-default.qml new file mode 100644 index 00000000..26c522c1 --- /dev/null +++ b/tests/auto/font/data/font-popup-default.qml @@ -0,0 +1,55 @@ +/**************************************************************************** +** +** Copyright (C) 2017 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:BSD$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, you may use this file under the terms of the BSD license +** as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of The Qt Company Ltd nor the names of its +** contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.9 +import QtQuick.Controls 2.2 + +Popup { +} diff --git a/tests/auto/font/data/inheritance-childcontrol.qml b/tests/auto/font/data/inheritance-childcontrol.qml new file mode 100644 index 00000000..8a04dd52 --- /dev/null +++ b/tests/auto/font/data/inheritance-childcontrol.qml @@ -0,0 +1,76 @@ +/**************************************************************************** +** +** Copyright (C) 2017 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:BSD$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, you may use this file under the terms of the BSD license +** as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of The Qt Company Ltd nor the names of its +** contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.9 +import QtQuick.Controls 2.2 + +ApplicationWindow { + id: window + + property alias control: control + property alias child: child + property alias grandChild: grandChild + + Item { + Control { + id: control + + Control { + id: child + + Item { + Control { + id: grandChild + } + } + } + } + } +} diff --git a/tests/auto/font/data/inheritance-childpopup.qml b/tests/auto/font/data/inheritance-childpopup.qml new file mode 100644 index 00000000..ca5cdc82 --- /dev/null +++ b/tests/auto/font/data/inheritance-childpopup.qml @@ -0,0 +1,76 @@ +/**************************************************************************** +** +** Copyright (C) 2017 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:BSD$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, you may use this file under the terms of the BSD license +** as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of The Qt Company Ltd nor the names of its +** contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.9 +import QtQuick.Controls 2.2 + +ApplicationWindow { + id: window + + property alias control: control + property alias child: child + property alias grandChild: grandChild + + Item { + Popup { + id: control + + Control { + id: child + + Item { + Control { + id: grandChild + } + } + } + } + } +} diff --git a/tests/auto/font/data/inheritance-control.qml b/tests/auto/font/data/inheritance-control.qml new file mode 100644 index 00000000..ac9c940a --- /dev/null +++ b/tests/auto/font/data/inheritance-control.qml @@ -0,0 +1,74 @@ +/**************************************************************************** +** +** Copyright (C) 2017 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:BSD$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, you may use this file under the terms of the BSD license +** as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of The Qt Company Ltd nor the names of its +** contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.9 +import QtQuick.Controls 2.2 + +ApplicationWindow { + id: window + + property alias control: control + property alias child: child + property alias grandChild: grandChild + + Control { + id: control + + Control { + id: child + + Item { + Control { + id: grandChild + } + } + } + } +} diff --git a/tests/auto/font/data/inheritance-dynamicchildcontrol.qml b/tests/auto/font/data/inheritance-dynamicchildcontrol.qml new file mode 100644 index 00000000..98c0f696 --- /dev/null +++ b/tests/auto/font/data/inheritance-dynamicchildcontrol.qml @@ -0,0 +1,75 @@ +/**************************************************************************** +** +** Copyright (C) 2017 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:BSD$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, you may use this file under the terms of the BSD license +** as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of The Qt Company Ltd nor the names of its +** contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.9 +import QtQuick.Controls 2.2 + +ApplicationWindow { + id: window + + property Control control + property Control child + property Control grandChild + + Item { + id: childItem + } + + Component { + id: component + Control { } + } + + Component.onCompleted: { + control = component.createObject(childItem) + child = component.createObject(control) + grandChild = component.createObject(child) + } +} diff --git a/tests/auto/font/data/inheritance-dynamicchildpopup.qml b/tests/auto/font/data/inheritance-dynamicchildpopup.qml new file mode 100644 index 00000000..ef4fe60c --- /dev/null +++ b/tests/auto/font/data/inheritance-dynamicchildpopup.qml @@ -0,0 +1,80 @@ +/**************************************************************************** +** +** Copyright (C) 2017 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:BSD$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, you may use this file under the terms of the BSD license +** as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of The Qt Company Ltd nor the names of its +** contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.9 +import QtQuick.Controls 2.2 + +ApplicationWindow { + id: window + + property Popup control + property Control child + property Control grandChild + + Item { + id: childItem + } + + Component { + id: popupComponent + Popup { } + } + + Component { + id: controlComponent + Control { } + } + + Component.onCompleted: { + control = popupComponent.createObject(childItem) + child = controlComponent.createObject(control.contentItem) + grandChild = controlComponent.createObject(child) + } +} diff --git a/tests/auto/font/data/inheritance-dynamiccontrol.qml b/tests/auto/font/data/inheritance-dynamiccontrol.qml new file mode 100644 index 00000000..a261d600 --- /dev/null +++ b/tests/auto/font/data/inheritance-dynamiccontrol.qml @@ -0,0 +1,71 @@ +/**************************************************************************** +** +** Copyright (C) 2017 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:BSD$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, you may use this file under the terms of the BSD license +** as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of The Qt Company Ltd nor the names of its +** contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.9 +import QtQuick.Controls 2.2 + +ApplicationWindow { + id: window + + property Control control + property Control child + property Control grandChild + + Component { + id: component + Control { } + } + + Component.onCompleted: { + control = component.createObject(contentItem) + child = component.createObject(control) + grandChild = component.createObject(child) + } +} diff --git a/tests/auto/font/data/inheritance-dynamicpopup.qml b/tests/auto/font/data/inheritance-dynamicpopup.qml new file mode 100644 index 00000000..f0d567da --- /dev/null +++ b/tests/auto/font/data/inheritance-dynamicpopup.qml @@ -0,0 +1,76 @@ +/**************************************************************************** +** +** Copyright (C) 2017 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:BSD$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, you may use this file under the terms of the BSD license +** as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of The Qt Company Ltd nor the names of its +** contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.9 +import QtQuick.Controls 2.2 + +ApplicationWindow { + id: window + + property Popup control + property Control child + property Control grandChild + + Component { + id: popupComponent + Popup { } + } + + Component { + id: controlComponent + Control { } + } + + Component.onCompleted: { + control = popupComponent.createObject(window) + child = controlComponent.createObject(control.contentItem) + grandChild = controlComponent.createObject(child) + } +} diff --git a/tests/auto/font/data/inheritance-popup.qml b/tests/auto/font/data/inheritance-popup.qml new file mode 100644 index 00000000..b8415e63 --- /dev/null +++ b/tests/auto/font/data/inheritance-popup.qml @@ -0,0 +1,74 @@ +/**************************************************************************** +** +** Copyright (C) 2017 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:BSD$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, you may use this file under the terms of the BSD license +** as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of The Qt Company Ltd nor the names of its +** contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.9 +import QtQuick.Controls 2.2 + +ApplicationWindow { + id: window + + property alias control: control + property alias child: child + property alias grandChild: grandChild + + Popup { + id: control + + Control { + id: child + + Item { + Control { + id: grandChild + } + } + } + } +} diff --git a/tests/auto/font/font.pro b/tests/auto/font/font.pro new file mode 100644 index 00000000..f6ccefd3 --- /dev/null +++ b/tests/auto/font/font.pro @@ -0,0 +1,14 @@ +CONFIG += testcase +TARGET = tst_font +SOURCES += tst_font.cpp + +macos:CONFIG -= app_bundle + +QT += core-private gui-private qml-private quick-private testlib quicktemplates2-private quickcontrols2-private + +include (../shared/util.pri) + +TESTDATA = data/* + +OTHER_FILES += \ + data/*.qml diff --git a/tests/auto/font/tst_font.cpp b/tests/auto/font/tst_font.cpp new file mode 100644 index 00000000..6f04a8c0 --- /dev/null +++ b/tests/auto/font/tst_font.cpp @@ -0,0 +1,289 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL3$ +** 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 http://www.qt.io/terms-conditions. For further +** information use the contact form at http://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.LGPLv3 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.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 later as published by the Free +** Software Foundation and appearing in the file LICENSE.GPL included in +** the packaging of this file. Please review the following information to +** ensure the GNU General Public License version 2.0 requirements will be +** met: http://www.gnu.org/licenses/gpl-2.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include +#include "../shared/visualtestutil.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +using namespace QQuickVisualTestUtil; + +class tst_font : public QQmlDataTest +{ + Q_OBJECT + +private slots: + void font_data(); + void font(); + + void inheritance_data(); + void inheritance(); + + void defaultFont_data(); + void defaultFont(); +}; + +void tst_font::font_data() +{ + QTest::addColumn("testFile"); + QTest::addColumn("expectedFont"); + + QTest::newRow("Control") << "font-control-default.qml" << QFont(); + QTest::newRow("AppWindow") << "font-appwindow-default.qml" << QFont(); + QTest::newRow("Popup") << "font-popup-default.qml" << QFont(); + + QFont customFont; + customFont.setCapitalization(QFont::AllUppercase); + customFont.setFamily("Courier"); + customFont.setItalic(true); + customFont.setPixelSize(60); + customFont.setStrikeOut(true); + customFont.setUnderline(true); + customFont.setWeight(QFont::DemiBold); + + QTest::newRow("Control:custom") << "font-control-custom.qml" << customFont; + QTest::newRow("AppWindow:custom") << "font-appwindow-custom.qml" << customFont; + QTest::newRow("Popup:custom") << "font-popup-custom.qml" << customFont; +} + +void tst_font::font() +{ + QFETCH(QString, testFile); + QFETCH(QFont, expectedFont); + + QQmlEngine engine; + QQmlComponent component(&engine); + component.loadUrl(testFileUrl(testFile)); + + QScopedPointer object(component.create()); + QVERIFY2(!object.isNull(), qPrintable(component.errorString())); + + QVariant var = object->property("font"); + QVERIFY(var.isValid()); + + QFont actualFont = var.value(); + QCOMPARE(actualFont, expectedFont); +} + +void tst_font::inheritance_data() +{ + QTest::addColumn("testFile"); + + QTest::newRow("Control") << "inheritance-control.qml"; + QTest::newRow("Child Control") << "inheritance-childcontrol.qml"; + QTest::newRow("Dynamic Control") << "inheritance-dynamiccontrol.qml"; + QTest::newRow("Dynamic Child Control") << "inheritance-dynamicchildcontrol.qml"; + + QTest::newRow("Popup") << "inheritance-popup.qml"; + QTest::newRow("Child Popup") << "inheritance-childpopup.qml"; + QTest::newRow("Dynamic Popup") << "inheritance-dynamicpopup.qml"; + QTest::newRow("Dynamic Child Popup") << "inheritance-dynamicchildpopup.qml"; +} + +void tst_font::inheritance() +{ + QFETCH(QString, testFile); + + QQmlEngine engine; + QQmlComponent component(&engine); + component.loadUrl(testFileUrl(testFile)); + + QScopedPointer window(qobject_cast(component.create())); + QVERIFY2(!window.isNull(), qPrintable(component.errorString())); + + QObject *control = window->property("control").value(); + QObject *child = window->property("child").value(); + QObject *grandChild = window->property("grandChild").value(); + QVERIFY(control && child && grandChild); + + QCOMPARE(window->font(), QFont()); + + QCOMPARE(control->property("font").value(), QFont()); + QCOMPARE(child->property("font").value(), QFont()); + QCOMPARE(grandChild->property("font").value(), QFont()); + + QFont childFont; + childFont.setFamily("Arial"); + childFont.setPixelSize(80); + childFont.setItalic(true); + child->setProperty("font", childFont); + QCOMPARE(child->property("font").value(), childFont); + QCOMPARE(grandChild->property("font").value(), childFont); + + QFont grandChildFont(childFont); + grandChildFont.setFamily("Times New Roman"); + grandChildFont.setUnderline(true); + grandChild->setProperty("font", grandChildFont); + QCOMPARE(child->property("font").value(), childFont); + QCOMPARE(grandChild->property("font").value(), grandChildFont); + + QFont windowFont; + windowFont.setWeight(QFont::Thin); + window->setFont(windowFont); + QCOMPARE(window->font(), windowFont); + QCOMPARE(control->property("font").value(), windowFont); + + childFont.setWeight(QFont::Thin); + QCOMPARE(child->property("font").value(), childFont); + + grandChildFont.setWeight(QFont::Thin); + QCOMPARE(grandChild->property("font").value(), grandChildFont); + + child->setProperty("font", QVariant()); + QCOMPARE(child->property("font").value(), windowFont); + QCOMPARE(grandChild->property("font").value(), grandChildFont); + + grandChild->setProperty("font", QVariant()); + QCOMPARE(grandChild->property("font").value(), windowFont); +} + +class TestFontTheme : public QQuickProxyTheme +{ +public: + TestFontTheme(QPlatformTheme *theme) : QQuickProxyTheme(theme) + { + std::fill(fonts, fonts + QPlatformTheme::NFonts, static_cast(0)); + + for (int i = QPlatformTheme::SystemFont; i < QPlatformTheme::NFonts; ++i) { + QFont font = QFont(); + font.setPixelSize(i + 10); + fonts[i] = new QFont(font); + } + + QGuiApplicationPrivate::platform_theme = this; + } + + const QFont *font(Font type = SystemFont) const override + { + return fonts[type]; + } + +private: + QFont *fonts[QPlatformTheme::NFonts]; +}; + +Q_DECLARE_METATYPE(QPlatformTheme::Font) + +void tst_font::defaultFont_data() +{ + QTest::addColumn("control"); + QTest::addColumn("fontType"); + + QTest::newRow("AbstractButton") << "AbstractButton" << QPlatformTheme::SystemFont; + QTest::newRow("ApplicationWindow") << "ApplicationWindow" << QPlatformTheme::SystemFont; + QTest::newRow("Button") << "Button" << QPlatformTheme::PushButtonFont; + QTest::newRow("CheckBox") << "CheckBox" << QPlatformTheme::CheckBoxFont; + QTest::newRow("CheckDelegate") << "CheckDelegate" << QPlatformTheme::ListViewFont; + QTest::newRow("ComboBox") << "ComboBox" << QPlatformTheme::ComboMenuItemFont; + QTest::newRow("Container") << "Container" << QPlatformTheme::SystemFont; + QTest::newRow("Control") << "Control" << QPlatformTheme::SystemFont; + QTest::newRow("Dial") << "Dial" << QPlatformTheme::SystemFont; + QTest::newRow("Dialog") << "Dialog" << QPlatformTheme::SystemFont; + QTest::newRow("DialogButtonBox") << "DialogButtonBox" << QPlatformTheme::SystemFont; + QTest::newRow("Drawer") << "Drawer" << QPlatformTheme::SystemFont; + QTest::newRow("Frame") << "Frame" << QPlatformTheme::SystemFont; + QTest::newRow("GroupBox") << "GroupBox" << QPlatformTheme::GroupBoxTitleFont; + QTest::newRow("ItemDelegate") << "ItemDelegate" << QPlatformTheme::ItemViewFont; + QTest::newRow("Label") << "Label" << QPlatformTheme::LabelFont; + QTest::newRow("Menu") << "Menu" << QPlatformTheme::MenuFont; + QTest::newRow("MenuItem") << "MenuItem" << QPlatformTheme::MenuItemFont; + QTest::newRow("MenuSeparator") << "MenuSeparator" << QPlatformTheme::SystemFont; + QTest::newRow("Page") << "Page" << QPlatformTheme::SystemFont; + QTest::newRow("Pane") << "Pane" << QPlatformTheme::SystemFont; + QTest::newRow("Popup") << "Popup" << QPlatformTheme::SystemFont; + QTest::newRow("ProgressBar") << "ProgressBar" << QPlatformTheme::SystemFont; + QTest::newRow("RadioButton") << "RadioButton" << QPlatformTheme::RadioButtonFont; + QTest::newRow("RadioDelegate") << "RadioDelegate" << QPlatformTheme::ListViewFont; + QTest::newRow("RangeSlider") << "RangeSlider" << QPlatformTheme::SystemFont; + QTest::newRow("RoundButton") << "RoundButton" << QPlatformTheme::PushButtonFont; + QTest::newRow("ScrollBar") << "ScrollBar" << QPlatformTheme::SystemFont; + QTest::newRow("ScrollIndicator") << "ScrollIndicator" << QPlatformTheme::SystemFont; + QTest::newRow("Slider") << "Slider" << QPlatformTheme::SystemFont; + QTest::newRow("SpinBox") << "SpinBox" << QPlatformTheme::EditorFont; + QTest::newRow("SwipeDelegate") << "SwipeDelegate" << QPlatformTheme::ListViewFont; + QTest::newRow("Switch") << "Switch" << QPlatformTheme::SystemFont; // ### TODO: add QPlatformTheme::SwitchFont + QTest::newRow("SwitchDelegate") << "SwitchDelegate" << QPlatformTheme::ListViewFont; + QTest::newRow("TabBar") << "TabBar" << QPlatformTheme::SystemFont; + QTest::newRow("TabButton") << "TabButton" << QPlatformTheme::TabButtonFont; + QTest::newRow("TextArea") << "TextArea" << QPlatformTheme::EditorFont; + QTest::newRow("TextField") << "TextField" << QPlatformTheme::EditorFont; + QTest::newRow("ToolBar") << "ToolBar" << QPlatformTheme::SystemFont; + QTest::newRow("ToolButton") << "ToolButton" << QPlatformTheme::ToolButtonFont; + QTest::newRow("ToolSeparator") << "ToolSeparator" << QPlatformTheme::SystemFont; + QTest::newRow("ToolTip") << "ToolTip" << QPlatformTheme::TipLabelFont; + QTest::newRow("Tumbler") << "Tumbler" << QPlatformTheme::SystemFont; +} + +void tst_font::defaultFont() +{ + QFETCH(QString, control); + QFETCH(QPlatformTheme::Font, fontType); + + TestFontTheme theme(QGuiApplicationPrivate::platform_theme); + + QQmlEngine engine; + QQmlComponent component(&engine); + component.setData(QString("import QtQuick.Controls 2.2; %1 { }").arg(control).toUtf8(), QUrl()); + + QScopedPointer object(component.create()); + QVERIFY2(!object.isNull(), qPrintable(component.errorString())); + + QVariant var = object->property("font"); + QVERIFY(var.isValid()); + + const QFont *expectedFont = theme.font(fontType); + QVERIFY(expectedFont); + + QFont actualFont = var.value(); + + if (actualFont != *expectedFont) { + qDebug() << QTest::currentDataTag() << actualFont << *expectedFont; + } + + QCOMPARE(actualFont, *expectedFont); +} + +QTEST_MAIN(tst_font) + +#include "tst_font.moc" -- cgit v1.2.3 From a5f8ceee8547c3447675d1c4e70f5706bbd2bd99 Mon Sep 17 00:00:00 2001 From: J-P Nurmi Date: Wed, 7 Jun 2017 13:52:36 +0200 Subject: Doc: reorganize the style images Task-number: QTBUG-60995 Change-Id: I3083a7a2bb39d242f31a9c5d0bfed66dbdb88202 Reviewed-by: Mitch Curtis --- .../images/qtquickcontrols2-default-thumbnail.png | Bin 0 -> 6159 bytes .../doc/images/qtquickcontrols2-material-dark.png | Bin 4981 -> 14996 bytes .../doc/images/qtquickcontrols2-material-light.png | Bin 0 -> 14682 bytes .../images/qtquickcontrols2-material-purple.png | Bin 0 -> 4981 bytes .../images/qtquickcontrols2-material-thumbnail.png | Bin 0 -> 12572 bytes .../doc/images/qtquickcontrols2-material.png | Bin 29049 -> 0 bytes .../doc/images/qtquickcontrols2-styles.png | Bin 0 -> 48670 bytes .../doc/images/qtquickcontrols2-universal-dark.png | Bin 2894 -> 12152 bytes .../images/qtquickcontrols2-universal-light.png | Bin 0 -> 12564 bytes .../qtquickcontrols2-universal-thumbnail.png | Bin 0 -> 9512 bytes .../images/qtquickcontrols2-universal-violet.png | Bin 0 -> 2894 bytes .../doc/images/qtquickcontrols2-universal.png | Bin 25572 -> 0 bytes .../controls/doc/src/qtquickcontrols2-index.qdoc | 29 +--------- .../doc/src/qtquickcontrols2-material.qdoc | 11 ++-- .../controls/doc/src/qtquickcontrols2-styles.qdoc | 60 ++++++++------------- .../doc/src/qtquickcontrols2-universal.qdoc | 11 ++-- 16 files changed, 40 insertions(+), 71 deletions(-) create mode 100644 src/imports/controls/doc/images/qtquickcontrols2-default-thumbnail.png create mode 100644 src/imports/controls/doc/images/qtquickcontrols2-material-light.png create mode 100644 src/imports/controls/doc/images/qtquickcontrols2-material-purple.png create mode 100644 src/imports/controls/doc/images/qtquickcontrols2-material-thumbnail.png delete mode 100644 src/imports/controls/doc/images/qtquickcontrols2-material.png create mode 100644 src/imports/controls/doc/images/qtquickcontrols2-styles.png create mode 100644 src/imports/controls/doc/images/qtquickcontrols2-universal-light.png create mode 100644 src/imports/controls/doc/images/qtquickcontrols2-universal-thumbnail.png create mode 100644 src/imports/controls/doc/images/qtquickcontrols2-universal-violet.png delete mode 100644 src/imports/controls/doc/images/qtquickcontrols2-universal.png diff --git a/src/imports/controls/doc/images/qtquickcontrols2-default-thumbnail.png b/src/imports/controls/doc/images/qtquickcontrols2-default-thumbnail.png new file mode 100644 index 00000000..5afcb6d7 Binary files /dev/null and b/src/imports/controls/doc/images/qtquickcontrols2-default-thumbnail.png differ diff --git a/src/imports/controls/doc/images/qtquickcontrols2-material-dark.png b/src/imports/controls/doc/images/qtquickcontrols2-material-dark.png index 8afb2cd6..eb0350dd 100644 Binary files a/src/imports/controls/doc/images/qtquickcontrols2-material-dark.png and b/src/imports/controls/doc/images/qtquickcontrols2-material-dark.png differ diff --git a/src/imports/controls/doc/images/qtquickcontrols2-material-light.png b/src/imports/controls/doc/images/qtquickcontrols2-material-light.png new file mode 100644 index 00000000..2635de68 Binary files /dev/null and b/src/imports/controls/doc/images/qtquickcontrols2-material-light.png differ diff --git a/src/imports/controls/doc/images/qtquickcontrols2-material-purple.png b/src/imports/controls/doc/images/qtquickcontrols2-material-purple.png new file mode 100644 index 00000000..8afb2cd6 Binary files /dev/null and b/src/imports/controls/doc/images/qtquickcontrols2-material-purple.png differ diff --git a/src/imports/controls/doc/images/qtquickcontrols2-material-thumbnail.png b/src/imports/controls/doc/images/qtquickcontrols2-material-thumbnail.png new file mode 100644 index 00000000..c1084673 Binary files /dev/null and b/src/imports/controls/doc/images/qtquickcontrols2-material-thumbnail.png differ diff --git a/src/imports/controls/doc/images/qtquickcontrols2-material.png b/src/imports/controls/doc/images/qtquickcontrols2-material.png deleted file mode 100644 index 4caef89e..00000000 Binary files a/src/imports/controls/doc/images/qtquickcontrols2-material.png and /dev/null differ diff --git a/src/imports/controls/doc/images/qtquickcontrols2-styles.png b/src/imports/controls/doc/images/qtquickcontrols2-styles.png new file mode 100644 index 00000000..aae046fd Binary files /dev/null and b/src/imports/controls/doc/images/qtquickcontrols2-styles.png differ diff --git a/src/imports/controls/doc/images/qtquickcontrols2-universal-dark.png b/src/imports/controls/doc/images/qtquickcontrols2-universal-dark.png index ec459457..2d6937c7 100644 Binary files a/src/imports/controls/doc/images/qtquickcontrols2-universal-dark.png and b/src/imports/controls/doc/images/qtquickcontrols2-universal-dark.png differ diff --git a/src/imports/controls/doc/images/qtquickcontrols2-universal-light.png b/src/imports/controls/doc/images/qtquickcontrols2-universal-light.png new file mode 100644 index 00000000..a6da6f7f Binary files /dev/null and b/src/imports/controls/doc/images/qtquickcontrols2-universal-light.png differ diff --git a/src/imports/controls/doc/images/qtquickcontrols2-universal-thumbnail.png b/src/imports/controls/doc/images/qtquickcontrols2-universal-thumbnail.png new file mode 100644 index 00000000..a189ed72 Binary files /dev/null and b/src/imports/controls/doc/images/qtquickcontrols2-universal-thumbnail.png differ diff --git a/src/imports/controls/doc/images/qtquickcontrols2-universal-violet.png b/src/imports/controls/doc/images/qtquickcontrols2-universal-violet.png new file mode 100644 index 00000000..ec459457 Binary files /dev/null and b/src/imports/controls/doc/images/qtquickcontrols2-universal-violet.png differ diff --git a/src/imports/controls/doc/images/qtquickcontrols2-universal.png b/src/imports/controls/doc/images/qtquickcontrols2-universal.png deleted file mode 100644 index b50d9cca..00000000 Binary files a/src/imports/controls/doc/images/qtquickcontrols2-universal.png and /dev/null differ diff --git a/src/imports/controls/doc/src/qtquickcontrols2-index.qdoc b/src/imports/controls/doc/src/qtquickcontrols2-index.qdoc index 868e77e0..51d672f3 100644 --- a/src/imports/controls/doc/src/qtquickcontrols2-index.qdoc +++ b/src/imports/controls/doc/src/qtquickcontrols2-index.qdoc @@ -35,36 +35,11 @@ to build complete interfaces in Qt Quick. The module was introduced in Qt 5.7. + \image qtquickcontrols2-styles.png + Qt Quick Controls 2 comes with a selection customizable styles. See \l {Styling Qt Quick Controls 2} for more details. - \raw HTML - - - - - - - - - - - -
- - Default - - - - Material - - - - Universal - -
DefaultMaterialUniversal
- \endraw - \section1 Prerequisites The \l{Qt Quick Controls 2 QML Types}{QML types} can be imported into your diff --git a/src/imports/controls/doc/src/qtquickcontrols2-material.qdoc b/src/imports/controls/doc/src/qtquickcontrols2-material.qdoc index 065f3fe9..0b3175d7 100644 --- a/src/imports/controls/doc/src/qtquickcontrols2-material.qdoc +++ b/src/imports/controls/doc/src/qtquickcontrols2-material.qdoc @@ -58,8 +58,13 @@ {Google Material Design Guidelines}. It allows for a unified experience across platforms and device sizes. - \image qtquickcontrols2-material.png - \caption The Material style in light and dark themes + \table + \row + \li \image qtquickcontrols2-material-light.png + \caption The Material style in light theme + \li \image qtquickcontrols2-material-dark.png + \caption The Material style in dark theme + \endtable To run an application with the Material style, see \l {Using Styles in Qt Quick Controls 2}. @@ -108,7 +113,7 @@ } \endqml \li - \image qtquickcontrols2-material-dark.png + \image qtquickcontrols2-material-purple.png \endtable In addition to specifying the attributes in QML, it is also possible to diff --git a/src/imports/controls/doc/src/qtquickcontrols2-styles.qdoc b/src/imports/controls/doc/src/qtquickcontrols2-styles.qdoc index 42d8bc62..f2df16ce 100644 --- a/src/imports/controls/doc/src/qtquickcontrols2-styles.qdoc +++ b/src/imports/controls/doc/src/qtquickcontrols2-styles.qdoc @@ -29,46 +29,30 @@ \page qtquickcontrols2-styles.html \title Styling Qt Quick Controls 2 + \section1 Available Styles + Qt Quick Controls 2 comes with a selection of styles. - \raw HTML - - - - - - - - - - - -
- - - - - - - - - - - -
- The Default style is - a simple and light-weight all-round style that offers the maximum - performance for Qt Quick Controls 2. - - The Material style offers an appealing design - based on the - Google Material Design Guidelines, but requires more system resources than the Default style. - - The Universal style offers an appealing design - based on the Microsoft Universal Design Guidelines, - but requires more system resources than the Default style. -
- \endraw + \section2 Default Style + + \image qtquickcontrols2-default-thumbnail.png + The \l {Default Style} is a simple and light-weight all-round style that offers + the maximum performance for Qt Quick Controls 2. + + \section2 Material Style + + \image qtquickcontrols2-material-thumbnail.png + The \l {Material Style} offers an appealing design based on the + \l {https://www.google.com/design/spec/material-design/introduction.html} + {Google Material Design Guidelines}, but requires more system resources than + the Default style. + + \section2 Universal Style + + \image qtquickcontrols2-universal-thumbnail.png + The \l {Universal Style} offers an appealing design based on the + \l {https://dev.windows.com/design}{Microsoft Universal Design Guidelines}, + but requires more system resources than the Default style. \section1 Using Styles in Qt Quick Controls 2 diff --git a/src/imports/controls/doc/src/qtquickcontrols2-universal.qdoc b/src/imports/controls/doc/src/qtquickcontrols2-universal.qdoc index 8f3d2330..4b5a2de2 100644 --- a/src/imports/controls/doc/src/qtquickcontrols2-universal.qdoc +++ b/src/imports/controls/doc/src/qtquickcontrols2-universal.qdoc @@ -57,8 +57,13 @@ The Universal style has been designed to look good on all devices, from phones and tablets to PCs. - \image qtquickcontrols2-universal.png - \caption The Universal style in light and dark themes + \table + \row + \li \image qtquickcontrols2-universal-light.png + \caption The Universal style in light theme + \li \image qtquickcontrols2-universal-dark.png + \caption The Universal style in dark theme + \endtable To run an application with the Universal style, see \l {Using Styles in Qt Quick Controls 2}. @@ -107,7 +112,7 @@ } \endqml \li - \image qtquickcontrols2-universal-dark.png + \image qtquickcontrols2-universal-violet.png \endtable In addition to specifying the attributes in QML, it is also possible to -- cgit v1.2.3