2
0
mirror of https://github.com/kotatogram/kotatogram-desktop synced 2025-08-31 06:35:14 +00:00

Show folders in settings async.

This commit is contained in:
John Preston
2020-03-24 11:26:08 +04:00
parent a7906f14ed
commit 568325f201
3 changed files with 53 additions and 16 deletions

View File

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