Migrate setting definitions to Core from plugins

Signed-off-by: Tim <tim.bentley@gmail.com>
This commit is contained in:
Tim Bentley 2019-12-30 08:42:49 +00:00
parent 5978ff9bf9
commit 63f67f6e17
42 changed files with 3322 additions and 286379 deletions

View File

@ -93,6 +93,16 @@ class LanguageSelection(IntEnum):
English = 2
@unique
class PluginStatus(IntEnum):
"""
Defines the status of the plugin
"""
Active = 1
Inactive = 0
Disabled = -1
@unique
class SongSearch(IntEnum):
"""

View File

@ -251,7 +251,7 @@ class RegistryProperties(object):
@property
def settings(self):
"""
Adds the projector manager to the class dynamically
Adds the settings object to the class dynamically
"""
if not hasattr(self, '_settings') or not self._settings:
self._settings = Registry().get('settings')

View File

@ -32,6 +32,8 @@ from tempfile import gettempdir
from PyQt5 import QtCore, QtGui
from openlp.core.common import SlideLimits, ThemeLevel, is_linux, is_win
from openlp.core.common.enum import AlertLocation, BibleSearch, CustomSearch, LayoutStyle, DisplayStyle, \
LanguageSelection, SongSearch, PluginStatus
from openlp.core.common.json import OpenLPJSONDecoder, OpenLPJSONEncoder, is_serializable
from openlp.core.common.path import files_to_paths, str_to_path
@ -47,6 +49,8 @@ class ProxyMode(IntEnum):
MANUAL_PROXY = 3
TODAY = QtCore.QDate.currentDate()
# Fix for bug #1014422.
X11_BYPASS_DEFAULT = True
if is_linux(): # pragma: no cover
@ -168,6 +172,20 @@ class Settings(QtCore.QSettings):
'advanced/x11 bypass wm': X11_BYPASS_DEFAULT,
'advanced/search as type': True,
'advanced/use_dark_style': False,
'alerts/font face': QtGui.QFont().family(),
'alerts/font size': 40,
'alerts/db type': 'sqlite',
'alerts/db username': '',
'alerts/db password': '',
'alerts/db hostname': '',
'alerts/db database': '',
'alerts/location': AlertLocation.Bottom,
'alerts/background color': '#660000',
'alerts/font color': '#ffffff',
'alerts/status': PluginStatus.Inactive,
'alerts/timeout': 10,
'alerts/repeat': 1,
'alerts/scroll': True,
'api/twelve hour': True,
'api/port': 4316,
'api/websocket port': 4317,
@ -176,7 +194,39 @@ class Settings(QtCore.QSettings):
'api/authentication enabled': False,
'api/ip address': '0.0.0.0',
'api/thumbnails': True,
'bibles/db type': 'sqlite',
'bibles/db username': '',
'bibles/db password': '',
'bibles/db hostname': '',
'bibles/db database': '',
'bibles/last used search type': BibleSearch.Combined,
'bibles/reset to combined quick search': True,
'bibles/verse layout style': LayoutStyle.VersePerSlide,
'bibles/book name language': LanguageSelection.Bible,
'bibles/display brackets': DisplayStyle.NoBrackets,
'bibles/is verse number visible': True,
'bibles/display new chapter': False,
'bibles/second bibles': True,
'bibles/status': PluginStatus.Inactive,
'bibles/primary bible': '',
'bibles/bible theme': '',
'bibles/verse separator': '',
'bibles/range separator': '',
'bibles/list separator': '',
'bibles/end separator': '',
'bibles/last directory import': None,
'bibles/hide combined quick error': False,
'bibles/is search while typing enabled': True,
'crashreport/last directory': None,
'custom/db type': 'sqlite',
'custom/db username': '',
'custom/db password': '',
'custom/db hostname': '',
'custom/db database': '',
'custom/last used search type': CustomSearch.Titles,
'custom/display footer': True,
'custom/add custom from service': True,
'custom/status': PluginStatus.Inactive,
'formattingTags/html_tags': '',
'core/auto open': False,
'core/auto preview': False,
@ -207,6 +257,16 @@ class Settings(QtCore.QSettings):
'core/monitor': {},
'core/application version': '0.0',
'images/background color': '#000000',
'images/db type': 'sqlite',
'images/db username': '',
'images/db password': '',
'images/db hostname': '',
'images/db database': '',
'images/last directory': None,
'images/status': PluginStatus.Inactive,
'media/status': PluginStatus.Inactive,
'media/media files': [],
'media/last directory': None,
'media/media auto start': QtCore.Qt.Unchecked,
'media/stream command': '',
'media/vlc arguments': '',
@ -216,6 +276,22 @@ class Settings(QtCore.QSettings):
'media/preview volume': 0,
'remotes/download version': '0.0',
'players/background color': '#000000',
'planningcenter/status': PluginStatus.Inactive,
'planningcenter/application_id': '',
'planningcenter/secret': '',
'presentations/status': PluginStatus.Inactive,
'presentations/override app': QtCore.Qt.Unchecked,
'presentations/enable_pdf_program': QtCore.Qt.Unchecked,
'presentations/pdf_program': None,
'presentations/maclo': QtCore.Qt.Checked,
'presentations/Impress': QtCore.Qt.Checked,
'presentations/Powerpoint': QtCore.Qt.Checked,
'presentations/Pdf': QtCore.Qt.Checked,
'presentations/presentations files': [],
'presentations/thumbnail_scheme': '',
'presentations/powerpoint slide click advance': QtCore.Qt.Unchecked,
'presentations/powerpoint control window': QtCore.Qt.Unchecked,
'presentations/last directory': None,
'servicemanager/last directory': None,
'servicemanager/last file': None,
'servicemanager/service theme': None,
@ -223,6 +299,37 @@ class Settings(QtCore.QSettings):
'SettingsImport/Make_Changes': 'At_Own_RISK',
'SettingsImport/type': 'OpenLP_settings_export',
'SettingsImport/version': '',
'songs/status': PluginStatus.Inactive,
'songs/db type': 'sqlite',
'songs/db username': '',
'songs/db password': '',
'songs/db hostname': '',
'songs/db database': '',
'songs/last used search type': SongSearch.Entire,
'songs/last import type': None,
'songs/update service on edit': False,
'songs/add song from service': True,
'songs/add songbook slide': False,
'songs/display songbar': True,
'songs/last directory import': None,
'songs/last directory export': None,
'songs/songselect username': '',
'songs/songselect password': '',
'songs/songselect searches': '',
'songs/enable chords': True,
'songs/chord notation': 'english', # Can be english, german or neo-latin
'songs/mainview chords': False,
'songs/disable chords import': False,
'songusage/status': PluginStatus.Inactive,
'songusage/db type': 'sqlite',
'songusage/db username': '',
'songusage/db password': '',
'songusage/db hostname': '',
'songusage/db database': '',
'songusage/active': False,
'songusage/to date': TODAY,
'songusage/from date': TODAY.addYears(-1),
'songusage/last directory export': None,
'themes/global theme': '',
'themes/last directory': None,
'themes/last directory export': None,

View File

@ -23,6 +23,7 @@ Provide the generic plugin functionality for OpenLP plugins.
"""
import logging
from openlp.core.common.enum import PluginStatus
from openlp.core.common.i18n import UiStrings
from openlp.core.common.mixins import RegistryProperties
from openlp.core.common.registry import Registry, RegistryBase
@ -33,15 +34,6 @@ from openlp.core.version import get_version
log = logging.getLogger(__name__)
class PluginStatus(object):
"""
Defines the status of the plugin
"""
Active = 1
Inactive = 0
Disabled = -1
class StringContent(object):
"""
Provide standard strings for objects to use.
@ -145,15 +137,17 @@ class Plugin(RegistryBase, RegistryProperties):
self.media_item = None
self.weight = 0
self.status = PluginStatus.Inactive
# Add the default status to the default settings.
default_settings[name + '/status'] = PluginStatus.Inactive
default_settings[name + '/last directory'] = None
# Append a setting for files in the mediamanager (note not all plugins
# which have a mediamanager need this).
if media_item_class is not None:
default_settings['{name}/{name} files'.format(name=name)] = []
# Add settings to the dict of all settings.
Settings.extend_default_settings(default_settings)
if default_settings:
# Add the default status to the default settings.
default_settings[name + '/status'] = PluginStatus.Inactive
default_settings[name + '/last directory'] = None
# Add settings to the dict of all settings.
Settings.extend_default_settings(default_settings)
# Append a setting for files in the mediamanager (note not all plugins
# which have a mediamanager need this).
if media_item_class is not None:
default_settings['{name}/{name} files'.format(name=name)] = []
Registry().register_function('{name}_add_service_item'.format(name=self.name), self.process_add_service_event)
Registry().register_function('{name}_config_updated'.format(name=self.name), self.config_update)
self._setup(version)

View File

@ -21,12 +21,9 @@
import logging
from PyQt5 import QtGui
from openlp.core.state import State
from openlp.core.api.http import register_endpoint
from openlp.core.common.actions import ActionList
from openlp.core.common.enum import AlertLocation
from openlp.core.common.i18n import UiStrings, translate
from openlp.core.common.settings import Settings
from openlp.core.lib.db import Manager
@ -114,22 +111,6 @@ HTML = """
<div id="alert" style="visibility:hidden"></div>
"""
__default_settings__ = {
'alerts/font face': QtGui.QFont().family(),
'alerts/font size': 40,
'alerts/db type': 'sqlite',
'alerts/db username': '',
'alerts/db password': '',
'alerts/db hostname': '',
'alerts/db database': '',
'alerts/location': AlertLocation.Bottom,
'alerts/background color': '#660000',
'alerts/font color': '#ffffff',
'alerts/timeout': 10,
'alerts/repeat': 1,
'alerts/scroll': True
}
class AlertsPlugin(Plugin):
"""
@ -141,7 +122,7 @@ class AlertsPlugin(Plugin):
"""
Class __init__ method
"""
super(AlertsPlugin, self).__init__('alerts', __default_settings__, settings_tab_class=AlertsTab)
super(AlertsPlugin, self).__init__('alerts', None, settings_tab_class=AlertsTab)
self.weight = -3
self.icon_path = UiIcons().alert
self.icon = self.icon_path

View File

@ -24,7 +24,6 @@ import logging
from openlp.core.state import State
from openlp.core.api.http import register_endpoint
from openlp.core.common.actions import ActionList
from openlp.core.common.enum import BibleSearch, LayoutStyle, DisplayStyle, LanguageSelection
from openlp.core.common.i18n import UiStrings, translate
from openlp.core.ui.icons import UiIcons
from openlp.core.lib.plugin import Plugin, StringContent
@ -38,32 +37,6 @@ from openlp.plugins.bibles.lib.mediaitem import BibleMediaItem
log = logging.getLogger(__name__)
__default_settings__ = {
'bibles/db type': 'sqlite',
'bibles/db username': '',
'bibles/db password': '',
'bibles/db hostname': '',
'bibles/db database': '',
'bibles/last used search type': BibleSearch.Combined,
'bibles/reset to combined quick search': True,
'bibles/verse layout style': LayoutStyle.VersePerSlide,
'bibles/book name language': LanguageSelection.Bible,
'bibles/display brackets': DisplayStyle.NoBrackets,
'bibles/is verse number visible': True,
'bibles/display new chapter': False,
'bibles/second bibles': True,
'bibles/primary bible': '',
'bibles/bible theme': '',
'bibles/verse separator': '',
'bibles/range separator': '',
'bibles/list separator': '',
'bibles/end separator': '',
'bibles/last directory import': None,
'bibles/hide combined quick error': False,
'bibles/is search while typing enabled': True
}
class BiblePlugin(Plugin):
"""
The Bible plugin provides a plugin for managing and displaying Bibles.
@ -71,7 +44,7 @@ class BiblePlugin(Plugin):
log.info('Bible Plugin loaded')
def __init__(self):
super(BiblePlugin, self).__init__('bibles', __default_settings__, BibleMediaItem, BiblesTab)
super(BiblePlugin, self).__init__('bibles', None, BibleMediaItem, BiblesTab)
self.weight = -9
self.icon_path = UiIcons().bible
self.icon = UiIcons().bible

View File

@ -27,7 +27,6 @@ import logging
from openlp.core.state import State
from openlp.core.api.http import register_endpoint
from openlp.core.common.enum import CustomSearch
from openlp.core.common.i18n import translate
from openlp.core.lib import build_icon
from openlp.core.lib.db import Manager
@ -41,17 +40,6 @@ from openlp.plugins.custom.lib.customtab import CustomTab
log = logging.getLogger(__name__)
__default_settings__ = {
'custom/db type': 'sqlite',
'custom/db username': '',
'custom/db password': '',
'custom/db hostname': '',
'custom/db database': '',
'custom/last used search type': CustomSearch.Titles,
'custom/display footer': True,
'custom/add custom from service': True
}
class CustomPlugin(Plugin):
"""
@ -63,7 +51,7 @@ class CustomPlugin(Plugin):
log.info('Custom Plugin loaded')
def __init__(self):
super(CustomPlugin, self).__init__('custom', __default_settings__, CustomMediaItem, CustomTab)
super(CustomPlugin, self).__init__('custom', None, CustomMediaItem, CustomTab)
self.weight = -5
self.db_manager = Manager('custom', init_schema)
self.icon_path = UiIcons().clone

