Merged whit current trunk

This commit is contained in:
Frode Woldsund 2010-06-17 00:14:46 +02:00
commit cc7b6a9ec3
28 changed files with 287 additions and 242 deletions

View File

@ -80,9 +80,9 @@ def str_to_bool(stringvalue):
``stringvalue`` ``stringvalue``
The string value to examine and convert to a boolean type. The string value to examine and convert to a boolean type.
""" """
if stringvalue is True or stringvalue is False: if isinstance(stringvalue, bool):
return stringvalue return stringvalue
return stringvalue.strip().lower() in (u'true', u'yes', u'y') return unicode(stringvalue).strip().lower() in (u'true', u'yes', u'y')
def build_icon(icon): def build_icon(icon):
""" """
@ -95,24 +95,24 @@ def build_icon(icon):
The icon to build. This can be a QIcon, a resource string in the form The icon to build. This can be a QIcon, a resource string in the form
``:/resource/file.png``, or a file location like ``/path/to/file.png``. ``:/resource/file.png``, or a file location like ``/path/to/file.png``.
""" """
ButtonIcon = None button_icon = None
if isinstance(icon, QtGui.QIcon): if isinstance(icon, QtGui.QIcon):
ButtonIcon = icon button_icon = icon
elif isinstance(icon, basestring): elif isinstance(icon, basestring):
ButtonIcon = QtGui.QIcon() button_icon = QtGui.QIcon()
if icon.startswith(u':/'): if icon.startswith(u':/'):
ButtonIcon.addPixmap( button_icon.addPixmap(QtGui.QPixmap(icon), QtGui.QIcon.Normal,
QtGui.QPixmap(icon), QtGui.QIcon.Normal, QtGui.QIcon.Off) QtGui.QIcon.Off)
else: else:
ButtonIcon.addPixmap(QtGui.QPixmap.fromImage(QtGui.QImage(icon)), button_icon.addPixmap(QtGui.QPixmap.fromImage(QtGui.QImage(icon)),
QtGui.QIcon.Normal, QtGui.QIcon.Off) QtGui.QIcon.Normal, QtGui.QIcon.Off)
elif isinstance(icon, QtGui.QImage): elif isinstance(icon, QtGui.QImage):
ButtonIcon = QtGui.QIcon() button_icon = QtGui.QIcon()
ButtonIcon.addPixmap( button_icon.addPixmap(QtGui.QPixmap.fromImage(icon),
QtGui.QPixmap.fromImage(icon), QtGui.QIcon.Normal, QtGui.QIcon.Off) QtGui.QIcon.Normal, QtGui.QIcon.Off)
return ButtonIcon return button_icon
def contextMenuAction(base, icon, text, slot): def context_menu_action(base, icon, text, slot):
""" """
Utility method to help build context menus for plugins Utility method to help build context menus for plugins
""" """
@ -122,7 +122,7 @@ def contextMenuAction(base, icon, text, slot):
QtCore.QObject.connect(action, QtCore.SIGNAL(u'triggered()'), slot) QtCore.QObject.connect(action, QtCore.SIGNAL(u'triggered()'), slot)
return action return action
def contextMenu(base, icon, text): def context_menu(base, icon, text):
""" """
Utility method to help build context menus for plugins Utility method to help build context menus for plugins
""" """
@ -130,7 +130,7 @@ def contextMenu(base, icon, text):
action.setIcon(build_icon(icon)) action.setIcon(build_icon(icon))
return action return action
def contextMenuSeparator(base): def context_menu_separator(base):
""" """
Add a separator to a context menu Add a separator to a context menu
""" """
@ -152,12 +152,12 @@ def resize_image(image, width, height):
realw = preview.width() realw = preview.width()
realh = preview.height() realh = preview.height()
# and move it to the centre of the preview space # and move it to the centre of the preview space
newImage = QtGui.QImage(width, height, new_image = QtGui.QImage(width, height,
QtGui.QImage.Format_ARGB32_Premultiplied) QtGui.QImage.Format_ARGB32_Premultiplied)
newImage.fill(QtCore.Qt.black) new_image.fill(QtCore.Qt.black)
painter = QtGui.QPainter(newImage) painter = QtGui.QPainter(new_image)
painter.drawImage((width - realw) / 2, (height - realh) / 2, preview) painter.drawImage((width - realw) / 2, (height - realh) / 2, preview)
return newImage return new_image
class ThemeLevel(object): class ThemeLevel(object):

View File

