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
This commit is contained in:
Kai Uwe Broulik 2015-01-18 01:52:04 +01:00
parent 260301155f
commit 930c107f7b
7 changed files with 34 additions and 34 deletions

View file

@ -377,13 +377,13 @@ void Device::privateReceivedPackage(const NetworkPackage& np)
qCDebug(KDECONNECT_CORE) << "Pair request"; qCDebug(KDECONNECT_CORE) << "Pair request";
KNotification* notification = new KNotification("pairingRequest"); KNotification* notification = new KNotification("pairingRequest");
notification->setPixmap(QIcon::fromTheme("dialog-information").pixmap(48, 48)); notification->setIconName(QStringLiteral("dialog-information"));
notification->setComponentName("kdeconnect"); notification->setComponentName("kdeconnect");
notification->setTitle("KDE Connect");
notification->setText(i18n("Pairing request from %1", m_deviceName)); notification->setText(i18n("Pairing request from %1", m_deviceName));
notification->setActions(QStringList() << i18n("Accept") << i18n("Reject")); notification->setActions(QStringList() << i18n("Accept") << i18n("Reject"));
connect(notification, SIGNAL(action1Activated()), this, SLOT(acceptPairing())); connect(notification, &KNotification::closed, this, &Device::rejectPairing);
connect(notification, SIGNAL(action2Activated()), this, SLOT(rejectPairing())); connect(notification, &KNotification::action1Activated, this, &Device::acceptPairing);
connect(notification, &KNotification::action2Activated, this, &Device::rejectPairing);
notification->sendEvent(); notification->sendEvent();
m_pairStatus = Device::RequestedByPeer; m_pairStatus = Device::RequestedByPeer;

View file

@ -73,9 +73,9 @@ bool BatteryPlugin::receivePackage(const NetworkPackage& np)
if ( thresholdEvent == ThresholdBatteryLow && !isCharging ) { if ( thresholdEvent == ThresholdBatteryLow && !isCharging ) {
KNotification* notification = new KNotification("batteryLow"); KNotification* notification = new KNotification("batteryLow");
notification->setPixmap(QIcon::fromTheme("battery-040").pixmap(48, 48)); notification->setIconName("battery-040");
notification->setComponentName("kdeconnect"); 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->setText(i18n("Battery at %1%", currentCharge));
notification->sendEvent(); notification->sendEvent();
} }

View file

