forked from openlp/openlp
Merge branch 'settings_plugins_3' into 'master'
Settings plugins 3 - More Plugin Migrations See merge request openlp/openlp!125
This commit is contained in:
commit
52d811331c
@ -413,7 +413,7 @@ class BiblesTab(SettingsTab):
|
||||
self.settings.endGroup()
|
||||
|
||||
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('display new chapter', self.show_new_chapters)
|
||||
self.settings.setValue('display brackets', self.display_style)
|
||||
|
@ -25,7 +25,6 @@ for the Custom Slides plugin, which is inserted into the configuration dialog.
|
||||
from PyQt5 import QtCore, QtWidgets
|
||||
|
||||
from openlp.core.common.i18n import translate
|
||||
from openlp.core.common.settings import Settings
|
||||
from openlp.core.lib.settingstab import SettingsTab
|
||||
|
||||
|
||||
@ -82,23 +81,21 @@ class CustomTab(SettingsTab):
|
||||
|
||||
Load the settings into the dialog
|
||||
"""
|
||||
settings = Settings()
|
||||
settings.beginGroup(self.settings_section)
|
||||
self.display_footer = settings.value('display footer')
|
||||
self.update_load = settings.value('add custom from service')
|
||||
self.settings.beginGroup(self.settings_section)
|
||||
self.display_footer = self.settings.value('display footer')
|
||||
self.update_load = self.settings.value('add custom from service')
|
||||
self.display_footer_check_box.setChecked(self.display_footer)
|
||||
self.add_from_service_checkbox.setChecked(self.update_load)
|
||||
settings.endGroup()
|
||||
self.settings.endGroup()
|
||||
|
||||
def save(self):
|
||||
"""
|
||||
Save the Dialog settings
|
||||
"""
|
||||
settings = Settings()
|
||||
settings.beginGroup(self.settings_section)
|
||||
settings.setValue('display footer', self.display_footer)
|
||||
settings.setValue('add custom from service', self.update_load)
|
||||
settings.endGroup()
|
||||
self.settings.beginGroup(self.settings_section)
|
||||
self.settings.setValue('display footer', self.display_footer)
|
||||
self.settings.setValue('add custom from service', self.update_load)
|
||||
self.settings.endGroup()
|
||||
if self.tab_visited:
|
||||
self.settings_form.register_post_process('custom_config_updated')
|
||||
self.tab_visited = False
|
||||
|
@ -22,7 +22,6 @@
|
||||
from PyQt5 import QtWidgets
|
||||
|
||||
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.widgets.buttons import ColorButton
|
||||
|
||||
@ -67,17 +66,15 @@ class ImageTab(SettingsTab):
|
||||
self.background_color = color
|
||||
|
||||
def load(self):
|
||||
settings = Settings()
|
||||
settings.beginGroup(self.settings_section)
|
||||
self.background_color = settings.value('background color')
|
||||
self.settings.beginGroup(self.settings_section)
|
||||
self.background_color = self.settings.value('background color')
|
||||
self.initial_color = self.background_color
|
||||
settings.endGroup()
|
||||
self.settings.endGroup()
|
||||
self.background_color_button.color = self.background_color
|
||||
|
||||
def save(self):
|
||||
settings = Settings()
|
||||
settings.beginGroup(self.settings_section)
|
||||
settings.setValue('background color', self.background_color)
|
||||
settings.endGroup()
|
||||
self.settings.beginGroup(self.settings_section)
|
||||
self.settings.setValue('background color', self.background_color)
|
||||
self.settings.endGroup()
|
||||
if self.initial_color != self.background_color:
|
||||
self.settings_form.register_post_process('images_config_updated')
|
||||
|
@ -30,7 +30,6 @@ from PyQt5 import QtCore, QtWidgets
|
||||
|
||||
from openlp.core.common.i18n import translate
|
||||
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.planningcenter.forms.selectplandialog import Ui_SelectPlanDialog
|
||||
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)
|
||||
self.plugin = plugin
|
||||
# create an Planning Center API Object
|
||||
application_id = Settings().value("planningcenter/application_id")
|
||||
secret = Settings().value("planningcenter/secret")
|
||||
application_id = Registry().get('settings').value("planningcenter/application_id")
|
||||
secret = Registry().get('settings').value("planningcenter/secret")
|
||||
self.planning_center_api = PlanningCenterAPI(application_id, secret)
|
||||
self.setup_ui(self)
|
||||
self.service_type_combo_box.currentIndexChanged.connect(self.on_service_type_combobox_changed)
|
||||
|
@ -25,7 +25,6 @@ the settings tab for the PlanningCenter plugin
|
||||
from PyQt5 import QtCore, QtWidgets
|
||||
|
||||
from openlp.core.common.i18n import translate
|
||||
from openlp.core.common.settings import Settings
|
||||
from openlp.core.lib.settingstab import SettingsTab
|
||||
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.
|
||||
"""
|
||||
settings = Settings()
|
||||
settings.beginGroup(self.settings_section)
|
||||
self.application_id = settings.value('application_id')
|
||||
self.secret = settings.value('secret')
|
||||
settings.endGroup()
|
||||
self.settings.beginGroup(self.settings_section)
|
||||
self.application_id = self.settings.value('application_id')
|
||||
self.secret = self.settings.value('secret')
|
||||
self.settings.endGroup()
|
||||
self.application_id_line_edit.setText(self.application_id)
|
||||
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.
|
||||
"""
|
||||
settings = Settings()
|
||||
settings.beginGroup(self.settings_section)
|
||||
settings.setValue('application_id', self.application_id_line_edit.text())
|
||||
settings.setValue('secret', self.secret_line_edit.text())
|
||||
settings.endGroup()
|
||||
self.settings.beginGroup(self.settings_section)
|
||||
self.settings.setValue('application_id', self.application_id_line_edit.text())
|
||||
self.settings.setValue('secret', self.secret_line_edit.text())
|
||||
self.settings.endGroup()
|
||||
|
||||
def on_test_credentials_button_clicked(self):
|
||||
"""
|
||||
|
@ -25,7 +25,6 @@ from pathlib import Path
|
||||
from PyQt5 import QtCore
|
||||
|
||||
from openlp.core.common.registry import Registry
|
||||
from openlp.core.common.settings import Settings
|
||||
from openlp.core.lib import ServiceItemContext
|
||||
from openlp.core.ui import HideMode
|
||||
from openlp.plugins.presentations.lib.pdfcontroller import PDF_CONTROLLER_FILETYPES
|
||||
@ -416,7 +415,7 @@ class MessageListener(object):
|
||||
is_live = message[1]
|
||||
if is_live:
|
||||
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')
|
||||
return ret
|
||||
else:
|
||||
@ -431,7 +430,7 @@ class MessageListener(object):
|
||||
is_live = message[1]
|
||||
if is_live:
|
||||
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')
|
||||
return ret
|
||||
else:
|
||||
|
@ -24,8 +24,8 @@ from shutil import which
|
||||
from subprocess import CalledProcessError, check_output
|
||||
|
||||
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.settings import Settings
|
||||
from openlp.core.display.screens import ScreenList
|
||||
from openlp.plugins.presentations.lib.presentationcontroller import PresentationController, PresentationDocument
|
||||
|
||||
@ -117,8 +117,8 @@ class PdfController(PresentationController):
|
||||
self.gsbin = None
|
||||
self.also_supports = []
|
||||
# Use the user defined program if given
|
||||
if Settings().value('presentations/enable_pdf_program'):
|
||||
program_path = Settings().value('presentations/pdf_program')
|
||||
if Registry().get('settings').value('presentations/enable_pdf_program'):
|
||||
program_path = Registry().get('settings').value('presentations/pdf_program')
|
||||
program_type = self.process_check_binary(program_path)
|
||||
if program_type == 'gs':
|
||||
self.gsbin = program_path
|
||||
|
@ -29,7 +29,6 @@ import logging
|
||||
from openlp.core.common import is_win, trace_error_handler
|
||||
from openlp.core.common.i18n import UiStrings
|
||||
from openlp.core.common.registry import Registry
|
||||
from openlp.core.common.settings import Settings
|
||||
from openlp.core.display.screens import ScreenList
|
||||
from openlp.core.lib.ui import critical_error_message_box, translate
|
||||
from openlp.plugins.presentations.lib.presentationcontroller import PresentationController, PresentationDocument
|
||||
@ -328,7 +327,7 @@ class PowerpointDocument(PresentationDocument):
|
||||
log.exception('Caught exception while in start_presentation')
|
||||
trace_error_handler(log)
|
||||
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:
|
||||
ppt_window.Top = size.y() * 72 / dpi
|
||||
ppt_window.Height = size.height() * 72 / dpi
|
||||
@ -422,7 +421,7 @@ class PowerpointDocument(PresentationDocument):
|
||||
"""
|
||||
log.debug('goto_slide')
|
||||
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:
|
||||
click_index = self.presentation.SlideShowWindow.View.GetClickIndex()
|
||||
click_count = self.presentation.SlideShowWindow.View.GetClickCount()
|
||||
|
@ -28,7 +28,6 @@ from openlp.core.common import md5_hash
|
||||
from openlp.core.common.applocation import AppLocation
|
||||
from openlp.core.common.path import create_paths
|
||||
from openlp.core.common.registry import Registry
|
||||
from openlp.core.common.settings import Settings
|
||||
from openlp.core.lib import create_thumb, validate_thumb
|
||||
|
||||
|
||||
@ -97,6 +96,7 @@ class PresentationDocument(object):
|
||||
:rtype: None
|
||||
"""
|
||||
self.controller = controller
|
||||
self.settings = Registry().get('settings')
|
||||
self._setup(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
|
||||
# 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))
|
||||
else:
|
||||
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
|
||||
# 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))
|
||||
else:
|
||||
folder = self.file_path.name
|
||||
@ -445,7 +445,7 @@ class PresentationController(object):
|
||||
"""
|
||||
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()
|
||||
else:
|
||||
return False
|
||||
|
@ -22,7 +22,6 @@
|
||||
from PyQt5 import QtWidgets
|
||||
|
||||
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.ui import critical_error_message_box
|
||||
from openlp.core.widgets.edits import PathEdit
|
||||
@ -139,21 +138,21 @@ class PresentationTab(SettingsTab):
|
||||
for key in self.controllers:
|
||||
controller = self.controllers[key]
|
||||
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():
|
||||
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
|
||||
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'))
|
||||
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)
|
||||
# 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.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):
|
||||
"""
|
||||
@ -168,25 +167,25 @@ class PresentationTab(SettingsTab):
|
||||
if controller.is_available():
|
||||
checkbox = self.presenter_check_boxes[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
|
||||
Settings().setValue(setting_key, checkbox.checkState())
|
||||
self.settings.setValue(setting_key, checkbox.checkState())
|
||||
if checkbox.isChecked():
|
||||
controller.start_process()
|
||||
else:
|
||||
controller.kill()
|
||||
setting_key = self.settings_section + '/override app'
|
||||
if Settings().value(setting_key) != self.override_app_check_box.checkState():
|
||||
Settings().setValue(setting_key, self.override_app_check_box.checkState())
|
||||
if self.settings.value(setting_key) != self.override_app_check_box.checkState():
|
||||
self.settings.setValue(setting_key, self.override_app_check_box.checkState())
|
||||
changed = True
|
||||
# Save powerpoint settings
|
||||
setting_key = self.settings_section + '/powerpoint slide click advance'
|
||||
if Settings().value(setting_key) != self.ppt_slide_click_check_box.checkState():
|
||||
Settings().setValue(setting_key, self.ppt_slide_click_check_box.checkState())
|
||||
if self.settings.value(setting_key) != self.ppt_slide_click_check_box.checkState():
|
||||
self.settings.setValue(setting_key, self.ppt_slide_click_check_box.checkState())
|
||||
changed = True
|
||||
setting_key = self.settings_section + '/powerpoint control window'
|
||||
if Settings().value(setting_key) != self.ppt_window_check_box.checkState():
|
||||
Settings().setValue(setting_key, self.ppt_window_check_box.checkState())
|
||||
if self.settings.value(setting_key) != self.ppt_window_check_box.checkState():
|
||||
self.settings.setValue(setting_key, self.ppt_window_check_box.checkState())
|
||||
changed = True
|
||||
# Save pdf-settings
|
||||
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 pdf_program_path is None:
|
||||
enable_pdf_program = 0
|
||||
if pdf_program_path != Settings().value(self.settings_section + '/pdf_program'):
|
||||
Settings().setValue(self.settings_section + '/pdf_program', pdf_program_path)
|
||||
if pdf_program_path != self.settings.value(self.settings_section + '/pdf_program'):
|
||||
self.settings.setValue(self.settings_section + '/pdf_program', pdf_program_path)
|
||||
changed = True
|
||||
if enable_pdf_program != Settings().value(self.settings_section + '/enable_pdf_program'):
|
||||
Settings().setValue(self.settings_section + '/enable_pdf_program', enable_pdf_program)
|
||||
if enable_pdf_program != self.settings.value(self.settings_section + '/enable_pdf_program'):
|
||||
self.settings.setValue(self.settings_section + '/enable_pdf_program', enable_pdf_program)
|
||||
changed = True
|
||||
if changed:
|
||||
self.settings_form.register_post_process('mediaitem_suffix_reset')
|
||||
|
@ -22,7 +22,7 @@
|
||||
from PyQt5 import QtWidgets
|
||||
|
||||
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.ui.icons import UiIcons
|
||||
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.addStretch()
|
||||
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.setObjectName('transpose_layout')
|
||||
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.setToolTip(translate('SongsPlugin.EditVerseForm',
|
||||
'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_up_button.setText(translate('SongsPlugin.EditVerseForm', 'Up'))
|
||||
self.transpose_down_button.setText(translate('SongsPlugin.EditVerseForm', 'Down'))
|
||||
|
@ -25,7 +25,7 @@ import re
|
||||
from PyQt5 import QtCore, QtGui, QtWidgets
|
||||
|
||||
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.plugins.songs.forms.editversedialog import Ui_EditVerseDialog
|
||||
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_type_combo_box.currentIndexChanged.connect(self.on_verse_type_combo_box_changed)
|
||||
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_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
|
||||
"""
|
||||
if Settings().value('songs/enable chords'):
|
||||
if Registry().get('settings').value('songs/enable chords'):
|
||||
try:
|
||||
transpose_lyrics(self.verse_text_edit.toPlainText(), 1)
|
||||
super(EditVerseForm, self).accept()
|
||||
|
@ -28,7 +28,6 @@ from PyQt5 import QtCore, QtWidgets
|
||||
|
||||
from openlp.core.common.i18n import UiStrings, translate
|
||||
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.ui import critical_error_message_box
|
||||
from openlp.core.common.i18n import get_natural_key
|
||||
@ -128,7 +127,7 @@ class SongExportForm(OpenLPWizard):
|
||||
self.output_directory_path_edit = PathEdit(
|
||||
self.export_song_page, PathEditType.Directories,
|
||||
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.setObjectName('directory_label')
|
||||
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', 'You need to specify a directory.'))
|
||||
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
|
||||
elif self.currentPage() == self.progress_page:
|
||||
self.available_list_widget.clear()
|
||||
|
@ -27,7 +27,6 @@ from PyQt5 import QtCore, QtWidgets
|
||||
|
||||
from openlp.core.common.i18n import UiStrings, translate
|
||||
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.widgets.dialogs import FileDialog
|
||||
from openlp.core.widgets.edits import PathEdit
|
||||
@ -198,7 +197,7 @@ class SongImportForm(OpenLPWizard, RegistryProperties):
|
||||
return True
|
||||
elif self.currentPage() == self.source_page:
|
||||
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')
|
||||
if select_mode == SongFormatSelect.MultipleFiles:
|
||||
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)
|
||||
file_paths, filter_used = FileDialog.getOpenFileNames(
|
||||
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:
|
||||
list_item = QtWidgets.QListWidgetItem(str(file_path))
|
||||
list_item.setData(QtCore.Qt.UserRole, file_path)
|
||||
listbox.addItem(list_item)
|
||||
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):
|
||||
"""
|
||||
@ -290,7 +289,7 @@ class SongImportForm(OpenLPWizard, RegistryProperties):
|
||||
self.restart()
|
||||
self.finish_button.setVisible(False)
|
||||
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():
|
||||
last_import_type = 0
|
||||
self.format_combo_box.setCurrentIndex(last_import_type)
|
||||
@ -349,7 +348,7 @@ class SongImportForm(OpenLPWizard, RegistryProperties):
|
||||
:rtype: None
|
||||
"""
|
||||
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:
|
||||
return
|
||||
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
|
||||
else:
|
||||
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)
|
||||
import_layout.addLayout(file_path_layout)
|
||||
import_layout.addSpacerItem(self.stack_spacer)
|
||||
|
@ -28,7 +28,6 @@ from PyQt5 import QtCore, QtWidgets
|
||||
|
||||
from openlp.core.common.i18n import translate
|
||||
from openlp.core.common.mixins import RegistryProperties
|
||||
from openlp.core.common.settings import Settings
|
||||
from openlp.core.threading import ThreadWorker, run_thread
|
||||
from openlp.plugins.songs.forms.songselectdialog import Ui_SongSelectDialog
|
||||
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_results_widget.clear()
|
||||
self.view_button.setEnabled(False)
|
||||
if Settings().contains(self.plugin.settings_section + '/songselect password'):
|
||||
self.username_edit.setText(Settings().value(self.plugin.settings_section + '/songselect username'))
|
||||
self.password_edit.setText(Settings().value(self.plugin.settings_section + '/songselect password'))
|
||||
if self.settings.contains(self.plugin.settings_section + '/songselect password'):
|
||||
self.username_edit.setText(self.settings.value(self.plugin.settings_section + '/songselect username'))
|
||||
self.password_edit.setText(self.settings.value(self.plugin.settings_section + '/songselect password'))
|
||||
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(
|
||||
Settings().value(self.plugin.settings_section + '/songselect searches').split('|'))
|
||||
self.settings.value(self.plugin.settings_section + '/songselect searches').split('|'))
|
||||
self.username_edit.setFocus()
|
||||
return QtWidgets.QDialog.exec(self)
|
||||
|
||||
@ -281,11 +280,11 @@ class SongSelectForm(QtWidgets.QDialog, Ui_SongSelectDialog, RegistryProperties)
|
||||
'in the public domain.')
|
||||
)
|
||||
if self.save_password_checkbox.isChecked():
|
||||
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 username', self.username_edit.text())
|
||||
self.settings.setValue(self.plugin.settings_section + '/songselect password', self.password_edit.text())
|
||||
else:
|
||||
Settings().remove(self.plugin.settings_section + '/songselect username')
|
||||
Settings().remove(self.plugin.settings_section + '/songselect password')
|
||||
self.settings.remove(self.plugin.settings_section + '/songselect username')
|
||||
self.settings.remove(self.plugin.settings_section + '/songselect password')
|
||||
self.stacked_widget.setCurrentIndex(1)
|
||||
self.login_progress_bar.setVisible(False)
|
||||
self.login_progress_bar.setValue(0)
|
||||
@ -315,7 +314,7 @@ class SongSelectForm(QtWidgets.QDialog, Ui_SongSelectDialog, RegistryProperties)
|
||||
self.application.process_events()
|
||||
self.song_count = 0
|
||||
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
|
||||
worker = SearchWorker(self.song_select_importer, self.search_combobox.currentText())
|
||||
worker.show_info.connect(self.on_search_show_info)
|
||||
|
@ -30,7 +30,7 @@ from PyQt5 import QtWidgets
|
||||
from openlp.core.common import CONTROL_CHARS
|
||||
from openlp.core.common.applocation import AppLocation
|
||||
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.plugins.songs.lib.db import Author, MediaFile, Song
|
||||
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
|
||||
verse_list = re.split(r'(---\[.+?:.+?\]---|\[---\])', lyrics)
|
||||
transposed_lyrics = ''
|
||||
notation = Settings().value('songs/chord notation')
|
||||
notation = Registry().get('settings').value('songs/chord notation')
|
||||
for verse in verse_list:
|
||||
if verse.startswith('---[') or verse == '[---]':
|
||||
transposed_lyrics += verse
|
||||
|
@ -26,7 +26,6 @@ import logging
|
||||
import re
|
||||
|
||||
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.db import AuthorType
|
||||
|
||||
@ -109,8 +108,8 @@ class ChordProImport(SongImport):
|
||||
if current_verse.strip():
|
||||
# Add collected verse to the lyrics
|
||||
# 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)
|
||||
self.add_verse(current_verse.rstrip(), current_verse_type)
|
||||
current_verse_type = 'v'
|
||||
@ -123,7 +122,8 @@ class ChordProImport(SongImport):
|
||||
elif tag_name in ['end_of_chorus', 'eoc']:
|
||||
# Add collected chorus to the lyrics
|
||||
# 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)
|
||||
self.add_verse(current_verse.rstrip(), current_verse_type)
|
||||
current_verse_type = 'v'
|
||||
@ -132,8 +132,8 @@ class ChordProImport(SongImport):
|
||||
if current_verse.strip():
|
||||
# Add collected verse to the lyrics
|
||||
# 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)
|
||||
self.add_verse(current_verse.rstrip(), current_verse_type)
|
||||
current_verse_type = 'v'
|
||||
@ -146,8 +146,8 @@ class ChordProImport(SongImport):
|
||||
if self.verses and self.title:
|
||||
if current_verse.strip():
|
||||
# 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)
|
||||
self.add_verse(current_verse.rstrip(), current_verse_type)
|
||||
if not self.finish():
|
||||
@ -170,7 +170,8 @@ class ChordProImport(SongImport):
|
||||
elif line == '' and current_verse.strip() and current_verse_type != 'c':
|
||||
# Add collected verse to the lyrics
|
||||
# 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)
|
||||
self.add_verse(current_verse.rstrip(), current_verse_type)
|
||||
current_verse_type = 'v'
|
||||
@ -182,7 +183,7 @@ class ChordProImport(SongImport):
|
||||
current_verse += line + '\n'
|
||||
if current_verse.strip():
|
||||
# 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'):
|
||||
current_verse = re.sub(r'\[.*?\]', '', current_verse)
|
||||
self.add_verse(current_verse.rstrip(), current_verse_type)
|
||||
|
@ -25,7 +25,6 @@ from lxml import objectify, etree
|
||||
|
||||
from openlp.core.common import normalize_str
|
||||
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.importers.songimport import SongImport
|
||||
from openlp.plugins.songs.lib.ui import SongStrings
|
||||
@ -254,7 +253,7 @@ class OpenSongImport(SongImport):
|
||||
verses[verse_tag][verse_num][inst] = []
|
||||
our_verse_order.append([verse_tag, verse_num, inst])
|
||||
# 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'):
|
||||
offset = 0
|
||||
for (column, chord) in chords:
|
||||
|
@ -30,7 +30,6 @@ from pathlib import Path
|
||||
|
||||
from openlp.core.common import get_file_encoding, is_macosx, is_win
|
||||
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.importers.songimport import SongImport
|
||||
|
||||
@ -223,7 +222,7 @@ class SongBeamerImport(SongImport):
|
||||
:param linenumber: Number of the current line
|
||||
: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:
|
||||
line_idx = sorted(self.chord_table[line_number].keys(), reverse=True)
|
||||
for idx in line_idx:
|
||||
|
@ -78,6 +78,7 @@ class SongImport(QtCore.QObject):
|
||||
self.stop_import_flag = False
|
||||
self.set_defaults()
|
||||
Registry().register_function('openlp_stop_wizard', self.stop_import)
|
||||
self.settings = Registry().get('settings')
|
||||
|
||||
def set_defaults(self):
|
||||
"""
|
||||
|
@ -27,7 +27,6 @@ import re
|
||||
from pathlib import Path
|
||||
|
||||
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.importers.songimport import SongImport
|
||||
|
||||
@ -125,7 +124,8 @@ class VideoPsalmImport(SongImport):
|
||||
continue
|
||||
verse_text = verse['Text']
|
||||
# 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)
|
||||
self.add_verse(verse_text, 'v')
|
||||
if not self.finish():
|
||||
|
@ -61,7 +61,7 @@ import re
|
||||
from lxml import etree, objectify
|
||||
|
||||
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.version import get_version
|
||||
from openlp.plugins.songs.lib import VerseType, clean_song
|
||||
@ -625,7 +625,8 @@ class OpenLyrics(object):
|
||||
return text
|
||||
# Convert chords to ChordPro format which OpenLP uses internally
|
||||
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'))
|
||||
if element.tail:
|
||||
# Append tail text at chord element.
|
||||
|
@ -22,7 +22,6 @@
|
||||
from PyQt5 import QtCore, QtWidgets
|
||||
|
||||
from openlp.core.common.i18n import translate
|
||||
from openlp.core.common.settings import Settings
|
||||
from openlp.core.lib.settingstab import SettingsTab
|
||||
from openlp.plugins.songs.lib.db import AuthorType
|
||||
|
||||
@ -211,19 +210,18 @@ class SongsTab(SettingsTab):
|
||||
self.chord_notation = 'neo-latin'
|
||||
|
||||
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):
|
||||
settings = Settings()
|
||||
settings.beginGroup(self.settings_section)
|
||||
self.tool_bar = settings.value('display songbar')
|
||||
self.update_edit = settings.value('update service on edit')
|
||||
self.update_load = settings.value('add song from service')
|
||||
self.songbook_slide = settings.value('add songbook slide')
|
||||
self.enable_chords = settings.value('enable chords')
|
||||
self.chord_notation = settings.value('chord notation')
|
||||
self.mainview_chords = settings.value('mainview chords')
|
||||
self.disable_chords_import = settings.value('disable chords import')
|
||||
self.settings.beginGroup(self.settings_section)
|
||||
self.tool_bar = self.settings.value('display songbar')
|
||||
self.update_edit = self.settings.value('update service on edit')
|
||||
self.update_load = self.settings.value('add song from service')
|
||||
self.songbook_slide = self.settings.value('add songbook slide')
|
||||
self.enable_chords = self.settings.value('enable chords')
|
||||
self.chord_notation = self.settings.value('chord notation')
|
||||
self.mainview_chords = self.settings.value('mainview chords')
|
||||
self.disable_chords_import = self.settings.value('disable chords import')
|
||||
self.tool_bar_active_check_box.setChecked(self.tool_bar)
|
||||
self.update_on_edit_check_box.setChecked(self.update_edit)
|
||||
self.add_from_service_check_box.setChecked(self.update_load)
|
||||
@ -236,24 +234,23 @@ class SongsTab(SettingsTab):
|
||||
self.neolatin_notation_radio_button.setChecked(True)
|
||||
else:
|
||||
self.english_notation_radio_button.setChecked(True)
|
||||
self.footer_edit_box.setPlainText(settings.value('footer template'))
|
||||
settings.endGroup()
|
||||
self.footer_edit_box.setPlainText(self.settings.value('footer template'))
|
||||
self.settings.endGroup()
|
||||
|
||||
def save(self):
|
||||
settings = Settings()
|
||||
settings.beginGroup(self.settings_section)
|
||||
settings.setValue('display songbar', self.tool_bar)
|
||||
settings.setValue('update service on edit', self.update_edit)
|
||||
settings.setValue('add song from service', self.update_load)
|
||||
settings.setValue('enable chords', self.chords_group_box.isChecked())
|
||||
settings.setValue('mainview chords', self.mainview_chords)
|
||||
settings.setValue('disable chords import', self.disable_chords_import)
|
||||
settings.setValue('chord notation', self.chord_notation)
|
||||
self.settings.beginGroup(self.settings_section)
|
||||
self.settings.setValue('display songbar', self.tool_bar)
|
||||
self.settings.setValue('update service on edit', self.update_edit)
|
||||
self.settings.setValue('add song from service', self.update_load)
|
||||
self.settings.setValue('enable chords', self.chords_group_box.isChecked())
|
||||
self.settings.setValue('mainview chords', self.mainview_chords)
|
||||
self.settings.setValue('disable chords import', self.disable_chords_import)
|
||||
self.settings.setValue('chord notation', self.chord_notation)
|
||||
# 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'):
|
||||
settings.setValue('footer template', self.footer_edit_box.toPlainText())
|
||||
settings.setValue('add songbook slide', self.songbook_slide)
|
||||
settings.endGroup()
|
||||
if self.footer_edit_box.toPlainText() != self.settings.get_default_value('songs/footer template'):
|
||||
self.settings.setValue('footer template', self.footer_edit_box.toPlainText())
|
||||
self.settings.setValue('add songbook slide', self.songbook_slide)
|
||||
self.settings.endGroup()
|
||||
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
|
||||
|
@ -51,6 +51,7 @@ class TestImageMediaItem(TestCase, TestMixin):
|
||||
Registry().register('settings_form', MagicMock())
|
||||
self.setup_application()
|
||||
self.build_settings()
|
||||
Registry().register('settings', Settings())
|
||||
Settings().extend_default_settings(__default_settings__)
|
||||
self.parent = QtWidgets.QMainWindow()
|
||||
self.form = ImageTab(self.parent, 'Images', None, None)
|
||||
|
@ -26,6 +26,8 @@ from tempfile import mkdtemp
|
||||
from unittest import TestCase
|
||||
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 tests.helpers.testmixin import TestMixin
|
||||
from tests.utils.constants import RESOURCE_PATH
|
||||
@ -167,6 +169,9 @@ class TestImpressDocument(TestCase):
|
||||
mocked_plugin = MagicMock()
|
||||
mocked_plugin.settings_section = 'presentations'
|
||||
self.file_name = RESOURCE_PATH / 'presentations' / 'test.pptx'
|
||||
self.settings = Settings()
|
||||
Registry.create()
|
||||
Registry().register('settings', self.settings)
|
||||
self.ppc = ImpressController(mocked_plugin)
|
||||
self.doc = ImpressDocument(self.ppc, self.file_name)
|
||||
|
||||
|
@ -33,6 +33,7 @@ from PyQt5 import QtCore, QtGui
|
||||
|
||||
from openlp.core.common import is_macosx, is_linux, is_win
|
||||
from openlp.core.common.settings import Settings
|
||||
from openlp.core.common.registry import Registry
|
||||
from openlp.core.display.screens import ScreenList
|
||||
from openlp.plugins.presentations.lib.pdfcontroller import PdfController, PdfDocument
|
||||
from tests.helpers.testmixin import TestMixin
|
||||
@ -89,6 +90,7 @@ class TestPdfController(TestCase, TestMixin):
|
||||
self.desktop.screenGeometry.return_value = SCREEN['size']
|
||||
self.screens = ScreenList.create(self.desktop)
|
||||
Settings().extend_default_settings(__default_settings__)
|
||||
Registry().register('settings', Settings())
|
||||
self.temp_folder_path = Path(mkdtemp())
|
||||
self.thumbnail_folder_path = Path(mkdtemp())
|
||||
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
|
||||
"""
|
||||
del self.screens
|
||||
Registry().remove('settings')
|
||||
self.destroy_settings()
|
||||
rmtree(self.thumbnail_folder_path)
|
||||
rmtree(self.temp_folder_path)
|
||||
|
@ -28,6 +28,7 @@ from unittest import TestCase
|
||||
from unittest.mock import MagicMock, patch
|
||||
|
||||
from openlp.core.common import is_win
|
||||
from openlp.core.common.registry import Registry
|
||||
from openlp.core.common.settings import Settings
|
||||
from openlp.plugins.presentations.lib.powerpointcontroller import PowerpointController, PowerpointDocument, \
|
||||
_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.real_controller = PowerpointController(self.mock_plugin)
|
||||
Settings().extend_default_settings(__default_settings__)
|
||||
Registry.create()
|
||||
Registry().register('settings', Settings())
|
||||
|
||||
def tearDown(self):
|
||||
"""
|
||||
|
@ -21,8 +21,6 @@
|
||||
"""
|
||||
This module contains tests for the OpenSong song importer.
|
||||
"""
|
||||
from unittest.mock import MagicMock, patch
|
||||
|
||||
from tests.helpers.songfileimport import SongImportTestHelper
|
||||
from tests.utils.constants import RESOURCE_PATH
|
||||
|
||||
@ -37,15 +35,12 @@ class TestChordProFileImport(SongImportTestHelper):
|
||||
self.importer_module_name = 'chordpro'
|
||||
super(TestChordProFileImport, self).__init__(*args, **kwargs)
|
||||
|
||||
@patch('openlp.plugins.songs.lib.importers.chordpro.Settings')
|
||||
def test_song_import(self, mocked_settings):
|
||||
def test_song_import(self):
|
||||
"""
|
||||
Test that loading an ChordPro file works correctly on various files
|
||||
"""
|
||||
# Mock out the settings - always return False
|
||||
mocked_returned_settings = MagicMock()
|
||||
mocked_returned_settings.value.side_effect = lambda value: True if value == 'songs/enable chords' else False
|
||||
mocked_settings.return_value = mocked_returned_settings
|
||||
self.settings.value.side_effect = lambda value: True if value == 'songs/enable chords' else False
|
||||
# Do the test import
|
||||
self.file_import([TEST_PATH / 'swing-low.chordpro'],
|
||||
self.load_external_result_data(TEST_PATH / 'swing-low.json'))
|
||||
|
@ -26,16 +26,11 @@ from unittest.mock import MagicMock
|
||||
|
||||
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 tests.helpers.testmixin import TestMixin
|
||||
|
||||
|
||||
__default_settings__ = {
|
||||
'songs/enable chords': True,
|
||||
}
|
||||
|
||||
|
||||
class TestEditVerseForm(TestCase, TestMixin):
|
||||
"""
|
||||
Test the functions in the :mod:`lib` module.
|
||||
@ -46,7 +41,9 @@ class TestEditVerseForm(TestCase, TestMixin):
|
||||
"""
|
||||
self.setup_application()
|
||||
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)
|
||||
QtCore.QLocale.setDefault(QtCore.QLocale('en_GB'))
|
||||
|
||||
|
@ -24,6 +24,7 @@ This module contains tests for the lib submodule of the Songs plugin.
|
||||
from unittest import TestCase
|
||||
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.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
|
||||
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'''
|
||||
Registry.create()
|
||||
Registry().register('settings', MagicMock())
|
||||
self.settings = Registry().get('settings')
|
||||
|
||||
def test_clean_string(self):
|
||||
"""
|
||||
@ -317,8 +321,7 @@ class TestLib(TestCase):
|
||||
'ValueError exception should have been thrown for invalid chord'
|
||||
|
||||
@patch('openlp.plugins.songs.lib.transpose_verse')
|
||||
@patch('openlp.plugins.songs.lib.Settings')
|
||||
def test_transpose_lyrics(self, mocked_settings, mocked_transpose_verse):
|
||||
def test_transpose_lyrics(self, mocked_transpose_verse):
|
||||
"""
|
||||
Test that the transpose_lyrics() splits verses correctly
|
||||
"""
|
||||
@ -329,9 +332,7 @@ class TestLib(TestCase):
|
||||
'That saved a wretch like me.\n'\
|
||||
'---[Verse:2]---\n'\
|
||||
'I once was lost but now I\'m found.'
|
||||
mocked_returned_settings = MagicMock()
|
||||
mocked_returned_settings.value.return_value = 'english'
|
||||
mocked_settings.return_value = mocked_returned_settings
|
||||
self.settings.value.return_value = 'english'
|
||||
|
||||
# WHEN: Transposing the lyrics
|
||||
transpose_lyrics(lyrics, 1)
|
||||
|
@ -40,15 +40,12 @@ class TestOpenSongFileImport(SongImportTestHelper):
|
||||
self.importer_module_name = 'opensong'
|
||||
super(TestOpenSongFileImport, self).__init__(*args, **kwargs)
|
||||
|
||||
@patch('openlp.plugins.songs.lib.importers.opensong.Settings')
|
||||
def test_song_import(self, mocked_settings):
|
||||
def test_song_import(self):
|
||||
"""
|
||||
Test that loading an OpenSong file works correctly on various files
|
||||
"""
|
||||
# Mock out the settings - always return False
|
||||
mocked_returned_settings = MagicMock()
|
||||
mocked_returned_settings.value.side_effect = lambda value: True if value == 'songs/enable chords' else False
|
||||
mocked_settings.return_value = mocked_returned_settings
|
||||
self.settings.value.side_effect = lambda value: True if value == 'songs/enable chords' else False
|
||||
# Do the test import
|
||||
self.file_import([TEST_PATH / 'Amazing Grace'],
|
||||
self.load_external_result_data(TEST_PATH / 'Amazing Grace.json'))
|
||||
|
@ -40,15 +40,12 @@ class TestSongBeamerFileImport(SongImportTestHelper):
|
||||
self.importer_module_name = 'songbeamer'
|
||||
super(TestSongBeamerFileImport, self).__init__(*args, **kwargs)
|
||||
|
||||
@patch('openlp.plugins.songs.lib.importers.songbeamer.Settings')
|
||||
def test_song_import(self, mocked_settings):
|
||||
def test_song_import(self):
|
||||
"""
|
||||
Test that loading an SongBeamer file works correctly on various files
|
||||
"""
|
||||
# Mock out the settings - always return False
|
||||
mocked_returned_settings = MagicMock()
|
||||
mocked_returned_settings.value.side_effect = lambda value: True if value == 'songs/enable chords' else False
|
||||
mocked_settings.return_value = mocked_returned_settings
|
||||
self.settings.value.side_effect = lambda value: True if value == 'songs/enable chords' else False
|
||||
self.file_import([TEST_PATH / 'Amazing Grace.sng'],
|
||||
self.load_external_result_data(TEST_PATH / 'Amazing Grace.json'))
|
||||
self.file_import([TEST_PATH / 'Lobsinget dem Herrn.sng'],
|
||||
|
@ -553,6 +553,7 @@ class TestSongSelectForm(TestCase, TestMixin):
|
||||
self.app.process_events = lambda: None
|
||||
Registry.create()
|
||||
Registry().register('application', self.app)
|
||||
Registry().register('settings', MagicMock())
|
||||
|
||||
def test_create_form(self):
|
||||
"""
|
||||
@ -802,10 +803,9 @@ class TestSongSelectForm(TestCase, TestMixin):
|
||||
assert ssform.search_button.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.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.
|
||||
"""
|
||||
|
@ -21,7 +21,6 @@
|
||||
"""
|
||||
This module contains tests for the VideoPsalm song importer.
|
||||
"""
|
||||
from unittest.mock import MagicMock, patch
|
||||
|
||||
from tests.helpers.songfileimport import SongImportTestHelper
|
||||
from tests.utils.constants import RESOURCE_PATH
|
||||
@ -37,15 +36,12 @@ class TestVideoPsalmFileImport(SongImportTestHelper):
|
||||
self.importer_module_name = 'videopsalm'
|
||||
super(TestVideoPsalmFileImport, self).__init__(*args, **kwargs)
|
||||
|
||||
@patch('openlp.plugins.songs.lib.importers.videopsalm.Settings')
|
||||
def test_song_import(self, mocked_settings):
|
||||
def test_song_import(self):
|
||||
"""
|
||||
Test that loading an VideoPsalm file works correctly on various files
|
||||
"""
|
||||
# Mock out the settings - always return False
|
||||
mocked_returned_settings = MagicMock()
|
||||
mocked_returned_settings.value.side_effect = lambda value: True if value == 'songs/enable chords' else False
|
||||
mocked_settings.return_value = mocked_returned_settings
|
||||
self.settings.value.side_effect = lambda value: True if value == 'songs/enable chords' else False
|
||||
# Do the test import
|
||||
self.file_import(TEST_PATH / 'videopsalm-as-safe-a-stronghold.json',
|
||||
self.load_external_result_data(TEST_PATH / 'as-safe-a-stronghold.json'))
|
||||
|
@ -42,12 +42,14 @@ class SongImportTestHelper(TestCase):
|
||||
self.importer_module = __import__('openlp.plugins.songs.lib.importers.%s' %
|
||||
self.importer_module_name, fromlist=[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):
|
||||
"""
|
||||
Patch and set up the mocks required.
|
||||
"""
|
||||
Registry.create()
|
||||
self.add_copyright_patcher = patch('openlp.plugins.songs.lib.importers.%s.%s.add_copyright' %
|
||||
(self.importer_module_name, self.importer_class_name))
|
||||
self.add_verse_patcher = patch('openlp.plugins.songs.lib.importers.%s.%s.add_verse' %
|
||||
|
@ -63,6 +63,7 @@ class TestSelectPlanForm(TestCase, TestMixin):
|
||||
self.setup_application()
|
||||
self.build_settings()
|
||||
State().load_settings()
|
||||
Registry().register('settings', Settings())
|
||||
Registry().register('main_window', MagicMock(service_manager_settings_section='servicemanager'))
|
||||
self.application_id = 'abc'
|
||||
self.secret = '123'
|
||||
|
@ -43,9 +43,9 @@ class TestPlanningCenterTab(TestCase, TestMixin):
|
||||
Create the UI
|
||||
"""
|
||||
self.setup_application()
|
||||
self.registry = Registry()
|
||||
Registry.create()
|
||||
State().load_settings()
|
||||
Registry().register('settings', Settings())
|
||||
self.plugin = PlanningCenterPlugin()
|
||||
Settings().setValue('planningcenter/application_id', 'abc')
|
||||
Settings().setValue('planningcenter/secret', '123')
|
||||
@ -62,7 +62,6 @@ class TestPlanningCenterTab(TestCase, TestMixin):
|
||||
"""
|
||||
del self.tab
|
||||
del self.dialog
|
||||
del self.registry
|
||||
|
||||
def test_bad_authentication_credentials(self):
|
||||
"""
|
||||
|
@ -47,6 +47,7 @@ class TestPlanningCenterPlugin(TestCase, TestMixin):
|
||||
self.registry = Registry()
|
||||
Registry.create()
|
||||
State().load_settings()
|
||||
Registry().register('settings', Settings())
|
||||
self.plugin = PlanningCenterPlugin()
|
||||
self.settings_form = SettingsForm()
|
||||
|
||||
|
@ -54,6 +54,7 @@ class TestEditSongForm(TestCase, TestMixin):
|
||||
Registry().register('theme_manager', MagicMock())
|
||||
self.build_settings()
|
||||
Settings().extend_default_settings(__default_settings__)
|
||||
Registry().register('settings', Settings())
|
||||
self.form = EditSongForm(MagicMock(), self.main_window, MagicMock())
|
||||
|
||||
def tearDown(self):
|
||||
|
@ -50,6 +50,7 @@ class TestEditVerseForm(TestCase, TestMixin):
|
||||
self.main_window = QtWidgets.QMainWindow()
|
||||
Registry().register('main_window', self.main_window)
|
||||
self.build_settings()
|
||||
Registry().register('settings', Settings())
|
||||
Settings().extend_default_settings(__default_settings__)
|
||||
self.form = EditVerseForm()
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user