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