Make a new onionshare_gui.GuiCommon object, and move css from onionshare.Common into it

This commit is contained in:
Micah Lee 2019-10-20 20:01:09 -07:00
parent 4f2ce99417
commit bba5286815
No known key found for this signature in database
GPG Key ID: 403C2657CD994F73
10 changed files with 323 additions and 290 deletions

View File

@ -32,7 +32,7 @@ import time
from .settings import Settings from .settings import Settings
class Common(object): class Common:
""" """
The Common object is shared amongst all parts of OnionShare. The Common object is shared amongst all parts of OnionShare.
""" """
@ -187,237 +187,6 @@ class Common(object):
r = random.SystemRandom() r = random.SystemRandom()
return "-".join(r.choice(wordlist) for _ in range(2)) return "-".join(r.choice(wordlist) for _ in range(2))
def define_css(self):
"""
This defines all of the stylesheets used in GUI mode, to avoid repeating code.
This method is only called in GUI mode.
"""
self.css = {
# OnionShareGui styles
"mode_switcher_selected_style": """
QPushButton {
color: #ffffff;
background-color: #4e064f;
border: 0;
border-right: 1px solid #69266b;
font-weight: bold;
border-radius: 0;
}""",
"mode_switcher_unselected_style": """
QPushButton {
color: #ffffff;
background-color: #601f61;
border: 0;
font-weight: normal;
border-radius: 0;
}""",
"settings_button": """
QPushButton {
background-color: #601f61;
border: 0;
border-left: 1px solid #69266b;
border-radius: 0;
}""",
"server_status_indicator_label": """
QLabel {
font-style: italic;
color: #666666;
padding: 2px;
}""",
"status_bar": """
QStatusBar {
font-style: italic;
color: #666666;
}
QStatusBar::item {
border: 0px;
}""",
# Common styles between modes and their child widgets
"mode_info_label": """
QLabel {
font-size: 12px;
color: #666666;
}
""",
"server_status_url": """
QLabel {
background-color: #ffffff;
color: #000000;
padding: 10px;
border: 1px solid #666666;
font-size: 12px;
}
""",
"server_status_url_buttons": """
QPushButton {
color: #3f7fcf;
}
""",
"server_status_button_stopped": """
QPushButton {
background-color: #5fa416;
color: #ffffff;
padding: 10px;
border: 0;
border-radius: 5px;
}""",
"server_status_button_working": """
QPushButton {
background-color: #4c8211;
color: #ffffff;
padding: 10px;
border: 0;
border-radius: 5px;
font-style: italic;
}""",
"server_status_button_started": """
QPushButton {
background-color: #d0011b;
color: #ffffff;
padding: 10px;
border: 0;
border-radius: 5px;
}""",
"downloads_uploads_empty": """
QWidget {
background-color: #ffffff;
border: 1px solid #999999;
}
QWidget QLabel {
background-color: none;
border: 0px;
}
""",
"downloads_uploads_empty_text": """
QLabel {
color: #999999;
}""",
"downloads_uploads_label": """
QLabel {
font-weight: bold;
font-size 14px;
text-align: center;
background-color: none;
border: none;
}""",
"downloads_uploads_clear": """
QPushButton {
color: #3f7fcf;
}
""",
"download_uploads_indicator": """
QLabel {
color: #ffffff;
background-color: #f44449;
font-weight: bold;
font-size: 10px;
padding: 2px;
border-radius: 7px;
text-align: center;
}""",
"downloads_uploads_progress_bar": """
QProgressBar {
border: 1px solid #4e064f;
background-color: #ffffff !important;
text-align: center;
color: #9b9b9b;
font-size: 14px;
}
QProgressBar::chunk {
background-color: #4e064f;
width: 10px;
}""",
"history_individual_file_timestamp_label": """
QLabel {
color: #666666;
}""",
"history_individual_file_status_code_label_2xx": """
QLabel {
color: #008800;
}""",
"history_individual_file_status_code_label_4xx": """
QLabel {
color: #cc0000;
}""",
# Share mode and child widget styles
"share_zip_progess_bar": """
QProgressBar {
border: 1px solid #4e064f;
background-color: #ffffff !important;
text-align: center;
color: #9b9b9b;
}
QProgressBar::chunk {
border: 0px;
background-color: #4e064f;
width: 10px;
}""",
"share_filesize_warning": """
QLabel {
padding: 10px 0;
font-weight: bold;
color: #333333;
}
""",
"share_file_selection_drop_here_label": """
QLabel {
color: #999999;
}""",
"share_file_selection_drop_count_label": """
QLabel {
color: #ffffff;
background-color: #f44449;
font-weight: bold;
padding: 5px 10px;
border-radius: 10px;
}""",
"share_file_list_drag_enter": """
FileList {
border: 3px solid #538ad0;
}
""",
"share_file_list_drag_leave": """
FileList {
border: none;
}
""",
"share_file_list_item_size": """
QLabel {
color: #666666;
font-size: 11px;
}""",
# Receive mode and child widget styles
"receive_file": """
QWidget {
background-color: #ffffff;
}
""",
"receive_file_size": """
QLabel {
color: #666666;
font-size: 11px;
}""",
# Settings dialog
"settings_version": """
QLabel {
color: #666666;
}""",
"settings_tor_status": """
QLabel {
background-color: #ffffff;
color: #000000;
padding: 10px;
}""",
"settings_whats_this": """
QLabel {
font-size: 12px;
}""",
"settings_connect_to_tor": """
QLabel {
font-style: italic;
}""",
}
@staticmethod @staticmethod
def random_string(num_bytes, output_len=None): def random_string(num_bytes, output_len=None):
""" """

