From 930c107f7b75eb742b6c98a8bbfd8f2954683c9c Mon Sep 17 00:00:00 2001 From: Kai Uwe Broulik Date: Sun, 18 Jan 2015 01:52:04 +0100 Subject: [PATCH] Cleanup notifications Use iconName instead of sending a fixed-size pixmap around, fix wording and use title capitalization, more meaningful names in notifyrc, QStringLiteral and new style connect. REVIEW: 122121 --- core/device.cpp | 8 +++--- plugins/battery/batteryplugin.cpp | 4 +-- plugins/kdeconnect.notifyrc | 18 ++++++------- .../notificationsdbusinterface.cpp | 2 +- plugins/ping/pingplugin.cpp | 2 +- plugins/share/shareplugin.cpp | 8 +++--- plugins/telephony/telephonyplugin.cpp | 26 +++++++++---------- 7 files changed, 34 insertions(+), 34 deletions(-) diff --git a/core/device.cpp b/core/device.cpp index 601447847..8dd8eb7a5 100644 --- a/core/device.cpp +++ b/core/device.cpp @@ -377,13 +377,13 @@ void Device::privateReceivedPackage(const NetworkPackage& np) qCDebug(KDECONNECT_CORE) << "Pair request"; KNotification* notification = new KNotification("pairingRequest"); - notification->setPixmap(QIcon::fromTheme("dialog-information").pixmap(48, 48)); + notification->setIconName(QStringLiteral("dialog-information")); notification->setComponentName("kdeconnect"); - notification->setTitle("KDE Connect"); notification->setText(i18n("Pairing request from %1", m_deviceName)); notification->setActions(QStringList() << i18n("Accept") << i18n("Reject")); - connect(notification, SIGNAL(action1Activated()), this, SLOT(acceptPairing())); - connect(notification, SIGNAL(action2Activated()), this, SLOT(rejectPairing())); + connect(notification, &KNotification::closed, this, &Device::rejectPairing); + connect(notification, &KNotification::action1Activated, this, &Device::acceptPairing); + connect(notification, &KNotification::action2Activated, this, &Device::rejectPairing); notification->sendEvent(); m_pairStatus = Device::RequestedByPeer; diff --git a/plugins/battery/batteryplugin.cpp b/plugins/battery/batteryplugin.cpp index c0d60f28d..320215686 100644 --- a/plugins/battery/batteryplugin.cpp +++ b/plugins/battery/batteryplugin.cpp @@ -73,9 +73,9 @@ bool BatteryPlugin::receivePackage(const NetworkPackage& np) if ( thresholdEvent == ThresholdBatteryLow && !isCharging ) { KNotification* notification = new KNotification("batteryLow"); - notification->setPixmap(QIcon::fromTheme("battery-040").pixmap(48, 48)); + notification->setIconName("battery-040"); notification->setComponentName("kdeconnect"); - notification->setTitle(i18nc("device name: low battery", "%1: low battery", device()->name())); + notification->setTitle(i18nc("device name: low battery", "%1: Low Battery", device()->name())); notification->setText(i18n("Battery at %1%", currentCharge)); notification->sendEvent(); } diff --git a/plugins/kdeconnect.notifyrc b/plugins/kdeconnect.notifyrc index ab20ab169..f6704e1f5 100644 --- a/plugins/kdeconnect.notifyrc +++ b/plugins/kdeconnect.notifyrc @@ -85,7 +85,7 @@ Comment[x-test]=xxPairing request received from a devicesxx Action=Popup [Event/callReceived] -Name=Calling +Name=Incoming Call Name[bg]=Позвъняване Name[bs]=Poziva se Name[ca]=Trucada @@ -136,7 +136,7 @@ Comment[x-test]=xxSomeone is calling youxx Action=Popup [Event/missedCall] -Name=Missed +Name=Missed Call Name[bg]=Пропуснати Name[bs]=Propušten Name[ca]=Perduda @@ -187,7 +187,7 @@ Comment[x-test]=xxYou have a missed callxx Action=Popup [Event/smsReceived] -Name=SMS +Name=SMS Received Name[bg]=Текстово съобщение Name[bs]=SMS Name[ca]=SMS @@ -238,7 +238,7 @@ Comment[x-test]=xxSomeone sent you an SMSxx Action=Popup [Event/batteryLow] -Name=Battery +Name=Battery Low Name[bg]=Батерия Name[bs]=Baterija Name[ca]=Bateria @@ -289,7 +289,7 @@ Comment[x-test]=xxYour battery is in low statexx Action=Popup [Event/pingReceived] -Name=Ping +Name=Ping Received Name[bg]=Пинг Name[bs]=Ping Name[ca]=Ping @@ -298,7 +298,7 @@ Name[da]=Ping Name[de]=Ping Name[es]=Ping Name[fi]=Tiedustelupaketti -Name[fr]=Commande « Ping » +Name[fr]=Commande « Ping » Name[hu]=Ping Name[it]=Ping Name[ko]=핑 @@ -322,7 +322,7 @@ Comment[da]=Ping modtaget Comment[de]=Ping empfangen Comment[es]=Ping recibido Comment[fi]=Vastaanotettiin tiedustelupaketti -Comment[fr]=Commande « Ping » reçue +Comment[fr]=Commande « Ping » reçue Comment[hu]=Ping érkezett Comment[it]=Hai ricevuto un ping Comment[ko]=핑 받음 @@ -340,7 +340,7 @@ Comment[x-test]=xxPing receivedxx Action=Popup [Event/notification] -Name=Notification +Name=Generic Notification Name[bg]=Уведомление Name[bs]=Obavještenje Name[ca]=Notificació @@ -391,7 +391,7 @@ Comment[x-test]=xxNotification receivedxx Action=Popup [Event/transferReceived] -Name=Pairing Request +Name=File Transfer Name[ca]=Sol·licitud d'aparellament Name[cs]=Požadavek na párování Name[de]=Verbindungsanfrage diff --git a/plugins/notifications/notificationsdbusinterface.cpp b/plugins/notifications/notificationsdbusinterface.cpp index de7b660e5..38b4533d4 100644 --- a/plugins/notifications/notificationsdbusinterface.cpp +++ b/plugins/notifications/notificationsdbusinterface.cpp @@ -77,7 +77,7 @@ void NotificationsDbusInterface::processPackage(const NetworkPackage& np) //Do not show updates to existent notification nor answers to a initialization request if (!mInternalIdToPublicId.contains(noti->internalId()) && !np.get("requestAnswer", false)) { KNotification* notification = new KNotification("notification", KNotification::CloseOnTimeout, this); - notification->setPixmap(QIcon::fromTheme("preferences-desktop-notification").pixmap(48, 48)); + notification->setIconName(QStringLiteral("preferences-desktop-notification")); notification->setComponentName("kdeconnect"); notification->setTitle(mDevice->name()); notification->setText(noti->appName() + ": " + noti->ticker()); diff --git a/plugins/ping/pingplugin.cpp b/plugins/ping/pingplugin.cpp index 5c8ddb7d5..72c2a50da 100644 --- a/plugins/ping/pingplugin.cpp +++ b/plugins/ping/pingplugin.cpp @@ -47,7 +47,7 @@ PingPlugin::~PingPlugin() bool PingPlugin::receivePackage(const NetworkPackage& np) { KNotification* notification = new KNotification("pingReceived"); //KNotification::Persistent - notification->setPixmap(QIcon::fromTheme("dialog-ok").pixmap(48, 48)); + notification->setIconName(QStringLiteral("dialog-ok")); notification->setComponentName("kdeconnect"); notification->setTitle(device()->name()); notification->setText(np.get("message",i18n("Ping!"))); //This can be a source of spam diff --git a/plugins/share/shareplugin.cpp b/plugins/share/shareplugin.cpp index b7ecec06d..5db025479 100644 --- a/plugins/share/shareplugin.cpp +++ b/plugins/share/shareplugin.cpp @@ -140,12 +140,12 @@ void SharePlugin::finished(KJob* job) FileTransferJob* transferJob = (FileTransferJob*)job; KNotification* notification = new KNotification("transferReceived"); - notification->setPixmap(QIcon::fromTheme(error? "edit-delete" : "dialog-ok").pixmap(48, 48)); + notification->setIconName(error ? QStringLiteral("dialog-error") : QStringLiteral("dialog-ok")); notification->setComponentName("kdeconnect"); - notification->setTitle(i18n("Transfer finished")); + notification->setTitle(i18n("Transfer Finished")); notification->setText(transferJob->destination().fileName()); - notification->setActions(QStringList(i18n("Open destination folder"))); - connect(notification, SIGNAL(action1Activated()), this, SLOT(openDestinationFolder())); + notification->setActions(QStringList(i18n("Open"))); + connect(notification, &KNotification::action1Activated, this, &SharePlugin::openDestinationFolder); notification->sendEvent(); } diff --git a/plugins/telephony/telephonyplugin.cpp b/plugins/telephony/telephonyplugin.cpp index 114b5eabe..e8d9ad56b 100644 --- a/plugins/telephony/telephonyplugin.cpp +++ b/plugins/telephony/telephonyplugin.cpp @@ -49,19 +49,19 @@ KNotification* TelephonyPlugin::createNotification(const NetworkPackage& np) const QString title = device()->name(); if (event == "ringing") { - type = "callReceived"; - icon = "call-start"; + type = QStringLiteral("callReceived"); + icon = QStringLiteral("call-start"); content = i18n("Incoming call from %1", phoneNumber); } else if (event == "missedCall") { - type = "missedCall"; - icon = "call-start"; + type = QStringLiteral("missedCall"); + icon = QStringLiteral("call-start"); content = i18n("Missed call from %1", phoneNumber); flags = KNotification::Persistent; } else if (event == "sms") { - type = "smsReceived"; - icon = "mail-receive"; + type = QStringLiteral("smsReceived"); + icon = QStringLiteral("mail-receive"); QString messageBody = np.get("messageBody",""); - content = i18n("SMS from %1: %2", phoneNumber, messageBody); + content = i18n("SMS from %1
%2", phoneNumber, messageBody); flags = KNotification::Persistent; } else if (event == "talking") { return NULL; @@ -69,8 +69,8 @@ KNotification* TelephonyPlugin::createNotification(const NetworkPackage& np) #ifndef NDEBUG return NULL; #else - type = "callReceived"; - icon = "phone"; + type = QStringLiteral("callReceived"); + icon = QStringLiteral("phone"); content = i18n("Unknown telephony event: %1", event); #endif } @@ -78,14 +78,14 @@ KNotification* TelephonyPlugin::createNotification(const NetworkPackage& np) qCDebug(KDECONNECT_PLUGIN_TELEPHONY) << "Creating notification with type:" << type; KNotification* notification = new KNotification(type, flags, this); - notification->setPixmap(QIcon::fromTheme(icon).pixmap(48, 48)); + notification->setIconName(icon); notification->setComponentName("kdeconnect"); notification->setTitle(title); notification->setText(content); - if (event == "ringing") { - notification->setActions( QStringList(i18n("Mute call")) ); - connect(notification, SIGNAL(action1Activated()), this, SLOT(sendMutePackage())); + if (event == QLatin1String("ringing")) { + notification->setActions( QStringList(i18n("Mute Call")) ); + connect(notification, &KNotification::action1Activated, this, &TelephonyPlugin::sendMutePackage); } return notification;