Changeset View
Changeset View
Standalone View
Standalone View
applets/kicker/package/contents/ui/ActionMenu.qml
Show First 20 Lines • Show All 58 Lines • ▼ Show 20 Line(s) | 56 | function refreshMenu() { | |||
---|---|---|---|---|---|
59 | } | 59 | } | ||
60 | 60 | | |||
61 | if (!actionList) { | 61 | if (!actionList) { | ||
62 | return; | 62 | return; | ||
63 | } | 63 | } | ||
64 | 64 | | |||
65 | menu = contextMenuComponent.createObject(root); | 65 | menu = contextMenuComponent.createObject(root); | ||
66 | 66 | | |||
67 | actionList.forEach(function(actionItem) { | 67 | fillMenu(menu, actionList); | ||
68 | var item = contextMenuItemComponent.createObject(menu, { | 68 | } | ||
69 | | ||||
70 | function fillMenu(menu, items) { | ||||
71 | items.forEach(function(actionItem) { | ||||
72 | if (actionItem.subActions) { | ||||
73 | // This is a menu | ||||
74 | var submenuItem = contextSubmenuItemComponent.createObject( | ||||
75 | menu, { "actionItem" : actionItem }); | ||||
76 | | ||||
77 | fillMenu(submenuItem.submenu, actionItem.subActions); | ||||
78 | | ||||
79 | } else { | ||||
80 | var item = contextMenuItemComponent.createObject( | ||||
81 | menu, | ||||
82 | { | ||||
69 | "actionItem": actionItem, | 83 | "actionItem": actionItem, | ||
84 | } | ||||
85 | ); | ||||
86 | } | ||||
70 | }); | 87 | }); | ||
71 | }); | 88 | | ||
72 | } | 89 | } | ||
73 | 90 | | |||
74 | Component { | 91 | Component { | ||
75 | id: contextMenuComponent | 92 | id: contextMenuComponent | ||
76 | 93 | | |||
77 | PlasmaComponents.ContextMenu { | 94 | PlasmaComponents.ContextMenu { | ||
78 | visualParent: root.visualParent | 95 | visualParent: root.visualParent | ||
79 | } | 96 | } | ||
80 | } | 97 | } | ||
81 | 98 | | |||
82 | Component { | 99 | Component { | ||
100 | id: contextSubmenuItemComponent | ||||
101 | | ||||
102 | PlasmaComponents.MenuItem { | ||||
103 | id: submenuItem | ||||
104 | | ||||
105 | property variant actionItem | ||||
106 | | ||||
107 | text: actionItem.text ? actionItem.text : "" | ||||
108 | icon: actionItem.icon ? actionItem.icon : null | ||||
109 | | ||||
110 | property variant submenu : submenu_ | ||||
111 | | ||||
112 | PlasmaComponents.ContextMenu { | ||||
113 | id: submenu_ | ||||
114 | visualParent: submenuItem.action | ||||
115 | } | ||||
116 | } | ||||
117 | } | ||||
118 | | ||||
119 | Component { | ||||
83 | id: contextMenuItemComponent | 120 | id: contextMenuItemComponent | ||
84 | 121 | | |||
85 | PlasmaComponents.MenuItem { | 122 | PlasmaComponents.MenuItem { | ||
86 | property variant actionItem | 123 | property variant actionItem | ||
87 | 124 | | |||
88 | text: actionItem.text ? actionItem.text : "" | 125 | text : actionItem.text ? actionItem.text : "" | ||
89 | enabled: actionItem.type != "title" && ("enabled" in actionItem ? actionItem.enabled : true) | 126 | enabled : actionItem.type != "title" && ("enabled" in actionItem ? actionItem.enabled : true) | ||
90 | separator: actionItem.type == "separator" | 127 | separator : actionItem.type == "separator" | ||
91 | section: actionItem.type == "title" | 128 | section : actionItem.type == "title" | ||
92 | icon: actionItem.icon ? actionItem.icon : null | 129 | icon : actionItem.icon ? actionItem.icon : null | ||
130 | checkable : actionItem.checkable ? actionItem.checkable : false | ||||
131 | checked : actionItem.checked ? actionItem.checked : false | ||||
93 | 132 | | |||
94 | onClicked: { | 133 | onClicked: { | ||
95 | actionClicked(actionItem.actionId, actionItem.actionArgument); | 134 | actionClicked(actionItem.actionId, actionItem.actionArgument); | ||
96 | } | 135 | } | ||
97 | } | 136 | } | ||
98 | } | 137 | } | ||
99 | } | 138 | } |