View File

@ -40,22 +40,12 @@ from openlp.plugins.images.lib.db import init_schema
log = logging.getLogger(__name__)
__default_settings__ = {
'images/db type': 'sqlite',
'images/db username': '',
'images/db password': '',
'images/db hostname': '',
'images/db database': '',
'images/background color': '#000000',
'images/last directory': None
}
class ImagePlugin(Plugin):
log.info('Image Plugin loaded')
def __init__(self):
super(ImagePlugin, self).__init__('images', __default_settings__, ImageMediaItem, ImageTab)
super(ImagePlugin, self).__init__('images', None, ImageMediaItem, ImageTab)
self.manager = Manager('images', init_schema, upgrade_mod=upgrade)
self.weight = -7
self.icon_path = UiIcons().picture

View File

@ -37,11 +37,6 @@ log = logging.getLogger(__name__)
# Some settings starting with "media" are in core, because they are needed for core functionality.
__default_settings__ = {
'media/media files': [],
'media/last directory': None
}
class MediaPlugin(Plugin):
"""
@ -50,7 +45,7 @@ class MediaPlugin(Plugin):
log.info('{name} MediaPlugin loaded'.format(name=__name__))
def __init__(self):
super(MediaPlugin, self).__init__('media', __default_settings__, MediaMediaItem)
super(MediaPlugin, self).__init__('media', None, MediaMediaItem)
self.weight = -6
self.icon_path = UiIcons().video
self.icon = build_icon(self.icon_path)

View File

@ -38,11 +38,6 @@ from openlp.plugins.songs.lib.db import Song
log = logging.getLogger(__name__)
__default_settings__ = {
'planningcenter/application_id': '',
'planningcenter/secret': ''
}
class PlanningCenterPlugin(Plugin):
"""
@ -54,8 +49,7 @@ class PlanningCenterPlugin(Plugin):
"""
Create and set up the PlanningCenter plugin.
"""
super(PlanningCenterPlugin, self).__init__('planningcenter', __default_settings__,
settings_tab_class=PlanningCenterTab)
super(PlanningCenterPlugin, self).__init__('planningcenter', None, settings_tab_class=PlanningCenterTab)
self.planningcenter_form = None
self.icon = UiIcons().planning_center
self.icon_path = self.icon

