diff options
-rw-r--r-- | src/imports/controls/material/ProgressBar.qml | 2 | ||||
-rw-r--r-- | src/imports/controls/material/qquickmaterialstyle.cpp | 2 | ||||
-rw-r--r-- | src/quicktemplates2/qquickapplicationwindow.cpp | 9 | ||||
-rw-r--r-- | src/quicktemplates2/qquickmenu.cpp | 1 | ||||
-rw-r--r-- | src/quicktemplates2/qquickswipeview.cpp | 19 | ||||
-rw-r--r-- | tests/auto/material/data/tst_material.qml | 47 |
6 files changed, 74 insertions, 6 deletions
diff --git a/src/imports/controls/material/ProgressBar.qml b/src/imports/controls/material/ProgressBar.qml index cab54952..d5e28700 100644 --- a/src/imports/controls/material/ProgressBar.qml +++ b/src/imports/controls/material/ProgressBar.qml @@ -67,7 +67,7 @@ T.ProgressBar { //! [background] background: Rectangle { implicitWidth: 200 - implicitHeight: 6 + implicitHeight: 4 x: control.leftPadding y: control.topPadding + (control.availableHeight - height) / 2 width: control.availableWidth diff --git a/src/imports/controls/material/qquickmaterialstyle.cpp b/src/imports/controls/material/qquickmaterialstyle.cpp index 55bc5066..49cbd5ed 100644 --- a/src/imports/controls/material/qquickmaterialstyle.cpp +++ b/src/imports/controls/material/qquickmaterialstyle.cpp @@ -542,6 +542,7 @@ void QQuickMaterialStyle::inheritPrimary(uint primary, bool custom) m_primary = primary; propagatePrimary(); emit primaryChanged(); + emit paletteChanged(); } void QQuickMaterialStyle::propagatePrimary() @@ -597,6 +598,7 @@ void QQuickMaterialStyle::inheritAccent(uint accent, bool custom) m_accent = accent; propagateAccent(); emit accentChanged(); + emit paletteChanged(); } void QQuickMaterialStyle::propagateAccent() diff --git a/src/quicktemplates2/qquickapplicationwindow.cpp b/src/quicktemplates2/qquickapplicationwindow.cpp index 1611ebaf..401313d8 100644 --- a/src/quicktemplates2/qquickapplicationwindow.cpp +++ b/src/quicktemplates2/qquickapplicationwindow.cpp @@ -110,6 +110,11 @@ public: , activeFocusControl(nullptr) { } + static QQuickApplicationWindowPrivate *get(QQuickApplicationWindow *window) + { + return window->d_func(); + } + void relayout(); void itemGeometryChanged(QQuickItem *item, const QRectF &newRect, const QRectF &oldRect) override; @@ -263,6 +268,7 @@ QQuickApplicationWindow::~QQuickApplicationWindow() if (d->footer) QQuickItemPrivate::get(d->footer)->removeItemChangeListener(d, QQuickItemPrivate::Geometry | QQuickItemPrivate::Visibility | QQuickItemPrivate::ImplicitWidth | QQuickItemPrivate::ImplicitHeight); + d_ptr.reset(); // QTBUG-52731 } /*! @@ -616,6 +622,9 @@ public: void QQuickApplicationWindowAttachedPrivate::windowChange(QQuickWindow *wnd) { Q_Q(QQuickApplicationWindowAttached); + if (window && !QQuickApplicationWindowPrivate::get(window)) + window = nullptr; // being deleted (QTBUG-52731) + QQuickApplicationWindow *newWindow = qobject_cast<QQuickApplicationWindow *>(wnd); if (window != newWindow) { QQuickApplicationWindow *oldWindow = window; diff --git a/src/quicktemplates2/qquickmenu.cpp b/src/quicktemplates2/qquickmenu.cpp index c47b3fd2..fdebf6fb 100644 --- a/src/quicktemplates2/qquickmenu.cpp +++ b/src/quicktemplates2/qquickmenu.cpp @@ -92,6 +92,7 @@ QT_BEGIN_NAMESPACE */ QQuickMenuPrivate::QQuickMenuPrivate() : + contentItem(nullptr), contentModel(nullptr) { Q_Q(QQuickMenu); diff --git a/src/quicktemplates2/qquickswipeview.cpp b/src/quicktemplates2/qquickswipeview.cpp index 3be41751..45d3b15a 100644 --- a/src/quicktemplates2/qquickswipeview.cpp +++ b/src/quicktemplates2/qquickswipeview.cpp @@ -192,6 +192,7 @@ public: void itemChildAdded(QQuickItem *, QQuickItem *) override; void itemChildRemoved(QQuickItem *, QQuickItem *) override; void itemParentChanged(QQuickItem *, QQuickItem *) override; + void itemDestroyed(QQuickItem *) override; void updateIndex(); void updateIsCurrent(); @@ -309,20 +310,28 @@ void QQuickSwipeViewAttachedPrivate::itemParentChanged(QQuickItem *, QQuickItem updateView(parent); } +void QQuickSwipeViewAttachedPrivate::itemDestroyed(QQuickItem *item) +{ + QQuickItemPrivate::get(item)->removeItemChangeListener(this, QQuickItemPrivate::Parent | QQuickItemPrivate::Destroyed); +} + QQuickSwipeViewAttached::QQuickSwipeViewAttached(QQuickItem *item) : QObject(*(new QQuickSwipeViewAttachedPrivate(item)), item) { Q_D(QQuickSwipeViewAttached); - if (item->parentItem()) { + if (item->parentItem()) d->updateView(item->parentItem()); - } else { - QQuickItemPrivate *p = QQuickItemPrivate::get(item); - p->addItemChangeListener(d, QQuickItemPrivate::Parent); - } + + QQuickItemPrivate *p = QQuickItemPrivate::get(item); + p->addItemChangeListener(d, QQuickItemPrivate::Parent | QQuickItemPrivate::Destroyed); } QQuickSwipeViewAttached::~QQuickSwipeViewAttached() { + Q_D(QQuickSwipeViewAttached); + QQuickItem *item = qobject_cast<QQuickItem *>(parent()); + if (item) + QQuickItemPrivate::get(item)->removeItemChangeListener(d, QQuickItemPrivate::Parent | QQuickItemPrivate::Destroyed); } QQuickSwipeView *QQuickSwipeViewAttached::view() const diff --git a/tests/auto/material/data/tst_material.qml b/tests/auto/material/data/tst_material.qml index 439bee59..25b4ec98 100644 --- a/tests/auto/material/data/tst_material.qml +++ b/tests/auto/material/data/tst_material.qml @@ -115,6 +115,26 @@ TestCase { } Component { + id: popupComponent + ApplicationWindow { + Material.primary: Material.Blue + Material.accent: Material.Red + visible: true + property alias popup: popupInstance + property alias label: labelInstance + Popup { + id: popupInstance + Label { + id: labelInstance + text: "test" + color: popupInstance.Material.textSelectionColor + } + Component.onCompleted: open() + } + } + } + + Component { id: comboBox ApplicationWindow { width: 200 @@ -245,6 +265,33 @@ TestCase { parent.destroy() } + function test_inheritance_popup_data() { + return [ + { tag: "primary", value1: Material.color(Material.Amber), value2: Material.color(Material.Indigo) }, + { tag: "accent", value1: Material.color(Material.Amber), value2: Material.color(Material.Indigo) }, + { tag: "theme", value1: Material.Dark, value2: Material.Light }, + ] + } + + function test_inheritance_popup(data) { + var prop = data.tag + var popupObject = popupComponent.createObject(testCase) + compare(popupObject.popup.Material.textSelectionColor.toString(), popupObject.Material.textSelectionColor.toString()) + compare(popupObject.label.color.toString(), popupObject.Material.textSelectionColor.toString()) + + popupObject.Material[prop] = data.value1 + compare(popupObject.Material[prop], data.value1) + compare(popupObject.popup.Material.textSelectionColor.toString(), popupObject.Material.textSelectionColor.toString()) + compare(popupObject.label.color.toString(), popupObject.Material.textSelectionColor.toString()) + + popupObject.Material[prop] = data.value2 + compare(popupObject.Material[prop], data.value2) + compare(popupObject.popup.Material.textSelectionColor.toString(), popupObject.Material.textSelectionColor.toString()) + compare(popupObject.label.color.toString(), popupObject.Material.textSelectionColor.toString()) + + popupObject.destroy() + } + function test_window() { var parent = window.createObject() |