Refactor and cleanup theming

This commit is contained in:
Luke D. Jones
2024-03-11 22:26:26 +13:00
parent c7b1624313
commit 9725062fb9
18 changed files with 570 additions and 333 deletions

View File

@@ -4,6 +4,14 @@ use gumdrop::Options;
pub struct CliStart {
#[options(help_flag, help = "print help message")]
pub help: bool,
#[options(help = "start fullscreen, if used the option is saved")]
pub fullscreen: bool,
#[options(help = "fullscreen width")]
pub width_fullscreen: u32,
#[options(help = "fullscreen height")]
pub height_fullscreen: u32,
#[options(help = "start windowed, if used the option is saved")]
pub windowed: bool,
#[options(help = "show program version number")]
pub version: bool,
#[options(

View File

@@ -17,6 +17,10 @@ pub struct Config {
pub bat_command: String,
pub enable_notifications: bool,
pub dark_mode: bool,
// intended for use with devices like the ROG Ally
pub start_fullscreen: bool,
pub fullscreen_width: u32,
pub fullscreen_height: u32,
// This field must be last
pub enabled_notifications: EnabledNotifications,
}
@@ -29,6 +33,9 @@ impl Default for Config {
enable_notifications: true,
enable_tray_icon: true,
dark_mode: true,
start_fullscreen: false,
fullscreen_width: 1920,
fullscreen_height: 1080,
enabled_notifications: EnabledNotifications::default(),
ac_command: String::new(),
bat_command: String::new(),
@@ -84,6 +91,9 @@ impl From<Config461> for Config {
ac_command: c.ac_command,
bat_command: c.bat_command,
dark_mode: true,
start_fullscreen: false,
fullscreen_width: 1920,
fullscreen_height: 1080,
enable_notifications: c.enable_notifications,
enabled_notifications: c.enabled_notifications,
}

View File

@@ -79,6 +79,19 @@ fn main() -> Result<()> {
// Startup
let mut config = Config::new().load();
if cli_parsed.fullscreen {
config.start_fullscreen = true;
if cli_parsed.width_fullscreen != 0 {
config.fullscreen_width = cli_parsed.width_fullscreen;
}
if cli_parsed.height_fullscreen != 0 {
config.fullscreen_height = cli_parsed.height_fullscreen;
}
config.write();
} else if cli_parsed.windowed {
config.start_fullscreen = false;
config.write();
}
if config.startup_in_background {
config.run_in_background = true;

View File

@@ -7,7 +7,7 @@ use rog_dbus::zbus_anime::AnimeProxy;
use rog_dbus::zbus_aura::AuraProxy;
use rog_dbus::zbus_platform::{PlatformProxy, PlatformProxyBlocking};
use rog_platform::platform::Properties;
use slint::{ComponentHandle, Model, RgbaColor, SharedString, Weak};
use slint::{ComponentHandle, Model, PhysicalSize, RgbaColor, SharedString, Weak};
use zbus::proxy::CacheProperties;
use crate::config::Config;
@@ -76,8 +76,17 @@ macro_rules! set_ui_callbacks {
};
}
pub fn setup_window(_config: Arc<Mutex<Config>>) -> MainWindow {
pub fn setup_window(config: Arc<Mutex<Config>>) -> MainWindow {
let ui = MainWindow::new().unwrap();
if let Ok(lock) = config.try_lock() {
let fullscreen = lock.start_fullscreen;
let width = lock.fullscreen_width;
let height = lock.fullscreen_height;
if fullscreen {
ui.window().set_fullscreen(fullscreen);
ui.window().set_size(PhysicalSize { width, height });
}
};
let conn = zbus::blocking::Connection::system().unwrap();
let platform = PlatformProxyBlocking::new(&conn).unwrap();
@@ -102,11 +111,11 @@ pub fn setup_window(_config: Arc<Mutex<Config>>) -> MainWindow {
slint::quit_event_loop().unwrap();
});
setup_app_settings_page(&ui, _config.clone());
setup_system_page(&ui, _config.clone());
setup_system_page_callbacks(&ui, _config.clone());
setup_aura_page(&ui, _config.clone());
setup_anime_page(&ui, _config);
setup_app_settings_page(&ui, config.clone());
setup_system_page(&ui, config.clone());
setup_system_page_callbacks(&ui, config.clone());
setup_aura_page(&ui, config.clone());
setup_anime_page(&ui, config);
ui
}