View File

@ -30,6 +30,7 @@ from onionshare.common import Common
from onionshare.onion import Onion from onionshare.onion import Onion
from onionshare.onionshare import OnionShare from onionshare.onionshare import OnionShare
from .gui_common import GuiCommon
from .widgets import Alert from .widgets import Alert
from .main_window import MainWindow from .main_window import MainWindow
@ -61,7 +62,7 @@ def main():
The main() function implements all of the logic that the GUI version of onionshare uses. The main() function implements all of the logic that the GUI version of onionshare uses.
""" """
common = Common() common = Common()
common.define_css() common.gui = GuiCommon(common)
# Display OnionShare banner # Display OnionShare banner
print(f"OnionShare {common.version} | https://onionshare.org/") print(f"OnionShare {common.version} | https://onionshare.org/")

View File

@ -0,0 +1,254 @@
# -*- coding: utf-8 -*-
"""
OnionShare | https://onionshare.org/
Copyright (C) 2014-2018 Micah Lee <micah@micahflee.com>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
"""
class GuiCommon:
"""
The shared code for all of the OnionShare GUI.
"""
def __init__(self, common):
self.common = common
self.css = {
# OnionShareGui styles
"mode_switcher_selected_style": """
QPushButton {
color: #ffffff;
background-color: #4e064f;
border: 0;
border-right: 1px solid #69266b;
font-weight: bold;
border-radius: 0;
}""",
"mode_switcher_unselected_style": """
QPushButton {
color: #ffffff;
background-color: #601f61;
border: 0;
font-weight: normal;
border-radius: 0;
}""",
"settings_button": """
QPushButton {
background-color: #601f61;
border: 0;
border-left: 1px solid #69266b;
border-radius: 0;
}""",
"server_status_indicator_label": """
QLabel {
font-style: italic;
color: #666666;
padding: 2px;
}""",
"status_bar": """
QStatusBar {
font-style: italic;
color: #666666;
}
QStatusBar::item {
border: 0px;
}""",
# Common styles between modes and their child widgets
"mode_info_label": """
QLabel {
font-size: 12px;
color: #666666;
}
""",
"server_status_url": """
QLabel {
background-color: #ffffff;
color: #000000;
padding: 10px;
border: 1px solid #666666;
font-size: 12px;
}
""",
"server_status_url_buttons": """
QPushButton {
color: #3f7fcf;
}
""",
"server_status_button_stopped": """
QPushButton {
background-color: #5fa416;
color: #ffffff;
padding: 10px;
border: 0;
border-radius: 5px;
}""",
"server_status_button_working": """
QPushButton {
background-color: #4c8211;
color: #ffffff;
padding: 10px;
border: 0;
border-radius: 5px;
font-style: italic;
}""",
"server_status_button_started": """
QPushButton {
background-color: #d0011b;
color: #ffffff;
padding: 10px;
border: 0;
border-radius: 5px;
}""",
"downloads_uploads_empty": """
QWidget {
background-color: #ffffff;
border: 1px solid #999999;
}
QWidget QLabel {
background-color: none;
border: 0px;
}
""",
"downloads_uploads_empty_text": """
QLabel {
color: #999999;
}""",
"downloads_uploads_label": """
QLabel {
font-weight: bold;
font-size 14px;
text-align: center;
background-color: none;
border: none;
}""",
"downloads_uploads_clear": """
QPushButton {
color: #3f7fcf;
}
""",
"download_uploads_indicator": """
QLabel {
color: #ffffff;
background-color: #f44449;
font-weight: bold;
font-size: 10px;
padding: 2px;
border-radius: 7px;
text-align: center;
}""",
"downloads_uploads_progress_bar": """
QProgressBar {
border: 1px solid #4e064f;
background-color: #ffffff !important;
text-align: center;
color: #9b9b9b;
font-size: 14px;
}
QProgressBar::chunk {
background-color: #4e064f;
width: 10px;
}""",
"history_individual_file_timestamp_label": """
QLabel {
color: #666666;
}""",
"history_individual_file_status_code_label_2xx": """
QLabel {
color: #008800;
}""",
"history_individual_file_status_code_label_4xx": """
QLabel {
color: #cc0000;
}""",
# Share mode and child widget styles
"share_zip_progess_bar": """
QProgressBar {
border: 1px solid #4e064f;
background-color: #ffffff !important;
text-align: center;
color: #9b9b9b;
}
QProgressBar::chunk {
border: 0px;
background-color: #4e064f;
width: 10px;
}""",
"share_filesize_warning": """
QLabel {
padding: 10px 0;
font-weight: bold;
color: #333333;
}
""",
"share_file_selection_drop_here_label": """
QLabel {
color: #999999;
}""",
"share_file_selection_drop_count_label": """
QLabel {
color: #ffffff;
background-color: #f44449;
font-weight: bold;
padding: 5px 10px;
border-radius: 10px;
}""",
"share_file_list_drag_enter": """
FileList {
border: 3px solid #538ad0;
}
""",
"share_file_list_drag_leave": """
FileList {
border: none;
}
""",
"share_file_list_item_size": """
QLabel {
color: #666666;
font-size: 11px;
}""",
# Receive mode and child widget styles
"receive_file": """
QWidget {
background-color: #ffffff;
}
""",
"receive_file_size": """
QLabel {
color: #666666;
font-size: 11px;
}""",
# Settings dialog
"settings_version": """
QLabel {
color: #666666;
}""",
"settings_tor_status": """
QLabel {
background-color: #ffffff;
color: #000000;
padding: 10px;
}""",
"settings_whats_this": """
QLabel {
font-size: 12px;
}""",
"settings_connect_to_tor": """
QLabel {
font-style: italic;
}""",
}

