shift-shell/containments/homescreen/homescreen.cpp

68 lines
1.7 KiB
C++
Raw Normal View History

2021-03-01 20:03:25 +00:00
/*
SPDX-FileCopyrightText: 2015 Marco Martin <mart@kde.org>
SPDX-License-Identifier: GPL-2.0-or-later
*/
#include "homescreen.h"
#include "applicationlistmodel.h"
#include "favoritesmodel.h"
#include <QtQml>
#include <QDebug>
2019-09-04 16:39:31 +00:00
#include <QQuickItem>
HomeScreen::HomeScreen(QObject *parent, const QVariantList &args)
: Plasma::Containment(parent, args)
{
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
setHasConfigurationInterface(true);
}
2020-03-20 00:08:59 +00:00
HomeScreen::~HomeScreen() = default;
void HomeScreen::configChanged()
{
Plasma::Containment::configChanged();
if (m_applicationListModel) {
m_applicationListModel->loadSettings();
}
}
ApplicationListModel *HomeScreen::applicationListModel()
{
2019-09-04 16:39:31 +00:00
if (!m_applicationListModel) {
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
}
return m_applicationListModel;
}
2019-09-04 16:39:31 +00:00
void HomeScreen::stackBefore(QQuickItem *item1, QQuickItem *item2)
{
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)
{
if (!item1 || !item2 || item1 == item2 || item1->parentItem() != item2->parentItem()) {
2019-09-04 16:39:31 +00:00
return;
}
item1->stackAfter(item2);
}
K_EXPORT_PLASMA_APPLET_WITH_JSON(homescreen, HomeScreen, "metadata.json")
#include "homescreen.moc"