2
0
mirror of https://github.com/telegramdesktop/tdesktop synced 2025-08-31 22:46:10 +00:00

Support custom keyboard placeholders.

This commit is contained in:
John Preston
2021-07-05 20:59:23 +03:00
parent 7f00065bd8
commit aaefeed3f1
6 changed files with 35 additions and 11 deletions

View File

@@ -217,6 +217,9 @@ HistoryWidget::HistoryWidget(
Ui::InputField::Mode::MultiLine,
tr::lng_message_ph())
, _kbScroll(this, st::botKbScroll)
, _keyboard(_kbScroll->setOwnedWidget(object_ptr<BotKeyboard>(
&session(),
this)))
, _membersDropdownShowTimer([=] { showMembersDropdown(); })
, _scrollTimer([=] { scrollByTimer(); })
, _saveDraftTimer([=] { saveDraft(); })
@@ -300,10 +303,6 @@ HistoryWidget::HistoryWidget(
_topBar->hide();
_scroll->hide();
_keyboard = _kbScroll->setOwnedWidget(object_ptr<BotKeyboard>(
&session(),
this));
_kbScroll->hide();
updateScrollColors();
@@ -3980,6 +3979,7 @@ void HistoryWidget::toggleKeyboard(bool manual) {
}
}
updateControlsGeometry();
updateFieldPlaceholder();
if (_botKeyboardHide->isHidden() && canWriteMessage() && !_a_show.animating()) {
_tabbedSelectorToggle->show();
} else {
@@ -4261,6 +4261,9 @@ void HistoryWidget::updateFieldPlaceholder() {
return tr::lng_edit_message_text();
} else if (!_history) {
return tr::lng_message_ph();
} else if ((_kbShown || _keyboard->forceReply())
&& !_keyboard->placeholder().isEmpty()) {
return rpl::single(_keyboard->placeholder());
} else if (const auto channel = _history->peer->asChannel()) {
if (channel->isBroadcast()) {
return session().data().notifySilentPosts(channel)
@@ -4960,7 +4963,9 @@ void HistoryWidget::updateBotKeyboard(History *h, bool force) {
changed = _keyboard->updateMarkup(keyboardItem, force);
}
updateCmdStartShown();
if (!changed) return;
if (!changed) {
return;
}
bool hasMarkup = _keyboard->hasMarkup(), forceReply = _keyboard->forceReply() && (!_replyToId || !_replyEditMsg);
if (hasMarkup || forceReply) {
@@ -5025,6 +5030,7 @@ void HistoryWidget::updateBotKeyboard(History *h, bool force) {
}
}
refreshTopBarActiveChat();
updateFieldPlaceholder();
updateControlsGeometry();
update();
}