From aa5f6a5abad80acf9b33f54a8d4a09a375601acf Mon Sep 17 00:00:00 2001 From: Sebastien Bourdeauducq Date: Mon, 15 Feb 2016 23:58:44 +0100 Subject: [PATCH] gui: basic MDI area --- artiq/frontend/artiq_gui.py | 1 + artiq/gui/experiments.py | 22 +++++++++++++--------- 2 files changed, 14 insertions(+), 9 deletions(-) diff --git a/artiq/frontend/artiq_gui.py b/artiq/frontend/artiq_gui.py index 60e5d4cb6..fa2c1a25d 100755 --- a/artiq/frontend/artiq_gui.py +++ b/artiq/frontend/artiq_gui.py @@ -93,6 +93,7 @@ def main(): status_bar = QtWidgets.QStatusBar() status_bar.showMessage("Connected to {}".format(args.server)) main_window.setStatusBar(status_bar) + main_window.setCentralWidget(QtWidgets.QMdiArea()) # create UI components expmgr = experiments.ExperimentManager(main_window, diff --git a/artiq/gui/experiments.py b/artiq/gui/experiments.py index b18214d13..b7a019b4c 100644 --- a/artiq/gui/experiments.py +++ b/artiq/gui/experiments.py @@ -5,8 +5,7 @@ from collections import OrderedDict from PyQt5 import QtCore, QtGui, QtWidgets -from artiq.gui.tools import (LayoutWidget, log_level_to_name, - QDockWidgetCloseDetect) +from artiq.gui.tools import LayoutWidget, log_level_to_name from artiq.gui.entries import argty_to_entry @@ -132,11 +131,12 @@ class _ArgumentEditor(QtWidgets.QTreeWidget): pass -class _ExperimentDock(QDockWidgetCloseDetect): +class _ExperimentDock(QtWidgets.QMdiSubWindow): + sigClosed = QtCore.pyqtSignal() + def __init__(self, manager, expurl): - name = "Exp: " + expurl - QDockWidgetCloseDetect.__init__(self, name) - self.setObjectName(name) + QtWidgets.QMdiSubWindow.__init__(self) + self.setWindowTitle(expurl) self.layout = QtWidgets.QGridLayout() top_widget = QtWidgets.QWidget() @@ -294,6 +294,10 @@ class _ExperimentDock(QDockWidgetCloseDetect): self.argeditor = _ArgumentEditor(self.manager, self, self.expurl) self.layout.addWidget(self.argeditor, 0, 0, 1, 5) + def closeEvent(self, event): + self.sigClosed.emit() + QtWidgets.QMdiSubWindow.closeEvent(self, event) + def save_state(self): return self.argeditor.save_state() @@ -389,12 +393,12 @@ class ExperimentManager: def open_experiment(self, expurl): if expurl in self.open_experiments: dock = self.open_experiments[expurl] - dock.setFloating(True) + self.main_window.centralWidget().setActiveSubWindow(dock) return dock dock = _ExperimentDock(self, expurl) self.open_experiments[expurl] = dock - self.main_window.addDockWidget(QtCore.Qt.RightDockWidgetArea, dock) - dock.setFloating(True) + self.main_window.centralWidget().addSubWindow(dock) + dock.show() dock.sigClosed.connect(partial(self.on_dock_closed, expurl)) return dock