Edit phone calls privacy in Settings.

This commit is contained in:
John Preston 2017-04-29 18:32:01 +03:00
parent 30d000e139
commit a3252c13d7
5 changed files with 63 additions and 0 deletions

View File

@ -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}";

View File

@ -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

View File

@ -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

View File

@ -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<EditPrivacyBox>(std::make_unique<LastSeenPrivacyController>()));
}
void PrivacyWidget::onCallsPrivacy() {
Ui::show(Box<EditPrivacyBox>(std::make_unique<CallsPrivacyController>()));
}
void PrivacyWidget::onGroupsInvitePrivacy() {
Ui::show(Box<EditPrivacyBox>(std::make_unique<GroupsInvitePrivacyController>()));
}

View File

@ -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<Ui::LinkButton> _blockedUsers = { nullptr };
object_ptr<Ui::LinkButton> _lastSeenPrivacy = { nullptr };
object_ptr<Ui::LinkButton> _callsPrivacy = { nullptr };
object_ptr<Ui::LinkButton> _groupsInvitePrivacy = { nullptr };
object_ptr<LocalPasscodeState> _localPasscodeState = { nullptr };
object_ptr<Ui::WidgetSlideWrap<LabeledLink>> _autoLock = { nullptr };