settings gui PoC
This commit is contained in:
@@ -14,7 +14,7 @@ use wgui::{
|
||||
};
|
||||
|
||||
use crate::{
|
||||
assets,
|
||||
assets, settings,
|
||||
tab::{
|
||||
Tab, TabParams, TabType, apps::TabApps, games::TabGames, home::TabHome, monado::TabMonado, processes::TabProcesses,
|
||||
settings::TabSettings,
|
||||
@@ -25,6 +25,8 @@ pub struct Frontend {
|
||||
pub layout: RcLayout,
|
||||
globals: WguiGlobals,
|
||||
|
||||
settings: settings::Settings,
|
||||
|
||||
#[allow(dead_code)]
|
||||
state: ParserState,
|
||||
|
||||
@@ -37,6 +39,10 @@ pub struct Frontend {
|
||||
label_time_id: WidgetID,
|
||||
}
|
||||
|
||||
pub struct InitParams {
|
||||
pub settings: settings::Settings,
|
||||
}
|
||||
|
||||
pub type RcFrontend = Rc<RefCell<Frontend>>;
|
||||
|
||||
pub enum FrontendTask {
|
||||
@@ -44,7 +50,7 @@ pub enum FrontendTask {
|
||||
}
|
||||
|
||||
impl Frontend {
|
||||
pub fn new() -> anyhow::Result<(RcFrontend, RcLayout)> {
|
||||
pub fn new(params: InitParams) -> anyhow::Result<(RcFrontend, RcLayout)> {
|
||||
let globals = WguiGlobals::new(Box::new(assets::Asset {}), wgui::globals::Defaults::default())?;
|
||||
|
||||
let (layout, state) = wgui::parser::new_layout_from_assets(
|
||||
@@ -71,6 +77,7 @@ impl Frontend {
|
||||
tasks,
|
||||
ticks: 0,
|
||||
label_time_id,
|
||||
settings: params.settings,
|
||||
}));
|
||||
|
||||
Frontend::register_widgets(&res)?;
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
mod assets;
|
||||
pub mod frontend;
|
||||
pub mod settings;
|
||||
mod tab;
|
||||
mod util;
|
||||
mod various;
|
||||
|
||||
41
dash-frontend/src/settings.rs
Normal file
41
dash-frontend/src/settings.rs
Normal file
@@ -0,0 +1,41 @@
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
#[derive(Default, Serialize, Deserialize)]
|
||||
pub struct HomeScreen {
|
||||
pub hide_username: bool,
|
||||
}
|
||||
|
||||
#[derive(Default, Serialize, Deserialize)]
|
||||
pub struct General {
|
||||
pub am_pm_clock: bool,
|
||||
pub opaque_background: bool,
|
||||
}
|
||||
|
||||
#[derive(Default, Serialize, Deserialize)]
|
||||
pub enum ApplicationRunMode {
|
||||
#[default]
|
||||
Native, /* use Smithay compositor */
|
||||
XWaylandCage,
|
||||
}
|
||||
|
||||
#[derive(Default, Serialize, Deserialize)]
|
||||
pub struct Tweaks {
|
||||
pub default_run_mode: ApplicationRunMode,
|
||||
}
|
||||
|
||||
#[derive(Default, Serialize, Deserialize)]
|
||||
pub struct Settings {
|
||||
pub home_screen: HomeScreen,
|
||||
pub general: General,
|
||||
pub tweaks: Tweaks,
|
||||
}
|
||||
|
||||
impl Settings {
|
||||
pub fn save(&self) -> String {
|
||||
serde_json::to_string(&self).unwrap() /* want panic */
|
||||
}
|
||||
|
||||
pub fn load(input: &str) -> anyhow::Result<Settings> {
|
||||
Ok(serde_json::from_str::<Settings>(input)?)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user