Merge branch 'downloads_window' of https://github.com/mig5/onionshare into mig5-downloads_window

This commit is contained in:
Micah Lee 2018-04-22 14:48:57 -07:00
commit 359bd59828
No known key found for this signature in database
GPG key ID: 403C2657CD994F73
6 changed files with 50 additions and 16 deletions

View file

@ -207,6 +207,8 @@ Section "install"
File "${BINPATH}\share\images\download_completed_none.png" File "${BINPATH}\share\images\download_completed_none.png"
File "${BINPATH}\share\images\download_in_progress.png" File "${BINPATH}\share\images\download_in_progress.png"
File "${BINPATH}\share\images\download_in_progress_none.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\favicon.ico"
File "${BINPATH}\share\images\file_delete.png" File "${BINPATH}\share\images\file_delete.png"
File "${BINPATH}\share\images\info.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_completed_none.png"
Delete "$INSTDIR\share\images\download_in_progress.png" Delete "$INSTDIR\share\images\download_in_progress.png"
Delete "$INSTDIR\share\images\download_in_progress_none.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\favicon.ico"
Delete "$INSTDIR\share\images\file_delete.png" Delete "$INSTDIR\share\images\file_delete.png"
Delete "$INSTDIR\share\images\info.png" Delete "$INSTDIR\share\images\info.png"

View file

@ -19,7 +19,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
""" """
import time import time
from PyQt5 import QtCore, QtWidgets from PyQt5 import QtCore, QtWidgets, QtGui
from onionshare import strings, common from onionshare import strings, common
@ -98,19 +98,35 @@ class Downloads(QtWidgets.QWidget):
def __init__(self): def __init__(self):
super(Downloads, self).__init__() super(Downloads, self).__init__()
self.downloads = {} self.downloads = {}
self.downloads_container = QtWidgets.QScrollArea()
self.downloads_container.setWidget(self)
self.downloads_container.setWindowTitle(strings._('gui_downloads', True))
self.downloads_container.setWidgetResizable(True)
self.downloads_container.setMaximumHeight(600)
self.downloads_container.setMinimumHeight(150)
self.downloads_container.setMinimumWidth(350)
self.downloads_container.setWindowIcon(QtGui.QIcon(common.get_resource_path('images/logo.png')))
self.downloads_container.setWindowFlags(QtCore.Qt.Sheet | QtCore.Qt.WindowTitleHint | QtCore.Qt.WindowSystemMenuHint | QtCore.Qt.CustomizeWindowHint)
self.downloads_container.vbar = self.downloads_container.verticalScrollBar()
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 = QtWidgets.QVBoxLayout()
self.layout.addWidget(self.downloads_label)
self.layout.addWidget(self.no_downloads_label)
self.setLayout(self.layout) self.setLayout(self.layout)
def add_download(self, download_id, total_bytes): def add_download(self, download_id, total_bytes):
""" """
Add a new download progress bar. Add a new download progress bar.
""" """
self.parent().show()
# add it to the list # add it to the list
download = Download(download_id, total_bytes) download = Download(download_id, total_bytes)
self.downloads[download_id] = download 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): def update_download(self, download_id, downloaded_bytes):
""" """

View file

