From 97d549c34c2ba8a198c9ad3cd1ffcf3452946304 Mon Sep 17 00:00:00 2001 From: Devin Lin Date: Sun, 5 Mar 2023 09:39:03 -0800 Subject: [PATCH] homescreens/folio: Port to plugin architecture --- .../qml/components/StartupFeedback.qml | 19 +++++++------ containments/homescreens/folio/CMakeLists.txt | 4 +-- containments/homescreens/folio/homescreen.cpp | 14 ---------- containments/homescreens/folio/homescreen.h | 3 -- .../package/contents/ui/HomeDelegate.qml | 10 ++++--- .../folio/package/contents/ui/HomeScreen.qml | 7 +++-- .../contents/ui/HomeScreenContents.qml | 16 ++++++----- .../contents/ui/LauncherDragManager.qml | 16 +++++------ .../package/contents/ui/LauncherRepeater.qml | 21 +++++++------- .../ui/appdrawer/GridViewAppDrawer.qml | 6 ++-- .../ui/appdrawer/ListViewAppDrawer.qml | 6 ++-- .../folio/package/contents/ui/main.qml | 7 ++--- .../ui/private/DelegateRemoveButton.qml | 9 ++++-- .../homescreens/folio/plugin/CMakeLists.txt | 28 +++++++++++++++++++ .../{ => plugin}/applicationlistmodel.cpp | 2 ++ .../folio/{ => plugin}/applicationlistmodel.h | 4 +-- .../folio/{ => plugin}/desktopmodel.cpp | 2 +- .../folio/{ => plugin}/desktopmodel.h | 3 +- .../homescreens/folio/plugin/folioplugin.cpp | 18 ++++++++++++ .../homescreens/folio/plugin/folioplugin.h | 16 +++++++++++ containments/homescreens/folio/plugin/qmldir | 6 ++++ .../homescreens/halcyon/plugin/CMakeLists.txt | 2 +- shell/contents/layout.js | 21 ++++++++------ 23 files changed, 154 insertions(+), 86 deletions(-) create mode 100644 containments/homescreens/folio/plugin/CMakeLists.txt rename containments/homescreens/folio/{ => plugin}/applicationlistmodel.cpp (99%) rename containments/homescreens/folio/{ => plugin}/applicationlistmodel.h (98%) rename containments/homescreens/folio/{ => plugin}/desktopmodel.cpp (99%) rename containments/homescreens/folio/{ => plugin}/desktopmodel.h (97%) create mode 100644 containments/homescreens/folio/plugin/folioplugin.cpp create mode 100644 containments/homescreens/folio/plugin/folioplugin.h create mode 100644 containments/homescreens/folio/plugin/qmldir diff --git a/components/mobileshell/qml/components/StartupFeedback.qml b/components/mobileshell/qml/components/StartupFeedback.qml index 65908237..aee435d3 100644 --- a/components/mobileshell/qml/components/StartupFeedback.qml +++ b/components/mobileshell/qml/components/StartupFeedback.qml @@ -62,15 +62,16 @@ MouseArea { // use mousearea to ensure clicks don't go behind } } - Connections { - target: NanoShell.StartupNotifier - enabled: NanoShell.StartupNotifier.isValid - - function onActivationStarted(appId, iconName) { - icon.source = iconName - background.state = "open"; - } - } + // TODO + // Connections { + // target: NanoShell.StartupNotifier + // enabled: NanoShell.StartupNotifier.isValid + // + // function onActivationStarted(appId, iconName) { + // icon.source = iconName + // background.state = "open"; + // } + // } property alias state: background.state property alias icon: icon.source diff --git a/containments/homescreens/folio/CMakeLists.txt b/containments/homescreens/folio/CMakeLists.txt index d0c9ff38..3116fbd8 100644 --- a/containments/homescreens/folio/CMakeLists.txt +++ b/containments/homescreens/folio/CMakeLists.txt @@ -3,8 +3,6 @@ set(homescreen_SRCS homescreen.cpp - desktopmodel.cpp - applicationlistmodel.cpp ) add_library(plasma_containment_phone_homescreen MODULE ${homescreen_SRCS}) @@ -27,3 +25,5 @@ target_link_libraries(plasma_containment_phone_homescreen install(TARGETS plasma_containment_phone_homescreen DESTINATION ${KDE_INSTALL_PLUGINDIR}/plasma/applets) plasma_install_package(package org.kde.plasma.mobile.homescreen.folio) + +add_subdirectory(plugin) diff --git a/containments/homescreens/folio/homescreen.cpp b/containments/homescreens/folio/homescreen.cpp index 982031be..16682495 100644 --- a/containments/homescreens/folio/homescreen.cpp +++ b/containments/homescreens/folio/homescreen.cpp @@ -14,20 +14,6 @@ HomeScreen::HomeScreen(QObject *parent, const KPluginMetaData &data, const QVari : Plasma::Containment{parent, data, args} { setHasConfigurationInterface(true); - - ApplicationListModel *applicationListModel = new ApplicationListModel{this}; - DesktopModel *desktopModel = new DesktopModel{this, this}; - qmlRegisterSingletonType("org.kde.phone.homescreen.default", - 1, - 0, - "ApplicationListModel", - [applicationListModel](QQmlEngine *, QJSEngine *) -> QObject * { - return applicationListModel; - }); - qmlRegisterSingletonType("org.kde.phone.homescreen.default", 1, 0, "DesktopModel", [desktopModel](QQmlEngine *, QJSEngine *) -> QObject * { - return desktopModel; - }); - connect(KWindowSystem::self(), &KWindowSystem::showingDesktopChanged, this, &HomeScreen::showingDesktopChanged); } diff --git a/containments/homescreens/folio/homescreen.h b/containments/homescreens/folio/homescreen.h index c9b7ed2e..87e96ab2 100644 --- a/containments/homescreens/folio/homescreen.h +++ b/containments/homescreens/folio/homescreen.h @@ -7,9 +7,6 @@ #include #include -#include -#include - class HomeScreen : public Plasma::Containment { Q_OBJECT diff --git a/containments/homescreens/folio/package/contents/ui/HomeDelegate.qml b/containments/homescreens/folio/package/contents/ui/HomeDelegate.qml index bc1b169c..cc614c1d 100644 --- a/containments/homescreens/folio/package/contents/ui/HomeDelegate.qml +++ b/containments/homescreens/folio/package/contents/ui/HomeDelegate.qml @@ -17,12 +17,13 @@ import org.kde.kquickcontrolsaddons 2.0 import org.kde.plasma.private.containmentlayoutmanager 1.0 as ContainmentLayoutManager import org.kde.plasma.private.mobileshell 1.0 as MobileShell import org.kde.plasma.private.mobileshell.state 1.0 as MobileShellState -import org.kde.phone.homescreen.default 1.0 as HomeScreenLib +import org.kde.private.plasma.mobile.homescreen.folio 1.0 as Folio import "private" as Private ContainmentLayoutManager.ItemContainer { id: delegate + required property Folio.DesktopModel desktopModel enabled: homeScreenState.currentView === HomeScreenState.PageView || homeScreenState.currentSwipeState === HomeScreenState.SwipingAppDrawerVisibility @@ -52,9 +53,9 @@ ContainmentLayoutManager.ItemContainer { } if (!MobileShellState.Shell.taskSwitcherVisible) { - HomeScreenLib.DesktopModel.setMinimizedDelegate(index, delegate); + desktopModel.setMinimizedDelegate(index, delegate); } else { - HomeScreenLib.DesktopModel.unsetMinimizedDelegate(index, delegate); + desktopModel.unsetMinimizedDelegate(index, delegate); } } @@ -65,7 +66,7 @@ ContainmentLayoutManager.ItemContainer { delegate.launch(delegate.x + (PlasmaCore.Units.smallSpacing * 2), delegate.y + (PlasmaCore.Units.smallSpacing * 2), icon.source, modelData.applicationName); } - HomeScreenLib.DesktopModel.setMinimizedDelegate(index, delegate); + desktopModel.setMinimizedDelegate(index, delegate); MobileShell.ShellUtil.launchApp(modelData.applicationStorageId); } @@ -197,6 +198,7 @@ ContainmentLayoutManager.ItemContainer { //TODO: in loader? Private.DelegateRemoveButton { id: removeButton + desktopModel: delegate.desktopModel } } diff --git a/containments/homescreens/folio/package/contents/ui/HomeScreen.qml b/containments/homescreens/folio/package/contents/ui/HomeScreen.qml index cb2cda94..cf54b065 100644 --- a/containments/homescreens/folio/package/contents/ui/HomeScreen.qml +++ b/containments/homescreens/folio/package/contents/ui/HomeScreen.qml @@ -21,7 +21,7 @@ import org.kde.plasma.private.containmentlayoutmanager 1.0 as ContainmentLayoutM import org.kde.plasma.private.mobileshell 1.0 as MobileShell import org.kde.plasma.private.mobileshell.state 1.0 as MobileShellState -import org.kde.phone.homescreen.default 1.0 as HomeScreenLib +import org.kde.private.plasma.mobile.homescreen.folio 1.0 as Folio Item { id: root @@ -54,6 +54,8 @@ Item { homeScreenState.goToPageIndex(0); homeScreenState.resetSwipeState(); } + + property var desktopModel: Folio.DesktopModel {} // the parent of the homescreen is a flickable that captures all flicks FlickContainer { @@ -96,6 +98,7 @@ Item { HomeScreenContents { id: contents + desktopModel: root.desktopModel homeScreenState: root.homeScreenState height: pages.height @@ -110,7 +113,7 @@ Item { appletsLayout: contents.appletsLayout visible: favoriteStrip.flow.children.length > 0 || contents.launcherDragManager.active || contents.containsDrag - opacity: contents.launcherDragManager.active && HomeScreenLib.DesktopModel.favoriteCount >= HomeScreenLib.DesktopModel.maxFavoriteCount ? 0.3 : 1 + opacity: contents.launcherDragManager.active && root.desktopModel.favoriteCount >= root.desktopModel.maxFavoriteCount ? 0.3 : 1 TapHandler { target: favoriteStrip diff --git a/containments/homescreens/folio/package/contents/ui/HomeScreenContents.qml b/containments/homescreens/folio/package/contents/ui/HomeScreenContents.qml index c025efb8..2f6ff691 100644 --- a/containments/homescreens/folio/package/contents/ui/HomeScreenContents.qml +++ b/containments/homescreens/folio/package/contents/ui/HomeScreenContents.qml @@ -17,7 +17,7 @@ import org.kde.draganddrop 2.0 as DragDrop import org.kde.plasma.private.containmentlayoutmanager 1.0 as ContainmentLayoutManager import org.kde.plasma.private.mobileshell 1.0 as MobileShell -import org.kde.phone.homescreen.default 1.0 as HomeScreenLib +import org.kde.private.plasma.mobile.homescreen.folio 1.0 as Folio import "private" as Private @@ -25,7 +25,10 @@ DragDrop.DropArea { id: dropArea required property var homeScreenState - + + required property Folio.DesktopModel desktopModel + property var applicationListModel: Folio.ApplicationListModel + property alias launcherDelegate: launcherRepeater.delegate property alias launcherModel: launcherRepeater.model property alias launcherRepeater: launcherRepeater @@ -52,9 +55,7 @@ DragDrop.DropArea { } property bool inAppletEditMode: false - - property var applicationListModel: HomeScreenLib.ApplicationListModel - property var desktopModel: HomeScreenLib.DesktopModel + Connections { target: plasmoid @@ -119,7 +120,7 @@ DragDrop.DropArea { } let pos = Math.min(desktopModel.count, Math.floor(posInFavorites.x/favoriteStrip.cellWidth)) - desktopModel.addFavorite(storageId, pos, HomeScreenLib.ApplicationListModel.Favorites) + desktopModel.addFavorite(storageId, pos, Folio.ApplicationListModel.Favorites) let item = launcherRepeater.itemAt(pos); if (item) { @@ -134,7 +135,7 @@ DragDrop.DropArea { } let pos = desktopModel.count; - desktopModel.addFavorite(storageId, pos, HomeScreenLib.ApplicationListModel.Desktop) + desktopModel.addFavorite(storageId, pos, Folio.ApplicationListModel.Desktop) let item = launcherRepeater.itemAt(pos); event.accept(event.proposedAction); @@ -222,6 +223,7 @@ DragDrop.DropArea { } LauncherRepeater { id: launcherRepeater + desktopModel: dropArea.desktopModel homeScreenState: dropArea.homeScreenState cellWidth: appletsLayout.cellWidth cellHeight: appletsLayout.cellHeight diff --git a/containments/homescreens/folio/package/contents/ui/LauncherDragManager.qml b/containments/homescreens/folio/package/contents/ui/LauncherDragManager.qml index 4075d55e..a18ab6f0 100644 --- a/containments/homescreens/folio/package/contents/ui/LauncherDragManager.qml +++ b/containments/homescreens/folio/package/contents/ui/LauncherDragManager.qml @@ -9,7 +9,7 @@ import QtQuick 2.4 import org.kde.plasma.plasmoid 2.0 import org.kde.plasma.private.containmentlayoutmanager 1.0 as ContainmentLayoutManager import org.kde.plasma.private.mobileshell 1.0 as MobileShell -import org.kde.phone.homescreen.default 1.0 as HomeScreenLib +import org.kde.private.plasma.mobile.homescreen.folio 1.0 as Folio Item { id: root @@ -19,7 +19,7 @@ Item { property ContainmentLayoutManager.ItemContainer currentlyDraggedDelegate property bool active - property var desktopModel: HomeScreenLib.DesktopModel + required property Folio.DesktopModel desktopModel readonly property Item spacer: Item { width: favoriteStrip.cellWidth @@ -45,7 +45,7 @@ Item { newRow = Math.floor((pos.x + dragCenterX) / delegate.width); showSpacer(delegate, dragCenterX, dragCenterY); - HomeScreenLib.DesktopModel.moveItem(delegate.modelData.index, newRow); + desktopModel.moveItem(delegate.modelData.index, newRow); // Put it on desktop } else { @@ -162,8 +162,8 @@ Item { if (!item.modelData) { return appletsLayout; } else if (favoriteStrip.contains(Qt.point(0,favoriteStrip.frame.mapFromItem(item, dragCenterX, dragCenterY).y)) - && (item.modelData.applicationLocation == HomeScreenLib.DesktopModel.Favorites - || HomeScreenLib.DesktopModel.favoriteCount < HomeScreenLib.DesktopModel.maxFavoriteCount)) { + && (item.modelData.applicationLocation == Folio.DesktopModel.Favorites + || desktopModel.favoriteCount < desktopModel.maxFavoriteCount)) { return favoriteStrip; } else { return appletsLayout; @@ -269,7 +269,7 @@ Item { if (container == appletsLayout) { if (item.modelData) { - HomeScreenLib.DesktopModel.setLocation(item.modelData.index, HomeScreenLib.DesktopModel.Desktop); + desktopModel.setLocation(item.modelData.index, Folio.DesktopModel.Desktop); } var pos = appletsLayout.mapFromItem(item, 0, 0); item.parent = appletsLayout; @@ -280,9 +280,9 @@ Item { return; } else if (container == favoriteStrip) { - HomeScreenLib.DesktopModel.setLocation(item.modelData.index, HomeScreenLib.DesktopModel.Favorites); + desktopModel.setLocation(item.modelData.index, Folio.DesktopModel.Favorites); } else { - HomeScreenLib.DesktopModel.setLocation(item.modelData.index, HomeScreenLib.DesktopModel.None); + desktopModel.setLocation(item.modelData.index, Folio.DesktopModel.None); } var child = nearestChild(item, dragCenterX, dragCenterY, container); diff --git a/containments/homescreens/folio/package/contents/ui/LauncherRepeater.qml b/containments/homescreens/folio/package/contents/ui/LauncherRepeater.qml index 44302367..d4d58a25 100644 --- a/containments/homescreens/folio/package/contents/ui/LauncherRepeater.qml +++ b/containments/homescreens/folio/package/contents/ui/LauncherRepeater.qml @@ -17,15 +17,15 @@ import org.kde.plasma.private.containmentlayoutmanager 1.0 as ContainmentLayoutM import org.kde.plasma.private.mobileshell 1.0 as MobileShell import org.kde.plasma.private.mobileshell.state 1.0 as MobileShellState import org.kde.plasma.private.nanoshell 2.0 as NanoShell -import org.kde.phone.homescreen.default 1.0 as HomeScreenLib +import org.kde.private.plasma.mobile.homescreen.folio 1.0 as Folio import org.kde.kirigami 2.14 as Kirigami Repeater { id: launcherRepeater - model: HomeScreenLib.DesktopModel - + required property var homeScreenState - + required property Folio.DesktopModel desktopModel + property ContainmentLayoutManager.AppletsLayout appletsLayout property FavoriteStrip favoriteStrip property int cellWidth @@ -37,6 +37,7 @@ Repeater { delegate: HomeDelegate { id: delegate + desktopModel: launcherRepeater.desktopModel homeScreenState: launcherRepeater.homeScreenState width: launcherRepeater.cellWidth @@ -53,15 +54,15 @@ Repeater { reservedSpaceForLabel: metrics.height property Item parentFromLocation: { switch (model.applicationLocation) { - case HomeScreenLib.DesktopModel.Favorites: + case Folio.DesktopModel.Favorites: return favoriteStrip.flow; - case HomeScreenLib.DesktopModel.Desktop: + case Folio.DesktopModel.Desktop: default: return appletsLayout; } } Component.onCompleted: { - if (model.applicationLocation === HomeScreenLib.DesktopModel.Desktop) { + if (model.applicationLocation === Folio.DesktopModel.Desktop) { appletsLayout.restoreItem(delegate); } } @@ -117,10 +118,10 @@ Repeater { onParentFromLocationChanged: { if (!launcherDragManager.active && parent != parentFromLocation) { parent = parentFromLocation; - if (model.applicationLocation === HomeScreenLib.DesktopModel.Favorites) { + if (model.applicationLocation === Folio.DesktopModel.Favorites) { MobileShell.ShellUtil.stackItemBefore(delegate, parentFromLocation.children[index]); - } else if (model.applicationLocation === HomeScreenLib.DesktopModel.None) { - MobileShell.ShellUtil.stackItemBefore(delegate, parentFromLocation.children[Math.max(0, index - HomeScreenLib.DesktopModel.favoriteCount)]); + } else if (model.applicationLocation === Folio.DesktopModel.None) { + MobileShell.ShellUtil.stackItemBefore(delegate, parentFromLocation.children[Math.max(0, index - desktopModel.favoriteCount)]); } } } diff --git a/containments/homescreens/folio/package/contents/ui/appdrawer/GridViewAppDrawer.qml b/containments/homescreens/folio/package/contents/ui/appdrawer/GridViewAppDrawer.qml index 2da5c5f2..d423d623 100644 --- a/containments/homescreens/folio/package/contents/ui/appdrawer/GridViewAppDrawer.qml +++ b/containments/homescreens/folio/package/contents/ui/appdrawer/GridViewAppDrawer.qml @@ -18,7 +18,7 @@ import org.kde.kirigami 2.10 as Kirigami import org.kde.plasma.private.nanoshell 2.0 as NanoShell import org.kde.plasma.private.mobileshell 1.0 as MobileShell import org.kde.plasma.private.mobileshell.state 1.0 as MobileShellState -import org.kde.phone.homescreen.default 1.0 as HomeScreenLib +import org.kde.private.plasma.mobile.homescreen.folio 1.0 as Folio import "../private" @@ -48,7 +48,7 @@ AbstractAppDrawer { cacheBuffer: Math.max(0, rows * cellHeight) - model: HomeScreenLib.ApplicationListModel + model: Folio.ApplicationListModel delegate: DrawerGridDelegate { id: delegate @@ -78,7 +78,7 @@ AbstractAppDrawer { Math.min(delegate.iconItem.width, delegate.iconItem.height)); } - HomeScreenLib.ApplicationListModel.setMinimizedDelegate(index, delegate); + Folio.ApplicationListModel.setMinimizedDelegate(index, delegate); MobileShell.ShellUtil.launchApp(storageId); root.launched(); } diff --git a/containments/homescreens/folio/package/contents/ui/appdrawer/ListViewAppDrawer.qml b/containments/homescreens/folio/package/contents/ui/appdrawer/ListViewAppDrawer.qml index 8684fdb3..b92dbe43 100644 --- a/containments/homescreens/folio/package/contents/ui/appdrawer/ListViewAppDrawer.qml +++ b/containments/homescreens/folio/package/contents/ui/appdrawer/ListViewAppDrawer.qml @@ -17,7 +17,7 @@ import org.kde.kirigami 2.10 as Kirigami import org.kde.plasma.private.nanoshell 2.0 as NanoShell import org.kde.plasma.private.mobileshell 1.0 as MobileShell -import org.kde.phone.homescreen.default 1.0 as HomeScreenLib +import org.kde.private.plasma.mobile.homescreen.folio 1.0 as Folio import "../private" @@ -34,7 +34,7 @@ AbstractAppDrawer { property int delegateHeight: PlasmaCore.Units.gridUnit * 3 - model: HomeScreenLib.ApplicationListModel + model: Folio.ApplicationListModel delegate: DrawerListDelegate { id: delegate @@ -64,7 +64,7 @@ AbstractAppDrawer { Math.min(delegate.iconItem.width, delegate.iconItem.height)); } - HomeScreenLib.ApplicationListModel.setMinimizedDelegate(index, delegate); + Folio.ApplicationListModel.setMinimizedDelegate(index, delegate); MobileShell.ShellUtil.launchApp(storageId); root.launched(); } diff --git a/containments/homescreens/folio/package/contents/ui/main.qml b/containments/homescreens/folio/package/contents/ui/main.qml index 5fee33d5..bc7a7728 100644 --- a/containments/homescreens/folio/package/contents/ui/main.qml +++ b/containments/homescreens/folio/package/contents/ui/main.qml @@ -15,7 +15,7 @@ import org.kde.plasma.components 3.0 as PlasmaComponents import org.kde.plasma.private.mobileshell 1.0 as MobileShell import org.kde.plasma.private.mobileshell.state 1.0 as MobileShellState -import org.kde.phone.homescreen.default 1.0 as HomeScreenLib +import org.kde.private.plasma.mobile.homescreen.folio 1.0 as Folio MobileShell.HomeScreen { id: root @@ -34,9 +34,6 @@ MobileShell.HomeScreen { property bool componentComplete: false Component.onCompleted: { - HomeScreenLib.ApplicationListModel.load(); - HomeScreenLib.DesktopModel.load(); - // ensure the gestures work immediately on load forceActiveFocus(); } @@ -124,7 +121,7 @@ MobileShell.HomeScreen { // listen to app launch errors Connections { - target: HomeScreenLib.ApplicationListModel + target: Folio.ApplicationListModel function onLaunchError(msg) { MobileShellState.Shell.closeAppLaunchAnimation() } diff --git a/containments/homescreens/folio/package/contents/ui/private/DelegateRemoveButton.qml b/containments/homescreens/folio/package/contents/ui/private/DelegateRemoveButton.qml index b2aa0a31..ac3b9a29 100644 --- a/containments/homescreens/folio/package/contents/ui/private/DelegateRemoveButton.qml +++ b/containments/homescreens/folio/package/contents/ui/private/DelegateRemoveButton.qml @@ -16,10 +16,13 @@ import org.kde.kquickcontrolsaddons 2.0 import org.kde.plasma.private.containmentlayoutmanager 1.0 as ContainmentLayoutManager import org.kde.plasma.private.mobileshell 1.0 as MobileShell -import org.kde.phone.homescreen.default 1.0 as HomeScreenLib +import org.kde.private.plasma.mobile.homescreen.folio 1.0 as Folio PC3.RoundButton { id: removeButton + + required property Folio.DesktopModel desktopModel + anchors { right: parent.right top: parent.top @@ -35,6 +38,7 @@ PC3.RoundButton { removeButtonScaleAnim.to = 1; removeButtonAnim.running = true; } + function hide() { if (!visible) { return; @@ -43,6 +47,7 @@ PC3.RoundButton { removeButtonScaleAnim.to = 0; removeButtonAnim.running = true; } + SequentialAnimation { id: delegateDestructionAnim NumberAnimation { @@ -56,7 +61,7 @@ PC3.RoundButton { ScriptAction { script: { appletsLayout.releaseSpace(delegate); - HomeScreenLib.DesktopModel.removeFavorite(index); + desktopModel.removeFavorite(index); } } } diff --git a/containments/homescreens/folio/plugin/CMakeLists.txt b/containments/homescreens/folio/plugin/CMakeLists.txt new file mode 100644 index 00000000..35b94195 --- /dev/null +++ b/containments/homescreens/folio/plugin/CMakeLists.txt @@ -0,0 +1,28 @@ +# SPDX-FileCopyrightText: 2023 Devin Lin +# SPDX-License-Identifier: GPL-2.0-or-later + +set(folioplugin_SRCS + folioplugin.cpp + applicationlistmodel.cpp + desktopmodel.cpp +) + +install(FILES qmldir DESTINATION ${KDE_INSTALL_QMLDIR}/org/kde/private/plasma/mobile/homescreen/halcyon) + +add_library(folioplugin SHARED ${folioplugin_SRCS}) + +target_link_libraries(folioplugin + Qt::Gui + Qt::Qml + Qt::Quick + KF6::Plasma + KF6::I18n + KF6::Service + KF6::KIOGui + KF6::Notifications + KF6::WaylandClient + KF6::WindowSystem) + +set_property(TARGET folioplugin PROPERTY LIBRARY_OUTPUT_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/org/kde/private/plasma/mobile/homescreen/folio) +install(TARGETS folioplugin DESTINATION ${KDE_INSTALL_QMLDIR}/org/kde/private/plasma/mobile/homescreen/folio) + diff --git a/containments/homescreens/folio/applicationlistmodel.cpp b/containments/homescreens/folio/plugin/applicationlistmodel.cpp similarity index 99% rename from containments/homescreens/folio/applicationlistmodel.cpp rename to containments/homescreens/folio/plugin/applicationlistmodel.cpp index 734ed78c..a279664c 100644 --- a/containments/homescreens/folio/applicationlistmodel.cpp +++ b/containments/homescreens/folio/plugin/applicationlistmodel.cpp @@ -40,6 +40,8 @@ ApplicationListModel::ApplicationListModel(QObject *parent) registry->setup(); connection->roundtrip(); + + load(); } ApplicationListModel::~ApplicationListModel() = default; diff --git a/containments/homescreens/folio/applicationlistmodel.h b/containments/homescreens/folio/plugin/applicationlistmodel.h similarity index 98% rename from containments/homescreens/folio/applicationlistmodel.h rename to containments/homescreens/folio/plugin/applicationlistmodel.h index 505d79fe..f7bfc783 100644 --- a/containments/homescreens/folio/applicationlistmodel.h +++ b/containments/homescreens/folio/plugin/applicationlistmodel.h @@ -58,8 +58,6 @@ public: QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const Q_DECL_OVERRIDE; QHash roleNames() const Q_DECL_OVERRIDE; - Q_INVOKABLE virtual void load(); - Q_INVOKABLE void setMinimizedDelegate(int row, QQuickItem *delegate); Q_INVOKABLE void unsetMinimizedDelegate(int row, QQuickItem *delegate); @@ -71,6 +69,8 @@ Q_SIGNALS: void launchError(const QString &msg); protected: + virtual void load(); + QList m_applicationList; KWayland::Client::PlasmaWindowManagement *m_windowManagement = nullptr; diff --git a/containments/homescreens/folio/desktopmodel.cpp b/containments/homescreens/folio/plugin/desktopmodel.cpp similarity index 99% rename from containments/homescreens/folio/desktopmodel.cpp rename to containments/homescreens/folio/plugin/desktopmodel.cpp index b7ac351e..65c6ffc2 100644 --- a/containments/homescreens/folio/desktopmodel.cpp +++ b/containments/homescreens/folio/plugin/desktopmodel.cpp @@ -19,7 +19,7 @@ const int MAX_FAVORITES = 5; DesktopModel::DesktopModel(QObject *parent, Plasma::Applet *applet) - : ApplicationListModel(parent) + : ApplicationListModel(parent) // constructor calls load() , m_applet{applet} { } diff --git a/containments/homescreens/folio/desktopmodel.h b/containments/homescreens/folio/plugin/desktopmodel.h similarity index 97% rename from containments/homescreens/folio/desktopmodel.h rename to containments/homescreens/folio/plugin/desktopmodel.h index 07d2e7c0..69d2c7d1 100644 --- a/containments/homescreens/folio/desktopmodel.h +++ b/containments/homescreens/folio/plugin/desktopmodel.h @@ -33,7 +33,6 @@ public: QString uniqueToStorageId(const QString &uniqueId) const; void loadSettings(); - Q_INVOKABLE void load() override; int count(); int favoriteCount(); @@ -50,6 +49,8 @@ Q_SIGNALS: void favoriteCountChanged(); private: + void load() override; + QStringList m_appOrder; QStringList m_favorites; QSet m_desktopItems; diff --git a/containments/homescreens/folio/plugin/folioplugin.cpp b/containments/homescreens/folio/plugin/folioplugin.cpp new file mode 100644 index 00000000..00b436c4 --- /dev/null +++ b/containments/homescreens/folio/plugin/folioplugin.cpp @@ -0,0 +1,18 @@ +// SPDX-FileCopyrightText: 2023 Devin Lin +// SPDX-License-Identifier: GPL-2.0-or-later + +#include "folioplugin.h" +#include "applicationlistmodel.h" +#include "desktopmodel.h" + +void HalcyonPlugin::registerTypes(const char *uri) +{ + Q_ASSERT(QLatin1String(uri) == QLatin1String("org.kde.private.plasma.mobile.homescreen.halcyon")); + + ApplicationListModel *applicationListModel = new ApplicationListModel{this}; + qmlRegisterSingletonType(uri, 1, 0, "ApplicationListModel", [applicationListModel](QQmlEngine *, QJSEngine *) -> QObject * { + return applicationListModel; + }); + + qmlRegisterType(uri, 1, 0, "DesktopModel"); +} diff --git a/containments/homescreens/folio/plugin/folioplugin.h b/containments/homescreens/folio/plugin/folioplugin.h new file mode 100644 index 00000000..eae08dc1 --- /dev/null +++ b/containments/homescreens/folio/plugin/folioplugin.h @@ -0,0 +1,16 @@ +// SPDX-FileCopyrightText: 2023 Devin Lin +// SPDX-License-Identifier: GPL-2.0-or-later + +#pragma once + +#include +#include + +class HalcyonPlugin : public QQmlExtensionPlugin +{ + Q_OBJECT + Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QQmlExtensionInterface") + +public: + void registerTypes(const char *uri) override; +}; diff --git a/containments/homescreens/folio/plugin/qmldir b/containments/homescreens/folio/plugin/qmldir new file mode 100644 index 00000000..4bd31fb5 --- /dev/null +++ b/containments/homescreens/folio/plugin/qmldir @@ -0,0 +1,6 @@ +# SPDX-FileCopyrightText: 2023 Devin Lin +# SPDX-License-Identifier: GPL-2.0-or-later + +module org.kde.private.plasma.mobile.homescreen.folio +plugin folioplugin + diff --git a/containments/homescreens/halcyon/plugin/CMakeLists.txt b/containments/homescreens/halcyon/plugin/CMakeLists.txt index ed999ae0..1df35fcb 100644 --- a/containments/homescreens/halcyon/plugin/CMakeLists.txt +++ b/containments/homescreens/halcyon/plugin/CMakeLists.txt @@ -26,5 +26,5 @@ target_link_libraries(halcyonplugin KF6::WaylandClient KF6::WindowSystem) -set_property(TARGET halcyonplugin PROPERTY LIBRARY_OUTPUT_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/org/kde/plasma/mm) +set_property(TARGET halcyonplugin PROPERTY LIBRARY_OUTPUT_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/org/kde/private/mobile/homescreen/halcyon) install(TARGETS halcyonplugin DESTINATION ${KDE_INSTALL_QMLDIR}/org/kde/private/mobile/homescreen/halcyon) diff --git a/shell/contents/layout.js b/shell/contents/layout.js index 0515cbdd..cc08aa92 100644 --- a/shell/contents/layout.js +++ b/shell/contents/layout.js @@ -16,13 +16,16 @@ for (var j = 0; j < desktopsArray.length; j++) { } } - // keep this list in sync with shell/contents/updates/panelsfix.js -var panel = new Panel("org.kde.plasma.mobile.panel"); -panel.location = "top"; -panel.addWidget("org.kde.plasma.notifications"); -panel.height = 1.25 * gridUnit; // HACK: supposed to be gridUnit + smallSpacing, but it doesn't seem to give the correct number - -var bottomPanel = new Panel("org.kde.desktopcontainment") -bottomPanel.location = "bottom"; -bottomPanel.height = 2 * gridUnit; +// var panel = new Panel("org.kde.plasma.mobile.panel"); +// panel.location = "top"; +// panel.addWidget("org.kde.plasma.notifications"); +// panel.height = 1.25 * gridUnit; // HACK: supposed to be gridUnit + smallSpacing, but it doesn't seem to give the correct number +// +// console.log('script'); +// +// var bottomPanel = new Panel("org.kde.plasma.mobile.taskpanel") +// bottomPanel.location = "bottom"; +// bottomPanel.height = 2 * gridUnit; +// +// console.log('script');