Sets text color and images based on the mac system color mode
| 
						 | 
				
			
			@ -27,7 +27,7 @@ import signal
 | 
			
		|||
import json
 | 
			
		||||
import psutil
 | 
			
		||||
import getpass
 | 
			
		||||
from PySide2 import QtCore, QtWidgets
 | 
			
		||||
from PySide2 import QtCore, QtWidgets, QtGui
 | 
			
		||||
 | 
			
		||||
from onionshare_cli.common import Common
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -46,6 +46,9 @@ class Application(QtWidgets.QApplication):
 | 
			
		|||
        if common.platform == "Linux" or common.platform == "BSD":
 | 
			
		||||
            self.setAttribute(QtCore.Qt.AA_X11InitThreads, True)
 | 
			
		||||
        QtWidgets.QApplication.__init__(self, sys.argv)
 | 
			
		||||
 | 
			
		||||
        # Check color mode on starting the app
 | 
			
		||||
        self.color_mode = self.get_color_mode()
 | 
			
		||||
        self.installEventFilter(self)
 | 
			
		||||
 | 
			
		||||
    def eventFilter(self, obj, event):
 | 
			
		||||
| 
						 | 
				
			
			@ -55,8 +58,21 @@ class Application(QtWidgets.QApplication):
 | 
			
		|||
            and event.modifiers() == QtCore.Qt.ControlModifier
 | 
			
		||||
        ):
 | 
			
		||||
            self.quit()
 | 
			
		||||
 | 
			
		||||
        # Check if color switched while the app was open
 | 
			
		||||
        if event.type() == QtCore.QEvent.Type.ApplicationPaletteChange:
 | 
			
		||||
            self.color_mode = self.get_color_mode()
 | 
			
		||||
        return False
 | 
			
		||||
 | 
			
		||||
    def is_dark_mode(self):
 | 
			
		||||
        baseColor = QtGui.QPalette().color(QtGui.QPalette.Base)
 | 
			
		||||
        if baseColor.name().lower() == "#ffffff":
 | 
			
		||||
            return False
 | 
			
		||||
        return True
 | 
			
		||||
 | 
			
		||||
    def get_color_mode(self):
 | 
			
		||||
        return "dark" if self.is_dark_mode() else "light"
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
def main():
 | 
			
		||||
    """
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -78,7 +78,19 @@ class GuiCommon:
 | 
			
		|||
            os.makedirs(self.events_dir, 0o700, True)
 | 
			
		||||
        self.events_filename = os.path.join(self.events_dir, "events")
 | 
			
		||||
 | 
			
		||||
        self.css = {
 | 
			
		||||
        self.css = self.get_css(qtapp.color_mode)
 | 
			
		||||
        self.color_mode = qtapp.color_mode
 | 
			
		||||
 | 
			
		||||
    def get_css(self, color_mode):
 | 
			
		||||
        header_color = "#4E064F"  # purple in light
 | 
			
		||||
        title_color = "#333333"  # dark gray color in main window
 | 
			
		||||
        stop_button_color = "#d0011b"  # red button color for stopping server
 | 
			
		||||
        if color_mode == "dark":
 | 
			
		||||
            header_color = "#F2F2F2"
 | 
			
		||||
            title_color = "#F2F2F2"
 | 
			
		||||
            stop_button_color = "#C32F2F"
 | 
			
		||||
 | 
			
		||||
        return {
 | 
			
		||||
            # OnionShareGui styles
 | 
			
		||||
            "tab_widget": """
 | 
			
		||||
                QTabBar::tab { width: 170px; height: 30px; }
 | 
			
		||||
