Use runtime OS checks in settings_menu

This commit is contained in:
Ilya Fedin 2020-12-25 20:47:03 +04:00
parent 3e16c5cf26
commit dac24fb5b5

View file

@ -469,34 +469,34 @@ void SetupKotatoSystem(
} }
#endif // !TDESKTOP_DISABLE_GTK_INTEGRATION #endif // !TDESKTOP_DISABLE_GTK_INTEGRATION
#if defined Q_OS_MAC if (Platform::IsMac()) {
const auto useNativeDecorationsToggled = Ui::CreateChild<rpl::event_stream<bool>>( const auto useNativeDecorationsToggled = Ui::CreateChild<rpl::event_stream<bool>>(
container.get()); container.get());
AddButton( AddButton(
container, container,
tr::lng_settings_native_frame(), tr::lng_settings_native_frame(),
st::settingsButton st::settingsButton
)->toggleOn( )->toggleOn(
useNativeDecorationsToggled->events_starting_with_copy(cUseNativeDecorations()) useNativeDecorationsToggled->events_starting_with_copy(cUseNativeDecorations())
)->toggledValue( )->toggledValue(
) | rpl::filter([](bool enabled) { ) | rpl::filter([](bool enabled) {
return (enabled != cUseNativeDecorations()); return (enabled != cUseNativeDecorations());
}) | rpl::start_with_next([=](bool enabled) { }) | rpl::start_with_next([=](bool enabled) {
const auto confirmed = [=] { const auto confirmed = [=] {
cSetUseNativeDecorations(enabled); cSetUseNativeDecorations(enabled);
::Kotato::JsonSettings::Write(); ::Kotato::JsonSettings::Write();
App::restart(); App::restart();
}; };
const auto cancelled = [=] { const auto cancelled = [=] {
useNativeDecorationsToggled->fire(cUseNativeDecorations() == true); useNativeDecorationsToggled->fire(cUseNativeDecorations() == true);
}; };
Ui::show(Box<ConfirmBox>( Ui::show(Box<ConfirmBox>(
tr::lng_settings_need_restart(tr::now), tr::lng_settings_need_restart(tr::now),
tr::lng_settings_restart_now(tr::now), tr::lng_settings_restart_now(tr::now),
confirmed, confirmed,
cancelled)); cancelled));
}, container->lifetime()); }, container->lifetime());
#endif // Q_OS_MAC }
AddButton( AddButton(
container, container,
@ -513,22 +513,22 @@ void SetupKotatoSystem(
::Kotato::JsonSettings::Write(); ::Kotato::JsonSettings::Write();
}, container->lifetime()); }, container->lifetime());
#if defined Q_OS_UNIX && !defined Q_OS_MAC if (Platform::IsLinux()) {
AddButton( AddButton(
container, container,
tr::ktg_settings_use_telegram_panel_icon(), tr::ktg_settings_use_telegram_panel_icon(),
st::settingsButton st::settingsButton
)->toggleOn( )->toggleOn(
rpl::single(cUseTelegramPanelIcon()) rpl::single(cUseTelegramPanelIcon())
)->toggledValue( )->toggledValue(
) | rpl::filter([](bool enabled) { ) | rpl::filter([](bool enabled) {
return (enabled != cUseTelegramPanelIcon()); return (enabled != cUseTelegramPanelIcon());
}) | rpl::start_with_next([controller](bool enabled) { }) | rpl::start_with_next([controller](bool enabled) {
cSetUseTelegramPanelIcon(enabled); cSetUseTelegramPanelIcon(enabled);
controller->session().data().notifyUnreadBadgeChanged(); controller->session().data().notifyUnreadBadgeChanged();
::Kotato::JsonSettings::Write(); ::Kotato::JsonSettings::Write();
}, container->lifetime()); }, container->lifetime());
#endif // Q_OS_UNIX && !Q_OS_MAC }
const QMap<int, QString> trayIconOptions = { const QMap<int, QString> trayIconOptions = {
{ 0, TrayIconLabel(0) }, { 0, TrayIconLabel(0) },