@ -28,9 +28,10 @@ import os
from PyQt4 import QtCore, QtGui from PyQt4 import QtCore, QtGui
from openlp.core.lib import contextMenuAction, contextMenuSeparator, \ from openlp.core.lib import context_menu_action, context_menu_separator, \
SettingsManager, OpenLPToolbar, ServiceItem, build_icon, translate SettingsManager, OpenLPToolbar, ServiceItem, build_icon, translate
log = logging.getLogger(__name__) log = logging.getLogger(__name__)
class MediaManagerItem(QtGui.QWidget): class MediaManagerItem(QtGui.QWidget):
@ -283,38 +284,38 @@ class MediaManagerItem(QtGui.QWidget):
self.ListView.setContextMenuPolicy(QtCore.Qt.ActionsContextMenu) self.ListView.setContextMenuPolicy(QtCore.Qt.ActionsContextMenu)
if self.hasEditIcon: if self.hasEditIcon:
self.ListView.addAction( self.ListView.addAction(
contextMenuAction( context_menu_action(
self.ListView, u':/general/general_edit.png', self.ListView, u':/general/general_edit.png',
unicode(translate(u'MediaManagerItem', u'&Edit %s')) % \ unicode(translate(u'MediaManagerItem', u'&Edit %s')) % \
self.PluginNameVisible, self.PluginNameVisible,
self.onEditClick)) self.onEditClick))
self.ListView.addAction(contextMenuSeparator(self.ListView)) self.ListView.addAction(context_menu_separator(self.ListView))
if self.hasDeleteIcon: if self.hasDeleteIcon:
self.ListView.addAction( self.ListView.addAction(
contextMenuAction( context_menu_action(
self.ListView, u':/general/general_delete.png', self.ListView, u':/general/general_delete.png',
unicode(translate(u'MediaManagerItem', u'&Delete %s')) % \ unicode(translate(u'MediaManagerItem', u'&Delete %s')) % \
self.PluginNameVisible, self.PluginNameVisible,
self.onDeleteClick)) self.onDeleteClick))
self.ListView.addAction(contextMenuSeparator(self.ListView)) self.ListView.addAction(context_menu_separator(self.ListView))
self.ListView.addAction( self.ListView.addAction(
contextMenuAction( context_menu_action(
self.ListView, u':/general/general_preview.png', self.ListView, u':/general/general_preview.png',
unicode(translate(u'MediaManagerItem', u'&Preview %s')) % \ unicode(translate(u'MediaManagerItem', u'&Preview %s')) % \
self.PluginNameVisible, self.PluginNameVisible,
self.onPreviewClick)) self.onPreviewClick))
self.ListView.addAction( self.ListView.addAction(
contextMenuAction( context_menu_action(
self.ListView, u':/general/general_live.png', self.ListView, u':/general/general_live.png',
translate(u'MediaManagerItem', u'&Show Live'), self.onLiveClick)) translate(u'MediaManagerItem', u'&Show Live'), self.onLiveClick))
self.ListView.addAction( self.ListView.addAction(
contextMenuAction( context_menu_action(
self.ListView, u':/general/general_add.png', self.ListView, u':/general/general_add.png',
translate(u'MediaManagerItem', u'&Add to Service'), translate(u'MediaManagerItem', u'&Add to Service'),
self.onAddClick)) self.onAddClick))
if self.addToServiceItem: if self.addToServiceItem:
self.ListView.addAction( self.ListView.addAction(
contextMenuAction( context_menu_action(
self.ListView, u':/general/general_add.png', self.ListView, u':/general/general_add.png',
translate(u'MediaManagerItem', translate(u'MediaManagerItem',
u'&Add to selected Service Item'), u'&Add to selected Service Item'),
@ -360,7 +361,7 @@ class MediaManagerItem(QtGui.QWidget):
filelist = [] filelist = []
while count < self.ListView.count(): while count < self.ListView.count():
bitem = self.ListView.item(count) bitem = self.ListView.item(count)
filename = unicode((bitem.data(QtCore.Qt.UserRole)).toString()) filename = unicode(bitem.data(QtCore.Qt.UserRole).toString())
filelist.append(filename) filelist.append(filename)
count += 1 count += 1
return filelist return filelist
@ -486,9 +487,9 @@ class MediaManagerItem(QtGui.QWidget):
""" """
service_item = ServiceItem(self.parent) service_item = ServiceItem(self.parent)
if self.ServiceItemIconName: if self.ServiceItemIconName:
service_item.addIcon(self.ServiceItemIconName) service_item.add_icon(self.ServiceItemIconName)
else: else:
service_item.addIcon( service_item.add_icon(
u':/media/media_' + self.PluginNameShort.lower() + u'.png') u':/media/media_' + self.PluginNameShort.lower() + u'.png')
if self.generateSlideData(service_item, item): if self.generateSlideData(service_item, item):
return service_item return service_item

View File

@ -468,7 +468,7 @@ class Renderer(object):
self._get_extent_and_render(line, footer, self._get_extent_and_render(line, footer,
tlcorner=(x + display_shadow_size, tlcorner=(x + display_shadow_size,
y + display_shadow_size), y + display_shadow_size),
draw=True, color = self._theme.display_shadow_color) draw=True, color=self._theme.display_shadow_color)
self._get_extent_and_render(line, footer, tlcorner=(x, y), self._get_extent_and_render(line, footer, tlcorner=(x, y),
draw=True, outline_size=display_outline_size) draw=True, outline_size=display_outline_size)
y += h y += h

View File

@ -73,9 +73,10 @@ class ServiceItem(object):
The plugin that this service item belongs to. The plugin that this service item belongs to.
""" """
if plugin: if plugin:
self.RenderManager = plugin.render_manager self.render_manager = plugin.render_manager
self.name = plugin.name self.name = plugin.name
self.title = u'' self.title = u''
self.shortname = u''
self.audit = u'' self.audit = u''
self.items = [] self.items = []
self.iconic_representation = None self.iconic_representation = None
@ -90,6 +91,7 @@ class ServiceItem(object):
self.capabilities = [] self.capabilities = []
self.is_valid = True self.is_valid = True
self.cache = [] self.cache = []
self.icon = None
def add_capability(self, capability): def add_capability(self, capability):
""" """
@ -109,7 +111,7 @@ class ServiceItem(object):
""" """
return capability in self.capabilities return capability in self.capabilities
def addIcon(self, icon): def add_icon(self, icon):
""" """
Add an icon to the service item. This is used when displaying the Add an icon to the service item. This is used when displaying the
service item in the service manager. service item in the service manager.
@ -131,12 +133,12 @@ class ServiceItem(object):
if self.service_item_type == ServiceItemType.Text: if self.service_item_type == ServiceItemType.Text:
log.debug(u'Formatting slides') log.debug(u'Formatting slides')
if self.theme is None: if self.theme is None:
self.RenderManager.set_override_theme(None) self.render_manager.set_override_theme(None)
else: else:
self.RenderManager.set_override_theme(self.theme) self.render_manager.set_override_theme(self.theme)
for slide in self._raw_frames: for slide in self._raw_frames:
before = time.time() before = time.time()
formated = self.RenderManager.format_slide(slide[u'raw_slide']) formated = self.render_manager.format_slide(slide[u'raw_slide'])
for format in formated: for format in formated:
lines = u'' lines = u''
title = u'' title = u''
@ -151,9 +153,8 @@ class ServiceItem(object):
log.log(15, u'Formatting took %4s' % (time.time() - before)) log.log(15, u'Formatting took %4s' % (time.time() - before))
elif self.service_item_type == ServiceItemType.Image: elif self.service_item_type == ServiceItemType.Image:
for slide in self._raw_frames: for slide in self._raw_frames:
slide[u'image'] = \ slide[u'image'] = resize_image(slide[u'image'],
resize_image(slide[u'image'], self.RenderManager.width, self.render_manager.width, self.render_manager.height)
self.RenderManager.height)
elif self.service_item_type == ServiceItemType.Command: elif self.service_item_type == ServiceItemType.Command:
pass pass
else: else:
@ -167,19 +168,19 @@ class ServiceItem(object):
""" """
log.debug(u'render individual') log.debug(u'render individual')
if self.theme is None: if self.theme is None:
self.RenderManager.set_override_theme(None) self.render_manager.set_override_theme(None)
else: else:
self.RenderManager.set_override_theme(self.theme) self.render_manager.set_override_theme(self.theme)
format = self._display_frames[row][u'text'].split(u'\n') format = self._display_frames[row][u'text'].split(u'\n')
#if screen blank then do not display footer #if screen blank then do not display footer
if self.cache[row] is not None: if self.cache[row] is not None:
frame = self.cache[row] frame = self.cache[row]
else: else:
if format[0]: if format[0]:
frame = self.RenderManager.generate_slide(format, frame = self.render_manager.generate_slide(format,
self.raw_footer) self.raw_footer)
else: else:
frame = self.RenderManager.generate_slide(format, u'') frame = self.render_manager.generate_slide(format, u'')
self.cache[row] = frame self.cache[row] = frame
return frame return frame
@ -200,7 +201,7 @@ class ServiceItem(object):
self._raw_frames.append( self._raw_frames.append(
{u'title': title, u'image': image, u'path': path}) {u'title': title, u'image': image, u'path': path})
def add_from_text(self, title, raw_slide, verseTag=None): def add_from_text(self, title, raw_slide, verse_tag=None):
""" """
Add a text slide to the service item. Add a text slide to the service item.
@ -213,7 +214,7 @@ class ServiceItem(object):
self.service_item_type = ServiceItemType.Text self.service_item_type = ServiceItemType.Text
title = title.split(u'\n')[0] title = title.split(u'\n')[0]
self._raw_frames.append( self._raw_frames.append(
{u'title': title, u'raw_slide': raw_slide, u'verseTag':verseTag}) {u'title': title, u'raw_slide': raw_slide, u'verseTag':verse_tag})
def add_from_command(self, path, file_name, image): def add_from_command(self, path, file_name, image):
""" """
@ -280,7 +281,7 @@ class ServiceItem(object):
self.service_item_type = header[u'type'] self.service_item_type = header[u'type']
self.shortname = header[u'plugin'] self.shortname = header[u'plugin']
self.theme = header[u'theme'] self.theme = header[u'theme']
self.addIcon(header[u'icon']) self.add_icon(header[u'icon'])
self.raw_footer = header[u'footer'] self.raw_footer = header[u'footer']
self.audit = header[u'audit'] self.audit = header[u'audit']
self.notes = header[u'notes'] self.notes = header[u'notes']

View File

@ -41,7 +41,7 @@ class XmlRootClass(object):
(element.tag, val) = self.post_tag_hook(element.tag, val) (element.tag, val) = self.post_tag_hook(element.tag, val)
""" """
def _setFromXml(self, xml, root_tag): def _set_from_xml(self, xml, root_tag):
""" """
Set song properties from given xml content. Set song properties from given xml content.

View File

@ -153,8 +153,8 @@ class Theme(object):
The data to initialise the theme with The data to initialise the theme with
""" """
# init to defaults # init to defaults
self._set_from_XML(BLANK_STYLE_XML) self._set_from_xml(BLANK_STYLE_XML)
self._set_from_XML(xml) self._set_from_xml(xml)
def _get_as_string(self): def _get_as_string(self):
""" """
@ -176,9 +176,9 @@ class Theme(object):
The data to apply to the theme The data to apply to the theme
""" """
root = ElementTree(element=XML(xml)) root = ElementTree(element=XML(xml))
iter = root.getiterator() xml_iter = root.getiterator()
for element in iter: for element in xml_iter:
delphiColorChange = False delphi_color_change = False
if element.tag != u'Theme': if element.tag != u'Theme':
element_text = element.text element_text = element.text
val = 0 val = 0
@ -194,7 +194,7 @@ class Theme(object):
pass pass
elif DELPHI_COLORS.has_key(element_text): elif DELPHI_COLORS.has_key(element_text):
val = DELPHI_COLORS[element_text] val = DELPHI_COLORS[element_text]
delphiColorChange = True delphi_color_change = True
else: else:
try: try:
val = int(element_text) val = int(element_text)
@ -204,7 +204,7 @@ class Theme(object):
(element.tag.find(u'BackgroundParameter') == 0 and (element.tag.find(u'BackgroundParameter') == 0 and
type(val) == type(0))): type(val) == type(0))):
# convert to a wx.Colour # convert to a wx.Colour
if not delphiColorChange: if not delphi_color_change:
val = QtGui.QColor( val = QtGui.QColor(
val&0xFF, (val>>8)&0xFF, (val>>16)&0xFF) val&0xFF, (val>>8)&0xFF, (val>>16)&0xFF)
else: else:

View File

@ -44,8 +44,8 @@ class AboutForm(QtGui.QDialog, Ui_AboutDialog):
about_text = about_text.replace(u'<version>', about_text = about_text.replace(u'<version>',
self.applicationVersion[u'version']) self.applicationVersion[u'version'])
if self.applicationVersion[u'build']: if self.applicationVersion[u'build']:
build_text = u' %s %s' % (translate(u'AboutForm', u'build'), build_text = unicode(translate(u'AboutForm', u' build %s')) % \
self.applicationVersion[u'build']) self.applicationVersion[u'build']
else: else:
build_text = u'' build_text = u''
about_text = about_text.replace(u'<revision>', build_text) about_text = about_text.replace(u'<revision>', build_text)

View File

@ -155,7 +155,7 @@ class AmendThemeForm(QtGui.QDialog, Ui_AmendThemeDialog):
self.theme.background_direction) self.theme.background_direction)
else: else:
filename = \ filename = \
os.path.split(unicode(self.theme.background_filename))[0] os.path.split(unicode(self.theme.background_filename))[1]
new_theme.add_background_image(filename) new_theme.add_background_image(filename)
save_to = os.path.join(self.path, theme_name, filename) save_to = os.path.join(self.path, theme_name, filename)
save_from = self.theme.background_filename save_from = self.theme.background_filename
@ -239,12 +239,13 @@ class AmendThemeForm(QtGui.QDialog, Ui_AmendThemeDialog):
self.previewTheme() self.previewTheme()
def onFontMainColorPushButtonClicked(self): def onFontMainColorPushButtonClicked(self):
self.theme.font_main_color = QtGui.QColorDialog.getColor( new_color = QtGui.QColorDialog.getColor(
QtGui.QColor(self.theme.font_main_color), self).name() QtGui.QColor(self.theme.font_main_color), self)
if new_color.isValid():
self.FontMainColorPushButton.setStyleSheet( self.theme.font_main_color = new_color.name()
u'background-color: %s' % unicode(self.theme.font_main_color)) self.FontMainColorPushButton.setStyleSheet(
self.previewTheme() u'background-color: %s' % unicode(self.theme.font_main_color))
self.previewTheme()
def onFontMainSizeSpinBoxChanged(self): def onFontMainSizeSpinBoxChanged(self):
if self.theme.font_main_proportion != self.FontMainSizeSpinBox.value(): if self.theme.font_main_proportion != self.FontMainSizeSpinBox.value():
@ -332,11 +333,13 @@ class AmendThemeForm(QtGui.QDialog, Ui_AmendThemeDialog):
self.previewTheme() self.previewTheme()
def onFontFooterColorPushButtonClicked(self): def onFontFooterColorPushButtonClicked(self):
self.theme.font_footer_color = QtGui.QColorDialog.getColor( new_color = QtGui.QColorDialog.getColor(
QtGui.QColor(self.theme.font_footer_color), self).name() QtGui.QColor(self.theme.font_footer_color), self)
self.FontFooterColorPushButton.setStyleSheet( if new_color.isValid():
'background-color: %s' % unicode(self.theme.font_footer_color)) self.theme.font_footer_color = new_color.name()
self.previewTheme() self.FontFooterColorPushButton.setStyleSheet(
u'background-color: %s' % unicode(self.theme.font_footer_color))
self.previewTheme()
def onFontFooterSizeSpinBoxChanged(self): def onFontFooterSizeSpinBoxChanged(self):
if self.theme.font_footer_proportion != \ if self.theme.font_footer_proportion != \
@ -431,24 +434,29 @@ class AmendThemeForm(QtGui.QDialog, Ui_AmendThemeDialog):
def onColor1PushButtonClicked(self): def onColor1PushButtonClicked(self):
if self.theme.background_type == u'solid': if self.theme.background_type == u'solid':
self.theme.background_color = QtGui.QColorDialog.getColor( new_color = QtGui.QColorDialog.getColor(
QtGui.QColor(self.theme.background_color), self).name() QtGui.QColor(self.theme.background_color), self)
self.Color1PushButton.setStyleSheet( if new_color.isValid():
u'background-color: %s' % unicode(self.theme.background_color)) self.theme.background_color = new_color.name()
self.Color1PushButton.setStyleSheet(u'background-color: %s' %
unicode(self.theme.background_color))
else: else:
self.theme.background_startColor = QtGui.QColorDialog.getColor( new_color = QtGui.QColorDialog.getColor(
QtGui.QColor(self.theme.background_startColor), self).name() QtGui.QColor(self.theme.background_startColor), self)
self.Color1PushButton.setStyleSheet( if new_color.isValid():
u'background-color: %s' % \ self.theme.background_startColor = new_color.name()
self.Color1PushButton.setStyleSheet(u'background-color: %s' %
unicode(self.theme.background_startColor)) unicode(self.theme.background_startColor))
self.previewTheme() self.previewTheme()
def onColor2PushButtonClicked(self): def onColor2PushButtonClicked(self):
self.theme.background_endColor = QtGui.QColorDialog.getColor( new_color = QtGui.QColorDialog.getColor(
QtGui.QColor(self.theme.background_endColor), self).name() QtGui.QColor(self.theme.background_endColor), self)
self.Color2PushButton.setStyleSheet( if new_color.isValid():
u'background-color: %s' % unicode(self.theme.background_endColor)) self.theme.background_endColor = new_color.name()
self.previewTheme() self.Color2PushButton.setStyleSheet(u'background-color: %s' %
unicode(self.theme.background_endColor))
self.previewTheme()
# #
#Other Tab #Other Tab
@ -472,11 +480,13 @@ class AmendThemeForm(QtGui.QDialog, Ui_AmendThemeDialog):
self.previewTheme() self.previewTheme()
def onOutlineColorPushButtonClicked(self): def onOutlineColorPushButtonClicked(self):
self.theme.display_outline_color = QtGui.QColorDialog.getColor( new_color = QtGui.QColorDialog.getColor(
QtGui.QColor(self.theme.display_outline_color), self).name() QtGui.QColor(self.theme.display_outline_color), self)
self.OutlineColorPushButton.setStyleSheet( if new_color.isValid():
u'background-color: %s' % unicode(self.theme.display_outline_color)) self.theme.display_outline_color = new_color.name()
self.previewTheme() self.OutlineColorPushButton.setStyleSheet(u'background-color: %s' %
unicode(self.theme.display_outline_color))
self.previewTheme()
def onShadowCheckBoxChanged(self, value): def onShadowCheckBoxChanged(self, value):
if value == 2: # checked if value == 2: # checked
@ -495,11 +505,13 @@ class AmendThemeForm(QtGui.QDialog, Ui_AmendThemeDialog):
self.previewTheme() self.previewTheme()
def onShadowColorPushButtonClicked(self): def onShadowColorPushButtonClicked(self):
self.theme.display_shadow_color = QtGui.QColorDialog.getColor( new_color = QtGui.QColorDialog.getColor(
QtGui.QColor(self.theme.display_shadow_color), self).name() QtGui.QColor(self.theme.display_shadow_color), self)
self.ShadowColorPushButton.setStyleSheet( if new_color.isValid():
u'background-color: %s' % unicode(self.theme.display_shadow_color)) self.theme.display_shadow_color = new_color.name()
self.previewTheme() self.ShadowColorPushButton.setStyleSheet(u'background-color: %s' %
unicode(self.theme.display_shadow_color))
self.previewTheme()
def onHorizontalComboBoxSelected(self, currentIndex): def onHorizontalComboBoxSelected(self, currentIndex):
self.theme.display_horizontalAlign = currentIndex self.theme.display_horizontalAlign = currentIndex

