2017-06-07 12:59:45 +00:00
|
|
|
/*
|
|
|
|
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;
|
|
|
|
} // namespace Ui
|
|
|
|
|
2017-06-09 16:12:02 +00:00
|
|
|
class CalendarBox;
|
|
|
|
|
2017-06-07 12:59:45 +00:00
|
|
|
class EditParticipantBox : public BoxContent {
|
|
|
|
public:
|
|
|
|
EditParticipantBox(QWidget*, gsl::not_null<ChannelData*> channel, gsl::not_null<UserData*> user);
|
|
|
|
|
|
|
|
protected:
|
2017-06-09 16:12:02 +00:00
|
|
|
void prepare() override;
|
2017-06-07 12:59:45 +00:00
|
|
|
|
2017-06-09 16:12:02 +00:00
|
|
|
void resizeToContent();
|
2017-06-07 12:59:45 +00:00
|
|
|
|
|
|
|
gsl::not_null<UserData*> user() const {
|
|
|
|
return _user;
|
|
|
|
}
|
|
|
|
gsl::not_null<ChannelData*> channel() const {
|
|
|
|
return _channel;
|
|
|
|
}
|
|
|
|
|
|
|
|
template <typename Widget>
|
2017-06-09 16:12:02 +00:00
|
|
|
QPointer<Widget> addControl(object_ptr<Widget> row);
|
2017-06-07 12:59:45 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
gsl::not_null<UserData*> _user;
|
|
|
|
gsl::not_null<ChannelData*> _channel;
|
|
|
|
|
2017-06-09 16:12:02 +00:00
|
|
|
class Inner;
|
|
|
|
QPointer<Inner> _inner;
|
2017-06-07 12:59:45 +00:00
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
class EditAdminBox : public EditParticipantBox {
|
|
|
|
public:
|
|
|
|
EditAdminBox(QWidget*, gsl::not_null<ChannelData*> channel, gsl::not_null<UserData*> user, const MTPChannelAdminRights &rights, base::lambda<void(MTPChannelAdminRights)> callback);
|
|
|
|
|
2017-06-09 16:12:02 +00:00
|
|
|
static MTPChannelAdminRights DefaultRights(gsl::not_null<ChannelData*> channel);
|
|
|
|
|
2017-06-07 12:59:45 +00:00
|
|
|
protected:
|
|
|
|
void prepare() override;
|
|
|
|
|
|
|
|
private:
|
|
|
|
using Flag = MTPDchannelAdminRights::Flag;
|
2017-06-09 16:12:02 +00:00
|
|
|
using Flags = MTPDchannelAdminRights::Flags;
|
2017-06-07 12:59:45 +00:00
|
|
|
|
2017-06-09 16:12:02 +00:00
|
|
|
void applyDependencies(QPointer<Ui::Checkbox> changed);
|
2017-06-07 12:59:45 +00:00
|
|
|
void refreshAboutAddAdminsText();
|
|
|
|
|
|
|
|
MTPChannelAdminRights _rights;
|
2017-06-09 16:12:02 +00:00
|
|
|
std::vector<std::pair<Flag, Flag>> _dependencies;
|
|
|
|
base::lambda<void(MTPChannelAdminRights)> _saveCallback;
|
2017-06-07 12:59:45 +00:00
|
|
|
|
2017-06-09 16:12:02 +00:00
|
|
|
std::map<Flags, QPointer<Ui::Checkbox>> _checkboxes;
|
2017-06-07 12:59:45 +00:00
|
|
|
QPointer<Ui::FlatLabel> _aboutAddAdmins;
|
|
|
|
|
|
|
|
};
|
|
|
|
|
2017-06-09 16:12:02 +00:00
|
|
|
// Restricted box works with flags in the opposite way.
|
|
|
|
// If some flag is set in the rights then the checkbox is unchecked.
|
|
|
|
|
2017-06-07 12:59:45 +00:00
|
|
|
class EditRestrictedBox : public EditParticipantBox {
|
|
|
|
public:
|
|
|
|
EditRestrictedBox(QWidget*, gsl::not_null<ChannelData*> channel, gsl::not_null<UserData*> user, const MTPChannelBannedRights &rights, base::lambda<void(MTPChannelBannedRights)> callback);
|
|
|
|
|
2017-06-09 16:12:02 +00:00
|
|
|
static MTPChannelBannedRights DefaultRights(gsl::not_null<ChannelData*> channel);
|
|
|
|
static constexpr auto kRestrictUntilForever = TimeId(INT_MAX);
|
|
|
|
|
2017-06-07 12:59:45 +00:00
|
|
|
protected:
|
|
|
|
void prepare() override;
|
|
|
|
|
|
|
|
private:
|
|
|
|
using Flag = MTPDchannelBannedRights::Flag;
|
2017-06-09 16:12:02 +00:00
|
|
|
using Flags = MTPDchannelBannedRights::Flags;
|
|
|
|
|
|
|
|
void applyDependencies(QPointer<Ui::Checkbox> changed);
|
|
|
|
void showRestrictUntil();
|
|
|
|
void setRestrictUntil(int32 until);
|
|
|
|
bool isUntilForever() {
|
|
|
|
return (_until <= 0) || (_until == kRestrictUntilForever);
|
|
|
|
}
|
2017-06-07 12:59:45 +00:00
|
|
|
|
|
|
|
MTPChannelBannedRights _rights;
|
2017-06-09 16:12:02 +00:00
|
|
|
int32 _until = 0;
|
|
|
|
std::vector<std::pair<Flag, Flag>> _dependencies;
|
|
|
|
base::lambda<void(MTPChannelBannedRights)> _saveCallback;
|
2017-06-07 12:59:45 +00:00
|
|
|
|
2017-06-09 16:12:02 +00:00
|
|
|
std::map<Flags, QPointer<Ui::Checkbox>> _checkboxes;
|
|
|
|
QPointer<Ui::LinkButton> _restrictUntil;
|
|
|
|
QPointer<CalendarBox> _restrictUntilBox;
|
2017-06-07 12:59:45 +00:00
|
|
|
|
|
|
|
};
|