@ -85,7 +85,7 @@ Comment[x-test]=xxPairing request received from a devicesxx
Action=Popup Action=Popup
[Event/callReceived] [Event/callReceived]
Name=Calling Name=Incoming Call
Name[bg]=Позвъняване Name[bg]=Позвъняване
Name[bs]=Poziva se Name[bs]=Poziva se
Name[ca]=Trucada Name[ca]=Trucada
@ -136,7 +136,7 @@ Comment[x-test]=xxSomeone is calling youxx
Action=Popup Action=Popup
[Event/missedCall] [Event/missedCall]
Name=Missed Name=Missed Call
Name[bg]=Пропуснати Name[bg]=Пропуснати
Name[bs]=Propušten Name[bs]=Propušten
Name[ca]=Perduda Name[ca]=Perduda
@ -187,7 +187,7 @@ Comment[x-test]=xxYou have a missed callxx
Action=Popup Action=Popup
[Event/smsReceived] [Event/smsReceived]
Name=SMS Name=SMS Received
Name[bg]=Текстово съобщение Name[bg]=Текстово съобщение
Name[bs]=SMS Name[bs]=SMS
Name[ca]=SMS Name[ca]=SMS
@ -238,7 +238,7 @@ Comment[x-test]=xxSomeone sent you an SMSxx
Action=Popup Action=Popup
[Event/batteryLow] [Event/batteryLow]
Name=Battery Name=Battery Low
Name[bg]=Батерия Name[bg]=Батерия
Name[bs]=Baterija Name[bs]=Baterija
Name[ca]=Bateria Name[ca]=Bateria
@ -289,7 +289,7 @@ Comment[x-test]=xxYour battery is in low statexx
Action=Popup Action=Popup
[Event/pingReceived] [Event/pingReceived]
Name=Ping Name=Ping Received
Name[bg]=Пинг Name[bg]=Пинг
Name[bs]=Ping Name[bs]=Ping
Name[ca]=Ping Name[ca]=Ping
@ -298,7 +298,7 @@ Name[da]=Ping
Name[de]=Ping Name[de]=Ping
Name[es]=Ping Name[es]=Ping
Name[fi]=Tiedustelupaketti Name[fi]=Tiedustelupaketti
Name[fr]=Commande « Ping » Name[fr]=Commande « Ping »
Name[hu]=Ping Name[hu]=Ping
Name[it]=Ping Name[it]=Ping
Name[ko]=핑 Name[ko]=핑
@ -322,7 +322,7 @@ Comment[da]=Ping modtaget
Comment[de]=Ping empfangen Comment[de]=Ping empfangen
Comment[es]=Ping recibido Comment[es]=Ping recibido
Comment[fi]=Vastaanotettiin tiedustelupaketti Comment[fi]=Vastaanotettiin tiedustelupaketti
Comment[fr]=Commande « Ping » reçue Comment[fr]=Commande « Ping » reçue
Comment[hu]=Ping érkezett Comment[hu]=Ping érkezett
Comment[it]=Hai ricevuto un ping Comment[it]=Hai ricevuto un ping
Comment[ko]=핑 받음 Comment[ko]=핑 받음
@ -340,7 +340,7 @@ Comment[x-test]=xxPing receivedxx
Action=Popup Action=Popup
[Event/notification] [Event/notification]
Name=Notification Name=Generic Notification
Name[bg]=Уведомление Name[bg]=Уведомление
Name[bs]=Obavještenje Name[bs]=Obavještenje
Name[ca]=Notificació Name[ca]=Notificació
@ -391,7 +391,7 @@ Comment[x-test]=xxNotification receivedxx
Action=Popup Action=Popup
[Event/transferReceived] [Event/transferReceived]
Name=Pairing Request Name=File Transfer
Name[ca]=Sol·licitud d'aparellament Name[ca]=Sol·licitud d'aparellament
Name[cs]=Požadavek na párování Name[cs]=Požadavek na párování
Name[de]=Verbindungsanfrage Name[de]=Verbindungsanfrage

View file

