Skip to content

Commit

Permalink
Completed FR and EN tr, use currentindex for themeComboBox instead of…
Browse files Browse the repository at this point in the history
… currenttext
  • Loading branch information
Odizinne committed Aug 7, 2024
1 parent 024f730 commit 5bfd59c
Show file tree
Hide file tree
Showing 12 changed files with 227 additions and 85 deletions.
2 changes: 1 addition & 1 deletion src/designer/ui_mainwindow.ui
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
</sizepolicy>
</property>
<property name="windowTitle">
<string>MainWindow</string>
<string>HeadsetControl-Qt</string>
</property>
<widget class="QWidget" name="centralwidget">
<layout class="QGridLayout" name="gridLayout_2">
Expand Down
17 changes: 11 additions & 6 deletions src/headsetcontrol-qt.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -110,15 +112,15 @@ 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 = {
"led_state": self.ui.ledBox.isChecked(),
"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)
Expand Down Expand Up @@ -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"
Expand All @@ -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:
Expand Down Expand Up @@ -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:
Expand Down
1 change: 1 addition & 0 deletions src/tr/headsetcontrol-qt_de.qm
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<�d��!�`���
20 changes: 19 additions & 1 deletion src/tr/headsetcontrol-qt_de.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,29 @@
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE TS>
<TS version="2.1">
<context>
<name>HeadsetControlApp</name>
<message>
<location filename="..\headsetcontrol-qt.py" line="66" />
<source>System</source>
<translation type="unfinished" />
</message>
<message>
<location filename="..\headsetcontrol-qt.py" line="67" />
<source>Light</source>
<translation type="unfinished" />
</message>
<message>
<location filename="..\headsetcontrol-qt.py" line="68" />
<source>Dark</source>
<translation type="unfinished" />
</message>
</context>
<context>
<name>HeadsetControlQt</name>
<message>
<location filename="..\designer\ui_mainwindow.ui" line="0" />
<source>MainWindow</source>
<source>HeadsetControl-Qt</source>
<translation type="unfinished" />
</message>
<message>
Expand Down
Binary file added src/tr/headsetcontrol-qt_en.qm
Binary file not shown.
92 changes: 55 additions & 37 deletions src/tr/headsetcontrol-qt_en.ts
Original file line number Diff line number Diff line change
@@ -1,63 +1,81 @@
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE TS>
<TS version="2.1">
<context>
<TS version="2.1" language="en_US">
<context>
<name>HeadsetControlApp</name>
<message>
<location filename="../headsetcontrol-qt.py" line="66"/>
<source>System</source>
<translation></translation>
</message>
<message>
<location filename="../headsetcontrol-qt.py" line="67"/>
<source>Light</source>
<translation></translation>
</message>
<message>
<location filename="../headsetcontrol-qt.py" line="68"/>
<source>Dark</source>
<translation></translation>
</message>
</context>
<context>
<name>HeadsetControlQt</name>
<message>
<location filename="..\designer\ui_mainwindow.ui" line="0" />
<source>MainWindow</source>
<translation type="unfinished" />
<location filename="../designer/ui_mainwindow.ui" line="0"/>
<source>HeadsetControl-Qt</source>
<translation></translation>
</message>
<message>
<location filename="..\designer\ui_mainwindow.ui" line="0" />
<source>No supported headset found.</source>
<translation type="unfinished" />
<location filename="../designer/ui_mainwindow.ui" line="0"/>
<source>No supported headset found.</source>
<translation></translation>
</message>
<message>
<location filename="..\designer\ui_mainwindow.ui" line="0" />
<source>Icon theme</source>
<translation type="unfinished" />
<location filename="../designer/ui_mainwindow.ui" line="0"/>
<source>Icon theme</source>
<translation></translation>
</message>
<message>
<location filename="..\designer\ui_mainwindow.ui" line="0" />
<source>Run at startup</source>
<translation type="unfinished" />
<location filename="../designer/ui_mainwindow.ui" line="0"/>
<source>Run at startup</source>
<translation></translation>
</message>
<message>
<location filename="..\designer\ui_mainwindow.ui" line="0" />
<source>Lights</source>
<translation type="unfinished" />
<location filename="../designer/ui_mainwindow.ui" line="0"/>
<source>Lights</source>
<translation></translation>
</message>
<message>
<location filename="..\designer\ui_mainwindow.ui" line="0" />
<source>Battery</source>
<translation type="unfinished" />
<location filename="../designer/ui_mainwindow.ui" line="0"/>
<source>Battery</source>
<translation></translation>
</message>
<message>
<location filename="..\designer\ui_mainwindow.ui" line="0" />
<source>Sidetone</source>
<translation type="unfinished" />
<location filename="../designer/ui_mainwindow.ui" line="0"/>
<source>Sidetone</source>
<translation></translation>
</message>
<message>
<location filename="..\designer\ui_mainwindow.ui" line="0" />
<source>Disable lights when battery goes below:</source>
<translation type="unfinished" />
<location filename="../designer/ui_mainwindow.ui" line="0"/>
<source>Disable lights when battery goes below:</source>
<translation></translation>
</message>
<message>
<location filename="..\designer\ui_mainwindow.ui" line="0" />
<source>Send notification when battery goes below</source>
<translation type="unfinished" />
<location filename="../designer/ui_mainwindow.ui" line="0"/>
<source>Send notification when battery goes below</source>
<translation></translation>
</message>
<message>
<location filename="..\designer\ui_mainwindow.ui" line="0" />
<location filename="..\designer\ui_mainwindow.ui" line="0" />
<source>TextLabel</source>
<translation type="unfinished" />
<location filename="../designer/ui_mainwindow.ui" line="0"/>
<location filename="../designer/ui_mainwindow.ui" line="0"/>
<source>TextLabel</source>
<translation></translation>
</message>
<message>
<location filename="..\designer\ui_mainwindow.ui" line="0" />
<source>General settings</source>
<translation type="unfinished" />
<location filename="../designer/ui_mainwindow.ui" line="0"/>
<source>General settings</source>
<translation></translation>
</message>
</context>
</context>
</TS>
1 change: 1 addition & 0 deletions src/tr/headsetcontrol-qt_es.qm
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<�d��!�`���
20 changes: 19 additions & 1 deletion src/tr/headsetcontrol-qt_es.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,29 @@
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE TS>
<TS version="2.1">
<context>
<name>HeadsetControlApp</name>
<message>
<location filename="..\headsetcontrol-qt.py" line="66" />
<source>System</source>
<translation type="unfinished" />
</message>
<message>
<location filename="..\headsetcontrol-qt.py" line="67" />
<source>Light</source>
<translation type="unfinished" />
</message>
<message>
<location filename="..\headsetcontrol-qt.py" line="68" />
<source>Dark</source>
<translation type="unfinished" />
</message>
</context>
<context>
<name>HeadsetControlQt</name>
<message>
<location filename="..\designer\ui_mainwindow.ui" line="0" />
<source>MainWindow</source>
<source>HeadsetControl-Qt</source>
<translation type="unfinished" />
</message>
<message>
Expand Down
Binary file added src/tr/headsetcontrol-qt_fr.qm
Binary file not shown.
92 changes: 55 additions & 37 deletions src/tr/headsetcontrol-qt_fr.ts
Original file line number Diff line number Diff line change
@@ -1,63 +1,81 @@
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE TS>
<TS version="2.1">
<context>
<TS version="2.1" language="fr_FR">
<context>
<name>HeadsetControlApp</name>
<message>
<location filename="../headsetcontrol-qt.py" line="66"/>
<source>System</source>
<translation>Système</translation>
</message>
<message>
<location filename="../headsetcontrol-qt.py" line="67"/>
<source>Light</source>
<translation>Clair</translation>
</message>
<message>
<location filename="../headsetcontrol-qt.py" line="68"/>
<source>Dark</source>
<translation>Sombre</translation>
</message>
</context>
<context>
<name>HeadsetControlQt</name>
<message>
<location filename="..\designer\ui_mainwindow.ui" line="0" />
<source>MainWindow</source>
<translation type="unfinished" />
<location filename="../designer/ui_mainwindow.ui" line="0"/>
<source>HeadsetControl-Qt</source>
<translation></translation>
</message>
<message>
<location filename="..\designer\ui_mainwindow.ui" line="0" />
<source>No supported headset found.</source>
<translation type="unfinished" />
<location filename="../designer/ui_mainwindow.ui" line="0"/>
<source>No supported headset found.</source>
<translation>Aucun casque détécté.</translation>
</message>
<message>
<location filename="..\designer\ui_mainwindow.ui" line="0" />
<source>Icon theme</source>
<translation type="unfinished" />
<location filename="../designer/ui_mainwindow.ui" line="0"/>
<source>Icon theme</source>
<translation>Thème des icones</translation>
</message>
<message>
<location filename="..\designer\ui_mainwindow.ui" line="0" />
<source>Run at startup</source>
<translation type="unfinished" />
<location filename="../designer/ui_mainwindow.ui" line="0"/>
<source>Run at startup</source>
<translation>Lancer au démarrage</translation>
</message>
<message>
<location filename="..\designer\ui_mainwindow.ui" line="0" />
<source>Lights</source>
<translation type="unfinished" />
<location filename="../designer/ui_mainwindow.ui" line="0"/>
<source>Lights</source>
<translation>LEDs</translation>
</message>
<message>
<location filename="..\designer\ui_mainwindow.ui" line="0" />
<source>Battery</source>
<translation type="unfinished" />
<location filename="../designer/ui_mainwindow.ui" line="0"/>
<source>Battery</source>
<translation>Batterie</translation>
</message>
<message>
<location filename="..\designer\ui_mainwindow.ui" line="0" />
<source>Sidetone</source>
<translation type="unfinished" />
<location filename="../designer/ui_mainwindow.ui" line="0"/>
<source>Sidetone</source>
<translation>Retour voix</translation>
</message>
<message>
<location filename="..\designer\ui_mainwindow.ui" line="0" />
<source>Disable lights when battery goes below:</source>
<translation type="unfinished" />
<location filename="../designer/ui_mainwindow.ui" line="0"/>
<source>Disable lights when battery goes below:</source>
<translation>Désactiver les LEDs quand la batterie tombe sous:</translation>
</message>
<message>
<location filename="..\designer\ui_mainwindow.ui" line="0" />
<source>Send notification when battery goes below</source>
<translation type="unfinished" />
<location filename="../designer/ui_mainwindow.ui" line="0"/>
<source>Send notification when battery goes below</source>
<translation>Notifier quand la batterie tombe sous</translation>
</message>
<message>
<location filename="..\designer\ui_mainwindow.ui" line="0" />
<location filename="..\designer\ui_mainwindow.ui" line="0" />
<source>TextLabel</source>
<translation type="unfinished" />
<location filename="../designer/ui_mainwindow.ui" line="0"/>
<location filename="../designer/ui_mainwindow.ui" line="0"/>
<source>TextLabel</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="..\designer\ui_mainwindow.ui" line="0" />
<source>General settings</source>
<translation type="unfinished" />
<location filename="../designer/ui_mainwindow.ui" line="0"/>
<source>General settings</source>
<translation>Paramètres</translation>
</message>
</context>
</context>
</TS>
4 changes: 2 additions & 2 deletions src/ui_mainwindow.py
Original file line number Diff line number Diff line change
@@ -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
#
Expand Down Expand Up @@ -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"))
Expand Down
Loading

0 comments on commit 5bfd59c

Please sign in to comment.