Added an indicator count for share mode

This commit is contained in:
Micah Lee 2018-09-28 19:54:46 -07:00
parent 9a05eef494
commit e87263353f
No known key found for this signature in database
GPG Key ID: 403C2657CD994F73
3 changed files with 37 additions and 0 deletions

View File

@ -279,6 +279,16 @@ class Common(object):
}
""",
'download_uploads_indicator': """
QLabel {
color: #ffffff;
background-color: #f44449;
font-weight: bold;
padding: 5px;
border-radius: 5px;
font-size: 10px;
}""",
'downloads_uploads_progress_bar': """
QProgressBar {
border: 1px solid #4e064f;

View File

@ -224,6 +224,7 @@ class ShareMode(Mode):
else:
filesize = self.web.share_mode.download_filesize
self.downloads.add(event["data"]["id"], filesize)
self.info.update_indicator(True)
self.downloads_in_progress += 1
self.info.update_downloads_in_progress()

View File

@ -51,12 +51,19 @@ class ShareModeInfo(QtWidgets.QWidget):
self.toggle_button.setIcon( QtGui.QIcon(self.common.get_resource_path('images/downloads_toggle.png')) )
self.toggle_button.clicked.connect(self.toggle_downloads)
# Keep track of indicator
self.indicator_count = 0
self.indicator_label = QtWidgets.QLabel()
self.indicator_label.setStyleSheet(self.common.css['download_uploads_indicator'])
self.update_indicator()
# Info layout
layout = QtWidgets.QHBoxLayout()
layout.addWidget(self.label)
layout.addStretch()
layout.addWidget(self.in_progress_downloads_count)
layout.addWidget(self.completed_downloads_count)
layout.addWidget(self.indicator_label)
layout.addWidget(self.toggle_button)
self.setLayout(layout)
@ -70,6 +77,21 @@ class ShareModeInfo(QtWidgets.QWidget):
self.label_text = s
self.label.setText(self.label_text)
def update_indicator(self, increment=False):
"""
Update the display of the indicator count. If increment is True, then
only increment the counter if Downloads is hidden.
"""
if increment and not self.share_mode.downloads.isVisible():
self.indicator_count += 1
self.indicator_label.setText("{}".format(self.indicator_count))
if self.indicator_count == 0:
self.indicator_label.hide()
else:
self.indicator_label.show()
def update_downloads_completed(self):
"""
Update the 'Downloads completed' info widget.
@ -107,6 +129,10 @@ class ShareModeInfo(QtWidgets.QWidget):
self.toggle_button.setIcon( QtGui.QIcon(self.common.get_resource_path('images/downloads_toggle_selected.png')) )
self.toggle_button.setFlat(False)
# Reset the indicator count
self.indicator_count = 0
self.update_indicator()
self.share_mode.resize_window()
def show_less(self):