| 
						 | 
				
			
			@ -96,7 +108,9 @@ class GuiCommon:
 | 
			
		|||
                }""",
 | 
			
		||||
            "mode_header_label": """
 | 
			
		||||
                QLabel {
 | 
			
		||||
                    color: #4E064F;
 | 
			
		||||
                    color: """
 | 
			
		||||
            + header_color
 | 
			
		||||
            + """;
 | 
			
		||||
                    font-size: 48px;
 | 
			
		||||
                    margin-bottom: 16px;
 | 
			
		||||
                }""",
 | 
			
		||||
| 
						 | 
				
			
			@ -173,7 +187,9 @@ class GuiCommon:
 | 
			
		|||
                }""",
 | 
			
		||||
            "server_status_button_started": """
 | 
			
		||||
                QPushButton {
 | 
			
		||||
                    background-color: #d0011b;
 | 
			
		||||
                    background-color: """
 | 
			
		||||
            + stop_button_color
 | 
			
		||||
            + """;
 | 
			
		||||
                    color: #ffffff;
 | 
			
		||||
                    padding: 10px 30px 10px 30px;
 | 
			
		||||
                    border: 0;
 | 
			
		||||
| 
						 | 
				
			
			@ -218,14 +234,18 @@ class GuiCommon:
 | 
			
		|||
                }""",
 | 
			
		||||
            "downloads_uploads_progress_bar": """
 | 
			
		||||
                QProgressBar {
 | 
			
		||||
                    border: 1px solid #4e064f;
 | 
			
		||||
                    border: 1px solid """
 | 
			
		||||
            + header_color
 | 
			
		||||
            + """;
 | 
			
		||||
                    background-color: #ffffff !important;
 | 
			
		||||
                    text-align: center;
 | 
			
		||||
                    color: #9b9b9b;
 | 
			
		||||
                    font-size: 14px;
 | 
			
		||||
                }
 | 
			
		||||
                QProgressBar::chunk {
 | 
			
		||||
                    background-color: #4e064f;
 | 
			
		||||
                    background-color: """
 | 
			
		||||
            + header_color
 | 
			
		||||
            + """;
 | 
			
		||||
                    width: 10px;
 | 
			
		||||
                }""",
 | 
			
		||||
            "history_individual_file_timestamp_label": """
 | 
			
		||||
| 
						 | 
				
			
			@ -259,7 +279,9 @@ class GuiCommon:
 | 
			
		|||
            "new_tab_title_text": """
 | 
			
		||||
                QLabel {
 | 
			
		||||
                    text-align: center;
 | 
			
		||||
                    color: #333333;
 | 
			
		||||
                    color: """
 | 
			
		||||
            + title_color
 | 
			
		||||
            + """;
 | 
			
		||||
                    font-size: 25px;
 | 
			
		||||
                }
 | 
			
		||||
                """,
 | 
			
		||||
| 
						 | 
				
			
			@ -271,26 +293,34 @@ class GuiCommon:
 | 
			
		|||
                """,
 | 
			
		||||
            "share_zip_progess_bar": """
 | 
			
		||||
                QProgressBar {
 | 
			
		||||
                    border: 1px solid #4e064f;
 | 
			
		||||
                    border: 1px solid """
 | 
			
		||||
            + header_color
 | 
			
		||||
            + """;
 | 
			
		||||
                    background-color: #ffffff !important;
 | 
			
		||||
                    text-align: center;
 | 
			
		||||
                    color: #9b9b9b;
 | 
			
		||||
                }
 | 
			
		||||
                QProgressBar::chunk {
 | 
			
		||||
                    border: 0px;
 | 
			
		||||
                    background-color: #4e064f;
 | 
			
		||||
                    background-color: """
 | 
			
		||||
            + header_color
 | 
			
		||||
            + """;
 | 
			
		||||
                    width: 10px;
 | 
			
		||||
                }""",
 | 
			
		||||
            "share_filesize_warning": """
 | 
			
		||||
                QLabel {
 | 
			
		||||
                    padding: 10px 0;
 | 
			
		||||
                    font-weight: bold;
 | 
			
		||||
                    color: #333333;
 | 
			
		||||
                    color: """
 | 
			
		||||
            + title_color
 | 
			
		||||
            + """;
 | 
			
		||||
                }
 | 
			
		||||
                """,
 | 
			
		||||
            "share_file_selection_drop_here_header_label": """
 | 
			
		||||
                QLabel {
 | 
			
		||||
                    color: #4E064F;
 | 
			
		||||
                    color: """
 | 
			
		||||
            + header_color
 | 
			
		||||
            + """;
 | 
			
		||||
                    font-size: 48px;
 | 
			
		||||
                    margin-bottom: 72px;
 | 
			
		||||
                }""",
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -113,7 +113,11 @@ class MainWindow(QtWidgets.QMainWindow):
 | 
			
		|||
        self.settings_button.setDefault(False)
 | 
			
		||||
        self.settings_button.setFixedSize(40, 50)
 | 
			
		||||
        self.settings_button.setIcon(
 | 
			
		||||
            QtGui.QIcon(GuiCommon.get_resource_path("images/settings.png"))
 | 
			
		||||
            QtGui.QIcon(
 | 
			
		||||
                GuiCommon.get_resource_path(
 | 
			
		||||
                    "images/{}_settings.png".format(self.common.gui.color_mode)
 | 
			
		||||
                )
 | 
			
		||||
            )
 | 
			
		||||
        )
 | 
			
		||||
        self.settings_button.clicked.connect(self.open_settings)
 | 
			
		||||
        self.settings_button.setStyleSheet(self.common.gui.css["settings_button"])
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
							
								
								
									
										
											BIN
										
									
								
								desktop/src/onionshare/resources/images/dark_icon-add.png
									
										
									
									
									
										Normal file
									
								
							
							
						
						| 
		 After Width: | Height: | Size: 203 B  | 
							
								
								
									
										
											BIN
										
									
								
								desktop/src/onionshare/resources/images/dark_icon-close.png
									
										
									
									
									
										Normal file
									
								
							
							
						
						| 
		 After Width: | Height: | Size: 305 B  | 
							
								
								
									
										
											BIN
										
									
								
								desktop/src/onionshare/resources/images/dark_logo_text.png
									
										
									
									
									
										Normal file
									
								
							
							
						
						| 
		 After Width: | Height: | Size: 3 KiB  | 
							
								
								
									
										
											BIN
										
									
								
								desktop/src/onionshare/resources/images/dark_mode_chat.png
									
										
									
									
									
										Normal file
									
								
							
							
						
						| 
		 After Width: | Height: | Size: 21 KiB  | 
