Managed to get the page loading, but there are 4 displays where there should only be 2. Confusing

This commit is contained in:
Raoul Snyman 2018-03-24 00:19:06 -07:00
parent df140019cf
commit 7f0d4c635f
10 changed files with 69 additions and 51 deletions

View File

@ -336,6 +336,7 @@ def main(args=None):
:param args: Some args
"""
args = parse_options(args)
# qt_args = ['--disable-web-security']
qt_args = []
if args and args.loglevel.lower() in ['d', 'debug']:
log.setLevel(logging.DEBUG)

View File

@ -14,6 +14,7 @@
<script type="text/javascript" src="qrc:///qtwebchannel/qwebchannel.js"></script>
<script type="text/javascript" src="reveal.js"></script>
<script type="text/javascript" src="display.js"></script>
<script type="text/javascript">console.log(Display);</script>
</head>
<body>
<div class="reveal">

View File

@ -276,7 +276,7 @@ var Display = {
},
/**
* Set text slides.
* @param {Object[]} slides - A list of slides to add as JS objects: {"verse": "v1", "html": "line 1<br>line2"}
* @param {Object[]} slides - A list of slides to add as JS objects: {"verse": "v1", "text": "line 1\nline2"}
*/
setTextSlides: function (slides) {
Display.clearSlides();

View File

@ -45,7 +45,9 @@ class WebEnginePage(QtWebEngineWidgets.QWebEnginePage):
"""
Override the parent method in order to log the messages in OpenLP
"""
log.log(LOG_LEVELS[level], message)
log.log(LOG_LEVELS[level], '{source_id}:{line_number} {message}'.format(source_id=source_id,
line_number=line_number,
message=message))
class WebEngineView(QtWebEngineWidgets.QWebEngineView):
@ -61,6 +63,12 @@ class WebEngineView(QtWebEngineWidgets.QWebEngineView):
"""
super(WebEngineView, self).__init__(parent)
self.setPage(WebEnginePage(self))
self.settings().setAttribute(QtWebEngineWidgets.QWebEngineSettings.LocalStorageEnabled, True)
self.settings().setAttribute(QtWebEngineWidgets.QWebEngineSettings.LocalContentCanAccessFileUrls, True)
self.settings().setAttribute(QtWebEngineWidgets.QWebEngineSettings.LocalContentCanAccessRemoteUrls, True)
self.page().settings().setAttribute(QtWebEngineWidgets.QWebEngineSettings.LocalStorageEnabled, True)
self.page().settings().setAttribute(QtWebEngineWidgets.QWebEngineSettings.LocalContentCanAccessFileUrls, True)
self.page().settings().setAttribute(QtWebEngineWidgets.QWebEngineSettings.LocalContentCanAccessRemoteUrls, True)
def eventFilter(self, obj, ev):
"""

View File

@ -25,12 +25,13 @@ The :mod:`~openlp.core.display.window` module contains the display window
import logging
import os
import json
from pathlib import Path
from PyQt5 import QtCore, QtWidgets, QtWebChannel
from openlp.core.common.path import Path, path_to_str
log = logging.getLogger(__name__)
DISPLAY_PATH = Path(__file__) / 'html' / 'display.html'
DISPLAY_PATH = Path(__file__).parent / 'html' / 'display.html'
class MediaWatcher(QtCore.QObject):
@ -114,7 +115,7 @@ class DisplayWindow(QtWidgets.QWidget):
self.webview = WebEngineView(self)
self.layout.addWidget(self.webview)
self.webview.loadFinished.connect(self.after_loaded)
self.set_url(QtCore.QUrl('file://' + os.getcwd() + '/display.html'))
self.set_url(QtCore.QUrl.fromLocalFile(path_to_str(DISPLAY_PATH)))
self.media_watcher = MediaWatcher(self)
self.channel = QtWebChannel.QWebChannel(self)
self.channel.registerObject('mediaWatcher', self.media_watcher)
@ -268,7 +269,6 @@ class DisplayWindow(QtWidgets.QWidget):
"""
Set the theme of the display
"""
print(theme.export_theme())
self.run_javascript('Display.setTheme({theme});'.format(theme=theme.export_theme()))
def get_video_types(self):

View File

@ -247,9 +247,9 @@ class ServiceItem(RegistryProperties):
log.debug('Render called')
self._display_frames = []
self.bg_image_bytes = None
if not provides_own_theme_data:
self.renderer.set_item_theme(self.theme)
self.theme_data, self.main, self.footer = self.renderer.pre_render()
# if not provides_own_theme_data:
# self.renderer.set_item_theme(self.theme)
# self.theme_data, self.main, self.footer = self.renderer.pre_render()
if self.service_item_type == ServiceItemType.Text:
can_render_chords = hasattr(self, 'name') and self.name == 'songs' and Settings().value(
'songs/enable chords')
@ -262,7 +262,7 @@ class ServiceItem(RegistryProperties):
if verse_tag in previous_pages and previous_pages[verse_tag][0] == slide['raw_slide']:
pages = previous_pages[verse_tag][1]
else:
pages = self.renderer.format_slide(slide['raw_slide'], self)
# pages = self.renderer.format_slide(slide['raw_slide'], self)
previous_pages[verse_tag] = (slide['raw_slide'], pages)
for page in pages:
page = page.replace('<br>', '{br}')

View File

@ -283,11 +283,14 @@ class GeneralTab(SettingsTab):
settings = Settings()
settings.beginGroup(self.settings_section)
self.monitor_combo_box.clear()
self.monitor_combo_box.addItems([str(screen) for screen in self.screens])
for screen in self.screens:
self.monitor_combo_box.addItem(str(screen), screen.number)
monitors = settings.value('monitors')
for number, monitor in monitors.items():
if monitor['is_display']:
self.monitor_combo_box.setCurrentIndex(int(number))
for item_index in range(self.monitor_combo_box.count()):
if self.monitor_combo_box.itemData(item_index) == number:
self.monitor_combo_box.setCurrentIndex(item_index)
else:
self.monitor_combo_box.setCurrentIndex(0)
self.number_edit.setText(settings.value('ccli number'))
@ -308,8 +311,8 @@ class GeneralTab(SettingsTab):
self.check_for_updates_check_box.setChecked(settings.value('update check'))
self.auto_preview_check_box.setChecked(settings.value('auto preview'))
self.timeout_spin_box.setValue(settings.value('loop delay'))
self.monitor_radio_button.setChecked(not settings.value('override position',))
self.override_radio_button.setChecked(settings.value('override position'))
# self.monitor_radio_button.setChecked(not settings.value('override position',))
# self.override_radio_button.setChecked(settings.value('override position'))
# self.custom_X_value_edit.setValue(settings.value('x position'))
# self.custom_Y_value_edit.setValue(settings.value('y position'))
# self.custom_height_value_edit.setValue(settings.value('height'))
@ -317,11 +320,11 @@ class GeneralTab(SettingsTab):
self.start_paused_check_box.setChecked(settings.value('audio start paused'))
self.repeat_list_check_box.setChecked(settings.value('audio repeat list'))
settings.endGroup()
self.monitor_combo_box.setDisabled(self.override_radio_button.isChecked())
self.custom_X_value_edit.setEnabled(self.override_radio_button.isChecked())
self.custom_Y_value_edit.setEnabled(self.override_radio_button.isChecked())
self.custom_height_value_edit.setEnabled(self.override_radio_button.isChecked())
self.custom_width_value_edit.setEnabled(self.override_radio_button.isChecked())
# self.monitor_combo_box.setDisabled(self.override_radio_button.isChecked())
# self.custom_X_value_edit.setEnabled(self.override_radio_button.isChecked())
# self.custom_Y_value_edit.setEnabled(self.override_radio_button.isChecked())
# self.custom_height_value_edit.setEnabled(self.override_radio_button.isChecked())
# self.custom_width_value_edit.setEnabled(self.override_radio_button.isChecked())
self.display_changed = False
def save(self):
@ -330,7 +333,7 @@ class GeneralTab(SettingsTab):
"""
settings = Settings()
settings.beginGroup(self.settings_section)
settings.setValue('monitor', self.monitor_combo_box.currentIndex())
# settings.setValue('monitor', self.monitor_combo_box.currentIndex())
settings.setValue('display on monitor', self.display_on_monitor_check.isChecked())
settings.setValue('blank warning', self.warning_check_box.isChecked())
settings.setValue('auto open', self.auto_open_check_box.isChecked())
@ -347,38 +350,38 @@ class GeneralTab(SettingsTab):
settings.setValue('ccli number', self.number_edit.displayText())
settings.setValue('songselect username', self.username_edit.displayText())
settings.setValue('songselect password', self.password_edit.displayText())
settings.setValue('x position', self.custom_X_value_edit.value())
settings.setValue('y position', self.custom_Y_value_edit.value())
settings.setValue('height', self.custom_height_value_edit.value())
settings.setValue('width', self.custom_width_value_edit.value())
settings.setValue('override position', self.override_radio_button.isChecked())
# settings.setValue('x position', self.custom_X_value_edit.value())
# settings.setValue('y position', self.custom_Y_value_edit.value())
# settings.setValue('height', self.custom_height_value_edit.value())
# settings.setValue('width', self.custom_width_value_edit.value())
# settings.setValue('override position', self.override_radio_button.isChecked())
settings.setValue('audio start paused', self.start_paused_check_box.isChecked())
settings.setValue('audio repeat list', self.repeat_list_check_box.isChecked())
settings.endGroup()
# On save update the screens as well
self.post_set_up(True)
def post_set_up(self, postUpdate=False):
def post_set_up(self, is_post_update=False):
"""
Apply settings after settings tab has loaded and most of the system so must be delayed
"""
self.settings_form.register_post_process('slidecontroller_live_spin_delay')
# Do not continue on start up.
if not postUpdate:
if not is_post_update:
return
self.screens.set_current_display(self.monitor_combo_box.currentIndex())
self.screens.display = self.display_on_monitor_check.isChecked()
self.screens.override['size'] = QtCore.QRect(
self.custom_X_value_edit.value(),
self.custom_Y_value_edit.value(),
self.custom_width_value_edit.value(),
self.custom_height_value_edit.value())
self.screens.override['number'] = self.screens.which_screen(self.screens.override['size'])
self.screens.override['primary'] = (self.screens.desktop.primaryScreen() == self.screens.override['number'])
if self.override_radio_button.isChecked():
self.screens.set_override_display()
else:
self.screens.reset_current_display()
self.screens.set_display_screen(self.monitor_combo_box.currentData())
# self.screens.display = self.display_on_monitor_check.isChecked()
# self.screens.override['size'] = QtCore.QRect(
# self.custom_X_value_edit.value(),
# self.custom_Y_value_edit.value(),
# self.custom_width_value_edit.value(),
# self.custom_height_value_edit.value())
# self.screens.override['number'] = self.screens.which_screen(self.screens.override['size'])
# self.screens.override['primary'] = (self.screens.desktop.primaryScreen() == self.screens.override['number'])
# if self.override_radio_button.isChecked():
# self.screens.set_override_display()
# else:
# self.screens.reset_current_display()
if self.display_changed:
self.settings_form.register_post_process('config_screen_changed')
self.display_changed = False

