tdesktop/Telegram/SourceFiles/boxes/peers/edit_peer_permissions_box.h

98 lines
2.6 KiB
C
Raw Normal View History

/*
This file is part of Telegram Desktop,
the official desktop application for the Telegram messaging service.
For license and copyright information please follow this link:
https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
*/
#pragma once
#include "boxes/abstract_box.h"
#include "data/data_chat_participant_status.h"
2019-01-08 10:54:18 +00:00
namespace Ui {
class RoundButton;
class VerticalLayout;
} // namespace Ui
namespace Window {
class SessionController;
class SessionNavigation;
} // namespace Window
2019-09-18 11:19:05 +00:00
class EditPeerPermissionsBox : public Ui::BoxContent {
2019-01-08 10:54:18 +00:00
public:
EditPeerPermissionsBox(
QWidget*,
not_null<Window::SessionNavigation*> navigation,
not_null<PeerData*> peer);
2019-01-08 10:54:18 +00:00
2019-07-16 11:46:50 +00:00
struct Result {
ChatRestrictions rights;
2019-07-16 11:46:50 +00:00
int slowmodeSeconds = 0;
};
rpl::producer<Result> saveEvents() const;
2019-01-08 10:54:18 +00:00
protected:
void prepare() override;
private:
2019-07-16 11:46:50 +00:00
Fn<int()> addSlowmodeSlider(not_null<Ui::VerticalLayout*> container);
void addSlowmodeLabels(not_null<Ui::VerticalLayout*> container);
2021-02-12 13:32:45 +00:00
void addSuggestGigagroup(not_null<Ui::VerticalLayout*> container);
void addBannedButtons(not_null<Ui::VerticalLayout*> container);
2019-01-08 10:54:18 +00:00
const not_null<Window::SessionNavigation*> _navigation;
const not_null<PeerData*> _peer;
2019-01-08 10:54:18 +00:00
Ui::RoundButton *_save = nullptr;
2019-07-16 11:46:50 +00:00
Fn<Result()> _value;
2019-01-08 10:54:18 +00:00
};
2021-02-19 13:53:20 +00:00
[[nodiscard]] Fn<void()> AboutGigagroupCallback(
not_null<ChannelData*> channel,
not_null<Window::SessionController*> controller);
2021-02-19 13:53:20 +00:00
struct RestrictionLabel {
ChatRestrictions flags;
QString label;
};
[[nodiscard]] std::vector<RestrictionLabel> RestrictionLabels(
Data::RestrictionsSetOptions options);
struct AdminRightLabel {
ChatAdminRights flags;
QString label;
};
[[nodiscard]] std::vector<AdminRightLabel> AdminRightLabels(
Data::AdminRightsSetOptions options);
template <typename Flags>
struct EditFlagsControl {
object_ptr<Ui::RpWidget> widget;
Fn<Flags()> value;
rpl::producer<Flags> changes;
};
[[nodiscard]] EditFlagsControl<ChatRestrictions> CreateEditRestrictions(
QWidget *parent,
2019-06-18 12:16:43 +00:00
rpl::producer<QString> header,
ChatRestrictions restrictions,
std::map<ChatRestrictions, QString> disabledMessages,
Data::RestrictionsSetOptions options);
[[nodiscard]] EditFlagsControl<ChatAdminRights> CreateEditAdminRights(
QWidget *parent,
2019-06-18 12:16:43 +00:00
rpl::producer<QString> header,
ChatAdminRights rights,
std::map<ChatAdminRights, QString> disabledMessages,
Data::AdminRightsSetOptions options);
[[nodiscard]] ChatAdminRights DisabledByDefaultRestrictions(
not_null<PeerData*> peer);
[[nodiscard]] ChatRestrictions FixDependentRestrictions(
ChatRestrictions restrictions);
[[nodiscard]] ChatAdminRights AdminRightsForOwnershipTransfer(
Data::AdminRightsSetOptions options);