summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMiguel Jacq <mig@mig5.net>2018-02-22 14:37:31 +1100
committerMiguel Jacq <mig@mig5.net>2018-02-22 14:37:31 +1100
commit921565158261207b4d4254cb682bea3766c6696d (patch)
tree4f4ce1f570566d0e3f73d34686b593ef102b5a56
parent6815665f1d69d83181a9774d5f94cb3ffacb9d85 (diff)
downloadonionshare-921565158261207b4d4254cb682bea3766c6696d.tar.gz
onionshare-921565158261207b4d4254cb682bea3766c6696d.zip
Remove the item_name QLabel widget and just let the QListWidgetItem text() display as title. Trim super-long filenames
-rw-r--r--onionshare_gui/file_selection.py18
1 files changed, 6 insertions, 12 deletions
diff --git a/onionshare_gui/file_selection.py b/onionshare_gui/file_selection.py
index 2a024620..6d4d8b15 100644
--- a/onionshare_gui/file_selection.py
+++ b/onionshare_gui/file_selection.py
@@ -86,6 +86,7 @@ class FileList(QtWidgets.QListWidget):
self.drop_here_text = DropHereLabel(self, False)
self.drop_count = DropCountLabel(self)
self.resizeEvent(None)
+ self.setStyleSheet('QListWidget::item { color: #000000; font-size: 13px; }')
def update(self):
"""
@@ -202,6 +203,8 @@ class FileList(QtWidgets.QListWidget):
fileinfo = QtCore.QFileInfo(filename)
basename = os.path.basename(filename.rstrip('/'))
+ if len(basename) > 35:
+ basename = basename[:35] + '...'
ip = QtWidgets.QFileIconProvider()
icon = ip.icon(fileinfo)
@@ -217,20 +220,13 @@ class FileList(QtWidgets.QListWidget):
item.setIcon(icon)
item.size_bytes = size_bytes
- # Item's name and size labels
- item_name = QtWidgets.QLabel(basename)
+ # Item's filename attribute and size labels
item.filename = filename
- item_name.setWordWrap(False)
- item_name.setSizePolicy(QtWidgets.QSizePolicy.Ignored, QtWidgets.QSizePolicy.Fixed)
- item_name.setStyleSheet('QLabel { color: #000000; font-size: 13px; }')
item_size = QtWidgets.QLabel(size_readable)
item_size.setStyleSheet('QLabel { color: #666666; font-size: 11px; }')
# Use the basename as the method with which to sort the list
item.setData(QtCore.Qt.DisplayRole, basename)
- # But we don't want to *display* the QString (we have our own QLabel), so paint over it.
- item.brush = QtGui.QBrush(QtGui.QColor('white'))
- item.setForeground(item.brush)
# Item's delete button
def delete_item():
@@ -246,11 +242,9 @@ class FileList(QtWidgets.QListWidget):
item.item_button.setSizePolicy(QtWidgets.QSizePolicy.Fixed, QtWidgets.QSizePolicy.Fixed)
# Create the item's widget and layouts
- item_vlayout = QtWidgets.QVBoxLayout()
- item_vlayout.addWidget(item_name)
- item_vlayout.addWidget(item_size)
item_hlayout = QtWidgets.QHBoxLayout()
- item_hlayout.addLayout(item_vlayout)
+ item_hlayout.addStretch()
+ item_hlayout.addWidget(item_size)
item_hlayout.addWidget(item.item_button)
widget = QtWidgets.QWidget()
widget.setLayout(item_hlayout)