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 /src/imports/controls/universal | |
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>
Diffstat (limited to 'src/imports/controls/universal')
-rw-r--r-- | src/imports/controls/universal/ComboBox.qml | 36 | ||||
-rw-r--r-- | src/imports/controls/universal/Menu.qml | 27 |
2 files changed, 33 insertions, 30 deletions
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] } |