Add locale settings
This commit is contained in:
parent
c07992b982
commit
c1338b7526
|
@ -1,9 +1,12 @@
|
|||
import os.path
|
||||
import platform
|
||||
import re
|
||||
from logging import getLogger
|
||||
|
||||
from PyQt5.QtCore import QSize
|
||||
from PyQt5.QtWidgets import QFileDialog, QMessageBox, QVBoxLayout, QDialog, QCheckBox, QLabel, \
|
||||
QHBoxLayout, QPushButton, QGroupBox, QWidget
|
||||
from qtawesome import icon
|
||||
|
||||
from legendary.core import LegendaryCore
|
||||
from rare.ui.components.tabs.settings.legendary import Ui_LegendarySettings
|
||||
|
@ -81,6 +84,22 @@ class LegendarySettings(QWidget, Ui_LegendarySettings):
|
|||
self.enable_sync_button.clicked.connect(self.enable_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.textChanged.connect(self.save_locale)
|
||||
|
||||
def save_locale(self, text):
|
||||
if re.match("^[a-z]{2}-[A-Z]{2}$", text):
|
||||
self.core.egs.language_code = text[:2]
|
||||
self.core.egs.country_code = text[-2:]
|
||||
self.core.lgd.config.set("Legendary", "locale", text)
|
||||
self.core.lgd.save_config()
|
||||
self.indicator_label.setPixmap(icon("ei.ok-sign", color="green").pixmap(16, 16))
|
||||
elif re.match("^[a-zA-Z]{2}[-_][a-zA-Z]{2}$", text):
|
||||
self.locale_lineedit.setText(text[:2].lower() + "-" + text[-2:].upper())
|
||||
else:
|
||||
self.indicator_label.setPixmap(icon("fa.warning", color="red").pixmap(16, 16))
|
||||
|
||||
def enable_sync(self):
|
||||
if not self.core.egl.programdata_path:
|
||||
if os.path.exists(path := self.manifest_path_edit.text()):
|
||||
|
|
|
@ -119,7 +119,7 @@ class Ui_LegendarySettings(object):
|
|||
self.export_scroll.setWidgetResizable(True)
|
||||
self.export_scroll.setObjectName("export_scroll")
|
||||
self.export_contents = QtWidgets.QWidget()
|
||||
self.export_contents.setGeometry(QtCore.QRect(0, 0, 264, 16))
|
||||
self.export_contents.setGeometry(QtCore.QRect(0, 0, 248, 18))
|
||||
sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Preferred, QtWidgets.QSizePolicy.Maximum)
|
||||
sizePolicy.setHorizontalStretch(0)
|
||||
sizePolicy.setVerticalStretch(0)
|
||||
|
@ -146,7 +146,7 @@ class Ui_LegendarySettings(object):
|
|||
self.import_scroll.setWidgetResizable(True)
|
||||
self.import_scroll.setObjectName("import_scroll")
|
||||
self.import_contents = QtWidgets.QWidget()
|
||||
self.import_contents.setGeometry(QtCore.QRect(0, 0, 264, 16))
|
||||
self.import_contents.setGeometry(QtCore.QRect(0, 0, 247, 18))
|
||||
sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Preferred, QtWidgets.QSizePolicy.Maximum)
|
||||
sizePolicy.setHorizontalStretch(0)
|
||||
sizePolicy.setVerticalStretch(0)
|
||||
|
@ -198,6 +198,34 @@ class Ui_LegendarySettings(object):
|
|||
self.egl_sync_button.setObjectName("egl_sync_button")
|
||||
self.egl_sync_layout_3.addWidget(self.egl_sync_button)
|
||||
self.right_layout.addWidget(self.egl_sync)
|
||||
self.locale_gb = QtWidgets.QGroupBox(LegendarySettings)
|
||||
sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Preferred, QtWidgets.QSizePolicy.Preferred)
|
||||
sizePolicy.setHorizontalStretch(0)
|
||||
sizePolicy.setVerticalStretch(0)
|
||||
sizePolicy.setHeightForWidth(self.locale_gb.sizePolicy().hasHeightForWidth())
|
||||
self.locale_gb.setSizePolicy(sizePolicy)
|
||||
self.locale_gb.setObjectName("locale_gb")
|
||||
self.horizontalLayout = QtWidgets.QHBoxLayout(self.locale_gb)
|
||||
self.horizontalLayout.setObjectName("horizontalLayout")
|
||||
self.locale_lineedit = QtWidgets.QLineEdit(self.locale_gb)
|
||||
sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Minimum, QtWidgets.QSizePolicy.Fixed)
|
||||
sizePolicy.setHorizontalStretch(0)
|
||||
sizePolicy.setVerticalStretch(0)
|
||||
sizePolicy.setHeightForWidth(self.locale_lineedit.sizePolicy().hasHeightForWidth())
|
||||
self.locale_lineedit.setSizePolicy(sizePolicy)
|
||||
self.locale_lineedit.setPlaceholderText("")
|
||||
self.locale_lineedit.setObjectName("locale_lineedit")
|
||||
self.horizontalLayout.addWidget(self.locale_lineedit)
|
||||
self.indicator_label = QtWidgets.QLabel(self.locale_gb)
|
||||
sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Maximum, QtWidgets.QSizePolicy.Preferred)
|
||||
sizePolicy.setHorizontalStretch(0)
|
||||
sizePolicy.setVerticalStretch(0)
|
||||
sizePolicy.setHeightForWidth(self.indicator_label.sizePolicy().hasHeightForWidth())
|
||||
self.indicator_label.setSizePolicy(sizePolicy)
|
||||
self.indicator_label.setText("")
|
||||
self.indicator_label.setObjectName("indicator_label")
|
||||
self.horizontalLayout.addWidget(self.indicator_label)
|
||||
self.right_layout.addWidget(self.locale_gb)
|
||||
spacerItem1 = QtWidgets.QSpacerItem(20, 40, QtWidgets.QSizePolicy.Minimum, QtWidgets.QSizePolicy.Expanding)
|
||||
self.right_layout.addItem(spacerItem1)
|
||||
self.settings_layout.addLayout(self.right_layout)
|
||||
|
@ -234,6 +262,7 @@ class Ui_LegendarySettings(object):
|
|||
self.clean_button.setText(_translate("LegendarySettings", "Remove everything"))
|
||||
self.egl_sync.setTitle(_translate("LegendarySettings", "EGL Sync"))
|
||||
self.egl_sync_button.setText(_translate("LegendarySettings", "Sync Settings"))
|
||||
self.locale_gb.setTitle(_translate("LegendarySettings", "Locale"))
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
|
|
@ -204,8 +204,8 @@
|
|||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>264</width>
|
||||
<height>16</height>
|
||||
<width>248</width>
|
||||
<height>18</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
|
@ -254,8 +254,8 @@
|
|||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>264</width>
|
||||
<height>16</height>
|
||||
<width>247</width>
|
||||
<height>18</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
|
@ -362,6 +362,47 @@
|
|||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QGroupBox" name="locale_gb">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="title">
|
||||
<string>Locale</string>
|
||||
</property>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<widget class="QLineEdit" name="locale_lineedit">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="placeholderText">
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="indicator_label">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Maximum" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="right_vspacer">
|
||||
<property name="orientation">
|
||||
|
|
Loading…
Reference in a new issue