diff options
Diffstat (limited to 'ui')
| -rw-r--r-- | ui/main_window.py | 3 | ||||
| -rw-r--r-- | ui/windows/settings_window.py | 56 |
2 files changed, 58 insertions, 1 deletions
diff --git a/ui/main_window.py b/ui/main_window.py index 90294ac..9090d0f 100644 --- a/ui/main_window.py +++ b/ui/main_window.py @@ -55,7 +55,8 @@ _LIGHT_QSS = os.path.join(os.path.dirname(os.path.abspath(__file__)), "style_lig class MainWindow(QMainWindow): def __init__(self): super().__init__() - self.setWindowTitle("LabDAQ") + from core.version import __version__ + self.setWindowTitle(f"LabDAQ v{__version__}") self.setMinimumSize(1000, 640) self.registry = DeviceRegistry() diff --git a/ui/windows/settings_window.py b/ui/windows/settings_window.py index 290d9e0..75b6991 100644 --- a/ui/windows/settings_window.py +++ b/ui/windows/settings_window.py @@ -118,6 +118,23 @@ class SettingsWindow(QWidget): ) lay.addRow("Developer mode:", self._dev_chk) + from core.version import __version__ as _app_version + version_lbl = QLabel(f"v{_app_version}") + version_lbl.setObjectName("traceSource") + lay.addRow("Version:", version_lbl) + + update_row = QHBoxLayout() + self._update_btn = QPushButton("Check for Updates") + self._update_btn.setObjectName("configButton") + self._update_btn.clicked.connect(self._check_for_updates) + update_row.addWidget(self._update_btn) + update_row.addStretch() + lay.addRow("Updates:", update_row) + self._update_status_lbl = QLabel("") + self._update_status_lbl.setObjectName("traceSource") + self._update_status_lbl.setWordWrap(True) + lay.addRow("", self._update_status_lbl) + rst = QPushButton("Reset to Defaults"); rst.setObjectName("configButton") rst.clicked.connect(self._reset_to_defaults) lay.addRow("", rst) @@ -286,6 +303,45 @@ class SettingsWindow(QWidget): # ── Actions ─────────────────────────────────────────────────────────── + def _check_for_updates(self): + from core.updater import is_frozen + + if not is_frozen(): + self._update_status_lbl.setText("Not available outside the packaged app (dev mode).") + return + + from PyQt6.QtWidgets import QApplication + from core.updater import apply_update, check_for_update + + self._update_btn.setEnabled(False) + self._update_status_lbl.setText("Checking…") + QApplication.processEvents() + try: + new_version = check_for_update() + except Exception as e: + self._update_status_lbl.setText(f"Check failed: {e}") + self._update_btn.setEnabled(True) + return + self._update_btn.setEnabled(True) + + if not new_version: + self._update_status_lbl.setText("Up to date.") + return + + self._update_status_lbl.setText(f"Version {new_version} available.") + reply = QMessageBox.question( + self, "Update Available", + f"Version {new_version} is available. Download and install now?\n\n" + f"The app will close and relaunch to complete the update.", + QMessageBox.StandardButton.Yes | QMessageBox.StandardButton.No, + QMessageBox.StandardButton.No, + ) + if reply == QMessageBox.StandardButton.Yes: + try: + apply_update() # may close/relaunch the process during this call + except Exception as e: + QMessageBox.critical(self, "Update Failed", str(e)) + def _reset_to_defaults(self): reply = QMessageBox.question( self, "Reset Settings", |
