Merge branch 'settings_plugins_3' into 'master'

Settings plugins 3 - More Plugin Migrations

See merge request openlp/openlp!125
This commit is contained in:
Tim Bentley 2020-01-26 17:12:45 +00:00
commit 52d811331c
40 changed files with 165 additions and 183 deletions

View File

@ -413,7 +413,7 @@ class BiblesTab(SettingsTab):
self.settings.endGroup() self.settings.endGroup()
def save(self): def save(self):
self.self.settings.beginGroup(self.settings_section) self.settings.beginGroup(self.settings_section)
self.settings.setValue('is verse number visible', self.is_verse_number_visible) self.settings.setValue('is verse number visible', self.is_verse_number_visible)
self.settings.setValue('display new chapter', self.show_new_chapters) self.settings.setValue('display new chapter', self.show_new_chapters)
self.settings.setValue('display brackets', self.display_style) self.settings.setValue('display brackets', self.display_style)

View File

@ -25,7 +25,6 @@ for the Custom Slides plugin, which is inserted into the configuration dialog.
from PyQt5 import QtCore, QtWidgets from PyQt5 import QtCore, QtWidgets
from openlp.core.common.i18n import translate from openlp.core.common.i18n import translate
from openlp.core.common.settings import Settings
from openlp.core.lib.settingstab import SettingsTab from openlp.core.lib.settingstab import SettingsTab
@ -82,23 +81,21 @@ class CustomTab(SettingsTab):
Load the settings into the dialog Load the settings into the dialog
""" """
settings = Settings() self.settings.beginGroup(self.settings_section)
settings.beginGroup(self.settings_section) self.display_footer = self.settings.value('display footer')
self.display_footer = settings.value('display footer') self.update_load = self.settings.value('add custom from service')
self.update_load = settings.value('add custom from service')
self.display_footer_check_box.setChecked(self.display_footer) self.display_footer_check_box.setChecked(self.display_footer)
self.add_from_service_checkbox.setChecked(self.update_load) self.add_from_service_checkbox.setChecked(self.update_load)
settings.endGroup() self.settings.endGroup()
def save(self): def save(self):
""" """
Save the Dialog settings Save the Dialog settings
""" """
settings = Settings() self.settings.beginGroup(self.settings_section)
settings.beginGroup(self.settings_section) self.settings.setValue('display footer', self.display_footer)
settings.setValue('display footer', self.display_footer) self.settings.setValue('add custom from service', self.update_load)
settings.setValue('add custom from service', self.update_load) self.settings.endGroup()
settings.endGroup()
if self.tab_visited: if self.tab_visited:
self.settings_form.register_post_process('custom_config_updated') self.settings_form.register_post_process('custom_config_updated')
self.tab_visited = False self.tab_visited = False

View File

@ -22,7 +22,6 @@
from PyQt5 import QtWidgets from PyQt5 import QtWidgets
from openlp.core.common.i18n import UiStrings, translate from openlp.core.common.i18n import UiStrings, translate
from openlp.core.common.settings import Settings
from openlp.core.lib.settingstab import SettingsTab from openlp.core.lib.settingstab import SettingsTab
from openlp.core.widgets.buttons import ColorButton from openlp.core.widgets.buttons import ColorButton
@ -67,17 +66,15 @@ class ImageTab(SettingsTab):
self.background_color = color self.background_color = color
def load(self): def load(self):
settings = Settings() self.settings.beginGroup(self.settings_section)
settings.beginGroup(self.settings_section) self.background_color = self.settings.value('background color')
self.background_color = settings.value('background color')
self.initial_color = self.background_color self.initial_color = self.background_color
settings.endGroup() self.settings.endGroup()
self.background_color_button.color = self.background_color self.background_color_button.color = self.background_color
def save(self): def save(self):
settings = Settings() self.settings.beginGroup(self.settings_section)
settings.beginGroup(self.settings_section) self.settings.setValue('background color', self.background_color)
settings.setValue('background color', self.background_color) self.settings.endGroup()
settings.endGroup()
if self.initial_color != self.background_color: if self.initial_color != self.background_color:
self.settings_form.register_post_process('images_config_updated') self.settings_form.register_post_process('images_config_updated')

View File

@ -30,7 +30,6 @@ from PyQt5 import QtCore, QtWidgets
from openlp.core.common.i18n import translate from openlp.core.common.i18n import translate
from openlp.core.common.registry import Registry from openlp.core.common.registry import Registry
from openlp.core.common.settings import Settings
from openlp.plugins.bibles.lib import parse_reference from openlp.plugins.bibles.lib import parse_reference
from openlp.plugins.planningcenter.forms.selectplandialog import Ui_SelectPlanDialog from openlp.plugins.planningcenter.forms.selectplandialog import Ui_SelectPlanDialog
from openlp.plugins.planningcenter.lib.customimport import PlanningCenterCustomImport from openlp.plugins.planningcenter.lib.customimport import PlanningCenterCustomImport
@ -49,8 +48,8 @@ class SelectPlanForm(QtWidgets.QDialog, Ui_SelectPlanDialog):
QtWidgets.QDialog.__init__(self, parent, QtCore.Qt.WindowSystemMenuHint | QtCore.Qt.WindowTitleHint) QtWidgets.QDialog.__init__(self, parent, QtCore.Qt.WindowSystemMenuHint | QtCore.Qt.WindowTitleHint)
self.plugin = plugin self.plugin = plugin
# create an Planning Center API Object # create an Planning Center API Object
application_id = Settings().value("planningcenter/application_id") application_id = Registry().get('settings').value("planningcenter/application_id")
secret = Settings().value("planningcenter/secret") secret = Registry().get('settings').value("planningcenter/secret")
self.planning_center_api = PlanningCenterAPI(application_id, secret) self.planning_center_api = PlanningCenterAPI(application_id, secret)
self.setup_ui(self) self.setup_ui(self)
self.service_type_combo_box.currentIndexChanged.connect(self.on_service_type_combobox_changed) self.service_type_combo_box.currentIndexChanged.connect(self.on_service_type_combobox_changed)

View File

@ -25,7 +25,6 @@ the settings tab for the PlanningCenter plugin
from PyQt5 import QtCore, QtWidgets from PyQt5 import QtCore, QtWidgets
from openlp.core.common.i18n import translate from openlp.core.common.i18n import translate
from openlp.core.common.settings import Settings
from openlp.core.lib.settingstab import SettingsTab from openlp.core.lib.settingstab import SettingsTab
from openlp.plugins.planningcenter.lib.planningcenter_api import PlanningCenterAPI from openlp.plugins.planningcenter.lib.planningcenter_api import PlanningCenterAPI
@ -105,11 +104,10 @@ below. Personal Access Tokens are created by doing the following:
""" """
Load the settings into the UI. Load the settings into the UI.
""" """
settings = Settings() self.settings.beginGroup(self.settings_section)
settings.beginGroup(self.settings_section) self.application_id = self.settings.value('application_id')
self.application_id = settings.value('application_id') self.secret = self.settings.value('secret')
self.secret = settings.value('secret') self.settings.endGroup()
settings.endGroup()
self.application_id_line_edit.setText(self.application_id) self.application_id_line_edit.setText(self.application_id)
self.secret_line_edit.setText(self.secret) self.secret_line_edit.setText(self.secret)
@ -117,11 +115,10 @@ below. Personal Access Tokens are created by doing the following:
""" """
Save the changes on exit of the Settings dialog. Save the changes on exit of the Settings dialog.
""" """
settings = Settings() self.settings.beginGroup(self.settings_section)
settings.beginGroup(self.settings_section) self.settings.setValue('application_id', self.application_id_line_edit.text())
settings.setValue('application_id', self.application_id_line_edit.text()) self.settings.setValue('secret', self.secret_line_edit.text())
settings.setValue('secret', self.secret_line_edit.text()) self.settings.endGroup()
settings.endGroup()
def on_test_credentials_button_clicked(self): def on_test_credentials_button_clicked(self):
""" """

View File

@ -25,7 +25,6 @@ from pathlib import Path
from PyQt5 import QtCore from PyQt5 import QtCore
from openlp.core.common.registry import Registry from openlp.core.common.registry import Registry
from openlp.core.common.settings import Settings
from openlp.core.lib import ServiceItemContext from openlp.core.lib import ServiceItemContext
from openlp.core.ui import HideMode from openlp.core.ui import HideMode
from openlp.plugins.presentations.lib.pdfcontroller import PDF_CONTROLLER_FILETYPES from openlp.plugins.presentations.lib.pdfcontroller import PDF_CONTROLLER_FILETYPES
@ -416,7 +415,7 @@ class MessageListener(object):
is_live = message[1] is_live = message[1]
if is_live: if is_live:
ret = self.live_handler.next() ret = self.live_handler.next()
if Settings().value('core/click live slide to unblank'): if Registry().get('settings').value('core/click live slide to unblank'):
Registry().execute('slidecontroller_live_unblank') Registry().execute('slidecontroller_live_unblank')
return ret return ret
else: else:
@ -431,7 +430,7 @@ class MessageListener(object):
is_live = message[1] is_live = message[1]
if is_live: if is_live:
ret = self.live_handler.previous() ret = self.live_handler.previous()
if Settings().value('core/click live slide to unblank'): if Registry().get('settings').value('core/click live slide to unblank'):
Registry().execute('slidecontroller_live_unblank') Registry().execute('slidecontroller_live_unblank')
return ret return ret
else: else:

