diff options
author | SIDDHANT DIXIT <siddhant.dixit23@gmail.com> | 2021-07-19 18:27:02 +0530 |
---|---|---|
committer | SIDDHANT DIXIT <siddhant.dixit23@gmail.com> | 2021-07-19 18:27:02 +0530 |
commit | 3cbe55916bdd2ace57b4603764c97cea7a864d2e (patch) | |
tree | d51a2b64343b60c4b3625befb113eb016b135d82 /desktop | |
parent | 76e7880702a83b89b2296a38d116b1c22159366c (diff) | |
download | onionshare-3cbe55916bdd2ace57b4603764c97cea7a864d2e.tar.gz onionshare-3cbe55916bdd2ace57b4603764c97cea7a864d2e.zip |
Added user theme preference option in Settings
Added an option to choose theme in settings dialog like auto, light and dark.
Fixed Dark Mode Dark Text.
Diffstat (limited to 'desktop')
-rw-r--r-- | desktop/src/onionshare/__init__.py | 21 | ||||
-rw-r--r-- | desktop/src/onionshare/gui_common.py | 2 | ||||
-rw-r--r-- | desktop/src/onionshare/resources/locale/en.json | 4 | ||||
-rw-r--r-- | desktop/src/onionshare/settings_dialog.py | 23 |
4 files changed, 45 insertions, 5 deletions
diff --git a/desktop/src/onionshare/__init__.py b/desktop/src/onionshare/__init__.py index 8276dae4..815dff0b 100644 --- a/desktop/src/onionshare/__init__.py +++ b/desktop/src/onionshare/__init__.py @@ -29,6 +29,7 @@ import getpass from PySide2 import QtCore, QtWidgets, QtGui from onionshare_cli.common import Common +from onionshare_cli.settings import Settings from .gui_common import GuiCommon from .widgets import Alert @@ -47,7 +48,8 @@ class Application(QtWidgets.QApplication): QtWidgets.QApplication.__init__(self, sys.argv) # Check color mode on starting the app - self.color_mode = self.get_color_mode() + # self.color_mode = self.get_color_mode() + self.color_mode = self.get_color_mode(common) self.installEventFilter(self) def eventFilter(self, obj, event): @@ -65,9 +67,20 @@ class Application(QtWidgets.QApplication): return False return True - def get_color_mode(self): - return "dark" if self.is_dark_mode() else "light" - + def get_color_mode(self, common): + # return "dark" if self.is_dark_mode() else "light" + curr_settings = Settings(common) + curr_settings.load() + current_theme = curr_settings.get("theme") + + if current_theme == 0: + return "dark" if self.is_dark_mode() else "light" + elif current_theme == 1: + return "light" + elif current_theme == 2: + return "dark" + else: + return "light" def main(): """ diff --git a/desktop/src/onionshare/gui_common.py b/desktop/src/onionshare/gui_common.py index 441aff25..3cc353cf 100644 --- a/desktop/src/onionshare/gui_common.py +++ b/desktop/src/onionshare/gui_common.py @@ -89,7 +89,7 @@ class GuiCommon: new_tab_button_text_color = "#4e0d4e" if color_mode == "dark": header_color = "#F2F2F2" - title_color = "#F2F2F2" + # title_color = "#F2F2F2" stop_button_color = "#C32F2F" new_tab_button_background = "#5F5F5F" new_tab_button_border = "#878787" diff --git a/desktop/src/onionshare/resources/locale/en.json b/desktop/src/onionshare/resources/locale/en.json index 0eacc618..3a5c2ecd 100644 --- a/desktop/src/onionshare/resources/locale/en.json +++ b/desktop/src/onionshare/resources/locale/en.json @@ -115,6 +115,10 @@ "gui_receive_mode_warning": "Receive mode lets people upload files to your computer.<br><br><b>Some files can potentially take control of your computer if you open them. Only open things from people you trust, or if you know what you are doing.</b>", "gui_open_folder_error": "Failed to open folder with xdg-open. The file is here: {}", "gui_settings_language_label": "Preferred language", + "gui_settings_theme_label": "Theme", + "gui_settings_theme_auto": "Auto", + "gui_settings_theme_light": "Light", + "gui_settings_theme_dark": "Dark", "gui_settings_language_changed_notice": "Restart OnionShare for the new language to be applied.", "gui_color_mode_changed_notice": "Restart OnionShare for the new color mode to be applied.", "systray_menu_exit": "Quit", diff --git a/desktop/src/onionshare/settings_dialog.py b/desktop/src/onionshare/settings_dialog.py index 190ae35d..72cc7fab 100644 --- a/desktop/src/onionshare/settings_dialog.py +++ b/desktop/src/onionshare/settings_dialog.py @@ -123,6 +123,20 @@ class SettingsDialog(QtWidgets.QDialog): language_layout.addWidget(self.language_combobox) language_layout.addStretch() + #Theme Settings + theme_label = QtWidgets.QLabel(strings._("gui_settings_theme_label")) + self.theme_combobox = QtWidgets.QComboBox() + theme_choices = [ + strings._("gui_settings_theme_auto"), + strings._("gui_settings_theme_light"), + strings._("gui_settings_theme_dark") + ] + self.theme_combobox.addItems(theme_choices) + theme_layout = QtWidgets.QHBoxLayout() + theme_layout.addWidget(theme_label) + theme_layout.addWidget(self.theme_combobox) + theme_layout.addStretch() + # Connection type: either automatic, control port, or socket file # Bundled Tor @@ -451,6 +465,8 @@ class SettingsDialog(QtWidgets.QDialog): layout.addSpacing(20) layout.addLayout(language_layout) layout.addSpacing(20) + layout.addLayout(theme_layout) + layout.addSpacing(20) layout.addStretch() layout.addLayout(buttons_layout) @@ -477,6 +493,9 @@ class SettingsDialog(QtWidgets.QDialog): locale_index = self.language_combobox.findData(locale) self.language_combobox.setCurrentIndex(locale_index) + theme_choice = self.old_settings.get("theme") + self.theme_combobox.setCurrentIndex(theme_choice) + connection_type = self.old_settings.get("connection_type") if connection_type == "bundled": if self.connection_type_bundled_radio.isEnabled(): @@ -931,6 +950,10 @@ class SettingsDialog(QtWidgets.QDialog): settings = Settings(self.common) settings.load() # To get the last update timestamp + # Theme + theme_index = self.theme_combobox.currentIndex() + settings.set("theme",theme_index) + # Language locale_index = self.language_combobox.currentIndex() locale = self.language_combobox.itemData(locale_index) |