View File

@ -36,8 +36,7 @@ from .server_status import ServerStatus
class MainWindow(QtWidgets.QMainWindow): class MainWindow(QtWidgets.QMainWindow):
""" """
MainWindow is the main window for the GUI that contains all of the MainWindow is the OnionShare main window, which contains the GUI elements, including all open tabs
GUI elements.
""" """
MODE_SHARE = "share" MODE_SHARE = "share"
@ -121,7 +120,7 @@ class MainWindow(QtWidgets.QMainWindow):
QtGui.QIcon(self.common.get_resource_path("images/settings.png")) QtGui.QIcon(self.common.get_resource_path("images/settings.png"))
) )
self.settings_button.clicked.connect(self.open_settings) self.settings_button.clicked.connect(self.open_settings)
self.settings_button.setStyleSheet(self.common.css["settings_button"]) self.settings_button.setStyleSheet(self.common.gui.css["settings_button"])
mode_switcher_layout = QtWidgets.QHBoxLayout() mode_switcher_layout = QtWidgets.QHBoxLayout()
mode_switcher_layout.setSpacing(0) mode_switcher_layout.setSpacing(0)
mode_switcher_layout.addWidget(self.share_mode_button) mode_switcher_layout.addWidget(self.share_mode_button)
@ -143,7 +142,7 @@ class MainWindow(QtWidgets.QMainWindow):
self.server_status_image_label.setFixedWidth(20) self.server_status_image_label.setFixedWidth(20)
self.server_status_label = QtWidgets.QLabel("") self.server_status_label = QtWidgets.QLabel("")
self.server_status_label.setStyleSheet( self.server_status_label.setStyleSheet(
self.common.css["server_status_indicator_label"] self.common.gui.css["server_status_indicator_label"]
) )
server_status_indicator_layout = QtWidgets.QHBoxLayout() server_status_indicator_layout = QtWidgets.QHBoxLayout()
server_status_indicator_layout.addWidget(self.server_status_image_label) server_status_indicator_layout.addWidget(self.server_status_image_label)
@ -154,7 +153,7 @@ class MainWindow(QtWidgets.QMainWindow):
# Status bar # Status bar
self.status_bar = QtWidgets.QStatusBar() self.status_bar = QtWidgets.QStatusBar()
self.status_bar.setSizeGripEnabled(False) self.status_bar.setSizeGripEnabled(False)
self.status_bar.setStyleSheet(self.common.css["status_bar"]) self.status_bar.setStyleSheet(self.common.gui.css["status_bar"])
self.status_bar.addPermanentWidget(self.server_status_indicator) self.status_bar.addPermanentWidget(self.server_status_indicator)
self.setStatusBar(self.status_bar) self.setStatusBar(self.status_bar)
@ -299,13 +298,13 @@ class MainWindow(QtWidgets.QMainWindow):
# and show and hide widgets to switch modes # and show and hide widgets to switch modes
if self.mode == self.MODE_SHARE: if self.mode == self.MODE_SHARE:
self.share_mode_button.setStyleSheet( self.share_mode_button.setStyleSheet(
self.common.css["mode_switcher_selected_style"] self.common.gui.css["mode_switcher_selected_style"]
) )
self.receive_mode_button.setStyleSheet( self.receive_mode_button.setStyleSheet(
self.common.css["mode_switcher_unselected_style"] self.common.gui.css["mode_switcher_unselected_style"]
) )
self.website_mode_button.setStyleSheet( self.website_mode_button.setStyleSheet(
self.common.css["mode_switcher_unselected_style"] self.common.gui.css["mode_switcher_unselected_style"]
) )
self.receive_mode.hide() self.receive_mode.hide()
@ -313,13 +312,13 @@ class MainWindow(QtWidgets.QMainWindow):
self.website_mode.hide() self.website_mode.hide()
elif self.mode == self.MODE_WEBSITE: elif self.mode == self.MODE_WEBSITE:
self.share_mode_button.setStyleSheet( self.share_mode_button.setStyleSheet(
self.common.css["mode_switcher_unselected_style"] self.common.gui.css["mode_switcher_unselected_style"]
) )
self.receive_mode_button.setStyleSheet( self.receive_mode_button.setStyleSheet(
self.common.css["mode_switcher_unselected_style"] self.common.gui.css["mode_switcher_unselected_style"]
) )
self.website_mode_button.setStyleSheet( self.website_mode_button.setStyleSheet(
self.common.css["mode_switcher_selected_style"] self.common.gui.css["mode_switcher_selected_style"]
) )
self.receive_mode.hide() self.receive_mode.hide()
@ -327,13 +326,13 @@ class MainWindow(QtWidgets.QMainWindow):
self.website_mode.show() self.website_mode.show()
else: else:
self.share_mode_button.setStyleSheet( self.share_mode_button.setStyleSheet(
self.common.css["mode_switcher_unselected_style"] self.common.gui.css["mode_switcher_unselected_style"]
) )
self.receive_mode_button.setStyleSheet( self.receive_mode_button.setStyleSheet(
self.common.css["mode_switcher_selected_style"] self.common.gui.css["mode_switcher_selected_style"]
) )
self.website_mode_button.setStyleSheet( self.website_mode_button.setStyleSheet(
self.common.css["mode_switcher_unselected_style"] self.common.gui.css["mode_switcher_unselected_style"]
) )
self.share_mode.hide() self.share_mode.hide()

