mirror of
https://github.com/telegramdesktop/tdesktop
synced 2025-04-01 23:00:58 +00:00
Added tooltip with forwards count to views info for channel messages.
This commit is contained in:
parent
5751d29c47
commit
4824b26afd
@ -1647,6 +1647,10 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||||||
"lng_edited" = "edited";
|
"lng_edited" = "edited";
|
||||||
"lng_edited_date" = "Edited: {date}";
|
"lng_edited_date" = "Edited: {date}";
|
||||||
"lng_sent_date" = "Sent: {date}";
|
"lng_sent_date" = "Sent: {date}";
|
||||||
|
"lng_views_tooltip#one" = "Views: {count}";
|
||||||
|
"lng_views_tooltip#other" = "Views: {count}";
|
||||||
|
"lng_forwards_tooltip#one" = "Forwards: {count}";
|
||||||
|
"lng_forwards_tooltip#other" = "Forwards: {count}";
|
||||||
"lng_imported" = "imported";
|
"lng_imported" = "imported";
|
||||||
"lng_admin_badge" = "admin";
|
"lng_admin_badge" = "admin";
|
||||||
"lng_owner_badge" = "owner";
|
"lng_owner_badge" = "owner";
|
||||||
|
@ -62,6 +62,7 @@ struct HistoryMessageViews : public RuntimeComponent<HistoryMessageViews, Histor
|
|||||||
MsgId commentsRootId = 0;
|
MsgId commentsRootId = 0;
|
||||||
MsgId commentsInboxReadTillId = 0;
|
MsgId commentsInboxReadTillId = 0;
|
||||||
MsgId commentsMaxId = 0;
|
MsgId commentsMaxId = 0;
|
||||||
|
int forwardsCount = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct HistoryMessageSigned : public RuntimeComponent<HistoryMessageSigned, HistoryItem> {
|
struct HistoryMessageSigned : public RuntimeComponent<HistoryMessageSigned, HistoryItem> {
|
||||||
|
@ -1585,6 +1585,15 @@ bool HistoryMessage::changeViewsCount(int count) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void HistoryMessage::setForwardsCount(int count) {
|
void HistoryMessage::setForwardsCount(int count) {
|
||||||
|
const auto views = Get<HistoryMessageViews>();
|
||||||
|
if (!views
|
||||||
|
|| views->forwardsCount == count
|
||||||
|
|| (count >= 0 && views->forwardsCount > count)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
views->forwardsCount = count;
|
||||||
|
history()->owner().notifyItemDataChange(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
void HistoryMessage::setPostAuthor(const QString &author) {
|
void HistoryMessage::setPostAuthor(const QString &author) {
|
||||||
|
@ -131,6 +131,35 @@ TextState BottomInfo::textState(
|
|||||||
if (_data.flags & (Data::Flag::OutLayout | Data::Flag::Sending)) {
|
if (_data.flags & (Data::Flag::OutLayout | Data::Flag::Sending)) {
|
||||||
withTicksWidth += st::historySendStateSpace;
|
withTicksWidth += st::historySendStateSpace;
|
||||||
}
|
}
|
||||||
|
if (!_views.isEmpty()) {
|
||||||
|
const auto viewsWidth = _views.maxWidth();
|
||||||
|
const auto right = width()
|
||||||
|
- withTicksWidth
|
||||||
|
- ((_data.flags & Data::Flag::Pinned) ? st::historyPinWidth : 0)
|
||||||
|
- st::historyViewsSpace
|
||||||
|
- st::historyViewsWidth
|
||||||
|
- viewsWidth;
|
||||||
|
const auto inViews = QRect(
|
||||||
|
right,
|
||||||
|
0,
|
||||||
|
withTicksWidth + st::historyViewsWidth,
|
||||||
|
st::msgDateFont->height
|
||||||
|
).contains(position);
|
||||||
|
if (inViews) {
|
||||||
|
result.customTooltip = true;
|
||||||
|
const auto fullViews = tr::lng_views_tooltip(
|
||||||
|
tr::now,
|
||||||
|
lt_count_decimal,
|
||||||
|
*_data.views);
|
||||||
|
const auto fullForwards = _data.forwardsCount
|
||||||
|
? ('\n' + tr::lng_forwards_tooltip(
|
||||||
|
tr::now,
|
||||||
|
lt_count_decimal,
|
||||||
|
*_data.forwardsCount))
|
||||||
|
: QString();
|
||||||
|
result.customTooltipText = fullViews + fullForwards;
|
||||||
|
}
|
||||||
|
}
|
||||||
const auto inTime = QRect(
|
const auto inTime = QRect(
|
||||||
width() - withTicksWidth,
|
width() - withTicksWidth,
|
||||||
0,
|
0,
|
||||||
@ -637,6 +666,9 @@ BottomInfo::Data BottomInfoDataFromMessage(not_null<Message*> message) {
|
|||||||
if (views->replies.count >= 0 && !views->commentsMegagroupId) {
|
if (views->replies.count >= 0 && !views->commentsMegagroupId) {
|
||||||
result.replies = views->replies.count;
|
result.replies = views->replies.count;
|
||||||
}
|
}
|
||||||
|
if (views->forwardsCount > 0) {
|
||||||
|
result.forwardsCount = views->forwardsCount;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (item->isSending() || item->hasFailed()) {
|
if (item->isSending() || item->hasFailed()) {
|
||||||
result.flags |= Flag::Sending;
|
result.flags |= Flag::Sending;
|
||||||
|
@ -55,6 +55,7 @@ public:
|
|||||||
std::vector<MessageReaction> reactions;
|
std::vector<MessageReaction> reactions;
|
||||||
std::optional<int> views;
|
std::optional<int> views;
|
||||||
std::optional<int> replies;
|
std::optional<int> replies;
|
||||||
|
std::optional<int> forwardsCount;
|
||||||
Flags flags;
|
Flags flags;
|
||||||
};
|
};
|
||||||
BottomInfo(not_null<::Data::Reactions*> reactionsOwner, Data &&data);
|
BottomInfo(not_null<::Data::Reactions*> reactionsOwner, Data &&data);
|
||||||
|
@ -1723,7 +1723,8 @@ TextState Message::textState(
|
|||||||
point,
|
point,
|
||||||
InfoDisplayType::Default);
|
InfoDisplayType::Default);
|
||||||
if (bottomInfoResult.link
|
if (bottomInfoResult.link
|
||||||
|| bottomInfoResult.cursor != CursorState::None) {
|
|| bottomInfoResult.cursor != CursorState::None
|
||||||
|
|| bottomInfoResult.customTooltip) {
|
||||||
result = bottomInfoResult;
|
result = bottomInfoResult;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -387,7 +387,8 @@ TextState ExtendedPreview::textState(QPoint point, StateRequest request) const {
|
|||||||
point,
|
point,
|
||||||
InfoDisplayType::Image);
|
InfoDisplayType::Image);
|
||||||
if (bottomInfoResult.link
|
if (bottomInfoResult.link
|
||||||
|| bottomInfoResult.cursor != CursorState::None) {
|
|| bottomInfoResult.cursor != CursorState::None
|
||||||
|
|| bottomInfoResult.customTooltip) {
|
||||||
return bottomInfoResult;
|
return bottomInfoResult;
|
||||||
}
|
}
|
||||||
if (const auto size = bubble ? std::nullopt : _parent->rightActionSize()) {
|
if (const auto size = bubble ? std::nullopt : _parent->rightActionSize()) {
|
||||||
|
@ -961,7 +961,8 @@ TextState Gif::textState(QPoint point, StateRequest request) const {
|
|||||||
? InfoDisplayType::Background
|
? InfoDisplayType::Background
|
||||||
: InfoDisplayType::Image));
|
: InfoDisplayType::Image));
|
||||||
if (bottomInfoResult.link
|
if (bottomInfoResult.link
|
||||||
|| bottomInfoResult.cursor != CursorState::None) {
|
|| bottomInfoResult.cursor != CursorState::None
|
||||||
|
|| bottomInfoResult.customTooltip) {
|
||||||
return bottomInfoResult;
|
return bottomInfoResult;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -328,7 +328,8 @@ TextState Location::textState(QPoint point, StateRequest request) const {
|
|||||||
point,
|
point,
|
||||||
InfoDisplayType::Image);
|
InfoDisplayType::Image);
|
||||||
if (bottomInfoResult.link
|
if (bottomInfoResult.link
|
||||||
|| bottomInfoResult.cursor != CursorState::None) {
|
|| bottomInfoResult.cursor != CursorState::None
|
||||||
|
|| bottomInfoResult.customTooltip) {
|
||||||
return bottomInfoResult;
|
return bottomInfoResult;
|
||||||
}
|
}
|
||||||
if (const auto size = bubble ? std::nullopt : _parent->rightActionSize()) {
|
if (const auto size = bubble ? std::nullopt : _parent->rightActionSize()) {
|
||||||
|
@ -453,7 +453,8 @@ TextState GroupedMedia::textState(QPoint point, StateRequest request) const {
|
|||||||
point,
|
point,
|
||||||
InfoDisplayType::Image);
|
InfoDisplayType::Image);
|
||||||
if (bottomInfoResult.link
|
if (bottomInfoResult.link
|
||||||
|| bottomInfoResult.cursor != CursorState::None) {
|
|| bottomInfoResult.cursor != CursorState::None
|
||||||
|
|| bottomInfoResult.customTooltip) {
|
||||||
return bottomInfoResult;
|
return bottomInfoResult;
|
||||||
}
|
}
|
||||||
if (const auto size = _parent->hasBubble() ? std::nullopt : _parent->rightActionSize()) {
|
if (const auto size = _parent->hasBubble() ? std::nullopt : _parent->rightActionSize()) {
|
||||||
|
@ -389,7 +389,8 @@ TextState UnwrappedMedia::textState(QPoint point, StateRequest request) const {
|
|||||||
point,
|
point,
|
||||||
InfoDisplayType::Background);
|
InfoDisplayType::Background);
|
||||||
if (bottomInfoResult.link
|
if (bottomInfoResult.link
|
||||||
|| bottomInfoResult.cursor != CursorState::None) {
|
|| bottomInfoResult.cursor != CursorState::None
|
||||||
|
|| bottomInfoResult.customTooltip) {
|
||||||
return bottomInfoResult;
|
return bottomInfoResult;
|
||||||
}
|
}
|
||||||
if (rightActionSize) {
|
if (rightActionSize) {
|
||||||
|
@ -523,7 +523,8 @@ TextState Photo::textState(QPoint point, StateRequest request) const {
|
|||||||
point,
|
point,
|
||||||
InfoDisplayType::Image);
|
InfoDisplayType::Image);
|
||||||
if (bottomInfoResult.link
|
if (bottomInfoResult.link
|
||||||
|| bottomInfoResult.cursor != CursorState::None) {
|
|| bottomInfoResult.cursor != CursorState::None
|
||||||
|
|| bottomInfoResult.customTooltip) {
|
||||||
return bottomInfoResult;
|
return bottomInfoResult;
|
||||||
}
|
}
|
||||||
if (const auto size = bubble ? std::nullopt : _parent->rightActionSize()) {
|
if (const auto size = bubble ? std::nullopt : _parent->rightActionSize()) {
|
||||||
|
Loading…
Reference in New Issue
Block a user