Make the IndividualFileHistoryItem widgets have color

This commit is contained in:
Micah Lee 2019-09-03 22:31:13 -07:00
parent dee9e40051
commit c2011e6915
No known key found for this signature in database
GPG Key ID: 403C2657CD994F73
2 changed files with 28 additions and 10 deletions

View File

@ -203,7 +203,7 @@ class Common(object):
border: 0px;
}""",
# Common styles between ShareMode and ReceiveMode and their child widgets
# Common styles between modes and their child widgets
'mode_info_label': """
QLabel {
font-size: 12px;
@ -310,6 +310,24 @@ class Common(object):
width: 10px;
}""",
'history_individual_file_timestamp_label': """
QLabel {
color: #666666;
}""",
'history_individual_file_request_label': """
QLabel { }""",
'history_individual_file_status_code_label_2xx': """
QLabel {
color: #008800;
}""",
'history_individual_file_status_code_label_4xx': """
QLabel {
color: #cc0000;
}""",
# Share mode and child widget styles
'share_zip_progess_bar': """
QProgressBar {

View File

@ -363,7 +363,9 @@ class IndividualFileHistoryItem(HistoryItem):
# Labels
self.timestamp_label = QtWidgets.QLabel(self.started_dt.strftime("%b %d, %I:%M%p"))
self.method_label = QtWidgets.QLabel("{} {}".format(self.method, self.path))
self.timestamp_label.setStyleSheet(self.common.css['history_individual_file_timestamp_label'])
self.request_label = QtWidgets.QLabel("{} {}".format(self.method, self.path))
self.request_label.setStyleSheet(self.common.css['history_individual_file_request_label'])
self.status_code_label = QtWidgets.QLabel()
# Progress bar
@ -377,7 +379,7 @@ class IndividualFileHistoryItem(HistoryItem):
# Text layout
labels_layout = QtWidgets.QHBoxLayout()
labels_layout.addWidget(self.timestamp_label)
labels_layout.addWidget(self.method_label)
labels_layout.addWidget(self.request_label)
labels_layout.addWidget(self.status_code_label)
labels_layout.addStretch()
@ -387,16 +389,13 @@ class IndividualFileHistoryItem(HistoryItem):
layout.addWidget(self.progress_bar)
self.setLayout(layout)
# All non-GET requests are error 405 Method Not Allowed
if self.method.lower() != 'get':
self.status_code_label.setText("405")
self.status = HistoryItem.STATUS_FINISHED
self.progress_bar.hide()
return
# Is a status code already sent?
if 'status_code' in data:
self.status_code_label.setText("{}".format(data['status_code']))
if data['status_code'] >= 200 and data['status_code'] < 300:
self.status_code_label.setStyleSheet(self.common.css['history_individual_file_status_code_label_2xx'])
if data['status_code'] >= 400 and data['status_code'] < 500:
self.status_code_label.setStyleSheet(self.common.css['history_individual_file_status_code_label_4xx'])
self.status = HistoryItem.STATUS_FINISHED
self.progress_bar.hide()
return
@ -416,6 +415,7 @@ class IndividualFileHistoryItem(HistoryItem):
self.progress_bar.setValue(downloaded_bytes)
if downloaded_bytes == self.progress_bar.total_bytes:
self.status_code_label.setText("200")
self.status_code_label.setStyleSheet(self.common.css['history_individual_file_status_code_label_2xx'])
self.progress_bar.hide()
self.status = HistoryItem.STATUS_FINISHED