View File

@ -50,7 +50,9 @@ class DropHereLabel(QtWidgets.QLabel):
) )
else: else:
self.setText(strings._("gui_drag_and_drop")) self.setText(strings._("gui_drag_and_drop"))
self.setStyleSheet(self.common.css["share_file_selection_drop_here_label"]) self.setStyleSheet(
self.common.gui.css["share_file_selection_drop_here_label"]
)
self.hide() self.hide()
@ -75,7 +77,7 @@ class DropCountLabel(QtWidgets.QLabel):
self.setAcceptDrops(True) self.setAcceptDrops(True)
self.setAlignment(QtCore.Qt.AlignCenter) self.setAlignment(QtCore.Qt.AlignCenter)
self.setText(strings._("gui_drag_and_drop")) self.setText(strings._("gui_drag_and_drop"))
self.setStyleSheet(self.common.css["share_file_selection_drop_count_label"]) self.setStyleSheet(self.common.gui.css["share_file_selection_drop_count_label"])
self.hide() self.hide()
def dragEnterEvent(self, event): def dragEnterEvent(self, event):
@ -169,7 +171,7 @@ class FileList(QtWidgets.QListWidget):
dragEnterEvent for dragging files and directories into the widget. dragEnterEvent for dragging files and directories into the widget.
""" """
if event.mimeData().hasUrls: if event.mimeData().hasUrls:
self.setStyleSheet(self.common.css["share_file_list_drag_enter"]) self.setStyleSheet(self.common.gui.css["share_file_list_drag_enter"])
count = len(event.mimeData().urls()) count = len(event.mimeData().urls())
self.drop_count.setText(f"+{count}") self.drop_count.setText(f"+{count}")
@ -189,7 +191,7 @@ class FileList(QtWidgets.QListWidget):
""" """
dragLeaveEvent for dragging files and directories into the widget. dragLeaveEvent for dragging files and directories into the widget.
""" """
self.setStyleSheet(self.common.css["share_file_list_drag_leave"]) self.setStyleSheet(self.common.gui.css["share_file_list_drag_leave"])
self.drop_count.hide() self.drop_count.hide()
event.accept() event.accept()
self.update() self.update()
@ -217,7 +219,7 @@ class FileList(QtWidgets.QListWidget):
else: else:
event.ignore() event.ignore()
self.setStyleSheet(self.common.css["share_file_list_drag_leave"]) self.setStyleSheet(self.common.gui.css["share_file_list_drag_leave"])
self.drop_count.hide() self.drop_count.hide()
self.files_dropped.emit() self.files_dropped.emit()
@ -254,7 +256,7 @@ class FileList(QtWidgets.QListWidget):
# Item's filename attribute and size labels # Item's filename attribute and size labels
item.filename = filename item.filename = filename
item_size = QtWidgets.QLabel(size_readable) item_size = QtWidgets.QLabel(size_readable)
item_size.setStyleSheet(self.common.css["share_file_list_item_size"]) item_size.setStyleSheet(self.common.gui.css["share_file_list_item_size"])
item.basename = os.path.basename(filename.rstrip("/")) item.basename = os.path.basename(filename.rstrip("/"))
# Use the basename as the method with which to sort the list # Use the basename as the method with which to sort the list

View File

