mirror of
https://invent.kde.org/marcoa/shift-shell.git
synced 2026-04-26 14:23:09 +00:00
homescreen: Collapse library into mobileshell and containment
This commit is contained in:
parent
6047c703b4
commit
2e6c1f837e
43 changed files with 334 additions and 441 deletions
|
|
@ -3,5 +3,4 @@
|
|||
# SPDX-License-Identifier: GPL-2.0-or-later
|
||||
|
||||
add_subdirectory(mmplugin)
|
||||
add_subdirectory(mobilehomescreencomponents)
|
||||
add_subdirectory(mobileshell)
|
||||
|
|
|
|||
|
|
@ -1,30 +0,0 @@
|
|||
# SPDX-FileCopyrightText: 2021 Devin Lin <devin@kde.org>
|
||||
# SPDX-FileCopyrightText: 2021 Marco Martin <mart@kde.org>
|
||||
# SPDX-FileCopyrightText: 2021 Aleix Pol <apol@kde.org>
|
||||
# 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)
|
||||
|
|
@ -1,38 +0,0 @@
|
|||
/*
|
||||
* SPDX-FileCopyrightText: 2019 by Marco Martin <mart@kde.org>
|
||||
*
|
||||
* SPDX-License-Identifier: GPL-2.0-or-later
|
||||
*/
|
||||
|
||||
#include "mobilehomescreencomponentsplugin.h"
|
||||
|
||||
#include <QQmlContext>
|
||||
#include <QQuickItem>
|
||||
|
||||
#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<HomeScreenUtils>(uri, 0, 1, "HomeScreenUtils",
|
||||
[](QQmlEngine *, QJSEngine *) {
|
||||
return new HomeScreenUtils{};
|
||||
});
|
||||
|
||||
qmlRegisterSingletonType<ApplicationListModel>(uri, 0, 1, "ApplicationListModel",
|
||||
[](QQmlEngine *, QJSEngine *) {
|
||||
return new ApplicationListModel{};
|
||||
});
|
||||
|
||||
qmlRegisterSingletonType<FavoritesModel>(uri, 0, 1, "FavoritesModel",
|
||||
[](QQmlEngine *, QJSEngine *) {
|
||||
return new FavoritesModel{};
|
||||
});
|
||||
|
||||
// qmlProtectModule(uri, 1);
|
||||
}
|
||||
|
||||
//#include "moc_mobilehomescreencomponentplugin.cpp"
|
||||
|
|
@ -1,21 +0,0 @@
|
|||
/*
|
||||
* SPDX-FileCopyrightText: 2019 by Marco Martin <mart@kde.org>
|
||||
*
|
||||
* SPDX-License-Identifier: GPL-2.0-or-later
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <QUrl>
|
||||
|
||||
#include <QQmlEngine>
|
||||
#include <QQmlExtensionPlugin>
|
||||
|
||||
class MobileHomeScreenComponentsPlugin : public QQmlExtensionPlugin
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QQmlExtensionInterface")
|
||||
|
||||
public:
|
||||
void registerTypes(const char *uri) override;
|
||||
};
|
||||
|
|
@ -1,28 +0,0 @@
|
|||
# SPDX-FileCopyrightText: 2021 Devin Lin <devin@kde.org>
|
||||
# SPDX-FileCopyrightText: 2021 Marco Martin <mart@kde.org>
|
||||
# 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
|
||||
|
|
@ -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
|
||||
)
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
/*
|
||||
* SPDX-FileCopyrightText: 2014 Antonis Tsiapaliokas <antonis.tsiapaliokas@kde.org>
|
||||
* SPDX-FileCopyrightText: 2022 Devin Lin <devin@kde.org>
|
||||
*
|
||||
* SPDX-License-Identifier: GPL-2.0-or-later
|
||||
*/
|
||||
|
|
@ -9,9 +10,9 @@
|
|||
|
||||
// Qt
|
||||
#include <QByteArray>
|
||||
#include <QDebug>
|
||||
#include <QModelIndex>
|
||||
#include <QProcess>
|
||||
#include <QDebug>
|
||||
#include <QQuickItem>
|
||||
#include <QQuickWindow>
|
||||
|
||||
|
|
@ -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<const QStringList &>(&KSycoca::databaseChanged),
|
||||
this, &ApplicationListModel::sycocaDbChanged);
|
||||
connect(KSycoca::self(), qOverload<const QStringList &>(&KSycoca::databaseChanged), this, &ApplicationListModel::sycocaDbChanged);
|
||||
|
||||
loadSettings();
|
||||
initWayland();
|
||||
|
|
@ -67,22 +67,20 @@ void ApplicationListModel::loadSettings()
|
|||
++i;
|
||||
}
|
||||
|
||||
//loadApplications();
|
||||
// loadApplications();
|
||||
}
|
||||
|
||||
QHash<int, QByteArray> 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<int> >("QVector<int>");
|
||||
connect(registry, &Registry::plasmaWindowManagementAnnounced, this, [this, registry](quint32 name, quint32 version) {
|
||||
m_windowManagement = registry->createPlasmaWindowManagement(name, version, this);
|
||||
qRegisterMetaType<QVector<int>>("QVector<int>");
|
||||
|
||||
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"
|
||||
|
||||
|
|
@ -1,16 +1,16 @@
|
|||
/*
|
||||
* SPDX-FileCopyrightText: 2014 Antonis Tsiapaliokas <antonis.tsiapaliokas@kde.org>
|
||||
* SPDX-FileCopyrightText: 2022 Devin Lin <devin@kde.org>
|
||||
*
|
||||
* SPDX-License-Identifier: GPL-2.0-or-later
|
||||
*/
|
||||
|
||||
#ifndef APPLICATIONLISTMODEL_H
|
||||
#define APPLICATIONLISTMODEL_H
|
||||
#pragma once
|
||||
|
||||
// Qt
|
||||
#include <QObject>
|
||||
#include <QAbstractListModel>
|
||||
#include <QList>
|
||||
#include <QObject>
|
||||
#include <QSet>
|
||||
|
||||
#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<QString> m_desktopItems;
|
||||
QHash<QString, int> m_appPositions;
|
||||
};
|
||||
|
||||
#endif // APPLICATIONLISTMODEL_H
|
||||
|
|
@ -9,8 +9,8 @@
|
|||
|
||||
// Qt
|
||||
#include <QByteArray>
|
||||
#include <QModelIndex>
|
||||
#include <QDebug>
|
||||
#include <QModelIndex>
|
||||
|
||||
// KDE
|
||||
#include <KService>
|
||||
|
|
@ -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"
|
||||
|
||||
|
|
@ -7,13 +7,13 @@
|
|||
#pragma once
|
||||
|
||||
// Qt
|
||||
#include <QObject>
|
||||
#include <QAbstractListModel>
|
||||
#include <QList>
|
||||
#include <QObject>
|
||||
#include <QSet>
|
||||
|
||||
#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;
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
|
@ -6,14 +6,13 @@
|
|||
#include "homescreenutils.h"
|
||||
#include "favoritesmodel.h"
|
||||
|
||||
#include <QtQml>
|
||||
#include <QDebug>
|
||||
#include <QQuickItem>
|
||||
#include <QtQml>
|
||||
|
||||
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"
|
||||
|
|
@ -6,7 +6,6 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
|
||||
#include <QObject>
|
||||
|
||||
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;
|
||||
};
|
||||
|
||||
|
|
@ -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<SavedQuickSettings>(uri, 1, 0, "SavedQuickSettings");
|
||||
qmlRegisterType<SavedQuickSettingsModel>(uri, 1, 0, "SavedQuickSettingsModel");
|
||||
|
||||
// taskswitcher
|
||||
qmlRegisterType<DisplaysModel>(uri, 1, 0, "DisplaysModel");
|
||||
|
||||
// homescreen
|
||||
qmlRegisterSingletonType<ApplicationListModel>(uri, 1, 0, "ApplicationListModel", [](QQmlEngine *, QJSEngine *) -> QObject * {
|
||||
return ApplicationListModel::instance();
|
||||
});
|
||||
qmlRegisterSingletonType<FavoritesModel>(uri, 1, 0, "FavoritesModel", [](QQmlEngine *, QJSEngine *) -> QObject * {
|
||||
return FavoritesModel::instance();
|
||||
});
|
||||
qmlRegisterSingletonType<HomeScreenUtils>(uri, 1, 0, "HomeScreenUtils", [](QQmlEngine *, QJSEngine *) -> QObject * {
|
||||
return HomeScreenUtils::instance();
|
||||
});
|
||||
|
||||
// notifications
|
||||
qmlRegisterType<NotificationThumbnailer>(uri, 1, 0, "NotificationThumbnailer");
|
||||
qmlRegisterType<NotificationFileMenu>(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");
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
156
components/mobileshell/qml/homescreen/HomeScreen.qml
Normal file
156
components/mobileshell/qml/homescreen/HomeScreen.qml
Normal file
|
|
@ -0,0 +1,156 @@
|
|||
/*
|
||||
* SPDX-FileCopyrightText: 2021 Devin Lin <devin@kde.org>
|
||||
* 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
|
||||
}
|
||||
}
|
||||
|
|
@ -31,6 +31,8 @@
|
|||
<file>qml/dataproviders/VolumeProvider.qml</file>
|
||||
<file>qml/dataproviders/WifiProvider.qml</file>
|
||||
|
||||
<file>qml/homescreen/HomeScreen.qml</file>
|
||||
|
||||
<file>qml/navigationpanel/NavigationGestureArea.qml</file>
|
||||
<file>qml/navigationpanel/NavigationPanel.qml</file>
|
||||
<file>qml/navigationpanel/NavigationPanelAction.qml</file>
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
|
|
|
|||
|
|
@ -4,15 +4,10 @@
|
|||
SPDX-License-Identifier: GPL-2.0-or-later
|
||||
*/
|
||||
|
||||
#ifndef HOMESCREEN_H
|
||||
#define HOMESCREEN_H
|
||||
#pragma once
|
||||
|
||||
#include <Plasma/Containment>
|
||||
|
||||
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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
@ -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
|
||||
|
|
@ -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);
|
||||
|
|
@ -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
|
||||
|
||||
|
|
@ -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;
|
||||
}
|
||||
|
|
@ -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)]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -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 "../"
|
||||
|
||||
|
|
@ -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 {
|
||||
|
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
|
@ -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
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Reference in a new issue