/* 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" class HistoryWidget; namespace Window { class Controller; } // namespace Window QString ConvertTagToMimeTag(const QString &tagId); QString PrepareMentionTag(not_null user); EntitiesInText ConvertTextTagsToEntities(const TextWithTags::Tags &tags); TextWithTags::Tags ConvertEntitiesToTextTags( const EntitiesInText &entities); std::unique_ptr MimeDataFromTextWithEntities( const TextWithEntities &forClipboard); void SetClipboardWithEntities( const TextWithEntities &forClipboard, QClipboard::Mode mode = QClipboard::Clipboard); Fn DefaultEditLinkCallback( not_null field); void InitMessageField( not_null controller, not_null field); bool HasSendText(not_null field); struct InlineBotQuery { QString query; QString username; UserData *bot = nullptr; bool lookingUpBot = false; }; InlineBotQuery ParseInlineBotQuery(not_null field); struct AutocompleteQuery { QString query; bool fromStart = false; }; AutocompleteQuery ParseMentionHashtagBotCommandQuery( not_null field); class QtConnectionOwner { public: QtConnectionOwner(QMetaObject::Connection connection = {}); QtConnectionOwner(QtConnectionOwner &&other); QtConnectionOwner &operator=(QtConnectionOwner &&other); ~QtConnectionOwner(); private: void disconnect(); QMetaObject::Connection _data; }; class MessageLinksParser : private QObject { public: MessageLinksParser(not_null field); 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; QtConnectionOwner _connection; };