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