Slowly start moving names to PEP8 style names.

This commit is contained in:
Raoul Snyman 2013-02-02 22:54:34 +02:00
parent 2f8bc1e2bb
commit 922c392ecb
14 changed files with 128 additions and 123 deletions

View File

@ -43,7 +43,7 @@ from traceback import format_exception
from PyQt4 import QtCore, QtGui from PyQt4 import QtCore, QtGui
from openlp.core.lib import Receiver, Settings, check_directory_exists, ScreenList, UiStrings, Registry from openlp.core.lib import Receiver, Settings, ScreenList, UiStrings, Registry, check_directory_exists
from openlp.core.resources import qInitResources from openlp.core.resources import qInitResources
from openlp.core.ui.mainwindow import MainWindow from openlp.core.ui.mainwindow import MainWindow
from openlp.core.ui.firsttimelanguageform import FirstTimeLanguageForm from openlp.core.ui.firsttimelanguageform import FirstTimeLanguageForm
@ -92,15 +92,16 @@ class OpenLP(QtGui.QApplication):
""" """
Override exec method to allow the shared memory to be released on exit Override exec method to allow the shared memory to be released on exit
""" """
self.eventLoopIsActive = True self.event_loop_is_active = True
QtGui.QApplication.exec_() result = QtGui.QApplication.exec_(self)
self.sharedMemory.detach() self.shared_memory.detach()
return result
def run(self, args, testing=False): def run(self, args, testing=False):
""" """
Run the OpenLP application. Run the OpenLP application.
""" """
self.eventLoopIsActive = False self.event_loop_is_active = False
# On Windows, the args passed into the constructor are ignored. Not # On Windows, the args passed into the constructor are ignored. Not
# very handy, so set the ones we want to use. On Linux and FreeBSD, in # very handy, so set the ones we want to use. On Linux and FreeBSD, in
# order to set the WM_CLASS property for X11, we pass "OpenLP" in as a # order to set the WM_CLASS property for X11, we pass "OpenLP" in as a
@ -111,8 +112,8 @@ class OpenLP(QtGui.QApplication):
self.args.extend(args) self.args.extend(args)
# provide a listener for widgets to reqest a screen update. # provide a listener for widgets to reqest a screen update.
QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'openlp_process_events'), self.processEvents) QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'openlp_process_events'), self.processEvents)
QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'cursor_busy'), self.setBusyCursor) QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'cursor_busy'), self.set_busy_cursor)
QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'cursor_normal'), self.setNormalCursor) QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'cursor_normal'), self.set_normal_cursor)
# Decide how many screens we have and their size # Decide how many screens we have and their size
screens = ScreenList.create(self.desktop()) screens = ScreenList.create(self.desktop())
# First time checks in settings # First time checks in settings
@ -138,44 +139,44 @@ class OpenLP(QtGui.QApplication):
# make sure Qt really display the splash screen # make sure Qt really display the splash screen
self.processEvents() self.processEvents()
# start the main app window # start the main app window
self.mainWindow = MainWindow(self) self.main_window = MainWindow(self)
self.mainWindow.show() self.main_window.show()
if show_splash: if show_splash:
# now kill the splashscreen # now kill the splashscreen
self.splash.finish(self.mainWindow) self.splash.finish(self.main_window)
log.debug(u'Splashscreen closed') log.debug(u'Splashscreen closed')
# make sure Qt really display the splash screen # make sure Qt really display the splash screen
self.processEvents() self.processEvents()
self.mainWindow.repaint() self.main_window.repaint()
self.processEvents() self.processEvents()
if not has_run_wizard: if not has_run_wizard:
self.mainWindow.firstTime() self.main_window.first_time()
update_check = Settings().value(u'general/update check') update_check = Settings().value(u'general/update check')
if update_check: if update_check:
VersionThread(self.mainWindow).start() VersionThread(self.main_window).start()
Receiver.send_message(u'live_display_blank_check') Receiver.send_message(u'live_display_blank_check')
self.mainWindow.appStartup() self.main_window.app_startup()
# Skip exec_() for gui tests # Skip exec_() for gui tests
if not testing: if not testing:
return self.exec_() return self.exec_()
def isAlreadyRunning(self): def is_already_running(self):
""" """
Look to see if OpenLP is already running and ask if a 2nd copy Look to see if OpenLP is already running and ask if a 2nd copy
is to be started. is to be started.
""" """
self.sharedMemory = QtCore.QSharedMemory('OpenLP') self.shared_memory = QtCore.QSharedMemory('OpenLP')
if self.sharedMemory.attach(): if self.shared_memory.attach():
status = QtGui.QMessageBox.critical(None, UiStrings().Error, UiStrings().OpenLPStart, status = QtGui.QMessageBox.critical(None, UiStrings().Error, UiStrings().OpenLPStart,
QtGui.QMessageBox.StandardButtons(QtGui.QMessageBox.Yes | QtGui.QMessageBox.No)) QtGui.QMessageBox.StandardButtons(QtGui.QMessageBox.Yes | QtGui.QMessageBox.No))
if status == QtGui.QMessageBox.No: if status == QtGui.QMessageBox.No:
return True return True
return False return False
else: else:
self.sharedMemory.create(1) self.shared_memory.create(1)
return False return False
def hookException(self, exctype, value, traceback): def hook_exception(self, exctype, value, traceback):
""" """
Add an exception hook so that any uncaught exceptions are displayed in this window rather than somewhere where Add an exception hook so that any uncaught exceptions are displayed in this window rather than somewhere where
users cannot see it and cannot report when we encounter these problems. users cannot see it and cannot report when we encounter these problems.
@ -193,19 +194,19 @@ class OpenLP(QtGui.QApplication):
log.exception(''.join(format_exception(exctype, value, traceback))) log.exception(''.join(format_exception(exctype, value, traceback)))
return return
if not hasattr(self, u'exceptionForm'): if not hasattr(self, u'exceptionForm'):
self.exceptionForm = ExceptionForm(self.mainWindow) self.exception_form = ExceptionForm(self.main_window)
self.exceptionForm.exceptionTextEdit.setPlainText(''.join(format_exception(exctype, value, traceback))) self.exception_form.exceptionTextEdit.setPlainText(''.join(format_exception(exctype, value, traceback)))
self.setNormalCursor() self.set_normal_cursor()
self.exceptionForm.exec_() self.exception_form.exec_()
def setBusyCursor(self): def set_busy_cursor(self):
""" """
Sets the Busy Cursor for the Application Sets the Busy Cursor for the Application
""" """
self.setOverrideCursor(QtCore.Qt.BusyCursor) self.setOverrideCursor(QtCore.Qt.BusyCursor)
self.processEvents() self.processEvents()
def setNormalCursor(self): def set_normal_cursor(self):
""" """
Sets the Normal Cursor for the Application Sets the Normal Cursor for the Application
""" """
@ -305,7 +306,7 @@ def main(args=None):
# Instance check # Instance check
if not options.testing: if not options.testing:
# Instance check # Instance check
if app.isAlreadyRunning(): if app.is_already_running():
sys.exit() sys.exit()
# First time checks in settings # First time checks in settings
if not Settings().value(u'general/has run wizard'): if not Settings().value(u'general/has run wizard'):
@ -322,7 +323,7 @@ def main(args=None):
else: else:
log.debug(u'Could not find default_translator.') log.debug(u'Could not find default_translator.')
if not options.no_error_form: if not options.no_error_form:
sys.excepthook = app.hookException sys.excepthook = app.hook_exception
# Do not run method app.exec_() when running gui tests # Do not run method app.exec_() when running gui tests
if options.testing: if options.testing:
app.run(qt_args, testing=True) app.run(qt_args, testing=True)

