From 6c200b1418ae4be77b348e189ad500a796b6387c Mon Sep 17 00:00:00 2001 From: Robert Jordens Date: Sun, 10 Apr 2016 16:22:24 +0800 Subject: [PATCH] browser: make results a dock again --- artiq/browser/results.py | 18 ++++++++++++------ artiq/frontend/artiq_browser.py | 24 ++++++++++++++++++++++-- 2 files changed, 34 insertions(+), 8 deletions(-) diff --git a/artiq/browser/results.py b/artiq/browser/results.py index 1aec0796f..22e8a2196 100644 --- a/artiq/browser/results.py +++ b/artiq/browser/results.py @@ -36,9 +36,15 @@ class ResultIconProvider(QtWidgets.QFileIconProvider): return QtGui.QIcon(pix) -class ResultsBrowser(QtWidgets.QSplitter): +class ResultsDock(QtWidgets.QDockWidget): def __init__(self, datasets, root=None): - QtWidgets.QSplitter.__init__(self) + QtWidgets.QDockWidget.__init__(self, "Results") + self.setObjectName("Results") + self.setFeatures(QtWidgets.QDockWidget.DockWidgetMovable | + QtWidgets.QDockWidget.DockWidgetFloatable) + + self.splitter = QtWidgets.QSplitter() + self.setWidget(self.splitter) if root is None: root = QtCore.QDir.currentPath() @@ -57,7 +63,7 @@ class ResultsBrowser(QtWidgets.QSplitter): self.rt.selectionModel().currentChanged.connect( self.tree_current_changed) self.rt.setRootIsDecorated(False) - self.addWidget(self.rt) + self.splitter.addWidget(self.rt) self.rl = QtWidgets.QListView() self.rl.setViewMode(QtWidgets.QListView.IconMode) @@ -66,7 +72,7 @@ class ResultsBrowser(QtWidgets.QSplitter): self.rl.setFlow(QtWidgets.QListView.LeftToRight) self.rl.setWrapping(True) self.tree_current_changed(self.rt.currentIndex(), None) - self.addWidget(self.rl) + self.splitter.addWidget(self.rl) def showEvent(self, ev): self.rt.hideColumn(1) @@ -118,7 +124,7 @@ class ResultsBrowser(QtWidgets.QSplitter): return { "selected": self.rl_model.filePath(self.rt.currentIndex()), "header": bytes(self.rt.header().saveState()), - "splitter": bytes(self.saveState()), + "splitter": bytes(self.splitter.saveState()), } def restore_state(self, state): @@ -130,4 +136,4 @@ class ResultsBrowser(QtWidgets.QSplitter): self.rt.header().restoreState(QtCore.QByteArray(header)) splitter = state.get("splitter") if splitter: - self.restoreState(QtCore.QByteArray(splitter)) + self.splitter.restoreState(QtCore.QByteArray(splitter)) diff --git a/artiq/frontend/artiq_browser.py b/artiq/frontend/artiq_browser.py index 5533db20a..87028a931 100755 --- a/artiq/frontend/artiq_browser.py +++ b/artiq/frontend/artiq_browser.py @@ -51,6 +51,21 @@ class MainWindow(QtWidgets.QMainWindow): self.restoreState(QtCore.QByteArray(state["state"])) +class MdiArea(QtWidgets.QMdiArea): + def __init__(self): + QtWidgets.QMdiArea.__init__(self) + self.pixmap = QtGui.QPixmap(os.path.join(artiq_dir, "gui", "logo.svg")) + + def paintEvent(self, event): + QtWidgets.QMdiArea.paintEvent(self, event) + painter = QtGui.QPainter(self.viewport()) + x = (self.width() - self.pixmap.width())//2 + y = (self.height() - self.pixmap.height())//2 + painter.setOpacity(0.5) + painter.drawPixmap(x, y, self.pixmap) + + + def main(): # initialize application args = get_argparser().parse_args() @@ -70,7 +85,7 @@ def main(): status_bar = QtWidgets.QStatusBar() main_window.setStatusBar(status_bar) - d_results = results.ResultsBrowser(datasets_sub) + d_results = results.ResultsDock(datasets_sub) smgr.register(d_results) d_applets = applets.AppletsDock(main_window, datasets_sub) @@ -80,7 +95,12 @@ def main(): d_datasets = datasets.DatasetsDock(datasets_sub) smgr.register(d_datasets) - main_window.setCentralWidget(d_results) + mdi_area = MdiArea() + mdi_area.setHorizontalScrollBarPolicy(QtCore.Qt.ScrollBarAsNeeded) + mdi_area.setVerticalScrollBarPolicy(QtCore.Qt.ScrollBarAsNeeded) + main_window.setCentralWidget(mdi_area) + + main_window.addDockWidget(QtCore.Qt.LeftDockWidgetArea, d_results) main_window.addDockWidget(QtCore.Qt.BottomDockWidgetArea, d_applets) main_window.addDockWidget(QtCore.Qt.RightDockWidgetArea, d_datasets)