View File

@ -25,8 +25,6 @@ presentations from a variety of document formats.
import logging
import os
from PyQt5 import QtCore
from openlp.core.api.http import register_endpoint
from openlp.core.common import extension_loader
from openlp.core.common.i18n import translate
@ -44,22 +42,6 @@ from openlp.plugins.presentations.lib.presentationtab import PresentationTab
log = logging.getLogger(__name__)
__default_settings__ = {
'presentations/override app': QtCore.Qt.Unchecked,
'presentations/enable_pdf_program': QtCore.Qt.Unchecked,
'presentations/pdf_program': None,
'presentations/maclo': QtCore.Qt.Checked,
'presentations/Impress': QtCore.Qt.Checked,
'presentations/Powerpoint': QtCore.Qt.Checked,
'presentations/Pdf': QtCore.Qt.Checked,
'presentations/presentations files': [],
'presentations/thumbnail_scheme': '',
'presentations/powerpoint slide click advance': QtCore.Qt.Unchecked,
'presentations/powerpoint control window': QtCore.Qt.Unchecked,
'presentations/last directory': None
}
class PresentationPlugin(Plugin):
"""
This plugin allowed a Presentation to be opened, controlled and displayed on the output display. The plugin controls
@ -73,7 +55,7 @@ class PresentationPlugin(Plugin):
"""
log.debug('Initialised')
self.controllers = {}
Plugin.__init__(self, 'presentations', __default_settings__, __default_settings__)
Plugin.__init__(self, 'presentations', None, None)
self.weight = -8
self.icon_path = UiIcons().presentation
self.icon = build_icon(self.icon_path)

View File

