File indexing completed on 2024-04-21 05:52:51
0001 /* 0002 * Copyright (C) 2016 by Aditya Mehra <aix.m@outlook.com> * 0003 * This program is free software; you can redistribute it and/or modify 0004 * it under the terms of the GNU Library General Public License as 0005 * published by the Free Software Foundation; either version 2, or 0006 * (at your option) any later version. 0007 * 0008 * This program is distributed in the hope that it will be useful, 0009 * but WITHOUT ANY WARRANTY; without even the implied warranty of 0010 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 0011 * GNU General Public License for more details 0012 * 0013 * You should have received a copy of the GNU Library General Public 0014 * License along with this program; if not, write to the 0015 * Free Software Foundation, Inc., 0016 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 0017 */ 0018 0019 #include "notify.h" 0020 #include <QIcon> 0021 #include <KNotification> 0022 #include <KLocalizedString> 0023 0024 Notify::Notify(QObject *parent) 0025 : QObject(parent) 0026 { 0027 } 0028 0029 void Notify::mycroftResponse(const QString &title, const QString ¬iftext) 0030 { 0031 KNotification *notification = new KNotification(QStringLiteral("MycroftResponse"), 0032 KNotification::CloseOnTimeout, this); 0033 notification->setComponentName(QStringLiteral("mycroftPlasmoid")); 0034 notification->setTitle(title); 0035 notification->setText(notiftext); 0036 notification->setActions(QStringList() << i18n("Stop") << i18n("Show Response")); 0037 connect(notification, &KNotification::action1Activated, this, &Notify::notificationStopSpeech); 0038 connect(notification, &KNotification::action2Activated, this, &Notify::notificationShowResponse); 0039 notification->sendEvent(); 0040 } 0041 0042 void Notify::mycroftConnectionStatus(const QString &connectionStatus) 0043 { 0044 KNotification *notification = new KNotification(QStringLiteral("MycroftConnectionStatus"), 0045 KNotification::CloseOnTimeout, this); 0046 notification->setComponentName(QStringLiteral("mycroftPlasmoid")); 0047 notification->setTitle(i18n("Mycroft")); 0048 notification->setText(connectionStatus); 0049 if(connectionStatus == QStringLiteral("Connected")){ 0050 notification->setIconName("mycroft-appicon-connected"); 0051 } 0052 else if(connectionStatus == QStringLiteral("Disconnected")){ 0053 notification->setIconName("mycroft-appicon-disconnected"); 0054 } 0055 else { 0056 notification->setIconName("mycroft-plasma-appicon"); 0057 } 0058 notification->sendEvent(); 0059 }