mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2026-07-25 06:54:43 +00:00
fix: highlight buttons in settings
This commit is contained in:
@@ -103,11 +103,18 @@ Fn<void()> AyuSectionBuilder::addCollapsibleToggle(
|
||||
|
||||
_builder.add([&](const Builder::BuildContext &ctx) {
|
||||
v::match(ctx, [&](const Builder::WidgetContext &wctx) {
|
||||
result = AddCollapsibleToggle(
|
||||
auto toggle = AddCollapsibleToggle(
|
||||
wctx.container,
|
||||
std::move(args.title),
|
||||
std::move(checkboxes),
|
||||
toggledWhenAll);
|
||||
result = std::move(toggle.refresh);
|
||||
if (!id.isEmpty() && wctx.highlights && toggle.widget) {
|
||||
wctx.highlights->push_back({
|
||||
id,
|
||||
{ toggle.widget, {} },
|
||||
});
|
||||
}
|
||||
}, [&](const Builder::SearchContext &sctx) {
|
||||
if (!id.isEmpty()) {
|
||||
sctx.entries->push_back({
|
||||
|
||||
@@ -368,14 +368,26 @@ void BuildGhostEssentials(SectionBuilder &builder) {
|
||||
},
|
||||
};
|
||||
|
||||
state->refreshCheckboxes = AddCollapsibleToggle(
|
||||
auto collapsible = AddCollapsibleToggle(
|
||||
container, tr::ayu_GhostModeToggle(), std::move(checkboxes), true);
|
||||
state->refreshCheckboxes = std::move(collapsible.refresh);
|
||||
if (wctx.highlights && collapsible.widget) {
|
||||
wctx.highlights->push_back(std::make_pair(
|
||||
u"ayu/ghostModeToggle"_q,
|
||||
HighlightEntry{ collapsible.widget, {} }));
|
||||
}
|
||||
|
||||
AddButtonWithIcon(
|
||||
const auto markReadButton = AddButtonWithIcon(
|
||||
container,
|
||||
tr::ayu_MarkReadAfterAction(),
|
||||
st::settingsButtonNoIcon
|
||||
)->toggleOn(
|
||||
);
|
||||
if (wctx.highlights) {
|
||||
wctx.highlights->push_back(std::make_pair(
|
||||
u"ayu/markReadAfterAction"_q,
|
||||
HighlightEntry{ markReadButton.get(), {} }));
|
||||
}
|
||||
markReadButton->toggleOn(
|
||||
state->selectedUserId.value()
|
||||
| rpl::map([](uint64 id) {
|
||||
return AyuSettings::ghost(id).markReadAfterActionChanges();
|
||||
@@ -398,11 +410,17 @@ void BuildGhostEssentials(SectionBuilder &builder) {
|
||||
AddDividerText(container, tr::ayu_MarkReadAfterActionDescription());
|
||||
|
||||
AddSkip(container);
|
||||
AddButtonWithIcon(
|
||||
const auto scheduleButton = AddButtonWithIcon(
|
||||
container,
|
||||
tr::ayu_UseScheduledMessages(),
|
||||
st::settingsButtonNoIcon
|
||||
)->toggleOn(
|
||||
);
|
||||
if (wctx.highlights) {
|
||||
wctx.highlights->push_back(std::make_pair(
|
||||
u"ayu/useScheduledMessages"_q,
|
||||
HighlightEntry{ scheduleButton.get(), {} }));
|
||||
}
|
||||
scheduleButton->toggleOn(
|
||||
state->selectedUserId.value()
|
||||
| rpl::map([](uint64 id) {
|
||||
return AyuSettings::ghost(id).useScheduledMessagesChanges();
|
||||
@@ -425,11 +443,17 @@ void BuildGhostEssentials(SectionBuilder &builder) {
|
||||
AddDividerText(container, tr::ayu_UseScheduledMessagesDescription());
|
||||
|
||||
AddSkip(container);
|
||||
AddButtonWithIcon(
|
||||
const auto silentButton = AddButtonWithIcon(
|
||||
container,
|
||||
tr::ayu_SendWithoutSoundByDefault(),
|
||||
st::settingsButtonNoIcon
|
||||
)->toggleOn(
|
||||
);
|
||||
if (wctx.highlights) {
|
||||
wctx.highlights->push_back(std::make_pair(
|
||||
u"ayu/sendWithoutSound"_q,
|
||||
HighlightEntry{ silentButton.get(), {} }));
|
||||
}
|
||||
silentButton->toggleOn(
|
||||
state->selectedUserId.value()
|
||||
| rpl::map([](uint64 id) {
|
||||
return AyuSettings::ghost(id).sendWithoutSoundChanges();
|
||||
|
||||
@@ -308,7 +308,7 @@ not_null<Ui::RpWidget*> AddInnerToggle(not_null<Ui::VerticalLayout*> container,
|
||||
return button;
|
||||
}
|
||||
|
||||
Fn<void()> AddCollapsibleToggle(not_null<Ui::VerticalLayout*> container,
|
||||
CollapsibleToggleResult AddCollapsibleToggle(not_null<Ui::VerticalLayout*> container,
|
||||
rpl::producer<QString> title,
|
||||
std::vector<NestedEntry> checkboxes,
|
||||
bool toggledWhenAll) {
|
||||
@@ -438,7 +438,7 @@ Fn<void()> AddCollapsibleToggle(not_null<Ui::VerticalLayout*> container,
|
||||
|
||||
const auto raw = wrap.data();
|
||||
raw->hide(anim::type::instant);
|
||||
AddInnerToggle(
|
||||
const auto toggleWidget = AddInnerToggle(
|
||||
container,
|
||||
st::powerSavingButtonNoIcon,
|
||||
innerChecks,
|
||||
@@ -455,22 +455,25 @@ Fn<void()> AddCollapsibleToggle(not_null<Ui::VerticalLayout*> container,
|
||||
},
|
||||
raw->lifetime());
|
||||
|
||||
return [cState] {
|
||||
for (auto i = 0u; i < cState->entries.size(); ++i) {
|
||||
cState->entries[i].checkView->setChecked(
|
||||
cState->checkboxes[i].getter(), anim::type::normal);
|
||||
// Refresh lock visuals.
|
||||
const auto &entry = cState->checkboxes[i];
|
||||
if (entry.lockGetter) {
|
||||
if (entry.lockGetter()) {
|
||||
auto *effect = new QGraphicsOpacityEffect(cState->entries[i].checkbox);
|
||||
effect->setOpacity(0.4);
|
||||
cState->entries[i].checkbox->setGraphicsEffect(effect);
|
||||
} else {
|
||||
cState->entries[i].checkbox->setGraphicsEffect(nullptr);
|
||||
return {
|
||||
.refresh = [cState] {
|
||||
for (auto i = 0u; i < cState->entries.size(); ++i) {
|
||||
cState->entries[i].checkView->setChecked(
|
||||
cState->checkboxes[i].getter(), anim::type::normal);
|
||||
// Refresh lock visuals.
|
||||
const auto &entry = cState->checkboxes[i];
|
||||
if (entry.lockGetter) {
|
||||
if (entry.lockGetter()) {
|
||||
auto *effect = new QGraphicsOpacityEffect(cState->entries[i].checkbox);
|
||||
effect->setOpacity(0.4);
|
||||
cState->entries[i].checkbox->setGraphicsEffect(effect);
|
||||
} else {
|
||||
cState->entries[i].checkbox->setGraphicsEffect(nullptr);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
.widget = toggleWidget,
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -41,7 +41,12 @@ not_null<Ui::RpWidget*> AddInnerToggle(not_null<Ui::VerticalLayout*> container,
|
||||
std::vector<Fn<bool()>> lockChecks = {},
|
||||
rpl::event_stream<> *lockChanges = nullptr);
|
||||
|
||||
Fn<void()> AddCollapsibleToggle(not_null<Ui::VerticalLayout*> container,
|
||||
struct CollapsibleToggleResult {
|
||||
Fn<void()> refresh;
|
||||
Ui::RpWidget *widget = nullptr;
|
||||
};
|
||||
|
||||
CollapsibleToggleResult AddCollapsibleToggle(not_null<Ui::VerticalLayout*> container,
|
||||
rpl::producer<QString> title,
|
||||
std::vector<NestedEntry> checkboxes,
|
||||
bool toggledWhenAll);
|
||||
|
||||
Reference in New Issue
Block a user