diff --git a/main.py b/main.py index 24d32d1..c422d73 100644 --- a/main.py +++ b/main.py @@ -38,6 +38,8 @@ def __init__(self): super().__init__() self.setupUi(self) self.setWindowFlags(self.windowFlags() | Qt.WindowStaysOnTopHint) + # set window title + self.setWindowTitle("Chainsaw Human Typing") self.startButton.clicked.connect(self.start_typing) self.stopButton.clicked.connect(self.stop_typing) self.languageComboBox.currentTextChanged.connect(self.change_language) @@ -83,9 +85,6 @@ def stop_typing(self): self.thread = None self.typing_finished() - def change_language(self, language): - self.update_ui_text() - if __name__ == "__main__": app = QApplication(sys.argv) app.setStyleSheet(open("style.css").read()) diff --git a/ui.py b/ui.py index 2bcf76b..029369d 100644 --- a/ui.py +++ b/ui.py @@ -83,6 +83,7 @@ def setupUi(self, MainWindow): self.languageComboBox = QtWidgets.QComboBox(self.horizontalLayoutWidget) self.languageComboBox.setObjectName("languageComboBox") + self.languageComboBox.currentTextChanged.connect(self.change_language) self.settingsLayout.addWidget(self.languageComboBox) self.lightModeCheckBox = QtWidgets.QCheckBox(self.horizontalLayoutWidget) @@ -92,15 +93,9 @@ def setupUi(self, MainWindow): self.horizontalLayout.addLayout(self.settingsLayout) MainWindow.setCentralWidget(self.centralwidget) - - self.retranslateUi(MainWindow) QtCore.QMetaObject.connectSlotsByName(MainWindow) - - def retranslateUi(self, MainWindow): + self.load_translations() - - self.languageComboBox.currentTextChanged.connect(self.change_language) - self.update_ui_text() def load_translations(self): self.translations = {} @@ -114,21 +109,12 @@ def load_translations(self): def change_language(self): self.current_language = self.languageComboBox.currentText() + print(f"Changed language to {self.current_language}") self.update_ui_text() def update_ui_text(self): - print(self.current_language) translation = self.translations.get(self.current_language, self.translations["English"]) for item in translation["MainWindow"]: component = getattr(self, item["component"], None) if component: - component.setText(item["text"]) - - _translate = QtCore.QCoreApplication.translate - self.delayLabel.setText(_translate("MainWindow", "Delay (seconds)")) - self.intervalLabel.setText(_translate("MainWindow", "Interval (seconds)")) - self.charPerStrokeLabel.setText(_translate("MainWindow", "Characters per stroke")) - self.enterCheckBox.setText(_translate("MainWindow", "Type Enter")) - self.startButton.setText(_translate("MainWindow", "Start")) - self.lightModeCheckBox.setText(_translate("MainWindow", "Light Mode")) - self.stopButton.setText(_translate("MainWindow", "Stop")) \ No newline at end of file + component.setText(item["text"]) \ No newline at end of file