diff --git a/src/controls/Action.qml b/src/controls/Action.qml --- a/src/controls/Action.qml +++ b/src/controls/Action.qml @@ -140,6 +140,13 @@ * } * @endcode */ + + /** + * separator: bool + * Whether the action is is a separator action; defaults to false. + */ + property bool separator: false + default property alias children: root.__children property list __children property Shortcut __shortcut: Shortcut { diff --git a/src/controls/BasicListItem.qml b/src/controls/BasicListItem.qml --- a/src/controls/BasicListItem.qml +++ b/src/controls/BasicListItem.qml @@ -77,6 +77,7 @@ Layout.minimumWidth: height selected: layout.indicateActiveFocus && (listItem.highlighted || listItem.checked || listItem.pressed) color: listItem.icon && listItem.icon.color && listItem.icon.color.a > 0 ? listItem.icon.color : (selected ? Theme.highlightedTextColor : Theme.textColor) + visible: !listItem.separatorDelegate } QQC2.Label { id: labelItem @@ -85,6 +86,13 @@ color: layout.indicateActiveFocus && (listItem.highlighted || listItem.checked || listItem.pressed) ? listItem.activeTextColor : listItem.textColor elide: Text.ElideRight font: listItem.font + visible: !listItem.separatorDelegate + } + + Separator { + id: separatorItem + Layout.fillWidth: true + visible: listItem.separatorDelegate } } } diff --git a/src/controls/ContextDrawer.qml b/src/controls/ContextDrawer.qml --- a/src/controls/ContextDrawer.qml +++ b/src/controls/ContextDrawer.qml @@ -136,8 +136,9 @@ icon: modelData.icon supportsMouseEvents: true separatorVisible: false + separatorDelegate: modelData.hasOwnProperty("separator") && modelData.separator label: model ? (model.tooltip ? model.tooltip : model.text) : (modelData.tooltip ? modelData.tooltip : modelData.text) - enabled: model ? model.enabled : modelData.enabled + enabled: separatorDelegate ? false : (model ? model.enabled : modelData.enabled) visible: model ? model.visible : modelData.visible opacity: enabled ? 1.0 : 0.6 onClicked: { diff --git a/src/controls/GlobalDrawer.qml b/src/controls/GlobalDrawer.qml --- a/src/controls/GlobalDrawer.qml +++ b/src/controls/GlobalDrawer.qml @@ -463,6 +463,8 @@ checked: modelData.checked || (actionsMenu && actionsMenu.visible) width: parent.width + separatorDelegate: modelData.hasOwnProperty("separator") && modelData.separator + icon: modelData.iconName label: width > height * 2 ? MnemonicData.richTextLabel : "" @@ -494,7 +496,7 @@ easing.type: Easing.InOutQuad } } - enabled: (model && model.enabled != undefined) ? model.enabled : modelData.enabled + enabled: listItem.separatorDelegate ? false : (model && model.enabled != undefined) ? model.enabled : modelData.enabled opacity: enabled ? 1.0 : 0.3 Icon { Shortcut { diff --git a/src/controls/private/ActionsMenu.qml b/src/controls/private/ActionsMenu.qml --- a/src/controls/private/ActionsMenu.qml +++ b/src/controls/private/ActionsMenu.qml @@ -19,6 +19,7 @@ import QtQuick 2.3 import QtQuick.Controls 2.1 as Controls +import org.kde.kirigami 2.4 as Kirigami Controls.Menu { @@ -27,6 +28,14 @@ property Component submenuComponent //renamed to work on both Qt 5.9 and 5.10 property Component itemDelegate: Component {ActionMenuItem {}} + property Component separatorDelegate: Component { + Controls.MenuSeparator { + contentItem: Rectangle { + implicitHeight: Math.floor(Kirigami.Units.devicePixelRatio) + color: Qt.tint(Kirigami.Theme.textColor, Qt.rgba(Kirigami.Theme.backgroundColor.r, Kirigami.Theme.backgroundColor.g, Kirigami.Theme.backgroundColor.b, 0.7)) + } + } + } Item { id: invisibleItems @@ -43,7 +52,12 @@ function create() { if (!action.children || action.children.length === 0) { - item = theMenu.itemDelegate.createObject(null, { ourAction: action }); + if (action.hasOwnProperty("separator") && action.separator) { + item = theMenu.separatorDelegate.createObject(null, {}); + } + else { + item = theMenu.itemDelegate.createObject(null, { ourAction: action }); + } theMenu.addItem(item) } else if (theMenu.submenuComponent) { item = theMenu.submenuComponent.createObject(null, { title: action.text, actions: action.children }); diff --git a/src/controls/templates/AbstractListItem.qml b/src/controls/templates/AbstractListItem.qml --- a/src/controls/templates/AbstractListItem.qml +++ b/src/controls/templates/AbstractListItem.qml @@ -96,6 +96,12 @@ */ property color activeBackgroundColor: Theme.highlightColor + /** + * separatorDelegate: bool + * If true the item will be a separator delegate. Defaults to false. + */ + property bool separatorDelegate: false + default property alias _default: listItem.contentItem Theme.colorGroup: internal.indicateActiveFocus ? Theme.Active : Theme.Inactive