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

@ -254,14 +254,37 @@ class VersaPadViewer(tk.Tk):
btn.configure(text=names[p])
def _rename_tab(self, profile):
if not self.editing.get() or self.combined is None:
return
current = self.combined["profile_names"][profile]
"""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
current = combined["profile_names"][profile]
name = simpledialog.askstring("Profil umbenennen", "Neuer Name (nur lokal, nicht aufs Board):",
initialvalue=current, parent=self)
if name:
self.combined["profile_names"][profile] = name
self._update_tab_labels()
if not 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()
def _show_mcp_info(self):
win = tk.Toplevel(self)