[SCM] kdeconnect packaging branch, master, updated. debian/0.9g-1-1183-g9d69498
Maximiliano Curia
maxy at moszumanska.debian.org
Fri Oct 14 14:29:39 UTC 2016
Gitweb-URL: http://git.debian.org/?p=pkg-kde/kde-extras/kdeconnect.git;a=commitdiff;h=623ca94
The following commit has been merged in the master branch:
commit 623ca94a0c2376cf4726f5b30f8ece9ed63658b1
Author: David Kahles <david.kahles96 at gmail.com>
Date: Wed Apr 27 19:45:58 2016 +0200
Don't hardcode app name to filter notifications
The app name used by KNotification is translated, and thus the filtering
doesn't work if the translated app name is different.
REVIEW: 127768
---
plugins/notifications/CMakeLists.txt | 3 ++-
plugins/notifications/notificationslistener.cpp | 20 +++++++++++++++++++-
plugins/notifications/notificationslistener.h | 3 +++
3 files changed, 24 insertions(+), 2 deletions(-)
diff --git a/plugins/notifications/CMakeLists.txt b/plugins/notifications/CMakeLists.txt
index d74cca6..464811e 100644
--- a/plugins/notifications/CMakeLists.txt
+++ b/plugins/notifications/CMakeLists.txt
@@ -1,4 +1,4 @@
-find_package(KF5 REQUIRED COMPONENTS Notifications KCMUtils I18n IconThemes)
+find_package(KF5 REQUIRED COMPONENTS Notifications KCMUtils I18n IconThemes Config)
set(kdeconnect_notifications_SRCS
notification.cpp
@@ -16,6 +16,7 @@ target_link_libraries(kdeconnect_notifications
KF5::Notifications
KF5::I18n
KF5::IconThemes
+ KF5::ConfigCore
)
#######################################
diff --git a/plugins/notifications/notificationslistener.cpp b/plugins/notifications/notificationslistener.cpp
index d21f3d7..34a9191 100644
--- a/plugins/notifications/notificationslistener.cpp
+++ b/plugins/notifications/notificationslistener.cpp
@@ -22,6 +22,9 @@
#include <QtDBus/QDBusInterface>
#include <QtDebug>
#include <QLoggingCategory>
+#include <QStandardPaths>
+#include <KConfig>
+#include <KConfigGroup>
#include <kiconloader.h>
#include <kicontheme.h>
@@ -62,6 +65,7 @@ NotificationsListener::NotificationsListener(KdeConnectPlugin* aPlugin,
iface.call("AddMatch",
"interface='org.freedesktop.Notifications',member='Notify',type='method_call',eavesdrop='true'");
+ setTranslatedAppName();
loadApplications();
connect(mPlugin->config(), SIGNAL(configChanged()), this, SLOT(loadApplications()));
@@ -77,6 +81,20 @@ NotificationsListener::~NotificationsListener()
QDBusConnection::sessionBus().unregisterObject("/org/freedesktop/Notifications");
}
+void NotificationsListener::setTranslatedAppName()
+{
+ QString filePath = QStandardPaths::locate(QStandardPaths::GenericDataLocation, QStringLiteral("knotifications5/kdeconnect.notifyrc"), QStandardPaths::LocateFile);
+ if (filePath.isEmpty()) {
+ qCDebug(KDECONNECT_PLUGIN_NOTIFICATION) << "Couldn't find kdeconnect.notifyrc to hide kdeconnect notifications on the devices. Using default name.";
+ mTranslatedAppName = QStringLiteral("KDE Connect");
+ return;
+ }
+
+ KConfig config(filePath, KConfig::OpenFlag::SimpleConfig);
+ KConfigGroup globalgroup(&config, QStringLiteral("Global"));
+ mTranslatedAppName = globalgroup.readEntry(QStringLiteral("Name"), QStringLiteral("KDE Connect"));
+}
+
void NotificationsListener::loadApplications()
{
applications.clear();
@@ -101,7 +119,7 @@ uint NotificationsListener::Notify(const QString &appName, uint replacesId,
//qCDebug(KDECONNECT_PLUGIN_NOTIFICATION) << "Got notification appName=" << appName << "replacesId=" << replacesId << "appIcon=" << appIcon << "summary=" << summary << "body=" << body << "actions=" << actions << "hints=" << hints << "timeout=" << timeout;
// skip our own notifications
- if (appName == QLatin1String("KDE Connect"))
+ if (appName == mTranslatedAppName)
return 0;
NotifyingApplication app;
diff --git a/plugins/notifications/notificationslistener.h b/plugins/notifications/notificationslistener.h
index dfa37b8..7ba01d8 100644
--- a/plugins/notifications/notificationslistener.h
+++ b/plugins/notifications/notificationslistener.h
@@ -49,4 +49,7 @@ public Q_SLOTS:
private Q_SLOTS:
void loadApplications();
+private:
+ void setTranslatedAppName();
+ QString mTranslatedAppName;
};
--
kdeconnect packaging
More information about the pkg-kde-commits
mailing list