🛠️ Values for options passed via command line will be converted to int if necessary. Fixes #83
Settings save fix after refactoring to `StrEnum`.
This commit is contained in:
@@ -34,6 +34,11 @@ class BaseConfig:
|
|||||||
f.write(data_json)
|
f.write(data_json)
|
||||||
|
|
||||||
def set_option(self, key: str, value: Any) -> None:
|
def set_option(self, key: str, value: Any) -> None:
|
||||||
|
tmp_data: Any = getattr(self.data, key)
|
||||||
|
|
||||||
|
if isinstance(tmp_data, int) and not isinstance(value, int):
|
||||||
|
value = int(value)
|
||||||
|
|
||||||
setattr(self.data, key, value)
|
setattr(self.data, key, value)
|
||||||
|
|
||||||
def read(self, path: str) -> bool:
|
def read(self, path: str) -> bool:
|
||||||
|
|||||||
+5
-3
@@ -2,6 +2,7 @@ import math
|
|||||||
import sys
|
import sys
|
||||||
import time
|
import time
|
||||||
from collections.abc import Callable
|
from collections.abc import Callable
|
||||||
|
from enum import Enum
|
||||||
|
|
||||||
from requests.exceptions import HTTPError
|
from requests.exceptions import HTTPError
|
||||||
|
|
||||||
@@ -297,12 +298,13 @@ class MainWindow(QtWidgets.QMainWindow, Ui_MainWindow):
|
|||||||
|
|
||||||
def apply_settings(self, settings: Settings):
|
def apply_settings(self, settings: Settings):
|
||||||
l_cb = [
|
l_cb = [
|
||||||
{"element": self.cb_quality_audio, "setting": settings.data.quality_audio.name, "default_id": 1},
|
{"element": self.cb_quality_audio, "setting": settings.data.quality_audio, "default_id": 1},
|
||||||
{"element": self.cb_quality_video, "setting": settings.data.quality_video.name, "default_id": 0},
|
{"element": self.cb_quality_video, "setting": settings.data.quality_video, "default_id": 0},
|
||||||
]
|
]
|
||||||
|
|
||||||
for item in l_cb:
|
for item in l_cb:
|
||||||
idx = item["element"].findText(item["setting"])
|
needle: str | int = item["setting"].name if isinstance(item["setting"], Enum) else item["setting"]
|
||||||
|
idx = item["element"].findText(needle)
|
||||||
|
|
||||||
if idx > -1:
|
if idx > -1:
|
||||||
item["element"].setCurrentIndex(idx)
|
item["element"].setCurrentIndex(idx)
|
||||||
|
|||||||
Reference in New Issue
Block a user