mirror of
https://github.com/telegramdesktop/tdesktop
synced 2024-12-29 01:52:48 +00:00
Add target account name to notifications.
This commit is contained in:
parent
997913be25
commit
5433c16244
@ -99,11 +99,11 @@ Application::Application(not_null<Launcher*> launcher)
|
||||
, _fallbackProductionConfig(
|
||||
std::make_unique<MTP::Config>(MTP::Environment::Production))
|
||||
, _domain(std::make_unique<Main::Domain>(cDataFile()))
|
||||
, _notifications(std::make_unique<Window::Notifications::System>())
|
||||
, _langpack(std::make_unique<Lang::Instance>())
|
||||
, _langCloudManager(std::make_unique<Lang::CloudManager>(langpack()))
|
||||
, _emojiKeywords(std::make_unique<ChatHelpers::EmojiKeywords>())
|
||||
, _audio(std::make_unique<Media::Audio::Instance>())
|
||||
, _notifications(std::make_unique<Window::Notifications::System>())
|
||||
, _logo(Window::LoadLogo())
|
||||
, _logoNoMargin(Window::LoadLogoNoMargin())
|
||||
, _autoLockTimer([=] { checkAutoLock(); }) {
|
||||
|
@ -31,6 +31,7 @@ protected:
|
||||
void doClearAllFast() override;
|
||||
void doClearFromHistory(not_null<History*> history) override;
|
||||
void doClearFromSession(not_null<Main::Session*> session) override;
|
||||
QString accountNameSeparator() override;
|
||||
|
||||
private:
|
||||
class Private;
|
||||
|
@ -386,5 +386,9 @@ void Manager::doClearFromSession(not_null<Main::Session*> session) {
|
||||
_private->clearFromSession(session);
|
||||
}
|
||||
|
||||
QString Manager::accountNameSeparator() {
|
||||
return QString::fromUtf8(" \xE2\x86\x92 ");
|
||||
}
|
||||
|
||||
} // namespace Notifications
|
||||
} // namespace Platform
|
||||
|
@ -18,6 +18,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||
#include "lang/lang_keys.h"
|
||||
#include "data/data_session.h"
|
||||
#include "data/data_channel.h"
|
||||
#include "data/data_user.h"
|
||||
#include "base/unixtime.h"
|
||||
#include "window/window_session_controller.h"
|
||||
#include "core/application.h"
|
||||
@ -547,6 +548,18 @@ Manager::DisplayOptions Manager::GetNotificationOptions(HistoryItem *item) {
|
||||
return result;
|
||||
}
|
||||
|
||||
QString Manager::addTargetAccountName(
|
||||
const QString &title,
|
||||
not_null<Main::Session*> session) {
|
||||
return (Core::App().domain().accounts().size() > 1)
|
||||
? (title + accountNameSeparator() + session->user()->name)
|
||||
: title;
|
||||
}
|
||||
|
||||
QString Manager::accountNameSeparator() {
|
||||
return QString::fromUtf8(" \xE2\x9E\x9C ");
|
||||
}
|
||||
|
||||
void Manager::notificationActivated(NotificationId id) {
|
||||
onBeforeNotificationActivated(id);
|
||||
if (const auto session = system()->findSession(id.selfId)) {
|
||||
@ -644,6 +657,7 @@ void NativeManager::doShowNotification(
|
||||
: (scheduled && peer->isSelf())
|
||||
? tr::lng_notification_reminder(tr::now)
|
||||
: peer->name;
|
||||
const auto fullTitle = addTargetAccountName(title, &peer->session());
|
||||
const auto subtitle = options.hideNameAndPhoto
|
||||
? QString()
|
||||
: item->notificationHeader();
|
||||
@ -661,7 +675,7 @@ void NativeManager::doShowNotification(
|
||||
item->history()->peer,
|
||||
userpicView,
|
||||
item->id,
|
||||
scheduled ? WrapFromScheduled(title) : title,
|
||||
scheduled ? WrapFromScheduled(fullTitle) : fullTitle,
|
||||
subtitle,
|
||||
text,
|
||||
options.hideNameAndPhoto,
|
||||
|
@ -186,6 +186,10 @@ public:
|
||||
[[nodiscard]] static DisplayOptions GetNotificationOptions(
|
||||
HistoryItem *item);
|
||||
|
||||
[[nodiscard]] QString addTargetAccountName(
|
||||
const QString &title,
|
||||
not_null<Main::Session*> session);
|
||||
|
||||
virtual ~Manager() = default;
|
||||
|
||||
protected:
|
||||
@ -206,6 +210,7 @@ protected:
|
||||
}
|
||||
virtual void onAfterNotificationActivated(NotificationId id) {
|
||||
}
|
||||
[[nodiscard]] virtual QString accountNameSeparator();
|
||||
|
||||
private:
|
||||
void openNotificationMessage(
|
||||
|
@ -812,16 +812,17 @@ void Notification::updateNotifyDisplay() {
|
||||
}
|
||||
|
||||
p.setPen(st::dialogsNameFg);
|
||||
if (options.hideNameAndPhoto) {
|
||||
p.setFont(st::msgNameFont);
|
||||
static QString notifyTitle = st::msgNameFont->elided(qsl("Telegram Desktop"), rectForName.width());
|
||||
p.drawText(rectForName.left(), rectForName.top() + st::msgNameFont->ascent, notifyTitle);
|
||||
} else if (reminder) {
|
||||
p.setFont(st::msgNameFont);
|
||||
p.drawText(rectForName.left(), rectForName.top() + st::msgNameFont->ascent, tr::lng_notification_reminder(tr::now));
|
||||
} else {
|
||||
_history->peer->nameText().drawElided(p, rectForName.left(), rectForName.top(), rectForName.width());
|
||||
}
|
||||
Ui::Text::String titleText;
|
||||
const auto title = options.hideNameAndPhoto
|
||||
? qsl("Telegram Desktop")
|
||||
: reminder
|
||||
? tr::lng_notification_reminder(tr::now)
|
||||
: _history->peer->nameText().toString();
|
||||
const auto fullTitle = manager()->addTargetAccountName(
|
||||
title,
|
||||
&_history->session());
|
||||
titleText.setText(st::msgNameStyle, fullTitle, Ui::NameTextOptions());
|
||||
titleText.drawElided(p, rectForName.left(), rectForName.top(), rectForName.width());
|
||||
}
|
||||
|
||||
_cache = App::pixmapFromImageInPlace(std::move(img));
|
||||
|
@ -152,7 +152,7 @@ protected:
|
||||
virtual void updateGeometry(int x, int y, int width, int height);
|
||||
|
||||
protected:
|
||||
not_null<Manager*> manager() const {
|
||||
[[nodiscard]] not_null<Manager*> manager() const {
|
||||
return _manager;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user