Skip to content

Commit

Permalink
Activate / deactivate spinners and active state icons at the right po…
Browse files Browse the repository at this point in the history
…ints in the state transitions for USB export and print.
  • Loading branch information
ntoll committed Mar 19, 2020
1 parent e621907 commit d42ef98
Showing 1 changed file with 33 additions and 9 deletions.
42 changes: 33 additions & 9 deletions securedrop_client/gui/widgets.py
Original file line number Diff line number Diff line change
Expand Up @@ -2553,8 +2553,16 @@ def animate_header(self):
def start_animate_activestate(self):
self.button_animation.start()
self.continue_button.setText("")
self.continue_button.setMinimumSize(QSize(150, 45))
css = "background-color: #f1f1f6; color: #fff; border: None;"
self.continue_button.setMinimumSize(QSize(142, 43))
css = """
background-color: #f1f1f6;
color: #fff;
border: 2px solid #f1f1f6;
margin: 0px 0px 0px 12px;
height: 40px;
padding-left: 20px;
padding-right: 20px;
"""
self.continue_button.setStyleSheet(css)

def start_animate_header(self):
Expand Down Expand Up @@ -2595,13 +2603,15 @@ def __init__(self, controller: Controller, file_uuid: str, file_name: str):
# Connect parent signals to slots
self.continue_button.setEnabled(False)

self.header_icon.update_image('printer.svg', svg_size=QSize(64, 64))

# Dialog content
self.starting_header = _(
'Preparing to print:'
'<br />'
'<span style="font-weight:normal">{}</span>'.format(self.file_name))
self.ready_header = _(
'Ready to print:'
'<br />'
'<span style="font-weight:normal">{}</span>'.format(self.file_name))
self.insert_usb_header = _('Insert USB printer')
self.error_header = _('Unable to print')
self.starting_message = _(
Expand All @@ -2621,6 +2631,7 @@ def __init__(self, controller: Controller, file_uuid: str, file_name: str):
self.generic_error_message = _('See your administrator for help.')

self._show_starting_instructions()
self.start_animate_header()
self._run_preflight()

def _show_starting_instructions(self):
Expand Down Expand Up @@ -2661,6 +2672,9 @@ def _print_file(self):
@pyqtSlot()
def _on_preflight_success(self):
# If the continue button is disabled then this is the result of a background preflight check
self.stop_animate_header()
self.header_icon.update_image('printer.svg', svg_size=QSize(64, 64))
self.header.setText(self.ready_header)
if not self.continue_button.isEnabled():
self.continue_button.clicked.disconnect()
self.continue_button.clicked.connect(self._print_file)
Expand All @@ -2671,6 +2685,8 @@ def _on_preflight_success(self):

@pyqtSlot(object)
def _on_preflight_failure(self, error: ExportError):
self.stop_animate_header()
self.header_icon.update_image('printer.svg', svg_size=QSize(64, 64))
self.error_status = error.status
# If the continue button is disabled then this is the result of a background preflight check
if not self.continue_button.isEnabled():
Expand Down Expand Up @@ -2729,13 +2745,15 @@ def __init__(self, controller: Controller, file_uuid: str, file_name: str):
# Connect parent signals to slots
self.continue_button.setEnabled(False)

self.header_icon.update_image('savetodisk.svg', QSize(64, 64))

# Dialog content
self.starting_header = _(
'Preparing to export:'
'<br />'
'<span style="font-weight:normal">{}</span>'.format(self.file_name))
self.ready_header = _(
'Ready to export:'
'<br />'
'<span style="font-weight:normal">{}</span>'.format(self.file_name))
self.insert_usb_header = _('Insert encrypted USB drive')
self.passphrase_header = _('Enter passphrase for USB drive')
self.success_header = _('Export successful')
Expand Down Expand Up @@ -2793,6 +2811,7 @@ def __init__(self, controller: Controller, file_uuid: str, file_name: str):
self.passphrase_form.hide()

self._show_starting_instructions()
self.start_animate_header()
self._run_preflight()

def _show_starting_instructions(self):
Expand Down Expand Up @@ -2886,12 +2905,15 @@ def _run_preflight(self):

@pyqtSlot()
def _export_file(self, checked: bool = False):
self.start_animate_header()
self.start_animate_activestate()
self.controller.export_file_to_usb_drive(self.file_uuid, self.passphrase_field.text())

@pyqtSlot()
def _on_preflight_success(self):
# If the continue button is disabled then this is the result of a background preflight check
self.stop_animate_header()
self.header_icon.update_image('savetodisk.svg', QSize(64, 64))
self.header.setText(self.ready_header)
if not self.continue_button.isEnabled():
self.continue_button.clicked.disconnect()
self.continue_button.clicked.connect(self._show_passphrase_request_message)
Expand All @@ -2902,16 +2924,18 @@ def _on_preflight_success(self):

@pyqtSlot(object)
def _on_preflight_failure(self, error: ExportError):
self.stop_animate_header()
self.header_icon.update_image('savetodisk.svg', QSize(64, 64))
self._update_dialog(error.status)

@pyqtSlot()
def _on_export_success(self):
self.stop_animate_header()
self.stop_animate_activestate()
self._show_success_message()

@pyqtSlot(object)
def _on_export_failure(self, error: ExportError):
self.stop_animate_header()
self.stop_animate_activestate()
self._update_dialog(error.status)

def _update_dialog(self, error_status: str):
Expand Down

0 comments on commit d42ef98

Please sign in to comment.