2
0
mirror of https://github.com/kotatogram/kotatogram-desktop synced 2025-09-02 15:45:12 +00:00

Fixed filling menu with send options for inline bots and autocomplete.

This commit is contained in:
23rd
2020-11-19 05:58:23 +03:00
committed by John Preston
parent a6e4ac679c
commit e1017380ec
7 changed files with 46 additions and 2 deletions

View File

@@ -68,6 +68,7 @@ public:
Api::SendOptions options = Api::SendOptions()) const;
void setRecentInlineBotsInRows(int32 bots);
void setSendMenuType(Fn<SendMenu::Type()> &&callback);
void rowsUpdated();
rpl::producer<FieldAutocomplete::MentionChosen> mentionChosen() const;
@@ -121,6 +122,8 @@ private:
bool _previewShown = false;
Fn<SendMenu::Type()> _sendMenuType;
rpl::event_stream<FieldAutocomplete::MentionChosen> _mentionChosen;
rpl::event_stream<FieldAutocomplete::HashtagChosen> _hashtagChosen;
rpl::event_stream<FieldAutocomplete::BotCommandChosen> _botCommandChosen;
@@ -686,6 +689,10 @@ bool FieldAutocomplete::chooseSelected(ChooseMethod method) const {
return _inner->chooseSelected(method);
}
void FieldAutocomplete::setSendMenuType(Fn<SendMenu::Type()> &&callback) {
_inner->setSendMenuType(std::move(callback));
}
bool FieldAutocomplete::eventFilter(QObject *obj, QEvent *e) {
auto hidden = isHidden();
auto moderate = Core::App().settings().moderateModeEnabled();
@@ -1116,7 +1123,9 @@ void FieldAutocomplete::Inner::contextMenuEvent(QContextMenuEvent *e) {
return;
}
const auto index = _sel;
const auto type = SendMenu::Type::Scheduled;
const auto type = _sendMenuType
? _sendMenuType()
: SendMenu::Type::Disabled;
const auto method = FieldAutocomplete::ChooseMethod::ByClick;
_menu = base::make_unique_q<Ui::PopupMenu>(this);
@@ -1301,6 +1310,11 @@ void FieldAutocomplete::Inner::showPreview() {
}
}
void FieldAutocomplete::Inner::setSendMenuType(
Fn<SendMenu::Type()> &&callback) {
_sendMenuType = std::move(callback);
}
auto FieldAutocomplete::Inner::mentionChosen() const
-> rpl::producer<FieldAutocomplete::MentionChosen> {
return _mentionChosen.events();