Share mode and website mode are looking awesome

This commit is contained in:
Micah Lee 2020-08-20 17:16:47 -04:00
parent 298cfa3d3f
commit 327253fc26
No known key found for this signature in database
GPG Key ID: 403C2657CD994F73
6 changed files with 67 additions and 45 deletions

View File

@ -254,9 +254,14 @@ class GuiCommon:
color: #333333; color: #333333;
} }
""", """,
"share_file_selection_drop_here_header_label": """
QLabel {
color: #333333;
font-size: 30px;
}""",
"share_file_selection_drop_here_label": """ "share_file_selection_drop_here_label": """
QLabel { QLabel {
color: #999999; color: #666666;
}""", }""",
"share_file_selection_drop_count_label": """ "share_file_selection_drop_count_label": """
QLabel { QLabel {

View File

@ -25,42 +25,55 @@ from onionshare import strings
from ...widgets import Alert, AddFileDialog from ...widgets import Alert, AddFileDialog
class DropHereLabel(QtWidgets.QLabel): class DropHereWidget(QtWidgets.QWidget):
""" """
When there are no files or folders in the FileList yet, display the When there are no files or folders in the FileList yet, display the
'drop files here' message and graphic. 'drop files here' message and graphic.
""" """
def __init__(self, common, parent, image=False): def __init__(self, common, image_filename, header_text, w, h, parent):
self.parent = parent super(DropHereWidget, self).__init__(parent)
super(DropHereLabel, self).__init__(parent=parent)
self.common = common self.common = common
self.setAcceptDrops(True) self.setAcceptDrops(True)
self.setAlignment(QtCore.Qt.AlignCenter)
if image: self.image_label = QtWidgets.QLabel(parent=self)
self.setPixmap( self.image_label.setPixmap(
QtGui.QPixmap.fromImage( QtGui.QPixmap.fromImage(
QtGui.QImage( QtGui.QImage(self.common.get_resource_path(image_filename))
self.common.get_resource_path("images/logo_transparent.png")
)
)
)
else:
self.setText(strings._("gui_drag_and_drop"))
self.setStyleSheet(
self.common.gui.css["share_file_selection_drop_here_label"]
) )
)
self.image_label.setAlignment(QtCore.Qt.AlignCenter)
self.image_label.show()
self.header_label = QtWidgets.QLabel(parent=self)
self.header_label.setText(header_text)
self.header_label.setStyleSheet(
self.common.gui.css["share_file_selection_drop_here_header_label"]
)
self.header_label.setAlignment(QtCore.Qt.AlignCenter)
self.header_label.show()
self.text_label = QtWidgets.QLabel(parent=self)
self.text_label.setText(strings._("gui_drag_and_drop"))
self.text_label.setStyleSheet(
self.common.gui.css["share_file_selection_drop_here_label"]
)
self.text_label.setAlignment(QtCore.Qt.AlignCenter)
self.text_label.show()
self.resize(w, h)
self.hide() self.hide()
def dragEnterEvent(self, event): def dragEnterEvent(self, event):
self.parent.drop_here_image.hide() self.text_label.hide()
self.parent.drop_here_text.hide()
event.accept() event.accept()
def resize(self, w, h):
self.setGeometry(0, 0, w, h)
self.image_label.setGeometry(0, 0, w, h - 100)
self.header_label.setGeometry(0, 340, w, h - 340)
self.text_label.setGeometry(0, 410, w, h - 410)
class DropCountLabel(QtWidgets.QLabel): class DropCountLabel(QtWidgets.QLabel):
""" """
@ -93,7 +106,7 @@ class FileList(QtWidgets.QListWidget):
files_dropped = QtCore.pyqtSignal() files_dropped = QtCore.pyqtSignal()
files_updated = QtCore.pyqtSignal() files_updated = QtCore.pyqtSignal()
def __init__(self, common, parent=None): def __init__(self, common, background_image_filename, header_text, parent=None):
super(FileList, self).__init__(parent) super(FileList, self).__init__(parent)
self.common = common self.common = common
@ -103,8 +116,14 @@ class FileList(QtWidgets.QListWidget):
self.setSortingEnabled(True) self.setSortingEnabled(True)
self.setMinimumHeight(160) self.setMinimumHeight(160)
self.setSelectionMode(QtWidgets.QAbstractItemView.ExtendedSelection) self.setSelectionMode(QtWidgets.QAbstractItemView.ExtendedSelection)
self.drop_here_image = DropHereLabel(self.common, self, True) self.drop_here = DropHereWidget(
self.drop_here_text = DropHereLabel(self.common, self, False) self.common,
background_image_filename,
header_text,
self.width(),
self.height(),
self,
)
self.drop_count = DropCountLabel(self.common, self) self.drop_count = DropCountLabel(self.common, self)
self.resizeEvent(None) self.resizeEvent(None)
self.setVerticalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOn) self.setVerticalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOn)
@ -115,11 +134,9 @@ class FileList(QtWidgets.QListWidget):
""" """
# file list should have a background image if empty # file list should have a background image if empty
if self.count() == 0: if self.count() == 0:
self.drop_here_image.show() self.drop_here.show()
self.drop_here_text.show()
else: else:
self.drop_here_image.hide() self.drop_here.hide()
self.drop_here_text.hide()
def server_started(self): def server_started(self):
""" """
@ -144,9 +161,7 @@ class FileList(QtWidgets.QListWidget):
""" """
When the widget is resized, resize the drop files image and text. When the widget is resized, resize the drop files image and text.
""" """
offset = 70 self.drop_here.resize(self.width(), self.height())
self.drop_here_image.setGeometry(0, 0, self.width(), self.height() - offset)
self.drop_here_text.setGeometry(0, offset, self.width(), self.height() - offset)
if self.count() > 0: if self.count() > 0:
# Add and delete an empty item, to force all items to get redrawn # Add and delete an empty item, to force all items to get redrawn
@ -313,7 +328,7 @@ class FileSelection(QtWidgets.QVBoxLayout):
delete the files and folders. delete the files and folders.
""" """
def __init__(self, common, parent): def __init__(self, common, background_image_filename, header_text, parent):
super(FileSelection, self).__init__() super(FileSelection, self).__init__()
self.common = common self.common = common
@ -322,7 +337,7 @@ class FileSelection(QtWidgets.QVBoxLayout):
self.server_on = False self.server_on = False
# File list # File list
self.file_list = FileList(self.common) self.file_list = FileList(self.common, background_image_filename, header_text)
self.file_list.itemSelectionChanged.connect(self.update) self.file_list.itemSelectionChanged.connect(self.update)
self.file_list.files_dropped.connect(self.update) self.file_list.files_dropped.connect(self.update)
self.file_list.files_updated.connect(self.update) self.file_list.files_updated.connect(self.update)

View File

@ -47,9 +47,6 @@ class ShareMode(Mode):
# Create the Web object # Create the Web object
self.web = Web(self.common, True, self.settings, "share") self.web = Web(self.common, True, self.settings, "share")
# Header
self.header_label.setText(strings._("gui_new_tab_share_button"))
# Settings # Settings
self.autostop_sharing_checkbox = QtWidgets.QCheckBox() self.autostop_sharing_checkbox = QtWidgets.QCheckBox()
self.autostop_sharing_checkbox.clicked.connect( self.autostop_sharing_checkbox.clicked.connect(
@ -68,7 +65,12 @@ class ShareMode(Mode):
) )
# File selection # File selection
self.file_selection = FileSelection(self.common, self) self.file_selection = FileSelection(
self.common,
"images/mode_share.png",
strings._("gui_new_tab_share_button"),
self,
)
if self.filenames: if self.filenames:
for filename in self.filenames: for filename in self.filenames:
self.file_selection.file_list.add_file(filename) self.file_selection.file_list.add_file(filename)
@ -162,7 +164,6 @@ class ShareMode(Mode):
# Wrapper layout # Wrapper layout
self.wrapper_layout = QtWidgets.QVBoxLayout() self.wrapper_layout = QtWidgets.QVBoxLayout()
self.wrapper_layout.addWidget(self.header_label)
self.wrapper_layout.addLayout(self.column_layout) self.wrapper_layout.addLayout(self.column_layout)
self.setLayout(self.wrapper_layout) self.setLayout(self.wrapper_layout)

View File

@ -49,9 +49,6 @@ class WebsiteMode(Mode):
# Create the Web object # Create the Web object
self.web = Web(self.common, True, self.settings, "website") self.web = Web(self.common, True, self.settings, "website")
# Header
self.header_label.setText(strings._("gui_new_tab_website_button"))
# Settings # Settings
self.disable_csp_checkbox = QtWidgets.QCheckBox() self.disable_csp_checkbox = QtWidgets.QCheckBox()
self.disable_csp_checkbox.clicked.connect(self.disable_csp_checkbox_clicked) self.disable_csp_checkbox.clicked.connect(self.disable_csp_checkbox_clicked)
@ -68,7 +65,12 @@ class WebsiteMode(Mode):
) )
# File selection # File selection
self.file_selection = FileSelection(self.common, self) self.file_selection = FileSelection(
self.common,
"images/mode_website.png",
strings._("gui_new_tab_website_button"),
self,
)
if self.filenames: if self.filenames:
for filename in self.filenames: for filename in self.filenames:
self.file_selection.file_list.add_file(filename) self.file_selection.file_list.add_file(filename)
@ -162,7 +164,6 @@ class WebsiteMode(Mode):
# Wrapper layout # Wrapper layout
self.wrapper_layout = QtWidgets.QVBoxLayout() self.wrapper_layout = QtWidgets.QVBoxLayout()
self.wrapper_layout.addWidget(self.header_label)
self.wrapper_layout.addLayout(self.column_layout) self.wrapper_layout.addLayout(self.column_layout)
self.setLayout(self.wrapper_layout) self.setLayout(self.wrapper_layout)

Binary file not shown.

Before

Width:  |  Height:  |  Size: 22 KiB

After

Width:  |  Height:  |  Size: 33 KiB

View File

@ -7,7 +7,7 @@
"close_on_autostop_timer": "Stopped because auto-stop timer ran out", "close_on_autostop_timer": "Stopped because auto-stop timer ran out",
"closing_automatically": "Stopped because transfer is complete", "closing_automatically": "Stopped because transfer is complete",
"large_filesize": "Warning: Sending a large share could take hours", "large_filesize": "Warning: Sending a large share could take hours",
"gui_drag_and_drop": "Drag and drop files and folders\nto start sharing", "gui_drag_and_drop": "Drag and drop files and folders to start sharing",
"gui_add": "Add", "gui_add": "Add",
"gui_add_files": "Add Files", "gui_add_files": "Add Files",
"gui_add_folder": "Add Folder", "gui_add_folder": "Add Folder",