2021-03-01 20:03:25 +00:00
|
|
|
/*
|
|
|
|
|
SPDX-FileCopyrightText: 2015 Marco Martin <mart@kde.org>
|
|
|
|
|
SPDX-License-Identifier: GPL-2.0-or-later
|
|
|
|
|
*/
|
2015-05-14 16:05:01 +00:00
|
|
|
|
|
|
|
|
#include "homescreen.h"
|
|
|
|
|
#include "applicationlistmodel.h"
|
2021-02-15 10:44:48 +00:00
|
|
|
#include "favoritesmodel.h"
|
2015-05-14 16:05:01 +00:00
|
|
|
|
|
|
|
|
#include <QtQml>
|
|
|
|
|
#include <QDebug>
|
2019-09-04 16:39:31 +00:00
|
|
|
#include <QQuickItem>
|
2015-05-14 16:05:01 +00:00
|
|
|
|
|
|
|
|
HomeScreen::HomeScreen(QObject *parent, const QVariantList &args)
|
|
|
|
|
: Plasma::Containment(parent, args)
|
|
|
|
|
{
|
2021-02-15 10:44:48 +00:00
|
|
|
qmlRegisterType<ApplicationListModel>("org.kde.phone.homescreen", 1, 0, "ApplicationListModel");
|
|
|
|
|
qmlRegisterType<FavoritesModel>("org.kde.phone.homescreen", 1, 0, "FavoritesModel");
|
2019-09-04 16:39:31 +00:00
|
|
|
|
2015-05-14 16:05:01 +00:00
|
|
|
setHasConfigurationInterface(true);
|
|
|
|
|
}
|
|
|
|
|
|
2020-03-20 00:08:59 +00:00
|
|
|
HomeScreen::~HomeScreen() = default;
|
2015-05-14 16:05:01 +00:00
|
|
|
|
2019-09-16 17:13:52 +00:00
|
|
|
void HomeScreen::configChanged()
|
|
|
|
|
{
|
|
|
|
|
Plasma::Containment::configChanged();
|
|
|
|
|
if (m_applicationListModel) {
|
|
|
|
|
m_applicationListModel->loadSettings();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2015-05-14 16:05:01 +00:00
|
|
|
ApplicationListModel *HomeScreen::applicationListModel()
|
|
|
|
|
{
|
2019-09-04 16:39:31 +00:00
|
|
|
if (!m_applicationListModel) {
|
2021-02-15 10:44:48 +00:00
|
|
|
if (m_showAllApps) {
|
|
|
|
|
m_applicationListModel = new ApplicationListModel(this);
|
|
|
|
|
} else {
|
|
|
|
|
m_applicationListModel = new FavoritesModel(this);
|
|
|
|
|
}
|
|
|
|
|
m_applicationListModel->setApplet(this);
|
|
|
|
|
m_applicationListModel->loadApplications();
|
2019-09-04 16:39:31 +00:00
|
|
|
}
|
2015-05-14 16:05:01 +00:00
|
|
|
return m_applicationListModel;
|
|
|
|
|
}
|
|
|
|
|
|
2019-09-04 16:39:31 +00:00
|
|
|
void HomeScreen::stackBefore(QQuickItem *item1, QQuickItem *item2)
|
|
|
|
|
{
|
2019-10-17 11:05:48 +00:00
|
|
|
if (!item1 || !item2 || item1 == item2 || item1->parentItem() != item2->parentItem()) {
|
2019-09-04 16:39:31 +00:00
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
item1->stackBefore(item2);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void HomeScreen::stackAfter(QQuickItem *item1, QQuickItem *item2)
|
|
|
|
|
{
|
2019-10-17 11:05:48 +00:00
|
|
|
if (!item1 || !item2 || item1 == item2 || item1->parentItem() != item2->parentItem()) {
|
2019-09-04 16:39:31 +00:00
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
item1->stackAfter(item2);
|
|
|
|
|
}
|
|
|
|
|
|
2015-05-14 16:05:01 +00:00
|
|
|
K_EXPORT_PLASMA_APPLET_WITH_JSON(homescreen, HomeScreen, "metadata.json")
|
|
|
|
|
|
|
|
|
|
#include "homescreen.moc"
|