mirror of
https://github.com/vale981/tdesktop
synced 2025-03-06 02:01:40 -05:00
Edit groups and channels invite privacy.
This commit is contained in:
parent
61c5b45d7a
commit
346daee421
7 changed files with 87 additions and 3 deletions
|
@ -406,6 +406,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_groups_invite_privacy" = "Groups invite privacy";
|
||||
"lng_settings_show_sessions" = "Show all sessions";
|
||||
"lng_settings_reset" = "Terminate all other sessions";
|
||||
"lng_settings_reset_sure" = "Are you sure you want to terminate\nall other sessions?";
|
||||
|
@ -456,6 +457,16 @@ Copyright (c) 2014-2017 John Preston, https://desktop.telegram.org
|
|||
"lng_edit_privacy_lastseen_always_title" = "Always share with";
|
||||
"lng_edit_privacy_lastseen_never_title" = "Never share with";
|
||||
|
||||
"lng_edit_privacy_groups_title" = "Group invite privacy";
|
||||
"lng_edit_privacy_groups_everyone" = "Anyone can invite me to groups and channels";
|
||||
"lng_edit_privacy_groups_contacts" = "Only contacts can invite me to groups and channels";
|
||||
"lng_edit_privacy_groups_description" = "You can restrict who can add you to groups and channels with granular precision.";
|
||||
"lng_edit_privacy_groups_always" = "Always allow{count:| # user| # users}";
|
||||
"lng_edit_privacy_groups_never" = "Never allow{count:| # user| # users}";
|
||||
"lng_edit_privacy_groups_exceptions" = "These users will or will not be able to add you to groups and channels regardless of the settings above.";
|
||||
"lng_edit_privacy_groups_always_title" = "Always allow";
|
||||
"lng_edit_privacy_groups_never_title" = "Never allow";
|
||||
|
||||
"lng_preview_loading" = "Getting Link Info...";
|
||||
|
||||
"lng_profile_chat_unaccessible" = "Group is inaccessible";
|
||||
|
|
|
@ -74,7 +74,6 @@ void PrivacyExceptionsBoxController::prepareViewHook() {
|
|||
|
||||
void PrivacyExceptionsBoxController::rowClicked(PeerListBox::Row *row) {
|
||||
view()->setRowChecked(row, !row->checked());
|
||||
view()->updateRow(row);
|
||||
}
|
||||
|
||||
std::unique_ptr<PrivacyExceptionsBoxController::Row> PrivacyExceptionsBoxController::createRow(History *history) {
|
||||
|
@ -190,12 +189,12 @@ int EditPrivacyBox::countDefaultHeight(int newWidth) {
|
|||
auto value = static_cast<int>(Option::Everyone);
|
||||
auto selected = false;
|
||||
auto fake = object_ptr<OptionWidget>(nullptr, value, selected, label, description);
|
||||
fake->resizeToWidth(newWidth);
|
||||
fake->resizeToNaturalWidth(newWidth - st::editPrivacyOptionMargin.left() - st::editPrivacyOptionMargin.right());
|
||||
return st::editPrivacyOptionMargin.top() + fake->heightNoMargins() + st::editPrivacyOptionMargin.bottom();
|
||||
};
|
||||
auto labelHeight = [this, newWidth](const QString &text, const style::FlatLabel &st) {
|
||||
auto fake = object_ptr<Ui::FlatLabel>(nullptr, text, Ui::FlatLabel::InitType::Simple, st);
|
||||
fake->resizeToWidth(newWidth);
|
||||
fake->resizeToNaturalWidth(newWidth - st::editPrivacyPadding.left() - st::editPrivacyPadding.right());
|
||||
return st::editPrivacyPadding.top() + fake->heightNoMargins() + st::editPrivacyPadding.bottom();
|
||||
};
|
||||
auto linkMargins = exceptionLinkMargins();
|
||||
|
|
|
@ -141,9 +141,14 @@ void PeerListBox::setRowChecked(Row *row, bool checked) {
|
|||
if (checked) {
|
||||
addSelectItem(peer, Row::SetStyle::Animated);
|
||||
_inner->changeCheckState(row, checked, Row::SetStyle::Animated);
|
||||
updateRow(row);
|
||||
|
||||
// This call deletes row from _globalSearchRows.
|
||||
_select->entity()->clearQuery();
|
||||
} else {
|
||||
// The itemRemovedCallback will call changeCheckState() here.
|
||||
_select->entity()->removeItem(peer->id);
|
||||
updateRow(row);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -265,4 +265,49 @@ QString LastSeenPrivacyController::exceptionsDescription() {
|
|||
return lang(lng_edit_privacy_lastseen_exceptions);
|
||||
}
|
||||
|
||||
MTPInputPrivacyKey GroupsInvitePrivacyController::key() {
|
||||
return MTP_inputPrivacyKeyChatInvite();
|
||||
}
|
||||
|
||||
void GroupsInvitePrivacyController::save(QVector<MTPInputPrivacyRule> &&result) {
|
||||
MTP::send(MTPaccount_SetPrivacy(MTP_inputPrivacyKeyChatInvite(), MTP_vector<MTPInputPrivacyRule>(result)));
|
||||
view()->closeBox();
|
||||
}
|
||||
|
||||
QString GroupsInvitePrivacyController::title() {
|
||||
return lang(lng_edit_privacy_groups_title);
|
||||
}
|
||||
|
||||
QString GroupsInvitePrivacyController::optionDescription(Option option) {
|
||||
switch (option) {
|
||||
case Option::Everyone: return lang(lng_edit_privacy_groups_everyone);
|
||||
case Option::Contacts: return lang(lng_edit_privacy_groups_contacts);
|
||||
}
|
||||
return QString();
|
||||
}
|
||||
|
||||
QString GroupsInvitePrivacyController::description() {
|
||||
return lang(lng_edit_privacy_groups_description);
|
||||
}
|
||||
|
||||
QString GroupsInvitePrivacyController::exceptionLinkText(Exception exception, int count) {
|
||||
switch (exception) {
|
||||
case Exception::Always: return lng_edit_privacy_groups_always(lt_count, count);
|
||||
case Exception::Never: return lng_edit_privacy_groups_never(lt_count, count);
|
||||
}
|
||||
Unexpected("Invalid exception value.");
|
||||
}
|
||||
|
||||
QString GroupsInvitePrivacyController::exceptionBoxTitle(Exception exception) {
|
||||
switch (exception) {
|
||||
case Exception::Always: return lang(lng_edit_privacy_groups_always_title);
|
||||
case Exception::Never: return lang(lng_edit_privacy_groups_never_title);
|
||||
}
|
||||
Unexpected("Invalid exception value.");
|
||||
}
|
||||
|
||||
QString GroupsInvitePrivacyController::exceptionsDescription() {
|
||||
return lang(lng_edit_privacy_groups_exceptions);
|
||||
}
|
||||
|
||||
} // namespace Settings
|
||||
|
|
|
@ -64,4 +64,21 @@ public:
|
|||
|
||||
};
|
||||
|
||||
class GroupsInvitePrivacyController : public EditPrivacyBox::Controller, private base::Subscriber {
|
||||
public:
|
||||
using Option = EditPrivacyBox::Option;
|
||||
using Exception = EditPrivacyBox::Exception;
|
||||
|
||||
MTPInputPrivacyKey key() override;
|
||||
void save(QVector<MTPInputPrivacyRule> &&result) override;
|
||||
|
||||
QString title() override;
|
||||
QString optionDescription(Option option) override;
|
||||
QString description() override;
|
||||
QString exceptionLinkText(Exception exception, int count) override;
|
||||
QString exceptionBoxTitle(Exception exception) override;
|
||||
QString exceptionsDescription() override;
|
||||
|
||||
};
|
||||
|
||||
} // namespace Settings
|
||||
|
|
|
@ -175,6 +175,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(_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);
|
||||
auto value = (Global::AutoLock() % 3600) ? lng_passcode_autolock_minutes(lt_count, Global::AutoLock() / 60) : lng_passcode_autolock_hours(lt_count, Global::AutoLock() / 3600);
|
||||
|
@ -203,6 +204,10 @@ void PrivacyWidget::onLastSeenPrivacy() {
|
|||
Ui::show(Box<EditPrivacyBox>(std::make_unique<LastSeenPrivacyController>()));
|
||||
}
|
||||
|
||||
void PrivacyWidget::onGroupsInvitePrivacy() {
|
||||
Ui::show(Box<EditPrivacyBox>(std::make_unique<GroupsInvitePrivacyController>()));
|
||||
}
|
||||
|
||||
void PrivacyWidget::onAutoLock() {
|
||||
Ui::show(Box<AutoLockBox>());
|
||||
}
|
||||
|
|
|
@ -87,6 +87,7 @@ public:
|
|||
private slots:
|
||||
void onBlockedUsers();
|
||||
void onLastSeenPrivacy();
|
||||
void onGroupsInvitePrivacy();
|
||||
void onAutoLock();
|
||||
void onShowSessions();
|
||||
|
||||
|
@ -96,6 +97,7 @@ private:
|
|||
|
||||
object_ptr<Ui::LinkButton> _blockedUsers = { nullptr };
|
||||
object_ptr<Ui::LinkButton> _lastSeenPrivacy = { nullptr };
|
||||
object_ptr<Ui::LinkButton> _groupsInvitePrivacy = { nullptr };
|
||||
object_ptr<LocalPasscodeState> _localPasscodeState = { nullptr };
|
||||
object_ptr<Ui::WidgetSlideWrap<LabeledLink>> _autoLock = { nullptr };
|
||||
object_ptr<CloudPasswordState> _cloudPasswordState = { nullptr };
|
||||
|
|
Loading…
Add table
Reference in a new issue