forked from openlp/openlp
Remove an unnecessary exception; Notify the user if one of the plugins fails to initialise; Try to make image slides work properly.
This commit is contained in:
parent
af446d31b9
commit
0d0ec8f818
@ -113,7 +113,6 @@ class CategoryActionList(object):
|
||||
if item[1] == action:
|
||||
self.actions.remove(item)
|
||||
return
|
||||
raise ValueError('Action "{action}" does not exist.'.format(action=action))
|
||||
|
||||
|
||||
class CategoryList(object):
|
||||
|
@ -24,8 +24,11 @@ Provide plugin management
|
||||
"""
|
||||
import os
|
||||
|
||||
from PyQt5 import QtWidgets
|
||||
|
||||
from openlp.core.common import extension_loader
|
||||
from openlp.core.common.applocation import AppLocation
|
||||
from openlp.core.common.i18n import UiStrings
|
||||
from openlp.core.common.mixins import LogMixin, RegistryProperties
|
||||
from openlp.core.common.registry import RegistryBase
|
||||
from openlp.core.lib import Plugin, PluginStatus
|
||||
@ -152,12 +155,21 @@ class PluginManager(RegistryBase, LogMixin, RegistryProperties):
|
||||
"""
|
||||
Loop through all the plugins and give them an opportunity to initialise themselves.
|
||||
"""
|
||||
uninitialised_plugins = []
|
||||
for plugin in self.plugins:
|
||||
self.log_info('initialising plugins {plugin} in a {state} state'.format(plugin=plugin.name,
|
||||
state=plugin.is_active()))
|
||||
if plugin.is_active():
|
||||
plugin.initialise()
|
||||
self.log_info('Initialisation Complete for {plugin}'.format(plugin=plugin.name))
|
||||
try:
|
||||
plugin.initialise()
|
||||
self.log_info('Initialisation Complete for {plugin}'.format(plugin=plugin.name))
|
||||
except Exception:
|
||||
uninitialised_plugins.append(plugin.name.title())
|
||||
self.log_exception('Unable to initialise plugin {plugin}'.format(plugin=plugin.name))
|
||||
if uninitialised_plugins:
|
||||
QtWidgets.QMessageBox.critical(None, UiStrings().Error, 'Unable to initialise the following plugins:\n' +
|
||||
'\n'.join(uninitialised_plugins) + '\n\nSee the log file for more details',
|
||||
QtWidgets.QMessageBox.StandardButtons(QtWidgets.QMessageBox.Ok))
|
||||
|
||||
def finalise_plugins(self):
|
||||
"""
|
||||
|
@ -31,7 +31,7 @@ from openlp.core.common.mixins import RegistryProperties
|
||||
from openlp.core.common.path import Path
|
||||
from openlp.core.common.registry import Registry
|
||||
from openlp.core.common.settings import Settings
|
||||
from openlp.core.lib import ImageSource, ItemCapabilities, ServiceItem
|
||||
from openlp.core.lib import ItemCapabilities, ServiceItem
|
||||
from openlp.core.widgets.layouts import AspectRatioLayout
|
||||
|
||||
|
||||
@ -54,6 +54,16 @@ def handle_mime_data_urls(mime_data):
|
||||
return file_paths
|
||||
|
||||
|
||||
def remove_url_prefix(filename):
|
||||
"""
|
||||
Remove the "file://" URL prefix
|
||||
|
||||
:param str filename: The filename that may have a file URL prefix
|
||||
:returns str: The file name without the file URL prefix
|
||||
"""
|
||||
return filename.replace('file://', '')
|
||||
|
||||
|
||||
class ListPreviewWidget(QtWidgets.QTableWidget, RegistryProperties):
|
||||
"""
|
||||
A special type of QTableWidget which lists the slides in the slide controller
|
||||
@ -187,52 +197,28 @@ class ListPreviewWidget(QtWidgets.QTableWidget, RegistryProperties):
|
||||
else:
|
||||
label = QtWidgets.QLabel()
|
||||
label.setContentsMargins(4, 4, 4, 4)
|
||||
if self.service_item.is_media():
|
||||
label.setAlignment(QtCore.Qt.AlignHCenter | QtCore.Qt.AlignVCenter)
|
||||
else:
|
||||
label.setAlignment(QtCore.Qt.AlignCenter)
|
||||
if not self.service_item.is_media():
|
||||
label.setScaledContents(True)
|
||||
if self.service_item.is_command():
|
||||
if self.service_item.is_capable(ItemCapabilities.HasThumbnails):
|
||||
image = self.image_manager.get_image(slide['image'], ImageSource.CommandPlugins)
|
||||
pixmap = QtGui.QPixmap.fromImage(image)
|
||||
pixmap = QtGui.QPixmap(remove_url_prefix(slide['thumbnail']))
|
||||
else:
|
||||
pixmap = QtGui.QPixmap(slide['image'])
|
||||
pixmap = QtGui.QPixmap(remove_url_prefix(slide['image']))
|
||||
else:
|
||||
# image = self.image_manager.get_image(slide['filename'], ImageSource.ImagePlugin)
|
||||
# pixmap = QtGui.QPixmap.fromImage(image)
|
||||
pixmap = QtGui.QPixmap(slide['filename'].replace('file://', ''))
|
||||
# pixmap.setDevicePixelRatio(label.devicePixelRatio())
|
||||
pixmap = QtGui.QPixmap(remove_url_prefix(slide['filename']))
|
||||
label.setPixmap(pixmap)
|
||||
label.setScaledContents(True)
|
||||
label.setAlignment(QtCore.Qt.AlignCenter)
|
||||
container = QtWidgets.QWidget()
|
||||
layout = AspectRatioLayout(container, self.screen_ratio)
|
||||
layout.setContentsMargins(0, 0, 0, 0)
|
||||
layout.addWidget(label)
|
||||
container.setLayout(layout)
|
||||
# slide_height = width // self.screen_ratio
|
||||
# Setup and validate row height cap if in use.
|
||||
# max_img_row_height = Settings().value('advanced/slide max height')
|
||||
# if isinstance(max_img_row_height, int) and max_img_row_height != 0:
|
||||
# if max_img_row_height > 0 and slide_height > max_img_row_height:
|
||||
# # Manual Setting
|
||||
# slide_height = max_img_row_height
|
||||
# elif max_img_row_height < 0 and slide_height > self.auto_row_height:
|
||||
# # Auto Setting
|
||||
# slide_height = self.auto_row_height
|
||||
# label.setMaximumWidth(slide_height * self.screen_ratio)
|
||||
# label.resize(slide_height * self.screen_ratio, slide_height)
|
||||
# # Build widget with stretch padding
|
||||
# container = QtWidgets.QWidget()
|
||||
# hbox = QtWidgets.QHBoxLayout()
|
||||
# hbox.setContentsMargins(0, 0, 0, 0)
|
||||
# hbox.addWidget(label, stretch=1)
|
||||
# hbox.addStretch(0)
|
||||
# container.setLayout(hbox)
|
||||
# # Add to table
|
||||
# self.setCellWidget(slide_index, 0, container)
|
||||
# else:
|
||||
# Add to table
|
||||
slide_height = width // self.screen_ratio
|
||||
max_slide_height = Settings().value('advanced/slide max height')
|
||||
if slide_height < 0:
|
||||
slide_height = max_slide_height
|
||||
else:
|
||||
slide_height = min(slide_height, max_slide_height)
|
||||
self.setCellWidget(slide_index, 0, container)
|
||||
row += 1
|
||||
text.append(str(row))
|
||||
|
Loading…
Reference in New Issue
Block a user