2017-04-08 13:27:53 +00:00
|
|
|
/*
|
|
|
|
This file is part of Telegram Desktop,
|
2018-01-03 10:23:14 +00:00
|
|
|
the official desktop application for the Telegram messaging service.
|
2017-04-08 13:27:53 +00:00
|
|
|
|
2018-01-03 10:23:14 +00:00
|
|
|
For license and copyright information please follow this link:
|
|
|
|
https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
2017-04-08 13:27:53 +00:00
|
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "ui/widgets/input_fields.h"
|
2018-05-21 21:31:46 +00:00
|
|
|
#include "base/timer.h"
|
2019-09-16 05:11:12 +00:00
|
|
|
#include "base/qt_connection.h"
|
2017-04-08 13:27:53 +00:00
|
|
|
|
2019-11-05 11:27:21 +00:00
|
|
|
#ifndef TDESKTOP_DISABLE_SPELLCHECK
|
2020-02-21 09:48:24 +00:00
|
|
|
#include "boxes/dictionaries_manager.h"
|
2019-11-05 11:27:21 +00:00
|
|
|
#include "spellcheck/spelling_highlighter.h"
|
|
|
|
#endif // TDESKTOP_DISABLE_SPELLCHECK
|
|
|
|
|
2019-09-04 07:19:15 +00:00
|
|
|
#include <QtGui/QClipboard>
|
|
|
|
|
2019-08-02 10:40:35 +00:00
|
|
|
namespace Main {
|
|
|
|
class Session;
|
|
|
|
} // namespace Main
|
2019-06-06 10:21:40 +00:00
|
|
|
|
2017-04-08 13:27:53 +00:00
|
|
|
namespace Window {
|
2019-06-06 10:21:40 +00:00
|
|
|
class SessionController;
|
2017-04-08 13:27:53 +00:00
|
|
|
} // namespace Window
|
|
|
|
|
2020-07-24 08:23:08 +00:00
|
|
|
namespace Ui {
|
|
|
|
class PopupMenu;
|
|
|
|
} // namespace Ui
|
|
|
|
|
2018-05-26 14:58:21 +00:00
|
|
|
QString PrepareMentionTag(not_null<UserData*> user);
|
2019-06-05 18:40:21 +00:00
|
|
|
TextWithTags PrepareEditText(not_null<HistoryItem*> item);
|
2017-04-08 13:27:53 +00:00
|
|
|
|
2018-06-04 15:35:11 +00:00
|
|
|
Fn<bool(
|
2018-05-26 14:58:21 +00:00
|
|
|
Ui::InputField::EditLinkSelection selection,
|
|
|
|
QString text,
|
|
|
|
QString link,
|
|
|
|
Ui::InputField::EditLinkAction action)> DefaultEditLinkCallback(
|
2020-06-10 18:08:17 +00:00
|
|
|
not_null<Window::SessionController*> controller,
|
2018-05-26 14:58:21 +00:00
|
|
|
not_null<Ui::InputField*> field);
|
|
|
|
void InitMessageField(
|
2019-06-06 10:21:40 +00:00
|
|
|
not_null<Window::SessionController*> controller,
|
2018-05-26 14:58:21 +00:00
|
|
|
not_null<Ui::InputField*> field);
|
2019-11-05 11:27:21 +00:00
|
|
|
|
|
|
|
void InitSpellchecker(
|
2020-06-10 18:08:17 +00:00
|
|
|
not_null<Window::SessionController*> controller,
|
2019-10-18 13:54:26 +00:00
|
|
|
not_null<Ui::InputField*> field);
|
2019-11-05 11:27:21 +00:00
|
|
|
|
2018-05-21 21:31:46 +00:00
|
|
|
bool HasSendText(not_null<const Ui::InputField*> field);
|
2017-04-08 13:27:53 +00:00
|
|
|
|
2018-05-21 21:31:46 +00:00
|
|
|
struct InlineBotQuery {
|
|
|
|
QString query;
|
|
|
|
QString username;
|
|
|
|
UserData *bot = nullptr;
|
|
|
|
bool lookingUpBot = false;
|
|
|
|
};
|
2020-06-08 09:06:50 +00:00
|
|
|
InlineBotQuery ParseInlineBotQuery(
|
|
|
|
not_null<Main::Session*> session,
|
|
|
|
not_null<const Ui::InputField*> field);
|
2018-05-21 21:31:46 +00:00
|
|
|
|
|
|
|
struct AutocompleteQuery {
|
|
|
|
QString query;
|
|
|
|
bool fromStart = false;
|
|
|
|
};
|
|
|
|
AutocompleteQuery ParseMentionHashtagBotCommandQuery(
|
|
|
|
not_null<const Ui::InputField*> field);
|
|
|
|
|
|
|
|
class MessageLinksParser : private QObject {
|
|
|
|
public:
|
|
|
|
MessageLinksParser(not_null<Ui::InputField*> field);
|
2017-04-08 13:27:53 +00:00
|
|
|
|
2018-05-21 21:31:46 +00:00
|
|
|
const rpl::variable<QStringList> &list() const;
|
2017-04-08 13:27:53 +00:00
|
|
|
|
|
|
|
protected:
|
2018-05-21 21:31:46 +00:00
|
|
|
bool eventFilter(QObject *object, QEvent *event) override;
|
2017-04-08 13:27:53 +00:00
|
|
|
|
|
|
|
private:
|
2018-05-21 21:31:46 +00:00
|
|
|
struct LinkRange {
|
|
|
|
int start;
|
|
|
|
int length;
|
2018-05-26 14:58:21 +00:00
|
|
|
QString custom;
|
2018-05-21 21:31:46 +00:00
|
|
|
};
|
|
|
|
friend inline bool operator==(const LinkRange &a, const LinkRange &b) {
|
2018-05-26 14:58:21 +00:00
|
|
|
return (a.start == b.start)
|
|
|
|
&& (a.length == b.length)
|
|
|
|
&& (a.custom == b.custom);
|
2018-05-21 21:31:46 +00:00
|
|
|
}
|
|
|
|
friend inline bool operator!=(const LinkRange &a, const LinkRange &b) {
|
|
|
|
return !(a == b);
|
|
|
|
}
|
2017-04-08 13:27:53 +00:00
|
|
|
|
2018-05-21 21:31:46 +00:00
|
|
|
void parse();
|
|
|
|
void apply(const QString &text, const QVector<LinkRange> &ranges);
|
|
|
|
|
|
|
|
not_null<Ui::InputField*> _field;
|
|
|
|
rpl::variable<QStringList> _list;
|
|
|
|
int _lastLength = 0;
|
|
|
|
base::Timer _timer;
|
2019-09-16 05:11:12 +00:00
|
|
|
base::qt_connection _connection;
|
2018-05-21 21:31:46 +00:00
|
|
|
|
2019-07-26 16:06:22 +00:00
|
|
|
};
|