feat(GUI): Integrate new config system

This commit is contained in:
Daniel S. 2019-09-28 15:49:09 +02:00
parent 0d89106b01
commit 22ca2d26a8

View file

@ -221,23 +221,13 @@ class ED_LRR(Ui_ED_LRR):
def __init__(self):
super().__init__()
self.config = cfg.load()
self.jobs = {}
def new_job(self, cls, *args, **kwargs):
print("CREATE JOB:", cls, args, kwargs)
name = cls.__name__
if name in self.jobs and self.jobs[name].done():
del self.jobs[name]
if not name in self.jobs:
self.jobs[name] = Job(self.app, self.main_window, cls, *args, **kwargs)
return self.jobs[name]
self.current_job = None
def get_open_file(self, filetypes, callback=None):
fileName, _ = QFileDialog.getOpenFileName(
self.main_window,
"Open file",
str(cfg.data_dir),
cfg["folders.data_dir"],
filetypes,
options=QFileDialog.DontUseNativeDialog,
)
@ -249,7 +239,7 @@ class ED_LRR(Ui_ED_LRR):
fileName, _ = QFileDialog.getSaveFileName(
self.main_window,
"Save file",
str(cfg.data_dir),
cfg["folders.data_dir"],
filetypes,
options=QFileDialog.DontUseNativeDialog,
)
@ -258,21 +248,21 @@ class ED_LRR(Ui_ED_LRR):
return fileName
def set_sys_lst(self, path):
if path not in self.config.history_out_path:
self.config.history_out_path.append(path)
if path not in cfg["history.out_path"]:
cfg["history.out_path"].append(path)
self.inp_sys_lst.addItem(path)
self.inp_out_pp.addItem(path)
self.inp_sys_lst.setCurrentText(path)
self.inp_out_pp.setCurrentText(path)
def set_bodies_file(self, path):
if path not in self.config.history_bodies_path:
self.config.history_bodies_path.append(path)
if path not in cfg["history.bodies_path"]:
cfg["history.bodies_path"].append(path)
self.inp_bodies_pp.addItem(path)
def set_systems_file(self, path):
if path not in self.config.history_systems_path:
self.config.history_systems_path.append(path)
if path not in cfg["history.systems_path"]:
cfg["history.systems_path"].append(path)
self.inp_systems_pp.addItem(path)
def update_dropdowns(self):
@ -552,7 +542,7 @@ class ED_LRR(Ui_ED_LRR):
)
def handle_close(self):
cfg.write(self.config)
cfg.sync()
print("BYEEEEEE!")
def setup_styles(self, win, app):