Changeset View
Changeset View
Standalone View
Standalone View
src/controls/private/ActionsMenu.qml
Show All 13 Lines | |||||
14 | * You should have received a copy of the GNU Library General Public | 14 | * You should have received a copy of the GNU Library General Public | ||
15 | * License along with this program; if not, write to the | 15 | * License along with this program; if not, write to the | ||
16 | * Free Software Foundation, Inc., | 16 | * Free Software Foundation, Inc., | ||
17 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | 17 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | ||
18 | */ | 18 | */ | ||
19 | 19 | | |||
20 | import QtQuick 2.3 | 20 | import QtQuick 2.3 | ||
21 | import QtQuick.Controls 2.1 as Controls | 21 | import QtQuick.Controls 2.1 as Controls | ||
22 | import org.kde.kirigami 2.4 as Kirigami | ||||
22 | 23 | | |||
23 | Controls.Menu | 24 | Controls.Menu | ||
24 | { | 25 | { | ||
25 | id: theMenu | 26 | id: theMenu | ||
26 | property alias actions: actionsInstantiator.model | 27 | property alias actions: actionsInstantiator.model | ||
27 | property Component submenuComponent | 28 | property Component submenuComponent | ||
28 | //renamed to work on both Qt 5.9 and 5.10 | 29 | //renamed to work on both Qt 5.9 and 5.10 | ||
29 | property Component itemDelegate: Component {ActionMenuItem {}} | 30 | property Component itemDelegate: Component {ActionMenuItem {}} | ||
31 | property Component separatorDelegate: Component { | ||||
32 | Controls.MenuSeparator { | ||||
33 | contentItem: Rectangle { | ||||
34 | implicitHeight: Math.floor(Kirigami.Units.devicePixelRatio) | ||||
35 | color: Qt.tint(Kirigami.Theme.textColor, Qt.rgba(Kirigami.Theme.backgroundColor.r, Kirigami.Theme.backgroundColor.g, Kirigami.Theme.backgroundColor.b, 0.7)) | ||||
36 | } | ||||
37 | } | ||||
38 | } | ||||
30 | 39 | | |||
31 | Item { | 40 | Item { | ||
32 | id: invisibleItems | 41 | id: invisibleItems | ||
33 | visible: false | 42 | visible: false | ||
34 | } | 43 | } | ||
35 | Instantiator { | 44 | Instantiator { | ||
36 | id: actionsInstantiator | 45 | id: actionsInstantiator | ||
37 | 46 | | |||
38 | delegate: QtObject { | 47 | delegate: QtObject { | ||
39 | readonly property QtObject action: modelData | 48 | readonly property QtObject action: modelData | ||
40 | property QtObject item: null | 49 | property QtObject item: null | ||
41 | 50 | | |||
42 | function create() { | 51 | function create() { | ||
43 | if (!action.children || action.children.length === 0) { | 52 | if (!action.children || action.children.length === 0) { | ||
53 | if (action.hasOwnProperty("separator") && action.separator) { | ||||
54 | item = theMenu.separatorDelegate.createObject(null, {}); | ||||
55 | } | ||||
broulik: `if (action.separator)`? | |||||
56 | else { | ||||
44 | item = theMenu.itemDelegate.createObject(null, { ourAction: action }); | 57 | item = theMenu.itemDelegate.createObject(null, { ourAction: action }); | ||
58 | } | ||||
45 | theMenu.addItem(item) | 59 | theMenu.addItem(item) | ||
46 | } else if (theMenu.submenuComponent) { | 60 | } else if (theMenu.submenuComponent) { | ||
47 | item = theMenu.submenuComponent.createObject(null, { title: action.text, actions: action.children }); | 61 | item = theMenu.submenuComponent.createObject(null, { title: action.text, actions: action.children }); | ||
48 | theMenu.addMenu(item) | 62 | theMenu.addMenu(item) | ||
49 | } | 63 | } | ||
50 | } | 64 | } | ||
51 | function remove() { | 65 | function remove() { | ||
52 | if (!action.children || action.children.length === 0) { | 66 | if (!action.children || action.children.length === 0) { | ||
Show All 11 Lines |
if (action.separator)?