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):
|
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")
|
QtWidgets.QDockWidget.__init__(self, "Files")
|
||||||
self.setObjectName("Files")
|
self.setObjectName("Files")
|
||||||
self.setFeatures(self.DockWidgetMovable | self.DockWidgetFloatable)
|
self.setFeatures(self.DockWidgetMovable | self.DockWidgetFloatable)
|
||||||
|
@ -67,6 +68,7 @@ class FilesDock(QtWidgets.QDockWidget):
|
||||||
|
|
||||||
self.datasets = datasets
|
self.datasets = datasets
|
||||||
self.main_window = main_window
|
self.main_window = main_window
|
||||||
|
self.override_restore_file = select_file
|
||||||
|
|
||||||
self.model = QtWidgets.QFileSystemModel()
|
self.model = QtWidgets.QFileSystemModel()
|
||||||
self.model.setFilter(QtCore.QDir.Drives | QtCore.QDir.NoDotAndDotDot |
|
self.model.setFilter(QtCore.QDir.Drives | QtCore.QDir.NoDotAndDotDot |
|
||||||
|
@ -180,6 +182,9 @@ class FilesDock(QtWidgets.QDockWidget):
|
||||||
dir = state.get("dir")
|
dir = state.get("dir")
|
||||||
if dir:
|
if dir:
|
||||||
self.select_dir(dir)
|
self.select_dir(dir)
|
||||||
|
if self.override_restore_file:
|
||||||
|
self.select_file(os.path.normpath(self.override_restore_file))
|
||||||
|
else:
|
||||||
file = state.get("file")
|
file = state.get("file")
|
||||||
if file:
|
if file:
|
||||||
self.select_file(file)
|
self.select_file(file)
|
||||||
|
|
|
@ -21,10 +21,12 @@ def get_argparser():
|
||||||
default_db_file = os.path.expanduser("~/.artiq_browser.pyon")
|
default_db_file = os.path.expanduser("~/.artiq_browser.pyon")
|
||||||
|
|
||||||
parser = argparse.ArgumentParser(description="ARTIQ Browser")
|
parser = argparse.ArgumentParser(description="ARTIQ Browser")
|
||||||
parser.add_argument(
|
parser.add_argument("--db-file", default=default_db_file,
|
||||||
"--db-file", default=default_db_file,
|
|
||||||
help="database file for local browser settings "
|
help="database file for local browser settings "
|
||||||
"(default: %(default)s)")
|
"(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")
|
parser.add_argument("PATH", nargs="?", help="browse path or file")
|
||||||
verbosity_args(parser)
|
verbosity_args(parser)
|
||||||
return parser
|
return parser
|
||||||
|
@ -90,7 +92,8 @@ def main():
|
||||||
status_bar = QtWidgets.QStatusBar()
|
status_bar = QtWidgets.QStatusBar()
|
||||||
main_window.setStatusBar(status_bar)
|
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)
|
smgr.register(d_files)
|
||||||
|
|
||||||
d_applets = applets.AppletsDock(main_window, datasets_sub)
|
d_applets = applets.AppletsDock(main_window, datasets_sub)
|
||||||
|
@ -124,9 +127,6 @@ def main():
|
||||||
# run
|
# run
|
||||||
main_window.show()
|
main_window.show()
|
||||||
|
|
||||||
if args.PATH:
|
|
||||||
d_files.select_file(os.path.normpath(args.PATH))
|
|
||||||
|
|
||||||
loop.run_until_complete(main_window.exit_request.wait())
|
loop.run_until_complete(main_window.exit_request.wait())
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
|
Loading…
Reference in New Issue