| 
		 After Width: | Height: | Size: 15 KiB  | 
| 
		 After Width: | Height: | Size: 15 KiB  | 
| 
		 After Width: | Height: | Size: 13 KiB  | 
| 
		 After Width: | Height: | Size: 10 KiB  | 
							
								
								
									
										
											BIN
										
									
								
								desktop/src/onionshare/resources/images/dark_mode_receive.png
									
										
									
									
									
										Normal file
									
								
							
							
						
						| 
		 After Width: | Height: | Size: 23 KiB  | 
							
								
								
									
										
											BIN
										
									
								
								desktop/src/onionshare/resources/images/dark_mode_share.png
									
										
									
									
									
										Normal file
									
								
							
							
						
						| 
		 After Width: | Height: | Size: 9.1 KiB  | 
							
								
								
									
										
											BIN
										
									
								
								desktop/src/onionshare/resources/images/dark_mode_website.png
									
										
									
									
									
										Normal file
									
								
							
							
						
						| 
		 After Width: | Height: | Size: 8.9 KiB  | 
							
								
								
									
										
											BIN
										
									
								
								desktop/src/onionshare/resources/images/dark_settings.png
									
										
									
									
									
										Normal file
									
								
							
							
						
						| 
		 After Width: | Height: | Size: 456 B  | 
							
								
								
									
										
											BIN
										
									
								
								desktop/src/onionshare/resources/images/light_logo_text.png
									
										
									
									
									
										Normal file
									
								
							
							
						
						| 
		 After Width: | Height: | Size: 3.3 KiB  | 
							
								
								
									
										
											BIN
										
									
								
								desktop/src/onionshare/resources/images/light_mode_chat.png
									
										
									
									
									
										Normal file
									
								
							
							
						
						| 
		 After Width: | Height: | Size: 22 KiB  | 
