forked from openlp/openlp
Merge branch 'bug_fixes' into 'master'
Bug fixes for beta1 Closes #588, #662, #663, and #664 See merge request openlp/openlp!233
This commit is contained in:
commit
35c56cecdb
@ -701,6 +701,8 @@ var Display = {
|
|||||||
var html = _prepareText(text);
|
var html = _prepareText(text);
|
||||||
slide = document.createElement("section");
|
slide = document.createElement("section");
|
||||||
slide.setAttribute("id", verse);
|
slide.setAttribute("id", verse);
|
||||||
|
// The "future" class is used internally by reveal, it's used here to hide newly added slides
|
||||||
|
slide.classList.add("future");
|
||||||
slide.innerHTML = html;
|
slide.innerHTML = html;
|
||||||
return slide;
|
return slide;
|
||||||
},
|
},
|
||||||
|
@ -27,7 +27,6 @@ import mako
|
|||||||
import math
|
import math
|
||||||
import os
|
import os
|
||||||
import re
|
import re
|
||||||
import time
|
|
||||||
|
|
||||||
from PyQt5 import QtWidgets, QtGui
|
from PyQt5 import QtWidgets, QtGui
|
||||||
|
|
||||||
@ -823,12 +822,9 @@ class ThemePreviewRenderer(DisplayWindow, LogMixin):
|
|||||||
Save a screenshot, either returning it or saving it to file. Do some extra work to actually get a picture.
|
Save a screenshot, either returning it or saving it to file. Do some extra work to actually get a picture.
|
||||||
"""
|
"""
|
||||||
self.setVisible(True)
|
self.setVisible(True)
|
||||||
|
QtWidgets.QApplication.instance().processEvents()
|
||||||
|
wait_for(lambda: False, timeout=1)
|
||||||
pixmap = self.grab()
|
pixmap = self.grab()
|
||||||
for i in range(0, 4):
|
|
||||||
QtWidgets.QApplication.instance().processEvents()
|
|
||||||
time.sleep(0.05)
|
|
||||||
QtWidgets.QApplication.instance().processEvents()
|
|
||||||
pixmap = self.grab()
|
|
||||||
self.setVisible(False)
|
self.setVisible(False)
|
||||||
pixmap = QtGui.QPixmap(self.webview.size())
|
pixmap = QtGui.QPixmap(self.webview.size())
|
||||||
self.webview.render(pixmap)
|
self.webview.render(pixmap)
|
||||||
|
@ -287,7 +287,6 @@ class VlcPlayer(MediaPlayer):
|
|||||||
controller.vlc_media_player.set_time(int(start_time))
|
controller.vlc_media_player.set_time(int(start_time))
|
||||||
controller.seek_slider.setMaximum(controller.media_info.length)
|
controller.seek_slider.setMaximum(controller.media_info.length)
|
||||||
self.set_state(MediaState.Playing, controller)
|
self.set_state(MediaState.Playing, controller)
|
||||||
controller.vlc_widget.raise_()
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def pause(self, controller):
|
def pause(self, controller):
|
||||||
|
@ -1361,7 +1361,7 @@ class ServiceManager(QtWidgets.QWidget, RegistryBase, Ui_ServiceManager, LogMixi
|
|||||||
"""
|
"""
|
||||||
The theme may have changed in the settings dialog so make sure the theme combo box is in the correct state.
|
The theme may have changed in the settings dialog so make sure the theme combo box is in the correct state.
|
||||||
"""
|
"""
|
||||||
visible = self.renderer.theme_level != ThemeLevel.Global
|
visible = self.settings.value('themes/theme level') != ThemeLevel.Global
|
||||||
self.toolbar.actions['theme_combo_box'].setVisible(visible)
|
self.toolbar.actions['theme_combo_box'].setVisible(visible)
|
||||||
self.toolbar.actions['theme_label'].setVisible(visible)
|
self.toolbar.actions['theme_label'].setVisible(visible)
|
||||||
self.regenerate_service_items()
|
self.regenerate_service_items()
|
||||||
|
@ -981,6 +981,10 @@ class SlideController(QtWidgets.QWidget, LogMixin, RegistryProperties):
|
|||||||
if self.service_item.is_command():
|
if self.service_item.is_command():
|
||||||
self.preview_display.load_verses(media_empty_song, True)
|
self.preview_display.load_verses(media_empty_song, True)
|
||||||
self.on_media_start(self.service_item)
|
self.on_media_start(self.service_item)
|
||||||
|
# Let media window init, then put webengine back on top
|
||||||
|
self.application.process_events()
|
||||||
|
for display in self.displays:
|
||||||
|
display.raise_()
|
||||||
self.slide_selected(True)
|
self.slide_selected(True)
|
||||||
if self.service_item.from_service:
|
if self.service_item.from_service:
|
||||||
self.preview_widget.setFocus()
|
self.preview_widget.setFocus()
|
||||||
|
@ -119,6 +119,7 @@ class ThemeForm(QtWidgets.QWizard, Ui_ThemeWizard, RegistryProperties):
|
|||||||
# Make sure we don't resize before the widgets are actually created
|
# Make sure we don't resize before the widgets are actually created
|
||||||
if hasattr(self, 'preview_area_layout'):
|
if hasattr(self, 'preview_area_layout'):
|
||||||
self.preview_area_layout.set_aspect_ratio(self.display_aspect_ratio)
|
self.preview_area_layout.set_aspect_ratio(self.display_aspect_ratio)
|
||||||
|
self.application.process_events()
|
||||||
self.preview_box.set_scale(float(self.preview_box.width()) / self.renderer.width())
|
self.preview_box.set_scale(float(self.preview_box.width()) / self.renderer.width())
|
||||||
|
|
||||||
def validateCurrentPage(self):
|
def validateCurrentPage(self):
|
||||||
@ -160,15 +161,8 @@ class ThemeForm(QtWidgets.QWizard, Ui_ThemeWizard, RegistryProperties):
|
|||||||
self.setOption(QtWidgets.QWizard.HaveCustomButton1, enabled)
|
self.setOption(QtWidgets.QWizard.HaveCustomButton1, enabled)
|
||||||
if self.page(page_id) == self.preview_page:
|
if self.page(page_id) == self.preview_page:
|
||||||
self.update_theme()
|
self.update_theme()
|
||||||
self.preview_box.set_theme(self.theme, service_item_type=ServiceItemType.Text)
|
|
||||||
self.preview_box.clear_slides()
|
|
||||||
self.preview_box.set_scale(float(self.preview_box.width()) / self.renderer.width())
|
|
||||||
try:
|
|
||||||
self.display_aspect_ratio = self.renderer.width() / self.renderer.height()
|
|
||||||
except ZeroDivisionError:
|
|
||||||
self.display_aspect_ratio = 1
|
|
||||||
self.preview_area_layout.set_aspect_ratio(self.display_aspect_ratio)
|
|
||||||
self.resizeEvent()
|
self.resizeEvent()
|
||||||
|
self.preview_box.clear_slides()
|
||||||
self.preview_box.show()
|
self.preview_box.show()
|
||||||
self.preview_box.generate_preview(self.theme, False, False)
|
self.preview_box.generate_preview(self.theme, False, False)
|
||||||
|
|
||||||
|
@ -597,7 +597,6 @@ def test_play(mocked_get_vlc, mocked_threading):
|
|||||||
mocked_thread.start.assert_called_with()
|
mocked_thread.start.assert_called_with()
|
||||||
mocked_volume.assert_called_with(mocked_controller, 100)
|
mocked_volume.assert_called_with(mocked_controller, 100)
|
||||||
assert MediaState.Playing == vlc_player.get_live_state()
|
assert MediaState.Playing == vlc_player.get_live_state()
|
||||||
mocked_controller.vlc_widget.raise_.assert_called_with()
|
|
||||||
assert result is True, 'The value returned from play() should be True'
|
assert result is True, 'The value returned from play() should be True'
|
||||||
|
|
||||||
|
|
||||||
@ -667,7 +666,6 @@ def test_play_dvd(mocked_get_vlc, mocked_threading):
|
|||||||
mocked_controller.vlc_media_player.video_set_spu.assert_called_with(1)
|
mocked_controller.vlc_media_player.video_set_spu.assert_called_with(1)
|
||||||
mocked_volume.assert_called_with(mocked_controller, 100)
|
mocked_volume.assert_called_with(mocked_controller, 100)
|
||||||
assert MediaState.Playing == vlc_player.get_live_state()
|
assert MediaState.Playing == vlc_player.get_live_state()
|
||||||
mocked_controller.vlc_widget.raise_.assert_called_with()
|
|
||||||
assert result is True, 'The value returned from play() should be True'
|
assert result is True, 'The value returned from play() should be True'
|
||||||
|
|
||||||
|
|
||||||
|
@ -697,16 +697,16 @@ def test_theme_change_global(mocked_regenerate_service_items, registry):
|
|||||||
"""
|
"""
|
||||||
Test that when a Toolbar theme combobox displays correctly when the theme is set to Global
|
Test that when a Toolbar theme combobox displays correctly when the theme is set to Global
|
||||||
"""
|
"""
|
||||||
# GIVEN: A service manager, a service to display with a theme level in the renderer
|
# GIVEN: A service manager, settings set to Global theme
|
||||||
mocked_renderer = MagicMock()
|
|
||||||
service_manager = ServiceManager(None)
|
service_manager = ServiceManager(None)
|
||||||
Registry().register('renderer', mocked_renderer)
|
|
||||||
service_manager.toolbar = OpenLPToolbar(None)
|
service_manager.toolbar = OpenLPToolbar(None)
|
||||||
service_manager.toolbar.add_toolbar_action('theme_combo_box', triggers=MagicMock())
|
service_manager.toolbar.add_toolbar_action('theme_combo_box', triggers=MagicMock())
|
||||||
service_manager.toolbar.add_toolbar_action('theme_label', triggers=MagicMock())
|
service_manager.toolbar.add_toolbar_action('theme_label', triggers=MagicMock())
|
||||||
|
mocked_settings = MagicMock()
|
||||||
|
mocked_settings.value.return_value = ThemeLevel.Global
|
||||||
|
Registry().register('settings', mocked_settings)
|
||||||
|
|
||||||
# WHEN: The service manager has a Global theme
|
# WHEN: theme_change is called
|
||||||
mocked_renderer.theme_level = ThemeLevel.Global
|
|
||||||
service_manager.theme_change()
|
service_manager.theme_change()
|
||||||
|
|
||||||
# THEN: The the theme toolbar should not be visible
|
# THEN: The the theme toolbar should not be visible
|
||||||
@ -719,16 +719,16 @@ def test_theme_change_service(mocked_regenerate_service_items, registry):
|
|||||||
"""
|
"""
|
||||||
Test that when a Toolbar theme combobox displays correctly when the theme is set to Theme
|
Test that when a Toolbar theme combobox displays correctly when the theme is set to Theme
|
||||||
"""
|
"""
|
||||||
# GIVEN: A service manager, a service to display with a theme level in the renderer
|
# GIVEN: A service manager, settings set to Service theme
|
||||||
mocked_renderer = MagicMock()
|
|
||||||
service_manager = ServiceManager(None)
|
service_manager = ServiceManager(None)
|
||||||
Registry().register('renderer', mocked_renderer)
|
|
||||||
service_manager.toolbar = OpenLPToolbar(None)
|
service_manager.toolbar = OpenLPToolbar(None)
|
||||||
service_manager.toolbar.add_toolbar_action('theme_combo_box', triggers=MagicMock())
|
service_manager.toolbar.add_toolbar_action('theme_combo_box', triggers=MagicMock())
|
||||||
service_manager.toolbar.add_toolbar_action('theme_label', triggers=MagicMock())
|
service_manager.toolbar.add_toolbar_action('theme_label', triggers=MagicMock())
|
||||||
|
mocked_settings = MagicMock()
|
||||||
|
mocked_settings.value.return_value = ThemeLevel.Service
|
||||||
|
Registry().register('settings', mocked_settings)
|
||||||
|
|
||||||
# WHEN: The service manager has a Service theme
|
# WHEN: theme_change is called
|
||||||
mocked_renderer.theme_level = ThemeLevel.Service
|
|
||||||
service_manager.theme_change()
|
service_manager.theme_change()
|
||||||
|
|
||||||
# THEN: The the theme toolbar should be visible
|
# THEN: The the theme toolbar should be visible
|
||||||
@ -741,18 +741,18 @@ def test_theme_change_song(mocked_regenerate_service_items, registry):
|
|||||||
"""
|
"""
|
||||||
Test that when a Toolbar theme combobox displays correctly when the theme is set to Song
|
Test that when a Toolbar theme combobox displays correctly when the theme is set to Song
|
||||||
"""
|
"""
|
||||||
# GIVEN: A service manager, a service to display with a theme level in the renderer
|
# GIVEN: A service manager, settings set to Song theme
|
||||||
mocked_renderer = MagicMock()
|
|
||||||
service_manager = ServiceManager(None)
|
service_manager = ServiceManager(None)
|
||||||
Registry().register('renderer', mocked_renderer)
|
|
||||||
service_manager.toolbar = OpenLPToolbar(None)
|
service_manager.toolbar = OpenLPToolbar(None)
|
||||||
service_manager.toolbar.add_toolbar_action('theme_combo_box', triggers=MagicMock())
|
service_manager.toolbar.add_toolbar_action('theme_combo_box', triggers=MagicMock())
|
||||||
service_manager.toolbar.add_toolbar_action('theme_label', triggers=MagicMock())
|
service_manager.toolbar.add_toolbar_action('theme_label', triggers=MagicMock())
|
||||||
|
mocked_settings = MagicMock()
|
||||||
|
mocked_settings.value.return_value = ThemeLevel.Song
|
||||||
|
Registry().register('settings', mocked_settings)
|
||||||
|
|
||||||
# WHEN: The service manager has a Song theme
|
# WHEN: theme_change is called
|
||||||
mocked_renderer.theme_level = ThemeLevel.Song
|
|
||||||
service_manager.theme_change()
|
service_manager.theme_change()
|
||||||
|
|
||||||
# THEN: The the theme toolbar should be visible
|
# THEN: The the theme toolbar should be visible
|
||||||
assert service_manager.toolbar.actions['theme_combo_box'].isVisible() is True, \
|
assert service_manager.toolbar.actions['theme_combo_box'].isVisible() is True, \
|
||||||
'The visibility should be True'
|
'The visibility should be True'
|
||||||
|
@ -794,6 +794,7 @@ def test_process_item(mocked_execute, registry):
|
|||||||
mocked_main_window = MagicMock()
|
mocked_main_window = MagicMock()
|
||||||
Registry().register('main_window', mocked_main_window)
|
Registry().register('main_window', mocked_main_window)
|
||||||
Registry().register('media_controller', MagicMock())
|
Registry().register('media_controller', MagicMock())
|
||||||
|
Registry().register('application', MagicMock())
|
||||||
slide_controller = SlideController(None)
|
slide_controller = SlideController(None)
|
||||||
slide_controller.service_item = mocked_pres_item
|
slide_controller.service_item = mocked_pres_item
|
||||||
slide_controller.is_live = False
|
slide_controller.is_live = False
|
||||||
|
@ -568,6 +568,16 @@ describe("Display.setTextSlide", function () {
|
|||||||
expect($(".slides > section > section")[0].innerHTML).toEqual(_prepareText(text));
|
expect($(".slides > section > section")[0].innerHTML).toEqual(_prepareText(text));
|
||||||
expect(Display.reinit).toHaveBeenCalledTimes(1); // only called once for the first setTextSlide
|
expect(Display.reinit).toHaveBeenCalledTimes(1); // only called once for the first setTextSlide
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it("should give the new slide the future class", function () {
|
||||||
|
var text = "That saved a wretch\nlike me";
|
||||||
|
spyOn(Display, "reinit");
|
||||||
|
Display.setTextSlide("Amazing grace,\nhow sweet the sound");
|
||||||
|
|
||||||
|
Display.setTextSlide(text);
|
||||||
|
|
||||||
|
expect($(".slides > section > section")[0].classList.contains("future")).toEqual(true);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("Display.setTextSlides", function () {
|
describe("Display.setTextSlides", function () {
|
||||||
|
@ -24,7 +24,6 @@ Test the ThemeForm class and related methods.
|
|||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from unittest.mock import patch, MagicMock
|
from unittest.mock import patch, MagicMock
|
||||||
|
|
||||||
from openlp.core.common.enum import ServiceItemType
|
|
||||||
from openlp.core.common.registry import Registry
|
from openlp.core.common.registry import Registry
|
||||||
from openlp.core.lib.theme import BackgroundType
|
from openlp.core.lib.theme import BackgroundType
|
||||||
from openlp.core.ui.themeform import ThemeForm
|
from openlp.core.ui.themeform import ThemeForm
|
||||||
@ -266,12 +265,8 @@ def test_on_current_id_changed_preview(mocked_setup, settings):
|
|||||||
|
|
||||||
# THEN: The right options should have been set
|
# THEN: The right options should have been set
|
||||||
theme_form.update_theme.assert_called_once()
|
theme_form.update_theme.assert_called_once()
|
||||||
theme_form.preview_box.set_theme.assert_called_once_with('my fake theme',
|
|
||||||
service_item_type=ServiceItemType.Text)
|
|
||||||
theme_form.preview_box.clear_slides.assert_called_once()
|
|
||||||
theme_form.preview_box.set_scale.assert_called_once_with(float(300 / 1920))
|
|
||||||
theme_form.preview_area_layout.set_aspect_ratio(16 / 9)
|
|
||||||
theme_form.resizeEvent.assert_called_once()
|
theme_form.resizeEvent.assert_called_once()
|
||||||
|
theme_form.preview_box.clear_slides.assert_called_once()
|
||||||
theme_form.preview_box.show.assert_called_once()
|
theme_form.preview_box.show.assert_called_once()
|
||||||
theme_form.preview_box.generate_preview.assert_called_once_with('my fake theme', False, False)
|
theme_form.preview_box.generate_preview.assert_called_once_with('my fake theme', False, False)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user