forked from openlp/openlp
Fixed loading and viewing presentations.
This commit is contained in:
parent
bf06411b93
commit
055d165830
@ -321,6 +321,52 @@ var Display = {
|
||||
Display._slides['0'] = 0;
|
||||
Display.reinit();
|
||||
},
|
||||
/**
|
||||
* Set fullscreen image from path
|
||||
* @param {string} bg_color - The background color
|
||||
* @param {string} image - Path to the image
|
||||
*/
|
||||
setFullscreenImage: function(bg_color, image) {
|
||||
Display.clearSlides();
|
||||
var globalBackground = $("#global-background")[0];
|
||||
globalBackground.style.cssText = "";
|
||||
globalBackground.style.setProperty("background", bg_color);
|
||||
var slidesDiv = $(".slides")[0];
|
||||
var section = document.createElement("section");
|
||||
section.setAttribute("id", 0);
|
||||
section.setAttribute("data-background", bg_color);
|
||||
section.setAttribute("style", "height: 100%; width: 100%;");
|
||||
var img = document.createElement('img');
|
||||
img.src = image;
|
||||
img.setAttribute("style", "height: 100%; width: 100%");
|
||||
section.appendChild(img);
|
||||
slidesDiv.appendChild(section);
|
||||
Display._slides['0'] = 0;
|
||||
Display.reinit();
|
||||
},
|
||||
/**
|
||||
* Set fullscreen image from base64 data
|
||||
* @param {string} bg_color - The background color
|
||||
* @param {string} image - Path to the image
|
||||
*/
|
||||
setFullscreenImageFromData: function(bg_color, image_data) {
|
||||
Display.clearSlides();
|
||||
var globalBackground = $("#global-background")[0];
|
||||
globalBackground.style.cssText = "";
|
||||
globalBackground.style.setProperty("background", bg_color);
|
||||
var slidesDiv = $(".slides")[0];
|
||||
var section = document.createElement("section");
|
||||
section.setAttribute("id", 0);
|
||||
section.setAttribute("data-background", bg_color);
|
||||
section.setAttribute("style", "height: 100%; width: 100%;");
|
||||
var img = document.createElement('img');
|
||||
img.src = 'data:image/png;base64,' + image_data;
|
||||
img.setAttribute("style", "height: 100%; width: 100%");
|
||||
section.appendChild(img);
|
||||
slidesDiv.appendChild(section);
|
||||
Display._slides['0'] = 0;
|
||||
Display.reinit();
|
||||
},
|
||||
/**
|
||||
* Add a slides. If the slide exists but the HTML is different, update the slide.
|
||||
* @param {string} verse - The verse number, e.g. "v1"
|
||||
|
@ -145,6 +145,12 @@ class DisplayWindow(QtWidgets.QWidget):
|
||||
self.setGeometry(screen.display_geometry)
|
||||
self.screen_number = screen.number
|
||||
|
||||
def set_single_image(self, bg_color, image):
|
||||
self.run_javascript('Display.setFullscreenImage("{bg_color}", "{image}");'.format(bg_color=bg_color, image=image))
|
||||
|
||||
def set_single_image_data(self, bg_color, image_data):
|
||||
self.run_javascript('Display.setFullscreenImageFromData("{bg_color}", "{image_data}");'.format(bg_color=bg_color, image_data=image_data))
|
||||
|
||||
def set_startup_screen(self):
|
||||
bg_color = Settings().value('core/logo background color')
|
||||
image = Settings().value('core/logo file')
|
||||
|
@ -163,7 +163,6 @@ class ServiceItem(RegistryProperties):
|
||||
# Save rendered pages to this dict. In the case that a slide is used twice we can use the pages saved to
|
||||
# the dict instead of rendering them again.
|
||||
previous_pages = {}
|
||||
#for slide in self._raw_frames:
|
||||
for raw_slide in self.slides:
|
||||
verse_tag = raw_slide['verse']
|
||||
if verse_tag in previous_pages and previous_pages[verse_tag][0] == raw_slide:
|
||||
@ -307,17 +306,20 @@ class ServiceItem(RegistryProperties):
|
||||
# If the item should have a display title but this frame doesn't have one, we make one up
|
||||
if self.is_capable(ItemCapabilities.HasDisplayTitle) and not display_title:
|
||||
display_title = translate('OpenLP.ServiceItem',
|
||||
'[slide {frame:d}]').format(frame=len(self._raw_frames) + 1)
|
||||
'[slide {frame:d}]').format(frame=len(self.slides) + 1)
|
||||
# Update image path to match servicemanager location if file was loaded from service
|
||||
if image and not self.has_original_files and self.name == 'presentations':
|
||||
file_location = os.path.join(path, file_name)
|
||||
file_location_hash = md5_hash(file_location.encode('utf-8'))
|
||||
image = os.path.join(str(AppLocation.get_section_data_path(self.name)), 'thumbnails',
|
||||
file_location_hash, ntpath.basename(image))
|
||||
#self.slides.append({'title': file_name, 'image': image, 'path': path,
|
||||
# 'display_title': display_title, 'notes': notes})
|
||||
self.slides.append({'title': file_name, 'image': image, 'path': path,
|
||||
'display_title': display_title, 'notes': notes})
|
||||
if self.is_capable(ItemCapabilities.HasThumbnails):
|
||||
self.image_manager.add_image(image, ImageSource.CommandPlugins, '#000000')
|
||||
'display_title': display_title, 'notes': notes,
|
||||
'thumbnail' : image})
|
||||
#if self.is_capable(ItemCapabilities.HasThumbnails):
|
||||
# self.image_manager.add_image(image, ImageSource.CommandPlugins, '#000000')
|
||||
self._new_item()
|
||||
|
||||
def get_service_repr(self, lite_save):
|
||||
@ -538,7 +540,7 @@ class ServiceItem(RegistryProperties):
|
||||
if self.service_item_type == ServiceItemType.Text:
|
||||
return self._display_frames
|
||||
else:
|
||||
return self._raw_frames
|
||||
return self.slides
|
||||
|
||||
def get_rendered_frame(self, row):
|
||||
"""
|
||||
@ -549,16 +551,16 @@ class ServiceItem(RegistryProperties):
|
||||
if self.service_item_type == ServiceItemType.Text:
|
||||
return self._display_frames[row]['html'].split('\n')[0]
|
||||
elif self.service_item_type == ServiceItemType.Image:
|
||||
return self._raw_frames[row]['path']
|
||||
return self.slides[row]['path']
|
||||
else:
|
||||
return self._raw_frames[row]['image']
|
||||
return self.slides[row]['image']
|
||||
|
||||
def get_frame_title(self, row=0):
|
||||
"""
|
||||
Returns the title of the raw frame
|
||||
"""
|
||||
try:
|
||||
return self._raw_frames[row]['title']
|
||||
return self.slides[row]['title']
|
||||
except IndexError:
|
||||
return ''
|
||||
|
||||
@ -568,7 +570,7 @@ class ServiceItem(RegistryProperties):
|
||||
"""
|
||||
if not frame:
|
||||
try:
|
||||
frame = self._raw_frames[row]
|
||||
frame = self.slides[row]
|
||||
except IndexError:
|
||||
return ''
|
||||
if self.is_image() or self.is_capable(ItemCapabilities.IsOptical):
|
||||
|
@ -36,7 +36,7 @@ from openlp.core.common.registry import Registry, RegistryBase
|
||||
from openlp.core.common.settings import Settings
|
||||
from openlp.core.display.screens import ScreenList
|
||||
from openlp.core.display.window import DisplayWindow
|
||||
from openlp.core.lib import ImageSource, ServiceItemAction
|
||||
from openlp.core.lib import ImageSource, ServiceItemAction, image_to_byte
|
||||
from openlp.core.lib.serviceitem import ItemCapabilities
|
||||
from openlp.core.lib.ui import create_action
|
||||
from openlp.core.ui import DisplayControllerType, HideMode
|
||||
@ -1183,13 +1183,14 @@ class SlideController(QtWidgets.QWidget, LogMixin, RegistryProperties):
|
||||
else:
|
||||
# If not live, use the slide's thumbnail/icon instead
|
||||
image_path = self.service_item.get_rendered_frame(self.selected_row)
|
||||
if self.service_item.is_capable(ItemCapabilities.HasThumbnails):
|
||||
image = self.image_manager.get_image(image_path, ImageSource.CommandPlugins)
|
||||
self.slide_image = QtGui.QPixmap.fromImage(image)
|
||||
else:
|
||||
self.slide_image = QtGui.QPixmap(image_path)
|
||||
self.slide_image.setDevicePixelRatio(self.main_window.devicePixelRatio())
|
||||
self.slide_preview.setPixmap(self.slide_image)
|
||||
#if self.service_item.is_capable(ItemCapabilities.HasThumbnails):
|
||||
# image = self.image_manager.get_image(image_path, ImageSource.CommandPlugins)
|
||||
# self.slide_image = QtGui.QPixmap.fromImage(image)
|
||||
#else:
|
||||
#self.slide_image = QtGui.QPixmap(image_path)
|
||||
#self.slide_image.setDevicePixelRatio(self.main_window.devicePixelRatio())
|
||||
#self.slide_preview.setPixmap(self.slide_image)
|
||||
self.preview_display.set_single_image('#000', image_path)
|
||||
else:
|
||||
self.preview_display.go_to_slide(self.selected_row)
|
||||
self.slide_count += 1
|
||||
@ -1200,11 +1201,13 @@ class SlideController(QtWidgets.QWidget, LogMixin, RegistryProperties):
|
||||
"""
|
||||
win_id = QtWidgets.QApplication.desktop().winId()
|
||||
screen = QtWidgets.QApplication.primaryScreen()
|
||||
rect = self.screens.current['size']
|
||||
rect = ScreenList().current.display_geometry
|
||||
win_image = screen.grabWindow(win_id, rect.x(), rect.y(), rect.width(), rect.height())
|
||||
win_image.setDevicePixelRatio(self.slide_preview.devicePixelRatio())
|
||||
self.slide_preview.setPixmap(win_image)
|
||||
win_image.setDevicePixelRatio(self.preview_display.devicePixelRatio())
|
||||
#self.slide_preview.setPixmap(win_image)
|
||||
self.slide_image = win_image
|
||||
base64_image = image_to_byte(win_image, True)
|
||||
self.preview_display.set_single_image_data('#000', base64_image)
|
||||
|
||||
def on_slide_selected_next_action(self, checked):
|
||||
"""
|
||||
|
@ -240,7 +240,7 @@ class ImpressDocument(PresentationDocument):
|
||||
log.warning('Failed to load presentation {url}'.format(url=url))
|
||||
return False
|
||||
self.presentation = self.document.getPresentation()
|
||||
self.presentation.Display = ScreenList().current['number'] + 1
|
||||
self.presentation.Display = ScreenList().current.number + 1
|
||||
self.control = None
|
||||
self.create_thumbnails()
|
||||
self.create_titles_and_notes()
|
||||
@ -387,7 +387,7 @@ class ImpressDocument(PresentationDocument):
|
||||
self.control.activate()
|
||||
self.goto_slide(1)
|
||||
# Make sure impress doesn't steal focus, unless we're on a single screen setup
|
||||
if len(ScreenList().screen_list) > 1:
|
||||
if len(ScreenList()) > 1:
|
||||
Registry().get('main_window').activateWindow()
|
||||
|
||||
def get_slide_number(self):
|
||||
|
@ -196,7 +196,7 @@ class PowerpointDocument(PresentationDocument):
|
||||
self.presentation = None
|
||||
self.controller.remove_doc(self)
|
||||
# Make sure powerpoint doesn't steal focus, unless we're on a single screen setup
|
||||
if len(ScreenList().screen_list) > 1:
|
||||
if len(ScreenList()) > 1:
|
||||
Registry().get('main_window').activateWindow()
|
||||
|
||||
def is_loaded(self):
|
||||
@ -315,7 +315,7 @@ class PowerpointDocument(PresentationDocument):
|
||||
dpi = win32ui.GetForegroundWindow().GetDC().GetDeviceCaps(88)
|
||||
except win32ui.error:
|
||||
dpi = 96
|
||||
size = ScreenList().current['size']
|
||||
size = ScreenList().current.display_geometry
|
||||
ppt_window = None
|
||||
try:
|
||||
ppt_window = self.presentation.SlideShowSettings.Run()
|
||||
|
Loading…
Reference in New Issue
Block a user