| 
		 After Width: | Height: | Size: 15 KiB  | 
| 
		 After Width: | Height: | Size: 15 KiB  | 
| 
		 After Width: | Height: | Size: 13 KiB  | 
| 
		 After Width: | Height: | Size: 10 KiB  | 
							
								
								
									
										
											BIN
										
									
								
								desktop/src/onionshare/resources/images/light_mode_receive.png
									
										
									
									
									
										Normal file
									
								
							
							
						
						| 
		 After Width: | Height: | Size: 23 KiB  | 
							
								
								
									
										
											BIN
										
									
								
								desktop/src/onionshare/resources/images/light_mode_share.png
									
										
									
									
									
										Normal file
									
								
							
							
						
						| 
		 After Width: | Height: | Size: 9.3 KiB  | 
							
								
								
									
										
											BIN
										
									
								
								desktop/src/onionshare/resources/images/light_mode_website.png
									
										
									
									
									
										Normal file
									
								
							
							
						
						| 
		 After Width: | Height: | Size: 8.4 KiB  | 
| 
		 Before Width: | Height: | Size: 1.1 KiB After Width: | Height: | Size: 1.1 KiB  | 
| 
		 Before Width: | Height: | Size: 3.7 KiB  | 
| 
		 Before Width: | Height: | Size: 27 KiB  | 
| 
		 Before Width: | Height: | Size: 5.1 KiB  | 
| 
		 Before Width: | Height: | Size: 6.3 KiB  | 
| 
		 Before Width: | Height: | Size: 4.4 KiB  | 
| 
		 Before Width: | Height: | Size: 3.8 KiB  | 
| 
		 Before Width: | Height: | Size: 36 KiB  | 
| 
		 Before Width: | Height: | Size: 9.3 KiB  | 
| 
		 Before Width: | Height: | Size: 7.9 KiB  | 
| 
						 | 
				
			
			@ -53,7 +53,11 @@ class ChatMode(Mode):
 | 
			
		|||
        self.image_label = QtWidgets.QLabel()
 | 
			
		||||
        self.image_label.setPixmap(
 | 
			
		||||
            QtGui.QPixmap.fromImage(
 | 
			
		||||
                QtGui.QImage(GuiCommon.get_resource_path("images/mode_chat.png"))
 | 
			
		||||
                QtGui.QImage(
 | 
			
		||||
                    GuiCommon.get_resource_path(
 | 
			
		||||
                        "images/{}_mode_chat.png".format(self.common.gui.color_mode)
 | 
			
		||||
                    )
 | 
			
		||||
                )
 | 
			
		||||
            )
 | 
			
		||||
        )
 | 
			
		||||
        self.image_label.setFixedSize(300, 300)
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -46,7 +46,11 @@ class ReceiveMode(Mode):
 | 
			
		|||
        self.image_label = QtWidgets.QLabel()
 | 
			
		||||
        self.image_label.setPixmap(
 | 
			
		||||
            QtGui.QPixmap.fromImage(
 | 
			
		||||
                QtGui.QImage(GuiCommon.get_resource_path("images/mode_receive.png"))
 | 
			
		||||
                QtGui.QImage(
 | 
			
		||||
                    GuiCommon.get_resource_path(
 | 
			
		||||
                        "images/{}_mode_receive.png".format(self.common.gui.color_mode)
 | 
			
		||||
                    )
 | 
			
		||||
                )
 | 
			
		||||
            )
 | 
			
		||||
        )
 | 
			
		||||
        self.image_label.setFixedSize(250, 250)
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -69,7 +69,7 @@ class ShareMode(Mode):
 | 
			
		|||
        # File selection
 | 
			
		||||
        self.file_selection = FileSelection(
 | 
			
		||||
            self.common,
 | 
			
		||||
            "images/mode_share.png",
 | 
			
		||||
            "images/{}_mode_share.png".format(self.common.gui.color_mode),
 | 
			
		||||
            strings._("gui_new_tab_share_button"),
 | 
			
		||||
            self,
 | 
			
		||||
        )
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -69,7 +69,7 @@ class WebsiteMode(Mode):
 | 
			
		|||
        # File selection
 | 
			
		||||
        self.file_selection = FileSelection(
 | 
			
		||||
            self.common,
 | 
			
		||||
            "images/mode_website.png",
 | 
			
		||||
            "images/{}_mode_website.png".format(self.common.gui.color_mode),
 | 
			
		||||
            strings._("gui_new_tab_website_button"),
 | 
			
		||||
            self,
 | 
			
		||||
        )
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -121,7 +121,11 @@ class Tab(QtWidgets.QWidget):
 | 
			
		|||
        self.image_label = QtWidgets.QLabel()
 | 
			
		||||
        self.image_label.setPixmap(
 | 
			
		||||
            QtGui.QPixmap.fromImage(
 | 
			
		||||
                QtGui.QImage(GuiCommon.get_resource_path("images/logo_text.png"))
 | 
			
		||||
                QtGui.QImage(
 | 
			
		||||
                    GuiCommon.get_resource_path(
 | 
			
		||||
                        "images/{}_logo_text.png".format(self.common.gui.color_mode)
 | 
			
		||||
                    )
 | 
			
		||||
                )
 | 
			
		||||
            )
 | 
			
		||||
        )
 | 
			
		||||
        self.image_label.setFixedSize(160, 40)
 | 
			
		||||
