From f5c13e141c9c9bf7b131da6948ebcfc01d82f160 Mon Sep 17 00:00:00 2001 From: J-P Nurmi Date: Fri, 15 Dec 2017 12:34:03 +0100 Subject: Popups: use deferred execution QQuickPopup is backed by a QQuickControl subclass aka QQuickPopupItem. However, since the QML engine sees "background" and "contentItem" as properties of QQuickPopup, we must ensure that the deferred properties are executed for the QQuickPopup wrapper object. Task-number: QTBUG-50992 Change-Id: I2ec055b382e41530a6f4a740cb80853c0181c21a Reviewed-by: Mitch Curtis --- src/quicktemplates2/qquickcontrol_p_p.h | 4 ++-- src/quicktemplates2/qquickmenu.cpp | 3 +++ src/quicktemplates2/qquickpagelayout.cpp | 13 ++++++++----- src/quicktemplates2/qquickpopup.cpp | 11 +++++++---- src/quicktemplates2/qquickpopup_p.h | 1 + src/quicktemplates2/qquickpopupitem.cpp | 30 ++++++++++++++++++++++++++++++ 6 files changed, 51 insertions(+), 11 deletions(-) (limited to 'src') diff --git a/src/quicktemplates2/qquickcontrol_p_p.h b/src/quicktemplates2/qquickcontrol_p_p.h index d8b1dd40..81fa03a4 100644 --- a/src/quicktemplates2/qquickcontrol_p_p.h +++ b/src/quicktemplates2/qquickcontrol_p_p.h @@ -127,8 +127,8 @@ public: static bool calcHoverEnabled(const QQuickItem *item); #endif - void executeContentItem(bool complete = false); - void executeBackground(bool complete = false); + virtual void executeContentItem(bool complete = false); + virtual void executeBackground(bool complete = false); static void destroyDelegate(QObject *object, QObject *parent); diff --git a/src/quicktemplates2/qquickmenu.cpp b/src/quicktemplates2/qquickmenu.cpp index 52c048a6..13c738ac 100644 --- a/src/quicktemplates2/qquickmenu.cpp +++ b/src/quicktemplates2/qquickmenu.cpp @@ -38,6 +38,7 @@ #include "qquickmenu_p_p.h" #include "qquickmenuitem_p.h" #include "qquickcontrol_p_p.h" +#include "qquickpopupitem_p_p.h" #include #include @@ -449,6 +450,8 @@ QVariant QQuickMenu::contentModel() const QQmlListProperty QQuickMenu::contentData() { Q_D(QQuickMenu); + if (!d->contentItem) + QQuickControlPrivate::get(d->popupItem)->executeContentItem(); return QQmlListProperty(this, d, QQuickMenuPrivate::contentData_append, QQuickMenuPrivate::contentData_count, diff --git a/src/quicktemplates2/qquickpagelayout.cpp b/src/quicktemplates2/qquickpagelayout.cpp index 99d4fe23..595db560 100644 --- a/src/quicktemplates2/qquickpagelayout.cpp +++ b/src/quicktemplates2/qquickpagelayout.cpp @@ -36,6 +36,7 @@ #include "qquickpagelayout_p_p.h" #include "qquickcontrol_p.h" +#include "qquickcontrol_p_p.h" #include "qquicktoolbar_p.h" #include "qquicktabbar_p.h" #include "qquickdialogbuttonbox_p.h" @@ -140,17 +141,19 @@ bool QQuickPageLayout::setFooter(QQuickItem *footer) void QQuickPageLayout::update() { - QQuickItem *content = m_control->contentItem(); + QQuickItem *content = QQuickControlPrivate::get(m_control)->contentItem; const qreal hh = m_header && m_header->isVisible() ? m_header->height() : 0; const qreal fh = m_footer && m_footer->isVisible() ? m_footer->height() : 0; const qreal hsp = hh > 0 ? m_control->spacing() : 0; const qreal fsp = fh > 0 ? m_control->spacing() : 0; - content->setY(m_control->topPadding() + hh + hsp); - content->setX(m_control->leftPadding()); - content->setWidth(m_control->availableWidth()); - content->setHeight(m_control->availableHeight() - hh - fh - hsp - fsp); + if (content) { + content->setY(m_control->topPadding() + hh + hsp); + content->setX(m_control->leftPadding()); + content->setWidth(m_control->availableWidth()); + content->setHeight(m_control->availableHeight() - hh - fh - hsp - fsp); + } if (m_header) m_header->setWidth(m_control->width()); diff --git a/src/quicktemplates2/qquickpopup.cpp b/src/quicktemplates2/qquickpopup.cpp index ce4072e5..bb5ce660 100644 --- a/src/quicktemplates2/qquickpopup.cpp +++ b/src/quicktemplates2/qquickpopup.cpp @@ -261,6 +261,7 @@ void QQuickPopupPrivate::init() popupItem->setVisible(false); q->setParentItem(qobject_cast(parent)); QObject::connect(popupItem, &QQuickControl::paddingChanged, q, &QQuickPopup::paddingChanged); + QObject::connect(popupItem, &QQuickControl::backgroundChanged, q, &QQuickPopup::backgroundChanged); QObject::connect(popupItem, &QQuickControl::contentItemChanged, q, &QQuickPopup::contentItemChanged); positioner = new QQuickPopupPositioner(q); } @@ -1428,11 +1429,7 @@ QQuickItem *QQuickPopup::background() const void QQuickPopup::setBackground(QQuickItem *background) { Q_D(QQuickPopup); - if (d->popupItem->background() == background) - return; - d->popupItem->setBackground(background); - emit backgroundChanged(); } /*! @@ -1485,6 +1482,9 @@ void QQuickPopup::setContentItem(QQuickItem *item) QQmlListProperty QQuickPopup::contentData() { Q_D(QQuickPopup); + QQuickControlPrivate *p = QQuickControlPrivate::get(d->popupItem); + if (!p->contentItem) + p->executeContentItem(); return QQmlListProperty(d->popupItem->contentItem(), nullptr, QQuickItemPrivate::data_append, QQuickItemPrivate::data_count, @@ -1886,6 +1886,9 @@ void QQuickPopup::classBegin() { Q_D(QQuickPopup); d->complete = false; + QQmlContext *context = qmlContext(this); + if (context) + QQmlEngine::setContextForObject(d->popupItem, context); d->popupItem->classBegin(); } diff --git a/src/quicktemplates2/qquickpopup_p.h b/src/quicktemplates2/qquickpopup_p.h index 199f7e4c..16e46755 100644 --- a/src/quicktemplates2/qquickpopup_p.h +++ b/src/quicktemplates2/qquickpopup_p.h @@ -115,6 +115,7 @@ class Q_QUICKTEMPLATES2_PRIVATE_EXPORT QQuickPopup : public QObject, public QQml Q_PROPERTY(QQuickTransition *exit READ exit WRITE setExit NOTIFY exitChanged FINAL) // 2.1 (Qt 5.8) Q_PROPERTY(qreal spacing READ spacing WRITE setSpacing RESET resetSpacing NOTIFY spacingChanged FINAL REVISION 1) + Q_CLASSINFO("DeferredPropertyNames", "background,contentItem") Q_CLASSINFO("DefaultProperty", "contentData") public: diff --git a/src/quicktemplates2/qquickpopupitem.cpp b/src/quicktemplates2/qquickpopupitem.cpp index bd667835..db335a06 100644 --- a/src/quicktemplates2/qquickpopupitem.cpp +++ b/src/quicktemplates2/qquickpopupitem.cpp @@ -39,6 +39,7 @@ #include "qquickshortcutcontext_p_p.h" #include "qquickcontrol_p_p.h" #include "qquickpopup_p_p.h" +#include "qquickdeferredexecute_p_p.h" #include #include @@ -59,6 +60,9 @@ public: QQuickItem *getContentItem() override; + void executeContentItem(bool complete = false) override; + void executeBackground(bool complete = false) override; + int backId; int escapeId; QQuickPopup *popup; @@ -100,6 +104,32 @@ QQuickItem *QQuickPopupItemPrivate::getContentItem() return new QQuickItem(q); } +static inline QString contentItemName() { return QStringLiteral("contentItem"); } + +void QQuickPopupItemPrivate::executeContentItem(bool complete) +{ + if (contentItem.wasExecuted()) + return; + + if (!contentItem) + quickBeginDeferred(popup, contentItemName(), contentItem); + if (complete) + quickCompleteDeferred(popup, contentItemName(), contentItem); +} + +static inline QString backgroundName() { return QStringLiteral("background"); } + +void QQuickPopupItemPrivate::executeBackground(bool complete) +{ + if (background.wasExecuted()) + return; + + if (!background) + quickBeginDeferred(popup, backgroundName(), background); + if (complete) + quickCompleteDeferred(popup, backgroundName(), background); +} + QQuickPopupItem::QQuickPopupItem(QQuickPopup *popup) : QQuickControl(*(new QQuickPopupItemPrivate(popup)), nullptr) { -- cgit v1.2.3 From 44382ff104965c5596b5138aa84e0e4ccf178772 Mon Sep 17 00:00:00 2001 From: J-P Nurmi Date: Wed, 8 Nov 2017 16:08:56 +0100 Subject: SwipeView: fix slow swiping in large views Flickable has a default maximumFlickVelocity of 2500 regardless of its size. When SwipeView covers the whole screen and ends up being large, 2500 pixels per second is nowhere near enough. Calculate a suitable maximum flick velocity based on the size of the view. Task-number: QTBUG-62110 Change-Id: Iaf26f586f99e7635ea931a4e3060ad4dd480a011 Reviewed-by: Mitch Curtis --- src/imports/controls/SwipeView.qml | 1 + src/imports/controls/material/SwipeView.qml | 1 + 2 files changed, 2 insertions(+) (limited to 'src') diff --git a/src/imports/controls/SwipeView.qml b/src/imports/controls/SwipeView.qml index 4ccef22b..9f2d9ccb 100644 --- a/src/imports/controls/SwipeView.qml +++ b/src/imports/controls/SwipeView.qml @@ -60,5 +60,6 @@ T.SwipeView { preferredHighlightBegin: 0 preferredHighlightEnd: 0 highlightMoveDuration: 250 + maximumFlickVelocity: 4 * (control.orientation === Qt.Horizontal ? width : height) } } diff --git a/src/imports/controls/material/SwipeView.qml b/src/imports/controls/material/SwipeView.qml index 293cce46..64ecb00f 100644 --- a/src/imports/controls/material/SwipeView.qml +++ b/src/imports/controls/material/SwipeView.qml @@ -59,5 +59,6 @@ T.SwipeView { preferredHighlightBegin: 0 preferredHighlightEnd: 0 highlightMoveDuration: 250 + maximumFlickVelocity: 4 * (control.orientation === Qt.Horizontal ? width : height) } } -- cgit v1.2.3 From bbdf0c2d8a3bf4779a973dda9436ce12c8360f13 Mon Sep 17 00:00:00 2001 From: J-P Nurmi Date: Mon, 18 Dec 2017 17:00:19 +0100 Subject: Default: cleanup unnecessary property assignments QQuickText's default horizontal alignment is AlignLeft. There's no need to repeat the default. Furthermore, an empty QQuickText element does not do anything, so the "visible: control.text" binding seems bogus. Change-Id: I9461301606c45a3d889ad49e62356d38fcef6f87 Reviewed-by: Mitch Curtis --- src/imports/controls/CheckBox.qml | 2 -- src/imports/controls/CheckDelegate.qml | 2 -- src/imports/controls/ComboBox.qml | 1 - src/imports/controls/GroupBox.qml | 1 - src/imports/controls/ItemDelegate.qml | 2 -- src/imports/controls/MenuItem.qml | 2 -- src/imports/controls/RadioButton.qml | 2 -- src/imports/controls/RadioDelegate.qml | 2 -- src/imports/controls/SwipeDelegate.qml | 2 -- src/imports/controls/Switch.qml | 2 -- src/imports/controls/SwitchDelegate.qml | 2 -- 11 files changed, 20 deletions(-) (limited to 'src') diff --git a/src/imports/controls/CheckBox.qml b/src/imports/controls/CheckBox.qml index 7945ca72..4da79098 100644 --- a/src/imports/controls/CheckBox.qml +++ b/src/imports/controls/CheckBox.qml @@ -66,8 +66,6 @@ T.CheckBox { font: control.font color: control.down ? Default.textDarkColor : Default.textColor elide: Text.ElideRight - visible: control.text - horizontalAlignment: Text.AlignLeft verticalAlignment: Text.AlignVCenter opacity: enabled ? 1 : 0.3 } diff --git a/src/imports/controls/CheckDelegate.qml b/src/imports/controls/CheckDelegate.qml index 05a0baf6..3333642c 100644 --- a/src/imports/controls/CheckDelegate.qml +++ b/src/imports/controls/CheckDelegate.qml @@ -60,8 +60,6 @@ T.CheckDelegate { font: control.font color: control.enabled ? Default.textDarkColor : Default.textDisabledColor elide: Text.ElideRight - visible: control.text - horizontalAlignment: Text.AlignLeft verticalAlignment: Text.AlignVCenter } diff --git a/src/imports/controls/ComboBox.qml b/src/imports/controls/ComboBox.qml index 8d1a28be..3eabcacf 100644 --- a/src/imports/controls/ComboBox.qml +++ b/src/imports/controls/ComboBox.qml @@ -88,7 +88,6 @@ T.ComboBox { color: !control.editable && control.visualFocus ? Default.focusColor : Default.textColor selectionColor: Default.focusColor selectedTextColor: Default.textLightColor - horizontalAlignment: Text.AlignLeft verticalAlignment: Text.AlignVCenter opacity: control.enabled ? 1 : 0.3 diff --git a/src/imports/controls/GroupBox.qml b/src/imports/controls/GroupBox.qml index ee81250b..272577c9 100644 --- a/src/imports/controls/GroupBox.qml +++ b/src/imports/controls/GroupBox.qml @@ -62,7 +62,6 @@ T.GroupBox { font: control.font color: control.enabled ? Default.textColor : Default.textDisabledColor elide: Text.ElideRight - horizontalAlignment: Text.AlignLeft verticalAlignment: Text.AlignVCenter } diff --git a/src/imports/controls/ItemDelegate.qml b/src/imports/controls/ItemDelegate.qml index 6ee03ca2..3a7e1044 100644 --- a/src/imports/controls/ItemDelegate.qml +++ b/src/imports/controls/ItemDelegate.qml @@ -60,8 +60,6 @@ T.ItemDelegate { font: control.font color: control.enabled ? Default.textDarkColor : Default.textDisabledColor elide: Text.ElideRight - visible: control.text - horizontalAlignment: Text.AlignLeft verticalAlignment: Text.AlignVCenter } diff --git a/src/imports/controls/MenuItem.qml b/src/imports/controls/MenuItem.qml index 2c8eab5f..74ae6002 100644 --- a/src/imports/controls/MenuItem.qml +++ b/src/imports/controls/MenuItem.qml @@ -59,8 +59,6 @@ T.MenuItem { font: control.font color: control.enabled ? Default.textDarkColor : Default.textDisabledColor elide: Text.ElideRight - visible: control.text - horizontalAlignment: Text.AlignLeft verticalAlignment: Text.AlignVCenter } diff --git a/src/imports/controls/RadioButton.qml b/src/imports/controls/RadioButton.qml index 878a0fe3..3ca0466b 100644 --- a/src/imports/controls/RadioButton.qml +++ b/src/imports/controls/RadioButton.qml @@ -66,8 +66,6 @@ T.RadioButton { font: control.font color: control.down ? Default.textDarkColor : Default.textColor elide: Text.ElideRight - visible: control.text - horizontalAlignment: Text.AlignLeft verticalAlignment: Text.AlignVCenter opacity: enabled ? 1 : 0.3 } diff --git a/src/imports/controls/RadioDelegate.qml b/src/imports/controls/RadioDelegate.qml index 03cd83bd..708c826a 100644 --- a/src/imports/controls/RadioDelegate.qml +++ b/src/imports/controls/RadioDelegate.qml @@ -60,8 +60,6 @@ T.RadioDelegate { font: control.font color: control.enabled ? Default.textDarkColor : Default.textDisabledColor elide: Text.ElideRight - visible: control.text - horizontalAlignment: Text.AlignLeft verticalAlignment: Text.AlignVCenter } diff --git a/src/imports/controls/SwipeDelegate.qml b/src/imports/controls/SwipeDelegate.qml index d9f72da9..2ddbea28 100644 --- a/src/imports/controls/SwipeDelegate.qml +++ b/src/imports/controls/SwipeDelegate.qml @@ -62,8 +62,6 @@ T.SwipeDelegate { font: control.font color: control.enabled ? Default.textDarkColor : Default.textDisabledColor elide: Text.ElideRight - visible: control.text - horizontalAlignment: Text.AlignLeft verticalAlignment: Text.AlignVCenter } diff --git a/src/imports/controls/Switch.qml b/src/imports/controls/Switch.qml index 55b08039..030cdfa0 100644 --- a/src/imports/controls/Switch.qml +++ b/src/imports/controls/Switch.qml @@ -66,8 +66,6 @@ T.Switch { font: control.font color: control.enabled ? Default.textDarkColor : Default.textDisabledColor elide: Text.ElideRight - visible: control.text - horizontalAlignment: Text.AlignLeft verticalAlignment: Text.AlignVCenter } } diff --git a/src/imports/controls/SwitchDelegate.qml b/src/imports/controls/SwitchDelegate.qml index 6536ac53..49e0fad2 100644 --- a/src/imports/controls/SwitchDelegate.qml +++ b/src/imports/controls/SwitchDelegate.qml @@ -66,8 +66,6 @@ T.SwitchDelegate { font: control.font color: control.enabled ? Default.textDarkColor : Default.textDisabledColor elide: Text.ElideRight - visible: control.text - horizontalAlignment: Text.AlignLeft verticalAlignment: Text.AlignVCenter } -- cgit v1.2.3 From d1706827085d648ccef13e1df74796f19d455e89 Mon Sep 17 00:00:00 2001 From: J-P Nurmi Date: Tue, 19 Dec 2017 10:33:50 +0100 Subject: StackView: don't block touch Unlike with mouse events there's setAcceptedMouseButtons(), currently there's no way to control whether a control receives touch events or not. As a temporary workaround until QQuickItem::setAcceptTouchEvents() has been added, we'll have to ignore touch events by hand. Task-number: QTBUG-65084 Change-Id: I3d51bdc80981557399f3bdfd181e359679cd1c20 Reviewed-by: Mitch Curtis --- src/quicktemplates2/qquickstackview.cpp | 7 +++++++ src/quicktemplates2/qquickstackview_p.h | 4 ++++ 2 files changed, 11 insertions(+) (limited to 'src') diff --git a/src/quicktemplates2/qquickstackview.cpp b/src/quicktemplates2/qquickstackview.cpp index 20e3c817..df67da87 100644 --- a/src/quicktemplates2/qquickstackview.cpp +++ b/src/quicktemplates2/qquickstackview.cpp @@ -1035,6 +1035,13 @@ bool QQuickStackView::childMouseEventFilter(QQuickItem *item, QEvent *event) return window && !window->mouseGrabberItem(); } +#if QT_CONFIG(quicktemplates2_multitouch) +void QQuickStackView::touchEvent(QTouchEvent *event) +{ + event->ignore(); // QTBUG-65084 +} +#endif + #if QT_CONFIG(accessibility) QAccessible::Role QQuickStackView::accessibleRole() const { diff --git a/src/quicktemplates2/qquickstackview_p.h b/src/quicktemplates2/qquickstackview_p.h index ff115416..645223fd 100644 --- a/src/quicktemplates2/qquickstackview_p.h +++ b/src/quicktemplates2/qquickstackview_p.h @@ -153,6 +153,10 @@ protected: void geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry) override; bool childMouseEventFilter(QQuickItem *, QEvent *) override; +#if QT_CONFIG(quicktemplates2_multitouch) + void touchEvent(QTouchEvent *event) override; +#endif + #if QT_CONFIG(accessibility) QAccessible::Role accessibleRole() const override; #endif -- cgit v1.2.3 From aea42abe76dae2cb47cda64ee36fcda85305e91d Mon Sep 17 00:00:00 2001 From: J-P Nurmi Date: Tue, 19 Dec 2017 10:43:21 +0100 Subject: Material: cleanup unnecessary property assignments Change-Id: I1698392b1ef75b84d114cb19207729217abb4aed Reviewed-by: Mitch Curtis --- src/imports/controls/material/CheckBox.qml | 2 -- src/imports/controls/material/CheckDelegate.qml | 2 -- src/imports/controls/material/ComboBox.qml | 1 - src/imports/controls/material/GroupBox.qml | 1 - src/imports/controls/material/ItemDelegate.qml | 2 -- src/imports/controls/material/MenuItem.qml | 2 -- src/imports/controls/material/RadioButton.qml | 2 -- src/imports/controls/material/RadioDelegate.qml | 2 -- src/imports/controls/material/SwipeDelegate.qml | 2 -- src/imports/controls/material/Switch.qml | 2 -- src/imports/controls/material/SwitchDelegate.qml | 2 -- 11 files changed, 20 deletions(-) (limited to 'src') diff --git a/src/imports/controls/material/CheckBox.qml b/src/imports/controls/material/CheckBox.qml index e1c559da..bb953761 100644 --- a/src/imports/controls/material/CheckBox.qml +++ b/src/imports/controls/material/CheckBox.qml @@ -80,8 +80,6 @@ T.CheckBox { font: control.font color: control.enabled ? control.Material.foreground : control.Material.hintTextColor elide: Text.ElideRight - visible: control.text - horizontalAlignment: Text.AlignLeft verticalAlignment: Text.AlignVCenter } } diff --git a/src/imports/controls/material/CheckDelegate.qml b/src/imports/controls/material/CheckDelegate.qml index 545ca64a..63c63bdf 100644 --- a/src/imports/controls/material/CheckDelegate.qml +++ b/src/imports/controls/material/CheckDelegate.qml @@ -68,8 +68,6 @@ T.CheckDelegate { font: control.font color: control.enabled ? control.Material.foreground : control.Material.hintTextColor elide: Text.ElideRight - visible: control.text - horizontalAlignment: Text.AlignLeft verticalAlignment: Text.AlignVCenter } diff --git a/src/imports/controls/material/ComboBox.qml b/src/imports/controls/material/ComboBox.qml index d2ca7679..79eee2b5 100644 --- a/src/imports/controls/material/ComboBox.qml +++ b/src/imports/controls/material/ComboBox.qml @@ -92,7 +92,6 @@ T.ComboBox { color: control.enabled ? control.Material.foreground : control.Material.hintTextColor selectionColor: control.Material.accentColor selectedTextColor: control.Material.primaryHighlightedTextColor - horizontalAlignment: Text.AlignLeft verticalAlignment: Text.AlignVCenter cursorDelegate: CursorDelegate { } diff --git a/src/imports/controls/material/GroupBox.qml b/src/imports/controls/material/GroupBox.qml index e7055404..67105653 100644 --- a/src/imports/controls/material/GroupBox.qml +++ b/src/imports/controls/material/GroupBox.qml @@ -62,7 +62,6 @@ T.GroupBox { font: control.font color: control.enabled ? control.Material.foreground : control.Material.hintTextColor elide: Text.ElideRight - horizontalAlignment: Text.AlignLeft verticalAlignment: Text.AlignVCenter } diff --git a/src/imports/controls/material/ItemDelegate.qml b/src/imports/controls/material/ItemDelegate.qml index 59d51c36..a096bfc2 100644 --- a/src/imports/controls/material/ItemDelegate.qml +++ b/src/imports/controls/material/ItemDelegate.qml @@ -60,8 +60,6 @@ T.ItemDelegate { font: control.font color: control.enabled ? control.Material.foreground : control.Material.hintTextColor elide: Text.ElideRight - visible: control.text - horizontalAlignment: Text.AlignLeft verticalAlignment: Text.AlignVCenter } diff --git a/src/imports/controls/material/MenuItem.qml b/src/imports/controls/material/MenuItem.qml index 5a136231..06408101 100644 --- a/src/imports/controls/material/MenuItem.qml +++ b/src/imports/controls/material/MenuItem.qml @@ -69,8 +69,6 @@ T.MenuItem { font: control.font color: control.enabled ? control.Material.foreground : control.Material.hintTextColor elide: Text.ElideRight - visible: control.text - horizontalAlignment: Text.AlignLeft verticalAlignment: Text.AlignVCenter } diff --git a/src/imports/controls/material/RadioButton.qml b/src/imports/controls/material/RadioButton.qml index d178654f..9dec07b5 100644 --- a/src/imports/controls/material/RadioButton.qml +++ b/src/imports/controls/material/RadioButton.qml @@ -80,8 +80,6 @@ T.RadioButton { font: control.font color: control.enabled ? control.Material.foreground : control.Material.hintTextColor elide: Text.ElideRight - visible: control.text - horizontalAlignment: Text.AlignLeft verticalAlignment: Text.AlignVCenter } } diff --git a/src/imports/controls/material/RadioDelegate.qml b/src/imports/controls/material/RadioDelegate.qml index fb4f33dc..e2c15342 100644 --- a/src/imports/controls/material/RadioDelegate.qml +++ b/src/imports/controls/material/RadioDelegate.qml @@ -68,8 +68,6 @@ T.RadioDelegate { font: control.font color: control.enabled ? control.Material.foreground : control.Material.hintTextColor elide: Text.ElideRight - visible: control.text - horizontalAlignment: Text.AlignLeft verticalAlignment: Text.AlignVCenter } diff --git a/src/imports/controls/material/SwipeDelegate.qml b/src/imports/controls/material/SwipeDelegate.qml index d9014fcd..a406df2c 100644 --- a/src/imports/controls/material/SwipeDelegate.qml +++ b/src/imports/controls/material/SwipeDelegate.qml @@ -64,8 +64,6 @@ T.SwipeDelegate { font: control.font color: control.enabled ? control.Material.foreground : control.Material.hintTextColor elide: Text.ElideRight - visible: control.text - horizontalAlignment: Text.AlignLeft verticalAlignment: Text.AlignVCenter } diff --git a/src/imports/controls/material/Switch.qml b/src/imports/controls/material/Switch.qml index c4f279ee..36adcb45 100644 --- a/src/imports/controls/material/Switch.qml +++ b/src/imports/controls/material/Switch.qml @@ -75,8 +75,6 @@ T.Switch { font: control.font color: control.enabled ? control.Material.foreground : control.Material.hintTextColor elide: Text.ElideRight - visible: control.text - horizontalAlignment: Text.AlignLeft verticalAlignment: Text.AlignVCenter } } diff --git a/src/imports/controls/material/SwitchDelegate.qml b/src/imports/controls/material/SwitchDelegate.qml index 717ee250..2af147a0 100644 --- a/src/imports/controls/material/SwitchDelegate.qml +++ b/src/imports/controls/material/SwitchDelegate.qml @@ -68,8 +68,6 @@ T.SwitchDelegate { font: control.font color: control.enabled ? control.Material.foreground : control.Material.hintTextColor elide: Text.ElideRight - visible: control.text - horizontalAlignment: Text.AlignLeft verticalAlignment: Text.AlignVCenter } -- cgit v1.2.3 From 6d88fc14ab97379ccc3546ad8bfb70effe69abda Mon Sep 17 00:00:00 2001 From: J-P Nurmi Date: Tue, 19 Dec 2017 10:45:28 +0100 Subject: Universal: cleanup unnecessary property assignments Change-Id: I80c258ea21b4f6651e9c6e075357daabfb32d64b Reviewed-by: Mitch Curtis --- src/imports/controls/universal/CheckBox.qml | 2 -- src/imports/controls/universal/CheckDelegate.qml | 2 -- src/imports/controls/universal/ComboBox.qml | 1 - src/imports/controls/universal/GroupBox.qml | 1 - src/imports/controls/universal/ItemDelegate.qml | 2 -- src/imports/controls/universal/MenuItem.qml | 2 -- src/imports/controls/universal/RadioButton.qml | 2 -- src/imports/controls/universal/RadioDelegate.qml | 2 -- src/imports/controls/universal/SwipeDelegate.qml | 2 -- src/imports/controls/universal/Switch.qml | 2 -- src/imports/controls/universal/SwitchDelegate.qml | 2 -- 11 files changed, 20 deletions(-) (limited to 'src') diff --git a/src/imports/controls/universal/CheckBox.qml b/src/imports/controls/universal/CheckBox.qml index 8f4b248d..97a46c86 100644 --- a/src/imports/controls/universal/CheckBox.qml +++ b/src/imports/controls/universal/CheckBox.qml @@ -67,8 +67,6 @@ T.CheckBox { text: control.text font: control.font elide: Text.ElideRight - visible: control.text - horizontalAlignment: Text.AlignLeft verticalAlignment: Text.AlignVCenter opacity: enabled ? 1.0 : 0.2 diff --git a/src/imports/controls/universal/CheckDelegate.qml b/src/imports/controls/universal/CheckDelegate.qml index d3d8690e..230851cf 100644 --- a/src/imports/controls/universal/CheckDelegate.qml +++ b/src/imports/controls/universal/CheckDelegate.qml @@ -68,8 +68,6 @@ T.CheckDelegate { text: control.text font: control.font elide: Text.ElideRight - visible: control.text - horizontalAlignment: Text.AlignLeft verticalAlignment: Text.AlignVCenter opacity: enabled ? 1.0 : 0.2 diff --git a/src/imports/controls/universal/ComboBox.qml b/src/imports/controls/universal/ComboBox.qml index 596dcf5b..17e869d4 100644 --- a/src/imports/controls/universal/ComboBox.qml +++ b/src/imports/controls/universal/ComboBox.qml @@ -100,7 +100,6 @@ T.ComboBox { control.editable && control.activeFocus ? control.Universal.chromeBlackHighColor : control.Universal.foreground selectionColor: control.Universal.accent selectedTextColor: control.Universal.chromeWhiteColor - horizontalAlignment: Text.AlignLeft verticalAlignment: Text.AlignVCenter } diff --git a/src/imports/controls/universal/GroupBox.qml b/src/imports/controls/universal/GroupBox.qml index 420cf22d..38ab3d0b 100644 --- a/src/imports/controls/universal/GroupBox.qml +++ b/src/imports/controls/universal/GroupBox.qml @@ -60,7 +60,6 @@ T.GroupBox { text: control.title font: control.font elide: Text.ElideRight - horizontalAlignment: Text.AlignLeft verticalAlignment: Text.AlignVCenter opacity: enabled ? 1.0 : 0.2 diff --git a/src/imports/controls/universal/ItemDelegate.qml b/src/imports/controls/universal/ItemDelegate.qml index 69b2cd9d..4154d6f7 100644 --- a/src/imports/controls/universal/ItemDelegate.qml +++ b/src/imports/controls/universal/ItemDelegate.qml @@ -61,8 +61,6 @@ T.ItemDelegate { text: control.text font: control.font elide: Text.ElideRight - visible: control.text - horizontalAlignment: Text.AlignLeft verticalAlignment: Text.AlignVCenter opacity: enabled ? 1.0 : 0.2 diff --git a/src/imports/controls/universal/MenuItem.qml b/src/imports/controls/universal/MenuItem.qml index 35e2f2ba..48e7bf1c 100644 --- a/src/imports/controls/universal/MenuItem.qml +++ b/src/imports/controls/universal/MenuItem.qml @@ -61,8 +61,6 @@ T.MenuItem { font: control.font color: !control.enabled ? control.Universal.baseLowColor : control.Universal.baseHighColor elide: Text.ElideRight - visible: control.text - horizontalAlignment: Text.AlignLeft verticalAlignment: Text.AlignVCenter } diff --git a/src/imports/controls/universal/RadioButton.qml b/src/imports/controls/universal/RadioButton.qml index 5d778660..44949614 100644 --- a/src/imports/controls/universal/RadioButton.qml +++ b/src/imports/controls/universal/RadioButton.qml @@ -67,8 +67,6 @@ T.RadioButton { text: control.text font: control.font elide: Text.ElideRight - visible: control.text - horizontalAlignment: Text.AlignLeft verticalAlignment: Text.AlignVCenter opacity: enabled ? 1.0 : 0.2 diff --git a/src/imports/controls/universal/RadioDelegate.qml b/src/imports/controls/universal/RadioDelegate.qml index e8b0216c..575fa84d 100644 --- a/src/imports/controls/universal/RadioDelegate.qml +++ b/src/imports/controls/universal/RadioDelegate.qml @@ -68,8 +68,6 @@ T.RadioDelegate { text: control.text font: control.font elide: Text.ElideRight - visible: control.text - horizontalAlignment: Text.AlignLeft verticalAlignment: Text.AlignVCenter opacity: enabled ? 1.0 : 0.2 diff --git a/src/imports/controls/universal/SwipeDelegate.qml b/src/imports/controls/universal/SwipeDelegate.qml index cec5c132..60f2542c 100644 --- a/src/imports/controls/universal/SwipeDelegate.qml +++ b/src/imports/controls/universal/SwipeDelegate.qml @@ -63,8 +63,6 @@ T.SwipeDelegate { text: control.text font: control.font elide: Text.ElideRight - visible: control.text - horizontalAlignment: Text.AlignLeft verticalAlignment: Text.AlignVCenter opacity: enabled ? 1.0 : 0.2 diff --git a/src/imports/controls/universal/Switch.qml b/src/imports/controls/universal/Switch.qml index ad07d0df..bffd2b57 100644 --- a/src/imports/controls/universal/Switch.qml +++ b/src/imports/controls/universal/Switch.qml @@ -67,8 +67,6 @@ T.Switch { text: control.text font: control.font elide: Text.ElideRight - visible: control.text - horizontalAlignment: Text.AlignLeft verticalAlignment: Text.AlignVCenter opacity: enabled ? 1.0 : 0.2 diff --git a/src/imports/controls/universal/SwitchDelegate.qml b/src/imports/controls/universal/SwitchDelegate.qml index a4ba85db..533c2554 100644 --- a/src/imports/controls/universal/SwitchDelegate.qml +++ b/src/imports/controls/universal/SwitchDelegate.qml @@ -68,8 +68,6 @@ T.SwitchDelegate { text: control.text font: control.font elide: Text.ElideRight - visible: control.text - horizontalAlignment: Text.AlignLeft verticalAlignment: Text.AlignVCenter opacity: enabled ? 1.0 : 0.2 -- cgit v1.2.3 From b7216da727e4d2c135601afdf561ffcd2460af4e Mon Sep 17 00:00:00 2001 From: J-P Nurmi Date: Tue, 19 Dec 2017 10:48:10 +0100 Subject: Examples: cleanup unnecessary/wrong property assignments Change-Id: Id7c65c9493c0e70512f3f2b167a091ece06ee5d8 Reviewed-by: Mitch Curtis --- src/imports/controls/doc/snippets/qtquickcontrols2-checkbox-custom.qml | 1 - .../controls/doc/snippets/qtquickcontrols2-checkdelegate-custom.qml | 1 - src/imports/controls/doc/snippets/qtquickcontrols2-combobox-custom.qml | 1 - .../controls/doc/snippets/qtquickcontrols2-itemdelegate-custom.qml | 2 -- .../controls/doc/snippets/qtquickcontrols2-radiobutton-custom.qml | 1 - .../controls/doc/snippets/qtquickcontrols2-radiodelegate-custom.qml | 1 - .../controls/doc/snippets/qtquickcontrols2-swipedelegate-custom.qml | 2 -- src/imports/controls/doc/snippets/qtquickcontrols2-switch-custom.qml | 1 - .../controls/doc/snippets/qtquickcontrols2-switchdelegate-custom.qml | 1 - 9 files changed, 11 deletions(-) (limited to 'src') diff --git a/src/imports/controls/doc/snippets/qtquickcontrols2-checkbox-custom.qml b/src/imports/controls/doc/snippets/qtquickcontrols2-checkbox-custom.qml index e86f1393..ed2a6621 100644 --- a/src/imports/controls/doc/snippets/qtquickcontrols2-checkbox-custom.qml +++ b/src/imports/controls/doc/snippets/qtquickcontrols2-checkbox-custom.qml @@ -58,7 +58,6 @@ CheckBox { font: control.font opacity: enabled ? 1.0 : 0.3 color: control.down ? "#17a81a" : "#21be2b" - horizontalAlignment: Text.AlignHCenter verticalAlignment: Text.AlignVCenter leftPadding: control.indicator.width + control.spacing } diff --git a/src/imports/controls/doc/snippets/qtquickcontrols2-checkdelegate-custom.qml b/src/imports/controls/doc/snippets/qtquickcontrols2-checkdelegate-custom.qml index 2815aa25..aa19ff14 100644 --- a/src/imports/controls/doc/snippets/qtquickcontrols2-checkdelegate-custom.qml +++ b/src/imports/controls/doc/snippets/qtquickcontrols2-checkdelegate-custom.qml @@ -41,7 +41,6 @@ CheckDelegate { opacity: enabled ? 1.0 : 0.3 color: control.down ? "#17a81a" : "#21be2b" elide: Text.ElideRight - horizontalAlignment: Text.AlignLeft verticalAlignment: Text.AlignVCenter } diff --git a/src/imports/controls/doc/snippets/qtquickcontrols2-combobox-custom.qml b/src/imports/controls/doc/snippets/qtquickcontrols2-combobox-custom.qml index eb5f832c..68e7ddad 100644 --- a/src/imports/controls/doc/snippets/qtquickcontrols2-combobox-custom.qml +++ b/src/imports/controls/doc/snippets/qtquickcontrols2-combobox-custom.qml @@ -76,7 +76,6 @@ ComboBox { text: control.displayText font: control.font color: control.pressed ? "#17a81a" : "#21be2b" - horizontalAlignment: Text.AlignLeft verticalAlignment: Text.AlignVCenter elide: Text.ElideRight } diff --git a/src/imports/controls/doc/snippets/qtquickcontrols2-itemdelegate-custom.qml b/src/imports/controls/doc/snippets/qtquickcontrols2-itemdelegate-custom.qml index 8ce86d61..e19d28f3 100644 --- a/src/imports/controls/doc/snippets/qtquickcontrols2-itemdelegate-custom.qml +++ b/src/imports/controls/doc/snippets/qtquickcontrols2-itemdelegate-custom.qml @@ -39,8 +39,6 @@ ItemDelegate { font: control.font color: control.enabled ? (control.down ? "#17a81a" : "#21be2b") : "#bdbebf" elide: Text.ElideRight - visible: control.text - horizontalAlignment: Text.AlignLeft verticalAlignment: Text.AlignVCenter } diff --git a/src/imports/controls/doc/snippets/qtquickcontrols2-radiobutton-custom.qml b/src/imports/controls/doc/snippets/qtquickcontrols2-radiobutton-custom.qml index 3b3e8d4a..6d77772d 100644 --- a/src/imports/controls/doc/snippets/qtquickcontrols2-radiobutton-custom.qml +++ b/src/imports/controls/doc/snippets/qtquickcontrols2-radiobutton-custom.qml @@ -58,7 +58,6 @@ RadioButton { font: control.font opacity: enabled ? 1.0 : 0.3 color: control.down ? "#17a81a" : "#21be2b" - horizontalAlignment: Text.AlignHCenter verticalAlignment: Text.AlignVCenter leftPadding: control.indicator.width + control.spacing } diff --git a/src/imports/controls/doc/snippets/qtquickcontrols2-radiodelegate-custom.qml b/src/imports/controls/doc/snippets/qtquickcontrols2-radiodelegate-custom.qml index 1033befd..d486943d 100644 --- a/src/imports/controls/doc/snippets/qtquickcontrols2-radiodelegate-custom.qml +++ b/src/imports/controls/doc/snippets/qtquickcontrols2-radiodelegate-custom.qml @@ -41,7 +41,6 @@ RadioDelegate { opacity: enabled ? 1.0 : 0.3 color: control.down ? "#17a81a" : "#21be2b" elide: Text.ElideRight - horizontalAlignment: Text.AlignLeft verticalAlignment: Text.AlignVCenter } diff --git a/src/imports/controls/doc/snippets/qtquickcontrols2-swipedelegate-custom.qml b/src/imports/controls/doc/snippets/qtquickcontrols2-swipedelegate-custom.qml index f8b8f7af..4159e7f7 100644 --- a/src/imports/controls/doc/snippets/qtquickcontrols2-swipedelegate-custom.qml +++ b/src/imports/controls/doc/snippets/qtquickcontrols2-swipedelegate-custom.qml @@ -58,8 +58,6 @@ SwipeDelegate { font: control.font color: control.enabled ? (control.down ? "#17a81a" : "#21be2b") : "#bdbebf" elide: Text.ElideRight - visible: control.text - horizontalAlignment: Text.AlignLeft verticalAlignment: Text.AlignVCenter Behavior on x { diff --git a/src/imports/controls/doc/snippets/qtquickcontrols2-switch-custom.qml b/src/imports/controls/doc/snippets/qtquickcontrols2-switch-custom.qml index f1ec0797..51e6b0c2 100644 --- a/src/imports/controls/doc/snippets/qtquickcontrols2-switch-custom.qml +++ b/src/imports/controls/doc/snippets/qtquickcontrols2-switch-custom.qml @@ -57,7 +57,6 @@ Switch { font: control.font opacity: enabled ? 1.0 : 0.3 color: control.down ? "#17a81a" : "#21be2b" - horizontalAlignment: Text.AlignHCenter verticalAlignment: Text.AlignVCenter leftPadding: control.indicator.width + control.spacing } diff --git a/src/imports/controls/doc/snippets/qtquickcontrols2-switchdelegate-custom.qml b/src/imports/controls/doc/snippets/qtquickcontrols2-switchdelegate-custom.qml index 00b82f79..726614d8 100644 --- a/src/imports/controls/doc/snippets/qtquickcontrols2-switchdelegate-custom.qml +++ b/src/imports/controls/doc/snippets/qtquickcontrols2-switchdelegate-custom.qml @@ -41,7 +41,6 @@ SwitchDelegate { opacity: enabled ? 1.0 : 0.3 color: control.down ? "#17a81a" : "#21be2b" elide: Text.ElideRight - horizontalAlignment: Text.AlignLeft verticalAlignment: Text.AlignVCenter } -- cgit v1.2.3 From b94cb52c8b03511a2549469dfed33c6e0e857021 Mon Sep 17 00:00:00 2001 From: J-P Nurmi Date: Tue, 19 Dec 2017 14:47:09 +0100 Subject: Default: cleanup and test internal IDs Remove the undesired internal IDs where easily possible, and add expected failures for the harder ones for now. Task-number: QTBUG-65341 Change-Id: I5964b2cb59652661c90141259c68b95c721cf6ca Reviewed-by: Mitch Curtis --- src/imports/controls/Dial.qml | 1 - src/imports/controls/ScrollBar.qml | 6 ++---- src/imports/controls/ScrollIndicator.qml | 6 ++---- 3 files changed, 4 insertions(+), 9 deletions(-) (limited to 'src') diff --git a/src/imports/controls/Dial.qml b/src/imports/controls/Dial.qml index affcfa62..0bd2f163 100644 --- a/src/imports/controls/Dial.qml +++ b/src/imports/controls/Dial.qml @@ -54,7 +54,6 @@ T.Dial { } handle: Image { - id: handleItem x: background.x + background.width / 2 - handle.width / 2 y: background.y + background.height / 2 - handle.height / 2 width: 14 diff --git a/src/imports/controls/ScrollBar.qml b/src/imports/controls/ScrollBar.qml index 79e3e1ee..3e763550 100644 --- a/src/imports/controls/ScrollBar.qml +++ b/src/imports/controls/ScrollBar.qml @@ -51,8 +51,6 @@ T.ScrollBar { visible: control.policy !== T.ScrollBar.AlwaysOff contentItem: Rectangle { - id: handle - implicitWidth: control.interactive ? 6 : 2 implicitHeight: control.interactive ? 6 : 2 @@ -63,14 +61,14 @@ T.ScrollBar { states: State { name: "active" when: control.policy === T.ScrollBar.AlwaysOn || (control.active && control.size < 1.0) - PropertyChanges { target: handle; opacity: 0.75 } + PropertyChanges { target: control.contentItem; opacity: 0.75 } } transitions: Transition { from: "active" SequentialAnimation { PauseAnimation { duration: 450 } - NumberAnimation { target: handle; duration: 200; property: "opacity"; to: 0.0 } + NumberAnimation { target: control.contentItem; duration: 200; property: "opacity"; to: 0.0 } } } } diff --git a/src/imports/controls/ScrollIndicator.qml b/src/imports/controls/ScrollIndicator.qml index 12ec2d40..8607c8d4 100644 --- a/src/imports/controls/ScrollIndicator.qml +++ b/src/imports/controls/ScrollIndicator.qml @@ -50,8 +50,6 @@ T.ScrollIndicator { padding: 2 contentItem: Rectangle { - id: indicator - implicitWidth: 2 implicitHeight: 2 @@ -62,7 +60,7 @@ T.ScrollIndicator { states: State { name: "active" when: control.active - PropertyChanges { target: indicator; opacity: 0.75 } + PropertyChanges { target: control.contentItem; opacity: 0.75 } } transitions: [ @@ -70,7 +68,7 @@ T.ScrollIndicator { from: "active" SequentialAnimation { PauseAnimation { duration: 450 } - NumberAnimation { target: indicator; duration: 200; property: "opacity"; to: 0.0 } + NumberAnimation { target: control.contentItem; duration: 200; property: "opacity"; to: 0.0 } } } ] -- cgit v1.2.3 From da27cace5aa65c1972b746d9fc1d4507a04b5f93 Mon Sep 17 00:00:00 2001 From: J-P Nurmi Date: Tue, 19 Dec 2017 16:05:52 +0100 Subject: Default: cleanup the internal ID from BusyIndicator An internal ID in the OpacityAnimator element prevented deferred execution for the whole content item. Apply the same visibility trick in C++ to avoid having to use an ID in QML. Task-number: QTBUG-65341 Change-Id: Icb20e4ecc60d1093e849737799bb269f7f03097a Reviewed-by: Mitch Curtis --- src/imports/controls/BusyIndicator.qml | 4 ++-- .../controls/qquickdefaultbusyindicator.cpp | 24 ++++++++++++++++++++-- .../controls/qquickdefaultbusyindicator_p.h | 4 ++++ 3 files changed, 28 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/imports/controls/BusyIndicator.qml b/src/imports/controls/BusyIndicator.qml index 234c2e01..c92ef720 100644 --- a/src/imports/controls/BusyIndicator.qml +++ b/src/imports/controls/BusyIndicator.qml @@ -51,8 +51,8 @@ T.BusyIndicator { implicitWidth: 48 implicitHeight: 48 + running: control.running opacity: control.running ? 1 : 0 - visible: control.running || animator.running - Behavior on opacity { OpacityAnimator { id: animator; duration: 250 } } + Behavior on opacity { OpacityAnimator { duration: 250 } } } } diff --git a/src/imports/controls/qquickdefaultbusyindicator.cpp b/src/imports/controls/qquickdefaultbusyindicator.cpp index 315b2b8b..526eb29f 100644 --- a/src/imports/controls/qquickdefaultbusyindicator.cpp +++ b/src/imports/controls/qquickdefaultbusyindicator.cpp @@ -136,6 +136,17 @@ QQuickDefaultBusyIndicator::QQuickDefaultBusyIndicator(QQuickItem *parent) : setFlag(ItemHasContents); } +bool QQuickDefaultBusyIndicator::isRunning() const +{ + return isVisible(); +} + +void QQuickDefaultBusyIndicator::setRunning(bool running) +{ + if (running) + setVisible(true); +} + int QQuickDefaultBusyIndicator::elapsed() const { return m_elapsed; @@ -144,14 +155,23 @@ int QQuickDefaultBusyIndicator::elapsed() const void QQuickDefaultBusyIndicator::itemChange(QQuickItem::ItemChange change, const QQuickItem::ItemChangeData &data) { QQuickItem::itemChange(change, data); - if (change == ItemVisibleHasChanged) + switch (change) { + case ItemOpacityHasChanged: + if (qFuzzyIsNull(data.realValue)) + setVisible(false); + break; + case ItemVisibleHasChanged: update(); + break; + default: + break; + } } QSGNode *QQuickDefaultBusyIndicator::updatePaintNode(QSGNode *oldNode, QQuickItem::UpdatePaintNodeData *) { QQuickDefaultBusyIndicatorNode *node = static_cast(oldNode); - if (isVisible() && width() > 0 && height() > 0) { + if (isRunning() && width() > 0 && height() > 0) { if (!node) { node = new QQuickDefaultBusyIndicatorNode(this); node->start(); diff --git a/src/imports/controls/qquickdefaultbusyindicator_p.h b/src/imports/controls/qquickdefaultbusyindicator_p.h index 7daeabd1..21a706e7 100644 --- a/src/imports/controls/qquickdefaultbusyindicator_p.h +++ b/src/imports/controls/qquickdefaultbusyindicator_p.h @@ -55,10 +55,14 @@ QT_BEGIN_NAMESPACE class QQuickDefaultBusyIndicator : public QQuickItem { Q_OBJECT + Q_PROPERTY(bool running READ isRunning WRITE setRunning) public: explicit QQuickDefaultBusyIndicator(QQuickItem *parent = nullptr); + bool isRunning() const; + void setRunning(bool running); + int elapsed() const; protected: -- cgit v1.2.3 From 1e33020fc02b56001d805d3d66badd41480b746d Mon Sep 17 00:00:00 2001 From: J-P Nurmi Date: Tue, 19 Dec 2017 17:00:15 +0100 Subject: Default: eliminate internal IDs in DelayButton An ID in the internal Text element prevented deferred execution for the whole content item. The ID was used for two reasons. First of all, it was used to propagate implicit size from the Text element to the root of the content item. Secondly, it was used to calculate clip areas to provide the same text in two different colors. This patch provides two internal C++ helpers, ItemGroup and ClippedText, that provide these functionalities without the need of using IDs in QML. At the same time we got rid of two wrapper Items and simplified some QML bindings, which results to a nice boost (18->22) in qmlbench on TX1. Task-number: QTBUG-65341 Change-Id: Icf9c09356cf5c0ed641bde537bee7291bd260057 Reviewed-by: Mitch Curtis --- src/imports/controls/DelayButton.qml | 62 ++++-------- src/imports/controls/qtquickcontrols2plugin.cpp | 4 + src/quickcontrols2/qquickclippedtext.cpp | 122 ++++++++++++++++++++++++ src/quickcontrols2/qquickclippedtext_p.h | 96 +++++++++++++++++++ src/quickcontrols2/qquickitemgroup.cpp | 122 ++++++++++++++++++++++++ src/quickcontrols2/qquickitemgroup_p.h | 83 ++++++++++++++++ src/quickcontrols2/quickcontrols2.pri | 4 + 7 files changed, 452 insertions(+), 41 deletions(-) create mode 100644 src/quickcontrols2/qquickclippedtext.cpp create mode 100644 src/quickcontrols2/qquickclippedtext_p.h create mode 100644 src/quickcontrols2/qquickitemgroup.cpp create mode 100644 src/quickcontrols2/qquickitemgroup_p.h (limited to 'src') diff --git a/src/imports/controls/DelayButton.qml b/src/imports/controls/DelayButton.qml index 4a569fcf..133b2786 100644 --- a/src/imports/controls/DelayButton.qml +++ b/src/imports/controls/DelayButton.qml @@ -58,55 +58,35 @@ T.DelayButton { } } - contentItem: Item { - implicitWidth: label.implicitWidth - implicitHeight: label.implicitHeight - - Item { - x: -control.leftPadding + (control.progress * control.width) - width: (1.0 - control.progress) * control.width - height: parent.height - + contentItem: ItemGroup { + ClippedText { clip: control.progress > 0 + clipX: -control.leftPadding + control.progress * control.width + clipWidth: (1.0 - control.progress) * control.width visible: control.progress < 1 - Text { - id: label - x: -parent.x - width: control.availableWidth - height: parent.height - - text: control.text - font: control.font - opacity: enabled ? 1 : 0.3 - color: control.visualFocus ? Default.focusColor : (control.down ? Default.textDarkColor : Default.textColor) - horizontalAlignment: Text.AlignHCenter - verticalAlignment: Text.AlignVCenter - elide: Text.ElideRight - } + text: control.text + font: control.font + opacity: enabled ? 1 : 0.3 + color: control.visualFocus ? Default.focusColor : (control.down ? Default.textDarkColor : Default.textColor) + horizontalAlignment: Text.AlignHCenter + verticalAlignment: Text.AlignVCenter + elide: Text.ElideRight } - Item { - x: -control.leftPadding - width: control.progress * control.width - height: parent.height - + ClippedText { clip: control.progress > 0 + clipX: -control.leftPadding + clipWidth: control.progress * control.width visible: control.progress > 0 - Text { - x: control.leftPadding - width: control.availableWidth - height: parent.height - - text: control.text - font: control.font - opacity: enabled ? 1 : 0.3 - color: Default.textLightColor - horizontalAlignment: Text.AlignHCenter - verticalAlignment: Text.AlignVCenter - elide: Text.ElideRight - } + text: control.text + font: control.font + opacity: enabled ? 1 : 0.3 + color: Default.textLightColor + horizontalAlignment: Text.AlignHCenter + verticalAlignment: Text.AlignVCenter + elide: Text.ElideRight } } diff --git a/src/imports/controls/qtquickcontrols2plugin.cpp b/src/imports/controls/qtquickcontrols2plugin.cpp index 32270be0..e9471227 100644 --- a/src/imports/controls/qtquickcontrols2plugin.cpp +++ b/src/imports/controls/qtquickcontrols2plugin.cpp @@ -44,6 +44,8 @@ #if QT_CONFIG(quick_listview) && QT_CONFIG(quick_pathview) #include #endif +#include +#include #include "qquickdefaultbusyindicator_p.h" #include "qquickdefaultprogressbar_p.h" @@ -164,8 +166,10 @@ void QtQuickControls2Plugin::initializeEngine(QQmlEngine *engine, const char *ur qmlRegisterModule(import, 2, QT_VERSION_MINOR - 7); // Qt 5.7->2.0, 5.8->2.1, 5.9->2.2... qmlRegisterType(import, 2, 0, "BusyIndicatorImpl"); + qmlRegisterType(import, 2, 2, "ClippedText"); qmlRegisterType(import, 2, 0, "ProgressBarImpl"); qmlRegisterType(import, 2, 0, "DialRing"); + qmlRegisterType(import, 2, 2, "ItemGroup"); qmlRegisterType(import, 2, 2, "PlaceholderText"); #if QT_CONFIG(quick_listview) && QT_CONFIG(quick_pathview) qmlRegisterType(import, 2, 1, "TumblerView"); diff --git a/src/quickcontrols2/qquickclippedtext.cpp b/src/quickcontrols2/qquickclippedtext.cpp new file mode 100644 index 00000000..7f113592 --- /dev/null +++ b/src/quickcontrols2/qquickclippedtext.cpp @@ -0,0 +1,122 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the Qt Quick Controls 2 module 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 "qquickclippedtext_p.h" + +#include + +QT_BEGIN_NAMESPACE + +QQuickClippedText::QQuickClippedText(QQuickItem *parent) + : QQuickText(parent), + m_hasClipWidth(false), + m_hasClipHeight(false), + m_clipX(0), + m_clipY(0), + m_clipWidth(0), + m_clipHeight(0) +{ +} + +qreal QQuickClippedText::clipX() const +{ + return m_clipX; +} + +void QQuickClippedText::setClipX(qreal x) +{ + if (qFuzzyCompare(x, m_clipX)) + return; + + m_clipX = x; + markClipDirty(); +} + +qreal QQuickClippedText::clipY() const +{ + return m_clipY; +} + +void QQuickClippedText::setClipY(qreal y) +{ + if (qFuzzyCompare(y, m_clipY)) + return; + + m_clipY = y; + markClipDirty(); +} + +qreal QQuickClippedText::clipWidth() const +{ + return m_clipWidth ? m_clipWidth : width(); +} + +void QQuickClippedText::setClipWidth(qreal width) +{ + m_hasClipWidth = true; + if (qFuzzyCompare(width, m_clipWidth)) + return; + + m_clipWidth = width; + markClipDirty(); +} + +qreal QQuickClippedText::clipHeight() const +{ + return m_clipHeight ? m_clipHeight : height(); +} + +void QQuickClippedText::setClipHeight(qreal height) +{ + m_hasClipHeight = true; + if (qFuzzyCompare(height, m_clipHeight)) + return; + + m_clipHeight = height; + markClipDirty(); +} + +QRectF QQuickClippedText::clipRect() const +{ + return QRectF(clipX(), clipY(), clipWidth(), clipHeight()); +} + +void QQuickClippedText::markClipDirty() +{ + QQuickItemPrivate::get(this)->dirty(QQuickItemPrivate::Size); +} + +QT_END_NAMESPACE diff --git a/src/quickcontrols2/qquickclippedtext_p.h b/src/quickcontrols2/qquickclippedtext_p.h new file mode 100644 index 00000000..7521525f --- /dev/null +++ b/src/quickcontrols2/qquickclippedtext_p.h @@ -0,0 +1,96 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the Qt Quick Controls 2 module 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$ +** +****************************************************************************/ + +#ifndef QQUICKCLIPPEDTEXT_P_H +#define QQUICKCLIPPEDTEXT_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include +#include + +QT_BEGIN_NAMESPACE + +class Q_QUICKCONTROLS2_PRIVATE_EXPORT QQuickClippedText : public QQuickText +{ + Q_OBJECT + Q_PROPERTY(qreal clipX READ clipX WRITE setClipX FINAL) + Q_PROPERTY(qreal clipY READ clipY WRITE setClipY FINAL) + Q_PROPERTY(qreal clipWidth READ clipWidth WRITE setClipWidth FINAL) + Q_PROPERTY(qreal clipHeight READ clipHeight WRITE setClipHeight FINAL) + +public: + explicit QQuickClippedText(QQuickItem *parent = nullptr); + + qreal clipX() const; + void setClipX(qreal x); + + qreal clipY() const; + void setClipY(qreal y); + + qreal clipWidth() const; + void setClipWidth(qreal width); + + qreal clipHeight() const; + void setClipHeight(qreal height); + + QRectF clipRect() const override; + +private: + void markClipDirty(); + + bool m_hasClipWidth; + bool m_hasClipHeight; + qreal m_clipX; + qreal m_clipY; + qreal m_clipWidth; + qreal m_clipHeight; +}; + +QT_END_NAMESPACE + +QML_DECLARE_TYPE(QQuickClippedText) + +#endif // QQUICKCLIPPEDTEXT_P_H diff --git a/src/quickcontrols2/qquickitemgroup.cpp b/src/quickcontrols2/qquickitemgroup.cpp new file mode 100644 index 00000000..1396a871 --- /dev/null +++ b/src/quickcontrols2/qquickitemgroup.cpp @@ -0,0 +1,122 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the Qt Quick Controls 2 module 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 "qquickitemgroup_p.h" + +#include + +QT_BEGIN_NAMESPACE + +QQuickItemGroup::QQuickItemGroup(QQuickItem *parent) + : QQuickImplicitSizeItem(*(new QQuickImplicitSizeItemPrivate), parent) +{ +} + +QQuickItemGroup::~QQuickItemGroup() +{ + const auto children = childItems(); + for (QQuickItem *child : children) + unwatch(child); +} + +void QQuickItemGroup::watch(QQuickItem *item) +{ + QQuickItemPrivate::get(item)->addItemChangeListener(this, QQuickItemPrivate::ImplicitWidth | QQuickItemPrivate::ImplicitHeight); +} + +void QQuickItemGroup::unwatch(QQuickItem *item) +{ + QQuickItemPrivate::get(item)->removeItemChangeListener(this, QQuickItemPrivate::ImplicitWidth | QQuickItemPrivate::ImplicitHeight); +} + +QSizeF QQuickItemGroup::calculateImplicitSize() const +{ + qreal width = 0; + qreal height = 0; + const auto children = childItems(); + for (QQuickItem *child : children) { + width = qMax(width, child->implicitWidth()); + height = qMax(height, child->implicitHeight()); + } + return QSizeF(width, height); +} + +void QQuickItemGroup::updateImplicitSize() +{ + QSizeF size = calculateImplicitSize(); + setImplicitSize(size.width(), size.height()); +} + +void QQuickItemGroup::itemChange(ItemChange change, const ItemChangeData &data) +{ + QQuickImplicitSizeItem::itemChange(change, data); + switch (change) { + case ItemChildAddedChange: + watch(data.item); + data.item->setSize(QSizeF(width(), height())); + updateImplicitSize(); + break; + case ItemChildRemovedChange: + unwatch(data.item); + updateImplicitSize(); + break; + default: + break; + } +} + +void QQuickItemGroup::geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry) +{ + QQuickImplicitSizeItem::geometryChanged(newGeometry, oldGeometry); + + if (newGeometry.size() != oldGeometry.size()) { + const auto children = childItems(); + for (QQuickItem *child : children) + child->setSize(newGeometry.size()); + } +} + +void QQuickItemGroup::itemImplicitWidthChanged(QQuickItem *) +{ + setImplicitWidth(calculateImplicitSize().width()); +} + +void QQuickItemGroup::itemImplicitHeightChanged(QQuickItem *) +{ + setImplicitHeight(calculateImplicitSize().height()); +} + +QT_END_NAMESPACE diff --git a/src/quickcontrols2/qquickitemgroup_p.h b/src/quickcontrols2/qquickitemgroup_p.h new file mode 100644 index 00000000..af062d57 --- /dev/null +++ b/src/quickcontrols2/qquickitemgroup_p.h @@ -0,0 +1,83 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the Qt Quick Controls 2 module 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$ +** +****************************************************************************/ + +#ifndef QQUICKITEMGROUP_P_H +#define QQUICKITEMGROUP_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include +#include +#include + +QT_BEGIN_NAMESPACE + +class Q_QUICKCONTROLS2_PRIVATE_EXPORT QQuickItemGroup : public QQuickImplicitSizeItem, protected QQuickItemChangeListener +{ + Q_OBJECT + +public: + explicit QQuickItemGroup(QQuickItem *parent = nullptr); + ~QQuickItemGroup(); + +protected: + void watch(QQuickItem *item); + void unwatch(QQuickItem *item); + + QSizeF calculateImplicitSize() const; + void updateImplicitSize(); + + void itemChange(ItemChange change, const ItemChangeData &data) override; + void geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry) override; + + void itemImplicitWidthChanged(QQuickItem *item) override; + void itemImplicitHeightChanged(QQuickItem *item) override; +}; + +QT_END_NAMESPACE + +QML_DECLARE_TYPE(QQuickItemGroup) + +#endif // QQUICKITEMGROUP_P_H diff --git a/src/quickcontrols2/quickcontrols2.pri b/src/quickcontrols2/quickcontrols2.pri index a618989e..9be0c009 100644 --- a/src/quickcontrols2/quickcontrols2.pri +++ b/src/quickcontrols2/quickcontrols2.pri @@ -1,6 +1,8 @@ HEADERS += \ $$PWD/qquickanimatednode_p.h \ + $$PWD/qquickclippedtext_p.h \ $$PWD/qquickcolorimageprovider_p.h \ + $$PWD/qquickitemgroup_p.h \ $$PWD/qquickplaceholdertext_p.h \ $$PWD/qquickproxytheme_p.h \ $$PWD/qquickstyle.h \ @@ -13,7 +15,9 @@ HEADERS += \ SOURCES += \ $$PWD/qquickanimatednode.cpp \ + $$PWD/qquickclippedtext.cpp \ $$PWD/qquickcolorimageprovider.cpp \ + $$PWD/qquickitemgroup.cpp \ $$PWD/qquickplaceholdertext.cpp \ $$PWD/qquickproxytheme.cpp \ $$PWD/qquickstyle.cpp \ -- cgit v1.2.3 From c40486acc352d49398186fa32d1ccabdd5fc83c6 Mon Sep 17 00:00:00 2001 From: J-P Nurmi Date: Tue, 19 Dec 2017 13:38:40 +0100 Subject: Fix deferred execution If the QML engine refuses to defer execution of a delegate (it contains an ID), we must make sure to cancel any pending deferred execution for the same delegate. Otherwise, we may end up overriding a custom (non- deferred) delegate with a default (deferred) delegate. This patch adds a new test style "identified" to tst_customization. This style contains delegates with IDs so we can test the behavior with IDs in base styles. Furthermore, overriding delegates is now tested in various ways (with and without IDs in the base and custom styles) in a separate test method. This is done by generating QML code to override delegates with dummy Item instances with appropriate IDs and names. Task-number: QTBUG-65341 Change-Id: Ie6dca287cb74672004d9d8f599760b9d32c3a380 Reviewed-by: Mitch Curtis --- src/quicktemplates2/qquickabstractbutton.cpp | 13 ++++++++-- src/quicktemplates2/qquickabstractbutton_p_p.h | 1 + src/quicktemplates2/qquickapplicationwindow.cpp | 12 +++++++++- src/quicktemplates2/qquickcombobox.cpp | 25 +++++++++++++++++-- src/quicktemplates2/qquickcontrol.cpp | 22 +++++++++++++++-- src/quicktemplates2/qquickcontrol_p_p.h | 3 +++ src/quicktemplates2/qquickdeferredexecute.cpp | 32 ++++++++++++++++++------- src/quicktemplates2/qquickdeferredexecute_p_p.h | 9 ++++--- src/quicktemplates2/qquickdial.cpp | 12 +++++++++- src/quicktemplates2/qquickgroupbox.cpp | 12 +++++++++- src/quicktemplates2/qquicklabel.cpp | 11 ++++++++- src/quicktemplates2/qquicklabel_p_p.h | 1 + src/quicktemplates2/qquickpopupitem.cpp | 17 +++++++++++-- src/quicktemplates2/qquickrangeslider.cpp | 16 ++++++++++--- src/quicktemplates2/qquickslider.cpp | 12 +++++++++- src/quicktemplates2/qquickspinbox.cpp | 12 +++++++++- src/quicktemplates2/qquicktextarea.cpp | 11 ++++++++- src/quicktemplates2/qquicktextarea_p_p.h | 1 + src/quicktemplates2/qquicktextfield.cpp | 11 ++++++++- src/quicktemplates2/qquicktextfield_p_p.h | 1 + 20 files changed, 204 insertions(+), 30 deletions(-) (limited to 'src') diff --git a/src/quicktemplates2/qquickabstractbutton.cpp b/src/quicktemplates2/qquickabstractbutton.cpp index 45ade7bb..af676a50 100644 --- a/src/quicktemplates2/qquickabstractbutton.cpp +++ b/src/quicktemplates2/qquickabstractbutton.cpp @@ -261,13 +261,19 @@ void QQuickAbstractButtonPrivate::toggle(bool value) static inline QString indicatorName() { return QStringLiteral("indicator"); } +void QQuickAbstractButtonPrivate::cancelIndicator() +{ + Q_Q(QQuickAbstractButton); + quickCancelDeferred(q, indicatorName()); +} + void QQuickAbstractButtonPrivate::executeIndicator(bool complete) { - Q_Q(QQuickControl); + Q_Q(QQuickAbstractButton); if (indicator.wasExecuted()) return; - if (!indicator) + if (!indicator || complete) quickBeginDeferred(q, indicatorName(), indicator); if (complete) quickCompleteDeferred(q, indicatorName(), indicator); @@ -572,6 +578,9 @@ void QQuickAbstractButton::setIndicator(QQuickItem *indicator) if (d->indicator == indicator) return; + if (!d->indicator.isExecuting()) + d->cancelIndicator(); + delete d->indicator; d->indicator = indicator; if (indicator) { diff --git a/src/quicktemplates2/qquickabstractbutton_p_p.h b/src/quicktemplates2/qquickabstractbutton_p_p.h index 6634971e..07e6d3f2 100644 --- a/src/quicktemplates2/qquickabstractbutton_p_p.h +++ b/src/quicktemplates2/qquickabstractbutton_p_p.h @@ -85,6 +85,7 @@ public: void toggle(bool value); + void cancelIndicator(); void executeIndicator(bool complete = false); QString text; diff --git a/src/quicktemplates2/qquickapplicationwindow.cpp b/src/quicktemplates2/qquickapplicationwindow.cpp index c1a7f301..b07b2142 100644 --- a/src/quicktemplates2/qquickapplicationwindow.cpp +++ b/src/quicktemplates2/qquickapplicationwindow.cpp @@ -175,6 +175,7 @@ public: static void contentData_append(QQmlListProperty *prop, QObject *obj); + void cancelBackground(); void executeBackground(bool complete = false); bool complete; @@ -301,13 +302,19 @@ void QQuickApplicationWindowPrivate::contentData_append(QQmlListPropertybackground == background) return; + if (!d->background.isExecuting()) + d->cancelBackground(); + delete d->background; d->background = background; if (background) { diff --git a/src/quicktemplates2/qquickcombobox.cpp b/src/quicktemplates2/qquickcombobox.cpp index d221b9bc..fb10730e 100644 --- a/src/quicktemplates2/qquickcombobox.cpp +++ b/src/quicktemplates2/qquickcombobox.cpp @@ -253,7 +253,10 @@ public: void handleRelease(const QPointF &point) override; void handleUngrab() override; + void cancelIndicator(); void executeIndicator(bool complete = false); + + void cancelPopup(); void executePopup(bool complete = false); bool flat; @@ -671,13 +674,19 @@ void QQuickComboBoxPrivate::handleUngrab() static inline QString indicatorName() { return QStringLiteral("indicator"); } +void QQuickComboBoxPrivate::cancelIndicator() +{ + Q_Q(QQuickComboBox); + quickCancelDeferred(q, indicatorName()); +} + void QQuickComboBoxPrivate::executeIndicator(bool complete) { Q_Q(QQuickComboBox); if (indicator.wasExecuted()) return; - if (!indicator) + if (!indicator || complete) quickBeginDeferred(q, indicatorName(), indicator); if (complete) quickCompleteDeferred(q, indicatorName(), indicator); @@ -685,13 +694,19 @@ void QQuickComboBoxPrivate::executeIndicator(bool complete) static inline QString popupName() { return QStringLiteral("popup"); } +void QQuickComboBoxPrivate::cancelPopup() +{ + Q_Q(QQuickComboBox); + quickCancelDeferred(q, popupName()); +} + void QQuickComboBoxPrivate::executePopup(bool complete) { Q_Q(QQuickComboBox); if (popup.wasExecuted()) return; - if (!popup) + if (!popup || complete) quickBeginDeferred(q, popupName(), popup); if (complete) quickCompleteDeferred(q, popupName(), popup); @@ -1015,6 +1030,9 @@ void QQuickComboBox::setIndicator(QQuickItem *indicator) if (d->indicator == indicator) return; + if (!d->indicator.isExecuting()) + d->cancelIndicator(); + delete d->indicator; d->indicator = indicator; if (indicator) { @@ -1052,6 +1070,9 @@ void QQuickComboBox::setPopup(QQuickPopup *popup) if (d->popup == popup) return; + if (!d->popup.isExecuting()) + d->cancelPopup(); + if (d->popup) { QObjectPrivate::disconnect(d->popup.data(), &QQuickPopup::visibleChanged, d, &QQuickComboBoxPrivate::popupVisibleChanged); delete d->popup; diff --git a/src/quicktemplates2/qquickcontrol.cpp b/src/quicktemplates2/qquickcontrol.cpp index cfecc67c..6fbd4c07 100644 --- a/src/quicktemplates2/qquickcontrol.cpp +++ b/src/quicktemplates2/qquickcontrol.cpp @@ -292,6 +292,9 @@ void QQuickControlPrivate::setContentItem_helper(QQuickItem *item, bool notify) if (contentItem == item) return; + if (!contentItem.isExecuting()) + cancelContentItem(); + q->contentItemChange(item, contentItem); delete contentItem; contentItem = item; @@ -938,13 +941,19 @@ QLocale QQuickControlPrivate::calcLocale(const QQuickItem *item) static inline QString contentItemName() { return QStringLiteral("contentItem"); } +void QQuickControlPrivate::cancelContentItem() +{ + Q_Q(QQuickControl); + quickCancelDeferred(q, contentItemName()); +} + void QQuickControlPrivate::executeContentItem(bool complete) { Q_Q(QQuickControl); if (contentItem.wasExecuted()) return; - if (!contentItem) + if (!contentItem || complete) quickBeginDeferred(q, contentItemName(), contentItem); if (complete) quickCompleteDeferred(q, contentItemName(), contentItem); @@ -952,13 +961,19 @@ void QQuickControlPrivate::executeContentItem(bool complete) static inline QString backgroundName() { return QStringLiteral("background"); } +void QQuickControlPrivate::cancelBackground() +{ + Q_Q(QQuickControl); + quickCancelDeferred(q, backgroundName()); +} + void QQuickControlPrivate::executeBackground(bool complete) { Q_Q(QQuickControl); if (background.wasExecuted()) return; - if (!background) + if (!background || complete) quickBeginDeferred(q, backgroundName(), background); if (complete) quickCompleteDeferred(q, backgroundName(), background); @@ -1257,6 +1272,9 @@ void QQuickControl::setBackground(QQuickItem *background) if (d->background == background) return; + if (!d->background.isExecuting()) + d->cancelBackground(); + delete d->background; d->background = background; if (background) { diff --git a/src/quicktemplates2/qquickcontrol_p_p.h b/src/quicktemplates2/qquickcontrol_p_p.h index 81fa03a4..3ed8b637 100644 --- a/src/quicktemplates2/qquickcontrol_p_p.h +++ b/src/quicktemplates2/qquickcontrol_p_p.h @@ -127,7 +127,10 @@ public: static bool calcHoverEnabled(const QQuickItem *item); #endif + virtual void cancelContentItem(); virtual void executeContentItem(bool complete = false); + + virtual void cancelBackground(); virtual void executeBackground(bool complete = false); static void destroyDelegate(QObject *object, QObject *parent); diff --git a/src/quicktemplates2/qquickdeferredexecute.cpp b/src/quicktemplates2/qquickdeferredexecute.cpp index 802ed3d0..ca6953bc 100644 --- a/src/quicktemplates2/qquickdeferredexecute.cpp +++ b/src/quicktemplates2/qquickdeferredexecute.cpp @@ -55,13 +55,24 @@ static inline uint qHash(QObject *object, const QString &propertyName) Q_GLOBAL_STATIC(DeferredStates, deferredStates) -static void beginDeferred(QQmlEnginePrivate *enginePriv, const QQmlProperty &property, QQmlComponentPrivate::DeferredState *deferredState) +static void cancelDeferred(QObject *object, int propertyIndex) +{ + QQmlData *ddata = QQmlData::get(object); + auto dit = ddata->deferredData.rbegin(); + while (dit != ddata->deferredData.rend()) { + (*dit)->bindings.remove(propertyIndex); + ++dit; + } +} + +static bool beginDeferred(QQmlEnginePrivate *enginePriv, const QQmlProperty &property, QQmlComponentPrivate::DeferredState *deferredState) { QObject *object = property.object(); QQmlData *ddata = QQmlData::get(object); Q_ASSERT(!ddata->deferredData.isEmpty()); int propertyIndex = property.index(); + int wasInProgress = enginePriv->inProgressCreations; for (auto dit = ddata->deferredData.rbegin(); dit != ddata->deferredData.rend(); ++dit) { QQmlData::DeferredData *deferData = *dit; @@ -91,12 +102,11 @@ static void beginDeferred(QQmlEnginePrivate *enginePriv, const QQmlProperty &pro // Cleanup any remaining deferred bindings for this property, also in inner contexts, // to avoid executing them later and overriding the property that was just populated. - while (dit != ddata->deferredData.rend()) { - (*dit)->bindings.remove(propertyIndex); - ++dit; - } + cancelDeferred(object, propertyIndex); break; } + + return enginePriv->inProgressCreations > wasInProgress; } void beginDeferred(QObject *object, const QString &property) @@ -106,15 +116,21 @@ void beginDeferred(QObject *object, const QString &property) QQmlEnginePrivate *ep = QQmlEnginePrivate::get(data->context->engine); QQmlComponentPrivate::DeferredState *state = new QQmlComponentPrivate::DeferredState; - beginDeferred(ep, QQmlProperty(object, property), state); + if (beginDeferred(ep, QQmlProperty(object, property), state)) + deferredStates()->insert(qHash(object, property), state); + else + delete state; // Release deferred data for those compilation units that no longer have deferred bindings data->releaseDeferredData(); - - deferredStates()->insert(qHash(object, property), state); } } +void cancelDeferred(QObject *object, const QString &property) +{ + cancelDeferred(object, QQmlProperty(object, property).index()); +} + void completeDeferred(QObject *object, const QString &property) { QQmlData *data = QQmlData::get(object); diff --git a/src/quicktemplates2/qquickdeferredexecute_p_p.h b/src/quicktemplates2/qquickdeferredexecute_p_p.h index 87124e48..400c5734 100644 --- a/src/quicktemplates2/qquickdeferredexecute_p_p.h +++ b/src/quicktemplates2/qquickdeferredexecute_p_p.h @@ -58,25 +58,28 @@ class QObject; namespace QtQuickPrivate { void beginDeferred(QObject *object, const QString &property); + void cancelDeferred(QObject *object, const QString &property); void completeDeferred(QObject *object, const QString &property); } template void quickBeginDeferred(QObject *object, const QString &property, QQuickDeferredPointer &delegate) { - Q_ASSERT(delegate.isNull()); delegate.setExecuting(true); QtQuickPrivate::beginDeferred(object, property); delegate.setExecuting(false); } +inline void quickCancelDeferred(QObject *object, const QString &property) +{ + QtQuickPrivate::cancelDeferred(object, property); +} + template void quickCompleteDeferred(QObject *object, const QString &property, QQuickDeferredPointer &delegate) { Q_ASSERT(!delegate.wasExecuted()); - delegate.setExecuting(true); QtQuickPrivate::completeDeferred(object, property); - delegate.setExecuting(false); delegate.setExecuted(); } diff --git a/src/quicktemplates2/qquickdial.cpp b/src/quicktemplates2/qquickdial.cpp index 964cefe1..b5957069 100644 --- a/src/quicktemplates2/qquickdial.cpp +++ b/src/quicktemplates2/qquickdial.cpp @@ -123,6 +123,7 @@ public: void handleRelease(const QPointF &point) override; void handleUngrab() override; + void cancelHandle(); void executeHandle(bool complete = false); qreal from; @@ -258,13 +259,19 @@ void QQuickDialPrivate::handleUngrab() static inline QString handleName() { return QStringLiteral("handle"); } +void QQuickDialPrivate::cancelHandle() +{ + Q_Q(QQuickDial); + quickCancelDeferred(q, handleName()); +} + void QQuickDialPrivate::executeHandle(bool complete) { Q_Q(QQuickDial); if (handle.wasExecuted()) return; - if (!handle) + if (!handle || complete) quickBeginDeferred(q, handleName(), handle); if (complete) quickCompleteDeferred(q, handleName(), handle); @@ -553,6 +560,9 @@ void QQuickDial::setHandle(QQuickItem *handle) if (handle == d->handle) return; + if (!d->handle.isExecuting()) + d->cancelHandle(); + delete d->handle; d->handle = handle; if (d->handle && !d->handle->parentItem()) diff --git a/src/quicktemplates2/qquickgroupbox.cpp b/src/quicktemplates2/qquickgroupbox.cpp index 674f5b18..3c7bf715 100644 --- a/src/quicktemplates2/qquickgroupbox.cpp +++ b/src/quicktemplates2/qquickgroupbox.cpp @@ -91,6 +91,7 @@ class QQuickGroupBoxPrivate : public QQuickFramePrivate public: QQuickGroupBoxPrivate() : label(nullptr) { } + void cancelLabel(); void executeLabel(bool complete = false); QString title; @@ -99,13 +100,19 @@ public: static inline QString labelName() { return QStringLiteral("label"); } +void QQuickGroupBoxPrivate::cancelLabel() +{ + Q_Q(QQuickGroupBox); + quickCancelDeferred(q, labelName()); +} + void QQuickGroupBoxPrivate::executeLabel(bool complete) { Q_Q(QQuickGroupBox); if (label.wasExecuted()) return; - if (!label) + if (!label || complete) quickBeginDeferred(q, labelName(), label); if (complete) quickCompleteDeferred(q, labelName(), label); @@ -162,6 +169,9 @@ void QQuickGroupBox::setLabel(QQuickItem *label) if (d->label == label) return; + if (!d->label.isExecuting()) + d->cancelLabel(); + delete d->label; d->label = label; if (label && !label->parentItem()) diff --git a/src/quicktemplates2/qquicklabel.cpp b/src/quicktemplates2/qquicklabel.cpp index 418a7834..c8b125ca 100644 --- a/src/quicktemplates2/qquicklabel.cpp +++ b/src/quicktemplates2/qquicklabel.cpp @@ -158,13 +158,19 @@ QAccessible::Role QQuickLabelPrivate::accessibleRole() const static inline QString backgroundName() { return QStringLiteral("background"); } +void QQuickLabelPrivate::cancelBackground() +{ + Q_Q(QQuickLabel); + quickCancelDeferred(q, backgroundName()); +} + void QQuickLabelPrivate::executeBackground(bool complete) { Q_Q(QQuickLabel); if (background.wasExecuted()) return; - if (!background) + if (!background || complete) quickBeginDeferred(q, backgroundName(), background); if (complete) quickCompleteDeferred(q, backgroundName(), background); @@ -217,6 +223,9 @@ void QQuickLabel::setBackground(QQuickItem *background) if (d->background == background) return; + if (!d->background.isExecuting()) + d->cancelBackground(); + delete d->background; d->background = background; if (background) { diff --git a/src/quicktemplates2/qquicklabel_p_p.h b/src/quicktemplates2/qquicklabel_p_p.h index b8ad2ae7..f612434b 100644 --- a/src/quicktemplates2/qquicklabel_p_p.h +++ b/src/quicktemplates2/qquicklabel_p_p.h @@ -85,6 +85,7 @@ public: QAccessible::Role accessibleRole() const override; #endif + void cancelBackground(); void executeBackground(bool complete = false); QFont font; diff --git a/src/quicktemplates2/qquickpopupitem.cpp b/src/quicktemplates2/qquickpopupitem.cpp index db335a06..96816eac 100644 --- a/src/quicktemplates2/qquickpopupitem.cpp +++ b/src/quicktemplates2/qquickpopupitem.cpp @@ -60,7 +60,10 @@ public: QQuickItem *getContentItem() override; + void cancelContentItem() override; void executeContentItem(bool complete = false) override; + + void cancelBackground() override; void executeBackground(bool complete = false) override; int backId; @@ -106,12 +109,17 @@ QQuickItem *QQuickPopupItemPrivate::getContentItem() static inline QString contentItemName() { return QStringLiteral("contentItem"); } +void QQuickPopupItemPrivate::cancelContentItem() +{ + quickCancelDeferred(popup, contentItemName()); +} + void QQuickPopupItemPrivate::executeContentItem(bool complete) { if (contentItem.wasExecuted()) return; - if (!contentItem) + if (!contentItem || complete) quickBeginDeferred(popup, contentItemName(), contentItem); if (complete) quickCompleteDeferred(popup, contentItemName(), contentItem); @@ -119,12 +127,17 @@ void QQuickPopupItemPrivate::executeContentItem(bool complete) static inline QString backgroundName() { return QStringLiteral("background"); } +void QQuickPopupItemPrivate::cancelBackground() +{ + quickCancelDeferred(popup, backgroundName()); +} + void QQuickPopupItemPrivate::executeBackground(bool complete) { if (background.wasExecuted()) return; - if (!background) + if (!background || complete) quickBeginDeferred(popup, backgroundName(), background); if (complete) quickCompleteDeferred(popup, backgroundName(), background); diff --git a/src/quicktemplates2/qquickrangeslider.cpp b/src/quicktemplates2/qquickrangeslider.cpp index 51b646ce..557adc3a 100644 --- a/src/quicktemplates2/qquickrangeslider.cpp +++ b/src/quicktemplates2/qquickrangeslider.cpp @@ -110,6 +110,7 @@ public: void setPosition(qreal position, bool ignoreOtherPosition = false); void updatePosition(bool ignoreOtherPosition = false); + void cancelHandle(); void executeHandle(bool complete = false); static QQuickRangeSliderNodePrivate *get(QQuickRangeSliderNode *node); @@ -154,13 +155,19 @@ void QQuickRangeSliderNodePrivate::updatePosition(bool ignoreOtherPosition) static inline QString handleName() { return QStringLiteral("handle"); } +void QQuickRangeSliderNodePrivate::cancelHandle() +{ + Q_Q(QQuickRangeSliderNode); + quickCancelDeferred(q, handleName()); +} + void QQuickRangeSliderNodePrivate::executeHandle(bool complete) { Q_Q(QQuickRangeSliderNode); if (handle.wasExecuted()) return; - if (!handle) + if (!handle || complete) quickBeginDeferred(q, handleName(), handle); if (complete) quickCompleteDeferred(q, handleName(), handle); @@ -256,14 +263,17 @@ void QQuickRangeSliderNode::setHandle(QQuickItem *handle) if (d->handle == handle) return; + if (!d->handle.isExecuting()) + d->cancelHandle(); + delete d->handle; d->handle = handle; if (handle) { if (!handle->parentItem()) handle->setParentItem(d->slider); - QQuickItem *firstHandle = d->slider->first()->handle(); - QQuickItem *secondHandle = d->slider->second()->handle(); + QQuickItem *firstHandle = QQuickRangeSliderNodePrivate::get(d->slider->first())->handle; + QQuickItem *secondHandle = QQuickRangeSliderNodePrivate::get(d->slider->second())->handle; if (firstHandle && secondHandle) { // The order of property assignments in QML is undefined, // but we need the first handle to be before the second due diff --git a/src/quicktemplates2/qquickslider.cpp b/src/quicktemplates2/qquickslider.cpp index 73fa2725..94c9762d 100644 --- a/src/quicktemplates2/qquickslider.cpp +++ b/src/quicktemplates2/qquickslider.cpp @@ -113,6 +113,7 @@ public: void handleRelease(const QPointF &point) override; void handleUngrab() override; + void cancelHandle(); void executeHandle(bool complete = false); qreal from; @@ -240,13 +241,19 @@ void QQuickSliderPrivate::handleUngrab() static inline QString handleName() { return QStringLiteral("handle"); } +void QQuickSliderPrivate::cancelHandle() +{ + Q_Q(QQuickSlider); + quickCancelDeferred(q, handleName()); +} + void QQuickSliderPrivate::executeHandle(bool complete) { Q_Q(QQuickSlider); if (handle.wasExecuted()) return; - if (!handle) + if (!handle || complete) quickBeginDeferred(q, handleName(), handle); if (complete) quickCompleteDeferred(q, handleName(), handle); @@ -514,6 +521,9 @@ void QQuickSlider::setHandle(QQuickItem *handle) if (d->handle == handle) return; + if (!d->handle.isExecuting()) + d->cancelHandle(); + delete d->handle; d->handle = handle; if (handle && !handle->parentItem()) diff --git a/src/quicktemplates2/qquickspinbox.cpp b/src/quicktemplates2/qquickspinbox.cpp index 80bef2db..24ec19f8 100644 --- a/src/quicktemplates2/qquickspinbox.cpp +++ b/src/quicktemplates2/qquickspinbox.cpp @@ -177,6 +177,7 @@ public: return button->d_func(); } + void cancelIndicator(); void executeIndicator(bool complete = false); bool pressed; @@ -934,13 +935,19 @@ void QQuickSpinBox::accessibilityActiveChanged(bool active) static inline QString indicatorName() { return QStringLiteral("indicator"); } +void QQuickSpinButtonPrivate::cancelIndicator() +{ + Q_Q(QQuickSpinButton); + quickCancelDeferred(q, indicatorName()); +} + void QQuickSpinButtonPrivate::executeIndicator(bool complete) { Q_Q(QQuickSpinButton); if (indicator.wasExecuted()) return; - if (!indicator) + if (!indicator || complete) quickBeginDeferred(q, indicatorName(), indicator); if (complete) quickCompleteDeferred(q, indicatorName(), indicator); @@ -981,6 +988,9 @@ void QQuickSpinButton::setIndicator(QQuickItem *indicator) if (d->indicator == indicator) return; + if (!d->indicator.isExecuting()) + d->cancelIndicator(); + delete d->indicator; d->indicator = indicator; diff --git a/src/quicktemplates2/qquicktextarea.cpp b/src/quicktemplates2/qquicktextarea.cpp index 06867742..500e7bba 100644 --- a/src/quicktemplates2/qquicktextarea.cpp +++ b/src/quicktemplates2/qquicktextarea.cpp @@ -394,13 +394,19 @@ QAccessible::Role QQuickTextAreaPrivate::accessibleRole() const static inline QString backgroundName() { return QStringLiteral("background"); } +void QQuickTextAreaPrivate::cancelBackground() +{ + Q_Q(QQuickTextArea); + quickCancelDeferred(q, backgroundName()); +} + void QQuickTextAreaPrivate::executeBackground(bool complete) { Q_Q(QQuickTextArea); if (background.wasExecuted()) return; - if (!background) + if (!background || complete) quickBeginDeferred(q, backgroundName(), background); if (complete) quickCompleteDeferred(q, backgroundName(), background); @@ -471,6 +477,9 @@ void QQuickTextArea::setBackground(QQuickItem *background) if (d->background == background) return; + if (!d->background.isExecuting()) + d->cancelBackground(); + delete d->background; d->background = background; if (background) { diff --git a/src/quicktemplates2/qquicktextarea_p_p.h b/src/quicktemplates2/qquicktextarea_p_p.h index ede9d97f..42ac6fe7 100644 --- a/src/quicktemplates2/qquicktextarea_p_p.h +++ b/src/quicktemplates2/qquicktextarea_p_p.h @@ -109,6 +109,7 @@ public: QAccessible::Role accessibleRole() const override; #endif + void cancelBackground(); void executeBackground(bool complete = false); #if QT_CONFIG(quicktemplates2_hover) diff --git a/src/quicktemplates2/qquicktextfield.cpp b/src/quicktemplates2/qquicktextfield.cpp index 2d432ec0..8ca51ddb 100644 --- a/src/quicktemplates2/qquicktextfield.cpp +++ b/src/quicktemplates2/qquicktextfield.cpp @@ -268,13 +268,19 @@ QAccessible::Role QQuickTextFieldPrivate::accessibleRole() const static inline QString backgroundName() { return QStringLiteral("background"); } +void QQuickTextFieldPrivate::cancelBackground() +{ + Q_Q(QQuickTextField); + quickCancelDeferred(q, backgroundName()); +} + void QQuickTextFieldPrivate::executeBackground(bool complete) { Q_Q(QQuickTextField); if (background.wasExecuted()) return; - if (!background) + if (!background || complete) quickBeginDeferred(q, backgroundName(), background); if (complete) quickCompleteDeferred(q, backgroundName(), background); @@ -333,6 +339,9 @@ void QQuickTextField::setBackground(QQuickItem *background) if (d->background == background) return; + if (!d->background.isExecuting()) + d->cancelBackground(); + delete d->background; d->background = background; if (background) { diff --git a/src/quicktemplates2/qquicktextfield_p_p.h b/src/quicktemplates2/qquicktextfield_p_p.h index 037c6a21..32a79db3 100644 --- a/src/quicktemplates2/qquicktextfield_p_p.h +++ b/src/quicktemplates2/qquicktextfield_p_p.h @@ -98,6 +98,7 @@ public: QAccessible::Role accessibleRole() const override; #endif + void cancelBackground(); void executeBackground(bool complete = false); #if QT_CONFIG(quicktemplates2_hover) -- cgit v1.2.3 From 54352f1721b7f2c29529341a0c955a387d6706d5 Mon Sep 17 00:00:00 2001 From: Jani Heikkinen Date: Tue, 19 Dec 2017 13:39:18 +0200 Subject: Fix license headers Old header.LGPL21 header was used at some files. Replase those with new header.LGPL one Task-number: QTBUG-57147 Change-Id: I7d707c15b33c0f14810ef8fffef9f74dd4192e64 Reviewed-by: J-P Nurmi --- src/quickcontrols2/qquickstyleselector.cpp | 30 +++++++++++++++++----------- src/quickcontrols2/qquickstyleselector_p.h | 30 +++++++++++++++++----------- src/quickcontrols2/qquickstyleselector_p_p.h | 30 +++++++++++++++++----------- 3 files changed, 54 insertions(+), 36 deletions(-) (limited to 'src') diff --git a/src/quickcontrols2/qquickstyleselector.cpp b/src/quickcontrols2/qquickstyleselector.cpp index 6d04c190..a9e905ca 100644 --- a/src/quickcontrols2/qquickstyleselector.cpp +++ b/src/quickcontrols2/qquickstyleselector.cpp @@ -6,27 +6,33 @@ ** ** This file is part of the Qt Quick Controls 2 module of the Qt Toolkit. ** -** $QT_BEGIN_LICENSE:LGPL21$ +** $QT_BEGIN_LICENSE:LGPL$ ** Commercial License Usage ** Licensees holding valid commercial Qt licenses may use this file in ** accordance with the commercial license agreement provided with the ** Software or, alternatively, in accordance with the terms contained in ** a written agreement between you and The Qt Company. For licensing terms -** and conditions see http://www.qt.io/terms-conditions. For further -** information use the contact form at http://www.qt.io/contact-us. +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. ** ** GNU Lesser General Public License Usage ** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. ** -** As a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. ** ** $QT_END_LICENSE$ ** diff --git a/src/quickcontrols2/qquickstyleselector_p.h b/src/quickcontrols2/qquickstyleselector_p.h index 086157dc..29dba836 100644 --- a/src/quickcontrols2/qquickstyleselector_p.h +++ b/src/quickcontrols2/qquickstyleselector_p.h @@ -6,27 +6,33 @@ ** ** This file is part of the Qt Quick Controls 2 module of the Qt Toolkit. ** -** $QT_BEGIN_LICENSE:LGPL21$ +** $QT_BEGIN_LICENSE:LGPL$ ** Commercial License Usage ** Licensees holding valid commercial Qt licenses may use this file in ** accordance with the commercial license agreement provided with the ** Software or, alternatively, in accordance with the terms contained in ** a written agreement between you and The Qt Company. For licensing terms -** and conditions see http://www.qt.io/terms-conditions. For further -** information use the contact form at http://www.qt.io/contact-us. +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. ** ** GNU Lesser General Public License Usage ** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. ** -** As a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. ** ** $QT_END_LICENSE$ ** diff --git a/src/quickcontrols2/qquickstyleselector_p_p.h b/src/quickcontrols2/qquickstyleselector_p_p.h index b8f717c8..e940cd87 100644 --- a/src/quickcontrols2/qquickstyleselector_p_p.h +++ b/src/quickcontrols2/qquickstyleselector_p_p.h @@ -6,27 +6,33 @@ ** ** This file is part of the Qt Quick Controls 2 module of the Qt Toolkit. ** -** $QT_BEGIN_LICENSE:LGPL21$ +** $QT_BEGIN_LICENSE:LGPL$ ** Commercial License Usage ** Licensees holding valid commercial Qt licenses may use this file in ** accordance with the commercial license agreement provided with the ** Software or, alternatively, in accordance with the terms contained in ** a written agreement between you and The Qt Company. For licensing terms -** and conditions see http://www.qt.io/terms-conditions. For further -** information use the contact form at http://www.qt.io/contact-us. +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. ** ** GNU Lesser General Public License Usage ** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. ** -** As a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. ** ** $QT_END_LICENSE$ ** -- cgit v1.2.3 From 951cf6baf0d34a104b01b42de1454696c51f7177 Mon Sep 17 00:00:00 2001 From: J-P Nurmi Date: Fri, 22 Dec 2017 07:48:50 +0100 Subject: Material ToolButton: fix round ripple for square buttons The condition for checking whether a tool button is square and thus, whether it should use a round ripple instead of a fill ripple, must be based on the size of the contents, not on the implicit size. This way, you get a round ripple for one-letter tool buttons but only if they are not stretched. Task-number: QTBUG-65052 Change-Id: I0d498dc65650f3b786b41e538748549d61f2b216 Reviewed-by: Mitch Curtis --- src/imports/controls/material/ToolButton.qml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/imports/controls/material/ToolButton.qml b/src/imports/controls/material/ToolButton.qml index eaff0b1c..b2186fd4 100644 --- a/src/imports/controls/material/ToolButton.qml +++ b/src/imports/controls/material/ToolButton.qml @@ -64,7 +64,7 @@ T.ToolButton { implicitWidth: 48 implicitHeight: 48 - readonly property bool square: control.contentItem.implicitWidth <= control.contentItem.implicitHeight + readonly property bool square: control.contentItem.width <= control.contentItem.height x: (parent.width - width) / 2 y: (parent.height - height) / 2 -- cgit v1.2.3 From 6f7607071e236eca91ab04c395dd061dcadeaef7 Mon Sep 17 00:00:00 2001 From: Mitch Curtis Date: Fri, 22 Dec 2017 13:51:21 +0100 Subject: Doc: update code snippet to add some content to the Drawer Task-number: QTBUG-60550 Change-Id: I14c4d0343e2b02180bbce0546a69a7241ee6008e Reviewed-by: J-P Nurmi --- src/quicktemplates2/qquickdrawer.cpp | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'src') diff --git a/src/quicktemplates2/qquickdrawer.cpp b/src/quicktemplates2/qquickdrawer.cpp index f5df8015..dd96b3a8 100644 --- a/src/quicktemplates2/qquickdrawer.cpp +++ b/src/quicktemplates2/qquickdrawer.cpp @@ -79,6 +79,11 @@ QT_BEGIN_NAMESPACE id: drawer width: 0.66 * window.width height: window.height + + Label { + text: "Content goes here!" + anchors.centerIn: parent + } } } \endcode -- cgit v1.2.3 From 368e8046184f71b31618e49de4f5e49ee20db5f4 Mon Sep 17 00:00:00 2001 From: J-P Nurmi Date: Fri, 22 Dec 2017 13:27:08 +0100 Subject: Fix and test deferred execution for Universal & Material Change-Id: I8ee27a0c65c9ce8c9cc48c6f59d2b34d02849be8 Reviewed-by: Mitch Curtis --- src/imports/controls/material/Dial.qml | 2 -- src/imports/controls/material/ScrollBar.qml | 2 -- src/imports/controls/material/ScrollIndicator.qml | 6 ++---- src/imports/controls/universal/ScrollIndicator.qml | 6 ++---- 4 files changed, 4 insertions(+), 12 deletions(-) (limited to 'src') diff --git a/src/imports/controls/material/Dial.qml b/src/imports/controls/material/Dial.qml index e0632e62..946142f1 100644 --- a/src/imports/controls/material/Dial.qml +++ b/src/imports/controls/material/Dial.qml @@ -57,8 +57,6 @@ T.Dial { } handle: SliderHandle { - id: handleItem - x: background.x + background.width / 2 - handle.width / 2 y: background.y + background.height / 2 - handle.height / 2 transform: [ diff --git a/src/imports/controls/material/ScrollBar.qml b/src/imports/controls/material/ScrollBar.qml index 8374c0f9..3687b550 100644 --- a/src/imports/controls/material/ScrollBar.qml +++ b/src/imports/controls/material/ScrollBar.qml @@ -50,8 +50,6 @@ T.ScrollBar { visible: control.policy !== T.ScrollBar.AlwaysOff contentItem: Rectangle { - id: handle - implicitWidth: control.interactive ? 13 : 4 implicitHeight: control.interactive ? 13 : 4 diff --git a/src/imports/controls/material/ScrollIndicator.qml b/src/imports/controls/material/ScrollIndicator.qml index effb18ad..41e72df6 100644 --- a/src/imports/controls/material/ScrollIndicator.qml +++ b/src/imports/controls/material/ScrollIndicator.qml @@ -49,8 +49,6 @@ T.ScrollIndicator { padding: 2 contentItem: Rectangle { - id: indicator - implicitWidth: 4 implicitHeight: 4 @@ -61,7 +59,7 @@ T.ScrollIndicator { states: State { name: "active" when: control.active - PropertyChanges { target: indicator; opacity: 0.75 } + PropertyChanges { target: control.contentItem; opacity: 0.75 } } transitions: [ @@ -69,7 +67,7 @@ T.ScrollIndicator { from: "active" SequentialAnimation { PauseAnimation { duration: 450 } - NumberAnimation { target: indicator; duration: 200; property: "opacity"; to: 0.0 } + NumberAnimation { target: control.contentItem; duration: 200; property: "opacity"; to: 0.0 } } } ] diff --git a/src/imports/controls/universal/ScrollIndicator.qml b/src/imports/controls/universal/ScrollIndicator.qml index 2f30ebe5..0b6733aa 100644 --- a/src/imports/controls/universal/ScrollIndicator.qml +++ b/src/imports/controls/universal/ScrollIndicator.qml @@ -47,8 +47,6 @@ T.ScrollIndicator { contentItem.implicitHeight + topPadding + bottomPadding) contentItem: Rectangle { - id: indicator - implicitWidth: 6 implicitHeight: 6 @@ -66,13 +64,13 @@ T.ScrollIndicator { transitions: [ Transition { to: "active" - NumberAnimation { target: indicator; property: "opacity"; to: 1.0 } + NumberAnimation { target: control.contentItem; property: "opacity"; to: 1.0 } }, Transition { from: "active" SequentialAnimation { PauseAnimation { duration: 5000 } - NumberAnimation { target: indicator; property: "opacity"; to: 0.0 } + NumberAnimation { target: control.contentItem; property: "opacity"; to: 0.0 } } } ] -- cgit v1.2.3 From 31a655402ff194e556853e6877f1a464a8e51243 Mon Sep 17 00:00:00 2001 From: J-P Nurmi Date: Fri, 22 Dec 2017 13:32:04 +0100 Subject: Material: cleanup the internal ID from BusyIndicator Same as da27cace for the Default style. An internal ID in the OpacityAnimator element prevented deferred execution for the whole content item. Apply the same visibility trick in C++ to avoid having to use an ID in QML. Change-Id: I4b54bbe3044aff9603b1135ac25d7325e01fdff2 Reviewed-by: Mitch Curtis --- src/imports/controls/material/BusyIndicator.qml | 4 ++-- .../material/qquickmaterialbusyindicator.cpp | 24 ++++++++++++++++++++-- .../material/qquickmaterialbusyindicator_p.h | 4 ++++ 3 files changed, 28 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/imports/controls/material/BusyIndicator.qml b/src/imports/controls/material/BusyIndicator.qml index f1cf8eb5..beaaf30e 100644 --- a/src/imports/controls/material/BusyIndicator.qml +++ b/src/imports/controls/material/BusyIndicator.qml @@ -52,8 +52,8 @@ T.BusyIndicator { implicitHeight: 48 color: control.Material.accentColor + running: control.running opacity: control.running ? 1 : 0 - visible: control.running || animator.running - Behavior on opacity { OpacityAnimator { id: animator; duration: 250 } } + Behavior on opacity { OpacityAnimator { duration: 250 } } } } diff --git a/src/imports/controls/material/qquickmaterialbusyindicator.cpp b/src/imports/controls/material/qquickmaterialbusyindicator.cpp index 9df8f5d2..bd15390b 100644 --- a/src/imports/controls/material/qquickmaterialbusyindicator.cpp +++ b/src/imports/controls/material/qquickmaterialbusyindicator.cpp @@ -197,6 +197,17 @@ void QQuickMaterialBusyIndicator::setColor(QColor color) update(); } +bool QQuickMaterialBusyIndicator::isRunning() const +{ + return isVisible(); +} + +void QQuickMaterialBusyIndicator::setRunning(bool running) +{ + if (running) + setVisible(true); +} + int QQuickMaterialBusyIndicator::elapsed() const { return m_elapsed; @@ -205,14 +216,23 @@ int QQuickMaterialBusyIndicator::elapsed() const void QQuickMaterialBusyIndicator::itemChange(QQuickItem::ItemChange change, const QQuickItem::ItemChangeData &data) { QQuickItem::itemChange(change, data); - if (change == ItemVisibleHasChanged) + switch (change) { + case ItemOpacityHasChanged: + if (qFuzzyIsNull(data.realValue)) + setVisible(false); + break; + case ItemVisibleHasChanged: update(); + break; + default: + break; + } } QSGNode *QQuickMaterialBusyIndicator::updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData *) { QQuickMaterialBusyIndicatorNode *node = static_cast(oldNode); - if (isVisible() && width() > 0 && height() > 0) { + if (isRunning() && width() > 0 && height() > 0) { if (!node) { node = new QQuickMaterialBusyIndicatorNode(this); node->start(); diff --git a/src/imports/controls/material/qquickmaterialbusyindicator_p.h b/src/imports/controls/material/qquickmaterialbusyindicator_p.h index da84c7b1..6c6d2445 100644 --- a/src/imports/controls/material/qquickmaterialbusyindicator_p.h +++ b/src/imports/controls/material/qquickmaterialbusyindicator_p.h @@ -57,6 +57,7 @@ class QQuickMaterialBusyIndicator : public QQuickItem { Q_OBJECT Q_PROPERTY(QColor color READ color WRITE setColor FINAL) + Q_PROPERTY(bool running READ isRunning WRITE setRunning FINAL) public: explicit QQuickMaterialBusyIndicator(QQuickItem *parent = nullptr); @@ -64,6 +65,9 @@ public: QColor color() const; void setColor(QColor color); + bool isRunning() const; + void setRunning(bool running); + int elapsed() const; protected: -- cgit v1.2.3 From 108f4829e43ed32cf1c6f925364d443c10bd7f80 Mon Sep 17 00:00:00 2001 From: J-P Nurmi Date: Thu, 4 Jan 2018 11:23:22 +0100 Subject: Fix qmlRegisterType() for RoundButton RoundButton was a new type in QQC2.1 (Qt 5.8). Even though passing a non-existent revision seems to be harmless, registerTypes() becomes easier to read when we distinguish between new types and new revisions. Change-Id: I682006570f63dd0b2cb2260740fb105619e61a28 Reviewed-by: Mitch Curtis --- src/imports/templates/qtquicktemplates2plugin.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/imports/templates/qtquicktemplates2plugin.cpp b/src/imports/templates/qtquicktemplates2plugin.cpp index 263d7fde..2abdeb6e 100644 --- a/src/imports/templates/qtquicktemplates2plugin.cpp +++ b/src/imports/templates/qtquicktemplates2plugin.cpp @@ -226,7 +226,7 @@ void QtQuickTemplates2Plugin::registerTypes(const char *uri) qmlRegisterType(uri, 2, 1, "Page"); qmlRegisterType(uri, 2, 1, "Popup"); qmlRegisterType(uri, 2, 1, "RangeSlider"); - qmlRegisterType(uri, 2, 1, "RoundButton"); + qmlRegisterType(uri, 2, 1, "RoundButton"); qmlRegisterType(uri, 2, 1, "Slider"); qmlRegisterType(uri, 2, 1, "SpinBox"); qmlRegisterType(uri, 2, 1, "StackView"); -- cgit v1.2.3 From f2696acaf7bef9d3427a357dd28d1ec52231024b Mon Sep 17 00:00:00 2001 From: Kai Koehne Date: Thu, 21 Dec 2017 10:13:03 +0100 Subject: Document license and attribute third party code [ChangeLog][Third-Party Code] Document constants from AngularJS in src/imports/controls/material/ElevationEffect.qml Task-number: QTBUG-65409 Change-Id: Ibd0dcf643abe036f34cea364f267fde8510057ea Reviewed-by: J-P Nurmi --- .../controls/doc/src/qtquickcontrols2-index.qdoc | 13 +++++++++++++ src/imports/controls/material/LICENSE_ANGULARJS.txt | 19 +++++++++++++++++++ src/imports/controls/material/qt_attribution.json | 13 +++++++++++++ 3 files changed, 45 insertions(+) create mode 100644 src/imports/controls/material/LICENSE_ANGULARJS.txt create mode 100644 src/imports/controls/material/qt_attribution.json (limited to 'src') diff --git a/src/imports/controls/doc/src/qtquickcontrols2-index.qdoc b/src/imports/controls/doc/src/qtquickcontrols2-index.qdoc index 51d672f3..26f7c19a 100644 --- a/src/imports/controls/doc/src/qtquickcontrols2-index.qdoc +++ b/src/imports/controls/doc/src/qtquickcontrols2-index.qdoc @@ -103,6 +103,19 @@ \li ... \endtable + \section1 License and Attributions + + Qt Quick Controls 2 is available under commercial licenses from \l{The Qt Company}. + In addition, it is available under the + \l{GNU Lesser General Public License, version 3}, or + the \l{GNU General Public License, version 2}. + See \l{Qt Licensing} for further details. + + Furthermore Qt Quick Controls 2 potentially contains third party + modules under following permissive licenses: + + \generatelist{groupsbymodule attributions-qtquickcontrols2} + \section1 Topics \list diff --git a/src/imports/controls/material/LICENSE_ANGULARJS.txt b/src/imports/controls/material/LICENSE_ANGULARJS.txt new file mode 100644 index 00000000..c1f2a826 --- /dev/null +++ b/src/imports/controls/material/LICENSE_ANGULARJS.txt @@ -0,0 +1,19 @@ +Copyright (c) 2014-2016 Google, Inc. http://angularjs.org + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/src/imports/controls/material/qt_attribution.json b/src/imports/controls/material/qt_attribution.json new file mode 100644 index 00000000..01b45e9f --- /dev/null +++ b/src/imports/controls/material/qt_attribution.json @@ -0,0 +1,13 @@ +{ + "Id": "shadow_angular_material", + "Name": "Shadow values from Angular Material", + "QDocModule": "qtquickcontrols2", + "QtUsage": "Used in the Material Style of Qt Quick Controls 2.", + "Files": "ElevationEffect.qml", + "Description": "Shadow values for the elevation effect.", + "Homepage": "https://angularjs.org/", + "License": "MIT License", + "LicenseId": "MIT", + "LicenseFile": "LICENSE_ANGULARJS.txt", + "Copyright": "Copyright (c) 2014-2016 Google, Inc" +} -- cgit v1.2.3 From aa9308d1d172a51a3e4356b8831b9f28fc68086e Mon Sep 17 00:00:00 2001 From: Mitch Curtis Date: Wed, 3 Jan 2018 13:30:51 +0100 Subject: Doc: improve Style/FallbackStyle documentation Link to relevant documentation and add entries for the Controls section to the configuration file docs. Task-number: QTBUG-65445 Change-Id: I175866167e36403475520ea4de0cb299aae542d7 Reviewed-by: J-P Nurmi --- .../doc/src/qtquickcontrols2-configuration.qdoc | 31 ++++++++++++++++++++-- src/quickcontrols2/qquickstyle.cpp | 4 +++ 2 files changed, 33 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/imports/controls/doc/src/qtquickcontrols2-configuration.qdoc b/src/imports/controls/doc/src/qtquickcontrols2-configuration.qdoc index 36bce98d..ca70ed2f 100644 --- a/src/imports/controls/doc/src/qtquickcontrols2-configuration.qdoc +++ b/src/imports/controls/doc/src/qtquickcontrols2-configuration.qdoc @@ -53,16 +53,43 @@ Primary=BlueGrey \endcode - \l {Material style} specific values that can be specified in a \c Material + \section1 Controls Section + + The following values can be specified in a \c Controls section of the + configuration file: + + \table + \header + \li Variable + \li Description + \row + \li \c Style + \li Specifies the style to run the application with. + The value can be the name of one of the \l {Available Styles}{built-in styles} + or a \l {Creating a Custom Style}{custom style}. + \row + \li \c FallbackStyle + \li Specifies the style to use for controls that are not implemented. + The style must be one of the \l {Available Styles}{built-in styles}. + By default, the \l {Default Style}{Default} style is used. + \endtable + + \section1 Material Section + + The following \l {Material style} specific values can be specified in a \c Material section of the configuration file: \include qquickmaterialstyle.qdocinc conf - \l {Universal style} specific values that can be specified in a \c Universal + \section1 Universal Section + + The following \l {Universal style} specific values can be specified in a \c Universal section of the configuration file: \include qquickuniversalstyle.qdocinc conf + \section1 Using the Configuration File in a Project + In order to make it possible for Qt Quick Controls 2 to find the configuration file, it must be built into application's resources using the \l {The Qt Resource System}. Here's an example \c .qrc file: diff --git a/src/quickcontrols2/qquickstyle.cpp b/src/quickcontrols2/qquickstyle.cpp index 64289d46..c57dc7ac 100644 --- a/src/quickcontrols2/qquickstyle.cpp +++ b/src/quickcontrols2/qquickstyle.cpp @@ -343,6 +343,8 @@ QString QQuickStyle::path() \note The style must be configured \b before loading QML that imports Qt Quick Controls 2. It is not possible to change the style after the QML types have been registered. + + \sa setFallbackStyle(), {Using Styles in Qt Quick Controls 2} */ void QQuickStyle::setStyle(const QString &style) { @@ -365,6 +367,8 @@ void QQuickStyle::setStyle(const QString &style) The fallback style can be also specified by setting the \c QT_QUICK_CONTROLS_FALLBACK_STYLE \l {Supported Environment Variables in Qt Quick Controls 2}{environment variable}. + + \sa setStyle(), {Using Styles in Qt Quick Controls 2} */ void QQuickStyle::setFallbackStyle(const QString &style) { -- cgit v1.2.3