Files
copydev-imposing-tool/app/presets/preset_manager.py
Jules 1d48e103e3 V3.1.0 — Selection multiple, impression, MAJ dans Aide, menu contextuel
- Selection multiple dans les vignettes (Ctrl+clic, Maj+clic)
- Rotation/suppression sur selection multiple
- Impression : os.startfile(print) avec fallback
- MAJ deplacee dans Aide > Rechercher une mise a jour (plus au demarrage)
- Support arguments CLI : ouvrir un PDF en argument, fusionner si plusieurs
- register_windows.bat : association fichier PDF + menu contextuel Windows
  - Clic droit > CopyDev Impose > Ouvrir / Livret A4 / Livret A3
- Presets manager (base pour macros)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-21 16:15:25 +01:00

46 lines
974 B
Python

"""Gestionnaire de presets / macros."""
import os
import sys
import json
PRESETS_FILE = os.path.join(
os.path.dirname(sys.executable) if getattr(sys, 'frozen', False)
else os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))),
".presets.json"
)
def load_presets():
if not os.path.exists(PRESETS_FILE):
return {}
try:
with open(PRESETS_FILE, "r") as f:
return json.load(f)
except Exception:
return {}
def save_presets(presets):
try:
with open(PRESETS_FILE, "w") as f:
json.dump(presets, f, indent=2)
except Exception:
pass
def save_preset(name, action_type, settings):
presets = load_presets()
presets[name] = {"action": action_type, "settings": settings}
save_presets(presets)
def delete_preset(name):
presets = load_presets()
presets.pop(name, None)
save_presets(presets)
def list_presets():
return load_presets()