mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-05 06:33:57 +02:00
Custom context menu for saved-tags reactions.
This commit is contained in:
parent
d1a0dfbb97
commit
3c6037a798
6 changed files with 75 additions and 4 deletions
|
@ -2749,7 +2749,9 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
"lng_context_seen_reacted#other" = "{count} Reacted";
|
"lng_context_seen_reacted#other" = "{count} Reacted";
|
||||||
"lng_context_seen_reacted_none" = "Nobody Reacted";
|
"lng_context_seen_reacted_none" = "Nobody Reacted";
|
||||||
"lng_context_seen_reacted_all" = "Show All Reactions";
|
"lng_context_seen_reacted_all" = "Show All Reactions";
|
||||||
"lng_context_set_as_quick" = "Set As Quick";
|
"lng_context_set_as_quick" = "Set as Quick";
|
||||||
|
"lng_context_filter_by_tag" = "Filter by Tag";
|
||||||
|
"lng_context_remove_tag" = "Remove Tag";
|
||||||
"lng_context_delete_from_disk" = "Delete from disk";
|
"lng_context_delete_from_disk" = "Delete from disk";
|
||||||
"lng_context_delete_all_files" = "Delete all files";
|
"lng_context_delete_all_files" = "Delete all files";
|
||||||
"lng_context_save_custom_sound" = "Save for notifications";
|
"lng_context_save_custom_sound" = "Save for notifications";
|
||||||
|
|
|
@ -179,6 +179,7 @@ PossibleItemReactionsRef LookupPossibleReactions(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
result.customAllowed = premiumPossible;
|
result.customAllowed = premiumPossible;
|
||||||
|
result.tags = true;
|
||||||
} else if (limited) {
|
} else if (limited) {
|
||||||
result.recent.reserve(all.size());
|
result.recent.reserve(all.size());
|
||||||
add([&](const Reaction &reaction) {
|
add([&](const Reaction &reaction) {
|
||||||
|
@ -243,11 +244,12 @@ PossibleItemReactionsRef LookupPossibleReactions(
|
||||||
|
|
||||||
PossibleItemReactions::PossibleItemReactions(
|
PossibleItemReactions::PossibleItemReactions(
|
||||||
const PossibleItemReactionsRef &other)
|
const PossibleItemReactionsRef &other)
|
||||||
: recent(other.recent | ranges::views::transform([](const auto &value) {
|
: recent(other.recent | ranges::views::transform([](const auto &value) {
|
||||||
return *value;
|
return *value;
|
||||||
}) | ranges::to_vector)
|
}) | ranges::to_vector)
|
||||||
, morePremiumAvailable(other.morePremiumAvailable)
|
, morePremiumAvailable(other.morePremiumAvailable)
|
||||||
, customAllowed(other.customAllowed) {
|
, customAllowed(other.customAllowed)
|
||||||
|
, tags(other.tags){
|
||||||
}
|
}
|
||||||
|
|
||||||
Reactions::Reactions(not_null<Session*> owner)
|
Reactions::Reactions(not_null<Session*> owner)
|
||||||
|
|
|
@ -42,6 +42,7 @@ struct PossibleItemReactionsRef {
|
||||||
std::vector<not_null<const Reaction*>> recent;
|
std::vector<not_null<const Reaction*>> recent;
|
||||||
bool morePremiumAvailable = false;
|
bool morePremiumAvailable = false;
|
||||||
bool customAllowed = false;
|
bool customAllowed = false;
|
||||||
|
bool tags = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct PossibleItemReactions {
|
struct PossibleItemReactions {
|
||||||
|
@ -51,6 +52,7 @@ struct PossibleItemReactions {
|
||||||
std::vector<Reaction> recent;
|
std::vector<Reaction> recent;
|
||||||
bool morePremiumAvailable = false;
|
bool morePremiumAvailable = false;
|
||||||
bool customAllowed = false;
|
bool customAllowed = false;
|
||||||
|
bool tags = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
[[nodiscard]] PossibleItemReactionsRef LookupPossibleReactions(
|
[[nodiscard]] PossibleItemReactionsRef LookupPossibleReactions(
|
||||||
|
|
|
@ -26,6 +26,8 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "history/view/media/history_view_web_page.h"
|
#include "history/view/media/history_view_web_page.h"
|
||||||
#include "history/view/reactions/history_view_reactions_list.h"
|
#include "history/view/reactions/history_view_reactions_list.h"
|
||||||
#include "ui/widgets/popup_menu.h"
|
#include "ui/widgets/popup_menu.h"
|
||||||
|
#include "ui/widgets/menu/menu_action.h"
|
||||||
|
#include "ui/widgets/menu/menu_common.h"
|
||||||
#include "ui/widgets/menu/menu_multiline_action.h"
|
#include "ui/widgets/menu/menu_multiline_action.h"
|
||||||
#include "ui/image/image.h"
|
#include "ui/image/image.h"
|
||||||
#include "ui/toast/toast.h"
|
#include "ui/toast/toast.h"
|
||||||
|
@ -1293,6 +1295,62 @@ void AddWhoReactedAction(
|
||||||
showAllChosen));
|
showAllChosen));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ShowTagMenu(
|
||||||
|
not_null<base::unique_qptr<Ui::PopupMenu>*> menu,
|
||||||
|
QPoint position,
|
||||||
|
not_null<QWidget*> context,
|
||||||
|
not_null<HistoryItem*> item,
|
||||||
|
const Data::ReactionId &id,
|
||||||
|
not_null<Window::SessionController*> controller) {
|
||||||
|
using namespace Data;
|
||||||
|
const auto itemId = item->fullId();
|
||||||
|
const auto owner = &controller->session().data();
|
||||||
|
*menu = base::make_unique_q<Ui::PopupMenu>(
|
||||||
|
context,
|
||||||
|
st::popupMenuExpandedSeparator);
|
||||||
|
(*menu)->addAction(tr::lng_context_filter_by_tag(tr::now), [=] {
|
||||||
|
HashtagClickHandler(SearchTagToQuery(id)).onClick({
|
||||||
|
.button = Qt::LeftButton,
|
||||||
|
.other = QVariant::fromValue(ClickHandlerContext{
|
||||||
|
.sessionWindow = controller,
|
||||||
|
}),
|
||||||
|
});
|
||||||
|
}, &st::menuIconFave);
|
||||||
|
|
||||||
|
const auto removeTag = [=] {
|
||||||
|
if (const auto item = owner->message(itemId)) {
|
||||||
|
const auto &list = item->reactions();
|
||||||
|
if (ranges::contains(list, id, &MessageReaction::id)) {
|
||||||
|
item->toggleReaction(
|
||||||
|
id,
|
||||||
|
HistoryItem::ReactionSource::Quick);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
(*menu)->addAction(base::make_unique_q<Ui::Menu::Action>(
|
||||||
|
(*menu)->menu(),
|
||||||
|
st::menuWithIconsAttention,
|
||||||
|
Ui::Menu::CreateAction(
|
||||||
|
(*menu)->menu(),
|
||||||
|
tr::lng_context_remove_tag(tr::now),
|
||||||
|
removeTag),
|
||||||
|
&st::menuIconDisableAttention,
|
||||||
|
&st::menuIconDisableAttention));
|
||||||
|
|
||||||
|
if (const auto custom = id.custom()) {
|
||||||
|
if (const auto set = owner->document(custom)->sticker()) {
|
||||||
|
if (set->set.id) {
|
||||||
|
AddEmojiPacksAction(
|
||||||
|
menu->get(),
|
||||||
|
{ set->set },
|
||||||
|
EmojiPacksSource::Reaction,
|
||||||
|
controller);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
(*menu)->popup(position);
|
||||||
|
}
|
||||||
|
|
||||||
void ShowWhoReactedMenu(
|
void ShowWhoReactedMenu(
|
||||||
not_null<base::unique_qptr<Ui::PopupMenu>*> menu,
|
not_null<base::unique_qptr<Ui::PopupMenu>*> menu,
|
||||||
QPoint position,
|
QPoint position,
|
||||||
|
@ -1301,6 +1359,11 @@ void ShowWhoReactedMenu(
|
||||||
const Data::ReactionId &id,
|
const Data::ReactionId &id,
|
||||||
not_null<Window::SessionController*> controller,
|
not_null<Window::SessionController*> controller,
|
||||||
rpl::lifetime &lifetime) {
|
rpl::lifetime &lifetime) {
|
||||||
|
if (item->reactionsAreTags()) {
|
||||||
|
ShowTagMenu(menu, position, context, item, id, controller);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
struct State {
|
struct State {
|
||||||
int addedToBottom = 0;
|
int addedToBottom = 0;
|
||||||
};
|
};
|
||||||
|
|
|
@ -451,6 +451,7 @@ void Manager::applyList(const Data::PossibleItemReactionsRef &reactions) {
|
||||||
: reactions.morePremiumAvailable
|
: reactions.morePremiumAvailable
|
||||||
? Button::Premium
|
? Button::Premium
|
||||||
: */Button::None));
|
: */Button::None));
|
||||||
|
_tagsStrip = reactions.tags;
|
||||||
}
|
}
|
||||||
|
|
||||||
QMargins Manager::innerMargins() const {
|
QMargins Manager::innerMargins() const {
|
||||||
|
@ -814,7 +815,7 @@ bool Manager::showContextMenu(
|
||||||
const ReactionId &favorite) {
|
const ReactionId &favorite) {
|
||||||
const auto selected = _strip.selected();
|
const auto selected = _strip.selected();
|
||||||
const auto id = std::get_if<ReactionId>(&selected);
|
const auto id = std::get_if<ReactionId>(&selected);
|
||||||
if (!id || id->empty()) {
|
if (!id || id->empty() || _tagsStrip) {
|
||||||
return false;
|
return false;
|
||||||
} else if (*id == favorite) {
|
} else if (*id == favorite) {
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -235,6 +235,7 @@ private:
|
||||||
|
|
||||||
rpl::variable<int> _uniqueLimit = 0;
|
rpl::variable<int> _uniqueLimit = 0;
|
||||||
bool _showingAll = false;
|
bool _showingAll = false;
|
||||||
|
bool _tagsStrip = false;
|
||||||
|
|
||||||
std::optional<ButtonParameters> _scheduledParameters;
|
std::optional<ButtonParameters> _scheduledParameters;
|
||||||
base::Timer _buttonShowTimer;
|
base::Timer _buttonShowTimer;
|
||||||
|
|
Loading…
Add table
Reference in a new issue