mirror of
https://github.com/kotatogram/kotatogram-desktop
synced 2025-08-30 22:25:12 +00:00
added forwarded and from names in files / audios / videos / contacts display, grouped notification for many forwarded messages, fix of getDifference() for new_session_created
This commit is contained in:
@@ -97,6 +97,12 @@ namespace {
|
||||
inline const HistoryReply *toHistoryReply(const HistoryItem *item) {
|
||||
return item ? item->toHistoryReply() : 0;
|
||||
}
|
||||
inline HistoryForwarded *toHistoryForwarded(HistoryItem *item) {
|
||||
return item ? item->toHistoryForwarded() : 0;
|
||||
}
|
||||
inline const HistoryForwarded *toHistoryForwarded(const HistoryItem *item) {
|
||||
return item ? item->toHistoryForwarded() : 0;
|
||||
}
|
||||
}
|
||||
|
||||
void historyInit() {
|
||||
@@ -1855,12 +1861,16 @@ void HistoryVideo::initDimensions(const HistoryItem *parent) {
|
||||
_maxw += st::mediaSaveDelta + _buttonWidth;
|
||||
}
|
||||
_minh = st::mediaPadding.top() + st::mediaThumbSize + st::mediaPadding.bottom();
|
||||
if (!parent->out() && parent->history()->peer->chat) {
|
||||
_minh += st::msgPadding.top() + st::msgNameFont->height;
|
||||
}
|
||||
if (const HistoryReply *reply = toHistoryReply(parent)) {
|
||||
_maxw += st::mediaPadding.left() + st::mediaPadding.right();
|
||||
_minh += st::msgReplyPadding.top() + st::msgReplyBarSize.height() + st::msgReplyPadding.bottom();
|
||||
if (!parent->out() && parent->history()->peer->chat) {
|
||||
_minh += st::msgPadding.top() + st::msgNameFont->height;
|
||||
} else if (const HistoryForwarded *fwd = toHistoryForwarded(parent)) {
|
||||
if (parent->out() || !parent->history()->peer->chat) {
|
||||
_minh += st::msgPadding.top();
|
||||
}
|
||||
_minh += st::msgServiceNameFont->height;
|
||||
}
|
||||
_height = _minh;
|
||||
}
|
||||
@@ -1894,13 +1904,20 @@ void HistoryVideo::getState(TextLinkPtr &lnk, bool &inText, int32 x, int32 y, co
|
||||
if (width < 1) return;
|
||||
|
||||
const HistoryReply *reply = toHistoryReply(parent);
|
||||
int skipy = 0, replyFrom = 0;
|
||||
const HistoryForwarded *fwd = reply ? 0 : toHistoryForwarded(parent);
|
||||
int skipy = 0, replyFrom = 0, fwdFrom = 0;
|
||||
if (reply) {
|
||||
skipy = st::msgReplyPadding.top() + st::msgReplyBarSize.height() + st::msgReplyPadding.bottom();
|
||||
if (!parent->out() && parent->history()->peer->chat) {
|
||||
replyFrom = st::msgPadding.top() + st::msgNameFont->height;
|
||||
skipy += replyFrom;
|
||||
}
|
||||
} else if (fwd) {
|
||||
skipy = st::msgServiceNameFont->height;
|
||||
}
|
||||
if (!parent->out() && parent->history()->peer->chat) {
|
||||
replyFrom = st::msgPadding.top() + st::msgNameFont->height;
|
||||
fwdFrom = st::msgPadding.top() + st::msgNameFont->height;
|
||||
skipy += replyFrom;
|
||||
} else if (fwd) {
|
||||
fwdFrom = st::msgPadding.top();
|
||||
skipy += fwdFrom;
|
||||
}
|
||||
|
||||
bool out = parent->out(), hovered, pressed;
|
||||
@@ -1917,17 +1934,21 @@ void HistoryVideo::getState(TextLinkPtr &lnk, bool &inText, int32 x, int32 y, co
|
||||
width -= btnw + st::mediaSaveDelta;
|
||||
}
|
||||
|
||||
if (reply) {
|
||||
if (!parent->out() && parent->history()->peer->chat) {
|
||||
if (x >= st::mediaPadding.left() && y >= st::msgPadding.top() && x < width - st::mediaPadding.left() - st::mediaPadding.right() && x < st::mediaPadding.left() + parent->from()->nameText.maxWidth() && y < replyFrom) {
|
||||
lnk = parent->from()->lnk;
|
||||
return;
|
||||
}
|
||||
if (!parent->out() && parent->history()->peer->chat) {
|
||||
if (x >= st::mediaPadding.left() && y >= st::msgPadding.top() && x < width - st::mediaPadding.left() - st::mediaPadding.right() && x < st::mediaPadding.left() + parent->from()->nameText.maxWidth() && y < replyFrom) {
|
||||
lnk = parent->from()->lnk;
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (reply) {
|
||||
if (x >= 0 && y >= replyFrom + st::msgReplyPadding.top() && x < width && y < skipy - st::msgReplyPadding.bottom()) {
|
||||
lnk = reply->replyToLink();
|
||||
return;
|
||||
}
|
||||
} else if (fwd) {
|
||||
if (y >= fwdFrom && y < skipy) {
|
||||
return fwd->getForwardedState(lnk, inText, x - st::mediaPadding.left(), width - st::mediaPadding.left() - st::mediaPadding.right());
|
||||
}
|
||||
}
|
||||
|
||||
if (x >= 0 && y >= skipy && x < width && y < _height && !data->loader && data->access) {
|
||||
@@ -1945,13 +1966,20 @@ void HistoryVideo::draw(QPainter &p, const HistoryItem *parent, bool selected, i
|
||||
if (width < 1) return;
|
||||
|
||||
const HistoryReply *reply = toHistoryReply(parent);
|
||||
int skipy = 0, replyFrom = 0;
|
||||
const HistoryForwarded *fwd = reply ? 0 : toHistoryForwarded(parent);
|
||||
int skipy = 0, replyFrom = 0, fwdFrom = 0;
|
||||
if (reply) {
|
||||
skipy = st::msgReplyPadding.top() + st::msgReplyBarSize.height() + st::msgReplyPadding.bottom();
|
||||
if (!parent->out() && parent->history()->peer->chat) {
|
||||
replyFrom = st::msgPadding.top() + st::msgNameFont->height;
|
||||
skipy += replyFrom;
|
||||
}
|
||||
} else if (fwd) {
|
||||
skipy = st::msgServiceNameFont->height;
|
||||
}
|
||||
if (!parent->out() && parent->history()->peer->chat) {
|
||||
replyFrom = st::msgPadding.top() + st::msgNameFont->height;
|
||||
fwdFrom = st::msgPadding.top() + st::msgNameFont->height;
|
||||
skipy += replyFrom;
|
||||
} else if (fwd) {
|
||||
fwdFrom = st::msgPadding.top();
|
||||
skipy += fwdFrom;
|
||||
}
|
||||
|
||||
data->thumb->checkload();
|
||||
@@ -1986,13 +2014,15 @@ void HistoryVideo::draw(QPainter &p, const HistoryItem *parent, bool selected, i
|
||||
style::color shadow(selected ? (out ? st::msgOutSelectShadow : st::msgInSelectShadow) : (out ? st::msgOutShadow : st::msgInShadow));
|
||||
p.fillRect(0, _height, width, st::msgShadow, shadow->b);
|
||||
|
||||
if (!parent->out() && parent->history()->peer->chat) {
|
||||
p.setFont(st::msgNameFont->f);
|
||||
p.setPen(parent->from()->color->p);
|
||||
parent->from()->nameText.drawElided(p, st::mediaPadding.left(), st::msgPadding.top(), width - st::mediaPadding.left() - st::mediaPadding.right());
|
||||
}
|
||||
if (reply) {
|
||||
if (!parent->out() && parent->history()->peer->chat) {
|
||||
p.setFont(st::msgNameFont->f);
|
||||
p.setPen(parent->from()->color->p);
|
||||
parent->from()->nameText.drawElided(p, st::mediaPadding.left(), st::msgPadding.top(), width - st::mediaPadding.left() - st::mediaPadding.right());
|
||||
}
|
||||
reply->drawReplyTo(p, st::msgReplyPadding.left(), replyFrom, width - st::msgReplyPadding.left() - st::msgReplyPadding.right(), selected);
|
||||
} else if (fwd) {
|
||||
fwd->drawForwardedFrom(p, st::mediaPadding.left(), fwdFrom, width - st::mediaPadding.left() - st::mediaPadding.right(), selected);
|
||||
}
|
||||
|
||||
if (_thumbw) {
|
||||
@@ -2102,12 +2132,16 @@ void HistoryAudio::initDimensions(const HistoryItem *parent) {
|
||||
}
|
||||
|
||||
_minh = st::mediaPadding.top() + st::mediaThumbSize + st::mediaPadding.bottom();
|
||||
if (!parent->out() && parent->history()->peer->chat) {
|
||||
_minh += st::msgPadding.top() + st::msgNameFont->height;
|
||||
}
|
||||
if (const HistoryReply *reply = toHistoryReply(parent)) {
|
||||
_maxw += st::mediaPadding.left() + st::mediaPadding.right();
|
||||
_minh += st::msgReplyPadding.top() + st::msgReplyBarSize.height() + st::msgReplyPadding.bottom();
|
||||
if (!parent->out() && parent->history()->peer->chat) {
|
||||
_minh += st::msgPadding.top() + st::msgNameFont->height;
|
||||
} else if (const HistoryForwarded *fwd = toHistoryForwarded(parent)) {
|
||||
if (parent->out() || !parent->history()->peer->chat) {
|
||||
_minh += st::msgPadding.top();
|
||||
}
|
||||
_minh += st::msgServiceNameFont->height;
|
||||
}
|
||||
_height = _minh;
|
||||
}
|
||||
@@ -2117,13 +2151,20 @@ void HistoryAudio::draw(QPainter &p, const HistoryItem *parent, bool selected, i
|
||||
if (width < 1) return;
|
||||
|
||||
const HistoryReply *reply = toHistoryReply(parent);
|
||||
int skipy = 0, replyFrom = 0;
|
||||
const HistoryForwarded *fwd = reply ? 0 : toHistoryForwarded(parent);
|
||||
int skipy = 0, replyFrom = 0, fwdFrom = 0;
|
||||
if (reply) {
|
||||
skipy = st::msgReplyPadding.top() + st::msgReplyBarSize.height() + st::msgReplyPadding.bottom();
|
||||
if (!parent->out() && parent->history()->peer->chat) {
|
||||
replyFrom = st::msgPadding.top() + st::msgNameFont->height;
|
||||
skipy += replyFrom;
|
||||
}
|
||||
} else if (fwd) {
|
||||
skipy = st::msgServiceNameFont->height;
|
||||
}
|
||||
if (!parent->out() && parent->history()->peer->chat) {
|
||||
replyFrom = st::msgPadding.top() + st::msgNameFont->height;
|
||||
fwdFrom = st::msgPadding.top() + st::msgNameFont->height;
|
||||
skipy += replyFrom;
|
||||
} else if (fwd) {
|
||||
fwdFrom = st::msgPadding.top();
|
||||
skipy += fwdFrom;
|
||||
}
|
||||
|
||||
bool out = parent->out(), hovered, pressed, already = !data->already().isEmpty(), hasdata = !data->data.isEmpty();
|
||||
@@ -2161,13 +2202,15 @@ void HistoryAudio::draw(QPainter &p, const HistoryItem *parent, bool selected, i
|
||||
style::color shadow(selected ? (out ? st::msgOutSelectShadow : st::msgInSelectShadow) : (out ? st::msgOutShadow : st::msgInShadow));
|
||||
p.fillRect(0, _height, width, st::msgShadow, shadow->b);
|
||||
|
||||
if (!parent->out() && parent->history()->peer->chat) {
|
||||
p.setFont(st::msgNameFont->f);
|
||||
p.setPen(parent->from()->color->p);
|
||||
parent->from()->nameText.drawElided(p, st::mediaPadding.left(), st::msgPadding.top(), width - st::mediaPadding.left() - st::mediaPadding.right());
|
||||
}
|
||||
if (reply) {
|
||||
if (!parent->out() && parent->history()->peer->chat) {
|
||||
p.setFont(st::msgNameFont->f);
|
||||
p.setPen(parent->from()->color->p);
|
||||
parent->from()->nameText.drawElided(p, st::mediaPadding.left(), st::msgPadding.top(), width - st::mediaPadding.left() - st::mediaPadding.right());
|
||||
}
|
||||
reply->drawReplyTo(p, st::msgReplyPadding.left(), replyFrom, width - st::msgReplyPadding.left() - st::msgReplyPadding.right(), selected);
|
||||
} else if (fwd) {
|
||||
fwd->drawForwardedFrom(p, st::mediaPadding.left(), fwdFrom, width - st::mediaPadding.left() - st::mediaPadding.right(), selected);
|
||||
}
|
||||
|
||||
AudioData *playing = 0;
|
||||
@@ -2280,13 +2323,20 @@ void HistoryAudio::getState(TextLinkPtr &lnk, bool &inText, int32 x, int32 y, co
|
||||
if (width < 1) return;
|
||||
|
||||
const HistoryReply *reply = toHistoryReply(parent);
|
||||
int skipy = 0, replyFrom = 0;
|
||||
const HistoryForwarded *fwd = reply ? 0 : toHistoryForwarded(parent);
|
||||
int skipy = 0, replyFrom = 0, fwdFrom = 0;
|
||||
if (reply) {
|
||||
skipy = st::msgReplyPadding.top() + st::msgReplyBarSize.height() + st::msgReplyPadding.bottom();
|
||||
if (!parent->out() && parent->history()->peer->chat) {
|
||||
replyFrom = st::msgPadding.top() + st::msgNameFont->height;
|
||||
skipy += replyFrom;
|
||||
}
|
||||
} else if (fwd) {
|
||||
skipy = st::msgServiceNameFont->height;
|
||||
}
|
||||
if (!parent->out() && parent->history()->peer->chat) {
|
||||
replyFrom = st::msgPadding.top() + st::msgNameFont->height;
|
||||
fwdFrom = st::msgPadding.top() + st::msgNameFont->height;
|
||||
skipy += replyFrom;
|
||||
} else if (fwd) {
|
||||
fwdFrom = st::msgPadding.top();
|
||||
skipy += fwdFrom;
|
||||
}
|
||||
|
||||
bool out = parent->out(), hovered, pressed;
|
||||
@@ -2303,17 +2353,21 @@ void HistoryAudio::getState(TextLinkPtr &lnk, bool &inText, int32 x, int32 y, co
|
||||
width -= btnw + st::mediaSaveDelta;
|
||||
}
|
||||
|
||||
if (reply) {
|
||||
if (!parent->out() && parent->history()->peer->chat) {
|
||||
if (x >= st::mediaPadding.left() && y >= st::msgPadding.top() && x < width - st::mediaPadding.left() - st::mediaPadding.right() && x < st::mediaPadding.left() + parent->from()->nameText.maxWidth() && y < replyFrom) {
|
||||
lnk = parent->from()->lnk;
|
||||
return;
|
||||
}
|
||||
if (!parent->out() && parent->history()->peer->chat) {
|
||||
if (x >= st::mediaPadding.left() && y >= st::msgPadding.top() && x < width - st::mediaPadding.left() - st::mediaPadding.right() && x < st::mediaPadding.left() + parent->from()->nameText.maxWidth() && y < replyFrom) {
|
||||
lnk = parent->from()->lnk;
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (reply) {
|
||||
if (x >= 0 && y >= replyFrom + st::msgReplyPadding.top() && x < width && y < skipy - st::msgReplyPadding.bottom()) {
|
||||
lnk = reply->replyToLink();
|
||||
return;
|
||||
}
|
||||
} else if (fwd) {
|
||||
if (y >= fwdFrom && y < skipy) {
|
||||
return fwd->getForwardedState(lnk, inText, x - st::mediaPadding.left(), width - st::mediaPadding.left() - st::mediaPadding.right());
|
||||
}
|
||||
}
|
||||
|
||||
if (x >= 0 && y >= skipy && x < width && y < _height && !data->loader && data->access) {
|
||||
@@ -2379,12 +2433,16 @@ void HistoryDocument::initDimensions(const HistoryItem *parent) {
|
||||
}
|
||||
_minh = st::mediaPadding.top() + st::mediaThumbSize + st::mediaPadding.bottom();
|
||||
|
||||
if (!parent->out() && parent->history()->peer->chat) {
|
||||
_minh += st::msgPadding.top() + st::msgNameFont->height;
|
||||
}
|
||||
if (const HistoryReply *reply = toHistoryReply(parent)) {
|
||||
_maxw += st::mediaPadding.left() + st::mediaPadding.right();
|
||||
_minh += st::msgReplyPadding.top() + st::msgReplyBarSize.height() + st::msgReplyPadding.bottom();
|
||||
if (!parent->out() && parent->history()->peer->chat) {
|
||||
_minh += st::msgPadding.top() + st::msgNameFont->height;
|
||||
} else if (const HistoryForwarded *fwd = toHistoryForwarded(parent)) {
|
||||
if (parent->out() || !parent->history()->peer->chat) {
|
||||
_minh += st::msgPadding.top();
|
||||
}
|
||||
_minh += st::msgServiceNameFont->height;
|
||||
}
|
||||
}
|
||||
_height = _minh;
|
||||
@@ -2416,13 +2474,20 @@ void HistoryDocument::draw(QPainter &p, const HistoryItem *parent, bool selected
|
||||
}
|
||||
|
||||
const HistoryReply *reply = toHistoryReply(parent);
|
||||
int skipy = 0, replyFrom = 0;
|
||||
const HistoryForwarded *fwd = reply ? 0 : toHistoryForwarded(parent);
|
||||
int skipy = 0, replyFrom = 0, fwdFrom = 0;
|
||||
if (reply) {
|
||||
skipy = st::msgReplyPadding.top() + st::msgReplyBarSize.height() + st::msgReplyPadding.bottom();
|
||||
if (!parent->out() && parent->history()->peer->chat) {
|
||||
replyFrom = st::msgPadding.top() + st::msgNameFont->height;
|
||||
skipy += replyFrom;
|
||||
}
|
||||
} else if (fwd) {
|
||||
skipy = st::msgServiceNameFont->height;
|
||||
}
|
||||
if (!parent->out() && parent->history()->peer->chat) {
|
||||
replyFrom = st::msgPadding.top() + st::msgNameFont->height;
|
||||
fwdFrom = st::msgPadding.top() + st::msgNameFont->height;
|
||||
skipy += replyFrom;
|
||||
} else if (fwd) {
|
||||
fwdFrom = st::msgPadding.top();
|
||||
skipy += fwdFrom;
|
||||
}
|
||||
|
||||
data->thumb->checkload();
|
||||
@@ -2456,15 +2521,16 @@ void HistoryDocument::draw(QPainter &p, const HistoryItem *parent, bool selected
|
||||
style::color shadow(selected ? (out ? st::msgOutSelectShadow : st::msgInSelectShadow) : (out ? st::msgOutShadow : st::msgInShadow));
|
||||
p.fillRect(0, _height, width, st::msgShadow, shadow->b);
|
||||
|
||||
if (reply) {
|
||||
if (!parent->out() && parent->history()->peer->chat) {
|
||||
p.setFont(st::msgNameFont->f);
|
||||
p.setPen(parent->from()->color->p);
|
||||
parent->from()->nameText.drawElided(p, st::mediaPadding.left(), st::msgPadding.top(), width - st::mediaPadding.left() - st::mediaPadding.right());
|
||||
}
|
||||
reply->drawReplyTo(p, st::msgReplyPadding.left(), replyFrom, width - st::msgReplyPadding.left() - st::msgReplyPadding.right(), selected);
|
||||
if (!parent->out() && parent->history()->peer->chat) {
|
||||
p.setFont(st::msgNameFont->f);
|
||||
p.setPen(parent->from()->color->p);
|
||||
parent->from()->nameText.drawElided(p, st::mediaPadding.left(), st::msgPadding.top(), width - st::mediaPadding.left() - st::mediaPadding.right());
|
||||
}
|
||||
if (reply) {
|
||||
reply->drawReplyTo(p, st::msgReplyPadding.left(), replyFrom, width - st::msgReplyPadding.left() - st::msgReplyPadding.right(), selected);
|
||||
} else if (fwd) {
|
||||
fwd->drawForwardedFrom(p, st::mediaPadding.left(), fwdFrom, width - st::mediaPadding.left() - st::mediaPadding.right(), selected);
|
||||
}
|
||||
|
||||
if (_thumbw) {
|
||||
int32 rf(cIntRetinaFactor());
|
||||
p.drawPixmap(QPoint(st::mediaPadding.left(), skipy + st::mediaPadding.top()), data->thumb->pix(_thumbw), QRect(_thumbx * rf, _thumby * rf, st::mediaThumbSize * rf, st::mediaThumbSize * rf));
|
||||
@@ -2617,13 +2683,20 @@ void HistoryDocument::getState(TextLinkPtr &lnk, bool &inText, int32 x, int32 y,
|
||||
}
|
||||
|
||||
const HistoryReply *reply = toHistoryReply(parent);
|
||||
int skipy = 0, replyFrom = 0;
|
||||
const HistoryForwarded *fwd = reply ? 0 : toHistoryForwarded(parent);
|
||||
int skipy = 0, replyFrom = 0, fwdFrom = 0;
|
||||
if (reply) {
|
||||
skipy = st::msgReplyPadding.top() + st::msgReplyBarSize.height() + st::msgReplyPadding.bottom();
|
||||
if (!parent->out() && parent->history()->peer->chat) {
|
||||
replyFrom = st::msgPadding.top() + st::msgNameFont->height;
|
||||
skipy += replyFrom;
|
||||
}
|
||||
} else if (fwd) {
|
||||
skipy = st::msgServiceNameFont->height;
|
||||
}
|
||||
if (!parent->out() && parent->history()->peer->chat) {
|
||||
replyFrom = st::msgPadding.top() + st::msgNameFont->height;
|
||||
fwdFrom = st::msgPadding.top() + st::msgNameFont->height;
|
||||
skipy += replyFrom;
|
||||
} else if (fwd) {
|
||||
fwdFrom = st::msgPadding.top();
|
||||
skipy += fwdFrom;
|
||||
}
|
||||
|
||||
if (!out) { // draw Download / Save As button
|
||||
@@ -2635,17 +2708,21 @@ void HistoryDocument::getState(TextLinkPtr &lnk, bool &inText, int32 x, int32 y,
|
||||
width -= btnw + st::mediaSaveDelta;
|
||||
}
|
||||
|
||||
if (reply) {
|
||||
if (!parent->out() && parent->history()->peer->chat) {
|
||||
if (x >= st::mediaPadding.left() && y >= st::msgPadding.top() && x < width - st::mediaPadding.left() - st::mediaPadding.right() && x < st::mediaPadding.left() + parent->from()->nameText.maxWidth() && y < replyFrom) {
|
||||
lnk = parent->from()->lnk;
|
||||
return;
|
||||
}
|
||||
if (!parent->out() && parent->history()->peer->chat) {
|
||||
if (x >= st::mediaPadding.left() && y >= st::msgPadding.top() && x < width - st::mediaPadding.left() - st::mediaPadding.right() && x < st::mediaPadding.left() + parent->from()->nameText.maxWidth() && y < replyFrom) {
|
||||
lnk = parent->from()->lnk;
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (reply) {
|
||||
if (x >= 0 && y >= replyFrom + st::msgReplyPadding.top() && x < width && y < skipy - st::msgReplyPadding.bottom()) {
|
||||
lnk = reply->replyToLink();
|
||||
return;
|
||||
}
|
||||
} else if (fwd) {
|
||||
if (y >= fwdFrom && y < skipy) {
|
||||
return fwd->getForwardedState(lnk, inText, x - st::mediaPadding.left(), width - st::mediaPadding.left() - st::mediaPadding.right());
|
||||
}
|
||||
}
|
||||
|
||||
if (x >= 0 && y >= skipy && x < width && y < _height && !data->loader && data->access) {
|
||||
@@ -2896,12 +2973,16 @@ void HistoryContact::initDimensions(const HistoryItem *parent) {
|
||||
_maxw = phonew + tleft + st::mediaPadding.right();
|
||||
}
|
||||
_minh = st::mediaPadding.top() + st::mediaThumbSize + st::mediaPadding.bottom();
|
||||
if (!parent->out() && parent->history()->peer->chat) {
|
||||
_minh += st::msgPadding.top() + st::msgNameFont->height;
|
||||
}
|
||||
if (const HistoryReply *reply = toHistoryReply(parent)) {
|
||||
_maxw += st::mediaPadding.left() + st::mediaPadding.right();
|
||||
_minh += st::msgReplyPadding.top() + st::msgReplyBarSize.height() + st::msgReplyPadding.bottom();
|
||||
if (!parent->out() && parent->history()->peer->chat) {
|
||||
_minh += st::msgPadding.top() + st::msgNameFont->height;
|
||||
} else if (const HistoryForwarded *fwd = toHistoryForwarded(parent)) {
|
||||
if (parent->out() || !parent->history()->peer->chat) {
|
||||
_minh += st::msgPadding.top();
|
||||
}
|
||||
_minh += st::msgServiceNameFont->height;
|
||||
}
|
||||
_height = _minh;
|
||||
}
|
||||
@@ -2923,26 +3004,37 @@ void HistoryContact::getState(TextLinkPtr &lnk, bool &inText, int32 x, int32 y,
|
||||
if (width < 0) width = w;
|
||||
|
||||
const HistoryReply *reply = toHistoryReply(parent);
|
||||
int skipy = 0, replyFrom = 0;
|
||||
const HistoryForwarded *fwd = reply ? 0 : toHistoryForwarded(parent);
|
||||
int skipy = 0, replyFrom = 0, fwdFrom = 0;
|
||||
if (reply) {
|
||||
skipy = st::msgReplyPadding.top() + st::msgReplyBarSize.height() + st::msgReplyPadding.bottom();
|
||||
if (!parent->out() && parent->history()->peer->chat) {
|
||||
replyFrom = st::msgPadding.top() + st::msgNameFont->height;
|
||||
skipy += replyFrom;
|
||||
}
|
||||
} else if (fwd) {
|
||||
skipy = st::msgServiceNameFont->height;
|
||||
}
|
||||
if (!parent->out() && parent->history()->peer->chat) {
|
||||
replyFrom = st::msgPadding.top() + st::msgNameFont->height;
|
||||
fwdFrom = st::msgPadding.top() + st::msgNameFont->height;
|
||||
skipy += replyFrom;
|
||||
} else if (fwd) {
|
||||
fwdFrom = st::msgPadding.top();
|
||||
skipy += fwdFrom;
|
||||
}
|
||||
|
||||
if (reply) {
|
||||
if (!parent->out() && parent->history()->peer->chat) {
|
||||
if (x >= st::mediaPadding.left() && y >= st::msgPadding.top() && x < width - st::mediaPadding.left() - st::mediaPadding.right() && x < st::mediaPadding.left() + parent->from()->nameText.maxWidth() && y < replyFrom) {
|
||||
lnk = parent->from()->lnk;
|
||||
return;
|
||||
}
|
||||
if (!parent->out() && parent->history()->peer->chat) {
|
||||
if (x >= st::mediaPadding.left() && y >= st::msgPadding.top() && x < width - st::mediaPadding.left() - st::mediaPadding.right() && x < st::mediaPadding.left() + parent->from()->nameText.maxWidth() && y < replyFrom) {
|
||||
lnk = parent->from()->lnk;
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (reply) {
|
||||
if (x >= 0 && y >= replyFrom + st::msgReplyPadding.top() && x < width && y < skipy - st::msgReplyPadding.bottom()) {
|
||||
lnk = reply->replyToLink();
|
||||
return;
|
||||
}
|
||||
} else if (fwd) {
|
||||
if (y >= fwdFrom && y < skipy) {
|
||||
return fwd->getForwardedState(lnk, inText, x - st::mediaPadding.left(), width - st::mediaPadding.left() - st::mediaPadding.right());
|
||||
}
|
||||
}
|
||||
|
||||
if (x >= 0 && y >= skipy && x < w && y < _height && contact) {
|
||||
@@ -2967,13 +3059,20 @@ void HistoryContact::draw(QPainter &p, const HistoryItem *parent, bool selected,
|
||||
if (width < 1) return;
|
||||
|
||||
const HistoryReply *reply = toHistoryReply(parent);
|
||||
int skipy = 0, replyFrom = 0;
|
||||
const HistoryForwarded *fwd = reply ? 0 : toHistoryForwarded(parent);
|
||||
int skipy = 0, replyFrom = 0, fwdFrom = 0;
|
||||
if (reply) {
|
||||
skipy = st::msgReplyPadding.top() + st::msgReplyBarSize.height() + st::msgReplyPadding.bottom();
|
||||
if (!parent->out() && parent->history()->peer->chat) {
|
||||
replyFrom = st::msgPadding.top() + st::msgNameFont->height;
|
||||
skipy += replyFrom;
|
||||
}
|
||||
} else if (fwd) {
|
||||
skipy = st::msgServiceNameFont->height;
|
||||
}
|
||||
if (!parent->out() && parent->history()->peer->chat) {
|
||||
replyFrom = st::msgPadding.top() + st::msgNameFont->height;
|
||||
fwdFrom = st::msgPadding.top() + st::msgNameFont->height;
|
||||
skipy += replyFrom;
|
||||
} else if (fwd) {
|
||||
fwdFrom = st::msgPadding.top();
|
||||
skipy += fwdFrom;
|
||||
}
|
||||
|
||||
bool out = parent->out();
|
||||
@@ -2987,13 +3086,15 @@ void HistoryContact::draw(QPainter &p, const HistoryItem *parent, bool selected,
|
||||
style::color shadow(selected ? (out ? st::msgOutSelectShadow : st::msgInSelectShadow) : (out ? st::msgOutShadow : st::msgInShadow));
|
||||
p.fillRect(0, _height, width, st::msgShadow, shadow->b);
|
||||
|
||||
if (!parent->out() && parent->history()->peer->chat) {
|
||||
p.setFont(st::msgNameFont->f);
|
||||
p.setPen(parent->from()->color->p);
|
||||
parent->from()->nameText.drawElided(p, st::mediaPadding.left(), st::msgPadding.top(), width - st::mediaPadding.left() - st::mediaPadding.right());
|
||||
}
|
||||
if (reply) {
|
||||
if (!parent->out() && parent->history()->peer->chat) {
|
||||
p.setFont(st::msgNameFont->f);
|
||||
p.setPen(parent->from()->color->p);
|
||||
parent->from()->nameText.drawElided(p, st::mediaPadding.left(), st::msgPadding.top(), width - st::mediaPadding.left() - st::mediaPadding.right());
|
||||
}
|
||||
reply->drawReplyTo(p, st::msgReplyPadding.left(), replyFrom, width - st::msgReplyPadding.left() - st::msgReplyPadding.right(), selected);
|
||||
} else if (fwd) {
|
||||
fwd->drawForwardedFrom(p, st::mediaPadding.left(), fwdFrom, width - st::mediaPadding.left() - st::mediaPadding.right(), selected);
|
||||
}
|
||||
|
||||
p.drawPixmap(st::mediaPadding.left(), skipy + st::mediaPadding.top(), (contact ? contact->photo : userDefPhoto(1))->pix(st::mediaThumbSize));
|
||||
@@ -4680,8 +4781,8 @@ void HistoryForwarded::initDimensions(const HistoryItem *parent) {
|
||||
}
|
||||
|
||||
void HistoryForwarded::fwdNameUpdated() const {
|
||||
if (justMedia()) return;
|
||||
fwdFromName.setText(st::msgServiceNameFont, App::peerName(fwdFrom), _textNameOptions);
|
||||
if (justMedia()) return;
|
||||
int32 _namew = fromWidth + fwdFromName.maxWidth() + st::msgPadding.left() + st::msgPadding.right();
|
||||
if (_namew > _maxw) _maxw = _namew;
|
||||
}
|
||||
@@ -4694,22 +4795,26 @@ void HistoryForwarded::draw(QPainter &p, uint32 selection) const {
|
||||
HistoryMessage::draw(p, selection);
|
||||
}
|
||||
|
||||
void HistoryForwarded::drawMessageText(QPainter &p, const QRect &trect, uint32 selection) const {
|
||||
void HistoryForwarded::drawForwardedFrom(QPainter &p, int32 x, int32 y, int32 w, bool selected) const {
|
||||
style::font serviceFont(st::msgServiceFont), serviceName(st::msgServiceNameFont);
|
||||
bool selected = (selection == FullItemSel);
|
||||
|
||||
p.setPen((selected ? (out() ? st::msgOutServiceSelColor : st::msgInServiceSelColor) : (out() ? st::msgOutServiceColor : st::msgInServiceColor))->p);
|
||||
p.setFont(serviceFont->f);
|
||||
|
||||
int32 h1 = 0, h2 = serviceName->height, h = h1 + (h1 > h2 ? h1 : h2);
|
||||
|
||||
if (trect.width() >= fromWidth) {
|
||||
p.drawText(trect.x(), trect.y() + h1 + serviceFont->ascent, lang(lng_forwarded_from));
|
||||
if (w >= fromWidth) {
|
||||
p.drawText(x, y + serviceFont->ascent, lang(lng_forwarded_from));
|
||||
|
||||
p.setFont(serviceName->f);
|
||||
fwdFromName.drawElided(p, trect.x() + fromWidth, trect.y() + h1, trect.width() - fromWidth);
|
||||
fwdFromName.drawElided(p, x + fromWidth, y, w - fromWidth);
|
||||
} else {
|
||||
p.drawText(trect.x(), trect.y() + h1 + serviceFont->ascent, serviceFont->m.elidedText(lang(lng_forwarded_from), Qt::ElideRight, trect.width()));
|
||||
p.drawText(x, y + serviceFont->ascent, serviceFont->m.elidedText(lang(lng_forwarded_from), Qt::ElideRight, w));
|
||||
}
|
||||
}
|
||||
|
||||
void HistoryForwarded::drawMessageText(QPainter &p, const QRect &trect, uint32 selection) const {
|
||||
int32 h = st::msgServiceNameFont->height;
|
||||
|
||||
drawForwardedFrom(p, trect.x(), trect.y(), trect.width(), (selection == FullItemSel));
|
||||
|
||||
QRect realtrect(trect);
|
||||
realtrect.setY(trect.y() + h);
|
||||
@@ -4783,16 +4888,22 @@ void HistoryForwarded::getState(TextLinkPtr &lnk, bool &inText, int32 x, int32 y
|
||||
QRect trect(r.marginsAdded(-st::msgPadding));
|
||||
|
||||
if (y >= trect.top() && y < trect.top() + st::msgServiceNameFont->height) {
|
||||
if (x >= trect.left() + fromWidth && x < trect.right() && x < trect.left() + fromWidth + fwdFromName.maxWidth()) {
|
||||
lnk = fwdFrom->lnk;
|
||||
}
|
||||
return;
|
||||
return getForwardedState(lnk, inText, x - trect.left(), trect.right() - trect.left());
|
||||
}
|
||||
y -= st::msgServiceNameFont->height;
|
||||
}
|
||||
return HistoryMessage::getState(lnk, inText, x, y);
|
||||
}
|
||||
|
||||
void HistoryForwarded::getForwardedState(TextLinkPtr &lnk, bool &inText, int32 x, int32 w) const {
|
||||
inText = false;
|
||||
if (x >= fromWidth && x < w && x < fromWidth + fwdFromName.maxWidth()) {
|
||||
lnk = fwdFrom->lnk;
|
||||
} else {
|
||||
lnk = TextLinkPtr();
|
||||
}
|
||||
}
|
||||
|
||||
void HistoryForwarded::getSymbol(uint16 &symbol, bool &after, bool &upon, int32 x, int32 y) const {
|
||||
symbol = 0;
|
||||
after = false;
|
||||
|
Reference in New Issue
Block a user