View File

@ -90,9 +90,8 @@ class ServiceItemAction(object):
Next = 3 Next = 3
def translate(context, text, comment=None, def translate(context, text, comment=None, encoding=QtCore.QCoreApplication.CodecForTr, n=-1,
encoding=QtCore.QCoreApplication.CodecForTr, n=-1, translate=QtCore.QCoreApplication.translate):
translate=QtCore.QCoreApplication.translate):
""" """
A special shortcut method to wrap around the Qt4 translation functions. A special shortcut method to wrap around the Qt4 translation functions.
This abstracts the translation procedure so that we can change it if at a This abstracts the translation procedure so that we can change it if at a

View File

@ -110,14 +110,17 @@ def upgrade_db(url, upgrade):
while hasattr(upgrade, u'upgrade_%d' % version): while hasattr(upgrade, u'upgrade_%d' % version):
log.debug(u'Running upgrade_%d', version) log.debug(u'Running upgrade_%d', version)
try: try:
getattr(upgrade, u'upgrade_%d' % version)(session, metadata, tables) upgrade_func = getattr(upgrade, u'upgrade_%d' % version)
upgrade_func(session, metadata, tables)
session.commit()
# Update the version number AFTER a commit so that we are sure the previous transaction happened
version_meta.value = unicode(version)
session.commit()
version += 1
except (SQLAlchemyError, DBAPIError): except (SQLAlchemyError, DBAPIError):
log.exception(u'Could not run database upgrade script ' log.exception(u'Could not run database upgrade script '
'"upgrade_%s", upgrade process has been halted.', version) '"upgrade_%s", upgrade process has been halted.', version)
break break
version_meta.value = unicode(version)
session.commit()
version += 1
else: else:
version_meta = Metadata.populate(key=u'version', value=int(upgrade.__version__)) version_meta = Metadata.populate(key=u'version', value=int(upgrade.__version__))
session.commit() session.commit()
@ -216,7 +219,8 @@ class Manager(object):
self.session = init_schema(self.db_url) self.session = init_schema(self.db_url)
except (SQLAlchemyError, DBAPIError): except (SQLAlchemyError, DBAPIError):
log.exception(u'Error loading database: %s', self.db_url) log.exception(u'Error loading database: %s', self.db_url)
critical_error_message_box(translate('OpenLP.Manager', 'Database Error'), critical_error_message_box(
translate('OpenLP.Manager', 'Database Error'),
translate('OpenLP.Manager', 'OpenLP cannot load your database.\n\nDatabase: %s') % self.db_url translate('OpenLP.Manager', 'OpenLP cannot load your database.\n\nDatabase: %s') % self.db_url
) )

