2
0
mirror of https://github.com/telegramdesktop/tdesktop synced 2025-08-22 18:27:17 +00:00
tdesktop/Telegram/SourceFiles/settings/settings_privacy_controllers.h

299 lines
8.8 KiB
C
Raw Normal View History

2018-09-11 22:00:23 +03:00
/*
This file is part of Telegram Desktop,
the official desktop application for the Telegram messaging service.
For license and copyright information please follow this link:
https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
*/
#pragma once
#include "boxes/peer_list_box.h"
#include "boxes/edit_privacy_box.h"
#include "history/view/history_view_element.h"
#include "api/api_blocked_peers.h"
2018-09-11 22:00:23 +03:00
2020-06-10 22:08:17 +04:00
namespace Window {
class SessionController;
} // namespace Window
namespace Ui {
class ChatStyle;
} // namespace Ui
2018-09-11 22:00:23 +03:00
namespace Settings {
class BlockedBoxController final : public PeerListController {
2018-09-11 22:00:23 +03:00
public:
2019-07-24 16:00:30 +02:00
explicit BlockedBoxController(
not_null<Window::SessionController*> window);
2019-07-25 20:55:11 +02:00
Main::Session &session() const override;
2018-09-11 22:00:23 +03:00
void prepare() override;
void rowClicked(not_null<PeerListRow*> row) override;
void rowRightActionClicked(not_null<PeerListRow*> row) override;
2018-09-11 22:00:23 +03:00
void loadMoreRows() override;
[[nodiscard]] rpl::producer<int> rowsCountChanges() const;
static void BlockNewPeer(not_null<Window::SessionController*> window);
2018-09-11 22:00:23 +03:00
private:
void applySlice(const Api::BlockedPeers::Slice &slice);
void handleBlockedEvent(not_null<PeerData*> peer);
2018-09-11 22:00:23 +03:00
bool appendRow(not_null<PeerData*> peer);
bool prependRow(not_null<PeerData*> peer);
std::unique_ptr<PeerListRow> createRow(not_null<PeerData*> peer) const;
2018-09-11 22:00:23 +03:00
2019-07-24 16:00:30 +02:00
const not_null<Window::SessionController*> _window;
2018-09-11 22:00:23 +03:00
int _offset = 0;
bool _allLoaded = false;
base::has_weak_ptr _guard;
rpl::event_stream<int> _rowsCountChanges;
2018-09-11 22:00:23 +03:00
};
class PhoneNumberPrivacyController final : public EditPrivacyController {
public:
using Option = EditPrivacyBox::Option;
using Exception = EditPrivacyBox::Exception;
explicit PhoneNumberPrivacyController(
not_null<Window::SessionController*> controller);
Key key() const override;
rpl::producer<QString> title() const override;
rpl::producer<QString> optionsTitleKey() const override;
rpl::producer<TextWithEntities> warning() const override;
void prepareWarningLabel(not_null<Ui::FlatLabel*> warning) const override;
2019-06-18 14:16:43 +02:00
rpl::producer<QString> exceptionButtonTextKey(
Exception exception) const override;
rpl::producer<QString> exceptionBoxTitle(
Exception exception) const override;
rpl::producer<QString> exceptionsDescription() const override;
2019-08-29 11:44:03 +03:00
object_ptr<Ui::RpWidget> setupMiddleWidget(
not_null<Window::SessionController*> controller,
not_null<QWidget*> parent,
rpl::producer<Option> optionValue) override;
void saveAdditional() override;
private:
const not_null<Window::SessionController*> _controller;
2019-08-29 11:44:03 +03:00
rpl::variable<Option> _phoneNumberOption = { Option::Contacts };
rpl::variable<Option> _addedByPhone = { Option::Everyone };
Fn<void()> _saveAdditional;
};
class LastSeenPrivacyController final : public EditPrivacyController {
2018-09-11 22:00:23 +03:00
public:
using Option = EditPrivacyBox::Option;
using Exception = EditPrivacyBox::Exception;
2019-07-24 16:00:30 +02:00
explicit LastSeenPrivacyController(not_null<::Main::Session*> session);
Key key() const override;
2018-09-11 22:00:23 +03:00
rpl::producer<QString> title() const override;
rpl::producer<QString> optionsTitleKey() const override;
rpl::producer<TextWithEntities> warning() const override;
2019-06-18 14:16:43 +02:00
rpl::producer<QString> exceptionButtonTextKey(
Exception exception) const override;
rpl::producer<QString> exceptionBoxTitle(
Exception exception) const override;
rpl::producer<QString> exceptionsDescription() const override;
2018-09-11 22:00:23 +03:00
2024-01-09 13:13:30 +04:00
object_ptr<Ui::RpWidget> setupBelowWidget(
not_null<Window::SessionController*> controller,
not_null<QWidget*> parent) override;
2019-06-18 14:16:43 +02:00
void confirmSave(
bool someAreDisallowed,
Fn<void()> saveCallback) override;
2018-09-11 22:00:23 +03:00
2024-01-09 04:19:55 -08:00
void saveAdditional() override;
2019-07-24 16:00:30 +02:00
private:
const not_null<::Main::Session*> _session;
2024-01-09 13:13:30 +04:00
bool _hideReadTime = false;
2019-07-24 16:00:30 +02:00
2018-09-11 22:00:23 +03:00
};
class GroupsInvitePrivacyController final : public EditPrivacyController {
2018-09-11 22:00:23 +03:00
public:
using Option = EditPrivacyBox::Option;
using Exception = EditPrivacyBox::Exception;
Key key() const override;
2018-09-11 22:00:23 +03:00
rpl::producer<QString> title() const override;
rpl::producer<QString> optionsTitleKey() const override;
2019-06-18 14:16:43 +02:00
rpl::producer<QString> exceptionButtonTextKey(
Exception exception) const override;
rpl::producer<QString> exceptionBoxTitle(
Exception exception) const override;
rpl::producer<QString> exceptionsDescription() const override;
2018-09-11 22:00:23 +03:00
};
class CallsPrivacyController final : public EditPrivacyController {
2018-09-11 22:00:23 +03:00
public:
using Option = EditPrivacyBox::Option;
using Exception = EditPrivacyBox::Exception;
Key key() const override;
2018-09-11 22:00:23 +03:00
rpl::producer<QString> title() const override;
rpl::producer<QString> optionsTitleKey() const override;
2019-06-18 14:16:43 +02:00
rpl::producer<QString> exceptionButtonTextKey(
Exception exception) const override;
rpl::producer<QString> exceptionBoxTitle(
Exception exception) const override;
rpl::producer<QString> exceptionsDescription() const override;
object_ptr<Ui::RpWidget> setupBelowWidget(
2019-07-24 16:00:30 +02:00
not_null<Window::SessionController*> controller,
not_null<QWidget*> parent) override;
};
class CallsPeer2PeerPrivacyController final : public EditPrivacyController {
public:
using Option = EditPrivacyBox::Option;
using Exception = EditPrivacyBox::Exception;
Key key() const override;
rpl::producer<QString> title() const override;
rpl::producer<QString> optionsTitleKey() const override;
QString optionLabel(EditPrivacyBox::Option option) const override;
rpl::producer<TextWithEntities> warning() const override;
2019-06-18 14:16:43 +02:00
rpl::producer<QString> exceptionButtonTextKey(
Exception exception) const override;
rpl::producer<QString> exceptionBoxTitle(
Exception exception) const override;
rpl::producer<QString> exceptionsDescription() const override;
2018-09-11 22:00:23 +03:00
};
class ForwardsPrivacyController
: public EditPrivacyController
2019-05-14 12:50:44 +03:00
, private HistoryView::SimpleElementDelegate {
public:
using Option = EditPrivacyBox::Option;
using Exception = EditPrivacyBox::Exception;
2020-06-10 22:08:17 +04:00
explicit ForwardsPrivacyController(
not_null<Window::SessionController*> controller);
2019-07-24 16:00:30 +02:00
Key key() const override;
rpl::producer<QString> title() const override;
rpl::producer<QString> optionsTitleKey() const override;
rpl::producer<TextWithEntities> warning() const override;
2019-06-18 14:16:43 +02:00
rpl::producer<QString> exceptionButtonTextKey(
Exception exception) const override;
rpl::producer<QString> exceptionBoxTitle(
Exception exception) const override;
rpl::producer<QString> exceptionsDescription() const override;
object_ptr<Ui::RpWidget> setupAboveWidget(
not_null<QWidget*> parent,
rpl::producer<Option> optionValue,
not_null<QWidget*> outerContainer) override;
private:
using Element = HistoryView::Element;
not_null<HistoryView::ElementDelegate*> delegate();
HistoryView::Context elementContext() override;
2020-06-10 22:08:17 +04:00
const not_null<Window::SessionController*> _controller;
const std::unique_ptr<Ui::ChatStyle> _chatStyle;
2019-07-24 16:00:30 +02:00
};
class ProfilePhotoPrivacyController final : public EditPrivacyController {
public:
using Option = EditPrivacyBox::Option;
using Exception = EditPrivacyBox::Exception;
Key key() const override;
rpl::producer<QString> title() const override;
rpl::producer<QString> optionsTitleKey() const override;
2019-06-18 14:16:43 +02:00
rpl::producer<QString> exceptionButtonTextKey(
Exception exception) const override;
rpl::producer<QString> exceptionBoxTitle(
Exception exception) const override;
rpl::producer<QString> exceptionsDescription() const override;
void handleExceptionsChange(
Exception exception,
rpl::producer<int> value) override;
object_ptr<Ui::RpWidget> setupAboveWidget(
not_null<QWidget*> parent,
rpl::producer<Option> optionValue,
not_null<QWidget*> outerContainer) override;
object_ptr<Ui::RpWidget> setupMiddleWidget(
not_null<Window::SessionController*> controller,
not_null<QWidget*> parent,
rpl::producer<Option> optionValue) override;
void saveAdditional() override;
private:
Fn<void()> _saveAdditional;
rpl::variable<Option> _option;
rpl::variable<int> _exceptionsNever;
};
class VoicesPrivacyController final : public EditPrivacyController {
public:
using Option = EditPrivacyBox::Option;
using Exception = EditPrivacyBox::Exception;
explicit VoicesPrivacyController(not_null<::Main::Session*> session);
Key key() const override;
rpl::producer<QString> title() const override;
rpl::producer<QString> optionsTitleKey() const override;
rpl::producer<QString> exceptionButtonTextKey(
Exception exception) const override;
rpl::producer<QString> exceptionBoxTitle(
Exception exception) const override;
rpl::producer<QString> exceptionsDescription() const override;
private:
rpl::lifetime _lifetime;
};
2023-05-30 18:41:02 +04:00
class AboutPrivacyController final : public EditPrivacyController {
public:
using Option = EditPrivacyBox::Option;
using Exception = EditPrivacyBox::Exception;
Key key() const override;
rpl::producer<QString> title() const override;
rpl::producer<QString> optionsTitleKey() const override;
rpl::producer<QString> exceptionButtonTextKey(
Exception exception) const override;
rpl::producer<QString> exceptionBoxTitle(
Exception exception) const override;
rpl::producer<QString> exceptionsDescription() const override;
};
2018-09-11 22:00:23 +03:00
} // namespace Settings