From a3252c13d7120e3700e29061120875ccdea5ee64 Mon Sep 17 00:00:00 2001 From: John Preston Date: Sat, 29 Apr 2017 18:32:01 +0300 Subject: [PATCH] Edit phone calls privacy in Settings. --- Telegram/Resources/langs/lang.strings | 9 ++++++ .../settings/settings_privacy_controllers.cpp | 32 +++++++++++++++++++ .../settings/settings_privacy_controllers.h | 15 +++++++++ .../settings/settings_privacy_widget.cpp | 5 +++ .../settings/settings_privacy_widget.h | 2 ++ 5 files changed, 63 insertions(+) diff --git a/Telegram/Resources/langs/lang.strings b/Telegram/Resources/langs/lang.strings index de94b6a60c..4f69ceed15 100644 --- a/Telegram/Resources/langs/lang.strings +++ b/Telegram/Resources/langs/lang.strings @@ -408,6 +408,7 @@ Copyright (c) 2014-2017 John Preston, https://desktop.telegram.org "lng_settings_blocked_users" = "Blocked users"; "lng_settings_last_seen_privacy" = "Last seen privacy"; +"lng_settings_calls_privacy" = "Phone calls privacy"; "lng_settings_groups_invite_privacy" = "Group invite settings"; "lng_settings_show_sessions" = "Show all sessions"; "lng_settings_self_destruct" = "Account self-destruct settings"; @@ -468,6 +469,14 @@ Copyright (c) 2014-2017 John Preston, https://desktop.telegram.org "lng_edit_privacy_groups_always_title" = "Always allow"; "lng_edit_privacy_groups_never_title" = "Never allow"; +"lng_edit_privacy_calls_title" = "Phone calls privacy"; +"lng_edit_privacy_calls_description" = "You can restrict who can call you:"; +"lng_edit_privacy_calls_always" = "Always allow{count:| # user| # users}"; +"lng_edit_privacy_calls_never" = "Never allow{count:| # user| # users}"; +"lng_edit_privacy_calls_exceptions" = "These users will or will not be able to call you regardless of the settings above."; +"lng_edit_privacy_calls_always_title" = "Always allow"; +"lng_edit_privacy_calls_never_title" = "Never allow"; + "lng_self_destruct_title" = "Account self-destruction"; "lng_self_destruct_description" = "If you don't come online at least once within this period, your account will be deleted along with all groups, messages and contacts."; "lng_self_destruct_months" = "{count:_not_used_|# month|# months}"; diff --git a/Telegram/SourceFiles/settings/settings_privacy_controllers.cpp b/Telegram/SourceFiles/settings/settings_privacy_controllers.cpp index 00fc8e8693..ebcafae10e 100644 --- a/Telegram/SourceFiles/settings/settings_privacy_controllers.cpp +++ b/Telegram/SourceFiles/settings/settings_privacy_controllers.cpp @@ -308,4 +308,36 @@ QString GroupsInvitePrivacyController::exceptionsDescription() { return lang(lng_edit_privacy_groups_exceptions); } +MTPInputPrivacyKey CallsPrivacyController::key() { + return MTP_inputPrivacyKeyPhoneCall(); +} + +QString CallsPrivacyController::title() { + return lang(lng_edit_privacy_calls_title); +} + +QString CallsPrivacyController::description() { + return lang(lng_edit_privacy_calls_description); +} + +QString CallsPrivacyController::exceptionLinkText(Exception exception, int count) { + switch (exception) { + case Exception::Always: return lng_edit_privacy_calls_always(lt_count, count); + case Exception::Never: return lng_edit_privacy_calls_never(lt_count, count); + } + Unexpected("Invalid exception value."); +} + +QString CallsPrivacyController::exceptionBoxTitle(Exception exception) { + switch (exception) { + case Exception::Always: return lang(lng_edit_privacy_calls_always_title); + case Exception::Never: return lang(lng_edit_privacy_calls_never_title); + } + Unexpected("Invalid exception value."); +} + +QString CallsPrivacyController::exceptionsDescription() { + return lang(lng_edit_privacy_calls_exceptions); +} + } // namespace Settings diff --git a/Telegram/SourceFiles/settings/settings_privacy_controllers.h b/Telegram/SourceFiles/settings/settings_privacy_controllers.h index 678b99c9b6..b3bc26d555 100644 --- a/Telegram/SourceFiles/settings/settings_privacy_controllers.h +++ b/Telegram/SourceFiles/settings/settings_privacy_controllers.h @@ -82,4 +82,19 @@ public: }; +class CallsPrivacyController : public EditPrivacyBox::Controller, private base::Subscriber { +public: + using Option = EditPrivacyBox::Option; + using Exception = EditPrivacyBox::Exception; + + MTPInputPrivacyKey key() override; + + QString title() override; + QString description() override; + QString exceptionLinkText(Exception exception, int count) override; + QString exceptionBoxTitle(Exception exception) override; + QString exceptionsDescription() override; + +}; + } // namespace Settings diff --git a/Telegram/SourceFiles/settings/settings_privacy_widget.cpp b/Telegram/SourceFiles/settings/settings_privacy_widget.cpp index a28d58cd00..f35b4814c6 100644 --- a/Telegram/SourceFiles/settings/settings_privacy_widget.cpp +++ b/Telegram/SourceFiles/settings/settings_privacy_widget.cpp @@ -176,6 +176,7 @@ void PrivacyWidget::createControls() { addChildRow(_blockedUsers, marginSmall, lang(lng_settings_blocked_users), SLOT(onBlockedUsers())); addChildRow(_lastSeenPrivacy, marginSmall, lang(lng_settings_last_seen_privacy), SLOT(onLastSeenPrivacy())); + addChildRow(_callsPrivacy, marginSmall, lang(lng_settings_calls_privacy), SLOT(onCallsPrivacy())); addChildRow(_groupsInvitePrivacy, marginSmall, lang(lng_settings_groups_invite_privacy), SLOT(onGroupsInvitePrivacy())); addChildRow(_localPasscodeState, marginSmall); auto label = lang(psIdleSupported() ? lng_passcode_autolock_away : lng_passcode_autolock_inactive); @@ -206,6 +207,10 @@ void PrivacyWidget::onLastSeenPrivacy() { Ui::show(Box(std::make_unique())); } +void PrivacyWidget::onCallsPrivacy() { + Ui::show(Box(std::make_unique())); +} + void PrivacyWidget::onGroupsInvitePrivacy() { Ui::show(Box(std::make_unique())); } diff --git a/Telegram/SourceFiles/settings/settings_privacy_widget.h b/Telegram/SourceFiles/settings/settings_privacy_widget.h index 00a11ea969..2af6c689b8 100644 --- a/Telegram/SourceFiles/settings/settings_privacy_widget.h +++ b/Telegram/SourceFiles/settings/settings_privacy_widget.h @@ -87,6 +87,7 @@ public: private slots: void onBlockedUsers(); void onLastSeenPrivacy(); + void onCallsPrivacy(); void onGroupsInvitePrivacy(); void onAutoLock(); void onShowSessions(); @@ -98,6 +99,7 @@ private: object_ptr _blockedUsers = { nullptr }; object_ptr _lastSeenPrivacy = { nullptr }; + object_ptr _callsPrivacy = { nullptr }; object_ptr _groupsInvitePrivacy = { nullptr }; object_ptr _localPasscodeState = { nullptr }; object_ptr> _autoLock = { nullptr };