Skip to content

Commit

Permalink
chore: Update window title to "Chainsaw Human Typing" and fix languag…
Browse files Browse the repository at this point in the history
…e selection
  • Loading branch information
LyubomirT committed Jul 27, 2024
1 parent 19436c6 commit 003154a
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 21 deletions.
5 changes: 2 additions & 3 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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())
Expand Down
22 changes: 4 additions & 18 deletions ui.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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 = {}
Expand All @@ -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"))
component.setText(item["text"])

0 comments on commit 003154a

Please sign in to comment.