support for separators

This commit is contained in:
Marco Martin 2012-01-02 15:58:11 +01:00
parent 7a55e44d5b
commit 5007558edb
2 changed files with 49 additions and 5 deletions

View File

@ -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
}

View File

@ -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