forked from openlp/openlp
Various adjustments, main window starts now, still no canvas.
This commit is contained in:
parent
31826f6962
commit
3094b053ff
@ -22,3 +22,5 @@
|
||||
"""
|
||||
The Display module.
|
||||
"""
|
||||
from .canvas import MainCanvas, Canvas, DisplayControllerType
|
||||
from .renderer import Renderer
|
@ -30,6 +30,7 @@ Some of the code for this form is based on the examples at:
|
||||
"""
|
||||
|
||||
import html
|
||||
import json
|
||||
import logging
|
||||
import os
|
||||
|
||||
@ -113,6 +114,8 @@ class Canvas(QtWidgets.QGraphicsView):
|
||||
self.webview = WebEngineView(self)
|
||||
self.webview.setGeometry(0, 0, self.screen['size'].width(), self.screen['size'].height())
|
||||
self.webview.settings().setAttribute(QtWebEngineWidgets.QWebEngineSettings.PluginsEnabled, True)
|
||||
self.layout = QtWidgets.QVBoxLayout(self)
|
||||
self.layout.setContentsMargins(0, 0, 0, 0)
|
||||
self.layout.addWidget(self.webview)
|
||||
self.webview.loadFinished.connect(self.after_loaded)
|
||||
self.set_url(QtCore.QUrl('file://' + os.getcwd() + '/display.html'))
|
||||
@ -124,12 +127,6 @@ class Canvas(QtWidgets.QGraphicsView):
|
||||
self.setVerticalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOff)
|
||||
self.setHorizontalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOff)
|
||||
|
||||
def after_loaded(self):
|
||||
"""
|
||||
Add stuff after page initialisation
|
||||
"""
|
||||
self.run_javascript('Display.init();')
|
||||
|
||||
def resizeEvent(self, event):
|
||||
"""
|
||||
React to resizing of this display
|
||||
@ -159,7 +156,7 @@ class Canvas(QtWidgets.QGraphicsView):
|
||||
"""
|
||||
self.webview.setHtml(html)
|
||||
|
||||
def after_loaded(self):
|
||||
def after_loaded(self, state):
|
||||
"""
|
||||
Add stuff after page initialisation
|
||||
"""
|
||||
@ -359,7 +356,7 @@ class MainCanvas(OpenLPMixin, Canvas, RegistryProperties):
|
||||
splash_image)
|
||||
service_item = ServiceItem()
|
||||
service_item.bg_image_bytes = image_to_byte(self.initial_fame)
|
||||
self.web_view.setHtml(build_html(service_item, self.screen, self.is_live, None,
|
||||
self.webview.setHtml(build_html(service_item, self.screen, self.is_live, None,
|
||||
plugins=self.plugin_manager.plugins))
|
||||
self._hide_mouse()
|
||||
|
||||
@ -374,17 +371,20 @@ class MainCanvas(OpenLPMixin, Canvas, RegistryProperties):
|
||||
while not self.web_loaded:
|
||||
self.application.process_events()
|
||||
self.setGeometry(self.screen['size'])
|
||||
if animate:
|
||||
# NOTE: Verify this works with ''.format()
|
||||
_text = slide.replace('\\', '\\\\').replace('\"', '\\\"')
|
||||
self.frame.evaluateJavaScript('show_text("{text}")'.format(text=_text))
|
||||
else:
|
||||
# This exists for https://bugs.launchpad.net/openlp/+bug/1016843
|
||||
# For unknown reasons if evaluateJavaScript is called
|
||||
# from the themewizard, then it causes a crash on
|
||||
# Windows if there are many items in the service to re-render.
|
||||
# Setting the div elements direct seems to solve the issue
|
||||
self.frame.findFirstElement("#lyricsmain").setInnerXml(slide)
|
||||
json_verses = json.dumps(slide)
|
||||
print(json_verses)
|
||||
self.run_javascript('Display.setTextSlides({verses});'.format(verses=json_verses))
|
||||
#if animate:
|
||||
# # NOTE: Verify this works with ''.format()
|
||||
# _text = slide.replace('\\', '\\\\').replace('\"', '\\\"')
|
||||
# self.frame.evaluateJavaScript('show_text("{text}")'.format(text=_text))
|
||||
#else:
|
||||
# # This exists for https://bugs.launchpad.net/openlp/+bug/1016843
|
||||
# # For unknown reasons if evaluateJavaScript is called
|
||||
# # from the themewizard, then it causes a crash on
|
||||
# # Windows if there are many items in the service to re-render.
|
||||
# # Setting the div elements direct seems to solve the issue
|
||||
# self.frame.findFirstElement("#lyricsmain").setInnerXml(slide)
|
||||
|
||||
def alert(self, text, location):
|
||||
"""
|
||||
@ -402,7 +402,7 @@ class MainCanvas(OpenLPMixin, Canvas, RegistryProperties):
|
||||
else:
|
||||
shrink = False
|
||||
js = 'show_alert("{text}", "")'.format(text=text_prepared)
|
||||
height = self.frame.evaluateJavaScript(js)
|
||||
height = self.run_javascript(js)
|
||||
if shrink:
|
||||
if text:
|
||||
alert_height = int(height)
|
||||
@ -453,11 +453,17 @@ class MainCanvas(OpenLPMixin, Canvas, RegistryProperties):
|
||||
:param image: The image to be displayed
|
||||
"""
|
||||
self.setGeometry(self.screen['size'])
|
||||
if image:
|
||||
js = 'show_image("data:image/png;base64,{image}");'.format(image=image)
|
||||
else:
|
||||
js = 'show_image("");'
|
||||
self.frame.evaluateJavaScript(js)
|
||||
#if image:
|
||||
# self.set_im
|
||||
# js = 'show_image("data:image/png;base64,{image}");'.format(image=image)
|
||||
#else:
|
||||
# js = 'show_image("");'
|
||||
#self.frame.evaluateJavaScript(js)
|
||||
if not image['file'].startswith('file://'):
|
||||
image['file'] = 'file://' + image['file']
|
||||
json_images = json.dumps(images)
|
||||
self.run_javascript('Display.setImageSlides({images});'.format(images=json_images))
|
||||
|
||||
|
||||
def reset_image(self):
|
||||
"""
|
||||
@ -484,7 +490,7 @@ class MainCanvas(OpenLPMixin, Canvas, RegistryProperties):
|
||||
# Wait for the fade to finish before geting the preview.
|
||||
# Important otherwise preview will have incorrect text if at all!
|
||||
if self.service_item.theme_data and self.service_item.theme_data.display_slide_transition:
|
||||
while not self.frame.evaluateJavaScript('show_text_completed()'):
|
||||
while not self.run_javascript('show_text_completed()'):
|
||||
self.application.process_events()
|
||||
# Wait for the webview to update before getting the preview.
|
||||
# Important otherwise first preview will miss the background !
|
||||
@ -540,7 +546,7 @@ class MainCanvas(OpenLPMixin, Canvas, RegistryProperties):
|
||||
image_bytes = self.image_manager.get_image_bytes(image_path, ImageSource.ImagePlugin)
|
||||
created_html = build_html(self.service_item, self.screen, self.is_live, background, image_bytes,
|
||||
plugins=self.plugin_manager.plugins)
|
||||
self.web_view.setHtml(created_html)
|
||||
self.webview.setHtml(created_html)
|
||||
if service_item.foot_text:
|
||||
self.footer(service_item.foot_text)
|
||||
# if was hidden keep it hidden
|
||||
@ -569,7 +575,7 @@ class MainCanvas(OpenLPMixin, Canvas, RegistryProperties):
|
||||
:param text: footer text to be displayed
|
||||
"""
|
||||
js = 'show_footer(\'' + text.replace('\\', '\\\\').replace('\'', '\\\'') + '\')'
|
||||
self.frame.evaluateJavaScript(js)
|
||||
self.run_javascript(js)
|
||||
|
||||
def hide_display(self, mode=HideMode.Screen):
|
||||
"""
|
||||
@ -583,16 +589,16 @@ class MainCanvas(OpenLPMixin, Canvas, RegistryProperties):
|
||||
if not Settings().value('core/display on monitor'):
|
||||
return
|
||||
if mode == HideMode.Screen:
|
||||
self.frame.evaluateJavaScript('show_blank("desktop");')
|
||||
self.run_javascript('show_blank("desktop");')
|
||||
self.setVisible(False)
|
||||
elif mode == HideMode.Blank or self.initial_fame:
|
||||
self.frame.evaluateJavaScript('show_blank("black");')
|
||||
self.run_javascript('show_blank("black");')
|
||||
else:
|
||||
self.frame.evaluateJavaScript('show_blank("theme");')
|
||||
self.run_javascript('show_blank("theme");')
|
||||
if mode != HideMode.Screen:
|
||||
if self.isHidden():
|
||||
self.setVisible(True)
|
||||
self.web_view.setVisible(True)
|
||||
self.webview.setVisible(True)
|
||||
self.hide_mode = mode
|
||||
|
||||
def show_display(self):
|
||||
@ -604,7 +610,7 @@ class MainCanvas(OpenLPMixin, Canvas, RegistryProperties):
|
||||
# Only make visible if setting enabled.
|
||||
if not Settings().value('core/display on monitor'):
|
||||
return
|
||||
self.frame.evaluateJavaScript('show_blank("show");')
|
||||
self.run_javascript('show_blank("show");')
|
||||
# Check if setting for hiding logo on startup is enabled.
|
||||
# If it is, display should remain hidden, otherwise logo is shown. (from def setup)
|
||||
if self.isHidden() and not Settings().value('core/logo hide on startup'):
|
||||
@ -620,10 +626,10 @@ class MainCanvas(OpenLPMixin, Canvas, RegistryProperties):
|
||||
"""
|
||||
if Settings().value('advanced/hide mouse'):
|
||||
self.setCursor(QtCore.Qt.BlankCursor)
|
||||
self.frame.evaluateJavaScript('document.body.style.cursor = "none"')
|
||||
self.run_javascript('document.body.style.cursor = "none"')
|
||||
else:
|
||||
self.setCursor(QtCore.Qt.ArrowCursor)
|
||||
self.frame.evaluateJavaScript('document.body.style.cursor = "auto"')
|
||||
self.run_javascript('document.body.style.cursor = "auto"')
|
||||
|
||||
def change_window_level(self, window):
|
||||
"""
|
||||
|
@ -644,7 +644,6 @@ from .settingstab import SettingsTab
|
||||
from .serviceitem import ServiceItem, ServiceItemType, ItemCapabilities
|
||||
from .htmlbuilder import build_html, build_lyrics_format_css, build_lyrics_outline_css, build_chords_css
|
||||
from .imagemanager import ImageManager
|
||||
from .renderer import Renderer
|
||||
from .mediamanageritem import MediaManagerItem
|
||||
from .projector.db import ProjectorDB, Projector
|
||||
from .projector.pjlink import PJLink
|
||||
|
@ -99,7 +99,6 @@ from .themelayoutform import ThemeLayoutForm
|
||||
from .themeform import ThemeForm
|
||||
from .filerenameform import FileRenameForm
|
||||
from .starttimeform import StartTimeForm
|
||||
from .maindisplay import MainDisplay, Display, AudioPlayer
|
||||
from .servicenoteform import ServiceNoteForm
|
||||
from .serviceitemeditform import ServiceItemEditForm
|
||||
from .slidecontroller import SlideController, DisplayController, PreviewController, LiveController
|
||||
|
@ -41,7 +41,7 @@ from openlp.core.common import Registry, RegistryProperties, AppLocation, Langua
|
||||
from openlp.core.common.actions import ActionList, CategoryOrder
|
||||
from openlp.core.common.path import Path, path_to_str, str_to_path
|
||||
from openlp.core.common.versionchecker import get_application_version
|
||||
from openlp.core.lib import Renderer, PluginManager, ImageManager, PluginStatus, ScreenList, build_icon
|
||||
from openlp.core.lib import PluginManager, ImageManager, PluginStatus, ScreenList, build_icon
|
||||
from openlp.core.lib.ui import create_action
|
||||
from openlp.core.ui import AboutForm, SettingsForm, ServiceManager, ThemeManager, LiveController, PluginForm, \
|
||||
ShortcutListForm, FormattingTagForm, PreviewController
|
||||
@ -52,7 +52,7 @@ from openlp.core.ui.projector.manager import ProjectorManager
|
||||
from openlp.core.ui.lib.dockwidget import OpenLPDockWidget
|
||||
from openlp.core.ui.lib.filedialog import FileDialog
|
||||
from openlp.core.ui.lib.mediadockmanager import MediaDockManager
|
||||
|
||||
from openlp.core.display import Renderer
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
|
@ -38,7 +38,8 @@ from openlp.core.lib import ItemCapabilities, ServiceItem, ImageSource, ServiceI
|
||||
from openlp.core.lib.ui import create_action
|
||||
from openlp.core.ui.lib.toolbar import OpenLPToolbar
|
||||
from openlp.core.ui.lib.listpreviewwidget import ListPreviewWidget
|
||||
from openlp.core.ui import HideMode, MainDisplay, Display, DisplayControllerType
|
||||
from openlp.core.ui import HideMode, DisplayControllerType
|
||||
from openlp.core.display import MainCanvas, Canvas
|
||||
|
||||
|
||||
# Threshold which has to be trespassed to toggle.
|
||||
@ -370,7 +371,7 @@ class SlideController(DisplayController, RegistryProperties):
|
||||
self.slide_layout.setSpacing(0)
|
||||
self.slide_layout.setContentsMargins(0, 0, 0, 0)
|
||||
self.slide_layout.setObjectName('SlideLayout')
|
||||
self.preview_display = Display(self)
|
||||
self.preview_display = Canvas(self)
|
||||
self.slide_layout.insertWidget(0, self.preview_display)
|
||||
self.preview_display.hide()
|
||||
# Actual preview screen
|
||||
@ -580,7 +581,7 @@ class SlideController(DisplayController, RegistryProperties):
|
||||
# rebuild display as screen size changed
|
||||
if self.display:
|
||||
self.display.close()
|
||||
self.display = MainDisplay(self)
|
||||
self.display = MainCanvas(self)
|
||||
self.display.setup()
|
||||
if self.is_live:
|
||||
self.__add_actions_to_widget(self.display)
|
||||
@ -596,7 +597,7 @@ class SlideController(DisplayController, RegistryProperties):
|
||||
self.preview_widget.screen_size_changed(self.ratio)
|
||||
self.preview_display.setup()
|
||||
service_item = ServiceItem()
|
||||
self.preview_display.web_view.setHtml(build_html(service_item, self.preview_display.screen, None, self.is_live,
|
||||
self.preview_display.webview.setHtml(build_html(service_item, self.preview_display.screen, None, self.is_live,
|
||||
plugins=self.plugin_manager.plugins))
|
||||
self.media_controller.setup_display(self.preview_display, True)
|
||||
if self.service_item:
|
||||
|
Loading…
Reference in New Issue
Block a user