/* 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 "ui/widgets/input_fields.h" #include "base/timer.h" #include "base/qt_connection.h" #ifndef TDESKTOP_DISABLE_SPELLCHECK #include "boxes/dictionaries_manager.h" #include "spellcheck/spelling_highlighter.h" #endif // TDESKTOP_DISABLE_SPELLCHECK #include namespace Main { class Session; } // namespace Main namespace Window { class SessionController; enum class GifPauseReason; } // namespace Window namespace Ui { class PopupMenu; class Show; } // namespace Ui QString PrepareMentionTag(not_null user); TextWithTags PrepareEditText(not_null item); Fn DefaultEditLinkCallback( std::shared_ptr show, not_null session, not_null field, const style::InputField *fieldStyle = nullptr); void InitMessageFieldHandlers( not_null session, std::shared_ptr show, not_null field, Fn customEmojiPaused, Fn)> allowPremiumEmoji = nullptr, const style::InputField *fieldStyle = nullptr); void InitMessageFieldHandlers( not_null controller, not_null field, Window::GifPauseReason pauseReasonLevel, Fn)> allowPremiumEmoji = nullptr); void InitMessageField( not_null controller, not_null field, Fn)> allowPremiumEmoji); void InitSpellchecker( std::shared_ptr show, not_null session, not_null field, bool skipDictionariesManager = false); bool HasSendText(not_null field); 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); class MessageLinksParser : private QObject { public: MessageLinksParser(not_null field); void parseNow(); [[nodiscard]] const rpl::variable &list() const; protected: bool eventFilter(QObject *object, QEvent *event) override; private: struct LinkRange { int start; int length; QString custom; }; friend inline bool operator==(const LinkRange &a, const LinkRange &b) { return (a.start == b.start) && (a.length == b.length) && (a.custom == b.custom); } friend inline bool operator!=(const LinkRange &a, const LinkRange &b) { return !(a == b); } void parse(); void apply(const QString &text, const QVector &ranges); not_null _field; rpl::variable _list; int _lastLength = 0; base::Timer _timer; base::qt_connection _connection; }; [[nodiscard]] base::unique_qptr CreateDisabledFieldView( QWidget *parent, not_null peer);