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