@ -33,7 +33,6 @@ from PyQt5 import QtCore, QtWidgets
from openlp.core.state import State
from openlp.core.api.http import register_endpoint
from openlp.core.common.actions import ActionList
from openlp.core.common.enum import SongSearch
from openlp.core.common.i18n import UiStrings, translate
from openlp.core.common.registry import Registry
from openlp.core.lib import build_icon
@ -55,26 +54,6 @@ from openlp.plugins.songs.lib.songstab import SongsTab
log = logging.getLogger(__name__)
__default_settings__ = {
'songs/db type': 'sqlite',
'songs/db username': '',
'songs/db password': '',
'songs/db hostname': '',
'songs/db database': '',
'songs/last used search type': SongSearch.Entire,
'songs/last import type': SongFormat.OpenLyrics,
'songs/update service on edit': False,
'songs/add song from service': True,
'songs/add songbook slide': False,
'songs/display songbar': True,
'songs/last directory import': None,
'songs/last directory export': None,
'songs/songselect username': '',
'songs/songselect password': '',
'songs/songselect searches': '',
'songs/enable chords': True,
'songs/chord notation': 'english', # Can be english, german or neo-latin
'songs/mainview chords': False,
'songs/disable chords import': False,
'songs/footer template': """\
${title}<br/>
@ -152,6 +131,8 @@ class SongsPlugin(Plugin):
register_endpoint(api_songs_endpoint)
State().add_service(self.name, self.weight, is_plugin=True)
State().update_pre_conditions(self.name, self.check_pre_conditions())
if not self.settings.value('songs/last import type'):
self.settings.setValue('songs/last import type', SongFormat.OpenLyrics)
def check_pre_conditions(self):
"""

View File

@ -43,18 +43,6 @@ log = logging.getLogger(__name__)
TODAY = QtCore.QDate.currentDate()
__default_settings__ = {
'songusage/db type': 'sqlite',
'songusage/db username': '',
'songusage/db password': '',
'songusage/db hostname': '',
'songusage/db database': '',
'songusage/active': False,
'songusage/to date': TODAY,
'songusage/from date': TODAY.addYears(-1),
'songusage/last directory export': None
}
class SongUsagePlugin(Plugin):
"""
@ -63,7 +51,7 @@ class SongUsagePlugin(Plugin):
log.info('SongUsage Plugin loaded')
def __init__(self):
super(SongUsagePlugin, self).__init__('songusage', __default_settings__)
super(SongUsagePlugin, self).__init__('songusage', None)
self.manager = Manager('songusage', init_schema, upgrade_mod=upgrade)
self.weight = -4
self.icon = UiIcons().song_usage

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -50,6 +50,7 @@ class TestPluginManager(TestCase):
Registry().register('service_list', MagicMock())
Registry().register('main_window', self.mocked_main_window)
Registry().register('settings_form', self.mocked_settings_form)
Registry().register('settings', MagicMock())
def test_bootstrap_initialise(self):
"""

View File

@ -26,9 +26,7 @@ from tempfile import mkdtemp
from unittest import TestCase
from unittest.mock import MagicMock, call, patch
from openlp.core.common.settings import Settings
from openlp.plugins.presentations.lib.impresscontroller import ImpressController, ImpressDocument, TextType
from openlp.plugins.presentations.presentationplugin import __default_settings__
from tests.helpers.testmixin import TestMixin
from tests.utils.constants import RESOURCE_PATH
@ -168,7 +166,6 @@ class TestImpressDocument(TestCase):
def setUp(self):
mocked_plugin = MagicMock()
mocked_plugin.settings_section = 'presentations'
Settings().extend_default_settings(__default_settings__)
self.file_name = RESOURCE_PATH / 'presentations' / 'test.pptx'
self.ppc = ImpressController(mocked_plugin)
self.doc = ImpressDocument(self.ppc, self.file_name)

View File

@ -27,10 +27,8 @@ from unittest import TestCase, SkipTest
from unittest.mock import MagicMock, patch, call
from openlp.core.common import is_macosx
from openlp.core.common.settings import Settings
from openlp.core.common.path import Path
from openlp.plugins.presentations.lib.maclocontroller import MacLOController, MacLODocument
from openlp.plugins.presentations.presentationplugin import __default_settings__
from tests.helpers.testmixin import TestMixin
from tests.utils.constants import TEST_RESOURCES_PATH
@ -159,7 +157,6 @@ class TestMacLODocument(TestCase):
def setUp(self):
mocked_plugin = MagicMock()
mocked_plugin.settings_section = 'presentations'
Settings().extend_default_settings(__default_settings__)
self.file_name = Path(TEST_RESOURCES_PATH) / 'presentations' / 'test.odp'
self.mocked_client = MagicMock()
with patch('openlp.plugins.presentations.lib.maclocontroller.MacLOController._start_server'):