@ -122,7 +122,7 @@ class ShareHistoryItem(HistoryItem):
self.progress_bar.setMaximum(total_bytes) self.progress_bar.setMaximum(total_bytes)
self.progress_bar.setValue(0) self.progress_bar.setValue(0)
self.progress_bar.setStyleSheet( self.progress_bar.setStyleSheet(
self.common.css["downloads_uploads_progress_bar"] self.common.gui.css["downloads_uploads_progress_bar"]
) )
self.progress_bar.total_bytes = total_bytes self.progress_bar.total_bytes = total_bytes
@ -193,7 +193,7 @@ class ReceiveHistoryItemFile(QtWidgets.QWidget):
# File size label # File size label
self.filesize_label = QtWidgets.QLabel() self.filesize_label = QtWidgets.QLabel()
self.filesize_label.setStyleSheet(self.common.css["receive_file_size"]) self.filesize_label.setStyleSheet(self.common.gui.css["receive_file_size"])
self.filesize_label.hide() self.filesize_label.hide()
# Folder button # Folder button
@ -290,14 +290,14 @@ class ReceiveHistoryItem(HistoryItem):
self.progress_bar.setMinimum(0) self.progress_bar.setMinimum(0)
self.progress_bar.setValue(0) self.progress_bar.setValue(0)
self.progress_bar.setStyleSheet( self.progress_bar.setStyleSheet(
self.common.css["downloads_uploads_progress_bar"] self.common.gui.css["downloads_uploads_progress_bar"]
) )
# This layout contains file widgets # This layout contains file widgets
self.files_layout = QtWidgets.QVBoxLayout() self.files_layout = QtWidgets.QVBoxLayout()
self.files_layout.setContentsMargins(0, 0, 0, 0) self.files_layout.setContentsMargins(0, 0, 0, 0)
files_widget = QtWidgets.QWidget() files_widget = QtWidgets.QWidget()
files_widget.setStyleSheet(self.common.css["receive_file"]) files_widget.setStyleSheet(self.common.gui.css["receive_file"])
files_widget.setLayout(self.files_layout) files_widget.setLayout(self.files_layout)
# Layout # Layout
@ -405,7 +405,7 @@ class IndividualFileHistoryItem(HistoryItem):
self.started_dt.strftime("%b %d, %I:%M%p") self.started_dt.strftime("%b %d, %I:%M%p")
) )
self.timestamp_label.setStyleSheet( self.timestamp_label.setStyleSheet(
self.common.css["history_individual_file_timestamp_label"] self.common.gui.css["history_individual_file_timestamp_label"]
) )
self.path_label = QtWidgets.QLabel(self.path) self.path_label = QtWidgets.QLabel(self.path)
self.status_code_label = QtWidgets.QLabel() self.status_code_label = QtWidgets.QLabel()
@ -417,7 +417,7 @@ class IndividualFileHistoryItem(HistoryItem):
self.progress_bar.setAlignment(QtCore.Qt.AlignHCenter) self.progress_bar.setAlignment(QtCore.Qt.AlignHCenter)
self.progress_bar.setValue(0) self.progress_bar.setValue(0)
self.progress_bar.setStyleSheet( self.progress_bar.setStyleSheet(
self.common.css["downloads_uploads_progress_bar"] self.common.gui.css["downloads_uploads_progress_bar"]
) )
# Text layout # Text layout
@ -438,11 +438,11 @@ class IndividualFileHistoryItem(HistoryItem):
self.status_code_label.setText(str(data["status_code"])) self.status_code_label.setText(str(data["status_code"]))
if data["status_code"] >= 200 and data["status_code"] < 300: if data["status_code"] >= 200 and data["status_code"] < 300:
self.status_code_label.setStyleSheet( self.status_code_label.setStyleSheet(
self.common.css["history_individual_file_status_code_label_2xx"] self.common.gui.css["history_individual_file_status_code_label_2xx"]
) )
if data["status_code"] >= 400 and data["status_code"] < 500: if data["status_code"] >= 400 and data["status_code"] < 500:
self.status_code_label.setStyleSheet( self.status_code_label.setStyleSheet(
self.common.css["history_individual_file_status_code_label_4xx"] self.common.gui.css["history_individual_file_status_code_label_4xx"]
) )
self.status = HistoryItem.STATUS_FINISHED self.status = HistoryItem.STATUS_FINISHED
self.progress_bar.hide() self.progress_bar.hide()
@ -464,7 +464,7 @@ class IndividualFileHistoryItem(HistoryItem):
if downloaded_bytes == self.progress_bar.total_bytes: if downloaded_bytes == self.progress_bar.total_bytes:
self.status_code_label.setText("200") self.status_code_label.setText("200")
self.status_code_label.setStyleSheet( self.status_code_label.setStyleSheet(
self.common.css["history_individual_file_status_code_label_2xx"] self.common.gui.css["history_individual_file_status_code_label_2xx"]
) )
self.progress_bar.hide() self.progress_bar.hide()
self.status = HistoryItem.STATUS_FINISHED self.status = HistoryItem.STATUS_FINISHED
@ -586,19 +586,19 @@ class History(QtWidgets.QWidget):
# In progress, completed, and requests labels # In progress, completed, and requests labels
self.in_progress_label = QtWidgets.QLabel() self.in_progress_label = QtWidgets.QLabel()
self.in_progress_label.setStyleSheet(self.common.css["mode_info_label"]) self.in_progress_label.setStyleSheet(self.common.gui.css["mode_info_label"])
self.completed_label = QtWidgets.QLabel() self.completed_label = QtWidgets.QLabel()
self.completed_label.setStyleSheet(self.common.css["mode_info_label"]) self.completed_label.setStyleSheet(self.common.gui.css["mode_info_label"])
self.requests_label = QtWidgets.QLabel() self.requests_label = QtWidgets.QLabel()
self.requests_label.setStyleSheet(self.common.css["mode_info_label"]) self.requests_label.setStyleSheet(self.common.gui.css["mode_info_label"])
# Header # Header
self.header_label = QtWidgets.QLabel(header_text) self.header_label = QtWidgets.QLabel(header_text)
self.header_label.setStyleSheet(self.common.css["downloads_uploads_label"]) self.header_label.setStyleSheet(self.common.gui.css["downloads_uploads_label"])
self.clear_button = QtWidgets.QPushButton( self.clear_button = QtWidgets.QPushButton(
strings._("gui_all_modes_clear_history") strings._("gui_all_modes_clear_history")
) )
self.clear_button.setStyleSheet(self.common.css["downloads_uploads_clear"]) self.clear_button.setStyleSheet(self.common.gui.css["downloads_uploads_clear"])
self.clear_button.setFlat(True) self.clear_button.setFlat(True)
self.clear_button.clicked.connect(self.reset) self.clear_button.clicked.connect(self.reset)
header_layout = QtWidgets.QHBoxLayout() header_layout = QtWidgets.QHBoxLayout()
@ -615,14 +615,16 @@ class History(QtWidgets.QWidget):
self.empty_image.setPixmap(empty_image) self.empty_image.setPixmap(empty_image)
self.empty_text = QtWidgets.QLabel(empty_text) self.empty_text = QtWidgets.QLabel(empty_text)
self.empty_text.setAlignment(QtCore.Qt.AlignCenter) self.empty_text.setAlignment(QtCore.Qt.AlignCenter)
self.empty_text.setStyleSheet(self.common.css["downloads_uploads_empty_text"]) self.empty_text.setStyleSheet(
self.common.gui.css["downloads_uploads_empty_text"]
)
empty_layout = QtWidgets.QVBoxLayout() empty_layout = QtWidgets.QVBoxLayout()
empty_layout.addStretch() empty_layout.addStretch()
empty_layout.addWidget(self.empty_image) empty_layout.addWidget(self.empty_image)
empty_layout.addWidget(self.empty_text) empty_layout.addWidget(self.empty_text)
empty_layout.addStretch() empty_layout.addStretch()
self.empty = QtWidgets.QWidget() self.empty = QtWidgets.QWidget()
self.empty.setStyleSheet(self.common.css["downloads_uploads_empty"]) self.empty.setStyleSheet(self.common.gui.css["downloads_uploads_empty"])
self.empty.setLayout(empty_layout) self.empty.setLayout(empty_layout)
# When there are items # When there are items
@ -759,7 +761,7 @@ class ToggleHistory(QtWidgets.QPushButton):
self.indicator_count = 0 self.indicator_count = 0
self.indicator_label = QtWidgets.QLabel(parent=self) self.indicator_label = QtWidgets.QLabel(parent=self)
self.indicator_label.setStyleSheet( self.indicator_label.setStyleSheet(
self.common.css["download_uploads_indicator"] self.common.gui.css["download_uploads_indicator"]
) )
self.update_indicator() self.update_indicator()

