Went back to to the load-into-imagemanager-on-demand approach

This commit is contained in:
Tomas Groth 2014-09-11 11:52:32 +02:00
parent 5dc722e017
commit 5c4be05fc1
5 changed files with 21 additions and 17 deletions

View File

@ -280,7 +280,7 @@ class ImageManager(QtCore.QObject):
"""
Add image to cache if it is not already there.
"""
log.debug('add_image path: %s, source: %s, width: %d, height: %d ' % (path, source, width, height))
log.debug('add_image %s' % path)
if not (path, source, width, height) in self._cache:
image = Image(path, source, background, width, height)
self._cache[(path, source, width, height)] = image

View File

@ -292,7 +292,7 @@ class ServiceItem(RegistryProperties):
:param path: The directory in which the image file is located.
:param title: A title for the slide in the service item.
:param background:
:param thumbnail: Optional thumbnail, used for remote thumbnails.
:param thumbnail: Optional alternative thumbnail, used for remote thumbnails.
"""
if background:
self.image_border = background
@ -302,8 +302,6 @@ class ServiceItem(RegistryProperties):
thumbnail = os.path.join(AppLocation.get_section_data_path('images'), 'thumbnails', os.path.split(path)[1])
create_thumb(path, thumbnail, False)
self._raw_frames.append({'title': title, 'path': path, 'image': thumbnail})
self.image_manager.add_image(thumbnail, ImageSource.ImagePlugin, self.image_border, 88, 88)
self.image_manager.add_image(thumbnail, ImageSource.ImagePlugin, self.image_border, 320, 240)
self.image_manager.add_image(path, ImageSource.ImagePlugin, self.image_border)
self._new_item()

View File

@ -34,7 +34,7 @@ from PyQt4 import QtCore, QtGui
from openlp.core.common import Registry, AppLocation, Settings, UiStrings, check_directory_exists, translate
from openlp.core.lib import ItemCapabilities, MediaManagerItem, ServiceItemContext, StringContent, TreeWidgetWithDnD,\
build_icon, check_item_selected, create_thumb, validate_thumb, ImageSource
build_icon, check_item_selected, create_thumb, validate_thumb
from openlp.core.lib.ui import create_widget_action, critical_error_message_box
from openlp.core.utils import delete_file, get_locale_key, get_images_filter
from openlp.plugins.images.forms import AddGroupForm, ChooseGroupForm
@ -590,8 +590,7 @@ class ImageMediaItem(MediaManagerItem):
# Continue with the existing images.
for filename in images_file_names:
name = os.path.split(filename)[1]
service_item.add_from_image(filename, ImageSource.ImagePlugin, background,
os.path.join(self.service_path, name))
service_item.add_from_image(filename, name, background, os.path.join(self.service_path, name))
return True
def check_group_exists(self, new_group):

View File

@ -90,18 +90,22 @@ window.OpenLP = {
var indexInt = parseInt(idx,10);
var slide = data.results.slides[idx];
var text = slide["tag"];
if (text != "") text = text + ": ";
if (slide["title"])
if (text != "") {
text = text + ": ";
}
if (slide["title"]) {
text += slide["title"]
else
} else {
text += slide["text"];
if (slide["notes"])
}
if (slide["notes"]) {
text += ("<div style='font-size:smaller;font-weight:normal'>" + slide["notes"] + "</div>");
}
text = text.replace(/\n/g, '<br />');
if (slide["img"])
if (slide["img"]) {
text += "<img src='" + slide["img"].replace("/thumbnails/", "/thumbnails88x88/") + "'>";
var li = $("<li data-icon=\"false\">").append(
$("<a href=\"#\">").html(text));
}
var li = $("<li data-icon=\"false\">").append($("<a href=\"#\">").html(text));
if (slide["selected"]) {
li.attr("data-theme", "e");
}

View File

@ -125,7 +125,7 @@ from mako.template import Template
from PyQt4 import QtCore
from openlp.core.common import Registry, RegistryProperties, AppLocation, Settings, translate
from openlp.core.lib import PluginStatus, StringContent, image_to_byte, ItemCapabilities, ImageSource
from openlp.core.lib import PluginStatus, StringContent, image_to_byte, ItemCapabilities
log = logging.getLogger(__name__)
FILE_TYPES = {
@ -406,8 +406,10 @@ class HttpRouter(RegistryProperties):
full_path = os.path.normpath(os.path.join(AppLocation.get_section_data_path(controller_name),
'thumbnails/' + full_path))
if os.path.exists(full_path):
path, just_file_name = os.path.split(full_path)
self.image_manager.add_image(full_path, just_file_name, None, width, height)
ext, content_type = self.get_content_type(full_path)
image = self.image_manager.get_image(full_path, ImageSource.ImagePlugin, width, height)
image = self.image_manager.get_image(full_path, just_file_name, width, height)
content = image_to_byte(image, False)
if len(content) == 0:
return self.do_not_found()
@ -502,7 +504,7 @@ class HttpRouter(RegistryProperties):
item['tag'] = str(index + 1)
item['text'] = str(frame['text'])
item['html'] = str(frame['html'])
# Handle images, unless a thumbnail is given or if thumbnails is disabled
# Handle images, unless a custom thumbnail is given or if thumbnails is disabled
elif current_item.is_image() and not frame.get('image', '') and Settings().value('remotes/thumbnails'):
item['tag'] = str(index + 1)
thumbnail_path = os.path.sep + os.path.join('images', 'thumbnails', frame['title'])
@ -528,6 +530,7 @@ class HttpRouter(RegistryProperties):
item['selected'] = (self.live_controller.selected_row == index)
if current_item.notes:
item['notes'] = item.get('notes', '') + '\n' + current_item.notes
print(item)
data.append(item)
json_data = {'results': {'slides': data}}
if current_item: