From 7427e2808324388678eefda45b3e83c675979290 Mon Sep 17 00:00:00 2001 From: J-P Nurmi Date: Fri, 22 Jan 2016 12:10:12 +0100 Subject: 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 --- src/imports/controls/universal/ComboBox.qml | 36 ++++++++++++++--------------- 1 file changed, 17 insertions(+), 19 deletions(-) (limited to 'src/imports/controls/universal/ComboBox.qml') 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] -- cgit v1.2.3 From 3bbd90c753fba9cc43c34ca9c509bcc35858b566 Mon Sep 17 00:00:00 2001 From: J-P Nurmi Date: Fri, 22 Jan 2016 15:20:04 +0100 Subject: Add Popup::parent The parent defaults to the QML parent object where Popup is declared. Popup::x/y are relative to the parent, and the popup also automatically follows the parent as appropriate. QQuickPopupPositioner has been adapted from Qt Quick Controls 1. It was called QQuickScenePosListener, and it was implemented for the text selection handle popups. ComboBox's popup now follows the control eg. when scrolling, but the below/above positioning feature is temporarily gone missing. It will be restored in a follow up commit. Change-Id: I8a6b58cd74e07f33930abc35d0ab9da056685128 Reviewed-by: J-P Nurmi --- src/imports/controls/universal/ComboBox.qml | 5 ----- 1 file changed, 5 deletions(-) (limited to 'src/imports/controls/universal/ComboBox.qml') diff --git a/src/imports/controls/universal/ComboBox.qml b/src/imports/controls/universal/ComboBox.qml index 32e28e53..79973dde 100644 --- a/src/imports/controls/universal/ComboBox.qml +++ b/src/imports/controls/universal/ComboBox.qml @@ -109,11 +109,6 @@ T.ComboBox { //! [popup] popup: T.Popup { - 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: Math.min(200, listview.contentHeight) // TODO: 396 -- cgit v1.2.3 From 63a858dfdea91d51cdba974766ccc2e4264a8280 Mon Sep 17 00:00:00 2001 From: J-P Nurmi Date: Sat, 23 Jan 2016 14:21:44 +0100 Subject: ComboBox: set implicit size for the popup Change-Id: I6642a740c93c24cc86b4c7377def252390ca9f71 Reviewed-by: J-P Nurmi --- src/imports/controls/universal/ComboBox.qml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/imports/controls/universal/ComboBox.qml') diff --git a/src/imports/controls/universal/ComboBox.qml b/src/imports/controls/universal/ComboBox.qml index 79973dde..d4e687d0 100644 --- a/src/imports/controls/universal/ComboBox.qml +++ b/src/imports/controls/universal/ComboBox.qml @@ -109,8 +109,8 @@ T.ComboBox { //! [popup] popup: T.Popup { - width: control.width - height: Math.min(200, listview.contentHeight) // TODO: 396 + implicitWidth: control.width + implicitHeight: Math.min(200, listview.contentHeight) // TODO: 396 contentItem: ListView { id: listview -- cgit v1.2.3