Toggle showing uploads and downloads for both share and receive modes

This commit is contained in:
Micah Lee 2018-09-28 13:43:10 -07:00
parent edbbe9377c
commit 4bec79f494
No known key found for this signature in database
GPG Key ID: 403C2657CD994F73
4 changed files with 51 additions and 4 deletions

View File

@ -36,6 +36,7 @@ class Mode(QtWidgets.QWidget):
starting_server_step3 = QtCore.pyqtSignal()
starting_server_error = QtCore.pyqtSignal(str)
set_server_active = QtCore.pyqtSignal(bool)
adjust_size = QtCore.pyqtSignal()
def __init__(self, common, qtapp, app, status_bar, server_status_label, system_tray, filenames=None, local_only=False):
super(Mode, self).__init__()

View File

@ -132,6 +132,7 @@ class OnionShareGui(QtWidgets.QMainWindow):
self.share_mode.server_status.url_copied.connect(self.copy_url)
self.share_mode.server_status.hidservauth_copied.connect(self.copy_hidservauth)
self.share_mode.set_server_active.connect(self.set_server_active)
self.share_mode.adjust_size.connect(self.adjust_size)
# Receive mode
self.receive_mode = ReceiveMode(self.common, qtapp, app, self.status_bar, self.server_status_label, self.system_tray, None, self.local_only)
@ -146,6 +147,7 @@ class OnionShareGui(QtWidgets.QMainWindow):
self.receive_mode.server_status.url_copied.connect(self.copy_url)
self.receive_mode.server_status.hidservauth_copied.connect(self.copy_hidservauth)
self.receive_mode.set_server_active.connect(self.set_server_active)
self.receive_mode.adjust_size.connect(self.adjust_size)
self.update_mode_switcher()
self.update_server_status_indicator()
@ -442,6 +444,11 @@ class OnionShareGui(QtWidgets.QMainWindow):
# Disable settings menu action when server is active
self.settings_action.setEnabled(not active)
def adjust_size(self):
self.share_mode.adjustSize()
self.receive_mode.adjustSize()
self.adjustSize()
def closeEvent(self, e):
self.common.log('OnionShareGui', 'closeEvent')
try:

View File

@ -63,10 +63,19 @@ class ReceiveMode(Mode):
self.update_uploads_completed()
self.update_uploads_in_progress()
self.info_toggle_button = QtWidgets.QPushButton()
self.info_toggle_button.setDefault(False)
self.info_toggle_button.setFixedWidth(30)
self.info_toggle_button.setFixedHeight(30)
self.info_toggle_button.setFlat(True)
self.info_toggle_button.setIcon( QtGui.QIcon(self.common.get_resource_path('images/uploads_toggle.png')) )
self.info_toggle_button.clicked.connect(self.toggle_uploads)
self.info_layout = QtWidgets.QHBoxLayout()
self.info_layout.addStretch()
self.info_layout.addWidget(self.info_in_progress_uploads_count)
self.info_layout.addWidget(self.info_completed_uploads_count)
self.info_layout.addWidget(self.info_toggle_button)
self.info_widget = QtWidgets.QWidget()
self.info_widget.setLayout(self.info_layout)
@ -226,4 +235,21 @@ class ReceiveMode(Mode):
self.info_widget.hide()
# Resize window
self.adjustSize()
self.adjust_size.emit()
def toggle_uploads(self):
"""
Toggle showing and hiding the Uploads widget
"""
self.common.log('ReceiveMode', 'toggle_uploads')
if self.uploads.isVisible():
self.uploads.hide()
self.info_toggle_button.setIcon( QtGui.QIcon(self.common.get_resource_path('images/uploads_toggle.png')) )
self.info_toggle_button.setFlat(True)
else:
self.uploads.show()
self.info_toggle_button.setIcon( QtGui.QIcon(self.common.get_resource_path('images/uploads_toggle_selected.png')) )
self.info_toggle_button.setFlat(False)
self.adjust_size.emit()

View File

@ -226,7 +226,7 @@ class ShareMode(Mode):
Stop the compression thread on cancel
"""
if self.compress_thread:
self.common.log('OnionShareGui', 'cancel_server: quitting compress thread')
self.common.log('ShareMode', 'cancel_server: quitting compress thread')
self.compress_thread.quit()
def handle_tor_broke_custom(self):
@ -305,6 +305,8 @@ class ShareMode(Mode):
self.info_widget.show()
def update_primary_action(self):
self.common.log('ShareMode', 'update_primary_action')
# Show or hide primary action layout
file_count = self.file_selection.file_list.count()
if file_count > 0:
@ -328,7 +330,7 @@ class ShareMode(Mode):
self.info_widget.hide()
# Resize window
self.adjustSize()
self.adjust_size.emit()
def reset_info_counters(self):
"""
@ -366,7 +368,18 @@ class ShareMode(Mode):
"""
Toggle showing and hiding the Downloads widget
"""
pass
self.common.log('ShareMode', 'toggle_downloads')
if self.downloads.isVisible():
self.downloads.hide()
self.info_toggle_button.setIcon( QtGui.QIcon(self.common.get_resource_path('images/downloads_toggle.png')) )
self.info_toggle_button.setFlat(True)
else:
self.downloads.show()
self.info_toggle_button.setIcon( QtGui.QIcon(self.common.get_resource_path('images/downloads_toggle_selected.png')) )
self.info_toggle_button.setFlat(False)
self.adjust_size.emit()
@staticmethod
def _compute_total_size(filenames):