2
0
mirror of https://github.com/telegramdesktop/tdesktop synced 2025-08-31 14:38:15 +00:00

Implement system-based dark mode for Windows and Linux

This commit is contained in:
Ilya Fedin
2020-07-14 20:36:55 +04:00
committed by John Preston
parent fc3a9d98c0
commit 47a237c924
12 changed files with 185 additions and 20 deletions

View File

@@ -902,6 +902,19 @@ void MainMenu::refreshMenu() {
*_nightThemeAction = action;
action->setCheckable(true);
action->setChecked(Window::Theme::IsNightMode());
Core::App().settings().systemDarkModeValue(
) | rpl::start_with_next([=](std::optional<bool> darkMode) {
const auto darkModeEnabled = Core::App().settings().systemDarkModeEnabled();
if (darkModeEnabled && darkMode.has_value()) {
action->setChecked(*darkMode);
}
action->setEnabled(!darkModeEnabled || !darkMode.has_value());
}, lifetime());
Core::App().settings().systemDarkModeEnabledChanges(
) | rpl::start_with_next([=](bool darkModeEnabled) {
const auto darkMode = Core::App().settings().systemDarkMode();
action->setEnabled(!darkModeEnabled || !darkMode.has_value());
}, lifetime());
_menu->finishAnimating();
updatePhone();