1use crate::Theme;
7use iced_core::Font;
8use iced_core::layout::Limits;
9
10#[allow(clippy::struct_excessive_bools)]
12#[must_use]
13#[derive(derive_setters::Setters)]
14pub struct Settings {
15 pub(crate) antialiasing: bool,
17
18 #[cfg(wayland_platform)]
20 pub(crate) autosize: bool,
21
22 pub(crate) no_main_window: bool,
24
25 pub(crate) client_decorations: bool,
27
28 pub(crate) debug: bool,
30
31 #[setters(skip)]
35 pub(crate) default_font: Option<Font>,
36
37 #[setters(skip)]
39 pub(crate) default_icon_theme: Option<String>,
40
41 pub(crate) default_text_size: f32,
43
44 pub(crate) default_mmap_threshold: Option<i32>,
46
47 pub(crate) resizable: Option<f64>,
50
51 pub(crate) scale_factor: f32,
53
54 pub(crate) size: iced::Size,
56
57 pub(crate) size_limits: Limits,
59
60 pub(crate) theme: Theme,
62
63 pub(crate) transparent: bool,
65
66 pub(crate) exit_on_close: bool,
68
69 pub(crate) is_daemon: bool,
71}
72
73impl Settings {
74 pub fn default_font(mut self, value: impl Into<Font>) -> Self {
78 self.default_font = Some(value.into());
79 self
80 }
81
82 pub fn default_icon_theme(mut self, value: impl Into<String>) -> Self {
85 let value: String = value.into();
86 self.default_icon_theme = if value.is_empty() { None } else { Some(value) };
87 self
88 }
89}
90
91impl Default for Settings {
92 fn default() -> Self {
93 Self {
94 antialiasing: true,
95 #[cfg(wayland_platform)]
96 autosize: false,
97 no_main_window: false,
98 client_decorations: true,
99 debug: false,
100 default_font: None,
101 default_icon_theme: None,
102 default_text_size: 14.0,
103 default_mmap_threshold: Some(128 * 1024),
104 resizable: Some(8.0),
105 scale_factor: std::env::var("COSMIC_SCALE")
106 .ok()
107 .and_then(|scale| scale.parse::<f32>().ok())
108 .unwrap_or(1.0),
109 size: iced::Size::new(1024.0, 768.0),
110 size_limits: Limits::NONE.min_height(1.0).min_width(1.0),
111 theme: crate::theme::system_preference(),
112 transparent: true,
113 exit_on_close: true,
114 is_daemon: true,
115 }
116 }
117}