merge ux-update in, and fix conflict

This commit is contained in:
Miguel Jacq 2018-02-20 07:47:21 +11:00
commit b7df7f8dc9
No known key found for this signature in database
GPG key ID: EEA4341C6D97A0B6
16 changed files with 278 additions and 164 deletions

View file

@ -30,6 +30,7 @@ class ServerStatus(QtWidgets.QWidget):
server_started = QtCore.pyqtSignal()
server_stopped = QtCore.pyqtSignal()
server_canceled = QtCore.pyqtSignal()
button_clicked = QtCore.pyqtSignal()
url_copied = QtCore.pyqtSignal()
hidservauth_copied = QtCore.pyqtSignal()
@ -48,17 +49,15 @@ class ServerStatus(QtWidgets.QWidget):
self.settings = settings
# Helper boolean as this is used in a few places
self.timer_enabled = False
# Shutdown timeout layout
self.shutdown_timeout_label = QtWidgets.QLabel(strings._('gui_settings_shutdown_timeout', True))
self.shutdown_timeout = QtWidgets.QDateTimeEdit()
# Set proposed timeout to be 5 minutes into the future
self.shutdown_timeout.setDisplayFormat("hh:mm A MMM d, yy")
self.shutdown_timeout.setDateTime(QtCore.QDateTime.currentDateTime().addSecs(300))
# Onion services can take a little while to start, so reduce the risk of it expiring too soon by setting the minimum to 2 min from now
self.shutdown_timeout.setMinimumDateTime(QtCore.QDateTime.currentDateTime().addSecs(120))
self.shutdown_timeout.setCurrentSectionIndex(4)
self.shutdown_timeout.setCurrentSection(QtWidgets.QDateTimeEdit.MinuteSection)
shutdown_timeout_layout = QtWidgets.QHBoxLayout()
shutdown_timeout_layout.addWidget(self.shutdown_timeout_label)
shutdown_timeout_layout.addWidget(self.shutdown_timeout)
@ -84,6 +83,7 @@ class ServerStatus(QtWidgets.QWidget):
self.url.setFont(url_font)
self.url.setWordWrap(True)
self.url.setMinimumHeight(60)
self.url.setMinimumSize(self.url.sizeHint())
self.url.setStyleSheet('QLabel { background-color: #ffffff; color: #000000; padding: 10px; border: 1px solid #666666; }')
url_buttons_style = 'QPushButton { color: #3f7fcf; }'
@ -115,22 +115,6 @@ class ServerStatus(QtWidgets.QWidget):
self.update()
def shutdown_timeout_toggled(self, checked):
"""
Shutdown timer option was toggled. If checked, show the timer settings.
"""
if checked:
self.timer_enabled = True
# Hide the checkbox, show the options
self.shutdown_timeout_label.show()
# Reset the default timer to 5 minutes into the future after toggling the option on
self.shutdown_timeout.setDateTime(QtCore.QDateTime.currentDateTime().addSecs(300))
self.shutdown_timeout.show()
else:
self.timer_enabled = False
self.shutdown_timeout_label.hide()
self.shutdown_timeout.hide()
def shutdown_timeout_reset(self):
"""
Reset the timeout in the UI after stopping a share
@ -146,10 +130,19 @@ class ServerStatus(QtWidgets.QWidget):
if self.status == self.STATUS_STARTED:
self.url_description.show()
if self.settings.get('close_after_first_download'):
self.url_label.setText(strings._('gui_url_label_one_time', True))
info_image = common.get_resource_path('images/info.png')
self.url_label.setText(strings._('gui_url_label', True).format(info_image))
# Show a Tool Tip explaining the lifecycle of this URL
if self.settings.get('save_private_key'):
if self.settings.get('close_after_first_download'):
self.url_label.setToolTip(strings._('gui_url_label_onetime_and_persistent', True))
else:
self.url_label.setToolTip(strings._('gui_url_label_persistent', True))
else:
self.url_label.setText(strings._('gui_url_label', True))
if self.settings.get('close_after_first_download'):
self.url_label.setToolTip(strings._('gui_url_label_onetime', True))
else:
self.url_label.setToolTip(strings._('gui_url_label_stay_open', True))
self.url_label.show()
self.url.setText('http://{0:s}/{1:s}'.format(self.app.onion_host, self.web.slug))
@ -213,7 +206,7 @@ class ServerStatus(QtWidgets.QWidget):
Toggle starting or stopping the server.
"""
if self.status == self.STATUS_STOPPED:
if self.timer_enabled:
if self.settings.get('shutdown_timeout'):
# Get the timeout chosen, stripped of its seconds. This prevents confusion if the share stops at (say) 37 seconds past the minute chosen
self.timeout = self.shutdown_timeout.dateTime().toPyDateTime().replace(second=0, microsecond=0)
# If the timeout has actually passed already before the user hit Start, refuse to start the server.
@ -227,6 +220,7 @@ class ServerStatus(QtWidgets.QWidget):
self.stop_server()
elif self.status == self.STATUS_WORKING:
self.cancel_server()
self.button_clicked.emit()
def start_server(self):
"""