Allow renaming profile tabs outside Programmiermodus

Double-click-to-rename already existed but silently no-op'd unless
Programmiermodus was on, and even there it only updated the in-memory
self.combined without saving -- the name was lost unless some later button
edit happened to trigger an autosave. Since profile_names lives purely in
the combined JSON and never touches the board, there's no reason to gate it
behind the heavier editing mode: it now works from any mode, loading/saving
the combined file directly (auto-creating it if needed) when not already in
an active Programmiermodus session, and always persists immediately.

(cherry picked from commit 82c3fd0056)
This commit is contained in:
Julian Appel 2026-08-14 23:17:38 +02:00 committed by cjjohn
parent b4ad7698ed
commit 9e21360393
2 changed files with 31 additions and 8 deletions

View file

@ -105,8 +105,8 @@ Quellcode im Projektordner (`versapad_data.app_dir()`). Fehlt sie (z.B.
frische Installation), wird sie automatisch angelegt — per Serial vom frische Installation), wird sie automatisch angelegt — per Serial vom
Board, falls eins angeschlossen ist, sonst als leere Default-Config. Board, falls eins angeschlossen ist, sonst als leere Default-Config.
Profilnamen (`profile_names`) stehen direkt in dieser Datei und lassen sich Profilnamen (`profile_names`) stehen direkt in dieser Datei und lassen sich
per Doppelklick auf einen Tab (Programmiermodus) oder `rename_profile()` per Doppelklick auf einen Tab (in jedem Modus — Nur-Lesen, Live-Sync oder
(MCP) ändern. Programmiermodus) oder `rename_profile()` (MCP) ändern.
Die klassischen `versapad_config1/2/3.json` sind kein von diesem Tool Die klassischen `versapad_config1/2/3.json` sind kein von diesem Tool
geschriebenes Format, sondern optionale Lese-Interop mit einem JSON-Export geschriebenes Format, sondern optionale Lese-Interop mit einem JSON-Export

View file

@ -254,13 +254,36 @@ class VersaPadViewer(tk.Tk):
btn.configure(text=names[p]) btn.configure(text=names[p])
def _rename_tab(self, profile): def _rename_tab(self, profile):
if not self.editing.get() or self.combined is None: """Profilname per Doppelklick auf den Tab umbenennen -- geht in
jedem Modus (rein lokal, landet nie aufs Board, siehe Kritische
Domänenregeln). Im Programmiermodus wird der bereits geladene
In-Memory-State direkt bearbeitet + autosaved; sonst wird die
kombinierte Datei frisch gelesen/geschrieben (legt sie bei Bedarf
automatisch an, siehe versapad_combined.load_or_fetch())."""
if self.editing.get() and self.combined is not None:
combined = self.combined
else:
try:
combined = vcomb.load_or_fetch()
except (OSError, ValueError, KeyError) as e:
messagebox.showerror("Umbenennen fehlgeschlagen", str(e))
return return
current = self.combined["profile_names"][profile]
current = combined["profile_names"][profile]
name = simpledialog.askstring("Profil umbenennen", "Neuer Name (nur lokal, nicht aufs Board):", name = simpledialog.askstring("Profil umbenennen", "Neuer Name (nur lokal, nicht aufs Board):",
initialvalue=current, parent=self) initialvalue=current, parent=self)
if name: if not name:
self.combined["profile_names"][profile] = name return
combined["profile_names"][profile] = name
if combined is self.combined:
self._autosave_combined()
else:
try:
vcomb.save_file(combined, vcomb.DEFAULT_PATH)
except OSError as e:
messagebox.showerror("Umbenennen fehlgeschlagen", f"Speichern fehlgeschlagen: {e}")
return
self._update_tab_labels() self._update_tab_labels()
def _show_mcp_info(self): def _show_mcp_info(self):