From 1d46f88e6e3f8b07cc22a586acb9e437776f87cc Mon Sep 17 00:00:00 2001 From: Yari Polla Date: Mon, 6 Mar 2023 00:52:40 +0100 Subject: [PATCH] fix halcyon pinned model --- .../halcyon/package/contents/ui/FavoritesGrid.qml | 15 +++++---------- .../homescreens/halcyon/plugin/halcyonplugin.cpp | 6 +++++- 2 files changed, 10 insertions(+), 11 deletions(-) diff --git a/containments/homescreens/halcyon/package/contents/ui/FavoritesGrid.qml b/containments/homescreens/halcyon/package/contents/ui/FavoritesGrid.qml index ffbf1919..b5ed0c8c 100644 --- a/containments/homescreens/halcyon/package/contents/ui/FavoritesGrid.qml +++ b/containments/homescreens/halcyon/package/contents/ui/FavoritesGrid.qml @@ -55,11 +55,6 @@ MobileShell.GridView { root.searchWidget.endGesture(); } } - - Halcyon.PinnedModel { - id: pinnedModel - applet: plasmoid.nativeInterface - } // open wallpaper menu when held on click TapHandler { @@ -82,7 +77,7 @@ MobileShell.GridView { model: DelegateModel { id: visualModel - model: pinnedModel + model: Halcyon.PinnedModel delegate: Item { id: delegateRoot @@ -94,7 +89,7 @@ MobileShell.GridView { function moveDragToCurrentPos(from, to) { if (from !== to) { visualModel.items.move(from, to); - pinnedModel.moveEntry(from, to); + Halcyon.PinnedModel.moveEntry(from, to); } } @@ -196,9 +191,9 @@ MobileShell.GridView { onDropped: (drop) => { if (transitionAnim.running || appDelegate.drag.active || drag.source.isFolder) return; // don't do anything when reordering if (appDelegate.isFolder) { - pinnedModel.addAppToFolder(drop.source.visualIndex, appDelegate.visualIndex); + Halcyon.PinnedModel.addAppToFolder(drop.source.visualIndex, appDelegate.visualIndex); } else { - pinnedModel.createFolderFromApps(drop.source.visualIndex, appDelegate.visualIndex); + Halcyon.PinnedModel.createFolderFromApps(drop.source.visualIndex, appDelegate.visualIndex); } folderAnim.to = 0; folderAnim.restart(); @@ -227,7 +222,7 @@ MobileShell.GridView { Kirigami.Action { iconName: "emblem-favorite" text: i18n("Remove from favourites") - onTriggered: pinnedModel.removeEntry(model.index) + onTriggered: Halcyon.PinnedModel.removeEntry(model.index) } ] diff --git a/containments/homescreens/halcyon/plugin/halcyonplugin.cpp b/containments/homescreens/halcyon/plugin/halcyonplugin.cpp index 0bef3919..e2df70ad 100644 --- a/containments/homescreens/halcyon/plugin/halcyonplugin.cpp +++ b/containments/homescreens/halcyon/plugin/halcyonplugin.cpp @@ -19,7 +19,11 @@ void HalcyonPlugin::registerTypes(const char *uri) return applicationListModel; }); - qmlRegisterType(uri, 1, 0, "PinnedModel"); + PinnedModel *pinnedModel = new PinnedModel{this}; + qmlRegisterSingletonType(uri, 1, 0, "PinnedModel", [pinnedModel](QQmlEngine *, QJSEngine *) -> QObject * { + return pinnedModel; + }); + qmlRegisterType(uri, 1, 0, "Application"); qmlRegisterType(uri, 1, 0, "ApplicationFolder"); }