1use crate::{Theme, font};
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(feature = "wayland")]
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 pub(crate) default_font: Font,
33
34 #[setters(skip)]
36 pub(crate) default_icon_theme: Option<String>,
37
38 pub(crate) default_text_size: f32,
40
41 pub(crate) default_mmap_threshold: Option<i32>,
43
44 pub(crate) resizable: Option<f64>,
47
48 pub(crate) scale_factor: f32,
50
51 pub(crate) size: iced::Size,
53
54 pub(crate) size_limits: Limits,
56
57 pub(crate) theme: Theme,
59
60 pub(crate) transparent: bool,
62
63 pub(crate) exit_on_close: bool,
65
66 pub(crate) is_daemon: bool,
68}
69
70impl Settings {
71 pub fn default_icon_theme(mut self, value: impl Into<String>) -> Self {
73 let value: String = value.into();
74 self.default_icon_theme = if value.is_empty() { None } else { Some(value) };
75 self
76 }
77}
78
79impl Default for Settings {
80 fn default() -> Self {
81 Self {
82 antialiasing: true,
83 #[cfg(feature = "wayland")]
84 autosize: false,
85 no_main_window: false,
86 client_decorations: true,
87 debug: false,
88 default_font: font::default(),
89 default_icon_theme: None,
90 default_text_size: 14.0,
91 default_mmap_threshold: Some(128 * 1024),
92 resizable: Some(8.0),
93 scale_factor: std::env::var("COSMIC_SCALE")
94 .ok()
95 .and_then(|scale| scale.parse::<f32>().ok())
96 .unwrap_or(1.0),
97 size: iced::Size::new(1024.0, 768.0),
98 size_limits: Limits::NONE.min_height(1.0).min_width(1.0),
99 theme: crate::theme::system_preference(),
100 transparent: true,
101 exit_on_close: true,
102 is_daemon: true,
103 }
104 }
105}