diff --git a/CMakeLists.txt b/CMakeLists.txt index 806a62d..9ad3229 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,38 +1,39 @@ # Set minimum CMake version (required for CMake 3.0 or later) cmake_minimum_required(VERSION 2.8.12) set(QT_MIN_VERSION "5.9.0") set(KF5_MIN_VERSION "5.0.0") # Use Extra CMake Modules (ECM) for common functionality. # See http://api.kde.org/ecm/manual/ecm.7.html # and http://api.kde.org/ecm/manual/ecm-kde-modules.7.html find_package(ECM REQUIRED NO_MODULE) set(CMAKE_MODULE_PATH ${ECM_MODULE_PATH} ${ECM_KDE_MODULE_DIR} ${CMAKE_MODULE_PATH}) set(VERSION 2.1.0) include(KDEInstallDirs) include(KDECMakeSettings) include(KDECompilerSettings NO_POLICY_SCOPE) include(ECMInstallIcons) # Locate plasma_install_package macro. find_package(KF5 ${KF5_MIN_VERSION} REQUIRED COMPONENTS Plasma I18n Notifications ) find_package(Qt5 ${QT_MIN_VERSION} CONFIG REQUIRED COMPONENTS Quick Core Qml DBus Network WebSockets ) add_subdirectory(icons) +add_subdirectory(plugin) plasma_install_package(plasmoid org.kde.plasma.mycroftplasmoid) install( DIRECTORY mycroft DESTINATION ${SYSCONF_INSTALL_DIR}) diff --git a/plasmoid/contents/ui/FullRepresentation.qml b/plasmoid/contents/ui/FullRepresentation.qml index 46edf58..6e2ef7e 100644 --- a/plasmoid/contents/ui/FullRepresentation.qml +++ b/plasmoid/contents/ui/FullRepresentation.qml @@ -1,248 +1,256 @@ /* Copyright 2016 Aditya Mehra Copyright 2018 Marco Martin This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) version 3, or any later version accepted by the membership of KDE e.V. (or its successor approved by the membership of KDE e.V.), which shall act as a proxy defined in Section 6 of version 3 of the license. This library 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 Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library. If not, see . */ import QtQuick 2.9 import QtQml.Models 2.2 import QtQuick.Controls 2.2 as Controls import QtQuick.Layouts 1.3 import org.kde.plasma.core 2.0 as PlasmaCore import org.kde.plasma.components 2.0 as PlasmaComponents import org.kde.plasma.extras 2.0 as PlasmaExtras import org.kde.plasma.plasmoid 2.0 import org.kde.kirigami 2.5 as Kirigami +import org.kde.private.mycroftplasmoid 1.0 as MycroftPlasmoid import Mycroft 1.0 as Mycroft Item { id: root implicitWidth: Kirigami.Units.gridUnit * 20 implicitHeight: Kirigami.Units.gridUnit * 32 + property bool cfg_notifications: plasmoid.configuration.notifications function pushMessage(text, inbound) { conversationModel.append({"text": text, "inbound": inbound}); // Limit to 20 items in the histry as ListModel is quite heavy on memory if (conversationModel.count > 20) { conversationModel.remove(0) } mainView.flick(0, -500); } Component.onCompleted: { pushMessage(i18n("How can I help you?"), true); } Item { id: topBar anchors.top: parent.top anchors.left: parent.left anchors.right: parent.right height: Kirigami.Units.gridUnit * 4 ColumnLayout{ anchors.fill: parent TopBarViewComponent { id: topBarView Layout.fillWidth: true Layout.preferredHeight: Kirigami.Units.gridUnit * 2 } PlasmaCore.SvgItem { Layout.fillWidth: true Layout.preferredHeight: horlineSvg.elementSize("horizontal-line").height elementId: "horizontal-line" svg: PlasmaCore.Svg { id: horlineSvg; imagePath: "widgets/line" } } PlasmaComponents.TabBar { id: tabBar visible: true Layout.fillWidth: true Layout.preferredHeight: Kirigami.Units.gridUnit * 1.5 PlasmaComponents.TabButton { id: mycroftTab iconSource: "go-home" text: "Conversation" } PlasmaComponents.TabButton { id: mycroftSkillsTab iconSource: "games-hint" text: "Hints & Tips" } PlasmaComponents.TabButton { id: mycroftMSMinstTab iconSource: "kmouth-phresebook-new" text: "Skill Browser" } } PlasmaCore.SvgItem { Layout.fillWidth: true Layout.preferredHeight: horlineSvg.elementSize("horizontal-line").height elementId: "horizontal-line" svg: PlasmaCore.Svg { id: horlineSvg2; imagePath: "widgets/line" } } } } ColumnLayout { anchors.left: parent.left anchors.right: parent.right anchors.bottom: bottomBar.top anchors.top: topBar.bottom anchors.topMargin: Kirigami.Units.largeSpacing + Kirigami.Units.smallSpacing opacity: Mycroft.MycroftController.status == Mycroft.MycroftController.Open visible: tabBar.currentTab == mycroftTab; Behavior on opacity { OpacityAnimator { duration: Kirigami.Units.longDuration easing.type: Easing.InOutCubic } } Mycroft.SkillView { id: skillView Kirigami.Theme.colorSet: Kirigami.Theme.View Layout.fillWidth: true Layout.fillHeight: true clip: true onCurrentItemChanged: { currentItem.background.visible = false inputField.forceActiveFocus(); } Connections { id: mycroftConnection target: Mycroft.MycroftController onFallbackTextRecieved: { pushMessage(data.utterance, true); + if (!plasmoid.expanded && cfg_notifications == true) { + var post = data.utterance; + var title = "Mycroft's Reply:" + var notiftext = " " + post; + MycroftPlasmoid.Notify.mycroftResponse(title, notiftext); + } } } initialItem: Controls.ScrollView { Kirigami.Theme.colorSet: Kirigami.Theme.View ListView { id: mainView spacing: Kirigami.Units.largeSpacing topMargin: Math.max(0, height - contentHeight - Kirigami.Units.largeSpacing * 3) bottomMargin: Kirigami.Units.largeSpacing //onContentHeightChanged: flick(0, 100); //contentY = contentHeight - height - topMargin + bottomMargin; model: ListModel { id: conversationModel } delegate: ConversationDelegate {} } } } } Item { id: bottomBar anchors.bottom: root.bottom anchors.left: root.left anchors.right: root.right height: Kirigami.Units.gridUnit * 4 BottomBarViewComponent { id: bottomBarView } } ColumnLayout { anchors.centerIn: parent opacity: Mycroft.MycroftController.status != Mycroft.MycroftController.Open Behavior on opacity { OpacityAnimator { duration: Kirigami.Units.longDuration easing.type: Easing.InOutCubic } } Kirigami.Heading { Layout.fillWidth: true text: i18n("Mycroft not connected") wrapMode: Text.WordWrap } Controls.Button { Layout.alignment: Qt.AlignHCenter text: i18n("Connect") onClicked: { Mycroft.MycroftController.start(); } } } ColumnLayout { id: mycroftSkillscolumntab visible: tabBar.currentTab == mycroftSkillsTab; anchors.left: parent.left anchors.right: parent.right anchors.bottom: bottomBar.top anchors.top: topBar.bottom anchors.topMargin: Kirigami.Units.largeSpacing + Kirigami.Units.smallSpacing anchors.bottomMargin: Kirigami.Units.smallSpacing HintsViewComponent { id: hintsView } } ColumnLayout { id: mycroftMsmColumn visible: tabBar.currentTab == mycroftMSMinstTab; anchors.left: parent.left anchors.right: parent.right anchors.bottom: bottomBar.top anchors.top: topBar.bottom anchors.topMargin: Kirigami.Units.largeSpacing + Kirigami.Units.smallSpacing anchors.bottomMargin: Kirigami.Units.smallSpacing SkillsInstallerComponent{ id: skillsInstallerView } } Mycroft.StatusIndicator { anchors.horizontalCenter: parent.horizontalCenter y: skillView.currentItem == skillView.initialItem ? parent.height/2 - height/2 : parent.height - height - Kirigami.Units.largeSpacing } } diff --git a/plugin/CMakeLists.txt b/plugin/CMakeLists.txt new file mode 100644 index 0000000..bfdce4d --- /dev/null +++ b/plugin/CMakeLists.txt @@ -0,0 +1,15 @@ +kde_enable_exceptions() + +add_definitions(-DTRANSLATION_DOMAIN=\"mycroftplasmoidplugin\") + +set(mycroftplasmoidplugin_SRCS mycroftplasmoidplugin.cpp notify.cpp mycroftplasmoid_dbus.cpp) + +add_library(mycroftplasmoidplugin SHARED ${mycroftplasmoidplugin_SRCS}) + +target_link_libraries(mycroftplasmoidplugin Qt5::Gui Qt5::Core Qt5::Qml Qt5::DBus Qt5::Network KF5::Plasma KF5::I18n KF5::Notifications) + +install(TARGETS mycroftplasmoidplugin DESTINATION ${QML_INSTALL_DIR}/org/kde/private/mycroftplasmoid) + +install(FILES qmldir DESTINATION ${QML_INSTALL_DIR}/org/kde/private/mycroftplasmoid) + +install(FILES mycroftPlasmoid.notifyrc DESTINATION ${KNOTIFYRC_INSTALL_DIR}) diff --git a/plugin/mycroftPlasmoid.notifyrc b/plugin/mycroftPlasmoid.notifyrc new file mode 100644 index 0000000..4f6250e --- /dev/null +++ b/plugin/mycroftPlasmoid.notifyrc @@ -0,0 +1,68 @@ +[Global] +IconName=mycroft-plasma-appicon +Comment=Mycroft Plasmoid +Comment[ca]=Plasmoide del Mycroft +Comment[ca@valencia]=Plasmoide del Mycroft +Comment[cs]=Plasmoid Mycroft +Comment[de]=Mycroft-Plasmoid +Comment[en_GB]=Mycroft Plasmoid +Comment[es]=Plasmoide Mycroft +Comment[fi]=Mycroft-sovelma +Comment[gl]=Plasmoide de Mycroft +Comment[it]=Plasmoide Mycroft +Comment[ko]=Mycroft Plasmoid +Comment[nl]=Mycroft Plasmoid +Comment[nn]=Mycroft-skjermelement +Comment[pl]=Plazmoid Mycroft +Comment[pt]=Plasmóide do Mycroft +Comment[pt_BR]=Plasmoide do Mycroft +Comment[sk]=Mycroft Plazmoid +Comment[sv]=Mycroft Plasmoid +Comment[uk]=Плазмоїд Mycroft +Comment[x-test]=xxMycroft Plasmoidxx + +[Event/MycroftResponse] +Name=Mycroft Response +Name[ca]=Resposta del Mycroft +Name[ca@valencia]=Resposta del Mycroft +Name[de]=Mycroft-Rückmeldung +Name[en_GB]=Mycroft Response +Name[es]=Respuesta de Mycroft +Name[fi]=Mycroftin vastaus +Name[gl]=Resposta de Mycroft +Name[it]=Risposta di Mycroft +Name[ko]=Mycroft 응답 +Name[nl]=Mycroft reactie +Name[nn]=Mycroft-svar +Name[pl]=Odpowiedź Mycroft +Name[pt]=Resposta do Mycroft +Name[pt_BR]=Resposta do Mycroft +Name[sk]=Odpoveď Mycroft +Name[sv]=Mycroft svar +Name[uk]=Відповідь Mycroft +Name[x-test]=xxMycroft Responsexx +Comment=Connection to device failed +Comment[ca]=Ha fallat la connexió amb el dispositiu +Comment[ca@valencia]=Ha fallat la connexió amb el dispositiu +Comment[cs]=Připojení k zařízení selhalo +Comment[de]=Die Verbindung zum Gerät ist fehlgeschlagen +Comment[en_GB]=Connection to device failed +Comment[es]=La conexión con el dispositivo ha fallado +Comment[fi]=Laitteeseen yhdistäminen epäonnistui +Comment[fr]=La connexion au périphérique a échoué +Comment[gl]=A conexión co dispositivo fallou. +Comment[it]=Connessione al dispositivo non riuscita +Comment[ko]=장치에 연결할 수 없음 +Comment[nl]=Verbinding met het apparaat is mislukt +Comment[nn]=Klarte ikkje kopla til eininga +Comment[pl]=Połączenie do urządzenia nie udało się +Comment[pt]=A ligação ao dispositivo foi mal-sucedida +Comment[pt_BR]=Falha na conexão do dispositivo +Comment[ru]=Не удалось подключиться к устройству +Comment[sk]=Pripojenie k zariadeniu zlyhalo +Comment[sv]=Anslutning till enhet misslyckades +Comment[uk]=Не вдалося встановити з’єднання із пристроєм +Comment[x-test]=xxConnection to device failedxx +Comment[zh_CN]=连接设备失败 +Icon=mycroft-plasma-appicon +Action=Popup diff --git a/plugin/mycroftplasmoid_dbus.cpp b/plugin/mycroftplasmoid_dbus.cpp new file mode 100644 index 0000000..b99193b --- /dev/null +++ b/plugin/mycroftplasmoid_dbus.cpp @@ -0,0 +1,89 @@ +/* + * Copyright (C) 2016 by Aditya Mehra * + * 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 "mycroftplasmoid_dbus.h" +#include "mycroftplasmoidplugin.h" +#include +#include +#include +#include +#include +#include +#include +#include + +/* + * Implementation of adaptor class MycroftDbusAdapterInterface + */ + +MycroftDbusAdapterInterface::MycroftDbusAdapterInterface(QObject *parent) + : QDBusAbstractAdaptor(parent) +{ + // constructor + QDBusConnection dbus = QDBusConnection::sessionBus(); + dbus.registerObject("/mycroftapplet", this, QDBusConnection::ExportScriptableSlots | QDBusConnection::ExportNonScriptableSlots); + dbus.registerService("org.kde.mycroftapplet"); + setAutoRelaySignals(true); +} + +MycroftDbusAdapterInterface::~MycroftDbusAdapterInterface() +{ + // destructor +} + +void MycroftDbusAdapterInterface::showMycroft() +{ + // handle method call org.kde.mycroft.showMycroft + emit sendShowMycroft("Show"); + QMetaObject::invokeMethod(this, "getMethod", Qt::DirectConnection, Q_ARG(QString, "Show")); +} + +void MycroftDbusAdapterInterface::showSkills() +{ + // handle method call org.kde.mycroft.showSkills + emit sendShowSkills("ShowSkills"); + QMetaObject::invokeMethod(this, "getMethod", Qt::DirectConnection, Q_ARG(QString, "ShowSkills")); +} + +void MycroftDbusAdapterInterface::showSkillsInstaller() +{ + // handle method call org.kde.mycroft.showSkillsInstaller + emit installList("ShowInstallSkills"); + QMetaObject::invokeMethod(this, "getMethod", Qt::DirectConnection, Q_ARG(QString, "ShowInstallSkills")); +} + +void MycroftDbusAdapterInterface::showRecipeMethod(const QString &recipeName) +{ + // handle method call org.kde.mycroft.showRecipeMethod + emit recipeMethod(recipeName); + QMetaObject::invokeMethod(this, "getMethod", Qt::DirectConnection, Q_ARG(QString, recipeName)); +} + +void MycroftDbusAdapterInterface::sendKioMethod(const QString &kioString) +{ + // handle method call org.kde.mycroft.showRecipeMethod + emit kioMethod(kioString); + QMetaObject::invokeMethod(this, "getMethod", Qt::DirectConnection, Q_ARG(QString, kioString)); +} + +Q_INVOKABLE QString MycroftDbusAdapterInterface::getMethod(const QString &method) +{ + QString str = method; + return str; +} + diff --git a/plugin/mycroftplasmoid_dbus.h b/plugin/mycroftplasmoid_dbus.h new file mode 100644 index 0000000..8e13512 --- /dev/null +++ b/plugin/mycroftplasmoid_dbus.h @@ -0,0 +1,88 @@ +/* + * Copyright (C) 2016 by Aditya Mehra * + * 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 MYCROFTPLASMOID_DBUS_H +#define MYCROFTPLASMOID_DBUS_H + +#include +#include +QT_BEGIN_NAMESPACE +class QByteArray; +template class QList; +template class QMap; +class QString; +class QStringList; +class QVariant; +QT_END_NAMESPACE + +/* + * Adaptor class for interface org.kde.mycroftapplet + */ +class MycroftDbusAdapterInterface: public QDBusAbstractAdaptor +{ + Q_OBJECT + Q_CLASSINFO("D-Bus Interface", "org.kde.mycroftapplet") + Q_CLASSINFO("D-Bus Introspection", "" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" + "") +public: + MycroftDbusAdapterInterface(QObject *parent); + virtual ~MycroftDbusAdapterInterface(); + Q_INVOKABLE QString getMethod(const QString &method); + +public: // PROPERTIES +public Q_SLOTS: // METHODS + void showMycroft(); + void showSkills(); + void showSkillsInstaller(); + void showRecipeMethod(const QString &recipeName); + void sendKioMethod(const QString &kioString); +Q_SIGNALS: // SIGNALS + void sendShowMycroft(const QString &msgShowMycroft); + void sendShowSkills(const QString &msgShowSkills); + void installList(const QString &msgShowInstallSkills); + void recipeMethod(const QString &msgRecipeMethod); + void kioMethod(const QString &msgKioMethod); +}; + +#endif diff --git a/plugin/mycroftplasmoidplugin.cpp b/plugin/mycroftplasmoidplugin.cpp new file mode 100644 index 0000000..616017e --- /dev/null +++ b/plugin/mycroftplasmoidplugin.cpp @@ -0,0 +1,45 @@ +/* + * Copyright (C) 2016 by Aditya Mehra * + * 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 "mycroftplasmoidplugin.h" +#include "mycroftplasmoid_dbus.h" +#include "notify.h" +#include +#include +#include + +static QObject *notify_singleton(QQmlEngine *engine, QJSEngine *scriptEngine) +{ + Q_UNUSED(engine) + Q_UNUSED(scriptEngine) + + return new Notify; +} + +void MycroftPlasmoidPlugin::registerTypes(const char *uri) +{ + Q_ASSERT(uri == QLatin1String("org.kde.private.mycroftplasmoid")); + qmlRegisterSingletonType(uri, 1, 0, "Notify", notify_singleton); +} + +void MycroftPlasmoidPlugin::initializeEngine(QQmlEngine* engine, const char* uri) +{ + QQmlExtensionPlugin::initializeEngine(engine, uri); + auto mycroftDbusAdapterInterface = new MycroftDbusAdapterInterface(engine); + engine->rootContext()->setContextProperty("main2", mycroftDbusAdapterInterface); +} diff --git a/plugin/mycroftplasmoidplugin.h b/plugin/mycroftplasmoidplugin.h new file mode 100644 index 0000000..332fddd --- /dev/null +++ b/plugin/mycroftplasmoidplugin.h @@ -0,0 +1,40 @@ +/* + * Copyright (C) 2016 by Aditya Mehra * + * 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 +#include +#include + +class QQmlEngine; + +class MycroftPlasmoidPlugin : public QQmlExtensionPlugin +{ + Q_OBJECT + Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QQmlExtensionInterface") + +public: + void registerTypes(const char *uri); + void initializeEngine(QQmlEngine *engine, const char *uri) override; + +Q_SIGNAL +}; + +#endif // PROTOTYPEPLASMOIDPLUGIN_H diff --git a/plugin/notify.cpp b/plugin/notify.cpp new file mode 100644 index 0000000..ce9482a --- /dev/null +++ b/plugin/notify.cpp @@ -0,0 +1,59 @@ +/* + * Copyright (C) 2016 by Aditya Mehra * + * 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 "notify.h" +#include +#include +#include + +Notify::Notify(QObject *parent) + : QObject(parent) +{ +} + +void Notify::mycroftResponse(const QString &title, const QString ¬iftext) +{ + KNotification *notification = new KNotification(QStringLiteral("MycroftResponse"), + KNotification::CloseOnTimeout, this); + notification->setComponentName(QStringLiteral("mycroftPlasmoid")); + notification->setTitle(title); + notification->setText(notiftext); + notification->setActions(QStringList() << i18n("Stop") << i18n("Show Response")); + connect(notification, &KNotification::action1Activated, this, &Notify::notificationStopSpeech); + connect(notification, &KNotification::action2Activated, this, &Notify::notificationShowResponse); + notification->sendEvent(); +} + +void Notify::mycroftConnectionStatus(const QString &connectionStatus) +{ + KNotification *notification = new KNotification(QStringLiteral("MycroftConnectionStatus"), + KNotification::CloseOnTimeout, this); + notification->setComponentName(QStringLiteral("mycroftPlasmoid")); + notification->setTitle(i18n("Mycroft")); + notification->setText(connectionStatus); + if(connectionStatus == QStringLiteral("Connected")){ + notification->setIconName("mycroft-appicon-connected"); + } + else if(connectionStatus == QStringLiteral("Disconnected")){ + notification->setIconName("mycroft-appicon-disconnected"); + } + else { + notification->setIconName("mycroft-plasma-appicon"); + } + notification->sendEvent(); +} diff --git a/plugin/notify.h b/plugin/notify.h new file mode 100644 index 0000000..4348656 --- /dev/null +++ b/plugin/notify.h @@ -0,0 +1,40 @@ +/* + * Copyright (C) 2016 by Aditya Mehra * + * 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 NOTIFY_H +#define NOTIFY_H + +#include +#include + +class Notify : public QObject +{ + Q_OBJECT + +public: + explicit Notify(QObject *parent = Q_NULLPTR); + +public Q_SLOTS: + void mycroftResponse(const QString &title, const QString ¬iftext); + void mycroftConnectionStatus(const QString &connectionStatus); +Q_SIGNALS: // SIGNALS + void notificationStopSpeech(); + void notificationShowResponse(); +}; + +#endif // NOTIFY_H diff --git a/plugin/qmldir b/plugin/qmldir new file mode 100644 index 0000000..662f827 --- /dev/null +++ b/plugin/qmldir @@ -0,0 +1,3 @@ +module org.kde.private.mycroftplasmoid + +plugin mycroftplasmoidplugin