update
This commit is contained in:
@@ -32,6 +32,7 @@ import json
|
||||
import os
|
||||
import sys
|
||||
import tkinter as tk
|
||||
from tkinter import messagebox
|
||||
from tkinter import ttk
|
||||
from tkinter.scrolledtext import ScrolledText
|
||||
from typing import Callable, Dict, List, Optional
|
||||
@@ -59,6 +60,9 @@ except Exception:
|
||||
|
||||
PREFS_FILENAME = "aza_office_shell_v11_prefs.json"
|
||||
|
||||
# Sektions-Toggles (Sidebar + Hauptbereich); Schema-Hochzählung nur bei echten Strukturänderungen.
|
||||
SECTION_PREFS_SCHEMA = 2
|
||||
|
||||
FF = "Segoe UI"
|
||||
FONT_DEFAULT = (FF, 9)
|
||||
FONT_BOLD = (FF, 9, "bold")
|
||||
@@ -127,29 +131,76 @@ def _prefs_path() -> str:
|
||||
return os.path.join(base, PREFS_FILENAME)
|
||||
|
||||
|
||||
def _load_dark_pref() -> bool:
|
||||
def _load_office_prefs() -> dict:
|
||||
try:
|
||||
with open(_prefs_path(), encoding="utf-8") as fh:
|
||||
data = json.load(fh)
|
||||
return bool(data.get("dark_mode", False))
|
||||
d = json.load(fh)
|
||||
return d if isinstance(d, dict) else {}
|
||||
except Exception:
|
||||
return {}
|
||||
|
||||
|
||||
def _save_office_prefs(data: dict) -> None:
|
||||
try:
|
||||
path = _prefs_path()
|
||||
root = os.path.dirname(path)
|
||||
if root:
|
||||
os.makedirs(root, exist_ok=True)
|
||||
with open(path, "w", encoding="utf-8") as fh:
|
||||
json.dump(data, fh, indent=2, ensure_ascii=False)
|
||||
except Exception as exc:
|
||||
print(f"[OfficeV1.2] Konnte Office-Prefs nicht speichern: {exc}")
|
||||
|
||||
|
||||
def _has_autotext_config_file_on_disk() -> bool:
|
||||
try:
|
||||
from aza_persistence import _autotext_config_path
|
||||
|
||||
return os.path.isfile(_autotext_config_path())
|
||||
except Exception:
|
||||
return False
|
||||
|
||||
|
||||
def _shell_sections_strict_new_defaults() -> dict:
|
||||
"""Neuinstallation / kein vorhandenes autotext.json: alles zu außer KG."""
|
||||
return {
|
||||
"schema": SECTION_PREFS_SCHEMA,
|
||||
"arb_open": False,
|
||||
"ersch_open": False,
|
||||
"tb_open": False,
|
||||
"transcript_open": False,
|
||||
"kg_open": True,
|
||||
"soap_open": False,
|
||||
"documents_open": False,
|
||||
}
|
||||
|
||||
|
||||
def _shell_sections_upgrade_defaults(app) -> dict:
|
||||
"""Bestehende Installation ohne Schema: früheres Layout (SOAP/Dokumente sichtbar)."""
|
||||
ad = getattr(app, "_autotext_data", None)
|
||||
tb_open = True
|
||||
if isinstance(ad, dict):
|
||||
tb_open = bool(ad.get("office_sidebar_textbloecke_open", True))
|
||||
return {
|
||||
"schema": SECTION_PREFS_SCHEMA,
|
||||
"arb_open": True,
|
||||
"ersch_open": True,
|
||||
"tb_open": tb_open,
|
||||
"transcript_open": False,
|
||||
"kg_open": True,
|
||||
"soap_open": True,
|
||||
"documents_open": True,
|
||||
}
|
||||
|
||||
|
||||
def _load_dark_pref() -> bool:
|
||||
return bool(_load_office_prefs().get("dark_mode", False))
|
||||
|
||||
|
||||
def _save_dark_pref(dark: bool) -> None:
|
||||
try:
|
||||
path = _prefs_path()
|
||||
data = {}
|
||||
try:
|
||||
with open(path, encoding="utf-8") as fh:
|
||||
data = json.load(fh)
|
||||
except Exception:
|
||||
pass
|
||||
data["dark_mode"] = dark
|
||||
with open(path, "w", encoding="utf-8") as fh:
|
||||
json.dump(data, fh, indent=2, ensure_ascii=False)
|
||||
except Exception as exc:
|
||||
print(f"[OfficeV1.2] Konnte Erscheinungsbild nicht speichern: {exc}")
|
||||
data = _load_office_prefs()
|
||||
data["dark_mode"] = dark
|
||||
_save_office_prefs(data)
|
||||
|
||||
|
||||
class PillButton(tk.Canvas):
|
||||
@@ -400,14 +451,20 @@ class _OfficeShellV12:
|
||||
self._license_lbl: Optional[tk.Label] = None
|
||||
self._theme_switch_pop: Optional[PopoverThemeSwitch] = None
|
||||
self._sidebar: Optional[tk.Frame] = None
|
||||
self._sec_arb_open: bool = True
|
||||
self._sec_ersch_open: bool = True
|
||||
self._sec_arb_open: bool = False
|
||||
self._sec_ersch_open: bool = False
|
||||
self._sec_arb_arrow: Optional[tk.Label] = None
|
||||
self._sec_ersch_arrow: Optional[tk.Label] = None
|
||||
self._sec_arb_body: Optional[tk.Frame] = None
|
||||
self._sec_ersch_body: Optional[tk.Frame] = None
|
||||
self._transcript_open: bool = False
|
||||
self._kg_open: bool = True
|
||||
self._soap_open: bool = False
|
||||
self._documents_open: bool = False
|
||||
self._soap_arrow: Optional[tk.Label] = None
|
||||
self._soap_fold_body: Optional[tk.Frame] = None
|
||||
self._documents_arrow: Optional[tk.Label] = None
|
||||
self._documents_fold_body: Optional[tk.Frame] = None
|
||||
self._main_fill: Optional[tk.Frame] = None
|
||||
self._content: Optional[tk.Frame] = None
|
||||
self._header_inner: Optional[tk.Frame] = None
|
||||
@@ -424,11 +481,20 @@ class _OfficeShellV12:
|
||||
self._footer_brand_title: Optional[tk.Label] = None
|
||||
self._footer_brand_sub: Optional[tk.Label] = None
|
||||
self._shell_labels: List[tk.Label] = []
|
||||
self._settings_win = None # Legacy-Popup
|
||||
self._gear_btn: Optional[tk.Misc] = None
|
||||
self._head_tb: Optional[tk.Frame] = None
|
||||
self._sidebar_head_arb: Optional[tk.Frame] = None
|
||||
self._sec_tb_open: bool = False
|
||||
self._sec_tb_arrow: Optional[tk.Label] = None
|
||||
self._sec_tb_body: Optional[tk.Frame] = None
|
||||
self._sidebar_head_ersch: Optional[tk.Frame] = None
|
||||
|
||||
# ── Öffentlich ────────────────────────────────────────────────────
|
||||
|
||||
def install(self):
|
||||
app = self.app
|
||||
self._hydrate_shell_section_prefs()
|
||||
self._dark_mode = _load_dark_pref()
|
||||
self._palette = (
|
||||
PALETTE_DARK.copy() if self._dark_mode else PALETTE_LIGHT.copy()
|
||||
@@ -452,6 +518,16 @@ class _OfficeShellV12:
|
||||
self._build_status_row()
|
||||
self._build_main_fill()
|
||||
|
||||
try:
|
||||
btp = getattr(app, "_bind_textblock_pending", None)
|
||||
if callable(btp):
|
||||
for attr in ("txt_transcript", "txt_output"):
|
||||
wid = getattr(app, attr, None)
|
||||
if wid is not None:
|
||||
btp(wid)
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
if self._record_btn is not None:
|
||||
app.btn_record = self._record_btn
|
||||
if self._korrigieren_btn is not None:
|
||||
@@ -477,6 +553,13 @@ class _OfficeShellV12:
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
try:
|
||||
from aza_workspace_license import ensure_workspace_license_dialog_then_start_hybrid_sync
|
||||
|
||||
ensure_workspace_license_dialog_then_start_hybrid_sync(app)
|
||||
except Exception as shell_exc:
|
||||
print(f"[OfficeV1.2] Workspace-Hybrid-Sync konnte nicht gestartet werden: {shell_exc}")
|
||||
|
||||
try:
|
||||
existing = getattr(app, "_dev_status_window", None)
|
||||
if existing is not None and existing.winfo_exists():
|
||||
@@ -485,6 +568,60 @@ class _OfficeShellV12:
|
||||
pass
|
||||
app._dev_status_window = None
|
||||
|
||||
def _hydrate_shell_section_prefs(self) -> None:
|
||||
app = self.app
|
||||
prefs = _load_office_prefs()
|
||||
ss = prefs.get("shell_sections") if isinstance(prefs.get("shell_sections"), dict) else {}
|
||||
valid = ss.get("schema") == SECTION_PREFS_SCHEMA
|
||||
|
||||
if not valid:
|
||||
if _has_autotext_config_file_on_disk():
|
||||
new_ss = _shell_sections_upgrade_defaults(app)
|
||||
else:
|
||||
new_ss = _shell_sections_strict_new_defaults()
|
||||
prefs["shell_sections"] = new_ss
|
||||
_save_office_prefs(prefs)
|
||||
self._apply_shell_section_prefs_from_dict(new_ss)
|
||||
|
||||
sync_tb = getattr(app, "_autotext_data", None)
|
||||
if isinstance(sync_tb, dict):
|
||||
sync_tb["office_sidebar_textbloecke_open"] = bool(new_ss["tb_open"])
|
||||
try:
|
||||
from aza_persistence import save_autotext
|
||||
|
||||
save_autotext(sync_tb)
|
||||
except Exception:
|
||||
pass
|
||||
return
|
||||
|
||||
self._apply_shell_section_prefs_from_dict(ss)
|
||||
|
||||
def _apply_shell_section_prefs_from_dict(self, ss: dict) -> None:
|
||||
app = self.app
|
||||
self._sec_arb_open = bool(ss.get("arb_open", False))
|
||||
self._sec_ersch_open = bool(ss.get("ersch_open", False))
|
||||
self._sec_tb_open = bool(ss.get("tb_open", False))
|
||||
self._transcript_open = bool(ss.get("transcript_open", False))
|
||||
self._kg_open = bool(ss.get("kg_open", True))
|
||||
self._soap_open = bool(ss.get("soap_open", False))
|
||||
self._documents_open = bool(ss.get("documents_open", False))
|
||||
setattr(app, "_transcript_collapsed", not self._transcript_open)
|
||||
setattr(app, "_kg_collapsed", not self._kg_open)
|
||||
|
||||
def _persist_shell_sections(self) -> None:
|
||||
d = _load_office_prefs()
|
||||
d["shell_sections"] = {
|
||||
"schema": SECTION_PREFS_SCHEMA,
|
||||
"arb_open": self._sec_arb_open,
|
||||
"ersch_open": self._sec_ersch_open,
|
||||
"tb_open": self._sec_tb_open,
|
||||
"transcript_open": self._transcript_open,
|
||||
"kg_open": self._kg_open,
|
||||
"soap_open": self._soap_open,
|
||||
"documents_open": self._documents_open,
|
||||
}
|
||||
_save_office_prefs(d)
|
||||
|
||||
# ── Hilfen ────────────────────────────────────────────────────────
|
||||
|
||||
def _register_pill(self, b: PillButton) -> PillButton:
|
||||
@@ -1035,9 +1172,13 @@ class _OfficeShellV12:
|
||||
if getattr(app, "_empfang_auto_var", None) is None:
|
||||
app._empfang_auto_var = tk.BooleanVar(master=app, value=False)
|
||||
|
||||
stack = tk.Frame(bar, bg=acc)
|
||||
stack.pack(fill="both", expand=True)
|
||||
|
||||
# ── Sektion: Arbeitsoptionen ─────────────────────────────
|
||||
head_arb = tk.Frame(bar, bg=acc, cursor="hand2")
|
||||
head_arb = tk.Frame(stack, bg=acc, cursor="hand2")
|
||||
head_arb.pack(fill="x", padx=10, pady=(14, 4))
|
||||
self._sidebar_head_arb = head_arb
|
||||
|
||||
self._sec_arb_arrow = tk.Label(
|
||||
head_arb,
|
||||
@@ -1057,7 +1198,7 @@ class _OfficeShellV12:
|
||||
for _w in (head_arb, self._sec_arb_arrow, ttl_arb):
|
||||
_w.bind("<Button-1>", lambda e: self._toggle_section_arb())
|
||||
|
||||
self._sec_arb_body = tk.Frame(bar, bg=acc)
|
||||
self._sec_arb_body = tk.Frame(stack, bg=acc)
|
||||
|
||||
tk.Checkbutton(
|
||||
self._sec_arb_body, text="Rechtsklick = Einfügen",
|
||||
@@ -1094,14 +1235,29 @@ class _OfficeShellV12:
|
||||
lambda e: _safe_call(app, "_open_empfang_chat_history"),
|
||||
)
|
||||
|
||||
tk.Label(
|
||||
self._sec_arb_body,
|
||||
text="Autotext verwalten …",
|
||||
bg=acc,
|
||||
fg="#E2EEF6",
|
||||
font=FONT_DEFAULT,
|
||||
cursor="hand2",
|
||||
anchor="w",
|
||||
).pack(fill="x", padx=(28, 12), pady=(2, 10))
|
||||
self._sec_arb_body.winfo_children()[-1].bind(
|
||||
"<Button-1>",
|
||||
lambda e: self._open_workspace_autotext(),
|
||||
)
|
||||
|
||||
if self._sec_arb_open:
|
||||
self._sec_arb_body.pack(fill="x")
|
||||
self._sec_arb_body.pack(fill="x", after=self._sidebar_head_arb)
|
||||
|
||||
tk.Frame(bar, bg=acc, height=10).pack()
|
||||
self._build_textbloecke_sidebar_section(stack, acc)
|
||||
|
||||
# ── Sektion: Erscheinungsbild ────────────────────────────
|
||||
head_ersch = tk.Frame(bar, bg=acc, cursor="hand2")
|
||||
head_ersch.pack(fill="x", padx=10, pady=(2, 4))
|
||||
# ── Sektion: Erscheinungsbild (nach Textblöcken) ─
|
||||
head_ersch = tk.Frame(stack, bg=acc, cursor="hand2")
|
||||
head_ersch.pack(fill="x", padx=10, pady=(10, 4))
|
||||
self._sidebar_head_ersch = head_ersch
|
||||
|
||||
self._sec_ersch_arrow = tk.Label(
|
||||
head_ersch,
|
||||
@@ -1121,7 +1277,7 @@ class _OfficeShellV12:
|
||||
for _w in (head_ersch, self._sec_ersch_arrow, ttl_ersch):
|
||||
_w.bind("<Button-1>", lambda e: self._toggle_section_ersch())
|
||||
|
||||
self._sec_ersch_body = tk.Frame(bar, bg=acc)
|
||||
self._sec_ersch_body = tk.Frame(stack, bg=acc)
|
||||
|
||||
tk.Label(
|
||||
self._sec_ersch_body, text="Fenster-Transparenz",
|
||||
@@ -1168,11 +1324,200 @@ class _OfficeShellV12:
|
||||
bg=acc, fg="white", font=(FF, 9, "underline"),
|
||||
cursor="hand2",
|
||||
)
|
||||
link.pack(anchor="w", padx=14, pady=(2, 12))
|
||||
link.pack(anchor="w", padx=14, pady=(2, 6))
|
||||
link.bind("<Button-1>", lambda e: _safe_call(app, "_open_settings"))
|
||||
|
||||
if self._sec_ersch_open:
|
||||
self._sec_ersch_body.pack(fill="x")
|
||||
self._sec_ersch_body.pack(fill="x", after=self._sidebar_head_ersch)
|
||||
|
||||
def _persist_tb_sidebar_open_flag(self) -> None:
|
||||
app = self.app
|
||||
data = getattr(app, "_autotext_data", None)
|
||||
if not isinstance(data, dict):
|
||||
return
|
||||
data["office_sidebar_textbloecke_open"] = self._sec_tb_open
|
||||
try:
|
||||
from aza_persistence import save_autotext
|
||||
|
||||
save_autotext(data)
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
def _toggle_section_tb(self) -> None:
|
||||
self._sec_tb_open = not self._sec_tb_open
|
||||
self._persist_tb_sidebar_open_flag()
|
||||
if self._sec_tb_arrow is not None:
|
||||
try:
|
||||
self._sec_tb_arrow.configure(
|
||||
text=("▼" if self._sec_tb_open else "▶"),
|
||||
)
|
||||
except tk.TclError:
|
||||
pass
|
||||
if self._sec_tb_body is not None:
|
||||
try:
|
||||
if self._sec_tb_open:
|
||||
self._sec_tb_body.pack(fill="x", after=self._head_tb)
|
||||
else:
|
||||
self._sec_tb_body.pack_forget()
|
||||
except tk.TclError:
|
||||
pass
|
||||
self._persist_shell_sections()
|
||||
|
||||
def _open_workspace_autotext(self) -> None:
|
||||
try:
|
||||
from aza_office_workspace_ui import open_workspace_autotext_manager
|
||||
|
||||
open_workspace_autotext_manager(self.app)
|
||||
except Exception as exc:
|
||||
print(f"[OfficeV1.2] Autotext-Fenster: {exc}")
|
||||
|
||||
def _build_textbloecke_sidebar_section(
|
||||
self,
|
||||
parent: tk.Frame,
|
||||
acc: str,
|
||||
) -> None:
|
||||
self._head_tb = tk.Frame(parent, bg=acc, cursor="hand2")
|
||||
self._head_tb.pack(fill="x", padx=10, pady=(10, 2))
|
||||
|
||||
self._sec_tb_arrow = tk.Label(
|
||||
self._head_tb,
|
||||
text=("▼" if self._sec_tb_open else "▶"),
|
||||
bg=acc, fg="white", font=(FF, 9, "bold"),
|
||||
cursor="hand2",
|
||||
)
|
||||
self._sec_tb_arrow.pack(side="left", padx=(0, 6))
|
||||
|
||||
ttl = tk.Label(
|
||||
self._head_tb, text="Textblöcke",
|
||||
bg=acc, fg="white", font=(FF, 9, "bold"),
|
||||
cursor="hand2",
|
||||
)
|
||||
ttl.pack(side="left")
|
||||
|
||||
minus = tk.Button(
|
||||
self._head_tb, text="−", command=self._office_tb_remove,
|
||||
bg=acc, fg="white", activebackground=acc, activeforeground="white",
|
||||
font=(FF, 11, "bold"), relief="flat", bd=0, highlightthickness=0,
|
||||
cursor="hand2", width=2, padx=0, pady=0,
|
||||
)
|
||||
minus.pack(side="right")
|
||||
|
||||
plus = tk.Button(
|
||||
self._head_tb, text="+", command=self._office_tb_add,
|
||||
bg=acc, fg="white", activebackground=acc, activeforeground="white",
|
||||
font=(FF, 11, "bold"), relief="flat", bd=0, highlightthickness=0,
|
||||
cursor="hand2", width=2, padx=0, pady=0,
|
||||
)
|
||||
plus.pack(side="right", padx=(0, 4))
|
||||
|
||||
for _w in (self._sec_tb_arrow, ttl):
|
||||
_w.bind("<Button-1>", lambda e: self._toggle_section_tb())
|
||||
|
||||
self._sec_tb_body = tk.Frame(parent, bg=acc)
|
||||
|
||||
from aza_persistence import load_textbloecke
|
||||
|
||||
tb = load_textbloecke()
|
||||
for sk in sorted(tb.keys(), key=int):
|
||||
row = tk.Frame(self._sec_tb_body, bg=acc)
|
||||
row.pack(fill="x", padx=(18, 10), pady=2)
|
||||
label = (tb.get(sk) or {}).get("name") or f"Textblock {sk}"
|
||||
lb = tk.Label(
|
||||
row, text=f" · {label}",
|
||||
bg=acc, fg="white", font=FONT_DEFAULT,
|
||||
cursor="hand2", anchor="w",
|
||||
)
|
||||
lb.pack(fill="x")
|
||||
lb.bind(
|
||||
"<Button-1>",
|
||||
lambda e, k=sk: self._on_sidebar_textblock_click(e, str(k)),
|
||||
)
|
||||
|
||||
if self._sec_tb_open:
|
||||
self._sec_tb_body.pack(fill="x", after=self._head_tb)
|
||||
|
||||
def _on_sidebar_textblock_click(self, event: tk.Event, slot_key: str) -> None:
|
||||
"""Einzelklick = Einfügen; Shift+Klick öffnet den Editor."""
|
||||
st = int(getattr(event, "state", 0) or 0)
|
||||
if st & 0x0001:
|
||||
self._open_workspace_textblock(str(slot_key))
|
||||
return
|
||||
ins = getattr(self.app, "_office_sidebar_insert_textblock", None)
|
||||
if callable(ins):
|
||||
try:
|
||||
ins(str(slot_key))
|
||||
except Exception as exc:
|
||||
print(f"[OfficeV1.2] Textblock-Einfügen: {exc}")
|
||||
|
||||
def _open_workspace_textblock(self, slot_key: str) -> None:
|
||||
try:
|
||||
from aza_office_workspace_ui import (
|
||||
open_workspace_textblock_editor,
|
||||
)
|
||||
|
||||
open_workspace_textblock_editor(self.app, slot_key)
|
||||
except Exception as exc:
|
||||
print(f"[OfficeV1.2] Textblock-Editor: {exc}")
|
||||
|
||||
def _office_tb_add(self) -> None:
|
||||
try:
|
||||
from aza_persistence import load_textbloecke, save_textbloecke
|
||||
from aza_workspace_sync import schedule_workspace_cloud_push, utc_now_iso
|
||||
|
||||
tb = load_textbloecke()
|
||||
keys = sorted(tb.keys(), key=int)
|
||||
new_key = str(int(keys[-1]) + 1)
|
||||
tb[new_key] = {
|
||||
"name": f"Textblock {new_key}",
|
||||
"content": "",
|
||||
"updated_at": utc_now_iso(),
|
||||
}
|
||||
save_textbloecke(tb)
|
||||
schedule_workspace_cloud_push()
|
||||
self.refresh_sidebar_textbloecke_section()
|
||||
except Exception as exc:
|
||||
try:
|
||||
messagebox.showerror("Textblöcke", str(exc), parent=self.app)
|
||||
except Exception:
|
||||
print(f"[OfficeV1.2] Textblock +: {exc}")
|
||||
|
||||
def _office_tb_remove(self) -> None:
|
||||
try:
|
||||
from aza_persistence import load_textbloecke, save_textbloecke
|
||||
from aza_workspace_sync import schedule_workspace_cloud_push
|
||||
|
||||
tb = load_textbloecke()
|
||||
keys = sorted(tb.keys(), key=int)
|
||||
if len(keys) <= 2:
|
||||
messagebox.showinfo(
|
||||
"Textblöcke",
|
||||
"Es bleiben mindestens zwei Textblöcke erhalten.",
|
||||
parent=self.app,
|
||||
)
|
||||
return
|
||||
last_k = str(keys[-1])
|
||||
name = (tb.get(last_k) or {}).get("name") or f"Textblock {last_k}"
|
||||
if not messagebox.askyesno(
|
||||
"Textblöcke",
|
||||
f"„{name}“ wirklich löschen?",
|
||||
parent=self.app,
|
||||
):
|
||||
return
|
||||
del tb[last_k]
|
||||
save_textbloecke(tb)
|
||||
schedule_workspace_cloud_push()
|
||||
self.refresh_sidebar_textbloecke_section()
|
||||
except Exception as exc:
|
||||
try:
|
||||
messagebox.showerror("Textblöcke", str(exc), parent=self.app)
|
||||
except Exception:
|
||||
print(f"[OfficeV1.2] Textblock −: {exc}")
|
||||
|
||||
def refresh_sidebar_textbloecke_section(self) -> None:
|
||||
try:
|
||||
self._build_sidebar_content()
|
||||
except Exception as exc:
|
||||
print(f"[OfficeV1.2] Sidebar-Refresh: {exc}")
|
||||
|
||||
def _toggle_section_arb(self):
|
||||
self._sec_arb_open = not self._sec_arb_open
|
||||
@@ -1188,12 +1533,13 @@ class _OfficeShellV12:
|
||||
if self._sec_arb_open:
|
||||
self._sec_arb_body.pack(
|
||||
fill="x",
|
||||
before=self._sec_ersch_arrow.master if self._sec_ersch_arrow else None,
|
||||
after=self._sidebar_head_arb,
|
||||
)
|
||||
else:
|
||||
self._sec_arb_body.pack_forget()
|
||||
except Exception:
|
||||
pass
|
||||
self._persist_shell_sections()
|
||||
|
||||
def _toggle_section_ersch(self):
|
||||
self._sec_ersch_open = not self._sec_ersch_open
|
||||
@@ -1207,11 +1553,16 @@ class _OfficeShellV12:
|
||||
if self._sec_ersch_body is not None:
|
||||
try:
|
||||
if self._sec_ersch_open:
|
||||
self._sec_ersch_body.pack(fill="x")
|
||||
hd = getattr(self, "_sidebar_head_ersch", None)
|
||||
if hd is not None:
|
||||
self._sec_ersch_body.pack(fill="x", after=hd)
|
||||
else:
|
||||
self._sec_ersch_body.pack(fill="x")
|
||||
else:
|
||||
self._sec_ersch_body.pack_forget()
|
||||
except Exception:
|
||||
pass
|
||||
self._persist_shell_sections()
|
||||
|
||||
def _build_transcript_section(self):
|
||||
app = self.app
|
||||
@@ -1226,7 +1577,9 @@ class _OfficeShellV12:
|
||||
self._shell_section_frames.extend([head])
|
||||
|
||||
arrow = tk.Label(
|
||||
head, text="▶", bg=p["BG"], fg=p["TEXT"], font=FONT_SECTION,
|
||||
head,
|
||||
text=("▼" if self._transcript_open else "▶"),
|
||||
bg=p["BG"], fg=p["TEXT"], font=FONT_SECTION,
|
||||
padx=2, cursor="hand2",
|
||||
)
|
||||
arrow.pack(side="left")
|
||||
@@ -1247,7 +1600,9 @@ class _OfficeShellV12:
|
||||
|
||||
app.txt_transcript = txt
|
||||
app._transcript_frame = body
|
||||
app._transcript_collapsed = True
|
||||
app._transcript_collapsed = not bool(self._transcript_open)
|
||||
if self._transcript_open:
|
||||
body.pack(fill="x")
|
||||
|
||||
def _toggle(_e=None):
|
||||
self._transcript_open = not self._transcript_open
|
||||
@@ -1259,6 +1614,7 @@ class _OfficeShellV12:
|
||||
body.pack_forget()
|
||||
arrow.configure(text="▶")
|
||||
app._transcript_collapsed = True
|
||||
self._persist_shell_sections()
|
||||
|
||||
for w in (head, arrow, title):
|
||||
w.bind("<Button-1>", _toggle)
|
||||
@@ -1279,7 +1635,9 @@ class _OfficeShellV12:
|
||||
toggle_box.pack(side="left")
|
||||
self._shell_section_frames.append(toggle_box)
|
||||
kg_arrow = tk.Label(
|
||||
toggle_box, text="▼", bg=p["BG"], fg=p["TEXT"],
|
||||
toggle_box,
|
||||
text=("▼" if self._kg_open else "▶"),
|
||||
bg=p["BG"], fg=p["TEXT"],
|
||||
font=FONT_SECTION, padx=2, cursor="hand2",
|
||||
)
|
||||
kg_arrow.pack(side="left")
|
||||
@@ -1323,7 +1681,6 @@ class _OfficeShellV12:
|
||||
app._btn_kommentare = btn_kom
|
||||
|
||||
body = tk.Frame(wrap, bg=p["BG"])
|
||||
body.pack(fill="both", expand=True, pady=(6, 0))
|
||||
self._shell_section_frames.append(body)
|
||||
|
||||
txt = ScrolledText(
|
||||
@@ -1336,7 +1693,9 @@ class _OfficeShellV12:
|
||||
|
||||
app.txt_output = txt
|
||||
app._kg_frame = body
|
||||
app._kg_collapsed = False
|
||||
app._kg_collapsed = not bool(self._kg_open)
|
||||
if self._kg_open:
|
||||
body.pack(fill="both", expand=True, pady=(6, 0))
|
||||
|
||||
def _toggle(_e=None):
|
||||
self._kg_open = not self._kg_open
|
||||
@@ -1348,6 +1707,7 @@ class _OfficeShellV12:
|
||||
body.pack_forget()
|
||||
kg_arrow.configure(text="▶")
|
||||
app._kg_collapsed = True
|
||||
self._persist_shell_sections()
|
||||
|
||||
for w in (toggle_box, kg_arrow, title):
|
||||
w.bind("<Button-1>", _toggle)
|
||||
@@ -1360,12 +1720,47 @@ class _OfficeShellV12:
|
||||
wrap.pack(side="top", fill="x", padx=18, pady=(8, 4))
|
||||
self._shell_section_frames.append(wrap)
|
||||
|
||||
soap_lbl = tk.Label(wrap, text="SOAP", bg=p["BG"], fg=p["TEXT"],
|
||||
font=FONT_SECTION)
|
||||
soap_lbl.pack(anchor="w")
|
||||
self._shell_labels.append(soap_lbl)
|
||||
head_soap = tk.Frame(wrap, bg=p["BG"], cursor="hand2")
|
||||
head_soap.pack(fill="x")
|
||||
self._shell_section_frames.append(head_soap)
|
||||
|
||||
sec_row = tk.Frame(wrap, bg=p["BG"])
|
||||
self._soap_arrow = tk.Label(
|
||||
head_soap,
|
||||
text=("▼" if self._soap_open else "▶"),
|
||||
bg=p["BG"], fg=p["TEXT"], font=FONT_SECTION,
|
||||
padx=2, cursor="hand2",
|
||||
)
|
||||
self._soap_arrow.pack(side="left")
|
||||
|
||||
soap_title = tk.Label(
|
||||
head_soap, text=" SOAP", bg=p["BG"], fg=p["TEXT"],
|
||||
font=FONT_SECTION, cursor="hand2",
|
||||
)
|
||||
soap_title.pack(side="left")
|
||||
self._shell_labels.extend([self._soap_arrow, soap_title])
|
||||
|
||||
reset_frm = tk.Frame(head_soap, bg=p["BG"], cursor="hand2")
|
||||
reset_frm.pack(side="right")
|
||||
reset_lbl = tk.Label(
|
||||
reset_frm,
|
||||
text="\u21BB",
|
||||
font=("Segoe UI", 13),
|
||||
bg=p["BG"],
|
||||
fg=p["SUBTLE"],
|
||||
cursor="hand2",
|
||||
padx=4,
|
||||
)
|
||||
reset_lbl.pack(side="right")
|
||||
reset_lbl.bind("<Button-1>",
|
||||
lambda e: _safe_call(app, "_reset_all_soap_sections"))
|
||||
reset_lbl.bind("<Enter>", lambda e: reset_lbl.configure(fg=p["ACCENT"]))
|
||||
reset_lbl.bind("<Leave>", lambda e: reset_lbl.configure(fg=p["SUBTLE"]))
|
||||
self._shell_labels.append(reset_lbl)
|
||||
|
||||
self._soap_fold_body = tk.Frame(wrap, bg=p["BG"])
|
||||
self._shell_section_frames.append(self._soap_fold_body)
|
||||
|
||||
sec_row = tk.Frame(self._soap_fold_body, bg=p["BG"])
|
||||
sec_row.pack(fill="x", pady=(6, 0))
|
||||
self._shell_section_frames.append(sec_row)
|
||||
|
||||
@@ -1382,7 +1777,7 @@ class _OfficeShellV12:
|
||||
except Exception as exc:
|
||||
print(f"[OfficeV1.2] SOAP-Sektionen: {exc}")
|
||||
|
||||
act = tk.Frame(wrap, bg=p["BG"])
|
||||
act = tk.Frame(self._soap_fold_body, bg=p["BG"])
|
||||
act.pack(fill="x", pady=(8, 0))
|
||||
self._shell_section_frames.append(act)
|
||||
|
||||
@@ -1416,6 +1811,31 @@ class _OfficeShellV12:
|
||||
btn_vor.pack(side="left")
|
||||
app.btn_kg_vorlage = btn_vor
|
||||
|
||||
def _soap_toggle(_e=None):
|
||||
self._soap_open = not self._soap_open
|
||||
arr = getattr(self, "_soap_arrow", None)
|
||||
fold = getattr(self, "_soap_fold_body", None)
|
||||
if isinstance(arr, tk.Label):
|
||||
try:
|
||||
arr.configure(text=("▼" if self._soap_open else "▶"))
|
||||
except tk.TclError:
|
||||
pass
|
||||
try:
|
||||
if self._soap_open:
|
||||
fold.pack(fill="x", after=head_soap)
|
||||
elif fold is not None:
|
||||
fold.pack_forget()
|
||||
except tk.TclError:
|
||||
pass
|
||||
self._persist_shell_sections()
|
||||
|
||||
head_soap.bind("<Button-1>", _soap_toggle)
|
||||
self._soap_arrow.bind("<Button-1>", _soap_toggle)
|
||||
soap_title.bind("<Button-1>", _soap_toggle)
|
||||
|
||||
if self._soap_open:
|
||||
self._soap_fold_body.pack(fill="x", after=head_soap)
|
||||
|
||||
def _build_documents_section(self):
|
||||
app = self.app
|
||||
p = self._palette
|
||||
@@ -1424,12 +1844,28 @@ class _OfficeShellV12:
|
||||
wrap.pack(side="top", fill="x", padx=18, pady=(12, 4))
|
||||
self._shell_section_frames.append(wrap)
|
||||
|
||||
doc_lbl = tk.Label(wrap, text="Dokumente", bg=p["BG"], fg=p["TEXT"],
|
||||
font=FONT_SECTION)
|
||||
doc_lbl.pack(anchor="w")
|
||||
self._shell_labels.append(doc_lbl)
|
||||
head_doc = tk.Frame(wrap, bg=p["BG"], cursor="hand2")
|
||||
head_doc.pack(fill="x")
|
||||
self._shell_section_frames.append(head_doc)
|
||||
|
||||
grid = tk.Frame(wrap, bg=p["BG"])
|
||||
self._documents_arrow = tk.Label(
|
||||
head_doc,
|
||||
text=("▼" if self._documents_open else "▶"),
|
||||
bg=p["BG"], fg=p["TEXT"], font=FONT_SECTION,
|
||||
padx=2, cursor="hand2",
|
||||
)
|
||||
self._documents_arrow.pack(side="left")
|
||||
ttl = tk.Label(
|
||||
head_doc, text=" Dokumente", bg=p["BG"], fg=p["TEXT"],
|
||||
font=FONT_SECTION, cursor="hand2",
|
||||
)
|
||||
ttl.pack(side="left")
|
||||
self._shell_labels.extend([self._documents_arrow, ttl])
|
||||
|
||||
self._documents_fold_body = tk.Frame(wrap, bg=p["BG"])
|
||||
self._shell_section_frames.append(self._documents_fold_body)
|
||||
|
||||
grid = tk.Frame(self._documents_fold_body, bg=p["BG"])
|
||||
grid.pack(fill="x", pady=(6, 0))
|
||||
self._shell_section_frames.append(grid)
|
||||
|
||||
@@ -1455,6 +1891,31 @@ class _OfficeShellV12:
|
||||
b.grid(row=r, column=c,
|
||||
padx=(0 if c == 0 else 8), pady=4, sticky="w")
|
||||
|
||||
def _doc_toggle(_e=None):
|
||||
self._documents_open = not self._documents_open
|
||||
arr = getattr(self, "_documents_arrow", None)
|
||||
fold = getattr(self, "_documents_fold_body", None)
|
||||
if isinstance(arr, tk.Label):
|
||||
try:
|
||||
arr.configure(text=("▼" if self._documents_open else "▶"))
|
||||
except tk.TclError:
|
||||
pass
|
||||
try:
|
||||
if self._documents_open:
|
||||
fold.pack(fill="x", after=head_doc)
|
||||
elif fold is not None:
|
||||
fold.pack_forget()
|
||||
except tk.TclError:
|
||||
pass
|
||||
self._persist_shell_sections()
|
||||
|
||||
head_doc.bind("<Button-1>", _doc_toggle)
|
||||
self._documents_arrow.bind("<Button-1>", _doc_toggle)
|
||||
ttl.bind("<Button-1>", _doc_toggle)
|
||||
|
||||
if self._documents_open:
|
||||
self._documents_fold_body.pack(fill="x", after=head_doc)
|
||||
|
||||
def _build_footer(self):
|
||||
app = self.app
|
||||
p = self._palette
|
||||
@@ -1530,6 +1991,7 @@ def apply_office_shell_v1(app) -> None:
|
||||
"""
|
||||
if getattr(app, "_aza_office_v1_installed", False):
|
||||
return
|
||||
app._suppress_inline_soap_reset_icon = True
|
||||
try:
|
||||
shell = _OfficeShellV12(app)
|
||||
shell.install()
|
||||
|
||||
Reference in New Issue
Block a user