Added hard types for getting settings values

This commit is contained in:
Brett Williams
2025-12-27 21:57:24 -06:00
parent 27c8d298ce
commit 1a18782598

View File

@@ -134,15 +134,15 @@ class SettingsWindow(QMainWindow):
render_settings_layout = QVBoxLayout() render_settings_layout = QVBoxLayout()
render_settings_layout.addWidget(QLabel("Restrict to render nodes with same:")) render_settings_layout.addWidget(QLabel("Restrict to render nodes with same:"))
require_same_engine_checkbox = QCheckBox("Renderer Version") require_same_engine_checkbox = QCheckBox("Renderer Version")
require_same_engine_checkbox.setChecked(bool(settings.value("render_require_same_engine_version", False))) require_same_engine_checkbox.setChecked(settings.value("render_require_same_engine_version", False, type=bool))
require_same_engine_checkbox.stateChanged.connect(lambda state: settings.setValue("render_require_same_engine_version", bool(state))) require_same_engine_checkbox.stateChanged.connect(lambda state: settings.setValue("render_require_same_engine_version", bool(state)))
render_settings_layout.addWidget(require_same_engine_checkbox) render_settings_layout.addWidget(require_same_engine_checkbox)
require_same_cpu_checkbox = QCheckBox("CPU Architecture") require_same_cpu_checkbox = QCheckBox("CPU Architecture")
require_same_cpu_checkbox.setChecked(bool(settings.value("render_require_same_cpu_type", False))) require_same_cpu_checkbox.setChecked(settings.value("render_require_same_cpu_type", False, type=bool))
require_same_cpu_checkbox.stateChanged.connect(lambda state: settings.setValue("render_require_same_cpu_type", bool(state))) require_same_cpu_checkbox.stateChanged.connect(lambda state: settings.setValue("render_require_same_cpu_type", bool(state)))
render_settings_layout.addWidget(require_same_cpu_checkbox) render_settings_layout.addWidget(require_same_cpu_checkbox)
require_same_os_checkbox = QCheckBox("Operating System") require_same_os_checkbox = QCheckBox("Operating System")
require_same_os_checkbox.setChecked(bool(settings.value("render_require_same_os", False))) require_same_os_checkbox.setChecked(settings.value("render_require_same_os", False, type=bool))
require_same_os_checkbox.stateChanged.connect(lambda state: settings.setValue("render_require_same_os", bool(state))) require_same_os_checkbox.stateChanged.connect(lambda state: settings.setValue("render_require_same_os", bool(state)))
render_settings_layout.addWidget(require_same_os_checkbox) render_settings_layout.addWidget(require_same_os_checkbox)
render_settings_group.setLayout(render_settings_layout) render_settings_group.setLayout(render_settings_layout)
@@ -165,23 +165,23 @@ class SettingsWindow(QMainWindow):
sharing_layout = QVBoxLayout() sharing_layout = QVBoxLayout()
enable_sharing_checkbox = QCheckBox("Enable other computers on the network to render to this machine") enable_sharing_checkbox = QCheckBox("Enable other computers on the network to render to this machine")
enable_sharing_checkbox.setChecked(settings.value("enable_network_sharing", False)) enable_sharing_checkbox.setChecked(settings.value("enable_network_sharing", False, type=bool))
enable_sharing_checkbox.stateChanged.connect(self.toggle_render_sharing) enable_sharing_checkbox.stateChanged.connect(self.toggle_render_sharing)
sharing_layout.addWidget(enable_sharing_checkbox) sharing_layout.addWidget(enable_sharing_checkbox)
password_layout = QHBoxLayout() password_layout = QHBoxLayout()
password_layout.setContentsMargins(0, 0, 0, 0) password_layout.setContentsMargins(0, 0, 0, 0)
self.enable_network_password_checkbox = QCheckBox("Enable network password:") self.enable_network_password_checkbox = QCheckBox("Enable network password:")
self.enable_network_password_checkbox.setChecked(settings.value("enable_network_password", False)) self.enable_network_password_checkbox.setChecked(settings.value("enable_network_password", False, type=bool))
self.enable_network_password_checkbox.stateChanged.connect(self.enable_network_password_changed) self.enable_network_password_checkbox.stateChanged.connect(self.enable_network_password_changed)
sharing_layout.addWidget(self.enable_network_password_checkbox) sharing_layout.addWidget(self.enable_network_password_checkbox)
self.network_password_line = QLineEdit() self.network_password_line = QLineEdit()
self.network_password_line.setPlaceholderText("Enter a password") self.network_password_line.setPlaceholderText("Enter a password")
self.network_password_line.setEchoMode(QLineEdit.EchoMode.Password) self.network_password_line.setEchoMode(QLineEdit.EchoMode.Password)
self.network_password_line.setEnabled(settings.value("enable_network_password", False)) self.network_password_line.setEnabled(settings.value("enable_network_password", False, type=bool))
password_layout.addWidget(self.network_password_line) password_layout.addWidget(self.network_password_line)
self.show_password_button = QPushButton("Show") self.show_password_button = QPushButton("Show")
self.show_password_button.setEnabled(settings.value("enable_network_password", False)) self.show_password_button.setEnabled(settings.value("enable_network_password", False, type=bool))
self.show_password_button.clicked.connect(self.show_password_button_pressed) self.show_password_button.clicked.connect(self.show_password_button_pressed)
password_layout.addWidget(self.show_password_button) password_layout.addWidget(self.show_password_button)
sharing_layout.addLayout(password_layout) sharing_layout.addLayout(password_layout)
@@ -197,7 +197,7 @@ class SettingsWindow(QMainWindow):
def toggle_render_sharing(self, enable_sharing): def toggle_render_sharing(self, enable_sharing):
settings.setValue("enable_network_sharing", enable_sharing) settings.setValue("enable_network_sharing", enable_sharing)
self.enable_network_password_checkbox.setEnabled(enable_sharing) self.enable_network_password_checkbox.setEnabled(enable_sharing)
enable_password = enable_sharing and settings.value("enable_network_password", False) enable_password = enable_sharing and settings.value("enable_network_password", False, type=bool)
self.network_password_line.setEnabled(enable_password) self.network_password_line.setEnabled(enable_password)
self.show_password_button.setEnabled(enable_password) self.show_password_button.setEnabled(enable_password)
@@ -228,7 +228,7 @@ class SettingsWindow(QMainWindow):
# Ignore system installs # Ignore system installs
engine_ignore_system_installs_checkbox = QCheckBox("Ignore system installs") engine_ignore_system_installs_checkbox = QCheckBox("Ignore system installs")
engine_ignore_system_installs_checkbox.setChecked(settings.value("engines_ignore_system_installs", False)) engine_ignore_system_installs_checkbox.setChecked(settings.value("engines_ignore_system_installs", False, type=bool))
engine_ignore_system_installs_checkbox.stateChanged.connect(self.change_ignore_system_installs) engine_ignore_system_installs_checkbox.stateChanged.connect(self.change_ignore_system_installs)
installed_layout.addWidget(engine_ignore_system_installs_checkbox) installed_layout.addWidget(engine_ignore_system_installs_checkbox)
@@ -256,7 +256,7 @@ class SettingsWindow(QMainWindow):
at_least_one_downloadable = False at_least_one_downloadable = False
for engine in EngineManager.downloadable_engines(): for engine in EngineManager.downloadable_engines():
engine_download_check = QCheckBox(engine.name()) engine_download_check = QCheckBox(engine.name())
is_checked = settings.value(f"engine_download-{engine.name()}", False) is_checked = settings.value(f"engine_download-{engine.name()}", False, type=bool)
at_least_one_downloadable |= is_checked at_least_one_downloadable |= is_checked
engine_download_check.setChecked(is_checked) engine_download_check.setChecked(is_checked)
# Capture the checkbox correctly using a default argument in lambda # Capture the checkbox correctly using a default argument in lambda
@@ -268,7 +268,7 @@ class SettingsWindow(QMainWindow):
engine_updates_layout.addLayout(engine_download_layout) engine_updates_layout.addLayout(engine_download_layout)
check_for_engine_updates_checkbox = QCheckBox("Check for new versions on launch") check_for_engine_updates_checkbox = QCheckBox("Check for new versions on launch")
check_for_engine_updates_checkbox.setChecked(settings.value('check_for_engine_updates_on_launch', True)) check_for_engine_updates_checkbox.setChecked(settings.value('check_for_engine_updates_on_launch', True, type=bool))
check_for_engine_updates_checkbox.setEnabled(at_least_one_downloadable) check_for_engine_updates_checkbox.setEnabled(at_least_one_downloadable)
check_for_engine_updates_checkbox.stateChanged.connect( check_for_engine_updates_checkbox.stateChanged.connect(
lambda state: settings.setValue("check_for_engine_updates_on_launch", bool(state))) lambda state: settings.setValue("check_for_engine_updates_on_launch", bool(state)))
@@ -310,7 +310,7 @@ class SettingsWindow(QMainWindow):
at_least_one_downloadable = False at_least_one_downloadable = False
for engine in EngineManager.downloadable_engines(): for engine in EngineManager.downloadable_engines():
at_least_one_downloadable |= settings.value(f"engine_download-{engine.name()}", False) at_least_one_downloadable |= settings.value(f"engine_download-{engine.name()}", False, type=bool)
self.check_for_new_engines_button.setEnabled(at_least_one_downloadable) self.check_for_new_engines_button.setEnabled(at_least_one_downloadable)
self.check_for_engine_updates_checkbox.setEnabled(at_least_one_downloadable) self.check_for_engine_updates_checkbox.setEnabled(at_least_one_downloadable)
self.engines_last_update_label.setEnabled(at_least_one_downloadable) self.engines_last_update_label.setEnabled(at_least_one_downloadable)
@@ -356,10 +356,10 @@ class SettingsWindow(QMainWindow):
def check_for_new_engines(self): def check_for_new_engines(self):
ignore_system = settings.value("engines_ignore_system_installs", False) ignore_system = settings.value("engines_ignore_system_installs", False, type=bool)
messagebox_shown = False messagebox_shown = False
for engine in EngineManager.downloadable_engines(): for engine in EngineManager.downloadable_engines():
if settings.value(f'engine_download-{engine.name()}', False): if settings.value(f'engine_download-{engine.name()}', False, type=bool):
result = EngineManager.is_engine_update_available(engine, ignore_system_installs=ignore_system) result = EngineManager.is_engine_update_available(engine, ignore_system_installs=ignore_system)
if result: if result:
result['name'] = engine.name() result['name'] = engine.name()
@@ -432,7 +432,7 @@ class EngineTableWidget(QWidget):
for _, engine_data in self.raw_server_data.items(): for _, engine_data in self.raw_server_data.items():
table_data.extend(engine_data['versions']) table_data.extend(engine_data['versions'])
if settings.value("engines_ignore_system_installs", False): if settings.value("engines_ignore_system_installs", False, type=bool):
table_data = [x for x in table_data if x['type'] != 'system'] table_data = [x for x in table_data if x['type'] != 'system']
self.table.clear() self.table.clear()