mirror of
https://github.com/dcs-retribution/dcs-retribution.git
synced 2025-11-10 15:41:24 +00:00
Fix UI not updating properly after loading settings
This commit is contained in:
parent
7e9380162c
commit
d3e727f205
@ -2,7 +2,6 @@ import json
|
|||||||
import logging
|
import logging
|
||||||
import textwrap
|
import textwrap
|
||||||
import zipfile
|
import zipfile
|
||||||
from enum import Enum
|
|
||||||
from typing import Callable, Optional, Dict
|
from typing import Callable, Optional, Dict
|
||||||
|
|
||||||
from PySide2 import QtWidgets
|
from PySide2 import QtWidgets
|
||||||
@ -238,10 +237,10 @@ class AutoSettingsLayout(QGridLayout):
|
|||||||
if isinstance(widget, QCheckBox):
|
if isinstance(widget, QCheckBox):
|
||||||
widget.setChecked(value)
|
widget.setChecked(value)
|
||||||
elif isinstance(widget, QComboBox):
|
elif isinstance(widget, QComboBox):
|
||||||
if isinstance(value, Enum):
|
if (index := widget.findData(value)) > -1:
|
||||||
widget.setCurrentText(value.value)
|
widget.setCurrentIndex(index)
|
||||||
elif isinstance(value, str):
|
elif (index := widget.findText(value)) > -1:
|
||||||
widget.setCurrentText(value)
|
widget.setCurrentIndex(index)
|
||||||
else:
|
else:
|
||||||
logging.error(
|
logging.error(
|
||||||
f"Incompatible type '{type(value)}' for ComboBox option {name}"
|
f"Incompatible type '{type(value)}' for ComboBox option {name}"
|
||||||
@ -333,6 +332,8 @@ class QSettingsWidget(QtWidgets.QWizardPage, SettingsContainer):
|
|||||||
self.pluginsPage = PluginsPage(self)
|
self.pluginsPage = PluginsPage(self)
|
||||||
self.pluginsOptionsPage = PluginOptionsPage(self)
|
self.pluginsOptionsPage = PluginOptionsPage(self)
|
||||||
|
|
||||||
|
self.updating_ui = False
|
||||||
|
|
||||||
self.initUi()
|
self.initUi()
|
||||||
|
|
||||||
def initUi(self):
|
def initUi(self):
|
||||||
@ -442,6 +443,8 @@ class QSettingsWidget(QtWidgets.QWizardPage, SettingsContainer):
|
|||||||
GameUpdateSignal.get_instance().updateGame(self.game)
|
GameUpdateSignal.get_instance().updateGame(self.game)
|
||||||
|
|
||||||
def applySettings(self):
|
def applySettings(self):
|
||||||
|
if self.updating_ui:
|
||||||
|
return
|
||||||
self.settings.show_red_ato = self.cheat_options.show_red_ato
|
self.settings.show_red_ato = self.cheat_options.show_red_ato
|
||||||
self.settings.enable_frontline_cheats = self.cheat_options.show_frontline_cheat
|
self.settings.enable_frontline_cheats = self.cheat_options.show_frontline_cheat
|
||||||
self.settings.enable_base_capture_cheat = (
|
self.settings.enable_base_capture_cheat = (
|
||||||
@ -460,6 +463,7 @@ class QSettingsWidget(QtWidgets.QWizardPage, SettingsContainer):
|
|||||||
self.right_layout.setCurrentIndex(index)
|
self.right_layout.setCurrentIndex(index)
|
||||||
|
|
||||||
def update_from_settings(self) -> None:
|
def update_from_settings(self) -> None:
|
||||||
|
self.updating_ui = True
|
||||||
for p in self.pages.values():
|
for p in self.pages.values():
|
||||||
p.update_from_settings()
|
p.update_from_settings()
|
||||||
|
|
||||||
@ -477,6 +481,8 @@ class QSettingsWidget(QtWidgets.QWizardPage, SettingsContainer):
|
|||||||
self.pluginsPage.update_from_settings()
|
self.pluginsPage.update_from_settings()
|
||||||
self.pluginsOptionsPage.update_from_settings()
|
self.pluginsOptionsPage.update_from_settings()
|
||||||
|
|
||||||
|
self.updating_ui = False
|
||||||
|
|
||||||
def load_settings(self):
|
def load_settings(self):
|
||||||
sd = settings_dir()
|
sd = settings_dir()
|
||||||
if not sd.exists():
|
if not sd.exists():
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user