mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2026-07-25 06:54:43 +00:00
Added ability to open full checked moderate box from left userpic menu.
This commit is contained in:
@@ -4864,6 +4864,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||||||
"lng_context_edit_permissions" = "Edit admin rights";
|
"lng_context_edit_permissions" = "Edit admin rights";
|
||||||
"lng_context_restrict_user" = "Restrict user";
|
"lng_context_restrict_user" = "Restrict user";
|
||||||
"lng_context_ban_user" = "Ban";
|
"lng_context_ban_user" = "Ban";
|
||||||
|
"lng_context_delete_and_ban" = "Delete and ban";
|
||||||
"lng_context_remove_from_group" = "Remove from group";
|
"lng_context_remove_from_group" = "Remove from group";
|
||||||
"lng_context_add_to_group" = "Add to group";
|
"lng_context_add_to_group" = "Add to group";
|
||||||
|
|
||||||
|
|||||||
@@ -2459,6 +2459,27 @@ void HistoryInner::showContextMenu(QContextMenuEvent *e, bool showFromTouch) {
|
|||||||
_widget->fillSenderUserpicMenu(
|
_widget->fillSenderUserpicMenu(
|
||||||
_menu.get(),
|
_menu.get(),
|
||||||
session->data().peer(PeerId(linkUserpicPeerId)));
|
session->data().peer(PeerId(linkUserpicPeerId)));
|
||||||
|
Window::AddSenderUserpicModerateAction(
|
||||||
|
_controller,
|
||||||
|
[&] {
|
||||||
|
auto moderateItem = _dragStateItem;
|
||||||
|
const auto contextY = mapFromGlobal(e->globalPos()).y();
|
||||||
|
enumerateItems<EnumItemsDirection::TopToBottom>(
|
||||||
|
[&](not_null<Element*> view, int top, int bottom) {
|
||||||
|
if (bottom <= contextY) {
|
||||||
|
return true;
|
||||||
|
} else if (top > contextY) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
const auto item = view->data();
|
||||||
|
if (item->from()->id == PeerId(linkUserpicPeerId)) {
|
||||||
|
moderateItem = item;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
});
|
||||||
|
return moderateItem;
|
||||||
|
}(),
|
||||||
|
Ui::Menu::CreateAddActionCallback(_menu.get()));
|
||||||
if (_menu->empty()) {
|
if (_menu->empty()) {
|
||||||
_menu = nullptr;
|
_menu = nullptr;
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -46,6 +46,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||||||
#include "window/window_peer_menu.h"
|
#include "window/window_peer_menu.h"
|
||||||
#include "main/main_session.h"
|
#include "main/main_session.h"
|
||||||
#include "ui/layers/generic_box.h"
|
#include "ui/layers/generic_box.h"
|
||||||
|
#include "ui/widgets/menu/menu_add_action_callback_factory.h"
|
||||||
#include "ui/widgets/popup_menu.h"
|
#include "ui/widgets/popup_menu.h"
|
||||||
#include "ui/widgets/scroll_area.h"
|
#include "ui/widgets/scroll_area.h"
|
||||||
#include "ui/toast/toast.h"
|
#include "ui/toast/toast.h"
|
||||||
@@ -2914,6 +2915,15 @@ void ListWidget::showContextMenu(QContextMenuEvent *e, bool showFromTouch) {
|
|||||||
} else if (linkUserpicPeerId) {
|
} else if (linkUserpicPeerId) {
|
||||||
_menu = _delegate->listFillSenderUserpicMenu(linkUserpicPeerId);
|
_menu = _delegate->listFillSenderUserpicMenu(linkUserpicPeerId);
|
||||||
if (_menu) {
|
if (_menu) {
|
||||||
|
Window::AddSenderUserpicModerateAction(
|
||||||
|
controller(),
|
||||||
|
[&] {
|
||||||
|
const auto contextY = _visibleTop
|
||||||
|
+ mapFromGlobal(e->globalPos()).y();
|
||||||
|
const auto contextView = strictFindItemByY(contextY);
|
||||||
|
return contextView ? contextView->data().get() : overItem;
|
||||||
|
}(),
|
||||||
|
Ui::Menu::CreateAddActionCallback(_menu.get()));
|
||||||
_menu->popup(e->globalPos());
|
_menu->popup(e->globalPos());
|
||||||
e->accept();
|
e->accept();
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -3798,6 +3798,44 @@ void FillSenderUserpicMenu(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void AddSenderUserpicModerateAction(
|
||||||
|
not_null<SessionController*> controller,
|
||||||
|
HistoryItem *moderateItem,
|
||||||
|
const PeerMenuCallback &addAction) {
|
||||||
|
const auto moderateChannel = moderateItem
|
||||||
|
? moderateItem->history()->peer->asChannel()
|
||||||
|
: nullptr;
|
||||||
|
const auto moderateUser = moderateItem
|
||||||
|
? moderateItem->from()->asUser()
|
||||||
|
: nullptr;
|
||||||
|
const auto canDeleteAndBan = moderateItem
|
||||||
|
&& moderateChannel
|
||||||
|
&& moderateChannel->isMegagroup()
|
||||||
|
&& moderateUser
|
||||||
|
&& !moderateChannel->isGroupAdmin(moderateUser)
|
||||||
|
&& moderateItem->suggestBanReport()
|
||||||
|
&& moderateItem->suggestDeleteAllReport();
|
||||||
|
if (canDeleteAndBan) {
|
||||||
|
addAction({ .isSeparator = true });
|
||||||
|
addAction({
|
||||||
|
.text = tr::lng_context_delete_and_ban(tr::now),
|
||||||
|
.handler = [=] {
|
||||||
|
controller->show(Box(
|
||||||
|
CreateModerateMessagesBox,
|
||||||
|
HistoryItemsList{ not_null<HistoryItem*>(moderateItem) },
|
||||||
|
nullptr,
|
||||||
|
ModerateMessagesBoxOptions{
|
||||||
|
.reportSpam = true,
|
||||||
|
.deleteAll = true,
|
||||||
|
.banUser = true,
|
||||||
|
}));
|
||||||
|
},
|
||||||
|
.icon = &st::menuIconBlockAttention,
|
||||||
|
.isAttention = true,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
bool IsUnreadThread(not_null<Data::Thread*> thread) {
|
bool IsUnreadThread(not_null<Data::Thread*> thread) {
|
||||||
return thread->chatListBadgesState().unread;
|
return thread->chatListBadgesState().unread;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||||||
#include "ui/widgets/menu/menu_add_action_callback.h"
|
#include "ui/widgets/menu/menu_add_action_callback.h"
|
||||||
|
|
||||||
class History;
|
class History;
|
||||||
|
class HistoryItem;
|
||||||
|
|
||||||
namespace Api {
|
namespace Api {
|
||||||
struct SendOptions;
|
struct SendOptions;
|
||||||
@@ -84,6 +85,11 @@ void FillSenderUserpicMenu(
|
|||||||
Dialogs::Key searchInEntry,
|
Dialogs::Key searchInEntry,
|
||||||
const PeerMenuCallback &addAction);
|
const PeerMenuCallback &addAction);
|
||||||
|
|
||||||
|
void AddSenderUserpicModerateAction(
|
||||||
|
not_null<SessionController*> controller,
|
||||||
|
HistoryItem *moderateItem,
|
||||||
|
const PeerMenuCallback &addAction);
|
||||||
|
|
||||||
void MenuAddMarkAsReadAllChatsAction(
|
void MenuAddMarkAsReadAllChatsAction(
|
||||||
not_null<Main::Session*> session,
|
not_null<Main::Session*> session,
|
||||||
std::shared_ptr<Ui::Show> show,
|
std::shared_ptr<Ui::Show> show,
|
||||||
|
|||||||
Reference in New Issue
Block a user