forked from M-Labs/artiq
1
0
Fork 0

gui: Add context menu entry to close all applets

This is occasionally very useful if a large number of
applets were left open (e.g. spawned via CCB).
This commit is contained in:
David Nadlinger 2021-01-17 11:46:51 +01:00
parent c675488a99
commit f11aef74b4
2 changed files with 18 additions and 0 deletions

View File

@ -37,6 +37,8 @@ Highlights:
- A "Quick Open" dialog to open experiments by typing part of their name can
be brought up Ctrl-P (Ctrl+Return to immediately submit the selected entry
with the default arguments).
- The Applets dock now has a context menu command to quickly close all open
applets (shortcut: Ctrl-Alt-W).
* Experiment results are now always saved to HDF5, even if run() fails.
* Core device: ``panic_reset 1`` now correctly resets the kernel CPU as well if
communication CPU panic occurs.

View File

@ -370,6 +370,11 @@ class AppletsDock(QtWidgets.QDockWidget):
delete_action.setShortcutContext(QtCore.Qt.WidgetShortcut)
delete_action.triggered.connect(self.delete)
self.table.addAction(delete_action)
close_all_action = QtWidgets.QAction("Close all applets", self.table)
close_all_action.setShortcut("CTRL+ALT+W")
close_all_action.setShortcutContext(QtCore.Qt.ApplicationShortcut)
close_all_action.triggered.connect(self.close_all)
self.table.addAction(close_all_action)
new_group_action = QtWidgets.QAction("New group", self.table)
new_group_action.triggered.connect(partial(self.new_with_parent, self.new_group))
self.table.addAction(new_group_action)
@ -641,3 +646,14 @@ class AppletsDock(QtWidgets.QDockWidget):
def restore_state(self, state):
self.restore_state_item(state, None)
def close_all(self):
def walk(wi):
for i in range(wi.childCount()):
cwi = wi.child(i)
if cwi.ty == "applet":
if cwi.checkState(0) == QtCore.Qt.Checked:
cwi.setCheckState(0, QtCore.Qt.Unchecked)
elif cwi.ty == "group":
walk(cwi)
walk(self.table.invisibleRootItem())