View File

@ -208,8 +208,7 @@ sup {
""" """
def build_html(item, screen, islive, background, image=None, def build_html(item, screen, is_live, background, image=None, plugins=None):
plugins=None):
""" """
Build the full web paged structure for display Build the full web paged structure for display
@ -234,7 +233,7 @@ def build_html(item, screen, islive, background, image=None,
width = screen[u'size'].width() width = screen[u'size'].width()
height = screen[u'size'].height() height = screen[u'size'].height()
theme = item.themedata theme = item.themedata
webkitvers = webkit_version() webkit_ver = webkit_version()
# Image generated and poked in # Image generated and poked in
if background: if background:
bgimage_src = u'src="data:image/png;base64,%s"' % background bgimage_src = u'src="data:image/png;base64,%s"' % background
@ -254,15 +253,17 @@ def build_html(item, screen, islive, background, image=None,
css_additions += plugin.getDisplayCss() css_additions += plugin.getDisplayCss()
js_additions += plugin.getDisplayJavaScript() js_additions += plugin.getDisplayJavaScript()
html_additions += plugin.getDisplayHtml() html_additions += plugin.getDisplayHtml()
html = HTMLSRC % (build_background_css(item, width, height), html = HTMLSRC % (
build_background_css(item, width, height),
css_additions, css_additions,
build_footer_css(item, height), build_footer_css(item, height),
build_lyrics_css(item, webkitvers), build_lyrics_css(item, webkit_ver),
u'true' if theme and theme.display_slide_transition and islive else u'false', u'true' if theme and theme.display_slide_transition and is_live else u'false',
js_additions, js_additions,
bgimage_src, image_src, bgimage_src, image_src,
html_additions, html_additions,
build_lyrics_html(item, webkitvers)) build_lyrics_html(item, webkit_ver)
)
return html return html
@ -272,11 +273,11 @@ def webkit_version():
Note method added relatively recently, so return 0 if prior to this Note method added relatively recently, so return 0 if prior to this
""" """
try: try:
webkitvers = float(QtWebKit.qWebKitVersion()) webkit_ver = float(QtWebKit.qWebKitVersion())
log.debug(u'Webkit version = %s' % webkitvers) log.debug(u'Webkit version = %s' % webkit_ver)
except AttributeError: except AttributeError:
webkitvers = 0 webkit_ver = 0
return webkitvers return webkit_ver
def build_background_css(item, width, height): def build_background_css(item, width, height):
@ -314,7 +315,7 @@ def build_background_css(item, width, height):
return background return background
def build_lyrics_css(item, webkitvers): def build_lyrics_css(item, webkit_ver):
""" """
Build the lyrics display css Build the lyrics display css
@ -371,12 +372,12 @@ def build_lyrics_css(item, webkitvers):
# Up to 534.3 the text-shadow didn't get displayed when # Up to 534.3 the text-shadow didn't get displayed when
# webkit-text-stroke was used. So use an offset text layer underneath. # webkit-text-stroke was used. So use an offset text layer underneath.
# https://bugs.webkit.org/show_bug.cgi?id=19728 # https://bugs.webkit.org/show_bug.cgi?id=19728
if webkitvers >= 533.3: if webkit_ver >= 533.3:
lyricsmain += build_lyrics_outline_css(theme) lyricsmain += build_lyrics_outline_css(theme)
else: else:
outline = build_lyrics_outline_css(theme) outline = build_lyrics_outline_css(theme)
if theme.font_main_shadow: if theme.font_main_shadow:
if theme.font_main_outline and webkitvers <= 534.3: if theme.font_main_outline and webkit_ver <= 534.3:
shadow = u'padding-left: %spx; padding-top: %spx;' % \ shadow = u'padding-left: %spx; padding-top: %spx;' % \
(int(theme.font_main_shadow_size) + (int(theme.font_main_outline_size) * 2), (int(theme.font_main_shadow_size) + (int(theme.font_main_outline_size) * 2),
theme.font_main_shadow_size) theme.font_main_shadow_size)

View File

@ -57,13 +57,13 @@ class ImageThread(QtCore.QThread):
The image manager. The image manager.
""" """
QtCore.QThread.__init__(self, None) QtCore.QThread.__init__(self, None)
self.imageManager = manager self.image_manager = manager
def run(self): def run(self):
""" """
Run the thread. Run the thread.
""" """
self.imageManager._process() self.image_manager._process()
class Priority(object): class Priority(object):
@ -189,74 +189,74 @@ class ImageManager(QtCore.QObject):
def __init__(self): def __init__(self):
""" """
Consutructor for the image manager. Constructor for the image manager.
""" """
QtCore.QObject.__init__(self) QtCore.QObject.__init__(self)
Registry().register(u'image_manager', self) Registry().register(u'image_manager', self)
currentScreen = ScreenList().current current_screen = ScreenList().current
self.width = currentScreen[u'size'].width() self.width = current_screen[u'size'].width()
self.height = currentScreen[u'size'].height() self.height = current_screen[u'size'].height()
self._cache = {} self._cache = {}
self.imageThread = ImageThread(self) self.image_thread = ImageThread(self)
self._conversionQueue = PriorityQueue() self._conversion_queue = PriorityQueue()
self.stopManager = False self.stop_manager = False
QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'config_updated'), self.processUpdates) QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'config_updated'), self.process_updates)
def updateDisplay(self): def update_display(self):
""" """
Screen has changed size so rebuild the cache to new size. Screen has changed size so rebuild the cache to new size.
""" """
log.debug(u'updateDisplay') log.debug(u'update_display')
currentScreen = ScreenList().current current_screen = ScreenList().current
self.width = currentScreen[u'size'].width() self.width = current_screen[u'size'].width()
self.height = currentScreen[u'size'].height() self.height = current_screen[u'size'].height()
# Mark the images as dirty for a rebuild by setting the image and byte # Mark the images as dirty for a rebuild by setting the image and byte
# stream to None. # stream to None.
for image in self._cache.values(): for image in self._cache.values():
self._resetImage(image) self._reset_image(image)
def updateImagesBorder(self, source, background): def update_images_border(self, source, background):
""" """
Border has changed so update all the images affected. Border has changed so update all the images affected.
""" """
log.debug(u'updateImages') log.debug(u'update_images_border')
# Mark the images as dirty for a rebuild by setting the image and byte # Mark the images as dirty for a rebuild by setting the image and byte
# stream to None. # stream to None.
for image in self._cache.values(): for image in self._cache.values():
if image.source == source: if image.source == source:
image.background = background image.background = background
self._resetImage(image) self._reset_image(image)
def updateImageBorder(self, path, source, background): def update_image_border(self, path, source, background):
""" """
Border has changed so update the image affected. Border has changed so update the image affected.
""" """
log.debug(u'updateImage') log.debug(u'update_image_border')
# Mark the image as dirty for a rebuild by setting the image and byte # Mark the image as dirty for a rebuild by setting the image and byte
# stream to None. # stream to None.
image = self._cache[(path, source)] image = self._cache[(path, source)]
if image.source == source: if image.source == source:
image.background = background image.background = background
self._resetImage(image) self._reset_image(image)
def _resetImage(self, image): def _reset_image(self, image):
""" """
Mark the given :class:`Image` instance as dirty by setting its ``image`` Mark the given :class:`Image` instance as dirty by setting its ``image``
and ``image_bytes`` attributes to None. and ``image_bytes`` attributes to None.
""" """
image.image = None image.image = None
image.image_bytes = None image.image_bytes = None
self._conversionQueue.modify_priority(image, Priority.Normal) self._conversion_queue.modify_priority(image, Priority.Normal)
def processUpdates(self): def process_updates(self):
""" """
Flush the queue to updated any data to update Flush the queue to updated any data to update
""" """
# We want only one thread. # We want only one thread.
if not self.imageThread.isRunning(): if not self.image_thread.isRunning():
self.imageThread.start() self.image_thread.start()
def getImage(self, path, source): def get_image(self, path, source):
""" """
Return the ``QImage`` from the cache. If not present wait for the Return the ``QImage`` from the cache. If not present wait for the
background thread to process it. background thread to process it.
@ -264,9 +264,9 @@ class ImageManager(QtCore.QObject):
log.debug(u'getImage %s' % path) log.debug(u'getImage %s' % path)
image = self._cache[(path, source)] image = self._cache[(path, source)]
if image.image is None: if image.image is None:
self._conversionQueue.modify_priority(image, Priority.High) self._conversion_queue.modify_priority(image, Priority.High)
# make sure we are running and if not give it a kick # make sure we are running and if not give it a kick
self.processUpdates() self.process_updates()
while image.image is None: while image.image is None:
log.debug(u'getImage - waiting') log.debug(u'getImage - waiting')
time.sleep(0.1) time.sleep(0.1)
@ -275,74 +275,74 @@ class ImageManager(QtCore.QObject):
# byte stream was not generated yet. However, we only need to do # byte stream was not generated yet. However, we only need to do
# this, when the image was generated before it was requested # this, when the image was generated before it was requested
# (otherwise this is already taken care of). # (otherwise this is already taken care of).
self._conversionQueue.modify_priority(image, Priority.Low) self._conversion_queue.modify_priority(image, Priority.Low)
return image.image return image.image
def getImageBytes(self, path, source): def get_image_bytes(self, path, source):
""" """
Returns the byte string for an image. If not present wait for the Returns the byte string for an image. If not present wait for the
background thread to process it. background thread to process it.
""" """
log.debug(u'getImageBytes %s' % path) log.debug(u'get_image_bytes %s' % path)
image = self._cache[(path, source)] image = self._cache[(path, source)]
if image.image_bytes is None: if image.image_bytes is None:
self._conversionQueue.modify_priority(image, Priority.Urgent) self._conversion_queue.modify_priority(image, Priority.Urgent)
# make sure we are running and if not give it a kick # make sure we are running and if not give it a kick
self.processUpdates() self.process_updates()
while image.image_bytes is None: while image.image_bytes is None:
log.debug(u'getImageBytes - waiting') log.debug(u'getImageBytes - waiting')
time.sleep(0.1) time.sleep(0.1)
return image.image_bytes return image.image_bytes
def addImage(self, path, source, background): def add_image(self, path, source, background):
""" """
Add image to cache if it is not already there. Add image to cache if it is not already there.
""" """
log.debug(u'addImage %s' % path) log.debug(u'add_image %s' % path)
if not (path, source) in self._cache: if not (path, source) in self._cache:
image = Image(path, source, background) image = Image(path, source, background)
self._cache[(path, source)] = image self._cache[(path, source)] = image
self._conversionQueue.put((image.priority, image.secondary_priority, image)) self._conversion_queue.put((image.priority, image.secondary_priority, image))
# Check if the there are any images with the same path and check if the # Check if the there are any images with the same path and check if the
# timestamp has changed. # timestamp has changed.
for image in self._cache.values(): for image in self._cache.values():
if os.path.exists(path): if os.path.exists(path):
if image.path == path and image.timestamp != os.stat(path).st_mtime: if image.path == path and image.timestamp != os.stat(path).st_mtime:
image.timestamp = os.stat(path).st_mtime image.timestamp = os.stat(path).st_mtime
self._resetImage(image) self._reset_image(image)
# We want only one thread. # We want only one thread.
if not self.imageThread.isRunning(): if not self.image_thread.isRunning():
self.imageThread.start() self.image_thread.start()
def _process(self): def _process(self):
""" """
Controls the processing called from a ``QtCore.QThread``. Controls the processing called from a ``QtCore.QThread``.
""" """
log.debug(u'_process - started') log.debug(u'_process - started')
while not self._conversionQueue.empty() and not self.stopManager: while not self._conversion_queue.empty() and not self.stop_manager:
self._processCache() self._process_cache()
log.debug(u'_process - ended') log.debug(u'_process - ended')
def _processCache(self): def _process_cache(self):
""" """
Actually does the work. Actually does the work.
""" """
log.debug(u'_processCache') log.debug(u'_processCache')
image = self._conversionQueue.get()[2] image = self._conversion_queue.get()[2]
# Generate the QImage for the image. # Generate the QImage for the image.
if image.image is None: if image.image is None:
image.image = resize_image(image.path, self.width, self.height, image.background) image.image = resize_image(image.path, self.width, self.height, image.background)
# Set the priority to Lowest and stop here as we need to process # Set the priority to Lowest and stop here as we need to process
# more important images first. # more important images first.
if image.priority == Priority.Normal: if image.priority == Priority.Normal:
self._conversionQueue.modify_priority(image, Priority.Lowest) self._conversion_queue.modify_priority(image, Priority.Lowest)
return return
# For image with high priority we set the priority to Low, as the # For image with high priority we set the priority to Low, as the
# byte stream might be needed earlier the byte stream of image with # byte stream might be needed earlier the byte stream of image with
# Normal priority. We stop here as we need to process more important # Normal priority. We stop here as we need to process more important
# images first. # images first.
elif image.priority == Priority.High: elif image.priority == Priority.High:
self._conversionQueue.modify_priority(image, Priority.Low) self._conversion_queue.modify_priority(image, Priority.Low)
return return
# Generate the byte stream for the image. # Generate the byte stream for the image.
if image.image_bytes is None: if image.image_bytes is None:

View File

@ -136,7 +136,7 @@ class Renderer(object):
theme_data, main_rect, footer_rect = self._theme_dimensions[theme_name] theme_data, main_rect, footer_rect = self._theme_dimensions[theme_name]
# if No file do not update cache # if No file do not update cache
if theme_data.background_filename: if theme_data.background_filename:
self.image_manager.addImage(theme_data.background_filename, self.image_manager.add_image(theme_data.background_filename,
ImageSource.Theme, QtGui.QColor(theme_data.background_border_color)) ImageSource.Theme, QtGui.QColor(theme_data.background_border_color))
def pre_render(self, override_theme_data=None): def pre_render(self, override_theme_data=None):
@ -238,7 +238,7 @@ class Renderer(object):
serviceItem.raw_footer = FOOTER serviceItem.raw_footer = FOOTER
# if No file do not update cache # if No file do not update cache
if theme_data.background_filename: if theme_data.background_filename:
self.image_manager.addImage(theme_data.background_filename, self.image_manager.add_image(theme_data.background_filename,
ImageSource.Theme, ImageSource.Theme,
QtGui.QColor(theme_data.background_border_color)) QtGui.QColor(theme_data.background_border_color))
theme_data, main, footer = self.pre_render(theme_data) theme_data, main, footer = self.pre_render(theme_data)
@ -661,4 +661,4 @@ class Renderer(object):
self._theme_manager = Registry().get(u'theme_manager') self._theme_manager = Registry().get(u'theme_manager')
return self._theme_manager return self._theme_manager
theme_manager = property(_get_theme_manager) theme_manager = property(_get_theme_manager)