View File

@ -24,8 +24,8 @@ from shutil import which
from subprocess import CalledProcessError, check_output from subprocess import CalledProcessError, check_output
from openlp.core.common import check_binary_exists, is_win from openlp.core.common import check_binary_exists, is_win
from openlp.core.common.registry import Registry
from openlp.core.common.applocation import AppLocation from openlp.core.common.applocation import AppLocation
from openlp.core.common.settings import Settings
from openlp.core.display.screens import ScreenList from openlp.core.display.screens import ScreenList
from openlp.plugins.presentations.lib.presentationcontroller import PresentationController, PresentationDocument from openlp.plugins.presentations.lib.presentationcontroller import PresentationController, PresentationDocument
@ -117,8 +117,8 @@ class PdfController(PresentationController):
self.gsbin = None self.gsbin = None
self.also_supports = [] self.also_supports = []
# Use the user defined program if given # Use the user defined program if given
if Settings().value('presentations/enable_pdf_program'): if Registry().get('settings').value('presentations/enable_pdf_program'):
program_path = Settings().value('presentations/pdf_program') program_path = Registry().get('settings').value('presentations/pdf_program')
program_type = self.process_check_binary(program_path) program_type = self.process_check_binary(program_path)
if program_type == 'gs': if program_type == 'gs':
self.gsbin = program_path self.gsbin = program_path

View File

@ -29,7 +29,6 @@ import logging
from openlp.core.common import is_win, trace_error_handler from openlp.core.common import is_win, trace_error_handler
from openlp.core.common.i18n import UiStrings from openlp.core.common.i18n import UiStrings
from openlp.core.common.registry import Registry from openlp.core.common.registry import Registry
from openlp.core.common.settings import Settings
from openlp.core.display.screens import ScreenList from openlp.core.display.screens import ScreenList
from openlp.core.lib.ui import critical_error_message_box, translate from openlp.core.lib.ui import critical_error_message_box, translate
from openlp.plugins.presentations.lib.presentationcontroller import PresentationController, PresentationDocument from openlp.plugins.presentations.lib.presentationcontroller import PresentationController, PresentationDocument
@ -328,7 +327,7 @@ class PowerpointDocument(PresentationDocument):
log.exception('Caught exception while in start_presentation') log.exception('Caught exception while in start_presentation')
trace_error_handler(log) trace_error_handler(log)
self.show_error_msg() self.show_error_msg()
if ppt_window and not Settings().value('presentations/powerpoint control window'): if ppt_window and not Registry().get('settings').value('presentations/powerpoint control window'):
try: try:
ppt_window.Top = size.y() * 72 / dpi ppt_window.Top = size.y() * 72 / dpi
ppt_window.Height = size.height() * 72 / dpi ppt_window.Height = size.height() * 72 / dpi
@ -422,7 +421,7 @@ class PowerpointDocument(PresentationDocument):
""" """
log.debug('goto_slide') log.debug('goto_slide')
try: try:
if Settings().value('presentations/powerpoint slide click advance') \ if Registry().get('settings').value('presentations/powerpoint slide click advance') \
and self.get_slide_number() == slide_no: and self.get_slide_number() == slide_no:
click_index = self.presentation.SlideShowWindow.View.GetClickIndex() click_index = self.presentation.SlideShowWindow.View.GetClickIndex()
click_count = self.presentation.SlideShowWindow.View.GetClickCount() click_count = self.presentation.SlideShowWindow.View.GetClickCount()

View File

@ -28,7 +28,6 @@ from openlp.core.common import md5_hash
from openlp.core.common.applocation import AppLocation from openlp.core.common.applocation import AppLocation
from openlp.core.common.path import create_paths from openlp.core.common.path import create_paths
from openlp.core.common.registry import Registry from openlp.core.common.registry import Registry
from openlp.core.common.settings import Settings
from openlp.core.lib import create_thumb, validate_thumb from openlp.core.lib import create_thumb, validate_thumb
@ -97,6 +96,7 @@ class PresentationDocument(object):
:rtype: None :rtype: None
""" """
self.controller = controller self.controller = controller
self.settings = Registry().get('settings')
self._setup(document_path) self._setup(document_path)
def _setup(self, document_path): def _setup(self, document_path):
@ -143,7 +143,7 @@ class PresentationDocument(object):
""" """
# TODO: Can be removed when the upgrade path to OpenLP 3.0 is no longer needed, also ensure code in # TODO: Can be removed when the upgrade path to OpenLP 3.0 is no longer needed, also ensure code in
# get_temp_folder and PresentationPluginapp_startup is removed # get_temp_folder and PresentationPluginapp_startup is removed
if Settings().value('presentations/thumbnail_scheme') == 'md5': if self.settings.value('presentations/thumbnail_scheme') == 'md5':
folder = md5_hash(bytes(self.file_path)) folder = md5_hash(bytes(self.file_path))
else: else:
folder = self.file_path.name folder = self.file_path.name
@ -158,7 +158,7 @@ class PresentationDocument(object):
""" """
# TODO: Can be removed when the upgrade path to OpenLP 3.0 is no longer needed, also ensure code in # TODO: Can be removed when the upgrade path to OpenLP 3.0 is no longer needed, also ensure code in
# get_thumbnail_folder and PresentationPluginapp_startup is removed # get_thumbnail_folder and PresentationPluginapp_startup is removed
if Settings().value('presentations/thumbnail_scheme') == 'md5': if self.settings.value('presentations/thumbnail_scheme') == 'md5':
folder = md5_hash(bytes(self.file_path)) folder = md5_hash(bytes(self.file_path))
else: else:
folder = self.file_path.name folder = self.file_path.name
@ -445,7 +445,7 @@ class PresentationController(object):
""" """
Return whether the controller is currently enabled Return whether the controller is currently enabled
""" """
if Settings().value(self.settings_section + '/' + self.name) == QtCore.Qt.Checked: if Registry().get('settings').value(self.settings_section + '/' + self.name) == QtCore.Qt.Checked:
return self.is_available() return self.is_available()
else: else:
return False return False

View File

@ -22,7 +22,6 @@
from PyQt5 import QtWidgets from PyQt5 import QtWidgets
from openlp.core.common.i18n import UiStrings, translate from openlp.core.common.i18n import UiStrings, translate
from openlp.core.common.settings import Settings
from openlp.core.lib.settingstab import SettingsTab from openlp.core.lib.settingstab import SettingsTab
from openlp.core.lib.ui import critical_error_message_box from openlp.core.lib.ui import critical_error_message_box
from openlp.core.widgets.edits import PathEdit from openlp.core.widgets.edits import PathEdit
@ -139,21 +138,21 @@ class PresentationTab(SettingsTab):
for key in self.controllers: for key in self.controllers:
controller = self.controllers[key] controller = self.controllers[key]
checkbox = self.presenter_check_boxes[controller.name] checkbox = self.presenter_check_boxes[controller.name]
checkbox.setChecked(Settings().value(self.settings_section + '/' + controller.name)) checkbox.setChecked(self.settings.value(self.settings_section + '/' + controller.name))
if controller.name == 'Powerpoint' and controller.is_available(): if controller.name == 'Powerpoint' and controller.is_available():
powerpoint_available = True powerpoint_available = True
self.override_app_check_box.setChecked(Settings().value(self.settings_section + '/override app')) self.override_app_check_box.setChecked(self.settings.value(self.settings_section + '/override app'))
# Load PowerPoint settings # Load PowerPoint settings
self.ppt_slide_click_check_box.setChecked(Settings().value(self.settings_section + self.ppt_slide_click_check_box.setChecked(self.settings.value(self.settings_section +
'/powerpoint slide click advance')) '/powerpoint slide click advance'))
self.ppt_slide_click_check_box.setEnabled(powerpoint_available) self.ppt_slide_click_check_box.setEnabled(powerpoint_available)
self.ppt_window_check_box.setChecked(Settings().value(self.settings_section + '/powerpoint control window')) self.ppt_window_check_box.setChecked(self.settings.value(self.settings_section + '/powerpoint control window'))
self.ppt_window_check_box.setEnabled(powerpoint_available) self.ppt_window_check_box.setEnabled(powerpoint_available)
# load pdf-program settings # load pdf-program settings
enable_pdf_program = Settings().value(self.settings_section + '/enable_pdf_program') enable_pdf_program = self.settings.value(self.settings_section + '/enable_pdf_program')
self.pdf_program_check_box.setChecked(enable_pdf_program) self.pdf_program_check_box.setChecked(enable_pdf_program)
self.program_path_edit.setEnabled(enable_pdf_program) self.program_path_edit.setEnabled(enable_pdf_program)
self.program_path_edit.path = Settings().value(self.settings_section + '/pdf_program') self.program_path_edit.path = self.settings.value(self.settings_section + '/pdf_program')
def save(self): def save(self):
""" """
@ -168,25 +167,25 @@ class PresentationTab(SettingsTab):
if controller.is_available(): if controller.is_available():
checkbox = self.presenter_check_boxes[controller.name] checkbox = self.presenter_check_boxes[controller.name]
setting_key = self.settings_section + '/' + controller.name setting_key = self.settings_section + '/' + controller.name
if Settings().value(setting_key) != checkbox.checkState(): if self.settings.value(setting_key) != checkbox.checkState():
changed = True changed = True
Settings().setValue(setting_key, checkbox.checkState()) self.settings.setValue(setting_key, checkbox.checkState())
if checkbox.isChecked(): if checkbox.isChecked():
controller.start_process() controller.start_process()
else: else:
controller.kill() controller.kill()
setting_key = self.settings_section + '/override app' setting_key = self.settings_section + '/override app'
if Settings().value(setting_key) != self.override_app_check_box.checkState(): if self.settings.value(setting_key) != self.override_app_check_box.checkState():
Settings().setValue(setting_key, self.override_app_check_box.checkState()) self.settings.setValue(setting_key, self.override_app_check_box.checkState())
changed = True changed = True
# Save powerpoint settings # Save powerpoint settings
setting_key = self.settings_section + '/powerpoint slide click advance' setting_key = self.settings_section + '/powerpoint slide click advance'
if Settings().value(setting_key) != self.ppt_slide_click_check_box.checkState(): if self.settings.value(setting_key) != self.ppt_slide_click_check_box.checkState():
Settings().setValue(setting_key, self.ppt_slide_click_check_box.checkState()) self.settings.setValue(setting_key, self.ppt_slide_click_check_box.checkState())
changed = True changed = True
setting_key = self.settings_section + '/powerpoint control window' setting_key = self.settings_section + '/powerpoint control window'
if Settings().value(setting_key) != self.ppt_window_check_box.checkState(): if self.settings.value(setting_key) != self.ppt_window_check_box.checkState():
Settings().setValue(setting_key, self.ppt_window_check_box.checkState()) self.settings.setValue(setting_key, self.ppt_window_check_box.checkState())
changed = True changed = True
# Save pdf-settings # Save pdf-settings
pdf_program_path = self.program_path_edit.path pdf_program_path = self.program_path_edit.path
@ -194,11 +193,11 @@ class PresentationTab(SettingsTab):
# If the given program is blank disable using the program # If the given program is blank disable using the program
if pdf_program_path is None: if pdf_program_path is None:
enable_pdf_program = 0 enable_pdf_program = 0
if pdf_program_path != Settings().value(self.settings_section + '/pdf_program'): if pdf_program_path != self.settings.value(self.settings_section + '/pdf_program'):
Settings().setValue(self.settings_section + '/pdf_program', pdf_program_path) self.settings.setValue(self.settings_section + '/pdf_program', pdf_program_path)
changed = True changed = True
if enable_pdf_program != Settings().value(self.settings_section + '/enable_pdf_program'): if enable_pdf_program != self.settings.value(self.settings_section + '/enable_pdf_program'):
Settings().setValue(self.settings_section + '/enable_pdf_program', enable_pdf_program) self.settings.setValue(self.settings_section + '/enable_pdf_program', enable_pdf_program)
changed = True changed = True
if changed: if changed:
self.settings_form.register_post_process('mediaitem_suffix_reset') self.settings_form.register_post_process('mediaitem_suffix_reset')

