Merge pull request 'feat: Ctrl+S save shortcut + enable/disable-all actions (#55)' (#59) from feat/55-ux-polish into main
CI / Lint (ruff) (push) Successful in 6s
CI / Tests (py3.10 / ubuntu-latest) (push) Successful in 10s
CI / Tests (py3.12 / windows-latest) (push) Successful in 20s
CI / Tests (py3.12 / ubuntu-latest) (push) Successful in 9s
CI / Tests (py3.13 / ubuntu-latest) (push) Successful in 9s
CI / Lint (ruff) (push) Successful in 6s
CI / Tests (py3.10 / ubuntu-latest) (push) Successful in 10s
CI / Tests (py3.12 / windows-latest) (push) Successful in 20s
CI / Tests (py3.12 / ubuntu-latest) (push) Successful in 9s
CI / Tests (py3.13 / ubuntu-latest) (push) Successful in 9s
This commit was merged in pull request #59.
This commit is contained in:
@@ -23,6 +23,7 @@ from PySide6.QtGui import (
|
|||||||
QDesktopServices,
|
QDesktopServices,
|
||||||
QGuiApplication,
|
QGuiApplication,
|
||||||
QIcon,
|
QIcon,
|
||||||
|
QKeySequence,
|
||||||
QPainter,
|
QPainter,
|
||||||
QPixmap,
|
QPixmap,
|
||||||
)
|
)
|
||||||
@@ -1687,11 +1688,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)
|
||||||
|
|
||||||
# Named server sets (issue #52): apply a saved Active/Disabled split
|
# Named server sets (issue #52): apply a saved Active/Disabled split
|
||||||
# in one click. Sets live in the config file under _bccServerSets.
|
# in one click. Sets live in the config file under _bccServerSets.
|
||||||
@@ -1799,6 +1810,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)
|
||||||
@@ -1825,6 +1842,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()
|
||||||
@@ -2412,6 +2442,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
|
||||||
|
|||||||
Reference in New Issue
Block a user