Fix locale and update pylint test
This commit is contained in:
parent
ba05cf3d2e
commit
b951c1af5f
2 changed files with 13 additions and 5 deletions
1
.github/workflows/tests.yml
vendored
1
.github/workflows/tests.yml
vendored
|
@ -79,6 +79,7 @@ jobs:
|
||||||
python -m pip install --upgrade pip
|
python -m pip install --upgrade pip
|
||||||
pip install pylint
|
pip install pylint
|
||||||
pip install -r requirements.txt
|
pip install -r requirements.txt
|
||||||
|
python legendary/setup.py install
|
||||||
- name: Analysing the code with pylint
|
- name: Analysing the code with pylint
|
||||||
run: |
|
run: |
|
||||||
pylint -E rare --disable=E0611 --ignore=ui,singleton.py --extension-pkg-whitelist=PyQt5
|
pylint -E rare --disable=E0611 --ignore=ui,singleton.py --extension-pkg-whitelist=PyQt5
|
||||||
|
|
|
@ -84,19 +84,26 @@ class LegendarySettings(QWidget, Ui_LegendarySettings):
|
||||||
self.enable_sync_button.clicked.connect(self.enable_sync)
|
self.enable_sync_button.clicked.connect(self.enable_sync)
|
||||||
self.sync_once_button.clicked.connect(self.core.egl_sync)
|
self.sync_once_button.clicked.connect(self.core.egl_sync)
|
||||||
|
|
||||||
self.locale_lineedit.setText(self.core.lgd.config.get("Legendary", "locale"))
|
self.locale_lineedit.setText(f"{self.core.language_code}-{self.core.country_code}")
|
||||||
|
|
||||||
self.locale_lineedit.textChanged.connect(self.save_locale)
|
self.locale_lineedit.textChanged.connect(self.save_locale)
|
||||||
|
|
||||||
def save_locale(self, text):
|
def save_locale(self, text: str):
|
||||||
if re.match("^[a-z]{2,3}-[A-Z]{2,3}$", text):
|
if re.match("^[a-z]{2,3}-[A-Z]{2,3}$", text):
|
||||||
self.core.egs.language_code = text[:2]
|
self.core.egs.language_code = text.split("-")[0]
|
||||||
self.core.egs.country_code = text[-2:]
|
self.core.egs.country_code = text.split("-")[1]
|
||||||
self.core.lgd.config.set("Legendary", "locale", text)
|
self.core.lgd.config.set("Legendary", "locale", text)
|
||||||
self.core.lgd.save_config()
|
self.core.lgd.save_config()
|
||||||
self.indicator_label.setPixmap(icon("ei.ok-sign", color="green").pixmap(16, 16))
|
self.indicator_label.setPixmap(icon("ei.ok-sign", color="green").pixmap(16, 16))
|
||||||
elif re.match("^[a-zA-Z]{2,3}[-_][a-zA-Z]{2,3}$", text):
|
elif re.match("^[a-zA-Z]{2,3}[-_][a-zA-Z]{2,3}$", text):
|
||||||
self.locale_lineedit.setText(text[:2].lower() + "-" + text[-2:].upper())
|
text = text.replace("_", "-")
|
||||||
|
# changing text triggers text changed signal
|
||||||
|
self.locale_lineedit.setText(text.split("-")[0].lower() + "-" + text.split("-")[1].upper())
|
||||||
|
elif text == "":
|
||||||
|
if self.core.lgd.config.has_option("Legendary", "locale"):
|
||||||
|
self.core.lgd.config.remove_option("Legendary", "locale")
|
||||||
|
self.core.lgd.save_config()
|
||||||
|
self.indicator_label.setPixmap(icon("ei.ok-sign", color="green").pixmap(16, 16))
|
||||||
else:
|
else:
|
||||||
self.indicator_label.setPixmap(icon("fa.warning", color="red").pixmap(16, 16))
|
self.indicator_label.setPixmap(icon("fa.warning", color="red").pixmap(16, 16))
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue