2026-01-07 20:42:28 +01:00
|
|
|
// SPDX-License-Identifier: GPL-3.0-or-later
|
2026-01-07 20:22:49 +01:00
|
|
|
// src/config.rs
|
2026-01-14 18:53:36 +01:00
|
|
|
//
|
|
|
|
|
// Global configuration for the application with cosmic-config support.
|
2026-01-07 20:22:49 +01:00
|
|
|
|
|
|
|
|
use cosmic::cosmic_config::{self, CosmicConfigEntry, cosmic_config_derive::CosmicConfigEntry};
|
|
|
|
|
use std::path::PathBuf;
|
|
|
|
|
|
|
|
|
|
/// Global configuration for the application.
|
2026-01-18 20:35:12 +01:00
|
|
|
#[derive(Debug, Clone, CosmicConfigEntry, PartialEq)]
|
2026-01-07 20:22:49 +01:00
|
|
|
#[version = 1]
|
|
|
|
|
pub struct AppConfig {
|
|
|
|
|
/// Optional default directory to open images from.
|
|
|
|
|
pub default_image_dir: Option<PathBuf>,
|
2026-01-14 18:53:36 +01:00
|
|
|
/// Whether the nav bar (left panel) is visible.
|
|
|
|
|
pub nav_bar_visible: bool,
|
|
|
|
|
/// Whether the context drawer (right panel) is visible.
|
|
|
|
|
pub context_drawer_visible: bool,
|
2026-01-18 20:35:12 +01:00
|
|
|
/// Scale step factor for keyboard zoom (e.g., 1.1 = 10% per step).
|
|
|
|
|
pub scale_step: f32,
|
|
|
|
|
/// Pan step size in pixels per key press.
|
|
|
|
|
pub pan_step: f32,
|
|
|
|
|
/// Minimum zoom scale (e.g., 0.1 = 10%).
|
|
|
|
|
pub min_scale: f32,
|
|
|
|
|
/// Maximum zoom scale (e.g., 20.0 = 2000%).
|
|
|
|
|
pub max_scale: f32,
|
2026-01-07 20:22:49 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
impl Default for AppConfig {
|
|
|
|
|
fn default() -> Self {
|
|
|
|
|
Self {
|
2026-01-14 20:54:42 +01:00
|
|
|
default_image_dir: dirs::picture_dir().or_else(dirs::home_dir),
|
2026-01-14 18:53:36 +01:00
|
|
|
nav_bar_visible: false,
|
|
|
|
|
context_drawer_visible: false,
|
2026-01-18 20:35:12 +01:00
|
|
|
scale_step: 1.1,
|
|
|
|
|
pan_step: 50.0,
|
|
|
|
|
min_scale: 0.1,
|
|
|
|
|
max_scale: 8.0,
|
2026-01-07 20:22:49 +01:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|