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/material/Menu.qml | |
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/material/Menu.qml')
-rw-r--r-- | src/imports/controls/material/Menu.qml | 42 |
1 files changed, 24 insertions, 18 deletions
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] } |