View File

@ -22,7 +22,7 @@
from PyQt5 import QtWidgets from PyQt5 import QtWidgets
from openlp.core.common.i18n import UiStrings, translate from openlp.core.common.i18n import UiStrings, translate
from openlp.core.common.settings import Settings from openlp.core.common.registry import Registry
from openlp.core.lib.ui import create_button_box from openlp.core.lib.ui import create_button_box
from openlp.core.ui.icons import UiIcons from openlp.core.ui.icons import UiIcons
from openlp.core.widgets.edits import SpellTextEdit from openlp.core.widgets.edits import SpellTextEdit
@ -68,7 +68,7 @@ class Ui_EditVerseDialog(object):
self.verse_type_layout.addWidget(self.insert_button) self.verse_type_layout.addWidget(self.insert_button)
self.verse_type_layout.addStretch() self.verse_type_layout.addStretch()
self.dialog_layout.addLayout(self.verse_type_layout) self.dialog_layout.addLayout(self.verse_type_layout)
if Settings().value('songs/enable chords'): if Registry().get('settings').value('songs/enable chords'):
self.transpose_layout = QtWidgets.QHBoxLayout() self.transpose_layout = QtWidgets.QHBoxLayout()
self.transpose_layout.setObjectName('transpose_layout') self.transpose_layout.setObjectName('transpose_layout')
self.transpose_label = QtWidgets.QLabel(edit_verse_dialog) self.transpose_label = QtWidgets.QLabel(edit_verse_dialog)
@ -105,7 +105,7 @@ class Ui_EditVerseDialog(object):
self.insert_button.setText(translate('SongsPlugin.EditVerseForm', '&Insert')) self.insert_button.setText(translate('SongsPlugin.EditVerseForm', '&Insert'))
self.insert_button.setToolTip(translate('SongsPlugin.EditVerseForm', self.insert_button.setToolTip(translate('SongsPlugin.EditVerseForm',
'Split a slide into two by inserting a verse splitter.')) 'Split a slide into two by inserting a verse splitter.'))
if Settings().value('songs/enable chords'): if Registry().get('settings').value('songs/enable chords'):
self.transpose_label.setText(translate('SongsPlugin.EditVerseForm', 'Transpose:')) self.transpose_label.setText(translate('SongsPlugin.EditVerseForm', 'Transpose:'))
self.transpose_up_button.setText(translate('SongsPlugin.EditVerseForm', 'Up')) self.transpose_up_button.setText(translate('SongsPlugin.EditVerseForm', 'Up'))
self.transpose_down_button.setText(translate('SongsPlugin.EditVerseForm', 'Down')) self.transpose_down_button.setText(translate('SongsPlugin.EditVerseForm', 'Down'))

View File

@ -25,7 +25,7 @@ import re
from PyQt5 import QtCore, QtGui, QtWidgets from PyQt5 import QtCore, QtGui, QtWidgets
from openlp.core.common.i18n import translate from openlp.core.common.i18n import translate
from openlp.core.common.settings import Settings from openlp.core.common.registry import Registry
from openlp.core.lib.ui import critical_error_message_box from openlp.core.lib.ui import critical_error_message_box
from openlp.plugins.songs.forms.editversedialog import Ui_EditVerseDialog from openlp.plugins.songs.forms.editversedialog import Ui_EditVerseDialog
from openlp.plugins.songs.lib import VerseType, transpose_lyrics from openlp.plugins.songs.lib import VerseType, transpose_lyrics
@ -53,7 +53,7 @@ class EditVerseForm(QtWidgets.QDialog, Ui_EditVerseDialog):
self.verse_text_edit.cursorPositionChanged.connect(self.on_cursor_position_changed) self.verse_text_edit.cursorPositionChanged.connect(self.on_cursor_position_changed)
self.verse_type_combo_box.currentIndexChanged.connect(self.on_verse_type_combo_box_changed) self.verse_type_combo_box.currentIndexChanged.connect(self.on_verse_type_combo_box_changed)
self.forced_split_button.clicked.connect(self.on_forced_split_button_clicked) self.forced_split_button.clicked.connect(self.on_forced_split_button_clicked)
if Settings().value('songs/enable chords'): if Registry().get('settings').value('songs/enable chords'):
self.transpose_down_button.clicked.connect(self.on_transpose_down_button_clicked) self.transpose_down_button.clicked.connect(self.on_transpose_down_button_clicked)
self.transpose_up_button.clicked.connect(self.on_transpose_up_button_clicked) self.transpose_up_button.clicked.connect(self.on_transpose_up_button_clicked)
@ -231,7 +231,7 @@ class EditVerseForm(QtWidgets.QDialog, Ui_EditVerseDialog):
""" """
Test if any invalid chords has been entered before closing the verse editor Test if any invalid chords has been entered before closing the verse editor
""" """
if Settings().value('songs/enable chords'): if Registry().get('settings').value('songs/enable chords'):
try: try:
transpose_lyrics(self.verse_text_edit.toPlainText(), 1) transpose_lyrics(self.verse_text_edit.toPlainText(), 1)
super(EditVerseForm, self).accept() super(EditVerseForm, self).accept()

View File

@ -28,7 +28,6 @@ from PyQt5 import QtCore, QtWidgets
from openlp.core.common.i18n import UiStrings, translate from openlp.core.common.i18n import UiStrings, translate
from openlp.core.common.registry import Registry from openlp.core.common.registry import Registry
from openlp.core.common.settings import Settings
from openlp.core.lib import create_separated_list from openlp.core.lib import create_separated_list
from openlp.core.lib.ui import critical_error_message_box from openlp.core.lib.ui import critical_error_message_box
from openlp.core.common.i18n import get_natural_key from openlp.core.common.i18n import get_natural_key
@ -128,7 +127,7 @@ class SongExportForm(OpenLPWizard):
self.output_directory_path_edit = PathEdit( self.output_directory_path_edit = PathEdit(
self.export_song_page, PathEditType.Directories, self.export_song_page, PathEditType.Directories,
dialog_caption=translate('SongsPlugin.ExportWizardForm', 'Select Destination Folder'), show_revert=False) dialog_caption=translate('SongsPlugin.ExportWizardForm', 'Select Destination Folder'), show_revert=False)
self.output_directory_path_edit.path = Settings().value('songs/last directory export') self.output_directory_path_edit.path = self.settings.value('songs/last directory export')
self.directory_label = QtWidgets.QLabel(self.export_song_page) self.directory_label = QtWidgets.QLabel(self.export_song_page)
self.directory_label.setObjectName('directory_label') self.directory_label.setObjectName('directory_label')
self.grid_layout.addWidget(self.directory_label, 0, 0) self.grid_layout.addWidget(self.directory_label, 0, 0)
@ -191,7 +190,7 @@ class SongExportForm(OpenLPWizard):
translate('SongsPlugin.ExportWizardForm', 'No Save Location specified'), translate('SongsPlugin.ExportWizardForm', 'No Save Location specified'),
translate('SongsPlugin.ExportWizardForm', 'You need to specify a directory.')) translate('SongsPlugin.ExportWizardForm', 'You need to specify a directory.'))
return False return False
Settings().setValue('songs/last directory export', self.output_directory_path_edit.path) self.settings.setValue('songs/last directory export', self.output_directory_path_edit.path)
return True return True
elif self.currentPage() == self.progress_page: elif self.currentPage() == self.progress_page:
self.available_list_widget.clear() self.available_list_widget.clear()

