Show pin icon in pinned messages.

This commit is contained in:
John Preston 2020-10-22 12:13:00 +03:00
parent 994e3d8da7
commit 3dbc131b98
8 changed files with 57 additions and 13 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 438 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 720 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 KiB

View File

@ -348,6 +348,7 @@ void HistoryItem::markMediaRead() {
}
void HistoryItem::setIsPinned(bool pinned) {
const auto changed = (isPinned() != pinned);
if (pinned) {
_flags |= MTPDmessage::Flag::f_pinned;
history()->session().storage().add(Storage::SharedMediaAddExisting(
@ -363,6 +364,9 @@ void HistoryItem::setIsPinned(bool pinned) {
Storage::SharedMediaType::Pinned,
id));
}
if (changed) {
history()->owner().requestItemResize(this);
}
}
bool HistoryItem::definesReplyKeyboard() const {

View File

@ -1816,9 +1816,28 @@ void Message::drawInfo(
p.drawText(dateX, dateY + st::msgDateFont->ascent, item->_timeText);
}
const auto viewIconTop = infoBottom + st::historyViewsTop;
const auto pinIconTop = infoBottom + st::historyPinTop;
auto left = infoRight - infoW;
if (displayPinIcon()) {
const auto icon = [&] {
if (outbg) {
return &(invertedsprites
? st::historyPinInvertedIcon
: selected
? st::historyPinOutSelectedIcon
: st::historyPinOutIcon);
}
return &(invertedsprites
? st::historyPinInvertedIcon
: selected
? st::historyPinInSelectedIcon
: st::historyPinInIcon);
}();
icon->paint(p, left, pinIconTop, width);
left += st::historyViewsWidth;
}
if (auto views = item->Get<HistoryMessageViews>()) {
auto left = infoRight - infoW;
const auto iconTop = infoBottom + st::historyViewsTop;
const auto textTop = infoBottom - st::msgDateFont->descent;
if (views->replies.count > 0
&& !views->commentsMegagroupId
@ -1843,11 +1862,11 @@ void Message::drawInfo(
: st::historyViewsSendingIcon);
}();
if (item->id > 0) {
icon->paint(p, left, iconTop, width);
icon->paint(p, left, viewIconTop, width);
p.drawText(left + st::historyViewsWidth, textTop, views->replies.text);
} else if (!outbg && views->views.count < 0) { // sending outbg icon will be painted below
auto iconSkip = st::historyViewsSpace + views->replies.textWidth;
icon->paint(p, left + iconSkip, iconTop, width);
icon->paint(p, left + iconSkip, viewIconTop, width);
}
left += st::historyViewsSpace
+ views->replies.textWidth
@ -1874,16 +1893,16 @@ void Message::drawInfo(
: st::historyViewsSendingIcon);
}();
if (item->id > 0) {
icon->paint(p, left, iconTop, width);
icon->paint(p, left, viewIconTop, width);
p.drawText(left + st::historyViewsWidth, textTop, views->views.text);
} else if (!outbg) { // sending outbg icon will be painted below
auto iconSkip = st::historyViewsSpace + views->views.textWidth;
icon->paint(p, left + iconSkip, iconTop, width);
icon->paint(p, left + iconSkip, viewIconTop, width);
}
}
} else if (item->id < 0 && item->history()->peer->isSelf() && !outbg) {
auto icon = &(invertedsprites ? st::historyViewsSendingInvertedIcon : st::historyViewsSendingIcon);
icon->paint(p, infoRight - infoW, infoBottom + st::historyViewsTop, width);
icon->paint(p, left, viewIconTop, width);
}
if (outbg) {
auto icon = [&] {
@ -1951,6 +1970,9 @@ int Message::infoWidth() const {
result += st::historySendStateSpace;
}
}
if (displayPinIcon()) {
result += st::historyViewsWidth;
}
// When message is scheduled until online, time is not displayed,
// so message should have less space.
@ -2000,6 +2022,9 @@ int Message::timeLeft() const {
result += st::historySendStateSpace;
}
}
if (displayPinIcon()) {
result += st::historyViewsWidth;
}
return result;
}
@ -2046,6 +2071,10 @@ HistoryMessageReply *Message::displayedReply() const {
return nullptr;
}
bool Message::displayPinIcon() const {
return data()->isPinned() && context() != Context::Pinned;
}
bool Message::hasFromName() const {
switch (context()) {
case Context::AdminLog:

View File

@ -176,11 +176,13 @@ private:
QSize performCountCurrentSize(int newWidth) override;
bool hasVisibleText() const override;
bool displayFastShare() const;
bool displayGoToOriginal() const;
ClickHandlerPtr fastReplyLink() const;
const HistoryMessageEdited *displayedEditBadge() const;
HistoryMessageEdited *displayedEditBadge();
[[nodiscard]] bool displayFastShare() const;
[[nodiscard]] bool displayGoToOriginal() const;
[[nodiscard]] ClickHandlerPtr fastReplyLink() const;
[[nodiscard]] const HistoryMessageEdited *displayedEditBadge() const;
[[nodiscard]] HistoryMessageEdited *displayedEditBadge();
[[nodiscard]] bool displayPinIcon() const;
void initTime();
[[nodiscard]] int timeLeft() const;
[[nodiscard]] int plainMaxWidth() const;

View File

@ -214,9 +214,12 @@ std::vector<PreparedGroup> DivideByGroups(
auto result = std::vector<PreparedGroup>();
auto pushGroup = [&] {
const auto type = (group.files.size() > 1)
? groupType
: AlbumType::None;
result.push_back(PreparedGroup{
.list = base::take(group),
.type = groupType,
.type = type,
});
};
for (auto i = 0; i != list.files.size(); ++i) {

View File

@ -182,6 +182,12 @@ historyRepliesInSelectedIcon: icon {{ "history_replies", msgInDateFgSelected }};
historyRepliesOutIcon: icon {{ "history_replies", historyOutIconFg }};
historyRepliesOutSelectedIcon: icon {{ "history_replies", historyOutIconFgSelected }};
historyRepliesInvertedIcon: icon {{ "history_replies", historySendingInvertedIconFg }};
historyPinTop: -18px;
historyPinInIcon: icon {{ "history_pin", msgInDateFg }};
historyPinInSelectedIcon: icon {{ "history_pin", msgInDateFgSelected }};
historyPinOutIcon: icon {{ "history_pin", historyOutIconFg }};
historyPinOutSelectedIcon: icon {{ "history_pin", historyOutIconFgSelected }};
historyPinInvertedIcon: icon {{ "history_pin", historySendingInvertedIconFg }};
historyComposeField: InputField(defaultInputField) {
font: msgFont;