View File

@ -293,7 +293,7 @@ class ServiceItem(object):
self.image_border = background self.image_border = background
self.service_item_type = ServiceItemType.Image self.service_item_type = ServiceItemType.Image
self._raw_frames.append({u'title': title, u'path': path}) self._raw_frames.append({u'title': title, u'path': path})
self.image_manager.addImage(path, ImageSource.ImagePlugin, self.image_border) self.image_manager.add_image(path, ImageSource.ImagePlugin, self.image_border)
self._new_item() self._new_item()
def add_from_text(self, raw_slide, verse_tag=None): def add_from_text(self, raw_slide, verse_tag=None):
@ -663,4 +663,4 @@ class ServiceItem(object):
self._image_manager = Registry().get(u'image_manager') self._image_manager = Registry().get(u'image_manager')
return self._image_manager return self._image_manager
image_manager = property(_get_image_manager) image_manager = property(_get_image_manager)

View File

@ -292,7 +292,7 @@ class MainDisplay(Display):
""" """
API for replacement backgrounds so Images are added directly to cache. API for replacement backgrounds so Images are added directly to cache.
""" """
self.image_manager.addImage(path, ImageSource.ImagePlugin, background) self.image_manager.add_image(path, ImageSource.ImagePlugin, background)
if not hasattr(self, u'serviceItem'): if not hasattr(self, u'serviceItem'):
return False return False
self.override[u'image'] = path self.override[u'image'] = path
@ -314,7 +314,7 @@ class MainDisplay(Display):
re-added to the image manager. re-added to the image manager.
""" """
log.debug(u'image to display') log.debug(u'image to display')
image = self.image_manager.getImageBytes(path, ImageSource.ImagePlugin) image = self.image_manager.get_image_bytes(path, ImageSource.ImagePlugin)
self.controller.media_controller.media_reset(self.controller) self.controller.media_controller.media_reset(self.controller)
self.displayImage(image) self.displayImage(image)
@ -395,16 +395,16 @@ class MainDisplay(Display):
self.override = {} self.override = {}
else: else:
# replace the background # replace the background
background = self.image_manager.getImageBytes(self.override[u'image'], ImageSource.ImagePlugin) background = self.image_manager.get_image_bytes(self.override[u'image'], ImageSource.ImagePlugin)
self.setTransparency(self.serviceItem.themedata.background_type == self.setTransparency(self.serviceItem.themedata.background_type ==
BackgroundType.to_string(BackgroundType.Transparent)) BackgroundType.to_string(BackgroundType.Transparent))
if self.serviceItem.themedata.background_filename: if self.serviceItem.themedata.background_filename:
self.serviceItem.bg_image_bytes = self.image_manager.getImageBytes( self.serviceItem.bg_image_bytes = self.image_manager.get_image_bytes(
self.serviceItem.themedata.background_filename, self.serviceItem.themedata.background_filename,
ImageSource.Theme ImageSource.Theme
) )
if image_path: if image_path:
image_bytes = self.image_manager.getImageBytes(image_path, ImageSource.ImagePlugin) image_bytes = self.image_manager.get_image_bytes(image_path, ImageSource.ImagePlugin)
else: else:
image_bytes = None image_bytes = None
html = build_html(self.serviceItem, self.screen, self.isLive, background, image_bytes, html = build_html(self.serviceItem, self.screen, self.isLive, background, image_bytes,

View File

@ -644,17 +644,17 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow):
self.setViewMode(False, True, False, False, True) self.setViewMode(False, True, False, False, True)
self.modeLiveItem.setChecked(True) self.modeLiveItem.setChecked(True)
def appStartup(self): def app_startup(self):
""" """
Give all the plugins a chance to perform some tasks at startup Give all the plugins a chance to perform some tasks at startup
""" """
Receiver.send_message(u'openlp_process_events') Receiver.send_message(u'openlp_process_events')
for plugin in self.pluginManager.plugins: for plugin in self.pluginManager.plugins:
if plugin.isActive(): if plugin.isActive():
plugin.appStartup() plugin.app_startup()
Receiver.send_message(u'openlp_process_events') Receiver.send_message(u'openlp_process_events')
def firstTime(self): def first_time(self):
""" """
Import themes if first time Import themes if first time
""" """
@ -662,7 +662,7 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow):
for plugin in self.pluginManager.plugins: for plugin in self.pluginManager.plugins:
if hasattr(plugin, u'firstTime'): if hasattr(plugin, u'firstTime'):
Receiver.send_message(u'openlp_process_events') Receiver.send_message(u'openlp_process_events')
plugin.firstTime() plugin.first_time()
Receiver.send_message(u'openlp_process_events') Receiver.send_message(u'openlp_process_events')
temp_dir = os.path.join(unicode(gettempdir()), u'openlp') temp_dir = os.path.join(unicode(gettempdir()), u'openlp')
shutil.rmtree(temp_dir, True) shutil.rmtree(temp_dir, True)
@ -690,7 +690,7 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow):
firstTime.exec_() firstTime.exec_()
if firstTime.downloadCancelled: if firstTime.downloadCancelled:
return return
self.firstTime() self.first_time()
for plugin in self.pluginManager.plugins: for plugin in self.pluginManager.plugins:
self.activePlugin = plugin self.activePlugin = plugin
oldStatus = self.activePlugin.status oldStatus = self.activePlugin.status
@ -698,7 +698,7 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow):
if oldStatus != self.activePlugin.status: if oldStatus != self.activePlugin.status:
if self.activePlugin.status == PluginStatus.Active: if self.activePlugin.status == PluginStatus.Active:
self.activePlugin.toggleStatus(PluginStatus.Active) self.activePlugin.toggleStatus(PluginStatus.Active)
self.activePlugin.appStartup() self.activePlugin.app_startup()
else: else:
self.activePlugin.toggleStatus(PluginStatus.Inactive) self.activePlugin.toggleStatus(PluginStatus.Inactive)
self.themeManagerContents.configUpdated() self.themeManagerContents.configUpdated()
@ -1004,7 +1004,7 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow):
""" """
log.debug(u'screenChanged') log.debug(u'screenChanged')
Receiver.send_message(u'cursor_busy') Receiver.send_message(u'cursor_busy')
self.imageManager.updateDisplay() self.imageManager.update_display()
self.renderer.update_display() self.renderer.update_display()
self.previewController.screenSizeChanged() self.previewController.screenSizeChanged()
self.liveController.screenSizeChanged() self.liveController.screenSizeChanged()
@ -1060,8 +1060,8 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow):
``save_settings`` ``save_settings``
Switch to prevent saving settings. Defaults to **True**. Switch to prevent saving settings. Defaults to **True**.
""" """
self.imageManager.stopManager = True self.imageManager.stop_manager = True
while self.imageManager.imageThread.isRunning(): while self.imageManager.image_thread.isRunning():
time.sleep(0.1) time.sleep(0.1)
# Clean temporary files used by services # Clean temporary files used by services
self.serviceManagerContents.cleanUp() self.serviceManagerContents.cleanUp()

