mirror of
https://github.com/telegramdesktop/tdesktop
synced 2025-04-08 18:51:50 +00:00
parent
0cbad9098e
commit
b3059248d4
Telegram
Resources
SourceFiles/history
@ -172,6 +172,21 @@ inFwdTextPaletteSelected: TextPalette(defaultTextPalette) {
|
||||
outFwdTextPaletteSelected: TextPalette(defaultTextPalette) {
|
||||
linkFg: msgOutServiceFgSelected;
|
||||
}
|
||||
inReplyTextPalette: TextPalette(inTextPalette) {
|
||||
linkFg: msgInDateFg;
|
||||
}
|
||||
inReplyTextPaletteSelected: TextPalette(inTextPaletteSelected) {
|
||||
linkFg: msgInDateFgSelected;
|
||||
}
|
||||
outReplyTextPalette: TextPalette(outTextPalette) {
|
||||
linkFg: msgOutDateFg;
|
||||
}
|
||||
outReplyTextPaletteSelected: TextPalette(outTextPaletteSelected) {
|
||||
linkFg: msgOutDateFgSelected;
|
||||
}
|
||||
imgReplyTextPalette: TextPalette(defaultTextPalette) {
|
||||
linkFg: msgImgReplyBarColor;
|
||||
}
|
||||
inSemiboldPalette: TextPalette(inTextPalette) {
|
||||
linkFg: msgInServiceFg;
|
||||
selectFg: msgInServiceFgSelected;
|
||||
@ -182,6 +197,9 @@ outSemiboldPalette: TextPalette(outTextPalette) {
|
||||
selectFg: msgOutServiceFgSelected;
|
||||
selectLinkFg: msgOutServiceFgSelected;
|
||||
}
|
||||
historyComposeAreaPalette: TextPalette(defaultTextPalette) {
|
||||
linkFg: historyComposeAreaFgService;
|
||||
}
|
||||
|
||||
mediaCaptionSkip: 5px;
|
||||
mediaInBubbleSkip: 5px;
|
||||
|
@ -183,7 +183,7 @@ public:
|
||||
// Example: "[link1-start]You:[link1-end] [link1-start]Photo,[link1-end] caption text"
|
||||
virtual QString inDialogsText(DrawInDialog way) const;
|
||||
virtual QString inReplyText() const {
|
||||
return notificationText();
|
||||
return inDialogsText(DrawInDialog::WithoutSender);
|
||||
}
|
||||
virtual TextWithEntities originalText() const {
|
||||
return { QString(), EntitiesInText() };
|
||||
|
@ -149,7 +149,7 @@ bool HistoryMessageReply::updateData(
|
||||
if (replyToMsg) {
|
||||
replyToText.setText(
|
||||
st::messageTextStyle,
|
||||
TextUtilities::Clean(replyToMsg->inReplyText()),
|
||||
replyToMsg->inReplyText(),
|
||||
Ui::DialogTextOptions());
|
||||
|
||||
updateName();
|
||||
@ -271,14 +271,14 @@ void HistoryMessageReply::paint(
|
||||
p.drawText(x + st::msgReplyBarSkip + previewSkip + replyToName.maxWidth() + st::msgServiceFont->spacew, y + st::msgReplyPadding.top() + st::msgServiceFont->ascent, replyToVia->text);
|
||||
}
|
||||
|
||||
auto replyToAsMsg = replyToMsg->toHistoryMessage();
|
||||
if (!(flags & PaintFlag::InBubble)) {
|
||||
} else if (!replyToAsMsg) {
|
||||
p.setPen(outbg ? (selected ? st::msgOutDateFgSelected : st::msgOutDateFg) : (selected ? st::msgInDateFgSelected : st::msgInDateFg));
|
||||
} else {
|
||||
if (flags & PaintFlag::InBubble) {
|
||||
p.setPen(outbg ? (selected ? st::historyTextOutFgSelected : st::historyTextOutFg) : (selected ? st::historyTextInFgSelected : st::historyTextInFg));
|
||||
p.setTextPalette(outbg ? (selected ? st::outReplyTextPaletteSelected : st::outReplyTextPalette) : (selected ? st::inReplyTextPaletteSelected : st::inReplyTextPalette));
|
||||
} else {
|
||||
p.setTextPalette(st::imgReplyTextPalette);
|
||||
}
|
||||
replyToText.drawLeftElided(p, x + st::msgReplyBarSkip + previewSkip, y + st::msgReplyPadding.top() + st::msgServiceNameFont->height, w - st::msgReplyBarSkip - previewSkip, w + 2 * x);
|
||||
p.setTextPalette(selected ? (outbg ? st::outTextPaletteSelected : st::inTextPaletteSelected) : (outbg ? st::outTextPalette : st::inTextPalette));
|
||||
}
|
||||
} else {
|
||||
p.setFont(st::msgDateFont);
|
||||
|
@ -464,8 +464,11 @@ QString HistoryService::inDialogsText(DrawInDialog way) const {
|
||||
}
|
||||
|
||||
QString HistoryService::inReplyText() const {
|
||||
QString result = HistoryService::notificationText();
|
||||
return result.trimmed().startsWith(author()->name) ? result.trimmed().mid(author()->name.size()).trimmed() : result;
|
||||
const auto result = HistoryService::notificationText();
|
||||
const auto text = result.trimmed().startsWith(author()->name)
|
||||
? result.trimmed().mid(author()->name.size()).trimmed()
|
||||
: result;
|
||||
return textcmdLink(1, text);
|
||||
}
|
||||
|
||||
std::unique_ptr<HistoryView::Element> HistoryService::createView(
|
||||
|
@ -3798,12 +3798,7 @@ void HistoryWidget::onKbToggle(bool manual) {
|
||||
_kbReplyTo = (_peer->isChat() || _peer->isChannel() || _keyboard->forceReply()) ? App::histItemById(_keyboard->forMsgId()) : 0;
|
||||
if (_kbReplyTo && !_editMsgId && !_replyToId && fieldEnabled) {
|
||||
updateReplyToName();
|
||||
_replyEditMsgText.setText(
|
||||
st::messageTextStyle,
|
||||
TextUtilities::Clean(_kbReplyTo->inReplyText()),
|
||||
Ui::DialogTextOptions());
|
||||
_fieldBarCancel->show();
|
||||
updateMouseTracking();
|
||||
updateReplyEditText(_kbReplyTo);
|
||||
}
|
||||
if (manual && _history) {
|
||||
_history->lastKeyboardHiddenId = 0;
|
||||
@ -3820,12 +3815,7 @@ void HistoryWidget::onKbToggle(bool manual) {
|
||||
_kbReplyTo = (_peer->isChat() || _peer->isChannel() || _keyboard->forceReply()) ? App::histItemById(_keyboard->forMsgId()) : 0;
|
||||
if (_kbReplyTo && !_editMsgId && !_replyToId) {
|
||||
updateReplyToName();
|
||||
_replyEditMsgText.setText(
|
||||
st::messageTextStyle,
|
||||
TextUtilities::Clean(_kbReplyTo->inReplyText()),
|
||||
Ui::DialogTextOptions());
|
||||
_fieldBarCancel->show();
|
||||
updateMouseTracking();
|
||||
updateReplyEditText(_kbReplyTo);
|
||||
}
|
||||
if (manual && _history) {
|
||||
_history->lastKeyboardHiddenId = 0;
|
||||
@ -5103,12 +5093,7 @@ void HistoryWidget::updateBotKeyboard(History *h, bool force) {
|
||||
_kbReplyTo = (_peer->isChat() || _peer->isChannel() || _keyboard->forceReply()) ? App::histItemById(_keyboard->forMsgId()) : 0;
|
||||
if (_kbReplyTo && !_replyToId) {
|
||||
updateReplyToName();
|
||||
_replyEditMsgText.setText(
|
||||
st::messageTextStyle,
|
||||
TextUtilities::Clean(_kbReplyTo->inReplyText()),
|
||||
Ui::DialogTextOptions());
|
||||
_fieldBarCancel->show();
|
||||
updateMouseTracking();
|
||||
updateReplyEditText(_kbReplyTo);
|
||||
}
|
||||
} else {
|
||||
if (!_a_show.animating()) {
|
||||
@ -5835,15 +5820,8 @@ void HistoryWidget::replyToMessage(not_null<HistoryItem*> item) {
|
||||
} else {
|
||||
_replyEditMsg = item;
|
||||
_replyToId = item->id;
|
||||
_replyEditMsgText.setText(
|
||||
st::messageTextStyle,
|
||||
TextUtilities::Clean(_replyEditMsg->inReplyText()),
|
||||
Ui::DialogTextOptions());
|
||||
|
||||
updateReplyEditText(_replyEditMsg);
|
||||
updateBotKeyboard();
|
||||
|
||||
if (!_field->isHidden()) _fieldBarCancel->show();
|
||||
updateMouseTracking();
|
||||
updateReplyToName();
|
||||
updateControlsGeometry();
|
||||
updateField();
|
||||
@ -6467,6 +6445,17 @@ void HistoryWidget::messageDataReceived(ChannelData *channel, MsgId msgId) {
|
||||
}
|
||||
}
|
||||
|
||||
void HistoryWidget::updateReplyEditText(not_null<HistoryItem*> item) {
|
||||
_replyEditMsgText.setText(
|
||||
st::messageTextStyle,
|
||||
item->inReplyText(),
|
||||
Ui::DialogTextOptions());
|
||||
if (!_field->isHidden() || _recording) {
|
||||
_fieldBarCancel->show();
|
||||
updateMouseTracking();
|
||||
}
|
||||
}
|
||||
|
||||
void HistoryWidget::updateReplyEditTexts(bool force) {
|
||||
if (!force) {
|
||||
if (_replyEditMsg || (!_editMsgId && !_replyToId)) {
|
||||
@ -6477,17 +6466,8 @@ void HistoryWidget::updateReplyEditTexts(bool force) {
|
||||
_replyEditMsg = App::histItemById(_channel, _editMsgId ? _editMsgId : _replyToId);
|
||||
}
|
||||
if (_replyEditMsg) {
|
||||
_replyEditMsgText.setText(
|
||||
st::messageTextStyle,
|
||||
TextUtilities::Clean(_replyEditMsg->inReplyText()),
|
||||
Ui::DialogTextOptions());
|
||||
|
||||
updateReplyEditText(_replyEditMsg);
|
||||
updateBotKeyboard();
|
||||
|
||||
if (!_field->isHidden() || _recording) {
|
||||
_fieldBarCancel->show();
|
||||
updateMouseTracking();
|
||||
}
|
||||
updateReplyToName();
|
||||
updateField();
|
||||
} else if (force) {
|
||||
@ -6536,13 +6516,13 @@ void HistoryWidget::updateForwardingTexts() {
|
||||
if (count < 2) {
|
||||
text = _toForward.front()->inReplyText();
|
||||
} else {
|
||||
text = lng_forward_messages(lt_count, count);
|
||||
text = textcmdLink(1, lng_forward_messages(lt_count, count));
|
||||
}
|
||||
}
|
||||
_toForwardFrom.setText(st::msgNameStyle, from, Ui::NameTextOptions());
|
||||
_toForwardText.setText(
|
||||
st::messageTextStyle,
|
||||
TextUtilities::Clean(text),
|
||||
text,
|
||||
Ui::DialogTextOptions());
|
||||
_toForwardNameVersion = version;
|
||||
}
|
||||
@ -6614,8 +6594,10 @@ void HistoryWidget::drawField(Painter &p, const QRect &rect) {
|
||||
} else {
|
||||
_replyToName.drawElided(p, replyLeft, backy + st::msgReplyPadding.top(), width() - replyLeft - _fieldBarCancel->width() - st::msgReplyPadding.right());
|
||||
}
|
||||
p.setPen(!drawMsgText->toHistoryMessage() ? st::historyComposeAreaFgService : st::historyComposeAreaFg);
|
||||
p.setPen(st::historyComposeAreaFg);
|
||||
p.setTextPalette(st::historyComposeAreaPalette);
|
||||
_replyEditMsgText.drawElided(p, replyLeft, backy + st::msgReplyPadding.top() + st::msgServiceNameFont->height, width() - replyLeft - _fieldBarCancel->width() - st::msgReplyPadding.right());
|
||||
p.restoreTextPalette();
|
||||
} else {
|
||||
p.setFont(st::msgDateFont);
|
||||
p.setPen(st::historyComposeAreaFgService);
|
||||
@ -6646,8 +6628,10 @@ void HistoryWidget::drawField(Painter &p, const QRect &rect) {
|
||||
}
|
||||
p.setPen(st::historyReplyNameFg);
|
||||
_toForwardFrom.drawElided(p, forwardLeft, backy + st::msgReplyPadding.top(), width() - forwardLeft - _fieldBarCancel->width() - st::msgReplyPadding.right());
|
||||
p.setPen(serviceColor ? st::historyComposeAreaFgService : st::historyComposeAreaFg);
|
||||
p.setPen(st::historyComposeAreaFg);
|
||||
p.setTextPalette(st::historyComposeAreaPalette);
|
||||
_toForwardText.drawElided(p, forwardLeft, backy + st::msgReplyPadding.top() + st::msgServiceNameFont->height, width() - forwardLeft - _fieldBarCancel->width() - st::msgReplyPadding.right());
|
||||
p.restoreTextPalette();
|
||||
}
|
||||
}
|
||||
if (drawWebPagePreview) {
|
||||
|
@ -571,6 +571,7 @@ private:
|
||||
|
||||
object_ptr<Ui::IconButton> _fieldBarCancel;
|
||||
void updateReplyEditTexts(bool force = false);
|
||||
void updateReplyEditText(not_null<HistoryItem*> item);
|
||||
|
||||
struct PinnedBar {
|
||||
PinnedBar(MsgId msgId, HistoryWidget *parent);
|
||||
|
Loading…
Reference in New Issue
Block a user