diff --git a/Telegram/Resources/langs/lang.strings b/Telegram/Resources/langs/lang.strings index 96ee55649e..45f656430e 100644 --- a/Telegram/Resources/langs/lang.strings +++ b/Telegram/Resources/langs/lang.strings @@ -355,9 +355,11 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL "lng_settings_privacy_title" = "Privacy"; "lng_settings_last_seen" = "Last seen"; "lng_settings_calls" = "Voice calls"; -"lng_settings_calls_peer_to_peer" = "Peer-to-peer in calls"; +"lng_settings_calls_peer_to_peer_title" = "Peer-to-peer"; +"lng_settings_calls_peer_to_peer_button" = "Use peer-to-peer with"; "lng_settings_groups_invite" = "Groups"; "lng_settings_group_privacy_about" = "Change who can add you to groups and channels."; +"lng_settings_phone_number_privacy" = "Phone number"; "lng_settings_forwards_privacy" = "Forwarded messages"; "lng_settings_profile_photo_privacy" = "Profile photo"; "lng_settings_sessions_about" = "Control your sessions on other devices."; @@ -604,6 +606,15 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL "lng_edit_privacy_exceptions_count#other" = "{count} users"; "lng_edit_privacy_exceptions_add" = "Add users or groups"; +"lng_edit_privacy_phone_number_title" = "Phone number privacy"; +"lng_edit_privacy_phone_number_header" = "Who can see your phone number"; +"lng_edit_privacy_phone_number_warning" = "Important: blabla."; +"lng_edit_privacy_phone_number_always_empty" = "Always share with"; +"lng_edit_privacy_phone_number_never_empty" = "Never share with"; +"lng_edit_privacy_phone_number_exceptions" = "These settings will override the values above."; +"lng_edit_privacy_phone_number_always_title" = "Always share with"; +"lng_edit_privacy_phone_number_never_title" = "Never share with"; + "lng_edit_privacy_lastseen_title" = "Last seen privacy"; "lng_edit_privacy_lastseen_header" = "Who can see your last seen time"; "lng_edit_privacy_lastseen_warning" = "Important: you won't be able to see Last Seen times for people with whom you don't share your Last Seen time. Approximate last seen will be shown instead (recently, within a week, within a month)."; diff --git a/Telegram/SourceFiles/apiwrap.cpp b/Telegram/SourceFiles/apiwrap.cpp index ccda0bb4fd..f80ebd13a0 100644 --- a/Telegram/SourceFiles/apiwrap.cpp +++ b/Telegram/SourceFiles/apiwrap.cpp @@ -173,6 +173,7 @@ MTPInputPrivacyKey ApiWrap::Privacy::Input(Key key) { switch (key) { case Privacy::Key::Calls: return MTP_inputPrivacyKeyPhoneCall(); case Privacy::Key::Invites: return MTP_inputPrivacyKeyChatInvite(); + case Privacy::Key::PhoneNumber: return MTP_inputPrivacyKeyPhoneNumber(); case Privacy::Key::LastSeen: return MTP_inputPrivacyKeyStatusTimestamp(); case Privacy::Key::CallsPeer2Peer: @@ -189,6 +190,8 @@ std::optional ApiWrap::Privacy::KeyFromMTP( mtpTypeId type) { using Key = Privacy::Key; switch (type) { + case mtpc_privacyKeyPhoneNumber: + case mtpc_inputPrivacyKeyPhoneNumber: return Key::PhoneNumber; case mtpc_privacyKeyStatusTimestamp: case mtpc_inputPrivacyKeyStatusTimestamp: return Key::LastSeen; case mtpc_privacyKeyChatInvite: diff --git a/Telegram/SourceFiles/apiwrap.h b/Telegram/SourceFiles/apiwrap.h index 32a6564d71..51bcbeaa6f 100644 --- a/Telegram/SourceFiles/apiwrap.h +++ b/Telegram/SourceFiles/apiwrap.h @@ -62,6 +62,7 @@ class ApiWrap : public MTP::Sender, private base::Subscriber { public: struct Privacy { enum class Key { + PhoneNumber, LastSeen, Calls, Invites, diff --git a/Telegram/SourceFiles/boxes/edit_privacy_box.cpp b/Telegram/SourceFiles/boxes/edit_privacy_box.cpp index 983a1c21cb..98fda2c807 100644 --- a/Telegram/SourceFiles/boxes/edit_privacy_box.cpp +++ b/Telegram/SourceFiles/boxes/edit_privacy_box.cpp @@ -100,7 +100,7 @@ std::unique_ptr PrivacyExceptionsBoxControl } // namespace -LangKey EditPrivacyBox::Controller::optionLabelKey(Option option) { +LangKey EditPrivacyController::optionLabelKey(Option option) { switch (option) { case Option::Everyone: return lng_edit_privacy_everyone; case Option::Contacts: return lng_edit_privacy_contacts; @@ -111,7 +111,7 @@ LangKey EditPrivacyBox::Controller::optionLabelKey(Option option) { EditPrivacyBox::EditPrivacyBox( QWidget*, - std::unique_ptr controller, + std::unique_ptr controller, const Value &value) : _controller(std::move(controller)) , _value(value) { @@ -350,6 +350,10 @@ void EditPrivacyBox::setupContent() { addLabel(content, _controller->exceptionsDescription()); AddSkip(content); + if (auto below = _controller->setupBelowWidget(content)) { + content->add(std::move(below)); + } + addButton(langFactory(lng_settings_save), [=] { const auto someAreDisallowed = (_value.option != Option::Everyone) || !_value.never.empty(); diff --git a/Telegram/SourceFiles/boxes/edit_privacy_box.h b/Telegram/SourceFiles/boxes/edit_privacy_box.h index cd56368293..4d44db5428 100644 --- a/Telegram/SourceFiles/boxes/edit_privacy_box.h +++ b/Telegram/SourceFiles/boxes/edit_privacy_box.h @@ -25,71 +25,79 @@ template class SlideWrap; } // namespace Ui -class EditPrivacyBox : public BoxContent, private MTP::Sender { +class EditPrivacyBox; + +class EditPrivacyController { public: - using Value = ApiWrap::Privacy; - using Option = Value::Option; + using Key = ApiWrap::Privacy::Key; + using Option = ApiWrap::Privacy::Option; enum class Exception { Always, Never, }; - class Controller { - public: - using Key = ApiWrap::Privacy::Key; + [[nodiscard]] virtual Key key() = 0; + [[nodiscard]] virtual MTPInputPrivacyKey apiKey() = 0; - [[nodiscard]] virtual Key key() = 0; - [[nodiscard]] virtual MTPInputPrivacyKey apiKey() = 0; + [[nodiscard]] virtual QString title() = 0; + [[nodiscard]] virtual bool hasOption(Option option) { + return true; + } + [[nodiscard]] virtual LangKey optionsTitleKey() = 0; + [[nodiscard]] virtual LangKey optionLabelKey(Option option); + [[nodiscard]] virtual rpl::producer warning() { + return rpl::never(); + } + [[nodiscard]] virtual LangKey exceptionButtonTextKey( + Exception exception) = 0; + [[nodiscard]] virtual QString exceptionBoxTitle( + Exception exception) = 0; + [[nodiscard]] virtual auto exceptionsDescription() + -> rpl::producer = 0; - [[nodiscard]] virtual QString title() = 0; - [[nodiscard]] virtual bool hasOption(Option option) { - return true; - } - [[nodiscard]] virtual LangKey optionsTitleKey() = 0; - [[nodiscard]] virtual LangKey optionLabelKey(Option option); - [[nodiscard]] virtual rpl::producer warning() { - return rpl::never(); - } - [[nodiscard]] virtual LangKey exceptionButtonTextKey( - Exception exception) = 0; - [[nodiscard]] virtual QString exceptionBoxTitle( - Exception exception) = 0; - [[nodiscard]] virtual auto exceptionsDescription() - -> rpl::producer = 0; + [[nodiscard]] virtual object_ptr setupAboveWidget( + not_null parent, + rpl::producer