2017-03-16 15:15:07 +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-03-16 15:15:07 +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-03-16 15:15:07 +00:00
|
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
|
2017-04-06 14:38:10 +00:00
|
|
|
#include "boxes/abstract_box.h"
|
2017-03-22 15:38:40 +00:00
|
|
|
#include "mtproto/sender.h"
|
2018-09-11 09:11:52 +00:00
|
|
|
#include "apiwrap.h"
|
2017-03-16 15:15:07 +00:00
|
|
|
|
2018-09-19 09:06:21 +00:00
|
|
|
enum LangKey : int;
|
|
|
|
|
2017-03-16 15:15:07 +00:00
|
|
|
namespace Ui {
|
2018-09-19 09:06:21 +00:00
|
|
|
class VerticalLayout;
|
2017-03-16 15:15:07 +00:00
|
|
|
class FlatLabel;
|
|
|
|
class LinkButton;
|
2017-03-18 21:06:10 +00:00
|
|
|
template <typename Enum>
|
|
|
|
class RadioenumGroup;
|
2017-03-19 08:29:05 +00:00
|
|
|
template <typename Enum>
|
|
|
|
class Radioenum;
|
2017-03-16 15:15:07 +00:00
|
|
|
template <typename Widget>
|
2017-09-13 16:57:44 +00:00
|
|
|
class SlideWrap;
|
2017-03-16 15:15:07 +00:00
|
|
|
} // namespace Ui
|
|
|
|
|
2017-03-22 15:38:40 +00:00
|
|
|
class EditPrivacyBox : public BoxContent, private MTP::Sender {
|
2017-03-16 15:15:07 +00:00
|
|
|
public:
|
2018-09-11 09:11:52 +00:00
|
|
|
using Value = ApiWrap::Privacy;
|
|
|
|
using Option = Value::Option;
|
2017-03-17 12:05:50 +00:00
|
|
|
enum class Exception {
|
|
|
|
Always,
|
|
|
|
Never,
|
|
|
|
};
|
2017-03-16 15:15:07 +00:00
|
|
|
|
|
|
|
class Controller {
|
|
|
|
public:
|
2018-09-11 09:11:52 +00:00
|
|
|
using Key = ApiWrap::Privacy::Key;
|
|
|
|
|
|
|
|
virtual Key key() = 0;
|
|
|
|
virtual MTPInputPrivacyKey apiKey() = 0;
|
2017-03-16 15:15:07 +00:00
|
|
|
|
|
|
|
virtual QString title() = 0;
|
2017-03-19 08:29:05 +00:00
|
|
|
virtual bool hasOption(Option option) {
|
|
|
|
return true;
|
2017-03-16 15:15:07 +00:00
|
|
|
}
|
2018-09-19 09:06:21 +00:00
|
|
|
virtual LangKey optionsTitleKey() = 0;
|
2018-11-16 05:40:42 +00:00
|
|
|
virtual LangKey optionLabelKey(Option option);
|
2018-09-19 09:06:21 +00:00
|
|
|
virtual rpl::producer<QString> warning() {
|
|
|
|
return rpl::never<QString>();
|
2017-03-19 08:29:05 +00:00
|
|
|
}
|
2018-09-19 09:06:21 +00:00
|
|
|
virtual LangKey exceptionButtonTextKey(Exception exception) = 0;
|
2017-03-17 12:05:50 +00:00
|
|
|
virtual QString exceptionBoxTitle(Exception exception) = 0;
|
2018-09-19 09:06:21 +00:00
|
|
|
virtual rpl::producer<QString> exceptionsDescription() = 0;
|
2017-03-16 15:15:07 +00:00
|
|
|
|
2018-09-19 09:06:21 +00:00
|
|
|
virtual void confirmSave(
|
|
|
|
bool someAreDisallowed,
|
|
|
|
FnMut<void()> saveCallback) {
|
2017-03-17 18:44:55 +00:00
|
|
|
saveCallback();
|
|
|
|
}
|
|
|
|
|
2017-03-16 15:15:07 +00:00
|
|
|
virtual ~Controller() = default;
|
|
|
|
|
|
|
|
protected:
|
|
|
|
EditPrivacyBox *view() const {
|
|
|
|
return _view;
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
void setView(EditPrivacyBox *box) {
|
|
|
|
_view = box;
|
|
|
|
}
|
|
|
|
|
|
|
|
EditPrivacyBox *_view = nullptr;
|
|
|
|
|
|
|
|
friend class EditPrivacyBox;
|
|
|
|
|
|
|
|
};
|
|
|
|
|
2018-09-11 09:11:52 +00:00
|
|
|
EditPrivacyBox(
|
|
|
|
QWidget*,
|
|
|
|
std::unique_ptr<Controller> controller,
|
2018-09-19 09:06:21 +00:00
|
|
|
const Value &value);
|
|
|
|
|
2017-03-16 15:15:07 +00:00
|
|
|
protected:
|
|
|
|
void prepare() override;
|
|
|
|
|
2017-03-19 08:29:05 +00:00
|
|
|
private:
|
2017-03-17 12:05:50 +00:00
|
|
|
bool showExceptionLink(Exception exception) const;
|
2018-09-19 09:06:21 +00:00
|
|
|
void setupContent();
|
2017-03-16 15:15:07 +00:00
|
|
|
QVector<MTPInputPrivacyRule> collectResult();
|
2017-03-17 12:05:50 +00:00
|
|
|
|
2018-11-16 05:40:42 +00:00
|
|
|
Ui::Radioenum<Option> *addOption(
|
|
|
|
not_null<Ui::VerticalLayout*> container,
|
|
|
|
const std::shared_ptr<Ui::RadioenumGroup<Option>> &group,
|
|
|
|
Option option);
|
|
|
|
Ui::FlatLabel *addLabel(
|
|
|
|
not_null<Ui::VerticalLayout*> container,
|
|
|
|
rpl::producer<QString> text);
|
|
|
|
|
2018-09-19 09:06:21 +00:00
|
|
|
void editExceptionUsers(Exception exception, Fn<void()> done);
|
2017-08-17 08:31:24 +00:00
|
|
|
std::vector<not_null<UserData*>> &exceptionUsers(Exception exception);
|
2017-03-16 15:15:07 +00:00
|
|
|
|
|
|
|
std::unique_ptr<Controller> _controller;
|
2018-09-11 09:11:52 +00:00
|
|
|
Value _value;
|
2018-09-12 17:02:30 +00:00
|
|
|
|
|
|
|
};
|