fix halcyon pinned model

This commit is contained in:
Yari Polla 2023-03-06 00:52:40 +01:00 committed by Devin Lin
parent 3b0cf51810
commit 1d46f88e6e
2 changed files with 10 additions and 11 deletions

View file

@ -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)
}
]

View file

@ -19,7 +19,11 @@ void HalcyonPlugin::registerTypes(const char *uri)
return applicationListModel;
});
qmlRegisterType<PinnedModel>(uri, 1, 0, "PinnedModel");
PinnedModel *pinnedModel = new PinnedModel{this};
qmlRegisterSingletonType<PinnedModel>(uri, 1, 0, "PinnedModel", [pinnedModel](QQmlEngine *, QJSEngine *) -> QObject * {
return pinnedModel;
});
qmlRegisterType<Application>(uri, 1, 0, "Application");
qmlRegisterType<ApplicationFolder>(uri, 1, 0, "ApplicationFolder");
}