forked from openlp/openlp
Head r861
This commit is contained in:
commit
afefd3c45f
@ -30,6 +30,7 @@ import os.path
|
||||
from PyQt4 import QtCore, QtGui
|
||||
|
||||
from openlp.core.lib import ThemeXML, translate
|
||||
from openlp.core.utils import get_images_filter
|
||||
from amendthemedialog import Ui_AmendThemeDialog
|
||||
|
||||
log = logging.getLogger(u'AmendThemeForm')
|
||||
@ -209,8 +210,11 @@ class AmendThemeForm(QtGui.QDialog, Ui_AmendThemeDialog):
|
||||
self.previewTheme()
|
||||
|
||||
def onImageToolButtonClicked(self):
|
||||
filename = unicode(QtGui.QFileDialog.getOpenFileName(
|
||||
self, translate('AmendThemeForm', 'Open File')))
|
||||
images_filter = get_images_filter()
|
||||
images_filter = '%s;;%s (*.*) (*)' % (images_filter,
|
||||
translate('AmendThemeForm', 'All Files'))
|
||||
filename = QtGui.QFileDialog.getOpenFileName(self,
|
||||
translate('AmendThemeForm', 'Select Image'), u'', images_filter)
|
||||
if filename:
|
||||
self.ImageLineEdit.setText(filename)
|
||||
self.theme.background_filename = filename
|
||||
|
@ -30,17 +30,20 @@ import os
|
||||
import sys
|
||||
import logging
|
||||
import urllib2
|
||||
|
||||
from datetime import datetime
|
||||
from PyQt4 import QtCore
|
||||
|
||||
from PyQt4 import QtGui, QtCore
|
||||
|
||||
import openlp
|
||||
from openlp.core.lib import translate
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
images_filter = None
|
||||
|
||||
class AppLocation(object):
|
||||
"""
|
||||
Retrieve a directory based on the directory type.
|
||||
The :class:`AppLocation` class is a static class which retrieves a
|
||||
directory based on the directory type.
|
||||
"""
|
||||
AppDir = 1
|
||||
ConfigDir = 2
|
||||
@ -176,6 +179,22 @@ def get_filesystem_encoding():
|
||||
encoding = sys.getdefaultencoding()
|
||||
return encoding
|
||||
|
||||
def get_images_filter():
|
||||
"""
|
||||
Returns a filter string for a file dialog containing all the supported
|
||||
image formats.
|
||||
"""
|
||||
global images_filter
|
||||
if not images_filter:
|
||||
log.debug(u'Generating images filter.')
|
||||
formats = [unicode(fmt)
|
||||
for fmt in QtGui.QImageReader.supportedImageFormats()]
|
||||
visible_formats = u'(*.%s)' % u'; *.'.join(formats)
|
||||
actual_formats = u'(*.%s)' % u' *.'.join(formats)
|
||||
images_filter = u'%s %s %s' % (translate('OpenLP', 'Image Files'),
|
||||
visible_formats, actual_formats)
|
||||
return images_filter
|
||||
|
||||
from languagemanager import LanguageManager
|
||||
|
||||
__all__ = [u'AppLocation', u'check_latest_version', u'add_actions',
|
||||
|
@ -30,7 +30,7 @@ from PyQt4 import QtCore, QtGui
|
||||
|
||||
from openlp.core.lib import MediaManagerItem, BaseListWithDnD, build_icon, \
|
||||
context_menu_action, ItemCapabilities, SettingsManager, translate
|
||||
from openlp.core.utils import AppLocation
|
||||
from openlp.core.utils import AppLocation, get_images_filter
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
@ -61,12 +61,9 @@ class ImageMediaItem(MediaManagerItem):
|
||||
def retranslateUi(self):
|
||||
self.OnNewPrompt = translate('ImagePlugin.MediaItem',
|
||||
'Select Image(s)')
|
||||
file_formats = u''
|
||||
for file_format in QtGui.QImageReader.supportedImageFormats():
|
||||
file_formats += u'*.%s ' % file_format
|
||||
self.OnNewFileMasks = unicode(
|
||||
translate('ImagePlugin.MediaItem',
|
||||
'Images (%s);; All files (*)')) % file_formats
|
||||
file_formats = get_images_filter()
|
||||
self.OnNewFileMasks = u'%s;;%s (*.*) (*)' % (file_formats,
|
||||
unicode(translate('ImagePlugin.MediaItem', 'All Files')))
|
||||
|
||||
def requiredIcons(self):
|
||||
MediaManagerItem.requiredIcons(self)
|
||||
|
Loading…
Reference in New Issue
Block a user