diff --git a/Telegram/SourceFiles/platform/linux/notifications_manager_linux.cpp b/Telegram/SourceFiles/platform/linux/notifications_manager_linux.cpp index f7fd5debc6..7f77c0235e 100644 --- a/Telegram/SourceFiles/platform/linux/notifications_manager_linux.cpp +++ b/Telegram/SourceFiles/platform/linux/notifications_manager_linux.cpp @@ -88,8 +88,12 @@ QVersionNumber ParseSpecificationVersion( NotificationData::NotificationData( const std::shared_ptr ¬ificationInterface, const base::weak_ptr &manager, - const QString &title, const QString &subtitle, - const QString &msg, PeerId peerId, MsgId msgId) + const QString &title, + const QString &subtitle, + const QString &msg, + PeerId peerId, + MsgId msgId, + bool hideReplyButton) : _notificationInterface(notificationInterface) , _manager(manager) , _title(title) @@ -120,7 +124,7 @@ NotificationData::NotificationData( this, SLOT(notificationClicked(uint,QString))); - if (capabilities.contains(qsl("inline-reply"))) { + if (capabilities.contains(qsl("inline-reply")) && !hideReplyButton) { _actions << qsl("inline-reply") << tr::lng_notification_reply(tr::now); @@ -169,12 +173,14 @@ NotificationData::NotificationData( SLOT(notificationClosed(uint))); } -bool NotificationData::show() { +bool NotificationData::show(bool hideNameAndPhoto) { const QDBusReply notifyReply = _notificationInterface->call( qsl("Notify"), AppName.utf16(), uint(0), - QString(), + hideNameAndPhoto + ? qsl("telegram") + : QString(), _title, _body, _actions, @@ -285,7 +291,8 @@ void NotificationData::notificationReplied(uint id, const QString &text) { } } -QDBusArgument &operator<<(QDBusArgument &argument, +QDBusArgument &operator<<( + QDBusArgument &argument, const NotificationData::ImageData &imageData) { argument.beginStructure(); argument << imageData.width @@ -299,7 +306,8 @@ QDBusArgument &operator<<(QDBusArgument &argument, return argument; } -const QDBusArgument &operator>>(const QDBusArgument &argument, +const QDBusArgument &operator>>( + const QDBusArgument &argument, NotificationData::ImageData &imageData) { argument.beginStructure(); argument >> imageData.width @@ -380,12 +388,13 @@ void Manager::Private::showNotification( subtitle, msg, peer->id, - msgId); + msgId, + hideReplyButton); - const auto key = hideNameAndPhoto - ? InMemoryKey() - : peer->userpicUniqueKey(); - notification->setImage(_cachedUserpics.get(key, peer)); + if (!hideNameAndPhoto) { + const auto key = peer->userpicUniqueKey(); + notification->setImage(_cachedUserpics.get(key, peer)); + } auto i = _notifications.find(peer->id); if (i != _notifications.cend()) { @@ -401,7 +410,7 @@ void Manager::Private::showNotification( i = _notifications.insert(peer->id, QMap()); } _notifications[peer->id].insert(msgId, notification); - if (!notification->show()) { + if (!notification->show(hideNameAndPhoto)) { i = _notifications.find(peer->id); if (i != _notifications.cend()) { i->remove(msgId); diff --git a/Telegram/SourceFiles/platform/linux/notifications_manager_linux.h b/Telegram/SourceFiles/platform/linux/notifications_manager_linux.h index 4ac937216b..ef641b4a9e 100644 --- a/Telegram/SourceFiles/platform/linux/notifications_manager_linux.h +++ b/Telegram/SourceFiles/platform/linux/notifications_manager_linux.h @@ -38,15 +38,19 @@ public: NotificationData( const std::shared_ptr ¬ificationInterface, const base::weak_ptr &manager, - const QString &title, const QString &subtitle, - const QString &msg, PeerId peerId, MsgId msgId); + const QString &title, + const QString &subtitle, + const QString &msg, + PeerId peerId, + MsgId msgId, + bool hideReplyButton); NotificationData(const NotificationData &other) = delete; NotificationData &operator=(const NotificationData &other) = delete; NotificationData(NotificationData &&other) = delete; NotificationData &operator=(NotificationData &&other) = delete; - bool show(); + bool show(bool hideNameAndPhoto); bool close(); void setImage(const QString &imagePath); @@ -78,10 +82,12 @@ private slots: using Notification = std::shared_ptr; -QDBusArgument &operator<<(QDBusArgument &argument, +QDBusArgument &operator<<( + QDBusArgument &argument, const NotificationData::ImageData &imageData); -const QDBusArgument &operator>>(const QDBusArgument &argument, +const QDBusArgument &operator>>( + const QDBusArgument &argument, NotificationData::ImageData &imageData); class Manager