Forbid auto-night mode with theme editor.

This commit is contained in:
John Preston 2020-07-24 10:01:37 +04:00
parent 9a186cd8ce
commit 511067981d
4 changed files with 20 additions and 2 deletions

View File

@ -309,6 +309,9 @@ void Application::checkSystemDarkMode() {
}
void Application::startSystemDarkModeViewer() {
if (Window::Theme::Background()->editingTheme()) {
_settings.setSystemDarkModeEnabled(false);
}
rpl::merge(
_settings.systemDarkModeChanges() | rpl::to_empty,
_settings.systemDarkModeEnabledChanges() | rpl::to_empty

View File

@ -1294,8 +1294,14 @@ void SetupAutoNightMode(not_null<Ui::VerticalLayout*> container) {
) | rpl::filter([=](bool checked) {
return (checked != Core::App().settings().systemDarkModeEnabled());
}) | rpl::start_with_next([=](bool checked) {
Core::App().settings().setSystemDarkModeEnabled(checked);
Core::App().saveSettingsDelayed();
if (checked && Window::Theme::Background()->editingTheme()) {
autoNight->setChecked(false);
Ui::show(Box<InformBox>(
tr::lng_theme_editor_cant_change_theme(tr::now)));
} else {
Core::App().settings().setSystemDarkModeEnabled(checked);
Core::App().saveSettingsDelayed();
}
}, autoNight->lifetime());
Core::App().settings().systemDarkModeEnabledChanges(

View File

@ -676,6 +676,10 @@ void StartEditor(
window->show(Box<InformBox>(tr::lng_theme_editor_error(tr::now)));
return;
}
if (Core::App().settings().systemDarkModeEnabled()) {
Core::App().settings().setSystemDarkModeEnabled(false);
Core::App().saveSettingsDelayed();
}
Background()->setEditingTheme(cloud);
window->showRightColumn(Box<Editor>(window, cloud));
}

View File

@ -880,6 +880,11 @@ void MainMenu::refreshMenu() {
_nightThemeAction = std::make_shared<QPointer<QAction>>();
auto action = _menu->addAction(tr::lng_menu_night_mode(tr::now), [=] {
if (Window::Theme::Background()->editingTheme()) {
Ui::show(Box<InformBox>(
tr::lng_theme_editor_cant_change_theme(tr::now)));
return;
}
const auto weak = MakeWeak(this);
const auto toggle = [=] {
if (!weak) {