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