Commit a02e7a1d authored by Marco Martin's avatar Marco Martin
Browse files

make the C++ part an applet plugin, not a qml one

parent 84ecedca
......@@ -25,36 +25,15 @@ import org.kde.plasma.core 2.0 as PlasmaCore
import org.kde.plasma.components 3.0 as PlasmaComponents
PlasmaComponents.Button {
AbstractIndicator {
id: button
Layout.fillHeight: true
Layout.preferredWidth: height
leftPadding: 0
topPadding: 0
rightPadding: 0
bottomPadding: 0
icon.name: "system-shutdown"
background: PlasmaCore.FrameSvgItem {
id: frame
imagePath: "widgets/viewitem"
prefix: "hover"
visible: button.activeFocus
}
contentItem: PlasmaCore.IconItem {
source: "system-shutdown"
colorGroup: PlasmaCore.ColorScope.colorGroup
Layout.fillHeight: true
Layout.preferredWidth: height
PlasmaCore.DataSource {
id: dataEngine
engine: "powermanagement"
connectedSources: ["PowerDevil"]
}
PlasmaCore.DataSource {
id: dataEngine
engine: "powermanagement"
connectedSources: ["PowerDevil"]
}
onClicked: {
......@@ -62,7 +41,4 @@ PlasmaComponents.Button {
var operation = service.operationDescription("requestShutDown");
service.startOperationCall(operation);
}
Keys.onReturnPressed: {
clicked();
}
}
......@@ -25,14 +25,10 @@ import org.kde.plasma.core 2.0 as PlasmaCore
import org.kde.plasma.components 2.0 as PlasmaComponents
import org.kde.plasma.networkmanagement 0.2 as PlasmaNM
PlasmaCore.IconItem {
AbstractIndicator {
id: connectionIcon
source: connectionIconProvider.connectionIcon
colorGroup: PlasmaCore.ColorScope.colorGroup
Layout.fillHeight: true
Layout.preferredWidth: height
icon.name: connectionIconProvider.connectionIcon
PlasmaComponents.BusyIndicator {
id: connectingIndicator
......@@ -49,4 +45,7 @@ PlasmaCore.IconItem {
PlasmaNM.ConnectionIcon {
id: connectionIconProvider
}
onClicked: {
plasmoid.nativeInterface.executeCommand("plasma-settings -m kcm_mobile_wifi")
}
}
......@@ -52,7 +52,7 @@ FocusScope {
Views.TileView {
id: gridView
model: root.voiceAppsModel
model: plasmoid.nativeInterface.voiceAppListModel
currentIndex: 0
focus: true
delegate: Delegates.VoiceAppDelegate {
......@@ -60,7 +60,7 @@ FocusScope {
}
navigationUp: shutdownButton
navigationUp: shutdownIndicator
navigationDown: gridView2
}
......@@ -71,7 +71,7 @@ FocusScope {
Views.TileView {
id: gridView2
model: root.appsModel
model: plasmoid.nativeInterface.applicationListModel
currentIndex: 0
focus: false
delegate: Delegates.AppDelegate {
......
......@@ -33,8 +33,6 @@ FocusScope {
id: root
readonly property int reservedSpaceForLabel: metrics.height
property var appsModel: applicationListModel
property var voiceAppsModel: voiceAppListModel
signal activateAppView
signal activateTopNavBar
signal activateSettingsView
......@@ -48,23 +46,15 @@ FocusScope {
return null;
}
Launcher.ApplicationListModel {
id: applicationListModel
}
Launcher.VoiceAppListModel {
id: voiceAppListModel
}
Component.onCompleted: {
root.forceActiveFocus();
applicationListModel.loadApplications();
voiceAppListModel.loadApplications();
plasmoid.nativeInterface.applicationListModel.loadApplications();
plasmoid.nativeInterface.voiceAppListModel.loadApplications();
root.activateAppView();
}
Connections {
target: applicationListModel
target: plasmoid.applicationListModel
onAppOrderChanged: {
root.activateAppView()
}
......
......@@ -108,15 +108,22 @@ Item {
margins: units.smallSpacing
}
Indicators.Wifi {
id: wifiIndicator
Layout.fillHeight: true
implicitWidth: height
KeyNavigation.down: launcher
KeyNavigation.right: shutdownIndicator
KeyNavigation.tab: shutdownIndicator
KeyNavigation.backtab: launcher
KeyNavigation.left: launcher
}
Indicators.Shutdown {
id: shutdownButton
id: shutdownIndicator
KeyNavigation.down: launcher
KeyNavigation.right: launcher
KeyNavigation.tab: launcher
KeyNavigation.backtab: launcher
KeyNavigation.backtab: wifiIndicator
KeyNavigation.left: wifiIndicator
}
}
......
......@@ -8,6 +8,7 @@ X-KDE-ParentApp=
X-KDE-PluginInfo-Author=Aditya Mehra
X-KDE-PluginInfo-Email=aix.m@outlook.com
X-KDE-PluginInfo-License=GPL
X-KDE-Library=plasma_containment_biglauncherhomescreen
X-KDE-PluginInfo-Name=org.kde.mycroft.bigscreen.homescreen
X-KDE-PluginInfo-Version=0.1
X-KDE-PluginInfo-Website=plasma.kde.org
......
kde_enable_exceptions()
add_definitions(-DTRANSLATION_DOMAIN=\"biglauncherplugin\")
add_definitions(-DTRANSLATION_DOMAIN=\"biglauncherhomescreen\")
set(biglauncherplugin_SRCS biglauncherplugin.cpp biglauncher_dbus.cpp applicationlistmodel.cpp voiceapplistmodel.cpp)
set(biglauncherhomescreen_SRCS
biglauncherhomescreen.cpp
biglauncher_dbus.cpp
applicationlistmodel.cpp
voiceapplistmodel.cpp)
add_library(biglauncherplugin SHARED ${biglauncherplugin_SRCS})
add_library(plasma_containment_biglauncherhomescreen MODULE ${biglauncherhomescreen_SRCS})
target_link_libraries(biglauncherplugin Qt5::Gui Qt5::Core Qt5::Qml Qt5::DBus Qt5::Network KF5::Plasma KF5::I18n KF5::Notifications KF5::Service KF5::KIOWidgets)
kcoreaddons_desktop_to_json(plasma_containment_biglauncherhomescreen ../package/metadata.desktop)
install(TARGETS biglauncherplugin DESTINATION ${QML_INSTALL_DIR}/org/kde/private/biglauncher)
target_link_libraries(plasma_containment_biglauncherhomescreen Qt5::Gui Qt5::Core Qt5::Qml Qt5::DBus Qt5::Network KF5::Plasma KF5::I18n KF5::Notifications KF5::Service KF5::KIOWidgets)
install(TARGETS plasma_containment_biglauncherhomescreen DESTINATION ${KDE_INSTALL_PLUGINDIR}/plasma/applets)
install(FILES qmldir DESTINATION ${QML_INSTALL_DIR}/org/kde/private/biglauncher)
......@@ -253,6 +253,12 @@ Q_INVOKABLE void ApplicationListModel::moveItem(int row, int destination)
endMoveRows();
}
void ApplicationListModel::executeCommand(const QString &command)
{
qWarning()<<"Executing"<<command;
QProcess::startDetached(command);
}
void ApplicationListModel::runApplication(const QString &storageId)
{
if (storageId.isEmpty()) {
......
......@@ -77,6 +77,8 @@ public:
Q_INVOKABLE void loadApplications();
Q_INVOKABLE void executeCommand(const QString &command);
public Q_SLOTS:
void sycocaDbChanged(const QStringList &change);
......
/***************************************************************************
* Copyright (C) 2019 Marco Martin <mart@kde.org> *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA . *
***************************************************************************/
#include "biglauncherhomescreen.h"
#include "biglauncher_dbus.h"
#include "applicationlistmodel.h"
#include "voiceapplistmodel.h"
#include <QDebug>
#include <QProcess>
#include <QtQml>
HomeScreen::HomeScreen(QObject *parent, const QVariantList &args)
: Plasma::Containment(parent, args)
{
const QByteArray uri("org.kde.private.biglauncher");
qmlRegisterUncreatableType<ApplicationListModel>(uri, 1, 0, "ApplicationListModel", QStringLiteral("Cannot create an item of type ApplicationListModel"));
qmlRegisterUncreatableType<VoiceAppListModel>(uri, 1, 0, "VoiceAppListModel", QStringLiteral("Cannot create an item of type VoiceAppListModel"));
qWarning()<<"££££££££ghjgjg£££££££££££££";
//setHasConfigurationInterface(true);
auto bigLauncherDbusAdapterInterface = new BigLauncherDbusAdapterInterface(this);
m_applicationListModel = new ApplicationListModel(this);
m_voiceAppListModel = new VoiceAppListModel(this);
}
HomeScreen::~HomeScreen()
{}
ApplicationListModel *HomeScreen::applicationListModel() const
{qWarning()<<"$$$$$$$$$$$$$$";
return m_applicationListModel;
}
VoiceAppListModel *HomeScreen::voiceAppListModel() const
{
return m_voiceAppListModel;
}
void HomeScreen::executeCommand(const QString &command)
{
qWarning()<<"Executing"<<command;
QProcess::startDetached(command);
}
K_EXPORT_PLASMA_APPLET_WITH_JSON(homescreen, HomeScreen, "metadata.json")
#include "biglauncherhomescreen.moc"
/***************************************************************************
* Copyright (C) 2015 Marco Martin <mart@kde.org> *
*
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA . *
***************************************************************************/
#pragma once
#include <Plasma/Containment>
class ApplicationListModel;
class VoiceAppListModel;
class HomeScreen : public Plasma::Containment
{
Q_OBJECT
Q_PROPERTY(ApplicationListModel *applicationListModel READ applicationListModel CONSTANT)
Q_PROPERTY(VoiceAppListModel *voiceAppListModel READ voiceAppListModel CONSTANT)
public:
HomeScreen( QObject *parent, const QVariantList &args );
~HomeScreen() override;
ApplicationListModel *applicationListModel() const;
VoiceAppListModel *voiceAppListModel() const;
public Q_SLOTS:
void executeCommand(const QString &command);
private:
ApplicationListModel *m_applicationListModel;
VoiceAppListModel *m_voiceAppListModel;
};
/*
* Copyright (C) 2016 by Aditya Mehra <aix.m@outlook.com> *
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Library General Public License as
* published by the Free Software Foundation; either version 2, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details
*
* You should have received a copy of the GNU Library General Public
* License along with this program; if not, write to the
* Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#include "biglauncherplugin.h"
#include "biglauncher_dbus.h"
#include "applicationlistmodel.h"
#include "voiceapplistmodel.h"
#include <QtQml>
#include <QtDebug>
#include <QtDBus>
void BigLauncherPlugin::registerTypes(const char *uri)
{
Q_ASSERT(uri == QLatin1String("org.kde.private.biglauncher"));
qmlRegisterType<ApplicationListModel>(uri, 1, 0, "ApplicationListModel");
qmlRegisterType<VoiceAppListModel>(uri, 1, 0, "VoiceAppListModel");
}
void BigLauncherPlugin::initializeEngine(QQmlEngine* engine, const char* uri)
{
QQmlExtensionPlugin::initializeEngine(engine, uri);
auto bigLauncherDbusAdapterInterface = new BigLauncherDbusAdapterInterface(engine);
m_applicationListModel = new ApplicationListModel(this);
m_voiceAppListModel = new VoiceAppListModel(this);
engine->rootContext()->setContextProperty("main2", bigLauncherDbusAdapterInterface);
}
ApplicationListModel *BigLauncherPlugin::applicationListModel()
{
return m_applicationListModel;
}
VoiceAppListModel *BigLauncherPlugin::voiceAppListModel()
{
return m_voiceAppListModel;
}
/*
* Copyright (C) 2016 by Aditya Mehra <aix.m@outlook.com> *
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Library General Public License as
* published by the Free Software Foundation; either version 2, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details
*
* You should have received a copy of the GNU Library General Public
* License along with this program; if not, write to the
* Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#ifndef PROTOTYPEPLASMOIDPLUGIN_H
#define PROTOTYPEPLASMOIDPLUGIN_H
#include <QQmlExtensionPlugin>
#include <QDBusAbstractAdaptor>
#include <Plasma/Applet>
class QQmlEngine;
class ApplicationListModel;
class VoiceAppListModel;
class QQuickItem;
class BigLauncherPlugin : public QQmlExtensionPlugin
{
Q_OBJECT
Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QQmlExtensionInterface")
Q_PROPERTY(ApplicationListModel *applicationListModel READ applicationListModel CONSTANT)
Q_PROPERTY(VoiceAppListModel *voiceAppListModel READ voiceAppListModel CONSTANT)
public:
void registerTypes(const char *uri);
void initializeEngine(QQmlEngine *engine, const char *uri) override;
ApplicationListModel *applicationListModel();
VoiceAppListModel *voiceAppListModel();
private:
ApplicationListModel *m_applicationListModel;
VoiceAppListModel *m_voiceAppListModel;
Q_SIGNAL
};
#endif // PROTOTYPEPLASMOIDPLUGIN_H
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment