Follow hidding reply setting in native notifications on Linux, use system icon
This commit is contained in:
parent
9979c220ce
commit
2b0e62dafe
|
@ -88,8 +88,12 @@ QVersionNumber ParseSpecificationVersion(
|
|||
NotificationData::NotificationData(
|
||||
const std::shared_ptr<QDBusInterface> ¬ificationInterface,
|
||||
const base::weak_ptr<Manager> &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<uint> 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<MsgId, Notification>());
|
||||
}
|
||||
_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);
|
||||
|
|
|
@ -38,15 +38,19 @@ public:
|
|||
NotificationData(
|
||||
const std::shared_ptr<QDBusInterface> ¬ificationInterface,
|
||||
const base::weak_ptr<Manager> &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<NotificationData>;
|
||||
|
||||
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
|
||||
|
|
Loading…
Reference in New Issue