View File

@ -144,7 +144,7 @@ class PluginForm(QtGui.QDialog, Ui_PluginViewDialog):
Receiver.send_message(u'cursor_busy') Receiver.send_message(u'cursor_busy')
self.activePlugin.toggleStatus(PluginStatus.Active) self.activePlugin.toggleStatus(PluginStatus.Active)
Receiver.send_message(u'cursor_normal') Receiver.send_message(u'cursor_normal')
self.activePlugin.appStartup() self.activePlugin.app_startup()
else: else:
self.activePlugin.toggleStatus(PluginStatus.Inactive) self.activePlugin.toggleStatus(PluginStatus.Inactive)
status_text = translate('OpenLP.PluginForm', '%s (Inactive)') status_text = translate('OpenLP.PluginForm', '%s (Inactive)')

View File

@ -819,9 +819,9 @@ class SlideController(DisplayController):
else: else:
# If current slide set background to image # If current slide set background to image
if framenumber == slideno: if framenumber == slideno:
self.serviceItem.bg_image_bytes = self.image_manager.getImageBytes(frame[u'path'], self.serviceItem.bg_image_bytes = self.image_manager.get_image_bytes(frame[u'path'],
ImageSource.ImagePlugin) ImageSource.ImagePlugin)
image = self.image_manager.getImage(frame[u'path'], ImageSource.ImagePlugin) image = self.image_manager.get_image(frame[u'path'], ImageSource.ImagePlugin)
label.setPixmap(QtGui.QPixmap.fromImage(image)) label.setPixmap(QtGui.QPixmap.fromImage(image))
self.previewListWidget.setCellWidget(framenumber, 0, label) self.previewListWidget.setCellWidget(framenumber, 0, label)
slideHeight = width * (1 / self.ratio) slideHeight = width * (1 / self.ratio)
@ -1395,4 +1395,4 @@ class SlideController(DisplayController):
self._live_controller = Registry().get(u'live_controller') self._live_controller = Registry().get(u'live_controller')
return self._live_controller return self._live_controller
live_controller = property(_get_live_controller) live_controller = property(_get_live_controller)

