Simplify settings menu switches adding
This commit is contained in:
parent
6c98350acd
commit
789ef6e6f8
1 changed files with 57 additions and 185 deletions
|
|
@ -38,6 +38,50 @@ https://github.com/kotatogram/kotatogram-desktop/blob/dev/LEGAL
|
||||||
|
|
||||||
namespace Settings {
|
namespace Settings {
|
||||||
|
|
||||||
|
#define SettingsMenuСSwitch(LangKey, Option) AddButton( \
|
||||||
|
container, \
|
||||||
|
tr::LangKey(), \
|
||||||
|
st::settingsButton \
|
||||||
|
)->toggleOn( \
|
||||||
|
rpl::single(c##Option()) \
|
||||||
|
)->toggledValue( \
|
||||||
|
) | rpl::filter([](bool enabled) { \
|
||||||
|
return (enabled != c##Option()); \
|
||||||
|
}) | rpl::start_with_next([](bool enabled) { \
|
||||||
|
cSet##Option(enabled); \
|
||||||
|
::Kotato::JsonSettings::Write(); \
|
||||||
|
}, container->lifetime());
|
||||||
|
|
||||||
|
#define SettingsMenuСFilterSwitch(LangKey, Option) AddButton( \
|
||||||
|
container, \
|
||||||
|
tr::LangKey(), \
|
||||||
|
st::settingsButton \
|
||||||
|
)->toggleOn( \
|
||||||
|
rpl::single(c##Option()) \
|
||||||
|
)->toggledValue( \
|
||||||
|
) | rpl::filter([](bool enabled) { \
|
||||||
|
return (enabled != c##Option()); \
|
||||||
|
}) | rpl::start_with_next([controller](bool enabled) { \
|
||||||
|
cSet##Option(enabled); \
|
||||||
|
::Kotato::JsonSettings::Write(); \
|
||||||
|
controller->reloadFiltersMenu(); \
|
||||||
|
App::wnd()->fixOrder(); \
|
||||||
|
}, container->lifetime());
|
||||||
|
|
||||||
|
#define SettingsMenuSwitch(LangKey, Option) AddButton( \
|
||||||
|
container, \
|
||||||
|
tr::LangKey(), \
|
||||||
|
st::settingsButton \
|
||||||
|
)->toggleOn( \
|
||||||
|
rpl::single(Option()) \
|
||||||
|
)->toggledValue( \
|
||||||
|
) | rpl::filter([](bool enabled) { \
|
||||||
|
return (enabled != Option()); \
|
||||||
|
}) | rpl::start_with_next([](bool enabled) { \
|
||||||
|
Set##Option(enabled); \
|
||||||
|
::Kotato::JsonSettings::Write(); \
|
||||||
|
}, container->lifetime());
|
||||||
|
|
||||||
void SetupKotatoChats(not_null<Ui::VerticalLayout*> container) {
|
void SetupKotatoChats(not_null<Ui::VerticalLayout*> container) {
|
||||||
AddSkip(container);
|
AddSkip(container);
|
||||||
AddSubsectionTitle(container, tr::ktg_settings_chats());
|
AddSubsectionTitle(container, tr::ktg_settings_chats());
|
||||||
|
|
@ -74,33 +118,8 @@ void SetupKotatoChats(not_null<Ui::VerticalLayout*> container) {
|
||||||
updateRecentStickersLimitHeight);
|
updateRecentStickersLimitHeight);
|
||||||
updateRecentStickersLimitLabel(RecentStickersLimit());
|
updateRecentStickersLimitLabel(RecentStickersLimit());
|
||||||
|
|
||||||
AddButton(
|
SettingsMenuСSwitch(ktg_settings_top_bar_mute, ProfileTopBarNotifications);
|
||||||
container,
|
SettingsMenuСSwitch(ktg_settings_disable_up_edit, DisableUpEdit);
|
||||||
tr::ktg_settings_top_bar_mute(),
|
|
||||||
st::settingsButton
|
|
||||||
)->toggleOn(
|
|
||||||
rpl::single(cProfileTopBarNotifications())
|
|
||||||
)->toggledValue(
|
|
||||||
) | rpl::filter([](bool enabled) {
|
|
||||||
return (enabled != cProfileTopBarNotifications());
|
|
||||||
}) | rpl::start_with_next([](bool enabled) {
|
|
||||||
cSetProfileTopBarNotifications(enabled);
|
|
||||||
::Kotato::JsonSettings::Write();
|
|
||||||
}, container->lifetime());
|
|
||||||
|
|
||||||
AddButton(
|
|
||||||
container,
|
|
||||||
tr::ktg_settings_disable_up_edit(),
|
|
||||||
st::settingsButton
|
|
||||||
)->toggleOn(
|
|
||||||
rpl::single(cDisableUpEdit())
|
|
||||||
)->toggledValue(
|
|
||||||
) | rpl::filter([](bool enabled) {
|
|
||||||
return (enabled != cDisableUpEdit());
|
|
||||||
}) | rpl::start_with_next([](bool enabled) {
|
|
||||||
cSetDisableUpEdit(enabled);
|
|
||||||
::Kotato::JsonSettings::Write();
|
|
||||||
}, container->lifetime());
|
|
||||||
|
|
||||||
AddButton(
|
AddButton(
|
||||||
container,
|
container,
|
||||||
|
|
@ -116,20 +135,7 @@ void SetupKotatoChats(not_null<Ui::VerticalLayout*> container) {
|
||||||
::Kotato::JsonSettings::Write();
|
::Kotato::JsonSettings::Write();
|
||||||
}, container->lifetime());
|
}, container->lifetime());
|
||||||
|
|
||||||
AddButton(
|
SettingsMenuСSwitch(ktg_settings_disable_up_edit, AlwaysShowScheduled);
|
||||||
container,
|
|
||||||
tr::ktg_settings_always_show_scheduled(),
|
|
||||||
st::settingsButton
|
|
||||||
)->toggleOn(
|
|
||||||
rpl::single(cAlwaysShowScheduled())
|
|
||||||
)->toggledValue(
|
|
||||||
) | rpl::filter([](bool enabled) {
|
|
||||||
return (enabled != cAlwaysShowScheduled());
|
|
||||||
}) | rpl::start_with_next([](bool enabled) {
|
|
||||||
cSetAlwaysShowScheduled(enabled);
|
|
||||||
Notify::showScheduledButtonChanged();
|
|
||||||
::Kotato::JsonSettings::Write();
|
|
||||||
}, container->lifetime());
|
|
||||||
|
|
||||||
AddButton(
|
AddButton(
|
||||||
container,
|
container,
|
||||||
|
|
@ -175,33 +181,8 @@ void SetupKotatoMessages(not_null<Ui::VerticalLayout*> container) {
|
||||||
updateStickerHeight);
|
updateStickerHeight);
|
||||||
updateStickerHeightLabel(StickerHeight());
|
updateStickerHeightLabel(StickerHeight());
|
||||||
|
|
||||||
AddButton(
|
SettingsMenuSwitch(ktg_settings_adaptive_bubbles, AdaptiveBubbles);
|
||||||
container,
|
SettingsMenuSwitch(ktg_settings_emoji_outline, BigEmojiOutline);
|
||||||
tr::ktg_settings_adaptive_bubbles(),
|
|
||||||
st::settingsButton
|
|
||||||
)->toggleOn(
|
|
||||||
rpl::single(AdaptiveBubbles())
|
|
||||||
)->toggledValue(
|
|
||||||
) | rpl::filter([](bool enabled) {
|
|
||||||
return (enabled != AdaptiveBubbles());
|
|
||||||
}) | rpl::start_with_next([](bool enabled) {
|
|
||||||
SetAdaptiveBubbles(enabled);
|
|
||||||
::Kotato::JsonSettings::Write();
|
|
||||||
}, container->lifetime());
|
|
||||||
|
|
||||||
AddButton(
|
|
||||||
container,
|
|
||||||
tr::ktg_settings_emoji_outline(),
|
|
||||||
st::settingsButton
|
|
||||||
)->toggleOn(
|
|
||||||
rpl::single(BigEmojiOutline())
|
|
||||||
)->toggledValue(
|
|
||||||
) | rpl::filter([](bool enabled) {
|
|
||||||
return (enabled != BigEmojiOutline());
|
|
||||||
}) | rpl::start_with_next([](bool enabled) {
|
|
||||||
SetBigEmojiOutline(enabled);
|
|
||||||
::Kotato::JsonSettings::Write();
|
|
||||||
}, container->lifetime());
|
|
||||||
|
|
||||||
AddSkip(container);
|
AddSkip(container);
|
||||||
}
|
}
|
||||||
|
|
@ -230,69 +211,10 @@ void SetupKotatoFolders(
|
||||||
AddSkip(container);
|
AddSkip(container);
|
||||||
AddSubsectionTitle(container, tr::ktg_settings_filters());
|
AddSubsectionTitle(container, tr::ktg_settings_filters());
|
||||||
|
|
||||||
AddButton(
|
SettingsMenuСFilterSwitch(ktg_settings_filters_only_unmuted_counter, UnmutedFilterCounterOnly);
|
||||||
container,
|
SettingsMenuСFilterSwitch(ktg_settings_filters_hide_all, HideFilterAllChats);
|
||||||
tr::ktg_settings_filters_only_unmuted_counter(),
|
SettingsMenuСFilterSwitch(ktg_settings_filters_hide_edit, HideFilterEditButton);
|
||||||
st::settingsButton
|
SettingsMenuСFilterSwitch(ktg_settings_filters_hide_folder_names, HideFilterNames);
|
||||||
)->toggleOn(
|
|
||||||
rpl::single(cUnmutedFilterCounterOnly())
|
|
||||||
)->toggledValue(
|
|
||||||
) | rpl::filter([](bool enabled) {
|
|
||||||
return (enabled != cUnmutedFilterCounterOnly());
|
|
||||||
}) | rpl::start_with_next([=](bool enabled) {
|
|
||||||
cSetUnmutedFilterCounterOnly(enabled);
|
|
||||||
::Kotato::JsonSettings::Write();
|
|
||||||
controller->reloadFiltersMenu();
|
|
||||||
App::wnd()->fixOrder();
|
|
||||||
}, container->lifetime());
|
|
||||||
|
|
||||||
AddButton(
|
|
||||||
container,
|
|
||||||
tr::ktg_settings_filters_hide_all(),
|
|
||||||
st::settingsButton
|
|
||||||
)->toggleOn(
|
|
||||||
rpl::single(cHideFilterAllChats())
|
|
||||||
)->toggledValue(
|
|
||||||
) | rpl::filter([](bool enabled) {
|
|
||||||
return (enabled != cHideFilterAllChats());
|
|
||||||
}) | rpl::start_with_next([=](bool enabled) {
|
|
||||||
cSetHideFilterAllChats(enabled);
|
|
||||||
::Kotato::JsonSettings::Write();
|
|
||||||
controller->reloadFiltersMenu();
|
|
||||||
App::wnd()->fixOrder();
|
|
||||||
}, container->lifetime());
|
|
||||||
|
|
||||||
AddButton(
|
|
||||||
container,
|
|
||||||
tr::ktg_settings_filters_hide_edit(),
|
|
||||||
st::settingsButton
|
|
||||||
)->toggleOn(
|
|
||||||
rpl::single(cHideFilterEditButton())
|
|
||||||
)->toggledValue(
|
|
||||||
) | rpl::filter([](bool enabled) {
|
|
||||||
return (enabled != cHideFilterEditButton());
|
|
||||||
}) | rpl::start_with_next([=](bool enabled) {
|
|
||||||
cSetHideFilterEditButton(enabled);
|
|
||||||
::Kotato::JsonSettings::Write();
|
|
||||||
controller->reloadFiltersMenu();
|
|
||||||
App::wnd()->fixOrder();
|
|
||||||
}, container->lifetime());
|
|
||||||
|
|
||||||
AddButton(
|
|
||||||
container,
|
|
||||||
tr::ktg_settings_filters_hide_folder_names(),
|
|
||||||
st::settingsButton
|
|
||||||
)->toggleOn(
|
|
||||||
rpl::single(cHideFilterNames())
|
|
||||||
)->toggledValue(
|
|
||||||
) | rpl::filter([](bool enabled) {
|
|
||||||
return (enabled != cHideFilterNames());
|
|
||||||
}) | rpl::start_with_next([=](bool enabled) {
|
|
||||||
cSetHideFilterNames(enabled);
|
|
||||||
::Kotato::JsonSettings::Write();
|
|
||||||
controller->reloadFiltersMenu();
|
|
||||||
App::wnd()->fixOrder();
|
|
||||||
}, container->lifetime());
|
|
||||||
|
|
||||||
AddSkip(container);
|
AddSkip(container);
|
||||||
}
|
}
|
||||||
|
|
@ -302,19 +224,7 @@ void SetupKotatoSystem(not_null<Ui::VerticalLayout*> container) {
|
||||||
AddSkip(container);
|
AddSkip(container);
|
||||||
AddSubsectionTitle(container, tr::ktg_settings_system());
|
AddSubsectionTitle(container, tr::ktg_settings_system());
|
||||||
|
|
||||||
AddButton(
|
SettingsMenuСSwitch(ktg_settings_no_taskbar_flash, NoTaskbarFlashing);
|
||||||
container,
|
|
||||||
tr::ktg_settings_no_taskbar_flash(),
|
|
||||||
st::settingsButton
|
|
||||||
)->toggleOn(
|
|
||||||
rpl::single(cNoTaskbarFlashing())
|
|
||||||
)->toggledValue(
|
|
||||||
) | rpl::filter([](bool enabled) {
|
|
||||||
return (enabled != cNoTaskbarFlashing());
|
|
||||||
}) | rpl::start_with_next([](bool enabled) {
|
|
||||||
cSetNoTaskbarFlashing(enabled);
|
|
||||||
::Kotato::JsonSettings::Write();
|
|
||||||
}, container->lifetime());
|
|
||||||
|
|
||||||
AddSkip(container);
|
AddSkip(container);
|
||||||
}
|
}
|
||||||
|
|
@ -324,47 +234,9 @@ void SetupKotatoOther(not_null<Ui::VerticalLayout*> container) {
|
||||||
AddSkip(container);
|
AddSkip(container);
|
||||||
AddSubsectionTitle(container, tr::ktg_settings_other());
|
AddSubsectionTitle(container, tr::ktg_settings_other());
|
||||||
|
|
||||||
AddButton(
|
SettingsMenuСSwitch(ktg_settings_show_phone_number, ShowPhoneInDrawer);
|
||||||
container,
|
SettingsMenuСSwitch(ktg_settings_show_chat_id, ShowChatId);
|
||||||
tr::ktg_settings_show_phone_number(),
|
SettingsMenuСSwitch(ktg_settings_call_confirm, ConfirmBeforeCall);
|
||||||
st::settingsButton
|
|
||||||
)->toggleOn(
|
|
||||||
rpl::single(cShowPhoneInDrawer())
|
|
||||||
)->toggledValue(
|
|
||||||
) | rpl::filter([](bool enabled) {
|
|
||||||
return (enabled != cShowPhoneInDrawer());
|
|
||||||
}) | rpl::start_with_next([](bool enabled) {
|
|
||||||
cSetShowPhoneInDrawer(enabled);
|
|
||||||
::Kotato::JsonSettings::Write();
|
|
||||||
}, container->lifetime());
|
|
||||||
|
|
||||||
AddButton(
|
|
||||||
container,
|
|
||||||
tr::ktg_settings_show_chat_id(),
|
|
||||||
st::settingsButton
|
|
||||||
)->toggleOn(
|
|
||||||
rpl::single(cShowChatId())
|
|
||||||
)->toggledValue(
|
|
||||||
) | rpl::filter([](bool enabled) {
|
|
||||||
return (enabled != cShowChatId());
|
|
||||||
}) | rpl::start_with_next([](bool enabled) {
|
|
||||||
cSetShowChatId(enabled);
|
|
||||||
::Kotato::JsonSettings::Write();
|
|
||||||
}, container->lifetime());
|
|
||||||
|
|
||||||
AddButton(
|
|
||||||
container,
|
|
||||||
tr::ktg_settings_call_confirm(),
|
|
||||||
st::settingsButton
|
|
||||||
)->toggleOn(
|
|
||||||
rpl::single(cConfirmBeforeCall())
|
|
||||||
)->toggledValue(
|
|
||||||
) | rpl::filter([](bool enabled) {
|
|
||||||
return (enabled != cConfirmBeforeCall());
|
|
||||||
}) | rpl::start_with_next([](bool enabled) {
|
|
||||||
cSetConfirmBeforeCall(enabled);
|
|
||||||
::Kotato::JsonSettings::Write();
|
|
||||||
}, container->lifetime());
|
|
||||||
|
|
||||||
AddSkip(container);
|
AddSkip(container);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue