forked from openlp/openlp
Slowly start moving names to PEP8 style names.
This commit is contained in:
parent
2f8bc1e2bb
commit
922c392ecb
@ -43,7 +43,7 @@ from traceback import format_exception
|
||||
|
||||
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.ui.mainwindow import MainWindow
|
||||
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
|
||||
"""
|
||||
self.eventLoopIsActive = True
|
||||
QtGui.QApplication.exec_()
|
||||
self.sharedMemory.detach()
|
||||
self.event_loop_is_active = True
|
||||
result = QtGui.QApplication.exec_(self)
|
||||
self.shared_memory.detach()
|
||||
return result
|
||||
|
||||
def run(self, args, testing=False):
|
||||
"""
|
||||
Run the OpenLP application.
|
||||
"""
|
||||
self.eventLoopIsActive = False
|
||||
self.event_loop_is_active = False
|
||||
# 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
|
||||
# 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)
|
||||
# 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'cursor_busy'), self.setBusyCursor)
|
||||
QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'cursor_normal'), self.setNormalCursor)
|
||||
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.set_normal_cursor)
|
||||
# Decide how many screens we have and their size
|
||||
screens = ScreenList.create(self.desktop())
|
||||
# First time checks in settings
|
||||
@ -138,44 +139,44 @@ class OpenLP(QtGui.QApplication):
|
||||
# make sure Qt really display the splash screen
|
||||
self.processEvents()
|
||||
# start the main app window
|
||||
self.mainWindow = MainWindow(self)
|
||||
self.mainWindow.show()
|
||||
self.main_window = MainWindow(self)
|
||||
self.main_window.show()
|
||||
if show_splash:
|
||||
# now kill the splashscreen
|
||||
self.splash.finish(self.mainWindow)
|
||||
self.splash.finish(self.main_window)
|
||||
log.debug(u'Splashscreen closed')
|
||||
# make sure Qt really display the splash screen
|
||||
self.processEvents()
|
||||
self.mainWindow.repaint()
|
||||
self.main_window.repaint()
|
||||
self.processEvents()
|
||||
if not has_run_wizard:
|
||||
self.mainWindow.firstTime()
|
||||
self.main_window.first_time()
|
||||
update_check = Settings().value(u'general/update check')
|
||||
if update_check:
|
||||
VersionThread(self.mainWindow).start()
|
||||
VersionThread(self.main_window).start()
|
||||
Receiver.send_message(u'live_display_blank_check')
|
||||
self.mainWindow.appStartup()
|
||||
self.main_window.app_startup()
|
||||
# Skip exec_() for gui tests
|
||||
if not testing:
|
||||
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
|
||||
is to be started.
|
||||
"""
|
||||
self.sharedMemory = QtCore.QSharedMemory('OpenLP')
|
||||
if self.sharedMemory.attach():
|
||||
self.shared_memory = QtCore.QSharedMemory('OpenLP')
|
||||
if self.shared_memory.attach():
|
||||
status = QtGui.QMessageBox.critical(None, UiStrings().Error, UiStrings().OpenLPStart,
|
||||
QtGui.QMessageBox.StandardButtons(QtGui.QMessageBox.Yes | QtGui.QMessageBox.No))
|
||||
if status == QtGui.QMessageBox.No:
|
||||
return True
|
||||
return False
|
||||
else:
|
||||
self.sharedMemory.create(1)
|
||||
self.shared_memory.create(1)
|
||||
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
|
||||
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)))
|
||||
return
|
||||
if not hasattr(self, u'exceptionForm'):
|
||||
self.exceptionForm = ExceptionForm(self.mainWindow)
|
||||
self.exceptionForm.exceptionTextEdit.setPlainText(''.join(format_exception(exctype, value, traceback)))
|
||||
self.setNormalCursor()
|
||||
self.exceptionForm.exec_()
|
||||
self.exception_form = ExceptionForm(self.main_window)
|
||||
self.exception_form.exceptionTextEdit.setPlainText(''.join(format_exception(exctype, value, traceback)))
|
||||
self.set_normal_cursor()
|
||||
self.exception_form.exec_()
|
||||
|
||||
def setBusyCursor(self):
|
||||
def set_busy_cursor(self):
|
||||
"""
|
||||
Sets the Busy Cursor for the Application
|
||||
"""
|
||||
self.setOverrideCursor(QtCore.Qt.BusyCursor)
|
||||
self.processEvents()
|
||||
|
||||
def setNormalCursor(self):
|
||||
def set_normal_cursor(self):
|
||||
"""
|
||||
Sets the Normal Cursor for the Application
|
||||
"""
|
||||
@ -305,7 +306,7 @@ def main(args=None):
|
||||
# Instance check
|
||||
if not options.testing:
|
||||
# Instance check
|
||||
if app.isAlreadyRunning():
|
||||
if app.is_already_running():
|
||||
sys.exit()
|
||||
# First time checks in settings
|
||||
if not Settings().value(u'general/has run wizard'):
|
||||
@ -322,7 +323,7 @@ def main(args=None):
|
||||
else:
|
||||
log.debug(u'Could not find default_translator.')
|
||||
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
|
||||
if options.testing:
|
||||
app.run(qt_args, testing=True)
|
||||
|
@ -90,9 +90,8 @@ class ServiceItemAction(object):
|
||||
Next = 3
|
||||
|
||||
|
||||
def translate(context, text, comment=None,
|
||||
encoding=QtCore.QCoreApplication.CodecForTr, n=-1,
|
||||
translate=QtCore.QCoreApplication.translate):
|
||||
def translate(context, text, comment=None, encoding=QtCore.QCoreApplication.CodecForTr, n=-1,
|
||||
translate=QtCore.QCoreApplication.translate):
|
||||
"""
|
||||
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
|
||||
|
@ -110,14 +110,17 @@ def upgrade_db(url, upgrade):
|
||||
while hasattr(upgrade, u'upgrade_%d' % version):
|
||||
log.debug(u'Running upgrade_%d', version)
|
||||
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):
|
||||
log.exception(u'Could not run database upgrade script '
|
||||
'"upgrade_%s", upgrade process has been halted.', version)
|
||||
break
|
||||
version_meta.value = unicode(version)
|
||||
session.commit()
|
||||
version += 1
|
||||
else:
|
||||
version_meta = Metadata.populate(key=u'version', value=int(upgrade.__version__))
|
||||
session.commit()
|
||||
@ -216,7 +219,8 @@ class Manager(object):
|
||||
self.session = init_schema(self.db_url)
|
||||
except (SQLAlchemyError, DBAPIError):
|
||||
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
|
||||
)
|
||||
|
||||
|
@ -208,8 +208,7 @@ sup {
|
||||
"""
|
||||
|
||||
|
||||
def build_html(item, screen, islive, background, image=None,
|
||||
plugins=None):
|
||||
def build_html(item, screen, is_live, background, image=None, plugins=None):
|
||||
"""
|
||||
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()
|
||||
height = screen[u'size'].height()
|
||||
theme = item.themedata
|
||||
webkitvers = webkit_version()
|
||||
webkit_ver = webkit_version()
|
||||
# Image generated and poked in
|
||||
if 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()
|
||||
js_additions += plugin.getDisplayJavaScript()
|
||||
html_additions += plugin.getDisplayHtml()
|
||||
html = HTMLSRC % (build_background_css(item, width, height),
|
||||
html = HTMLSRC % (
|
||||
build_background_css(item, width, height),
|
||||
css_additions,
|
||||
build_footer_css(item, height),
|
||||
build_lyrics_css(item, webkitvers),
|
||||
u'true' if theme and theme.display_slide_transition and islive else u'false',
|
||||
build_lyrics_css(item, webkit_ver),
|
||||
u'true' if theme and theme.display_slide_transition and is_live else u'false',
|
||||
js_additions,
|
||||
bgimage_src, image_src,
|
||||
html_additions,
|
||||
build_lyrics_html(item, webkitvers))
|
||||
build_lyrics_html(item, webkit_ver)
|
||||
)
|
||||
return html
|
||||
|
||||
|
||||
@ -272,11 +273,11 @@ def webkit_version():
|
||||
Note method added relatively recently, so return 0 if prior to this
|
||||
"""
|
||||
try:
|
||||
webkitvers = float(QtWebKit.qWebKitVersion())
|
||||
log.debug(u'Webkit version = %s' % webkitvers)
|
||||
webkit_ver = float(QtWebKit.qWebKitVersion())
|
||||
log.debug(u'Webkit version = %s' % webkit_ver)
|
||||
except AttributeError:
|
||||
webkitvers = 0
|
||||
return webkitvers
|
||||
webkit_ver = 0
|
||||
return webkit_ver
|
||||
|
||||
|
||||
def build_background_css(item, width, height):
|
||||
@ -314,7 +315,7 @@ def build_background_css(item, width, height):
|
||||
return background
|
||||
|
||||
|
||||
def build_lyrics_css(item, webkitvers):
|
||||
def build_lyrics_css(item, webkit_ver):
|
||||
"""
|
||||
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
|
||||
# webkit-text-stroke was used. So use an offset text layer underneath.
|
||||
# https://bugs.webkit.org/show_bug.cgi?id=19728
|
||||
if webkitvers >= 533.3:
|
||||
if webkit_ver >= 533.3:
|
||||
lyricsmain += build_lyrics_outline_css(theme)
|
||||
else:
|
||||
outline = build_lyrics_outline_css(theme)
|
||||
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;' % \
|
||||
(int(theme.font_main_shadow_size) + (int(theme.font_main_outline_size) * 2),
|
||||
theme.font_main_shadow_size)
|
||||
|
@ -57,13 +57,13 @@ class ImageThread(QtCore.QThread):
|
||||
The image manager.
|
||||
"""
|
||||
QtCore.QThread.__init__(self, None)
|
||||
self.imageManager = manager
|
||||
self.image_manager = manager
|
||||
|
||||
def run(self):
|
||||
"""
|
||||
Run the thread.
|
||||
"""
|
||||
self.imageManager._process()
|
||||
self.image_manager._process()
|
||||
|
||||
|
||||
class Priority(object):
|
||||
@ -189,74 +189,74 @@ class ImageManager(QtCore.QObject):
|
||||
|
||||
def __init__(self):
|
||||
"""
|
||||
Consutructor for the image manager.
|
||||
Constructor for the image manager.
|
||||
"""
|
||||
QtCore.QObject.__init__(self)
|
||||
Registry().register(u'image_manager', self)
|
||||
currentScreen = ScreenList().current
|
||||
self.width = currentScreen[u'size'].width()
|
||||
self.height = currentScreen[u'size'].height()
|
||||
current_screen = ScreenList().current
|
||||
self.width = current_screen[u'size'].width()
|
||||
self.height = current_screen[u'size'].height()
|
||||
self._cache = {}
|
||||
self.imageThread = ImageThread(self)
|
||||
self._conversionQueue = PriorityQueue()
|
||||
self.stopManager = False
|
||||
QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'config_updated'), self.processUpdates)
|
||||
self.image_thread = ImageThread(self)
|
||||
self._conversion_queue = PriorityQueue()
|
||||
self.stop_manager = False
|
||||
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.
|
||||
"""
|
||||
log.debug(u'updateDisplay')
|
||||
currentScreen = ScreenList().current
|
||||
self.width = currentScreen[u'size'].width()
|
||||
self.height = currentScreen[u'size'].height()
|
||||
log.debug(u'update_display')
|
||||
current_screen = ScreenList().current
|
||||
self.width = current_screen[u'size'].width()
|
||||
self.height = current_screen[u'size'].height()
|
||||
# Mark the images as dirty for a rebuild by setting the image and byte
|
||||
# stream to None.
|
||||
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.
|
||||
"""
|
||||
log.debug(u'updateImages')
|
||||
log.debug(u'update_images_border')
|
||||
# Mark the images as dirty for a rebuild by setting the image and byte
|
||||
# stream to None.
|
||||
for image in self._cache.values():
|
||||
if image.source == source:
|
||||
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.
|
||||
"""
|
||||
log.debug(u'updateImage')
|
||||
log.debug(u'update_image_border')
|
||||
# Mark the image as dirty for a rebuild by setting the image and byte
|
||||
# stream to None.
|
||||
image = self._cache[(path, source)]
|
||||
if image.source == source:
|
||||
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``
|
||||
and ``image_bytes`` attributes to None.
|
||||
"""
|
||||
image.image = 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
|
||||
"""
|
||||
# We want only one thread.
|
||||
if not self.imageThread.isRunning():
|
||||
self.imageThread.start()
|
||||
if not self.image_thread.isRunning():
|
||||
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
|
||||
background thread to process it.
|
||||
@ -264,9 +264,9 @@ class ImageManager(QtCore.QObject):
|
||||
log.debug(u'getImage %s' % path)
|
||||
image = self._cache[(path, source)]
|
||||
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
|
||||
self.processUpdates()
|
||||
self.process_updates()
|
||||
while image.image is None:
|
||||
log.debug(u'getImage - waiting')
|
||||
time.sleep(0.1)
|
||||
@ -275,74 +275,74 @@ class ImageManager(QtCore.QObject):
|
||||
# byte stream was not generated yet. However, we only need to do
|
||||
# this, when the image was generated before it was requested
|
||||
# (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
|
||||
|
||||
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
|
||||
background thread to process it.
|
||||
"""
|
||||
log.debug(u'getImageBytes %s' % path)
|
||||
log.debug(u'get_image_bytes %s' % path)
|
||||
image = self._cache[(path, source)]
|
||||
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
|
||||
self.processUpdates()
|
||||
self.process_updates()
|
||||
while image.image_bytes is None:
|
||||
log.debug(u'getImageBytes - waiting')
|
||||
time.sleep(0.1)
|
||||
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.
|
||||
"""
|
||||
log.debug(u'addImage %s' % path)
|
||||
log.debug(u'add_image %s' % path)
|
||||
if not (path, source) in self._cache:
|
||||
image = Image(path, source, background)
|
||||
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
|
||||
# timestamp has changed.
|
||||
for image in self._cache.values():
|
||||
if os.path.exists(path):
|
||||
if image.path == path and 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.
|
||||
if not self.imageThread.isRunning():
|
||||
self.imageThread.start()
|
||||
if not self.image_thread.isRunning():
|
||||
self.image_thread.start()
|
||||
|
||||
def _process(self):
|
||||
"""
|
||||
Controls the processing called from a ``QtCore.QThread``.
|
||||
"""
|
||||
log.debug(u'_process - started')
|
||||
while not self._conversionQueue.empty() and not self.stopManager:
|
||||
self._processCache()
|
||||
while not self._conversion_queue.empty() and not self.stop_manager:
|
||||
self._process_cache()
|
||||
log.debug(u'_process - ended')
|
||||
|
||||
def _processCache(self):
|
||||
def _process_cache(self):
|
||||
"""
|
||||
Actually does the work.
|
||||
"""
|
||||
log.debug(u'_processCache')
|
||||
image = self._conversionQueue.get()[2]
|
||||
image = self._conversion_queue.get()[2]
|
||||
# Generate the QImage for the image.
|
||||
if image.image is None:
|
||||
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
|
||||
# more important images first.
|
||||
if image.priority == Priority.Normal:
|
||||
self._conversionQueue.modify_priority(image, Priority.Lowest)
|
||||
self._conversion_queue.modify_priority(image, Priority.Lowest)
|
||||
return
|
||||
# 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
|
||||
# Normal priority. We stop here as we need to process more important
|
||||
# images first.
|
||||
elif image.priority == Priority.High:
|
||||
self._conversionQueue.modify_priority(image, Priority.Low)
|
||||
self._conversion_queue.modify_priority(image, Priority.Low)
|
||||
return
|
||||
# Generate the byte stream for the image.
|
||||
if image.image_bytes is None:
|
||||
|
@ -136,7 +136,7 @@ class Renderer(object):
|
||||
theme_data, main_rect, footer_rect = self._theme_dimensions[theme_name]
|
||||
# if No file do not update cache
|
||||
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))
|
||||
|
||||
def pre_render(self, override_theme_data=None):
|
||||
@ -238,7 +238,7 @@ class Renderer(object):
|
||||
serviceItem.raw_footer = FOOTER
|
||||
# if No file do not update cache
|
||||
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))
|
||||
theme_data, main, footer = self.pre_render(theme_data)
|
||||
@ -661,4 +661,4 @@ class Renderer(object):
|
||||
self._theme_manager = Registry().get(u'theme_manager')
|
||||
return self._theme_manager
|
||||
|
||||
theme_manager = property(_get_theme_manager)
|
||||
theme_manager = property(_get_theme_manager)
|
||||
|
@ -293,7 +293,7 @@ class ServiceItem(object):
|
||||
self.image_border = background
|
||||
self.service_item_type = ServiceItemType.Image
|
||||
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()
|
||||
|
||||
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')
|
||||
return self._image_manager
|
||||
|
||||
image_manager = property(_get_image_manager)
|
||||
image_manager = property(_get_image_manager)
|
||||
|
@ -292,7 +292,7 @@ class MainDisplay(Display):
|
||||
"""
|
||||
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'):
|
||||
return False
|
||||
self.override[u'image'] = path
|
||||
@ -314,7 +314,7 @@ class MainDisplay(Display):
|
||||
re-added to the image manager.
|
||||
"""
|
||||
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.displayImage(image)
|
||||
|
||||
@ -395,16 +395,16 @@ class MainDisplay(Display):
|
||||
self.override = {}
|
||||
else:
|
||||
# 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 ==
|
||||
BackgroundType.to_string(BackgroundType.Transparent))
|
||||
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,
|
||||
ImageSource.Theme
|
||||
)
|
||||
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:
|
||||
image_bytes = None
|
||||
html = build_html(self.serviceItem, self.screen, self.isLive, background, image_bytes,
|
||||
|
@ -644,17 +644,17 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow):
|
||||
self.setViewMode(False, True, False, False, True)
|
||||
self.modeLiveItem.setChecked(True)
|
||||
|
||||
def appStartup(self):
|
||||
def app_startup(self):
|
||||
"""
|
||||
Give all the plugins a chance to perform some tasks at startup
|
||||
"""
|
||||
Receiver.send_message(u'openlp_process_events')
|
||||
for plugin in self.pluginManager.plugins:
|
||||
if plugin.isActive():
|
||||
plugin.appStartup()
|
||||
plugin.app_startup()
|
||||
Receiver.send_message(u'openlp_process_events')
|
||||
|
||||
def firstTime(self):
|
||||
def first_time(self):
|
||||
"""
|
||||
Import themes if first time
|
||||
"""
|
||||
@ -662,7 +662,7 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow):
|
||||
for plugin in self.pluginManager.plugins:
|
||||
if hasattr(plugin, u'firstTime'):
|
||||
Receiver.send_message(u'openlp_process_events')
|
||||
plugin.firstTime()
|
||||
plugin.first_time()
|
||||
Receiver.send_message(u'openlp_process_events')
|
||||
temp_dir = os.path.join(unicode(gettempdir()), u'openlp')
|
||||
shutil.rmtree(temp_dir, True)
|
||||
@ -690,7 +690,7 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow):
|
||||
firstTime.exec_()
|
||||
if firstTime.downloadCancelled:
|
||||
return
|
||||
self.firstTime()
|
||||
self.first_time()
|
||||
for plugin in self.pluginManager.plugins:
|
||||
self.activePlugin = plugin
|
||||
oldStatus = self.activePlugin.status
|
||||
@ -698,7 +698,7 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow):
|
||||
if oldStatus != self.activePlugin.status:
|
||||
if self.activePlugin.status == PluginStatus.Active:
|
||||
self.activePlugin.toggleStatus(PluginStatus.Active)
|
||||
self.activePlugin.appStartup()
|
||||
self.activePlugin.app_startup()
|
||||
else:
|
||||
self.activePlugin.toggleStatus(PluginStatus.Inactive)
|
||||
self.themeManagerContents.configUpdated()
|
||||
@ -1004,7 +1004,7 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow):
|
||||
"""
|
||||
log.debug(u'screenChanged')
|
||||
Receiver.send_message(u'cursor_busy')
|
||||
self.imageManager.updateDisplay()
|
||||
self.imageManager.update_display()
|
||||
self.renderer.update_display()
|
||||
self.previewController.screenSizeChanged()
|
||||
self.liveController.screenSizeChanged()
|
||||
@ -1060,8 +1060,8 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow):
|
||||
``save_settings``
|
||||
Switch to prevent saving settings. Defaults to **True**.
|
||||
"""
|
||||
self.imageManager.stopManager = True
|
||||
while self.imageManager.imageThread.isRunning():
|
||||
self.imageManager.stop_manager = True
|
||||
while self.imageManager.image_thread.isRunning():
|
||||
time.sleep(0.1)
|
||||
# Clean temporary files used by services
|
||||
self.serviceManagerContents.cleanUp()
|
||||
|
@ -144,7 +144,7 @@ class PluginForm(QtGui.QDialog, Ui_PluginViewDialog):
|
||||
Receiver.send_message(u'cursor_busy')
|
||||
self.activePlugin.toggleStatus(PluginStatus.Active)
|
||||
Receiver.send_message(u'cursor_normal')
|
||||
self.activePlugin.appStartup()
|
||||
self.activePlugin.app_startup()
|
||||
else:
|
||||
self.activePlugin.toggleStatus(PluginStatus.Inactive)
|
||||
status_text = translate('OpenLP.PluginForm', '%s (Inactive)')
|
||||
|
@ -819,9 +819,9 @@ class SlideController(DisplayController):
|
||||
else:
|
||||
# If current slide set background to image
|
||||
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)
|
||||
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))
|
||||
self.previewListWidget.setCellWidget(framenumber, 0, label)
|
||||
slideHeight = width * (1 / self.ratio)
|
||||
@ -1395,4 +1395,4 @@ class SlideController(DisplayController):
|
||||
self._live_controller = Registry().get(u'live_controller')
|
||||
return self._live_controller
|
||||
|
||||
live_controller = property(_get_live_controller)
|
||||
live_controller = property(_get_live_controller)
|
||||
|
@ -638,9 +638,9 @@ class ThemeManager(QtGui.QWidget):
|
||||
"""
|
||||
self._writeTheme(theme, image_from, image_to)
|
||||
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))
|
||||
self.image_manager.processUpdates()
|
||||
self.image_manager.process_updates()
|
||||
|
||||
def _writeTheme(self, theme, image_from, image_to):
|
||||
"""
|
||||
|
@ -349,7 +349,7 @@ class BibleMediaItem(MediaManagerItem):
|
||||
self.loadBibles()
|
||||
# If called from first time wizard re-run, process any new bibles.
|
||||
if process:
|
||||
self.plugin.appStartup()
|
||||
self.plugin.app_startup()
|
||||
self.updateAutoCompleter()
|
||||
|
||||
def initialiseAdvancedBible(self, bible, last_book_id=None):
|
||||
|
@ -98,4 +98,4 @@ class ImagePlugin(Plugin):
|
||||
last part of saving the config.
|
||||
"""
|
||||
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)
|
||||
|
Loading…
Reference in New Issue
Block a user