summaryrefslogtreecommitdiff
path: root/ui/windows/settings_window.py
diff options
context:
space:
mode:
authorChristian Kolset <christian.kolset@gmail.com>2026-08-02 01:34:43 -0600
committerChristian Kolset <christian.kolset@gmail.com>2026-08-02 01:34:43 -0600
commita3aa1df99df8f413cac2ba6020b7cd0dec6d2390 (patch)
treea4c5feca6b0db326d9e54f417abc132c1270a7a3 /ui/windows/settings_window.py
parentf5066a8ca2fb50aa3dddf2c8847e52574cdde6ad (diff)
parentf1aaffbc3eb1e2c154315c556d2555803eea7997 (diff)
Merge origin/main: reconcile ConfigWindow consolidation with Debug window + protocol updates
origin/main (23 commits) added a Debug window/log system on top of the old separate Devices/Channels/Plot windows, plus protocol fixes (cml, mark10, modbus_rtu, scpi) and device/profile changes. Local main (3 commits) replaced the separate windows with a unified ConfigWindow + dock panel. Kept local's ConfigWindow/dock architecture and ported the Debug window onto it: new toolbar button + _open_debug(), gated by developer_mode same as origin's version. Deduped the two independent "developer mode" toggles that had collided in SettingsWindow (origin's General-tab checkbox gating Debug window + device sim-mode visibility, local's Advanced-tab checkbox setting verbose logging) into one General-tab checkbox that does both. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Diffstat (limited to 'ui/windows/settings_window.py')
-rw-r--r--ui/windows/settings_window.py45
1 files changed, 22 insertions, 23 deletions
diff --git a/ui/windows/settings_window.py b/ui/windows/settings_window.py
index 1afbca5..09b7a1a 100644
--- a/ui/windows/settings_window.py
+++ b/ui/windows/settings_window.py
@@ -51,6 +51,7 @@ class SettingsWindow(QWidget):
self.registry = registry
self.engine = engine
self._plugin_mgr = plugin_manager
+ self._plugin_buttons: dict = {} # plugin_id -> QPushButton
self.cfg = dict(self._defaults)
if current:
self.cfg.update(current)
@@ -78,7 +79,6 @@ class SettingsWindow(QWidget):
tabs.addTab(self._acquisition_tab(), " Acquisition ")
tabs.addTab(self._display_tab(), " Display ")
tabs.addTab(self._plugins_tab(), " Plugins ")
- tabs.addTab(self._advanced_tab(), " Advanced ")
# Bottom bar
btm = QWidget(); btm.setObjectName("cfgBottomBar")
@@ -110,6 +110,15 @@ class SettingsWindow(QWidget):
self._aa_chk = QCheckBox(); self._aa_chk.setChecked(self.cfg["antialias"])
lay.addRow("Anti-alias plots:", self._aa_chk)
+ self._dev_chk = QCheckBox()
+ self._dev_chk.setChecked(self.cfg["developer_mode"])
+ self._dev_chk.setToolTip(
+ "Controls whether the Debug window and each device's Simulation\n"
+ "Mode option are available, and enables verbose DEBUG output in\n"
+ "the terminal. Off = real-hardware-only, no debug tools."
+ )
+ lay.addRow("Developer mode:", self._dev_chk)
+
rst = QPushButton("Reset to Defaults"); rst.setObjectName("configButton")
rst.clicked.connect(self._reset_to_defaults)
lay.addRow("", rst)
@@ -122,13 +131,13 @@ class SettingsWindow(QWidget):
self._theme_cb.setCurrentText(self.cfg["theme"].title())
self._font_sp.setValue(self.cfg["font_size"])
self._aa_chk.setChecked(self.cfg["antialias"])
+ self._dev_chk.setChecked(self.cfg["developer_mode"])
self._poll_sp.setValue(self.cfg["poll_ms"])
self._buf_sp.setValue(self.cfg["buffer_size"])
self._log_edit.setText(self.cfg["log_dir"])
self._tw_sp.setValue(self.cfg["time_window_s"])
self._legend_chk.setChecked(self.cfg["show_legend"])
self._grid_chk.setChecked(self.cfg["show_grid"])
- self._dev_mode_chk.setChecked(self.cfg.get("developer_mode", False))
def _acquisition_tab(self):
w = QWidget()
@@ -236,6 +245,7 @@ class SettingsWindow(QWidget):
toggle.clicked.connect(
lambda _, pid=manifest.plugin_id, btn=toggle: self._toggle_plugin(pid, btn)
)
+ self._plugin_buttons[manifest.plugin_id] = toggle
hdr.addWidget(toggle)
cl.addLayout(hdr)
@@ -259,32 +269,21 @@ class SettingsWindow(QWidget):
return card
- def _advanced_tab(self):
- w = QWidget()
- scroll = QScrollArea(); scroll.setWidgetResizable(True)
- scroll.setObjectName("deviceScroll")
- cont = QWidget(); lay = QFormLayout(cont)
- lay.setContentsMargins(16, 14, 16, 14); lay.setSpacing(10)
-
- self._dev_mode_chk = QCheckBox()
- self._dev_mode_chk.setChecked(self.cfg.get("developer_mode", False))
- lay.addRow("Developer mode:", self._dev_mode_chk)
-
- note = QLabel("Enables verbose DEBUG output in the terminal.\nNo effect when running as a packaged app.")
- note.setObjectName("traceSource"); note.setWordWrap(True)
- lay.addRow("", note)
-
- scroll.setWidget(cont)
- root = QVBoxLayout(w); root.setContentsMargins(0, 0, 0, 0); root.addWidget(scroll)
- return w
-
def _toggle_plugin(self, plugin_id: str, btn: QPushButton):
if self._plugin_mgr.is_enabled(plugin_id):
self.plugin_disable_requested.emit(plugin_id)
btn.setText("Enable")
else:
+ # Don't flip to "Disable" yet — enabling can fail (missing
+ # dependencies, bad plugin code). main_window confirms the
+ # real outcome via sync_plugin_button() once enable() returns.
self.plugin_enable_requested.emit(plugin_id)
- btn.setText("Disable")
+
+ def sync_plugin_button(self, plugin_id: str):
+ """Refresh one plugin's toggle button to match its actual enabled state."""
+ btn = self._plugin_buttons.get(plugin_id)
+ if btn is not None and self._plugin_mgr is not None:
+ btn.setText("Disable" if self._plugin_mgr.is_enabled(plugin_id) else "Enable")
# ── Actions ───────────────────────────────────────────────────────────
@@ -310,13 +309,13 @@ class SettingsWindow(QWidget):
"theme": theme,
"font_size": self._font_sp.value(),
"antialias": self._aa_chk.isChecked(),
+ "developer_mode": self._dev_chk.isChecked(),
"poll_ms": self._poll_sp.value(),
"buffer_size": self._buf_sp.value(),
"log_dir": self._log_edit.text(),
"time_window_s": self._tw_sp.value(),
"show_legend": self._legend_chk.isChecked(),
"show_grid": self._grid_chk.isChecked(),
- "developer_mode": self._dev_mode_chk.isChecked(),
})
self.theme_changed.emit(theme)
self.settings_changed.emit(dict(self.cfg))