View File

@ -27,7 +27,6 @@ from PyQt5 import QtCore, QtWidgets
from openlp.core.common.i18n import UiStrings, translate from openlp.core.common.i18n import UiStrings, translate
from openlp.core.common.mixins import RegistryProperties from openlp.core.common.mixins import RegistryProperties
from openlp.core.common.settings import Settings
from openlp.core.lib.ui import critical_error_message_box from openlp.core.lib.ui import critical_error_message_box
from openlp.core.widgets.dialogs import FileDialog from openlp.core.widgets.dialogs import FileDialog
from openlp.core.widgets.edits import PathEdit from openlp.core.widgets.edits import PathEdit
@ -198,7 +197,7 @@ class SongImportForm(OpenLPWizard, RegistryProperties):
return True return True
elif self.currentPage() == self.source_page: elif self.currentPage() == self.source_page:
this_format = self.current_format this_format = self.current_format
Settings().setValue('songs/last import type', this_format) self.settings.setValue('songs/last import type', this_format)
select_mode, class_, error_msg = SongFormat.get(this_format, 'selectMode', 'class', 'invalidSourceMsg') select_mode, class_, error_msg = SongFormat.get(this_format, 'selectMode', 'class', 'invalidSourceMsg')
if select_mode == SongFormatSelect.MultipleFiles: if select_mode == SongFormatSelect.MultipleFiles:
import_source = self.get_list_of_paths(self.format_widgets[this_format]['file_list_widget']) import_source = self.get_list_of_paths(self.format_widgets[this_format]['file_list_widget'])
@ -232,13 +231,13 @@ class SongImportForm(OpenLPWizard, RegistryProperties):
filters += '{text} (*)'.format(text=UiStrings().AllFiles) filters += '{text} (*)'.format(text=UiStrings().AllFiles)
file_paths, filter_used = FileDialog.getOpenFileNames( file_paths, filter_used = FileDialog.getOpenFileNames(
self, title, self, title,
Settings().value(self.plugin.settings_section + '/last directory import'), filters) self.settings.value(self.plugin.settings_section + '/last directory import'), filters)
for file_path in file_paths: for file_path in file_paths:
list_item = QtWidgets.QListWidgetItem(str(file_path)) list_item = QtWidgets.QListWidgetItem(str(file_path))
list_item.setData(QtCore.Qt.UserRole, file_path) list_item.setData(QtCore.Qt.UserRole, file_path)
listbox.addItem(list_item) listbox.addItem(list_item)
if file_paths: if file_paths:
Settings().setValue(self.plugin.settings_section + '/last directory import', file_paths[0].parent) self.settings.setValue(self.plugin.settings_section + '/last directory import', file_paths[0].parent)
def get_list_of_paths(self, list_box): def get_list_of_paths(self, list_box):
""" """
@ -290,7 +289,7 @@ class SongImportForm(OpenLPWizard, RegistryProperties):
self.restart() self.restart()
self.finish_button.setVisible(False) self.finish_button.setVisible(False)
self.cancel_button.setVisible(True) self.cancel_button.setVisible(True)
last_import_type = Settings().value('songs/last import type') last_import_type = self.settings.value('songs/last import type')
if last_import_type < 0 or last_import_type >= self.format_combo_box.count(): if last_import_type < 0 or last_import_type >= self.format_combo_box.count():
last_import_type = 0 last_import_type = 0
self.format_combo_box.setCurrentIndex(last_import_type) self.format_combo_box.setCurrentIndex(last_import_type)
@ -349,7 +348,7 @@ class SongImportForm(OpenLPWizard, RegistryProperties):
:rtype: None :rtype: None
""" """
file_path, filter_used = FileDialog.getSaveFileName( file_path, filter_used = FileDialog.getSaveFileName(
self, Settings().value(self.plugin.settings_section + '/last directory import')) self, self.settings.value(self.plugin.settings_section + '/last directory import'))
if file_path is None: if file_path is None:
return return
file_path.write_text(self.error_report_text_edit.toPlainText(), encoding='utf-8') file_path.write_text(self.error_report_text_edit.toPlainText(), encoding='utf-8')
@ -400,7 +399,7 @@ class SongImportForm(OpenLPWizard, RegistryProperties):
path_edit.filters = filters + ';;' + path_edit.filters path_edit.filters = filters + ';;' + path_edit.filters
else: else:
path_edit.filters = filters path_edit.filters = filters
path_edit.path = Settings().value(self.plugin.settings_section + '/last directory import') path_edit.path = self.settings.value(self.plugin.settings_section + '/last directory import')
file_path_layout.addWidget(path_edit) file_path_layout.addWidget(path_edit)
import_layout.addLayout(file_path_layout) import_layout.addLayout(file_path_layout)
import_layout.addSpacerItem(self.stack_spacer) import_layout.addSpacerItem(self.stack_spacer)

View File

@ -28,7 +28,6 @@ from PyQt5 import QtCore, QtWidgets
from openlp.core.common.i18n import translate from openlp.core.common.i18n import translate
from openlp.core.common.mixins import RegistryProperties from openlp.core.common.mixins import RegistryProperties
from openlp.core.common.settings import Settings
from openlp.core.threading import ThreadWorker, run_thread from openlp.core.threading import ThreadWorker, run_thread
from openlp.plugins.songs.forms.songselectdialog import Ui_SongSelectDialog from openlp.plugins.songs.forms.songselectdialog import Ui_SongSelectDialog
from openlp.plugins.songs.lib.songselect import SongSelectImport from openlp.plugins.songs.lib.songselect import SongSelectImport
@ -118,13 +117,13 @@ class SongSelectForm(QtWidgets.QDialog, Ui_SongSelectDialog, RegistryProperties)
self.search_combobox.clear() self.search_combobox.clear()
self.search_results_widget.clear() self.search_results_widget.clear()
self.view_button.setEnabled(False) self.view_button.setEnabled(False)
if Settings().contains(self.plugin.settings_section + '/songselect password'): if self.settings.contains(self.plugin.settings_section + '/songselect password'):
self.username_edit.setText(Settings().value(self.plugin.settings_section + '/songselect username')) self.username_edit.setText(self.settings.value(self.plugin.settings_section + '/songselect username'))
self.password_edit.setText(Settings().value(self.plugin.settings_section + '/songselect password')) self.password_edit.setText(self.settings.value(self.plugin.settings_section + '/songselect password'))
self.save_password_checkbox.setChecked(True) self.save_password_checkbox.setChecked(True)
if Settings().contains(self.plugin.settings_section + '/songselect searches'): if self.settings.contains(self.plugin.settings_section + '/songselect searches'):
self.search_combobox.addItems( self.search_combobox.addItems(
Settings().value(self.plugin.settings_section + '/songselect searches').split('|')) self.settings.value(self.plugin.settings_section + '/songselect searches').split('|'))
self.username_edit.setFocus() self.username_edit.setFocus()
return QtWidgets.QDialog.exec(self) return QtWidgets.QDialog.exec(self)
@ -281,11 +280,11 @@ class SongSelectForm(QtWidgets.QDialog, Ui_SongSelectDialog, RegistryProperties)
'in the public domain.') 'in the public domain.')
) )
if self.save_password_checkbox.isChecked(): if self.save_password_checkbox.isChecked():
Settings().setValue(self.plugin.settings_section + '/songselect username', self.username_edit.text()) self.settings.setValue(self.plugin.settings_section + '/songselect username', self.username_edit.text())
Settings().setValue(self.plugin.settings_section + '/songselect password', self.password_edit.text()) self.settings.setValue(self.plugin.settings_section + '/songselect password', self.password_edit.text())
else: else:
Settings().remove(self.plugin.settings_section + '/songselect username') self.settings.remove(self.plugin.settings_section + '/songselect username')
Settings().remove(self.plugin.settings_section + '/songselect password') self.settings.remove(self.plugin.settings_section + '/songselect password')
self.stacked_widget.setCurrentIndex(1) self.stacked_widget.setCurrentIndex(1)
self.login_progress_bar.setVisible(False) self.login_progress_bar.setVisible(False)
self.login_progress_bar.setValue(0) self.login_progress_bar.setValue(0)
@ -315,7 +314,7 @@ class SongSelectForm(QtWidgets.QDialog, Ui_SongSelectDialog, RegistryProperties)
self.application.process_events() self.application.process_events()
self.song_count = 0 self.song_count = 0
search_history = self.search_combobox.getItems() search_history = self.search_combobox.getItems()
Settings().setValue(self.plugin.settings_section + '/songselect searches', '|'.join(search_history)) self.settings.setValue(self.plugin.settings_section + '/songselect searches', '|'.join(search_history))
# Create thread and run search # Create thread and run search
worker = SearchWorker(self.song_select_importer, self.search_combobox.currentText()) worker = SearchWorker(self.song_select_importer, self.search_combobox.currentText())
worker.show_info.connect(self.on_search_show_info) worker.show_info.connect(self.on_search_show_info)

