forked from M-Labs/artiq
1
0
Fork 0

waveform: delete all waveforms confirm dialog

This commit is contained in:
Simon Renblad 2024-02-19 11:37:46 +08:00 committed by Sébastien Bourdeauducq
parent f460af3a6a
commit edd23977f8
1 changed files with 15 additions and 2 deletions

View File

@ -455,6 +455,18 @@ class _WaveformView(QtWidgets.QWidget):
self.cursorMove.connect(self.onCursorMove)
self.confirm_delete_dialog = QtWidgets.QMessageBox(self)
self.confirm_delete_dialog.setIcon(
QtWidgets.QMessageBox.Icon.Warning
)
self.confirm_delete_dialog.setText("Delete all waveforms?")
self.confirm_delete_dialog.setStandardButtons(
QtWidgets.QMessageBox.Ok | QtWidgets.QMessageBox.Cancel
)
self.confirm_delete_dialog.setDefaultButton(
QtWidgets.QMessageBox.Ok
)
def setModel(self, model):
self._model = model
self._model.dataChanged.connect(self.onDataChange)
@ -462,6 +474,7 @@ class _WaveformView(QtWidgets.QWidget):
self._model.rowsRemoved.connect(self.onRemove)
self._model.rowsMoved.connect(self.onMove)
self._splitter.dropped.connect(self._model.move)
self.confirm_delete_dialog.accepted.connect(self._model.clear)
def setTimescale(self, timescale):
self._timescale = timescale
@ -525,8 +538,8 @@ class _WaveformView(QtWidgets.QWidget):
action = QtWidgets.QAction("Delete waveform", w)
action.triggered.connect(lambda: self._delete_waveform(w))
w.addAction(action)
action = QtWidgets.QAction("Clear waveforms", w)
action.triggered.connect(self._model.clear)
action = QtWidgets.QAction("Delete all waveforms", w)
action.triggered.connect(self.confirm_delete_dialog.open)
w.addAction(action)
return w