Merge branch 'settings_2' into 'master'

Settings 2

See merge request openlp/openlp!91
This commit is contained in:
Raoul Snyman 2019-12-04 20:01:03 +00:00
commit 3094e6574d
4 changed files with 1045 additions and 1020 deletions

1
.gitignore vendored
View File

@ -25,6 +25,7 @@
.vscode
.eggs
.venv
.mypy_cache
OpenLP.egg-info
\#*\#
__pycache__

View File

@ -34,7 +34,6 @@ from openlp.core.common.actions import ActionList, CategoryOrder
from openlp.core.common.i18n import UiStrings, translate
from openlp.core.common.mixins import LogMixin, RegistryProperties
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 ServiceItemAction, image_to_byte
@ -324,7 +323,7 @@ class SlideController(QtWidgets.QWidget, LogMixin, RegistryProperties):
self.play_slides_once = create_action(self, 'playSlidesOnce', text=UiStrings().PlaySlidesToEnd,
icon=UiIcons().clock, checked=False, can_shortcuts=True,
category=self.category, triggers=self.on_play_slides_once)
if Settings().value(self.main_window.advanced_settings_section + '/slide limits') == SlideLimits.Wrap:
if self.settings.value(self.main_window.advanced_settings_section + '/slide limits') == SlideLimits.Wrap:
self.play_slides_menu.setDefaultAction(self.play_slides_loop)
else:
self.play_slides_menu.setDefaultAction(self.play_slides_once)
@ -697,13 +696,13 @@ class SlideController(QtWidgets.QWidget, LogMixin, RegistryProperties):
"""
Adjusts the value of the ``delay_spin_box`` to the given one.
"""
self.delay_spin_box.setValue(Settings().value('core/loop delay'))
self.delay_spin_box.setValue(self.settings.value('core/loop delay'))
def update_slide_limits(self):
"""
Updates the Slide Limits variable from the settings.
"""
self.slide_limits = Settings().value(self.main_window.advanced_settings_section + '/slide limits')
self.slide_limits = self.settings.value(self.main_window.advanced_settings_section + '/slide limits')
def enable_tool_bar(self, item):
"""
@ -737,7 +736,7 @@ class SlideController(QtWidgets.QWidget, LogMixin, RegistryProperties):
self.play_slides_loop.setIcon(UiIcons().clock)
self.play_slides_loop.setText(UiStrings().PlaySlidesInLoop)
if item.is_text():
if (Settings().value(self.main_window.songs_settings_section + '/display songbar') and
if (self.settings.value(self.main_window.songs_settings_section + '/display songbar') and
not self.song_menu.menu().isEmpty()):
self.toolbar.set_widget_visible('song_menu', True)
if item.is_capable(ItemCapabilities.CanLoop) and len(item.slides) > 1:
@ -1013,9 +1012,9 @@ class SlideController(QtWidgets.QWidget, LogMixin, RegistryProperties):
self.theme_screen.setChecked(False)
self.desktop_screen.setChecked(False)
if checked:
Settings().setValue(self.main_window.general_settings_section + '/screen blank', 'blanked')
self.settings.setValue(self.main_window.general_settings_section + '/screen blank', 'blanked')
else:
Settings().remove(self.main_window.general_settings_section + '/screen blank')
self.settings.remove(self.main_window.general_settings_section + '/screen blank')
self.blank_plugin()
self.update_preview()
self.on_toggle_loop()
@ -1034,9 +1033,9 @@ class SlideController(QtWidgets.QWidget, LogMixin, RegistryProperties):
self.theme_screen.setChecked(checked)
self.desktop_screen.setChecked(False)
if checked:
Settings().setValue(self.main_window.general_settings_section + '/screen blank', 'themed')
self.settings.setValue(self.main_window.general_settings_section + '/screen blank', 'themed')
else:
Settings().remove(self.main_window.general_settings_section + '/screen blank')
self.settings.remove(self.main_window.general_settings_section + '/screen blank')
self.blank_plugin()
self.update_preview()
self.on_toggle_loop()
@ -1056,9 +1055,9 @@ class SlideController(QtWidgets.QWidget, LogMixin, RegistryProperties):
self.theme_screen.setChecked(False)
self.desktop_screen.setChecked(checked)
if checked:
Settings().setValue(self.main_window.general_settings_section + '/screen blank', 'hidden')
self.settings.setValue(self.main_window.general_settings_section + '/screen blank', 'hidden')
else:
Settings().remove(self.main_window.general_settings_section + '/screen blank')
self.settings.remove(self.main_window.general_settings_section + '/screen blank')
self.hide_plugin(checked)
self.update_preview()
self.on_toggle_loop()
@ -1145,7 +1144,7 @@ class SlideController(QtWidgets.QWidget, LogMixin, RegistryProperties):
return
# If "click live slide to unblank" is enabled, unblank the display. And start = Item is sent to Live.
# Note: If this if statement is placed at the bottom of this function instead of top slide transitions are lost.
if self.is_live and Settings().value('core/click live slide to unblank'):
if self.is_live and self.settings.value('core/click live slide to unblank'):
if not start:
Registry().execute('slidecontroller_live_unblank')
row = self.preview_widget.current_slide_number()
@ -1353,7 +1352,7 @@ class SlideController(QtWidgets.QWidget, LogMixin, RegistryProperties):
self.play_slides_once.setText(UiStrings().PlaySlidesToEnd)
self.play_slides_menu.setDefaultAction(self.play_slides_loop)
self.play_slides_once.setChecked(False)
if Settings().value('core/click live slide to unblank'):
if self.settings.value('core/click live slide to unblank'):
Registry().execute('slidecontroller_live_unblank')
else:
self.play_slides_loop.setIcon(UiIcons().clock)
@ -1378,7 +1377,7 @@ class SlideController(QtWidgets.QWidget, LogMixin, RegistryProperties):
self.play_slides_loop.setText(UiStrings().PlaySlidesInLoop)
self.play_slides_menu.setDefaultAction(self.play_slides_once)
self.play_slides_loop.setChecked(False)
if Settings().value('core/click live slide to unblank'):
if self.settings.value('core/click live slide to unblank'):
Registry().execute('slidecontroller_live_unblank')
else:
self.play_slides_once.setIcon(UiIcons().clock)
@ -1423,7 +1422,7 @@ class SlideController(QtWidgets.QWidget, LogMixin, RegistryProperties):
Triggered when a preview slide item is double clicked
"""
if self.service_item:
if Settings().value('advanced/double click live') and Settings().value('core/auto unblank'):
if self.settings.value('advanced/double click live') and self.settings.value('core/auto unblank'):
# Live and Preview have issues if we have video or presentations
# playing in both at the same time.
if self.service_item.is_command():

View File

@ -23,6 +23,7 @@ All the tests
"""
import os
from tempfile import mkstemp
from unittest.mock import MagicMock
import pytest
from PyQt5 import QtCore, QtWidgets
@ -39,24 +40,34 @@ def qapp():
del app
@pytest.fixture
def registry():
"""An instance of the Registry"""
Registry.create()
@pytest.yield_fixture
def settings(qapp):
def settings(qapp, registry):
"""A Settings() instance"""
fd, ini_file = mkstemp('.ini')
Settings.set_filename(ini_file)
Registry.create()
Settings().setDefaultFormat(QtCore.QSettings.IniFormat)
# Needed on windows to make sure a Settings object is available during the tests
sets = Settings()
sets.setValue('themes/global theme', 'my_theme')
Registry().register('settings', set)
Registry().register('settings', sets)
yield sets
del sets
os.close(fd)
os.unlink(Settings().fileName())
@pytest.fixture
def registry():
"""An instance of the Registry"""
Registry.create()
@pytest.yield_fixture
def mock_settings(registry):
"""A Mock Settings() instance"""
# Create and register a mock settings object to work with
mock_settings = MagicMock()
Registry().register('settings', mock_settings)
yield mock_settings
Registry().remove('settings')
del mock_settings

File diff suppressed because it is too large Load Diff