diff options
| author | Christian Kolset <christian.kolset@gmail.com> | 2026-06-03 12:53:35 -0600 |
|---|---|---|
| committer | Christian Kolset <christian.kolset@gmail.com> | 2026-06-03 12:53:35 -0600 |
| commit | 6edbeba5d93569cd4f8f00670399c86909047bab (patch) | |
| tree | 4af17f2f6029281bfadd676b64f17d9c1798bcd6 /ui/windows/settings_window.py | |
| parent | 6fb559b64682d6f564d134b8937a688df59ed8e5 (diff) | |
Persist settings per-computer; add Reset to Defaults in General tab
- New core/app_settings.py: load/save settings.json to platform config dir
(Windows: %APPDATA%, Linux: ~/.config, macOS: ~/Library/Application Support)
- MainWindow loads saved settings on startup, saves on every Apply & Close
- Settings survive profile switches and app restarts independently of profiles
- Settings > General: Reset to Defaults button with QMessageBox confirmation
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Diffstat (limited to 'ui/windows/settings_window.py')
| -rw-r--r-- | ui/windows/settings_window.py | 28 |
1 files changed, 27 insertions, 1 deletions
diff --git a/ui/windows/settings_window.py b/ui/windows/settings_window.py index 422b6c9..1630efa 100644 --- a/ui/windows/settings_window.py +++ b/ui/windows/settings_window.py @@ -13,7 +13,7 @@ from PyQt6.QtWidgets import ( QWidget, QVBoxLayout, QHBoxLayout, QLabel, QPushButton, QTabWidget, QFrame, QFormLayout, QComboBox, QSpinBox, QDoubleSpinBox, QCheckBox, QLineEdit, - QFileDialog, QScrollArea, QGroupBox, + QFileDialog, QScrollArea, QGroupBox, QMessageBox, ) from PyQt6.QtCore import Qt, pyqtSignal from PyQt6.QtGui import QCloseEvent, QFont @@ -108,10 +108,25 @@ class SettingsWindow(QWidget): self._aa_chk = QCheckBox(); self._aa_chk.setChecked(self.cfg["antialias"]) lay.addRow("Anti-alias plots:", self._aa_chk) + rst = QPushButton("Reset to Defaults"); rst.setObjectName("configButton") + rst.clicked.connect(self._reset_to_defaults) + lay.addRow("", rst) + scroll.setWidget(cont) root = QVBoxLayout(w); root.setContentsMargins(0,0,0,0); root.addWidget(scroll) return w + def _populate_from_cfg(self): + self._theme_cb.setCurrentText(self.cfg["theme"].title()) + self._font_sp.setValue(self.cfg["font_size"]) + self._aa_chk.setChecked(self.cfg["antialias"]) + 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"]) + def _acquisition_tab(self): w = QWidget() scroll = QScrollArea(); scroll.setWidgetResizable(True) @@ -251,6 +266,17 @@ class SettingsWindow(QWidget): # ── Actions ─────────────────────────────────────────────────────────── + def _reset_to_defaults(self): + reply = QMessageBox.question( + self, "Reset Settings", + "Reset all settings to defaults?\nThis cannot be undone.", + QMessageBox.StandardButton.Yes | QMessageBox.StandardButton.No, + QMessageBox.StandardButton.No, + ) + if reply == QMessageBox.StandardButton.Yes: + self.cfg = dict(self._defaults) + self._populate_from_cfg() + def _browse_log(self): path = QFileDialog.getExistingDirectory(self, "Select Log Directory") if path: |
