Adjust main settings icons to the mockup.

This commit is contained in:
John Preston 2022-02-09 13:43:07 +03:00
parent 1468be0af4
commit 9c903bacf2
91 changed files with 204 additions and 123 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 493 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 945 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 488 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 863 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 507 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 806 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 428 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 717 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 462 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 746 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 477 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 871 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 481 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 952 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 278 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 378 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 578 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 428 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 747 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 545 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 925 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 428 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 690 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 989 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 393 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 626 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 901 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 509 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 831 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 290 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 566 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 902 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 248 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 393 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 806 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 939 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 599 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 360 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 633 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1,017 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 589 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 541 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 382 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 729 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 431 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 930 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 391 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 770 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 499 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 946 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

View file

@ -929,9 +929,7 @@ void SessionsContent::Inner::setupContent() {
terminateInner,
tr::lng_sessions_terminate_all(),
st::sessionsTerminateAll,
&st::sessionsTerminateAllIcon,
st::sessionsTerminateAllIconLeft,
&st::attentionButtonFg));
{ .icon = &st::sessionsTerminateAllIcon }));
AddSkip(terminateInner);
AddDividerText(terminateInner, tr::lng_sessions_terminate_all_about());

View file

@ -749,11 +749,11 @@ groupCallAddMember: SettingsButton(defaultSettingsButton) {
height: 22px;
padding: margins(63px, 17px, 22px, 11px);
iconLeft: 16px;
ripple: groupCallRipple;
}
groupCallAddMemberIcon: icon {{ "info_add_member", groupCallMemberInactiveIcon, point(0px, 3px) }};
groupCallAddMemberIconLeft: 16px;
groupCallSubtitleLabel: FlatLabel(defaultFlatLabel) {
maxHeight: 18px;
textFg: groupCallMemberNotJoinedStatus;

View file

@ -1685,9 +1685,7 @@ void Members::setupAddMember(not_null<GroupCall*> call) {
_layout.get(),
tr::lng_group_call_invite(),
st::groupCallAddMember,
&st::groupCallAddMemberIcon,
st::groupCallAddMemberIconLeft,
&st::groupCallMemberInactiveIcon);
{ .icon = &st::groupCallAddMemberIcon });
addMember->clicks(
) | rpl::to_empty | rpl::start_to_stream(
_addMemberRequests,

View file

@ -382,6 +382,7 @@ infoProfileButton: SettingsButton(defaultSettingsButton) {
height: 20px;
padding: margins(79px, 10px, 8px, 8px);
iconLeft: 22px;
toggle: infoProfileToggle;
toggleOver: infoProfileToggleOver;

View file

@ -216,7 +216,9 @@ int LayerWidget::resizeGetHeight(int newWidth) {
st::infoLayerTopMinimal,
st::infoLayerTopMaximal);
auto newBottom = newTop;
auto desiredHeight = st::boxRadius + _desiredHeight + st::boxRadius;
// Top rounding is included in _desiredHeight.
auto desiredHeight = _desiredHeight + st::boxRadius;
accumulate_min(desiredHeight, windowHeight - newTop - newBottom);
// First resize content to new width and get the new desired height.

View file

@ -490,7 +490,7 @@ void FormSummary::setupSections(not_null<VerticalLayout*> layout) {
std::move(title),
rpl::single(label),
st::paymentsSectionButton,
icon);
{ .icon = icon });
button->addClickHandler(std::move(handler));
if (_invoice.receipt) {
button->setAttribute(Qt::WA_TransparentForMouseEvents);

View file

@ -12,7 +12,8 @@ using "boxes/boxes.style";
settingsSectionButton: SettingsButton(infoProfileButton) {
font: boxTextFont;
padding: margins(60px, 11px, 22px, 9px);
padding: margins(60px, 10px, 22px, 10px);
iconLeft: 20px;
}
settingsButton: SettingsButton(settingsSectionButton) {
padding: margins(22px, 10px, 22px, 8px);
@ -28,13 +29,11 @@ settingsOptionDisabled: SettingsButton(settingsButton) {
textBgOver: windowBg;
toggleOver: infoProfileToggle;
}
settingsSectionSkip: 5px;
settingsSectionBottomSkip: 7px;
settingsSectionIconLeft: 22px;
settingsSectionSkip: 6px;
settingsSeparatorPadding: margins(22px, infoProfileSkip, 0px, infoProfileSkip);
settingsButtonRightSkip: 23px;
settingsScalePadding: margins(63px, 8px, 21px, 5px);
settingsBigScalePadding: margins(21px, 8px, 21px, 5px);
settingsScalePadding: margins(63px, 7px, 21px, 4px);
settingsBigScalePadding: margins(21px, 7px, 21px, 4px);
settingsSlider: SettingsSlider(defaultSettingsSlider) {
barFg: windowBgOver;
labelFg: windowSubTextFg;
@ -52,18 +51,20 @@ settingsUpdate: SettingsButton(infoMainButton, settingsButton) {
settingsUpdateStatePosition: point(22px, 29px);
settingsDividerLabelPadding: margins(22px, 10px, 22px, 19px);
settingsIconInformation: icon {{ "settings/settings_information", menuIconFg }};
settingsIconNotifications: icon {{ "settings/settings_notifications", menuIconFg }};
settingsIconChat: icon {{ "settings/settings_chat", menuIconFg }};
settingsIconFolders: icon {{ "settings/settings_folders", menuIconFg }};
settingsIconGeneral: icon {{ "settings/settings_advanced", menuIconFg }};
settingsIconPrivacySecurity: icon {{ "settings/settings_privacy_security", menuIconFg }};
settingsIconLanguage: icon {{ "settings/settings_language", menuIconFg }};
settingsIconInterfaceScale: icon {{ "settings/settings_interface_scale", menuIconFg }};
settingsIconFaq: icon {{ "settings/settings_faq", menuIconFg }};
settingsIconStickers: icon {{ "settings/settings_stickers", menuIconFg }};
settingsIconEmoji: icon {{ "settings/settings_emoji", menuIconFg }};
settingsIconThemes: icon {{ "settings/settings_themes", menuIconFg }};
settingsIconInformation: icon {{ "settings/account", settingsIconFg }};
settingsIconNotifications: icon {{ "settings/notifications", settingsIconFg }};
settingsIconChat: icon {{ "settings/chat", settingsIconFg }};
settingsIconFolders: icon {{ "settings/folders", settingsIconFg }};
settingsIconGeneral: icon {{ "settings/advanced", settingsIconFg }};
settingsIconPrivacySecurity: icon {{ "settings/lock", settingsIconFg }};
settingsIconLanguage: icon {{ "settings/language", settingsIconFg }};
settingsIconInterfaceScale: icon {{ "settings/interface_scale", settingsIconFg }};
settingsIconFaq: icon {{ "settings/faq", settingsIconFg }};
settingsIconCalls: icon {{ "settings/calls", settingsIconFg }};
settingsIconAskQuestion: icon {{ "settings/ask_question", settingsIconFg }};
settingsIconStickers: icon {{ "settings/stickers", settingsIconFg }};
settingsIconEmoji: icon {{ "settings/emoji", settingsIconFg }};
settingsIconThemes: icon {{ "settings/palette", settingsIconFg }};
settingsSetPhotoSkip: 7px;
@ -167,11 +168,6 @@ settingsBioLabelPadding: margins(22px, 11px, 22px, 0px);
settingsPrivacyEditLabelPadding: margins(22px, 11px, 22px, 11px);
settingsChatButton: SettingsButton(settingsSectionButton) {
padding: margins(59px, 13px, 22px, 11px);
}
settingsChatIconLeft: 19px;
settingsThemesTopSkip: 10px;
settingsThemesBottomSkip: 8px;
settingsTheme: Checkbox(defaultCheckbox) {
@ -254,9 +250,9 @@ sessionsTerminateAll: SettingsButton(defaultSettingsButton) {
font: font(boxFontSize semibold);
height: 20px;
padding: margins(77px, 12px, 22px, 10px);
iconLeft: 30px;
}
sessionsTerminateAllIcon: icon {{ "settings/devices/terminate_all", attentionButtonFg }};
sessionsTerminateAllIconLeft: 30px;
sessionLocationTop: 54px;
sessionCurrentSkip: 8px;
sessionSubtitleSkip: 14px;
@ -350,3 +346,5 @@ settingsPhoneLeft: settingsNameLeft;
settingsPhoneTop: 37px;
settingsUsernameLeft: settingsNameLeft;
settingsUsernameTop: 58px;
settingsIconRadius: 6px;

View file

@ -707,13 +707,6 @@ void SetupSystemIntegration(
AddDivider(container);
AddSkip(container);
AddSubsectionTitle(container, tr::lng_settings_system_integration());
AddButton(
container,
tr::lng_settings_section_call_settings(),
st::settingsButton
)->addClickHandler([=] {
showOther(Type::Calls);
});
SetupSystemIntegrationOptions(controller, container);
AddSkip(container);
}

View file

@ -747,9 +747,8 @@ void SetupStickersEmoji(
AddButton(
container,
tr::lng_stickers_you_have(),
st::settingsChatButton,
&st::settingsIconStickers,
st::settingsChatIconLeft
st::settingsSectionButton,
{ &st::settingsIconStickers, kIconLightOrange }
)->addClickHandler([=] {
controller->show(
Box<StickersBox>(controller, StickersBox::Section::Installed));
@ -758,9 +757,8 @@ void SetupStickersEmoji(
AddButton(
container,
tr::lng_emoji_manage_sets(),
st::settingsChatButton,
&st::settingsIconEmoji,
st::settingsChatIconLeft
st::settingsSectionButton,
{ &st::settingsIconEmoji, kIconDarkOrange }
)->addClickHandler([=] {
controller->show(Box<Ui::Emoji::ManageSetsBox>(session));
});
@ -1274,9 +1272,8 @@ void SetupCloudThemes(
AddButton(
edit,
tr::lng_settings_bg_theme_edit(),
st::settingsChatButton,
&st::settingsIconThemes,
st::settingsChatIconLeft
st::settingsSectionButton,
{ &st::settingsIconThemes, kIconGreen }
)->addClickHandler([=] {
StartEditor(
&controller->window(),

View file

@ -37,10 +37,57 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
namespace Settings {
Icon::Icon(IconDescriptor descriptor) : _icon(descriptor.icon) {
const auto background = [&] {
if (descriptor.color > 0) {
const auto list = std::array{
&st::settingsIconBg1,
&st::settingsIconBg2,
&st::settingsIconBg3,
&st::settingsIconBg4,
&st::settingsIconBg5,
&st::settingsIconBg6,
(const style::color*)nullptr,
&st::settingsIconBg8,
&st::settingsIconBgArchive,
};
Assert(descriptor.color < 10 && descriptor.color != 7);
return list[descriptor.color - 1];
}
return descriptor.background;
}();
if (background) {
_background.emplace(st::settingsIconRadius, *background);
}
}
void Icon::paint(QPainter &p, QPoint position) const {
paint(p, position.x(), position.y());
}
void Icon::paint(QPainter &p, int x, int y) const {
if (_background) {
_background->paint(p, { { x, y }, _icon->size() });
}
_icon->paint(p, { x, y }, 2 * x + _icon->width());
}
int Icon::width() const {
return _icon->width();
}
int Icon::height() const {
return _icon->height();
}
QSize Icon::size() const {
return _icon->size();
}
object_ptr<Section> CreateSection(
Type type,
not_null<QWidget*> parent,
not_null<Window::SessionController*> controller) {
Type type,
not_null<QWidget*> parent,
not_null<Window::SessionController*> controller) {
switch (type) {
case Type::Main:
return object_ptr<Main>(parent, controller);
@ -81,8 +128,8 @@ void AddDivider(not_null<Ui::VerticalLayout*> container) {
}
void AddDividerText(
not_null<Ui::VerticalLayout*> container,
rpl::producer<QString> text) {
not_null<Ui::VerticalLayout*> container,
rpl::producer<QString> text) {
container->add(object_ptr<Ui::DividerLabel>(
container,
object_ptr<Ui::FlatLabel>(
@ -92,49 +139,48 @@ void AddDividerText(
st::settingsDividerLabelPadding));
}
not_null<Ui::RpWidget*> AddButtonIcon(
void AddButtonIcon(
not_null<Ui::AbstractButton*> button,
const style::icon *leftIcon,
int iconLeft,
const style::color *leftIconOver) {
const auto icon = Ui::CreateChild<Ui::RpWidget>(button.get());
icon->setAttribute(Qt::WA_TransparentForMouseEvents);
icon->resize(leftIcon->size());
button->sizeValue(
) | rpl::start_with_next([=](QSize size) {
icon->moveToLeft(
iconLeft ? iconLeft : st::settingsSectionIconLeft,
(size.height() - icon->height()) / 2,
size.width());
}, icon->lifetime());
icon->paintRequest(
) | rpl::start_with_next([=] {
Painter p(icon);
const auto width = icon->width();
const auto paintOver = (button->isOver() || button->isDown())
&& !button->isDisabled();
if (!paintOver) {
leftIcon->paint(p, QPoint(), width);
} else if (leftIconOver) {
leftIcon->paint(p, QPoint(), width, (*leftIconOver)->c);
} else {
leftIcon->paint(p, QPoint(), width, st::menuIconFgOver->c);
const style::SettingsButton &st,
IconDescriptor &&descriptor) {
Expects(descriptor.icon != nullptr);
struct IconWidget {
IconWidget(QWidget *parent, IconDescriptor &&descriptor)
: widget(parent)
, icon(std::move(descriptor)) {
}
}, icon->lifetime());
return icon;
Ui::RpWidget widget;
Icon icon;
};
const auto icon = button->lifetime().make_state<IconWidget>(
button,
std::move(descriptor));
icon->widget.setAttribute(Qt::WA_TransparentForMouseEvents);
icon->widget.resize(icon->icon.size());
button->sizeValue(
) | rpl::start_with_next([=, left = st.iconLeft](QSize size) {
icon->widget.moveToLeft(
left,
(size.height() - icon->widget.height()) / 2,
size.width());
}, icon->widget.lifetime());
icon->widget.paintRequest(
) | rpl::start_with_next([=] {
auto p = QPainter(&icon->widget);
icon->icon.paint(p, 0, 0);
}, icon->widget.lifetime());
}
object_ptr<Button> CreateButton(
not_null<QWidget*> parent,
rpl::producer<QString> text,
const style::SettingsButton &st,
const style::icon *leftIcon,
int iconLeft,
const style::color *leftIconOver) {
IconDescriptor &&descriptor) {
auto result = object_ptr<Button>(parent, std::move(text), st);
const auto button = result.data();
if (leftIcon) {
AddButtonIcon(button, leftIcon, iconLeft, leftIconOver);
if (descriptor) {
AddButtonIcon(button, st, std::move(descriptor));
}
return result;
}
@ -143,10 +189,9 @@ not_null<Button*> AddButton(
not_null<Ui::VerticalLayout*> container,
rpl::producer<QString> text,
const style::SettingsButton &st,
const style::icon *leftIcon,
int iconLeft) {
IconDescriptor &&descriptor) {
return container->add(
CreateButton(container, std::move(text), st, leftIcon, iconLeft));
CreateButton(container, std::move(text), st, std::move(descriptor)));
}
void CreateRightLabel(
@ -182,14 +227,12 @@ not_null<Button*> AddButtonWithLabel(
rpl::producer<QString> text,
rpl::producer<QString> label,
const style::SettingsButton &st,
const style::icon *leftIcon,
int iconLeft) {
IconDescriptor &&descriptor) {
const auto button = AddButton(
container,
rpl::duplicate(text),
st,
leftIcon,
iconLeft);
std::move(descriptor));
CreateRightLabel(button, std::move(label), st, std::move(text));
return button;
}

View file

@ -8,6 +8,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#pragma once
#include "ui/rp_widget.h"
#include "ui/round_rect.h"
#include "base/object_ptr.h"
namespace Main {
@ -59,6 +60,42 @@ public:
};
inline constexpr auto kIconRed = 1;
inline constexpr auto kIconGreen = 2;
inline constexpr auto kIconLightOrange = 3;
inline constexpr auto kIconLightBlue = 4;
inline constexpr auto kIconDarkBlue = 5;
inline constexpr auto kIconPurple = 6;
inline constexpr auto kIconDarkOrange = 8;
inline constexpr auto kIconGray = 9;
struct IconDescriptor {
const style::icon *icon = nullptr;
int color = 0; // settingsIconBg{color}, 9 for settingsIconBgArchive.
const style::color *background = nullptr;
explicit operator bool() const {
return (icon != nullptr);
}
};
class Icon final {
public:
explicit Icon(IconDescriptor descriptor);
void paint(QPainter &p, QPoint position) const;
void paint(QPainter &p, int x, int y) const;
[[nodiscard]] int width() const;
[[nodiscard]] int height() const;
[[nodiscard]] QSize size() const;
private:
not_null<const style::icon*> _icon;
std::optional<Ui::RoundRect> _background;
};
object_ptr<Section> CreateSection(
Type type,
not_null<QWidget*> parent,
@ -70,31 +107,26 @@ void AddDivider(not_null<Ui::VerticalLayout*> container);
void AddDividerText(
not_null<Ui::VerticalLayout*> container,
rpl::producer<QString> text);
not_null<Ui::RpWidget*> AddButtonIcon(
void AddButtonIcon(
not_null<Ui::AbstractButton*> button,
const style::icon *leftIcon,
int iconLeft,
const style::color *leftIconOver);
const style::SettingsButton &st,
IconDescriptor &&descriptor);
object_ptr<Button> CreateButton(
not_null<QWidget*> parent,
rpl::producer<QString> text,
const style::SettingsButton &st,
const style::icon *leftIcon = nullptr,
int iconLeft = 0,
const style::color *leftIconOver = nullptr);
IconDescriptor &&descriptor = {});
not_null<Button*> AddButton(
not_null<Ui::VerticalLayout*> container,
rpl::producer<QString> text,
const style::SettingsButton &st,
const style::icon *leftIcon = nullptr,
int iconLeft = 0);
IconDescriptor &&descriptor = {});
not_null<Button*> AddButtonWithLabel(
not_null<Ui::VerticalLayout*> container,
rpl::producer<QString> text,
rpl::producer<QString> label,
const style::SettingsButton &st,
const style::icon *leftIcon = nullptr,
int iconLeft = 0);
IconDescriptor &&descriptor = {});
void CreateRightLabel(
not_null<Button*> button,
rpl::producer<QString> label,

View file

@ -110,7 +110,7 @@ void AddRow(
container,
rpl::single(QString()),
st::settingsInfoRow,
&icon);
{ .icon = &icon });
const auto forcopy = Ui::CreateChild<QString>(wrap.get());
wrap->setAcceptBoth();
wrap->clicks(

View file

@ -214,7 +214,7 @@ void SetupLanguageButton(
Lang::GetInstance().idChanges()
) | rpl::map([] { return Lang::GetInstance().nativeName(); }),
icon ? st::settingsSectionButton : st::settingsButton,
icon ? &st::settingsIconLanguage : nullptr);
{ icon ? &st::settingsIconLanguage : nullptr, kIconDarkOrange });
const auto guard = Ui::CreateChild<base::binary_guard>(button.get());
button->addClickHandler([=] {
const auto m = button->clickModifiers();
@ -236,12 +236,12 @@ void SetupSections(
const auto addSection = [&](
rpl::producer<QString> label,
Type type,
const style::icon *icon) {
IconDescriptor &&descriptor) {
AddButton(
container,
std::move(label),
st::settingsSectionButton,
icon
std::move(descriptor)
)->addClickHandler([=] { showOther(type); });
};
if (controller->session().supportMode()) {
@ -253,20 +253,20 @@ void SetupSections(
addSection(
tr::lng_settings_information(),
Type::Information,
&st::settingsIconInformation);
{ &st::settingsIconInformation, kIconLightOrange });
}
addSection(
tr::lng_settings_section_notify(),
Type::Notifications,
&st::settingsIconNotifications);
{ &st::settingsIconNotifications, kIconRed });
addSection(
tr::lng_settings_section_privacy(),
Type::PrivacySecurity,
&st::settingsIconPrivacySecurity);
{ &st::settingsIconPrivacySecurity, kIconGreen });
addSection(
tr::lng_settings_section_chat_settings(),
Type::Chat,
&st::settingsIconChat);
{ &st::settingsIconChat, kIconLightBlue });
const auto preload = [=] {
controller->session().data().chatsFilters().requestSuggested();
@ -279,7 +279,8 @@ void SetupSections(
container,
tr::lng_settings_section_filters(),
st::settingsSectionButton,
&st::settingsIconFolders)))->setDuration(0);
{ &st::settingsIconFolders, kIconDarkBlue }))
)->setDuration(0);
if (!controller->session().data().chatsFilters().list().empty()
|| controller->session().settings().dialogsFiltersEnabled()) {
slided->show(anim::type::instant);
@ -315,11 +316,11 @@ void SetupSections(
addSection(
tr::lng_settings_advanced(),
Type::Advanced,
&st::settingsIconGeneral);
{ &st::settingsIconGeneral, kIconPurple });
SetupLanguageButton(container);
AddSkip(container, st::settingsSectionBottomSkip);
AddSkip(container);
}
bool HasInterfaceScale() {
@ -342,7 +343,7 @@ void SetupInterfaceScale(
container,
tr::lng_settings_default_scale(),
icon ? st::settingsSectionButton : st::settingsButton,
icon ? &st::settingsIconInterfaceScale : nullptr
{ icon ? &st::settingsIconInterfaceScale : nullptr, kIconLightBlue }
)->toggleOn(toggled->events_starting_with_copy(switched));
const auto slider = container->add(
@ -449,7 +450,7 @@ void SetupFaq(not_null<Ui::VerticalLayout*> container, bool icon) {
container,
tr::lng_settings_faq(),
icon ? st::settingsSectionButton : st::settingsButton,
icon ? &st::settingsIconFaq : nullptr
{ icon ? &st::settingsIconFaq : nullptr, kIconLightBlue }
)->addClickHandler(OpenFaq);
}
@ -464,7 +465,8 @@ void SetupHelp(
const auto button = AddButton(
container,
tr::lng_settings_ask_question(),
st::settingsSectionButton);
st::settingsSectionButton,
{ &st::settingsIconAskQuestion, kIconLightOrange });
const auto requestId = button->lifetime().make_state<mtpRequestId>();
button->lifetime().add([=] {
if (*requestId) {

View file

@ -167,6 +167,10 @@ SettingsSlider::SettingsSlider(
const style::SettingsSlider &st)
: DiscreteSlider(parent)
, _st(st) {
if (_st.barRadius > 0) {
_bar.emplace(_st.barRadius, _st.barFg);
_barActive.emplace(_st.barRadius, _st.barFgActive);
}
setSelectOnPress(_st.ripple.showDuration == 0);
}
@ -283,6 +287,14 @@ void SettingsSlider::paintEvent(QPaintEvent *e) {
auto clip = e->rect();
auto activeLeft = getCurrentActiveLeft();
const auto drawRect = [&](QRect rect, bool active = false) {
const auto &bar = active ? _barActive : _bar;
if (bar) {
bar->paint(p, rect);
} else {
p.fillRect(rect, active ? _st.barFgActive : _st.barFg);
}
};
enumerateSections([&](Section &section) {
auto active = 1.
- std::clamp(
@ -299,19 +311,21 @@ void SettingsSlider::paintEvent(QPaintEvent *e) {
auto from = section.left, tofill = section.width;
if (activeLeft > from) {
auto fill = qMin(tofill, activeLeft - from);
p.fillRect(myrtlrect(from, _st.barTop, fill, _st.barStroke), _st.barFg);
drawRect(myrtlrect(from, _st.barTop, fill, _st.barStroke));
from += fill;
tofill -= fill;
}
if (activeLeft + section.width > from) {
if (auto fill = qMin(tofill, activeLeft + section.width - from)) {
p.fillRect(myrtlrect(from, _st.barTop, fill, _st.barStroke), _st.barFgActive);
drawRect(
myrtlrect(from, _st.barTop, fill, _st.barStroke),
true);
from += fill;
tofill -= fill;
}
}
if (tofill) {
p.fillRect(myrtlrect(from, _st.barTop, tofill, _st.barStroke), _st.barFg);
drawRect(myrtlrect(from, _st.barTop, tofill, _st.barStroke));
}
if (myrtlrect(section.left, _st.labelTop, section.width, _st.labelStyle.font->height).intersects(clip)) {
p.setPen(anim::pen(_st.labelFg, _st.labelFgActive, active));

View file

@ -8,6 +8,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#pragma once
#include "ui/rp_widget.h"
#include "ui/round_rect.h"
#include "ui/effects/animations.h"
#include "styles/style_widgets.h"
@ -115,6 +116,8 @@ private:
std::vector<float64> countSectionsWidths(int newWidth) const;
const style::SettingsSlider &_st;
std::optional<Ui::RoundRect> _bar;
std::optional<Ui::RoundRect> _barActive;
int _rippleTopRoundRadius = 0;

@ -1 +1 @@
Subproject commit 6685a1565eb19f6c434d72f5bf1147c14e98ac2c
Subproject commit c1f44ca8c739cd7183c1e85eb1b7a62f1ada12d6