mirror of
https://github.com/kotatogram/kotatogram-desktop
synced 2025-08-31 06:35:14 +00:00
Adjust privacy edit boxes to the mockup.
This commit is contained in:
@@ -124,71 +124,50 @@ void SetupPrivacy(
|
||||
AddSubsectionTitle(container, tr::lng_settings_privacy_title());
|
||||
|
||||
const auto session = &controller->session();
|
||||
auto count = rpl::combine(
|
||||
BlockedPeersCount(session),
|
||||
tr::lng_settings_no_blocked_users()
|
||||
) | rpl::map([](int count, const QString &none) {
|
||||
return count ? QString::number(count) : none;
|
||||
});
|
||||
const auto blockedPeers = AddButtonWithLabel(
|
||||
container,
|
||||
tr::lng_settings_blocked_users(),
|
||||
std::move(count),
|
||||
st::settingsButton);
|
||||
blockedPeers->addClickHandler([=] {
|
||||
const auto initBox = [=](not_null<PeerListBox*> box) {
|
||||
box->addButton(tr::lng_close(), [=] {
|
||||
box->closeBox();
|
||||
});
|
||||
box->addLeftButton(tr::lng_blocked_list_add(), [=] {
|
||||
BlockedBoxController::BlockNewPeer(controller);
|
||||
});
|
||||
};
|
||||
controller->show(Box<PeerListBox>(
|
||||
std::make_unique<BlockedBoxController>(controller),
|
||||
initBox));
|
||||
});
|
||||
std::move(
|
||||
updateTrigger
|
||||
) | rpl::start_with_next([=] {
|
||||
session->api().blockedPeers().reload();
|
||||
}, blockedPeers->lifetime());
|
||||
|
||||
using Key = Privacy::Key;
|
||||
const auto add = [&](
|
||||
rpl::producer<QString> label,
|
||||
IconDescriptor &&descriptor,
|
||||
Key key,
|
||||
auto controllerFactory) {
|
||||
AddPrivacyButton(
|
||||
controller,
|
||||
container,
|
||||
std::move(label),
|
||||
std::move(descriptor),
|
||||
key,
|
||||
controllerFactory);
|
||||
};
|
||||
add(
|
||||
tr::lng_settings_phone_number_privacy(),
|
||||
{ &st::settingsIconCalls, kIconGreen },
|
||||
Key::PhoneNumber,
|
||||
[] { return std::make_unique<PhoneNumberPrivacyController>(); });
|
||||
add(
|
||||
tr::lng_settings_last_seen(),
|
||||
{ &st::settingsIconOnline, kIconLightBlue },
|
||||
Key::LastSeen,
|
||||
[=] { return std::make_unique<LastSeenPrivacyController>(session); });
|
||||
add(
|
||||
tr::lng_settings_forwards_privacy(),
|
||||
{ &st::settingsIconForward, kIconLightOrange },
|
||||
Key::Forwards,
|
||||
[=] { return std::make_unique<ForwardsPrivacyController>(
|
||||
controller); });
|
||||
add(
|
||||
tr::lng_settings_profile_photo_privacy(),
|
||||
{ &st::settingsIconAccount, kIconRed },
|
||||
Key::ProfilePhoto,
|
||||
[] { return std::make_unique<ProfilePhotoPrivacyController>(); });
|
||||
add(
|
||||
tr::lng_settings_calls(),
|
||||
{ &st::settingsIconVideoCalls, kIconGreen },
|
||||
Key::Calls,
|
||||
[] { return std::make_unique<CallsPrivacyController>(); });
|
||||
add(
|
||||
tr::lng_settings_groups_invite(),
|
||||
{ &st::settingsIconGroup, kIconDarkBlue },
|
||||
Key::Invites,
|
||||
[] { return std::make_unique<GroupsInvitePrivacyController>(); });
|
||||
|
||||
@@ -219,7 +198,7 @@ void SetupArchiveAndMute(
|
||||
AddButton(
|
||||
inner,
|
||||
tr::lng_settings_auto_archive(),
|
||||
st::settingsButton
|
||||
st::settingsButtonNoIcon
|
||||
)->toggleOn(
|
||||
privacy->archiveAndMute()
|
||||
)->toggledChanges(
|
||||
@@ -245,7 +224,8 @@ void SetupLocalPasscode(
|
||||
not_null<Window::SessionController*> controller,
|
||||
not_null<Ui::VerticalLayout*> container) {
|
||||
AddSkip(container);
|
||||
AddSubsectionTitle(container, tr::lng_settings_passcode_title());
|
||||
AddDivider(container);
|
||||
AddSkip(container);
|
||||
|
||||
auto has = rpl::single(
|
||||
rpl::empty_value()
|
||||
@@ -261,11 +241,11 @@ void SetupLocalPasscode(
|
||||
[](const QString &change, const QString &create, bool has) {
|
||||
return has ? change : create;
|
||||
});
|
||||
container->add(
|
||||
object_ptr<Button>(
|
||||
container,
|
||||
std::move(text),
|
||||
st::settingsButton)
|
||||
AddButton(
|
||||
container,
|
||||
std::move(text),
|
||||
st::settingsButton,
|
||||
{ &st::settingsIconLock, kIconGreen }
|
||||
)->addClickHandler([=] {
|
||||
controller->show(Box<PasscodeBox>(&controller->session(), false));
|
||||
});
|
||||
@@ -275,11 +255,11 @@ void SetupLocalPasscode(
|
||||
container,
|
||||
object_ptr<Ui::VerticalLayout>(container)));
|
||||
const auto inner = wrap->entity();
|
||||
inner->add(
|
||||
object_ptr<Button>(
|
||||
inner,
|
||||
tr::lng_settings_passcode_disable(),
|
||||
st::settingsButton)
|
||||
AddButton(
|
||||
inner,
|
||||
tr::lng_settings_passcode_disable(),
|
||||
st::settingsButton,
|
||||
{ &st::settingsIconMinus, kIconRed }
|
||||
)->addClickHandler([=] {
|
||||
controller->show(Box<PasscodeBox>(&controller->session(), true));
|
||||
});
|
||||
@@ -318,7 +298,8 @@ void SetupLocalPasscode(
|
||||
inner,
|
||||
label(),
|
||||
std::move(value),
|
||||
st::settingsButton
|
||||
st::settingsButton,
|
||||
{ &st::settingsIconTimer, kIconGreen }
|
||||
)->addClickHandler([=] {
|
||||
const auto box = controller->show(Box<AutoLockBox>());
|
||||
box->boxClosing(
|
||||
@@ -326,8 +307,6 @@ void SetupLocalPasscode(
|
||||
});
|
||||
|
||||
wrap->toggleOn(base::duplicate(has));
|
||||
|
||||
AddSkip(container);
|
||||
}
|
||||
|
||||
void SetupCloudPassword(
|
||||
@@ -336,9 +315,9 @@ void SetupCloudPassword(
|
||||
using namespace rpl::mappers;
|
||||
using State = Core::CloudPasswordState;
|
||||
|
||||
AddSkip(container);
|
||||
AddDivider(container);
|
||||
AddSkip(container);
|
||||
AddSubsectionTitle(container, tr::lng_settings_password_title());
|
||||
|
||||
const auto session = &controller->session();
|
||||
auto has = rpl::single(
|
||||
@@ -384,12 +363,12 @@ void SetupCloudPassword(
|
||||
base::duplicate(confirmation),
|
||||
st::settingsCloudPasswordLabel),
|
||||
QMargins(
|
||||
st::settingsButton.padding.left(),
|
||||
st::settingsButton.padding.top(),
|
||||
st::settingsButton.padding.right(),
|
||||
(st::settingsButton.height
|
||||
st::settingsButtonNoIcon.padding.left(),
|
||||
st::settingsButtonNoIcon.padding.top(),
|
||||
st::settingsButtonNoIcon.padding.right(),
|
||||
(st::settingsButtonNoIcon.height
|
||||
- st::settingsCloudPasswordLabel.style.font->height
|
||||
+ st::settingsButton.padding.bottom()))));
|
||||
+ st::settingsButtonNoIcon.padding.bottom()))));
|
||||
label->toggleOn(base::duplicate(noconfirmed))->setDuration(0);
|
||||
|
||||
std::move(
|
||||
@@ -408,10 +387,11 @@ void SetupCloudPassword(
|
||||
const auto change = container->add(
|
||||
object_ptr<Ui::SlideWrap<Button>>(
|
||||
container,
|
||||
object_ptr<Button>(
|
||||
CreateButton(
|
||||
container,
|
||||
std::move(text),
|
||||
st::settingsButton)));
|
||||
st::settingsButton,
|
||||
{ &st::settingsIconKey, kIconLightBlue })));
|
||||
change->toggleOn(rpl::duplicate(
|
||||
noconfirmed
|
||||
) | rpl::map(
|
||||
@@ -428,10 +408,11 @@ void SetupCloudPassword(
|
||||
const auto confirm = container->add(
|
||||
object_ptr<Ui::SlideWrap<Button>>(
|
||||
container,
|
||||
object_ptr<Button>(
|
||||
CreateButton(
|
||||
container,
|
||||
tr::lng_cloud_password_confirm(),
|
||||
st::settingsButton)));
|
||||
st::settingsButton,
|
||||
{ &st::settingsIconEmail, kIconLightOrange })));
|
||||
confirm->toggleOn(rpl::single(
|
||||
false
|
||||
) | rpl::then(rpl::duplicate(
|
||||
@@ -471,10 +452,11 @@ void SetupCloudPassword(
|
||||
const auto disable = container->add(
|
||||
object_ptr<Ui::SlideWrap<Button>>(
|
||||
container,
|
||||
object_ptr<Button>(
|
||||
CreateButton(
|
||||
container,
|
||||
tr::lng_settings_password_disable(),
|
||||
st::settingsButton)));
|
||||
st::settingsButton,
|
||||
{ &st::settingsIconMinus, kIconRed })));
|
||||
disable->toggleOn(rpl::combine(
|
||||
rpl::duplicate(has),
|
||||
rpl::duplicate(noconfirmed),
|
||||
@@ -543,7 +525,7 @@ void SetupCloudPassword(
|
||||
const auto reset = container->add(
|
||||
object_ptr<Ui::SlideWrap<Button>>(
|
||||
container,
|
||||
object_ptr<Button>(
|
||||
CreateButton(
|
||||
container,
|
||||
rpl::duplicate(resetText),
|
||||
st::settingsButton))
|
||||
@@ -596,7 +578,7 @@ void SetupCloudPassword(
|
||||
const auto abort = container->add(
|
||||
object_ptr<Ui::SlideWrap<Button>>(
|
||||
container,
|
||||
object_ptr<Button>(
|
||||
CreateButton(
|
||||
container,
|
||||
tr::lng_settings_password_abort(),
|
||||
st::settingsAttentionButton)));
|
||||
@@ -648,7 +630,7 @@ void SetupSensitiveContent(
|
||||
AddButton(
|
||||
inner,
|
||||
tr::lng_settings_sensitive_disable_filtering(),
|
||||
st::settingsButton
|
||||
st::settingsButtonNoIcon
|
||||
)->toggleOn(
|
||||
session->api().sensitiveContent().enabled()
|
||||
)->toggledChanges(
|
||||
@@ -689,7 +671,7 @@ void SetupSelfDestruction(
|
||||
container,
|
||||
tr::lng_settings_destroy_if(),
|
||||
label(),
|
||||
st::settingsButton
|
||||
st::settingsButtonNoIcon
|
||||
)->addClickHandler([=] {
|
||||
controller->show(Box<SelfDestructionBox>(
|
||||
session,
|
||||
@@ -769,7 +751,7 @@ void SetupBotsAndWebsites(
|
||||
AddButton(
|
||||
container,
|
||||
tr::lng_settings_clear_payment_info(),
|
||||
st::settingsButton
|
||||
st::settingsButtonNoIcon
|
||||
)->addClickHandler([=] {
|
||||
controller->show(ClearPaymentInfoBox(session));
|
||||
});
|
||||
@@ -777,14 +759,49 @@ void SetupBotsAndWebsites(
|
||||
AddSkip(container);
|
||||
}
|
||||
|
||||
void SetupBlockedList(
|
||||
not_null<Window::SessionController*> controller,
|
||||
not_null<Ui::VerticalLayout*> container,
|
||||
rpl::producer<> updateTrigger,
|
||||
Fn<void(Type)> showOther) {
|
||||
const auto session = &controller->session();
|
||||
auto blockedCount = rpl::combine(
|
||||
BlockedPeersCount(session),
|
||||
tr::lng_settings_no_blocked_users()
|
||||
) | rpl::map([](int count, const QString &none) {
|
||||
return count ? QString::number(count) : none;
|
||||
});
|
||||
const auto blockedPeers = AddButtonWithLabel(
|
||||
container,
|
||||
tr::lng_settings_blocked_users(),
|
||||
std::move(blockedCount),
|
||||
st::settingsButton,
|
||||
{ &st::settingsIconMinus, kIconRed });
|
||||
blockedPeers->addClickHandler([=] {
|
||||
const auto initBox = [=](not_null<PeerListBox*> box) {
|
||||
box->addButton(tr::lng_close(), [=] {
|
||||
box->closeBox();
|
||||
});
|
||||
box->addLeftButton(tr::lng_blocked_list_add(), [=] {
|
||||
BlockedBoxController::BlockNewPeer(controller);
|
||||
});
|
||||
};
|
||||
controller->show(Box<PeerListBox>(
|
||||
std::make_unique<BlockedBoxController>(controller),
|
||||
initBox));
|
||||
});
|
||||
std::move(
|
||||
updateTrigger
|
||||
) | rpl::start_with_next([=] {
|
||||
session->api().blockedPeers().reload();
|
||||
}, blockedPeers->lifetime());
|
||||
}
|
||||
|
||||
void SetupSessionsList(
|
||||
not_null<Window::SessionController*> controller,
|
||||
not_null<Ui::VerticalLayout*> container,
|
||||
rpl::producer<> updateTrigger,
|
||||
Fn<void(Type)> showOther) {
|
||||
AddSkip(container);
|
||||
AddSubsectionTitle(container, tr::lng_settings_sessions_title());
|
||||
|
||||
std::move(
|
||||
updateTrigger
|
||||
) | rpl::start_with_next([=] {
|
||||
@@ -800,12 +817,33 @@ void SetupSessionsList(
|
||||
container,
|
||||
tr::lng_settings_show_sessions(),
|
||||
std::move(count),
|
||||
st::settingsButton
|
||||
st::settingsButton,
|
||||
{ &st::settingsIconLaptop, kIconLightOrange }
|
||||
)->addClickHandler([=] {
|
||||
showOther(Type::Sessions);
|
||||
});
|
||||
AddSkip(container, st::settingsPrivacySecurityPadding);
|
||||
AddDividerText(container, tr::lng_settings_sessions_about());
|
||||
}
|
||||
|
||||
void SetupSecurity(
|
||||
not_null<Window::SessionController*> controller,
|
||||
not_null<Ui::VerticalLayout*> container,
|
||||
rpl::producer<> updateTrigger,
|
||||
Fn<void(Type)> showOther) {
|
||||
AddSkip(container, st::settingsPrivacySkip);
|
||||
AddSubsectionTitle(container, rpl::single(u"Security"_q));
|
||||
|
||||
SetupBlockedList(
|
||||
controller,
|
||||
container,
|
||||
rpl::duplicate(updateTrigger),
|
||||
showOther);
|
||||
SetupSessionsList(
|
||||
controller,
|
||||
container,
|
||||
rpl::duplicate(updateTrigger),
|
||||
showOther);
|
||||
SetupLocalPasscode(controller, container);
|
||||
SetupCloudPassword(controller, container);
|
||||
}
|
||||
|
||||
} // namespace
|
||||
@@ -901,6 +939,7 @@ void AddPrivacyButton(
|
||||
not_null<Window::SessionController*> controller,
|
||||
not_null<Ui::VerticalLayout*> container,
|
||||
rpl::producer<QString> label,
|
||||
IconDescriptor &&descriptor,
|
||||
Privacy::Key key,
|
||||
Fn<std::unique_ptr<EditPrivacyController>()> controllerFactory) {
|
||||
const auto shower = Ui::CreateChild<rpl::lifetime>(container.get());
|
||||
@@ -909,7 +948,8 @@ void AddPrivacyButton(
|
||||
container,
|
||||
std::move(label),
|
||||
PrivacyString(session, key),
|
||||
st::settingsButton
|
||||
st::settingsButton,
|
||||
std::move(descriptor)
|
||||
)->addClickHandler([=] {
|
||||
*shower = session->api().userPrivacy().value(
|
||||
key
|
||||
@@ -945,20 +985,18 @@ void PrivacySecurity::setupContent(
|
||||
};
|
||||
|
||||
SetupPrivacy(controller, content, trigger());
|
||||
SetupSessionsList(controller, content, trigger(), [=](Type type) {
|
||||
SetupSecurity(controller, content, trigger(), [=](Type type) {
|
||||
_showOther.fire_copy(type);
|
||||
});
|
||||
SetupLocalPasscode(controller, content);
|
||||
SetupCloudPassword(controller, content);
|
||||
#if !defined OS_MAC_STORE && !defined OS_WIN_STORE
|
||||
SetupSensitiveContent(controller, content, trigger());
|
||||
#else // !OS_MAC_STORE && !OS_WIN_STORE
|
||||
AddDivider(content);
|
||||
#endif // !OS_MAC_STORE && !OS_WIN_STORE
|
||||
SetupArchiveAndMute(controller, content);
|
||||
SetupSelfDestruction(controller, content, trigger());
|
||||
AddDivider(content);
|
||||
SetupBotsAndWebsites(controller, content);
|
||||
AddDivider(content);
|
||||
SetupSelfDestruction(controller, content, trigger());
|
||||
|
||||
Ui::ResizeFitChild(this, content);
|
||||
}
|
||||
|
Reference in New Issue
Block a user