mirror of https://github.com/procxx/kepka.git
Show folders in settings async.
This commit is contained in:
parent
a7906f14ed
commit
568325f201
Telegram/SourceFiles/settings
|
@ -80,21 +80,19 @@ void AddDividerText(
|
|||
st::settingsDividerLabelPadding));
|
||||
}
|
||||
|
||||
not_null<Button*> AddButton(
|
||||
not_null<Ui::VerticalLayout*> container,
|
||||
object_ptr<Button> CreateButton(
|
||||
not_null<QWidget*> parent,
|
||||
rpl::producer<QString> text,
|
||||
const style::SettingsButton &st,
|
||||
const style::icon *leftIcon,
|
||||
int iconLeft) {
|
||||
const auto result = container->add(object_ptr<Button>(
|
||||
container,
|
||||
std::move(text),
|
||||
st));
|
||||
auto result = object_ptr<Button>(parent, std::move(text), st);
|
||||
const auto button = result.data();
|
||||
if (leftIcon) {
|
||||
const auto icon = Ui::CreateChild<Ui::RpWidget>(result);
|
||||
const auto icon = Ui::CreateChild<Ui::RpWidget>(button);
|
||||
icon->setAttribute(Qt::WA_TransparentForMouseEvents);
|
||||
icon->resize(leftIcon->size());
|
||||
result->sizeValue(
|
||||
button->sizeValue(
|
||||
) | rpl::start_with_next([=](QSize size) {
|
||||
icon->moveToLeft(
|
||||
iconLeft ? iconLeft : st::settingsSectionIconLeft,
|
||||
|
@ -105,8 +103,8 @@ not_null<Button*> AddButton(
|
|||
) | rpl::start_with_next([=] {
|
||||
Painter p(icon);
|
||||
const auto width = icon->width();
|
||||
const auto paintOver = (result->isOver() || result->isDown())
|
||||
&& !result->isDisabled();
|
||||
const auto paintOver = (button->isOver() || button->isDown())
|
||||
&& !button->isDisabled();
|
||||
if (paintOver) {
|
||||
leftIcon->paint(p, QPoint(), width, st::menuIconFgOver->c);
|
||||
} else {
|
||||
|
@ -117,6 +115,16 @@ not_null<Button*> AddButton(
|
|||
return result;
|
||||
}
|
||||
|
||||
not_null<Button*> AddButton(
|
||||
not_null<Ui::VerticalLayout*> container,
|
||||
rpl::producer<QString> text,
|
||||
const style::SettingsButton &st,
|
||||
const style::icon *leftIcon,
|
||||
int iconLeft) {
|
||||
return container->add(
|
||||
CreateButton(container, std::move(text), st, leftIcon, iconLeft));
|
||||
}
|
||||
|
||||
void CreateRightLabel(
|
||||
not_null<Button*> button,
|
||||
rpl::producer<QString> label,
|
||||
|
|
|
@ -70,6 +70,12 @@ void AddDivider(not_null<Ui::VerticalLayout*> container);
|
|||
void AddDividerText(
|
||||
not_null<Ui::VerticalLayout*> container,
|
||||
rpl::producer<QString> text);
|
||||
object_ptr<Button> CreateButton(
|
||||
not_null<QWidget*> parent,
|
||||
rpl::producer<QString> text,
|
||||
const style::SettingsButton &st,
|
||||
const style::icon *leftIcon = nullptr,
|
||||
int iconLeft = 0);
|
||||
not_null<Button*> AddButton(
|
||||
not_null<Ui::VerticalLayout*> container,
|
||||
rpl::producer<QString> text,
|
||||
|
|
|
@ -14,6 +14,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
#include "boxes/confirm_box.h"
|
||||
#include "boxes/about_box.h"
|
||||
#include "ui/wrap/vertical_layout.h"
|
||||
#include "ui/wrap/slide_wrap.h"
|
||||
#include "ui/widgets/labels.h"
|
||||
#include "ui/widgets/discrete_sliders.h"
|
||||
#include "ui/widgets/buttons.h"
|
||||
|
@ -104,14 +105,36 @@ void SetupSections(
|
|||
tr::lng_settings_section_chat_settings(),
|
||||
Type::Chat,
|
||||
&st::settingsIconChat);
|
||||
const auto &appConfig = controller->session().account().appConfig();
|
||||
|
||||
const auto account = &controller->session().account();
|
||||
const auto slided = container->add(
|
||||
object_ptr<Ui::SlideWrap<Ui::SettingsButton>>(
|
||||
container,
|
||||
CreateButton(
|
||||
container,
|
||||
tr::lng_settings_section_filters(),
|
||||
st::settingsSectionButton,
|
||||
&st::settingsIconFolders)))->setDuration(0);
|
||||
if (!controller->session().data().chatsFilters().list().empty()
|
||||
|| appConfig.get<bool>("dialog_filters_enabled", false)) {
|
||||
addSection(
|
||||
tr::lng_settings_section_filters(),
|
||||
Type::Folders,
|
||||
&st::settingsIconFolders);
|
||||
|| Global::DialogsFiltersEnabled()) {
|
||||
slided->show(anim::type::instant);
|
||||
} else {
|
||||
const auto enabled = [=] {
|
||||
return account->appConfig().get<bool>(
|
||||
"dialog_filters_enabled",
|
||||
false);
|
||||
};
|
||||
slided->toggleOn(
|
||||
rpl::single(
|
||||
rpl::empty_value()
|
||||
) | rpl::then(
|
||||
account->appConfig().refreshed()
|
||||
) | rpl::map(enabled));
|
||||
}
|
||||
slided->entity()->setClickedCallback([=] {
|
||||
showOther(Type::Folders);
|
||||
});
|
||||
|
||||
addSection(
|
||||
tr::lng_settings_advanced(),
|
||||
Type::Advanced,
|
||||
|
|
Loading…
Reference in New Issue