summaryrefslogtreecommitdiff
path: root/desktop/src/onionshare/tab/mode
diff options
context:
space:
mode:
Diffstat (limited to 'desktop/src/onionshare/tab/mode')
-rw-r--r--desktop/src/onionshare/tab/mode/__init__.py52
-rw-r--r--desktop/src/onionshare/tab/mode/chat_mode/__init__.py22
-rw-r--r--desktop/src/onionshare/tab/mode/file_selection.py4
-rw-r--r--desktop/src/onionshare/tab/mode/history.py88
-rw-r--r--desktop/src/onionshare/tab/mode/mode_settings_widget.py50
-rw-r--r--desktop/src/onionshare/tab/mode/receive_mode/__init__.py116
-rw-r--r--desktop/src/onionshare/tab/mode/share_mode/__init__.py12
-rw-r--r--desktop/src/onionshare/tab/mode/share_mode/threads.py5
-rw-r--r--desktop/src/onionshare/tab/mode/website_mode/__init__.py14
9 files changed, 309 insertions, 54 deletions
diff --git a/desktop/src/onionshare/tab/mode/__init__.py b/desktop/src/onionshare/tab/mode/__init__.py
index 0cbccc51..aeecaf66 100644
--- a/desktop/src/onionshare/tab/mode/__init__.py
+++ b/desktop/src/onionshare/tab/mode/__init__.py
@@ -18,7 +18,7 @@ You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
"""
-from PySide2 import QtCore, QtWidgets, QtGui
+from PySide2 import QtCore, QtWidgets
from onionshare_cli.common import AutoStopTimer
@@ -158,9 +158,16 @@ class Mode(QtWidgets.QWidget):
)
)
else:
- self.server_status.server_button.setText(
- strings._("gui_please_wait")
- )
+ if self.common.platform == "Windows" or self.settings.get(
+ "general", "autostart_timer"
+ ):
+ self.server_status.server_button.setText(
+ strings._("gui_please_wait")
+ )
+ else:
+ self.server_status.server_button.setText(
+ strings._("gui_please_wait_no_button")
+ )
# If the auto-stop timer has stopped, stop the server
if self.server_status.status == ServerStatus.STATUS_STARTED:
@@ -354,14 +361,19 @@ class Mode(QtWidgets.QWidget):
self.app.onion.scheduled_key = None
self.app.onion.scheduled_auth_cookie = None
self.startup_thread.quit()
- if self.onion_thread:
- self.common.log("Mode", "cancel_server: quitting onion thread")
- self.onion_thread.terminate()
- self.onion_thread.wait()
- if self.web_thread:
- self.common.log("Mode", "cancel_server: quitting web thread")
- self.web_thread.terminate()
- self.web_thread.wait()
+
+ # Canceling only works in Windows
+ # https://github.com/onionshare/onionshare/issues/1371
+ if self.common.platform == "Windows":
+ if self.onion_thread:
+ self.common.log("Mode", "cancel_server: quitting onion thread")
+ self.onion_thread.terminate()
+ self.onion_thread.wait()
+ if self.web_thread:
+ self.common.log("Mode", "cancel_server: quitting web thread")
+ self.web_thread.terminate()
+ self.web_thread.wait()
+
self.stop_server()
def cancel_server_custom(self):
@@ -379,10 +391,10 @@ class Mode(QtWidgets.QWidget):
if self.server_status.status != ServerStatus.STATUS_STOPPED:
try:
self.web.stop(self.app.port)
- except:
+ except Exception:
# Probably we had no port to begin with (Onion service didn't start)
pass
- self.app.cleanup()
+ self.web.cleanup()
self.stop_server_custom()
@@ -447,12 +459,24 @@ class Mode(QtWidgets.QWidget):
"""
pass
+ def handle_request_upload_includes_message(self, event):
+ """
+ Handle REQUEST_UPLOAD_INCLUDES_MESSAGE event.
+ """
+ pass
+
def handle_request_upload_file_renamed(self, event):
"""
Handle REQUEST_UPLOAD_FILE_RENAMED event.
"""
pass
+ def handle_request_upload_message(self, event):
+ """
+ Handle REQUEST_UPLOAD_MESSAGE event.
+ """
+ pass
+
def handle_request_upload_set_dir(self, event):
"""
Handle REQUEST_UPLOAD_SET_DIR event.
diff --git a/desktop/src/onionshare/tab/mode/chat_mode/__init__.py b/desktop/src/onionshare/tab/mode/chat_mode/__init__.py
index 2312a64e..fe3e69f1 100644
--- a/desktop/src/onionshare/tab/mode/chat_mode/__init__.py
+++ b/desktop/src/onionshare/tab/mode/chat_mode/__init__.py
@@ -18,19 +18,13 @@ You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
"""
-import os
-import random
-import string
-
from PySide2 import QtCore, QtWidgets, QtGui
-from onionshare_cli.onion import *
-from onionshare_cli.common import Common
from onionshare_cli.web import Web
from .. import Mode
from .... import strings
-from ....widgets import MinimumWidthWidget
+from ....widgets import MinimumSizeWidget
from ....gui_common import GuiCommon
@@ -68,6 +62,11 @@ class ChatMode(Mode):
self.image = QtWidgets.QWidget()
self.image.setLayout(image_layout)
+ # Set title placeholder
+ self.mode_settings_widget.title_lineedit.setPlaceholderText(
+ strings._("gui_tab_name_chat")
+ )
+
# Server status
self.server_status.set_mode("chat")
self.server_status.server_started_finished.connect(self.update_primary_action)
@@ -83,17 +82,16 @@ class ChatMode(Mode):
# Top bar
top_bar_layout = QtWidgets.QHBoxLayout()
- top_bar_layout.addStretch()
+ # Add space at the top, same height as the toggle history bar in other modes
+ top_bar_layout.addWidget(MinimumSizeWidget(0, 30))
# Main layout
self.main_layout = QtWidgets.QVBoxLayout()
self.main_layout.addLayout(top_bar_layout)
- self.main_layout.addStretch()
self.main_layout.addWidget(header_label)
- self.main_layout.addWidget(self.primary_action)
+ self.main_layout.addWidget(self.primary_action, stretch=1)
self.main_layout.addWidget(self.server_status)
- self.main_layout.addStretch()
- self.main_layout.addWidget(MinimumWidthWidget(700))
+ self.main_layout.addWidget(MinimumSizeWidget(700, 0))
# Column layout
self.column_layout = QtWidgets.QHBoxLayout()
diff --git a/desktop/src/onionshare/tab/mode/file_selection.py b/desktop/src/onionshare/tab/mode/file_selection.py
index e9604ec5..302f07b9 100644
--- a/desktop/src/onionshare/tab/mode/file_selection.py
+++ b/desktop/src/onionshare/tab/mode/file_selection.py
@@ -72,8 +72,8 @@ class DropHereWidget(QtWidgets.QWidget):
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, 310, w, h - 380)
- self.text_label.setGeometry(0, 360, w, h - 400)
+ self.header_label.setGeometry(0, 290, w, h - 360)
+ self.text_label.setGeometry(0, 340, w, h - 380)
class DropCountLabel(QtWidgets.QLabel):
diff --git a/desktop/src/onionshare/tab/mode/history.py b/desktop/src/onionshare/tab/mode/history.py
index 45e37c75..091905f7 100644
--- a/desktop/src/onionshare/tab/mode/history.py
+++ b/desktop/src/onionshare/tab/mode/history.py
@@ -148,6 +148,7 @@ class ShareHistoryItem(HistoryItem):
# Change the label
self.label.setText(self.get_finished_label_text(self.started_dt))
+ self.label.setStyleSheet(self.common.gui.css["history_default_label"])
self.status = HistoryItem.STATUS_FINISHED
else:
@@ -253,7 +254,7 @@ class ReceiveHistoryItemFile(QtWidgets.QWidget):
try:
# If nautilus is available, open it
subprocess.Popen(["xdg-open", self.dir])
- except:
+ except Exception:
Alert(
self.common,
strings._("gui_open_folder_error").format(abs_filename),
@@ -268,6 +269,60 @@ class ReceiveHistoryItemFile(QtWidgets.QWidget):
subprocess.Popen(["explorer", f"/select,{abs_filename}"])
+class ReceiveHistoryItemMessage(QtWidgets.QWidget):
+ def __init__(
+ self,
+ common,
+ ):
+ super(ReceiveHistoryItemMessage, self).__init__()
+ self.common = common
+ self.filename = None
+
+ # Read message button
+ message_pixmap = QtGui.QPixmap.fromImage(
+ QtGui.QImage(GuiCommon.get_resource_path("images/open_message.png"))
+ )
+ message_icon = QtGui.QIcon(message_pixmap)
+ self.message_button = QtWidgets.QPushButton(
+ strings._("history_receive_read_message_button")
+ )
+ self.message_button.setStyleSheet(self.common.gui.css["receive_message_button"])
+ self.message_button.clicked.connect(self.open_message)
+ self.message_button.setIcon(message_icon)
+ self.message_button.setIconSize(message_pixmap.rect().size())
+
+ # Layouts
+ layout = QtWidgets.QHBoxLayout()
+ layout.addWidget(self.message_button)
+ layout.addStretch()
+ self.setLayout(layout)
+
+ self.hide()
+
+ def set_filename(self, new_filename):
+ self.filename = new_filename
+ self.show()
+
+ def open_message(self):
+ """
+ Open the message in the operating system's default text editor
+ """
+ self.common.log("ReceiveHistoryItemMessage", "open_message", self.filename)
+
+ # Linux
+ if self.common.platform == "Linux" or self.common.platform == "BSD":
+ # If nautilus is available, open it
+ subprocess.Popen(["xdg-open", self.filename])
+
+ # macOS
+ elif self.common.platform == "Darwin":
+ subprocess.call(["open", self.filename])
+
+ # Windows
+ elif self.common.platform == "Windows":
+ subprocess.Popen(["notepad", self.filename])
+
+
class ReceiveHistoryItem(HistoryItem):
def __init__(self, common, id, content_length):
super(ReceiveHistoryItem, self).__init__()
@@ -277,6 +332,12 @@ class ReceiveHistoryItem(HistoryItem):
self.started = datetime.now()
self.status = HistoryItem.STATUS_STARTED
+ self.common.log(
+ "ReceiveHistoryItem",
+ "__init__",
+ f"id={self.id} content_length={self.content_length}",
+ )
+
# Label
self.label = QtWidgets.QLabel(
strings._("gui_all_modes_transfer_started").format(
@@ -295,6 +356,9 @@ class ReceiveHistoryItem(HistoryItem):
self.common.gui.css["downloads_uploads_progress_bar"]
)
+ # The message widget, if a message was included
+ self.message = ReceiveHistoryItemMessage(self.common)
+
# This layout contains file widgets
self.files_layout = QtWidgets.QVBoxLayout()
self.files_layout.setContentsMargins(0, 0, 0, 0)
@@ -305,6 +369,7 @@ class ReceiveHistoryItem(HistoryItem):
# Layout
layout = QtWidgets.QVBoxLayout()
layout.addWidget(self.label)
+ layout.addWidget(self.message)
layout.addWidget(self.progress_bar)
layout.addWidget(files_widget)
layout.addStretch()
@@ -313,6 +378,9 @@ class ReceiveHistoryItem(HistoryItem):
# We're also making a dictionary of file widgets, to make them easier to access
self.files = {}
+ def includes_message(self, message_filename):
+ self.message.set_filename(message_filename)
+
def update(self, data):
"""
Using the progress from Web, update the progress bar and file size labels
@@ -372,6 +440,7 @@ class ReceiveHistoryItem(HistoryItem):
# Change the label
self.label.setText(self.get_finished_label_text(self.started))
+ self.label.setStyleSheet(self.common.gui.css["history_default_label"])
elif data["action"] == "canceled":
# Change the status
@@ -412,6 +481,7 @@ class IndividualFileHistoryItem(HistoryItem):
self.common.gui.css["history_individual_file_timestamp_label"]
)
self.path_label = QtWidgets.QLabel(self.path)
+ self.path_label.setStyleSheet(self.common.gui.css["history_default_label"])
self.status_code_label = QtWidgets.QLabel()
# Progress bar
@@ -560,6 +630,13 @@ class HistoryItemList(QtWidgets.QScrollArea):
if id in self.items:
self.items[id].cancel()
+ def includes_message(self, id, message_filename):
+ """
+ Show message button for receive mode
+ """
+ if id in self.items:
+ self.items[id].includes_message(message_filename)
+
def reset(self):
"""
Reset all items, emptying the list. Override this method.
@@ -637,6 +714,7 @@ class History(QtWidgets.QWidget):
self.not_empty_layout.addLayout(header_layout)
self.not_empty_layout.addWidget(self.item_list)
self.not_empty = QtWidgets.QWidget()
+ self.not_empty.setStyleSheet(self.common.gui.css["downloads_uploads_not_empty"])
self.not_empty.setLayout(self.not_empty_layout)
# Layout
@@ -653,7 +731,7 @@ class History(QtWidgets.QWidget):
"""
Add a new item.
"""
- self.common.log("History", "add", f"id: {id}, item: {item}")
+ self.common.log("History", "add", f"id: {id}")
# Hide empty, show not empty
self.empty.hide()
@@ -674,6 +752,12 @@ class History(QtWidgets.QWidget):
"""
self.item_list.cancel(id)
+ def includes_message(self, id, message_filename):
+ """
+ Show the message button
+ """
+ self.item_list.includes_message(id, message_filename)
+
def reset(self):
"""
Reset all items.
diff --git a/desktop/src/onionshare/tab/mode/mode_settings_widget.py b/desktop/src/onionshare/tab/mode/mode_settings_widget.py
index a3a315c9..9f55dbaf 100644
--- a/desktop/src/onionshare/tab/mode/mode_settings_widget.py
+++ b/desktop/src/onionshare/tab/mode/mode_settings_widget.py
@@ -23,7 +23,7 @@ from PySide2 import QtCore, QtWidgets
from ... import strings
-class ModeSettingsWidget(QtWidgets.QWidget):
+class ModeSettingsWidget(QtWidgets.QScrollArea):
"""
All of the common settings for each mode are in this widget
"""
@@ -57,6 +57,16 @@ class ModeSettingsWidget(QtWidgets.QWidget):
else:
self.public_checkbox.setCheckState(QtCore.Qt.Unchecked)
+ # Title
+ title_label = QtWidgets.QLabel(strings._("mode_settings_title_label"))
+ self.title_lineedit = QtWidgets.QLineEdit()
+ self.title_lineedit.editingFinished.connect(self.title_editing_finished)
+ if self.settings.get("general", "title"):
+ self.title_lineedit.setText(self.settings.get("general", "title"))
+ title_layout = QtWidgets.QHBoxLayout()
+ title_layout.addWidget(title_label)
+ title_layout.addWidget(self.title_lineedit)
+
# Whether or not to use an auto-start timer
self.autostart_timer_checkbox = QtWidgets.QCheckBox()
self.autostart_timer_checkbox.clicked.connect(
@@ -152,6 +162,7 @@ class ModeSettingsWidget(QtWidgets.QWidget):
# Advanced group itself
advanced_layout = QtWidgets.QVBoxLayout()
advanced_layout.setContentsMargins(0, 0, 0, 0)
+ advanced_layout.addLayout(title_layout)
advanced_layout.addLayout(autostart_timer_layout)
advanced_layout.addLayout(autostop_timer_layout)
advanced_layout.addWidget(self.legacy_checkbox)
@@ -166,7 +177,15 @@ class ModeSettingsWidget(QtWidgets.QWidget):
layout.addWidget(self.public_checkbox)
layout.addWidget(self.advanced_widget)
layout.addWidget(self.toggle_advanced_button)
- self.setLayout(layout)
+ layout.addStretch()
+ main_widget = QtWidgets.QWidget()
+ main_widget.setLayout(layout)
+
+ self.setHorizontalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOff)
+ self.setVerticalScrollBarPolicy(QtCore.Qt.ScrollBarAsNeeded)
+ self.setWidgetResizable(True)
+ self.setFrameShape(QtWidgets.QFrame.NoFrame)
+ self.setWidget(main_widget)
self.update_ui()
@@ -203,6 +222,33 @@ class ModeSettingsWidget(QtWidgets.QWidget):
self.legacy_checkbox.hide()
self.client_auth_checkbox.hide()
+ def title_editing_finished(self):
+ if self.title_lineedit.text().strip() == "":
+ self.title_lineedit.setText("")
+ self.settings.set("general", "title", None)
+ if self.tab.mode == self.common.gui.MODE_SHARE:
+ self.tab.change_title.emit(
+ self.tab.tab_id, strings._("gui_tab_name_share")
+ )
+ elif self.tab.mode == self.common.gui.MODE_RECEIVE:
+ self.tab.change_title.emit(
+ self.tab.tab_id, strings._("gui_tab_name_receive")
+ )
+ elif self.tab.mode == self.common.gui.MODE_WEBSITE:
+ self.tab.change_title.emit(
+ self.tab.tab_id, strings._("gui_tab_name_website")
+ )
+ elif self.tab.mode == self.common.gui.MODE_CHAT:
+ self.tab.change_title.emit(
+ self.tab.tab_id, strings._("gui_tab_name_chat")
+ )
+ elif self.tab_mode is None:
+ pass
+ else:
+ title = self.title_lineedit.text()
+ self.settings.set("general", "title", title)
+ self.tab.change_title.emit(self.tab.tab_id, title)
+
def persistent_checkbox_clicked(self):
self.settings.set("persistent", "enabled", self.persistent_checkbox.isChecked())
self.settings.set("persistent", "mode", self.tab.mode)
diff --git a/desktop/src/onionshare/tab/mode/receive_mode/__init__.py b/desktop/src/onionshare/tab/mode/receive_mode/__init__.py
index 8a848128..d07b5ffc 100644
--- a/desktop/src/onionshare/tab/mode/receive_mode/__init__.py
+++ b/desktop/src/onionshare/tab/mode/receive_mode/__init__.py
@@ -26,7 +26,7 @@ from onionshare_cli.web import Web
from ..history import History, ToggleHistory, ReceiveHistoryItem
from .. import Mode
from .... import strings
-from ....widgets import MinimumWidthWidget, Alert
+from ....widgets import MinimumSizeWidget, Alert
from ....gui_common import GuiCommon
@@ -60,6 +60,8 @@ class ReceiveMode(Mode):
self.image.setLayout(image_layout)
# Settings
+
+ # Data dir
data_dir_label = QtWidgets.QLabel(
strings._("mode_settings_receive_data_dir_label")
)
@@ -74,9 +76,60 @@ class ReceiveMode(Mode):
data_dir_layout.addWidget(data_dir_label)
data_dir_layout.addWidget(self.data_dir_lineedit)
data_dir_layout.addWidget(data_dir_button)
-
self.mode_settings_widget.mode_specific_layout.addLayout(data_dir_layout)
+ # Disable text or files
+ self.disable_text_checkbox = self.settings.get("receive", "disable_files")
+ self.disable_text_checkbox = QtWidgets.QCheckBox()
+ self.disable_text_checkbox.clicked.connect(self.disable_text_checkbox_clicked)
+ self.disable_text_checkbox.setText(
+ strings._("mode_settings_receive_disable_text_checkbox")
+ )
+ self.disable_files_checkbox = self.settings.get("receive", "disable_files")
+ self.disable_files_checkbox = QtWidgets.QCheckBox()
+ self.disable_files_checkbox.clicked.connect(self.disable_files_checkbox_clicked)
+ self.disable_files_checkbox.setText(
+ strings._("mode_settings_receive_disable_files_checkbox")
+ )
+ disable_layout = QtWidgets.QHBoxLayout()
+ disable_layout.addWidget(self.disable_text_checkbox)
+ disable_layout.addWidget(self.disable_files_checkbox)
+ disable_layout.addStretch()
+ self.mode_settings_widget.mode_specific_layout.addLayout(disable_layout)
+
+ # Webhook URL
+ webhook_url = self.settings.get("receive", "webhook_url")
+ self.webhook_url_checkbox = QtWidgets.QCheckBox()
+ self.webhook_url_checkbox.clicked.connect(self.webhook_url_checkbox_clicked)
+ self.webhook_url_checkbox.setText(
+ strings._("mode_settings_receive_webhook_url_checkbox")
+ )
+ self.webhook_url_lineedit = QtWidgets.QLineEdit()
+ self.webhook_url_lineedit.editingFinished.connect(
+ self.webhook_url_editing_finished
+ )
+ self.webhook_url_lineedit.setPlaceholderText(
+ "https://example.com/post-when-file-uploaded"
+ )
+ webhook_url_layout = QtWidgets.QHBoxLayout()
+ webhook_url_layout.addWidget(self.webhook_url_checkbox)
+ webhook_url_layout.addWidget(self.webhook_url_lineedit)
+ if webhook_url is not None and webhook_url != "":
+ self.webhook_url_checkbox.setCheckState(QtCore.Qt.Checked)
+ self.webhook_url_lineedit.setText(
+ self.settings.get("receive", "webhook_url")
+ )
+ self.show_webhook_url()
+ else:
+ self.webhook_url_checkbox.setCheckState(QtCore.Qt.Unchecked)
+ self.hide_webhook_url()
+ self.mode_settings_widget.mode_specific_layout.addLayout(webhook_url_layout)
+
+ # Set title placeholder
+ self.mode_settings_widget.title_lineedit.setPlaceholderText(
+ strings._("gui_tab_name_receive")
+ )
+
# Server status
self.server_status.set_mode("receive")
self.server_status.server_started_finished.connect(self.update_primary_action)
@@ -129,8 +182,8 @@ class ReceiveMode(Mode):
self.main_layout = QtWidgets.QVBoxLayout()
self.main_layout.addWidget(header_label)
self.main_layout.addWidget(receive_warning)
- self.main_layout.addWidget(self.primary_action)
- self.main_layout.addWidget(MinimumWidthWidget(525))
+ self.main_layout.addWidget(self.primary_action, stretch=1)
+ self.main_layout.addWidget(MinimumSizeWidget(525, 0))
# Row layout
content_row = QtWidgets.QHBoxLayout()
@@ -138,10 +191,8 @@ class ReceiveMode(Mode):
content_row.addWidget(self.image)
row_layout = QtWidgets.QVBoxLayout()
row_layout.addLayout(top_bar_layout)
- row_layout.addStretch()
- row_layout.addLayout(content_row)
+ row_layout.addLayout(content_row, stretch=1)
row_layout.addWidget(self.server_status)
- row_layout.addStretch()
# Column layout
self.column_layout = QtWidgets.QHBoxLayout()
@@ -183,6 +234,36 @@ class ReceiveMode(Mode):
self.data_dir_lineedit.setText(selected_dir)
self.settings.set("receive", "data_dir", selected_dir)
+ def disable_text_checkbox_clicked(self):
+ self.settings.set(
+ "receive", "disable_text", self.disable_text_checkbox.isChecked()
+ )
+
+ def disable_files_checkbox_clicked(self):
+ self.settings.set(
+ "receive", "disable_files", self.disable_files_checkbox.isChecked()
+ )
+
+ def webhook_url_checkbox_clicked(self):
+ if self.webhook_url_checkbox.isChecked():
+ if self.settings.get("receive", "webhook_url"):
+ self.webhook_url_lineedit.setText(
+ self.settings.get("receive", "webhook_url")
+ )
+ self.show_webhook_url()
+ else:
+ self.settings.set("receive", "webhook_url", None)
+ self.hide_webhook_url()
+
+ def webhook_url_editing_finished(self):
+ self.settings.set("receive", "webhook_url", self.webhook_url_lineedit.text())
+
+ def hide_webhook_url(self):
+ self.webhook_url_lineedit.hide()
+
+ def show_webhook_url(self):
+ self.webhook_url_lineedit.show()
+
def get_stop_server_autostop_timer_text(self):
"""
Return the string to put on the stop server button, if there's an auto-stop timer
@@ -220,6 +301,16 @@ class ReceiveMode(Mode):
# Hide and reset the uploads if we have previously shared
self.reset_info_counters()
+ # Set proxies for webhook URL
+ if self.common.gui.local_only:
+ self.web.proxies = None
+ else:
+ (socks_address, socks_port) = self.common.gui.onion.get_tor_socks_port()
+ self.web.proxies = {
+ "http": f"socks5h://{socks_address}:{socks_port}",
+ "https": f"socks5h://{socks_address}:{socks_port}",
+ }
+
def start_server_step2_custom(self):
"""
Step 2 in starting the server.
@@ -248,8 +339,11 @@ class ReceiveMode(Mode):
Handle REQUEST_STARTED event.
"""
item = ReceiveHistoryItem(
- self.common, event["data"]["id"], event["data"]["content_length"]
+ self.common,
+ event["data"]["id"],
+ event["data"]["content_length"],
)
+
self.history.add(event["data"]["id"], item)
self.toggle_history.update_indicator(True)
self.history.in_progress_count += 1
@@ -269,6 +363,12 @@ class ReceiveMode(Mode):
{"action": "progress", "progress": event["data"]["progress"]},
)
+ def handle_request_upload_includes_message(self, event):
+ """
+ Handle REQUEST_UPLOAD_INCLUDES_MESSAGE event.
+ """
+ self.history.includes_message(event["data"]["id"], event["data"]["filename"])
+
def handle_request_upload_file_renamed(self, event):
"""
Handle REQUEST_UPLOAD_FILE_RENAMED event.
diff --git a/desktop/src/onionshare/tab/mode/share_mode/__init__.py b/desktop/src/onionshare/tab/mode/share_mode/__init__.py
index 74a4e2c2..4056d92e 100644
--- a/desktop/src/onionshare/tab/mode/share_mode/__init__.py
+++ b/desktop/src/onionshare/tab/mode/share_mode/__init__.py
@@ -21,7 +21,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
import os
from PySide2 import QtCore, QtWidgets, QtGui
-from onionshare_cli.onion import *
from onionshare_cli.common import Common
from onionshare_cli.web import Web
@@ -30,7 +29,7 @@ from .. import Mode
from ..file_selection import FileSelection
from ..history import History, ToggleHistory, ShareHistoryItem
from .... import strings
-from ....widgets import Alert, MinimumWidthWidget
+from ....widgets import MinimumSizeWidget
from ....gui_common import GuiCommon
@@ -77,6 +76,11 @@ class ShareMode(Mode):
for filename in self.filenames:
self.file_selection.file_list.add_file(filename)
+ # Set title placeholder
+ self.mode_settings_widget.title_lineedit.setPlaceholderText(
+ strings._("gui_tab_name_share")
+ )
+
# Server status
self.server_status.set_mode("share", self.file_selection)
self.server_status.server_started.connect(self.file_selection.server_started)
@@ -156,9 +160,9 @@ class ShareMode(Mode):
self.main_layout = QtWidgets.QVBoxLayout()
self.main_layout.addLayout(top_bar_layout)
self.main_layout.addLayout(self.file_selection)
- self.main_layout.addWidget(self.primary_action)
+ self.main_layout.addWidget(self.primary_action, stretch=1)
self.main_layout.addWidget(self.server_status)
- self.main_layout.addWidget(MinimumWidthWidget(700))
+ self.main_layout.addWidget(MinimumSizeWidget(700, 0))
# Column layout
self.column_layout = QtWidgets.QHBoxLayout()
diff --git a/desktop/src/onionshare/tab/mode/share_mode/threads.py b/desktop/src/onionshare/tab/mode/share_mode/threads.py
index 6f5c44ea..839d30ea 100644
--- a/desktop/src/onionshare/tab/mode/share_mode/threads.py
+++ b/desktop/src/onionshare/tab/mode/share_mode/threads.py
@@ -36,7 +36,7 @@ class CompressThread(QtCore.QThread):
# prepare files to share
def set_processed_size(self, x):
- if self.mode._zip_progress_bar != None:
+ if self.mode._zip_progress_bar is not None:
self.mode._zip_progress_bar.update_processed_size_signal.emit(x)
def run(self):
@@ -47,9 +47,6 @@ class CompressThread(QtCore.QThread):
self.mode.filenames, processed_size_callback=self.set_processed_size
)
self.success.emit()
- self.mode.app.cleanup_filenames += (
- self.mode.web.share_mode.cleanup_filenames
- )
except OSError as e:
self.error.emit(e.strerror)
diff --git a/desktop/src/onionshare/tab/mode/website_mode/__init__.py b/desktop/src/onionshare/tab/mode/website_mode/__init__.py
index 6aa83de0..577ea28e 100644
--- a/desktop/src/onionshare/tab/mode/website_mode/__init__.py
+++ b/desktop/src/onionshare/tab/mode/website_mode/__init__.py
@@ -19,12 +19,9 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
"""
import os
-import random
-import string
from PySide2 import QtCore, QtWidgets, QtGui
-from onionshare_cli.onion import *
from onionshare_cli.common import Common
from onionshare_cli.web import Web
@@ -32,7 +29,7 @@ from .. import Mode
from ..file_selection import FileSelection
from ..history import History, ToggleHistory
from .... import strings
-from ....widgets import Alert, MinimumWidthWidget
+from ....widgets import MinimumSizeWidget
from ....gui_common import GuiCommon
@@ -77,6 +74,11 @@ class WebsiteMode(Mode):
for filename in self.filenames:
self.file_selection.file_list.add_file(filename)
+ # Set title placeholder
+ self.mode_settings_widget.title_lineedit.setPlaceholderText(
+ strings._("gui_tab_name_website")
+ )
+
# Server status
self.server_status.set_mode("website", self.file_selection)
self.server_status.server_started.connect(self.file_selection.server_started)
@@ -156,9 +158,9 @@ class WebsiteMode(Mode):
self.main_layout = QtWidgets.QVBoxLayout()
self.main_layout.addLayout(top_bar_layout)
self.main_layout.addLayout(self.file_selection)
- self.main_layout.addWidget(self.primary_action)
+ self.main_layout.addWidget(self.primary_action, stretch=1)
self.main_layout.addWidget(self.server_status)
- self.main_layout.addWidget(MinimumWidthWidget(700))
+ self.main_layout.addWidget(MinimumSizeWidget(700, 0))
# Column layout
self.column_layout = QtWidgets.QHBoxLayout()