View File

@ -638,9 +638,9 @@ class ThemeManager(QtGui.QWidget):
""" """
self._writeTheme(theme, image_from, image_to) self._writeTheme(theme, image_from, image_to)
if theme.background_type == BackgroundType.to_string(BackgroundType.Image): if theme.background_type == BackgroundType.to_string(BackgroundType.Image):
self.image_manager.updateImageBorder(theme.background_filename, self.image_manager.update_image_border(theme.background_filename,
ImageSource.Theme, QtGui.QColor(theme.background_border_color)) ImageSource.Theme, QtGui.QColor(theme.background_border_color))
self.image_manager.processUpdates() self.image_manager.process_updates()
def _writeTheme(self, theme, image_from, image_to): def _writeTheme(self, theme, image_from, image_to):
""" """

View File

@ -349,7 +349,7 @@ class BibleMediaItem(MediaManagerItem):
self.loadBibles() self.loadBibles()
# If called from first time wizard re-run, process any new bibles. # If called from first time wizard re-run, process any new bibles.
if process: if process:
self.plugin.appStartup() self.plugin.app_startup()
self.updateAutoCompleter() self.updateAutoCompleter()
def initialiseAdvancedBible(self, bible, last_book_id=None): def initialiseAdvancedBible(self, bible, last_book_id=None):

View File

@ -98,4 +98,4 @@ class ImagePlugin(Plugin):
last part of saving the config. last part of saving the config.
""" """
background = QtGui.QColor(Settings().value(self.settingsSection + u'/background color')) background = QtGui.QColor(Settings().value(self.settingsSection + u'/background color'))
self.liveController.imageManager.updateImagesBorder(ImageSource.ImagePlugin, background) self.liveController.imageManager.update_images_border(ImageSource.ImagePlugin, background)