mirror of
https://github.com/onionshare/onionshare.git
synced 2024-10-01 01:35:40 -04:00
Move downloads into their own window that can be toggled on/off
This commit is contained in:
parent
8299aad90b
commit
ee5c35d502
@ -207,6 +207,8 @@ Section "install"
|
||||
File "${BINPATH}\share\images\download_completed_none.png"
|
||||
File "${BINPATH}\share\images\download_in_progress.png"
|
||||
File "${BINPATH}\share\images\download_in_progress_none.png"
|
||||
File "${BINPATH}\share\images\download_window_gray.png"
|
||||
File "${BINPATH}\share\images\download_window_green.png"
|
||||
File "${BINPATH}\share\images\favicon.ico"
|
||||
File "${BINPATH}\share\images\file_delete.png"
|
||||
File "${BINPATH}\share\images\info.png"
|
||||
@ -393,6 +395,8 @@ FunctionEnd
|
||||
Delete "$INSTDIR\share\images\download_completed_none.png"
|
||||
Delete "$INSTDIR\share\images\download_in_progress.png"
|
||||
Delete "$INSTDIR\share\images\download_in_progress_none.png"
|
||||
Delete "$INSTDIR\share\images\download_window_gray.png"
|
||||
Delete "$INSTDIR\share\images\download_window_green.png"
|
||||
Delete "$INSTDIR\share\images\favicon.ico"
|
||||
Delete "$INSTDIR\share\images\file_delete.png"
|
||||
Delete "$INSTDIR\share\images\info.png"
|
||||
|
@ -19,7 +19,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
"""
|
||||
import time
|
||||
|
||||
from PyQt5 import QtCore, QtWidgets
|
||||
from PyQt5 import QtCore, QtWidgets, QtGui
|
||||
|
||||
from onionshare import strings, common
|
||||
|
||||
@ -98,19 +98,27 @@ class Downloads(QtWidgets.QWidget):
|
||||
def __init__(self):
|
||||
super(Downloads, self).__init__()
|
||||
self.downloads = {}
|
||||
self.downloads_label = QtWidgets.QLabel(strings._('gui_downloads', True))
|
||||
self.downloads_label.setStyleSheet('QLabel { font-weight: bold; font-size 14px; text-align: center; }')
|
||||
self.no_downloads_label = QtWidgets.QLabel(strings._('gui_no_downloads', True))
|
||||
self.layout = QtWidgets.QVBoxLayout()
|
||||
self.layout.addWidget(self.downloads_label)
|
||||
self.layout.addWidget(self.no_downloads_label)
|
||||
self.setLayout(self.layout)
|
||||
self.setWindowTitle(strings._('gui_downloads', True))
|
||||
self.setMinimumWidth(350)
|
||||
self.setWindowIcon(QtGui.QIcon(common.get_resource_path('images/logo.png')))
|
||||
self.setWindowFlags(QtCore.Qt.Sheet | QtCore.Qt.WindowTitleHint | QtCore.Qt.WindowSystemMenuHint | QtCore.Qt.CustomizeWindowHint)
|
||||
|
||||
def add_download(self, download_id, total_bytes):
|
||||
"""
|
||||
Add a new download progress bar.
|
||||
"""
|
||||
self.parent().show()
|
||||
|
||||
# add it to the list
|
||||
self.no_downloads_label.hide()
|
||||
download = Download(download_id, total_bytes)
|
||||
self.downloads[download_id] = download
|
||||
self.layout.insertWidget(-1, download.progress_bar)
|
||||
self.layout.addWidget(download.progress_bar)
|
||||
|
||||
def update_download(self, download_id, downloaded_bytes):
|
||||
"""
|
||||
|
@ -103,13 +103,6 @@ class OnionShareGui(QtWidgets.QMainWindow):
|
||||
|
||||
# Downloads
|
||||
self.downloads = Downloads()
|
||||
self.downloads_container = QtWidgets.QScrollArea()
|
||||
self.downloads_container.setWidget(self.downloads)
|
||||
self.downloads_container.setWidgetResizable(True)
|
||||
self.downloads_container.setMaximumHeight(200)
|
||||
self.downloads_container.setMinimumHeight(75)
|
||||
self.vbar = self.downloads_container.verticalScrollBar()
|
||||
self.downloads_container.hide() # downloads start out hidden
|
||||
self.new_download = False
|
||||
self.downloads_in_progress = 0
|
||||
self.downloads_completed = 0
|
||||
@ -119,6 +112,12 @@ class OnionShareGui(QtWidgets.QMainWindow):
|
||||
self.info_label = QtWidgets.QLabel()
|
||||
self.info_label.setStyleSheet('QLabel { font-size: 12px; color: #666666; }')
|
||||
|
||||
self.info_show_downloads = QtWidgets.QToolButton()
|
||||
self.info_show_downloads.setIcon(QtGui.QIcon(common.get_resource_path('images/download_window_gray.png')))
|
||||
self.info_show_downloads.setCheckable(True)
|
||||
self.info_show_downloads.toggled.connect(self.downloads_toggled)
|
||||
self.info_show_downloads.setToolTip(strings._('gui_downloads_window_tooltip', True))
|
||||
|
||||
self.info_in_progress_downloads_count = QtWidgets.QLabel()
|
||||
self.info_in_progress_downloads_count.setStyleSheet('QLabel { font-size: 12px; color: #666666; }')
|
||||
|
||||
@ -132,6 +131,7 @@ class OnionShareGui(QtWidgets.QMainWindow):
|
||||
self.info_layout.addStretch()
|
||||
self.info_layout.addWidget(self.info_in_progress_downloads_count)
|
||||
self.info_layout.addWidget(self.info_completed_downloads_count)
|
||||
self.info_layout.addWidget(self.info_show_downloads)
|
||||
|
||||
self.info_widget = QtWidgets.QWidget()
|
||||
self.info_widget.setLayout(self.info_layout)
|
||||
@ -189,7 +189,6 @@ class OnionShareGui(QtWidgets.QMainWindow):
|
||||
primary_action_layout = QtWidgets.QVBoxLayout()
|
||||
primary_action_layout.addWidget(self.server_status)
|
||||
primary_action_layout.addWidget(self.filesize_warning)
|
||||
primary_action_layout.addWidget(self.downloads_container)
|
||||
self.primary_action = QtWidgets.QWidget()
|
||||
self.primary_action.setLayout(primary_action_layout)
|
||||
self.primary_action.hide()
|
||||
@ -370,7 +369,6 @@ class OnionShareGui(QtWidgets.QMainWindow):
|
||||
self.app.set_stealth(self.settings.get('use_stealth'))
|
||||
|
||||
# Hide and reset the downloads if we have previously shared
|
||||
self.downloads_container.hide()
|
||||
self.downloads.reset_downloads()
|
||||
self.reset_info_counters()
|
||||
self.status_bar.clearMessage()
|
||||
@ -562,7 +560,6 @@ class OnionShareGui(QtWidgets.QMainWindow):
|
||||
# scroll to the bottom of the dl progress bar log pane
|
||||
# if a new download has been added
|
||||
if self.new_download:
|
||||
self.vbar.setValue(self.vbar.maximum())
|
||||
self.new_download = False
|
||||
|
||||
events = []
|
||||
@ -580,7 +577,6 @@ class OnionShareGui(QtWidgets.QMainWindow):
|
||||
self.status_bar.showMessage(strings._('download_page_loaded', True))
|
||||
|
||||
elif event["type"] == web.REQUEST_DOWNLOAD:
|
||||
self.downloads_container.show() # show the downloads layout
|
||||
self.downloads.add_download(event["data"]["id"], web.zip_filesize)
|
||||
self.new_download = True
|
||||
self.downloads_in_progress += 1
|
||||
@ -647,6 +643,16 @@ class OnionShareGui(QtWidgets.QMainWindow):
|
||||
self.status_bar.clearMessage()
|
||||
self.server_share_status_label.setText(strings._('timeout_download_still_running', True))
|
||||
|
||||
def downloads_toggled(self, checked):
|
||||
"""
|
||||
When the 'Show/hide downloads' button is toggled, show or hide the downloads window.
|
||||
"""
|
||||
common.log('OnionShareGui', 'toggle_downloads')
|
||||
if checked:
|
||||
self.downloads.show()
|
||||
else:
|
||||
self.downloads.hide()
|
||||
|
||||
def copy_url(self):
|
||||
"""
|
||||
When the URL gets copied to the clipboard, display this in the status bar.
|
||||
@ -687,6 +693,7 @@ class OnionShareGui(QtWidgets.QMainWindow):
|
||||
"""
|
||||
self.update_downloads_completed(0)
|
||||
self.update_downloads_in_progress(0)
|
||||
self.info_show_downloads.setIcon(QtGui.QIcon(common.get_resource_path('images/download_window_gray.png')))
|
||||
|
||||
def update_downloads_completed(self, count):
|
||||
"""
|
||||
@ -707,6 +714,7 @@ class OnionShareGui(QtWidgets.QMainWindow):
|
||||
self.info_in_progress_downloads_image = common.get_resource_path('images/download_in_progress_none.png')
|
||||
else:
|
||||
self.info_in_progress_downloads_image = common.get_resource_path('images/download_in_progress.png')
|
||||
self.info_show_downloads.setIcon(QtGui.QIcon(common.get_resource_path('images/download_window_green.png')))
|
||||
self.info_in_progress_downloads_count.setText('<img src="{0:s}" /> {1:d}'.format(self.info_in_progress_downloads_image, count))
|
||||
self.info_in_progress_downloads_count.setToolTip(strings._('info_in_progress_downloads_tooltip', True).format(count))
|
||||
|
||||
|
0
share/images/download_window_gray.png
Normal file
0
share/images/download_window_gray.png
Normal file
0
share/images/download_window_green.png
Normal file
0
share/images/download_window_green.png
Normal file
@ -44,7 +44,9 @@
|
||||
"gui_stop_server_shutdown_timeout_tooltip": "Share will stop automatically at {}",
|
||||
"gui_copy_url": "Copy Address",
|
||||
"gui_copy_hidservauth": "Copy HidServAuth",
|
||||
"gui_downloads": "Downloads:",
|
||||
"gui_downloads": "Download History",
|
||||
"gui_downloads_window_tooltip": "Show/hide downloads",
|
||||
"gui_no_downloads": "No downloads yet.",
|
||||
"gui_canceled": "Canceled",
|
||||
"gui_copied_url_title": "Copied OnionShare address",
|
||||
"gui_copied_url": "The OnionShare address has been copied to clipboard",
|
||||
|
Loading…
Reference in New Issue
Block a user