From cc7c463e805017215f1dc6d0a2b80e2d614d976f Mon Sep 17 00:00:00 2001 From: Micah Lee Date: Sun, 27 Oct 2019 15:21:46 -0700 Subject: [PATCH] Add purple headers to each mode --- onionshare_gui/gui_common.py | 19 ++++++------------- onionshare_gui/tab/mode/__init__.py | 13 +++++++++++++ .../tab/mode/receive_mode/__init__.py | 4 ++++ .../tab/mode/share_mode/__init__.py | 4 ++++ .../tab/mode/website_mode/__init__.py | 4 ++++ onionshare_gui/tab/tab.py | 6 +++--- onionshare_gui/tab_widget.py | 4 +++- 7 files changed, 37 insertions(+), 17 deletions(-) diff --git a/onionshare_gui/gui_common.py b/onionshare_gui/gui_common.py index 9ab16470..4507d998 100644 --- a/onionshare_gui/gui_common.py +++ b/onionshare_gui/gui_common.py @@ -50,33 +50,26 @@ class GuiCommon: self.css = { # OnionShareGui styles - "tab_bar_new_tab_button": """ + "tab_widget_new_tab_button": """ QPushButton { font-weight: bold; font-size: 20px; }""", - "new_tab_button": """ + "mode_new_tab_button": """ QPushButton { font-weight: bold; font-size: 30px; color: #601f61; }""", - "mode_switcher_selected_style": """ - QPushButton { + "mode_header_label": """ + QLabel { color: #ffffff; background-color: #4e064f; border: 0; - border-right: 1px solid #69266b; font-weight: bold; + font-size: 18px; border-radius: 0; - }""", - "mode_switcher_unselected_style": """ - QPushButton { - color: #ffffff; - background-color: #601f61; - border: 0; - font-weight: normal; - border-radius: 0; + padding: 10px 0 10px 0; }""", "settings_button": """ QPushButton { diff --git a/onionshare_gui/tab/mode/__init__.py b/onionshare_gui/tab/mode/__init__.py index e993f5e2..7ab321f8 100644 --- a/onionshare_gui/tab/mode/__init__.py +++ b/onionshare_gui/tab/mode/__init__.py @@ -75,6 +75,19 @@ class Mode(QtWidgets.QWidget): self.web_thread = None self.startup_thread = None + # Header + # Note: It's up to the downstream Mode to add this to its layout + self.header_label = QtWidgets.QLabel() + self.header_label.setStyleSheet(self.common.gui.css["mode_header_label"]) + self.header_label.setAlignment(QtCore.Qt.AlignHCenter) + + header_layout = QtWidgets.QVBoxLayout() + header_layout.setContentsMargins(0, 0, 0, 0) + header_layout.addWidget(self.header_label) + + self.header = QtWidgets.QWidget() + self.header.setLayout(header_layout) + # Server status self.server_status = ServerStatus( self.common, self.qtapp, self.app, None, self.local_only diff --git a/onionshare_gui/tab/mode/receive_mode/__init__.py b/onionshare_gui/tab/mode/receive_mode/__init__.py index a0507949..46b1dd57 100644 --- a/onionshare_gui/tab/mode/receive_mode/__init__.py +++ b/onionshare_gui/tab/mode/receive_mode/__init__.py @@ -38,6 +38,9 @@ class ReceiveMode(Mode): # Create the Web object self.web = Web(self.common, True, "receive") + # Header + self.header_label.setText(strings._("gui_new_tab_receive_button")) + # Server status self.server_status.set_mode("receive") self.server_status.server_started_finished.connect(self.update_primary_action) @@ -86,6 +89,7 @@ class ReceiveMode(Mode): # Main layout self.main_layout = QtWidgets.QVBoxLayout() + self.main_layout.addWidget(self.header) self.main_layout.addLayout(top_bar_layout) self.main_layout.addWidget(receive_warning) self.main_layout.addWidget(self.primary_action) diff --git a/onionshare_gui/tab/mode/share_mode/__init__.py b/onionshare_gui/tab/mode/share_mode/__init__.py index 1d495cd5..9bf875cb 100644 --- a/onionshare_gui/tab/mode/share_mode/__init__.py +++ b/onionshare_gui/tab/mode/share_mode/__init__.py @@ -47,6 +47,9 @@ class ShareMode(Mode): # Create the Web object self.web = Web(self.common, True, "share") + # Header + self.header_label.setText(strings._("gui_new_tab_share_button")) + # File selection self.file_selection = FileSelection(self.common, self) if self.filenames: @@ -118,6 +121,7 @@ class ShareMode(Mode): # Main layout self.main_layout = QtWidgets.QVBoxLayout() + self.main_layout.addWidget(self.header) self.main_layout.addLayout(top_bar_layout) self.main_layout.addLayout(self.file_selection) self.main_layout.addWidget(self.primary_action) diff --git a/onionshare_gui/tab/mode/website_mode/__init__.py b/onionshare_gui/tab/mode/website_mode/__init__.py index 6da08bd2..b9e7b647 100644 --- a/onionshare_gui/tab/mode/website_mode/__init__.py +++ b/onionshare_gui/tab/mode/website_mode/__init__.py @@ -49,6 +49,9 @@ class WebsiteMode(Mode): # Create the Web object self.web = Web(self.common, True, "website") + # Header + self.header_label.setText(strings._("gui_new_tab_website_button")) + # File selection self.file_selection = FileSelection(self.common, self) if self.filenames: @@ -120,6 +123,7 @@ class WebsiteMode(Mode): # Main layout self.main_layout = QtWidgets.QVBoxLayout() + self.main_layout.addWidget(self.header) self.main_layout.addLayout(top_bar_layout) self.main_layout.addLayout(self.file_selection) self.main_layout.addWidget(self.primary_action) diff --git a/onionshare_gui/tab/tab.py b/onionshare_gui/tab/tab.py index bb0e8d84..b9416bc7 100644 --- a/onionshare_gui/tab/tab.py +++ b/onionshare_gui/tab/tab.py @@ -57,13 +57,13 @@ class Tab(QtWidgets.QWidget): # New tab widget share_button = QtWidgets.QPushButton(strings._("gui_new_tab_share_button")) - share_button.setStyleSheet(self.common.gui.css["new_tab_button"]) + share_button.setStyleSheet(self.common.gui.css["mode_new_tab_button"]) share_description = QtWidgets.QLabel(strings._("gui_new_tab_share_description")) share_description.setWordWrap(True) share_button.clicked.connect(self.share_mode_clicked) receive_button = QtWidgets.QPushButton(strings._("gui_new_tab_receive_button")) - receive_button.setStyleSheet(self.common.gui.css["new_tab_button"]) + receive_button.setStyleSheet(self.common.gui.css["mode_new_tab_button"]) receive_button.clicked.connect(self.receive_mode_clicked) receive_description = QtWidgets.QLabel( strings._("gui_new_tab_receive_description") @@ -71,7 +71,7 @@ class Tab(QtWidgets.QWidget): receive_description.setWordWrap(True) website_button = QtWidgets.QPushButton(strings._("gui_new_tab_website_button")) - website_button.setStyleSheet(self.common.gui.css["new_tab_button"]) + website_button.setStyleSheet(self.common.gui.css["mode_new_tab_button"]) website_button.clicked.connect(self.website_mode_clicked) website_description = QtWidgets.QLabel( strings._("gui_new_tab_website_description") diff --git a/onionshare_gui/tab_widget.py b/onionshare_gui/tab_widget.py index 6207dde4..189c742f 100644 --- a/onionshare_gui/tab_widget.py +++ b/onionshare_gui/tab_widget.py @@ -47,7 +47,9 @@ class TabWidget(QtWidgets.QTabWidget): self.new_tab_button.setAutoFillBackground(True) self.new_tab_button.setFixedSize(30, 30) self.new_tab_button.clicked.connect(self.new_tab_clicked) - self.new_tab_button.setStyleSheet(self.common.gui.css["tab_bar_new_tab_button"]) + self.new_tab_button.setStyleSheet( + self.common.gui.css["tab_widget_new_tab_button"] + ) self.new_tab_button.setToolTip(strings._("gui_new_tab_tooltip")) # Use a custom tab bar