View File

@ -69,7 +69,9 @@ class ShareMode(Mode):
# Filesize warning # Filesize warning
self.filesize_warning = QtWidgets.QLabel() self.filesize_warning = QtWidgets.QLabel()
self.filesize_warning.setWordWrap(True) self.filesize_warning.setWordWrap(True)
self.filesize_warning.setStyleSheet(self.common.css["share_filesize_warning"]) self.filesize_warning.setStyleSheet(
self.common.gui.css["share_filesize_warning"]
)
self.filesize_warning.hide() self.filesize_warning.hide()
# Download history # Download history
@ -372,7 +374,7 @@ class ZipProgressBar(QtWidgets.QProgressBar):
self.setMinimumWidth(200) self.setMinimumWidth(200)
self.setValue(0) self.setValue(0)
self.setFormat(strings._("zip_progress_bar_format")) self.setFormat(strings._("zip_progress_bar_format"))
self.setStyleSheet(self.common.css["share_zip_progess_bar"]) self.setStyleSheet(self.common.gui.css["share_zip_progess_bar"])
self._total_files_size = total_files_size self._total_files_size = total_files_size
self._processed_size = 0 self._processed_size = 0

View File

@ -71,7 +71,9 @@ class WebsiteMode(Mode):
# Filesize warning # Filesize warning
self.filesize_warning = QtWidgets.QLabel() self.filesize_warning = QtWidgets.QLabel()
self.filesize_warning.setWordWrap(True) self.filesize_warning.setWordWrap(True)
self.filesize_warning.setStyleSheet(self.common.css["share_filesize_warning"]) self.filesize_warning.setStyleSheet(
self.common.gui.css["share_filesize_warning"]
)
self.filesize_warning.hide() self.filesize_warning.hide()
# Download history # Download history

View File

