chore(app): remove redundant system theme property

The system theme is now set globally, so this is no longer used.
This commit is contained in:
Michael Aaron Murphy 2023-09-13 15:24:18 +02:00 committed by Michael Murphy
parent 16eec65765
commit 02413e5fa6
2 changed files with 2 additions and 25 deletions

View file

@ -1,8 +1,6 @@
// Copyright 2023 System76 <info@system76.com> // Copyright 2023 System76 <info@system76.com>
// SPDX-License-Identifier: MPL-2.0 // SPDX-License-Identifier: MPL-2.0
use crate::{theme, Theme};
/// Status of the nav bar and its panels. /// Status of the nav bar and its panels.
#[derive(Clone)] #[derive(Clone)]
pub struct NavBar { pub struct NavBar {
@ -41,7 +39,6 @@ pub struct Core {
/// Scaling factor used by the application /// Scaling factor used by the application
scale_factor: f32, scale_factor: f32,
pub system_theme: Theme,
pub(crate) title: String, pub(crate) title: String,
pub window: Window, pub window: Window,
#[cfg(feature = "applet")] #[cfg(feature = "applet")]
@ -59,7 +56,6 @@ impl Default for Core {
toggled_condensed: true, toggled_condensed: true,
}, },
scale_factor: 1.0, scale_factor: 1.0,
system_theme: theme::theme(),
title: String::new(), title: String::new(),
window: Window { window: Window {
use_template: true, use_template: true,

View file

@ -2,7 +2,7 @@
// SPDX-License-Identifier: MPL-2.0 // SPDX-License-Identifier: MPL-2.0
use super::{command, Application, ApplicationExt, Core, Subscription}; use super::{command, Application, ApplicationExt, Core, Subscription};
use crate::theme::{self, Theme, ThemeType, THEME}; use crate::theme::{self, Theme, THEME};
use crate::widget::nav_bar; use crate::widget::nav_bar;
use crate::{keyboard_nav, Element}; use crate::{keyboard_nav, Element};
#[cfg(feature = "wayland")] #[cfg(feature = "wayland")]
@ -36,8 +36,6 @@ pub enum Message {
ScaleFactor(f32), ScaleFactor(f32),
/// Requests theme changes. /// Requests theme changes.
ThemeChange(Theme), ThemeChange(Theme),
/// Notification of system theme changes.
SystemThemeChange(Theme),
/// Toggles visibility of the nav bar. /// Toggles visibility of the nav bar.
ToggleNavBar, ToggleNavBar,
/// Toggles the condensed status of the nav bar. /// Toggles the condensed status of the nav bar.
@ -151,7 +149,7 @@ where
.map(Message::KeyboardNav) .map(Message::KeyboardNav)
.map(super::Message::Cosmic), .map(super::Message::Cosmic),
theme::subscription(0) theme::subscription(0)
.map(Message::SystemThemeChange) .map(Message::ThemeChange)
.map(super::Message::Cosmic), .map(super::Message::Cosmic),
window_events.map(super::Message::Cosmic), window_events.map(super::Message::Cosmic),
]) ])
@ -275,13 +273,6 @@ impl<T: Application> Cosmic<T> {
} }
Message::ThemeChange(theme) => { Message::ThemeChange(theme) => {
// our system theme is always receiving updates so we should use it instead
let theme = if matches!(theme.theme_type, ThemeType::System(_)) {
self.app.core().system_theme.clone()
} else {
theme
};
THEME.with(move |t| { THEME.with(move |t| {
let mut cosmic_theme = t.borrow_mut(); let mut cosmic_theme = t.borrow_mut();
cosmic_theme.set_theme(theme.theme_type); cosmic_theme.set_theme(theme.theme_type);
@ -291,16 +282,6 @@ impl<T: Application> Cosmic<T> {
Message::ScaleFactor(factor) => { Message::ScaleFactor(factor) => {
self.app.core_mut().set_scale_factor(factor); self.app.core_mut().set_scale_factor(factor);
} }
Message::SystemThemeChange(theme) => {
self.app.core_mut().system_theme = theme.clone();
THEME.with(move |t| {
let mut cosmic_theme = t.borrow_mut();
// only apply update if the theme is set to load a system theme
if matches!(cosmic_theme.theme_type, ThemeType::System(_)) {
cosmic_theme.set_theme(theme.theme_type);
}
});
}
} }
iced::Command::none() iced::Command::none()