@ -103,13 +103,6 @@ class OnionShareGui(QtWidgets.QMainWindow):
# Downloads # Downloads
self.downloads = 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.new_download = False
self.downloads_in_progress = 0 self.downloads_in_progress = 0
self.downloads_completed = 0 self.downloads_completed = 0
@ -119,6 +112,12 @@ class OnionShareGui(QtWidgets.QMainWindow):
self.info_label = QtWidgets.QLabel() self.info_label = QtWidgets.QLabel()
self.info_label.setStyleSheet('QLabel { font-size: 12px; color: #666666; }') 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 = QtWidgets.QLabel()
self.info_in_progress_downloads_count.setStyleSheet('QLabel { font-size: 12px; color: #666666; }') 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.addStretch()
self.info_layout.addWidget(self.info_in_progress_downloads_count) 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_completed_downloads_count)
self.info_layout.addWidget(self.info_show_downloads)
self.info_widget = QtWidgets.QWidget() self.info_widget = QtWidgets.QWidget()
self.info_widget.setLayout(self.info_layout) self.info_widget.setLayout(self.info_layout)
@ -189,7 +189,6 @@ class OnionShareGui(QtWidgets.QMainWindow):
primary_action_layout = QtWidgets.QVBoxLayout() primary_action_layout = QtWidgets.QVBoxLayout()
primary_action_layout.addWidget(self.server_status) primary_action_layout.addWidget(self.server_status)
primary_action_layout.addWidget(self.filesize_warning) primary_action_layout.addWidget(self.filesize_warning)
primary_action_layout.addWidget(self.downloads_container)
self.primary_action = QtWidgets.QWidget() self.primary_action = QtWidgets.QWidget()
self.primary_action.setLayout(primary_action_layout) self.primary_action.setLayout(primary_action_layout)
self.primary_action.hide() self.primary_action.hide()
@ -370,7 +369,6 @@ class OnionShareGui(QtWidgets.QMainWindow):
self.app.set_stealth(self.settings.get('use_stealth')) self.app.set_stealth(self.settings.get('use_stealth'))
# Hide and reset the downloads if we have previously shared # Hide and reset the downloads if we have previously shared
self.downloads_container.hide()
self.downloads.reset_downloads() self.downloads.reset_downloads()
self.reset_info_counters() self.reset_info_counters()
self.status_bar.clearMessage() self.status_bar.clearMessage()
@ -562,7 +560,7 @@ class OnionShareGui(QtWidgets.QMainWindow):
# scroll to the bottom of the dl progress bar log pane # scroll to the bottom of the dl progress bar log pane
# if a new download has been added # if a new download has been added
if self.new_download: if self.new_download:
self.vbar.setValue(self.vbar.maximum()) self.downloads.downloads_container.vbar.setValue(self.downloads.downloads_container.vbar.maximum())
self.new_download = False self.new_download = False
events = [] events = []
@ -580,7 +578,7 @@ class OnionShareGui(QtWidgets.QMainWindow):
self.status_bar.showMessage(strings._('download_page_loaded', True)) self.status_bar.showMessage(strings._('download_page_loaded', True))
elif event["type"] == web.REQUEST_DOWNLOAD: elif event["type"] == web.REQUEST_DOWNLOAD:
self.downloads_container.show() # show the downloads layout self.downloads.no_downloads_label.hide()
self.downloads.add_download(event["data"]["id"], web.zip_filesize) self.downloads.add_download(event["data"]["id"], web.zip_filesize)
self.new_download = True self.new_download = True
self.downloads_in_progress += 1 self.downloads_in_progress += 1
@ -647,6 +645,16 @@ class OnionShareGui(QtWidgets.QMainWindow):
self.status_bar.clearMessage() self.status_bar.clearMessage()
self.server_share_status_label.setText(strings._('timeout_download_still_running', True)) 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.downloads_container.show()
else:
self.downloads.downloads_container.hide()
def copy_url(self): def copy_url(self):
""" """
When the URL gets copied to the clipboard, display this in the status bar. When the URL gets copied to the clipboard, display this in the status bar.
@ -687,6 +695,9 @@ class OnionShareGui(QtWidgets.QMainWindow):
""" """
self.update_downloads_completed(0) self.update_downloads_completed(0)
self.update_downloads_in_progress(0) self.update_downloads_in_progress(0)
self.info_show_downloads.setIcon(QtGui.QIcon(common.get_resource_path('images/download_window_gray.png')))
self.downloads.no_downloads_label.show()
self.downloads.downloads_container.resize(self.downloads.downloads_container.sizeHint())
def update_downloads_completed(self, count): def update_downloads_completed(self, count):
""" """
@ -707,6 +718,7 @@ class OnionShareGui(QtWidgets.QMainWindow):
self.info_in_progress_downloads_image = common.get_resource_path('images/download_in_progress_none.png') self.info_in_progress_downloads_image = common.get_resource_path('images/download_in_progress_none.png')
else: else:
self.info_in_progress_downloads_image = common.get_resource_path('images/download_in_progress.png') 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.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)) self.info_in_progress_downloads_count.setToolTip(strings._('info_in_progress_downloads_tooltip', True).format(count))

Binary file not shown.

After

Width:  |  Height:  |  Size: 440 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 761 B

View file

@ -44,7 +44,9 @@
"gui_stop_server_shutdown_timeout_tooltip": "Share will stop automatically at {}", "gui_stop_server_shutdown_timeout_tooltip": "Share will stop automatically at {}",
"gui_copy_url": "Copy Address", "gui_copy_url": "Copy Address",
"gui_copy_hidservauth": "Copy HidServAuth", "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_canceled": "Canceled",
"gui_copied_url_title": "Copied OnionShare address", "gui_copied_url_title": "Copied OnionShare address",
"gui_copied_url": "The OnionShare address has been copied to clipboard", "gui_copied_url": "The OnionShare address has been copied to clipboard",