[Improvement] Show group manage buttons in profile
This commit is contained in:
parent
7d0daf1e3c
commit
6d5d2059e4
14 changed files with 211 additions and 2 deletions
BIN
Telegram/Resources/icons/info/edit/group_manage_permissions.png
Normal file
BIN
Telegram/Resources/icons/info/edit/group_manage_permissions.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 677 B |
Binary file not shown.
|
After Width: | Height: | Size: 1.4 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 1.9 KiB |
BIN
Telegram/Resources/icons/info/info_blacklist.png
Normal file
BIN
Telegram/Resources/icons/info/info_blacklist.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 457 B |
BIN
Telegram/Resources/icons/info/info_blacklist@2x.png
Normal file
BIN
Telegram/Resources/icons/info/info_blacklist@2x.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 991 B |
BIN
Telegram/Resources/icons/info/info_blacklist@3x.png
Normal file
BIN
Telegram/Resources/icons/info/info_blacklist@3x.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.4 KiB |
|
|
@ -193,6 +193,8 @@ void SaveSlowmodeSeconds(
|
|||
api->registerModifyRequest(key, requestId);
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
void ShowEditPermissions(
|
||||
not_null<Window::SessionNavigation*> navigation,
|
||||
not_null<PeerData*> peer) {
|
||||
|
|
@ -238,8 +240,6 @@ void ShowEditPermissions(
|
|||
}, box->lifetime());
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
namespace {
|
||||
|
||||
class Controller : public base::has_weak_ptr {
|
||||
|
|
|
|||
|
|
@ -26,6 +26,13 @@ class VerticalLayout;
|
|||
class SettingsButton;
|
||||
} // namespace Ui
|
||||
|
||||
void ShowEditPermissions(
|
||||
not_null<Window::SessionNavigation*> navigation,
|
||||
not_null<PeerData*> peer);
|
||||
void ShowEditInviteLinks(
|
||||
not_null<Window::SessionNavigation*> navigation,
|
||||
not_null<PeerData*> peer);
|
||||
|
||||
class EditPeerInfoBox : public Ui::BoxContent {
|
||||
public:
|
||||
EditPeerInfoBox(
|
||||
|
|
|
|||
|
|
@ -356,6 +356,8 @@ infoIconMediaLink: icon {{ "info/info_media_link", infoIconFg }};
|
|||
infoIconMediaGroup: icon {{ "info/info_common_groups", infoIconFg }};
|
||||
infoIconMediaVoice: icon {{ "info/info_media_voice", infoIconFg }};
|
||||
infoIconMediaRound: icon {{ "info/info_media_round", infoIconFg }};
|
||||
infoIconBlacklist: icon {{ "info/info_blacklist", settingsIconFg }};
|
||||
infoIconPermissions: icon {{ "info/edit/group_manage_permissions", settingsIconFg }};
|
||||
|
||||
infoRoundedIconRequests: icon {{ "info/edit/group_manage_join_requests", settingsIconFg }};
|
||||
infoRoundedIconRecentActions: icon {{ "info/edit/group_manage_actions", settingsIconFg }};
|
||||
|
|
|
|||
|
|
@ -31,6 +31,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
#include "ui/text/format_values.h" // Ui::FormatPhone
|
||||
#include "history/history_location_manager.h" // LocationClickHandler.
|
||||
#include "history/view/history_view_context_menu.h" // HistoryView::ShowReportPeerBox
|
||||
#include "history/admin_log/history_admin_log_section.h"
|
||||
#include "boxes/abstract_box.h"
|
||||
#include "ui/boxes/confirm_box.h"
|
||||
#include "boxes/peer_list_box.h"
|
||||
|
|
@ -38,6 +39,9 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
#include "boxes/add_contact_box.h"
|
||||
#include "boxes/peers/add_bot_to_chat_box.h"
|
||||
#include "boxes/peers/edit_contact_box.h"
|
||||
#include "boxes/peers/edit_peer_info_box.h"
|
||||
#include "boxes/peers/edit_peer_invite_links.h"
|
||||
#include "boxes/peers/edit_participants_box.h"
|
||||
#include "boxes/report_messages_box.h"
|
||||
#include "lang/lang_keys.h"
|
||||
#include "menu/menu_mute.h"
|
||||
|
|
@ -196,6 +200,31 @@ private:
|
|||
|
||||
};
|
||||
|
||||
class ManageFiller {
|
||||
public:
|
||||
ManageFiller(
|
||||
not_null<Controller*> controller,
|
||||
not_null<Ui::RpWidget*> parent,
|
||||
not_null<PeerData*> peer);
|
||||
|
||||
object_ptr<Ui::RpWidget> fill();
|
||||
|
||||
private:
|
||||
void addPeerPermissions(not_null<PeerData*> peer);
|
||||
void addPeerAdmins(not_null<PeerData*> peer);
|
||||
void addPeerInviteLinks(not_null<PeerData*> peer);
|
||||
void addChannelBlockedUsers(not_null<ChannelData*> channel);
|
||||
void addChannelRecentActions(not_null<ChannelData*> channel);
|
||||
|
||||
void fillChatActions(not_null<ChatData*> chat);
|
||||
void fillChannelActions(not_null<ChannelData*> channel);
|
||||
|
||||
not_null<Controller*> _controller;
|
||||
not_null<Ui::RpWidget*> _parent;
|
||||
not_null<PeerData*> _peer;
|
||||
object_ptr<Ui::VerticalLayout> _wrap = { nullptr };
|
||||
};
|
||||
|
||||
DetailsFiller::DetailsFiller(
|
||||
not_null<Controller*> controller,
|
||||
not_null<Ui::RpWidget*> parent,
|
||||
|
|
@ -917,6 +946,153 @@ object_ptr<Ui::RpWidget> ActionsFiller::fill() {
|
|||
return { nullptr };
|
||||
}
|
||||
|
||||
ManageFiller::ManageFiller(
|
||||
not_null<Controller*> controller,
|
||||
not_null<Ui::RpWidget*> parent,
|
||||
not_null<PeerData*> peer)
|
||||
: _controller(controller)
|
||||
, _parent(parent)
|
||||
, _peer(peer) {
|
||||
}
|
||||
|
||||
void ManageFiller::addPeerPermissions(
|
||||
not_null<PeerData*> peer) {
|
||||
if (peer->isUser() || (peer->isChannel() && !peer->isMegagroup())) return;
|
||||
|
||||
const auto canEditPermissions = [&] {
|
||||
return peer->isChannel()
|
||||
? peer->asChannel()->canEditPermissions()
|
||||
: peer->asChat()->canEditPermissions();
|
||||
}();
|
||||
|
||||
if (canEditPermissions) {
|
||||
const auto controller = _controller;
|
||||
auto button = AddActionButton(
|
||||
_wrap,
|
||||
tr::lng_manage_peer_permissions(),
|
||||
rpl::single(true),
|
||||
[=] { ShowEditPermissions(controller->parentController(), peer); },
|
||||
&st::infoIconPermissions);
|
||||
}
|
||||
}
|
||||
|
||||
void ManageFiller::addPeerAdmins(
|
||||
not_null<PeerData*> peer) {
|
||||
if (peer->isUser()) return;
|
||||
|
||||
const auto canViewAdmins = [&] {
|
||||
return peer->isChannel()
|
||||
? peer->asChannel()->canViewAdmins()
|
||||
: peer->asChat()->amIn();
|
||||
}();
|
||||
if (canViewAdmins) {
|
||||
const auto controller = _controller;
|
||||
auto button = AddActionButton(
|
||||
_wrap,
|
||||
tr::lng_manage_peer_administrators(),
|
||||
rpl::single(true),
|
||||
[=] { ParticipantsBoxController::Start(
|
||||
controller->parentController(),
|
||||
peer,
|
||||
ParticipantsBoxController::Role::Admins);},
|
||||
&st::infoRoundedIconAdministrators);
|
||||
}
|
||||
}
|
||||
|
||||
void ManageFiller::addPeerInviteLinks(
|
||||
not_null<PeerData*> peer) {
|
||||
if (peer->isUser()) return;
|
||||
|
||||
const auto canHaveInviteLink = [&] {
|
||||
return peer->isChannel()
|
||||
? peer->asChannel()->canHaveInviteLink()
|
||||
: peer->asChat()->canHaveInviteLink();
|
||||
}();
|
||||
if (canHaveInviteLink) {
|
||||
auto button = AddActionButton(
|
||||
_wrap,
|
||||
tr::lng_manage_peer_invite_links(),
|
||||
rpl::single(true),
|
||||
[=] {
|
||||
Ui::show(Box(ManageInviteLinksBox, peer, peer->session().user(), 0, 0),
|
||||
Ui::LayerOption::KeepOther);
|
||||
},
|
||||
&st::infoRoundedIconInviteLinks);
|
||||
}
|
||||
}
|
||||
|
||||
void ManageFiller::addChannelBlockedUsers(
|
||||
not_null<ChannelData*> channel) {
|
||||
if (channel->hasAdminRights() || channel->amCreator()) {
|
||||
const auto controller = _controller;
|
||||
auto button = AddActionButton(
|
||||
_wrap,
|
||||
tr::lng_manage_peer_removed_users(),
|
||||
rpl::single(true),
|
||||
[=] { ParticipantsBoxController::Start(
|
||||
controller->parentController(),
|
||||
channel,
|
||||
ParticipantsBoxController::Role::Kicked);},
|
||||
&st::infoIconBlacklist);
|
||||
}
|
||||
}
|
||||
|
||||
void ManageFiller::addChannelRecentActions(
|
||||
not_null<ChannelData*> channel) {
|
||||
if (channel->hasAdminRights() || channel->amCreator()) {
|
||||
const auto controller = _controller;
|
||||
auto button = AddActionButton(
|
||||
_wrap,
|
||||
tr::lng_manage_peer_recent_actions(),
|
||||
rpl::single(true),
|
||||
[=] {
|
||||
if (!App::main()->areRecentActionsOpened()) {
|
||||
controller->showSection(
|
||||
std::make_shared<AdminLog::SectionMemento>(channel));
|
||||
}
|
||||
},
|
||||
&st::infoRoundedIconRecentActions);
|
||||
}
|
||||
}
|
||||
|
||||
void ManageFiller::fillChatActions(
|
||||
not_null<ChatData*> chat) {
|
||||
addPeerPermissions(chat);
|
||||
addPeerAdmins(chat);
|
||||
addPeerInviteLinks(chat);
|
||||
}
|
||||
|
||||
void ManageFiller::fillChannelActions(
|
||||
not_null<ChannelData*> channel) {
|
||||
addPeerPermissions(channel);
|
||||
addPeerAdmins(channel);
|
||||
addPeerInviteLinks(channel);
|
||||
addChannelBlockedUsers(channel);
|
||||
addChannelRecentActions(channel);
|
||||
}
|
||||
|
||||
object_ptr<Ui::RpWidget> ManageFiller::fill() {
|
||||
auto wrapResult = [=](auto &&callback) {
|
||||
_wrap = object_ptr<Ui::VerticalLayout>(_parent);
|
||||
_wrap->add(CreateSkipWidget(_wrap));
|
||||
callback();
|
||||
_wrap->add(CreateSkipWidget(_wrap));
|
||||
return std::move(_wrap);
|
||||
};
|
||||
if (auto chat = _peer->asChat()) {
|
||||
return wrapResult([=] {
|
||||
fillChatActions(chat);
|
||||
});
|
||||
} else if (auto channel = _peer->asChannel()) {
|
||||
if (channel->isMegagroup() || channel->hasAdminRights() || channel->amCreator()) {
|
||||
return wrapResult([=] {
|
||||
fillChannelActions(channel);
|
||||
});
|
||||
}
|
||||
}
|
||||
return { nullptr };
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
object_ptr<Ui::RpWidget> SetupDetails(
|
||||
|
|
@ -927,6 +1103,14 @@ object_ptr<Ui::RpWidget> SetupDetails(
|
|||
return filler.fill();
|
||||
}
|
||||
|
||||
object_ptr<Ui::RpWidget> SetupManage(
|
||||
not_null<Controller*> controller,
|
||||
not_null<Ui::RpWidget*> parent,
|
||||
not_null<PeerData*> peer) {
|
||||
ManageFiller filler(controller, parent, peer);
|
||||
return filler.fill();
|
||||
}
|
||||
|
||||
object_ptr<Ui::RpWidget> SetupActions(
|
||||
not_null<Controller*> controller,
|
||||
not_null<Ui::RpWidget*> parent,
|
||||
|
|
|
|||
|
|
@ -24,6 +24,11 @@ object_ptr<Ui::RpWidget> SetupDetails(
|
|||
not_null<Ui::RpWidget*> parent,
|
||||
not_null<PeerData*> peer);
|
||||
|
||||
object_ptr<Ui::RpWidget> SetupManage(
|
||||
not_null<Controller*> controller,
|
||||
not_null<Ui::RpWidget*> parent,
|
||||
not_null<PeerData*> peer);
|
||||
|
||||
object_ptr<Ui::RpWidget> SetupActions(
|
||||
not_null<Controller*> controller,
|
||||
not_null<Ui::RpWidget*> parent,
|
||||
|
|
|
|||
|
|
@ -76,6 +76,10 @@ object_ptr<Ui::RpWidget> InnerWidget::setupContent(
|
|||
_cover->setOnlineCount(rpl::single(0));
|
||||
auto details = SetupDetails(_controller, parent, _peer);
|
||||
result->add(std::move(details));
|
||||
if (auto manage = SetupManage(_controller, result.data(), _peer)) {
|
||||
result->add(object_ptr<Ui::BoxContentDivider>(result));
|
||||
result->add(std::move(manage));
|
||||
}
|
||||
result->add(setupSharedMedia(result.data()));
|
||||
if (auto members = SetupChannelMembers(_controller, result.data(), _peer)) {
|
||||
result->add(std::move(members));
|
||||
|
|
|
|||
|
|
@ -62,6 +62,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
#include "history/history.h"
|
||||
#include "history/history_widget.h"
|
||||
#include "history/history_message.h"
|
||||
#include "history/admin_log/history_admin_log_section.h"
|
||||
#include "history/view/media/history_view_media.h"
|
||||
#include "history/view/history_view_service_message.h"
|
||||
#include "history/view/history_view_element.h"
|
||||
|
|
@ -1831,6 +1832,11 @@ bool MainWidget::preventsCloseSection(
|
|||
: preventsCloseSection(std::move(callback));
|
||||
}
|
||||
|
||||
bool MainWidget::areRecentActionsOpened() {
|
||||
return _mainSection
|
||||
&& static_cast<AdminLog::Widget*>(_mainSection.data());
|
||||
}
|
||||
|
||||
void MainWidget::showBackFromStack(
|
||||
const SectionShow ¶ms) {
|
||||
|
||||
|
|
|
|||
|
|
@ -233,6 +233,7 @@ public:
|
|||
Fn<void()> callback,
|
||||
const SectionShow ¶ms) const;
|
||||
|
||||
bool areRecentActionsOpened();
|
||||
void dialogsCancelled();
|
||||
|
||||
protected:
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue