diff --git a/onionshare/common.py b/onionshare/common.py index 27e8efc2..06563461 100644 --- a/onionshare/common.py +++ b/onionshare/common.py @@ -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 { diff --git a/onionshare_gui/mode/history.py b/onionshare_gui/mode/history.py index cd8fe529..797950ab 100644 --- a/onionshare_gui/mode/history.py +++ b/onionshare_gui/mode/history.py @@ -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