From 5007558edb94f26520e3a321569314055f34b31f Mon Sep 17 00:00:00 2001 From: Marco Martin Date: Mon, 2 Jan 2012 15:58:11 +0100 Subject: [PATCH] support for separators --- .../platformcomponents/touch/Menu.qml | 22 ++++++++++++- .../platformcomponents/touch/MenuItem.qml | 32 ++++++++++++++++--- 2 files changed, 49 insertions(+), 5 deletions(-) diff --git a/declarativeimports/plasmacomponents/platformcomponents/touch/Menu.qml b/declarativeimports/plasmacomponents/platformcomponents/touch/Menu.qml index d0ef8004e..9e71a8094 100644 --- a/declarativeimports/plasmacomponents/platformcomponents/touch/Menu.qml +++ b/declarativeimports/plasmacomponents/platformcomponents/touch/Menu.qml @@ -28,6 +28,26 @@ Item { property Item visualParent property int status: DialogStatus.Closed + onVisualParentChanged: { + //if is a menuitem move to menuColumn + if (visualParent.separator !== undefined) { + var obj = arrowComponent.createObject(visualParent) + } + } + + Component { + id: arrowComponent + PlasmaCore.SvgItem { + svg: PlasmaCore.Svg {imagePath: "widgets/arrows"} + elementId: "right-arrow" + width: naturalSize.width + height: naturalSize.height + anchors { + right: parent.right + verticalCenter: parent.verticalCenter + } + } + } function open() { var parent = root.visualParent ? root.visualParent : root.parent @@ -50,9 +70,9 @@ Item { } onChildrenChanged: { - //if is a menuitem move to menuColumn for (var i = 0; i < children.length; ++i) { var item = children[i] + //if is a menuitem move to menuColumn if (item.separator !== undefined) { item.parent = menuColumn } diff --git a/declarativeimports/plasmacomponents/platformcomponents/touch/MenuItem.qml b/declarativeimports/plasmacomponents/platformcomponents/touch/MenuItem.qml index 16f2546b9..e9408355c 100644 --- a/declarativeimports/plasmacomponents/platformcomponents/touch/MenuItem.qml +++ b/declarativeimports/plasmacomponents/platformcomponents/touch/MenuItem.qml @@ -50,11 +50,21 @@ Item { signal clicked implicitWidth: textArea.paintedWidth + iconLoader.width*2 + 6 - implicitHeight: textArea.paintedHeight + 6 + implicitHeight: Math.max(theme.smallIconSize, textArea.paintedHeight + 6) + width: Math.max(implicitWidth, parent.width) property bool separator: false + onSeparatorChanged: { + if (separator) { + internal.separatorItem = separatorComponent.createObject(root) + } else { + internal.separatorItem.destroy() + } + } property alias icon: iconLoader.source + enabled: !separator + Private.IconLoader { id: iconLoader width: parent.height @@ -72,10 +82,24 @@ Item { horizontalAlignment: Text.AlignHCenter elide: Text.ElideRight } - /*Component.onCompleted: { - contentItem.width = 300//Math.max(contentItem.width, root.width) - }*/ + QtObject { + id: internal + property Item separatorItem + } + Component { + id: separatorComponent + PlasmaCore.FrameSvgItem { + imagePath: "widgets/viewitem" + prefix: "normal" + height: text ? parent.height : margins.top+margins.bottom + anchors { + right: parent.right + left: parent.left + verticalCenter: parent.verticalCenter + } + } + } MouseArea { id: mouseArea