[plasma/plasma-desktop/work.mart/reorderAppletsSupport] containments/panel: Panel: expose reorderApplets() function for scripting
Marco Martin <[email protected]>
| Newsgroups | gmane.comp.kde.cvs |
|---|---|
| Message-ID | <[email protected]> |
Git commit 9dbcb320a161b0062697470f7508abf137d5b63f by Marco Martin.
Committed on 05/08/2026 at 15:19.
Pushed by mart into branch 'work.mart/reorderAppletsSupport'.
Panel: expose reorderApplets() function for scripting
Expose a reorderApplets function which takes a list of applet
ids and reorders the known applets consistent to such list.
M +17 -0 containments/panel/LayoutManager.js
M +8 -0 containments/panel/main.qml
https://invent.kde.org/plasma/plasma-desktop/-/commit/9dbcb320a161b0062697470f7508abf137d5b63f
diff --git a/containments/panel/LayoutManager.js b/containments/panel/LayoutManager.js
index fe0863f57c..2ab706d349 100644
--- a/containments/panel/LayoutManager.js
+++ b/containments/panel/LayoutManager.js
@@ -93,6 +93,23 @@ function save() {
updateMargins();
}
+function reorderApplets(order) {
+ let containerById = {};
+
+ for (let i = 0; i < appletsModel.count; ++i) {
+ let container = appletsModel.get(i).applet.parent;
+ containerById[container.applet.Plasmoid.id] = container
+ }
+
+ let i = 0;
+ order.forEach((appletId) => {
+ if (appletId in containerById) {
+ move(containerById[appletId], i);
+ }
+ ++i;
+ });
+}
+
function childAtCoordinates(x, y) {
if (root.isHorizontal) {
y = layout.height / 2;
diff --git a/containments/panel/main.qml b/containments/panel/main.qml
index 7f8910b6fc..55034a2416 100644
--- a/containments/panel/main.qml
+++ b/containments/panel/main.qml
@@ -77,6 +77,13 @@ ContainmentItem {
}
return "";
}
+
+ // This function is called externally by the Plasma scripting language to setup
+ // the panel layout
+ function reorderApplets(order) {
+ LayoutManager.reorderApplets(order);
+ }
+
//END functions
//BEGIN connections
@@ -140,6 +147,7 @@ ContainmentItem {
});
component.destroy();
}
+
//END connections
TapHandler {