Added author of channel post in tooltip.

- Added "const" to vars within HistoryMessageSigned::refresh().
This commit is contained in:
23rd 2019-03-09 13:14:50 +03:00 committed by John Preston
parent 32bc723745
commit d7dc277003
4 changed files with 12 additions and 4 deletions

View File

@ -1000,6 +1000,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
"lng_forwarded_via" = "Forwarded from {user} via {inline_bot}";
"lng_forwarded_channel_via" = "Forwarded from {channel} via {inline_bot}";
"lng_forwarded_signed" = "{channel} ({user})";
"lng_signed_author" = "Author: {user}";
"lng_in_reply_to" = "In reply to";
"lng_edited" = "edited";
"lng_edited_date" = "Edited: {date}";

View File

@ -3055,6 +3055,11 @@ QString HistoryInner::tooltipText() const {
QLocale::system().dateTimeFormat(
QLocale::LongFormat)));
}
if (const auto msgsigned = view->data()->Get<HistoryMessageSigned>()) {
if (msgsigned->isElided) {
dateText += '\n' + lng_signed_author(lt_user, msgsigned->author);
}
}
return dateText;
}
} else if (_mouseCursorState == CursorState::Forwarded

View File

@ -50,11 +50,12 @@ void HistoryMessageVia::resize(int32 availw) const {
}
void HistoryMessageSigned::refresh(const QString &date) {
auto time = qsl(", ") + date;
auto name = author;
auto timew = st::msgDateFont->width(time);
auto namew = st::msgDateFont->width(name);
if (timew + namew > st::maxSignatureSize) {
const auto time = qsl(", ") + date;
const auto timew = st::msgDateFont->width(time);
const auto namew = st::msgDateFont->width(name);
isElided = (timew + namew > st::maxSignatureSize);
if (isElided) {
name = st::msgDateFont->elided(author, st::maxSignatureSize - timew);
}
signature.setText(

View File

@ -37,6 +37,7 @@ struct HistoryMessageSigned : public RuntimeComponent<HistoryMessageSigned, Hist
void refresh(const QString &date);
int maxWidth() const;
bool isElided = false;
QString author;
Text signature;
};