mirror of https://github.com/procxx/kepka.git
Improve published scheduled notifications.
This commit is contained in:
parent
87addd41b1
commit
07f45b7eab
|
@ -297,6 +297,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
"lng_notification_reply" = "Reply";
|
"lng_notification_reply" = "Reply";
|
||||||
"lng_notification_hide_all" = "Hide all";
|
"lng_notification_hide_all" = "Hide all";
|
||||||
"lng_notification_sample" = "This is a sample notification";
|
"lng_notification_sample" = "This is a sample notification";
|
||||||
|
"lng_notification_reminder" = "Reminder";
|
||||||
|
|
||||||
"lng_settings_section_general" = "General";
|
"lng_settings_section_general" = "General";
|
||||||
"lng_settings_change_lang" = "Change language";
|
"lng_settings_change_lang" = "Change language";
|
||||||
|
|
|
@ -1202,7 +1202,9 @@ void Session::changeMessageId(ChannelId channel, MsgId wasId, MsgId nowId) {
|
||||||
Assert(i != list->end());
|
Assert(i != list->end());
|
||||||
auto owned = std::move(i->second);
|
auto owned = std::move(i->second);
|
||||||
list->erase(i);
|
list->erase(i);
|
||||||
list->emplace(nowId, std::move(owned));
|
const auto [j, ok] = list->emplace(nowId, std::move(owned));
|
||||||
|
|
||||||
|
Ensures(ok);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Session::notifyItemIdChange(IdChange event) {
|
void Session::notifyItemIdChange(IdChange event) {
|
||||||
|
|
|
@ -91,6 +91,9 @@ public:
|
||||||
[[nodiscard]] ScheduledMessages &scheduledMessages() const {
|
[[nodiscard]] ScheduledMessages &scheduledMessages() const {
|
||||||
return *_scheduledMessages;
|
return *_scheduledMessages;
|
||||||
}
|
}
|
||||||
|
[[nodiscard]] MsgId nextNonHistoryEntryId() {
|
||||||
|
return ++_nonHistoryEntryId;
|
||||||
|
}
|
||||||
|
|
||||||
void clear();
|
void clear();
|
||||||
|
|
||||||
|
@ -991,6 +994,7 @@ private:
|
||||||
|
|
||||||
Groups _groups;
|
Groups _groups;
|
||||||
std::unique_ptr<ScheduledMessages> _scheduledMessages;
|
std::unique_ptr<ScheduledMessages> _scheduledMessages;
|
||||||
|
MsgId _nonHistoryEntryId = ServerMaxMsgId;
|
||||||
|
|
||||||
rpl::lifetime _lifetime;
|
rpl::lifetime _lifetime;
|
||||||
|
|
||||||
|
|
|
@ -1658,8 +1658,11 @@ void History::inboxRead(MsgId upTo, std::optional<int> stillUnread) {
|
||||||
}
|
}
|
||||||
|
|
||||||
_firstUnreadView = nullptr;
|
_firstUnreadView = nullptr;
|
||||||
|
if (!peer->isSelf()) {
|
||||||
|
// Only reminders generate notifications in Saved Messages.
|
||||||
session().notifications().clearFromHistory(this);
|
session().notifications().clearFromHistory(this);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void History::inboxRead(not_null<const HistoryItem*> wasRead) {
|
void History::inboxRead(not_null<const HistoryItem*> wasRead) {
|
||||||
if (IsServerMsgId(wasRead->id)) {
|
if (IsServerMsgId(wasRead->id)) {
|
||||||
|
@ -1832,7 +1835,7 @@ void History::getNextFirstUnreadMessage() {
|
||||||
}
|
}
|
||||||
|
|
||||||
MsgId History::nextNonHistoryEntryId() {
|
MsgId History::nextNonHistoryEntryId() {
|
||||||
return ++_nonHistoryEntryId;
|
return owner().nextNonHistoryEntryId();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool History::folderKnown() const {
|
bool History::folderKnown() const {
|
||||||
|
|
|
@ -532,8 +532,6 @@ private:
|
||||||
|
|
||||||
std::deque<not_null<HistoryItem*>> _notifications;
|
std::deque<not_null<HistoryItem*>> _notifications;
|
||||||
|
|
||||||
MsgId _nonHistoryEntryId = ServerMaxMsgId;
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class HistoryBlock {
|
class HistoryBlock {
|
||||||
|
|
|
@ -763,7 +763,7 @@ bool HistoryItem::showNotification() const {
|
||||||
if (channel && !channel->amIn()) {
|
if (channel && !channel->amIn()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return out() ? isFromScheduled() : unread();
|
return (out() || _history->peer->isSelf()) ? isFromScheduled() : unread();
|
||||||
}
|
}
|
||||||
|
|
||||||
void HistoryItem::markClientSideAsRead() {
|
void HistoryItem::markClientSideAsRead() {
|
||||||
|
|
|
@ -1302,7 +1302,7 @@ void HistoryMessage::dependencyItemRemoved(HistoryItem *dependency) {
|
||||||
}
|
}
|
||||||
|
|
||||||
QString HistoryMessage::notificationHeader() const {
|
QString HistoryMessage::notificationHeader() const {
|
||||||
if (out() && isFromScheduled()) {
|
if (out() && isFromScheduled() && !_history->peer->isSelf()) {
|
||||||
return tr::lng_from_you(tr::now);
|
return tr::lng_from_you(tr::now);
|
||||||
} else if (!_history->peer->isUser() && !isPost()) {
|
} else if (!_history->peer->isUser() && !isPost()) {
|
||||||
return App::peerName(from());
|
return App::peerName(from());
|
||||||
|
|
|
@ -2256,6 +2256,9 @@ void HistoryWidget::unreadMessageAdded(not_null<HistoryItem*> item) {
|
||||||
session().api().markMediaRead(item);
|
session().api().markMediaRead(item);
|
||||||
}
|
}
|
||||||
session().api().readServerHistoryForce(_history);
|
session().api().readServerHistoryForce(_history);
|
||||||
|
|
||||||
|
// Also clear possible scheduled messages notifications.
|
||||||
|
session().notifications().clearFromHistory(_history);
|
||||||
}
|
}
|
||||||
|
|
||||||
void HistoryWidget::historyToDown(History *history) {
|
void HistoryWidget::historyToDown(History *history) {
|
||||||
|
@ -2688,19 +2691,23 @@ bool HistoryWidget::isItemCompletelyHidden(HistoryItem *item) const {
|
||||||
|
|
||||||
void HistoryWidget::visibleAreaUpdated() {
|
void HistoryWidget::visibleAreaUpdated() {
|
||||||
if (_list && !_scroll->isHidden()) {
|
if (_list && !_scroll->isHidden()) {
|
||||||
auto scrollTop = _scroll->scrollTop();
|
const auto scrollTop = _scroll->scrollTop();
|
||||||
auto scrollBottom = scrollTop + _scroll->height();
|
const auto scrollBottom = scrollTop + _scroll->height();
|
||||||
_list->visibleAreaUpdated(scrollTop, scrollBottom);
|
_list->visibleAreaUpdated(scrollTop, scrollBottom);
|
||||||
|
const auto atBottom = (scrollTop >= _scroll->scrollTopMax());
|
||||||
if (_history->loadedAtBottom() && (_history->unreadCount() > 0 || (_migrated && _migrated->unreadCount() > 0))) {
|
if (_history->loadedAtBottom() && (_history->unreadCount() > 0 || (_migrated && _migrated->unreadCount() > 0))) {
|
||||||
const auto unread = firstUnreadMessage();
|
const auto unread = firstUnreadMessage();
|
||||||
const auto unreadVisible = unread
|
const auto unreadVisible = unread
|
||||||
&& (scrollBottom > _list->itemTop(unread));
|
&& (scrollBottom > _list->itemTop(unread));
|
||||||
const auto atBottom = (scrollTop >= _scroll->scrollTopMax());
|
|
||||||
if ((unreadVisible || atBottom)
|
if ((unreadVisible || atBottom)
|
||||||
&& App::wnd()->doWeReadServerHistory()) {
|
&& App::wnd()->doWeReadServerHistory()) {
|
||||||
session().api().readServerHistory(_history);
|
session().api().readServerHistory(_history);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (_history->loadedAtBottom() && atBottom) {
|
||||||
|
// Clear possible scheduled messages notifications.
|
||||||
|
session().notifications().clearFromHistory(_history);
|
||||||
|
}
|
||||||
controller()->floatPlayerAreaUpdated().notify(true);
|
controller()->floatPlayerAreaUpdated().notify(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,6 +11,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "platform/platform_info.h"
|
#include "platform/platform_info.h"
|
||||||
#include "platform/mac/mac_utilities.h"
|
#include "platform/mac/mac_utilities.h"
|
||||||
#include "history/history.h"
|
#include "history/history.h"
|
||||||
|
#include "ui/empty_userpic.h"
|
||||||
#include "mainwindow.h"
|
#include "mainwindow.h"
|
||||||
#include "styles/style_window.h"
|
#include "styles/style_window.h"
|
||||||
|
|
||||||
|
@ -237,7 +238,9 @@ void Manager::Private::showNotification(
|
||||||
[notification setSubtitle:Q2NSString(subtitle)];
|
[notification setSubtitle:Q2NSString(subtitle)];
|
||||||
[notification setInformativeText:Q2NSString(msg)];
|
[notification setInformativeText:Q2NSString(msg)];
|
||||||
if (!hideNameAndPhoto && [notification respondsToSelector:@selector(setContentImage:)]) {
|
if (!hideNameAndPhoto && [notification respondsToSelector:@selector(setContentImage:)]) {
|
||||||
auto userpic = peer->genUserpic(st::notifyMacPhotoSize);
|
auto userpic = peer->isSelf()
|
||||||
|
? Ui::EmptyUserpic::GenerateSavedMessages(st::notifyMacPhotoSize)
|
||||||
|
: peer->genUserpic(st::notifyMacPhotoSize);
|
||||||
NSImage *img = [qt_mac_create_nsimage(userpic) autorelease];
|
NSImage *img = [qt_mac_create_nsimage(userpic) autorelease];
|
||||||
[notification setContentImage:img];
|
[notification setContentImage:img];
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,86 +12,15 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "styles/style_history.h"
|
#include "styles/style_history.h"
|
||||||
|
|
||||||
namespace Ui {
|
namespace Ui {
|
||||||
|
namespace {
|
||||||
|
|
||||||
EmptyUserpic::EmptyUserpic(const style::color &color, const QString &name)
|
void PaintSavedMessagesInner(
|
||||||
: _color(color) {
|
|
||||||
fillString(name);
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename Callback>
|
|
||||||
void EmptyUserpic::paint(
|
|
||||||
Painter &p,
|
Painter &p,
|
||||||
int x,
|
int x,
|
||||||
int y,
|
int y,
|
||||||
int outerWidth,
|
|
||||||
int size,
|
|
||||||
Callback paintBackground) const {
|
|
||||||
x = rtl() ? (outerWidth - x - size) : x;
|
|
||||||
|
|
||||||
const auto fontsize = (size * 13) / 33;
|
|
||||||
auto font = st::historyPeerUserpicFont->f;
|
|
||||||
font.setPixelSize(fontsize);
|
|
||||||
|
|
||||||
PainterHighQualityEnabler hq(p);
|
|
||||||
p.setBrush(_color);
|
|
||||||
p.setPen(Qt::NoPen);
|
|
||||||
paintBackground();
|
|
||||||
|
|
||||||
p.setFont(font);
|
|
||||||
p.setBrush(Qt::NoBrush);
|
|
||||||
p.setPen(st::historyPeerUserpicFg);
|
|
||||||
p.drawText(QRect(x, y, size, size), _string, QTextOption(style::al_center));
|
|
||||||
}
|
|
||||||
|
|
||||||
void EmptyUserpic::paint(
|
|
||||||
Painter &p,
|
|
||||||
int x,
|
|
||||||
int y,
|
|
||||||
int outerWidth,
|
|
||||||
int size) const {
|
|
||||||
paint(p, x, y, outerWidth, size, [&p, x, y, size] {
|
|
||||||
p.drawEllipse(x, y, size, size);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
void EmptyUserpic::paintRounded(Painter &p, int x, int y, int outerWidth, int size) const {
|
|
||||||
paint(p, x, y, outerWidth, size, [&p, x, y, size] {
|
|
||||||
p.drawRoundedRect(x, y, size, size, st::buttonRadius, st::buttonRadius);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
void EmptyUserpic::paintSquare(Painter &p, int x, int y, int outerWidth, int size) const {
|
|
||||||
paint(p, x, y, outerWidth, size, [&p, x, y, size] {
|
|
||||||
p.fillRect(x, y, size, size, p.brush());
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
void EmptyUserpic::PaintSavedMessages(
|
|
||||||
Painter &p,
|
|
||||||
int x,
|
|
||||||
int y,
|
|
||||||
int outerWidth,
|
|
||||||
int size) {
|
|
||||||
const auto &bg = st::historyPeerSavedMessagesBg;
|
|
||||||
const auto &fg = st::historyPeerUserpicFg;
|
|
||||||
PaintSavedMessages(p, x, y, outerWidth, size, bg, fg);
|
|
||||||
}
|
|
||||||
|
|
||||||
void EmptyUserpic::PaintSavedMessages(
|
|
||||||
Painter &p,
|
|
||||||
int x,
|
|
||||||
int y,
|
|
||||||
int outerWidth,
|
|
||||||
int size,
|
int size,
|
||||||
const style::color &bg,
|
const style::color &bg,
|
||||||
const style::color &fg) {
|
const style::color &fg) {
|
||||||
x = rtl() ? (outerWidth - x - size) : x;
|
|
||||||
|
|
||||||
PainterHighQualityEnabler hq(p);
|
|
||||||
p.setBrush(bg);
|
|
||||||
p.setPen(Qt::NoPen);
|
|
||||||
p.drawEllipse(x, y, size, size);
|
|
||||||
|
|
||||||
// |<----width----->|
|
// |<----width----->|
|
||||||
//
|
//
|
||||||
// XXXXXXXXXXXXXXXXXX ---
|
// XXXXXXXXXXXXXXXXXX ---
|
||||||
|
@ -160,6 +89,145 @@ void EmptyUserpic::PaintSavedMessages(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template <typename Callback>
|
||||||
|
[[nodiscard]] QPixmap Generate(int size, Callback callback) {
|
||||||
|
auto result = QImage(
|
||||||
|
QSize(size, size) * cIntRetinaFactor(),
|
||||||
|
QImage::Format_ARGB32_Premultiplied);
|
||||||
|
result.setDevicePixelRatio(cRetinaFactor());
|
||||||
|
result.fill(Qt::transparent);
|
||||||
|
{
|
||||||
|
Painter p(&result);
|
||||||
|
callback(p);
|
||||||
|
}
|
||||||
|
return App::pixmapFromImageInPlace(std::move(result));
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace
|
||||||
|
|
||||||
|
EmptyUserpic::EmptyUserpic(const style::color &color, const QString &name)
|
||||||
|
: _color(color) {
|
||||||
|
fillString(name);
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename Callback>
|
||||||
|
void EmptyUserpic::paint(
|
||||||
|
Painter &p,
|
||||||
|
int x,
|
||||||
|
int y,
|
||||||
|
int outerWidth,
|
||||||
|
int size,
|
||||||
|
Callback paintBackground) const {
|
||||||
|
x = rtl() ? (outerWidth - x - size) : x;
|
||||||
|
|
||||||
|
const auto fontsize = (size * 13) / 33;
|
||||||
|
auto font = st::historyPeerUserpicFont->f;
|
||||||
|
font.setPixelSize(fontsize);
|
||||||
|
|
||||||
|
PainterHighQualityEnabler hq(p);
|
||||||
|
p.setBrush(_color);
|
||||||
|
p.setPen(Qt::NoPen);
|
||||||
|
paintBackground();
|
||||||
|
|
||||||
|
p.setFont(font);
|
||||||
|
p.setBrush(Qt::NoBrush);
|
||||||
|
p.setPen(st::historyPeerUserpicFg);
|
||||||
|
p.drawText(QRect(x, y, size, size), _string, QTextOption(style::al_center));
|
||||||
|
}
|
||||||
|
|
||||||
|
void EmptyUserpic::paint(
|
||||||
|
Painter &p,
|
||||||
|
int x,
|
||||||
|
int y,
|
||||||
|
int outerWidth,
|
||||||
|
int size) const {
|
||||||
|
paint(p, x, y, outerWidth, size, [&p, x, y, size] {
|
||||||
|
p.drawEllipse(x, y, size, size);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
void EmptyUserpic::paintRounded(Painter &p, int x, int y, int outerWidth, int size) const {
|
||||||
|
paint(p, x, y, outerWidth, size, [&p, x, y, size] {
|
||||||
|
p.drawRoundedRect(x, y, size, size, st::buttonRadius, st::buttonRadius);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
void EmptyUserpic::paintSquare(Painter &p, int x, int y, int outerWidth, int size) const {
|
||||||
|
paint(p, x, y, outerWidth, size, [&p, x, y, size] {
|
||||||
|
p.fillRect(x, y, size, size, p.brush());
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
void EmptyUserpic::PaintSavedMessages(
|
||||||
|
Painter &p,
|
||||||
|
int x,
|
||||||
|
int y,
|
||||||
|
int outerWidth,
|
||||||
|
int size) {
|
||||||
|
const auto &bg = st::historyPeerSavedMessagesBg;
|
||||||
|
const auto &fg = st::historyPeerUserpicFg;
|
||||||
|
PaintSavedMessages(p, x, y, outerWidth, size, bg, fg);
|
||||||
|
}
|
||||||
|
|
||||||
|
void EmptyUserpic::PaintSavedMessagesRounded(
|
||||||
|
Painter &p,
|
||||||
|
int x,
|
||||||
|
int y,
|
||||||
|
int outerWidth,
|
||||||
|
int size) {
|
||||||
|
const auto &bg = st::historyPeerSavedMessagesBg;
|
||||||
|
const auto &fg = st::historyPeerUserpicFg;
|
||||||
|
PaintSavedMessagesRounded(p, x, y, outerWidth, size, bg, fg);
|
||||||
|
}
|
||||||
|
|
||||||
|
void EmptyUserpic::PaintSavedMessages(
|
||||||
|
Painter &p,
|
||||||
|
int x,
|
||||||
|
int y,
|
||||||
|
int outerWidth,
|
||||||
|
int size,
|
||||||
|
const style::color &bg,
|
||||||
|
const style::color &fg) {
|
||||||
|
x = rtl() ? (outerWidth - x - size) : x;
|
||||||
|
|
||||||
|
PainterHighQualityEnabler hq(p);
|
||||||
|
p.setBrush(bg);
|
||||||
|
p.setPen(Qt::NoPen);
|
||||||
|
p.drawEllipse(x, y, size, size);
|
||||||
|
|
||||||
|
PaintSavedMessagesInner(p, x, y, size, bg, fg);
|
||||||
|
}
|
||||||
|
|
||||||
|
void EmptyUserpic::PaintSavedMessagesRounded(
|
||||||
|
Painter &p,
|
||||||
|
int x,
|
||||||
|
int y,
|
||||||
|
int outerWidth,
|
||||||
|
int size,
|
||||||
|
const style::color &bg,
|
||||||
|
const style::color &fg) {
|
||||||
|
x = rtl() ? (outerWidth - x - size) : x;
|
||||||
|
|
||||||
|
PainterHighQualityEnabler hq(p);
|
||||||
|
p.setBrush(bg);
|
||||||
|
p.setPen(Qt::NoPen);
|
||||||
|
p.drawRoundedRect(x, y, size, size, st::buttonRadius, st::buttonRadius);
|
||||||
|
|
||||||
|
PaintSavedMessagesInner(p, x, y, size, bg, fg);
|
||||||
|
}
|
||||||
|
|
||||||
|
QPixmap EmptyUserpic::GenerateSavedMessages(int size) {
|
||||||
|
return Generate(size, [&](Painter &p) {
|
||||||
|
PaintSavedMessages(p, 0, 0, size, size);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
QPixmap EmptyUserpic::GenerateSavedMessagesRounded(int size) {
|
||||||
|
return Generate(size, [&](Painter &p) {
|
||||||
|
PaintSavedMessagesRounded(p, 0, 0, size, size);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
InMemoryKey EmptyUserpic::uniqueKey() const {
|
InMemoryKey EmptyUserpic::uniqueKey() const {
|
||||||
const auto first = (uint64(0xFFFFFFFFU) << 32)
|
const auto first = (uint64(0xFFFFFFFFU) << 32)
|
||||||
| anim::getPremultiplied(_color->c);
|
| anim::getPremultiplied(_color->c);
|
||||||
|
|
|
@ -40,6 +40,12 @@ public:
|
||||||
int y,
|
int y,
|
||||||
int outerWidth,
|
int outerWidth,
|
||||||
int size);
|
int size);
|
||||||
|
static void PaintSavedMessagesRounded(
|
||||||
|
Painter &p,
|
||||||
|
int x,
|
||||||
|
int y,
|
||||||
|
int outerWidth,
|
||||||
|
int size);
|
||||||
static void PaintSavedMessages(
|
static void PaintSavedMessages(
|
||||||
Painter &p,
|
Painter &p,
|
||||||
int x,
|
int x,
|
||||||
|
@ -48,6 +54,16 @@ public:
|
||||||
int size,
|
int size,
|
||||||
const style::color &bg,
|
const style::color &bg,
|
||||||
const style::color &fg);
|
const style::color &fg);
|
||||||
|
static void PaintSavedMessagesRounded(
|
||||||
|
Painter &p,
|
||||||
|
int x,
|
||||||
|
int y,
|
||||||
|
int outerWidth,
|
||||||
|
int size,
|
||||||
|
const style::color &bg,
|
||||||
|
const style::color &fg);
|
||||||
|
static QPixmap GenerateSavedMessages(int size);
|
||||||
|
static QPixmap GenerateSavedMessagesRounded(int size);
|
||||||
|
|
||||||
~EmptyUserpic();
|
~EmptyUserpic();
|
||||||
|
|
||||||
|
|
|
@ -464,6 +464,8 @@ Manager::DisplayOptions Manager::getNotificationOptions(HistoryItem *item) {
|
||||||
|| (Global::NotifyView() > dbinvShowPreview);
|
|| (Global::NotifyView() > dbinvShowPreview);
|
||||||
result.hideReplyButton = result.hideMessageText
|
result.hideReplyButton = result.hideMessageText
|
||||||
|| !item
|
|| !item
|
||||||
|
|| ((item->out() || item->history()->peer->isSelf())
|
||||||
|
&& item->isFromScheduled())
|
||||||
|| !item->history()->peer->canWrite()
|
|| !item->history()->peer->canWrite()
|
||||||
|| (item->history()->peer->slowmodeSecondsLeft() > 0);
|
|| (item->history()->peer->slowmodeSecondsLeft() > 0);
|
||||||
return result;
|
return result;
|
||||||
|
@ -542,20 +544,31 @@ void NativeManager::doShowNotification(
|
||||||
int forwardedCount) {
|
int forwardedCount) {
|
||||||
const auto options = getNotificationOptions(item);
|
const auto options = getNotificationOptions(item);
|
||||||
|
|
||||||
const auto scheduled = (item->out() && item->isFromScheduled());
|
const auto peer = item->history()->peer;
|
||||||
const auto title = options.hideNameAndPhoto ? qsl("Telegram Desktop") : item->history()->peer->name;
|
const auto scheduled = !options.hideNameAndPhoto
|
||||||
const auto subtitle = options.hideNameAndPhoto ? QString() : item->notificationHeader();
|
&& (item->out() || peer->isSelf())
|
||||||
|
&& item->isFromScheduled();
|
||||||
|
const auto title = options.hideNameAndPhoto
|
||||||
|
? qsl("Telegram Desktop")
|
||||||
|
: (scheduled && peer->isSelf())
|
||||||
|
? tr::lng_notification_reminder(tr::now)
|
||||||
|
: App::peerName(peer);
|
||||||
|
const auto subtitle = options.hideNameAndPhoto
|
||||||
|
? QString()
|
||||||
|
: item->notificationHeader();
|
||||||
const auto text = options.hideMessageText
|
const auto text = options.hideMessageText
|
||||||
? tr::lng_notification_preview(tr::now)
|
? tr::lng_notification_preview(tr::now)
|
||||||
: (forwardedCount < 2
|
: (forwardedCount < 2
|
||||||
? (item->groupId() ? tr::lng_in_dlg_album(tr::now) : item->notificationText())
|
? (item->groupId()
|
||||||
|
? tr::lng_in_dlg_album(tr::now)
|
||||||
|
: item->notificationText())
|
||||||
: tr::lng_forward_messages(tr::now, lt_count, forwardedCount));
|
: tr::lng_forward_messages(tr::now, lt_count, forwardedCount));
|
||||||
|
|
||||||
doShowNativeNotification(
|
doShowNativeNotification(
|
||||||
item->history()->peer,
|
item->history()->peer,
|
||||||
item->id,
|
item->id,
|
||||||
title,
|
scheduled ? WrapFromScheduled(title) : title,
|
||||||
scheduled ? WrapFromScheduled(subtitle) : subtitle,
|
subtitle,
|
||||||
text,
|
text,
|
||||||
options.hideNameAndPhoto,
|
options.hideNameAndPhoto,
|
||||||
options.hideReplyButton);
|
options.hideReplyButton);
|
||||||
|
|
|
@ -13,6 +13,8 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "ui/widgets/buttons.h"
|
#include "ui/widgets/buttons.h"
|
||||||
#include "ui/widgets/input_fields.h"
|
#include "ui/widgets/input_fields.h"
|
||||||
#include "ui/text_options.h"
|
#include "ui/text_options.h"
|
||||||
|
#include "ui/emoji_config.h"
|
||||||
|
#include "ui/empty_userpic.h"
|
||||||
#include "dialogs/dialogs_layout.h"
|
#include "dialogs/dialogs_layout.h"
|
||||||
#include "window/themes/window_theme.h"
|
#include "window/themes/window_theme.h"
|
||||||
#include "styles/style_dialogs.h"
|
#include "styles/style_dialogs.h"
|
||||||
|
@ -74,7 +76,7 @@ Manager::QueuedNotification::QueuedNotification(
|
||||||
, author(item->notificationHeader())
|
, author(item->notificationHeader())
|
||||||
, item((forwardedCount < 2) ? item.get() : nullptr)
|
, item((forwardedCount < 2) ? item.get() : nullptr)
|
||||||
, forwardedCount(forwardedCount)
|
, forwardedCount(forwardedCount)
|
||||||
, fromScheduled(item->out() && item->isFromScheduled()) {
|
, fromScheduled((item->out() || peer->isSelf()) && item->isFromScheduled()) {
|
||||||
}
|
}
|
||||||
|
|
||||||
QPixmap Manager::hiddenUserpicPlaceholder() const {
|
QPixmap Manager::hiddenUserpicPlaceholder() const {
|
||||||
|
@ -680,8 +682,12 @@ void Notification::updateNotifyDisplay() {
|
||||||
p.fillRect(0, st::notifyBorderWidth, st::notifyBorderWidth, h - st::notifyBorderWidth, st::notifyBorder);
|
p.fillRect(0, st::notifyBorderWidth, st::notifyBorderWidth, h - st::notifyBorderWidth, st::notifyBorder);
|
||||||
|
|
||||||
if (!options.hideNameAndPhoto) {
|
if (!options.hideNameAndPhoto) {
|
||||||
|
if (_fromScheduled && _history->peer->isSelf()) {
|
||||||
|
Ui::EmptyUserpic::PaintSavedMessages(p, st::notifyPhotoPos.x(), st::notifyPhotoPos.y(), width(), st::notifyPhotoSize);
|
||||||
|
} else {
|
||||||
_history->peer->loadUserpic();
|
_history->peer->loadUserpic();
|
||||||
_history->peer->paintUserpicLeft(p, st::notifyPhotoPos.x(), st::notifyPhotoPos.y(), width(), st::notifyPhotoSize);
|
_history->peer->paintUserpicLeft(p, st::notifyPhotoPos.x(), st::notifyPhotoPos.y(), width(), st::notifyPhotoSize);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
p.drawPixmap(st::notifyPhotoPos.x(), st::notifyPhotoPos.y(), manager()->hiddenUserpicPlaceholder());
|
p.drawPixmap(st::notifyPhotoPos.x(), st::notifyPhotoPos.y(), manager()->hiddenUserpicPlaceholder());
|
||||||
}
|
}
|
||||||
|
@ -689,7 +695,15 @@ void Notification::updateNotifyDisplay() {
|
||||||
int32 itemWidth = w - st::notifyPhotoPos.x() - st::notifyPhotoSize - st::notifyTextLeft - st::notifyClosePos.x() - st::notifyClose.width;
|
int32 itemWidth = w - st::notifyPhotoPos.x() - st::notifyPhotoSize - st::notifyTextLeft - st::notifyClosePos.x() - st::notifyClose.width;
|
||||||
|
|
||||||
QRect rectForName(st::notifyPhotoPos.x() + st::notifyPhotoSize + st::notifyTextLeft, st::notifyTextTop, itemWidth, st::msgNameFont->height);
|
QRect rectForName(st::notifyPhotoPos.x() + st::notifyPhotoSize + st::notifyTextLeft, st::notifyTextTop, itemWidth, st::msgNameFont->height);
|
||||||
|
const auto reminder = _fromScheduled && _history->peer->isSelf();
|
||||||
if (!options.hideNameAndPhoto) {
|
if (!options.hideNameAndPhoto) {
|
||||||
|
if (_fromScheduled) {
|
||||||
|
static const auto emoji = Ui::Emoji::Find(QString::fromUtf8("\xF0\x9F\x93\x85"));
|
||||||
|
const auto size = Ui::Emoji::GetSizeNormal() / cIntRetinaFactor();
|
||||||
|
const auto top = rectForName.top() + (st::msgNameFont->height - size) / 2;
|
||||||
|
Ui::Emoji::Draw(p, emoji, Ui::Emoji::GetSizeNormal(), rectForName.left(), top);
|
||||||
|
rectForName.setLeft(rectForName.left() + size + st::msgNameFont->spacew);
|
||||||
|
}
|
||||||
if (const auto chatTypeIcon = Dialogs::Layout::ChatTypeIcon(_history->peer, false, false)) {
|
if (const auto chatTypeIcon = Dialogs::Layout::ChatTypeIcon(_history->peer, false, false)) {
|
||||||
chatTypeIcon->paint(p, rectForName.topLeft(), w);
|
chatTypeIcon->paint(p, rectForName.topLeft(), w);
|
||||||
rectForName.setLeft(rectForName.left() + st::dialogsChatTypeSkip);
|
rectForName.setLeft(rectForName.left() + st::dialogsChatTypeSkip);
|
||||||
|
@ -707,7 +721,9 @@ void Notification::updateNotifyDisplay() {
|
||||||
p.setPen(st::dialogsTextFg);
|
p.setPen(st::dialogsTextFg);
|
||||||
p.setFont(st::dialogsTextFont);
|
p.setFont(st::dialogsTextFont);
|
||||||
const auto text = _item
|
const auto text = _item
|
||||||
? _item->inDialogsText(HistoryItem::DrawInDialog::Normal)
|
? _item->inDialogsText(reminder
|
||||||
|
? HistoryItem::DrawInDialog::WithoutSender
|
||||||
|
: HistoryItem::DrawInDialog::Normal)
|
||||||
: ((!_author.isEmpty()
|
: ((!_author.isEmpty()
|
||||||
? textcmdLink(1, _author)
|
? textcmdLink(1, _author)
|
||||||
: QString())
|
: QString())
|
||||||
|
@ -724,10 +740,7 @@ void Notification::updateNotifyDisplay() {
|
||||||
0,
|
0,
|
||||||
Qt::LayoutDirectionAuto,
|
Qt::LayoutDirectionAuto,
|
||||||
};
|
};
|
||||||
itemTextCache.setText(
|
itemTextCache.setText(st::dialogsTextStyle, text, Options);
|
||||||
st::dialogsTextStyle,
|
|
||||||
_fromScheduled ? WrapFromScheduled(text) : text,
|
|
||||||
Options);
|
|
||||||
itemTextCache.drawElided(
|
itemTextCache.drawElided(
|
||||||
p,
|
p,
|
||||||
r.left(),
|
r.left(),
|
||||||
|
@ -747,12 +760,15 @@ void Notification::updateNotifyDisplay() {
|
||||||
}
|
}
|
||||||
|
|
||||||
p.setPen(st::dialogsNameFg);
|
p.setPen(st::dialogsNameFg);
|
||||||
if (!options.hideNameAndPhoto) {
|
if (options.hideNameAndPhoto) {
|
||||||
_history->peer->nameText().drawElided(p, rectForName.left(), rectForName.top(), rectForName.width());
|
|
||||||
} else {
|
|
||||||
p.setFont(st::msgNameFont);
|
p.setFont(st::msgNameFont);
|
||||||
static QString notifyTitle = st::msgNameFont->elided(qsl("Telegram Desktop"), rectForName.width());
|
static QString notifyTitle = st::msgNameFont->elided(qsl("Telegram Desktop"), rectForName.width());
|
||||||
p.drawText(rectForName.left(), rectForName.top() + st::msgNameFont->ascent, notifyTitle);
|
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());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -10,6 +10,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "platform/platform_specific.h"
|
#include "platform/platform_specific.h"
|
||||||
#include "core/application.h"
|
#include "core/application.h"
|
||||||
#include "data/data_peer.h"
|
#include "data/data_peer.h"
|
||||||
|
#include "ui/empty_userpic.h"
|
||||||
#include "styles/style_window.h"
|
#include "styles/style_window.h"
|
||||||
|
|
||||||
namespace Window {
|
namespace Window {
|
||||||
|
@ -45,7 +46,12 @@ QString CachedUserpics::get(const InMemoryKey &key, PeerData *peer) {
|
||||||
}
|
}
|
||||||
v.path = cWorkingDir() + qsl("tdata/temp/") + QString::number(rand_value<uint64>(), 16) + qsl(".png");
|
v.path = cWorkingDir() + qsl("tdata/temp/") + QString::number(rand_value<uint64>(), 16) + qsl(".png");
|
||||||
if (key.first || key.second) {
|
if (key.first || key.second) {
|
||||||
if (_type == Type::Rounded) {
|
if (peer->isSelf()) {
|
||||||
|
const auto method = _type == Type::Rounded
|
||||||
|
? Ui::EmptyUserpic::GenerateSavedMessagesRounded
|
||||||
|
: Ui::EmptyUserpic::GenerateSavedMessages;
|
||||||
|
method(st::notifyMacPhotoSize).save(v.path, "PNG");
|
||||||
|
} else if (_type == Type::Rounded) {
|
||||||
peer->saveUserpicRounded(v.path, st::notifyMacPhotoSize);
|
peer->saveUserpicRounded(v.path, st::notifyMacPhotoSize);
|
||||||
} else {
|
} else {
|
||||||
peer->saveUserpic(v.path, st::notifyMacPhotoSize);
|
peer->saveUserpic(v.path, st::notifyMacPhotoSize);
|
||||||
|
|
Loading…
Reference in New Issue