Fix inline keyboard. Disable it in the event log.

Also disable game preview click handler in the event log.
This commit is contained in:
John Preston 2017-06-24 13:32:30 +03:00
parent 816ee794e8
commit 85e234938d
5 changed files with 22 additions and 5 deletions

View file

@ -797,6 +797,10 @@ void HistoryItem::setId(MsgId newId) {
markup->inlineKeyboard->updateMessageId(); markup->inlineKeyboard->updateMessageId();
} }
} }
if (_media) {
_media->updateMessageId();
}
} }
bool HistoryItem::canPin() const { bool HistoryItem::canPin() const {

View file

@ -60,6 +60,8 @@ public:
return false; return false;
} }
virtual void initDimensions() = 0; virtual void initDimensions() = 0;
virtual void updateMessageId() {
}
virtual int resizeGetHeight(int width) { virtual int resizeGetHeight(int width) {
_width = qMin(width, _maxw); _width = qMin(width, _maxw);
return _height; return _height;

View file

@ -3696,7 +3696,7 @@ HistoryGame::HistoryGame(gsl::not_null<HistoryItem*> parent, const HistoryGame &
void HistoryGame::initDimensions() { void HistoryGame::initDimensions() {
auto lineHeight = unitedLineHeight(); auto lineHeight = unitedLineHeight();
if (!_openl) { if (!_openl && _parent->id > 0) {
_openl = MakeShared<ReplyMarkupClickHandler>(_parent, 0, 0); _openl = MakeShared<ReplyMarkupClickHandler>(_parent, 0, 0);
} }
@ -3774,6 +3774,12 @@ void HistoryGame::initDimensions() {
} }
} }
void HistoryGame::updateMessageId() {
if (_openl) {
_openl = MakeShared<ReplyMarkupClickHandler>(_parent, 0, 0);
}
}
int HistoryGame::resizeGetHeight(int width) { int HistoryGame::resizeGetHeight(int width) {
_width = width = qMin(width, _maxw); _width = width = qMin(width, _maxw);
width -= st::msgPadding.left() + st::webPageLeft + st::msgPadding.right(); width -= st::msgPadding.left() + st::webPageLeft + st::msgPadding.right();
@ -3934,7 +3940,9 @@ HistoryTextState HistoryGame::getState(QPoint point, HistoryStateRequest request
tshift += _descriptionLines * lineHeight; tshift += _descriptionLines * lineHeight;
} }
if (inThumb) { if (inThumb) {
if (!_parent->isLogEntry()) {
result.link = _openl; result.link = _openl;
}
} else if (_attach) { } else if (_attach) {
auto attachAtTop = !_titleLines && !_descriptionLines; auto attachAtTop = !_titleLines && !_descriptionLines;
if (!attachAtTop) tshift += st::mediaInBubbleSkip; if (!attachAtTop) tshift += st::mediaInBubbleSkip;
@ -3945,7 +3953,9 @@ HistoryTextState HistoryGame::getState(QPoint point, HistoryStateRequest request
if (QRect(attachLeft, tshift, _attach->currentWidth(), _height - tshift - bshift).contains(point)) { if (QRect(attachLeft, tshift, _attach->currentWidth(), _height - tshift - bshift).contains(point)) {
if (_attach->isReadyForOpen()) { if (_attach->isReadyForOpen()) {
if (!_parent->isLogEntry()) {
result.link = _openl; result.link = _openl;
}
} else { } else {
result = _attach->getState(point - QPoint(attachLeft, attachTop), request); result = _attach->getState(point - QPoint(attachLeft, attachTop), request);
} }

View file

@ -882,6 +882,7 @@ public:
void initDimensions() override; void initDimensions() override;
int resizeGetHeight(int width) override; int resizeGetHeight(int width) override;
void updateMessageId() override;
void draw(Painter &p, const QRect &r, TextSelection selection, TimeMs ms) const override; void draw(Painter &p, const QRect &r, TextSelection selection, TimeMs ms) const override;
HistoryTextState getState(QPoint point, HistoryStateRequest request) const override; HistoryTextState getState(QPoint point, HistoryStateRequest request) const override;

View file

@ -1792,10 +1792,10 @@ HistoryTextState HistoryMessage::getState(QPoint point, HistoryStateRequest requ
result.symbol += _text.length(); result.symbol += _text.length();
} }
if (keyboard) { if (keyboard && !isLogEntry()) {
auto keyboardTop = g.top() + g.height() + st::msgBotKbButton.margin; auto keyboardTop = g.top() + g.height() + st::msgBotKbButton.margin;
if (QRect(g.left(), keyboardTop, g.width(), keyboardHeight).contains(point)) { if (QRect(g.left(), keyboardTop, g.width(), keyboardHeight).contains(point)) {
result.link = keyboard->getState(point - g.topLeft()); result.link = keyboard->getState(point - QPoint(g.left(), keyboardTop));
return result; return result;
} }
} }