/* This file is part of Telegram Desktop, the official desktop application for the Telegram messaging service. For license and copyright information please follow this link: https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL */ #pragma once #include "base/qt/qt_compare.h" #include "base/timer.h" #include "chat_helpers/compose/compose_features.h" #include "ui/widgets/fields/input_field.h" #ifndef TDESKTOP_DISABLE_SPELLCHECK #include "boxes/dictionaries_manager.h" #include "spellcheck/spelling_highlighter.h" #endif // TDESKTOP_DISABLE_SPELLCHECK #include namespace Main { class Session; class SessionShow; } // namespace Main namespace Window { class SessionController; } // namespace Window namespace ChatHelpers { enum class PauseReason; class Show; } // namespace ChatHelpers namespace Ui { class PopupMenu; } // namespace Ui [[nodiscard]] QString PrepareMentionTag(not_null user); [[nodiscard]] TextWithTags PrepareEditText(not_null item); [[nodiscard]] bool EditTextChanged( not_null item, const TextWithTags &updated); Fn DefaultEditLinkCallback( std::shared_ptr show, not_null field, const style::InputField *fieldStyle = nullptr); void InitMessageFieldHandlers( not_null session, std::shared_ptr show, // may be null not_null field, Fn customEmojiPaused, Fn)> allowPremiumEmoji = nullptr, const style::InputField *fieldStyle = nullptr); void InitMessageFieldHandlers( not_null controller, not_null field, ChatHelpers::PauseReason pauseReasonLevel, Fn)> allowPremiumEmoji = nullptr); void InitMessageField( std::shared_ptr show, not_null field, Fn)> allowPremiumEmoji); void InitMessageField( not_null controller, not_null field, Fn)> allowPremiumEmoji); void InitSpellchecker( std::shared_ptr show, not_null field, bool skipDictionariesManager = false); bool HasSendText(not_null field); void InitMessageFieldFade( not_null field, const style::color &bg); struct InlineBotQuery { QString query; QString username; UserData *bot = nullptr; bool lookingUpBot = false; }; InlineBotQuery ParseInlineBotQuery( not_null session, not_null field); struct AutocompleteQuery { QString query; bool fromStart = false; }; AutocompleteQuery ParseMentionHashtagBotCommandQuery( not_null field, ChatHelpers::ComposeFeatures features); struct MessageLinkRange { int start = 0; int length = 0; QString custom; friend inline auto operator<=>( const MessageLinkRange&, const MessageLinkRange&) = default; friend inline bool operator==( const MessageLinkRange&, const MessageLinkRange&) = default; }; class MessageLinksParser final : private QObject { public: MessageLinksParser(not_null field); void parseNow(); void setDisabled(bool disabled); [[nodiscard]] const rpl::variable &list() const { return _list; } [[nodiscard]] const std::vector &ranges() const { return _ranges; } private: bool eventFilter(QObject *object, QEvent *event) override; void parse(); void applyRanges(const QString &text); not_null _field; rpl::variable _list; std::vector _ranges; int _lastLength = 0; bool _disabled = false; base::Timer _timer; rpl::lifetime _lifetime; }; [[nodiscard]] base::unique_qptr CreateDisabledFieldView( QWidget *parent, not_null peer); [[nodiscard]] base::unique_qptr TextErrorSendRestriction( QWidget *parent, const QString &text); [[nodiscard]] base::unique_qptr PremiumRequiredSendRestriction( QWidget *parent, not_null user, not_null controller);