diff --git a/daemon/plugins/telephony/telephonyplugin.cpp b/daemon/plugins/telephony/telephonyplugin.cpp index 0a1423600..5029d324a 100644 --- a/daemon/plugins/telephony/telephonyplugin.cpp +++ b/daemon/plugins/telephony/telephonyplugin.cpp @@ -29,17 +29,12 @@ K_EXPORT_PLUGIN( KdeConnectPluginFactory("kdeconnect_telephony", "kdeconnect_tel TelephonyPlugin::TelephonyPlugin(QObject *parent, const QVariantList &args) : KdeConnectPlugin(parent, args) { - trayIcon = new KStatusNotifierItem(parent); - trayIcon->setIconByName("pda"); - trayIcon->setTitle("KdeConnect"); - connect(trayIcon,SIGNAL(activateRequested(bool,QPoint)),this,SLOT(showPendingNotifications())); + } KNotification* TelephonyPlugin::createNotification(const NetworkPackage& np) { - QString id = QString::number(np.id()); - QString npType = np.get("notificationType"); QString title, content, type, icon; @@ -75,56 +70,16 @@ KNotification* TelephonyPlugin::createNotification(const NetworkPackage& np) qDebug() << "Creating notification with type:" << type; - - if (transient) { - trayIcon->setStatus(KStatusNotifierItem::Active); - - KNotification* notification = new KNotification(type); - notification->setPixmap(KIcon(icon).pixmap(48, 48)); - notification->setComponentData(KComponentData("kdeconnect", "kdeconnect")); - notification->setTitle(title); - notification->setText(content); - - pendingNotifications.insert(id, notification); - } - - KNotification* notification = new KNotification(type); //, KNotification::Persistent notification->setPixmap(KIcon(icon).pixmap(48, 48)); notification->setComponentData(KComponentData("kdeconnect", "kdeconnect")); notification->setTitle(title); notification->setText(content); - notification->setProperty("id",id); - - connect(notification,SIGNAL(activated()),this,SLOT(notificationAttended())); - connect(notification,SIGNAL(closed()),this,SLOT(notificationAttended())); return notification; } -void TelephonyPlugin::notificationAttended() -{ - KNotification* normalNotification = (KNotification*)sender(); - QString id = normalNotification->property("id").toString(); - if (pendingNotifications.contains(id)) { - delete pendingNotifications[id]; - pendingNotifications.remove(id); - if (pendingNotifications.isEmpty()) { - trayIcon->setStatus(KStatusNotifierItem::Passive); - } - } -} - -void TelephonyPlugin::showPendingNotifications() -{ - trayIcon->setStatus(KStatusNotifierItem::Passive); - Q_FOREACH (KNotification* notification, pendingNotifications) { - notification->sendEvent(); - } - pendingNotifications.clear(); -} - bool TelephonyPlugin::receivePackage(const NetworkPackage& np) { diff --git a/daemon/plugins/telephony/telephonyplugin.h b/daemon/plugins/telephony/telephonyplugin.h index d1931e618..6d4db882d 100644 --- a/daemon/plugins/telephony/telephonyplugin.h +++ b/daemon/plugins/telephony/telephonyplugin.h @@ -37,13 +37,9 @@ public: public Q_SLOTS: virtual bool receivePackage(const NetworkPackage& np); - void showPendingNotifications(); - void notificationAttended(); private: KNotification* createNotification(const NetworkPackage& np); - KStatusNotifierItem* trayIcon; - QHash pendingNotifications; };