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(
|
NotificationData::NotificationData(
|
||||||
const std::shared_ptr<QDBusInterface> ¬ificationInterface,
|
const std::shared_ptr<QDBusInterface> ¬ificationInterface,
|
||||||
const base::weak_ptr<Manager> &manager,
|
const base::weak_ptr<Manager> &manager,
|
||||||
const QString &title, const QString &subtitle,
|
const QString &title,
|
||||||
const QString &msg, PeerId peerId, MsgId msgId)
|
const QString &subtitle,
|
||||||
|
const QString &msg,
|
||||||
|
PeerId peerId,
|
||||||
|
MsgId msgId,
|
||||||
|
bool hideReplyButton)
|
||||||
: _notificationInterface(notificationInterface)
|
: _notificationInterface(notificationInterface)
|
||||||
, _manager(manager)
|
, _manager(manager)
|
||||||
, _title(title)
|
, _title(title)
|
||||||
|
@ -120,7 +124,7 @@ NotificationData::NotificationData(
|
||||||
this,
|
this,
|
||||||
SLOT(notificationClicked(uint,QString)));
|
SLOT(notificationClicked(uint,QString)));
|
||||||
|
|
||||||
if (capabilities.contains(qsl("inline-reply"))) {
|
if (capabilities.contains(qsl("inline-reply")) && !hideReplyButton) {
|
||||||
_actions << qsl("inline-reply")
|
_actions << qsl("inline-reply")
|
||||||
<< tr::lng_notification_reply(tr::now);
|
<< tr::lng_notification_reply(tr::now);
|
||||||
|
|
||||||
|
@ -169,12 +173,14 @@ NotificationData::NotificationData(
|
||||||
SLOT(notificationClosed(uint)));
|
SLOT(notificationClosed(uint)));
|
||||||
}
|
}
|
||||||
|
|
||||||
bool NotificationData::show() {
|
bool NotificationData::show(bool hideNameAndPhoto) {
|
||||||
const QDBusReply<uint> notifyReply = _notificationInterface->call(
|
const QDBusReply<uint> notifyReply = _notificationInterface->call(
|
||||||
qsl("Notify"),
|
qsl("Notify"),
|
||||||
AppName.utf16(),
|
AppName.utf16(),
|
||||||
uint(0),
|
uint(0),
|
||||||
QString(),
|
hideNameAndPhoto
|
||||||
|
? qsl("telegram")
|
||||||
|
: QString(),
|
||||||
_title,
|
_title,
|
||||||
_body,
|
_body,
|
||||||
_actions,
|
_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) {
|
const NotificationData::ImageData &imageData) {
|
||||||
argument.beginStructure();
|
argument.beginStructure();
|
||||||
argument << imageData.width
|
argument << imageData.width
|
||||||
|
@ -299,7 +306,8 @@ QDBusArgument &operator<<(QDBusArgument &argument,
|
||||||
return argument;
|
return argument;
|
||||||
}
|
}
|
||||||
|
|
||||||
const QDBusArgument &operator>>(const QDBusArgument &argument,
|
const QDBusArgument &operator>>(
|
||||||
|
const QDBusArgument &argument,
|
||||||
NotificationData::ImageData &imageData) {
|
NotificationData::ImageData &imageData) {
|
||||||
argument.beginStructure();
|
argument.beginStructure();
|
||||||
argument >> imageData.width
|
argument >> imageData.width
|
||||||
|
@ -380,12 +388,13 @@ void Manager::Private::showNotification(
|
||||||
subtitle,
|
subtitle,
|
||||||
msg,
|
msg,
|
||||||
peer->id,
|
peer->id,
|
||||||
msgId);
|
msgId,
|
||||||
|
hideReplyButton);
|
||||||
|
|
||||||
const auto key = hideNameAndPhoto
|
if (!hideNameAndPhoto) {
|
||||||
? InMemoryKey()
|
const auto key = peer->userpicUniqueKey();
|
||||||
: peer->userpicUniqueKey();
|
notification->setImage(_cachedUserpics.get(key, peer));
|
||||||
notification->setImage(_cachedUserpics.get(key, peer));
|
}
|
||||||
|
|
||||||
auto i = _notifications.find(peer->id);
|
auto i = _notifications.find(peer->id);
|
||||||
if (i != _notifications.cend()) {
|
if (i != _notifications.cend()) {
|
||||||
|
@ -401,7 +410,7 @@ void Manager::Private::showNotification(
|
||||||
i = _notifications.insert(peer->id, QMap<MsgId, Notification>());
|
i = _notifications.insert(peer->id, QMap<MsgId, Notification>());
|
||||||
}
|
}
|
||||||
_notifications[peer->id].insert(msgId, notification);
|
_notifications[peer->id].insert(msgId, notification);
|
||||||
if (!notification->show()) {
|
if (!notification->show(hideNameAndPhoto)) {
|
||||||
i = _notifications.find(peer->id);
|
i = _notifications.find(peer->id);
|
||||||
if (i != _notifications.cend()) {
|
if (i != _notifications.cend()) {
|
||||||
i->remove(msgId);
|
i->remove(msgId);
|
||||||
|
|
|
@ -38,15 +38,19 @@ public:
|
||||||
NotificationData(
|
NotificationData(
|
||||||
const std::shared_ptr<QDBusInterface> ¬ificationInterface,
|
const std::shared_ptr<QDBusInterface> ¬ificationInterface,
|
||||||
const base::weak_ptr<Manager> &manager,
|
const base::weak_ptr<Manager> &manager,
|
||||||
const QString &title, const QString &subtitle,
|
const QString &title,
|
||||||
const QString &msg, PeerId peerId, MsgId msgId);
|
const QString &subtitle,
|
||||||
|
const QString &msg,
|
||||||
|
PeerId peerId,
|
||||||
|
MsgId msgId,
|
||||||
|
bool hideReplyButton);
|
||||||
|
|
||||||
NotificationData(const NotificationData &other) = delete;
|
NotificationData(const NotificationData &other) = delete;
|
||||||
NotificationData &operator=(const NotificationData &other) = delete;
|
NotificationData &operator=(const NotificationData &other) = delete;
|
||||||
NotificationData(NotificationData &&other) = delete;
|
NotificationData(NotificationData &&other) = delete;
|
||||||
NotificationData &operator=(NotificationData &&other) = delete;
|
NotificationData &operator=(NotificationData &&other) = delete;
|
||||||
|
|
||||||
bool show();
|
bool show(bool hideNameAndPhoto);
|
||||||
bool close();
|
bool close();
|
||||||
void setImage(const QString &imagePath);
|
void setImage(const QString &imagePath);
|
||||||
|
|
||||||
|
@ -78,10 +82,12 @@ private slots:
|
||||||
|
|
||||||
using Notification = std::shared_ptr<NotificationData>;
|
using Notification = std::shared_ptr<NotificationData>;
|
||||||
|
|
||||||
QDBusArgument &operator<<(QDBusArgument &argument,
|
QDBusArgument &operator<<(
|
||||||
|
QDBusArgument &argument,
|
||||||
const NotificationData::ImageData &imageData);
|
const NotificationData::ImageData &imageData);
|
||||||
|
|
||||||
const QDBusArgument &operator>>(const QDBusArgument &argument,
|
const QDBusArgument &operator>>(
|
||||||
|
const QDBusArgument &argument,
|
||||||
NotificationData::ImageData &imageData);
|
NotificationData::ImageData &imageData);
|
||||||
|
|
||||||
class Manager
|
class Manager
|
||||||
|
|
Loading…
Reference in New Issue