minor config stuf
This commit is contained in:
parent
894d980a64
commit
2285bb78c1
|
@ -154,8 +154,8 @@ class MainWindow(QMainWindow):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
super().__init__()
|
super().__init__()
|
||||||
|
|
||||||
self.config_path = None
|
self.config_path = DEFAULT_CONFIG
|
||||||
with open(DEFAULT_CONFIG, "r") as f:
|
with open(self.config_path, "r") as f:
|
||||||
config = json.load(f)
|
config = json.load(f)
|
||||||
self._frequency = config["frequency"]
|
self._frequency = config["frequency"]
|
||||||
|
|
||||||
|
@ -234,11 +234,12 @@ class MainWindow(QMainWindow):
|
||||||
dialog.setAcceptMode(QFileDialog.AcceptMode.AcceptSave)
|
dialog.setAcceptMode(QFileDialog.AcceptMode.AcceptSave)
|
||||||
if dialog.exec():
|
if dialog.exec():
|
||||||
config_path = Path(dialog.selectedFiles()[0])
|
config_path = Path(dialog.selectedFiles()[0])
|
||||||
print(config_path)
|
|
||||||
if config_path.suffix != CONFIG_SUFFIX:
|
if config_path.suffix != CONFIG_SUFFIX:
|
||||||
raise ValueError(
|
raise ValueError(
|
||||||
f"{config_path.name} is not a valid configuration file. Must have extension {CONFIG_SUFFIX}"
|
f"{config_path.name} is not a valid configuration file. Must have extension {CONFIG_SUFFIX}"
|
||||||
)
|
)
|
||||||
|
if config_path == DEFAULT_CONFIG:
|
||||||
|
raise ValueError(f"Cannot overwrite default configuration file at {DEFAULT_CONFIG}")
|
||||||
self.config_path = config_path
|
self.config_path = config_path
|
||||||
print(f"Config path is now {self.config_path.resolve()}")
|
print(f"Config path is now {self.config_path.resolve()}")
|
||||||
|
|
||||||
|
@ -262,7 +263,7 @@ class MainWindow(QMainWindow):
|
||||||
self.load_config(self.config_path)
|
self.load_config(self.config_path)
|
||||||
|
|
||||||
def save_config(self) -> None:
|
def save_config(self) -> None:
|
||||||
if self.config_path is None:
|
if self.config_path == DEFAULT_CONFIG:
|
||||||
self.saveas_config()
|
self.saveas_config()
|
||||||
else:
|
else:
|
||||||
print(f"Saving config to {self.config_path.resolve()}")
|
print(f"Saving config to {self.config_path.resolve()}")
|
||||||
|
|
Loading…
Reference in New Issue
Block a user