summaryrefslogtreecommitdiff
path: root/onionshare_gui
diff options
context:
space:
mode:
authorMicah Lee <micah@micahflee.com>2019-01-20 15:25:36 -0800
committerMicah Lee <micah@micahflee.com>2019-01-20 15:25:36 -0800
commitb75757ee49f58f77f524da9ec32cda8062697628 (patch)
treef30e480bcbee8b195b8ee838a2ab3057fa15e73d /onionshare_gui
parent89ccf0306b207356f5f3e80c5d173da5b5862a08 (diff)
downloadonionshare-b75757ee49f58f77f524da9ec32cda8062697628.tar.gz
onionshare-b75757ee49f58f77f524da9ec32cda8062697628.zip
- Refactor the Web.ShareMode client_cancel variable to be Web.stop_q, a thread-safe queue that communicates to both share and receive mode when the user stops the server. In share mode this still stops sending the file. In receive mode, if there's a transfer in progress, it cancels it in the middle, and doesn't end up saving that file
- In receive mode, make the receive mode dir right before saving a file (so if it doesn't complete, don't make an empty dir) - Minor UX tweak: resizing the window stretches the History widget first
Diffstat (limited to 'onionshare_gui')
-rw-r--r--onionshare_gui/mode/__init__.py6
-rw-r--r--onionshare_gui/mode/history.py9
-rw-r--r--onionshare_gui/mode/receive_mode/__init__.py14
-rw-r--r--onionshare_gui/mode/share_mode/__init__.py2
-rw-r--r--onionshare_gui/onionshare_gui.py3
5 files changed, 31 insertions, 3 deletions
diff --git a/onionshare_gui/mode/__init__.py b/onionshare_gui/mode/__init__.py
index 5110289f..bd363915 100644
--- a/onionshare_gui/mode/__init__.py
+++ b/onionshare_gui/mode/__init__.py
@@ -335,3 +335,9 @@ class Mode(QtWidgets.QWidget):
Handle REQUEST_UPLOAD_FINISHED event.
"""
pass
+
+ def handle_request_upload_canceled(self, event):
+ """
+ Handle REQUEST_UPLOAD_CANCELED event.
+ """
+ pass
diff --git a/onionshare_gui/mode/history.py b/onionshare_gui/mode/history.py
index e72a3838..5f895d75 100644
--- a/onionshare_gui/mode/history.py
+++ b/onionshare_gui/mode/history.py
@@ -184,7 +184,7 @@ class UploadHistoryItemFile(QtWidgets.QWidget):
# macOS
elif self.common.platform == 'Darwin':
- subprocess.call(['open', '-R', abs_filename])
+ subprocess.call(['open', '-R', abs_filename])
# Windows
elif self.common.platform == 'Windows':
@@ -295,6 +295,13 @@ class UploadHistoryItem(HistoryItem):
)
self.label.setText(text)
+ elif data['action'] == 'canceled':
+ # Hide the progress bar
+ self.progress_bar.hide()
+
+ # Change the label
+ self.label.setText(strings._('gui_canceled'))
+
class HistoryItemList(QtWidgets.QScrollArea):
"""
diff --git a/onionshare_gui/mode/receive_mode/__init__.py b/onionshare_gui/mode/receive_mode/__init__.py
index c53f1ea1..cde2cb8a 100644
--- a/onionshare_gui/mode/receive_mode/__init__.py
+++ b/onionshare_gui/mode/receive_mode/__init__.py
@@ -83,7 +83,7 @@ class ReceiveMode(Mode):
# Wrapper layout
self.wrapper_layout = QtWidgets.QHBoxLayout()
self.wrapper_layout.addLayout(self.main_layout)
- self.wrapper_layout.addWidget(self.history)
+ self.wrapper_layout.addWidget(self.history, stretch=1)
self.setLayout(self.wrapper_layout)
def get_stop_server_shutdown_timeout_text(self):
@@ -198,6 +198,18 @@ class ReceiveMode(Mode):
self.history.update_completed()
self.history.update_in_progress()
+ def handle_request_upload_canceled(self, event):
+ """
+ Handle REQUEST_UPLOAD_CANCELED event.
+ """
+ self.history.update(event["data"]["id"], {
+ 'action': 'canceled'
+ })
+ self.history.completed_count += 1
+ self.history.in_progress_count -= 1
+ self.history.update_completed()
+ self.history.update_in_progress()
+
def on_reload_settings(self):
"""
We should be ok to re-enable the 'Start Receive Mode' button now.
diff --git a/onionshare_gui/mode/share_mode/__init__.py b/onionshare_gui/mode/share_mode/__init__.py
index 0cc00f92..d86a17e4 100644
--- a/onionshare_gui/mode/share_mode/__init__.py
+++ b/onionshare_gui/mode/share_mode/__init__.py
@@ -115,7 +115,7 @@ class ShareMode(Mode):
# Wrapper layout
self.wrapper_layout = QtWidgets.QHBoxLayout()
self.wrapper_layout.addLayout(self.main_layout)
- self.wrapper_layout.addWidget(self.history)
+ self.wrapper_layout.addWidget(self.history, stretch=1)
self.setLayout(self.wrapper_layout)
# Always start with focus on file selection
diff --git a/onionshare_gui/onionshare_gui.py b/onionshare_gui/onionshare_gui.py
index eab3261e..c4f69b2d 100644
--- a/onionshare_gui/onionshare_gui.py
+++ b/onionshare_gui/onionshare_gui.py
@@ -396,6 +396,9 @@ class OnionShareGui(QtWidgets.QMainWindow):
elif event["type"] == Web.REQUEST_UPLOAD_FINISHED:
mode.handle_request_upload_finished(event)
+ elif event["type"] == Web.REQUEST_UPLOAD_CANCELED:
+ mode.handle_request_upload_canceled(event)
+
if event["type"] == Web.REQUEST_ERROR_DOWNLOADS_DIR_CANNOT_CREATE:
Alert(self.common, strings._('error_cannot_create_downloads_dir').format(event["data"]["receive_mode_dir"]))