mirror of https://github.com/procxx/kepka.git
Fix notification actions for Cinnamon, fix notification icon for Gnome, add support for TDESKTOP_LAUNCHER_FILENAME in notifications and fix indentation
This commit is contained in:
parent
6fdd1389e6
commit
ee9336f781
|
@ -28,7 +28,7 @@ std::vector<QString> GetServerInformation(
|
|||
const std::shared_ptr<QDBusInterface> ¬ificationInterface) {
|
||||
std::vector<QString> serverInformation;
|
||||
auto serverInformationReply = notificationInterface
|
||||
->call("GetServerInformation");
|
||||
->call(qsl("GetServerInformation"));
|
||||
|
||||
if (serverInformationReply.type() == QDBusMessage::ReplyMessage) {
|
||||
for (const auto &arg : serverInformationReply.arguments()) {
|
||||
|
@ -55,7 +55,7 @@ std::vector<QString> GetServerInformation(
|
|||
std::vector<QString> GetCapabilities(
|
||||
const std::shared_ptr<QDBusInterface> ¬ificationInterface) {
|
||||
QDBusReply<QStringList> capabilitiesReply = notificationInterface
|
||||
->call("GetCapabilities");
|
||||
->call(qsl("GetCapabilities"));
|
||||
|
||||
if (capabilitiesReply.isValid()) {
|
||||
return capabilitiesReply.value().toVector().toStdVector();
|
||||
|
@ -106,8 +106,10 @@ NotificationData::NotificationData(
|
|||
}
|
||||
|
||||
if (ranges::find(capabilities, qsl("actions")) != capabilitiesEnd) {
|
||||
_actions << qsl("default") << QString();
|
||||
|
||||
// icon name according to https://specifications.freedesktop.org/icon-naming-spec/icon-naming-spec-latest.html
|
||||
_actions << "mail-reply-sender"
|
||||
_actions << qsl("mail-reply-sender")
|
||||
<< tr::lng_notification_reply(tr::now);
|
||||
|
||||
connect(_notificationInterface.get(),
|
||||
|
@ -125,17 +127,26 @@ NotificationData::NotificationData(
|
|||
_hints["suppress-sound"] = true;
|
||||
} else {
|
||||
// sound name according to http://0pointer.de/public/sound-naming-spec.html
|
||||
_hints["sound-name"] = "message-new-instant";
|
||||
_hints["sound-name"] = qsl("message-new-instant");
|
||||
}
|
||||
}
|
||||
|
||||
if (ranges::find(capabilities, qsl("x-canonical-append"))
|
||||
!= capabilitiesEnd) {
|
||||
_hints["x-canonical-append"] = "true";
|
||||
_hints["x-canonical-append"] = qsl("true");
|
||||
}
|
||||
|
||||
_hints["category"] = "im.received";
|
||||
_hints["desktop-entry"] = "telegramdesktop";
|
||||
_hints["category"] = qsl("im.received");
|
||||
|
||||
#ifdef TDESKTOP_LAUNCHER_FILENAME
|
||||
#define TDESKTOP_LAUNCHER_FILENAME_TO_STRING_HELPER(V) #V
|
||||
#define TDESKTOP_LAUNCHER_FILENAME_TO_STRING(V) TDESKTOP_LAUNCHER_FILENAME_TO_STRING_HELPER(V)
|
||||
_hints["desktop-entry"] =
|
||||
qsl(TDESKTOP_LAUNCHER_FILENAME_TO_STRING(TDESKTOP_LAUNCHER_FILENAME))
|
||||
.remove(QRegExp(qsl("\\.desktop$"), Qt::CaseInsensitive));
|
||||
#else
|
||||
_hints["desktop-entry"] = qsl("telegramdesktop");
|
||||
#endif
|
||||
|
||||
connect(_notificationInterface.get(),
|
||||
SIGNAL(NotificationClosed(uint, uint)),
|
||||
|
@ -143,8 +154,8 @@ NotificationData::NotificationData(
|
|||
}
|
||||
|
||||
bool NotificationData::show() {
|
||||
QDBusReply<uint> notifyReply = _notificationInterface->call("Notify",
|
||||
str_const_toString(AppName), uint(0), "telegram", _title, _body,
|
||||
QDBusReply<uint> notifyReply = _notificationInterface->call(qsl("Notify"),
|
||||
str_const_toString(AppName), uint(0), QString(), _title, _body,
|
||||
_actions, _hints, -1);
|
||||
|
||||
if (notifyReply.isValid()) {
|
||||
|
@ -159,7 +170,7 @@ bool NotificationData::show() {
|
|||
|
||||
bool NotificationData::close() {
|
||||
QDBusReply<void> closeReply = _notificationInterface
|
||||
->call("CloseNotification", _notificationId);
|
||||
->call(qsl("CloseNotification"), _notificationId);
|
||||
|
||||
if (!closeReply.isValid()) {
|
||||
LOG(("Native notification error: %1")
|
||||
|
@ -180,12 +191,12 @@ void NotificationData::setImage(const QString &imagePath) {
|
|||
const auto minorVersion = specificationVersion.minorVersion();
|
||||
|
||||
if ((majorVersion == 1 && minorVersion >= 2) || majorVersion > 1) {
|
||||
imageKey = "image-data";
|
||||
} else if (majorVersion == 1 && minorVersion) {
|
||||
imageKey = "image_data";
|
||||
imageKey = qsl("image-data");
|
||||
} else if (majorVersion == 1 && minorVersion == 1) {
|
||||
imageKey = qsl("image_data");
|
||||
} else if ((majorVersion == 1 && minorVersion < 1)
|
||||
|| majorVersion < 1) {
|
||||
imageKey = "icon_data";
|
||||
imageKey = qsl("icon_data");
|
||||
} else {
|
||||
LOG(("Native notification error: unknown specification version"));
|
||||
return;
|
||||
|
@ -258,18 +269,12 @@ const QDBusArgument &operator>>(const QDBusArgument &argument,
|
|||
}
|
||||
|
||||
bool Supported() {
|
||||
static auto Checked = false;
|
||||
static auto NotificationDaemonRunning = false;
|
||||
|
||||
if (!Checked) {
|
||||
Checked = true;
|
||||
NotificationDaemonRunning = QDBusInterface(
|
||||
static auto Available = QDBusInterface(
|
||||
str_const_toString(kService),
|
||||
str_const_toString(kObjectPath),
|
||||
str_const_toString(kInterface)).isValid();
|
||||
}
|
||||
|
||||
return NotificationDaemonRunning;
|
||||
return Available;
|
||||
}
|
||||
|
||||
std::unique_ptr<Window::Notifications::Manager> Create(
|
||||
|
|
Loading…
Reference in New Issue