diff --git a/.gitignore b/.gitignore index 48ad37c..ceeed0a 100644 --- a/.gitignore +++ b/.gitignore @@ -5,4 +5,5 @@ Virtual/ output/ dist/ dist.zip -language.txt \ No newline at end of file +language.txt +theme.txt \ No newline at end of file diff --git a/main.py b/main.py index 4509a94..97d0d0b 100644 --- a/main.py +++ b/main.py @@ -91,6 +91,16 @@ def toggleTheme(self): else: self.setStyleSheet(open("darkmode.css").read()) + self.save_theme_based_on_last_choice() + + def save_theme_based_on_last_choice(self): + if self.lightModeCheckBox.isChecked(): + with open("theme.txt", "w", encoding="utf-8") as f: + f.write("light") + else: + with open("theme.txt", "w", encoding="utf-8") as f: + f.write("dark") + if __name__ == "__main__": app = QApplication(sys.argv) app.setStyleSheet(open("style.css").read()) diff --git a/ui.py b/ui.py index 8302fc8..3f0c90c 100644 --- a/ui.py +++ b/ui.py @@ -105,6 +105,8 @@ def setupUi(self, MainWindow): self.update_ui_text() + self.load_theme_based_on_last_choice() + # set the current language of the dropdown to the saved language self.languageComboBox.setCurrentText(self.current_language) @@ -117,6 +119,18 @@ def load_translations(self): with open(os.path.join(translations_dir, filename), "r", encoding="utf-8") as f: self.translations[language_code] = json.load(f) self.languageComboBox.addItem(language_code) + + def load_theme_based_on_last_choice(self): + if not os.path.exists("theme.txt"): + return + with open("theme.txt", "r", encoding="utf-8") as f: + theme = f.read() + if theme == "dark": + self.lightModeCheckBox.setChecked(False) + self.toggleTheme() + if theme == "light": + self.lightModeCheckBox.setChecked(True) + self.toggleTheme() def change_language(self): self.current_language = self.languageComboBox.currentText()