mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-05 22:54:01 +02:00
Format markup-lacking Linux notifications using lng_dialogs_text_with_from
This commit is contained in:
parent
25cd6106f5
commit
9bdc19e2fd
1 changed files with 25 additions and 14 deletions
|
@ -537,17 +537,23 @@ void Manager::Private::showNotification(
|
||||||
.msgId = info.itemId,
|
.msgId = info.itemId,
|
||||||
};
|
};
|
||||||
auto notification = _application
|
auto notification = _application
|
||||||
? Gio::Notification::new_(
|
? Gio::Notification::new_(info.title.toStdString())
|
||||||
info.subtitle.isEmpty()
|
|
||||||
? info.title.toStdString()
|
|
||||||
: info.subtitle.toStdString()
|
|
||||||
+ " (" + info.title.toStdString() + ')')
|
|
||||||
: Gio::Notification();
|
: Gio::Notification();
|
||||||
|
|
||||||
std::vector<gi::cstring> actions;
|
std::vector<gi::cstring> actions;
|
||||||
auto hints = GLib::VariantDict::new_();
|
auto hints = GLib::VariantDict::new_();
|
||||||
if (notification) {
|
if (notification) {
|
||||||
notification.set_body(info.message.toStdString());
|
notification.set_body(info.subtitle.isEmpty()
|
||||||
|
? info.message.toStdString()
|
||||||
|
: tr::lng_dialogs_text_with_from(
|
||||||
|
tr::now,
|
||||||
|
lt_from_part,
|
||||||
|
tr::lng_dialogs_text_from_wrapped(
|
||||||
|
tr::now,
|
||||||
|
lt_from,
|
||||||
|
info.subtitle),
|
||||||
|
lt_message,
|
||||||
|
info.message).toStdString());
|
||||||
|
|
||||||
notification.set_icon(
|
notification.set_icon(
|
||||||
Gio::ThemedIcon::new_(ApplicationIconName().toStdString()));
|
Gio::ThemedIcon::new_(ApplicationIconName().toStdString()));
|
||||||
|
@ -726,8 +732,6 @@ void Manager::Private::showNotification(
|
||||||
const auto hasImage = !imageKey.empty()
|
const auto hasImage = !imageKey.empty()
|
||||||
&& hints.lookup_value(imageKey);
|
&& hints.lookup_value(imageKey);
|
||||||
|
|
||||||
const auto hasBodyMarkup = HasCapability("body-markup");
|
|
||||||
|
|
||||||
const auto callbackWrap = gi::unwrap(
|
const auto callbackWrap = gi::unwrap(
|
||||||
Gio::AsyncReadyCallback(
|
Gio::AsyncReadyCallback(
|
||||||
crl::guard(this, [=](
|
crl::guard(this, [=](
|
||||||
|
@ -766,17 +770,24 @@ void Manager::Private::showNotification(
|
||||||
(!hasImage
|
(!hasImage
|
||||||
? ApplicationIconName().toStdString()
|
? ApplicationIconName().toStdString()
|
||||||
: std::string()).c_str(),
|
: std::string()).c_str(),
|
||||||
(hasBodyMarkup || info.subtitle.isEmpty()
|
info.title.toStdString().c_str(),
|
||||||
? info.title.toStdString()
|
(HasCapability("body-markup")
|
||||||
: info.subtitle.toStdString()
|
|
||||||
+ " (" + info.title.toStdString() + ')').c_str(),
|
|
||||||
(hasBodyMarkup
|
|
||||||
? info.subtitle.isEmpty()
|
? info.subtitle.isEmpty()
|
||||||
? info.message.toHtmlEscaped().toStdString()
|
? info.message.toHtmlEscaped().toStdString()
|
||||||
: u"<b>%1</b>\n%2"_q.arg(
|
: u"<b>%1</b>\n%2"_q.arg(
|
||||||
info.subtitle.toHtmlEscaped(),
|
info.subtitle.toHtmlEscaped(),
|
||||||
info.message.toHtmlEscaped()).toStdString()
|
info.message.toHtmlEscaped()).toStdString()
|
||||||
: info.message.toStdString()).c_str(),
|
: info.subtitle.isEmpty()
|
||||||
|
? info.message.toStdString()
|
||||||
|
: tr::lng_dialogs_text_with_from(
|
||||||
|
tr::now,
|
||||||
|
lt_from_part,
|
||||||
|
tr::lng_dialogs_text_from_wrapped(
|
||||||
|
tr::now,
|
||||||
|
lt_from,
|
||||||
|
info.subtitle),
|
||||||
|
lt_message,
|
||||||
|
info.message).toStdString()).c_str(),
|
||||||
!actions.empty()
|
!actions.empty()
|
||||||
? (actions
|
? (actions
|
||||||
| ranges::views::transform(&gi::cstring::c_str)
|
| ranges::views::transform(&gi::cstring::c_str)
|
||||||
|
|
Loading…
Add table
Reference in a new issue