Attempting to redesign Downloads

This commit is contained in:
Micah Lee 2018-09-28 17:01:48 -07:00
parent 08ac4137c7
commit c0e6968b2b
No known key found for this signature in database
GPG key ID: 403C2657CD994F73
7 changed files with 69 additions and 24 deletions

View file

@ -248,6 +248,15 @@ class Common(object):
border-radius: 5px;
}""",
'downloads_uploads': """
background-color: #ffffff;
""",
'downloads_uploads_empty_text': """
QLabel {
color: #999999;
}""",
'downloads_uploads_label': """
QLabel {
font-weight: bold;
@ -255,6 +264,12 @@ class Common(object):
text-align: center;
}""",
'downloads_uploads_clear': """
QPushButton {
color: #3f7fcf;
}
""",
'downloads_uploads_progress_bar': """
QProgressBar {
border: 1px solid #4e064f;

View file

@ -89,33 +89,64 @@ class Downloads(QtWidgets.QScrollArea):
self.downloads = {}
self.setWindowTitle(strings._('gui_downloads', True))
self.setWidgetResizable(True)
self.setMinimumHeight(150)
self.setMinimumWidth(350)
self.setWindowIcon(QtGui.QIcon(common.get_resource_path('images/logo.png')))
self.setWindowFlags(QtCore.Qt.Sheet | QtCore.Qt.WindowTitleHint | QtCore.Qt.WindowSystemMenuHint | QtCore.Qt.CustomizeWindowHint)
self.setStyleSheet(self.common.css['downloads_uploads'])
# Scroll bar
self.vbar = self.verticalScrollBar()
self.vbar.rangeChanged.connect(self.resizeScroll)
# When there are no downloads
empty_image = QtWidgets.QLabel()
empty_image.setAlignment(QtCore.Qt.AlignCenter)
empty_image.setPixmap(QtGui.QPixmap.fromImage(QtGui.QImage(self.common.get_resource_path('images/downloads_transparent.png'))))
empty_text = QtWidgets.QLabel(strings._('gui_no_downloads', True))
empty_text.setAlignment(QtCore.Qt.AlignCenter)
empty_text.setStyleSheet(self.common.css['downloads_uploads_empty_text'])
empty_layout = QtWidgets.QVBoxLayout()
empty_layout.addStretch()
empty_layout.addWidget(empty_image)
empty_layout.addWidget(empty_text)
empty_layout.addStretch()
self.empty = QtWidgets.QWidget()
self.empty.setLayout(empty_layout)
# When there are downloads
downloads_label = QtWidgets.QLabel(strings._('gui_downloads', True))
downloads_label.setStyleSheet(self.common.css['downloads_uploads_label'])
self.no_downloads_label = QtWidgets.QLabel(strings._('gui_no_downloads', True))
self.clear_history_button = QtWidgets.QPushButton(strings._('gui_clear_history', True))
self.clear_history_button.clicked.connect(self.reset)
self.clear_history_button.hide()
clear_button = QtWidgets.QPushButton(strings._('gui_clear_history', True))
clear_button.setStyleSheet(self.common.css['downloads_uploads_clear'])
clear_button.setFlat(True)
clear_button.clicked.connect(self.reset)
download_header = QtWidgets.QHBoxLayout()
download_header.addWidget(downloads_label)
download_header.addStretch()
download_header.addWidget(clear_button)
self.not_empty = QtWidgets.QWidget()
self.not_empty.setLayout(download_header)
self.downloads_layout = QtWidgets.QVBoxLayout()
widget = QtWidgets.QWidget()
# Layout
self.widget = QtWidgets.QWidget()
layout = QtWidgets.QVBoxLayout()
layout.addWidget(downloads_label)
layout.addWidget(self.no_downloads_label)
layout.addWidget(self.clear_history_button)
layout.setContentsMargins(0, 0, 0, 0)
layout.addWidget(self.empty)
layout.addWidget(self.not_empty)
layout.addLayout(self.downloads_layout)
layout.addStretch()
widget.setLayout(layout)
self.setWidget(widget)
self.widget.setLayout(layout)
self.setWidget(self.widget)
# Reset once at the beginning
self.reset()
def resizeEvent(self, event):
"""
When the widget resizes, resize the inner widget to match
"""
#self.empty.resize(self.width()-2, self.width()-2)
pass
def resizeScroll(self, minimum, maximum):
"""
@ -127,10 +158,9 @@ class Downloads(QtWidgets.QScrollArea):
"""
Add a new download progress bar.
"""
# Hide the no_downloads_label
self.no_downloads_label.hide()
# Show the clear_history_button
self.clear_history_button.show()
# Hide empty, show not empty
self.empty.hide()
self.not_empty.show()
# Add it to the list
download = Download(self.common, download_id, total_bytes)
@ -158,6 +188,6 @@ class Downloads(QtWidgets.QScrollArea):
download.progress_bar.close()
self.downloads = {}
self.no_downloads_label.show()
self.clear_history_button.hide()
self.resize(self.sizeHint())
# Hide not empty, show empty
self.not_empty.hide()
self.empty.show()

BIN
share/images/downloads.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.1 KiB

BIN
share/images/uploads.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2 KiB

View file

@ -46,7 +46,7 @@
"gui_copy_url": "Copy Address",
"gui_copy_hidservauth": "Copy HidServAuth",
"gui_downloads": "Download History",
"gui_no_downloads": "No downloads yet.",
"gui_no_downloads": "No Downloads Yet",
"gui_canceled": "Canceled",
"gui_copied_url_title": "Copied OnionShare Address",
"gui_copied_url": "OnionShare address copied to clipboard",
@ -176,7 +176,7 @@
"systray_upload_page_loaded_message": "A user loaded the upload page",
"gui_uploads": "Upload History",
"gui_no_uploads": "No uploads yet.",
"gui_clear_history": "Clear history",
"gui_clear_history": "Clear All",
"gui_upload_in_progress": "Upload Started {}",
"gui_upload_finished_range": "Uploaded {} to {}",
"gui_upload_finished": "Uploaded {}",