mirror of
https://git.hiabuto.net/C3MA/CCMA.git
synced 2026-08-26 15:25:19 +02:00
feat: configure minimum splash duration
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
from __future__ import annotations
|
||||
|
||||
import json
|
||||
import math
|
||||
import os
|
||||
from dataclasses import dataclass
|
||||
from pathlib import Path
|
||||
@@ -18,6 +19,7 @@ class AppConfig:
|
||||
gnucash_path: str = ""
|
||||
theme_mode: str = "dark"
|
||||
run_housekeeper_on_startup: bool = True
|
||||
splash_minimum_seconds: float = 5.0
|
||||
birthday_days_before: int = 7
|
||||
birthday_days_after: int = 2
|
||||
anniversary_days_before: int = 14
|
||||
@@ -40,6 +42,7 @@ class AppConfig:
|
||||
"gnucash_path": self.gnucash_path,
|
||||
"theme_mode": self.theme_mode,
|
||||
"run_housekeeper_on_startup": self.run_housekeeper_on_startup,
|
||||
"splash_minimum_seconds": _non_negative_float(self.splash_minimum_seconds, 5.0),
|
||||
"birthday_days_before": self.birthday_days_before,
|
||||
"birthday_days_after": self.birthday_days_after,
|
||||
"anniversary_days_before": self.anniversary_days_before,
|
||||
@@ -96,6 +99,7 @@ def load_config() -> AppConfig:
|
||||
gnucash_path=str(data.get("gnucash_path", "")),
|
||||
theme_mode=str(data.get("theme_mode", "dark")),
|
||||
run_housekeeper_on_startup=bool(data.get("run_housekeeper_on_startup", True)),
|
||||
splash_minimum_seconds=_non_negative_float(data.get("splash_minimum_seconds", 5.0), 5.0),
|
||||
birthday_days_before=int(data.get("birthday_days_before", 7)),
|
||||
birthday_days_after=int(data.get("birthday_days_after", 2)),
|
||||
anniversary_days_before=int(data.get("anniversary_days_before", 14)),
|
||||
@@ -113,3 +117,11 @@ def _legacy_config_directory() -> Path:
|
||||
if os.name == "nt":
|
||||
return Path(os.environ.get("APPDATA", Path.home())) / "C3MA"
|
||||
return Path(os.environ.get("XDG_CONFIG_HOME", Path.home() / ".config")) / "c3ma"
|
||||
|
||||
|
||||
def _non_negative_float(value: object, default: float) -> float:
|
||||
try:
|
||||
parsed = float(value)
|
||||
except (TypeError, ValueError):
|
||||
return default
|
||||
return max(0.0, parsed) if math.isfinite(parsed) else default
|
||||
|
||||
Reference in New Issue
Block a user