mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-04-15 21:57:10 +02:00
Support persistent flag for bot keyboard.
This commit is contained in:
parent
54a12aa74f
commit
4518067f9c
6 changed files with 20 additions and 5 deletions
|
@ -255,7 +255,7 @@ void BotKeyboard::clickHandlerPressedChanged(const ClickHandlerPtr &p, bool pres
|
|||
bool BotKeyboard::updateMarkup(HistoryItem *to, bool force) {
|
||||
if (!to || !to->definesReplyKeyboard()) {
|
||||
if (_wasForMsgId.msg) {
|
||||
_maximizeSize = _singleUse = _forceReply = false;
|
||||
_maximizeSize = _singleUse = _forceReply = _persistent = false;
|
||||
_wasForMsgId = FullMsgId();
|
||||
_placeholder = QString();
|
||||
_impl = nullptr;
|
||||
|
@ -275,6 +275,7 @@ bool BotKeyboard::updateMarkup(HistoryItem *to, bool force) {
|
|||
_forceReply = markupFlags & ReplyMarkupFlag::ForceReply;
|
||||
_maximizeSize = !(markupFlags & ReplyMarkupFlag::Resize);
|
||||
_singleUse = _forceReply || (markupFlags & ReplyMarkupFlag::SingleUse);
|
||||
_persistent = (markupFlags & ReplyMarkupFlag::Persistent);
|
||||
|
||||
if (const auto markup = to->Get<HistoryMessageReplyMarkup>()) {
|
||||
_placeholder = markup->data.placeholder;
|
||||
|
@ -326,6 +327,10 @@ bool BotKeyboard::singleUse() const {
|
|||
return _singleUse;
|
||||
}
|
||||
|
||||
bool BotKeyboard::persistent() const {
|
||||
return _persistent;
|
||||
}
|
||||
|
||||
void BotKeyboard::updateStyle(int newWidth) {
|
||||
if (!_impl) return;
|
||||
|
||||
|
|
|
@ -49,6 +49,7 @@ public:
|
|||
|
||||
[[nodiscard]] bool maximizeSize() const;
|
||||
[[nodiscard]] bool singleUse() const;
|
||||
[[nodiscard]] bool persistent() const;
|
||||
|
||||
[[nodiscard]] FullMsgId forMsgId() const {
|
||||
return _wasForMsgId;
|
||||
|
@ -91,6 +92,7 @@ private:
|
|||
bool _maximizeSize = false;
|
||||
bool _singleUse = false;
|
||||
bool _forceReply = false;
|
||||
bool _persistent = false;
|
||||
|
||||
QPoint _lastMousePos;
|
||||
std::unique_ptr<ReplyKeyboard> _impl;
|
||||
|
|
|
@ -154,7 +154,8 @@ HistoryMessageMarkupData::HistoryMessageMarkupData(
|
|||
data->match([&](const MTPDreplyKeyboardMarkup &data) {
|
||||
flags = (data.is_resize() ? Flag::Resize : Flag())
|
||||
| (data.is_selective() ? Flag::Selective : Flag())
|
||||
| (data.is_single_use() ? Flag::SingleUse : Flag());
|
||||
| (data.is_single_use() ? Flag::SingleUse : Flag())
|
||||
| (data.is_persistent() ? Flag::Persistent : Flag());
|
||||
placeholder = qs(data.vplaceholder().value_or_empty());
|
||||
fillRows(data.vrows().v);
|
||||
}, [&](const MTPDreplyInlineMarkup &data) {
|
||||
|
|
|
@ -23,6 +23,7 @@ enum class ReplyMarkupFlag : uint32 {
|
|||
Selective = (1U << 6),
|
||||
IsNull = (1U << 7),
|
||||
OnlyBuyButton = (1U << 8),
|
||||
Persistent = (1U << 9),
|
||||
};
|
||||
inline constexpr bool is_flag_type(ReplyMarkupFlag) { return true; }
|
||||
using ReplyMarkupFlags = base::flags<ReplyMarkupFlag>;
|
||||
|
|
|
@ -2737,7 +2737,7 @@ void HistoryWidget::updateControlsVisibility() {
|
|||
if (_kbShown) {
|
||||
_kbScroll->show();
|
||||
_tabbedSelectorToggle->hide();
|
||||
_botKeyboardHide->show();
|
||||
showKeyboardHideButton();
|
||||
_botKeyboardShow->hide();
|
||||
_botCommandStart->hide();
|
||||
} else if (_kbReplyTo) {
|
||||
|
@ -4543,6 +4543,11 @@ bool HistoryWidget::kbWasHidden() const {
|
|||
_history->lastKeyboardHiddenId));
|
||||
}
|
||||
|
||||
void HistoryWidget::showKeyboardHideButton() {
|
||||
_botKeyboardHide->setVisible(!_peer->isUser()
|
||||
|| !_keyboard->persistent());
|
||||
}
|
||||
|
||||
void HistoryWidget::toggleKeyboard(bool manual) {
|
||||
auto fieldEnabled = canWriteMessage() && !_showAnimation;
|
||||
if (_kbShown || _kbReplyTo) {
|
||||
|
@ -4594,7 +4599,7 @@ void HistoryWidget::toggleKeyboard(bool manual) {
|
|||
_history->lastKeyboardHiddenId = 0;
|
||||
}
|
||||
} else if (fieldEnabled) {
|
||||
_botKeyboardHide->show();
|
||||
showKeyboardHideButton();
|
||||
_botKeyboardShow->hide();
|
||||
_kbScroll->show();
|
||||
_kbShown = true;
|
||||
|
@ -5741,7 +5746,7 @@ void HistoryWidget::updateBotKeyboard(History *h, bool force) {
|
|||
if (hasMarkup) {
|
||||
_kbScroll->show();
|
||||
_tabbedSelectorToggle->hide();
|
||||
_botKeyboardHide->show();
|
||||
showKeyboardHideButton();
|
||||
} else {
|
||||
_kbScroll->hide();
|
||||
_tabbedSelectorToggle->show();
|
||||
|
|
|
@ -391,6 +391,7 @@ private:
|
|||
[[nodiscard]] int computeMaxFieldHeight() const;
|
||||
void toggleMuteUnmute();
|
||||
void reportSelectedMessages();
|
||||
void showKeyboardHideButton();
|
||||
void toggleKeyboard(bool manual = true);
|
||||
void startBotCommand();
|
||||
void hidePinnedMessage();
|
||||
|
|
Loading…
Add table
Reference in a new issue