2021-09-07 15:44:01 +00:00
|
|
|
/*
|
|
|
|
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/unique_qptr.h"
|
2022-08-26 19:53:48 +00:00
|
|
|
#include "ui/text/text_block.h"
|
2023-06-01 16:01:29 +00:00
|
|
|
#include "ui/widgets/menu/menu_item_base.h"
|
2021-09-07 15:44:01 +00:00
|
|
|
|
|
|
|
namespace Ui {
|
|
|
|
|
|
|
|
class PopupMenu;
|
|
|
|
|
|
|
|
struct WhoReadParticipant {
|
|
|
|
QString name;
|
2023-03-03 13:15:02 +00:00
|
|
|
QString date;
|
2023-03-08 10:06:08 +00:00
|
|
|
bool dateReacted = false;
|
2022-08-26 19:53:48 +00:00
|
|
|
QString customEntityData;
|
2021-09-08 21:10:49 +00:00
|
|
|
QImage userpicSmall;
|
|
|
|
QImage userpicLarge;
|
2021-09-07 15:44:01 +00:00
|
|
|
std::pair<uint64, uint64> userpicKey = {};
|
|
|
|
uint64 id = 0;
|
2021-09-08 21:10:49 +00:00
|
|
|
|
|
|
|
static constexpr auto kMaxSmallUserpics = 3;
|
2021-09-07 15:44:01 +00:00
|
|
|
};
|
|
|
|
|
2021-09-07 18:31:13 +00:00
|
|
|
bool operator==(const WhoReadParticipant &a, const WhoReadParticipant &b);
|
|
|
|
bool operator!=(const WhoReadParticipant &a, const WhoReadParticipant &b);
|
|
|
|
|
|
|
|
enum class WhoReadType {
|
|
|
|
Seen,
|
|
|
|
Listened,
|
|
|
|
Watched,
|
2021-12-29 14:54:01 +00:00
|
|
|
Reacted,
|
2021-09-07 18:31:13 +00:00
|
|
|
};
|
|
|
|
|
2024-01-09 13:49:02 +00:00
|
|
|
enum class WhoReadState : uchar {
|
|
|
|
Empty,
|
|
|
|
Unknown,
|
|
|
|
MyHidden,
|
|
|
|
HisHidden,
|
|
|
|
TooOld,
|
|
|
|
};
|
|
|
|
|
2021-09-07 15:44:01 +00:00
|
|
|
struct WhoReadContent {
|
|
|
|
std::vector<WhoReadParticipant> participants;
|
2021-09-07 18:31:13 +00:00
|
|
|
WhoReadType type = WhoReadType::Seen;
|
2022-08-26 19:53:48 +00:00
|
|
|
QString singleCustomEntityData;
|
2021-12-29 14:54:01 +00:00
|
|
|
int fullReactionsCount = 0;
|
2022-01-18 16:55:24 +00:00
|
|
|
int fullReadCount = 0;
|
2024-01-09 13:49:02 +00:00
|
|
|
WhoReadState state = WhoReadState::Empty;
|
2021-09-07 15:44:01 +00:00
|
|
|
};
|
|
|
|
|
2021-12-24 13:51:53 +00:00
|
|
|
[[nodiscard]] base::unique_qptr<Menu::ItemBase> WhoReactedContextAction(
|
2021-09-07 15:44:01 +00:00
|
|
|
not_null<PopupMenu*> menu,
|
|
|
|
rpl::producer<WhoReadContent> content,
|
2022-08-26 19:53:48 +00:00
|
|
|
Text::CustomEmojiFactory factory,
|
2021-12-29 14:54:01 +00:00
|
|
|
Fn<void(uint64)> participantChosen,
|
|
|
|
Fn<void()> showAllChosen);
|
2021-09-07 15:44:01 +00:00
|
|
|
|
2023-12-14 22:59:50 +00:00
|
|
|
enum class WhoReactedType : uchar {
|
|
|
|
Viewed,
|
|
|
|
Reacted,
|
|
|
|
Reposted,
|
|
|
|
Forwarded,
|
|
|
|
Preloader,
|
|
|
|
};
|
|
|
|
|
2023-06-01 16:01:29 +00:00
|
|
|
struct WhoReactedEntryData {
|
|
|
|
QString text;
|
|
|
|
QString date;
|
2023-12-14 22:59:50 +00:00
|
|
|
WhoReactedType type = WhoReactedType::Viewed;
|
2023-06-01 16:01:29 +00:00
|
|
|
QString customEntityData;
|
|
|
|
QImage userpic;
|
|
|
|
Fn<void()> callback;
|
|
|
|
};
|
|
|
|
|
|
|
|
class WhoReactedEntryAction final : public Menu::ItemBase {
|
|
|
|
public:
|
|
|
|
using Data = WhoReactedEntryData;
|
|
|
|
|
|
|
|
WhoReactedEntryAction(
|
|
|
|
not_null<RpWidget*> parent,
|
|
|
|
Text::CustomEmojiFactory factory,
|
|
|
|
const style::Menu &st,
|
|
|
|
Data &&data);
|
|
|
|
|
|
|
|
void setData(Data &&data);
|
|
|
|
|
|
|
|
not_null<QAction*> action() const override;
|
|
|
|
bool isEnabled() const override;
|
|
|
|
|
|
|
|
private:
|
|
|
|
int contentHeight() const override;
|
|
|
|
|
|
|
|
void paint(Painter &&p);
|
|
|
|
|
|
|
|
const not_null<QAction*> _dummyAction;
|
|
|
|
const Text::CustomEmojiFactory _customEmojiFactory;
|
|
|
|
const style::Menu &_st;
|
|
|
|
const int _height = 0;
|
|
|
|
|
|
|
|
Text::String _text;
|
|
|
|
Text::String _date;
|
|
|
|
std::unique_ptr<Ui::Text::CustomEmoji> _custom;
|
|
|
|
QImage _userpic;
|
|
|
|
int _textWidth = 0;
|
|
|
|
int _customSize = 0;
|
2023-12-14 22:59:50 +00:00
|
|
|
WhoReactedType _type = WhoReactedType::Viewed;
|
2023-06-01 16:01:29 +00:00
|
|
|
|
|
|
|
};
|
|
|
|
|
2022-01-14 15:42:24 +00:00
|
|
|
class WhoReactedListMenu final {
|
|
|
|
public:
|
|
|
|
WhoReactedListMenu(
|
2022-08-26 19:53:48 +00:00
|
|
|
Text::CustomEmojiFactory factory,
|
2022-01-14 15:42:24 +00:00
|
|
|
Fn<void(uint64)> participantChosen,
|
|
|
|
Fn<void()> showAllChosen);
|
|
|
|
|
|
|
|
void clear();
|
|
|
|
void populate(
|
|
|
|
not_null<PopupMenu*> menu,
|
|
|
|
const WhoReadContent &content,
|
2022-08-31 13:51:41 +00:00
|
|
|
Fn<void()> refillTopActions = nullptr,
|
|
|
|
int addedToBottom = 0,
|
|
|
|
Fn<void()> appendBottomActions = nullptr);
|
2022-01-14 15:42:24 +00:00
|
|
|
|
|
|
|
private:
|
2022-08-26 19:53:48 +00:00
|
|
|
const Text::CustomEmojiFactory _customEmojiFactory;
|
2022-01-14 15:42:24 +00:00
|
|
|
const Fn<void(uint64)> _participantChosen;
|
|
|
|
const Fn<void()> _showAllChosen;
|
|
|
|
|
2023-06-01 16:01:29 +00:00
|
|
|
std::vector<not_null<WhoReactedEntryAction*>> _actions;
|
2022-01-14 15:42:24 +00:00
|
|
|
|
|
|
|
};
|
|
|
|
|
2021-09-07 15:44:01 +00:00
|
|
|
} // namespace Ui
|