2017-03-16 18:15:07 +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-03-16 18:15:07 +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-03-16 18:15:07 +03:00
|
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
|
2022-07-14 23:10:50 +03:00
|
|
|
#include "ui/layers/box_content.h"
|
2017-03-22 18:38:40 +03:00
|
|
|
#include "mtproto/sender.h"
|
2021-07-31 17:11:53 +03:00
|
|
|
#include "api/api_user_privacy.h"
|
2017-03-16 18:15:07 +03:00
|
|
|
|
|
|
|
namespace Ui {
|
2024-01-11 12:29:23 +04:00
|
|
|
class GenericBox;
|
2018-09-19 12:06:21 +03:00
|
|
|
class VerticalLayout;
|
2017-03-16 18:15:07 +03:00
|
|
|
class FlatLabel;
|
|
|
|
class LinkButton;
|
2017-03-19 00:06:10 +03:00
|
|
|
template <typename Enum>
|
|
|
|
class RadioenumGroup;
|
2017-03-19 11:29:05 +03:00
|
|
|
template <typename Enum>
|
|
|
|
class Radioenum;
|
2017-03-16 18:15:07 +03:00
|
|
|
template <typename Widget>
|
2017-09-13 19:57:44 +03:00
|
|
|
class SlideWrap;
|
2017-03-16 18:15:07 +03:00
|
|
|
} // namespace Ui
|
|
|
|
|
2019-09-18 14:19:05 +03:00
|
|
|
namespace Window {
|
|
|
|
class SessionController;
|
|
|
|
} // namespace Window
|
|
|
|
|
2019-05-21 14:51:24 +02:00
|
|
|
class EditPrivacyBox;
|
|
|
|
|
|
|
|
class EditPrivacyController {
|
2017-03-16 18:15:07 +03:00
|
|
|
public:
|
2021-07-31 17:11:53 +03:00
|
|
|
using Key = Api::UserPrivacy::Key;
|
|
|
|
using Option = Api::UserPrivacy::Option;
|
2017-03-17 15:05:50 +03:00
|
|
|
enum class Exception {
|
|
|
|
Always,
|
|
|
|
Never,
|
|
|
|
};
|
2017-03-16 18:15:07 +03:00
|
|
|
|
2022-07-14 23:10:50 +03:00
|
|
|
[[nodiscard]] virtual Key key() const = 0;
|
2019-05-21 14:51:24 +02:00
|
|
|
|
2022-07-14 23:10:50 +03:00
|
|
|
[[nodiscard]] virtual rpl::producer<QString> title() const = 0;
|
2023-05-09 19:34:04 +04:00
|
|
|
[[nodiscard]] virtual bool hasOption(Option option) const;
|
2022-07-14 23:10:50 +03:00
|
|
|
[[nodiscard]] virtual rpl::producer<QString> optionsTitleKey() const = 0;
|
|
|
|
[[nodiscard]] virtual QString optionLabel(Option option) const;
|
|
|
|
[[nodiscard]] virtual rpl::producer<TextWithEntities> warning() const {
|
2019-06-18 16:07:45 +02:00
|
|
|
return nullptr;
|
2019-05-21 14:51:24 +02:00
|
|
|
}
|
2024-04-01 17:03:04 +04:00
|
|
|
virtual void prepareWarningLabel(
|
|
|
|
not_null<Ui::FlatLabel*> warning) const {
|
2022-03-01 15:30:55 +03:00
|
|
|
}
|
2019-06-18 14:16:43 +02:00
|
|
|
[[nodiscard]] virtual rpl::producer<QString> exceptionButtonTextKey(
|
2022-07-14 23:10:50 +03:00
|
|
|
Exception exception) const = 0;
|
2019-06-18 17:00:55 +02:00
|
|
|
[[nodiscard]] virtual rpl::producer<QString> exceptionBoxTitle(
|
2022-07-14 23:10:50 +03:00
|
|
|
Exception exception) const = 0;
|
2019-05-21 14:51:24 +02:00
|
|
|
[[nodiscard]] virtual auto exceptionsDescription()
|
2022-07-14 23:10:50 +03:00
|
|
|
const -> rpl::producer<QString> = 0;
|
2024-04-01 17:03:04 +04:00
|
|
|
[[nodiscard]] virtual bool allowPremiumsToggle(
|
|
|
|
Exception exception) const {
|
|
|
|
return false;
|
|
|
|
}
|
2024-11-15 15:34:23 +04:00
|
|
|
[[nodiscard]] virtual bool allowMiniAppsToggle(
|
|
|
|
Exception exception) const {
|
|
|
|
return false;
|
|
|
|
}
|
2022-12-19 17:36:02 +03:00
|
|
|
virtual void handleExceptionsChange(
|
|
|
|
Exception exception,
|
|
|
|
rpl::producer<int> value) {
|
|
|
|
}
|
2019-05-21 14:51:24 +02:00
|
|
|
|
|
|
|
[[nodiscard]] virtual object_ptr<Ui::RpWidget> setupAboveWidget(
|
2024-03-22 12:41:28 +04:00
|
|
|
not_null<Window::SessionController*> controller,
|
2019-05-21 14:51:24 +02:00
|
|
|
not_null<QWidget*> parent,
|
2022-02-13 16:30:43 +03:00
|
|
|
rpl::producer<Option> option,
|
|
|
|
not_null<QWidget*> outerContainer) {
|
2019-05-21 14:51:24 +02:00
|
|
|
return { nullptr };
|
|
|
|
}
|
2019-08-29 11:44:03 +03: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 14:51:24 +02:00
|
|
|
[[nodiscard]] virtual object_ptr<Ui::RpWidget> setupBelowWidget(
|
2019-07-24 16:00:30 +02:00
|
|
|
not_null<Window::SessionController*> controller,
|
2024-01-16 16:53:46 +04:00
|
|
|
not_null<QWidget*> parent,
|
|
|
|
rpl::producer<Option> option) {
|
2019-05-21 14:51:24 +02:00
|
|
|
return { nullptr };
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual void confirmSave(
|
|
|
|
bool someAreDisallowed,
|
2022-02-27 13:41:18 +03:00
|
|
|
Fn<void()> saveCallback) {
|
2019-05-21 14:51:24 +02:00
|
|
|
saveCallback();
|
|
|
|
}
|
2019-08-29 11:44:03 +03:00
|
|
|
virtual void saveAdditional() {
|
|
|
|
}
|
2019-05-21 14:51:24 +02:00
|
|
|
|
2024-03-07 19:07:05 +03:00
|
|
|
[[nodiscard]] virtual Fn<void()> premiumClickedCallback(
|
|
|
|
Option option,
|
|
|
|
not_null<Window::SessionController*> controller) {
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
2019-05-21 14:51:24 +02:00
|
|
|
virtual ~EditPrivacyController() = default;
|
2017-03-16 18:15:07 +03:00
|
|
|
|
2019-05-21 14:51:24 +02:00
|
|
|
protected:
|
2022-07-14 23:10:50 +03:00
|
|
|
[[nodiscard]] EditPrivacyBox *view() const {
|
2019-05-21 14:51:24 +02:00
|
|
|
return _view;
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
void setView(EditPrivacyBox *box) {
|
|
|
|
_view = box;
|
|
|
|
}
|
|
|
|
|
|
|
|
EditPrivacyBox *_view = nullptr;
|
|
|
|
|
|
|
|
friend class EditPrivacyBox;
|
|
|
|
|
|
|
|
};
|
|
|
|
|
2022-07-14 23:10:50 +03:00
|
|
|
class EditPrivacyBox final : public Ui::BoxContent {
|
2019-05-21 14:51:24 +02:00
|
|
|
public:
|
2021-07-31 17:11:53 +03:00
|
|
|
using Value = Api::UserPrivacy::Rule;
|
|
|
|
using Option = Api::UserPrivacy::Option;
|
2024-04-01 17:03:04 +04:00
|
|
|
using Exceptions = Api::UserPrivacy::Exceptions;
|
2019-05-21 14:51:24 +02:00
|
|
|
using Exception = EditPrivacyController::Exception;
|
2017-03-16 18:15:07 +03:00
|
|
|
|
2018-09-11 12:11:52 +03:00
|
|
|
EditPrivacyBox(
|
|
|
|
QWidget*,
|
2019-07-24 16:00:30 +02:00
|
|
|
not_null<Window::SessionController*> window,
|
2019-05-21 14:51:24 +02:00
|
|
|
std::unique_ptr<EditPrivacyController> controller,
|
2018-09-19 12:06:21 +03:00
|
|
|
const Value &value);
|
|
|
|
|
2019-08-29 11:44:03 +03: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 18:15:07 +03:00
|
|
|
protected:
|
|
|
|
void prepare() override;
|
|
|
|
|
2017-03-19 11:29:05 +03:00
|
|
|
private:
|
2017-03-17 15:05:50 +03:00
|
|
|
bool showExceptionLink(Exception exception) const;
|
2018-09-19 12:06:21 +03:00
|
|
|
void setupContent();
|
2017-03-17 15:05:50 +03:00
|
|
|
|
2018-11-16 09:40:42 +04:00
|
|
|
Ui::FlatLabel *addLabel(
|
|
|
|
not_null<Ui::VerticalLayout*> container,
|
2022-03-01 15:30:55 +03:00
|
|
|
rpl::producer<TextWithEntities> text,
|
2022-02-13 16:30:43 +03:00
|
|
|
int topSkip);
|
2022-03-01 15:30:55 +03:00
|
|
|
Ui::FlatLabel *addLabelOrDivider(
|
2022-02-13 16:30:43 +03:00
|
|
|
not_null<Ui::VerticalLayout*> container,
|
2022-03-01 15:30:55 +03:00
|
|
|
rpl::producer<TextWithEntities> text,
|
2022-02-13 16:30:43 +03:00
|
|
|
int topSkip);
|
2018-11-16 09:40:42 +04:00
|
|
|
|
2019-05-20 20:40:53 +02:00
|
|
|
void editExceptions(Exception exception, Fn<void()> done);
|
2024-04-01 17:03:04 +04:00
|
|
|
Exceptions &exceptions(Exception exception);
|
2017-03-16 18:15:07 +03:00
|
|
|
|
2019-07-24 16:00:30 +02:00
|
|
|
const not_null<Window::SessionController*> _window;
|
2019-05-21 14:51:24 +02:00
|
|
|
std::unique_ptr<EditPrivacyController> _controller;
|
2018-09-11 12:11:52 +03:00
|
|
|
Value _value;
|
2018-09-12 20:02:30 +03:00
|
|
|
|
|
|
|
};
|
2024-01-11 12:29:23 +04:00
|
|
|
|
|
|
|
void EditMessagesPrivacyBox(
|
|
|
|
not_null<Ui::GenericBox*> box,
|
|
|
|
not_null<Window::SessionController*> controller);
|
2025-02-13 14:12:19 +04:00
|
|
|
|
|
|
|
[[nodiscard]] rpl::producer<int> SetupChargeSlider(
|
|
|
|
not_null<Ui::VerticalLayout*> container,
|
|
|
|
not_null<PeerData*> peer,
|
|
|
|
int savedValue);
|