mirror of
https://github.com/vale981/tdesktop
synced 2025-03-06 10:11:41 -05:00
Crash in Qt fixed for OS X. Edited badge removed for bot messages.
Sticker with reply layout fixed once more.
This commit is contained in:
parent
8b2c351933
commit
23a598ba3d
3 changed files with 54 additions and 28 deletions
|
@ -4728,21 +4728,21 @@ void HistorySticker::initDimensions() {
|
|||
if (_pixh < 1) _pixh = 1;
|
||||
_maxw = qMax(_pixw, int16(st::minPhotoSize));
|
||||
_minh = qMax(_pixh, int16(st::minPhotoSize));
|
||||
if (_parent->getMedia() == this) {
|
||||
_maxw += additionalWidth();
|
||||
}
|
||||
|
||||
_height = _minh;
|
||||
}
|
||||
|
||||
int HistorySticker::resizeGetHeight(int width) { // return new height
|
||||
int maxWidth = _maxw;
|
||||
if (_parent->getMedia() == this) {
|
||||
maxWidth += additionalWidth();
|
||||
}
|
||||
_width = qMin(width, maxWidth);
|
||||
_width = qMin(width, _maxw);
|
||||
if (_parent->getMedia() == this) {
|
||||
auto via = _parent->Get<HistoryMessageVia>();
|
||||
auto reply = _parent->Get<HistoryMessageReply>();
|
||||
if (via || reply) {
|
||||
int availw = _width - _maxw - st::msgReplyPadding.left() - st::msgReplyPadding.left() - st::msgReplyPadding.left();
|
||||
int usew = _maxw - additionalWidth(via, reply);
|
||||
int availw = _width - usew - st::msgReplyPadding.left() - st::msgReplyPadding.left() - st::msgReplyPadding.left();
|
||||
if (via) {
|
||||
via->resize(availw);
|
||||
}
|
||||
|
@ -4767,6 +4767,7 @@ void HistorySticker::draw(Painter &p, const QRect &r, TextSelection selection, u
|
|||
auto via = childmedia ? nullptr : _parent->Get<HistoryMessageVia>();
|
||||
auto reply = childmedia ? nullptr : _parent->Get<HistoryMessageReply>();
|
||||
if (via || reply) {
|
||||
usew -= additionalWidth(via, reply);
|
||||
if (isPost) {
|
||||
} else if (out) {
|
||||
usex = _width - usew;
|
||||
|
@ -4836,6 +4837,7 @@ HistoryTextState HistorySticker::getState(int x, int y, HistoryStateRequest requ
|
|||
auto via = childmedia ? nullptr : _parent->Get<HistoryMessageVia>();
|
||||
auto reply = childmedia ? nullptr : _parent->Get<HistoryMessageReply>();
|
||||
if (via || reply) {
|
||||
usew -= additionalWidth(via, reply);
|
||||
if (isPost) {
|
||||
} else if (out) {
|
||||
usex = _width - usew;
|
||||
|
@ -6207,10 +6209,12 @@ void HistoryMessageReply::clearData(HistoryMessage *holder) {
|
|||
replyToMsgId = 0;
|
||||
}
|
||||
|
||||
void HistoryMessageReply::checkNameUpdate() const {
|
||||
bool HistoryMessageReply::isNameUpdated() const {
|
||||
if (replyToMsg && replyToMsg->author()->nameVersion > replyToVersion) {
|
||||
updateName();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void HistoryMessageReply::updateName() const {
|
||||
|
@ -6482,6 +6486,22 @@ void HistoryMessage::createComponentsHelper(MTPDmessage::Flags flags, MsgId repl
|
|||
createComponents(config);
|
||||
}
|
||||
|
||||
bool HistoryMessage::displayEditedBadge(bool hasViaBot) const {
|
||||
if (!(_flags & MTPDmessage::Flag::f_edit_date)) {
|
||||
return false;
|
||||
}
|
||||
if (auto fromUser = from()->asUser()) {
|
||||
if (fromUser->botInfo) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if (hasViaBot) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
void HistoryMessage::createComponents(const CreateConfig &config) {
|
||||
uint64 mask = 0;
|
||||
if (config.replyTo) {
|
||||
|
@ -6496,7 +6516,7 @@ void HistoryMessage::createComponents(const CreateConfig &config) {
|
|||
if (isPost() && _from->isUser()) {
|
||||
mask |= HistoryMessageSigned::Bit();
|
||||
}
|
||||
if (wasEdited()) {
|
||||
if (displayEditedBadge(config.viaBotId != 0)) {
|
||||
mask |= HistoryMessageEdited::Bit();
|
||||
}
|
||||
if (config.authorIdOriginal && config.fromIdOriginal) {
|
||||
|
@ -6638,6 +6658,10 @@ int32 HistoryMessage::plainMaxWidth() const {
|
|||
}
|
||||
|
||||
void HistoryMessage::initDimensions() {
|
||||
auto reply = Get<HistoryMessageReply>();
|
||||
if (reply) {
|
||||
reply->updateName();
|
||||
}
|
||||
if (drawBubble()) {
|
||||
auto fwd = Get<HistoryMessageForwarded>();
|
||||
auto via = Get<HistoryMessageVia>();
|
||||
|
@ -6696,15 +6720,12 @@ void HistoryMessage::initDimensions() {
|
|||
_maxw = _media->maxWidth();
|
||||
_minh = _media->minHeight();
|
||||
}
|
||||
if (auto reply = Get<HistoryMessageReply>()) {
|
||||
reply->updateName();
|
||||
if (!_text.isEmpty()) {
|
||||
int replyw = st::msgPadding.left() + reply->_maxReplyWidth - st::msgReplyPadding.left() - st::msgReplyPadding.right() + st::msgPadding.right();
|
||||
if (reply->_replyToVia) {
|
||||
replyw += st::msgServiceFont->spacew + reply->_replyToVia->_maxWidth;
|
||||
}
|
||||
if (replyw > _maxw) _maxw = replyw;
|
||||
if (reply && !_text.isEmpty()) {
|
||||
int replyw = st::msgPadding.left() + reply->_maxReplyWidth - st::msgReplyPadding.left() - st::msgReplyPadding.right() + st::msgPadding.right();
|
||||
if (reply->_replyToVia) {
|
||||
replyw += st::msgServiceFont->spacew + reply->_replyToVia->_maxWidth;
|
||||
}
|
||||
if (replyw > _maxw) _maxw = replyw;
|
||||
}
|
||||
if (HistoryMessageReplyMarkup *markup = inlineReplyMarkup()) {
|
||||
if (!markup->inlineKeyboard) {
|
||||
|
@ -6761,10 +6782,14 @@ void HistoryMessage::applyEdition(const MTPDmessage &message) {
|
|||
|
||||
if (message.has_edit_date()) {
|
||||
_flags |= MTPDmessage::Flag::f_edit_date;
|
||||
if (!Has<HistoryMessageEdited>()) {
|
||||
AddComponents(HistoryMessageEdited::Bit());
|
||||
if (displayEditedBadge(Has<HistoryMessageVia>())) {
|
||||
if (!Has<HistoryMessageEdited>()) {
|
||||
AddComponents(HistoryMessageEdited::Bit());
|
||||
}
|
||||
Get<HistoryMessageEdited>()->create(::date(message.vedit_date), date);
|
||||
} else if (Has<HistoryMessageEdited>()) {
|
||||
RemoveComponents(HistoryMessageEdited::Bit());
|
||||
}
|
||||
Get<HistoryMessageEdited>()->create(::date(message.vedit_date), date);
|
||||
initTime();
|
||||
}
|
||||
|
||||
|
@ -7161,11 +7186,6 @@ void HistoryMessage::draw(Painter &p, const QRect &r, TextSelection selection, u
|
|||
p.translate(-left, -top);
|
||||
}
|
||||
|
||||
auto reply = Get<HistoryMessageReply>();
|
||||
if (reply) {
|
||||
reply->checkNameUpdate();
|
||||
}
|
||||
|
||||
if (bubble) {
|
||||
auto fwd = Get<HistoryMessageForwarded>();
|
||||
auto via = Get<HistoryMessageVia>();
|
||||
|
@ -7225,6 +7245,11 @@ void HistoryMessage::draw(Painter &p, const QRect &r, TextSelection selection, u
|
|||
}
|
||||
|
||||
textstyleRestore();
|
||||
|
||||
auto reply = Get<HistoryMessageReply>();
|
||||
if (reply && reply->isNameUpdated()) {
|
||||
const_cast<HistoryMessage*>(this)->setPendingInitDimensions();
|
||||
}
|
||||
}
|
||||
|
||||
void HistoryMessage::paintForwardedInfo(Painter &p, QRect &trect, bool selected) const {
|
||||
|
|
|
@ -823,7 +823,7 @@ struct HistoryMessageReply : public BaseComponent<HistoryMessageReply> {
|
|||
bool updateData(HistoryMessage *holder, bool force = false);
|
||||
void clearData(HistoryMessage *holder); // must be called before destructor
|
||||
|
||||
void checkNameUpdate() const;
|
||||
bool isNameUpdated() const;
|
||||
void updateName() const;
|
||||
void resize(int width) const;
|
||||
void itemRemoved(HistoryMessage *holder, HistoryItem *removed);
|
||||
|
@ -1299,9 +1299,6 @@ public:
|
|||
}
|
||||
|
||||
bool canEdit(const QDateTime &cur) const;
|
||||
bool wasEdited() const {
|
||||
return _flags & MTPDmessage::Flag::f_edit_date;
|
||||
}
|
||||
|
||||
bool suggestBanReportDeleteAll() const {
|
||||
ChannelData *channel = history()->peer->asChannel();
|
||||
|
@ -2598,6 +2595,7 @@ public:
|
|||
|
||||
return (!emptyText() || !_media || !_media->isDisplayed() || Has<HistoryMessageReply>() || Has<HistoryMessageForwarded>() || viaBot() || !_media->hideFromName());
|
||||
}
|
||||
bool displayEditedBadge(bool hasViaBot) const;
|
||||
bool uploading() const {
|
||||
return _media && _media->uploading();
|
||||
}
|
||||
|
|
|
@ -482,6 +482,9 @@ public:
|
|||
bool skip = false, isNewLine = multiline && chIsNewline(ch), isSpace = chIsSpace(ch), isDiac = chIsDiac(ch), isTilde = checkTilde && (ch == '~');
|
||||
if (chIsBad(ch) || ch.isLowSurrogate()) {
|
||||
skip = true;
|
||||
} else if (ch == 0xFE0F && (cPlatform() == dbipMac || cPlatform() == dbipMacOld)) {
|
||||
// Some sequences like 0x0E53 0xFE0F crash OS X harfbuzz text processing :(
|
||||
skip = true;
|
||||
} else if (isDiac) {
|
||||
if (lastSkipped || emoji || ++diacs > chMaxDiacAfterSymbol()) {
|
||||
skip = true;
|
||||
|
|
Loading…
Add table
Reference in a new issue