diff options
author | J-P Nurmi <jpnurmi@theqtcompany.com> | 2016-01-22 12:10:12 +0100 |
---|---|---|
committer | J-P Nurmi <jpnurmi@theqtcompany.com> | 2016-01-22 14:09:23 +0000 |
commit | 7427e2808324388678eefda45b3e83c675979290 (patch) | |
tree | 2fe0308a0c84d8fd55ff1a3664565b2f5536dd6b | |
parent | 482ecb0fdc011687eec3df5803653be88f14f539 (diff) |
Refactor Popup
Added relevant properties to make it almost like a Control: x, y,
width, height, padding, background... This change makes popup use
an internal item where the style/user-supplied contentItem and
background are re-parented. This way we can provide a default style
(background) for Popup.
Change-Id: I3e7933562464c5c852e4ba4bc37d9ac25691c714
Reviewed-by: Mitch Curtis <mitch.curtis@theqtcompany.com>
-rw-r--r-- | examples/controls/gallery/gallery.qml | 169 | ||||
-rw-r--r-- | src/controls/qquickstyle.cpp | 4 | ||||
-rw-r--r-- | src/imports/controls/ComboBox.qml | 42 | ||||
-rw-r--r-- | src/imports/controls/Menu.qml | 25 | ||||
-rw-r--r-- | src/imports/controls/Popup.qml | 11 | ||||
-rw-r--r-- | src/imports/controls/material/ComboBox.qml | 40 | ||||
-rw-r--r-- | src/imports/controls/material/Menu.qml | 42 | ||||
-rw-r--r-- | src/imports/controls/material/Popup.qml | 21 | ||||
-rw-r--r-- | src/imports/controls/universal/ComboBox.qml | 36 | ||||
-rw-r--r-- | src/imports/controls/universal/Menu.qml | 27 | ||||
-rw-r--r-- | src/templates/qquickoverlay.cpp | 6 | ||||
-rw-r--r-- | src/templates/qquickpopup.cpp | 448 | ||||
-rw-r--r-- | src/templates/qquickpopup_p.h | 71 | ||||
-rw-r--r-- | src/templates/qquickpopup_p_p.h | 44 | ||||
-rw-r--r-- | tests/auto/material/data/tst_material.qml | 2 | ||||
-rw-r--r-- | tests/auto/menu/tst_menu.cpp | 12 | ||||
-rw-r--r-- | tests/auto/universal/data/tst_universal.qml | 2 | ||||
-rw-r--r-- | tests/manual/testbench/main.qml | 4 |
18 files changed, 786 insertions, 220 deletions
diff --git a/examples/controls/gallery/gallery.qml b/examples/controls/gallery/gallery.qml index 2bd7d40f..7001057d 100644 --- a/examples/controls/gallery/gallery.qml +++ b/examples/controls/gallery/gallery.qml @@ -193,83 +193,76 @@ ApplicationWindow { Popup { id: settingsPopup + x: (window.width - width) / 2 + y: window.height / 6 + width: Math.min(window.width, window.height) / 3 * 2 + height: settingsColumn.implicitHeight + topPadding + bottomPadding modal: true focus: true onPressedOutside: close() - contentItem: Pane { - id: settingsPane - x: (window.width - width) / 2 - y: window.height / 6 - width: Math.min(window.width, window.height) / 3 * 2 - contentHeight: settingsColumn.implicitHeight - - Keys.onEscapePressed: settingsPopup.close() + contentItem: ColumnLayout { + id: settingsColumn + spacing: 20 + Keys.onEscapePressed: settingsPopup.close() // TODO: Popup::closePolicy + Label { + text: "Settings" + font.bold: true + } - ColumnLayout { - id: settingsColumn - spacing: 20 - anchors.fill: parent + RowLayout { + spacing: 10 Label { - text: "Settings" - font.bold: true + text: "Style:" } - RowLayout { - spacing: 10 - - Label { - text: "Style:" - } - - ComboBox { - id: styleBox - property int styleIndex: -1 - model: ["Default", "Material", "Universal"] - Component.onCompleted: { - styleIndex = find(settings.style) - if (styleIndex !== -1) - currentIndex = styleIndex - } - Layout.fillWidth: true + ComboBox { + id: styleBox + property int styleIndex: -1 + model: ["Default", "Material", "Universal"] + Component.onCompleted: { + styleIndex = find(settings.style) + if (styleIndex !== -1) + currentIndex = styleIndex } - } - - Label { - text: "Restart required" - opacity: styleBox.currentIndex !== styleBox.styleIndex ? 1.0 : 0.0 - horizontalAlignment: Label.AlignHCenter - verticalAlignment: Label.AlignVCenter Layout.fillWidth: true - Layout.fillHeight: true } + } + + Label { + text: "Restart required" + opacity: styleBox.currentIndex !== styleBox.styleIndex ? 1.0 : 0.0 + horizontalAlignment: Label.AlignHCenter + verticalAlignment: Label.AlignVCenter + Layout.fillWidth: true + Layout.fillHeight: true + } - RowLayout { - spacing: 10 + RowLayout { + spacing: 10 - Button { - id: okButton - text: "Ok" - onClicked: { - settings.style = styleBox.displayText - settingsPopup.close() - } - Layout.preferredWidth: 0 - Layout.fillWidth: true + Button { + id: okButton + text: "Ok" + onClicked: { + settings.style = styleBox.displayText + settingsPopup.close() } + Layout.preferredWidth: 0 + Layout.fillWidth: true + } - Button { - id: cancelButton - text: "Cancel" - onClicked: { - styleBox.currentIndex = styleBox.styleIndex - settingsPopup.close() - } - Layout.preferredWidth: 0 - Layout.fillWidth: true + Button { + id: cancelButton + text: "Cancel" + onClicked: { + styleBox.currentIndex = styleBox.styleIndex + settingsPopup.close() } + Layout.preferredWidth: 0 + Layout.fillWidth: true } } } @@ -279,49 +272,43 @@ ApplicationWindow { id: aboutDialog modal: true focus: true + x: (window.width - width) / 2 + y: (window.height - height) / 2 + width: Math.min(window.width, window.height) / 3 * 2 + height: aboutColumn.implicitHeight + topPadding + bottomPadding onPressedOutside: close() - contentItem: Pane { - x: (window.width - width) / 2 - y: (window.height - height) / 2 - width: Math.min(window.width, window.height) / 3 * 2 - contentHeight: aboutColumn.implicitHeight - - Keys.onEscapePressed: aboutDialog.close() - - Column { - id: aboutColumn - - spacing: 20 - anchors.fill: parent + contentItem: Column { + id: aboutColumn + spacing: 20 + Keys.onEscapePressed: aboutDialog.close() // TODO: Popup::closePolicy - Label { - text: "About" - font.bold: true - } + Label { + text: "About" + font.bold: true + } - Label { - width: parent.width - text: "The Qt Labs Controls module is a technology preview of the next generation user interface controls based on Qt Quick." - wrapMode: Label.Wrap - font.pixelSize: 12 - } + Label { + width: parent.width + text: "The Qt Labs Controls module is a technology preview of the next generation user interface controls based on Qt Quick." + wrapMode: Label.Wrap + font.pixelSize: 12 + } - Label { - width: parent.width - text: "In comparison to the desktop oriented Qt Quick Controls 1, the experimental Qt Labs " - + "Controls are an order of magnitude simpler, lighter and faster, and are primarily targeting embedded " - + "and mobile platforms." - wrapMode: Label.Wrap - font.pixelSize: 12 - } + Label { + width: parent.width + text: "In comparison to the desktop oriented Qt Quick Controls 1, the experimental Qt Labs " + + "Controls are an order of magnitude simpler, lighter and faster, and are primarily targeting embedded " + + "and mobile platforms." + wrapMode: Label.Wrap + font.pixelSize: 12 } } } Menu { id: optionsMenu - contentItem.x: contentItem.parent ? (contentItem.parent.width - contentItem.width) : 0 + x: window.width - width MenuItem { text: "Settings" diff --git a/src/controls/qquickstyle.cpp b/src/controls/qquickstyle.cpp index a44c8c99..05f4fbff 100644 --- a/src/controls/qquickstyle.cpp +++ b/src/controls/qquickstyle.cpp @@ -40,7 +40,7 @@ #include <QtCore/qsettings.h> #include <QtCore/qfileselector.h> #include <QtQuick/private/qquickitem_p.h> -#include <QtLabsTemplates/private/qquickpopup_p.h> +#include <QtLabsTemplates/private/qquickpopup_p_p.h> QT_BEGIN_NAMESPACE @@ -118,7 +118,7 @@ static QList<QQuickStyle *> findChildStyles(const QMetaObject *type, QObject *ob } } } else if (QQuickPopup *popup = qobject_cast<QQuickPopup *>(object)) { - item = popup->contentItem(); + item = QQuickPopupPrivate::get(popup)->popupItem; QQuickStyle *style = attachedStyle(type, popup); if (style) diff --git a/src/imports/controls/ComboBox.qml b/src/imports/controls/ComboBox.qml index e06372e7..f18140f9 100644 --- a/src/imports/controls/ComboBox.qml +++ b/src/imports/controls/ComboBox.qml @@ -98,35 +98,33 @@ T.ComboBox { //! [popup] popup: T.Popup { - contentItem: Rectangle { - // TODO: Popup::anchors - readonly property var above: popup.visible ? control.mapToItem(null, 0, -height + 1) : Qt.point(0, 0) - readonly property var below: popup.visible ? control.mapToItem(null, 0, control.height - 1) : Qt.point(0, 0) + readonly property var above: popup.visible ? control.mapToItem(null, 0, -height + 1) : Qt.point(0, 0) + readonly property var below: popup.visible ? control.mapToItem(null, 0, control.height - 1) : Qt.point(0, 0) - x: below.x - y: above.y >= 0 && below.y + height > control.Window.height ? above.y : below.y - width: control.width - height: listview.height - - ListView { - id: listview - width: control.width - height: Math.min(200, contentHeight) - - clip: true - model: control.delegateModel - currentIndex: control.highlightedIndex + x: below.x + y: above.y >= 0 && below.y + height > control.Window.height ? above.y : below.y + width: control.width + height: Math.min(200, listview.contentHeight) -// ScrollIndicator.vertical: ScrollIndicator { } - } + contentItem: ListView { + id: listview + clip: true + model: control.delegateModel + currentIndex: control.highlightedIndex Rectangle { - width: parent.width - height: parent.height - color: "transparent" + z: 10 + parent: listview + width: listview.width + height: listview.height border.color: "#353637" + color: "transparent" } + +// ScrollIndicator.vertical: ScrollIndicator { } } + + background: Rectangle { } } //! [popup] } diff --git a/src/imports/controls/Menu.qml b/src/imports/controls/Menu.qml index f4a4243e..482b68a3 100644 --- a/src/imports/controls/Menu.qml +++ b/src/imports/controls/Menu.qml @@ -41,10 +41,14 @@ import Qt.labs.templates 1.0 as T T.Menu { id: control + width: Math.max(background ? background.implicitWidth : 0, + contentItem ? contentItem.implicitWidth + leftPadding + rightPadding : 0) + height: Math.min(background ? background.implicitHeight : 0, + contentItem ? contentItem.implicitHeight + topPadding + bottomPadding : 0) + //! [contentItem] contentItem: ListView { - implicitWidth: 200 - implicitHeight: Math.min(contentHeight, 200) + implicitHeight: contentHeight model: control.contentModel // TODO: improve this? interactive: ApplicationWindow.window ? contentHeight > ApplicationWindow.window.height : false @@ -53,14 +57,15 @@ T.Menu { currentIndex: -1 ScrollIndicator.vertical: ScrollIndicator {} - - Rectangle { - width: parent.width - height: parent.height - color: "#ffffff" - border.color: "#353637" - z: -1 - } } //! [contentItem] + + //! [background] + background: Rectangle { + implicitWidth: 200 + implicitHeight: 200 + color: "#ffffff" + border.color: "#353637" + } + //! [background] } diff --git a/src/imports/controls/Popup.qml b/src/imports/controls/Popup.qml index b7c6fe08..3d3fb365 100644 --- a/src/imports/controls/Popup.qml +++ b/src/imports/controls/Popup.qml @@ -39,4 +39,15 @@ import Qt.labs.templates 1.0 as T T.Popup { id: control + + width: Math.max(background ? background.implicitWidth : 0, + contentItem ? contentItem.implicitWidth + leftPadding + rightPadding : 0) + height: Math.max(background ? background.implicitHeight : 0, + contentItem ? contentItem.implicitHeight + topPadding + bottomPadding : 0) + + padding: 6 + + background: Rectangle { + border.color: "#353637" + } } diff --git a/src/imports/controls/material/ComboBox.qml b/src/imports/controls/material/ComboBox.qml index 93494a60..c4ceecdd 100644 --- a/src/imports/controls/material/ComboBox.qml +++ b/src/imports/controls/material/ComboBox.qml @@ -114,6 +114,15 @@ T.ComboBox { //! [popup] popup: T.Popup { + readonly property var above: popup.visible ? control.mapToItem(null, 0, -height) : Qt.point(0, 0) + readonly property var below: popup.visible ? control.mapToItem(null, 0, control.height) : Qt.point(0, 0) + readonly property bool showAbove: above.y >= 0 && below.y + height > control.Window.height + + x: below.x + y: showAbove ? above.y : below.y + width: control.width + height: Math.min(200, listview.contentHeight) + enter: Transition { // grow_fade_in NumberAnimation { property: "scale"; from: 0.9; to: 1.0; easing.type: Easing.OutQuint; duration: 220 } @@ -126,18 +135,17 @@ T.ComboBox { NumberAnimation { property: "opacity"; from: 1.0; to: 0.0; easing.type: Easing.OutCubic; duration: 150 } } - contentItem: Item { - // TODO: Popup::anchors - readonly property var above: popup.visible ? control.mapToItem(null, 0, -height) : Qt.point(0, 0) - readonly property var below: popup.visible ? control.mapToItem(null, 0, control.height) : Qt.point(0, 0) - readonly property bool showAbove: above.y >= 0 && below.y + height > control.Window.height + contentItem: ListView { + id: listview + clip: true + model: control.delegateModel + currentIndex: control.highlightedIndex + transformOrigin: popup.showAbove ? Item.Bottom : Item.Top - x: below.x - y: showAbove ? above.y : below.y - width: control.width - height: listview.height - transformOrigin: showAbove ? Item.Bottom : Item.Top +// ScrollIndicator.vertical: ScrollIndicator { } + } + background: Item { Rectangle { id: panel width: parent.width @@ -155,18 +163,6 @@ T.ComboBox { samples: 15 spread: 0.5 } - - ListView { - id: listview - width: control.width - height: Math.min(200, contentHeight) // TODO: 396 - - clip: true - model: control.delegateModel - currentIndex: control.highlightedIndex - -// ScrollIndicator.vertical: ScrollIndicator { } - } } } //! [popup] diff --git a/src/imports/controls/material/Menu.qml b/src/imports/controls/material/Menu.qml index 4523fc26..86ab5c81 100644 --- a/src/imports/controls/material/Menu.qml +++ b/src/imports/controls/material/Menu.qml @@ -43,6 +43,11 @@ import QtGraphicalEffects 1.0 T.Menu { id: control + width: Math.max(background ? background.implicitWidth : 0, + contentItem ? contentItem.implicitWidth + leftPadding + rightPadding : 0) + height: Math.min(background ? background.implicitHeight : 0, + contentItem ? contentItem.implicitHeight + topPadding + bottomPadding : 0) + enter: Transition { // grow_fade_in NumberAnimation { property: "scale"; from: 0.9; to: 1.0; easing.type: Easing.OutQuint; duration: 220 } @@ -56,11 +61,26 @@ T.Menu { } //! [contentItem] - contentItem: Item { - implicitWidth: 200 - implicitHeight: Math.min(listview.contentHeight, 200) + contentItem: ListView { + implicitHeight: contentHeight transformOrigin: Item.Top + model: control.contentModel + // TODO: improve this? + interactive: ApplicationWindow.window ? contentHeight > ApplicationWindow.window.height : false + clip: true + keyNavigationWraps: false + currentIndex: -1 + + ScrollIndicator.vertical: ScrollIndicator {} + } + //! [contentItem] + + //! [background] + background: Item { + implicitWidth: 200 + implicitHeight: 200 + Rectangle { id: panel width: parent.width @@ -77,20 +97,6 @@ T.Menu { samples: 15 spread: 0.5 } - - ListView { - id: listview - width: parent.width - height: parent.height - model: control.contentModel - // TODO: improve this? - interactive: ApplicationWindow.window ? contentHeight > ApplicationWindow.window.height : false - clip: true - keyNavigationWraps: false - currentIndex: -1 - - ScrollIndicator.vertical: ScrollIndicator {} - } } - //! [contentItem] + //! [background] } diff --git a/src/imports/controls/material/Popup.qml b/src/imports/controls/material/Popup.qml index 40531c61..8eb56a01 100644 --- a/src/imports/controls/material/Popup.qml +++ b/src/imports/controls/material/Popup.qml @@ -35,11 +35,20 @@ ****************************************************************************/ import QtQuick 2.6 +import QtGraphicalEffects 1.0 import Qt.labs.templates 1.0 as T +import Qt.labs.controls.material 1.0 T.Popup { id: control + width: Math.max(background ? background.implicitWidth : 0, + contentItem ? contentItem.implicitWidth + leftPadding + rightPadding : 0) + height: Math.max(background ? background.implicitHeight : 0, + contentItem ? contentItem.implicitHeight + topPadding + bottomPadding : 0) + + padding: 6 + enter: Transition { // grow_fade_in NumberAnimation { property: "scale"; from: 0.9; to: 1.0; easing.type: Easing.OutQuint; duration: 220 } @@ -51,4 +60,16 @@ T.Popup { NumberAnimation { property: "scale"; from: 1.0; to: 0.9; easing.type: Easing.OutQuint; duration: 220 } NumberAnimation { property: "opacity"; from: 1.0; to: 0.0; easing.type: Easing.OutCubic; duration: 150 } } + + background: Rectangle { + radius: 3 + color: control.Material.dialogColor + + layer.effect: DropShadow { + verticalOffset: 1 + color: control.Material.dropShadowColor + samples: 15 + spread: 0.5 + } + } } diff --git a/src/imports/controls/universal/ComboBox.qml b/src/imports/controls/universal/ComboBox.qml index b91e4581..32e28e53 100644 --- a/src/imports/controls/universal/ComboBox.qml +++ b/src/imports/controls/universal/ComboBox.qml @@ -109,29 +109,27 @@ T.ComboBox { //! [popup] popup: T.Popup { - contentItem: Rectangle { - // TODO: Popup::anchors - readonly property var above: popup.visible ? control.mapToItem(null, 0, control.height - height) : Qt.point(0, 0) - readonly property var below: popup.visible ? control.mapToItem(null, 0, 0) : Qt.point(0, 0) + readonly property var above: popup.visible ? control.mapToItem(null, 0, control.height - height) : Qt.point(0, 0) + readonly property var below: popup.visible ? control.mapToItem(null, 0, 0) : Qt.point(0, 0) - x: below.x - y: above.y >= 0 && below.y + height > control.Window.height ? above.y : below.y - width: control.width - height: listview.height - - color: control.Universal.chromeMediumLowColor + x: below.x + y: above.y >= 0 && below.y + height > control.Window.height ? above.y : below.y + width: control.width + height: Math.min(200, listview.contentHeight) // TODO: 396 - ListView { - id: listview - width: control.width - height: Math.min(200, contentHeight) // TODO: 396 + contentItem: ListView { + id: listview + clip: true + model: control.delegateModel + currentIndex: control.highlightedIndex - clip: true - model: control.delegateModel - currentIndex: control.highlightedIndex +// ScrollIndicator.vertical: ScrollIndicator { } + } -// ScrollIndicator.vertical: ScrollIndicator { } - } + background: Rectangle { + color: control.Universal.chromeMediumLowColor + border.color: control.Universal.chromeHighColor + border.width: 1 // FlyoutBorderThemeThickness } } //! [popup] diff --git a/src/imports/controls/universal/Menu.qml b/src/imports/controls/universal/Menu.qml index fec16c16..765ca030 100644 --- a/src/imports/controls/universal/Menu.qml +++ b/src/imports/controls/universal/Menu.qml @@ -42,10 +42,14 @@ import Qt.labs.controls.universal 1.0 T.Menu { id: control + width: Math.max(background ? background.implicitWidth : 0, + contentItem ? contentItem.implicitWidth + leftPadding + rightPadding : 0) + height: Math.min(background ? background.implicitHeight : 0, + contentItem ? contentItem.implicitHeight + topPadding + bottomPadding : 0) + //! [contentItem] contentItem: ListView { - implicitWidth: 200 - implicitHeight: Math.min(contentHeight, 200) + implicitHeight: contentHeight model: control.contentModel // TODO: improve this? interactive: ApplicationWindow.window ? contentHeight > ApplicationWindow.window.height : false @@ -54,15 +58,16 @@ T.Menu { currentIndex: -1 ScrollIndicator.vertical: ScrollIndicator {} - - Rectangle { - z: -1 - width: parent.width - height: parent.height - color: control.Universal.chromeMediumLowColor - border.color: control.Universal.chromeHighColor - border.width: 1 // FlyoutBorderThemeThickness - } } //! [contentItem] + + //! [background] + background: Rectangle { + implicitWidth: 200 + implicitHeight: 200 + color: control.Universal.chromeMediumLowColor + border.color: control.Universal.chromeHighColor + border.width: 1 // FlyoutBorderThemeThickness + } + //! [background] } diff --git a/src/templates/qquickoverlay.cpp b/src/templates/qquickoverlay.cpp index ecee2767..bef6193d 100644 --- a/src/templates/qquickoverlay.cpp +++ b/src/templates/qquickoverlay.cpp @@ -261,11 +261,11 @@ bool QQuickOverlay::childMouseEventFilter(QQuickItem *item, QEvent *event) const QQuickItemPrivate *priv = QQuickItemPrivate::get(this); const QList<QQuickItem *> &sortedChildren = priv->paintOrderChildItems(); for (int i = sortedChildren.count() - 1; i >= 0; --i) { - QQuickItem *contentItem = sortedChildren[i]; - if (contentItem == item) + QQuickItem *popupItem = sortedChildren[i]; + if (popupItem == item) break; - QQuickPopup *popup = d->popups.value(contentItem); + QQuickPopup *popup = d->popups.value(popupItem); if (popup) { emit popup->pressedOutside(); diff --git a/src/templates/qquickpopup.cpp b/src/templates/qquickpopup.cpp index 1b8c5611..6ebdffda 100644 --- a/src/templates/qquickpopup.cpp +++ b/src/templates/qquickpopup.cpp @@ -63,28 +63,136 @@ QQuickPopupPrivate::QQuickPopupPrivate() : QObjectPrivate() , focus(false) , modal(false) + , hasTopPadding(false) + , hasLeftPadding(false) + , hasRightPadding(false) + , hasBottomPadding(false) + , padding(0) + , topPadding(0) + , leftPadding(0) + , rightPadding(0) + , bottomPadding(0) + , background(Q_NULLPTR) , contentItem(Q_NULLPTR) , overlay(Q_NULLPTR) , enter(Q_NULLPTR) , exit(Q_NULLPTR) + , popupItem(Q_NULLPTR) , transitionManager(this) { } +void QQuickPopupPrivate::init() +{ + Q_Q(QQuickPopup); + popupItem = new QQuickPopupItem(q); + popupItem->setParent(q); +} + void QQuickPopupPrivate::finalizeEnterTransition() { if (focus) - contentItem->setFocus(true); + popupItem->setFocus(true); } void QQuickPopupPrivate::finalizeExitTransition() { Q_Q(QQuickPopup); overlay = Q_NULLPTR; - contentItem->setParentItem(Q_NULLPTR); + popupItem->setParentItem(Q_NULLPTR); emit q->visibleChanged(); } +void QQuickPopupPrivate::resizeBackground() +{ + Q_Q(QQuickPopup); + if (background) { + QQuickItemPrivate *p = QQuickItemPrivate::get(background); + if (!p->widthValid && qFuzzyIsNull(background->x())) { + background->setWidth(q->width()); + p->widthValid = false; + } + if (!p->heightValid && qFuzzyIsNull(background->y())) { + background->setHeight(q->height()); + p->heightValid = false; + } + } +} + +void QQuickPopupPrivate::resizeContent() +{ + Q_Q(QQuickPopup); + if (contentItem) { + contentItem->setPosition(QPointF(q->leftPadding(), q->topPadding())); + contentItem->setSize(QSizeF(q->availableWidth(), q->availableHeight())); + } +} + +void QQuickPopupPrivate::setTopPadding(qreal value, bool reset) +{ + Q_Q(QQuickPopup); + qreal oldPadding = q->topPadding(); + topPadding = value; + hasTopPadding = !reset; + if ((!reset && !qFuzzyCompare(oldPadding, value)) || (reset && !qFuzzyCompare(oldPadding, padding))) { + emit q->topPaddingChanged(); + emit q->availableHeightChanged(); + q->paddingChange(QMarginsF(leftPadding, topPadding, rightPadding, bottomPadding), + QMarginsF(leftPadding, oldPadding, rightPadding, bottomPadding)); + } +} + +void QQuickPopupPrivate::setLeftPadding(qreal value, bool reset) +{ + Q_Q(QQuickPopup); + qreal oldPadding = q->leftPadding(); + leftPadding = value; + hasLeftPadding = !reset; + if ((!reset && !qFuzzyCompare(oldPadding, value)) || (reset && !qFuzzyCompare(oldPadding, padding))) { + emit q->leftPaddingChanged(); + emit q->availableWidthChanged(); + q->paddingChange(QMarginsF(leftPadding, topPadding, rightPadding, bottomPadding), + QMarginsF(oldPadding, topPadding, rightPadding, bottomPadding)); + } +} + +void QQuickPopupPrivate::setRightPadding(qreal value, bool reset) +{ + Q_Q(QQuickPopup); + qreal oldPadding = q->rightPadding(); + rightPadding = value; + hasRightPadding = !reset; + if ((!reset && !qFuzzyCompare(oldPadding, value)) || (reset && !qFuzzyCompare(oldPadding, padding))) { + emit q->rightPaddingChanged(); + emit q->availableWidthChanged(); + q->paddingChange(QMarginsF(leftPadding, topPadding, rightPadding, bottomPadding), + QMarginsF(leftPadding, topPadding, oldPadding, bottomPadding)); + } +} + +void QQuickPopupPrivate::setBottomPadding(qreal value, bool reset) +{ + Q_Q(QQuickPopup); + qreal oldPadding = q->bottomPadding(); + bottomPadding = value; + hasBottomPadding = !reset; + if ((!reset && !qFuzzyCompare(oldPadding, value)) || (reset && !qFuzzyCompare(oldPadding, padding))) { + emit q->bottomPaddingChanged(); + emit q->availableHeightChanged(); + q->paddingChange(QMarginsF(leftPadding, topPadding, rightPadding, bottomPadding), + QMarginsF(leftPadding, topPadding, rightPadding, oldPadding)); + } +} + +QQuickPopupItem::QQuickPopupItem(QQuickPopup *popup) : popup(popup) +{ +} + +void QQuickPopupItem::geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry) +{ + popup->geometryChanged(newGeometry, oldGeometry); +} + QQuickPopupTransitionManager::QQuickPopupTransitionManager(QQuickPopupPrivate *popup) : QQuickTransitionManager() , state(Off) @@ -98,7 +206,7 @@ void QQuickPopupTransitionManager::transitionEnter() return; QList<QQuickStateAction> actions; state = Enter; - transition(actions, popup->enter, popup->contentItem); + transition(actions, popup->enter, popup->popupItem); } void QQuickPopupTransitionManager::transitionExit() @@ -107,7 +215,7 @@ void QQuickPopupTransitionManager::transitionExit() return; QList<QQuickStateAction> actions; state = Exit; - transition(actions, popup->exit, popup->contentItem); + transition(actions, popup->exit, popup->popupItem); } void QQuickPopupTransitionManager::finished() @@ -123,11 +231,15 @@ void QQuickPopupTransitionManager::finished() QQuickPopup::QQuickPopup(QObject *parent) : QObject(*(new QQuickPopupPrivate), parent) { + Q_D(QQuickPopup); + d->init(); } QQuickPopup::QQuickPopup(QQuickPopupPrivate &dd, QObject *parent) : QObject(dd, parent) { + Q_D(QQuickPopup); + d->init(); } /*! @@ -138,10 +250,6 @@ QQuickPopup::QQuickPopup(QQuickPopupPrivate &dd, QObject *parent) void QQuickPopup::open() { Q_D(QQuickPopup); - if (!d->contentItem) { - qmlInfo(this) << "no popup content to show."; - return; - } if (d->overlay) { // popup already open return; @@ -173,7 +281,10 @@ void QQuickPopup::open() } d->overlay = static_cast<QQuickOverlay *>(applicationWindow->overlay()); - d->contentItem->setParentItem(d->overlay); + d->popupItem->setParentItem(d->overlay); + // TODO: add Popup::transformOrigin? + if (d->contentItem) + d->popupItem->setTransformOrigin(d->contentItem->transformOrigin()); emit aboutToShow(); d->transitionManager.transitionEnter(); emit visibleChanged(); @@ -193,12 +304,286 @@ void QQuickPopup::close() return; } - d->contentItem->setFocus(false); + d->popupItem->setFocus(false); emit aboutToHide(); d->transitionManager.transitionExit(); } /*! + \qmlproperty real Qt.labs.controls::Popup::x + + This property holds the x-coordinate of the popup. +*/ +qreal QQuickPopup::x() const +{ + Q_D(const QQuickPopup); + return d->popupItem->x(); +} + +void QQuickPopup::setX(qreal x) +{ + Q_D(QQuickPopup); + d->popupItem->setX(x); +} + +/*! + \qmlproperty real Qt.labs.controls::Popup::y + + This property holds the y-coordinate of the popup. +*/ +qreal QQuickPopup::y() const +{ + Q_D(const QQuickPopup); + return d->popupItem->y(); +} + +void QQuickPopup::setY(qreal y) +{ + Q_D(QQuickPopup); + d->popupItem->setY(y); +} + +/*! + \qmlproperty real Qt.labs.controls::Popup::width + + This property holds the width of the popup. +*/ +qreal QQuickPopup::width() const +{ + Q_D(const QQuickPopup); + return d->popupItem->width(); +} + +void QQuickPopup::setWidth(qreal width) +{ + Q_D(QQuickPopup); + d->popupItem->setWidth(width); +} + +/*! + \qmlproperty real Qt.labs.controls::Popup::height + + This property holds the height of the popup. +*/ +qreal QQuickPopup::height() const +{ + Q_D(const QQuickPopup); + return d->popupItem->height(); +} + +void QQuickPopup::setHeight(qreal height) +{ + Q_D(QQuickPopup); + d->popupItem->setHeight(height); +} + +/*! + \qmlproperty real Qt.labs.controls::Popup::availableWidth + + This property holds the width available after deducting horizontal padding. + + \sa padding, leftPadding, rightPadding +*/ +qreal QQuickPopup::availableWidth() const +{ + return qMax<qreal>(0.0, width() - leftPadding() - rightPadding()); +} + +/*! + \qmlproperty real Qt.labs.controls::Popup::availableHeight + + This property holds the height available after deducting vertical padding. + + \sa padding, topPadding, bottomPadding +*/ +qreal QQuickPopup::availableHeight() const +{ + return qMax<qreal>(0.0, height() - topPadding() - bottomPadding()); +} + +/*! + \qmlproperty real Qt.labs.controls::Popup::padding + + This property holds the default padding. + + \sa availableWidth, availableHeight, topPadding, leftPadding, rightPadding, bottomPadding +*/ +qreal QQuickPopup::padding() const +{ + Q_D(const QQuickPopup); + return d->padding; +} + +void QQuickPopup::setPadding(qreal padding) +{ + Q_D(QQuickPopup); + if (qFuzzyCompare(d->padding, padding)) + return; + QMarginsF oldPadding(leftPadding(), topPadding(), rightPadding(), bottomPadding()); + d->padding = padding; + emit paddingChanged(); + QMarginsF newPadding(leftPadding(), topPadding(), rightPadding(), bottomPadding()); + if (!qFuzzyCompare(newPadding.top(), oldPadding.top())) + emit topPaddingChanged(); + if (!qFuzzyCompare(newPadding.left(), oldPadding.left())) + emit leftPaddingChanged(); + if (!qFuzzyCompare(newPadding.right(), oldPadding.right())) + emit rightPaddingChanged(); + if (!qFuzzyCompare(newPadding.bottom(), oldPadding.bottom())) + emit bottomPaddingChanged(); + if (!qFuzzyCompare(newPadding.top(), oldPadding.top()) || !qFuzzyCompare(newPadding.bottom(), oldPadding.bottom())) + emit availableHeightChanged(); + if (!qFuzzyCompare(newPadding.left(), oldPadding.left()) || !qFuzzyCompare(newPadding.right(), oldPadding.right())) + emit availableWidthChanged(); + paddingChange(newPadding, oldPadding); +} + +void QQuickPopup::resetPadding() +{ + setPadding(0); +} + +/*! + \qmlproperty real Qt.labs.controls::Popup::topPadding + + This property holds the top padding. + + \sa padding, bottomPadding, availableHeight +*/ +qreal QQuickPopup::topPadding() const +{ + Q_D(const QQuickPopup); + if (d->hasTopPadding) + return d->topPadding; + return d->padding; +} + +void QQuickPopup::setTopPadding(qreal padding) +{ + Q_D(QQuickPopup); + d->setTopPadding(padding); +} + +void QQuickPopup::resetTopPadding() +{ + Q_D(QQuickPopup); + d->setTopPadding(0, true); +} + +/*! + \qmlproperty real Qt.labs.controls::Popup::leftPadding + + This property holds the left padding. + + \sa padding, rightPadding, availableWidth +*/ +qreal QQuickPopup::leftPadding() const +{ + Q_D(const QQuickPopup); + if (d->hasLeftPadding) + return d->leftPadding; + return d->padding; +} + +void QQuickPopup::setLeftPadding(qreal padding) +{ + Q_D(QQuickPopup); + d->setLeftPadding(padding); +} + +void QQuickPopup::resetLeftPadding() +{ + Q_D(QQuickPopup); + d->setLeftPadding(0, true); +} + +/*! + \qmlproperty real Qt.labs.controls::Popup::rightPadding + + This property holds the right padding. + + \sa padding, leftPadding, availableWidth +*/ +qreal QQuickPopup::rightPadding() const +{ + Q_D(const QQuickPopup); + if (d->hasRightPadding) + return d->rightPadding; + return d->padding; +} + +void QQuickPopup::setRightPadding(qreal padding) +{ + Q_D(QQuickPopup); + d->setRightPadding(padding); +} + +void QQuickPopup::resetRightPadding() +{ + Q_D(QQuickPopup); + d->setRightPadding(0, true); +} + +/*! + \qmlproperty real Qt.labs.controls::Popup::bottomPadding + + This property holds the bottom padding. + + \sa padding, topPadding, availableHeight +*/ +qreal QQuickPopup::bottomPadding() const +{ + Q_D(const QQuickPopup); + if (d->hasBottomPadding) + return d->bottomPadding; + return d->padding; +} + +void QQuickPopup::setBottomPadding(qreal padding) +{ + Q_D(QQuickPopup); + d->setBottomPadding(padding); +} + +void QQuickPopup::resetBottomPadding() +{ + Q_D(QQuickPopup); + d->setBottomPadding(0, true); +} + +/*! + \qmlproperty Item Qt.labs.popups::Popup::background + + This property holds the background item. + + \note If the background item has no explicit size specified, it automatically + follows the popup's size. In most cases, there is no need to specify + width or height for a background item. +*/ +QQuickItem *QQuickPopup::background() const +{ + Q_D(const QQuickPopup); + return d->background; +} + +void QQuickPopup::setBackground(QQuickItem *background) +{ + Q_D(QQuickPopup); + if (d->background != background) { + delete d->background; + d->background = background; + if (background) { + background->setParentItem(d->popupItem); + if (qFuzzyIsNull(background->z())) + background->setZ(-1); + if (isComponentComplete()) + d->resizeBackground(); + } + emit backgroundChanged(); + } +} + +/*! \qmlproperty Item Qt.labs.controls::Popup::contentItem This property holds the content item of the popup. @@ -226,8 +611,12 @@ void QQuickPopup::setContentItem(QQuickItem *item) contentItemChange(item, d->contentItem); delete d->contentItem; d->contentItem = item; - if (item) + if (item) { + item->setParentItem(d->popupItem); QQuickItemPrivate::get(item)->isTabFence = true; + if (isComponentComplete()) + d->resizeContent(); + } emit contentItemChanged(); } } @@ -325,6 +714,20 @@ void QQuickPopup::setExit(QQuickTransition *transition) emit exitChanged(); } +/*! + \qmlproperty list<Object> Qt.labs.controls::Popup::data + \default + + This property holds the list of data. + + \sa Item::data +*/ +QQmlListProperty<QObject> QQuickPopup::data() +{ + Q_D(QQuickPopup); + return QQuickItemPrivate::get(d->popupItem)->data(); +} + void QQuickPopup::classBegin() { } @@ -347,6 +750,29 @@ void QQuickPopup::contentItemChange(QQuickItem *newItem, QQuickItem *oldItem) Q_UNUSED(oldItem); } +void QQuickPopup::geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry) +{ + Q_D(QQuickPopup); + d->resizeBackground(); + d->resizeContent(); + if (!qFuzzyCompare(newGeometry.width(), oldGeometry.width())) { + emit widthChanged(); + emit availableWidthChanged(); + } + if (!qFuzzyCompare(newGeometry.height(), oldGeometry.height())) { + emit heightChanged(); + emit availableHeightChanged(); + } +} + +void QQuickPopup::paddingChange(const QMarginsF &newPadding, const QMarginsF &oldPadding) +{ + Q_D(QQuickPopup); + Q_UNUSED(newPadding); + Q_UNUSED(oldPadding); + d->resizeContent(); +} + QT_END_NAMESPACE #include "moc_qquickpopup_p.cpp" diff --git a/src/templates/qquickpopup_p.h b/src/templates/qquickpopup_p.h index fe485d12..675c43c7 100644 --- a/src/templates/qquickpopup_p.h +++ b/src/templates/qquickpopup_p.h @@ -49,8 +49,10 @@ // #include <QtCore/qobject.h> +#include <QtCore/qmargins.h> #include <QtLabsTemplates/private/qtlabstemplatesglobal_p.h> #include <QtQml/qqml.h> +#include <QtQml/qqmllist.h> #include <QtQml/qqmlparserstatus.h> QT_BEGIN_NAMESPACE @@ -63,16 +65,68 @@ class Q_LABSTEMPLATES_EXPORT QQuickPopup : public QObject, public QQmlParserStat { Q_OBJECT Q_INTERFACES(QQmlParserStatus) + Q_PROPERTY(qreal x READ x WRITE setX NOTIFY xChanged FINAL) + Q_PROPERTY(qreal y READ y WRITE setY NOTIFY yChanged FINAL) + Q_PROPERTY(qreal width READ width WRITE setWidth NOTIFY widthChanged FINAL) + Q_PROPERTY(qreal height READ height WRITE setHeight NOTIFY heightChanged FINAL) + Q_PROPERTY(qreal availableWidth READ availableWidth NOTIFY availableWidthChanged FINAL) + Q_PROPERTY(qreal availableHeight READ availableHeight NOTIFY availableHeightChanged FINAL) + Q_PROPERTY(qreal padding READ padding WRITE setPadding RESET resetPadding NOTIFY paddingChanged FINAL) + Q_PROPERTY(qreal topPadding READ topPadding WRITE setTopPadding RESET resetTopPadding NOTIFY topPaddingChanged FINAL) + Q_PROPERTY(qreal leftPadding READ leftPadding WRITE setLeftPadding RESET resetLeftPadding NOTIFY leftPaddingChanged FINAL) + Q_PROPERTY(qreal rightPadding READ rightPadding WRITE setRightPadding RESET resetRightPadding NOTIFY rightPaddingChanged FINAL) + Q_PROPERTY(qreal bottomPadding READ bottomPadding WRITE setBottomPadding RESET resetBottomPadding NOTIFY bottomPaddingChanged FINAL) + Q_PROPERTY(QQuickItem *background READ background WRITE setBackground NOTIFY backgroundChanged FINAL) Q_PROPERTY(QQuickItem *contentItem READ contentItem WRITE setContentItem NOTIFY contentItemChanged FINAL) Q_PROPERTY(bool focus READ hasFocus WRITE setFocus NOTIFY focusChanged) Q_PROPERTY(bool modal READ isModal WRITE setModal NOTIFY modalChanged) Q_PROPERTY(bool visible READ isVisible NOTIFY visibleChanged) Q_PROPERTY(QQuickTransition *enter READ enter WRITE setEnter NOTIFY enterChanged FINAL) Q_PROPERTY(QQuickTransition *exit READ exit WRITE setExit NOTIFY exitChanged FINAL) + Q_PROPERTY(QQmlListProperty<QObject> data READ data FINAL) + Q_CLASSINFO("DefaultProperty", "data") public: explicit QQuickPopup(QObject *parent = Q_NULLPTR); + qreal x() const; + void setX(qreal x); + + qreal y() const; + void setY(qreal y); + + qreal width() const; + void setWidth(qreal width); + + qreal height() const; + void setHeight(qreal height); + + qreal availableWidth() const; + qreal availableHeight() const; + + qreal padding() const; + void setPadding(qreal padding); + void resetPadding(); + + qreal topPadding() const; + void setTopPadding(qreal padding); + void resetTopPadding(); + + qreal leftPadding() const; + void setLeftPadding(qreal padding); + void resetLeftPadding(); + + qreal rightPadding() const; + void setRightPadding(qreal padding); + void resetRightPadding(); + + qreal bottomPadding() const; + void setBottomPadding(qreal padding); + void resetBottomPadding(); + + QQuickItem *background() const; + void setBackground(QQuickItem *background); + QQuickItem *contentItem() const; void setContentItem(QQuickItem *item); @@ -90,11 +144,25 @@ public: QQuickTransition *exit() const; void setExit(QQuickTransition *transition); + QQmlListProperty<QObject> data(); + public Q_SLOTS: void open(); void close(); Q_SIGNALS: + void xChanged(); + void yChanged(); + void widthChanged(); + void heightChanged(); + void availableWidthChanged(); + void availableHeightChanged(); + void paddingChanged(); + void topPaddingChanged(); + void leftPaddingChanged(); + void rightPaddingChanged(); + void bottomPaddingChanged(); + void backgroundChanged(); void contentItemChanged(); void focusChanged(); void modalChanged(); @@ -117,10 +185,13 @@ protected: bool isComponentComplete() const; virtual void contentItemChange(QQuickItem *newItem, QQuickItem *oldItem); + virtual void geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry); + virtual void paddingChange(const QMarginsF &newPadding, const QMarginsF &oldPadding); private: Q_DISABLE_COPY(QQuickPopup) Q_DECLARE_PRIVATE(QQuickPopup) + friend class QQuickPopupItem; }; QT_END_NAMESPACE diff --git a/src/templates/qquickpopup_p_p.h b/src/templates/qquickpopup_p_p.h index 807c8cd9..77366207 100644 --- a/src/templates/qquickpopup_p_p.h +++ b/src/templates/qquickpopup_p_p.h @@ -48,12 +48,14 @@ // We mean it. // +#include "qquickpopup_p.h" + #include <QtCore/private/qobject_p.h> +#include <QtQuick/qquickitem.h> #include <QtQuick/private/qquicktransitionmanager_p_p.h> QT_BEGIN_NAMESPACE -class QQuickItem; class QQuickTransition; class QQuickTransitionManager; class QQuickPopup; @@ -80,6 +82,20 @@ private: QQuickPopupPrivate *popup; }; +class QQuickPopupItem : public QQuickItem +{ + Q_OBJECT + +public: + explicit QQuickPopupItem(QQuickPopup *popup); + +protected: + void geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry) Q_DECL_OVERRIDE; + +private: + QQuickPopup *popup; +}; + class QQuickPopupPrivate : public QObjectPrivate { Q_DECLARE_PUBLIC(QQuickPopup) @@ -87,16 +103,42 @@ class QQuickPopupPrivate : public QObjectPrivate public: QQuickPopupPrivate(); + static QQuickPopupPrivate *get(QQuickPopup *popup) + { + return popup->d_func(); + } + + void init(); + void finalizeEnterTransition(); void finalizeExitTransition(); + void resizeBackground(); + void resizeContent(); + + void setTopPadding(qreal value, bool reset = false); + void setLeftPadding(qreal value, bool reset = false); + void setRightPadding(qreal value, bool reset = false); + void setBottomPadding(qreal value, bool reset = false); + bool focus; bool modal; bool complete; + bool hasTopPadding; + bool hasLeftPadding; + bool hasRightPadding; + bool hasBottomPadding; + qreal padding; + qreal topPadding; + qreal leftPadding; + qreal rightPadding; + qreal bottomPadding; + QQuickItem *background; QQuickItem *contentItem; QQuickOverlay *overlay; QQuickTransition *enter; QQuickTransition *exit; + QQuickPopupItem *popupItem; QQuickPopupTransitionManager transitionManager; }; diff --git a/tests/auto/material/data/tst_material.qml b/tests/auto/material/data/tst_material.qml index 58360df4..6cd704eb 100644 --- a/tests/auto/material/data/tst_material.qml +++ b/tests/auto/material/data/tst_material.qml @@ -304,7 +304,7 @@ TestCase { verify(window.combo.activeFocus) keyClick(Qt.Key_Space) verify(window.combo.popup.visible) - var listView = window.combo.popup.contentItem.children[0] + var listView = window.combo.popup.contentItem verify(listView) var child = listView.contentItem.children[0] verify(child) diff --git a/tests/auto/menu/tst_menu.cpp b/tests/auto/menu/tst_menu.cpp index 3a2d9c61..d072af4b 100644 --- a/tests/auto/menu/tst_menu.cpp +++ b/tests/auto/menu/tst_menu.cpp @@ -86,7 +86,7 @@ void tst_menu::mouse() QQuickMenu *menu = window->property("menu").value<QQuickMenu*>(); menu->open(); QVERIFY(menu->isVisible()); - QVERIFY(window->overlay()->childItems().contains(menu->contentItem())); + QVERIFY(window->overlay()->childItems().contains(menu->contentItem()->parentItem())); QQuickItem *firstItem = menu->itemAt(0); QSignalSpy clickedSpy(firstItem, SIGNAL(clicked(QQuickMouseEvent*))); @@ -111,7 +111,7 @@ void tst_menu::mouse() menu->open(); QCOMPARE(visibleSpy.count(), 2); QVERIFY(menu->isVisible()); - QVERIFY(window->overlay()->childItems().contains(menu->contentItem())); + QVERIFY(window->overlay()->childItems().contains(menu->contentItem()->parentItem())); // Ensure that we have enough space to click outside of the menu. QVERIFY(window->width() > menu->contentItem()->width()); @@ -120,12 +120,12 @@ void tst_menu::mouse() QPoint(menu->contentItem()->width() + 1, menu->contentItem()->height() + 1)); QCOMPARE(visibleSpy.count(), 3); QVERIFY(!menu->isVisible()); - QVERIFY(!window->overlay()->childItems().contains(menu->contentItem())); + QVERIFY(!window->overlay()->childItems().contains(menu->contentItem()->parentItem())); menu->open(); QCOMPARE(visibleSpy.count(), 4); QVERIFY(menu->isVisible()); - QVERIFY(window->overlay()->childItems().contains(menu->contentItem())); + QVERIFY(window->overlay()->childItems().contains(menu->contentItem()->parentItem())); // Try pressing within the menu and releasing outside of it; it should close. // TODO: won't work until QQuickPopup::releasedOutside() actually gets emitted @@ -167,7 +167,7 @@ void tst_menu::contextMenuKeyboard() menu->open(); QCOMPARE(visibleSpy.count(), 1); QVERIFY(menu->isVisible()); - QVERIFY(window->overlay()->childItems().contains(menu->contentItem())); + QVERIFY(window->overlay()->childItems().contains(menu->contentItem()->parentItem())); QVERIFY(!firstItem->hasActiveFocus()); QCOMPARE(menu->contentItem()->property("currentIndex"), QVariant(-1)); @@ -194,7 +194,7 @@ void tst_menu::contextMenuKeyboard() menu->open(); QCOMPARE(visibleSpy.count(), 3); QVERIFY(menu->isVisible()); - QVERIFY(window->overlay()->childItems().contains(menu->contentItem())); + QVERIFY(window->overlay()->childItems().contains(menu->contentItem()->parentItem())); QVERIFY(!firstItem->hasActiveFocus()); QVERIFY(!secondItem->hasActiveFocus()); QCOMPARE(menu->contentItem()->property("currentIndex"), QVariant(-1)); diff --git a/tests/auto/universal/data/tst_universal.qml b/tests/auto/universal/data/tst_universal.qml index af70ad0e..36e8b0b2 100644 --- a/tests/auto/universal/data/tst_universal.qml +++ b/tests/auto/universal/data/tst_universal.qml @@ -276,7 +276,7 @@ TestCase { verify(window.combo.activeFocus) keyClick(Qt.Key_Space) verify(window.combo.popup.visible) - var listView = window.combo.popup.contentItem.children[0] + var listView = window.combo.popup.contentItem verify(listView) var child = listView.contentItem.children[0] verify(child) diff --git a/tests/manual/testbench/main.qml b/tests/manual/testbench/main.qml index edf0aa49..275c5f08 100644 --- a/tests/manual/testbench/main.qml +++ b/tests/manual/testbench/main.qml @@ -116,8 +116,8 @@ ApplicationWindow { Menu { id: menu - contentItem.x: 1 - contentItem.y: header.height + x: 1 + y: header.height MenuItem { text: "Option 1" |