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"
|
2021-07-31 14:11:53 +00:00
|
|
|
#include "api/api_user_privacy.h"
|
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
|
|
|
|
|
2019-09-18 11:19:05 +00:00
|
|
|
namespace Window {
|
|
|
|
class SessionController;
|
|
|
|
} // namespace Window
|
|
|
|
|
2019-05-21 12:51:24 +00:00
|
|
|
class EditPrivacyBox;
|
|
|
|
|
|
|
|
class EditPrivacyController {
|
2017-03-16 15:15:07 +00:00
|
|
|
public:
|
2021-07-31 14:11:53 +00:00
|
|
|
using Key = Api::UserPrivacy::Key;
|
|
|
|
using Option = Api::UserPrivacy::Option;
|
2017-03-17 12:05:50 +00:00
|
|
|
enum class Exception {
|
|
|
|
Always,
|
|
|
|
Never,
|
|
|
|
};
|
2017-03-16 15:15:07 +00:00
|
|
|
|
2019-05-21 12:51:24 +00:00
|
|
|
[[nodiscard]] virtual Key key() = 0;
|
|
|
|
|
2019-06-18 15:00:55 +00:00
|
|
|
[[nodiscard]] virtual rpl::producer<QString> title() = 0;
|
2019-05-21 12:51:24 +00:00
|
|
|
[[nodiscard]] virtual bool hasOption(Option option) {
|
|
|
|
return true;
|
|
|
|
}
|
2019-06-18 12:16:43 +00:00
|
|
|
[[nodiscard]] virtual rpl::producer<QString> optionsTitleKey() = 0;
|
2019-06-19 15:09:03 +00:00
|
|
|
[[nodiscard]] virtual QString optionLabel(Option option);
|
2019-05-21 12:51:24 +00:00
|
|
|
[[nodiscard]] virtual rpl::producer<QString> warning() {
|
2019-06-18 14:07:45 +00:00
|
|
|
return nullptr;
|
2019-05-21 12:51:24 +00:00
|
|
|
}
|
2019-06-18 12:16:43 +00:00
|
|
|
[[nodiscard]] virtual rpl::producer<QString> exceptionButtonTextKey(
|
2019-05-21 12:51:24 +00:00
|
|
|
Exception exception) = 0;
|
2019-06-18 15:00:55 +00:00
|
|
|
[[nodiscard]] virtual rpl::producer<QString> exceptionBoxTitle(
|
2019-05-21 12:51:24 +00:00
|
|
|
Exception exception) = 0;
|
|
|
|
[[nodiscard]] virtual auto exceptionsDescription()
|
|
|
|
-> rpl::producer<QString> = 0;
|
|
|
|
|
|
|
|
[[nodiscard]] virtual object_ptr<Ui::RpWidget> setupAboveWidget(
|
|
|
|
not_null<QWidget*> parent,
|
2022-02-13 13:30:43 +00:00
|
|
|
rpl::producer<Option> option,
|
|
|
|
not_null<QWidget*> outerContainer) {
|
2019-05-21 12:51:24 +00:00
|
|
|
return { nullptr };
|
|
|
|
}
|
2019-08-29 08:44:03 +00:00
|
|
|
[[nodiscard]] virtual object_ptr<Ui::RpWidget> setupMiddleWidget(
|
|
|
|
not_null<Window::SessionController*> controller,
|
|
|
|
not_null<QWidget*> parent,
|
|
|
|
rpl::producer<Option> option) {
|
|
|
|
return { nullptr };
|
|
|
|
}
|
2019-05-21 12:51:24 +00:00
|
|
|
[[nodiscard]] virtual object_ptr<Ui::RpWidget> setupBelowWidget(
|
2019-07-24 14:00:30 +00:00
|
|
|
not_null<Window::SessionController*> controller,
|
2019-05-21 12:51:24 +00:00
|
|
|
not_null<QWidget*> parent) {
|
|
|
|
return { nullptr };
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual void confirmSave(
|
|
|
|
bool someAreDisallowed,
|
|
|
|
FnMut<void()> saveCallback) {
|
|
|
|
saveCallback();
|
|
|
|
}
|
2019-08-29 08:44:03 +00:00
|
|
|
virtual void saveAdditional() {
|
|
|
|
}
|
2019-05-21 12:51:24 +00:00
|
|
|
|
|
|
|
virtual ~EditPrivacyController() = default;
|
2017-03-16 15:15:07 +00:00
|
|
|
|
2019-05-21 12:51:24 +00:00
|
|
|
protected:
|
|
|
|
EditPrivacyBox *view() const {
|
|
|
|
return _view;
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
void setView(EditPrivacyBox *box) {
|
|
|
|
_view = box;
|
|
|
|
}
|
|
|
|
|
|
|
|
EditPrivacyBox *_view = nullptr;
|
|
|
|
|
|
|
|
friend class EditPrivacyBox;
|
|
|
|
|
|
|
|
};
|
|
|
|
|
2019-11-27 08:02:56 +00:00
|
|
|
class EditPrivacyBox : public Ui::BoxContent {
|
2019-05-21 12:51:24 +00:00
|
|
|
public:
|
2021-07-31 14:11:53 +00:00
|
|
|
using Value = Api::UserPrivacy::Rule;
|
|
|
|
using Option = Api::UserPrivacy::Option;
|
2019-05-21 12:51:24 +00:00
|
|
|
using Exception = EditPrivacyController::Exception;
|
2017-03-16 15:15:07 +00:00
|
|
|
|
2018-09-11 09:11:52 +00:00
|
|
|
EditPrivacyBox(
|
|
|
|
QWidget*,
|
2019-07-24 14:00:30 +00:00
|
|
|
not_null<Window::SessionController*> window,
|
2019-05-21 12:51:24 +00:00
|
|
|
std::unique_ptr<EditPrivacyController> controller,
|
2018-09-19 09:06:21 +00:00
|
|
|
const Value &value);
|
|
|
|
|
2019-08-29 08:44:03 +00:00
|
|
|
static Ui::Radioenum<Option> *AddOption(
|
|
|
|
not_null<Ui::VerticalLayout*> container,
|
|
|
|
not_null<EditPrivacyController*> controller,
|
|
|
|
const std::shared_ptr<Ui::RadioenumGroup<Option>> &group,
|
|
|
|
Option option);
|
|
|
|
|
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-17 12:05:50 +00:00
|
|
|
|
2018-11-16 05:40:42 +00:00
|
|
|
Ui::FlatLabel *addLabel(
|
|
|
|
not_null<Ui::VerticalLayout*> container,
|
2022-02-13 13:30:43 +00:00
|
|
|
rpl::producer<QString> text,
|
|
|
|
int topSkip);
|
|
|
|
void addLabelOrDivider(
|
|
|
|
not_null<Ui::VerticalLayout*> container,
|
|
|
|
rpl::producer<QString> text,
|
|
|
|
int topSkip);
|
2018-11-16 05:40:42 +00:00
|
|
|
|
2019-05-20 18:40:53 +00:00
|
|
|
void editExceptions(Exception exception, Fn<void()> done);
|
|
|
|
std::vector<not_null<PeerData*>> &exceptions(Exception exception);
|
2017-03-16 15:15:07 +00:00
|
|
|
|
2019-07-24 14:00:30 +00:00
|
|
|
const not_null<Window::SessionController*> _window;
|
2019-05-21 12:51:24 +00:00
|
|
|
std::unique_ptr<EditPrivacyController> _controller;
|
2018-09-11 09:11:52 +00:00
|
|
|
Value _value;
|
2018-09-12 17:02:30 +00:00
|
|
|
|
|
|
|
};
|