View File

@ -30,7 +30,7 @@ from PyQt5 import QtWidgets
from openlp.core.common import CONTROL_CHARS from openlp.core.common import CONTROL_CHARS
from openlp.core.common.applocation import AppLocation from openlp.core.common.applocation import AppLocation
from openlp.core.common.i18n import translate from openlp.core.common.i18n import translate
from openlp.core.common.settings import Settings from openlp.core.common.registry import Registry
from openlp.core.display.render import remove_tags from openlp.core.display.render import remove_tags
from openlp.plugins.songs.lib.db import Author, MediaFile, Song from openlp.plugins.songs.lib.db import Author, MediaFile, Song
from openlp.plugins.songs.lib.ui import SongStrings from openlp.plugins.songs.lib.ui import SongStrings
@ -558,7 +558,7 @@ def transpose_lyrics(lyrics, transpose_value):
# Split text by verse delimiter - both normal and optional # Split text by verse delimiter - both normal and optional
verse_list = re.split(r'(---\[.+?:.+?\]---|\[---\])', lyrics) verse_list = re.split(r'(---\[.+?:.+?\]---|\[---\])', lyrics)
transposed_lyrics = '' transposed_lyrics = ''
notation = Settings().value('songs/chord notation') notation = Registry().get('settings').value('songs/chord notation')
for verse in verse_list: for verse in verse_list:
if verse.startswith('---[') or verse == '[---]': if verse.startswith('---[') or verse == '[---]':
transposed_lyrics += verse transposed_lyrics += verse

View File

@ -26,7 +26,6 @@ import logging
import re import re
from openlp.core.common.i18n import translate from openlp.core.common.i18n import translate
from openlp.core.common.settings import Settings
from openlp.plugins.songs.lib.importers.songimport import SongImport from openlp.plugins.songs.lib.importers.songimport import SongImport
from openlp.plugins.songs.lib.db import AuthorType from openlp.plugins.songs.lib.db import AuthorType
@ -109,8 +108,8 @@ class ChordProImport(SongImport):
if current_verse.strip(): if current_verse.strip():
# Add collected verse to the lyrics # Add collected verse to the lyrics
# Strip out chords if set up to # Strip out chords if set up to
if not Settings().value('songs/enable chords') or Settings().value( if not self.settings.value('songs/enable chords') or \
'songs/disable chords import'): self.settings.value('songs/disable chords import'):
current_verse = re.sub(r'\[.*?\]', '', current_verse) current_verse = re.sub(r'\[.*?\]', '', current_verse)
self.add_verse(current_verse.rstrip(), current_verse_type) self.add_verse(current_verse.rstrip(), current_verse_type)
current_verse_type = 'v' current_verse_type = 'v'
@ -123,7 +122,8 @@ class ChordProImport(SongImport):
elif tag_name in ['end_of_chorus', 'eoc']: elif tag_name in ['end_of_chorus', 'eoc']:
# Add collected chorus to the lyrics # Add collected chorus to the lyrics
# Strip out chords if set up to # Strip out chords if set up to
if not Settings().value('songs/enable chords') or Settings().value('songs/disable chords import'): if not self.settings.value('songs/enable chords') or \
self.settings.value('songs/disable chords import'):
current_verse = re.sub(r'\[.*?\]', '', current_verse) current_verse = re.sub(r'\[.*?\]', '', current_verse)
self.add_verse(current_verse.rstrip(), current_verse_type) self.add_verse(current_verse.rstrip(), current_verse_type)
current_verse_type = 'v' current_verse_type = 'v'
@ -132,8 +132,8 @@ class ChordProImport(SongImport):
if current_verse.strip(): if current_verse.strip():
# Add collected verse to the lyrics # Add collected verse to the lyrics
# Strip out chords if set up to # Strip out chords if set up to
if not Settings().value('songs/enable chords') or Settings().value( if not self.settings.value('songs/enable chords') or \
'songs/disable chords import'): self.settings.value('songs/disable chords import'):
current_verse = re.sub(r'\[.*?\]', '', current_verse) current_verse = re.sub(r'\[.*?\]', '', current_verse)
self.add_verse(current_verse.rstrip(), current_verse_type) self.add_verse(current_verse.rstrip(), current_verse_type)
current_verse_type = 'v' current_verse_type = 'v'
@ -146,8 +146,8 @@ class ChordProImport(SongImport):
if self.verses and self.title: if self.verses and self.title:
if current_verse.strip(): if current_verse.strip():
# Strip out chords if set up to # Strip out chords if set up to
if not Settings().value('songs/enable chords') or Settings().value( if not self.settings.value('songs/enable chords') or \
'songs/disable chords import'): self.settings.value('songs/disable chords import'):
current_verse = re.sub(r'\[.*?\]', '', current_verse) current_verse = re.sub(r'\[.*?\]', '', current_verse)
self.add_verse(current_verse.rstrip(), current_verse_type) self.add_verse(current_verse.rstrip(), current_verse_type)
if not self.finish(): if not self.finish():
@ -170,7 +170,8 @@ class ChordProImport(SongImport):
elif line == '' and current_verse.strip() and current_verse_type != 'c': elif line == '' and current_verse.strip() and current_verse_type != 'c':
# Add collected verse to the lyrics # Add collected verse to the lyrics
# Strip out chords if set up to # Strip out chords if set up to
if not Settings().value('songs/enable chords') or Settings().value('songs/disable chords import'): if not self.settings.value('songs/enable chords') or \
self.settings.value('songs/disable chords import'):
current_verse = re.sub(r'\[.*?\]', '', current_verse) current_verse = re.sub(r'\[.*?\]', '', current_verse)
self.add_verse(current_verse.rstrip(), current_verse_type) self.add_verse(current_verse.rstrip(), current_verse_type)
current_verse_type = 'v' current_verse_type = 'v'
@ -182,7 +183,7 @@ class ChordProImport(SongImport):
current_verse += line + '\n' current_verse += line + '\n'
if current_verse.strip(): if current_verse.strip():
# Strip out chords if set up to # Strip out chords if set up to
if not Settings().value('songs/enable chords') or Settings().value( if not self.settings.value('songs/enable chords') or self.settings.value(
'songs/disable chords import'): 'songs/disable chords import'):
current_verse = re.sub(r'\[.*?\]', '', current_verse) current_verse = re.sub(r'\[.*?\]', '', current_verse)
self.add_verse(current_verse.rstrip(), current_verse_type) self.add_verse(current_verse.rstrip(), current_verse_type)

View File

@ -25,7 +25,6 @@ from lxml import objectify, etree
from openlp.core.common import normalize_str from openlp.core.common import normalize_str
from openlp.core.common.i18n import translate from openlp.core.common.i18n import translate
from openlp.core.common.settings import Settings
from openlp.plugins.songs.lib import VerseType from openlp.plugins.songs.lib import VerseType
from openlp.plugins.songs.lib.importers.songimport import SongImport from openlp.plugins.songs.lib.importers.songimport import SongImport
from openlp.plugins.songs.lib.ui import SongStrings from openlp.plugins.songs.lib.ui import SongStrings
@ -254,7 +253,7 @@ class OpenSongImport(SongImport):
verses[verse_tag][verse_num][inst] = [] verses[verse_tag][verse_num][inst] = []
our_verse_order.append([verse_tag, verse_num, inst]) our_verse_order.append([verse_tag, verse_num, inst])
# If chords exists insert them # If chords exists insert them
if chords and Settings().value('songs/enable chords') and not Settings().value( if chords and self.settings.value('songs/enable chords') and not self.settings.value(
'songs/disable chords import'): 'songs/disable chords import'):
offset = 0 offset = 0
for (column, chord) in chords: for (column, chord) in chords:

View File

@ -30,7 +30,6 @@ from pathlib import Path
from openlp.core.common import get_file_encoding, is_macosx, is_win from openlp.core.common import get_file_encoding, is_macosx, is_win
from openlp.core.common.i18n import translate from openlp.core.common.i18n import translate
from openlp.core.common.settings import Settings
from openlp.plugins.songs.lib import VerseType from openlp.plugins.songs.lib import VerseType
from openlp.plugins.songs.lib.importers.songimport import SongImport from openlp.plugins.songs.lib.importers.songimport import SongImport
@ -223,7 +222,7 @@ class SongBeamerImport(SongImport):
:param linenumber: Number of the current line :param linenumber: Number of the current line
:param line: The line of lyrics to insert chords :param line: The line of lyrics to insert chords
""" """
if self.chord_table and Settings().value('songs/enable chords') and not Settings().value( if self.chord_table and self.settings.value('songs/enable chords') and not self.settings.value(
'songs/disable chords import') and line_number in self.chord_table: 'songs/disable chords import') and line_number in self.chord_table:
line_idx = sorted(self.chord_table[line_number].keys(), reverse=True) line_idx = sorted(self.chord_table[line_number].keys(), reverse=True)
for idx in line_idx: for idx in line_idx:

