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)
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))

View File

@ -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)