diff --git a/onionshare_gui/gui_common.py b/onionshare_gui/gui_common.py index bf05dac0..13b16923 100644 --- a/onionshare_gui/gui_common.py +++ b/onionshare_gui/gui_common.py @@ -254,9 +254,14 @@ class GuiCommon: color: #333333; } """, + "share_file_selection_drop_here_header_label": """ + QLabel { + color: #333333; + font-size: 30px; + }""", "share_file_selection_drop_here_label": """ QLabel { - color: #999999; + color: #666666; }""", "share_file_selection_drop_count_label": """ QLabel { diff --git a/onionshare_gui/tab/mode/file_selection.py b/onionshare_gui/tab/mode/file_selection.py index 5a9e5d59..52163847 100644 --- a/onionshare_gui/tab/mode/file_selection.py +++ b/onionshare_gui/tab/mode/file_selection.py @@ -25,42 +25,55 @@ from onionshare import strings 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 'drop files here' message and graphic. """ - def __init__(self, common, parent, image=False): - self.parent = parent - super(DropHereLabel, self).__init__(parent=parent) - + def __init__(self, common, image_filename, header_text, w, h, parent): + super(DropHereWidget, self).__init__(parent) self.common = common - self.setAcceptDrops(True) - self.setAlignment(QtCore.Qt.AlignCenter) - if image: - self.setPixmap( - QtGui.QPixmap.fromImage( - QtGui.QImage( - 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 = QtWidgets.QLabel(parent=self) + self.image_label.setPixmap( + QtGui.QPixmap.fromImage( + QtGui.QImage(self.common.get_resource_path(image_filename)) ) + ) + 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() def dragEnterEvent(self, event): - self.parent.drop_here_image.hide() - self.parent.drop_here_text.hide() + self.text_label.hide() 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): """ @@ -93,7 +106,7 @@ class FileList(QtWidgets.QListWidget): files_dropped = 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) self.common = common @@ -103,8 +116,14 @@ class FileList(QtWidgets.QListWidget): self.setSortingEnabled(True) self.setMinimumHeight(160) self.setSelectionMode(QtWidgets.QAbstractItemView.ExtendedSelection) - self.drop_here_image = DropHereLabel(self.common, self, True) - self.drop_here_text = DropHereLabel(self.common, self, False) + self.drop_here = DropHereWidget( + self.common, + background_image_filename, + header_text, + self.width(), + self.height(), + self, + ) self.drop_count = DropCountLabel(self.common, self) self.resizeEvent(None) self.setVerticalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOn) @@ -115,11 +134,9 @@ class FileList(QtWidgets.QListWidget): """ # file list should have a background image if empty if self.count() == 0: - self.drop_here_image.show() - self.drop_here_text.show() + self.drop_here.show() else: - self.drop_here_image.hide() - self.drop_here_text.hide() + self.drop_here.hide() def server_started(self): """ @@ -144,9 +161,7 @@ class FileList(QtWidgets.QListWidget): """ When the widget is resized, resize the drop files image and text. """ - offset = 70 - self.drop_here_image.setGeometry(0, 0, self.width(), self.height() - offset) - self.drop_here_text.setGeometry(0, offset, self.width(), self.height() - offset) + self.drop_here.resize(self.width(), self.height()) if self.count() > 0: # 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. """ - def __init__(self, common, parent): + def __init__(self, common, background_image_filename, header_text, parent): super(FileSelection, self).__init__() self.common = common @@ -322,7 +337,7 @@ class FileSelection(QtWidgets.QVBoxLayout): self.server_on = False # 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.files_dropped.connect(self.update) self.file_list.files_updated.connect(self.update) diff --git a/onionshare_gui/tab/mode/share_mode/__init__.py b/onionshare_gui/tab/mode/share_mode/__init__.py index a81f83d4..aa386e3d 100644 --- a/onionshare_gui/tab/mode/share_mode/__init__.py +++ b/onionshare_gui/tab/mode/share_mode/__init__.py @@ -47,9 +47,6 @@ class ShareMode(Mode): # Create the Web object self.web = Web(self.common, True, self.settings, "share") - # Header - self.header_label.setText(strings._("gui_new_tab_share_button")) - # Settings self.autostop_sharing_checkbox = QtWidgets.QCheckBox() self.autostop_sharing_checkbox.clicked.connect( @@ -68,7 +65,12 @@ class ShareMode(Mode): ) # 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: for filename in self.filenames: self.file_selection.file_list.add_file(filename) @@ -162,7 +164,6 @@ class ShareMode(Mode): # Wrapper layout self.wrapper_layout = QtWidgets.QVBoxLayout() - self.wrapper_layout.addWidget(self.header_label) self.wrapper_layout.addLayout(self.column_layout) self.setLayout(self.wrapper_layout) diff --git a/onionshare_gui/tab/mode/website_mode/__init__.py b/onionshare_gui/tab/mode/website_mode/__init__.py index 6199812c..c520d8f7 100644 --- a/onionshare_gui/tab/mode/website_mode/__init__.py +++ b/onionshare_gui/tab/mode/website_mode/__init__.py @@ -49,9 +49,6 @@ class WebsiteMode(Mode): # Create the Web object self.web = Web(self.common, True, self.settings, "website") - # Header - self.header_label.setText(strings._("gui_new_tab_website_button")) - # Settings self.disable_csp_checkbox = QtWidgets.QCheckBox() self.disable_csp_checkbox.clicked.connect(self.disable_csp_checkbox_clicked) @@ -68,7 +65,12 @@ class WebsiteMode(Mode): ) # 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: for filename in self.filenames: self.file_selection.file_list.add_file(filename) @@ -162,7 +164,6 @@ class WebsiteMode(Mode): # Wrapper layout self.wrapper_layout = QtWidgets.QVBoxLayout() - self.wrapper_layout.addWidget(self.header_label) self.wrapper_layout.addLayout(self.column_layout) self.setLayout(self.wrapper_layout) diff --git a/share/images/mode_share.png b/share/images/mode_share.png index a1ca2abf..f2565bd5 100644 Binary files a/share/images/mode_share.png and b/share/images/mode_share.png differ diff --git a/share/locale/en.json b/share/locale/en.json index dc2f5208..61fc0e2e 100644 --- a/share/locale/en.json +++ b/share/locale/en.json @@ -7,7 +7,7 @@ "close_on_autostop_timer": "Stopped because auto-stop timer ran out", "closing_automatically": "Stopped because transfer is complete", "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_files": "Add Files", "gui_add_folder": "Add Folder",