Add a 'persistent URL' label when re-using a private key

This commit is contained in:
Miguel Jacq 2018-01-14 18:41:54 +11:00
parent efb9ba2e26
commit 339eb09b57
3 changed files with 14 additions and 7 deletions

View File

@ -69,7 +69,7 @@ class OnionShareGui(QtWidgets.QMainWindow):
self.file_selection.file_list.add_file(filename)
# Server status
self.server_status = ServerStatus(self.qtapp, self.app, web, self.file_selection, self.settings)
self.server_status = ServerStatus(self.qtapp, self.app, web, self.file_selection)
self.server_status.server_started.connect(self.file_selection.server_started)
self.server_status.server_started.connect(self.start_server)
self.server_status.server_stopped.connect(self.file_selection.server_stopped)
@ -119,11 +119,17 @@ class OnionShareGui(QtWidgets.QMainWindow):
# Status bar, zip progress bar
self._zip_progress_bar = None
# Persistent URL notification
self.persistent_url_label = QtWidgets.QLabel(strings._('persistent_url_in_use', True))
self.persistent_url_label.setStyleSheet('padding: 10px 0; font-weight: bold; color: #333333;')
self.persistent_url_label.hide()
# Main layout
self.layout = QtWidgets.QVBoxLayout()
self.layout.addLayout(self.file_selection)
self.layout.addLayout(self.server_status)
self.layout.addWidget(self.filesize_warning)
self.layout.addWidget(self.persistent_url_label)
self.layout.addWidget(self.downloads_container)
central_widget = QtWidgets.QWidget()
central_widget.setLayout(self.layout)
@ -329,6 +335,9 @@ class OnionShareGui(QtWidgets.QMainWindow):
self.stop_server()
self.start_server_error(strings._('gui_server_started_after_timeout'))
if self.settings.get('save_private_key'):
self.persistent_url_label.show()
def start_server_error(self, error):
"""
If there's an error when trying to start the onion service
@ -357,6 +366,7 @@ class OnionShareGui(QtWidgets.QMainWindow):
# Remove ephemeral service, but don't disconnect from Tor
self.onion.cleanup(stop_tor=False)
self.filesize_warning.hide()
self.persistent_url_label.hide()
self.stop_server_finished.emit()
self.set_server_active(False)

View File

@ -22,7 +22,6 @@ from .alert import Alert
from PyQt5 import QtCore, QtWidgets, QtGui
from onionshare import strings, common
from onionshare.settings import Settings
class ServerStatus(QtWidgets.QVBoxLayout):
"""
@ -37,7 +36,7 @@ class ServerStatus(QtWidgets.QVBoxLayout):
STATUS_WORKING = 1
STATUS_STARTED = 2
def __init__(self, qtapp, app, web, file_selection, settings):
def __init__(self, qtapp, app, web, file_selection):
super(ServerStatus, self).__init__()
self.status = self.STATUS_STOPPED
@ -45,7 +44,6 @@ class ServerStatus(QtWidgets.QVBoxLayout):
self.app = app
self.web = web
self.file_selection = file_selection
self.settings = settings
# Helper boolean as this is used in a few places
self.timer_enabled = False
@ -142,8 +140,6 @@ class ServerStatus(QtWidgets.QVBoxLayout):
self.url_label.setText('http://{0:s}/{1:s}'.format(self.app.onion_host, self.web.slug))
self.url_label.show()
self.copy_url_button.show()
if self.settings.get('save_private_key'):
common.log('ServerStatus', 'update', '@TODO need to show a "persistent URL in use" label')
if self.app.stealth:
self.copy_hidservauth_button.show()

View File

@ -123,5 +123,6 @@
"gui_server_started_after_timeout": "The server started after your chosen auto-timeout.\nPlease start a new share.",
"gui_server_timeout_expired": "The chosen timeout has already expired.\nPlease update the timeout and then you may start sharing.",
"share_via_onionshare": "Share via OnionShare",
"gui_save_private_key_checkbox": "Use a persistent URL\n(unchecking will delete any saved URL)"
"gui_save_private_key_checkbox": "Use a persistent URL\n(unchecking will delete any saved URL)",
"persistent_url_in_use": "This share is using a persistent URL"
}