From e17dbd4fddb8a8ca25eb6d7e7ad450fd6de357ad Mon Sep 17 00:00:00 2001 From: Micah Lee Date: Sun, 4 Feb 2018 20:50:24 -0800 Subject: [PATCH] Only do the fake item hack if there are items in the list --- onionshare_gui/file_selection.py | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/onionshare_gui/file_selection.py b/onionshare_gui/file_selection.py index 53937e51..5a371d3c 100644 --- a/onionshare_gui/file_selection.py +++ b/onionshare_gui/file_selection.py @@ -62,7 +62,7 @@ class DropCountLabel(QtWidgets.QLabel): self.setStyleSheet('color: #ffffff; background-color: #f44449; font-weight: bold; padding: 5px 10px; border-radius: 10px;') self.hide() - def dragLeaveEvent(self, event): + def dragEnterEvent(self, event): self.hide() event.accept() @@ -109,12 +109,13 @@ class FileList(QtWidgets.QListWidget): self.drop_here_image.setGeometry(0, 0, self.width(), self.height() - offset) self.drop_here_text.setGeometry(0, offset, self.width(), self.height() - offset) - # Add and delete an empty item, to force all items to get redrawn - # This is ugly, but the only way I could figure out how to proceed - item = QtWidgets.QListWidgetItem('fake item') - self.addItem(item) - self.takeItem(self.row(item)) - self.update() + if self.count() > 0: + # Add and delete an empty item, to force all items to get redrawn + # This is ugly, but the only way I could figure out how to proceed + item = QtWidgets.QListWidgetItem('fake item') + self.addItem(item) + self.takeItem(self.row(item)) + self.update() def dragEnterEvent(self, event): """