forked from M-Labs/artiq
browser: add root dir option, load only one file on restore
This commit is contained in:
parent
40b47b8440
commit
3d393e4654
|
@ -57,7 +57,8 @@ class DirsOnlyProxy(QtCore.QSortFilterProxyModel):
|
|||
|
||||
|
||||
class FilesDock(QtWidgets.QDockWidget):
|
||||
def __init__(self, datasets, main_window, root=""):
|
||||
def __init__(self, datasets, main_window, root="",
|
||||
select_file=None):
|
||||
QtWidgets.QDockWidget.__init__(self, "Files")
|
||||
self.setObjectName("Files")
|
||||
self.setFeatures(self.DockWidgetMovable | self.DockWidgetFloatable)
|
||||
|
@ -67,6 +68,7 @@ class FilesDock(QtWidgets.QDockWidget):
|
|||
|
||||
self.datasets = datasets
|
||||
self.main_window = main_window
|
||||
self.override_restore_file = select_file
|
||||
|
||||
self.model = QtWidgets.QFileSystemModel()
|
||||
self.model.setFilter(QtCore.QDir.Drives | QtCore.QDir.NoDotAndDotDot |
|
||||
|
@ -180,9 +182,12 @@ class FilesDock(QtWidgets.QDockWidget):
|
|||
dir = state.get("dir")
|
||||
if dir:
|
||||
self.select_dir(dir)
|
||||
file = state.get("file")
|
||||
if file:
|
||||
self.select_file(file)
|
||||
if self.override_restore_file:
|
||||
self.select_file(os.path.normpath(self.override_restore_file))
|
||||
else:
|
||||
file = state.get("file")
|
||||
if file:
|
||||
self.select_file(file)
|
||||
header = state.get("header")
|
||||
if header:
|
||||
self.rt.header().restoreState(QtCore.QByteArray(header))
|
||||
|
|
|
@ -21,10 +21,12 @@ def get_argparser():
|
|||
default_db_file = os.path.expanduser("~/.artiq_browser.pyon")
|
||||
|
||||
parser = argparse.ArgumentParser(description="ARTIQ Browser")
|
||||
parser.add_argument(
|
||||
"--db-file", default=default_db_file,
|
||||
help="database file for local browser settings "
|
||||
"(default: %(default)s)")
|
||||
parser.add_argument("--db-file", default=default_db_file,
|
||||
help="database file for local browser settings "
|
||||
"(default: %(default)s)")
|
||||
parser.add_argument("--root", default="",
|
||||
help="root path for directory tree "
|
||||
"(default %(default)s)")
|
||||
parser.add_argument("PATH", nargs="?", help="browse path or file")
|
||||
verbosity_args(parser)
|
||||
return parser
|
||||
|
@ -90,7 +92,8 @@ def main():
|
|||
status_bar = QtWidgets.QStatusBar()
|
||||
main_window.setStatusBar(status_bar)
|
||||
|
||||
d_files = files.FilesDock(datasets_sub, main_window)
|
||||
d_files = files.FilesDock(datasets_sub, main_window, args.root,
|
||||
args.PATH)
|
||||
smgr.register(d_files)
|
||||
|
||||
d_applets = applets.AppletsDock(main_window, datasets_sub)
|
||||
|
@ -124,9 +127,6 @@ def main():
|
|||
# run
|
||||
main_window.show()
|
||||
|
||||
if args.PATH:
|
||||
d_files.select_file(os.path.normpath(args.PATH))
|
||||
|
||||
loop.run_until_complete(main_window.exit_request.wait())
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
|
Loading…
Reference in New Issue