View File

@ -78,6 +78,7 @@ class SongImport(QtCore.QObject):
self.stop_import_flag = False self.stop_import_flag = False
self.set_defaults() self.set_defaults()
Registry().register_function('openlp_stop_wizard', self.stop_import) Registry().register_function('openlp_stop_wizard', self.stop_import)
self.settings = Registry().get('settings')
def set_defaults(self): def set_defaults(self):
""" """

View File

@ -27,7 +27,6 @@ import re
from pathlib import Path from pathlib import Path
from openlp.core.common.i18n import translate from openlp.core.common.i18n import translate
from openlp.core.common.settings import Settings
from openlp.plugins.songs.lib.db import AuthorType from openlp.plugins.songs.lib.db import AuthorType
from openlp.plugins.songs.lib.importers.songimport import SongImport from openlp.plugins.songs.lib.importers.songimport import SongImport
@ -125,7 +124,8 @@ class VideoPsalmImport(SongImport):
continue continue
verse_text = verse['Text'] verse_text = verse['Text']
# Strip out chords if set up to # Strip out chords if set up to
if not Settings().value('songs/enable chords') or Settings().value('songs/disable chords import'): if not self.settings.value('songs/enable chords') or \
self.settings.value('songs/disable chords import'):
verse_text = re.sub(r'\[.*?\]', '', verse_text) verse_text = re.sub(r'\[.*?\]', '', verse_text)
self.add_verse(verse_text, 'v') self.add_verse(verse_text, 'v')
if not self.finish(): if not self.finish():

View File

@ -61,7 +61,7 @@ import re
from lxml import etree, objectify from lxml import etree, objectify
from openlp.core.common.i18n import translate from openlp.core.common.i18n import translate
from openlp.core.common.settings import Settings from openlp.core.common.registry import Registry
from openlp.core.lib.formattingtags import FormattingTags from openlp.core.lib.formattingtags import FormattingTags
from openlp.core.version import get_version from openlp.core.version import get_version
from openlp.plugins.songs.lib import VerseType, clean_song from openlp.plugins.songs.lib import VerseType, clean_song
@ -625,7 +625,8 @@ class OpenLyrics(object):
return text return text
# Convert chords to ChordPro format which OpenLP uses internally # Convert chords to ChordPro format which OpenLP uses internally
elif element.tag == NSMAP.format(tag='chord'): elif element.tag == NSMAP.format(tag='chord'):
if Settings().value('songs/enable chords') and not Settings().value('songs/disable chords import'): if Registry().get('settings').value('songs/enable chords') and not \
Registry().get('settings').value('songs/disable chords import'):
text += '[{chord}]'.format(chord=element.get('name')) text += '[{chord}]'.format(chord=element.get('name'))
if element.tail: if element.tail:
# Append tail text at chord element. # Append tail text at chord element.

View File

@ -22,7 +22,6 @@
from PyQt5 import QtCore, QtWidgets from PyQt5 import QtCore, QtWidgets
from openlp.core.common.i18n import translate from openlp.core.common.i18n import translate
from openlp.core.common.settings import Settings
from openlp.core.lib.settingstab import SettingsTab from openlp.core.lib.settingstab import SettingsTab
from openlp.plugins.songs.lib.db import AuthorType from openlp.plugins.songs.lib.db import AuthorType
@ -211,19 +210,18 @@ class SongsTab(SettingsTab):
self.chord_notation = 'neo-latin' self.chord_notation = 'neo-latin'
def on_footer_reset_button_clicked(self): def on_footer_reset_button_clicked(self):
self.footer_edit_box.setPlainText(Settings().get_default_value('songs/footer template')) self.footer_edit_box.setPlainText(self.settings.get_default_value('songs/footer template'))
def load(self): def load(self):
settings = Settings() self.settings.beginGroup(self.settings_section)
settings.beginGroup(self.settings_section) self.tool_bar = self.settings.value('display songbar')
self.tool_bar = settings.value('display songbar') self.update_edit = self.settings.value('update service on edit')
self.update_edit = settings.value('update service on edit') self.update_load = self.settings.value('add song from service')
self.update_load = settings.value('add song from service') self.songbook_slide = self.settings.value('add songbook slide')
self.songbook_slide = settings.value('add songbook slide') self.enable_chords = self.settings.value('enable chords')
self.enable_chords = settings.value('enable chords') self.chord_notation = self.settings.value('chord notation')
self.chord_notation = settings.value('chord notation') self.mainview_chords = self.settings.value('mainview chords')
self.mainview_chords = settings.value('mainview chords') self.disable_chords_import = self.settings.value('disable chords import')
self.disable_chords_import = settings.value('disable chords import')
self.tool_bar_active_check_box.setChecked(self.tool_bar) self.tool_bar_active_check_box.setChecked(self.tool_bar)
self.update_on_edit_check_box.setChecked(self.update_edit) self.update_on_edit_check_box.setChecked(self.update_edit)
self.add_from_service_check_box.setChecked(self.update_load) self.add_from_service_check_box.setChecked(self.update_load)
@ -236,24 +234,23 @@ class SongsTab(SettingsTab):
self.neolatin_notation_radio_button.setChecked(True) self.neolatin_notation_radio_button.setChecked(True)
else: else:
self.english_notation_radio_button.setChecked(True) self.english_notation_radio_button.setChecked(True)
self.footer_edit_box.setPlainText(settings.value('footer template')) self.footer_edit_box.setPlainText(self.settings.value('footer template'))
settings.endGroup() self.settings.endGroup()
def save(self): def save(self):
settings = Settings() self.settings.beginGroup(self.settings_section)
settings.beginGroup(self.settings_section) self.settings.setValue('display songbar', self.tool_bar)
settings.setValue('display songbar', self.tool_bar) self.settings.setValue('update service on edit', self.update_edit)
settings.setValue('update service on edit', self.update_edit) self.settings.setValue('add song from service', self.update_load)
settings.setValue('add song from service', self.update_load) self.settings.setValue('enable chords', self.chords_group_box.isChecked())
settings.setValue('enable chords', self.chords_group_box.isChecked()) self.settings.setValue('mainview chords', self.mainview_chords)
settings.setValue('mainview chords', self.mainview_chords) self.settings.setValue('disable chords import', self.disable_chords_import)
settings.setValue('disable chords import', self.disable_chords_import) self.settings.setValue('chord notation', self.chord_notation)
settings.setValue('chord notation', self.chord_notation)
# Only save footer template if it has been changed. This allows future updates # Only save footer template if it has been changed. This allows future updates
if self.footer_edit_box.toPlainText() != Settings().get_default_value('songs/footer template'): if self.footer_edit_box.toPlainText() != self.settings.get_default_value('songs/footer template'):
settings.setValue('footer template', self.footer_edit_box.toPlainText()) self.settings.setValue('footer template', self.footer_edit_box.toPlainText())
settings.setValue('add songbook slide', self.songbook_slide) self.settings.setValue('add songbook slide', self.songbook_slide)
settings.endGroup() self.settings.endGroup()
if self.tab_visited: if self.tab_visited:
self.settings_form.register_post_process('songs_config_updated') self.self.settings_form.register_post_process('songs_config_updated')
self.tab_visited = False self.tab_visited = False

View File

@ -51,6 +51,7 @@ class TestImageMediaItem(TestCase, TestMixin):
Registry().register('settings_form', MagicMock()) Registry().register('settings_form', MagicMock())
self.setup_application() self.setup_application()
self.build_settings() self.build_settings()
Registry().register('settings', Settings())
Settings().extend_default_settings(__default_settings__) Settings().extend_default_settings(__default_settings__)
self.parent = QtWidgets.QMainWindow() self.parent = QtWidgets.QMainWindow()
self.form = ImageTab(self.parent, 'Images', None, None) self.form = ImageTab(self.parent, 'Images', None, None)

View File

@ -26,6 +26,8 @@ from tempfile import mkdtemp
from unittest import TestCase from unittest import TestCase
from unittest.mock import MagicMock, call, patch from unittest.mock import MagicMock, call, patch
from openlp.core.common.registry import Registry
from openlp.core.common.settings import Settings
from openlp.plugins.presentations.lib.impresscontroller import ImpressController, ImpressDocument, TextType from openlp.plugins.presentations.lib.impresscontroller import ImpressController, ImpressDocument, TextType
from tests.helpers.testmixin import TestMixin from tests.helpers.testmixin import TestMixin
from tests.utils.constants import RESOURCE_PATH from tests.utils.constants import RESOURCE_PATH
@ -167,6 +169,9 @@ class TestImpressDocument(TestCase):
mocked_plugin = MagicMock() mocked_plugin = MagicMock()
mocked_plugin.settings_section = 'presentations' mocked_plugin.settings_section = 'presentations'
self.file_name = RESOURCE_PATH / 'presentations' / 'test.pptx' self.file_name = RESOURCE_PATH / 'presentations' / 'test.pptx'
self.settings = Settings()
Registry.create()
Registry().register('settings', self.settings)
self.ppc = ImpressController(mocked_plugin) self.ppc = ImpressController(mocked_plugin)
self.doc = ImpressDocument(self.ppc, self.file_name) self.doc = ImpressDocument(self.ppc, self.file_name)

