diff --git a/src/designer/ui_mainwindow.ui b/src/designer/ui_mainwindow.ui
index 46e8d94..8a6721b 100644
--- a/src/designer/ui_mainwindow.ui
+++ b/src/designer/ui_mainwindow.ui
@@ -17,7 +17,7 @@
- MainWindow
+ HeadsetControl-Qt
diff --git a/src/headsetcontrol-qt.py b/src/headsetcontrol-qt.py
index 7d4023d..51e20fc 100644
--- a/src/headsetcontrol-qt.py
+++ b/src/headsetcontrol-qt.py
@@ -63,7 +63,9 @@ def init_ui(self):
self.ui.notificationBatterySpinbox.valueChanged.connect(self.save_settings)
self.ui.startupCheckbox.stateChanged.connect(self.on_startup_checkbox_state_changed)
self.ui.sidetoneSlider.sliderReleased.connect(self.set_sidetone)
- self.ui.themeComboBox.addItems(["System", "Light", "Dark"])
+ self.ui.themeComboBox.addItem(self.tr("System"))
+ self.ui.themeComboBox.addItem(self.tr("Light"))
+ self.ui.themeComboBox.addItem(self.tr("Dark"))
self.ui.themeComboBox.currentIndexChanged.connect(self.on_themeComboBox_index_changed)
def create_tray_icon(self):
@@ -110,7 +112,7 @@ def load_settings(self):
self.ui.lightBatterySpinbox.setValue(settings.get("light_battery_threshold", 20))
self.ui.notificationBatterySpinbox.setValue(settings.get("notification_battery_threshold", 20))
self.ui.sidetoneSlider.setValue(settings.get("sidetone", 0))
- self.ui.themeComboBox.setCurrentText(settings.get("theme", "System"))
+ self.ui.themeComboBox.setCurrentIndex(settings.get("theme", 0))
def save_settings(self):
settings = {
@@ -118,7 +120,7 @@ def save_settings(self):
"light_battery_threshold": self.ui.lightBatterySpinbox.value(),
"notification_battery_threshold": self.ui.notificationBatterySpinbox.value(),
"sidetone": self.ui.sidetoneSlider.value(),
- "theme": self.ui.themeComboBox.currentText(),
+ "theme": self.ui.themeComboBox.currentIndex(),
}
with open(SETTINGS_FILE, "w") as f:
json.dump(settings, f, indent=4)
@@ -253,7 +255,8 @@ def update_ui_with_headset_info(self, headset_info):
def get_battery_icon(self, battery_level, charging=False, missing=False):
theme = None
- if self.ui.themeComboBox.currentText() == "System":
+ print(self.ui.themeComboBox.currentIndex())
+ if self.ui.themeComboBox.currentIndex() == 0:
if sys.platform == "win32":
dark_mode = darkdetect.isDark()
theme = "light" if dark_mode else "dark"
@@ -263,13 +266,14 @@ def get_battery_icon(self, battery_level, charging=False, missing=False):
else:
# I cannot detect every desktop and settings, so assume user is using dark theme and use light icons
theme = "light"
- elif self.ui.themeComboBox.currentText() == "Light":
+ elif self.ui.themeComboBox.currentIndex() == 1:
theme = "light"
- elif self.ui.themeComboBox.currentText() == "Dark":
+ elif self.ui.themeComboBox.currentIndex() == 2:
theme = "dark"
if missing:
icon_name = f"battery-missing-{theme}"
+ print(icon_name)
elif charging:
icon_name = f"battery-100-charging-{theme}"
else:
@@ -398,6 +402,7 @@ def check_startup_checkbox(self):
translator = QTranslator()
locale_name = QLocale.system().name()
locale = locale_name[:2]
+ locale = "fr"
if locale:
file_name = f"tr/headsetcontrol-qt_{locale}.qm"
else:
diff --git a/src/tr/headsetcontrol-qt_de.qm b/src/tr/headsetcontrol-qt_de.qm
new file mode 100644
index 0000000..be651ee
--- /dev/null
+++ b/src/tr/headsetcontrol-qt_de.qm
@@ -0,0 +1 @@
+<¸dÊÍ!¿`¡½Ý
\ No newline at end of file
diff --git a/src/tr/headsetcontrol-qt_de.ts b/src/tr/headsetcontrol-qt_de.ts
index 7812ad9..eff36a0 100644
--- a/src/tr/headsetcontrol-qt_de.ts
+++ b/src/tr/headsetcontrol-qt_de.ts
@@ -1,11 +1,29 @@
+
+ HeadsetControlApp
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
HeadsetControlQt
-
+
diff --git a/src/tr/headsetcontrol-qt_en.qm b/src/tr/headsetcontrol-qt_en.qm
new file mode 100644
index 0000000..22337ed
Binary files /dev/null and b/src/tr/headsetcontrol-qt_en.qm differ
diff --git a/src/tr/headsetcontrol-qt_en.ts b/src/tr/headsetcontrol-qt_en.ts
index 7812ad9..cb4a14d 100644
--- a/src/tr/headsetcontrol-qt_en.ts
+++ b/src/tr/headsetcontrol-qt_en.ts
@@ -1,63 +1,81 @@
-
-
+
+
+ HeadsetControlApp
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
HeadsetControlQt
-
-
-
+
+
+
-
-
-
+
+
+
-
-
-
+
+
+
-
-
-
+
+
+
-
-
-
+
+
+
-
-
-
+
+
+
-
-
-
+
+
+
-
-
-
+
+
+
-
-
-
+
+
+
-
-
-
-
+
+
+
+
-
-
-
+
+
+
-
+
diff --git a/src/tr/headsetcontrol-qt_es.qm b/src/tr/headsetcontrol-qt_es.qm
new file mode 100644
index 0000000..be651ee
--- /dev/null
+++ b/src/tr/headsetcontrol-qt_es.qm
@@ -0,0 +1 @@
+<¸dÊÍ!¿`¡½Ý
\ No newline at end of file
diff --git a/src/tr/headsetcontrol-qt_es.ts b/src/tr/headsetcontrol-qt_es.ts
index 7812ad9..eff36a0 100644
--- a/src/tr/headsetcontrol-qt_es.ts
+++ b/src/tr/headsetcontrol-qt_es.ts
@@ -1,11 +1,29 @@
+
+ HeadsetControlApp
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
HeadsetControlQt
-
+
diff --git a/src/tr/headsetcontrol-qt_fr.qm b/src/tr/headsetcontrol-qt_fr.qm
new file mode 100644
index 0000000..cf51350
Binary files /dev/null and b/src/tr/headsetcontrol-qt_fr.qm differ
diff --git a/src/tr/headsetcontrol-qt_fr.ts b/src/tr/headsetcontrol-qt_fr.ts
index 7812ad9..65a1508 100644
--- a/src/tr/headsetcontrol-qt_fr.ts
+++ b/src/tr/headsetcontrol-qt_fr.ts
@@ -1,63 +1,81 @@
-
-
+
+
+ HeadsetControlApp
+
+
+
+ Système
+
+
+
+
+ Clair
+
+
+
+
+ Sombre
+
+
+
HeadsetControlQt
-
-
-
+
+
+
-
-
-
+
+
+ Aucun casque détécté.
-
-
-
+
+
+ Thème des icones
-
-
-
+
+
+ Lancer au démarrage
-
-
-
+
+
+ LEDs
-
-
-
+
+
+ Batterie
-
-
-
+
+
+ Retour voix
-
-
-
+
+
+ Désactiver les LEDs quand la batterie tombe sous:
-
-
-
+
+
+ Notifier quand la batterie tombe sous
-
-
-
-
+
+
+
+
-
-
-
+
+
+ Paramètres
-
+
diff --git a/src/ui_mainwindow.py b/src/ui_mainwindow.py
index 1dd7066..b09d8bb 100644
--- a/src/ui_mainwindow.py
+++ b/src/ui_mainwindow.py
@@ -1,4 +1,4 @@
-# Form implementation generated from reading ui file '.\designer\ui_mainwindow.ui'
+# Form implementation generated from reading ui file '.\src\designer\ui_mainwindow.ui'
#
# Created by: PyQt6 UI code generator 6.7.0
#
@@ -177,7 +177,7 @@ def setupUi(self, HeadsetControlQt):
def retranslateUi(self, HeadsetControlQt):
_translate = QtCore.QCoreApplication.translate
- HeadsetControlQt.setWindowTitle(_translate("HeadsetControlQt", "MainWindow"))
+ HeadsetControlQt.setWindowTitle(_translate("HeadsetControlQt", "HeadsetControl-Qt"))
self.notFoundLabel.setText(_translate("HeadsetControlQt", "No supported headset found."))
self.label.setText(_translate("HeadsetControlQt", "Icon theme"))
self.startupLabel.setText(_translate("HeadsetControlQt", "Run at startup"))
diff --git a/tr_script.py b/tr_script.py
new file mode 100644
index 0000000..c600392
--- /dev/null
+++ b/tr_script.py
@@ -0,0 +1,63 @@
+import argparse
+import subprocess
+
+
+PROJECT = "headsetcontrol-qt"
+
+
+def run_pylupdate():
+ try:
+ subprocess.run(
+ [
+ "pylupdate6.exe",
+ f"./src/{PROJECT}.py",
+ "./src/designer/ui_mainwindow.ui",
+ "-ts",
+ f"./src/tr/{PROJECT}_fr.ts",
+ "-ts",
+ f"./src/tr/{PROJECT}_de.ts",
+ "-ts",
+ f"./src/tr/{PROJECT}_es.ts",
+ "-ts",
+ f"./src/tr/{PROJECT}_en.ts",
+ ],
+ check=True,
+ )
+ print("pylupdate6 executed successfully.")
+ except subprocess.CalledProcessError as e:
+ print(f"Error running pylupdate6: {e}")
+
+
+def run_lrelease():
+ try:
+ subprocess.run(
+ [
+ "lrelease.exe",
+ f"./src/tr/{PROJECT}_de.ts",
+ f"./src/tr/{PROJECT}_en.ts",
+ f"./src/tr/{PROJECT}_es.ts",
+ f"./src/tr/{PROJECT}_fr.ts",
+ ],
+ check=True,
+ )
+ print("lrelease executed successfully.")
+ except subprocess.CalledProcessError as e:
+ print(f"Error running lrelease: {e}")
+
+
+def main():
+ parser = argparse.ArgumentParser(description="Run pylupdate6 or lrelease.")
+ group = parser.add_mutually_exclusive_group(required=True)
+ group.add_argument("--generate", "-g", action="store_true", help="Run pylupdate6")
+ group.add_argument("--compile", "-c", action="store_true", help="Run lrelease")
+
+ args = parser.parse_args()
+
+ if args.generate:
+ run_pylupdate()
+ elif args.compile:
+ run_lrelease()
+
+
+if __name__ == "__main__":
+ main()