mirror of
https://github.com/vale981/tdesktop
synced 2025-03-06 10:11:41 -05:00
better @via display
This commit is contained in:
parent
e840d2bb17
commit
a1646a8f9e
2 changed files with 122 additions and 33 deletions
|
@ -4762,6 +4762,16 @@ void HistorySticker::initDimensions(const HistoryItem *parent) {
|
||||||
_height = _minh;
|
_height = _minh;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int32 HistorySticker::resize(int32 width, const HistoryItem *parent) { // return new height
|
||||||
|
_width = qMin(width, _maxw);
|
||||||
|
if (const HistoryReply *reply = toHistoryReply(parent)) {
|
||||||
|
int32 usew = _maxw - st::msgReplyPadding.left() - reply->replyToWidth();
|
||||||
|
int32 rw = _width - usew - st::msgReplyPadding.left() - st::msgReplyPadding.left() - st::msgReplyPadding.right();
|
||||||
|
reply->resizeVia(rw);
|
||||||
|
}
|
||||||
|
return _height;
|
||||||
|
}
|
||||||
|
|
||||||
void HistorySticker::draw(Painter &p, const HistoryItem *parent, const QRect &r, bool selected, uint64 ms) const {
|
void HistorySticker::draw(Painter &p, const HistoryItem *parent, const QRect &r, bool selected, uint64 ms) const {
|
||||||
if (_width < st::msgPadding.left() + st::msgPadding.right() + 1) return;
|
if (_width < st::msgPadding.left() + st::msgPadding.right() + 1) return;
|
||||||
|
|
||||||
|
@ -5958,7 +5968,7 @@ void ViaInlineBotLink::onClick(Qt::MouseButton button) const {
|
||||||
HistoryMessageVia::HistoryMessageVia(int32 userId)
|
HistoryMessageVia::HistoryMessageVia(int32 userId)
|
||||||
: bot(App::userLoaded(peerFromUser(userId)))
|
: bot(App::userLoaded(peerFromUser(userId)))
|
||||||
, width(0)
|
, width(0)
|
||||||
, fullWidth(st::msgServiceNameFont->width(qsl("via @") + bot->username))
|
, maxWidth(st::msgServiceNameFont->width(qsl("via @") + bot->username))
|
||||||
, lnk(new ViaInlineBotLink(bot)) {
|
, lnk(new ViaInlineBotLink(bot)) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5967,13 +5977,21 @@ bool HistoryMessageVia::isNull() const {
|
||||||
}
|
}
|
||||||
|
|
||||||
void HistoryMessageVia::resize(int32 availw) {
|
void HistoryMessageVia::resize(int32 availw) {
|
||||||
if (width < fullWidth && availw > width) {
|
if (width < maxWidth && availw > width) {
|
||||||
if (availw < fullWidth) {
|
if (availw < maxWidth) {
|
||||||
text = st::msgServiceNameFont->elided(qsl("via @") + bot->username, availw);
|
text = st::msgServiceNameFont->elided(qsl("via @") + bot->username, availw);
|
||||||
width = st::msgServiceNameFont->width(text);
|
width = st::msgServiceNameFont->width(text);
|
||||||
} else {
|
} else {
|
||||||
text = qsl("via @") + bot->username;
|
text = qsl("via @") + bot->username;
|
||||||
width = fullWidth;
|
width = maxWidth;
|
||||||
|
}
|
||||||
|
} else if (availw < width) {
|
||||||
|
if (availw > 0) {
|
||||||
|
text = st::msgServiceNameFont->elided(qsl("via @") + bot->username, availw);
|
||||||
|
width = st::msgServiceNameFont->width(text);
|
||||||
|
} else {
|
||||||
|
text = QString();
|
||||||
|
width = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -6165,9 +6183,9 @@ void HistoryMessage::initDimensions() {
|
||||||
if (maxw > _maxw) _maxw = maxw;
|
if (maxw > _maxw) _maxw = maxw;
|
||||||
_minh += _media->minHeight();
|
_minh += _media->minHeight();
|
||||||
}
|
}
|
||||||
if (via()) {
|
if (!_media && !displayFromName() && via() && !toHistoryForwarded()) {
|
||||||
if (st::msgPadding.left() + via()->fullWidth + st::msgPadding.right() > _maxw) {
|
if (st::msgPadding.left() + via()->maxWidth + st::msgPadding.right() > _maxw) {
|
||||||
_maxw = st::msgPadding.left() + via()->fullWidth + st::msgPadding.right() > _maxw;
|
_maxw = st::msgPadding.left() + via()->maxWidth + st::msgPadding.right();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -6200,8 +6218,11 @@ void HistoryMessage::countPositionAndSize(int32 &left, int32 &width) const {
|
||||||
|
|
||||||
void HistoryMessage::fromNameUpdated() const {
|
void HistoryMessage::fromNameUpdated() const {
|
||||||
if (!_media && displayFromName()) {
|
if (!_media && displayFromName()) {
|
||||||
int32 _namew = st::msgPadding.left() + _from->nameText.maxWidth() + st::msgPadding.right();
|
int32 namew = st::msgPadding.left() + _from->nameText.maxWidth() + st::msgPadding.right();
|
||||||
if (_namew > _maxw) _maxw = _namew;
|
if (via() && !toHistoryForwarded()) {
|
||||||
|
namew += st::msgServiceFont->spacew + via()->maxWidth;
|
||||||
|
}
|
||||||
|
if (namew > _maxw) _maxw = namew;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -6437,7 +6458,7 @@ void HistoryMessage::draw(Painter &p, const QRect &r, uint32 selection, uint64 m
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_from->nameVersion > _fromVersion) {
|
if (_from->nameVersion > _fromVersion) {
|
||||||
fromNameUpdated();
|
// fromNameUpdated();
|
||||||
_fromVersion = _from->nameVersion;
|
_fromVersion = _from->nameVersion;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -6464,6 +6485,10 @@ void HistoryMessage::draw(Painter &p, const QRect &r, uint32 selection, uint64 m
|
||||||
p.setPen(_from->color);
|
p.setPen(_from->color);
|
||||||
}
|
}
|
||||||
_from->nameText.drawElided(p, r.left() + st::msgPadding.left(), r.top() + st::msgPadding.top(), width - st::msgPadding.left() - st::msgPadding.right());
|
_from->nameText.drawElided(p, r.left() + st::msgPadding.left(), r.top() + st::msgPadding.top(), width - st::msgPadding.left() - st::msgPadding.right());
|
||||||
|
if (via() && !toHistoryForwarded() && width > st::msgPadding.left() + st::msgPadding.right() + _from->nameText.maxWidth() + st::msgServiceFont->spacew) {
|
||||||
|
p.setPen(selected ? (outbg ? st::msgOutServiceFgSelected : st::msgInServiceFgSelected) : (outbg ? st::msgOutServiceFg : st::msgInServiceFg));
|
||||||
|
p.drawText(r.left() + st::msgPadding.left() + _from->nameText.maxWidth() + st::msgServiceFont->spacew, r.top() + st::msgPadding.top() + st::msgServiceFont->ascent, via()->text);
|
||||||
|
}
|
||||||
r.setTop(r.top() + st::msgNameFont->height);
|
r.setTop(r.top() + st::msgNameFont->height);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -6495,15 +6520,15 @@ void HistoryMessage::draw(Painter &p, const QRect &r, uint32 selection, uint64 m
|
||||||
|
|
||||||
void HistoryMessage::drawMessageText(Painter &p, QRect trect, uint32 selection) const {
|
void HistoryMessage::drawMessageText(Painter &p, QRect trect, uint32 selection) const {
|
||||||
bool outbg = out() && !fromChannel(), selected = (selection == FullSelection);
|
bool outbg = out() && !fromChannel(), selected = (selection == FullSelection);
|
||||||
if (via()) {
|
if (!displayFromName() && via() && !toHistoryForwarded()) {
|
||||||
p.setFont(st::msgServiceNameFont);
|
p.setFont(st::msgServiceNameFont);
|
||||||
p.setPen((selected ? (outbg ? st::msgOutServiceFgSelected : st::msgInServiceFgSelected) : (outbg ? st::msgOutServiceFg : st::msgInServiceFg))->p);
|
p.setPen(selected ? (outbg ? st::msgOutServiceFgSelected : st::msgInServiceFgSelected) : (outbg ? st::msgOutServiceFg : st::msgInServiceFg));
|
||||||
p.drawTextLeft(trect.left(), trect.top(), _history->width, via()->text);
|
p.drawTextLeft(trect.left(), trect.top(), _history->width, via()->text);
|
||||||
trect.setY(trect.y() + st::msgServiceNameFont->height);
|
trect.setY(trect.y() + st::msgServiceNameFont->height);
|
||||||
}
|
}
|
||||||
|
|
||||||
p.setPen(st::msgColor->p);
|
p.setPen(st::msgColor);
|
||||||
p.setFont(st::msgFont->f);
|
p.setFont(st::msgFont);
|
||||||
uint16 selectedFrom = (selection == FullSelection) ? 0 : (selection >> 16) & 0xFFFF;
|
uint16 selectedFrom = (selection == FullSelection) ? 0 : (selection >> 16) & 0xFFFF;
|
||||||
uint16 selectedTo = (selection == FullSelection) ? 0 : selection & 0xFFFF;
|
uint16 selectedTo = (selection == FullSelection) ? 0 : selection & 0xFFFF;
|
||||||
_text.draw(p, trect.x(), trect.y(), trect.width(), Qt::AlignLeft, 0, -1, selectedFrom, selectedTo);
|
_text.draw(p, trect.x(), trect.y(), trect.width(), Qt::AlignLeft, 0, -1, selectedFrom, selectedTo);
|
||||||
|
@ -6549,8 +6574,10 @@ int32 HistoryMessage::resize(int32 width) {
|
||||||
} else {
|
} else {
|
||||||
_height += st::msgNameFont->height;
|
_height += st::msgNameFont->height;
|
||||||
}
|
}
|
||||||
}
|
if (via() && !toHistoryForwarded()) {
|
||||||
if (via()) {
|
via()->resize(width - st::msgPadding.left() - st::msgPadding.right() - _from->nameText.maxWidth() - st::msgServiceFont->spacew);
|
||||||
|
}
|
||||||
|
} else if (via() && !toHistoryForwarded()) {
|
||||||
via()->resize(width - st::msgPadding.left() - st::msgPadding.right());
|
via()->resize(width - st::msgPadding.left() - st::msgPadding.right());
|
||||||
if (emptyText() && !displayFromName()) {
|
if (emptyText() && !displayFromName()) {
|
||||||
_height += st::msgPadding.top() + st::msgNameFont->height + st::mediaHeaderSkip;
|
_height += st::msgPadding.top() + st::msgNameFont->height + st::mediaHeaderSkip;
|
||||||
|
@ -6612,9 +6639,15 @@ void HistoryMessage::getState(TextLinkPtr &lnk, HistoryCursorState &state, int32
|
||||||
if (drawBubble()) {
|
if (drawBubble()) {
|
||||||
QRect r(left, st::msgMargin.top(), width, _height - st::msgMargin.top() - st::msgMargin.bottom());
|
QRect r(left, st::msgMargin.top(), width, _height - st::msgMargin.top() - st::msgMargin.bottom());
|
||||||
if (displayFromName()) { // from user left name
|
if (displayFromName()) { // from user left name
|
||||||
if (x >= r.left() + st::msgPadding.left() && y >= r.top() + st::msgPadding.top() && y < r.top() + st::msgPadding.top() + st::msgNameFont->height && x < r.left() + r.width() - st::msgPadding.right() && x < r.left() + st::msgPadding.left() + _from->nameText.maxWidth()) {
|
if (y >= r.top() + st::msgPadding.top() && y < r.top() + st::msgPadding.top() + st::msgNameFont->height) {
|
||||||
lnk = _from->lnk;
|
if (x >= r.left() + st::msgPadding.left() && x < r.left() + r.width() - st::msgPadding.right() && x < r.left() + st::msgPadding.left() + _from->nameText.maxWidth()) {
|
||||||
return;
|
lnk = _from->lnk;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (via() && !toHistoryForwarded() && x >= r.left() + st::msgPadding.left() + _from->nameText.maxWidth() + st::msgServiceFont->spacew && x < r.left() + st::msgPadding.left() + _from->nameText.maxWidth() + st::msgServiceFont->spacew + via()->width) {
|
||||||
|
lnk = via()->lnk;
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
r.setTop(r.top() + st::msgNameFont->height);
|
r.setTop(r.top() + st::msgNameFont->height);
|
||||||
}
|
}
|
||||||
|
@ -6629,7 +6662,7 @@ void HistoryMessage::getStateFromMessageText(TextLinkPtr &lnk, HistoryCursorStat
|
||||||
|
|
||||||
QRect trect(r.marginsAdded(-st::msgPadding));
|
QRect trect(r.marginsAdded(-st::msgPadding));
|
||||||
|
|
||||||
if (via()) {
|
if (!displayFromName() && via() && !toHistoryForwarded()) {
|
||||||
if (x >= trect.left() && y >= trect.top() && y < trect.top() + st::msgNameFont->height && x < trect.left() + via()->width) {
|
if (x >= trect.left() && y >= trect.top() && y < trect.top() + st::msgNameFont->height && x < trect.left() + via()->width) {
|
||||||
lnk = via()->lnk;
|
lnk = via()->lnk;
|
||||||
return;
|
return;
|
||||||
|
@ -6678,8 +6711,7 @@ void HistoryMessage::getSymbol(uint16 &symbol, bool &after, bool &upon, int32 x,
|
||||||
QRect r(left, st::msgMargin.top(), width, _height - st::msgMargin.top() - st::msgMargin.bottom());
|
QRect r(left, st::msgMargin.top(), width, _height - st::msgMargin.top() - st::msgMargin.bottom());
|
||||||
if (displayFromName()) { // from user left name
|
if (displayFromName()) { // from user left name
|
||||||
r.setTop(r.top() + st::msgNameFont->height);
|
r.setTop(r.top() + st::msgNameFont->height);
|
||||||
}
|
} else if (via() && !toHistoryForwarded()) {
|
||||||
if (via()) {
|
|
||||||
r.setTop(r.top() + st::msgNameFont->height);
|
r.setTop(r.top() + st::msgNameFont->height);
|
||||||
}
|
}
|
||||||
QRect trect(r.marginsAdded(-st::msgPadding));
|
QRect trect(r.marginsAdded(-st::msgPadding));
|
||||||
|
@ -6765,12 +6797,16 @@ void HistoryForwarded::initDimensions() {
|
||||||
HistoryMessage::initDimensions();
|
HistoryMessage::initDimensions();
|
||||||
if (!_media) {
|
if (!_media) {
|
||||||
int32 _namew = st::msgPadding.left() + fromWidth + fwdFromName.maxWidth() + st::msgPadding.right();
|
int32 _namew = st::msgPadding.left() + fromWidth + fwdFromName.maxWidth() + st::msgPadding.right();
|
||||||
|
if (via()) {
|
||||||
|
_namew += st::msgServiceFont->spacew + via()->maxWidth;
|
||||||
|
}
|
||||||
if (_namew > _maxw) _maxw = _namew;
|
if (_namew > _maxw) _maxw = _namew;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void HistoryForwarded::fwdNameUpdated() const {
|
void HistoryForwarded::fwdNameUpdated() const {
|
||||||
fwdFromName.setText(st::msgServiceNameFont, App::peerName(fwdFrom), _textNameOptions);
|
QString fwdName((via() && fwdFrom->isUser()) ? fwdFrom->asUser()->firstName : App::peerName(fwdFrom));
|
||||||
|
fwdFromName.setText(st::msgServiceNameFont, fwdName, _textNameOptions);
|
||||||
}
|
}
|
||||||
|
|
||||||
void HistoryForwarded::draw(Painter &p, const QRect &r, uint32 selection, uint64 ms) const {
|
void HistoryForwarded::draw(Painter &p, const QRect &r, uint32 selection, uint64 ms) const {
|
||||||
|
@ -6788,10 +6824,17 @@ void HistoryForwarded::drawForwardedFrom(Painter &p, int32 x, int32 y, int32 w,
|
||||||
p.setPen((selected ? (outbg ? st::msgOutServiceFgSelected : st::msgInServiceFgSelected) : (outbg ? st::msgOutServiceFg : st::msgInServiceFg))->p);
|
p.setPen((selected ? (outbg ? st::msgOutServiceFgSelected : st::msgInServiceFgSelected) : (outbg ? st::msgOutServiceFg : st::msgInServiceFg))->p);
|
||||||
p.setFont(serviceFont);
|
p.setFont(serviceFont);
|
||||||
|
|
||||||
if (w >= fromWidth) {
|
if (via() && w > fromWidth + fwdFromName.maxWidth() + serviceFont->spacew) {
|
||||||
p.drawText(x, y + serviceFont->ascent, lang(lng_forwarded_from));
|
p.drawText(x, y + serviceFont->ascent, lang(lng_forwarded_from));
|
||||||
|
|
||||||
p.setFont(serviceName->f);
|
p.setFont(serviceName);
|
||||||
|
fwdFromName.draw(p, x + fromWidth, y, w - fromWidth);
|
||||||
|
|
||||||
|
p.drawText(x + fromWidth + fwdFromName.maxWidth() + serviceFont->spacew, y + serviceFont->ascent, via()->text);
|
||||||
|
} else if (w > fromWidth) {
|
||||||
|
p.drawText(x, y + serviceFont->ascent, lang(lng_forwarded_from));
|
||||||
|
|
||||||
|
p.setFont(serviceName);
|
||||||
fwdFromName.drawElided(p, x + fromWidth, y, w - fromWidth);
|
fwdFromName.drawElided(p, x + fromWidth, y, w - fromWidth);
|
||||||
} else {
|
} else {
|
||||||
p.drawText(x, y + serviceFont->ascent, serviceFont->elided(lang(lng_forwarded_from), w));
|
p.drawText(x, y + serviceFont->ascent, serviceFont->elided(lang(lng_forwarded_from), w));
|
||||||
|
@ -6810,11 +6853,14 @@ int32 HistoryForwarded::resize(int32 width) {
|
||||||
HistoryMessage::resize(width);
|
HistoryMessage::resize(width);
|
||||||
if (drawBubble()) {
|
if (drawBubble()) {
|
||||||
if (displayForwardedFrom()) {
|
if (displayForwardedFrom()) {
|
||||||
if (emptyText() && !displayFromName() && !via()) {
|
if (emptyText() && !displayFromName()) {
|
||||||
_height += st::msgPadding.top() + st::msgServiceNameFont->height + st::mediaHeaderSkip;
|
_height += st::msgPadding.top() + st::msgServiceNameFont->height + st::mediaHeaderSkip;
|
||||||
} else {
|
} else {
|
||||||
_height += st::msgServiceNameFont->height;
|
_height += st::msgServiceNameFont->height;
|
||||||
}
|
}
|
||||||
|
if (via()) {
|
||||||
|
via()->resize(width - st::msgPadding.left() - st::msgPadding.right() - fromWidth - fwdFromName.maxWidth() - st::msgServiceFont->spacew);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return _height;
|
return _height;
|
||||||
|
@ -6876,6 +6922,8 @@ void HistoryForwarded::getForwardedState(TextLinkPtr &lnk, HistoryCursorState &s
|
||||||
state = HistoryDefaultCursorState;
|
state = HistoryDefaultCursorState;
|
||||||
if (x >= fromWidth && x < w && x < fromWidth + fwdFromName.maxWidth()) {
|
if (x >= fromWidth && x < w && x < fromWidth + fwdFromName.maxWidth()) {
|
||||||
lnk = fwdFrom->lnk;
|
lnk = fwdFrom->lnk;
|
||||||
|
} else if (via() && x >= fromWidth + fwdFromName.maxWidth() + st::msgServiceFont->spacew && x < w && x < fromWidth + fwdFromName.maxWidth() + st::msgServiceFont->spacew + via()->maxWidth) {
|
||||||
|
lnk = via()->lnk;
|
||||||
} else {
|
} else {
|
||||||
lnk = TextLinkPtr();
|
lnk = TextLinkPtr();
|
||||||
}
|
}
|
||||||
|
@ -6910,7 +6958,8 @@ HistoryReply::HistoryReply(History *history, HistoryBlock *block, const MTPDmess
|
||||||
, replyToMsgId(msg.vreply_to_msg_id.v)
|
, replyToMsgId(msg.vreply_to_msg_id.v)
|
||||||
, replyToMsg(0)
|
, replyToMsg(0)
|
||||||
, replyToVersion(0)
|
, replyToVersion(0)
|
||||||
, _maxReplyWidth(0) {
|
, _maxReplyWidth(0)
|
||||||
|
, _replyToVia(0) {
|
||||||
if (!updateReplyTo() && App::api()) {
|
if (!updateReplyTo() && App::api()) {
|
||||||
App::api()->requestReplyTo(this, history->peer->asChannel(), replyToMsgId);
|
App::api()->requestReplyTo(this, history->peer->asChannel(), replyToMsgId);
|
||||||
}
|
}
|
||||||
|
@ -6921,7 +6970,8 @@ HistoryReply::HistoryReply(History *history, HistoryBlock *block, MsgId msgId, i
|
||||||
, replyToMsgId(replyTo)
|
, replyToMsgId(replyTo)
|
||||||
, replyToMsg(0)
|
, replyToMsg(0)
|
||||||
, replyToVersion(0)
|
, replyToVersion(0)
|
||||||
, _maxReplyWidth(0) {
|
, _maxReplyWidth(0)
|
||||||
|
, _replyToVia(0) {
|
||||||
if (!updateReplyTo() && App::api()) {
|
if (!updateReplyTo() && App::api()) {
|
||||||
App::api()->requestReplyTo(this, history->peer->asChannel(), replyToMsgId);
|
App::api()->requestReplyTo(this, history->peer->asChannel(), replyToMsgId);
|
||||||
}
|
}
|
||||||
|
@ -6932,7 +6982,8 @@ HistoryReply::HistoryReply(History *history, HistoryBlock *block, MsgId msgId, i
|
||||||
, replyToMsgId(replyTo)
|
, replyToMsgId(replyTo)
|
||||||
, replyToMsg(0)
|
, replyToMsg(0)
|
||||||
, replyToVersion(0)
|
, replyToVersion(0)
|
||||||
, _maxReplyWidth(0) {
|
, _maxReplyWidth(0)
|
||||||
|
, _replyToVia(0) {
|
||||||
if (!updateReplyTo() && App::api()) {
|
if (!updateReplyTo() && App::api()) {
|
||||||
App::api()->requestReplyTo(this, history->peer->asChannel(), replyToMsgId);
|
App::api()->requestReplyTo(this, history->peer->asChannel(), replyToMsgId);
|
||||||
}
|
}
|
||||||
|
@ -6952,6 +7003,9 @@ void HistoryReply::initDimensions() {
|
||||||
HistoryMessage::initDimensions();
|
HistoryMessage::initDimensions();
|
||||||
if (!_media) {
|
if (!_media) {
|
||||||
int32 replyw = st::msgPadding.left() + _maxReplyWidth - st::msgReplyPadding.left() - st::msgReplyPadding.right() + st::msgPadding.right();
|
int32 replyw = st::msgPadding.left() + _maxReplyWidth - st::msgReplyPadding.left() - st::msgReplyPadding.right() + st::msgPadding.right();
|
||||||
|
if (replyToVia()) {
|
||||||
|
replyw += st::msgServiceFont->spacew + via()->maxWidth;
|
||||||
|
}
|
||||||
if (replyw > _maxw) _maxw = replyw;
|
if (replyw > _maxw) _maxw = replyw;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -6959,6 +7013,7 @@ void HistoryReply::initDimensions() {
|
||||||
bool HistoryReply::updateReplyTo(bool force) {
|
bool HistoryReply::updateReplyTo(bool force) {
|
||||||
if (replyToMsg || !replyToMsgId) return true;
|
if (replyToMsg || !replyToMsgId) return true;
|
||||||
replyToMsg = App::histItemById(channelId(), replyToMsgId);
|
replyToMsg = App::histItemById(channelId(), replyToMsgId);
|
||||||
|
|
||||||
if (replyToMsg) {
|
if (replyToMsg) {
|
||||||
App::historyRegReply(this, replyToMsg);
|
App::historyRegReply(this, replyToMsg);
|
||||||
replyToText.setText(st::msgFont, replyToMsg->inReplyText(), _textDlgOptions);
|
replyToText.setText(st::msgFont, replyToMsg->inReplyText(), _textDlgOptions);
|
||||||
|
@ -6966,6 +7021,11 @@ bool HistoryReply::updateReplyTo(bool force) {
|
||||||
replyToNameUpdated();
|
replyToNameUpdated();
|
||||||
|
|
||||||
replyToLnk = TextLinkPtr(new MessageLink(replyToMsg->history()->peer->id, replyToMsg->id));
|
replyToLnk = TextLinkPtr(new MessageLink(replyToMsg->history()->peer->id, replyToMsg->id));
|
||||||
|
if (!replyToMsg->toHistoryForwarded()) {
|
||||||
|
if (UserData *bot = replyToMsg->viaBot()) {
|
||||||
|
_replyToVia = new HistoryMessageVia(peerToUser(bot->id));
|
||||||
|
}
|
||||||
|
}
|
||||||
} else if (force) {
|
} else if (force) {
|
||||||
replyToMsgId = 0;
|
replyToMsgId = 0;
|
||||||
}
|
}
|
||||||
|
@ -6978,12 +7038,17 @@ bool HistoryReply::updateReplyTo(bool force) {
|
||||||
|
|
||||||
void HistoryReply::replyToNameUpdated() const {
|
void HistoryReply::replyToNameUpdated() const {
|
||||||
if (replyToMsg) {
|
if (replyToMsg) {
|
||||||
replyToName.setText(st::msgServiceNameFont, App::peerName(replyToMsg->from()), _textNameOptions);
|
QString name = (replyToVia() && replyToMsg->from()->isUser()) ? replyToMsg->from()->asUser()->firstName : App::peerName(replyToMsg->from());
|
||||||
|
replyToName.setText(st::msgServiceNameFont, name, _textNameOptions);
|
||||||
replyToVersion = replyToMsg->from()->nameVersion;
|
replyToVersion = replyToMsg->from()->nameVersion;
|
||||||
bool hasPreview = replyToMsg->getMedia() ? replyToMsg->getMedia()->hasReplyPreview() : false;
|
bool hasPreview = replyToMsg->getMedia() ? replyToMsg->getMedia()->hasReplyPreview() : false;
|
||||||
int32 previewSkip = hasPreview ? (st::msgReplyBarSize.height() + st::msgReplyBarSkip - st::msgReplyBarSize.width() - st::msgReplyBarPos.x()) : 0;
|
int32 previewSkip = hasPreview ? (st::msgReplyBarSize.height() + st::msgReplyBarSkip - st::msgReplyBarSize.width() - st::msgReplyBarPos.x()) : 0;
|
||||||
|
int32 w = replyToName.maxWidth();
|
||||||
|
if (replyToVia()) {
|
||||||
|
w += st::msgServiceFont->spacew + replyToVia()->maxWidth;
|
||||||
|
}
|
||||||
|
|
||||||
_maxReplyWidth = previewSkip + qMax(replyToName.maxWidth(), qMin(replyToText.maxWidth(), 4 * replyToName.maxWidth()));
|
_maxReplyWidth = previewSkip + qMax(w, qMin(replyToText.maxWidth(), 4 * w));
|
||||||
} else {
|
} else {
|
||||||
_maxReplyWidth = st::msgDateFont->width(lang(replyToMsgId ? lng_profile_loading : lng_deleted_message));
|
_maxReplyWidth = st::msgDateFont->width(lang(replyToMsgId ? lng_profile_loading : lng_deleted_message));
|
||||||
}
|
}
|
||||||
|
@ -7056,6 +7121,10 @@ void HistoryReply::drawReplyTo(Painter &p, int32 x, int32 y, int32 w, bool selec
|
||||||
p.setPen(selected ? (outbg ? st::msgOutServiceFgSelected : st::msgInServiceFgSelected) : (outbg ? st::msgOutServiceFg : st::msgInServiceFg));
|
p.setPen(selected ? (outbg ? st::msgOutServiceFgSelected : st::msgInServiceFgSelected) : (outbg ? st::msgOutServiceFg : st::msgInServiceFg));
|
||||||
}
|
}
|
||||||
replyToName.drawLeftElided(p, x + st::msgReplyBarSkip + previewSkip, y + st::msgReplyPadding.top(), w - st::msgReplyBarSkip - previewSkip, w + 2 * x);
|
replyToName.drawLeftElided(p, x + st::msgReplyBarSkip + previewSkip, y + st::msgReplyPadding.top(), w - st::msgReplyBarSkip - previewSkip, w + 2 * x);
|
||||||
|
if (replyToVia() && w > st::msgReplyBarSkip + previewSkip + replyToName.maxWidth() + st::msgServiceFont->spacew) {
|
||||||
|
p.setFont(st::msgServiceFont);
|
||||||
|
p.drawText(x + st::msgReplyBarSkip + previewSkip + replyToName.maxWidth() + st::msgServiceFont->spacew, y + st::msgReplyPadding.top() + st::msgServiceFont->ascent, replyToVia()->text);
|
||||||
|
}
|
||||||
|
|
||||||
HistoryMessage *replyToAsMsg = replyToMsg->toHistoryMessage();
|
HistoryMessage *replyToAsMsg = replyToMsg->toHistoryMessage();
|
||||||
if (likeService) {
|
if (likeService) {
|
||||||
|
@ -7094,10 +7163,23 @@ int32 HistoryReply::resize(int32 width) {
|
||||||
} else {
|
} else {
|
||||||
_height += st::msgReplyPadding.top() + st::msgReplyBarSize.height() + st::msgReplyPadding.bottom();
|
_height += st::msgReplyPadding.top() + st::msgReplyBarSize.height() + st::msgReplyPadding.bottom();
|
||||||
}
|
}
|
||||||
|
if (replyToVia()) {
|
||||||
|
bool hasPreview = replyToMsg->getMedia() ? replyToMsg->getMedia()->hasReplyPreview() : false;
|
||||||
|
int previewSkip = hasPreview ? (st::msgReplyBarSize.height() + st::msgReplyBarSkip - st::msgReplyBarSize.width() - st::msgReplyBarPos.x()) : 0;
|
||||||
|
replyToVia()->resize(width - st::msgPadding.left() - st::msgPadding.right() - st::msgReplyBarSkip + previewSkip + replyToName.maxWidth() + st::msgServiceFont->spacew);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return _height;
|
return _height;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void HistoryReply::resizeVia(int32 w) const {
|
||||||
|
if (!replyToVia()) return;
|
||||||
|
|
||||||
|
bool hasPreview = replyToMsg->getMedia() ? replyToMsg->getMedia()->hasReplyPreview() : false;
|
||||||
|
int previewSkip = hasPreview ? (st::msgReplyBarSize.height() + st::msgReplyBarSkip - st::msgReplyBarSize.width() - st::msgReplyBarPos.x()) : 0;
|
||||||
|
replyToVia()->resize(w - st::msgReplyBarSkip - previewSkip - replyToName.maxWidth() - st::msgServiceFont->spacew);
|
||||||
|
}
|
||||||
|
|
||||||
bool HistoryReply::hasPoint(int32 x, int32 y) const {
|
bool HistoryReply::hasPoint(int32 x, int32 y) const {
|
||||||
if (drawBubble()) {
|
if (drawBubble()) {
|
||||||
int32 left = 0, width = 0;
|
int32 left = 0, width = 0;
|
||||||
|
@ -7186,6 +7268,7 @@ HistoryReply::~HistoryReply() {
|
||||||
} else if (replyToMsgId && App::api()) {
|
} else if (replyToMsgId && App::api()) {
|
||||||
App::api()->itemRemoved(this);
|
App::api()->itemRemoved(this);
|
||||||
}
|
}
|
||||||
|
deleteAndMark(_replyToVia);
|
||||||
}
|
}
|
||||||
|
|
||||||
void HistoryServiceMsg::setMessageByAction(const MTPmessageAction &action) {
|
void HistoryServiceMsg::setMessageByAction(const MTPmessageAction &action) {
|
||||||
|
|
|
@ -1680,6 +1680,7 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
void initDimensions(const HistoryItem *parent);
|
void initDimensions(const HistoryItem *parent);
|
||||||
|
int32 resize(int32 width, const HistoryItem *parent);
|
||||||
|
|
||||||
void draw(Painter &p, const HistoryItem *parent, const QRect &r, bool selected, uint64 ms) const;
|
void draw(Painter &p, const HistoryItem *parent, const QRect &r, bool selected, uint64 ms) const;
|
||||||
void getState(TextLinkPtr &lnk, HistoryCursorState &state, int32 x, int32 y, const HistoryItem *parent) const;
|
void getState(TextLinkPtr &lnk, HistoryCursorState &state, int32 x, int32 y, const HistoryItem *parent) const;
|
||||||
|
@ -1979,7 +1980,7 @@ public:
|
||||||
|
|
||||||
UserData *bot;
|
UserData *bot;
|
||||||
QString text;
|
QString text;
|
||||||
int32 width, fullWidth;
|
int32 width, maxWidth;
|
||||||
TextLinkPtr lnk;
|
TextLinkPtr lnk;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
@ -2164,7 +2165,7 @@ public:
|
||||||
}
|
}
|
||||||
QString selectedText(uint32 selection) const;
|
QString selectedText(uint32 selection) const;
|
||||||
bool displayForwardedFrom() const {
|
bool displayForwardedFrom() const {
|
||||||
return (!_media || !_media->isDisplayed() || !_media->hideForwardedFrom());
|
return via() || !_media || !_media->isDisplayed() || !_media->hideForwardedFrom();
|
||||||
}
|
}
|
||||||
|
|
||||||
HistoryForwarded *toHistoryForwarded() {
|
HistoryForwarded *toHistoryForwarded() {
|
||||||
|
@ -2207,6 +2208,7 @@ public:
|
||||||
void drawReplyTo(Painter &p, int32 x, int32 y, int32 w, bool selected, bool likeService = false) const;
|
void drawReplyTo(Painter &p, int32 x, int32 y, int32 w, bool selected, bool likeService = false) const;
|
||||||
void drawMessageText(Painter &p, QRect trect, uint32 selection) const;
|
void drawMessageText(Painter &p, QRect trect, uint32 selection) const;
|
||||||
int32 resize(int32 width);
|
int32 resize(int32 width);
|
||||||
|
void resizeVia(int32 w) const;
|
||||||
bool hasPoint(int32 x, int32 y) const;
|
bool hasPoint(int32 x, int32 y) const;
|
||||||
void getState(TextLinkPtr &lnk, HistoryCursorState &state, int32 x, int32 y) const;
|
void getState(TextLinkPtr &lnk, HistoryCursorState &state, int32 x, int32 y) const;
|
||||||
void getStateFromMessageText(TextLinkPtr &lnk, HistoryCursorState &state, int32 x, int32 y, const QRect &r) const;
|
void getStateFromMessageText(TextLinkPtr &lnk, HistoryCursorState &state, int32 x, int32 y, const QRect &r) const;
|
||||||
|
@ -2234,6 +2236,10 @@ protected:
|
||||||
mutable Text replyToName, replyToText;
|
mutable Text replyToName, replyToText;
|
||||||
mutable int32 replyToVersion;
|
mutable int32 replyToVersion;
|
||||||
mutable int32 _maxReplyWidth;
|
mutable int32 _maxReplyWidth;
|
||||||
|
HistoryMessageVia *_replyToVia;
|
||||||
|
HistoryMessageVia *replyToVia() const {
|
||||||
|
return (_replyToVia && !_replyToVia->isNull()) ? _replyToVia : 0;
|
||||||
|
}
|
||||||
int32 toWidth;
|
int32 toWidth;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
Loading…
Add table
Reference in a new issue