View File

@ -452,8 +452,8 @@ class Ui_MainWindow(object):
translate(u'MainWindow', u'Choose System language, if available')) translate(u'MainWindow', u'Choose System language, if available'))
for item in self.LanguageGroup.actions(): for item in self.LanguageGroup.actions():
item.setText(item.objectName()) item.setText(item.objectName())
item.setStatusTip(translate(u'MainWindow', item.setStatusTip(unicode(translate(u'MainWindow',
u'Set the interface language to %1').arg(item.objectName())) u'Set the interface language to %s')) % item.objectName())
self.ToolsAddToolItem.setText(translate(u'MainWindow', u'Add &Tool...')) self.ToolsAddToolItem.setText(translate(u'MainWindow', u'Add &Tool...'))
self.ToolsAddToolItem.setStatusTip( self.ToolsAddToolItem.setStatusTip(
translate(u'MainWindow', translate(u'MainWindow',
@ -488,7 +488,7 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow):
self.displayManager = DisplayManager(screens) self.displayManager = DisplayManager(screens)
self.aboutForm = AboutForm(self, applicationVersion) self.aboutForm = AboutForm(self, applicationVersion)
self.settingsForm = SettingsForm(self.screens, self, self) self.settingsForm = SettingsForm(self.screens, self, self)
self.recentFiles = [] self.recentFiles = QtCore.QStringList()
# Set up the path with plugins # Set up the path with plugins
pluginpath = AppLocation.get_directory(AppLocation.PluginsDir) pluginpath = AppLocation.get_directory(AppLocation.PluginsDir)
self.plugin_manager = PluginManager(pluginpath) self.plugin_manager = PluginManager(pluginpath)
@ -849,5 +849,4 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow):
if filename and filename not in self.recentFiles: if filename and filename not in self.recentFiles:
self.recentFiles.insert(0, QtCore.QString(filename)) self.recentFiles.insert(0, QtCore.QString(filename))
while self.recentFiles.count() > recentFileCount: while self.recentFiles.count() > recentFileCount:
self.recentFiles.pop() self.recentFiles.removeLast()

View File

@ -27,7 +27,7 @@ import logging
from PyQt4 import QtCore, QtGui from PyQt4 import QtCore, QtGui
from openlp.core.lib.plugin import PluginStatus from openlp.core.lib import PluginStatus, translate
from plugindialog import Ui_PluginViewDialog from plugindialog import Ui_PluginViewDialog
log = logging.getLogger(__name__) log = logging.getLogger(__name__)
@ -63,14 +63,14 @@ class PluginForm(QtGui.QDialog, Ui_PluginViewDialog):
# sometimes when it's loaded from the config, it isn't cast to int. # sometimes when it's loaded from the config, it isn't cast to int.
plugin.status = int(plugin.status) plugin.status = int(plugin.status)
# Set the little status text in brackets next to the plugin name. # Set the little status text in brackets next to the plugin name.
status_text = 'Inactive' status_text = unicode(translate(u'PluginForm', u'%s (Inactive)'))
if plugin.status == PluginStatus.Active: if plugin.status == PluginStatus.Active:
status_text = 'Active' status_text = unicode(translate(u'PluginForm', u'%s (Active)'))
elif plugin.status == PluginStatus.Inactive: elif plugin.status == PluginStatus.Inactive:
status_text = 'Inactive' status_text = unicode(translate(u'PluginForm', u'%s (Inactive)'))
elif plugin.status == PluginStatus.Disabled: elif plugin.status == PluginStatus.Disabled:
status_text = 'Disabled' status_text = unicode(translate(u'PluginForm', u'%s (Disabled)'))
item.setText(u'%s (%s)' % (plugin.name, status_text)) item.setText(status_text % plugin.name)
# If the plugin has an icon, set it! # If the plugin has an icon, set it!
if plugin.icon: if plugin.icon:
item.setIcon(plugin.icon) item.setIcon(plugin.icon)

View File

@ -32,7 +32,7 @@ log = logging.getLogger(__name__)
from PyQt4 import QtCore, QtGui from PyQt4 import QtCore, QtGui
from openlp.core.lib import OpenLPToolbar, ServiceItem, contextMenuAction, \ from openlp.core.lib import OpenLPToolbar, ServiceItem, context_menu_action, \
Receiver, build_icon, ItemCapabilities, SettingsManager, translate Receiver, build_icon, ItemCapabilities, SettingsManager, translate
from openlp.core.ui import ServiceNoteForm, ServiceItemEditForm from openlp.core.ui import ServiceNoteForm, ServiceItemEditForm
from openlp.core.utils import AppLocation from openlp.core.utils import AppLocation
@ -599,11 +599,11 @@ class ServiceManager(QtGui.QWidget):
path_from = unicode(os.path.join( path_from = unicode(os.path.join(
frame[u'path'], frame[u'path'],
frame[u'title'])) frame[u'title']))
zip.write(path_from) zip.write(path_from.encode(u'utf-8'))
file = open(servicefile, u'wb') file = open(servicefile, u'wb')
cPickle.dump(service, file) cPickle.dump(service, file)
file.close() file.close()
zip.write(servicefile) zip.write(servicefile.encode(u'utf-8'))
except IOError: except IOError:
log.exception(u'Failed to save service to disk') log.exception(u'Failed to save service to disk')
finally: finally:
@ -669,7 +669,18 @@ class ServiceManager(QtGui.QWidget):
try: try:
zip = zipfile.ZipFile(unicode(filename)) zip = zipfile.ZipFile(unicode(filename))
for file in zip.namelist(): for file in zip.namelist():
osfile = unicode(QtCore.QDir.toNativeSeparators(file)) try:
ucsfile = file.decode(u'utf-8')
except UnicodeDecodeError:
QtGui.QMessageBox.critical(
self, translate(u'ServiceManager', u'Error'),
translate(u'ServiceManager',
u'File is not a valid service.\n'
u'The content encoding is not UTF-8.'))
log.exception(u'Filename "%s" is not valid UTF-8' % \
file.decode(u'utf-8', u'replace'))
continue
osfile = unicode(QtCore.QDir.toNativeSeparators(ucsfile))
names = osfile.split(os.path.sep) names = osfile.split(os.path.sep)
file_path = os.path.join(self.servicePath, file_path = os.path.join(self.servicePath,
names[len(names) - 1]) names[len(names) - 1])
@ -679,22 +690,29 @@ class ServiceManager(QtGui.QWidget):
file_to.close() file_to.close()
if file_path.endswith(u'osd'): if file_path.endswith(u'osd'):
p_file = file_path p_file = file_path
file_to = open(p_file, u'r') if 'p_file' in locals():
items = cPickle.load(file_to) file_to = open(p_file, u'r')
file_to.close() items = cPickle.load(file_to)
self.onNewService() file_to.close()
for item in items: self.onNewService()
serviceitem = ServiceItem() for item in items:
serviceitem.RenderManager = self.parent.RenderManager serviceitem = ServiceItem()
serviceitem.set_from_service(item, self.servicePath) serviceitem.RenderManager = self.parent.RenderManager
self.validateItem(serviceitem) serviceitem.set_from_service(item, self.servicePath)
self.addServiceItem(serviceitem) self.validateItem(serviceitem)
try: self.addServiceItem(serviceitem)
if os.path.isfile(p_file): try:
os.remove(p_file) if os.path.isfile(p_file):
except (IOError, OSError): os.remove(p_file)
log.exception(u'Failed to remove osd file') except (IOError, OSError):
except IOError: log.exception(u'Failed to remove osd file')
else:
QtGui.QMessageBox.critical(
self, translate(u'ServiceManager', u'Error'),
translate(u'ServiceManager',
u'File is not a valid service.'))
log.exception(u'File contains no service data')
except (IOError, NameError):
log.exception(u'Problem loading a service file') log.exception(u'Problem loading a service file')
finally: finally:
if file_to: if file_to:
@ -954,7 +972,7 @@ class ServiceManager(QtGui.QWidget):
self.ThemeComboBox.addItem(u'') self.ThemeComboBox.addItem(u'')
for theme in theme_list: for theme in theme_list:
self.ThemeComboBox.addItem(theme) self.ThemeComboBox.addItem(theme)
action = contextMenuAction( action = context_menu_action(
self.ServiceManagerList, self.ServiceManagerList,
None, None,
theme , self.onThemeChangeAction) theme , self.onThemeChangeAction)

View File

@ -563,8 +563,7 @@ class SlideController(QtGui.QWidget):
if self.isLive and frame[u'verseTag'] is not None: if self.isLive and frame[u'verseTag'] is not None:
if tag1 not in self.slideList: if tag1 not in self.slideList:
self.slideList[tag1] = framenumber self.slideList[tag1] = framenumber
self.SongMenu.menu().addAction( self.SongMenu.menu().addAction(tag1,
translate(u'SlideController', u'%s'%tag1),
self.onSongBarHandler) self.onSongBarHandler)
item.setText(frame[u'text']) item.setText(frame[u'text'])
else: else:

View File

@ -33,10 +33,10 @@ from PyQt4 import QtCore, QtGui
from openlp.core.ui import AmendThemeForm from openlp.core.ui import AmendThemeForm
from openlp.core.theme import Theme from openlp.core.theme import Theme
from openlp.core.lib import OpenLPToolbar, contextMenuAction, \ from openlp.core.lib import OpenLPToolbar, context_menu_action, \
ThemeXML, str_to_bool, get_text_file_string, build_icon, Receiver, \ ThemeXML, str_to_bool, get_text_file_string, build_icon, Receiver, \
contextMenuSeparator, SettingsManager, translate context_menu_separator, SettingsManager, translate
from openlp.core.utils import AppLocation from openlp.core.utils import AppLocation, get_filesystem_encoding
log = logging.getLogger(__name__) log = logging.getLogger(__name__)
@ -81,27 +81,28 @@ class ThemeManager(QtGui.QWidget):
self.Layout.addWidget(self.ThemeListWidget) self.Layout.addWidget(self.ThemeListWidget)
self.ThemeListWidget.setContextMenuPolicy(QtCore.Qt.ActionsContextMenu) self.ThemeListWidget.setContextMenuPolicy(QtCore.Qt.ActionsContextMenu)
self.ThemeListWidget.addAction( self.ThemeListWidget.addAction(
contextMenuAction(self.ThemeListWidget, u':/themes/theme_edit.png', context_menu_action(self.ThemeListWidget,
u':/themes/theme_edit.png',
translate(u'ThemeManager', u'Edit a theme'), self.onEditTheme)) translate(u'ThemeManager', u'Edit a theme'), self.onEditTheme))
self.ThemeListWidget.addAction( self.ThemeListWidget.addAction(
contextMenuSeparator(self.ThemeListWidget)) context_menu_separator(self.ThemeListWidget))
self.ThemeListWidget.addAction( self.ThemeListWidget.addAction(
contextMenuAction(self.ThemeListWidget, context_menu_action(self.ThemeListWidget,
u':/general/general_delete.png', u':/general/general_delete.png',
translate(u'ThemeManager', u'Delete theme'), translate(u'ThemeManager', u'Delete theme'),
self.onDeleteTheme)) self.onDeleteTheme))
self.ThemeListWidget.addAction( self.ThemeListWidget.addAction(
contextMenuAction(self.ThemeListWidget, context_menu_action(self.ThemeListWidget,
u':/general/general_export.png', u':/general/general_export.png',
translate(u'ThemeManager', u'Make Global'), translate(u'ThemeManager', u'Make Global'),
self.changeGlobalFromScreen)) self.changeGlobalFromScreen))
self.ThemeListWidget.addAction( self.ThemeListWidget.addAction(
contextMenuAction(self.ThemeListWidget, context_menu_action(self.ThemeListWidget,
u':/general/general_export.png', u':/general/general_export.png',
translate(u'ThemeManager', u'Export theme'), translate(u'ThemeManager', u'Export theme'),
self.onExportTheme)) self.onExportTheme))
self.ThemeListWidget.addAction( self.ThemeListWidget.addAction(
contextMenuSeparator(self.ThemeListWidget)) context_menu_separator(self.ThemeListWidget))
#Signals #Signals
QtCore.QObject.connect(self.ThemeListWidget, QtCore.QObject.connect(self.ThemeListWidget,
QtCore.SIGNAL(u'doubleClicked(QModelIndex)'), QtCore.SIGNAL(u'doubleClicked(QModelIndex)'),
@ -135,8 +136,8 @@ class ThemeManager(QtGui.QWidget):
self.ThemeListWidget.item(count).setText(newName) self.ThemeListWidget.item(count).setText(newName)
#Set the new name #Set the new name
if themeName == newName: if themeName == newName:
name = u'%s (%s)' % (newName, name = unicode(translate(u'ThemeManager', u'%s (default)')) % \
translate(u'ThemeManager', u'default')) newName
self.ThemeListWidget.item(count).setText(name) self.ThemeListWidget.item(count).setText(name)
def changeGlobalFromScreen(self, index = -1): def changeGlobalFromScreen(self, index = -1):
@ -157,8 +158,8 @@ class ThemeManager(QtGui.QWidget):
if count == selected_row: if count == selected_row:
self.global_theme = unicode( self.global_theme = unicode(
self.ThemeListWidget.item(count).text()) self.ThemeListWidget.item(count).text())
name = u'%s (%s)' % (self.global_theme, name = unicode(translate(u'ThemeManager', u'%s (default)')) % \
translate(u'ThemeManager', u'default')) self.global_theme
self.ThemeListWidget.item(count).setText(name) self.ThemeListWidget.item(count).setText(name)
QtCore.QSettings().setValue( QtCore.QSettings().setValue(
self.settingsSection + u'/global theme', self.settingsSection + u'/global theme',
@ -230,7 +231,9 @@ class ThemeManager(QtGui.QWidget):
try: try:
os.remove(os.path.join(self.path, th)) os.remove(os.path.join(self.path, th))
os.remove(os.path.join(self.thumbPath, th)) os.remove(os.path.join(self.thumbPath, th))
shutil.rmtree(os.path.join(self.path, theme)) encoding = get_filesystem_encoding()
shutil.rmtree(
os.path.join(self.path, theme).encode(encoding))
except OSError: except OSError:
#if not present do not worry #if not present do not worry
pass pass
@ -264,8 +267,8 @@ class ThemeManager(QtGui.QWidget):
for files in os.walk(source): for files in os.walk(source):
for name in files[2]: for name in files[2]:
zip.write( zip.write(
os.path.join(source, name), os.path.join(source, name).encode(u'utf-8'),
os.path.join(theme, name)) os.path.join(theme, name).encode(u'utf-8'))
QtGui.QMessageBox.information(self, QtGui.QMessageBox.information(self,
translate(u'ThemeManager', u'Theme Exported'), translate(u'ThemeManager', u'Theme Exported'),
translate(u'ThemeManager', translate(u'ThemeManager',
@ -315,8 +318,8 @@ class ThemeManager(QtGui.QWidget):
if os.path.exists(theme): if os.path.exists(theme):
textName = os.path.splitext(name)[0] textName = os.path.splitext(name)[0]
if textName == self.global_theme: if textName == self.global_theme:
name = u'%s (%s)' % (textName, name = unicode(translate(u'ThemeManager',
translate(u'ThemeManager', u'default')) u'%s (default)')) % textName
else: else:
name = textName name = textName
thumb = os.path.join(self.thumbPath, u'%s.png' % textName) thumb = os.path.join(self.thumbPath, u'%s.png' % textName)
@ -387,7 +390,17 @@ class ThemeManager(QtGui.QWidget):
filexml = None filexml = None
themename = None themename = None
for file in zip.namelist(): for file in zip.namelist():
osfile = unicode(QtCore.QDir.toNativeSeparators(file)) try:
ucsfile = file.decode(u'utf-8')
except UnicodeDecodeError:
QtGui.QMessageBox.critical(
self, translate(u'ThemeManager', u'Error'),
translate(u'ThemeManager', u'File is not a valid '
u'theme.\nThe content encoding is not UTF-8.'))
log.exception(u'Filename "%s" is not valid UTF-8' % \
file.decode(u'utf-8', u'replace'))
continue
osfile = unicode(QtCore.QDir.toNativeSeparators(ucsfile))
theme_dir = None theme_dir = None
if osfile.endswith(os.path.sep): if osfile.endswith(os.path.sep):
theme_dir = os.path.join(dir, osfile) theme_dir = os.path.join(dir, osfile)
@ -405,7 +418,7 @@ class ThemeManager(QtGui.QWidget):
if not os.path.exists(theme_dir): if not os.path.exists(theme_dir):
os.mkdir(os.path.join(dir, names[0])) os.mkdir(os.path.join(dir, names[0]))
xml_data = zip.read(file) xml_data = zip.read(file)
if os.path.splitext(file)[1].lower() in [u'.xml']: if os.path.splitext(ucsfile)[1].lower() in [u'.xml']:
if self.checkVersion1(xml_data): if self.checkVersion1(xml_data):
# upgrade theme xml # upgrade theme xml
filexml = self.migrateVersion122(xml_data) filexml = self.migrateVersion122(xml_data)
@ -416,8 +429,14 @@ class ThemeManager(QtGui.QWidget):
else: else:
outfile = open(fullpath, u'wb') outfile = open(fullpath, u'wb')
outfile.write(zip.read(file)) outfile.write(zip.read(file))
self.generateAndSaveImage(dir, themename, filexml) if filexml:
except IOError: self.generateAndSaveImage(dir, themename, filexml)
else:
QtGui.QMessageBox.critical(
self, translate(u'ThemeManager', u'Error'),
translate(u'ThemeManager', u'File is not a valid theme.'))
log.exception(u'Theme file dosen\'t contain XML data %s' % filename)
except (IOError, NameError):
QtGui.QMessageBox.critical( QtGui.QMessageBox.critical(
self, translate(u'ThemeManager', u'Error'), self, translate(u'ThemeManager', u'Error'),
translate(u'ThemeManager', u'File is not a valid theme.')) translate(u'ThemeManager', u'File is not a valid theme.'))
@ -526,7 +545,10 @@ class ThemeManager(QtGui.QWidget):
outfile.close() outfile.close()
if image_from and image_from != image_to: if image_from and image_from != image_to:
try: try:
shutil.copyfile(image_from, image_to) encoding = get_filesystem_encoding()
shutil.copyfile(
unicode(image_from).encode(encoding),
unicode(image_to).encode(encoding))
except IOError: except IOError:
log.exception(u'Failed to save theme image') log.exception(u'Failed to save theme image')
self.generateAndSaveImage(self.path, name, theme_xml) self.generateAndSaveImage(self.path, name, theme_xml)

View File

@ -149,27 +149,6 @@ def check_latest_version(current_version):
log.exception(u'Reason for failure: %s', e.reason) log.exception(u'Reason for failure: %s', e.reason)
return version_string return version_string
def string_to_unicode(string):
"""
Converts a QString to a Python unicode object.
"""
if isinstance(string, QtCore.QString):
string = unicode(string.toUtf8(), u'utf8')
return string
def variant_to_unicode(variant):
"""
Converts a QVariant to a Python unicode object.
``variant``
The QVariant instance to convert to unicode.
"""
if isinstance(variant, QtCore.QVariant):
string = variant.toString()
if not isinstance(string, unicode):
string = string_to_unicode(string)
return string
def add_actions(target, actions): def add_actions(target, actions):
""" """
Adds multiple actions to a menu or toolbar in one command. Adds multiple actions to a menu or toolbar in one command.
@ -187,7 +166,17 @@ def add_actions(target, actions):
else: else:
target.addAction(action) target.addAction(action)
def get_filesystem_encoding():
"""
Returns the name of the encoding used to convert Unicode filenames into
system file names.
"""
encoding = sys.getfilesystemencoding()
if encoding is None:
encoding = sys.getdefaultencoding()
return encoding
from languagemanager import LanguageManager from languagemanager import LanguageManager
__all__ = [u'AppLocation', u'check_latest_version', u'add_actions', __all__ = [u'AppLocation', u'check_latest_version', u'add_actions',
u'LanguageManager'] u'get_filesystem_encoding', u'LanguageManager']

View File

@ -214,11 +214,13 @@ class AlertsTab(SettingsTab):
translate(u'AlertsPlugin.AlertsTab', u'Bottom')) translate(u'AlertsPlugin.AlertsTab', u'Bottom'))
def onBackgroundColorButtonClicked(self): def onBackgroundColorButtonClicked(self):
self.bg_color = QtGui.QColorDialog.getColor( new_color = QtGui.QColorDialog.getColor(
QtGui.QColor(self.bg_color), self).name() QtGui.QColor(self.bg_color), self)
self.BackgroundColorButton.setStyleSheet( if new_color.isValid():
u'background-color: %s' % self.bg_color) self.bg_color = new_color.name()
self.updateDisplay() self.BackgroundColorButton.setStyleSheet(
u'background-color: %s' % self.bg_color)
self.updateDisplay()
def onFontComboBoxClicked(self): def onFontComboBoxClicked(self):
self.updateDisplay() self.updateDisplay()
@ -227,11 +229,13 @@ class AlertsTab(SettingsTab):
self.location = location self.location = location
def onFontColorButtonClicked(self): def onFontColorButtonClicked(self):
self.font_color = QtGui.QColorDialog.getColor( new_color = QtGui.QColorDialog.getColor(
QtGui.QColor(self.font_color), self).name() QtGui.QColor(self.font_color), self)
self.FontColorButton.setStyleSheet( if new_color.isValid():
u'background-color: %s' % self.font_color) self.font_color = new_color.name()
self.updateDisplay() self.FontColorButton.setStyleSheet(
u'background-color: %s' % self.font_color)
self.updateDisplay()
def onTimeoutSpinBoxChanged(self): def onTimeoutSpinBoxChanged(self):
self.timeout = self.TimeoutSpinBox.value() self.timeout = self.TimeoutSpinBox.value()

View File

@ -32,7 +32,7 @@ from PyQt4 import QtCore, QtGui
from bibleimportwizard import Ui_BibleImportWizard from bibleimportwizard import Ui_BibleImportWizard
from openlp.core.lib import Receiver, SettingsManager, translate from openlp.core.lib import Receiver, SettingsManager, translate
from openlp.core.utils import AppLocation, variant_to_unicode from openlp.core.utils import AppLocation
from openlp.plugins.bibles.lib.manager import BibleFormat from openlp.plugins.bibles.lib.manager import BibleFormat
log = logging.getLogger(__name__) log = logging.getLogger(__name__)
@ -167,9 +167,9 @@ class ImportWizardForm(QtGui.QWizard, Ui_BibleImportWizard):
return True return True
elif self.currentId() == 2: elif self.currentId() == 2:
# License details # License details
license_version = variant_to_unicode(self.field(u'license_version')) license_version = unicode(self.field(u'license_version').toString())
license_copyright = variant_to_unicode( license_copyright = \
self.field(u'license_copyright')) unicode(self.field(u'license_copyright').toString())
if license_version == u'': if license_version == u'':
QtGui.QMessageBox.critical(self, QtGui.QMessageBox.critical(self,
translate(u'BiblesPlugin.ImportWizardForm', translate(u'BiblesPlugin.ImportWizardForm',
@ -391,37 +391,35 @@ class ImportWizardForm(QtGui.QWizard, Ui_BibleImportWizard):
def performImport(self): def performImport(self):
bible_type = self.field(u'source_format').toInt()[0] bible_type = self.field(u'source_format').toInt()[0]
license_version = variant_to_unicode(self.field(u'license_version')) license_version = unicode(self.field(u'license_version').toString())
license_copyright = variant_to_unicode(self.field(u'license_copyright')) license_copyright = unicode(self.field(u'license_copyright').toString())
license_permission = variant_to_unicode( license_permission = \
self.field(u'license_permission')) unicode(self.field(u'license_permission').toString())
importer = None importer = None
if bible_type == BibleFormat.OSIS: if bible_type == BibleFormat.OSIS:
# Import an OSIS bible # Import an OSIS bible
importer = self.manager.import_bible(BibleFormat.OSIS, importer = self.manager.import_bible(BibleFormat.OSIS,
name=license_version, name=license_version,
filename=variant_to_unicode(self.field(u'osis_location')) filename=unicode(self.field(u'osis_location').toString())
) )
elif bible_type == BibleFormat.CSV: elif bible_type == BibleFormat.CSV:
# Import a CSV bible # Import a CSV bible
importer = self.manager.import_bible(BibleFormat.CSV, importer = self.manager.import_bible(BibleFormat.CSV,
name=license_version, name=license_version,
booksfile=variant_to_unicode(self.field(u'csv_booksfile')), booksfile=unicode(self.field(u'csv_booksfile').toString()),
versefile=variant_to_unicode(self.field(u'csv_versefile')) versefile=unicode(self.field(u'csv_versefile').toString())
) )
elif bible_type == BibleFormat.OpenSong: elif bible_type == BibleFormat.OpenSong:
# Import an OpenSong bible # Import an OpenSong bible
importer = self.manager.import_bible(BibleFormat.OpenSong, importer = self.manager.import_bible(BibleFormat.OpenSong,
name=license_version, name=license_version,
filename=variant_to_unicode(self.field(u'opensong_file')) filename=unicode(self.field(u'opensong_file').toString())
) )
elif bible_type == BibleFormat.WebDownload: elif bible_type == BibleFormat.WebDownload:
# Import a bible from the web # Import a bible from the web
self.ImportProgressBar.setMaximum(1) self.ImportProgressBar.setMaximum(1)
download_location = self.field(u'web_location').toInt()[0] download_location = self.field(u'web_location').toInt()[0]
bible_version = self.BibleComboBox.currentText() bible_version = unicode(self.BibleComboBox.currentText())
if not isinstance(bible_version, unicode):
bible_version = unicode(bible_version, u'utf8')
if download_location == WebDownload.Crosswalk: if download_location == WebDownload.Crosswalk:
bible = \ bible = \
self.web_bible_list[WebDownload.Crosswalk][bible_version] self.web_bible_list[WebDownload.Crosswalk][bible_version]
@ -433,10 +431,10 @@ class ImportWizardForm(QtGui.QWizard, Ui_BibleImportWizard):
name=license_version, name=license_version,
download_source=WebDownload.get_name(download_location), download_source=WebDownload.get_name(download_location),
download_name=bible, download_name=bible,
proxy_server=variant_to_unicode(self.field(u'proxy_server')), proxy_server=unicode(self.field(u'proxy_server').toString()),
proxy_username=variant_to_unicode( proxy_username=\
self.field(u'proxy_username')), unicode(self.field(u'proxy_username').toString()),
proxy_password=variant_to_unicode(self.field(u'proxy_password')) proxy_password=unicode(self.field(u'proxy_password').toString())
) )
success = importer.do_import() success = importer.do_import()
if success: if success:

View File

@ -59,6 +59,7 @@ class BibleDB(QtCore.QObject):
""" """
log.info(u'BibleDB loaded') log.info(u'BibleDB loaded')
QtCore.QObject.__init__(self) QtCore.QObject.__init__(self)
self.bible_plugin = parent
if u'path' not in kwargs: if u'path' not in kwargs:
raise KeyError(u'Missing keyword argument "path".') raise KeyError(u'Missing keyword argument "path".')
if u'name' not in kwargs and u'file' not in kwargs: if u'name' not in kwargs and u'file' not in kwargs:

View File

@ -288,8 +288,7 @@ class CWExtract(BibleCommon):
``chapter`` ``chapter``
Chapter number Chapter number
""" """
log.debug(u'get_bible_chapter %s,%s,%s', log.debug(u'get_bible_chapter %s,%s,%s', version, bookname, chapter)
version, bookname, chapter)
urlbookname = bookname.replace(u' ', u'-') urlbookname = bookname.replace(u' ', u'-')
chapter_url = u'http://www.biblestudytools.com/%s/%s/%s.html' % \ chapter_url = u'http://www.biblestudytools.com/%s/%s/%s.html' % \
(version, urlbookname.lower(), chapter) (version, urlbookname.lower(), chapter)

View File

@ -454,7 +454,7 @@ class BibleMediaItem(MediaManagerItem):
def onQuickSearchButton(self): def onQuickSearchButton(self):
log.debug(u'Quick Search Button pressed') log.debug(u'Quick Search Button pressed')
bible = unicode(self.QuickVersionComboBox.currentText()) bible = unicode(self.QuickVersionComboBox.currentText())
text = unicode(self.QuickSearchEdit.displayText()) text = unicode(self.QuickSearchEdit.text())
if self.ClearQuickSearchComboBox.currentIndex() == 0: if self.ClearQuickSearchComboBox.currentIndex() == 0:
self.ListView.clear() self.ListView.clear()
self.lastReference = [] self.lastReference = []

View File

@ -29,7 +29,7 @@ import os
from PyQt4 import QtCore, QtGui from PyQt4 import QtCore, QtGui
from openlp.core.lib import MediaManagerItem, BaseListWithDnD, build_icon, \ from openlp.core.lib import MediaManagerItem, BaseListWithDnD, build_icon, \
contextMenuAction, ItemCapabilities, SettingsManager, translate context_menu_action, ItemCapabilities, SettingsManager, translate
from openlp.core.utils import AppLocation from openlp.core.utils import AppLocation
log = logging.getLogger(__name__) log = logging.getLogger(__name__)
@ -54,6 +54,7 @@ class ImageMediaItem(MediaManagerItem):
# be instanced by the base MediaManagerItem # be instanced by the base MediaManagerItem
self.ListViewWithDnD_class = ImageListView self.ListViewWithDnD_class = ImageListView
MediaManagerItem.__init__(self, parent, icon, title) MediaManagerItem.__init__(self, parent, icon, title)
self.addToServiceItem = True
def initPluginNameVisible(self): def initPluginNameVisible(self):
self.PluginNameVisible = translate(u'ImagePlugin.MediaItem', u'Image') self.PluginNameVisible = translate(u'ImagePlugin.MediaItem', u'Image')
@ -73,7 +74,6 @@ class ImageMediaItem(MediaManagerItem):
self.hasFileIcon = True self.hasFileIcon = True
self.hasNewIcon = False self.hasNewIcon = False
self.hasEditIcon = False self.hasEditIcon = False
self.addToServiceItem = True
def initialise(self): def initialise(self):
log.debug(u'initialise') log.debug(u'initialise')
@ -93,7 +93,7 @@ class ImageMediaItem(MediaManagerItem):
MediaManagerItem.addListViewToToolBar(self) MediaManagerItem.addListViewToToolBar(self)
self.ListView.setContextMenuPolicy(QtCore.Qt.ActionsContextMenu) self.ListView.setContextMenuPolicy(QtCore.Qt.ActionsContextMenu)
self.ListView.addAction( self.ListView.addAction(
contextMenuAction( context_menu_action(
self.ListView, u':/slides/slide_blank.png', self.ListView, u':/slides/slide_blank.png',
translate(u'ImagePlugin.MediaItem', u'Replace Live Background'), translate(u'ImagePlugin.MediaItem', u'Replace Live Background'),
self.onReplaceClick)) self.onReplaceClick))
@ -120,12 +120,13 @@ class ImageMediaItem(MediaManagerItem):
if items: if items:
for item in items: for item in items:
text = self.ListView.item(item.row()) text = self.ListView.item(item.row())
try: if text:
os.remove( try:
os.path.join(self.servicePath, unicode(text.text()))) os.remove(
except OSError: os.path.join(self.servicePath, unicode(text.text())))
#if not present do not worry except OSError:
pass #if not present do not worry
pass
self.ListView.takeItem(item.row()) self.ListView.takeItem(item.row())
SettingsManager.set_list(self.settingsSection, SettingsManager.set_list(self.settingsSection,
self.settingsSection, self.getFileList()) self.settingsSection, self.getFileList())
@ -157,7 +158,7 @@ class ImageMediaItem(MediaManagerItem):
service_item.add_capability(ItemCapabilities.AllowsAdditions) service_item.add_capability(ItemCapabilities.AllowsAdditions)
for item in items: for item in items:
bitem = self.ListView.item(item.row()) bitem = self.ListView.item(item.row())
filename = unicode((bitem.data(QtCore.Qt.UserRole)).toString()) filename = unicode(bitem.data(QtCore.Qt.UserRole).toString())
frame = QtGui.QImage(unicode(filename)) frame = QtGui.QImage(unicode(filename))
(path, name) = os.path.split(filename) (path, name) = os.path.split(filename)
service_item.add_from_image(path, name, frame) service_item.add_from_image(path, name, frame)
@ -174,7 +175,7 @@ class ImageMediaItem(MediaManagerItem):
items = self.ListView.selectedIndexes() items = self.ListView.selectedIndexes()
for item in items: for item in items:
bitem = self.ListView.item(item.row()) bitem = self.ListView.item(item.row())
filename = unicode((bitem.data(QtCore.Qt.UserRole)).toString()) filename = unicode(bitem.data(QtCore.Qt.UserRole).toString())
frame = QtGui.QImage(unicode(filename)) frame = QtGui.QImage(unicode(filename))
self.parent.maindisplay.addImageWithText(frame) self.parent.maindisplay.addImageWithText(frame)

View File

@ -29,7 +29,7 @@ import os
from PyQt4 import QtCore, QtGui from PyQt4 import QtCore, QtGui
from openlp.core.lib import MediaManagerItem, BaseListWithDnD, build_icon, \ from openlp.core.lib import MediaManagerItem, BaseListWithDnD, build_icon, \
ItemCapabilities, SettingsManager, contextMenuAction, Receiver, translate ItemCapabilities, SettingsManager, context_menu_action, Receiver, translate
log = logging.getLogger(__name__) log = logging.getLogger(__name__)
@ -77,7 +77,7 @@ class MediaMediaItem(MediaManagerItem):
MediaManagerItem.addListViewToToolBar(self) MediaManagerItem.addListViewToToolBar(self)
self.ListView.setContextMenuPolicy(QtCore.Qt.ActionsContextMenu) self.ListView.setContextMenuPolicy(QtCore.Qt.ActionsContextMenu)
self.ListView.addAction( self.ListView.addAction(
contextMenuAction(self.ListView, u':/slides/slide_blank.png', context_menu_action(self.ListView, u':/slides/slide_blank.png',
translate(u'MediaPlugin.MediaItem', u'Replace Live Background'), translate(u'MediaPlugin.MediaItem', u'Replace Live Background'),
self.onReplaceClick)) self.onReplaceClick))
@ -112,7 +112,7 @@ class MediaMediaItem(MediaManagerItem):
items = self.ListView.selectedIndexes() items = self.ListView.selectedIndexes()
for item in items: for item in items:
bitem = self.ListView.item(item.row()) bitem = self.ListView.item(item.row())
filename = unicode((bitem.data(QtCore.Qt.UserRole)).toString()) filename = unicode(bitem.data(QtCore.Qt.UserRole).toString())
Receiver.send_message(u'videodisplay_background', filename) Receiver.send_message(u'videodisplay_background', filename)
def generateSlideData(self, service_item, item=None): def generateSlideData(self, service_item, item=None):
@ -120,7 +120,7 @@ class MediaMediaItem(MediaManagerItem):
item = self.ListView.currentItem() item = self.ListView.currentItem()
if item is None: if item is None:
return False return False
filename = unicode((item.data(QtCore.Qt.UserRole)).toString()) filename = unicode(item.data(QtCore.Qt.UserRole).toString())
service_item.title = unicode( service_item.title = unicode(
translate(u'MediaPlugin.MediaItem', u'Media')) translate(u'MediaPlugin.MediaItem', u'Media'))
service_item.add_capability(ItemCapabilities.RequiresMedia) service_item.add_capability(ItemCapabilities.RequiresMedia)

View File

@ -180,7 +180,7 @@ class PresentationMediaItem(MediaManagerItem):
self.ListView.takeItem(row) self.ListView.takeItem(row)
SettingsManager.set_list(self.settingsSection, SettingsManager.set_list(self.settingsSection,
self.settingsSection, self.getFileList()) self.settingsSection, self.getFileList())
filepath = unicode((item.data(QtCore.Qt.UserRole)).toString()) filepath = unicode(item.data(QtCore.Qt.UserRole).toString())
#not sure of this has errors #not sure of this has errors
#John please can you look at . #John please can you look at .
for cidx in self.controllers: for cidx in self.controllers:
@ -198,7 +198,7 @@ class PresentationMediaItem(MediaManagerItem):
if shortname: if shortname:
for item in items: for item in items:
bitem = self.ListView.item(item.row()) bitem = self.ListView.item(item.row())
filename = unicode((bitem.data(QtCore.Qt.UserRole)).toString()) filename = unicode(bitem.data(QtCore.Qt.UserRole).toString())
if shortname == self.Automatic: if shortname == self.Automatic:
service_item.shortname = self.findControllerByType(filename) service_item.shortname = self.findControllerByType(filename)
if not service_item.shortname: if not service_item.shortname:

View File

@ -291,7 +291,7 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog):
rowLabel = [] rowLabel = []
for row in range(0, self.VerseListWidget.rowCount()): for row in range(0, self.VerseListWidget.rowCount()):
item = self.VerseListWidget.item(row, 0) item = self.VerseListWidget.item(row, 0)
data = unicode((item.data(QtCore.Qt.UserRole)).toString()) data = unicode(item.data(QtCore.Qt.UserRole).toString())
bit = data.split(u':') bit = data.split(u':')
rowTag = u'%s\n%s' % (bit[0][0:1], bit[1]) rowTag = u'%s\n%s' % (bit[0][0:1], bit[1])
rowLabel.append(rowTag) rowLabel.append(rowTag)
@ -382,7 +382,7 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog):
item = self.VerseListWidget.currentItem() item = self.VerseListWidget.currentItem()
if item: if item:
tempText = item.text() tempText = item.text()
verseId = unicode((item.data(QtCore.Qt.UserRole)).toString()) verseId = unicode(item.data(QtCore.Qt.UserRole).toString())
self.verse_form.setVerse(tempText, True, verseId) self.verse_form.setVerse(tempText, True, verseId)
if self.verse_form.exec_(): if self.verse_form.exec_():
afterText, verse, subVerse = self.verse_form.getVerse() afterText, verse, subVerse = self.verse_form.getVerse()
@ -413,7 +413,7 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog):
if self.VerseListWidget.rowCount() > 0: if self.VerseListWidget.rowCount() > 0:
for row in range(0, self.VerseListWidget.rowCount()): for row in range(0, self.VerseListWidget.rowCount()):
item = self.VerseListWidget.item(row, 0) item = self.VerseListWidget.item(row, 0)
field = unicode((item.data(QtCore.Qt.UserRole)).toString()) field = unicode(item.data(QtCore.Qt.UserRole).toString())
verse_list += u'---[%s]---\n' % field verse_list += u'---[%s]---\n' % field
verse_list += item.text() verse_list += item.text()
verse_list += u'\n' verse_list += u'\n'
@ -504,7 +504,7 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog):
def onCopyrightInsertButtonTriggered(self): def onCopyrightInsertButtonTriggered(self):
text = self.CopyrightEditItem.text() text = self.CopyrightEditItem.text()
pos = self.CopyrightEditItem.cursorPosition() pos = self.CopyrightEditItem.cursorPosition()
text = text[:pos] + u'©' + text[pos:] text = text[:pos] + u'\xa9' + text[pos:]
self.CopyrightEditItem.setText(text) self.CopyrightEditItem.setText(text)
self.CopyrightEditItem.setFocus() self.CopyrightEditItem.setFocus()
self.CopyrightEditItem.setCursorPosition(pos + 1) self.CopyrightEditItem.setCursorPosition(pos + 1)
@ -562,7 +562,7 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog):
text = u' ' text = u' '
for i in range (0, self.VerseListWidget.rowCount()): for i in range (0, self.VerseListWidget.rowCount()):
item = self.VerseListWidget.item(i, 0) item = self.VerseListWidget.item(i, 0)
verseId = unicode((item.data(QtCore.Qt.UserRole)).toString()) verseId = unicode(item.data(QtCore.Qt.UserRole).toString())
bits = verseId.split(u':') bits = verseId.split(u':')
sxml.add_verse_to_lyrics(bits[0], bits[1], unicode(item.text())) sxml.add_verse_to_lyrics(bits[0], bits[1], unicode(item.text()))
text = text + unicode(self.VerseListWidget.item(i, 0).text()) \ text = text + unicode(self.VerseListWidget.item(i, 0).text()) \

View File

@ -104,7 +104,7 @@ class EditVerseForm(QtGui.QDialog, Ui_EditVerseDialog):
verse_type = match.group(1) verse_type = match.group(1)
verse_number = int(match.group(2)) verse_number = int(match.group(2))
verse_type_index = VerseType.from_string(verse_type) verse_type_index = VerseType.from_string(verse_type)
if verse_type_index: if verse_type_index is not None:
self.VerseTypeComboBox.setCurrentIndex(verse_type_index) self.VerseTypeComboBox.setCurrentIndex(verse_type_index)
self.VerseNumberBox.setValue(verse_number) self.VerseNumberBox.setValue(verse_number)
@ -112,8 +112,9 @@ class EditVerseForm(QtGui.QDialog, Ui_EditVerseDialog):
tag=u'%s:1' % VerseType.to_string(VerseType.Verse)): tag=u'%s:1' % VerseType.to_string(VerseType.Verse)):
if single: if single:
verse_type, verse_number = tag.split(u':') verse_type, verse_number = tag.split(u':')
self.VerseTypeComboBox.setCurrentIndex( verse_type_index = VerseType.from_string(verse_type)
VerseType.from_string(verse_type)) if verse_type_index is not None:
self.VerseTypeComboBox.setCurrentIndex(verse_type_index)
self.VerseNumberBox.setValue(int(verse_number)) self.VerseNumberBox.setValue(int(verse_number))
self.InsertButton.setVisible(False) self.InsertButton.setVisible(False)
else: else:

View File

@ -29,7 +29,7 @@ from PyQt4 import QtCore, QtGui
from songimportwizard import Ui_SongImportWizard from songimportwizard import Ui_SongImportWizard
from openlp.core.lib import Receiver, SettingsManager, translate from openlp.core.lib import Receiver, SettingsManager, translate
#from openlp.core.utils import AppLocation, variant_to_unicode #from openlp.core.utils import AppLocation
from openlp.plugins.songs.lib.manager import SongFormat from openlp.plugins.songs.lib.manager import SongFormat
log = logging.getLogger(__name__) log = logging.getLogger(__name__)
@ -203,20 +203,20 @@ class ImportWizardForm(QtGui.QWizard, Ui_SongImportWizard):
# # Import an OSIS bible # # Import an OSIS bible
# importer = self.manager.import_bible(BibleFormat.OSIS, # importer = self.manager.import_bible(BibleFormat.OSIS,
# name=license_version, # name=license_version,
# filename=variant_to_unicode(self.field(u'osis_location')) # filename=unicode(self.field(u'osis_location').toString())
# ) # )
# elif bible_type == BibleFormat.CSV: # elif bible_type == BibleFormat.CSV:
# # Import a CSV bible # # Import a CSV bible
# importer = self.manager.import_bible(BibleFormat.CSV, # importer = self.manager.import_bible(BibleFormat.CSV,
# name=license_version, # name=license_version,
# booksfile=variant_to_unicode(self.field(u'csv_booksfile')), # booksfile=unicode(self.field(u'csv_booksfile').toString()),
# versefile=variant_to_unicode(self.field(u'csv_versefile')) # versefile=unicode(self.field(u'csv_versefile').toString())
# ) # )
# elif bible_type == BibleFormat.OpenSong: # elif bible_type == BibleFormat.OpenSong:
# # Import an OpenSong bible # # Import an OpenSong bible
# importer = self.manager.import_bible(BibleFormat.OpenSong, # importer = self.manager.import_bible(BibleFormat.OpenSong,
# name=license_version, # name=license_version,
# filename=variant_to_unicode(self.field(u'opensong_file')) # filename=unicode(self.field(u'opensong_file').toString())
# ) # )
# elif bible_type == BibleFormat.WebDownload: # elif bible_type == BibleFormat.WebDownload:
# # Import a bible from the web # # Import a bible from the web
@ -234,9 +234,9 @@ class ImportWizardForm(QtGui.QWizard, Ui_SongImportWizard):
# name=license_version, # name=license_version,
# download_source=WebDownload.get_name(download_location), # download_source=WebDownload.get_name(download_location),
# download_name=bible, # download_name=bible,
# proxy_server=variant_to_unicode(self.field(u'proxy_server')), # proxy_server=unicode(self.field(u'proxy_server').toString()),
# proxy_username=variant_to_unicode(self.field(u'proxy_username')), # proxy_username=unicode(self.field(u'proxy_username').toString()),
# proxy_password=variant_to_unicode(self.field(u'proxy_password')) # proxy_password=unicode(self.field(u'proxy_password').toString())
# ) # )
# success = importer.do_import() # success = importer.do_import()
# if success: # if success:

View File

@ -96,7 +96,7 @@ class SongManager(object):
settings = QtCore.QSettings() settings = QtCore.QSettings()
settings.beginGroup(u'songs') settings.beginGroup(u'songs')
self.db_url = u'' self.db_url = u''
db_type = unicode(settings.value(u'songs/db type', db_type = unicode(settings.value(u'db type',
QtCore.QVariant(u'sqlite')).toString()) QtCore.QVariant(u'sqlite')).toString())
if db_type == u'sqlite': if db_type == u'sqlite':
self.db_url = u'sqlite:///%s/songs.sqlite' % \ self.db_url = u'sqlite:///%s/songs.sqlite' % \

View File

@ -333,7 +333,7 @@ class SongMediaItem(MediaManagerItem):
for verse in verseList: for verse in verseList:
verseTag = u'%s:%s' % ( verseTag = u'%s:%s' % (
verse[0][u'type'], verse[0][u'label']) verse[0][u'type'], verse[0][u'label'])
service_item.add_from_text(\ service_item.add_from_text(
verse[1][:30], unicode(verse[1]), verseTag) verse[1][:30], unicode(verse[1]), verseTag)
else: else:
#Loop through the verse list and expand the song accordingly. #Loop through the verse list and expand the song accordingly.
@ -345,8 +345,8 @@ class SongMediaItem(MediaManagerItem):
verse[0][u'type'][0] == order[0]: verse[0][u'type'][0] == order[0]:
verseTag = u'%s:%s' % \ verseTag = u'%s:%s' % \
(verse[0][u'type'], verse[0][u'label']) (verse[0][u'type'], verse[0][u'label'])
service_item.add_from_text\ service_item.add_from_text(
(verse[1][:30], verse[1], verseTag) verse[1][:30], verse[1], verseTag)
else: else:
verses = song.lyrics.split(u'\n\n') verses = song.lyrics.split(u'\n\n')
for slide in verses: for slide in verses:

View File

@ -66,7 +66,7 @@ class SongImport(object):
self.copyright_string = unicode(QtGui.QApplication.translate( \ self.copyright_string = unicode(QtGui.QApplication.translate( \
u'SongsPlugin.SongImport', u'copyright')) u'SongsPlugin.SongImport', u'copyright'))
self.copyright_symbol = unicode(QtGui.QApplication.translate( \ self.copyright_symbol = unicode(QtGui.QApplication.translate( \
u'SongsPlugin.SongImport', u'©')) u'SongsPlugin.SongImport', u'\xa9'))
@staticmethod @staticmethod
def process_songs_text(manager, text): def process_songs_text(manager, text):