2017-06-07 12:59:45 +00:00
|
|
|
/*
|
|
|
|
This file is part of Telegram Desktop,
|
2018-01-03 10:23:14 +00:00
|
|
|
the official desktop application for the Telegram messaging service.
|
2017-06-07 12:59:45 +00:00
|
|
|
|
2018-01-03 10:23:14 +00:00
|
|
|
For license and copyright information please follow this link:
|
|
|
|
https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
2017-06-07 12:59:45 +00:00
|
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "boxes/abstract_box.h"
|
2019-01-08 10:54:18 +00:00
|
|
|
#include "base/unique_qptr.h"
|
2017-06-07 12:59:45 +00:00
|
|
|
|
|
|
|
namespace Ui {
|
|
|
|
class FlatLabel;
|
|
|
|
class LinkButton;
|
|
|
|
class Checkbox;
|
2017-07-10 10:43:25 +00:00
|
|
|
class Radiobutton;
|
|
|
|
class RadiobuttonGroup;
|
2017-06-07 12:59:45 +00:00
|
|
|
} // 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:
|
2019-01-07 12:55:49 +00:00
|
|
|
EditParticipantBox(
|
|
|
|
QWidget*,
|
2019-01-10 06:26:08 +00:00
|
|
|
not_null<PeerData*> peer,
|
2019-01-07 12:55:49 +00:00
|
|
|
not_null<UserData*> user,
|
|
|
|
bool hasAdminRights);
|
2017-06-07 12:59:45 +00:00
|
|
|
|
|
|
|
protected:
|
2017-06-09 16:12:02 +00:00
|
|
|
void prepare() override;
|
2017-06-07 12:59:45 +00:00
|
|
|
|
2017-08-17 08:31:24 +00:00
|
|
|
not_null<UserData*> user() const {
|
2017-06-07 12:59:45 +00:00
|
|
|
return _user;
|
|
|
|
}
|
2019-01-10 06:26:08 +00:00
|
|
|
not_null<PeerData*> peer() const {
|
|
|
|
return _peer;
|
2017-06-07 12:59:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
template <typename Widget>
|
2019-01-08 10:54:18 +00:00
|
|
|
Widget *addControl(object_ptr<Widget> widget, QMargins margin = {});
|
2017-06-07 12:59:45 +00:00
|
|
|
|
2017-06-17 19:51:23 +00:00
|
|
|
bool hasAdminRights() const {
|
|
|
|
return _hasAdminRights;
|
|
|
|
}
|
|
|
|
|
2017-06-07 12:59:45 +00:00
|
|
|
private:
|
2019-01-10 06:26:08 +00:00
|
|
|
not_null<PeerData*> _peer;
|
2017-08-17 08:31:24 +00:00
|
|
|
not_null<UserData*> _user;
|
2017-06-17 19:51:23 +00:00
|
|
|
bool _hasAdminRights = false;
|
2017-06-07 12:59:45 +00:00
|
|
|
|
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:
|
2019-01-07 12:55:49 +00:00
|
|
|
EditAdminBox(
|
|
|
|
QWidget*,
|
2019-01-10 06:26:08 +00:00
|
|
|
not_null<PeerData*> peer,
|
2019-01-07 12:55:49 +00:00
|
|
|
not_null<UserData*> user,
|
|
|
|
const MTPChatAdminRights &rights);
|
|
|
|
|
|
|
|
void setSaveCallback(
|
|
|
|
Fn<void(MTPChatAdminRights, MTPChatAdminRights)> callback) {
|
2017-07-10 12:29:55 +00:00
|
|
|
_saveCallback = std::move(callback);
|
|
|
|
}
|
2017-06-09 16:12:02 +00:00
|
|
|
|
2017-06-07 12:59:45 +00:00
|
|
|
protected:
|
|
|
|
void prepare() override;
|
|
|
|
|
|
|
|
private:
|
2019-01-03 14:39:19 +00:00
|
|
|
using Flag = MTPDchatAdminRights::Flag;
|
|
|
|
using Flags = MTPDchatAdminRights::Flags;
|
2017-06-07 12:59:45 +00:00
|
|
|
|
2019-01-10 06:26:08 +00:00
|
|
|
static MTPChatAdminRights Defaults(not_null<PeerData*> peer);
|
2017-07-05 21:11:49 +00:00
|
|
|
|
2017-07-10 12:29:55 +00:00
|
|
|
bool canSave() const {
|
|
|
|
return !!_saveCallback;
|
|
|
|
}
|
2019-01-07 12:55:49 +00:00
|
|
|
void refreshAboutAddAdminsText(bool canAddAdmins);
|
2017-06-07 12:59:45 +00:00
|
|
|
|
2019-01-03 14:39:19 +00:00
|
|
|
const MTPChatAdminRights _oldRights;
|
|
|
|
Fn<void(MTPChatAdminRights, MTPChatAdminRights)> _saveCallback;
|
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:
|
2019-01-07 12:55:49 +00:00
|
|
|
EditRestrictedBox(
|
|
|
|
QWidget*,
|
2019-01-10 06:26:08 +00:00
|
|
|
not_null<PeerData*> peer,
|
2019-01-07 12:55:49 +00:00
|
|
|
not_null<UserData*> user,
|
|
|
|
bool hasAdminRights,
|
|
|
|
const MTPChatBannedRights &rights);
|
|
|
|
|
|
|
|
void setSaveCallback(
|
|
|
|
Fn<void(MTPChatBannedRights, MTPChatBannedRights)> callback) {
|
2017-07-10 12:29:55 +00:00
|
|
|
_saveCallback = std::move(callback);
|
|
|
|
}
|
2017-06-09 16:12:02 +00:00
|
|
|
|
2017-06-07 12:59:45 +00:00
|
|
|
protected:
|
|
|
|
void prepare() override;
|
|
|
|
|
|
|
|
private:
|
2019-01-03 14:39:19 +00:00
|
|
|
using Flag = MTPDchatBannedRights::Flag;
|
|
|
|
using Flags = MTPDchatBannedRights::Flags;
|
2017-06-09 16:12:02 +00:00
|
|
|
|
2019-01-10 06:26:08 +00:00
|
|
|
static MTPChatBannedRights Defaults(not_null<PeerData*> peer);
|
2017-07-05 21:11:49 +00:00
|
|
|
|
2017-07-10 12:29:55 +00:00
|
|
|
bool canSave() const {
|
|
|
|
return !!_saveCallback;
|
|
|
|
}
|
2017-06-09 16:12:02 +00:00
|
|
|
void showRestrictUntil();
|
2017-07-10 10:43:25 +00:00
|
|
|
void setRestrictUntil(TimeId until);
|
2019-01-04 11:09:48 +00:00
|
|
|
bool isUntilForever() const;
|
2017-07-10 10:43:25 +00:00
|
|
|
void createUntilGroup();
|
|
|
|
void createUntilVariants();
|
|
|
|
TimeId getRealUntilValue() const;
|
2017-06-07 12:59:45 +00:00
|
|
|
|
2019-01-03 14:39:19 +00:00
|
|
|
const MTPChatBannedRights _oldRights;
|
2017-07-10 10:43:25 +00:00
|
|
|
TimeId _until = 0;
|
2019-01-03 14:39:19 +00:00
|
|
|
Fn<void(MTPChatBannedRights, MTPChatBannedRights)> _saveCallback;
|
2017-06-07 12:59:45 +00:00
|
|
|
|
2017-07-10 10:43:25 +00:00
|
|
|
std::shared_ptr<Ui::RadiobuttonGroup> _untilGroup;
|
2019-01-08 10:54:18 +00:00
|
|
|
std::vector<base::unique_qptr<Ui::Radiobutton>> _untilVariants;
|
2017-06-09 16:12:02 +00:00
|
|
|
QPointer<CalendarBox> _restrictUntilBox;
|
2017-06-07 12:59:45 +00:00
|
|
|
|
2017-07-10 10:43:25 +00:00
|
|
|
static constexpr auto kUntilOneDay = -1;
|
|
|
|
static constexpr auto kUntilOneWeek = -2;
|
|
|
|
static constexpr auto kUntilCustom = -3;
|
|
|
|
|
2017-06-07 12:59:45 +00:00
|
|
|
};
|