Begin writing config loading module
- Start with structs
This commit is contained in:
parent
a321b03ba4
commit
ed5a08ef94
@ -6,7 +6,9 @@ build = "build.rs"
|
||||
|
||||
[dependencies]
|
||||
i-slint-backend-winit = { version = "1.14.1", default-features = false, features = ["x11"] }
|
||||
serde = { version = "1.0.228", default-features = false, features = ["derive"] }
|
||||
slint = { version = "1.14.1", default-features = false, features = ["backend-winit", "compat-1-2", "renderer-software"] }
|
||||
toml = "0.9.11"
|
||||
|
||||
[build-dependencies]
|
||||
slint-build = "1.14.1"
|
||||
|
||||
65
src/config.rs
Normal file
65
src/config.rs
Normal file
@ -0,0 +1,65 @@
|
||||
use serde::Deserialize;
|
||||
use slint::{Color, SharedString};
|
||||
use std::{fs, path::PathBuf};
|
||||
|
||||
#[derive(Debug, Deserialize)]
|
||||
pub struct Config {
|
||||
pub screen: Option<ScreenConfig>,
|
||||
pub menu_popup: Option<MenuPopupConfig>,
|
||||
pub buttons: Option<ButtonConfig>,
|
||||
pub button: Option<ButtonContentConfig>,
|
||||
pub options: Option<Vec<MenuOption>>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Deserialize)]
|
||||
pub struct ScreenConfig {
|
||||
pub width: Option<i32>,
|
||||
pub height: Option<i32>,
|
||||
pub bg_color: Option<String>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Deserialize)]
|
||||
pub struct MenuPopupConfig {
|
||||
pub width: Option<i32>,
|
||||
pub height: Option<i32>,
|
||||
pub bg_color: Option<String>,
|
||||
pub border_radius: Option<i32>,
|
||||
pub padding_x: Option<i32>,
|
||||
pub padding_y: Option<i32>,
|
||||
pub button_spacing: Option<i32>,
|
||||
pub pos_x: Option<i32>,
|
||||
pub pos_y: Option<i32>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Deserialize)]
|
||||
pub struct ButtonConfig {
|
||||
pub width: Option<i32>,
|
||||
pub height: Option<i32>,
|
||||
pub border_radius: Option<i32>,
|
||||
pub bg_color_normal: Option<String>,
|
||||
pub bg_color_hover: Option<String>,
|
||||
pub bg_color_clicked: Option<String>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Deserialize)]
|
||||
pub struct ButtonContentConfig {
|
||||
pub icon: Option<ButtonPartConfig>,
|
||||
pub text: Option<ButtonPartConfig>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Deserialize)]
|
||||
pub struct ButtonPartConfig {
|
||||
pub width: Option<i32>,
|
||||
pub height: Option<i32>,
|
||||
pub font_size: Option<i32>,
|
||||
pub font: Option<String>,
|
||||
pub color: Option<String>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Deserialize)]
|
||||
pub struct MenuOption {
|
||||
pub id: String,
|
||||
pub icon: String,
|
||||
pub text: String,
|
||||
pub command: String,
|
||||
}
|
||||
@ -6,6 +6,7 @@ use i_slint_backend_winit::{
|
||||
},
|
||||
};
|
||||
|
||||
mod config;
|
||||
mod powermenu;
|
||||
|
||||
fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user