2024-01-24 14:31:39 -07:00
|
|
|
// SPDX-License-Identifier: GPL-3.0-only
|
|
|
|
|
|
|
|
|
|
use cosmic::{
|
|
|
|
|
cosmic_config::{self, cosmic_config_derive::CosmicConfigEntry, CosmicConfigEntry},
|
|
|
|
|
theme,
|
|
|
|
|
};
|
|
|
|
|
use serde::{Deserialize, Serialize};
|
2025-01-24 12:49:02 -07:00
|
|
|
use std::collections::VecDeque;
|
2024-02-14 03:09:44 -05:00
|
|
|
|
2024-01-24 14:31:39 -07:00
|
|
|
pub const CONFIG_VERSION: u64 = 1;
|
|
|
|
|
|
|
|
|
|
#[derive(Clone, Copy, Debug, Deserialize, Eq, PartialEq, Serialize)]
|
|
|
|
|
pub enum AppTheme {
|
|
|
|
|
Dark,
|
|
|
|
|
Light,
|
|
|
|
|
System,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
impl AppTheme {
|
|
|
|
|
pub fn theme(&self) -> theme::Theme {
|
|
|
|
|
match self {
|
|
|
|
|
Self::Dark => theme::Theme::dark(),
|
|
|
|
|
Self::Light => theme::Theme::light(),
|
|
|
|
|
Self::System => theme::system_preference(),
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[derive(Clone, CosmicConfigEntry, Debug, Deserialize, Eq, PartialEq, Serialize)]
|
2024-10-05 10:05:18 -06:00
|
|
|
#[serde(default)]
|
2024-01-24 14:31:39 -07:00
|
|
|
pub struct Config {
|
|
|
|
|
pub app_theme: AppTheme,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
impl Default for Config {
|
|
|
|
|
fn default() -> Self {
|
|
|
|
|
Self {
|
|
|
|
|
app_theme: AppTheme::System,
|
2024-02-15 23:38:23 -05:00
|
|
|
}
|
|
|
|
|
}
|
2024-10-10 11:22:22 -06:00
|
|
|
}
|
2025-01-24 12:49:02 -07:00
|
|
|
|
|
|
|
|
#[derive(Clone, CosmicConfigEntry, Debug, Deserialize, Eq, PartialEq, Serialize)]
|
|
|
|
|
pub struct ConfigState {
|
|
|
|
|
pub recent_files: VecDeque<url::Url>,
|
|
|
|
|
pub recent_folders: VecDeque<url::Url>,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
impl Default for ConfigState {
|
|
|
|
|
fn default() -> Self {
|
|
|
|
|
Self {
|
|
|
|
|
recent_files: VecDeque::new(),
|
|
|
|
|
recent_folders: VecDeque::new(),
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|