mirror of
https://github.com/onionshare/onionshare.git
synced 2024-12-29 01:06:16 -05:00
Added an indicator count for share mode
This commit is contained in:
parent
9a05eef494
commit
e87263353f
@ -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;
|
||||
|
@ -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()
|
||||
|
||||
|
@ -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):
|
||||
|
Loading…
Reference in New Issue
Block a user