@ -77,7 +77,7 @@ void NotificationsDbusInterface::processPackage(const NetworkPackage& np)
//Do not show updates to existent notification nor answers to a initialization request //Do not show updates to existent notification nor answers to a initialization request
if (!mInternalIdToPublicId.contains(noti->internalId()) && !np.get<bool>("requestAnswer", false)) { if (!mInternalIdToPublicId.contains(noti->internalId()) && !np.get<bool>("requestAnswer", false)) {
KNotification* notification = new KNotification("notification", KNotification::CloseOnTimeout, this); 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->setComponentName("kdeconnect");
notification->setTitle(mDevice->name()); notification->setTitle(mDevice->name());
notification->setText(noti->appName() + ": " + noti->ticker()); notification->setText(noti->appName() + ": " + noti->ticker());

View file

@ -47,7 +47,7 @@ PingPlugin::~PingPlugin()
bool PingPlugin::receivePackage(const NetworkPackage& np) bool PingPlugin::receivePackage(const NetworkPackage& np)
{ {
KNotification* notification = new KNotification("pingReceived"); //KNotification::Persistent 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->setComponentName("kdeconnect");
notification->setTitle(device()->name()); notification->setTitle(device()->name());
notification->setText(np.get<QString>("message",i18n("Ping!"))); //This can be a source of spam notification->setText(np.get<QString>("message",i18n("Ping!"))); //This can be a source of spam

View file

@ -140,12 +140,12 @@ void SharePlugin::finished(KJob* job)
FileTransferJob* transferJob = (FileTransferJob*)job; FileTransferJob* transferJob = (FileTransferJob*)job;
KNotification* notification = new KNotification("transferReceived"); 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->setComponentName("kdeconnect");
notification->setTitle(i18n("Transfer finished")); notification->setTitle(i18n("Transfer Finished"));
notification->setText(transferJob->destination().fileName()); notification->setText(transferJob->destination().fileName());
notification->setActions(QStringList(i18n("Open destination folder"))); notification->setActions(QStringList(i18n("Open")));
connect(notification, SIGNAL(action1Activated()), this, SLOT(openDestinationFolder())); connect(notification, &KNotification::action1Activated, this, &SharePlugin::openDestinationFolder);
notification->sendEvent(); notification->sendEvent();
} }

View file

@ -49,19 +49,19 @@ KNotification* TelephonyPlugin::createNotification(const NetworkPackage& np)
const QString title = device()->name(); const QString title = device()->name();
if (event == "ringing") { if (event == "ringing") {
type = "callReceived"; type = QStringLiteral("callReceived");
icon = "call-start"; icon = QStringLiteral("call-start");
content = i18n("Incoming call from %1", phoneNumber); content = i18n("Incoming call from %1", phoneNumber);
} else if (event == "missedCall") { } else if (event == "missedCall") {
type = "missedCall"; type = QStringLiteral("missedCall");
icon = "call-start"; icon = QStringLiteral("call-start");
content = i18n("Missed call from %1", phoneNumber); content = i18n("Missed call from %1", phoneNumber);
flags = KNotification::Persistent; flags = KNotification::Persistent;
} else if (event == "sms") { } else if (event == "sms") {
type = "smsReceived"; type = QStringLiteral("smsReceived");
icon = "mail-receive"; icon = QStringLiteral("mail-receive");
QString messageBody = np.get<QString>("messageBody",""); QString messageBody = np.get<QString>("messageBody","");
content = i18n("SMS from %1: %2", phoneNumber, messageBody); content = i18n("SMS from %1<br>%2", phoneNumber, messageBody);
flags = KNotification::Persistent; flags = KNotification::Persistent;
} else if (event == "talking") { } else if (event == "talking") {
return NULL; return NULL;
@ -69,8 +69,8 @@ KNotification* TelephonyPlugin::createNotification(const NetworkPackage& np)
#ifndef NDEBUG #ifndef NDEBUG
return NULL; return NULL;
#else #else
type = "callReceived"; type = QStringLiteral("callReceived");
icon = "phone"; icon = QStringLiteral("phone");
content = i18n("Unknown telephony event: %1", event); content = i18n("Unknown telephony event: %1", event);
#endif #endif
} }
@ -78,14 +78,14 @@ KNotification* TelephonyPlugin::createNotification(const NetworkPackage& np)
qCDebug(KDECONNECT_PLUGIN_TELEPHONY) << "Creating notification with type:" << type; qCDebug(KDECONNECT_PLUGIN_TELEPHONY) << "Creating notification with type:" << type;
KNotification* notification = new KNotification(type, flags, this); KNotification* notification = new KNotification(type, flags, this);
notification->setPixmap(QIcon::fromTheme(icon).pixmap(48, 48)); notification->setIconName(icon);
notification->setComponentName("kdeconnect"); notification->setComponentName("kdeconnect");
notification->setTitle(title); notification->setTitle(title);
notification->setText(content); notification->setText(content);
if (event == "ringing") { if (event == QLatin1String("ringing")) {
notification->setActions( QStringList(i18n("Mute call")) ); notification->setActions( QStringList(i18n("Mute Call")) );
connect(notification, SIGNAL(action1Activated()), this, SLOT(sendMutePackage())); connect(notification, &KNotification::action1Activated, this, &TelephonyPlugin::sendMutePackage);
} }
return notification; return notification;