forked from M-Labs/artiq
gui: reliable detection of dock close
This commit is contained in:
parent
3c12c13a67
commit
489f69f991
|
@ -8,6 +8,7 @@ from quamash import QtCore, QtGui, QtWidgets
|
|||
|
||||
from artiq.protocols.pipe_ipc import AsyncioParentComm
|
||||
from artiq.protocols import pyon
|
||||
from artiq.gui.tools import QDockWidgetCloseDetect
|
||||
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
@ -84,11 +85,9 @@ class AppletIPCServer(AsyncioParentComm):
|
|||
await asyncio.wait([self.server_task])
|
||||
|
||||
|
||||
class AppletDock(QtWidgets.QDockWidget):
|
||||
sigClosed = QtCore.pyqtSignal()
|
||||
|
||||
class AppletDock(QDockWidgetCloseDetect):
|
||||
def __init__(self, datasets_sub, uid, name, command):
|
||||
QtWidgets.QDockWidget.__init__(self, "Applet: " + name)
|
||||
QDockWidgetCloseDetect.__init__(self, "Applet: " + name)
|
||||
self.setObjectName("applet" + str(uid))
|
||||
|
||||
self.datasets_sub = datasets_sub
|
||||
|
@ -164,10 +163,6 @@ class AppletDock(QtWidgets.QDockWidget):
|
|||
await self.terminate()
|
||||
await self.start()
|
||||
|
||||
def closeEvent(self, event):
|
||||
QtWidgets.QDockWidget.closeEvent(self, event)
|
||||
self.sigClosed.emit()
|
||||
|
||||
|
||||
_templates = [
|
||||
("Big number", "{python} -m artiq.applets.big_number "
|
||||
|
|
|
@ -7,7 +7,7 @@ from quamash import QtGui, QtCore, QtWidgets
|
|||
|
||||
from pyqtgraph import LayoutWidget
|
||||
|
||||
from artiq.gui.tools import log_level_to_name
|
||||
from artiq.gui.tools import log_level_to_name, QDockWidgetCloseDetect
|
||||
from artiq.gui.entries import argty_to_entry
|
||||
|
||||
|
||||
|
@ -133,12 +133,10 @@ class _ArgumentEditor(QtGui.QTreeWidget):
|
|||
pass
|
||||
|
||||
|
||||
class _ExperimentDock(QtWidgets.QDockWidget):
|
||||
sigClosed = QtCore.pyqtSignal()
|
||||
|
||||
class _ExperimentDock(QDockWidgetCloseDetect):
|
||||
def __init__(self, manager, expurl):
|
||||
name = "Exp: " + expurl
|
||||
QtWidgets.QDockWidget.__init__(self, name)
|
||||
QDockWidgetCloseDetect.__init__(self, name)
|
||||
self.setObjectName(name)
|
||||
|
||||
self.layout = QtWidgets.QGridLayout()
|
||||
|
@ -297,10 +295,6 @@ class _ExperimentDock(QtWidgets.QDockWidget):
|
|||
self.argeditor = _ArgumentEditor(self.manager, self, self.expurl)
|
||||
self.layout.addWidget(self.argeditor, 0, 0, 1, 5)
|
||||
|
||||
def closeEvent(self, event):
|
||||
QtWidgets.QDockWidget.closeEvent(self, event)
|
||||
self.sigClosed.emit()
|
||||
|
||||
def save_state(self):
|
||||
return self.argeditor.save_state()
|
||||
|
||||
|
|
|
@ -7,7 +7,7 @@ from functools import partial
|
|||
from quamash import QtGui, QtCore, QtWidgets
|
||||
from pyqtgraph import LayoutWidget
|
||||
|
||||
from artiq.gui.tools import log_level_to_name
|
||||
from artiq.gui.tools import log_level_to_name, QDockWidgetCloseDetect
|
||||
|
||||
|
||||
def _make_wrappable(row, width=30):
|
||||
|
@ -140,11 +140,9 @@ class _LogFilterProxyModel(QtCore.QSortFilterProxyModel):
|
|||
self.invalidateFilter()
|
||||
|
||||
|
||||
class _LogDock(QtWidgets.QDockWidget):
|
||||
sigClosed = QtCore.pyqtSignal()
|
||||
|
||||
class _LogDock(QDockWidgetCloseDetect):
|
||||
def __init__(self, manager, name, log_sub):
|
||||
QtWidgets.QDockWidget.__init__(self, "Log")
|
||||
QDockWidgetCloseDetect.__init__(self, "Log")
|
||||
self.setObjectName(name)
|
||||
|
||||
grid = LayoutWidget()
|
||||
|
@ -254,10 +252,6 @@ class _LogDock(QtWidgets.QDockWidget):
|
|||
self.table_model_filter.rowsInserted.connect(self.rows_inserted_after)
|
||||
self.table_model_filter.rowsRemoved.connect(self.rows_removed)
|
||||
|
||||
def closeEvent(self, event):
|
||||
QtWidgets.QDockWidget.closeEvent(self, event)
|
||||
self.sigClosed.emit()
|
||||
|
||||
def save_state(self):
|
||||
return {
|
||||
"min_level_idx": self.filter_level.currentIndex(),
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import logging
|
||||
|
||||
from quamash import QtCore
|
||||
from PyQt5 import QtCore, QtWidgets, QtGui
|
||||
|
||||
|
||||
def log_level_to_name(level):
|
||||
|
@ -27,3 +27,12 @@ class _WheelFilter(QtCore.QObject):
|
|||
def disable_scroll_wheel(widget):
|
||||
widget.setFocusPolicy(QtCore.Qt.StrongFocus)
|
||||
widget.installEventFilter(_WheelFilter(widget))
|
||||
|
||||
|
||||
class QDockWidgetCloseDetect(QtWidgets.QDockWidget):
|
||||
sigClosed = QtCore.pyqtSignal()
|
||||
|
||||
def event(self, event):
|
||||
if isinstance(event, QtGui.QCloseEvent):
|
||||
self.sigClosed.emit()
|
||||
return QtWidgets.QDockWidget.event(self, event)
|
||||
|
|
Loading…
Reference in New Issue