mirror of
https://github.com/onionshare/onionshare.git
synced 2025-05-16 13:22:28 -04:00
Make receive mode info widget show when server is stated, hide when it is not started
This commit is contained in:
parent
114b9d497b
commit
b35bd976d7
3 changed files with 41 additions and 24 deletions
|
@ -51,6 +51,8 @@ class Mode(QtWidgets.QWidget):
|
||||||
|
|
||||||
self.filenames = filenames
|
self.filenames = filenames
|
||||||
|
|
||||||
|
self.setMinimumWidth(450)
|
||||||
|
|
||||||
# The web object gets created in init()
|
# The web object gets created in init()
|
||||||
self.web = None
|
self.web = None
|
||||||
|
|
||||||
|
@ -107,26 +109,26 @@ class Mode(QtWidgets.QWidget):
|
||||||
Add custom timer code.
|
Add custom timer code.
|
||||||
"""
|
"""
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def get_stop_server_shutdown_timeout_text(self):
|
def get_stop_server_shutdown_timeout_text(self):
|
||||||
"""
|
"""
|
||||||
Return the string to put on the stop server button, if there's a shutdown timeout
|
Return the string to put on the stop server button, if there's a shutdown timeout
|
||||||
"""
|
"""
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def timeout_finished_should_stop_server(self):
|
def timeout_finished_should_stop_server(self):
|
||||||
"""
|
"""
|
||||||
The shutdown timer expired, should we stop the server? Returns a bool
|
The shutdown timer expired, should we stop the server? Returns a bool
|
||||||
"""
|
"""
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def start_server(self):
|
def start_server(self):
|
||||||
"""
|
"""
|
||||||
Start the onionshare server. This uses multiple threads to start the Tor onion
|
Start the onionshare server. This uses multiple threads to start the Tor onion
|
||||||
server and the web app.
|
server and the web app.
|
||||||
"""
|
"""
|
||||||
self.common.log('Mode', 'start_server')
|
self.common.log('Mode', 'start_server')
|
||||||
|
|
||||||
self.start_server_custom()
|
self.start_server_custom()
|
||||||
|
|
||||||
self.set_server_active.emit(True)
|
self.set_server_active.emit(True)
|
||||||
|
@ -165,7 +167,7 @@ class Mode(QtWidgets.QWidget):
|
||||||
self.t = OnionThread(self.common, function=start_onion_service, kwargs={'self': self})
|
self.t = OnionThread(self.common, function=start_onion_service, kwargs={'self': self})
|
||||||
self.t.daemon = True
|
self.t.daemon = True
|
||||||
self.t.start()
|
self.t.start()
|
||||||
|
|
||||||
def start_server_custom(self):
|
def start_server_custom(self):
|
||||||
"""
|
"""
|
||||||
Add custom initialization here.
|
Add custom initialization here.
|
||||||
|
@ -185,7 +187,7 @@ class Mode(QtWidgets.QWidget):
|
||||||
# start_server_step2_custom has call these to move on:
|
# start_server_step2_custom has call these to move on:
|
||||||
# self.starting_server_step3.emit()
|
# self.starting_server_step3.emit()
|
||||||
# self.start_server_finished.emit()
|
# self.start_server_finished.emit()
|
||||||
|
|
||||||
def start_server_step2_custom(self):
|
def start_server_step2_custom(self):
|
||||||
"""
|
"""
|
||||||
Add custom initialization here.
|
Add custom initialization here.
|
||||||
|
@ -194,7 +196,7 @@ class Mode(QtWidgets.QWidget):
|
||||||
|
|
||||||
def start_server_step3(self):
|
def start_server_step3(self):
|
||||||
"""
|
"""
|
||||||
Step 3 in starting the onionshare server.
|
Step 3 in starting the onionshare server.
|
||||||
"""
|
"""
|
||||||
self.common.log('Mode', 'start_server_step3')
|
self.common.log('Mode', 'start_server_step3')
|
||||||
|
|
||||||
|
@ -231,7 +233,7 @@ class Mode(QtWidgets.QWidget):
|
||||||
self.status_bar.clearMessage()
|
self.status_bar.clearMessage()
|
||||||
|
|
||||||
self.start_server_error_custom()
|
self.start_server_error_custom()
|
||||||
|
|
||||||
def start_server_error_custom(self):
|
def start_server_error_custom(self):
|
||||||
"""
|
"""
|
||||||
Add custom initialization here.
|
Add custom initialization here.
|
||||||
|
@ -270,7 +272,7 @@ class Mode(QtWidgets.QWidget):
|
||||||
Add custom initialization here.
|
Add custom initialization here.
|
||||||
"""
|
"""
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def handle_tor_broke(self):
|
def handle_tor_broke(self):
|
||||||
"""
|
"""
|
||||||
Handle connection from Tor breaking.
|
Handle connection from Tor breaking.
|
||||||
|
@ -278,7 +280,7 @@ class Mode(QtWidgets.QWidget):
|
||||||
if self.server_status.status != ServerStatus.STATUS_STOPPED:
|
if self.server_status.status != ServerStatus.STATUS_STOPPED:
|
||||||
self.server_status.stop_server()
|
self.server_status.stop_server()
|
||||||
self.handle_tor_broke_custom()
|
self.handle_tor_broke_custom()
|
||||||
|
|
||||||
def handle_tor_broke_custom(self):
|
def handle_tor_broke_custom(self):
|
||||||
"""
|
"""
|
||||||
Add custom initialization here.
|
Add custom initialization here.
|
||||||
|
@ -317,7 +319,7 @@ class Mode(QtWidgets.QWidget):
|
||||||
Handle REQUEST_CANCELED event.
|
Handle REQUEST_CANCELED event.
|
||||||
"""
|
"""
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def handle_request_close_server(self, event):
|
def handle_request_close_server(self, event):
|
||||||
"""
|
"""
|
||||||
Handle REQUEST_CLOSE_SERVER event.
|
Handle REQUEST_CLOSE_SERVER event.
|
||||||
|
|
|
@ -37,9 +37,10 @@ class ReceiveMode(Mode):
|
||||||
|
|
||||||
# Server status
|
# Server status
|
||||||
self.server_status.set_mode('receive')
|
self.server_status.set_mode('receive')
|
||||||
#self.server_status.server_stopped.connect(self.update_primary_action)
|
self.server_status.server_started_finished.connect(self.update_primary_action)
|
||||||
#self.server_status.server_canceled.connect(self.update_primary_action)
|
self.server_status.server_stopped.connect(self.update_primary_action)
|
||||||
|
self.server_status.server_canceled.connect(self.update_primary_action)
|
||||||
|
|
||||||
# Tell server_status about web, then update
|
# Tell server_status about web, then update
|
||||||
self.server_status.web = self.web
|
self.server_status.web = self.web
|
||||||
self.server_status.update()
|
self.server_status.update()
|
||||||
|
@ -84,7 +85,7 @@ class ReceiveMode(Mode):
|
||||||
# Layout
|
# Layout
|
||||||
self.layout.insertWidget(0, self.receive_info)
|
self.layout.insertWidget(0, self.receive_info)
|
||||||
self.layout.insertWidget(0, self.info_widget)
|
self.layout.insertWidget(0, self.info_widget)
|
||||||
|
|
||||||
def timer_callback_custom(self):
|
def timer_callback_custom(self):
|
||||||
"""
|
"""
|
||||||
This method is called regularly on a timer while share mode is active.
|
This method is called regularly on a timer while share mode is active.
|
||||||
|
@ -93,31 +94,31 @@ class ReceiveMode(Mode):
|
||||||
#if self.new_download:
|
#if self.new_download:
|
||||||
# self.downloads.downloads_container.vbar.setValue(self.downloads.downloads_container.vbar.maximum())
|
# self.downloads.downloads_container.vbar.setValue(self.downloads.downloads_container.vbar.maximum())
|
||||||
# self.new_download = False
|
# self.new_download = False
|
||||||
|
|
||||||
def get_stop_server_shutdown_timeout_text(self):
|
def get_stop_server_shutdown_timeout_text(self):
|
||||||
"""
|
"""
|
||||||
Return the string to put on the stop server button, if there's a shutdown timeout
|
Return the string to put on the stop server button, if there's a shutdown timeout
|
||||||
"""
|
"""
|
||||||
return strings._('gui_receive_stop_server_shutdown_timeout', True)
|
return strings._('gui_receive_stop_server_shutdown_timeout', True)
|
||||||
|
|
||||||
def timeout_finished_should_stop_server(self):
|
def timeout_finished_should_stop_server(self):
|
||||||
"""
|
"""
|
||||||
The shutdown timer expired, should we stop the server? Returns a bool
|
The shutdown timer expired, should we stop the server? Returns a bool
|
||||||
"""
|
"""
|
||||||
# TODO: wait until the final upload is done before stoppign the server?
|
# TODO: wait until the final upload is done before stoppign the server?
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def start_server_custom(self):
|
def start_server_custom(self):
|
||||||
"""
|
"""
|
||||||
Starting the server.
|
Starting the server.
|
||||||
"""
|
"""
|
||||||
# Reset web counters
|
# Reset web counters
|
||||||
self.web.error404_count = 0
|
self.web.error404_count = 0
|
||||||
|
|
||||||
# Hide and reset the downloads if we have previously shared
|
# Hide and reset the downloads if we have previously shared
|
||||||
#self.downloads.reset_downloads()
|
#self.downloads.reset_downloads()
|
||||||
#self.reset_info_counters()
|
#self.reset_info_counters()
|
||||||
|
|
||||||
def start_server_step2_custom(self):
|
def start_server_step2_custom(self):
|
||||||
"""
|
"""
|
||||||
Step 2 in starting the server.
|
Step 2 in starting the server.
|
||||||
|
@ -125,13 +126,13 @@ class ReceiveMode(Mode):
|
||||||
# Continue
|
# Continue
|
||||||
self.starting_server_step3.emit()
|
self.starting_server_step3.emit()
|
||||||
self.start_server_finished.emit()
|
self.start_server_finished.emit()
|
||||||
|
|
||||||
def handle_request_load(self, event):
|
def handle_request_load(self, event):
|
||||||
"""
|
"""
|
||||||
Handle REQUEST_LOAD event.
|
Handle REQUEST_LOAD event.
|
||||||
"""
|
"""
|
||||||
self.system_tray.showMessage(strings._('systray_page_loaded_title', True), strings._('systray_upload_page_loaded_message', True))
|
self.system_tray.showMessage(strings._('systray_page_loaded_title', True), strings._('systray_upload_page_loaded_message', True))
|
||||||
|
|
||||||
def handle_request_close_server(self, event):
|
def handle_request_close_server(self, event):
|
||||||
"""
|
"""
|
||||||
Handle REQUEST_CLOSE_SERVER event.
|
Handle REQUEST_CLOSE_SERVER event.
|
||||||
|
@ -161,3 +162,15 @@ class ReceiveMode(Mode):
|
||||||
self.info_show_uploads.setIcon(QtGui.QIcon(self.common.get_resource_path('images/download_window_green.png')))
|
self.info_show_uploads.setIcon(QtGui.QIcon(self.common.get_resource_path('images/download_window_green.png')))
|
||||||
self.info_in_progress_uploads_count.setText('<img src="{0:s}" /> {1:d}'.format(image, self.uploads_in_progress))
|
self.info_in_progress_uploads_count.setText('<img src="{0:s}" /> {1:d}'.format(image, self.uploads_in_progress))
|
||||||
self.info_in_progress_uploads_count.setToolTip(strings._('info_in_progress_downloads_tooltip', True).format(self.uploads_in_progress))
|
self.info_in_progress_uploads_count.setToolTip(strings._('info_in_progress_downloads_tooltip', True).format(self.uploads_in_progress))
|
||||||
|
|
||||||
|
def update_primary_action(self):
|
||||||
|
self.common.log('ReceiveMode', 'update_primary_action')
|
||||||
|
|
||||||
|
# Show the info widget when the server is active
|
||||||
|
if self.server_status.status == self.server_status.STATUS_STARTED:
|
||||||
|
self.info_widget.show()
|
||||||
|
else:
|
||||||
|
self.info_widget.hide()
|
||||||
|
|
||||||
|
# Resize window
|
||||||
|
self.adjustSize()
|
||||||
|
|
|
@ -29,6 +29,7 @@ class ServerStatus(QtWidgets.QWidget):
|
||||||
The server status chunk of the GUI.
|
The server status chunk of the GUI.
|
||||||
"""
|
"""
|
||||||
server_started = QtCore.pyqtSignal()
|
server_started = QtCore.pyqtSignal()
|
||||||
|
server_started_finished = QtCore.pyqtSignal()
|
||||||
server_stopped = QtCore.pyqtSignal()
|
server_stopped = QtCore.pyqtSignal()
|
||||||
server_canceled = QtCore.pyqtSignal()
|
server_canceled = QtCore.pyqtSignal()
|
||||||
button_clicked = QtCore.pyqtSignal()
|
button_clicked = QtCore.pyqtSignal()
|
||||||
|
@ -116,7 +117,7 @@ class ServerStatus(QtWidgets.QWidget):
|
||||||
layout.addLayout(url_layout)
|
layout.addLayout(url_layout)
|
||||||
layout.addWidget(self.shutdown_timeout_container)
|
layout.addWidget(self.shutdown_timeout_container)
|
||||||
self.setLayout(layout)
|
self.setLayout(layout)
|
||||||
|
|
||||||
def set_mode(self, share_mode, file_selection=None):
|
def set_mode(self, share_mode, file_selection=None):
|
||||||
"""
|
"""
|
||||||
The server status is in share mode.
|
The server status is in share mode.
|
||||||
|
@ -268,6 +269,7 @@ class ServerStatus(QtWidgets.QWidget):
|
||||||
self.status = self.STATUS_STARTED
|
self.status = self.STATUS_STARTED
|
||||||
self.copy_url()
|
self.copy_url()
|
||||||
self.update()
|
self.update()
|
||||||
|
self.server_started_finished.emit()
|
||||||
|
|
||||||
def stop_server(self):
|
def stop_server(self):
|
||||||
"""
|
"""
|
||||||
|
@ -312,7 +314,7 @@ class ServerStatus(QtWidgets.QWidget):
|
||||||
clipboard.setText(self.app.auth_string)
|
clipboard.setText(self.app.auth_string)
|
||||||
|
|
||||||
self.hidservauth_copied.emit()
|
self.hidservauth_copied.emit()
|
||||||
|
|
||||||
def get_url(self):
|
def get_url(self):
|
||||||
"""
|
"""
|
||||||
Returns the OnionShare URL.
|
Returns the OnionShare URL.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue