This commit is contained in:
Tim Bentley 2018-12-21 15:42:12 +00:00
parent 7be849681a
commit 3bfa92cd47
3 changed files with 25 additions and 23 deletions

View File

@ -193,8 +193,8 @@ class ListPreviewWidget(QtWidgets.QTableWidget, RegistryProperties):
if self.service_item.is_capable(ItemCapabilities.HasThumbnails):
image = self.image_manager.get_image(frame['image'], ImageSource.CommandPlugins)
pixmap = QtGui.QPixmap.fromImage(image)
# else:
# pixmap = frame['image'].pixmap(80, 80)
else:
pixmap = frame['image'].pixmap(80, 80)
else:
image = self.image_manager.get_image(frame['path'], ImageSource.ImagePlugin)
pixmap = QtGui.QPixmap.fromImage(image)

View File

@ -34,9 +34,8 @@ from openlp.core.common.registry import Registry
from openlp.core.common.settings import Settings
from openlp.core.lib import MediaType, ServiceItemContext, check_item_selected
from openlp.core.lib.mediamanageritem import MediaManagerItem
from openlp.core.lib.serviceitem import ItemCapabilities, ServiceItem
from openlp.core.lib.ui import create_widget_action, critical_error_message_box, create_horizontal_adjusting_combo_box
from openlp.core.ui import DisplayControllerType
from openlp.core.lib.serviceitem import ItemCapabilities
from openlp.core.lib.ui import critical_error_message_box
from openlp.core.ui.icons import UiIcons
from openlp.core.ui.media import parse_optical_path, format_milliseconds
from openlp.core.ui.media.vlcplayer import get_vlc

View File

@ -32,6 +32,9 @@ from PyQt5 import QtGui
from openlp.core.common.i18n import UiStrings
from openlp.core.lib import ImageSource
from openlp.core.widgets.views import ListPreviewWidget, ListWidgetWithDnD, TreeWidgetWithDnD, handle_mime_data_urls
from openlp.core.ui.icons import UiIcons
CLAPPERBOARD = UiIcons().clapperboard
class TestHandleMimeDataUrls(TestCase):
@ -148,16 +151,16 @@ class TestListPreviewWidget(TestCase):
mocked_img_service_item.is_media.return_value = False
mocked_img_service_item.is_command.return_value = False
mocked_img_service_item.is_capable.return_value = False
mocked_img_service_item.get_frames.return_value = [{'title': None, 'path': 'TEST1', 'image': 'FAIL'},
{'title': None, 'path': 'TEST2', 'image': 'FAIL'}]
mocked_img_service_item.get_frames.return_value = [{'title': None, 'path': 'TEST1', 'image': CLAPPERBOARD},
{'title': None, 'path': 'TEST2', 'image': CLAPPERBOARD}]
# Mock Command service item
mocked_cmd_service_item = MagicMock()
mocked_cmd_service_item.is_text.return_value = False
mocked_cmd_service_item.is_media.return_value = False
mocked_cmd_service_item.is_command.return_value = True
mocked_cmd_service_item.is_capable.return_value = True
mocked_cmd_service_item.get_frames.return_value = [{'title': None, 'path': 'FAIL', 'image': 'TEST3'},
{'title': None, 'path': 'FAIL', 'image': 'TEST4'}]
mocked_cmd_service_item.get_frames.return_value = [{'title': None, 'path': 'FAIL', 'image': CLAPPERBOARD},
{'title': None, 'path': 'FAIL', 'image': CLAPPERBOARD}]
# Mock image_manager
mocked_image_manager.get_image.return_value = QtGui.QImage()
@ -223,8 +226,8 @@ class TestListPreviewWidget(TestCase):
service_item = MagicMock()
service_item.is_text.return_value = False
service_item.is_capable.return_value = False
service_item.get_frames.return_value = [{'title': None, 'path': None, 'image': None},
{'title': None, 'path': None, 'image': None}]
service_item.get_frames.return_value = [{'title': None, 'path': None, 'image': CLAPPERBOARD},
{'title': None, 'path': None, 'image': CLAPPERBOARD}]
# init ListPreviewWidget and load service item
list_preview_widget = ListPreviewWidget(None, 1)
list_preview_widget.replace_service_item(service_item, 200, 0)
@ -260,8 +263,8 @@ class TestListPreviewWidget(TestCase):
service_item = MagicMock()
service_item.is_text.return_value = False
service_item.is_capable.return_value = False
service_item.get_frames.return_value = [{'title': None, 'path': None, 'image': None},
{'title': None, 'path': None, 'image': None}]
service_item.get_frames.return_value = [{'title': None, 'path': None, 'image': CLAPPERBOARD},
{'title': None, 'path': None, 'image': CLAPPERBOARD}]
# init ListPreviewWidget and load service item
list_preview_widget = ListPreviewWidget(None, 1)
list_preview_widget.replace_service_item(service_item, 200, 0)
@ -296,8 +299,8 @@ class TestListPreviewWidget(TestCase):
service_item = MagicMock()
service_item.is_text.return_value = False
service_item.is_capable.return_value = False
service_item.get_frames.return_value = [{'title': None, 'path': None, 'image': None},
{'title': None, 'path': None, 'image': None}]
service_item.get_frames.return_value = [{'title': None, 'path': None, 'image': CLAPPERBOARD},
{'title': None, 'path': None, 'image': CLAPPERBOARD}]
# init ListPreviewWidget and load service item
list_preview_widget = ListPreviewWidget(None, 1)
list_preview_widget.replace_service_item(service_item, 200, 0)
@ -333,8 +336,8 @@ class TestListPreviewWidget(TestCase):
# Mock text service item
service_item = MagicMock()
service_item.is_text.return_value = True
service_item.get_frames.return_value = [{'title': None, 'text': None, 'verseTag': None},
{'title': None, 'text': None, 'verseTag': None}]
service_item.get_frames.return_value = [{'title': None, 'text': None, 'verseTag': CLAPPERBOARD},
{'title': None, 'text': None, 'verseTag': CLAPPERBOARD}]
# Mock self.cellWidget().children().setMaximumWidth()
mocked_cellWidget_child = MagicMock()
mocked_cellWidget_obj = MagicMock()
@ -368,8 +371,8 @@ class TestListPreviewWidget(TestCase):
service_item = MagicMock()
service_item.is_text.return_value = False
service_item.is_capable.return_value = False
service_item.get_frames.return_value = [{'title': None, 'path': None, 'image': None},
{'title': None, 'path': None, 'image': None}]
service_item.get_frames.return_value = [{'title': None, 'path': None, 'image': CLAPPERBOARD},
{'title': None, 'path': None, 'image': CLAPPERBOARD}]
# Mock self.cellWidget().children().setMaximumWidth()
mocked_cellWidget_child = MagicMock()
mocked_cellWidget_obj = MagicMock()
@ -405,8 +408,8 @@ class TestListPreviewWidget(TestCase):
service_item = MagicMock()
service_item.is_text.return_value = False
service_item.is_capable.return_value = False
service_item.get_frames.return_value = [{'title': None, 'path': None, 'image': None},
{'title': None, 'path': None, 'image': None}]
service_item.get_frames.return_value = [{'title': None, 'path': None, 'image': CLAPPERBOARD},
{'title': None, 'path': None, 'image': CLAPPERBOARD}]
# Mock self.cellWidget().children().setMaximumWidth()
mocked_cellWidget_child = MagicMock()
mocked_cellWidget_obj = MagicMock()
@ -440,8 +443,8 @@ class TestListPreviewWidget(TestCase):
service_item = MagicMock()
service_item.is_text.return_value = False
service_item.is_capable.return_value = False
service_item.get_frames.return_value = [{'title': None, 'path': None, 'image': None},
{'title': None, 'path': None, 'image': None}]
service_item.get_frames.return_value = [{'title': None, 'path': None, 'image': CLAPPERBOARD},
{'title': None, 'path': None, 'image': CLAPPERBOARD}]
# Mock self.cellWidget().children()
mocked_cellWidget_obj = MagicMock()
mocked_cellWidget_obj.children.return_value = None