[Pkg-anonymity-tools] [onionshare] 104/140: Fixed drag & drop issue, and made drop here image work in Windows (fixes #129)
Ulrike Uhlig
u-guest at moszumanska.debian.org
Mon Sep 29 20:33:52 UTC 2014
This is an automated email from the git hooks/post-receive script.
u-guest pushed a commit to branch master
in repository onionshare.
commit b1e48fa9bbda98051387b62f2c8ae60ac899c99d
Author: Micah Lee <micah at micahflee.com>
Date: Wed Sep 17 15:48:19 2014 -0700
Fixed drag & drop issue, and made drop here image work in Windows (fixes #129)
---
onionshare_gui/file_selection.py | 40 ++++++++++++++++++++++++++++++++--------
1 file changed, 32 insertions(+), 8 deletions(-)
diff --git a/onionshare_gui/file_selection.py b/onionshare_gui/file_selection.py
index a5a7b70..d5c21dc 100644
--- a/onionshare_gui/file_selection.py
+++ b/onionshare_gui/file_selection.py
@@ -33,11 +33,28 @@ class FileList(QtGui.QListWidget):
self.setIconSize(QtCore.QSize(32, 32))
self.setSortingEnabled(True)
- # drag and drop label
- self.drop_label = QtGui.QLabel(QtCore.QString(strings._('gui_drag_and_drop', True)), parent=self)
- self.drop_label.setAlignment(QtCore.Qt.AlignCenter)
- self.drop_label.setStyleSheet('background: url({0}) no-repeat center center; color: #999999;'.format(common.get_image_path('drop_files.png')))
- self.drop_label.hide()
+ class DropHereLabel(QtGui.QLabel):
+ def __init__(self, parent, image=False):
+ self.parent = parent
+ super(DropHereLabel, self).__init__(parent=parent)
+ self.setAcceptDrops(True)
+ self.setAlignment(QtCore.Qt.AlignCenter)
+
+ if image:
+ self.setPixmap(QtGui.QPixmap.fromImage(QtGui.QImage(common.get_image_path('drop_files.png'))))
+ else:
+ self.setText(QtCore.QString(strings._('gui_drag_and_drop', True)))
+ self.setStyleSheet('color: #999999;')
+
+ self.hide()
+
+ def dragEnterEvent(self, event):
+ self.parent.drop_here_image.hide()
+ self.parent.drop_here_text.hide()
+ event.ignore()
+
+ self.drop_here_image = DropHereLabel(self, True)
+ self.drop_here_text = DropHereLabel(self, False)
self.filenames = []
self.update()
@@ -45,12 +62,15 @@ class FileList(QtGui.QListWidget):
def update(self):
# file list should have a background image if empty
if len(self.filenames) == 0:
- self.drop_label.show()
+ self.drop_here_image.show()
+ self.drop_here_text.show()
else:
- self.drop_label.hide()
+ self.drop_here_image.hide()
+ self.drop_here_text.hide()
def resizeEvent(self, event):
- self.drop_label.setGeometry(0, 0, self.width(), self.height())
+ self.drop_here_image.setGeometry(0, 0, self.width(), self.height())
+ self.drop_here_text.setGeometry(0, 0, self.width(), self.height())
def dragEnterEvent(self, event):
if event.mimeData().hasUrls:
@@ -58,6 +78,10 @@ class FileList(QtGui.QListWidget):
else:
event.ignore()
+ def dragLeaveEvent(self, event):
+ event.accept()
+ self.update()
+
def dragMoveEvent(self, event):
if event.mimeData().hasUrls:
event.setDropAction(QtCore.Qt.CopyAction)
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/collab-maint/onionshare.git
More information about the Pkg-anonymity-tools
mailing list