1use gpui::App;
2pub use settings::ImageFileSizeUnit;
3use settings::Settings;
4use util::MergeFrom;
5
6/// The settings for the image viewer.
7#[derive(Clone, Debug, Default)]
8pub struct ImageViewerSettings {
9 /// The unit to use for displaying image file sizes.
10 ///
11 /// Default: "binary"
12 pub unit: ImageFileSizeUnit,
13}
14
15impl Settings for ImageViewerSettings {
16 fn from_defaults(content: &settings::SettingsContent, _cx: &mut App) -> Self {
17 Self {
18 unit: content.image_viewer.clone().unwrap().unit.unwrap(),
19 }
20 }
21
22 fn refine(&mut self, content: &settings::SettingsContent, _cx: &mut App) {
23 self.unit.merge_from(
24 &content
25 .image_viewer
26 .as_ref()
27 .and_then(|image_viewer| image_viewer.unit),
28 );
29 }
30}