flowsurface_data/config/
state.rs1use super::ScaleFactor;
2use super::sidebar::Sidebar;
3use super::timezone::UserTimezone;
4use crate::layout::WindowSpec;
5use crate::{AudioStream, Layout, Theme};
6
7use serde::{Deserialize, Serialize};
8
9#[derive(Clone, Serialize, Deserialize, Default)]
10pub struct Layouts {
11 pub layouts: Vec<Layout>,
12 pub active_layout: Option<String>,
13}
14
15#[derive(Default, Clone, Deserialize, Serialize)]
16#[serde(default)]
17pub struct State {
18 pub layout_manager: Layouts,
19 pub selected_theme: Theme,
20 pub custom_theme: Option<Theme>,
21 pub main_window: Option<WindowSpec>,
22 pub timezone: UserTimezone,
23 pub sidebar: Sidebar,
24 pub scale_factor: ScaleFactor,
25 pub audio_cfg: AudioStream,
26 pub trade_fetch_enabled: bool,
27 pub size_in_quote_ccy: exchange::SizeUnit,
28 pub proxy_cfg: Option<exchange::proxy::Proxy>,
29}
30
31impl State {
32 pub fn from_parts(
33 layout_manager: Layouts,
34 selected_theme: Theme,
35 custom_theme: Option<Theme>,
36 main_window: Option<WindowSpec>,
37 timezone: UserTimezone,
38 sidebar: Sidebar,
39 scale_factor: ScaleFactor,
40 audio_cfg: AudioStream,
41 trade_fetch_enabled: bool,
42 volume_size_unit: exchange::SizeUnit,
43 proxy_cfg: Option<exchange::proxy::Proxy>,
44 ) -> Self {
45 State {
46 layout_manager,
47 selected_theme: Theme(selected_theme.0),
48 custom_theme: custom_theme.map(|t| Theme(t.0)),
49 main_window,
50 timezone,
51 sidebar,
52 scale_factor,
53 audio_cfg,
54 trade_fetch_enabled,
55 size_in_quote_ccy: volume_size_unit,
56 proxy_cfg,
57 }
58 }
59}