Make ReceiveMode start using Uploads

This commit is contained in:
Micah Lee 2018-05-07 15:44:04 -07:00
parent a0db6d0ee7
commit 23821ebae6
No known key found for this signature in database
GPG Key ID: 403C2657CD994F73
3 changed files with 29 additions and 23 deletions

View File

@ -87,15 +87,6 @@ class ReceiveMode(Mode):
self.layout.insertWidget(0, self.receive_info)
self.layout.insertWidget(0, self.info_widget)
def timer_callback_custom(self):
"""
This method is called regularly on a timer while share mode is active.
"""
# Scroll to the bottom of the download progress bar log pane if a new download has been added
#if self.new_download:
# self.downloads.downloads_container.vbar.setValue(self.downloads.downloads_container.vbar.maximum())
# self.new_download = False
def get_stop_server_shutdown_timeout_text(self):
"""
Return the string to put on the stop server button, if there's a shutdown timeout
@ -116,9 +107,8 @@ class ReceiveMode(Mode):
# Reset web counters
self.web.error404_count = 0
# Hide and reset the downloads if we have previously shared
#self.downloads.reset_downloads()
#self.reset_info_counters()
# Hide and reset the uploads if we have previously shared
self.reset_info_counters()
def start_server_step2_custom(self):
"""
@ -141,6 +131,17 @@ class ReceiveMode(Mode):
self.stop_server()
self.system_tray.showMessage(strings._('systray_close_server_title', True), strings._('systray_close_server_message', True))
def reset_info_counters(self):
"""
Set the info counters back to zero.
"""
self.uploads_completed = 0
self.uploads_in_progress = 0
self.update_uploads_completed()
self.update_uploads_in_progress()
self.info_show_uploads.setIcon(QtGui.QIcon(self.common.get_resource_path('images/upload_window_gray.png')))
self.uploads.reset()
def update_uploads_completed(self):
"""
Update the 'Downloads completed' info widget.

View File

@ -21,6 +21,7 @@ from PyQt5 import QtCore, QtWidgets, QtGui
from onionshare import strings
class Uploads(QtWidgets.QScrollArea):
"""
The uploads chunk of the GUI. This lists all of the active upload
@ -55,3 +56,9 @@ class Uploads(QtWidgets.QScrollArea):
layout.addStretch()
widget.setLayout(layout)
self.setWidget(widget)
def reset(self):
"""
Reset the uploads back to zero
"""
pass

View File

@ -23,7 +23,6 @@ from PyQt5 import QtCore, QtWidgets, QtGui
from onionshare import strings
class Download(object):
def __init__(self, common, download_id, total_bytes):
self.common = common
@ -33,7 +32,14 @@ class Download(object):
self.downloaded_bytes = 0
# make a new progress bar
cssStyleData ="""
self.progress_bar = QtWidgets.QProgressBar()
self.progress_bar.setTextVisible(True)
self.progress_bar.setAttribute(QtCore.Qt.WA_DeleteOnClose)
self.progress_bar.setAlignment(QtCore.Qt.AlignHCenter)
self.progress_bar.setMinimum(0)
self.progress_bar.setMaximum(total_bytes)
self.progress_bar.setValue(0)
self.progress_bar.setStyleSheet("""
QProgressBar {
border: 1px solid #4e064f;
background-color: #ffffff !important;
@ -45,15 +51,7 @@ class Download(object):
QProgressBar::chunk {
background-color: #4e064f;
width: 10px;
}"""
self.progress_bar = QtWidgets.QProgressBar()
self.progress_bar.setTextVisible(True)
self.progress_bar.setAttribute(QtCore.Qt.WA_DeleteOnClose)
self.progress_bar.setAlignment(QtCore.Qt.AlignHCenter)
self.progress_bar.setMinimum(0)
self.progress_bar.setMaximum(total_bytes)
self.progress_bar.setValue(0)
self.progress_bar.setStyleSheet(cssStyleData)
}""")
self.progress_bar.total_bytes = total_bytes
# start at 0