diff --git a/Telegram/SourceFiles/config.h b/Telegram/SourceFiles/config.h index a7f66be4e..d1e88b6c4 100644 --- a/Telegram/SourceFiles/config.h +++ b/Telegram/SourceFiles/config.h @@ -23,7 +23,7 @@ Copyright (c) 2014-2016 John Preston, https://desktop.telegram.org static const int32 AppVersion = 9040; static const wchar_t *AppVersionStr = L"0.9.40"; static const bool DevVersion = false; -#define BETA_VERSION (9040126ULL) // just comment this line to build public version +#define BETA_VERSION (9040127ULL) // just comment this line to build public version static const wchar_t *AppNameOld = L"Telegram Win (Unofficial)"; static const wchar_t *AppName = L"Telegram Desktop"; diff --git a/Telegram/SourceFiles/dropdown.cpp b/Telegram/SourceFiles/dropdown.cpp index 59be24664..8fce3e32e 100644 --- a/Telegram/SourceFiles/dropdown.cpp +++ b/Telegram/SourceFiles/dropdown.cpp @@ -3835,7 +3835,7 @@ int32 EmojiPan::showInlineRows(bool newResults) { if (clear) { if (!hidden && hideOnNoInlineResults()) { hideAnimated(); - } else { + } else if (!_hiding) { _cache = QPixmap(); // clear after refreshInlineRows() } } else { diff --git a/Telegram/SourceFiles/facades.cpp b/Telegram/SourceFiles/facades.cpp index 396505f70..252404416 100644 --- a/Telegram/SourceFiles/facades.cpp +++ b/Telegram/SourceFiles/facades.cpp @@ -87,7 +87,17 @@ namespace App { case HistoryMessageReplyMarkup::Button::SwitchInline: { if (MainWidget *m = App::main()) { if (UserData *bot = msg->history()->peer->asUser()) { - m->inlineSwitchLayer('@' + bot->username + ' ' + QString::fromUtf8(button->data)); + auto tryFastSwitch = [bot, &button]() -> bool { + if (bot->botInfo && bot->botInfo->inlineReturnPeerId) { + if (Notify::switchInlineBotButtonReceived(QString::fromUtf8(button->data))) { + return true; + } + } + return false; + }; + if (!tryFastSwitch()) { + m->inlineSwitchLayer('@' + bot->username + ' ' + QString::fromUtf8(button->data)); + } } } } break; @@ -280,10 +290,11 @@ namespace Notify { } } - void switchInlineBotButtonReceived(const QString &query) { + bool switchInlineBotButtonReceived(const QString &query) { if (MainWidget *m = App::main()) { - m->notify_switchInlineBotButtonReceived(query); + return m->notify_switchInlineBotButtonReceived(query); } + return false; } void migrateUpdated(PeerData *peer) { diff --git a/Telegram/SourceFiles/facades.h b/Telegram/SourceFiles/facades.h index 87461d585..7888b8c64 100644 --- a/Telegram/SourceFiles/facades.h +++ b/Telegram/SourceFiles/facades.h @@ -104,7 +104,7 @@ namespace Notify { void inlineBotRequesting(bool requesting); void replyMarkupUpdated(const HistoryItem *item); void inlineKeyboardMoved(const HistoryItem *item, int oldKeyboardTop, int newKeyboardTop); - void switchInlineBotButtonReceived(const QString &query); + bool switchInlineBotButtonReceived(const QString &query); void migrateUpdated(PeerData *peer); diff --git a/Telegram/SourceFiles/history.cpp b/Telegram/SourceFiles/history.cpp index acd26701a..1bb19233c 100644 --- a/Telegram/SourceFiles/history.cpp +++ b/Telegram/SourceFiles/history.cpp @@ -2574,16 +2574,20 @@ void ReplyKeyboard::resize(int width, int height) { for (ButtonRow &row : _rows) { int s = row.size(); - float64 widthForText = _width - ((s - 1) * _st->buttonSkip() + s * 2 * _st->buttonPadding()), widthOfText = 0.; + int widthForText = _width - ((s - 1) * _st->buttonSkip()); + int widthOfText = 0; for_const (const Button &button, row) { widthOfText += qMax(button.text.maxWidth(), 1); + widthForText -= _st->minButtonWidth(button.type); } + bool exact = (widthForText == widthOfText); - float64 x = 0, coef = widthForText / widthOfText; + float64 x = 0; for (Button &button : row) { - float64 tw = widthForText / float64(s), w = 2 * _st->buttonPadding() + tw; + int buttonw = qMax(button.text.maxWidth(), 1); + float64 textw = exact ? buttonw : (widthForText / float64(s)); float64 minw = _st->minButtonWidth(button.type); - if (w < minw) w = minw; + float64 w = minw + qMax(textw, 0.); int rectx = static_cast(std::floor(x)); int rectw = static_cast(std::floor(x + w)) - rectx; @@ -2591,7 +2595,7 @@ void ReplyKeyboard::resize(int width, int height) { if (rtl()) button.rect.setX(_width - button.rect.x() - button.rect.width()); x += w + _st->buttonSkip(); - button.link->setFullDisplayed(tw >= button.text.maxWidth()); + button.link->setFullDisplayed(textw >= buttonw); } y += buttonHeight; } @@ -2625,9 +2629,9 @@ int ReplyKeyboard::naturalWidth() const { auto markup = _item->Get(); for_const (const ButtonRow &row, _rows) { int rowSize = row.size(); - int rowWidth = (rowSize - 1) * _st->buttonSkip() + rowSize * 2 * _st->buttonPadding(); - for_const(const Button &button, row) { - rowWidth += qMax(button.text.maxWidth(), 1); + int rowWidth = (rowSize - 1) * _st->buttonSkip(); + for_const (const Button &button, row) { + rowWidth += qMax(button.text.maxWidth(), 1) + _st->minButtonWidth(button.type); } if (rowWidth > result) { result = rowWidth; @@ -2753,7 +2757,7 @@ void ReplyKeyboard::Style::paintButton(Painter &p, const ReplyKeyboard::Button & } int tx = rect.x(), tw = rect.width(); - if (tw > st::botKbFont->elidew + _st->padding * 2) { + if (tw >= st::botKbFont->elidew + _st->padding * 2) { tx += _st->padding; tw -= _st->padding * 2; } else if (tw > st::botKbFont->elidew) { @@ -6510,7 +6514,7 @@ int HistoryMessage::KeyboardStyle::minButtonWidth(HistoryMessageReplyMarkup::But case Button::Callback: iconWidth = st::msgInvSendingImg.pxWidth(); break; } if (iconWidth > 0) { - result = std::min(result, iconWidth + 2 * int(st::msgBotKbIconPadding)); + result = std::max(result, 2 * iconWidth + 4 * int(st::msgBotKbIconPadding)); } return result; } diff --git a/Telegram/SourceFiles/historywidget.cpp b/Telegram/SourceFiles/historywidget.cpp index 8c3f6eb54..0a7da493a 100644 --- a/Telegram/SourceFiles/historywidget.cpp +++ b/Telegram/SourceFiles/historywidget.cpp @@ -2265,12 +2265,17 @@ bool BotKeyboard::updateMarkup(HistoryItem *to, bool force) { _wasForMsgId = FullMsgId(to->channelId(), to->id); clearSelection(); - auto markup = to->Get(); - _forceReply = markup->flags & MTPDreplyKeyboardMarkup_ClientFlag::f_force_reply; - _maximizeSize = !(markup->flags & MTPDreplyKeyboardMarkup::Flag::f_resize); - _singleUse = _forceReply || (markup->flags & MTPDreplyKeyboardMarkup::Flag::f_single_use); + auto markupFlags = to->replyKeyboardFlags(); + _forceReply = markupFlags & MTPDreplyKeyboardMarkup_ClientFlag::f_force_reply; + _maximizeSize = !(markupFlags & MTPDreplyKeyboardMarkup::Flag::f_resize); + _singleUse = _forceReply || (markupFlags & MTPDreplyKeyboardMarkup::Flag::f_single_use); - _impl.reset(markup->rows.isEmpty() ? nullptr : new ReplyKeyboard(to, std_::make_unique