mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-05 06:33:57 +02:00
Show who've seen the message in submenu.
This commit is contained in:
parent
2f5f100626
commit
abbac61702
6 changed files with 48 additions and 15 deletions
|
@ -1709,6 +1709,8 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
"lng_context_seen_text#other" = "{count} Seen";
|
"lng_context_seen_text#other" = "{count} Seen";
|
||||||
"lng_context_seen_listened#one" = "{count} Listened";
|
"lng_context_seen_listened#one" = "{count} Listened";
|
||||||
"lng_context_seen_listened#other" = "{count} Listened";
|
"lng_context_seen_listened#other" = "{count} Listened";
|
||||||
|
"lng_context_seen_watched#one" = "{count} Watched";
|
||||||
|
"lng_context_seen_watched#other" = "{count} Watched";
|
||||||
|
|
||||||
"lng_send_image_empty" = "Could not send an empty file: {name}";
|
"lng_send_image_empty" = "Could not send an empty file: {name}";
|
||||||
"lng_send_image_too_large" = "Could not send a file, because it is larger than 1500 MB: {name}";
|
"lng_send_image_too_large" = "Could not send a file, because it is larger than 1500 MB: {name}";
|
||||||
|
|
|
@ -182,6 +182,7 @@ rpl::producer<Ui::WhoReadContent> WhoRead(
|
||||||
}) | ranges::views::transform([](UserData *user) {
|
}) | ranges::views::transform([](UserData *user) {
|
||||||
return Ui::WhoReadParticipant{
|
return Ui::WhoReadParticipant{
|
||||||
.name = user->name,
|
.name = user->name,
|
||||||
|
.id = user->id.value,
|
||||||
};
|
};
|
||||||
}) | ranges::to_vector;
|
}) | ranges::to_vector;
|
||||||
return Ui::WhoReadContent{
|
return Ui::WhoReadContent{
|
||||||
|
|
|
@ -1587,7 +1587,7 @@ void HistoryInner::showContextMenu(QContextMenuEvent *e, bool showFromTouch) {
|
||||||
const auto itemId = item->fullId();
|
const auto itemId = item->fullId();
|
||||||
if (Api::WhoReadExists(item)) {
|
if (Api::WhoReadExists(item)) {
|
||||||
const auto participantChosen = [=](uint64 id) {
|
const auto participantChosen = [=](uint64 id) {
|
||||||
controller->showPeerInfo(PeerId(UserId(id)));
|
controller->showPeerInfo(PeerId(id));
|
||||||
};
|
};
|
||||||
_menu->addAction(Ui::WhoReadContextAction(
|
_menu->addAction(Ui::WhoReadContextAction(
|
||||||
_menu.get(),
|
_menu.get(),
|
||||||
|
|
|
@ -41,10 +41,10 @@ private:
|
||||||
void paint(Painter &p);
|
void paint(Painter &p);
|
||||||
|
|
||||||
void updateUserpicsFromContent();
|
void updateUserpicsFromContent();
|
||||||
void setupSubMenu();
|
|
||||||
void resolveMinWidth();
|
void resolveMinWidth();
|
||||||
void refreshText();
|
void refreshText();
|
||||||
void refreshDimensions();
|
void refreshDimensions();
|
||||||
|
void populateSubmenu();
|
||||||
|
|
||||||
const not_null<PopupMenu*> _parentMenu;
|
const not_null<PopupMenu*> _parentMenu;
|
||||||
const not_null<QAction*> _dummyAction;
|
const not_null<QAction*> _dummyAction;
|
||||||
|
@ -81,19 +81,13 @@ Action::Action(
|
||||||
rpl::never<bool>(),
|
rpl::never<bool>(),
|
||||||
[=] { update(); }))
|
[=] { update(); }))
|
||||||
, _st(parentMenu->menu()->st())
|
, _st(parentMenu->menu()->st())
|
||||||
, _height(st::ttlItemPadding.top()
|
, _height(_st.itemPadding.top()
|
||||||
+ _st.itemStyle.font->height
|
+ _st.itemStyle.font->height
|
||||||
+ st::ttlItemTimerFont->height
|
+ _st.itemPadding.bottom()) {
|
||||||
+ st::ttlItemPadding.bottom()) {
|
|
||||||
const auto parent = parentMenu->menu();
|
const auto parent = parentMenu->menu();
|
||||||
|
|
||||||
setAcceptBoth(true);
|
setAcceptBoth(true);
|
||||||
initResizeHook(parent->sizeValue());
|
initResizeHook(parent->sizeValue());
|
||||||
setClickedCallback([=] {
|
|
||||||
if (!_content.participants.empty()) {
|
|
||||||
setupSubMenu();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
resolveMinWidth();
|
resolveMinWidth();
|
||||||
|
|
||||||
auto copy = std::move(
|
auto copy = std::move(
|
||||||
|
@ -110,7 +104,11 @@ Action::Action(
|
||||||
std::move(
|
std::move(
|
||||||
content
|
content
|
||||||
) | rpl::start_with_next([=](WhoReadContent &&content) {
|
) | rpl::start_with_next([=](WhoReadContent &&content) {
|
||||||
|
const auto changed = (_content.participants != content.participants);
|
||||||
_content = content;
|
_content = content;
|
||||||
|
if (changed) {
|
||||||
|
PostponeCall(this, [=] { populateSubmenu(); });
|
||||||
|
}
|
||||||
updateUserpicsFromContent();
|
updateUserpicsFromContent();
|
||||||
refreshText();
|
refreshText();
|
||||||
refreshDimensions();
|
refreshDimensions();
|
||||||
|
@ -161,8 +159,19 @@ void Action::updateUserpicsFromContent() {
|
||||||
_userpics->update(users, true);
|
_userpics->update(users, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Action::setupSubMenu() {
|
void Action::populateSubmenu() {
|
||||||
|
if (_content.participants.empty()) {
|
||||||
|
_parentMenu->removeSubmenu(action());
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const auto submenu = _parentMenu->ensureSubmenu(action());
|
||||||
|
submenu->clearActions();
|
||||||
|
for (const auto &participant : _content.participants) {
|
||||||
|
const auto chosen = [call = _participantChosen, id = participant.id] {
|
||||||
|
call(id);
|
||||||
|
};
|
||||||
|
submenu->addAction(participant.name, chosen);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Action::paint(Painter &p) {
|
void Action::paint(Painter &p) {
|
||||||
|
@ -196,7 +205,9 @@ void Action::refreshText() {
|
||||||
? tr::lng_context_seen_loading(tr::now)
|
? tr::lng_context_seen_loading(tr::now)
|
||||||
: (count == 1)
|
: (count == 1)
|
||||||
? _content.participants.front().name
|
? _content.participants.front().name
|
||||||
: _content.listened
|
: (_content.type == WhoReadType::Watched)
|
||||||
|
? tr::lng_context_seen_watched(tr::now, lt_count, count)
|
||||||
|
: (_content.type == WhoReadType::Listened)
|
||||||
? tr::lng_context_seen_listened(tr::now, lt_count, count)
|
? tr::lng_context_seen_listened(tr::now, lt_count, count)
|
||||||
: tr::lng_context_seen_text(tr::now, lt_count, count)) },
|
: tr::lng_context_seen_text(tr::now, lt_count, count)) },
|
||||||
MenuTextOptions);
|
MenuTextOptions);
|
||||||
|
@ -250,6 +261,16 @@ void Action::handleKeyPress(not_null<QKeyEvent*> e) {
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
|
bool operator==(const WhoReadParticipant &a, const WhoReadParticipant &b) {
|
||||||
|
return (a.id == b.id)
|
||||||
|
&& (a.name == b.name)
|
||||||
|
&& (a.userpicKey == b.userpicKey);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool operator!=(const WhoReadParticipant &a, const WhoReadParticipant &b) {
|
||||||
|
return !(a == b);
|
||||||
|
}
|
||||||
|
|
||||||
base::unique_qptr<Menu::ItemBase> WhoReadContextAction(
|
base::unique_qptr<Menu::ItemBase> WhoReadContextAction(
|
||||||
not_null<PopupMenu*> menu,
|
not_null<PopupMenu*> menu,
|
||||||
rpl::producer<WhoReadContent> content,
|
rpl::producer<WhoReadContent> content,
|
||||||
|
|
|
@ -23,9 +23,18 @@ struct WhoReadParticipant {
|
||||||
uint64 id = 0;
|
uint64 id = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
bool operator==(const WhoReadParticipant &a, const WhoReadParticipant &b);
|
||||||
|
bool operator!=(const WhoReadParticipant &a, const WhoReadParticipant &b);
|
||||||
|
|
||||||
|
enum class WhoReadType {
|
||||||
|
Seen,
|
||||||
|
Listened,
|
||||||
|
Watched,
|
||||||
|
};
|
||||||
|
|
||||||
struct WhoReadContent {
|
struct WhoReadContent {
|
||||||
std::vector<WhoReadParticipant> participants;
|
std::vector<WhoReadParticipant> participants;
|
||||||
bool listened = false;
|
WhoReadType type = WhoReadType::Seen;
|
||||||
bool unknown = false;
|
bool unknown = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
Subproject commit e0339b7da1e344bf13b7544676da9613fa8a5640
|
Subproject commit 6651d9f9b6fb7ebc9d18e6b3429862477d891b2e
|
Loading…
Add table
Reference in a new issue