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/Menu.qml | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) (limited to 'src/imports/controls/Menu.qml') 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] } -- cgit v1.2.3