summaryrefslogtreecommitdiff
path: root/ui/windows/settings_window.py
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/windows/settings_window.py
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/windows/settings_window.py')
-rw-r--r--ui/windows/settings_window.py31
1 files changed, 31 insertions, 0 deletions
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",