/* This file is part of Telegram Desktop, the official desktop version of Telegram messaging app, see https://telegram.org Telegram Desktop is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. It is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. In addition, as a special exception, the copyright holders give permission to link the code of portions of this program with the OpenSSL library. Full license: https://github.com/telegramdesktop/tdesktop/blob/master/LICENSE Copyright (c) 2014-2017 John Preston, https://desktop.telegram.org */ #pragma once #include "boxes/abstract_box.h" namespace Ui { class FlatLabel; class LinkButton; class Checkbox; class Radiobutton; class RadiobuttonGroup; } // namespace Ui class CalendarBox; class EditParticipantBox : public BoxContent { public: EditParticipantBox(QWidget*, gsl::not_null channel, gsl::not_null user, bool hasAdminRights); protected: void prepare() override; void resizeToContent(); gsl::not_null user() const { return _user; } gsl::not_null channel() const { return _channel; } template QPointer addControl(object_ptr widget, QMargins margin); void removeControl(QPointer widget); bool hasAdminRights() const { return _hasAdminRights; } class Divider; private: gsl::not_null _channel; gsl::not_null _user; bool _hasAdminRights = false; class Inner; QPointer _inner; }; class EditAdminBox : public EditParticipantBox { public: EditAdminBox(QWidget*, gsl::not_null channel, gsl::not_null user, const MTPChannelAdminRights &rights, base::lambda callback); protected: void prepare() override; private: using Flag = MTPDchannelAdminRights::Flag; using Flags = MTPDchannelAdminRights::Flags; static MTPChannelAdminRights DefaultRights(gsl::not_null channel); void applyDependencies(QPointer changed); void refreshAboutAddAdminsText(); const MTPChannelAdminRights _oldRights; std::vector> _dependencies; base::lambda _saveCallback; std::map> _checkboxes; QPointer _aboutAddAdmins; }; // Restricted box works with flags in the opposite way. // If some flag is set in the rights then the checkbox is unchecked. class EditRestrictedBox : public EditParticipantBox { public: EditRestrictedBox(QWidget*, gsl::not_null channel, gsl::not_null user, bool hasAdminRights, const MTPChannelBannedRights &rights, base::lambda callback); protected: void prepare() override; private: using Flag = MTPDchannelBannedRights::Flag; using Flags = MTPDchannelBannedRights::Flags; static MTPChannelBannedRights DefaultRights(gsl::not_null channel); void applyDependencies(QPointer changed); void showRestrictUntil(); void setRestrictUntil(TimeId until); bool isUntilForever() { return ChannelData::IsRestrictedForever(_until); } void clearVariants(); void createUntilGroup(); void createUntilVariants(); TimeId getRealUntilValue() const; const MTPChannelBannedRights _oldRights; TimeId _until = 0; std::vector> _dependencies; base::lambda _saveCallback; std::map> _checkboxes; std::shared_ptr _untilGroup; QVector> _untilVariants; QPointer _restrictUntilBox; static constexpr auto kUntilOneDay = -1; static constexpr auto kUntilOneWeek = -2; static constexpr auto kUntilCustom = -3; };