mirror of
https://github.com/yusufipk/dikte.git
synced 2026-09-11 10:56:10 +00:00
Rebuild the settings window when the language changes
Saving already switched the language everywhere strings are made at the moment they are shown: the tray is rebuilt, the indicator and the message box translate as they speak. The settings window is the one place written once, at construction, so the window that took the new language was the one place still showing the old one, and a tooltip asked for a restart. Now the window remembers the language it was built in, and a save that changed it has the app replace the window: a fresh one comes up where the old one stood, on the same tab. The restart tooltip goes, having nothing left to excuse. Co-Authored-By: Claude Fable 5 <[email protected]>
This commit is contained in:
co-authored by
Claude Fable 5
parent
569fe7cea8
commit
c7b14ff84e
@@ -903,6 +903,7 @@ class Dikte:
|
|||||||
if self.settings_window is None:
|
if self.settings_window is None:
|
||||||
self.settings_window = SettingsWindow(self.conf, self.meetings)
|
self.settings_window = SettingsWindow(self.conf, self.meetings)
|
||||||
self.settings_window.applied.connect(self._apply_settings)
|
self.settings_window.applied.connect(self._apply_settings)
|
||||||
|
self.settings_window.language_changed.connect(self._reopen_settings)
|
||||||
self.settings_window.finished.connect(self._settings_closed)
|
self.settings_window.finished.connect(self._settings_closed)
|
||||||
self.settings_window.show()
|
self.settings_window.show()
|
||||||
self.settings_window.raise_()
|
self.settings_window.raise_()
|
||||||
@@ -912,6 +913,31 @@ class Dikte:
|
|||||||
# Don't drop the object while its own signal is still being delivered.
|
# Don't drop the object while its own signal is still being delivered.
|
||||||
QTimer.singleShot(0, lambda: setattr(self, "settings_window", None))
|
QTimer.singleShot(0, lambda: setattr(self, "settings_window", None))
|
||||||
|
|
||||||
|
def _reopen_settings(self):
|
||||||
|
"""Replace the settings window, so a language change reaches it too.
|
||||||
|
|
||||||
|
A save switches the language everywhere strings are made at the moment
|
||||||
|
they are shown: the tray is rebuilt, the indicator and the message box
|
||||||
|
translate as they speak. The settings window is the one place written
|
||||||
|
once, at construction, so the window that took the new language is the
|
||||||
|
one place still showing the old one. A fresh window comes up where the
|
||||||
|
old one stood, on the same tab.
|
||||||
|
"""
|
||||||
|
old = self.settings_window
|
||||||
|
if old is None:
|
||||||
|
return
|
||||||
|
tab = old.tabs.currentIndex()
|
||||||
|
geometry = old.geometry()
|
||||||
|
# Replaced rather than merely closed: left connected, _settings_closed
|
||||||
|
# would drop the reference to the new window a moment after it is made.
|
||||||
|
old.finished.disconnect(self._settings_closed)
|
||||||
|
old.close()
|
||||||
|
old.deleteLater()
|
||||||
|
self.settings_window = None
|
||||||
|
self.open_settings()
|
||||||
|
self.settings_window.tabs.setCurrentIndex(tab)
|
||||||
|
self.settings_window.setGeometry(geometry)
|
||||||
|
|
||||||
def _apply_local(self):
|
def _apply_local(self):
|
||||||
"""Pass the local settings on, and hold the models ready if asked to.
|
"""Pass the local settings on, and hold the models ready if asked to.
|
||||||
|
|
||||||
|
|||||||
@@ -158,8 +158,6 @@ TR = {
|
|||||||
"Automatic (system)": "Otomatik (sistem)",
|
"Automatic (system)": "Otomatik (sistem)",
|
||||||
"Turkish": "Türkçe",
|
"Turkish": "Türkçe",
|
||||||
"English": "İngilizce",
|
"English": "İngilizce",
|
||||||
"Restart Dikte for the language change to reach every window.":
|
|
||||||
"Dil değişikliğinin her pencereye işlemesi için Dikte'yi yeniden başlat.",
|
|
||||||
"Microphone": "Mikrofon",
|
"Microphone": "Mikrofon",
|
||||||
"Default microphone": "Varsayılan mikrofon",
|
"Default microphone": "Varsayılan mikrofon",
|
||||||
"Speech language": "Konuşma dili",
|
"Speech language": "Konuşma dili",
|
||||||
|
|||||||
+14
-3
@@ -21,6 +21,7 @@ from . import config as cfg
|
|||||||
from . import filetranscribe
|
from . import filetranscribe
|
||||||
from . import ggml
|
from . import ggml
|
||||||
from . import hotkey
|
from . import hotkey
|
||||||
|
from . import i18n
|
||||||
from . import ipc
|
from . import ipc
|
||||||
from . import meeting
|
from . import meeting
|
||||||
from . import paste
|
from . import paste
|
||||||
@@ -512,6 +513,10 @@ class LocalModelBox(QGroupBox):
|
|||||||
|
|
||||||
class SettingsWindow(QDialog):
|
class SettingsWindow(QDialog):
|
||||||
applied = pyqtSignal()
|
applied = pyqtSignal()
|
||||||
|
# A save changed the interface language. Every label below is translated
|
||||||
|
# as the window is built, so the change cannot reach this window: the
|
||||||
|
# owner replaces it with a fresh one instead.
|
||||||
|
language_changed = pyqtSignal()
|
||||||
|
|
||||||
_models_loaded = pyqtSignal(list, str)
|
_models_loaded = pyqtSignal(list, str)
|
||||||
_transcribe_models_loaded = pyqtSignal(list, str)
|
_transcribe_models_loaded = pyqtSignal(list, str)
|
||||||
@@ -533,6 +538,8 @@ class SettingsWindow(QDialog):
|
|||||||
self._key_fields = {}
|
self._key_fields = {}
|
||||||
self._testers = {}
|
self._testers = {}
|
||||||
self._shown_provider = ""
|
self._shown_provider = ""
|
||||||
|
# What _save compares against to know a rebuild is due.
|
||||||
|
self._built_language = i18n.language()
|
||||||
self.transcriber = FileTranscriber(conf, self)
|
self.transcriber = FileTranscriber(conf, self)
|
||||||
self.setWindowTitle(t("Dikte Settings"))
|
self.setWindowTitle(t("Dikte Settings"))
|
||||||
|
|
||||||
@@ -627,9 +634,6 @@ class SettingsWindow(QDialog):
|
|||||||
self.ui_language = QComboBox()
|
self.ui_language = QComboBox()
|
||||||
for label, code in UI_LANGUAGES:
|
for label, code in UI_LANGUAGES:
|
||||||
self.ui_language.addItem(t(label), code)
|
self.ui_language.addItem(t(label), code)
|
||||||
self.ui_language.setToolTip(
|
|
||||||
t("Restart Dikte for the language change to reach every window.")
|
|
||||||
)
|
|
||||||
form.addRow(t("Interface language"), self.ui_language)
|
form.addRow(t("Interface language"), self.ui_language)
|
||||||
|
|
||||||
self.mic = QComboBox()
|
self.mic = QComboBox()
|
||||||
@@ -1744,7 +1748,14 @@ class SettingsWindow(QDialog):
|
|||||||
print(f"dikte: could not trim the history ({exc})")
|
print(f"dikte: could not trim the history ({exc})")
|
||||||
self._load_history() # the trim may just have dropped rows from the list
|
self._load_history() # the trim may just have dropped rows from the list
|
||||||
self.applied.emit()
|
self.applied.emit()
|
||||||
|
# conf.save() has switched the language t() speaks, so the message box
|
||||||
|
# already answers in the new one; the labels around it were translated
|
||||||
|
# when the window was built and stay behind. Asking for the rebuild
|
||||||
|
# waits until the box is dismissed, so the window is not pulled out
|
||||||
|
# from under a dialog it is holding up.
|
||||||
QMessageBox.information(self, t("Dikte Settings"), t("Saved successfully."))
|
QMessageBox.information(self, t("Dikte Settings"), t("Saved successfully."))
|
||||||
|
if i18n.language() != self._built_language:
|
||||||
|
self.language_changed.emit()
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def _select_data(combo, value):
|
def _select_data(combo, value):
|
||||||
|
|||||||
Reference in New Issue
Block a user