mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-05 06:33:57 +02:00
Replaced AdminLog::FilterBox with GenericBox.
This commit is contained in:
parent
8011adb219
commit
c6ea91e671
3 changed files with 103 additions and 1 deletions
|
@ -10,6 +10,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "boxes/peers/edit_peer_permissions_box.h"
|
#include "boxes/peers/edit_peer_permissions_box.h"
|
||||||
#include "history/admin_log/history_admin_log_filter_value.h"
|
#include "history/admin_log/history_admin_log_filter_value.h"
|
||||||
#include "lang/lang_keys.h"
|
#include "lang/lang_keys.h"
|
||||||
|
#include "ui/wrap/vertical_layout.h"
|
||||||
|
|
||||||
namespace AdminLog {
|
namespace AdminLog {
|
||||||
|
|
||||||
|
@ -85,4 +86,17 @@ EditFlagsDescriptor<FilterValue::Flags> FilterValueLabels(bool isChannel) {
|
||||||
}, .st = nullptr };
|
}, .st = nullptr };
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Fn<FilterValue::Flags()> FillFilterValueList(
|
||||||
|
not_null<Ui::VerticalLayout*> container,
|
||||||
|
bool isChannel,
|
||||||
|
const FilterValue &filter) {
|
||||||
|
auto [checkboxes, getResult, changes] = CreateEditAdminLogFilter(
|
||||||
|
container,
|
||||||
|
filter.flags ? (*filter.flags) : ~FilterValue::Flags(0),
|
||||||
|
isChannel);
|
||||||
|
const auto controlsRaw = checkboxes.data();
|
||||||
|
container->add(std::move(checkboxes));
|
||||||
|
return getResult;
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace AdminLog
|
} // namespace AdminLog
|
||||||
|
|
|
@ -13,10 +13,19 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
template <typename Flags>
|
template <typename Flags>
|
||||||
struct EditFlagsDescriptor;
|
struct EditFlagsDescriptor;
|
||||||
|
|
||||||
|
namespace Ui {
|
||||||
|
class VerticalLayout;
|
||||||
|
} // namespace Ui
|
||||||
|
|
||||||
namespace AdminLog {
|
namespace AdminLog {
|
||||||
|
|
||||||
struct FilterValue;
|
struct FilterValue;
|
||||||
|
|
||||||
|
[[nodiscard]] Fn<FilterValue::Flags()> FillFilterValueList(
|
||||||
|
not_null<Ui::VerticalLayout*> container,
|
||||||
|
bool isChannel,
|
||||||
|
const FilterValue &filter);
|
||||||
|
|
||||||
EditFlagsDescriptor<FilterValue::Flags> FilterValueLabels(bool isChannel);
|
EditFlagsDescriptor<FilterValue::Flags> FilterValueLabels(bool isChannel);
|
||||||
|
|
||||||
} // namespace AdminLog
|
} // namespace AdminLog
|
||||||
|
|
|
@ -37,11 +37,14 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "main/main_session_settings.h"
|
#include "main/main_session_settings.h"
|
||||||
#include "ui/chat/chat_theme.h"
|
#include "ui/chat/chat_theme.h"
|
||||||
#include "ui/chat/chat_style.h"
|
#include "ui/chat/chat_style.h"
|
||||||
|
#include "ui/widgets/checkbox.h"
|
||||||
|
#include "ui/widgets/expandable_peer_list.h"
|
||||||
#include "ui/widgets/popup_menu.h"
|
#include "ui/widgets/popup_menu.h"
|
||||||
#include "ui/image/image.h"
|
#include "ui/image/image.h"
|
||||||
#include "ui/text/text_utilities.h"
|
#include "ui/text/text_utilities.h"
|
||||||
#include "ui/inactive_press.h"
|
#include "ui/inactive_press.h"
|
||||||
#include "ui/painter.h"
|
#include "ui/painter.h"
|
||||||
|
#include "ui/vertical_list.h"
|
||||||
#include "ui/effects/path_shift_gradient.h"
|
#include "ui/effects/path_shift_gradient.h"
|
||||||
#include "core/click_handler_types.h"
|
#include "core/click_handler_types.h"
|
||||||
#include "core/file_utilities.h"
|
#include "core/file_utilities.h"
|
||||||
|
@ -59,6 +62,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "data/data_channel.h"
|
#include "data/data_channel.h"
|
||||||
#include "data/data_user.h"
|
#include "data/data_user.h"
|
||||||
#include "styles/style_chat.h"
|
#include "styles/style_chat.h"
|
||||||
|
#include "styles/style_layers.h"
|
||||||
#include "styles/style_menu_icons.h"
|
#include "styles/style_menu_icons.h"
|
||||||
|
|
||||||
#include <QtWidgets/QApplication>
|
#include <QtWidgets/QApplication>
|
||||||
|
@ -496,8 +500,83 @@ void InnerWidget::requestAdmins() {
|
||||||
void InnerWidget::showFilter(Fn<void(FilterValue &&filter)> callback) {
|
void InnerWidget::showFilter(Fn<void(FilterValue &&filter)> callback) {
|
||||||
if (_admins.empty()) {
|
if (_admins.empty()) {
|
||||||
_showFilterCallback = std::move(callback);
|
_showFilterCallback = std::move(callback);
|
||||||
} else {
|
return;
|
||||||
}
|
}
|
||||||
|
const auto isChannel = !_channel->isMegagroup();
|
||||||
|
const auto filter = _filter;
|
||||||
|
const auto admins = _admins;
|
||||||
|
_controller->uiShow()->show(Box([=](not_null<Ui::GenericBox*> box) {
|
||||||
|
box->setTitle(tr::lng_manage_peer_recent_actions());
|
||||||
|
Ui::AddSubsectionTitle(
|
||||||
|
box->verticalLayout(),
|
||||||
|
tr::lng_admin_log_filter_actions_type_subtitle());
|
||||||
|
const auto collectFlags = FillFilterValueList(
|
||||||
|
box->verticalLayout(),
|
||||||
|
isChannel,
|
||||||
|
filter);
|
||||||
|
Ui::AddSkip(box->verticalLayout());
|
||||||
|
Ui::AddDivider(box->verticalLayout());
|
||||||
|
Ui::AddSkip(box->verticalLayout());
|
||||||
|
Ui::AddSubsectionTitle(
|
||||||
|
box->verticalLayout(),
|
||||||
|
tr::lng_admin_log_filter_actions_admins_subtitle());
|
||||||
|
Ui::AddSkip(box->verticalLayout());
|
||||||
|
|
||||||
|
auto checkedPeerId = std::vector<PeerId>();
|
||||||
|
{
|
||||||
|
checkedPeerId.reserve(admins.size());
|
||||||
|
for (const auto &user : admins) {
|
||||||
|
if (!filter.admins
|
||||||
|
|| ranges::contains(
|
||||||
|
(*filter.admins),
|
||||||
|
user->id,
|
||||||
|
&UserData::id)) {
|
||||||
|
checkedPeerId.push_back(user->id);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const auto checkbox = box->addRow(
|
||||||
|
object_ptr<Ui::Checkbox>(
|
||||||
|
box->verticalLayout(),
|
||||||
|
tr::lng_admin_log_filter_actions_admins_section(
|
||||||
|
tr::now,
|
||||||
|
Ui::Text::WithEntities),
|
||||||
|
checkedPeerId.size() == admins.size(),
|
||||||
|
st::defaultBoxCheckbox));
|
||||||
|
using Controller = Ui::ExpandablePeerListController;
|
||||||
|
using Data = Ui::ExpandablePeerListController::Data;
|
||||||
|
const auto controller = box->lifetime().make_state<Controller>(Data{
|
||||||
|
.participants = ranges::views::all(
|
||||||
|
admins
|
||||||
|
) | ranges::views::transform([](
|
||||||
|
not_null<UserData*> user) -> not_null<PeerData*> {
|
||||||
|
return not_null{ user };
|
||||||
|
}) | ranges::to_vector,
|
||||||
|
.checked = std::move(checkedPeerId),
|
||||||
|
.skipSingle = true,
|
||||||
|
.hideRightButton = true,
|
||||||
|
.checkTopOnAllInner = true,
|
||||||
|
});
|
||||||
|
Ui::AddExpandablePeerList(
|
||||||
|
checkbox,
|
||||||
|
controller,
|
||||||
|
box->verticalLayout());
|
||||||
|
|
||||||
|
box->addButton(tr::lng_settings_save(), [=] {
|
||||||
|
const auto peers = controller->collectRequests();
|
||||||
|
const auto users = ranges::views::all(
|
||||||
|
peers
|
||||||
|
) | ranges::views::transform([](not_null<PeerData*> p) {
|
||||||
|
return not_null{ p->asUser() };
|
||||||
|
}) | ranges::to_vector;
|
||||||
|
callback(FilterValue{
|
||||||
|
.flags = collectFlags(),
|
||||||
|
.admins = users,
|
||||||
|
});
|
||||||
|
});
|
||||||
|
box->addButton(tr::lng_cancel(), [box] { box->closeBox(); });
|
||||||
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
void InnerWidget::clearAndRequestLog() {
|
void InnerWidget::clearAndRequestLog() {
|
||||||
|
|
Loading…
Add table
Reference in a new issue