View File

@ -22,7 +22,6 @@
"""
This is the main window, where all the action happens.
"""
import logging
import sys
from datetime import datetime
from distutils import dir_util
@ -1004,7 +1003,7 @@ class MainWindow(QtWidgets.QMainWindow, Ui_MainWindow, LogMixin, RegistryPropert
"""
self.application.set_busy_cursor()
self.image_manager.update_display()
self.renderer.update_display()
# self.renderer.update_display()
self.preview_controller.screen_size_changed()
self.live_controller.screen_size_changed()
self.setFocus()

View File

@ -576,7 +576,7 @@ class SlideController(QtWidgets.QWidget, LogMixin, RegistryProperties):
# rebuild display as screen size changed
if self.displays:
for display in self.displays:
display.resize(self.screens.current['size'])
display.resize(self.screens.current.display_geometry.size())
# if self.is_live:
# self.__add_actions_to_widget(self.display)
# The SlidePreview's ratio.
@ -743,12 +743,17 @@ class SlideController(QtWidgets.QWidget, LogMixin, RegistryProperties):
:param item: The current service item
"""
item.render()
slide_no = 0
if self.song_edit:
slide_no = self.selected_row
self.song_edit = False
self._process_item(item, slide_no)
if item.theme:
self.preview_display.set_theme(item.theme)
if item.is_text():
self.preview_display.load_verses([{'verse': f['verseTag'], 'text': f['raw_slide']}
for f in item._raw_frames])
self.display
# slide_no = 0
# if self.song_edit:
# slide_no = self.selected_row
# self.song_edit = False
# self._process_item(item, slide_no)
def replace_service_manager_item(self, item):
"""
@ -908,7 +913,7 @@ class SlideController(QtWidgets.QWidget, LogMixin, RegistryProperties):
"""
Allow the main display to blank the main display at startup time
"""
display_type = Settings().value(self.main_window.general_settings_section + '/screen blank')
# display_type = Settings().value(self.main_window.general_settings_section + '/screen blank')
# if self.screens.which_screen(self.window()) != self.screens.which_screen(self.display):
# # Order done to handle initial conversion
# if display_type == 'themed':
@ -1510,6 +1515,7 @@ class LiveController(RegistryBase, SlideController):
"""
Set up the base Controller as a live.
"""
self.__registry_name = 'live_controller'
super().__init__(*args, **kwargs)
self.is_live = True
self.split = 1

View File

@ -159,7 +159,7 @@ class ThemesTab(SettingsTab):
settings.setValue('global theme', self.global_theme)
settings.setValue('wrap footer', self.wrap_footer_check_box.isChecked())
settings.endGroup()
self.renderer.set_theme_level(self.theme_level)
# self.renderer.set_theme_level(self.theme_level)
if self.tab_visited:
self.settings_form.register_post_process('theme_update_global')
self.tab_visited = False