File indexing completed on 2024-06-16 05:08:35
0001 /* 0002 SPDX-FileCopyrightText: 2021 Aditya Mehra <aix.m@outlook.com> 0003 SPDX-FileCopyrightText: 2019 Marco Martin <mart@kde.org> 0004 0005 SPDX-License-Identifier: GPL-2.0-or-later 0006 */ 0007 0008 #include "biglauncherhomescreen.h" 0009 #include "applicationlistmodel.h" 0010 #include "kcmslistmodel.h" 0011 0012 #include <QDebug> 0013 #include <QProcess> 0014 #include <QtQml> 0015 0016 #include <sessionmanagement.h> 0017 0018 HomeScreen::HomeScreen(QObject *parent, const KPluginMetaData &data, const QVariantList &args) 0019 : Plasma::Containment(parent, data, args) 0020 , m_session(new SessionManagement(this)) 0021 { 0022 const char *uri = "org.kde.private.biglauncher"; 0023 qmlRegisterUncreatableType<KcmsListModel>(uri, 1, 0, "KcmsListModel", QStringLiteral("KcmsListModel is uncreatable")); 0024 qmlRegisterUncreatableType<ApplicationListModel>(uri, 1, 0, "ApplicationListModel", QStringLiteral("Cannot create an item of type ApplicationListModel")); 0025 qmlRegisterUncreatableType<BigLauncherDbusAdapterInterface>(uri, 0026 1, 0027 0, 0028 "BigLauncherDbusAdapterInterface", 0029 QStringLiteral("Cannot create an item of type BigLauncherDbusAdapterInterface")); 0030 0031 // setHasConfigurationInterface(true); 0032 m_bigLauncherDbusAdapterInterface = new BigLauncherDbusAdapterInterface(this); 0033 m_applicationListModel = new ApplicationListModel(this); 0034 m_kcmsListModel = new KcmsListModel(this); 0035 } 0036 0037 HomeScreen::~HomeScreen() 0038 { 0039 } 0040 0041 KcmsListModel *HomeScreen::kcmsListModel() const 0042 { 0043 return m_kcmsListModel; 0044 } 0045 0046 ApplicationListModel *HomeScreen::applicationListModel() const 0047 { 0048 return m_applicationListModel; 0049 } 0050 0051 BigLauncherDbusAdapterInterface *HomeScreen::bigLauncherDbusAdapterInterface() const 0052 { 0053 return m_bigLauncherDbusAdapterInterface; 0054 } 0055 0056 void HomeScreen::executeCommand(const QString &command) 0057 { 0058 qInfo() << "Executing" << command; 0059 QStringList split = QProcess::splitCommand(command); 0060 QProcess::startDetached(split.takeFirst(), split); 0061 } 0062 0063 void HomeScreen::requestShutdown() 0064 { 0065 if (m_session->state() == SessionManagement::State::Loading) { 0066 connect(m_session, &SessionManagement::stateChanged, this, [this]() { 0067 if (m_session->state() == SessionManagement::State::Ready) { 0068 m_session->requestShutdown(); 0069 disconnect(m_session, nullptr, this, nullptr); 0070 } 0071 }); 0072 } 0073 m_session->requestShutdown(); 0074 } 0075 0076 void HomeScreen::setUseColoredTiles(bool coloredTiles) 0077 { 0078 m_bigLauncherDbusAdapterInterface->setColoredTilesActive(coloredTiles); 0079 } 0080 0081 void HomeScreen::setUseExpandableTiles(bool expandableTiles) 0082 { 0083 m_bigLauncherDbusAdapterInterface->setExpandableTilesActive(expandableTiles); 0084 } 0085 0086 K_PLUGIN_CLASS_WITH_JSON(HomeScreen, "metadata.json") 0087 0088 #include "biglauncherhomescreen.moc" 0089 #include "moc_biglauncherhomescreen.cpp"