forked from M-Labs/artiq
1
0
Fork 0

browser: make results a dock again

This commit is contained in:
Robert Jördens 2016-04-10 16:22:24 +08:00
parent 3a0c2066a9
commit 6c200b1418
2 changed files with 34 additions and 8 deletions

View File

@ -36,9 +36,15 @@ class ResultIconProvider(QtWidgets.QFileIconProvider):
return QtGui.QIcon(pix) return QtGui.QIcon(pix)
class ResultsBrowser(QtWidgets.QSplitter): class ResultsDock(QtWidgets.QDockWidget):
def __init__(self, datasets, root=None): 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: if root is None:
root = QtCore.QDir.currentPath() root = QtCore.QDir.currentPath()
@ -57,7 +63,7 @@ class ResultsBrowser(QtWidgets.QSplitter):
self.rt.selectionModel().currentChanged.connect( self.rt.selectionModel().currentChanged.connect(
self.tree_current_changed) self.tree_current_changed)
self.rt.setRootIsDecorated(False) self.rt.setRootIsDecorated(False)
self.addWidget(self.rt) self.splitter.addWidget(self.rt)
self.rl = QtWidgets.QListView() self.rl = QtWidgets.QListView()
self.rl.setViewMode(QtWidgets.QListView.IconMode) self.rl.setViewMode(QtWidgets.QListView.IconMode)
@ -66,7 +72,7 @@ class ResultsBrowser(QtWidgets.QSplitter):
self.rl.setFlow(QtWidgets.QListView.LeftToRight) self.rl.setFlow(QtWidgets.QListView.LeftToRight)
self.rl.setWrapping(True) self.rl.setWrapping(True)
self.tree_current_changed(self.rt.currentIndex(), None) self.tree_current_changed(self.rt.currentIndex(), None)
self.addWidget(self.rl) self.splitter.addWidget(self.rl)
def showEvent(self, ev): def showEvent(self, ev):
self.rt.hideColumn(1) self.rt.hideColumn(1)
@ -118,7 +124,7 @@ class ResultsBrowser(QtWidgets.QSplitter):
return { return {
"selected": self.rl_model.filePath(self.rt.currentIndex()), "selected": self.rl_model.filePath(self.rt.currentIndex()),
"header": bytes(self.rt.header().saveState()), "header": bytes(self.rt.header().saveState()),
"splitter": bytes(self.saveState()), "splitter": bytes(self.splitter.saveState()),
} }
def restore_state(self, state): def restore_state(self, state):
@ -130,4 +136,4 @@ class ResultsBrowser(QtWidgets.QSplitter):
self.rt.header().restoreState(QtCore.QByteArray(header)) self.rt.header().restoreState(QtCore.QByteArray(header))
splitter = state.get("splitter") splitter = state.get("splitter")
if splitter: if splitter:
self.restoreState(QtCore.QByteArray(splitter)) self.splitter.restoreState(QtCore.QByteArray(splitter))

View File

@ -51,6 +51,21 @@ class MainWindow(QtWidgets.QMainWindow):
self.restoreState(QtCore.QByteArray(state["state"])) 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(): def main():
# initialize application # initialize application
args = get_argparser().parse_args() args = get_argparser().parse_args()
@ -70,7 +85,7 @@ def main():
status_bar = QtWidgets.QStatusBar() status_bar = QtWidgets.QStatusBar()
main_window.setStatusBar(status_bar) main_window.setStatusBar(status_bar)
d_results = results.ResultsBrowser(datasets_sub) d_results = results.ResultsDock(datasets_sub)
smgr.register(d_results) smgr.register(d_results)
d_applets = applets.AppletsDock(main_window, datasets_sub) d_applets = applets.AppletsDock(main_window, datasets_sub)
@ -80,7 +95,12 @@ def main():
d_datasets = datasets.DatasetsDock(datasets_sub) d_datasets = datasets.DatasetsDock(datasets_sub)
smgr.register(d_datasets) 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.BottomDockWidgetArea, d_applets)
main_window.addDockWidget(QtCore.Qt.RightDockWidgetArea, d_datasets) main_window.addDockWidget(QtCore.Qt.RightDockWidgetArea, d_datasets)