summaryrefslogtreecommitdiff
path: root/onionshare_gui
diff options
context:
space:
mode:
authorMiguel Jacq <mig@mig5.net>2019-09-02 18:01:56 +1000
committerMiguel Jacq <mig@mig5.net>2019-09-02 18:01:56 +1000
commit173b2d3f5ed1cf37fdb33e675e337eb4350498eb (patch)
treea60ae3d7704c5a6026bec87d852416c3a3e7cbb4 /onionshare_gui
parent877a73ab59e6903dcd3c56ee85d6136db5ea3bb3 (diff)
downloadonionshare-173b2d3f5ed1cf37fdb33e675e337eb4350498eb.tar.gz
onionshare-173b2d3f5ed1cf37fdb33e675e337eb4350498eb.zip
Register a history item when an individual file is viewed that does not match a 'reserved' path
Diffstat (limited to 'onionshare_gui')
-rw-r--r--onionshare_gui/mode/history.py31
-rw-r--r--onionshare_gui/mode/share_mode/__init__.py11
2 files changed, 41 insertions, 1 deletions
diff --git a/onionshare_gui/mode/history.py b/onionshare_gui/mode/history.py
index 51b36f9a..c2c696fc 100644
--- a/onionshare_gui/mode/history.py
+++ b/onionshare_gui/mode/history.py
@@ -341,6 +341,37 @@ class ReceiveHistoryItem(HistoryItem):
self.label.setText(self.get_canceled_label_text(self.started))
+class IndividualFileHistoryItem(HistoryItem):
+ """
+ Individual file history item, for share mode viewing of individual files
+ """
+ def __init__(self, common, path):
+ super(IndividualFileHistoryItem, self).__init__()
+ self.status = HistoryItem.STATUS_STARTED
+ self.common = common
+
+ self.visited = time.time()
+ self.visited_dt = datetime.fromtimestamp(self.visited)
+
+ # Labels
+ self.timestamp_label = QtWidgets.QLabel(self.visited_dt.strftime("%b %d, %I:%M%p"))
+ self.path_viewed_label = QtWidgets.QLabel(strings._('gui_individual_file_download').format(path))
+
+ # Layout
+ layout = QtWidgets.QVBoxLayout()
+ layout.addWidget(self.timestamp_label)
+ layout.addWidget(self.path_viewed_label)
+ self.setLayout(layout)
+
+
+ def update(self):
+ self.label.setText(self.get_finished_label_text(self.started_dt))
+ self.status = HistoryItem.STATUS_FINISHED
+
+ def cancel(self):
+ self.progress_bar.setFormat(strings._('gui_canceled'))
+ self.status = HistoryItem.STATUS_CANCELED
+
class VisitHistoryItem(HistoryItem):
"""
Download history item, for share mode
diff --git a/onionshare_gui/mode/share_mode/__init__.py b/onionshare_gui/mode/share_mode/__init__.py
index 143fd577..dd4ec1ab 100644
--- a/onionshare_gui/mode/share_mode/__init__.py
+++ b/onionshare_gui/mode/share_mode/__init__.py
@@ -28,7 +28,7 @@ from onionshare.web import Web
from ..file_selection import FileSelection
from .threads import CompressThread
from .. import Mode
-from ..history import History, ToggleHistory, ShareHistoryItem
+from ..history import History, ToggleHistory, ShareHistoryItem, IndividualFileHistoryItem
from ...widgets import Alert
@@ -230,6 +230,15 @@ class ShareMode(Mode):
Handle REQUEST_LOAD event.
"""
self.system_tray.showMessage(strings._('systray_page_loaded_title'), strings._('systray_page_loaded_message'))
+ if not event["path"].startswith(('/favicon.ico', '/download', self.web.static_url_path)) and event["path"] != '/':
+
+ item = IndividualFileHistoryItem(self.common, event["path"])
+
+ self.history.add(0, item)
+ self.toggle_history.update_indicator(True)
+ self.history.completed_count += 1
+ self.history.update_completed()
+ self.system_tray.showMessage(strings._('systray_individual_file_downloaded_title'), strings._('systray_individual_file_downloaded_message').format(event["path"]))
def handle_request_started(self, event):
"""