Fix service messages time showing in dialogs as text
This commit is contained in:
parent
8f133b5791
commit
12b25d973d
3 changed files with 13 additions and 6 deletions
|
|
@ -832,6 +832,10 @@ ClickHandlerPtr HistoryService::fromLink() const {
|
||||||
|
|
||||||
void HistoryService::setServiceText(const PreparedText &prepared) {
|
void HistoryService::setServiceText(const PreparedText &prepared) {
|
||||||
_text.setText(
|
_text.setText(
|
||||||
|
st::serviceTextStyle,
|
||||||
|
prepared.text,
|
||||||
|
Ui::ItemTextServiceOptions());
|
||||||
|
_postfixedText.setText(
|
||||||
st::serviceTextStyle,
|
st::serviceTextStyle,
|
||||||
prepared.text + GenerateServiceTime(date()),
|
prepared.text + GenerateServiceTime(date()),
|
||||||
Ui::ItemTextServiceOptions());
|
Ui::ItemTextServiceOptions());
|
||||||
|
|
@ -839,6 +843,7 @@ void HistoryService::setServiceText(const PreparedText &prepared) {
|
||||||
for_const (auto &link, prepared.links) {
|
for_const (auto &link, prepared.links) {
|
||||||
// Link indices start with 1.
|
// Link indices start with 1.
|
||||||
_text.setLink(++linkIndex, link);
|
_text.setLink(++linkIndex, link);
|
||||||
|
_postfixedText.setLink(linkIndex, link);
|
||||||
}
|
}
|
||||||
_textWidth = -1;
|
_textWidth = -1;
|
||||||
_textHeight = 0;
|
_textHeight = 0;
|
||||||
|
|
|
||||||
|
|
@ -164,6 +164,8 @@ private:
|
||||||
|
|
||||||
friend class HistoryView::Service;
|
friend class HistoryView::Service;
|
||||||
|
|
||||||
|
Ui::Text::String _postfixedText;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
not_null<HistoryService*> GenerateJoinedMessage(
|
not_null<HistoryService*> GenerateJoinedMessage(
|
||||||
|
|
|
||||||
|
|
@ -355,7 +355,7 @@ QSize Service::performCountCurrentSize(int newWidth) {
|
||||||
auto nwidth = qMax(contentWidth - st::msgServicePadding.left() - st::msgServicePadding.right(), 0);
|
auto nwidth = qMax(contentWidth - st::msgServicePadding.left() - st::msgServicePadding.right(), 0);
|
||||||
if (nwidth != item->_textWidth) {
|
if (nwidth != item->_textWidth) {
|
||||||
item->_textWidth = nwidth;
|
item->_textWidth = nwidth;
|
||||||
item->_textHeight = item->_text.countHeight(nwidth);
|
item->_textHeight = item->_postfixedText.countHeight(nwidth);
|
||||||
}
|
}
|
||||||
if (contentWidth >= maxWidth()) {
|
if (contentWidth >= maxWidth()) {
|
||||||
newHeight += minHeight();
|
newHeight += minHeight();
|
||||||
|
|
@ -375,8 +375,8 @@ QSize Service::performCountOptimalSize() {
|
||||||
const auto item = message();
|
const auto item = message();
|
||||||
const auto media = this->media();
|
const auto media = this->media();
|
||||||
|
|
||||||
auto maxWidth = item->_text.maxWidth() + st::msgServicePadding.left() + st::msgServicePadding.right();
|
auto maxWidth = item->_postfixedText.maxWidth() + st::msgServicePadding.left() + st::msgServicePadding.right();
|
||||||
auto minHeight = item->_text.minHeight();
|
auto minHeight = item->_postfixedText.minHeight();
|
||||||
if (media) {
|
if (media) {
|
||||||
media->initDimensions();
|
media->initDimensions();
|
||||||
}
|
}
|
||||||
|
|
@ -449,12 +449,12 @@ void Service::draw(
|
||||||
|
|
||||||
auto trect = QRect(g.left(), st::msgServiceMargin.top(), g.width(), height).marginsAdded(-st::msgServicePadding);
|
auto trect = QRect(g.left(), st::msgServiceMargin.top(), g.width(), height).marginsAdded(-st::msgServicePadding);
|
||||||
|
|
||||||
ServiceMessagePainter::paintComplexBubble(p, g.left(), g.width(), item->_text, trect);
|
ServiceMessagePainter::paintComplexBubble(p, g.left(), g.width(), item->_postfixedText, trect);
|
||||||
|
|
||||||
p.setBrush(Qt::NoBrush);
|
p.setBrush(Qt::NoBrush);
|
||||||
p.setPen(st::msgServiceFg);
|
p.setPen(st::msgServiceFg);
|
||||||
p.setFont(st::msgServiceFont);
|
p.setFont(st::msgServiceFont);
|
||||||
item->_text.draw(p, trect.x(), trect.y(), trect.width(), Qt::AlignCenter, 0, -1, selection, false);
|
item->_postfixedText.draw(p, trect.x(), trect.y(), trect.width(), Qt::AlignCenter, 0, -1, selection, false);
|
||||||
|
|
||||||
p.restoreTextPalette();
|
p.restoreTextPalette();
|
||||||
|
|
||||||
|
|
@ -512,7 +512,7 @@ TextState Service::textState(QPoint point, StateRequest request) const {
|
||||||
if (trect.contains(point)) {
|
if (trect.contains(point)) {
|
||||||
auto textRequest = request.forText();
|
auto textRequest = request.forText();
|
||||||
textRequest.align = style::al_center;
|
textRequest.align = style::al_center;
|
||||||
result = TextState(item, item->_text.getState(
|
result = TextState(item, item->_postfixedText.getState(
|
||||||
point - trect.topLeft(),
|
point - trect.topLeft(),
|
||||||
trect.width(),
|
trect.width(),
|
||||||
textRequest));
|
textRequest));
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue