diff --git a/components/CMakeLists.txt b/components/CMakeLists.txt index 1668a18c..8e7904bd 100644 --- a/components/CMakeLists.txt +++ b/components/CMakeLists.txt @@ -3,5 +3,4 @@ # SPDX-License-Identifier: GPL-2.0-or-later add_subdirectory(mmplugin) -add_subdirectory(mobilehomescreencomponents) add_subdirectory(mobileshell) diff --git a/components/mobilehomescreencomponents/CMakeLists.txt b/components/mobilehomescreencomponents/CMakeLists.txt deleted file mode 100644 index 2ab59bf4..00000000 --- a/components/mobilehomescreencomponents/CMakeLists.txt +++ /dev/null @@ -1,30 +0,0 @@ -# SPDX-FileCopyrightText: 2021 Devin Lin -# SPDX-FileCopyrightText: 2021 Marco Martin -# SPDX-FileCopyrightText: 2021 Aleix Pol -# SPDX-License-Identifier: GPL-2.0-or-later - -set(mobilehomescreencomponentsplugin_SRCS - mobilehomescreencomponentsplugin.cpp - applicationlistmodel.cpp - favoritesmodel.cpp - homescreenutils.cpp -) - -add_library(mobilehomescreencomponentsplugin ${mobilehomescreencomponentsplugin_SRCS}) - -target_link_libraries(mobilehomescreencomponentsplugin - PUBLIC - Qt::Core - PRIVATE - Qt::Qml - Qt::Quick - KF5::KIOGui - KF5::Plasma - KF5::Notifications - KF5::PlasmaQuick - KF5::WaylandClient - ) - -install(TARGETS mobilehomescreencomponentsplugin DESTINATION ${KDE_INSTALL_QMLDIR}/org/kde/plasma/private/mobilehomescreencomponents) - -install(DIRECTORY qml/ DESTINATION ${KDE_INSTALL_QMLDIR}/org/kde/plasma/private/mobilehomescreencomponents) diff --git a/components/mobilehomescreencomponents/mobilehomescreencomponentsplugin.cpp b/components/mobilehomescreencomponents/mobilehomescreencomponentsplugin.cpp deleted file mode 100644 index 2967c73f..00000000 --- a/components/mobilehomescreencomponents/mobilehomescreencomponentsplugin.cpp +++ /dev/null @@ -1,38 +0,0 @@ -/* - * SPDX-FileCopyrightText: 2019 by Marco Martin - * - * SPDX-License-Identifier: GPL-2.0-or-later - */ - -#include "mobilehomescreencomponentsplugin.h" - -#include -#include - -#include "applicationlistmodel.h" -#include "favoritesmodel.h" -#include "homescreenutils.h" - -void MobileHomeScreenComponentsPlugin::registerTypes(const char *uri) -{ - Q_ASSERT(QLatin1String(uri) == QLatin1String("org.kde.plasma.private.mobilehomescreencomponents")); - - qmlRegisterSingletonType(uri, 0, 1, "HomeScreenUtils", - [](QQmlEngine *, QJSEngine *) { - return new HomeScreenUtils{}; - }); - - qmlRegisterSingletonType(uri, 0, 1, "ApplicationListModel", - [](QQmlEngine *, QJSEngine *) { - return new ApplicationListModel{}; - }); - - qmlRegisterSingletonType(uri, 0, 1, "FavoritesModel", - [](QQmlEngine *, QJSEngine *) { - return new FavoritesModel{}; - }); - - // qmlProtectModule(uri, 1); -} - -//#include "moc_mobilehomescreencomponentplugin.cpp" diff --git a/components/mobilehomescreencomponents/mobilehomescreencomponentsplugin.h b/components/mobilehomescreencomponents/mobilehomescreencomponentsplugin.h deleted file mode 100644 index c948f9c8..00000000 --- a/components/mobilehomescreencomponents/mobilehomescreencomponentsplugin.h +++ /dev/null @@ -1,21 +0,0 @@ -/* - * SPDX-FileCopyrightText: 2019 by Marco Martin - * - * SPDX-License-Identifier: GPL-2.0-or-later - */ - -#pragma once - -#include - -#include -#include - -class MobileHomeScreenComponentsPlugin : public QQmlExtensionPlugin -{ - Q_OBJECT - Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QQmlExtensionInterface") - -public: - void registerTypes(const char *uri) override; -}; diff --git a/components/mobilehomescreencomponents/qml/qmldir b/components/mobilehomescreencomponents/qml/qmldir deleted file mode 100644 index 10a5cc65..00000000 --- a/components/mobilehomescreencomponents/qml/qmldir +++ /dev/null @@ -1,28 +0,0 @@ -# SPDX-FileCopyrightText: 2021 Devin Lin -# SPDX-FileCopyrightText: 2021 Marco Martin -# SPDX-License-Identifier: GPL-2.0-or-later - -module org.kde.plasma.private.mobilehomescreencomponents - -plugin mobilehomescreencomponentsplugin - -AbstractAppDrawer 0.1 appdrawer/AbstractAppDrawer.qml -AppDrawerHeader 0.1 appdrawer/AppDrawerHeader.qml -AppDrawerLoader 0.1 appdrawer/AppDrawerLoader.qml -DrawerGridDelegate 0.1 appdrawer/DrawerGridDelegate.qml -DrawerListDelegate 0.1 appdrawer/DrawerListDelegate.qml -GridViewAppDrawer 0.1 appdrawer/GridViewAppDrawer.qml -ListViewAppDrawer 0.1 appdrawer/ListViewAppDrawer.qml - -FavoriteStrip 0.1 FavoriteStrip.qml -FlickContainer 0.1 FlickContainer.qml -HomeDelegate 0.1 HomeDelegate.qml -HomeScreen 0.1 HomeScreen.qml -HomeScreenContents 0.1 HomeScreenContents.qml -HomeScreenPages 0.1 HomeScreenPages.qml -HomeScreenState 0.1 HomeScreenState.qml -LauncherContainer 0.1 LauncherContainer.qml -LauncherDragManager 0.1 LauncherDragManager.qml -LauncherGrid 0.1 LauncherGrid.qml -LauncherRepeater 0.1 LauncherRepeater.qml -MobileAppletContainer 0.1 MobileAppletContainer.qml diff --git a/components/mobileshell/CMakeLists.txt b/components/mobileshell/CMakeLists.txt index 0a441493..a45c80f9 100644 --- a/components/mobileshell/CMakeLists.txt +++ b/components/mobileshell/CMakeLists.txt @@ -14,6 +14,9 @@ set(mobileshellplugin_SRCS shellutil.cpp notifications/notificationthumbnailer.cpp notifications/notificationfilemenu.cpp + homescreen/applicationlistmodel.cpp + homescreen/favoritesmodel.cpp + homescreen/homescreenutils.cpp taskswitcher/displaysmodel.cpp ) diff --git a/components/mobilehomescreencomponents/applicationlistmodel.cpp b/components/mobileshell/homescreen/applicationlistmodel.cpp similarity index 79% rename from components/mobilehomescreencomponents/applicationlistmodel.cpp rename to components/mobileshell/homescreen/applicationlistmodel.cpp index 0b1b99b4..749bff05 100644 --- a/components/mobilehomescreencomponents/applicationlistmodel.cpp +++ b/components/mobileshell/homescreen/applicationlistmodel.cpp @@ -1,5 +1,6 @@ /* * SPDX-FileCopyrightText: 2014 Antonis Tsiapaliokas + * SPDX-FileCopyrightText: 2022 Devin Lin * * SPDX-License-Identifier: GPL-2.0-or-later */ @@ -9,9 +10,9 @@ // Qt #include +#include #include #include -#include #include #include @@ -35,10 +36,9 @@ constexpr int MAX_FAVOURITES = 5; ApplicationListModel::ApplicationListModel(QObject *parent) : QAbstractListModel(parent) - //m_applet(parent) +// m_applet(parent) { - connect(KSycoca::self(), qOverload(&KSycoca::databaseChanged), - this, &ApplicationListModel::sycocaDbChanged); + connect(KSycoca::self(), qOverload(&KSycoca::databaseChanged), this, &ApplicationListModel::sycocaDbChanged); loadSettings(); initWayland(); @@ -67,22 +67,20 @@ void ApplicationListModel::loadSettings() ++i; } - //loadApplications(); + // loadApplications(); } QHash ApplicationListModel::roleNames() const { - return { - {ApplicationNameRole, QByteArrayLiteral("applicationName")}, - {ApplicationIconRole, QByteArrayLiteral("applicationIcon")}, - {ApplicationStorageIdRole, QByteArrayLiteral("applicationStorageId")}, - {ApplicationEntryPathRole, QByteArrayLiteral("applicationEntryPath")}, - {ApplicationOriginalRowRole, QByteArrayLiteral("applicationOriginalRow")}, - {ApplicationStartupNotifyRole, QByteArrayLiteral("applicationStartupNotify")}, - {ApplicationLocationRole, QByteArrayLiteral("applicationLocation")}, - {ApplicationRunningRole, QByteArrayLiteral("applicationRunning")}, - {ApplicationUniqueIdRole, QByteArrayLiteral("applicationUniqueId")} - }; + return {{ApplicationNameRole, QByteArrayLiteral("applicationName")}, + {ApplicationIconRole, QByteArrayLiteral("applicationIcon")}, + {ApplicationStorageIdRole, QByteArrayLiteral("applicationStorageId")}, + {ApplicationEntryPathRole, QByteArrayLiteral("applicationEntryPath")}, + {ApplicationOriginalRowRole, QByteArrayLiteral("applicationOriginalRow")}, + {ApplicationStartupNotifyRole, QByteArrayLiteral("applicationStartupNotify")}, + {ApplicationLocationRole, QByteArrayLiteral("applicationLocation")}, + {ApplicationRunningRole, QByteArrayLiteral("applicationRunning")}, + {ApplicationUniqueIdRole, QByteArrayLiteral("applicationUniqueId")}}; } void ApplicationListModel::sycocaDbChanged(const QStringList &changes) @@ -114,39 +112,36 @@ void ApplicationListModel::initWayland() } auto *registry = new Registry(this); registry->create(connection); - connect(registry, &Registry::plasmaWindowManagementAnnounced, this, - [this, registry] (quint32 name, quint32 version) { - m_windowManagement = registry->createPlasmaWindowManagement(name, version, this); - qRegisterMetaType >("QVector"); + connect(registry, &Registry::plasmaWindowManagementAnnounced, this, [this, registry](quint32 name, quint32 version) { + m_windowManagement = registry->createPlasmaWindowManagement(name, version, this); + qRegisterMetaType>("QVector"); - connect(m_windowManagement, &KWayland::Client::PlasmaWindowManagement::windowCreated, - this, [this] (KWayland::Client::PlasmaWindow *window) { - if (window->appId() == QStringLiteral("org.kde.plasmashell")) { - return; - } - int idx = 0; - for (auto i = m_applicationList.begin(); i != m_applicationList.end(); i++) { - if ((*i).storageId == window->appId() + QStringLiteral(".desktop")) { - (*i).window = window; - emit dataChanged(index(idx, 0), index(idx, 0)); - connect(window, &KWayland::Client::PlasmaWindow::unmapped, this, [this, window] () { - int idx = 0; - for (auto i = m_applicationList.begin(); i != m_applicationList.end(); i++) { - if ((*i).storageId == window->appId() + QStringLiteral(".desktop")) { - (*i).window = nullptr; - emit dataChanged(index(idx, 0), index(idx, 0)); - break; - } - idx++; + connect(m_windowManagement, &KWayland::Client::PlasmaWindowManagement::windowCreated, this, [this](KWayland::Client::PlasmaWindow *window) { + if (window->appId() == QStringLiteral("org.kde.plasmashell")) { + return; + } + int idx = 0; + for (auto i = m_applicationList.begin(); i != m_applicationList.end(); i++) { + if ((*i).storageId == window->appId() + QStringLiteral(".desktop")) { + (*i).window = window; + emit dataChanged(index(idx, 0), index(idx, 0)); + connect(window, &KWayland::Client::PlasmaWindow::unmapped, this, [this, window]() { + int idx = 0; + for (auto i = m_applicationList.begin(); i != m_applicationList.end(); i++) { + if ((*i).storageId == window->appId() + QStringLiteral(".desktop")) { + (*i).window = nullptr; + emit dataChanged(index(idx, 0), index(idx, 0)); + break; } - }); - break; - } - idx++; + idx++; + } + }); + break; } - }); - } - ); + idx++; + } + }); + }); registry->setup(); connection->roundtrip(); @@ -270,7 +265,7 @@ Qt::ItemFlags ApplicationListModel::flags(const QModelIndex &index) const { if (!index.isValid()) return {}; - return Qt::ItemIsDragEnabled|QAbstractListModel::flags(index); + return Qt::ItemIsDragEnabled | QAbstractListModel::flags(index); } int ApplicationListModel::rowCount(const QModelIndex &parent) const @@ -282,7 +277,7 @@ int ApplicationListModel::rowCount(const QModelIndex &parent) const return m_applicationList.count(); } -void ApplicationListModel::moveRow(const QModelIndex& /* sourceParent */, int sourceRow, const QModelIndex& /* destinationParent */, int destinationChild) +void ApplicationListModel::moveRow(const QModelIndex & /* sourceParent */, int sourceRow, const QModelIndex & /* destinationParent */, int destinationChild) { moveItem(sourceRow, destinationChild); } @@ -301,8 +296,7 @@ void ApplicationListModel::setLocation(int row, LauncherLocation location) if (location == Favorites) { qWarning() << "favoriting" << row << data.name; // Deny favorites when full - if (row >= m_maxFavoriteCount || m_favorites.count() >= m_maxFavoriteCount || - m_favorites.contains(data.uniqueId)) { + if (row >= m_maxFavoriteCount || m_favorites.count() >= m_maxFavoriteCount || m_favorites.contains(data.uniqueId)) { return; } @@ -313,8 +307,8 @@ void ApplicationListModel::setLocation(int row, LauncherLocation location) } emit favoriteCountChanged(); - // Out of favorites - } else if (data.location == Favorites) { + // Out of favorites + } else if (data.location == Favorites) { m_favorites.removeAll(data.uniqueId); if (m_applet) { m_applet->applet()->config().writeEntry("Favorites", m_favorites); @@ -329,8 +323,8 @@ void ApplicationListModel::setLocation(int row, LauncherLocation location) m_applet->applet()->config().writeEntry("DesktopItems", m_desktopItems.values()); } - // Out of Desktop - } else if (data.location == Desktop) { + // Out of Desktop + } else if (data.location == Desktop) { m_desktopItems.remove(data.uniqueId); if (m_applet) { m_applet->applet()->config().writeEntry(QStringLiteral("DesktopItems"), m_desktopItems.values()); @@ -346,8 +340,7 @@ void ApplicationListModel::setLocation(int row, LauncherLocation location) void ApplicationListModel::moveItem(int row, int destination) { - if (row < 0 || destination < 0 || row >= m_applicationList.length() || - destination >= m_applicationList.length() || row == destination) { + if (row < 0 || destination < 0 || row >= m_applicationList.length() || destination >= m_applicationList.length() || row == destination) { return; } if (destination > row) { @@ -365,7 +358,6 @@ void ApplicationListModel::moveItem(int row, int destination) m_applicationList.insert(destination, data); } - m_appOrder.clear(); m_appPositions.clear(); int i = 0; @@ -481,7 +473,7 @@ void ApplicationListModel::setMinimizedDelegate(int row, QQuickItem *delegate) return; } - QRect rect = delegate->mapRectToScene(QRectF(0,0, delegate->width(), delegate->height())).toRect(); + QRect rect = delegate->mapRectToScene(QRectF(0, 0, delegate->width(), delegate->height())).toRect(); window->setMinimizedGeometry(surface, rect); } @@ -512,6 +504,3 @@ void ApplicationListModel::unsetMinimizedDelegate(int row, QQuickItem *delegate) window->unsetMinimizedGeometry(surface); } - -#include "moc_applicationlistmodel.cpp" - diff --git a/components/mobilehomescreencomponents/applicationlistmodel.h b/components/mobileshell/homescreen/applicationlistmodel.h similarity index 85% rename from components/mobilehomescreencomponents/applicationlistmodel.h rename to components/mobileshell/homescreen/applicationlistmodel.h index 94f66da5..7ce0b02a 100644 --- a/components/mobilehomescreencomponents/applicationlistmodel.h +++ b/components/mobileshell/homescreen/applicationlistmodel.h @@ -1,16 +1,16 @@ /* * SPDX-FileCopyrightText: 2014 Antonis Tsiapaliokas + * SPDX-FileCopyrightText: 2022 Devin Lin * * SPDX-License-Identifier: GPL-2.0-or-later */ -#ifndef APPLICATIONLISTMODEL_H -#define APPLICATIONLISTMODEL_H +#pragma once // Qt -#include #include #include +#include #include #include "homescreenutils.h" @@ -33,7 +33,8 @@ class AppletQuickItem; class ApplicationListModel; -class ApplicationListModel : public QAbstractListModel { +class ApplicationListModel : public QAbstractListModel +{ Q_OBJECT Q_PROPERTY(PlasmaQuick::AppletQuickItem *applet READ applet WRITE setApplet NOTIFY appletChanged) @@ -43,11 +44,7 @@ class ApplicationListModel : public QAbstractListModel { Q_PROPERTY(int maxFavoriteCount READ maxFavoriteCount WRITE setMaxFavoriteCount NOTIFY maxFavoriteCountChanged) public: - enum LauncherLocation { - Grid = 0, - Favorites, - Desktop - }; + enum LauncherLocation { Grid = 0, Favorites, Desktop }; Q_ENUM(LauncherLocation) struct ApplicationData { @@ -76,14 +73,26 @@ public: ApplicationListModel(QObject *parent = nullptr); ~ApplicationListModel() override; + static ApplicationListModel *instance() + { + static ApplicationListModel *model = new ApplicationListModel; + return model; + } + void loadSettings(); int rowCount(const QModelIndex &parent = QModelIndex()) const Q_DECL_OVERRIDE; void moveRow(const QModelIndex &sourceParent, int sourceRow, const QModelIndex &destinationParent, int destinationChild); - int count() const { return m_applicationList.count(); } - int favoriteCount() const { return m_favorites.count();} + int count() const + { + return m_applicationList.count(); + } + int favoriteCount() const + { + return m_favorites.count(); + } int maxFavoriteCount() const; void setMaxFavoriteCount(int count); @@ -109,7 +118,7 @@ public: Q_INVOKABLE void unsetMinimizedDelegate(int row, QQuickItem *delegate); public Q_SLOTS: - void sycocaDbChanged(const QStringList &change); + void sycocaDbChanged(const QStringList &change); Q_SIGNALS: void countChanged(); @@ -131,5 +140,3 @@ protected: QSet m_desktopItems; QHash m_appPositions; }; - -#endif // APPLICATIONLISTMODEL_H diff --git a/components/mobilehomescreencomponents/favoritesmodel.cpp b/components/mobileshell/homescreen/favoritesmodel.cpp similarity index 99% rename from components/mobilehomescreencomponents/favoritesmodel.cpp rename to components/mobileshell/homescreen/favoritesmodel.cpp index a45ddb6e..5b88894e 100644 --- a/components/mobilehomescreencomponents/favoritesmodel.cpp +++ b/components/mobileshell/homescreen/favoritesmodel.cpp @@ -9,8 +9,8 @@ // Qt #include -#include #include +#include // KDE #include @@ -28,7 +28,6 @@ FavoritesModel::FavoritesModel(QObject *parent) FavoritesModel::~FavoritesModel() = default; - QString FavoritesModel::storageToUniqueId(const QString &storageId) const { if (storageId.isEmpty()) { @@ -54,10 +53,8 @@ QString FavoritesModel::uniqueToStorageId(const QString &uniqueId) const return uniqueId.split(QLatin1Char('-')).first(); } - void FavoritesModel::loadApplications() { - beginResetModel(); m_applicationList.clear(); @@ -97,7 +94,7 @@ void FavoritesModel::loadApplications() } m_desktopItems.remove(uniqueId); } - + endResetModel(); emit countChanged(); @@ -185,4 +182,3 @@ void FavoritesModel::removeFavorite(int row) } #include "moc_favoritesmodel.cpp" - diff --git a/components/mobilehomescreencomponents/favoritesmodel.h b/components/mobileshell/homescreen/favoritesmodel.h similarity index 82% rename from components/mobilehomescreencomponents/favoritesmodel.h rename to components/mobileshell/homescreen/favoritesmodel.h index fce1459c..d63c8657 100644 --- a/components/mobilehomescreencomponents/favoritesmodel.h +++ b/components/mobileshell/homescreen/favoritesmodel.h @@ -7,13 +7,13 @@ #pragma once // Qt -#include #include #include +#include #include -#include "homescreenutils.h" #include "applicationlistmodel.h" +#include "homescreenutils.h" class QString; @@ -28,13 +28,19 @@ class PlasmaWindow; class FavoritesModel; -class FavoritesModel : public ApplicationListModel { +class FavoritesModel : public ApplicationListModel +{ Q_OBJECT public: FavoritesModel(QObject *parent = nullptr); ~FavoritesModel() override; + static FavoritesModel *instance() + { + static FavoritesModel *model = new FavoritesModel; + return model; + } QString storageToUniqueId(const QString &storageId) const; QString uniqueToStorageId(const QString &uniqueId) const; @@ -43,7 +49,4 @@ public: Q_INVOKABLE void removeFavorite(int row); Q_INVOKABLE void loadApplications() override; - - }; - diff --git a/components/mobilehomescreencomponents/homescreenutils.cpp b/components/mobileshell/homescreen/homescreenutils.cpp similarity index 99% rename from components/mobilehomescreencomponents/homescreenutils.cpp rename to components/mobileshell/homescreen/homescreenutils.cpp index 40932586..b10d1306 100644 --- a/components/mobilehomescreencomponents/homescreenutils.cpp +++ b/components/mobileshell/homescreen/homescreenutils.cpp @@ -6,14 +6,13 @@ #include "homescreenutils.h" #include "favoritesmodel.h" -#include #include #include +#include HomeScreenUtils::HomeScreenUtils(QObject *parent) : QObject(parent) { - } HomeScreenUtils::~HomeScreenUtils() = default; @@ -36,5 +35,4 @@ void HomeScreenUtils::stackAfter(QQuickItem *item1, QQuickItem *item2) item1->stackAfter(item2); } - #include "moc_homescreenutils.cpp" diff --git a/components/mobilehomescreencomponents/homescreenutils.h b/components/mobileshell/homescreen/homescreenutils.h similarity index 69% rename from components/mobilehomescreencomponents/homescreenutils.h rename to components/mobileshell/homescreen/homescreenutils.h index db43ab95..efaebc15 100644 --- a/components/mobilehomescreencomponents/homescreenutils.h +++ b/components/mobileshell/homescreen/homescreenutils.h @@ -6,7 +6,6 @@ #pragma once - #include class QQuickItem; @@ -17,16 +16,21 @@ class HomeScreenUtils : public QObject Q_OBJECT public: - HomeScreenUtils( QObject *parent = 0); + HomeScreenUtils(QObject *parent = 0); ~HomeScreenUtils() override; + static HomeScreenUtils *instance() + { + static HomeScreenUtils *model = new HomeScreenUtils; + return model; + } + Q_INVOKABLE void stackBefore(QQuickItem *item1, QQuickItem *item2); Q_INVOKABLE void stackAfter(QQuickItem *item1, QQuickItem *item2); protected: - // void configChanged() override; + // void configChanged() override; private: bool m_showAllApps = false; }; - diff --git a/components/mobileshell/mobileshellplugin.cpp b/components/mobileshell/mobileshellplugin.cpp index c6df7d0e..b8c3f2c3 100644 --- a/components/mobileshell/mobileshellplugin.cpp +++ b/components/mobileshell/mobileshellplugin.cpp @@ -12,6 +12,10 @@ #include "notifications/notificationfilemenu.h" #include "notifications/notificationthumbnailer.h" +#include "homescreen/applicationlistmodel.h" +#include "homescreen/favoritesmodel.h" +#include "homescreen/homescreenutils.h" + #include "mobileshellsettings.h" #include "quicksetting.h" #include "quicksettingsmodel.h" @@ -40,8 +44,20 @@ void MobileShellPlugin::registerTypes(const char *uri) qmlRegisterType(uri, 1, 0, "SavedQuickSettings"); qmlRegisterType(uri, 1, 0, "SavedQuickSettingsModel"); + // taskswitcher qmlRegisterType(uri, 1, 0, "DisplaysModel"); + // homescreen + qmlRegisterSingletonType(uri, 1, 0, "ApplicationListModel", [](QQmlEngine *, QJSEngine *) -> QObject * { + return ApplicationListModel::instance(); + }); + qmlRegisterSingletonType(uri, 1, 0, "FavoritesModel", [](QQmlEngine *, QJSEngine *) -> QObject * { + return FavoritesModel::instance(); + }); + qmlRegisterSingletonType(uri, 1, 0, "HomeScreenUtils", [](QQmlEngine *, QJSEngine *) -> QObject * { + return HomeScreenUtils::instance(); + }); + // notifications qmlRegisterType(uri, 1, 0, "NotificationThumbnailer"); qmlRegisterType(uri, 1, 0, "NotificationFileMenu"); @@ -65,6 +81,9 @@ void MobileShellPlugin::registerTypes(const char *uri) qmlRegisterSingletonType(resolvePath("dataproviders/VolumeProvider.qml"), uri, 1, 0, "VolumeProvider"); qmlRegisterSingletonType(resolvePath("dataproviders/WifiProvider.qml"), uri, 1, 0, "WifiProvider"); + // /homescreen + qmlRegisterType(resolvePath("homescreen/HomeScreen.qml"), uri, 1, 0, "HomeScreen"); + // /navigationpanel qmlRegisterType(resolvePath("navigationpanel/NavigationGestureArea.qml"), uri, 1, 0, "NavigationGestureArea"); qmlRegisterType(resolvePath("navigationpanel/NavigationPanel.qml"), uri, 1, 0, "NavigationPanel"); diff --git a/components/mobileshell/qml/HomeScreenControls.qml b/components/mobileshell/qml/HomeScreenControls.qml index 288608e1..91e69cd6 100644 --- a/components/mobileshell/qml/HomeScreenControls.qml +++ b/components/mobileshell/qml/HomeScreenControls.qml @@ -18,7 +18,6 @@ QtObject { signal openHomeScreen() signal resetHomeScreenPosition() - signal snapHomeScreenPosition() signal requestRelativeScroll(point pos) signal openAppLaunchAnimation(string splashIcon, string title, real x, real y, real sourceIconSize) diff --git a/components/mobileshell/qml/homescreen/HomeScreen.qml b/components/mobileshell/qml/homescreen/HomeScreen.qml new file mode 100644 index 00000000..efac718d --- /dev/null +++ b/components/mobileshell/qml/homescreen/HomeScreen.qml @@ -0,0 +1,156 @@ +/* + * SPDX-FileCopyrightText: 2021 Devin Lin + * SPDX-License-Identifier: LGPL-2.0-or-later + */ + +import QtQuick 2.15 +import QtQuick.Window 2.15 + +import org.kde.plasma.core 2.0 as PlasmaCore +import org.kde.plasma.plasmoid 2.0 +import org.kde.taskmanager 0.1 as TaskManager + +import org.kde.plasma.private.mobileshell 1.0 as MobileShell + +/** + * The base homescreen component, implementing features that simplify + * homescreen implementation. + */ +FocusScope { + id: root + + /** + * Emitted when an action is triggered to open the homescreen. + */ + signal homeTriggered() + + /** + * Emitted when resetting the homescreen position is requested. + */ + signal resetHomeScreenPosition() + + /** + * Emitted when moving the homescreen position is requested. + */ + signal requestRelativeScroll(var pos) + + /** + * The requested opacity of homescreen elements (for opacity animations). + */ + property real homeScreenOpacity: 1 + + /** + * Whether a component is being shown on top of the homescreen within the same + * window. + */ + property bool overlayShown: taskSwitcher.visible || startupFeedback.visible + + NumberAnimation on homeScreenOpacity { + id: opacityAnimation + duration: PlasmaCore.Units.longDuration + } + + //BEGIN API implementation + Connections { + target: MobileShell.HomeScreenControls + + function onOpenHomeScreen() { + MobileShell.HomeScreenControls.resetHomeScreenPosition(); + taskSwitcher.visible = false; // will trigger homescreen open + taskSwitcher.minimizeAll(); + root.homeTriggered(); + } + + function onResetHomeScreenPosition() { + root.resetHomeScreenPosition(); + } + + function onRequestRelativeScroll(pos) { + // TODO + //homescreen.appDrawer.offset -= pos.y; + //lastRequestedPosition = pos.y; + } + + function onOpenAppLaunchAnimation(splashIcon, title, x, y, sourceIconSize) { + startupFeedback.open(splashIcon, title, x, y, sourceIconSize); + } + + function onCloseAppLaunchAnimation() { + startupFeedback.close(); + } + } + + Plasmoid.onScreenChanged: { + if (plasmoid.screen == 0) { + MobileShell.HomeScreenControls.taskSwitcher = taskSwitcher; + MobileShell.HomeScreenControls.homeScreenWindow = root.Window.window; + } + } + Window.onWindowChanged: { + if (plasmoid.screen == 0) { + MobileShell.HomeScreenControls.homeScreenWindow = root.Window.window; + } + } + +//END API implementation + + Component.onCompleted: { + // set API variables + if (plasmoid.screen == 0) { + MobileShell.HomeScreenControls.taskSwitcher = taskSwitcher; + MobileShell.HomeScreenControls.homeScreenWindow = root.Window.window; + } + } + + // task switcher component + TaskManager.VirtualDesktopInfo { + id: virtualDesktopInfo + } + + TaskManager.ActivityInfo { + id: activityInfo + } + + MobileShell.TaskSwitcher { + id: taskSwitcher + z: 999999 + + tasksModel: TaskManager.TasksModel { + groupMode: TaskManager.TasksModel.GroupDisabled + + screenGeometry: plasmoid.screenGeometry + sortMode: TaskManager.TasksModel.SortAlpha + + virtualDesktop: virtualDesktopInfo.currentDesktop + activity: activityInfo.currentActivity + } + + anchors.fill: parent + + // hide homescreen elements to make use of wallpaper + onVisibleChanged: { + if (visible) { + startupFeedback.visible = false; + + // only animate if going from homescreen + if (taskSwitcher.wasInActiveTask) { + opacityAnimation.to = 0; + opacityAnimation.restart(); + } else { + root.homeScreenOpacity = 0; + } + + } else { + opacityAnimation.to = 1; + opacityAnimation.restart(); + } + } + } + + // start app animation component + MobileShell.StartupFeedback { + id: startupFeedback + z: 999999 + anchors.fill: parent + } +} diff --git a/components/mobileshell/resources.qrc b/components/mobileshell/resources.qrc index 358cf20f..f5c485d3 100644 --- a/components/mobileshell/resources.qrc +++ b/components/mobileshell/resources.qrc @@ -31,6 +31,8 @@ qml/dataproviders/VolumeProvider.qml qml/dataproviders/WifiProvider.qml + qml/homescreen/HomeScreen.qml + qml/navigationpanel/NavigationGestureArea.qml qml/navigationpanel/NavigationPanel.qml qml/navigationpanel/NavigationPanelAction.qml diff --git a/containments/homescreen/homescreen.cpp b/containments/homescreen/homescreen.cpp index 983f77be..5688b92e 100644 --- a/containments/homescreen/homescreen.cpp +++ b/containments/homescreen/homescreen.cpp @@ -24,25 +24,6 @@ void HomeScreen::configChanged() Plasma::Containment::configChanged(); } - -void HomeScreen::stackBefore(QQuickItem *item1, QQuickItem *item2) -{ - if (!item1 || !item2 || item1 == item2 || item1->parentItem() != item2->parentItem()) { - return; - } - - item1->stackBefore(item2); -} - -void HomeScreen::stackAfter(QQuickItem *item1, QQuickItem *item2) -{ - if (!item1 || !item2 || item1 == item2 || item1->parentItem() != item2->parentItem()) { - return; - } - - item1->stackAfter(item2); -} - bool HomeScreen::showingDesktop() const { return KWindowSystem::showingDesktop(); diff --git a/containments/homescreen/homescreen.h b/containments/homescreen/homescreen.h index daefa497..be9ee6f6 100644 --- a/containments/homescreen/homescreen.h +++ b/containments/homescreen/homescreen.h @@ -4,15 +4,10 @@ SPDX-License-Identifier: GPL-2.0-or-later */ -#ifndef HOMESCREEN_H -#define HOMESCREEN_H +#pragma once #include -class QQuickItem; -class ApplicationListModel; -class FavoritesModel; - class HomeScreen : public Plasma::Containment { Q_OBJECT @@ -27,17 +22,9 @@ public: bool showingDesktop() const; void setShowingDesktop(bool showingDesktop); - Q_INVOKABLE void stackBefore(QQuickItem *item1, QQuickItem *item2); - Q_INVOKABLE void stackAfter(QQuickItem *item1, QQuickItem *item2); - Q_SIGNALS: void showingDesktopChanged(bool showingDesktop); -protected: - // void configChanged() override; - private: bool m_showAllApps = false; }; - -#endif diff --git a/components/mobilehomescreencomponents/qml/FavoriteStrip.qml b/containments/homescreen/package/contents/ui/FavoriteStrip.qml similarity index 100% rename from components/mobilehomescreencomponents/qml/FavoriteStrip.qml rename to containments/homescreen/package/contents/ui/FavoriteStrip.qml diff --git a/components/mobilehomescreencomponents/qml/FlickContainer.qml b/containments/homescreen/package/contents/ui/FlickContainer.qml similarity index 100% rename from components/mobilehomescreencomponents/qml/FlickContainer.qml rename to containments/homescreen/package/contents/ui/FlickContainer.qml diff --git a/components/mobilehomescreencomponents/qml/HomeDelegate.qml b/containments/homescreen/package/contents/ui/HomeDelegate.qml similarity index 88% rename from components/mobilehomescreencomponents/qml/HomeDelegate.qml rename to containments/homescreen/package/contents/ui/HomeDelegate.qml index 00586c95..b93dcada 100644 --- a/components/mobilehomescreencomponents/qml/HomeDelegate.qml +++ b/containments/homescreen/package/contents/ui/HomeDelegate.qml @@ -16,7 +16,6 @@ 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.mobilehomescreencomponents 0.1 as HomeScreenComponents import "private" as Private @@ -49,9 +48,9 @@ ContainmentLayoutManager.ItemContainer { } if (!MobileShell.HomeScreenControls.taskSwitcherVisible) { - HomeScreenComponents.ApplicationListModel.setMinimizedDelegate(index, delegate); + MobileShell.ApplicationListModel.setMinimizedDelegate(index, delegate); } else { - HomeScreenComponents.ApplicationListModel.unsetMinimizedDelegate(index, delegate); + MobileShell.ApplicationListModel.unsetMinimizedDelegate(index, delegate); } } @@ -96,8 +95,8 @@ ContainmentLayoutManager.ItemContainer { delegate.launch(delegate.x + (PlasmaCore.Units.smallSpacing * 2), delegate.y + (PlasmaCore.Units.smallSpacing * 2), icon.source, modelData.applicationName); } - HomeScreenComponents.ApplicationListModel.setMinimizedDelegate(index, delegate); - HomeScreenComponents.ApplicationListModel.runApplication(modelData.applicationStorageId); + MobileShell.ApplicationListModel.setMinimizedDelegate(index, delegate); + MobileShell.ApplicationListModel.runApplication(modelData.applicationStorageId); } //preventStealing: true @@ -158,9 +157,9 @@ ContainmentLayoutManager.ItemContainer { //FIXME: export smallestReadableFont font.pointSize: PlasmaCore.Theme.defaultFont.pointSize * 0.9 - color: "white"//model.applicationLocation == HomeScreenComponents.ApplicationListModel.Desktop ? "white" : PlasmaCore.Theme.textColor + color: "white"//model.applicationLocation == MobileShell.ApplicationListModel.Desktop ? "white" : PlasmaCore.Theme.textColor - layer.enabled: true//model.applicationLocation == HomeScreenComponents.ApplicationListModel.Desktop + layer.enabled: true//model.applicationLocation == MobileShell.ApplicationListModel.Desktop layer.effect: DropShadow { horizontalOffset: 0 verticalOffset: 2 diff --git a/components/mobilehomescreencomponents/qml/HomeScreen.qml b/containments/homescreen/package/contents/ui/HomeScreen.qml similarity index 93% rename from components/mobilehomescreencomponents/qml/HomeScreen.qml rename to containments/homescreen/package/contents/ui/HomeScreen.qml index a0c549ae..982ae90f 100644 --- a/components/mobilehomescreencomponents/qml/HomeScreen.qml +++ b/containments/homescreen/package/contents/ui/HomeScreen.qml @@ -21,8 +21,6 @@ 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.mobilehomescreencomponents 0.1 as HomeScreenComponents - Item { id: root @@ -68,8 +66,10 @@ Item { // listen to app launch errors Connections { - target: HomeScreenComponents.ApplicationListModel - onLaunchError: MobileShell.HomeScreenControls.closeAppLaunchAnimation() + target: MobileShell.ApplicationListModel + function onLaunchError(msg) { + MobileShell.HomeScreenControls.closeAppLaunchAnimation() + } } // horizontal pages @@ -109,7 +109,7 @@ Item { appletsLayout: contents.appletsLayout visible: favoriteStrip.flow.children.length > 0 || contents.launcherDragManager.active || contents.containsDrag - opacity: contents.launcherDragManager.active && HomeScreenComponents.ApplicationListModel.favoriteCount >= HomeScreenComponents.ApplicationListModel.maxFavoriteCount ? 0.3 : 1 + opacity: contents.launcherDragManager.active && MobileShell.ApplicationListModel.favoriteCount >= MobileShell.ApplicationListModel.maxFavoriteCount ? 0.3 : 1 TapHandler { target: favoriteStrip diff --git a/components/mobilehomescreencomponents/qml/HomeScreenContents.qml b/containments/homescreen/package/contents/ui/HomeScreenContents.qml similarity index 90% rename from components/mobilehomescreencomponents/qml/HomeScreenContents.qml rename to containments/homescreen/package/contents/ui/HomeScreenContents.qml index a67b22e1..3ba2768e 100644 --- a/components/mobilehomescreencomponents/qml/HomeScreenContents.qml +++ b/containments/homescreen/package/contents/ui/HomeScreenContents.qml @@ -18,8 +18,6 @@ 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.mobilehomescreencomponents 0.1 as HomeScreenComponents - import "private" as Private DragDrop.DropArea { @@ -67,7 +65,7 @@ DragDrop.DropArea { onDragMove: { let posInFavorites = favoriteStrip.mapFromItem(this, event.x, event.y); if (posInFavorites.y > 0) { - if (HomeScreenComponents.ApplicationListModel.favoriteCount >= HomeScreenComponents.ApplicationListModel.maxFavoriteCount ) { + if (MobileShell.ApplicationListModel.favoriteCount >= MobileShell.ApplicationListModel.maxFavoriteCount ) { launcherDragManager.hideSpacer(); } else { launcherDragManager.showSpacerAtPos(event.x, event.y, favoriteStrip); @@ -110,12 +108,12 @@ DragDrop.DropArea { let posInFavorites = favoriteStrip.flow.mapFromItem(this, event.x, event.y); if (posInFavorites.y > 0) { - if (HomeScreenComponents.ApplicationListModel.favoriteCount >= HomeScreenComponents.ApplicationListModel.maxFavoriteCount ) { + if (MobileShell.ApplicationListModel.favoriteCount >= MobileShell.ApplicationListModel.maxFavoriteCount ) { return; } - let pos = Math.min(HomeScreenComponents.FavoritesModel.count, Math.floor(posInFavorites.x/favoriteStrip.cellWidth)) - HomeScreenComponents.FavoritesModel.addFavorite(storageId, pos, HomeScreenComponents.ApplicationListModel.Favorites) + let pos = Math.min(MobileShell.FavoritesModel.count, Math.floor(posInFavorites.x/favoriteStrip.cellWidth)) + MobileShell.FavoritesModel.addFavorite(storageId, pos, MobileShell.ApplicationListModel.Favorites) let item = launcherRepeater.itemAt(pos); if (item) { @@ -129,8 +127,8 @@ DragDrop.DropArea { return; } - let pos = HomeScreenComponents.FavoritesModel.count; - HomeScreenComponents.FavoritesModel.addFavorite(storageId, pos, HomeScreenComponents.ApplicationListModel.Desktop) + let pos = MobileShell.FavoritesModel.count; + MobileShell.FavoritesModel.addFavorite(storageId, pos, MobileShell.ApplicationListModel.Desktop) let item = launcherRepeater.itemAt(pos); event.accept(event.proposedAction); diff --git a/components/mobilehomescreencomponents/qml/HomeScreenPages.qml b/containments/homescreen/package/contents/ui/HomeScreenPages.qml similarity index 98% rename from components/mobilehomescreencomponents/qml/HomeScreenPages.qml rename to containments/homescreen/package/contents/ui/HomeScreenPages.qml index 62ef93b0..bba94ef7 100644 --- a/components/mobilehomescreencomponents/qml/HomeScreenPages.qml +++ b/containments/homescreen/package/contents/ui/HomeScreenPages.qml @@ -20,8 +20,6 @@ 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.mobilehomescreencomponents 0.1 as HomeScreenComponents - Flickable { id: mainFlickable diff --git a/components/mobilehomescreencomponents/qml/HomeScreenState.qml b/containments/homescreen/package/contents/ui/HomeScreenState.qml similarity index 100% rename from components/mobilehomescreencomponents/qml/HomeScreenState.qml rename to containments/homescreen/package/contents/ui/HomeScreenState.qml diff --git a/components/mobilehomescreencomponents/qml/LauncherContainer.qml b/containments/homescreen/package/contents/ui/LauncherContainer.qml similarity index 100% rename from components/mobilehomescreencomponents/qml/LauncherContainer.qml rename to containments/homescreen/package/contents/ui/LauncherContainer.qml diff --git a/components/mobilehomescreencomponents/qml/LauncherDragManager.qml b/containments/homescreen/package/contents/ui/LauncherDragManager.qml similarity index 88% rename from components/mobilehomescreencomponents/qml/LauncherDragManager.qml rename to containments/homescreen/package/contents/ui/LauncherDragManager.qml index 77fbab1a..968e9c05 100644 --- a/components/mobilehomescreencomponents/qml/LauncherDragManager.qml +++ b/containments/homescreen/package/contents/ui/LauncherDragManager.qml @@ -7,8 +7,7 @@ import QtQuick 2.4 import org.kde.plasma.private.containmentlayoutmanager 1.0 as ContainmentLayoutManager -import org.kde.plasma.private.mobilehomescreencomponents 0.1 as HomeScreenComponents - +import org.kde.plasma.private.mobileshell 1.0 as MobileShell Item { id: root @@ -17,7 +16,7 @@ Item { property FavoriteStrip favoriteStrip property ContainmentLayoutManager.ItemContainer currentlyDraggedDelegate property bool active - property QtObject model: HomeScreenComponents.ApplicationListModel + property QtObject model: MobileShell.ApplicationListModel readonly property Item spacer: Item { width: favoriteStrip.cellWidth @@ -42,7 +41,7 @@ Item { var pos = favoriteStrip.flow.mapFromItem(delegate, 0, 0); newRow = Math.floor((pos.x + dragCenterX) / delegate.width); - //root.model.setLocation(delegate.modelData.index, HomeScreenComponents.ApplicationListModel.Favorites); + //root.model.setLocation(delegate.modelData.index, MobileShell.ApplicationListModel.Favorites); showSpacer(delegate, dragCenterX, dragCenterY); root.model.moveItem(delegate.modelData.index, newRow); @@ -50,7 +49,7 @@ Item { // Put it on desktop } else { var pos = appletsLayout.mapFromItem(delegate, 0, 0); - //root.model.setLocation(delegate.modelData.index, HomeScreenComponents.ApplicationListModel.Desktop); + //root.model.setLocation(delegate.modelData.index, MobileShell.ApplicationListModel.Desktop); showSpacer(delegate, dragCenterX, dragCenterY); return; @@ -94,9 +93,9 @@ Item { var pos = container.flow.mapFromItem(item, dragCenterX, dragCenterY); if (pos.x < child.x + child.width / 2) { - HomeScreenComponents.HomeScreenUtils.stackBefore(spacer, child); + MobileShell.HomeScreenUtils.stackBefore(spacer, child); } else { - HomeScreenComponents.HomeScreenUtils.stackAfter(spacer, child); + MobileShell.HomeScreenUtils.stackAfter(spacer, child); } internal.putItemInDragSpace(item); @@ -130,9 +129,9 @@ Item { spacer.parent = container.flow if (pos.x < child.x + child.width / 2) { - HomeScreenComponents.HomeScreenUtils.stackBefore(spacer, child); + MobileShell.HomeScreenUtils.stackBefore(spacer, child); } else { - HomeScreenComponents.HomeScreenUtils.stackAfter(spacer, child); + MobileShell.HomeScreenUtils.stackAfter(spacer, child); } spacer.visible = true; @@ -163,7 +162,7 @@ Item { if (!item.modelData) { return appletsLayout; } else if (favoriteStrip.contains(Qt.point(0,favoriteStrip.frame.mapFromItem(item, dragCenterX, dragCenterY).y)) - && (item.modelData.applicationLocation == HomeScreenComponents.ApplicationListModel.Favorites + && (item.modelData.applicationLocation == MobileShell.ApplicationListModel.Favorites || root.model.favoriteCount < root.model.maxFavoriteCount)) { return favoriteStrip; } else { @@ -278,7 +277,7 @@ Item { if (container == appletsLayout) { if (item.modelData) { - root.model.setLocation(item.modelData.index, HomeScreenComponents.ApplicationListModel.Desktop); + root.model.setLocation(item.modelData.index, MobileShell.ApplicationListModel.Desktop); } var pos = appletsLayout.mapFromItem(item, 0, 0); item.parent = appletsLayout; @@ -289,15 +288,15 @@ Item { return; } else if (container == favoriteStrip) { - root.model.setLocation(item.modelData.index, HomeScreenComponents.ApplicationListModel.Favorites); + root.model.setLocation(item.modelData.index, MobileShell.ApplicationListModel.Favorites); } else { - root.model.setLocation(item.modelData.index, HomeScreenComponents.ApplicationListModel.Grid); + root.model.setLocation(item.modelData.index, MobileShell.ApplicationListModel.Grid); } var child = nearestChild(item, dragCenterX, dragCenterY, container); putInContainerLayout(item, container); - HomeScreenComponents.HomeScreenUtils.stackBefore(item, spacer); + MobileShell.HomeScreenUtils.stackBefore(item, spacer); spacer.visible = false; spacer.parent = root; } diff --git a/components/mobilehomescreencomponents/qml/LauncherRepeater.qml b/containments/homescreen/package/contents/ui/LauncherRepeater.qml similarity index 86% rename from components/mobilehomescreencomponents/qml/LauncherRepeater.qml rename to containments/homescreen/package/contents/ui/LauncherRepeater.qml index dc622c1c..1ba2a7ee 100644 --- a/components/mobilehomescreencomponents/qml/LauncherRepeater.qml +++ b/containments/homescreen/package/contents/ui/LauncherRepeater.qml @@ -17,11 +17,10 @@ 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.nanoshell 2.0 as NanoShell import org.kde.kirigami 2.14 as Kirigami -import org.kde.plasma.private.mobilehomescreencomponents 0.1 as HomeScreenComponents Repeater { id: launcherRepeater - model: HomeScreenComponents.FavoritesModel + model: MobileShell.FavoritesModel required property var homeScreenState @@ -52,15 +51,15 @@ Repeater { reservedSpaceForLabel: metrics.height property Item parentFromLocation: { switch (model.applicationLocation) { - case HomeScreenComponents.ApplicationListModel.Favorites: + case MobileShell.ApplicationListModel.Favorites: return favoriteStrip.flow; - case HomeScreenComponents.ApplicationListModel.Desktop: + case MobileShell.ApplicationListModel.Desktop: default: return appletsLayout; } } Component.onCompleted: { - if (model.applicationLocation === HomeScreenComponents.ApplicationListModel.Desktop) { + if (model.applicationLocation === MobileShell.ApplicationListModel.Desktop) { appletsLayout.restoreItem(delegate); } } @@ -117,11 +116,11 @@ Repeater { onParentFromLocationChanged: { if (!launcherDragManager.active && parent != parentFromLocation) { parent = parentFromLocation; - if (model.applicationLocation === HomeScreenComponents.ApplicationListModel.Favorites) { + if (model.applicationLocation === MobileShell.ApplicationListModel.Favorites) { plasmoid.nativeInterface.stackBefore(delegate, parentFromLocation.children[index]); - } else if (model.applicationLocation === HomeScreenComponents.ApplicationListModel.Grid) { - plasmoid.nativeInterface.stackBefore(delegate, parentFromLocation.children[Math.max(0, index - HomeScreenComponents.ApplicationListModel.favoriteCount)]); + } else if (model.applicationLocation === MobileShell.ApplicationListModel.Grid) { + plasmoid.nativeInterface.stackBefore(delegate, parentFromLocation.children[Math.max(0, index - MobileShell.ApplicationListModel.favoriteCount)]); } } } diff --git a/components/mobilehomescreencomponents/qml/MobileAppletContainer.qml b/containments/homescreen/package/contents/ui/MobileAppletContainer.qml similarity index 100% rename from components/mobilehomescreencomponents/qml/MobileAppletContainer.qml rename to containments/homescreen/package/contents/ui/MobileAppletContainer.qml diff --git a/components/mobilehomescreencomponents/qml/appdrawer/AbstractAppDrawer.qml b/containments/homescreen/package/contents/ui/appdrawer/AbstractAppDrawer.qml similarity index 98% rename from components/mobilehomescreencomponents/qml/appdrawer/AbstractAppDrawer.qml rename to containments/homescreen/package/contents/ui/appdrawer/AbstractAppDrawer.qml index 548b0fcf..98fdd70c 100644 --- a/components/mobilehomescreencomponents/qml/appdrawer/AbstractAppDrawer.qml +++ b/containments/homescreen/package/contents/ui/appdrawer/AbstractAppDrawer.qml @@ -18,8 +18,6 @@ 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.mobilehomescreencomponents 0.1 as HomeScreenComponents - import "../private" import "../" diff --git a/components/mobilehomescreencomponents/qml/appdrawer/AppDrawerHeader.qml b/containments/homescreen/package/contents/ui/appdrawer/AppDrawerHeader.qml similarity index 100% rename from components/mobilehomescreencomponents/qml/appdrawer/AppDrawerHeader.qml rename to containments/homescreen/package/contents/ui/appdrawer/AppDrawerHeader.qml diff --git a/components/mobilehomescreencomponents/qml/appdrawer/AppDrawerLoader.qml b/containments/homescreen/package/contents/ui/appdrawer/AppDrawerLoader.qml similarity index 96% rename from components/mobilehomescreencomponents/qml/appdrawer/AppDrawerLoader.qml rename to containments/homescreen/package/contents/ui/appdrawer/AppDrawerLoader.qml index c1a1a383..85a8ae93 100644 --- a/components/mobilehomescreencomponents/qml/appdrawer/AppDrawerLoader.qml +++ b/containments/homescreen/package/contents/ui/appdrawer/AppDrawerLoader.qml @@ -13,7 +13,6 @@ import org.kde.plasma.plasmoid 2.0 import org.kde.plasma.core 2.0 as PlasmaCore import org.kde.plasma.components 3.0 as PlasmaComponents -import org.kde.plasma.private.mobilehomescreencomponents 0.1 as HomeScreenComponents import org.kde.plasma.private.mobileshell 1.0 as MobileShell Loader { diff --git a/components/mobilehomescreencomponents/qml/appdrawer/DrawerGridDelegate.qml b/containments/homescreen/package/contents/ui/appdrawer/DrawerGridDelegate.qml similarity index 100% rename from components/mobilehomescreencomponents/qml/appdrawer/DrawerGridDelegate.qml rename to containments/homescreen/package/contents/ui/appdrawer/DrawerGridDelegate.qml diff --git a/components/mobilehomescreencomponents/qml/appdrawer/DrawerListDelegate.qml b/containments/homescreen/package/contents/ui/appdrawer/DrawerListDelegate.qml similarity index 100% rename from components/mobilehomescreencomponents/qml/appdrawer/DrawerListDelegate.qml rename to containments/homescreen/package/contents/ui/appdrawer/DrawerListDelegate.qml diff --git a/components/mobilehomescreencomponents/qml/appdrawer/GridViewAppDrawer.qml b/containments/homescreen/package/contents/ui/appdrawer/GridViewAppDrawer.qml similarity index 90% rename from components/mobilehomescreencomponents/qml/appdrawer/GridViewAppDrawer.qml rename to containments/homescreen/package/contents/ui/appdrawer/GridViewAppDrawer.qml index 93097c97..52dc81a4 100644 --- a/components/mobilehomescreencomponents/qml/appdrawer/GridViewAppDrawer.qml +++ b/containments/homescreen/package/contents/ui/appdrawer/GridViewAppDrawer.qml @@ -18,8 +18,6 @@ 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.mobilehomescreencomponents 0.1 as HomeScreenComponents - import "../private" AbstractAppDrawer { @@ -38,7 +36,7 @@ AbstractAppDrawer { cacheBuffer: Math.max(0, rows * cellHeight) - model: HomeScreenComponents.ApplicationListModel + model: MobileShell.ApplicationListModel delegate: DrawerGridDelegate { id: delegate @@ -68,8 +66,8 @@ AbstractAppDrawer { Math.min(delegate.iconItem.width, delegate.iconItem.height)); } - HomeScreenComponents.ApplicationListModel.setMinimizedDelegate(index, delegate); - HomeScreenComponents.ApplicationListModel.runApplication(storageId); + MobileShell.ApplicationListModel.setMinimizedDelegate(index, delegate); + MobileShell.ApplicationListModel.runApplication(storageId); root.launched(); } } diff --git a/components/mobilehomescreencomponents/qml/appdrawer/ListViewAppDrawer.qml b/containments/homescreen/package/contents/ui/appdrawer/ListViewAppDrawer.qml similarity index 89% rename from components/mobilehomescreencomponents/qml/appdrawer/ListViewAppDrawer.qml rename to containments/homescreen/package/contents/ui/appdrawer/ListViewAppDrawer.qml index 4c1d8350..4896f690 100644 --- a/components/mobilehomescreencomponents/qml/appdrawer/ListViewAppDrawer.qml +++ b/containments/homescreen/package/contents/ui/appdrawer/ListViewAppDrawer.qml @@ -18,8 +18,6 @@ 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.mobilehomescreencomponents 0.1 as HomeScreenComponents - import "../private" AbstractAppDrawer { @@ -35,7 +33,7 @@ AbstractAppDrawer { property int delegateHeight: PlasmaCore.Units.gridUnit * 3 - model: HomeScreenComponents.ApplicationListModel + model: MobileShell.ApplicationListModel delegate: DrawerListDelegate { id: delegate @@ -65,8 +63,8 @@ AbstractAppDrawer { Math.min(delegate.iconItem.width, delegate.iconItem.height)); } - HomeScreenComponents.ApplicationListModel.setMinimizedDelegate(index, delegate); - HomeScreenComponents.ApplicationListModel.runApplication(storageId); + MobileShell.ApplicationListModel.setMinimizedDelegate(index, delegate); + MobileShell.ApplicationListModel.runApplication(storageId); root.launched(); } } diff --git a/containments/homescreen/package/contents/ui/main.qml b/containments/homescreen/package/contents/ui/main.qml index 41355401..93662a99 100644 --- a/containments/homescreen/package/contents/ui/main.qml +++ b/containments/homescreen/package/contents/ui/main.qml @@ -9,104 +9,44 @@ import QtQuick 2.15 import QtQuick.Window 2.15 import QtQuick.Layouts 1.1 -import org.kde.taskmanager 0.1 as TaskManager import org.kde.plasma.plasmoid 2.0 import org.kde.plasma.core 2.0 as PlasmaCore import org.kde.plasma.components 3.0 as PlasmaComponents -import org.kde.plasma.private.mobilehomescreencomponents 0.1 as HomeScreenComponents import org.kde.plasma.private.mobileshell 1.0 as MobileShell -FocusScope { +MobileShell.HomeScreen { id: root width: 640 height: 480 -//BEGIN functions - + onResetHomeScreenPosition: { + homescreen.homeScreenState.animateGoToPageIndex(0, PlasmaCore.Units.longDuration); + homescreen.homeScreenState.closeAppDrawer(); + } + + onHomeTriggered: { + searchWidget.close(); + } + + property bool componentComplete: false + function recalculateMaxFavoriteCount() { if (!componentComplete) { return; } - HomeScreenComponents.ApplicationListModel.maxFavoriteCount = Math.max(4, Math.floor(Math.min(width, height) / homescreen.homeScreenContents.favoriteStrip.cellWidth)); - } - - function triggerHomeScreen() { - MobileShell.HomeScreenControls.resetHomeScreenPosition(); - taskSwitcher.visible = false; // will trigger homescreen open - searchWidget.close(); - taskSwitcher.minimizeAll(); + MobileShell.ApplicationListModel.maxFavoriteCount = Math.max(4, Math.floor(Math.min(width, height) / homescreen.homeScreenContents.favoriteStrip.cellWidth)); } -//END functions - -//BEGIN API implementation - Connections { - target: MobileShell.HomeScreenControls - - property real lastRequestedPosition: 0 - - function onOpenHomeScreen() { - root.triggerHomeScreen(); - } - - function onResetHomeScreenPosition() { - homescreen.homeScreenState.animateGoToPageIndex(0, PlasmaCore.Units.longDuration); - homescreen.homeScreenState.closeAppDrawer(); - } - - function onSnapHomeScreenPosition() { - if (lastRequestedPosition < 0) { - homescreen.homeScreenState.openAppDrawer(); - } else { - homescreen.homeScreenState.closeAppDrawer(); - } - } - - function onRequestRelativeScroll(pos) { - // TODO - //homescreen.appDrawer.offset -= pos.y; - //lastRequestedPosition = pos.y; - } - - function onOpenAppLaunchAnimation(splashIcon, title, x, y, sourceIconSize) { - startupFeedback.open(splashIcon, title, x, y, sourceIconSize); - } - - function onCloseAppLaunchAnimation() { - startupFeedback.close(); - } - } - - Plasmoid.onScreenChanged: { - if (plasmoid.screen == 0) { - MobileShell.HomeScreenControls.taskSwitcher = taskSwitcher; - MobileShell.HomeScreenControls.homeScreenWindow = root.Window.window; - } - } - Window.onWindowChanged: { - if (plasmoid.screen == 0) { - MobileShell.HomeScreenControls.homeScreenWindow = root.Window.window; - } - } - -//END API implementation - - property bool componentComplete: false onWidthChanged: recalculateMaxFavoriteCount() onHeightChanged: recalculateMaxFavoriteCount() Component.onCompleted: { // ApplicationListModel doesn't have a plasmoid as is not the one that should be doing writing - HomeScreenComponents.ApplicationListModel.loadApplications(); - HomeScreenComponents.FavoritesModel.applet = plasmoid; - HomeScreenComponents.FavoritesModel.loadApplications(); + MobileShell.ApplicationListModel.loadApplications(); + MobileShell.FavoritesModel.applet = plasmoid; + MobileShell.FavoritesModel.loadApplications(); - // set API variables - if (plasmoid.screen == 0) { - MobileShell.HomeScreenControls.taskSwitcher = taskSwitcher; - MobileShell.HomeScreenControls.homeScreenWindow = root.Window.window; - } componentComplete = true; recalculateMaxFavoriteCount() @@ -131,21 +71,14 @@ FocusScope { } } - // control the opacity of both the search and homescreen components - property real homeScreenOpacity: 1 - NumberAnimation on homeScreenOpacity { - id: opacityAnimation - duration: PlasmaCore.Units.longDuration - } - // homescreen component - HomeScreenComponents.HomeScreen { + HomeScreen { id: homescreen anchors.fill: parent opacity: root.homeScreenOpacity * (1 - searchWidget.openFactor) // make the homescreen not interactable when task switcher or startup feedback is on - interactive: !taskSwitcher.visible && !startupFeedback.visible + interactive: !root.overlayShown } // search component @@ -170,56 +103,5 @@ FocusScope { searchWidget.updateGestureOffset(-offset); } } - - // task switcher component - - TaskManager.VirtualDesktopInfo { - id: virtualDesktopInfo - } - - TaskManager.ActivityInfo { - id: activityInfo - } - - MobileShell.TaskSwitcher { - id: taskSwitcher - - tasksModel: TaskManager.TasksModel { - groupMode: TaskManager.TasksModel.GroupDisabled - - screenGeometry: plasmoid.screenGeometry - sortMode: TaskManager.TasksModel.SortAlpha - - virtualDesktop: virtualDesktopInfo.currentDesktop - activity: activityInfo.currentActivity - } - - anchors.fill: parent - - // hide homescreen elements to make use of wallpaper - onVisibleChanged: { - if (visible) { - startupFeedback.visible = false; - - // only animate if going from homescreen - if (taskSwitcher.wasInActiveTask) { - opacityAnimation.to = 0; - opacityAnimation.restart(); - } else { - root.homeScreenOpacity = 0; - } - - } else { - opacityAnimation.to = 1; - opacityAnimation.restart(); - } - } - } - - // start app animation component - MobileShell.StartupFeedback { - id: startupFeedback - anchors.fill: parent - } } diff --git a/components/mobilehomescreencomponents/qml/private/ActionButton.qml b/containments/homescreen/package/contents/ui/private/ActionButton.qml similarity index 100% rename from components/mobilehomescreencomponents/qml/private/ActionButton.qml rename to containments/homescreen/package/contents/ui/private/ActionButton.qml diff --git a/components/mobilehomescreencomponents/qml/private/ConfigOverlay.qml b/containments/homescreen/package/contents/ui/private/ConfigOverlay.qml similarity index 100% rename from components/mobilehomescreencomponents/qml/private/ConfigOverlay.qml rename to containments/homescreen/package/contents/ui/private/ConfigOverlay.qml diff --git a/components/mobilehomescreencomponents/qml/private/DelegateRemoveButton.qml b/containments/homescreen/package/contents/ui/private/DelegateRemoveButton.qml similarity index 92% rename from components/mobilehomescreencomponents/qml/private/DelegateRemoveButton.qml rename to containments/homescreen/package/contents/ui/private/DelegateRemoveButton.qml index 4c238eee..9d9484ac 100644 --- a/components/mobilehomescreencomponents/qml/private/DelegateRemoveButton.qml +++ b/containments/homescreen/package/contents/ui/private/DelegateRemoveButton.qml @@ -16,7 +16,6 @@ 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.mobilehomescreencomponents 0.1 as HomeScreenComponents PC3.RoundButton { id: removeButton @@ -56,7 +55,7 @@ PC3.RoundButton { ScriptAction { script: { appletsLayout.releaseSpace(delegate); - HomeScreenComponents.FavoritesModel.removeFavorite(index); + MobileShell.FavoritesModel.removeFavorite(index); } } } diff --git a/components/mobilehomescreencomponents/qml/private/GradientBar.qml b/containments/homescreen/package/contents/ui/private/GradientBar.qml similarity index 100% rename from components/mobilehomescreencomponents/qml/private/GradientBar.qml rename to containments/homescreen/package/contents/ui/private/GradientBar.qml diff --git a/components/mobilehomescreencomponents/qml/private/OpenDrawerButton.qml b/containments/homescreen/package/contents/ui/private/OpenDrawerButton.qml similarity index 100% rename from components/mobilehomescreencomponents/qml/private/OpenDrawerButton.qml rename to containments/homescreen/package/contents/ui/private/OpenDrawerButton.qml diff --git a/components/mobilehomescreencomponents/qml/private/ScrollIndicator.qml b/containments/homescreen/package/contents/ui/private/ScrollIndicator.qml similarity index 100% rename from components/mobilehomescreencomponents/qml/private/ScrollIndicator.qml rename to containments/homescreen/package/contents/ui/private/ScrollIndicator.qml