feat: Ctrl+S save shortcut + enable/disable-all actions (#55)
CI / Tests (py3.12 / windows-latest) (pull_request) Successful in 20s
CI / Tests (py3.13 / ubuntu-latest) (pull_request) Successful in 8s
CI / Lint (ruff) (pull_request) Successful in 7s
CI / Tests (py3.10 / ubuntu-latest) (pull_request) Successful in 9s
CI / Tests (py3.12 / ubuntu-latest) (pull_request) Successful in 8s

Closes #55

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
Cowork Supervisor
2026-07-12 13:55:19 -04:00
parent 9f535fb77f
commit 31ef4a0e85
+38 -1
View File
@@ -23,6 +23,7 @@ from PySide6.QtGui import (
QDesktopServices, QDesktopServices,
QGuiApplication, QGuiApplication,
QIcon, QIcon,
QKeySequence,
QPainter, QPainter,
QPixmap, QPixmap,
) )
@@ -1686,11 +1687,21 @@ class MainWindow(QMainWindow):
head.setObjectName("h1") head.setObjectName("h1")
v.addWidget(head) v.addWidget(head)
search_row = QHBoxLayout()
self.search_box = QLineEdit() self.search_box = QLineEdit()
self.search_box.setPlaceholderText("Search servers by name, command, or url…") self.search_box.setPlaceholderText("Search servers by name, command, or url…")
self.search_box.setClearButtonEnabled(True) self.search_box.setClearButtonEnabled(True)
self.search_box.textChanged.connect(self._on_search_changed) self.search_box.textChanged.connect(self._on_search_changed)
v.addWidget(self.search_box) search_row.addWidget(self.search_box, 1)
self.enable_all_btn = QPushButton("All on")
self.enable_all_btn.setToolTip("Enable every server")
self.enable_all_btn.clicked.connect(lambda: self._set_all_enabled(True))
search_row.addWidget(self.enable_all_btn)
self.disable_all_btn = QPushButton("All off")
self.disable_all_btn.setToolTip("Disable every server")
self.disable_all_btn.clicked.connect(lambda: self._set_all_enabled(False))
search_row.addWidget(self.disable_all_btn)
v.addLayout(search_row)
# Active and Disabled sections live in a vertical splitter so the user # Active and Disabled sections live in a vertical splitter so the user
# can drag the divider instead of being stuck with a fixed-height # can drag the divider instead of being stuck with a fixed-height
@@ -1774,6 +1785,12 @@ class MainWindow(QMainWindow):
undo_action.setShortcut("Ctrl+Z") undo_action.setShortcut("Ctrl+Z")
undo_action.triggered.connect(self._undo) undo_action.triggered.connect(self._undo)
self.addAction(undo_action) self.addAction(undo_action)
# Ctrl+S / Cmd+S shortcut — routed through a guard so it respects
# the same dirty/validation gating as the Save button.
save_action = QAction(self)
save_action.setShortcut(QKeySequence.StandardKey.Save)
save_action.triggered.connect(self._save_shortcut)
self.addAction(save_action)
bar.addStretch() bar.addStretch()
self.validation_lbl = QLabel("") self.validation_lbl = QLabel("")
bar.addWidget(self.validation_lbl) bar.addWidget(self.validation_lbl)
@@ -1800,6 +1817,19 @@ class MainWindow(QMainWindow):
self._mark_dirty() self._mark_dirty()
self.status.setText("Undone.") self.status.setText("Undone.")
def _set_all_enabled(self, enabled: bool):
"""Flip every server's enabled flag in one step (one undo snapshot)."""
if not self.servers or all(s.enabled == enabled for s in self.servers):
return # nothing to change
cur = self._current_index()
self._push_undo()
for s in self.servers:
s.enabled = enabled
sel = cur if 0 <= cur < len(self.servers) else None
self._refresh_tables(select_index=sel)
self._mark_dirty()
self.status.setText("All servers enabled." if enabled else "All servers disabled.")
# --- profiles -------------------------------------------------------- # # --- profiles -------------------------------------------------------- #
def reload_profiles(self): def reload_profiles(self):
discovered = core.discover_profiles() discovered = core.discover_profiles()
@@ -2314,6 +2344,13 @@ class MainWindow(QMainWindow):
self.save_btn.setEnabled(self.dirty) self.save_btn.setEnabled(self.dirty)
return True return True
def _save_shortcut(self):
"""Ctrl+S / Cmd+S handler — only fires when the Save button itself
would accept a click, so the shortcut can't bypass validation/dirty
gating."""
if self.save_btn.isEnabled():
self.save()
def save(self): def save(self):
if not self.current_profile: if not self.current_profile:
return return