When canceling a receive mode transfer, display date range in the UI

This commit is contained in:
Micah Lee 2019-01-20 15:49:08 -08:00
parent 0ef0659e2f
commit 634b8ecebd
No known key found for this signature in database
GPG Key ID: 403C2657CD994F73
2 changed files with 19 additions and 4 deletions

View File

@ -45,19 +45,32 @@ class HistoryItem(QtWidgets.QWidget):
When an item finishes, returns a string displaying the start/end datetime range.
started is a datetime object.
"""
return self._get_label_text('gui_all_modes_transfer_finished', 'gui_all_modes_transfer_finished_range', started)
def get_canceled_label_text(self, started):
"""
When an item is canceled, returns a string displaying the start/end datetime range.
started is a datetime object.
"""
return self._get_label_text('gui_all_modes_transfer_canceled', 'gui_all_modes_transfer_canceled_range', started)
def _get_label_text(self, string_name, string_range_name, started):
"""
Return a string that contains a date, or date range.
"""
ended = datetime.now()
if started.year == ended.year and started.month == ended.month and started.day == ended.day:
if started.hour == ended.hour and started.minute == ended.minute:
text = strings._('gui_all_modes_transfer_finished').format(
text = strings._(string_name).format(
started.strftime("%b %d, %I:%M%p")
)
else:
text = strings._('gui_all_modes_transfer_finished_range').format(
text = strings._(string_range_name).format(
started.strftime("%b %d, %I:%M%p"),
ended.strftime("%I:%M%p")
)
else:
text = strings._('gui_all_modes_transfer_finished_range').format(
text = strings._(string_range_name).format(
started.strftime("%b %d, %I:%M%p"),
ended.strftime("%b %d, %I:%M%p")
)
@ -311,7 +324,7 @@ class ReceiveHistoryItem(HistoryItem):
self.progress_bar.hide()
# Change the label
self.label.setText(strings._('gui_canceled'))
self.label.setText(self.get_canceled_label_text(self.started))
class HistoryItemList(QtWidgets.QScrollArea):

View File

@ -171,6 +171,8 @@
"gui_all_modes_transfer_started": "Started {}",
"gui_all_modes_transfer_finished_range": "Transferred {} - {}",
"gui_all_modes_transfer_finished": "Transferred {}",
"gui_all_modes_transfer_canceled_range": "Canceled {} - {}",
"gui_all_modes_transfer_canceled": "Canceled {}",
"gui_all_modes_progress_complete": "%p%, {0:s} elapsed.",
"gui_all_modes_progress_starting": "{0:s}, %p% (calculating)",
"gui_all_modes_progress_eta": "{0:s}, ETA: {1:s}, %p%",