[Pkg-anonymity-tools] [onionshare] 101/140: fixes unicode filename display in GUI (#141)

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 0a4ee35f5b1658a2144f9af901d65ffd94c211f5
Author: Micah Lee <micah at micahflee.com>
Date:   Tue Sep 16 01:15:57 2014 +0000

    fixes unicode filename display in GUI (#141)
---
 onionshare_gui/file_selection.py | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/onionshare_gui/file_selection.py b/onionshare_gui/file_selection.py
index d638a3b..19fb3f8 100644
--- a/onionshare_gui/file_selection.py
+++ b/onionshare_gui/file_selection.py
@@ -78,10 +78,13 @@ class FileList(QtGui.QListWidget):
 
     def add_file(self, filename):
         if filename not in self.filenames:
+            # make filenames unicode-safe for Qt (#141)
+            filename = filename.encode('utf-8').decode('utf-8', 'replace')
+
             self.filenames.append(filename)
 
-            basename = os.path.basename(filename)
             fileinfo = QtCore.QFileInfo(filename)
+            basename = os.path.basename(filename)
             ip = QtGui.QFileIconProvider()
             icon = ip.icon(fileinfo)
 
@@ -89,7 +92,8 @@ class FileList(QtGui.QListWidget):
                 size = self.human_readable_filesize(fileinfo.size())
             else:
                 size = self.human_readable_filesize(helpers.dir_size(filename))
-            item = QtGui.QListWidgetItem('{0} ({1})'.format(basename, size))
+            item_name = unicode('{0} ({1})'.format(basename, size))
+            item = QtGui.QListWidgetItem(item_name)
             item.setToolTip(QtCore.QString(size))
 
             item.setIcon(icon)

-- 
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