mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-04-14 21:27:07 +02:00
Add "when edited" context menu information.
This commit is contained in:
parent
9166acbbb9
commit
81492b7d3a
11 changed files with 64 additions and 9 deletions
BIN
Telegram/Resources/icons/menu/edited_status.png
Normal file
BIN
Telegram/Resources/icons/menu/edited_status.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 586 B |
BIN
Telegram/Resources/icons/menu/edited_status@2x.png
Normal file
BIN
Telegram/Resources/icons/menu/edited_status@2x.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.2 KiB |
BIN
Telegram/Resources/icons/menu/edited_status@3x.png
Normal file
BIN
Telegram/Resources/icons/menu/edited_status@3x.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.8 KiB |
|
@ -756,5 +756,19 @@ rpl::producer<Ui::WhoReadContent> WhoReacted(
|
|||
const style::WhoRead &st) {
|
||||
return WhoReacted(item, reaction, context, st, nullptr);
|
||||
}
|
||||
rpl::producer<Ui::WhoReadContent> WhenEdited(
|
||||
not_null<PeerData*> author,
|
||||
TimeId date) {
|
||||
return rpl::single(Ui::WhoReadContent{
|
||||
.participants = { Ui::WhoReadParticipant{
|
||||
.name = author->name(),
|
||||
.date = FormatReadDate(date, QDateTime::currentDateTime()),
|
||||
.id = author->id.value,
|
||||
} },
|
||||
.type = Ui::WhoReadType::Edited,
|
||||
.fullReadCount = 1,
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
} // namespace Api
|
||||
|
|
|
@ -61,5 +61,8 @@ struct WhoReadList {
|
|||
const Data::ReactionId &reaction,
|
||||
not_null<QWidget*> context, // Cache results for this lifetime.
|
||||
const style::WhoRead &st);
|
||||
[[nodiscard]] rpl::producer<Ui::WhoReadContent> WhenEdited(
|
||||
not_null<PeerData*> author,
|
||||
TimeId date);
|
||||
|
||||
} // namespace Api
|
||||
|
|
|
@ -2252,22 +2252,22 @@ void HistoryInner::showContextMenu(QContextMenuEvent *e, bool showFromTouch) {
|
|||
}
|
||||
return item;
|
||||
};
|
||||
const auto whoReactedItem = groupLeaderOrSelf(_dragStateItem);
|
||||
const auto hasWhoReactedItem = whoReactedItem
|
||||
&& Api::WhoReactedExists(whoReactedItem, Api::WhoReactedList::All);
|
||||
const auto leaderOrSelf = groupLeaderOrSelf(_dragStateItem);
|
||||
const auto hasWhoReactedItem = leaderOrSelf
|
||||
&& Api::WhoReactedExists(leaderOrSelf, Api::WhoReactedList::All);
|
||||
const auto clickedReaction = link
|
||||
? link->property(
|
||||
kReactionsCountEmojiProperty).value<Data::ReactionId>()
|
||||
: Data::ReactionId();
|
||||
_whoReactedMenuLifetime.destroy();
|
||||
if (!clickedReaction.empty()
|
||||
&& whoReactedItem
|
||||
&& Api::WhoReactedExists(whoReactedItem, Api::WhoReactedList::One)) {
|
||||
&& leaderOrSelf
|
||||
&& Api::WhoReactedExists(leaderOrSelf, Api::WhoReactedList::One)) {
|
||||
HistoryView::ShowWhoReactedMenu(
|
||||
&_menu,
|
||||
e->globalPos(),
|
||||
this,
|
||||
whoReactedItem,
|
||||
leaderOrSelf,
|
||||
clickedReaction,
|
||||
_controller,
|
||||
_whoReactedMenuLifetime);
|
||||
|
@ -2954,8 +2954,10 @@ void HistoryInner::showContextMenu(QContextMenuEvent *e, bool showFromTouch) {
|
|||
HistoryView::AddWhoReactedAction(
|
||||
_menu,
|
||||
this,
|
||||
whoReactedItem,
|
||||
leaderOrSelf,
|
||||
_controller);
|
||||
} else {
|
||||
HistoryView::MaybeAddWhenEditedAction(_menu, leaderOrSelf);
|
||||
}
|
||||
|
||||
if (_menu->empty()) {
|
||||
|
|
|
@ -22,6 +22,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
#include "history/view/history_view_cursor_state.h"
|
||||
#include "history/history.h"
|
||||
#include "history/history_item.h"
|
||||
#include "history/history_item_components.h"
|
||||
#include "history/history_item_text.h"
|
||||
#include "history/view/history_view_schedule_box.h"
|
||||
#include "history/view/media/history_view_media.h"
|
||||
|
@ -1286,6 +1287,8 @@ base::unique_qptr<Ui::PopupMenu> FillContextMenu(
|
|||
}
|
||||
if (hasWhoReactedItem) {
|
||||
AddWhoReactedAction(result, list, item, list->controller());
|
||||
} else if (item) {
|
||||
MaybeAddWhenEditedAction(result, item);
|
||||
}
|
||||
|
||||
return result;
|
||||
|
@ -1441,6 +1444,24 @@ void AddSaveSoundForNotifications(
|
|||
}, &st::menuIconSoundAdd);
|
||||
}
|
||||
|
||||
void AddWhenEditedActionHelper(
|
||||
not_null<Ui::PopupMenu*> menu,
|
||||
not_null<HistoryItem*> item,
|
||||
bool insertSeparator) {
|
||||
if (item->history()->peer->isUser()) {
|
||||
if (const auto edited = item->Get<HistoryMessageEdited>()) {
|
||||
if (!item->hideEditedBadge()) {
|
||||
if (insertSeparator && !menu->empty()) {
|
||||
menu->addSeparator(&st::expandedMenuSeparator);
|
||||
}
|
||||
menu->addAction(Ui::WhenReadContextAction(
|
||||
menu.get(),
|
||||
Api::WhenEdited(item->from(), edited->date)));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void AddWhoReactedAction(
|
||||
not_null<Ui::PopupMenu*> menu,
|
||||
not_null<QWidget*> context,
|
||||
|
@ -1486,6 +1507,7 @@ void AddWhoReactedAction(
|
|||
if (!menu->empty()) {
|
||||
menu->addSeparator(&st::expandedMenuSeparator);
|
||||
}
|
||||
AddWhenEditedActionHelper(menu, item, false);
|
||||
if (item->history()->peer->isUser()) {
|
||||
menu->addAction(Ui::WhenReadContextAction(
|
||||
menu.get(),
|
||||
|
@ -1501,6 +1523,12 @@ void AddWhoReactedAction(
|
|||
}
|
||||
}
|
||||
|
||||
void MaybeAddWhenEditedAction(
|
||||
not_null<Ui::PopupMenu*> menu,
|
||||
not_null<HistoryItem*> item) {
|
||||
AddWhenEditedActionHelper(menu, item, true);
|
||||
}
|
||||
|
||||
void AddEditTagAction(
|
||||
not_null<Ui::PopupMenu*> menu,
|
||||
const Data::ReactionId &id,
|
||||
|
|
|
@ -84,6 +84,9 @@ void AddWhoReactedAction(
|
|||
not_null<QWidget*> context,
|
||||
not_null<HistoryItem*> item,
|
||||
not_null<Window::SessionController*> controller);
|
||||
void MaybeAddWhenEditedAction(
|
||||
not_null<Ui::PopupMenu*> menu,
|
||||
not_null<HistoryItem*> item);
|
||||
void ShowWhoReactedMenu(
|
||||
not_null<base::unique_qptr<Ui::PopupMenu>*> menu,
|
||||
QPoint position,
|
||||
|
|
|
@ -808,6 +808,8 @@ whoReadPlayedDisabled: icon {{ "menu/read_audio", menuFgDisabled }};
|
|||
whoReadReactions: icon{{ "menu/read_reactions", windowBoldFg }};
|
||||
whoReadReactionsOver: icon{{ "menu/read_reactions", windowBoldFg }};
|
||||
whoReadReactionsDisabled: icon{{ "menu/read_reactions", menuFgDisabled }};
|
||||
whenEdited: icon {{ "menu/edited_status", windowBoldFg }};
|
||||
whenEditedOver: icon {{ "menu/edited_status", windowBoldFg }};
|
||||
|
||||
reactionsTabAll: icon {{ "menu/read_reactions", windowFg }};
|
||||
reactionsTabAllSelected: icon {{ "menu/read_reactions", activeButtonFg }};
|
||||
|
|
|
@ -597,7 +597,9 @@ void WhenAction::paint(Painter &p) {
|
|||
p.fillRect(0, 0, width(), _height, _st.itemBg);
|
||||
}
|
||||
p.fillRect(0, 0, width(), _height, _st.itemBg);
|
||||
const auto &icon = loading
|
||||
const auto &icon = (_content.type == WhoReadType::Edited)
|
||||
? (selected ? st::whenEditedOver : st::whenEdited)
|
||||
: loading
|
||||
? st::whoReadChecksDisabled
|
||||
: selected
|
||||
? st::whoReadChecksOver
|
||||
|
|
|
@ -36,6 +36,7 @@ enum class WhoReadType {
|
|||
Listened,
|
||||
Watched,
|
||||
Reacted,
|
||||
Edited,
|
||||
};
|
||||
|
||||
enum class WhoReadState : uchar {
|
||||
|
@ -65,7 +66,7 @@ struct WhoReadContent {
|
|||
[[nodiscard]] base::unique_qptr<Menu::ItemBase> WhenReadContextAction(
|
||||
not_null<PopupMenu*> menu,
|
||||
rpl::producer<WhoReadContent> content,
|
||||
Fn<void()> showOrPremium);
|
||||
Fn<void()> showOrPremium = nullptr);
|
||||
|
||||
enum class WhoReactedType : uchar {
|
||||
Viewed,
|
||||
|
|
Loading…
Add table
Reference in a new issue