2016-04-29 13:46:16 +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.
|
2016-04-29 13:46:16 +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
|
2016-04-29 13:46:16 +00:00
|
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
|
2020-08-09 14:52:51 +00:00
|
|
|
#include "api/api_common.h"
|
2019-04-02 09:13:30 +00:00
|
|
|
#include "ui/effects/animations.h"
|
2022-02-11 05:24:54 +00:00
|
|
|
#include "ui/effects/message_sending_animation_common.h"
|
2019-07-02 14:29:26 +00:00
|
|
|
#include "ui/rp_widget.h"
|
2018-11-21 18:14:48 +00:00
|
|
|
#include "base/timer.h"
|
2019-09-13 12:22:54 +00:00
|
|
|
#include "base/object_ptr.h"
|
2016-04-29 13:46:16 +00:00
|
|
|
|
2016-11-16 10:44:06 +00:00
|
|
|
namespace Ui {
|
2020-08-09 14:52:51 +00:00
|
|
|
class PopupMenu;
|
2016-11-16 10:44:06 +00:00
|
|
|
class ScrollArea;
|
2020-11-10 14:10:08 +00:00
|
|
|
class InputField;
|
2016-11-16 10:44:06 +00:00
|
|
|
} // namespace Ui
|
|
|
|
|
2019-07-02 14:29:26 +00:00
|
|
|
namespace Lottie {
|
|
|
|
class SinglePlayer;
|
|
|
|
class FrameRenderer;
|
|
|
|
} // namespace Lottie;
|
|
|
|
|
2020-05-12 08:18:31 +00:00
|
|
|
namespace Window {
|
|
|
|
class SessionController;
|
|
|
|
} // namespace Window
|
2019-08-02 10:40:35 +00:00
|
|
|
|
2020-04-09 08:15:47 +00:00
|
|
|
namespace Data {
|
|
|
|
class DocumentMedia;
|
2020-05-28 14:32:10 +00:00
|
|
|
class CloudImageView;
|
2020-04-09 08:15:47 +00:00
|
|
|
} // namespace Data
|
|
|
|
|
2020-11-19 02:58:23 +00:00
|
|
|
namespace SendMenu {
|
|
|
|
enum class Type;
|
|
|
|
} // namespace SendMenu
|
|
|
|
|
|
|
|
|
2019-07-02 14:29:26 +00:00
|
|
|
class FieldAutocomplete final : public Ui::RpWidget {
|
2016-04-29 13:46:16 +00:00
|
|
|
public:
|
2020-05-12 08:18:31 +00:00
|
|
|
FieldAutocomplete(
|
|
|
|
QWidget *parent,
|
|
|
|
not_null<Window::SessionController*> controller);
|
2019-07-02 14:29:26 +00:00
|
|
|
~FieldAutocomplete();
|
2016-04-29 13:46:16 +00:00
|
|
|
|
2020-11-10 14:10:08 +00:00
|
|
|
[[nodiscard]] not_null<Window::SessionController*> controller() const;
|
|
|
|
|
2016-04-29 13:46:16 +00:00
|
|
|
bool clearFilteredBotCommands();
|
2018-06-26 20:15:29 +00:00
|
|
|
void showFiltered(
|
|
|
|
not_null<PeerData*> peer,
|
|
|
|
QString query,
|
|
|
|
bool addInlineBots);
|
2016-04-29 13:46:16 +00:00
|
|
|
void showStickers(EmojiPtr emoji);
|
|
|
|
void setBoundings(QRect boundings);
|
|
|
|
|
|
|
|
const QString &filter() const;
|
|
|
|
ChatData *chat() const;
|
|
|
|
ChannelData *channel() const;
|
|
|
|
UserData *user() const;
|
|
|
|
|
|
|
|
int32 innerTop();
|
|
|
|
int32 innerBottom();
|
|
|
|
|
2016-05-10 13:39:42 +00:00
|
|
|
bool eventFilter(QObject *obj, QEvent *e) override;
|
2016-04-29 13:46:16 +00:00
|
|
|
|
|
|
|
enum class ChooseMethod {
|
|
|
|
ByEnter,
|
|
|
|
ByTab,
|
|
|
|
ByClick,
|
|
|
|
};
|
2020-08-09 14:13:24 +00:00
|
|
|
struct MentionChosen {
|
|
|
|
not_null<UserData*> user;
|
|
|
|
ChooseMethod method;
|
|
|
|
};
|
|
|
|
struct HashtagChosen {
|
|
|
|
QString hashtag;
|
|
|
|
ChooseMethod method;
|
|
|
|
};
|
|
|
|
struct BotCommandChosen {
|
|
|
|
QString command;
|
|
|
|
ChooseMethod method;
|
|
|
|
};
|
|
|
|
struct StickerChosen {
|
|
|
|
not_null<DocumentData*> sticker;
|
2020-08-09 14:52:51 +00:00
|
|
|
Api::SendOptions options;
|
2020-08-09 14:13:24 +00:00
|
|
|
ChooseMethod method;
|
2022-02-11 05:24:54 +00:00
|
|
|
Ui::MessageSendingAnimationFrom messageSendingFrom;
|
2020-08-09 14:13:24 +00:00
|
|
|
};
|
2021-08-31 22:22:31 +00:00
|
|
|
enum class Type {
|
|
|
|
Mentions,
|
|
|
|
Hashtags,
|
|
|
|
BotCommands,
|
|
|
|
Stickers,
|
|
|
|
};
|
2020-08-09 14:13:24 +00:00
|
|
|
|
2016-04-29 13:46:16 +00:00
|
|
|
bool chooseSelected(ChooseMethod method) const;
|
|
|
|
|
|
|
|
bool stickersShown() const {
|
2018-03-07 21:25:03 +00:00
|
|
|
return !_srows.empty();
|
2016-04-29 13:46:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bool overlaps(const QRect &globalRect) {
|
|
|
|
if (isHidden() || !testAttribute(Qt::WA_OpaquePaintEvent)) return false;
|
|
|
|
|
|
|
|
return rect().contains(QRect(mapFromGlobal(globalRect.topLeft()), globalRect.size()));
|
|
|
|
}
|
|
|
|
|
2020-08-09 14:13:24 +00:00
|
|
|
void setModerateKeyActivateCallback(Fn<bool(int)> callback) {
|
|
|
|
_moderateKeyActivateCallback = std::move(callback);
|
|
|
|
}
|
2020-11-19 02:58:23 +00:00
|
|
|
void setSendMenuType(Fn<SendMenu::Type()> &&callback);
|
2016-10-26 16:43:13 +00:00
|
|
|
|
2020-08-09 14:13:24 +00:00
|
|
|
void hideFast();
|
2016-04-29 13:46:16 +00:00
|
|
|
|
2020-08-09 14:13:24 +00:00
|
|
|
rpl::producer<MentionChosen> mentionChosen() const;
|
|
|
|
rpl::producer<HashtagChosen> hashtagChosen() const;
|
|
|
|
rpl::producer<BotCommandChosen> botCommandChosen() const;
|
|
|
|
rpl::producer<StickerChosen> stickerChosen() const;
|
2021-08-31 22:22:31 +00:00
|
|
|
rpl::producer<Type> choosingProcesses() const;
|
2016-06-22 18:41:13 +00:00
|
|
|
|
2021-03-03 18:22:42 +00:00
|
|
|
public Q_SLOTS:
|
2016-10-26 16:43:13 +00:00
|
|
|
void showAnimated();
|
|
|
|
void hideAnimated();
|
2016-04-29 13:46:16 +00:00
|
|
|
|
2016-10-01 12:34:23 +00:00
|
|
|
protected:
|
2016-04-29 13:46:16 +00:00
|
|
|
void paintEvent(QPaintEvent *e) override;
|
|
|
|
|
2016-10-01 12:34:23 +00:00
|
|
|
private:
|
2020-11-10 14:10:08 +00:00
|
|
|
class Inner;
|
|
|
|
friend class Inner;
|
2022-01-25 09:53:08 +00:00
|
|
|
struct StickerSuggestion;
|
2020-11-10 14:10:08 +00:00
|
|
|
|
|
|
|
struct MentionRow {
|
|
|
|
not_null<UserData*> user;
|
|
|
|
std::shared_ptr<Data::CloudImageView> userpic;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct BotCommandRow {
|
|
|
|
not_null<UserData*> user;
|
2021-07-01 09:49:37 +00:00
|
|
|
QString command;
|
|
|
|
QString description;
|
2020-11-10 14:10:08 +00:00
|
|
|
std::shared_ptr<Data::CloudImageView> userpic;
|
2021-07-01 09:49:37 +00:00
|
|
|
Ui::Text::String descriptionText;
|
2020-11-10 14:10:08 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
using HashtagRows = std::vector<QString>;
|
|
|
|
using BotCommandRows = std::vector<BotCommandRow>;
|
|
|
|
using StickerRows = std::vector<StickerSuggestion>;
|
|
|
|
using MentionRows = std::vector<MentionRow>;
|
|
|
|
|
2016-12-07 13:32:25 +00:00
|
|
|
void animationCallback();
|
2016-10-26 16:43:13 +00:00
|
|
|
void hideFinish();
|
|
|
|
|
2016-04-29 13:46:16 +00:00
|
|
|
void updateFiltered(bool resetScroll = false);
|
|
|
|
void recount(bool resetScroll = false);
|
2020-11-10 14:10:08 +00:00
|
|
|
StickerRows getStickerSuggestions();
|
2016-04-29 13:46:16 +00:00
|
|
|
|
2020-05-12 08:18:31 +00:00
|
|
|
const not_null<Window::SessionController*> _controller;
|
2016-04-29 13:46:16 +00:00
|
|
|
QPixmap _cache;
|
2020-11-10 14:10:08 +00:00
|
|
|
MentionRows _mrows;
|
|
|
|
HashtagRows _hrows;
|
|
|
|
BotCommandRows _brows;
|
|
|
|
StickerRows _srows;
|
2016-04-29 13:46:16 +00:00
|
|
|
|
2019-07-02 14:29:26 +00:00
|
|
|
void rowsUpdated(
|
2020-11-10 14:10:08 +00:00
|
|
|
MentionRows &&mrows,
|
|
|
|
HashtagRows &&hrows,
|
|
|
|
BotCommandRows &&brows,
|
|
|
|
StickerRows &&srows,
|
2019-07-02 14:29:26 +00:00
|
|
|
bool resetScroll);
|
2016-04-29 13:46:16 +00:00
|
|
|
|
2016-12-13 17:07:56 +00:00
|
|
|
object_ptr<Ui::ScrollArea> _scroll;
|
2020-11-10 14:10:08 +00:00
|
|
|
QPointer<Inner> _inner;
|
2016-04-29 13:46:16 +00:00
|
|
|
|
2016-10-01 12:34:23 +00:00
|
|
|
ChatData *_chat = nullptr;
|
|
|
|
UserData *_user = nullptr;
|
|
|
|
ChannelData *_channel = nullptr;
|
2016-04-29 13:46:16 +00:00
|
|
|
EmojiPtr _emoji;
|
2018-03-07 21:25:03 +00:00
|
|
|
uint64 _stickersSeed = 0;
|
2016-05-08 16:11:47 +00:00
|
|
|
Type _type = Type::Mentions;
|
2016-04-29 13:46:16 +00:00
|
|
|
QString _filter;
|
|
|
|
QRect _boundings;
|
|
|
|
bool _addInlineBots;
|
|
|
|
|
2016-10-01 12:34:23 +00:00
|
|
|
bool _hiding = false;
|
2016-04-29 13:46:16 +00:00
|
|
|
|
2019-04-02 09:13:30 +00:00
|
|
|
Ui::Animations::Simple _a_opacity;
|
2016-04-29 13:46:16 +00:00
|
|
|
|
2020-08-09 14:13:24 +00:00
|
|
|
Fn<bool(int)> _moderateKeyActivateCallback;
|
|
|
|
|
2016-04-29 13:46:16 +00:00
|
|
|
};
|