summaryrefslogtreecommitdiff
path: root/ui
diff options
context:
space:
mode:
authorChristian Kolset <ckolset@colostate.edu>2026-08-17 10:01:59 -0600
committerChristian Kolset <ckolset@colostate.edu>2026-08-17 10:01:59 -0600
commite749cca30da2d02839aca736873e7e5ad45e191c (patch)
treeca57d9ce2ff6a6f33193a59216be17b3b159c1af /ui
parent34c12b2b5b280206890cd03153b1c95116acc85e (diff)
Add .labui file association — open by double-click, cross-platform
Windows/Linux self-register via core/file_association.py (winreg / XDG .desktop+mime), triggered from a new Settings button since there's no installer to do it at install time. macOS gets it at build time via labui.spec's new BUNDLE() step (CFBundleDocumentTypes in Info.plist) — that step also makes mac builds a real .app bundle for the first time, not just a bare onedir folder. main.py gains a LabUIApplication subclass to catch the macOS QFileOpenEvent (buffered if it arrives before MainWindow exists) plus argv[1] handling for Windows/Linux. ProfileButton.load_path() extracted so both paths share the same load-and-apply logic as the existing file-dialog flow. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Diffstat (limited to 'ui')
-rw-r--r--ui/main_window.py5
-rw-r--r--ui/profile_manager_ui.py8
-rw-r--r--ui/windows/settings_window.py31
3 files changed, 44 insertions, 0 deletions
diff --git a/ui/main_window.py b/ui/main_window.py
index 012d6f5..b632535 100644
--- a/ui/main_window.py
+++ b/ui/main_window.py
@@ -601,6 +601,11 @@ class MainWindow(QMainWindow):
# ── Profile callbacks ─────────────────────────────────────────────────
+ def load_profile_path(self, path: str) -> bool:
+ """Load a .labui file from an explicit path — used when one is
+ opened from the OS (double-click / CLI argv), see main.py."""
+ return self._file_btn.load_path(path)
+
def _profile_new(self):
"""Reset to a blank slate."""
# Clear devices
diff --git a/ui/profile_manager_ui.py b/ui/profile_manager_ui.py
index 446e867..79f333e 100644
--- a/ui/profile_manager_ui.py
+++ b/ui/profile_manager_ui.py
@@ -85,13 +85,21 @@ class ProfileButton(QPushButton):
)
if not path:
return
+ self.load_path(path)
+
+ def load_path(self, path: str) -> bool:
+ """Load a profile from an explicit path — shared by the file dialog
+ above and by opening a .labui file from the OS (double-click / CLI
+ argv), see main.py."""
try:
profile = Profile.load(path)
self._apply_profile(profile)
self._current_path = path
self._update_title(profile.name)
+ return True
except Exception as e:
QMessageBox.critical(self, "Load Failed", str(e))
+ return False
def _do_save(self):
if not self._current_path:
diff --git a/ui/windows/settings_window.py b/ui/windows/settings_window.py
index cea7e5c..ae44c31 100644
--- a/ui/windows/settings_window.py
+++ b/ui/windows/settings_window.py
@@ -137,6 +137,24 @@ class SettingsWindow(QWidget):
self._update_status_lbl.setWordWrap(True)
lay.addRow("", self._update_status_lbl)
+ import sys as _sys
+ if _sys.platform.startswith(("win", "linux")):
+ assoc_row = QHBoxLayout()
+ self._assoc_btn = QPushButton("Register .labui Files")
+ self._assoc_btn.setObjectName("configButton")
+ self._assoc_btn.setToolTip(
+ "Associates .labui files with LabUI so double-clicking one\n"
+ "in the OS file browser opens it here."
+ )
+ self._assoc_btn.clicked.connect(self._register_file_association)
+ assoc_row.addWidget(self._assoc_btn)
+ assoc_row.addStretch()
+ lay.addRow("File Associations:", assoc_row)
+ self._assoc_status_lbl = QLabel("")
+ self._assoc_status_lbl.setObjectName("traceSource")
+ self._assoc_status_lbl.setWordWrap(True)
+ lay.addRow("", self._assoc_status_lbl)
+
rst = QPushButton("Reset to Defaults"); rst.setObjectName("configButton")
rst.clicked.connect(self._reset_to_defaults)
lay.addRow("", rst)
@@ -390,6 +408,19 @@ class SettingsWindow(QWidget):
except Exception as e:
QMessageBox.critical(self, "Update Failed", str(e))
+ def _register_file_association(self):
+ from core.updater import is_frozen
+ if not is_frozen():
+ self._assoc_status_lbl.setText("Not available outside the packaged app (dev mode).")
+ return
+
+ from core.file_association import register
+ err = register()
+ if err:
+ self._assoc_status_lbl.setText(f"Failed: {err}")
+ else:
+ self._assoc_status_lbl.setText("✓ .labui files now open with LabUI.")
+
def _reset_to_defaults(self):
reply = QMessageBox.question(
self, "Reset Settings",