View File

@ -33,6 +33,7 @@ from PyQt5 import QtCore, QtGui
from openlp.core.common import is_macosx, is_linux, is_win from openlp.core.common import is_macosx, is_linux, is_win
from openlp.core.common.settings import Settings from openlp.core.common.settings import Settings
from openlp.core.common.registry import Registry
from openlp.core.display.screens import ScreenList from openlp.core.display.screens import ScreenList
from openlp.plugins.presentations.lib.pdfcontroller import PdfController, PdfDocument from openlp.plugins.presentations.lib.pdfcontroller import PdfController, PdfDocument
from tests.helpers.testmixin import TestMixin from tests.helpers.testmixin import TestMixin
@ -89,6 +90,7 @@ class TestPdfController(TestCase, TestMixin):
self.desktop.screenGeometry.return_value = SCREEN['size'] self.desktop.screenGeometry.return_value = SCREEN['size']
self.screens = ScreenList.create(self.desktop) self.screens = ScreenList.create(self.desktop)
Settings().extend_default_settings(__default_settings__) Settings().extend_default_settings(__default_settings__)
Registry().register('settings', Settings())
self.temp_folder_path = Path(mkdtemp()) self.temp_folder_path = Path(mkdtemp())
self.thumbnail_folder_path = Path(mkdtemp()) self.thumbnail_folder_path = Path(mkdtemp())
self.mock_plugin = MagicMock() self.mock_plugin = MagicMock()
@ -99,6 +101,7 @@ class TestPdfController(TestCase, TestMixin):
Delete all the C++ objects at the end so that we don't have a segfault Delete all the C++ objects at the end so that we don't have a segfault
""" """
del self.screens del self.screens
Registry().remove('settings')
self.destroy_settings() self.destroy_settings()
rmtree(self.thumbnail_folder_path) rmtree(self.thumbnail_folder_path)
rmtree(self.temp_folder_path) rmtree(self.temp_folder_path)

View File

@ -28,6 +28,7 @@ from unittest import TestCase
from unittest.mock import MagicMock, patch from unittest.mock import MagicMock, patch
from openlp.core.common import is_win from openlp.core.common import is_win
from openlp.core.common.registry import Registry
from openlp.core.common.settings import Settings from openlp.core.common.settings import Settings
from openlp.plugins.presentations.lib.powerpointcontroller import PowerpointController, PowerpointDocument, \ from openlp.plugins.presentations.lib.powerpointcontroller import PowerpointController, PowerpointDocument, \
_get_text_from_shapes _get_text_from_shapes
@ -108,6 +109,8 @@ class TestPowerpointDocument(TestCase, TestMixin):
self.file_name = os.path.join(TEST_RESOURCES_PATH, 'presentations', 'test.pptx') self.file_name = os.path.join(TEST_RESOURCES_PATH, 'presentations', 'test.pptx')
self.real_controller = PowerpointController(self.mock_plugin) self.real_controller = PowerpointController(self.mock_plugin)
Settings().extend_default_settings(__default_settings__) Settings().extend_default_settings(__default_settings__)
Registry.create()
Registry().register('settings', Settings())
def tearDown(self): def tearDown(self):
""" """

View File

@ -21,8 +21,6 @@
""" """
This module contains tests for the OpenSong song importer. This module contains tests for the OpenSong song importer.
""" """
from unittest.mock import MagicMock, patch
from tests.helpers.songfileimport import SongImportTestHelper from tests.helpers.songfileimport import SongImportTestHelper
from tests.utils.constants import RESOURCE_PATH from tests.utils.constants import RESOURCE_PATH
@ -37,15 +35,12 @@ class TestChordProFileImport(SongImportTestHelper):
self.importer_module_name = 'chordpro' self.importer_module_name = 'chordpro'
super(TestChordProFileImport, self).__init__(*args, **kwargs) super(TestChordProFileImport, self).__init__(*args, **kwargs)
@patch('openlp.plugins.songs.lib.importers.chordpro.Settings') def test_song_import(self):
def test_song_import(self, mocked_settings):
""" """
Test that loading an ChordPro file works correctly on various files Test that loading an ChordPro file works correctly on various files
""" """
# Mock out the settings - always return False # Mock out the settings - always return False
mocked_returned_settings = MagicMock() self.settings.value.side_effect = lambda value: True if value == 'songs/enable chords' else False
mocked_returned_settings.value.side_effect = lambda value: True if value == 'songs/enable chords' else False
mocked_settings.return_value = mocked_returned_settings
# Do the test import # Do the test import
self.file_import([TEST_PATH / 'swing-low.chordpro'], self.file_import([TEST_PATH / 'swing-low.chordpro'],
self.load_external_result_data(TEST_PATH / 'swing-low.json')) self.load_external_result_data(TEST_PATH / 'swing-low.json'))

View File

@ -26,16 +26,11 @@ from unittest.mock import MagicMock
from PyQt5 import QtCore from PyQt5 import QtCore
from openlp.core.common.settings import Settings from openlp.core.common.registry import Registry
from openlp.plugins.songs.forms.editverseform import EditVerseForm from openlp.plugins.songs.forms.editverseform import EditVerseForm
from tests.helpers.testmixin import TestMixin from tests.helpers.testmixin import TestMixin
__default_settings__ = {
'songs/enable chords': True,
}
class TestEditVerseForm(TestCase, TestMixin): class TestEditVerseForm(TestCase, TestMixin):
""" """
Test the functions in the :mod:`lib` module. Test the functions in the :mod:`lib` module.
@ -46,7 +41,9 @@ class TestEditVerseForm(TestCase, TestMixin):
""" """
self.setup_application() self.setup_application()
self.build_settings() self.build_settings()
Settings().extend_default_settings(__default_settings__) self.setting.setValue('songs/enable chords', True)
Registry.create()
Registry().register('settings', self.setting)
self.edit_verse_form = EditVerseForm(None) self.edit_verse_form = EditVerseForm(None)
QtCore.QLocale.setDefault(QtCore.QLocale('en_GB')) QtCore.QLocale.setDefault(QtCore.QLocale('en_GB'))

View File

@ -24,6 +24,7 @@ This module contains tests for the lib submodule of the Songs plugin.
from unittest import TestCase from unittest import TestCase
from unittest.mock import MagicMock, PropertyMock, patch from unittest.mock import MagicMock, PropertyMock, patch
from openlp.core.common.registry import Registry
from openlp.plugins.songs.lib import VerseType, clean_string, clean_title, strip_rtf, transpose_chord, transpose_lyrics from openlp.plugins.songs.lib import VerseType, clean_string, clean_title, strip_rtf, transpose_chord, transpose_lyrics
from openlp.plugins.songs.lib.songcompare import _op_length, _remove_typos, songs_probably_equal from openlp.plugins.songs.lib.songcompare import _op_length, _remove_typos, songs_probably_equal
@ -50,6 +51,9 @@ class TestLib(TestCase):
i love that old cross where the dearest and best for a world of lost sinners was slain so ill cherish the i love that old cross where the dearest and best for a world of lost sinners was slain so ill cherish the
old rugged cross till my trophies at last i lay down i will cling to the old rugged cross and exchange it old rugged cross till my trophies at last i lay down i will cling to the old rugged cross and exchange it
some day for a crown''' some day for a crown'''
Registry.create()
Registry().register('settings', MagicMock())
self.settings = Registry().get('settings')
def test_clean_string(self): def test_clean_string(self):
""" """
@ -317,8 +321,7 @@ class TestLib(TestCase):
'ValueError exception should have been thrown for invalid chord' 'ValueError exception should have been thrown for invalid chord'
@patch('openlp.plugins.songs.lib.transpose_verse') @patch('openlp.plugins.songs.lib.transpose_verse')
@patch('openlp.plugins.songs.lib.Settings') def test_transpose_lyrics(self, mocked_transpose_verse):
def test_transpose_lyrics(self, mocked_settings, mocked_transpose_verse):
""" """
Test that the transpose_lyrics() splits verses correctly Test that the transpose_lyrics() splits verses correctly
""" """
@ -329,9 +332,7 @@ class TestLib(TestCase):
'That saved a wretch like me.\n'\ 'That saved a wretch like me.\n'\
'---[Verse:2]---\n'\ '---[Verse:2]---\n'\
'I once was lost but now I\'m found.' 'I once was lost but now I\'m found.'
mocked_returned_settings = MagicMock() self.settings.value.return_value = 'english'
mocked_returned_settings.value.return_value = 'english'
mocked_settings.return_value = mocked_returned_settings
# WHEN: Transposing the lyrics # WHEN: Transposing the lyrics
transpose_lyrics(lyrics, 1) transpose_lyrics(lyrics, 1)

View File

