a lightweight, interval-based utility to combat digital strain through "Ma" (intentional pauses) for the eyes and body.
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

refactor: move active_profile() to timer/profile

+16 -17
+1 -10
src/app.rs
··· 4 4 5 5 use crate::config::{self, AppConfig}; 6 6 use crate::idle; 7 - use crate::timer::{Profile, TimerCommand, TimerEvent, TimerTask}; 7 + use crate::timer::{active_profile, TimerCommand, TimerEvent, TimerTask}; 8 8 9 9 // Shared app state accessed from multiple threads. 10 10 pub struct AppState { ··· 30 30 log::warn!("Failed to save config: {e}"); 31 31 } 32 32 } 33 - } 34 - 35 - pub fn active_profile(cfg: &AppConfig) -> Profile { 36 - let prof_cfg = cfg 37 - .profiles 38 - .get(&cfg.app.active_profile) 39 - .or_else(|| cfg.profiles.values().next()) 40 - .expect("config must have at least one profile"); 41 - Profile::from_config(prof_cfg) 42 33 } 43 34 44 35 // Spawns the idle detection polling loop on a plain OS thread (not tokio)
+2 -2
src/main.rs
··· 25 25 use std::sync::{Arc, Mutex}; 26 26 use std::sync::atomic::AtomicBool; 27 27 28 - use app::{AppState, active_profile, spawn_idle_poller}; 28 + use app::{AppState, spawn_idle_poller}; 29 29 use config::AppConfig; 30 30 use overlay::OverlayManager; 31 31 use settings::SettingsManager; 32 - use timer::{BreakMode, TimerCommand, TimerEvent}; 32 + use timer::{active_profile, BreakMode, TimerCommand, TimerEvent}; 33 33 use tray::AppTray; 34 34 use tray_format::{build_working_tracker_lines, fmt_countdown, fmt_tray_duration, fmt_tray_minutes}; 35 35
+1 -2
src/overlay/multi_slint.rs
··· 5 5 #[cfg(any(target_os = "linux", target_os = "windows"))] 6 6 use slint::winit_030::{WinitWindowAccessor, winit}; 7 7 8 - use crate::app::active_profile; 9 8 use crate::config::AppConfig; 10 9 use crate::generated::OverlayWindow; 11 10 use crate::overlay::OverlayBackend; 12 11 use crate::overlay::fmt_dur; 13 12 use crate::overlay::monitors::MonitorInfo; 14 - use crate::timer::{BreakMode, ScheduledBreak, TimerCommand}; 13 + use crate::timer::{active_profile, BreakMode, ScheduledBreak, TimerCommand}; 15 14 16 15 struct WindowEntry { 17 16 window: OverlayWindow,
+1 -1
src/settings/mod.rs
··· 5 5 use fontdue::Font; 6 6 use slint::{ComponentHandle, Model, ModelRc, SharedString, VecModel}; 7 7 8 - use crate::app::active_profile; 8 + use crate::timer::active_profile; 9 9 use crate::autostart; 10 10 use crate::config::{ 11 11 self, AppConfig, BreakLevelConfig, BreakModeConfig, LongBreakConfig, OverlayTheme,
+1 -1
src/timer/mod.rs
··· 1 1 pub mod profile; 2 2 pub mod scheduler; 3 3 4 - pub use profile::{BreakMode, Profile}; 4 + pub use profile::{active_profile, BreakMode, Profile}; 5 5 pub use scheduler::{LevelBreakStatus, LongBreakStatus, ScheduledBreak, Scheduler}; 6 6 7 7 use std::sync::mpsc as std_mpsc;
+10 -1
src/timer/profile.rs
··· 1 1 use std::time::Duration; 2 2 3 - use crate::config::{BreakLevelConfig, BreakModeConfig, LongBreakConfig, ProfileConfig}; 3 + use crate::config::{AppConfig, BreakLevelConfig, BreakModeConfig, LongBreakConfig, ProfileConfig}; 4 + 5 + pub fn active_profile(cfg: &AppConfig) -> Profile { 6 + let prof_cfg = cfg 7 + .profiles 8 + .get(&cfg.app.active_profile) 9 + .or_else(|| cfg.profiles.values().next()) 10 + .expect("config must have at least one profile"); 11 + Profile::from_config(prof_cfg) 12 + } 4 13 5 14 #[derive(Debug, Clone, PartialEq)] 6 15 pub enum BreakMode {