| 
						 | 
				
			
			@ -134,7 +138,7 @@ class Tab(QtWidgets.QWidget):
 | 
			
		|||
        # New tab buttons
 | 
			
		||||
        self.share_button = NewTabButton(
 | 
			
		||||
            self.common,
 | 
			
		||||
            "images/mode_new_tab_share.png",
 | 
			
		||||
            "images/{}_mode_new_tab_share.png".format(self.common.gui.color_mode),
 | 
			
		||||
            strings._("gui_new_tab_share_button"),
 | 
			
		||||
            strings._("gui_main_page_share_button"),
 | 
			
		||||
        )
 | 
			
		||||
| 
						 | 
				
			
			@ -142,7 +146,7 @@ class Tab(QtWidgets.QWidget):
 | 
			
		|||
 | 
			
		||||
        self.receive_button = NewTabButton(
 | 
			
		||||
            self.common,
 | 
			
		||||
            "images/mode_new_tab_receive.png",
 | 
			
		||||
            "images/{}_mode_new_tab_receive.png".format(self.common.gui.color_mode),
 | 
			
		||||
            strings._("gui_new_tab_receive_button"),
 | 
			
		||||
            strings._("gui_main_page_receive_button"),
 | 
			
		||||
        )
 | 
			
		||||
| 
						 | 
				
			
			@ -150,7 +154,7 @@ class Tab(QtWidgets.QWidget):
 | 
			
		|||
 | 
			
		||||
        self.website_button = NewTabButton(
 | 
			
		||||
            self.common,
 | 
			
		||||
            "images/mode_new_tab_website.png",
 | 
			
		||||
            "images/{}_mode_new_tab_website.png".format(self.common.gui.color_mode),
 | 
			
		||||
            strings._("gui_new_tab_website_button"),
 | 
			
		||||
            strings._("gui_main_page_website_button"),
 | 
			
		||||
        )
 | 
			
		||||
| 
						 | 
				
			
			@ -158,7 +162,7 @@ class Tab(QtWidgets.QWidget):
 | 
			
		|||
 | 
			
		||||
        self.chat_button = NewTabButton(
 | 
			
		||||
            self.common,
 | 
			
		||||
            "images/mode_new_tab_chat.png",
 | 
			
		||||
            "images/{}_mode_new_tab_chat.png".format(self.common.gui.color_mode),
 | 
			
		||||
            strings._("gui_new_tab_chat_button"),
 | 
			
		||||
            strings._("gui_main_page_chat_button"),
 | 
			
		||||
        )
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||