@ -40,15 +40,12 @@ class TestOpenSongFileImport(SongImportTestHelper):
self.importer_module_name = 'opensong' self.importer_module_name = 'opensong'
super(TestOpenSongFileImport, self).__init__(*args, **kwargs) super(TestOpenSongFileImport, self).__init__(*args, **kwargs)
@patch('openlp.plugins.songs.lib.importers.opensong.Settings') def test_song_import(self):
def test_song_import(self, mocked_settings):
""" """
Test that loading an OpenSong file works correctly on various files Test that loading an OpenSong file works correctly on various files
""" """
# Mock out the settings - always return False # Mock out the settings - always return False
mocked_returned_settings = MagicMock() self.settings.value.side_effect = lambda value: True if value == 'songs/enable chords' else False
mocked_returned_settings.value.side_effect = lambda value: True if value == 'songs/enable chords' else False
mocked_settings.return_value = mocked_returned_settings
# Do the test import # Do the test import
self.file_import([TEST_PATH / 'Amazing Grace'], self.file_import([TEST_PATH / 'Amazing Grace'],
self.load_external_result_data(TEST_PATH / 'Amazing Grace.json')) self.load_external_result_data(TEST_PATH / 'Amazing Grace.json'))

View File

@ -40,15 +40,12 @@ class TestSongBeamerFileImport(SongImportTestHelper):
self.importer_module_name = 'songbeamer' self.importer_module_name = 'songbeamer'
super(TestSongBeamerFileImport, self).__init__(*args, **kwargs) super(TestSongBeamerFileImport, self).__init__(*args, **kwargs)
@patch('openlp.plugins.songs.lib.importers.songbeamer.Settings') def test_song_import(self):
def test_song_import(self, mocked_settings):
""" """
Test that loading an SongBeamer file works correctly on various files Test that loading an SongBeamer file works correctly on various files
""" """
# Mock out the settings - always return False # Mock out the settings - always return False
mocked_returned_settings = MagicMock() self.settings.value.side_effect = lambda value: True if value == 'songs/enable chords' else False
mocked_returned_settings.value.side_effect = lambda value: True if value == 'songs/enable chords' else False
mocked_settings.return_value = mocked_returned_settings
self.file_import([TEST_PATH / 'Amazing Grace.sng'], self.file_import([TEST_PATH / 'Amazing Grace.sng'],
self.load_external_result_data(TEST_PATH / 'Amazing Grace.json')) self.load_external_result_data(TEST_PATH / 'Amazing Grace.json'))
self.file_import([TEST_PATH / 'Lobsinget dem Herrn.sng'], self.file_import([TEST_PATH / 'Lobsinget dem Herrn.sng'],

View File

@ -553,6 +553,7 @@ class TestSongSelectForm(TestCase, TestMixin):
self.app.process_events = lambda: None self.app.process_events = lambda: None
Registry.create() Registry.create()
Registry().register('application', self.app) Registry().register('application', self.app)
Registry().register('settings', MagicMock())
def test_create_form(self): def test_create_form(self):
""" """
@ -802,10 +803,9 @@ class TestSongSelectForm(TestCase, TestMixin):
assert ssform.search_button.isEnabled() is True assert ssform.search_button.isEnabled() is True
assert ssform.search_combobox.isEnabled() is True assert ssform.search_combobox.isEnabled() is True
@patch('openlp.plugins.songs.forms.songselectform.Settings')
@patch('openlp.plugins.songs.forms.songselectform.run_thread') @patch('openlp.plugins.songs.forms.songselectform.run_thread')
@patch('openlp.plugins.songs.forms.songselectform.SearchWorker') @patch('openlp.plugins.songs.forms.songselectform.SearchWorker')
def test_on_search_button_clicked(self, MockedSearchWorker, mocked_run_thread, MockedSettings): def test_on_search_button_clicked(self, MockedSearchWorker, mocked_run_thread):
""" """
Test that search fields are disabled when search button is clicked. Test that search fields are disabled when search button is clicked.
""" """

View File

@ -21,7 +21,6 @@
""" """
This module contains tests for the VideoPsalm song importer. This module contains tests for the VideoPsalm song importer.
""" """
from unittest.mock import MagicMock, patch
from tests.helpers.songfileimport import SongImportTestHelper from tests.helpers.songfileimport import SongImportTestHelper
from tests.utils.constants import RESOURCE_PATH from tests.utils.constants import RESOURCE_PATH
@ -37,15 +36,12 @@ class TestVideoPsalmFileImport(SongImportTestHelper):
self.importer_module_name = 'videopsalm' self.importer_module_name = 'videopsalm'
super(TestVideoPsalmFileImport, self).__init__(*args, **kwargs) super(TestVideoPsalmFileImport, self).__init__(*args, **kwargs)
@patch('openlp.plugins.songs.lib.importers.videopsalm.Settings') def test_song_import(self):
def test_song_import(self, mocked_settings):
""" """
Test that loading an VideoPsalm file works correctly on various files Test that loading an VideoPsalm file works correctly on various files
""" """
# Mock out the settings - always return False # Mock out the settings - always return False
mocked_returned_settings = MagicMock() self.settings.value.side_effect = lambda value: True if value == 'songs/enable chords' else False
mocked_returned_settings.value.side_effect = lambda value: True if value == 'songs/enable chords' else False
mocked_settings.return_value = mocked_returned_settings
# Do the test import # Do the test import
self.file_import(TEST_PATH / 'videopsalm-as-safe-a-stronghold.json', self.file_import(TEST_PATH / 'videopsalm-as-safe-a-stronghold.json',
self.load_external_result_data(TEST_PATH / 'as-safe-a-stronghold.json')) self.load_external_result_data(TEST_PATH / 'as-safe-a-stronghold.json'))

View File

@ -42,12 +42,14 @@ class SongImportTestHelper(TestCase):
self.importer_module = __import__('openlp.plugins.songs.lib.importers.%s' % self.importer_module = __import__('openlp.plugins.songs.lib.importers.%s' %
self.importer_module_name, fromlist=[self.importer_class_name]) self.importer_module_name, fromlist=[self.importer_class_name])
self.importer_class = getattr(self.importer_module, self.importer_class_name) self.importer_class = getattr(self.importer_module, self.importer_class_name)
Registry.create()
Registry().register('settings', MagicMock())
self.settings = Registry().get('settings')
def setUp(self): def setUp(self):
""" """
Patch and set up the mocks required. Patch and set up the mocks required.
""" """
Registry.create()
self.add_copyright_patcher = patch('openlp.plugins.songs.lib.importers.%s.%s.add_copyright' % self.add_copyright_patcher = patch('openlp.plugins.songs.lib.importers.%s.%s.add_copyright' %
(self.importer_module_name, self.importer_class_name)) (self.importer_module_name, self.importer_class_name))
self.add_verse_patcher = patch('openlp.plugins.songs.lib.importers.%s.%s.add_verse' % self.add_verse_patcher = patch('openlp.plugins.songs.lib.importers.%s.%s.add_verse' %

View File

@ -63,6 +63,7 @@ class TestSelectPlanForm(TestCase, TestMixin):
self.setup_application() self.setup_application()
self.build_settings() self.build_settings()
State().load_settings() State().load_settings()
Registry().register('settings', Settings())
Registry().register('main_window', MagicMock(service_manager_settings_section='servicemanager')) Registry().register('main_window', MagicMock(service_manager_settings_section='servicemanager'))
self.application_id = 'abc' self.application_id = 'abc'
self.secret = '123' self.secret = '123'

View File

@ -43,9 +43,9 @@ class TestPlanningCenterTab(TestCase, TestMixin):
Create the UI Create the UI
""" """
self.setup_application() self.setup_application()
self.registry = Registry()
Registry.create() Registry.create()
State().load_settings() State().load_settings()
Registry().register('settings', Settings())
self.plugin = PlanningCenterPlugin() self.plugin = PlanningCenterPlugin()
Settings().setValue('planningcenter/application_id', 'abc') Settings().setValue('planningcenter/application_id', 'abc')
Settings().setValue('planningcenter/secret', '123') Settings().setValue('planningcenter/secret', '123')
@ -62,7 +62,6 @@ class TestPlanningCenterTab(TestCase, TestMixin):
""" """
del self.tab del self.tab
del self.dialog del self.dialog
del self.registry
def test_bad_authentication_credentials(self): def test_bad_authentication_credentials(self):
""" """

View File

@ -47,6 +47,7 @@ class TestPlanningCenterPlugin(TestCase, TestMixin):
self.registry = Registry() self.registry = Registry()
Registry.create() Registry.create()
State().load_settings() State().load_settings()
Registry().register('settings', Settings())
self.plugin = PlanningCenterPlugin() self.plugin = PlanningCenterPlugin()
self.settings_form = SettingsForm() self.settings_form = SettingsForm()

View File

@ -54,6 +54,7 @@ class TestEditSongForm(TestCase, TestMixin):
Registry().register('theme_manager', MagicMock()) Registry().register('theme_manager', MagicMock())
self.build_settings() self.build_settings()
Settings().extend_default_settings(__default_settings__) Settings().extend_default_settings(__default_settings__)
Registry().register('settings', Settings())
self.form = EditSongForm(MagicMock(), self.main_window, MagicMock()) self.form = EditSongForm(MagicMock(), self.main_window, MagicMock())
def tearDown(self): def tearDown(self):

View File

@ -50,6 +50,7 @@ class TestEditVerseForm(TestCase, TestMixin):
self.main_window = QtWidgets.QMainWindow() self.main_window = QtWidgets.QMainWindow()
Registry().register('main_window', self.main_window) Registry().register('main_window', self.main_window)
self.build_settings() self.build_settings()
Registry().register('settings', Settings())
Settings().extend_default_settings(__default_settings__) Settings().extend_default_settings(__default_settings__)
self.form = EditVerseForm() self.form = EditVerseForm()