@ -151,11 +151,13 @@ class ServerStatus(QtWidgets.QWidget):
self.url.setFont(url_font) self.url.setFont(url_font)
self.url.setWordWrap(True) self.url.setWordWrap(True)
self.url.setMinimumSize(self.url.sizeHint()) self.url.setMinimumSize(self.url.sizeHint())
self.url.setStyleSheet(self.common.css["server_status_url"]) self.url.setStyleSheet(self.common.gui.css["server_status_url"])
self.copy_url_button = QtWidgets.QPushButton(strings._("gui_copy_url")) self.copy_url_button = QtWidgets.QPushButton(strings._("gui_copy_url"))
self.copy_url_button.setFlat(True) self.copy_url_button.setFlat(True)
self.copy_url_button.setStyleSheet(self.common.css["server_status_url_buttons"]) self.copy_url_button.setStyleSheet(
self.common.gui.css["server_status_url_buttons"]
)
self.copy_url_button.setMinimumHeight(65) self.copy_url_button.setMinimumHeight(65)
self.copy_url_button.clicked.connect(self.copy_url) self.copy_url_button.clicked.connect(self.copy_url)
self.copy_hidservauth_button = QtWidgets.QPushButton( self.copy_hidservauth_button = QtWidgets.QPushButton(
@ -163,7 +165,7 @@ class ServerStatus(QtWidgets.QWidget):
) )
self.copy_hidservauth_button.setFlat(True) self.copy_hidservauth_button.setFlat(True)
self.copy_hidservauth_button.setStyleSheet( self.copy_hidservauth_button.setStyleSheet(
self.common.css["server_status_url_buttons"] self.common.gui.css["server_status_url_buttons"]
) )
self.copy_hidservauth_button.clicked.connect(self.copy_hidservauth) self.copy_hidservauth_button.clicked.connect(self.copy_hidservauth)
url_buttons_layout = QtWidgets.QHBoxLayout() url_buttons_layout = QtWidgets.QHBoxLayout()
@ -329,7 +331,7 @@ class ServerStatus(QtWidgets.QWidget):
if self.status == self.STATUS_STOPPED: if self.status == self.STATUS_STOPPED:
self.server_button.setStyleSheet( self.server_button.setStyleSheet(
self.common.css["server_status_button_stopped"] self.common.gui.css["server_status_button_stopped"]
) )
self.server_button.setEnabled(True) self.server_button.setEnabled(True)
if self.mode == ServerStatus.MODE_SHARE: if self.mode == ServerStatus.MODE_SHARE:
@ -345,7 +347,7 @@ class ServerStatus(QtWidgets.QWidget):
self.autostop_timer_container.show() self.autostop_timer_container.show()
elif self.status == self.STATUS_STARTED: elif self.status == self.STATUS_STARTED:
self.server_button.setStyleSheet( self.server_button.setStyleSheet(
self.common.css["server_status_button_started"] self.common.gui.css["server_status_button_started"]
) )
self.server_button.setEnabled(True) self.server_button.setEnabled(True)
if self.mode == ServerStatus.MODE_SHARE: if self.mode == ServerStatus.MODE_SHARE:
@ -367,7 +369,7 @@ class ServerStatus(QtWidgets.QWidget):
) )
elif self.status == self.STATUS_WORKING: elif self.status == self.STATUS_WORKING:
self.server_button.setStyleSheet( self.server_button.setStyleSheet(
self.common.css["server_status_button_working"] self.common.gui.css["server_status_button_working"]
) )
self.server_button.setEnabled(True) self.server_button.setEnabled(True)
if self.autostart_timer_datetime: if self.autostart_timer_datetime:
@ -385,7 +387,7 @@ class ServerStatus(QtWidgets.QWidget):
self.autostop_timer_container.hide() self.autostop_timer_container.hide()
else: else:
self.server_button.setStyleSheet( self.server_button.setStyleSheet(
self.common.css["server_status_button_working"] self.common.gui.css["server_status_button_working"]
) )
self.server_button.setEnabled(False) self.server_button.setEnabled(False)
self.server_button.setText(strings._("gui_please_wait")) self.server_button.setText(strings._("gui_please_wait"))

View File

