Commit 866fb54a authored by Yan's avatar Yan
Browse files

Slight redesign of main window, reduced line count

* rewritten few lines of code to make it more shorter and clear
* moved toolbar into main widget toolbar position
parent 88e62581
......@@ -309,8 +309,7 @@ def main():
main_window.menuBar().addMenu(help_menu)
help_menu.addAction(aboutact)
main_widget = QtWidgets.QWidget(main_window)
main_window.setCentralWidget(main_widget)
main_window.setCentralWidget(mpl_canvas)
toolBar = QtWidgets.QToolBar(main_window)
toolBar.setAllowedAreas(QtCore.Qt.TopToolBarArea)
......@@ -330,7 +329,7 @@ def main():
toolBar.addAction(autozoomy)
#fileModel gots stuck sometimes, better give it a separate thread
#it complains in separate thread but work as should, maybe fix later..
#it complains at the start, but works and I did not found better solution
fileModel = QtWidgets.QFileSystemModel()
treedockThread = QtCore.QThread()
treedockThread.start()
......@@ -350,36 +349,23 @@ def main():
treedock_layout = QtWidgets.QVBoxLayout(treedock.widget())
treedock_layout.addWidget(treeview)
treedock_layout.addWidget(dirview)
update.signal.connect(
lambda: treeview.setCurrentIndex(fileModel.index(filename[0])))
update.signal.connect(
lambda: dirview.setRootIndex(fileModel.index(
update.signal.connect(lambda: treeview.setCurrentIndex(fileModel.index(
filename[0])))
update.signal.connect(lambda: dirview.setRootIndex(fileModel.index(
os.path.dirname(os.path.realpath(filename[0])))))
treeview.doubleClicked.connect(lambda index: load_file(
clickload = lambda index: load_file(
main_window, chromatogram, spectrum, ds, ms, filename, chrom,
update, config, filename=fileModel.filePath(index)))
dirview.doubleClicked.connect(lambda index: load_file(
main_window, chromatogram, spectrum, ds, ms, filename, chrom,
update, config, filename=fileModel.filePath(index)))
dirview.clicked.connect(lambda index: load_file(
main_window, chromatogram, spectrum, ds, ms, filename, chrom,
update, config, filename=fileModel.filePath(index)))
update, config, filename=fileModel.filePath(index))
for i in [treeview.doubleClicked, dirview.doubleClicked, dirview.clicked]:
i.connect(clickload)
def closeOverride(event, dock, action):
action.setChecked(False)
dock.hide()
event.ignore()
treedock.closeEvent = lambda event: closeOverride(
event, treedock, filebrowseract)
main_window.addDockWidget(QtCore.Qt.LeftDockWidgetArea, treedock)
main_window.closeEvent = lambda event: treedockThread.quit()
layout = QtWidgets.QVBoxLayout(main_widget)
layout.addWidget(toolBar)
layout.addWidget(mpl_canvas)
main_window.setFocus()
main_window.dragEnterEvent = lambda event: drag_entered(event)
main_window.dropEvent = lambda event: dropped(
event, main_window, chromatogram, spectrum, ds, ms, filename,
......@@ -388,6 +374,11 @@ def main():
main_window.keyPressEvent = lambda event: key_pressed(event, chromatogram,
spectrum, ds, ms, filename, chrom, config)
main_window.addToolBar(QtCore.Qt.TopToolBarArea, toolBar)
main_window.addDockWidget(QtCore.Qt.LeftDockWidgetArea, treedock)
main_window.setFocus()
if len(sys.argv) == 2:
load_file(main_window, chromatogram, spectrum, ds, ms,
filename, chrom, update, config, filename=sys.argv[1])
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment