Changeset View
Changeset View
Standalone View
Standalone View
applets/taskmanager/package/contents/ui/ContextMenu.qml
Show First 20 Lines • Show All 113 Lines • ▼ Show 20 Line(s) | 97 | function loadDynamicLaunchActions(launcherUrl) { | |||
---|---|---|---|---|---|
114 | ] | 114 | ] | ||
115 | 115 | | |||
116 | // QMenu does not limit its width automatically. Even if we set a maximumWidth | 116 | // QMenu does not limit its width automatically. Even if we set a maximumWidth | ||
117 | // it would just cut off text rather than eliding. So we do this manually. | 117 | // it would just cut off text rather than eliding. So we do this manually. | ||
118 | var textMetrics = Qt.createQmlObject("import QtQuick 2.4; TextMetrics {}", menu); | 118 | var textMetrics = Qt.createQmlObject("import QtQuick 2.4; TextMetrics {}", menu); | ||
119 | var maximumWidth = LayoutManager.maximumContextMenuTextWidth(); | 119 | var maximumWidth = LayoutManager.maximumContextMenuTextWidth(); | ||
120 | 120 | | |||
121 | sections.forEach(function (section) { | 121 | sections.forEach(function (section) { | ||
122 | // Always show the "Actions:" header, since we visually merge | | |||
123 | // This section with the one beneath it that shows universal actions | | |||
124 | if (section["actions"].length > 0 || section["group"] == "actions") { | 122 | if (section["actions"].length > 0 || section["group"] == "actions") { | ||
123 | // Don't add the "Actions" header if the menu has nothing but actions | ||||
124 | // in it, because then it's redundant (all menus have actions) | ||||
125 | if ( | ||||
126 | (section["group"] != "actions") || | ||||
127 | (section["group"] == "actions" && (sections[0]["actions"].length > 0 || sections[1]["actions"].length > 0)) | ||||
128 | ) { | ||||
125 | var sectionHeader = newMenuItem(menu); | 129 | var sectionHeader = newMenuItem(menu); | ||
126 | sectionHeader.text = section["title"]; | 130 | sectionHeader.text = section["title"]; | ||
127 | sectionHeader.section = true; | 131 | sectionHeader.section = true; | ||
128 | menu.addMenuItem(sectionHeader, startNewInstanceItem); | 132 | menu.addMenuItem(sectionHeader, startNewInstanceItem); | ||
129 | } | 133 | } | ||
134 | } | ||||
130 | 135 | | |||
131 | for (var i = 0; i < section["actions"].length; ++i) { | 136 | for (var i = 0; i < section["actions"].length; ++i) { | ||
132 | var item = newMenuItem(menu); | 137 | var item = newMenuItem(menu); | ||
133 | item.action = section["actions"][i]; | 138 | item.action = section["actions"][i]; | ||
134 | 139 | | |||
135 | // Crude way of manually eliding... | 140 | // Crude way of manually eliding... | ||
136 | var elided = false; | 141 | var elided = false; | ||
137 | textMetrics.text = Qt.binding(function() { | 142 | textMetrics.text = Qt.binding(function() { | ||
▲ Show 20 Lines • Show All 601 Lines • Show Last 20 Lines |