From 43e0d04c8fdd4280139aa4388d824f4d2a9334d5 Mon Sep 17 00:00:00 2001 From: Lyubomir Ternavskiy <127299159+LyubomirT@users.noreply.github.com> Date: Sat, 27 Jul 2024 21:54:19 +0300 Subject: [PATCH] feat: Add toggleTheme function to enable light and dark mode --- main.py | 6 ++++++ ui.py | 2 ++ 2 files changed, 8 insertions(+) diff --git a/main.py b/main.py index c422d73..4509a94 100644 --- a/main.py +++ b/main.py @@ -84,6 +84,12 @@ def stop_typing(self): self.thread.wait() self.thread = None self.typing_finished() + + def toggleTheme(self): + if self.lightModeCheckBox.isChecked(): + self.setStyleSheet(open("style.css").read()) + else: + self.setStyleSheet(open("darkmode.css").read()) if __name__ == "__main__": app = QApplication(sys.argv) diff --git a/ui.py b/ui.py index 70ea574..8302fc8 100644 --- a/ui.py +++ b/ui.py @@ -92,6 +92,8 @@ def setupUi(self, MainWindow): self.lightModeCheckBox = QtWidgets.QCheckBox(self.horizontalLayoutWidget) self.lightModeCheckBox.setObjectName("lightModeCheckBox") + self.lightModeCheckBox.clicked.connect(self.toggleTheme) + self.lightModeCheckBox.setChecked(True) self.settingsLayout.addWidget(self.lightModeCheckBox) self.horizontalLayout.addLayout(self.settingsLayout)