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.
This commit is contained in:
parent
5d14bdd826
commit
82c3fd0056
2 changed files with 31 additions and 8 deletions
|
|
@ -113,8 +113,8 @@ Quellcode im Projektordner (`versapad_data.app_dir()`). Fehlt sie (z.B.
|
|||
frische Installation), wird sie automatisch angelegt — per Serial vom
|
||||
Board, falls eins angeschlossen ist, sonst als leere Default-Config.
|
||||
Profilnamen (`profile_names`) stehen direkt in dieser Datei und lassen sich
|
||||
per Doppelklick auf einen Tab (Programmiermodus) oder `rename_profile()`
|
||||
(MCP) ändern.
|
||||
per Doppelklick auf einen Tab (in jedem Modus — Nur-Lesen, Live-Sync oder
|
||||
Programmiermodus) oder `rename_profile()` (MCP) ändern.
|
||||
|
||||
Die klassischen `versapad_config1/2/3.json` sind kein von diesem Tool
|
||||
geschriebenes Format, sondern optionale Lese-Interop mit einem JSON-Export
|
||||
|
|
|
|||
|
|
@ -254,13 +254,36 @@ class VersaPadViewer(tk.Tk):
|
|||
btn.configure(text=names[p])
|
||||
|
||||
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
|
||||
current = self.combined["profile_names"][profile]
|
||||
|
||||
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
|
||||
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):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue