forked from openlp/openlp
Fix bug #1209515 by subclassing QFileDialog and attempting to urldecode any files not found
bzr-revno: 2163 Fixes: https://launchpad.net/bugs/1209515
This commit is contained in:
commit
5090d48ee7
@ -384,6 +384,7 @@ def create_separated_list(stringlist):
|
|||||||
|
|
||||||
|
|
||||||
from eventreceiver import Receiver
|
from eventreceiver import Receiver
|
||||||
|
from filedialog import FileDialog
|
||||||
from listwidgetwithdnd import ListWidgetWithDnD
|
from listwidgetwithdnd import ListWidgetWithDnD
|
||||||
from formattingtags import FormattingTags
|
from formattingtags import FormattingTags
|
||||||
from spelltextedit import SpellTextEdit
|
from spelltextedit import SpellTextEdit
|
||||||
|
63
openlp/core/lib/filedialog.py
Normal file
63
openlp/core/lib/filedialog.py
Normal file
@ -0,0 +1,63 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4
|
||||||
|
|
||||||
|
###############################################################################
|
||||||
|
# OpenLP - Open Source Lyrics Projection #
|
||||||
|
# --------------------------------------------------------------------------- #
|
||||||
|
# Copyright (c) 2008-2013 Raoul Snyman #
|
||||||
|
# Portions copyright (c) 2008-2013 Tim Bentley, Gerald Britton, Jonathan #
|
||||||
|
# Corwin, Samuel Findlay, Michael Gorven, Scott Guerrieri, Matthias Hub, #
|
||||||
|
# Meinert Jordan, Armin Köhler, Erik Lundin, Edwin Lunando, Brian T. Meyer. #
|
||||||
|
# Joshua Miller, Stevan Pettit, Andreas Preikschat, Mattias Põldaru, #
|
||||||
|
# Christian Richter, Philip Ridout, Simon Scudder, Jeffrey Smith, #
|
||||||
|
# Maikel Stuivenberg, Martin Thompson, Jon Tibble, Dave Warnock, #
|
||||||
|
# Frode Woldsund, Martin Zibricky #
|
||||||
|
# --------------------------------------------------------------------------- #
|
||||||
|
# This program is free software; you can redistribute it and/or modify it #
|
||||||
|
# under the terms of the GNU General Public License as published by the Free #
|
||||||
|
# Software Foundation; version 2 of the License. #
|
||||||
|
# #
|
||||||
|
# This program is distributed in the hope that it will be useful, but WITHOUT #
|
||||||
|
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or #
|
||||||
|
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for #
|
||||||
|
# more details. #
|
||||||
|
# #
|
||||||
|
# You should have received a copy of the GNU General Public License along #
|
||||||
|
# with this program; if not, write to the Free Software Foundation, Inc., 59 #
|
||||||
|
# Temple Place, Suite 330, Boston, MA 02111-1307 USA #
|
||||||
|
###############################################################################
|
||||||
|
|
||||||
|
"""
|
||||||
|
Provide a work around for a bug in QFileDialog
|
||||||
|
<https://bugs.launchpad.net/openlp/+bug/1209515>
|
||||||
|
"""
|
||||||
|
import os
|
||||||
|
import urllib
|
||||||
|
|
||||||
|
from PyQt4 import QtCore, QtGui
|
||||||
|
|
||||||
|
from openlp.core.lib.ui import UiStrings
|
||||||
|
|
||||||
|
class FileDialog(QtGui.QFileDialog):
|
||||||
|
"""
|
||||||
|
Subclass QFileDialog to work round a bug
|
||||||
|
"""
|
||||||
|
@staticmethod
|
||||||
|
def getOpenFileNames(parent, title, path, filters):
|
||||||
|
"""
|
||||||
|
Reimplement getOpenFileNames to fix the way it returns some file
|
||||||
|
names that url encoded when selecting multiple files/
|
||||||
|
"""
|
||||||
|
files = QtGui.QFileDialog.getOpenFileNames(parent, title, path, filters)
|
||||||
|
file_list = QtCore.QStringList()
|
||||||
|
for file in files:
|
||||||
|
file = unicode(file)
|
||||||
|
if not os.path.exists(file):
|
||||||
|
file = urllib.unquote(file)
|
||||||
|
if not os.path.exists(file):
|
||||||
|
QtGui.QMessageBox.information(parent,
|
||||||
|
UiStrings().FileNotFound,
|
||||||
|
UiStrings().FileNotFoundMessage % file)
|
||||||
|
continue
|
||||||
|
file_list.append(QtCore.QString(file))
|
||||||
|
return file_list
|
@ -35,7 +35,7 @@ import re
|
|||||||
|
|
||||||
from PyQt4 import QtCore, QtGui
|
from PyQt4 import QtCore, QtGui
|
||||||
|
|
||||||
from openlp.core.lib import SettingsManager, OpenLPToolbar, ServiceItem, \
|
from openlp.core.lib import FileDialog, SettingsManager, OpenLPToolbar, ServiceItem, \
|
||||||
StringContent, build_icon, translate, Receiver, ListWidgetWithDnD
|
StringContent, build_icon, translate, Receiver, ListWidgetWithDnD
|
||||||
from openlp.core.lib.searchedit import SearchEdit
|
from openlp.core.lib.searchedit import SearchEdit
|
||||||
from openlp.core.lib.ui import UiStrings, create_widget_action, \
|
from openlp.core.lib.ui import UiStrings, create_widget_action, \
|
||||||
@ -337,7 +337,7 @@ class MediaManagerItem(QtGui.QWidget):
|
|||||||
"""
|
"""
|
||||||
Add a file to the list widget to make it available for showing
|
Add a file to the list widget to make it available for showing
|
||||||
"""
|
"""
|
||||||
files = QtGui.QFileDialog.getOpenFileNames(
|
files = FileDialog.getOpenFileNames(
|
||||||
self, self.onNewPrompt,
|
self, self.onNewPrompt,
|
||||||
SettingsManager.get_last_dir(self.settingsSection),
|
SettingsManager.get_last_dir(self.settingsSection),
|
||||||
self.onNewFileMasks)
|
self.onNewFileMasks)
|
||||||
|
@ -77,6 +77,10 @@ class UiStrings(object):
|
|||||||
self.Error = translate('OpenLP.Ui', 'Error')
|
self.Error = translate('OpenLP.Ui', 'Error')
|
||||||
self.Export = translate('OpenLP.Ui', 'Export')
|
self.Export = translate('OpenLP.Ui', 'Export')
|
||||||
self.File = translate('OpenLP.Ui', 'File')
|
self.File = translate('OpenLP.Ui', 'File')
|
||||||
|
self.FileNotFound = unicode(translate('OpenLP.Ui',
|
||||||
|
'File Not Found'))
|
||||||
|
self.FileNotFoundMessage = unicode(translate('OpenLP.Ui',
|
||||||
|
'File %s not found.\nPlease try selecting it individually.'))
|
||||||
self.FontSizePtUnit = translate('OpenLP.Ui', 'pt',
|
self.FontSizePtUnit = translate('OpenLP.Ui', 'pt',
|
||||||
'Abbreviated font pointsize unit')
|
'Abbreviated font pointsize unit')
|
||||||
self.Help = translate('OpenLP.Ui', 'Help')
|
self.Help = translate('OpenLP.Ui', 'Help')
|
||||||
|
@ -36,7 +36,7 @@ import re
|
|||||||
from xml.etree.ElementTree import ElementTree, XML
|
from xml.etree.ElementTree import ElementTree, XML
|
||||||
from PyQt4 import QtCore, QtGui
|
from PyQt4 import QtCore, QtGui
|
||||||
|
|
||||||
from openlp.core.lib import OpenLPToolbar, get_text_file_string, build_icon, \
|
from openlp.core.lib import FileDialog, OpenLPToolbar, get_text_file_string, build_icon, \
|
||||||
Receiver, SettingsManager, translate, check_item_selected, \
|
Receiver, SettingsManager, translate, check_item_selected, \
|
||||||
check_directory_exists, create_thumb, validate_thumb, ImageSource
|
check_directory_exists, create_thumb, validate_thumb, ImageSource
|
||||||
from openlp.core.lib.theme import ThemeXML, BackgroundType, VerticalType, \
|
from openlp.core.lib.theme import ThemeXML, BackgroundType, VerticalType, \
|
||||||
@ -420,7 +420,7 @@ class ThemeManager(QtGui.QWidget):
|
|||||||
attempting to extract OpenLP themes from those files. This process
|
attempting to extract OpenLP themes from those files. This process
|
||||||
will load both OpenLP version 1 and version 2 themes.
|
will load both OpenLP version 1 and version 2 themes.
|
||||||
"""
|
"""
|
||||||
files = QtGui.QFileDialog.getOpenFileNames(self,
|
files = FileDialog.getOpenFileNames(self,
|
||||||
translate('OpenLP.ThemeManager', 'Select Theme Import File'),
|
translate('OpenLP.ThemeManager', 'Select Theme Import File'),
|
||||||
SettingsManager.get_last_dir(self.settingsSection),
|
SettingsManager.get_last_dir(self.settingsSection),
|
||||||
unicode(translate('OpenLP.ThemeManager',
|
unicode(translate('OpenLP.ThemeManager',
|
||||||
|
@ -34,7 +34,7 @@ import shutil
|
|||||||
|
|
||||||
from PyQt4 import QtCore, QtGui
|
from PyQt4 import QtCore, QtGui
|
||||||
|
|
||||||
from openlp.core.lib import PluginStatus, Receiver, MediaType, translate, \
|
from openlp.core.lib import FileDialog, PluginStatus, Receiver, MediaType, translate, \
|
||||||
create_separated_list, check_directory_exists
|
create_separated_list, check_directory_exists
|
||||||
from openlp.core.lib.ui import UiStrings, set_case_insensitive_completer, \
|
from openlp.core.lib.ui import UiStrings, set_case_insensitive_completer, \
|
||||||
critical_error_message_box, find_and_set_in_combo_box
|
critical_error_message_box, find_and_set_in_combo_box
|
||||||
@ -762,7 +762,7 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog):
|
|||||||
Loads file(s) from the filesystem.
|
Loads file(s) from the filesystem.
|
||||||
"""
|
"""
|
||||||
filters = u'%s (*)' % UiStrings().AllFiles
|
filters = u'%s (*)' % UiStrings().AllFiles
|
||||||
filenames = QtGui.QFileDialog.getOpenFileNames(self,
|
filenames = FileDialog.getOpenFileNames(self,
|
||||||
translate('SongsPlugin.EditSongForm', 'Open File(s)'),
|
translate('SongsPlugin.EditSongForm', 'Open File(s)'),
|
||||||
QtCore.QString(), filters)
|
QtCore.QString(), filters)
|
||||||
for filename in filenames:
|
for filename in filenames:
|
||||||
|
@ -35,7 +35,7 @@ import os
|
|||||||
|
|
||||||
from PyQt4 import QtCore, QtGui
|
from PyQt4 import QtCore, QtGui
|
||||||
|
|
||||||
from openlp.core.lib import Receiver, SettingsManager, translate
|
from openlp.core.lib import FileDialog, Receiver, SettingsManager, translate
|
||||||
from openlp.core.lib.ui import UiStrings, critical_error_message_box
|
from openlp.core.lib.ui import UiStrings, critical_error_message_box
|
||||||
from openlp.core.lib.settings import Settings
|
from openlp.core.lib.settings import Settings
|
||||||
from openlp.core.ui.wizard import OpenLPWizard, WizardStrings
|
from openlp.core.ui.wizard import OpenLPWizard, WizardStrings
|
||||||
@ -281,7 +281,7 @@ class SongImportForm(OpenLPWizard):
|
|||||||
if filters:
|
if filters:
|
||||||
filters += u';;'
|
filters += u';;'
|
||||||
filters += u'%s (*)' % UiStrings().AllFiles
|
filters += u'%s (*)' % UiStrings().AllFiles
|
||||||
filenames = QtGui.QFileDialog.getOpenFileNames(self, title,
|
filenames = FileDialog.getOpenFileNames(self, title,
|
||||||
SettingsManager.get_last_dir(self.plugin.settingsSection, 1),
|
SettingsManager.get_last_dir(self.plugin.settingsSection, 1),
|
||||||
filters)
|
filters)
|
||||||
if filenames:
|
if filenames:
|
||||||
|
Loading…
Reference in New Issue
Block a user