@ -76,7 +76,7 @@ class SettingsDialog(QtWidgets.QDialog):
"https://github.com/micahflee/onionshare/wiki/Public-Mode" "https://github.com/micahflee/onionshare/wiki/Public-Mode"
) )
) )
public_mode_label.setStyleSheet(self.common.css["settings_whats_this"]) public_mode_label.setStyleSheet(self.common.gui.css["settings_whats_this"])
public_mode_label.setTextInteractionFlags(QtCore.Qt.TextBrowserInteraction) public_mode_label.setTextInteractionFlags(QtCore.Qt.TextBrowserInteraction)
public_mode_label.setOpenExternalLinks(True) public_mode_label.setOpenExternalLinks(True)
public_mode_label.setMinimumSize(public_mode_label.sizeHint()) public_mode_label.setMinimumSize(public_mode_label.sizeHint())
@ -99,7 +99,7 @@ class SettingsDialog(QtWidgets.QDialog):
"https://github.com/micahflee/onionshare/wiki/Using-the-Auto-Start-Timer" "https://github.com/micahflee/onionshare/wiki/Using-the-Auto-Start-Timer"
) )
) )
autostart_timer_label.setStyleSheet(self.common.css["settings_whats_this"]) autostart_timer_label.setStyleSheet(self.common.gui.css["settings_whats_this"])
autostart_timer_label.setTextInteractionFlags(QtCore.Qt.TextBrowserInteraction) autostart_timer_label.setTextInteractionFlags(QtCore.Qt.TextBrowserInteraction)
autostart_timer_label.setOpenExternalLinks(True) autostart_timer_label.setOpenExternalLinks(True)
autostart_timer_label.setMinimumSize(public_mode_label.sizeHint()) autostart_timer_label.setMinimumSize(public_mode_label.sizeHint())
@ -122,7 +122,7 @@ class SettingsDialog(QtWidgets.QDialog):
"https://github.com/micahflee/onionshare/wiki/Using-the-Auto-Stop-Timer" "https://github.com/micahflee/onionshare/wiki/Using-the-Auto-Stop-Timer"
) )
) )
autostop_timer_label.setStyleSheet(self.common.css["settings_whats_this"]) autostop_timer_label.setStyleSheet(self.common.gui.css["settings_whats_this"])
autostop_timer_label.setTextInteractionFlags(QtCore.Qt.TextBrowserInteraction) autostop_timer_label.setTextInteractionFlags(QtCore.Qt.TextBrowserInteraction)
autostop_timer_label.setOpenExternalLinks(True) autostop_timer_label.setOpenExternalLinks(True)
autostop_timer_label.setMinimumSize(public_mode_label.sizeHint()) autostop_timer_label.setMinimumSize(public_mode_label.sizeHint())
@ -149,7 +149,7 @@ class SettingsDialog(QtWidgets.QDialog):
strings._("gui_connect_to_tor_for_onion_settings") strings._("gui_connect_to_tor_for_onion_settings")
) )
self.connect_to_tor_label.setStyleSheet( self.connect_to_tor_label.setStyleSheet(
self.common.css["settings_connect_to_tor"] self.common.gui.css["settings_connect_to_tor"]
) )
# Whether or not to save the Onion private key for reuse (persistent URL mode) # Whether or not to save the Onion private key for reuse (persistent URL mode)
@ -163,7 +163,7 @@ class SettingsDialog(QtWidgets.QDialog):
"https://github.com/micahflee/onionshare/wiki/Using-a-Persistent-URL" "https://github.com/micahflee/onionshare/wiki/Using-a-Persistent-URL"
) )
) )
save_private_key_label.setStyleSheet(self.common.css["settings_whats_this"]) save_private_key_label.setStyleSheet(self.common.gui.css["settings_whats_this"])
save_private_key_label.setTextInteractionFlags(QtCore.Qt.TextBrowserInteraction) save_private_key_label.setTextInteractionFlags(QtCore.Qt.TextBrowserInteraction)
save_private_key_label.setOpenExternalLinks(True) save_private_key_label.setOpenExternalLinks(True)
save_private_key_layout = QtWidgets.QHBoxLayout() save_private_key_layout = QtWidgets.QHBoxLayout()
@ -188,7 +188,7 @@ class SettingsDialog(QtWidgets.QDialog):
"https://github.com/micahflee/onionshare/wiki/Legacy-Addresses" "https://github.com/micahflee/onionshare/wiki/Legacy-Addresses"
) )
) )
use_legacy_v2_onions_label.setStyleSheet(self.common.css["settings_whats_this"]) use_legacy_v2_onions_label.setStyleSheet(self.common.gui.css["settings_whats_this"])
use_legacy_v2_onions_label.setTextInteractionFlags( use_legacy_v2_onions_label.setTextInteractionFlags(
QtCore.Qt.TextBrowserInteraction QtCore.Qt.TextBrowserInteraction
) )
@ -211,7 +211,7 @@ class SettingsDialog(QtWidgets.QDialog):
"https://github.com/micahflee/onionshare/wiki/Stealth-Onion-Services" "https://github.com/micahflee/onionshare/wiki/Stealth-Onion-Services"
) )
) )
use_stealth_label.setStyleSheet(self.common.css["settings_whats_this"]) use_stealth_label.setStyleSheet(self.common.gui.css["settings_whats_this"])
use_stealth_label.setTextInteractionFlags(QtCore.Qt.TextBrowserInteraction) use_stealth_label.setTextInteractionFlags(QtCore.Qt.TextBrowserInteraction)
use_stealth_label.setOpenExternalLinks(True) use_stealth_label.setOpenExternalLinks(True)
use_stealth_label.setMinimumSize(use_stealth_label.sizeHint()) use_stealth_label.setMinimumSize(use_stealth_label.sizeHint())
@ -305,7 +305,7 @@ class SettingsDialog(QtWidgets.QDialog):
"https://github.com/micahflee/onionshare/wiki/Content-Security-Policy" "https://github.com/micahflee/onionshare/wiki/Content-Security-Policy"
) )
) )
csp_header_label.setStyleSheet(self.common.css["settings_whats_this"]) csp_header_label.setStyleSheet(self.common.gui.css["settings_whats_this"])
csp_header_label.setTextInteractionFlags(QtCore.Qt.TextBrowserInteraction) csp_header_label.setTextInteractionFlags(QtCore.Qt.TextBrowserInteraction)
csp_header_label.setOpenExternalLinks(True) csp_header_label.setOpenExternalLinks(True)
csp_header_label.setMinimumSize(csp_header_label.sizeHint()) csp_header_label.setMinimumSize(csp_header_label.sizeHint())
@ -673,7 +673,7 @@ class SettingsDialog(QtWidgets.QDialog):
) )
self.cancel_button.clicked.connect(self.cancel_clicked) self.cancel_button.clicked.connect(self.cancel_clicked)
version_label = QtWidgets.QLabel(f"OnionShare {self.common.version}") version_label = QtWidgets.QLabel(f"OnionShare {self.common.version}")
version_label.setStyleSheet(self.common.css["settings_version"]) version_label.setStyleSheet(self.common.gui.css["settings_version"])
self.help_button = QtWidgets.QPushButton(strings._("gui_settings_button_help")) self.help_button = QtWidgets.QPushButton(strings._("gui_settings_button_help"))
self.help_button.clicked.connect(self.help_clicked) self.help_button.clicked.connect(self.help_clicked)
buttons_layout = QtWidgets.QHBoxLayout() buttons_layout = QtWidgets.QHBoxLayout()
@ -685,7 +685,7 @@ class SettingsDialog(QtWidgets.QDialog):
# Tor network connection status # Tor network connection status
self.tor_status = QtWidgets.QLabel() self.tor_status = QtWidgets.QLabel()
self.tor_status.setStyleSheet(self.common.css["settings_tor_status"]) self.tor_status.setStyleSheet(self.common.gui.css["settings_tor_status"])
self.tor_status.hide() self.tor_status.hide()
# Layout # Layout