forked from openlp/openlp
Fix variable naming
This commit is contained in:
parent
e70ad3ca90
commit
ec4d54e66a
@ -95,24 +95,24 @@ def build_icon(icon):
|
||||
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``.
|
||||
"""
|
||||
ButtonIcon = None
|
||||
button_icon = None
|
||||
if isinstance(icon, QtGui.QIcon):
|
||||
ButtonIcon = icon
|
||||
button_icon = icon
|
||||
elif isinstance(icon, basestring):
|
||||
ButtonIcon = QtGui.QIcon()
|
||||
button_icon = QtGui.QIcon()
|
||||
if icon.startswith(u':/'):
|
||||
ButtonIcon.addPixmap(
|
||||
QtGui.QPixmap(icon), QtGui.QIcon.Normal, QtGui.QIcon.Off)
|
||||
button_icon.addPixmap(QtGui.QPixmap(icon), QtGui.QIcon.Normal,
|
||||
QtGui.QIcon.Off)
|
||||
else:
|
||||
ButtonIcon.addPixmap(QtGui.QPixmap.fromImage(QtGui.QImage(icon)),
|
||||
button_icon.addPixmap(QtGui.QPixmap.fromImage(QtGui.QImage(icon)),
|
||||
QtGui.QIcon.Normal, QtGui.QIcon.Off)
|
||||
elif isinstance(icon, QtGui.QImage):
|
||||
ButtonIcon = QtGui.QIcon()
|
||||
ButtonIcon.addPixmap(
|
||||
QtGui.QPixmap.fromImage(icon), QtGui.QIcon.Normal, QtGui.QIcon.Off)
|
||||
return ButtonIcon
|
||||
button_icon = QtGui.QIcon()
|
||||
button_icon.addPixmap(QtGui.QPixmap.fromImage(icon),
|
||||
QtGui.QIcon.Normal, QtGui.QIcon.Off)
|
||||
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
|
||||
"""
|
||||
@ -122,7 +122,7 @@ def contextMenuAction(base, icon, text, slot):
|
||||
QtCore.QObject.connect(action, QtCore.SIGNAL(u'triggered()'), slot)
|
||||
return action
|
||||
|
||||
def contextMenu(base, icon, text):
|
||||
def context_menu(base, icon, text):
|
||||
"""
|
||||
Utility method to help build context menus for plugins
|
||||
"""
|
||||
@ -130,7 +130,7 @@ def contextMenu(base, icon, text):
|
||||
action.setIcon(build_icon(icon))
|
||||
return action
|
||||
|
||||
def contextMenuSeparator(base):
|
||||
def context_menu_separator(base):
|
||||
"""
|
||||
Add a separator to a context menu
|
||||
"""
|
||||
@ -152,12 +152,12 @@ def resize_image(image, width, height):
|
||||
realw = preview.width()
|
||||
realh = preview.height()
|
||||
# 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)
|
||||
newImage.fill(QtCore.Qt.black)
|
||||
painter = QtGui.QPainter(newImage)
|
||||
new_image.fill(QtCore.Qt.black)
|
||||
painter = QtGui.QPainter(new_image)
|
||||
painter.drawImage((width - realw) / 2, (height - realh) / 2, preview)
|
||||
return newImage
|
||||
return new_image
|
||||
|
||||
|
||||
class ThemeLevel(object):
|
||||
|
@ -28,7 +28,7 @@ import os
|
||||
|
||||
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
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
@ -271,34 +271,34 @@ class MediaManagerItem(QtGui.QWidget):
|
||||
self.ListView.setContextMenuPolicy(QtCore.Qt.ActionsContextMenu)
|
||||
if self.hasEditIcon:
|
||||
self.ListView.addAction(
|
||||
contextMenuAction(
|
||||
context_menu_action(
|
||||
self.ListView, u':/general/general_edit.png',
|
||||
u'%s %s' % (self.trUtf8('&Edit'), self.PluginNameVisible),
|
||||
self.onEditClick))
|
||||
self.ListView.addAction(contextMenuSeparator(self.ListView))
|
||||
self.ListView.addAction(context_menu_separator(self.ListView))
|
||||
if self.hasDeleteIcon:
|
||||
self.ListView.addAction(
|
||||
contextMenuAction(
|
||||
context_menu_action(
|
||||
self.ListView, u':/general/general_delete.png',
|
||||
u'%s %s' % (self.trUtf8('&Delete'), self.PluginNameVisible),
|
||||
self.onDeleteClick))
|
||||
self.ListView.addAction(contextMenuSeparator(self.ListView))
|
||||
self.ListView.addAction(context_menu_separator(self.ListView))
|
||||
self.ListView.addAction(
|
||||
contextMenuAction(
|
||||
context_menu_action(
|
||||
self.ListView, u':/general/general_preview.png',
|
||||
u'%s %s' % (self.trUtf8('&Preview'), self.PluginNameVisible),
|
||||
self.onPreviewClick))
|
||||
self.ListView.addAction(
|
||||
contextMenuAction(
|
||||
context_menu_action(
|
||||
self.ListView, u':/general/general_live.png',
|
||||
self.trUtf8('&Show Live'), self.onLiveClick))
|
||||
self.ListView.addAction(
|
||||
contextMenuAction(
|
||||
context_menu_action(
|
||||
self.ListView, u':/general/general_add.png',
|
||||
self.trUtf8('&Add to Service'), self.onAddClick))
|
||||
if self.addToServiceItem:
|
||||
self.ListView.addAction(
|
||||
contextMenuAction(
|
||||
context_menu_action(
|
||||
self.ListView, u':/general/general_add.png',
|
||||
self.trUtf8('&Add to selected Service Item'),
|
||||
self.onAddEditClick))
|
||||
@ -465,9 +465,9 @@ class MediaManagerItem(QtGui.QWidget):
|
||||
"""
|
||||
service_item = ServiceItem(self.parent)
|
||||
if self.ServiceItemIconName:
|
||||
service_item.addIcon(self.ServiceItemIconName)
|
||||
service_item.add_icon(self.ServiceItemIconName)
|
||||
else:
|
||||
service_item.addIcon(
|
||||
service_item.add_icon(
|
||||
u':/media/media_' + self.PluginNameShort.lower() + u'.png')
|
||||
if self.generateSlideData(service_item, item):
|
||||
return service_item
|
||||
|
@ -73,9 +73,10 @@ class ServiceItem(object):
|
||||
The plugin that this service item belongs to.
|
||||
"""
|
||||
if plugin:
|
||||
self.RenderManager = plugin.render_manager
|
||||
self.render_manager = plugin.render_manager
|
||||
self.name = plugin.name
|
||||
self.title = u''
|
||||
self.shortname = u''
|
||||
self.audit = u''
|
||||
self.items = []
|
||||
self.iconic_representation = None
|
||||
@ -90,6 +91,7 @@ class ServiceItem(object):
|
||||
self.capabilities = []
|
||||
self.is_valid = True
|
||||
self.cache = []
|
||||
self.icon = None
|
||||
|
||||
def add_capability(self, capability):
|
||||
"""
|
||||
@ -109,7 +111,7 @@ class ServiceItem(object):
|
||||
"""
|
||||
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
|
||||
service item in the service manager.
|
||||
@ -131,12 +133,12 @@ class ServiceItem(object):
|
||||
if self.service_item_type == ServiceItemType.Text:
|
||||
log.debug(u'Formatting slides')
|
||||
if self.theme is None:
|
||||
self.RenderManager.set_override_theme(None)
|
||||
self.render_manager.set_override_theme(None)
|
||||
else:
|
||||
self.RenderManager.set_override_theme(self.theme)
|
||||
self.render_manager.set_override_theme(self.theme)
|
||||
for slide in self._raw_frames:
|
||||
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:
|
||||
lines = u''
|
||||
title = u''
|
||||
@ -151,9 +153,8 @@ class ServiceItem(object):
|
||||
log.log(15, u'Formatting took %4s' % (time.time() - before))
|
||||
elif self.service_item_type == ServiceItemType.Image:
|
||||
for slide in self._raw_frames:
|
||||
slide[u'image'] = \
|
||||
resize_image(slide[u'image'], self.RenderManager.width,
|
||||
self.RenderManager.height)
|
||||
slide[u'image'] = resize_image(slide[u'image'],
|
||||
self.render_manager.width, self.render_manager.height)
|
||||
elif self.service_item_type == ServiceItemType.Command:
|
||||
pass
|
||||
else:
|
||||
@ -167,19 +168,19 @@ class ServiceItem(object):
|
||||
"""
|
||||
log.debug(u'render individual')
|
||||
if self.theme is None:
|
||||
self.RenderManager.set_override_theme(None)
|
||||
self.render_manager.set_override_theme(None)
|
||||
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')
|
||||
#if screen blank then do not display footer
|
||||
if self.cache[row] is not None:
|
||||
frame = self.cache[row]
|
||||
else:
|
||||
if format[0]:
|
||||
frame = self.RenderManager.generate_slide(format,
|
||||
self.raw_footer)
|
||||
frame = self.render_manager.generate_slide(format,
|
||||
self.raw_footer)
|
||||
else:
|
||||
frame = self.RenderManager.generate_slide(format, u'')
|
||||
frame = self.render_manager.generate_slide(format, u'')
|
||||
self.cache[row] = frame
|
||||
return frame
|
||||
|
||||
@ -200,7 +201,7 @@ class ServiceItem(object):
|
||||
self._raw_frames.append(
|
||||
{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.
|
||||
|
||||
@ -213,7 +214,7 @@ class ServiceItem(object):
|
||||
self.service_item_type = ServiceItemType.Text
|
||||
title = title.split(u'\n')[0]
|
||||
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):
|
||||
"""
|
||||
@ -280,7 +281,7 @@ class ServiceItem(object):
|
||||
self.service_item_type = header[u'type']
|
||||
self.shortname = header[u'plugin']
|
||||
self.theme = header[u'theme']
|
||||
self.addIcon(header[u'icon'])
|
||||
self.add_icon(header[u'icon'])
|
||||
self.raw_footer = header[u'footer']
|
||||
self.audit = header[u'audit']
|
||||
self.notes = header[u'notes']
|
||||
|
@ -41,7 +41,7 @@ class XmlRootClass(object):
|
||||
|
||||
(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.
|
||||
|
||||
|
@ -153,8 +153,8 @@ class Theme(object):
|
||||
The data to initialise the theme with
|
||||
"""
|
||||
# init to defaults
|
||||
self._set_from_XML(BLANK_STYLE_XML)
|
||||
self._set_from_XML(xml)
|
||||
self._set_from_xml(BLANK_STYLE_XML)
|
||||
self._set_from_xml(xml)
|
||||
|
||||
def _get_as_string(self):
|
||||
"""
|
||||
@ -176,9 +176,9 @@ class Theme(object):
|
||||
The data to apply to the theme
|
||||
"""
|
||||
root = ElementTree(element=XML(xml))
|
||||
iter = root.getiterator()
|
||||
for element in iter:
|
||||
delphiColorChange = False
|
||||
xml_iter = root.getiterator()
|
||||
for element in xml_iter:
|
||||
delphi_color_change = False
|
||||
if element.tag != u'Theme':
|
||||
element_text = element.text
|
||||
val = 0
|
||||
@ -194,7 +194,7 @@ class Theme(object):
|
||||
pass
|
||||
elif DELPHI_COLORS.has_key(element_text):
|
||||
val = DELPHI_COLORS[element_text]
|
||||
delphiColorChange = True
|
||||
delphi_color_change = True
|
||||
else:
|
||||
try:
|
||||
val = int(element_text)
|
||||
@ -204,7 +204,7 @@ class Theme(object):
|
||||
(element.tag.find(u'BackgroundParameter') == 0 and
|
||||
type(val) == type(0))):
|
||||
# convert to a wx.Colour
|
||||
if not delphiColorChange:
|
||||
if not delphi_color_change:
|
||||
val = QtGui.QColor(
|
||||
val&0xFF, (val>>8)&0xFF, (val>>16)&0xFF)
|
||||
else:
|
||||
|
@ -32,7 +32,7 @@ log = logging.getLogger(__name__)
|
||||
|
||||
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
|
||||
from openlp.core.ui import ServiceNoteForm, ServiceItemEditForm
|
||||
from openlp.core.utils import AppLocation
|
||||
@ -954,7 +954,7 @@ class ServiceManager(QtGui.QWidget):
|
||||
self.ThemeComboBox.addItem(u'')
|
||||
for theme in theme_list:
|
||||
self.ThemeComboBox.addItem(theme)
|
||||
action = contextMenuAction(
|
||||
action = context_menu_action(
|
||||
self.ServiceManagerList,
|
||||
None,
|
||||
theme , self.onThemeChangeAction)
|
||||
|
@ -33,9 +33,9 @@ from PyQt4 import QtCore, QtGui
|
||||
|
||||
from openlp.core.ui import AmendThemeForm
|
||||
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, \
|
||||
contextMenuSeparator, SettingsManager, translate
|
||||
context_menu_separator, SettingsManager, translate
|
||||
from openlp.core.utils import AppLocation
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
@ -81,27 +81,28 @@ class ThemeManager(QtGui.QWidget):
|
||||
self.Layout.addWidget(self.ThemeListWidget)
|
||||
self.ThemeListWidget.setContextMenuPolicy(QtCore.Qt.ActionsContextMenu)
|
||||
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))
|
||||
self.ThemeListWidget.addAction(
|
||||
contextMenuSeparator(self.ThemeListWidget))
|
||||
context_menu_separator(self.ThemeListWidget))
|
||||
self.ThemeListWidget.addAction(
|
||||
contextMenuAction(self.ThemeListWidget,
|
||||
context_menu_action(self.ThemeListWidget,
|
||||
u':/general/general_delete.png',
|
||||
translate(u'ThemeManager', u'Delete theme'),
|
||||
self.onDeleteTheme))
|
||||
self.ThemeListWidget.addAction(
|
||||
contextMenuAction(self.ThemeListWidget,
|
||||
context_menu_action(self.ThemeListWidget,
|
||||
u':/general/general_export.png',
|
||||
translate(u'ThemeManager', u'Make Global'),
|
||||
self.changeGlobalFromScreen))
|
||||
self.ThemeListWidget.addAction(
|
||||
contextMenuAction(self.ThemeListWidget,
|
||||
context_menu_action(self.ThemeListWidget,
|
||||
u':/general/general_export.png',
|
||||
translate(u'ThemeManager', u'Export theme'),
|
||||
self.onExportTheme))
|
||||
self.ThemeListWidget.addAction(
|
||||
contextMenuSeparator(self.ThemeListWidget))
|
||||
context_menu_separator(self.ThemeListWidget))
|
||||
#Signals
|
||||
QtCore.QObject.connect(self.ThemeListWidget,
|
||||
QtCore.SIGNAL(u'doubleClicked(QModelIndex)'),
|
||||
|
@ -29,7 +29,7 @@ import os
|
||||
from PyQt4 import QtCore, QtGui
|
||||
|
||||
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
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
@ -93,7 +93,7 @@ class ImageMediaItem(MediaManagerItem):
|
||||
MediaManagerItem.addListViewToToolBar(self)
|
||||
self.ListView.setContextMenuPolicy(QtCore.Qt.ActionsContextMenu)
|
||||
self.ListView.addAction(
|
||||
contextMenuAction(
|
||||
context_menu_action(
|
||||
self.ListView, u':/slides/slide_blank.png',
|
||||
translate(u'ImagePlugin.MediaItem', u'Replace Live Background'),
|
||||
self.onReplaceClick))
|
||||
|
@ -29,7 +29,7 @@ import os
|
||||
from PyQt4 import QtCore, QtGui
|
||||
|
||||
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__)
|
||||
|
||||
@ -77,7 +77,7 @@ class MediaMediaItem(MediaManagerItem):
|
||||
MediaManagerItem.addListViewToToolBar(self)
|
||||
self.ListView.setContextMenuPolicy(QtCore.Qt.ActionsContextMenu)
|
||||
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'),
|
||||
self.onReplaceClick))
|
||||
|
||||
|
@ -333,7 +333,7 @@ class SongMediaItem(MediaManagerItem):
|
||||
for verse in verseList:
|
||||
verseTag = u'%s:%s' % (
|
||||
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)
|
||||
else:
|
||||
#Loop through the verse list and expand the song accordingly.
|
||||
@ -345,8 +345,8 @@ class SongMediaItem(MediaManagerItem):
|
||||
verse[0][u'type'][0] == order[0]:
|
||||
verseTag = u'%s:%s' % \
|
||||
(verse[0][u'type'], verse[0][u'label'])
|
||||
service_item.add_from_text\
|
||||
(verse[1][:30], verse[1], verseTag)
|
||||
service_item.add_from_text(
|
||||
verse[1][:30], verse[1], verseTag)
|
||||
else:
|
||||
verses = song.lyrics.split(u'\n\n')
|
||||
for slide in verses:
|
||||
|
Loading…
Reference in New Issue
Block a user