forked from M-Labs/artiq
1
0
Fork 0

moninj: delete widget action

This commit is contained in:
Simon Renblad 2024-05-02 17:02:52 +08:00
parent 91241bd5c2
commit b2924ef9bb
1 changed files with 17 additions and 0 deletions

View File

@ -835,6 +835,23 @@ class _MonInjDock(QDockWidgetCloseDetect):
self.flow = DragDropFlowLayoutWidget()
scroll_area.setWidgetResizable(True)
scroll_area.setWidget(self.flow)
self.flow.setContextMenuPolicy(QtCore.Qt.CustomContextMenu)
self.flow.customContextMenuRequested.connect(self.custom_context_menu)
def custom_context_menu(self, pos):
index = self.flow._get_index(pos)
if index == -1:
return
menu = QtWidgets.QMenu()
delete_action = QtWidgets.QAction("Delete widget", menu)
delete_action.triggered.connect(partial(self.delete_widget, index))
menu.addAction(delete_action)
menu.exec_(self.flow.mapToGlobal(pos))
def delete_widget(self, index, checked):
widget = self.flow.itemAt(index).widget()
widget.hide()
self.flow.layout.takeAt(index)
def add_channels(self):
channels = self.channel_dialog.channels