Settings cleanup

This commit is contained in:
Tim Bentley 2020-06-06 16:05:36 +00:00
parent e2cd0cc4a0
commit 6eba3b7a3e
49 changed files with 314 additions and 374 deletions

View File

@ -256,16 +256,16 @@ class ApiTab(SettingsTab):
"""
Load the configuration and update the server configuration if necessary
"""
self.port_spin_box.setText(str(self.settings.value(self.settings_section + '/port')))
self.address_edit.setText(self.settings.value(self.settings_section + '/ip address'))
self.twelve_hour = self.settings.value(self.settings_section + '/twelve hour')
self.port_spin_box.setText(str(self.settings.value('api/port')))
self.address_edit.setText(self.settings.value('api/ip address'))
self.twelve_hour = self.settings.value('api/twelve hour')
self.twelve_hour_check_box.setChecked(self.twelve_hour)
self.thumbnails = self.settings.value(self.settings_section + '/thumbnails')
self.thumbnails = self.settings.value('api/thumbnails')
self.thumbnails_check_box.setChecked(self.thumbnails)
self.user_login_group_box.setChecked(self.settings.value(self.settings_section + '/authentication enabled'))
self.user_id.setText(self.settings.value(self.settings_section + '/user id'))
self.password.setText(self.settings.value(self.settings_section + '/password'))
self.current_version_value.setText(self.settings.value(self.settings_section + '/download version'))
self.user_login_group_box.setChecked(self.settings.value('api/authentication enabled'))
self.user_id.setText(self.settings.value('api/user id'))
self.password.setText(self.settings.value('api/password'))
self.current_version_value.setText(self.settings.value('api/download version'))
self.set_master_version()
self.set_urls()
@ -273,14 +273,14 @@ class ApiTab(SettingsTab):
"""
Save the configuration and update the server configuration if necessary
"""
if self.settings.value(self.settings_section + '/ip address') != self.address_edit.text():
if self.settings.value('api/ip address') != self.address_edit.text():
self.settings_form.register_post_process('remotes_config_updated')
self.settings.setValue(self.settings_section + '/ip address', self.address_edit.text())
self.settings.setValue(self.settings_section + '/twelve hour', self.twelve_hour)
self.settings.setValue(self.settings_section + '/thumbnails', self.thumbnails)
self.settings.setValue(self.settings_section + '/authentication enabled', self.user_login_group_box.isChecked())
self.settings.setValue(self.settings_section + '/user id', self.user_id.text())
self.settings.setValue(self.settings_section + '/password', self.password.text())
self.settings.setValue('api/ip address', self.address_edit.text())
self.settings.setValue('api/twelve hour', self.twelve_hour)
self.settings.setValue('api/thumbnails', self.thumbnails)
self.settings.setValue('api/authentication enabled', self.user_login_group_box.isChecked())
self.settings.setValue('api/user id', self.user_id.text())
self.settings.setValue('api/password', self.password.text())
def on_twelve_hour_check_box_changed(self, check_state):
"""
@ -332,5 +332,5 @@ class ApiTab(SettingsTab):
progress.close()
app.process_events()
self.current_version_value.setText(downloaded_version)
self.settings.setValue(self.settings_section + '/download version', downloaded_version)
self.settings.setValue('api/download version', downloaded_version)
self.upgrade_button.setEnabled(self.can_enable_upgrade_button())

View File

@ -244,16 +244,14 @@ class ActionList(object):
if category not in self.categories:
self.categories.append(category)
settings = Registry().get('settings')
settings.beginGroup('shortcuts')
# Get the default shortcut from the config.
action.default_shortcuts = settings.get_default_value(action.objectName())
action.default_shortcuts = settings.get_default_value('shortcuts/' + action.objectName())
if weight is None:
self.categories[category].actions.append(action)
else:
self.categories[category].actions.add(action, weight)
# Load the shortcut from the config.
shortcuts = settings.value(action.objectName())
settings.endGroup()
shortcuts = settings.value('shortcuts/' + action.objectName())
if not shortcuts:
action.setShortcuts([])
return

View File

@ -762,19 +762,17 @@ class Settings(QtCore.QSettings):
now = datetime.datetime.now()
# Write INI format using QSettings.
# Write our header.
export_settings.beginGroup('SettingsImport')
export_settings.setValue('Make_Changes', 'At_Own_RISK')
export_settings.setValue('type', 'OpenLP_settings_export')
export_settings.setValue('file_date_created', now.strftime("%Y-%m-%d %H:%M"))
export_settings.endGroup()
export_settings.setValue('SettingsImport/Make_Changes', 'At_Own_RISK')
export_settings.setValue('SettingsImport/type', 'OpenLP_settings_export')
export_settings.setValue('SettingsImport/file_date_created', now.strftime("%Y-%m-%d %H:%M"))
# Write all the sections and keys.
for section_key in keys:
# FIXME: We are conflicting with the standard "General" section.
if 'eneral' in section_key:
section_key = section_key.lower()
key_value = super().value(section_key)
if key_value is not None:
export_settings.setValue(section_key, key_value)
try:
key_value = super().value(section_key)
if key_value is not None:
export_settings.setValue(section_key, key_value)
except TypeError:
log.exception(f'Key Value invalid and bypassed for {section_key}')
export_settings.sync()
# Temp CONF file has been written. Blanks in keys are now '%20'.
# Read the temp file and output the user's CONF file with blanks to

View File

@ -170,10 +170,8 @@ def init_url(plugin_name, db_file_name=None):
:rtype: str
"""
settings = Registry().get('settings')
settings.beginGroup(plugin_name)
db_type = settings.value('db type')
db_type = settings.value(f'{plugin_name}/db type')
if db_type == 'sqlite':
settings.endGroup()
db_url = get_db_path(plugin_name, db_file_name)
else:
db_url = '{type}://{user}:{password}@{host}/{db}'.format(type=db_type,
@ -181,7 +179,6 @@ def init_url(plugin_name, db_file_name=None):
password=urlquote(settings.value('db password')),
host=urlquote(settings.value('db hostname')),
db=urlquote(settings.value('db database')))
settings.endGroup()
return db_url

View File

@ -61,9 +61,6 @@ class Plugin(RegistryBase, RegistryProperties):
``version``
The version number of this iteration of the plugin.
``settings_section``
The namespace to store settings for the plugin.
``icon``
An instance of QIcon, which holds an icon for this plugin.
@ -126,7 +123,6 @@ class Plugin(RegistryBase, RegistryProperties):
self.text_strings = {}
self.set_plugin_text_strings()
self.name_strings = self.text_strings[StringContent.Name]
self.settings_section = self.name
self.icon = None
self.media_item_class = media_item_class
self.settings_tab_class = settings_tab_class
@ -163,14 +159,14 @@ class Plugin(RegistryBase, RegistryProperties):
"""
Sets the status of the plugin
"""
self.status = self.settings.value(self.settings_section + '/status')
self.status = self.settings.value(f'{self.name}/status')
def toggle_status(self, new_status):
"""
Changes the status of the plugin and remembers it
"""
self.status = new_status
self.settings.setValue(self.settings_section + '/status', self.status)
self.settings.setValue(f'{self.name}/status', self.status)
if new_status == PluginStatus.Active:
self.initialise()
elif new_status == PluginStatus.Inactive:

View File

@ -43,7 +43,6 @@ class SettingsTab(QtWidgets.QWidget, RegistryProperties):
super(SettingsTab, self).__init__(parent)
self.tab_title = title
self.tab_title_visible = visible_title
self.settings_section = self.tab_title.lower()
self.tab_visited = False
if icon_path:
self.icon_path = icon_path

View File

@ -342,54 +342,54 @@ class AdvancedTab(SettingsTab):
"""
Load settings from disk.
"""
self.settings.beginGroup(self.settings_section)
# The max recent files value does not have an interface and so never
# gets actually stored in the settings therefore the default value of
# 20 will always be used.
self.recent_spin_box.setMaximum(self.settings.value('max recent files'))
self.recent_spin_box.setValue(self.settings.value('recent file count'))
self.media_plugin_check_box.setChecked(self.settings.value('save current plugin'))
self.double_click_live_check_box.setChecked(self.settings.value('double click live'))
self.single_click_preview_check_box.setChecked(self.settings.value('single click preview'))
self.single_click_service_preview_check_box.setChecked(self.settings.value('single click service preview'))
self.expand_service_item_check_box.setChecked(self.settings.value('expand service item'))
slide_max_height_value = self.settings.value('slide max height')
self.recent_spin_box.setMaximum(self.settings.value('advanced/max recent files'))
self.recent_spin_box.setValue(self.settings.value('advanced/recent file count'))
self.media_plugin_check_box.setChecked(self.settings.value('advanced/save current plugin'))
self.double_click_live_check_box.setChecked(self.settings.value('advanced/double click live'))
self.single_click_preview_check_box.setChecked(self.settings.value('advanced/single click preview'))
self.single_click_service_preview_check_box.setChecked(
self.settings.value('advanced/single click service preview'))
self.expand_service_item_check_box.setChecked(self.settings.value('advanced/expand service item'))
slide_max_height_value = self.settings.value('advanced/slide max height')
for i in range(0, self.slide_max_height_combo_box.count()):
if self.slide_max_height_combo_box.itemData(i) == slide_max_height_value:
self.slide_max_height_combo_box.setCurrentIndex(i)
autoscroll_value = self.settings.value('autoscrolling')
autoscroll_value = self.settings.value('advanced/autoscrolling')
for i in range(0, len(self.autoscroll_map)):
if self.autoscroll_map[i] == autoscroll_value and i < self.autoscroll_combo_box.count():
self.autoscroll_combo_box.setCurrentIndex(i)
self.enable_auto_close_check_box.setChecked(self.settings.value('enable exit confirmation'))
self.enable_auto_close_check_box.setChecked(self.settings.value('advanced/enable exit confirmation'))
if HAS_DARK_STYLE:
self.use_dark_style_checkbox.setChecked(self.settings.value('use_dark_style'))
self.hide_mouse_check_box.setChecked(self.settings.value('hide mouse'))
self.service_name_day.setCurrentIndex(self.settings.value('default service day'))
self.service_name_time.setTime(QtCore.QTime(self.settings.value('default service hour'),
self.settings.value('default service minute')))
self.use_dark_style_checkbox.setChecked(self.settings.value('advanced/use_dark_style'))
self.hide_mouse_check_box.setChecked(self.settings.value('advanced/hide mouse'))
self.service_name_day.setCurrentIndex(self.settings.value('advanced/default service day'))
self.service_name_time.setTime(QtCore.QTime(self.settings.value('advanced/default service hour'),
self.settings.value('advanced/default service minute')))
self.should_update_service_name_example = True
self.service_name_edit.setText(self.settings.value('default service name'))
default_service_enabled = self.settings.value('default service enabled')
self.service_name_edit.setText(self.settings.value('advanced/default service name'))
default_service_enabled = self.settings.value('advanced/default service enabled')
self.service_name_check_box.setChecked(default_service_enabled)
self.service_name_check_box_toggled(default_service_enabled)
self.ignore_aspect_ratio_check_box.setChecked(self.settings.value('ignore aspect ratio'))
self.x11_bypass_check_box.setChecked(self.settings.value('x11 bypass wm'))
self.slide_limits = self.settings.value('slide limits')
self.is_search_as_you_type_enabled = self.settings.value('search as type')
self.ignore_aspect_ratio_check_box.setChecked(self.settings.value('advanced/ignore aspect ratio'))
self.x11_bypass_check_box.setChecked(self.settings.value('advanced/x11 bypass wm'))
self.slide_limits = self.settings.value('advanced/slide limits')
self.is_search_as_you_type_enabled = self.settings.value('advanced/search as type')
self.search_as_type_check_box.setChecked(self.is_search_as_you_type_enabled)
# Prevent the dialog displayed by the alternate_rows_check_box to display.
self.alternate_rows_check_box.blockSignals(True)
self.alternate_rows_check_box.setChecked(self.settings.value('alternate rows'))
self.alternate_rows_check_box.setChecked(self.settings.value('advanced/alternate rows'))
self.alternate_rows_check_box.blockSignals(False)
self.allow_transparent_display_check_box.setChecked(self.settings.value('disable transparent display'))
self.allow_transparent_display_check_box.setChecked(self.settings.value('advanced/disable transparent display'))
if self.slide_limits == SlideLimits.End:
self.end_slide_radio_button.setChecked(True)
elif self.slide_limits == SlideLimits.Wrap:
self.wrap_slide_radio_button.setChecked(True)
else:
self.next_item_radio_button.setChecked(True)
self.settings.endGroup()
self.data_directory_copy_check_box.hide()
self.new_data_directory_has_files_label.hide()
self.data_directory_cancel_button.hide()
@ -403,42 +403,42 @@ class AdvancedTab(SettingsTab):
"""
Save settings to disk.
"""
self.settings.beginGroup(self.settings_section)
self.settings.setValue('default service enabled', self.service_name_check_box.isChecked())
self.settings.setValue('advanced/default service enabled', self.service_name_check_box.isChecked())
service_name = self.service_name_edit.text()
preset_is_valid = self.generate_service_name_example()[0]
if service_name == UiStrings().DefaultServiceName or not preset_is_valid:
self.settings.remove('default service name')
self.settings.remove('advanced/default service name')
self.service_name_edit.setText(service_name)
else:
self.settings.setValue('default service name', service_name)
self.settings.setValue('default service day', self.service_name_day.currentIndex())
self.settings.setValue('default service hour', self.service_name_time.time().hour())
self.settings.setValue('default service minute', self.service_name_time.time().minute())
self.settings.setValue('recent file count', self.recent_spin_box.value())
self.settings.setValue('save current plugin', self.media_plugin_check_box.isChecked())
self.settings.setValue('double click live', self.double_click_live_check_box.isChecked())
self.settings.setValue('single click preview', self.single_click_preview_check_box.isChecked())
self.settings.setValue('single click service preview', self.single_click_service_preview_check_box.isChecked())
self.settings.setValue('expand service item', self.expand_service_item_check_box.isChecked())
self.settings.setValue('advanced/default service name', service_name)
self.settings.setValue('advanced/default service day', self.service_name_day.currentIndex())
self.settings.setValue('advanced/default service hour', self.service_name_time.time().hour())
self.settings.setValue('advanced/default service minute', self.service_name_time.time().minute())
self.settings.setValue('advanced/recent file count', self.recent_spin_box.value())
self.settings.setValue('advanced/save current plugin', self.media_plugin_check_box.isChecked())
self.settings.setValue('advanced/double click live', self.double_click_live_check_box.isChecked())
self.settings.setValue('advanced/single click preview', self.single_click_preview_check_box.isChecked())
self.settings.setValue('advanced/single click service preview',
self.single_click_service_preview_check_box.isChecked())
self.settings.setValue('advanced/expand service item', self.expand_service_item_check_box.isChecked())
slide_max_height_index = self.slide_max_height_combo_box.currentIndex()
slide_max_height_value = self.slide_max_height_combo_box.itemData(slide_max_height_index)
self.settings.setValue('slide max height', slide_max_height_value)
self.settings.setValue('autoscrolling', self.autoscroll_map[self.autoscroll_combo_box.currentIndex()])
self.settings.setValue('enable exit confirmation', self.enable_auto_close_check_box.isChecked())
self.settings.setValue('hide mouse', self.hide_mouse_check_box.isChecked())
self.settings.setValue('alternate rows', self.alternate_rows_check_box.isChecked())
self.settings.setValue('disable transparent display', self.allow_transparent_display_check_box.isChecked())
self.settings.setValue('slide limits', self.slide_limits)
self.settings.setValue('ignore aspect ratio', self.ignore_aspect_ratio_check_box.isChecked())
if self.x11_bypass_check_box.isChecked() != self.settings.value('x11 bypass wm'):
self.settings.setValue('x11 bypass wm', self.x11_bypass_check_box.isChecked())
self.settings.setValue('advanced/slide max height', slide_max_height_value)
self.settings.setValue('advanced/autoscrolling', self.autoscroll_map[self.autoscroll_combo_box.currentIndex()])
self.settings.setValue('advanced/enable exit confirmation', self.enable_auto_close_check_box.isChecked())
self.settings.setValue('advanced/hide mouse', self.hide_mouse_check_box.isChecked())
self.settings.setValue('advanced/alternate rows', self.alternate_rows_check_box.isChecked())
self.settings.setValue('advanced/disable transparent display',
self.allow_transparent_display_check_box.isChecked())
self.settings.setValue('advanced/slide limits', self.slide_limits)
self.settings.setValue('advanced/ignore aspect ratio', self.ignore_aspect_ratio_check_box.isChecked())
if self.x11_bypass_check_box.isChecked() != self.settings.value('advanced/x11 bypass wm'):
self.settings.setValue('advanced/x11 bypass wm', self.x11_bypass_check_box.isChecked())
self.settings_form.register_post_process('config_screen_changed')
self.settings_form.register_post_process('slidecontroller_update_slide_limits')
self.settings.setValue('search as type', self.is_search_as_you_type_enabled)
self.settings.setValue('advanced/search as type', self.is_search_as_you_type_enabled)
if HAS_DARK_STYLE:
self.settings.setValue('use_dark_style', self.use_dark_style_checkbox.isChecked())
self.settings.endGroup()
self.settings.setValue('advanced/use_dark_style', self.use_dark_style_checkbox.isChecked())
self.proxy_widget.save()
def on_search_as_type_check_box_changed(self, check_state):

View File

@ -185,44 +185,41 @@ class GeneralTab(SettingsTab):
"""
Load the settings to populate the form
"""
self.settings.beginGroup(self.settings_section)
self.number_edit.setText(self.settings.value('ccli number'))
self.username_edit.setText(self.settings.value('songselect username'))
self.password_edit.setText(self.settings.value('songselect password'))
self.auto_unblank_check_box.setChecked(self.settings.value('auto unblank'))
self.click_live_slide_to_unblank_check_box.setChecked(self.settings.value('click live slide to unblank'))
self.warning_check_box.setChecked(self.settings.value('blank warning'))
self.auto_open_check_box.setChecked(self.settings.value('auto open'))
self.show_splash_check_box.setChecked(self.settings.value('show splash'))
self.logo_background_color = self.settings.value('logo background color')
self.logo_file_path_edit.path = self.settings.value('logo file')
self.logo_hide_on_startup_check_box.setChecked(self.settings.value('logo hide on startup'))
self.number_edit.setText(self.settings.value('core/ccli number'))
self.username_edit.setText(self.settings.value('core/songselect username'))
self.password_edit.setText(self.settings.value('core/songselect password'))
self.auto_unblank_check_box.setChecked(self.settings.value('core/auto unblank'))
self.click_live_slide_to_unblank_check_box.setChecked(self.settings.value('core/click live slide to unblank'))
self.warning_check_box.setChecked(self.settings.value('core/blank warning'))
self.auto_open_check_box.setChecked(self.settings.value('core/auto open'))
self.show_splash_check_box.setChecked(self.settings.value('core/show splash'))
self.logo_background_color = self.settings.value('core/logo background color')
self.logo_file_path_edit.path = self.settings.value('core/logo file')
self.logo_hide_on_startup_check_box.setChecked(self.settings.value('core/logo hide on startup'))
self.logo_color_button.color = self.logo_background_color
self.check_for_updates_check_box.setChecked(self.settings.value('update check'))
self.auto_preview_check_box.setChecked(self.settings.value('auto preview'))
self.timeout_spin_box.setValue(self.settings.value('loop delay'))
self.settings.endGroup()
self.check_for_updates_check_box.setChecked(self.settings.value('core/update check'))
self.auto_preview_check_box.setChecked(self.settings.value('core/auto preview'))
self.timeout_spin_box.setValue(self.settings.value('core/loop delay'))
def save(self):
"""
Save the settings from the form
"""
self.settings.beginGroup(self.settings_section)
self.settings.setValue('blank warning', self.warning_check_box.isChecked())
self.settings.setValue('auto open', self.auto_open_check_box.isChecked())
self.settings.setValue('show splash', self.show_splash_check_box.isChecked())
self.settings.setValue('logo background color', self.logo_background_color)
self.settings.setValue('logo file', self.logo_file_path_edit.path)
self.settings.setValue('logo hide on startup', self.logo_hide_on_startup_check_box.isChecked())
self.settings.setValue('update check', self.check_for_updates_check_box.isChecked())
self.settings.setValue('auto unblank', self.auto_unblank_check_box.isChecked())
self.settings.setValue('click live slide to unblank', self.click_live_slide_to_unblank_check_box.isChecked())
self.settings.setValue('auto preview', self.auto_preview_check_box.isChecked())
self.settings.setValue('loop delay', self.timeout_spin_box.value())
self.settings.setValue('ccli number', self.number_edit.displayText())
self.settings.setValue('songselect username', self.username_edit.displayText())
self.settings.setValue('songselect password', self.password_edit.displayText())
self.settings.endGroup()
self.settings.setValue('core/blank warning', self.warning_check_box.isChecked())
self.settings.setValue('core/auto open', self.auto_open_check_box.isChecked())
self.settings.setValue('core/show splash', self.show_splash_check_box.isChecked())
self.settings.setValue('core/logo background color', self.logo_background_color)
self.settings.setValue('core/logo file', self.logo_file_path_edit.path)
self.settings.setValue('core/logo hide on startup', self.logo_hide_on_startup_check_box.isChecked())
self.settings.setValue('core/update check', self.check_for_updates_check_box.isChecked())
self.settings.setValue('core/auto unblank', self.auto_unblank_check_box.isChecked())
self.settings.setValue('core/click live slide to unblank',
self.click_live_slide_to_unblank_check_box.isChecked())
self.settings.setValue('core/auto preview', self.auto_preview_check_box.isChecked())
self.settings.setValue('core/loop delay', self.timeout_spin_box.value())
self.settings.setValue('core/ccli number', self.number_edit.displayText())
self.settings.setValue('core/songselect username', self.username_edit.displayText())
self.settings.setValue('core/songselect password', self.password_edit.displayText())
self.post_set_up()
def post_set_up(self):

View File

@ -476,18 +476,6 @@ class MainWindow(QtWidgets.QMainWindow, Ui_MainWindow, LogMixin, RegistryPropert
super(MainWindow, self).__init__()
Registry().register('main_window', self)
self.clipboard = QtWidgets.QApplication.clipboard()
# Set up settings sections for the main application (not for use by plugins).
self.ui_settings_section = 'user interface'
self.general_settings_section = 'core'
self.advanced_settings_section = 'advanced'
self.shortcuts_settings_section = 'shortcuts'
self.service_manager_settings_section = 'servicemanager'
self.songs_settings_section = 'songs'
self.themes_settings_section = 'themes'
self.projector_settings_section = 'projector'
self.players_settings_section = 'players'
self.display_tags_section = 'displayTags'
self.header_section = 'SettingsImport'
self.recent_files = []
self.timer_id = 0
self.new_data_path = None
@ -657,11 +645,11 @@ class MainWindow(QtWidgets.QMainWindow, Ui_MainWindow, LogMixin, RegistryPropert
# If not we need to see if we want to use the previous file.so count of 1
if self.application.args and len(self.application.args) > 1:
self.open_cmd_line_files(self.application.args)
elif self.settings.value(self.general_settings_section + '/auto open'):
elif self.settings.value('core/auto open'):
self.service_manager_contents.load_last_file()
# This will store currently used layout preset so it remains enabled on next startup.
# If any panel is enabled/disabled after preset is set, this setting is not saved.
view_mode = self.settings.value('{section}/view mode'.format(section=self.general_settings_section))
view_mode = self.settings.value('core/view mode')
if view_mode == 'default' and self.settings.value('user interface/is preset layout'):
self.mode_default_item.setChecked(True)
elif view_mode == 'setup' and self.settings.value('user interface/is preset layout'):
@ -737,8 +725,8 @@ class MainWindow(QtWidgets.QMainWindow, Ui_MainWindow, LogMixin, RegistryPropert
"""
Check and display message if screen blank on setup.
"""
if self.settings.value('{section}/screen blank'.format(section=self.general_settings_section)):
if self.settings.value('{section}/blank warning'.format(section=self.general_settings_section)):
if self.settings.value('core/screen blank'):
if self.settings.value('core/blank warning'):
QtWidgets.QMessageBox.question(self, translate('OpenLP.MainWindow', 'OpenLP Main Display Blanked'),
translate('OpenLP.MainWindow', 'The Main Display has been blanked out'))
@ -866,16 +854,16 @@ class MainWindow(QtWidgets.QMainWindow, Ui_MainWindow, LogMixin, RegistryPropert
return
setting_sections = []
# Add main sections.
setting_sections.extend([self.general_settings_section])
setting_sections.extend([self.advanced_settings_section])
setting_sections.extend([self.ui_settings_section])
setting_sections.extend([self.shortcuts_settings_section])
setting_sections.extend([self.service_manager_settings_section])
setting_sections.extend([self.themes_settings_section])
setting_sections.extend([self.projector_settings_section])
setting_sections.extend([self.players_settings_section])
setting_sections.extend([self.display_tags_section])
setting_sections.extend([self.header_section])
setting_sections.extend(['core'])
setting_sections.extend(['advanced'])
setting_sections.extend(['user interface'])
setting_sections.extend(['shortcuts'])
setting_sections.extend(['servicemanager'])
setting_sections.extend(['themes'])
setting_sections.extend(['projector'])
setting_sections.extend(['players'])
setting_sections.extend(['displayTags'])
setting_sections.extend(['SettingsImport'])
setting_sections.extend(['crashreport'])
# Add plugin sections.
setting_sections.extend([plugin.name for plugin in State().list_plugins()])
@ -929,10 +917,8 @@ class MainWindow(QtWidgets.QMainWindow, Ui_MainWindow, LogMixin, RegistryPropert
if value is not None:
self.settings.setValue('{key}'.format(key=section_key), value)
now = datetime.now()
self.settings.beginGroup(self.header_section)
self.settings.setValue('file_imported', import_file_path)
self.settings.setValue('file_date_imported', now.strftime("%Y-%m-%d %H:%M"))
self.settings.endGroup()
self.settings.setValue('SettingsImport/file_imported', import_file_path)
self.settings.setValue('SettingsImport/file_date_imported', now.strftime("%Y-%m-%d %H:%M"))
self.settings.sync()
# We must do an immediate restart or current configuration will overwrite what was just imported when
# application terminates normally. We need to exit without saving configuration.
@ -996,7 +982,7 @@ class MainWindow(QtWidgets.QMainWindow, Ui_MainWindow, LogMixin, RegistryPropert
Set OpenLP to a different view mode.
"""
if mode:
self.settings.setValue('{section}/view mode'.format(section=self.general_settings_section), mode)
self.settings.setValue('core/view mode', mode)
self.media_manager_dock.setVisible(media)
self.service_manager_dock.setVisible(service)
self.theme_manager_dock.setVisible(theme)
@ -1240,20 +1226,16 @@ class MainWindow(QtWidgets.QMainWindow, Ui_MainWindow, LogMixin, RegistryPropert
# Remove obsolete entries.
self.settings.remove('custom slide')
self.settings.remove('service')
self.settings.beginGroup(self.general_settings_section)
self.recent_files = self.settings.value('recent files')
self.settings.endGroup()
self.settings.beginGroup(self.ui_settings_section)
self.move(self.settings.value('main window position'))
self.restoreGeometry(self.settings.value('main window geometry'))
self.restoreState(self.settings.value('main window state'))
self.live_controller.splitter.restoreState(self.settings.value('live splitter geometry'))
self.preview_controller.splitter.restoreState(self.settings.value('preview splitter geometry'))
self.control_splitter.restoreState(self.settings.value('main window splitter geometry'))
self.recent_files = self.settings.value('core/recent files')
self.move(self.settings.value('user interface/main window position'))
self.restoreGeometry(self.settings.value('user interface/main window geometry'))
self.restoreState(self.settings.value('user interface/main window state'))
self.live_controller.splitter.restoreState(self.settings.value('user interface/live splitter geometry'))
self.preview_controller.splitter.restoreState(self.settings.value('user interface/preview splitter geometry'))
self.control_splitter.restoreState(self.settings.value('user interface/main window splitter geometry'))
# This needs to be called after restoreState(), because saveState() also saves the "Collapsible" property
# which was True (by default) < OpenLP 2.1.
self.control_splitter.setChildrenCollapsible(False)
self.settings.endGroup()
def save_settings(self):
"""
@ -1262,17 +1244,13 @@ class MainWindow(QtWidgets.QMainWindow, Ui_MainWindow, LogMixin, RegistryPropert
# Exit if we just did a settings import.
if self.settings_imported:
return
self.settings.beginGroup(self.general_settings_section)
self.settings.setValue('recent files', self.recent_files)
self.settings.endGroup()
self.settings.beginGroup(self.ui_settings_section)
self.settings.setValue('main window position', self.pos())
self.settings.setValue('main window state', self.saveState())
self.settings.setValue('main window geometry', self.saveGeometry())
self.settings.setValue('live splitter geometry', self.live_controller.splitter.saveState())
self.settings.setValue('preview splitter geometry', self.preview_controller.splitter.saveState())
self.settings.setValue('main window splitter geometry', self.control_splitter.saveState())
self.settings.endGroup()
self.settings.setValue('core/recent files', self.recent_files)
self.settings.setValue('user interface/main window position', self.pos())
self.settings.setValue('user interface/main window state', self.saveState())
self.settings.setValue('user interface/main window geometry', self.saveGeometry())
self.settings.setValue('user interface/live splitter geometry', self.live_controller.splitter.saveState())
self.settings.setValue('user interface/preview splitter geometry', self.preview_controller.splitter.saveState())
self.settings.setValue('user interface/main window splitter geometry', self.control_splitter.saveState())
def update_recent_files_menu(self):
"""

View File

@ -87,17 +87,17 @@ class MediaTab(SettingsTab):
"""
Load the settings
"""
self.auto_start_check_box.setChecked(self.settings.value(self.settings_section + '/media auto start'))
self.vlc_arguments_edit.setText(self.settings.value(self.settings_section + '/vlc arguments'))
self.auto_start_check_box.setChecked(self.settings.value('media/media auto start'))
self.vlc_arguments_edit.setText(self.settings.value('media/vlc arguments'))
def save(self):
"""
Save the settings
"""
setting_key = self.settings_section + '/media auto start'
setting_key = 'media/media auto start'
if self.settings.value(setting_key) != self.auto_start_check_box.checkState():
self.settings.setValue(setting_key, self.auto_start_check_box.checkState())
self.settings.setValue(self.settings_section + '/vlc arguments', self.vlc_arguments_edit.text())
self.settings.setValue('media/vlc arguments', self.vlc_arguments_edit.text())
def post_set_up(self, post_update=False):
"""

View File

@ -234,7 +234,7 @@ class Ui_ServiceManager(object):
self.service_manager_list.itemCollapsed.connect(self.collapsed)
self.service_manager_list.itemExpanded.connect(self.expanded)
# Last little bits of setting up
self.service_theme = self.settings.value(self.main_window.service_manager_settings_section + '/service theme')
self.service_theme = self.settings.value('servicemanager/service theme')
self.service_path = AppLocation.get_section_data_path('servicemanager')
# build the drag and drop context menu
self.dnd_menu = QtWidgets.QMenu()
@ -468,11 +468,11 @@ class ServiceManager(QtWidgets.QWidget, RegistryBase, Ui_ServiceManager, LogMixi
file_path, filter_used = FileDialog.getOpenFileName(
self.main_window,
translate('OpenLP.ServiceManager', 'Open File'),
self.settings.value(self.main_window.service_manager_settings_section + '/last directory'),
self.settings.value('servicemanager/last directory'),
translate('OpenLP.ServiceManager', 'OpenLP Service Files (*.osz *.oszl)'))
if not file_path:
return False
self.settings.setValue(self.main_window.service_manager_settings_section + '/last directory', file_path.parent)
self.settings.setValue('servicemanager/last directory', file_path.parent)
self.load_file(file_path)
def save_modified_service(self):
@ -660,8 +660,7 @@ class ServiceManager(QtWidgets.QWidget, RegistryBase, Ui_ServiceManager, LogMixi
with suppress(FileNotFoundError):
file_path.unlink()
os.link(temp_file.name, file_path)
self.settings.setValue(self.main_window.service_manager_settings_section + '/last directory',
file_path.parent)
self.settings.setValue('servicemanager/last directory', file_path.parent)
except (PermissionError, OSError) as error:
self.log_exception('Failed to save service to disk: {name}'.format(name=file_path))
self.main_window.error_message(
@ -698,7 +697,7 @@ class ServiceManager(QtWidgets.QWidget, RegistryBase, Ui_ServiceManager, LogMixi
else:
default_file_name = ''
default_file_path = Path(default_file_name)
directory_path = self.settings.value(self.main_window.service_manager_settings_section + '/last directory')
directory_path = self.settings.value('servicemanager/last directory')
if directory_path:
default_file_path = directory_path / default_file_path
lite_filter = translate('OpenLP.ServiceManager', 'OpenLP Service Files - lite (*.oszl)')
@ -944,8 +943,7 @@ class ServiceManager(QtWidgets.QWidget, RegistryBase, Ui_ServiceManager, LogMixi
service_item.auto_play_slides_loop = False
self.auto_play_slides_loop.setChecked(False)
if service_item.auto_play_slides_once and service_item.timed_slide_interval == 0:
service_item.timed_slide_interval = self.settings.value(
self.main_window.general_settings_section + '/loop delay')
service_item.timed_slide_interval = self.settings.value('core/loop delay')
self.set_modified()
def toggle_auto_play_slides_loop(self):
@ -959,8 +957,7 @@ class ServiceManager(QtWidgets.QWidget, RegistryBase, Ui_ServiceManager, LogMixi
service_item.auto_play_slides_once = False
self.auto_play_slides_once.setChecked(False)
if service_item.auto_play_slides_loop and service_item.timed_slide_interval == 0:
service_item.timed_slide_interval = self.settings.value(
self.main_window.general_settings_section + '/loop delay')
service_item.timed_slide_interval = self.settings.value('core/loop delay')
self.set_modified()
def on_timed_slide_interval(self):
@ -970,7 +967,7 @@ class ServiceManager(QtWidgets.QWidget, RegistryBase, Ui_ServiceManager, LogMixi
item = self.find_service_item()[0]
service_item = self.service_items[item]['service_item']
if service_item.timed_slide_interval == 0:
timed_slide_interval = self.settings.value(self.main_window.general_settings_section + '/loop delay')
timed_slide_interval = self.settings.value('core/loop delay')
else:
timed_slide_interval = service_item.timed_slide_interval
timed_slide_interval, ok = QtWidgets.QInputDialog.getInt(self, translate('OpenLP.ServiceManager',
@ -1548,7 +1545,7 @@ class ServiceManager(QtWidgets.QWidget, RegistryBase, Ui_ServiceManager, LogMixi
self.application.set_busy_cursor()
if self.service_items[item]['service_item'].is_valid:
self.live_controller.add_service_manager_item(self.service_items[item]['service_item'], child)
if self.settings.value(self.main_window.general_settings_section + '/auto preview'):
if self.settings.value('core/auto preview'):
item += 1
if self.service_items and item < len(self.service_items) and \
self.service_items[item]['service_item'].is_capable(ItemCapabilities.CanPreview):

View File

@ -345,7 +345,6 @@ class ShortcutListForm(QtWidgets.QDialog, Ui_ShortcutListDialog, RegistryPropert
Save the shortcuts. **Note**, that we do not have to load the shortcuts, as they are loaded in
:class:`~openlp.core.utils.ActionList`.
"""
self.settings.beginGroup('shortcuts')
for category in self.action_list.categories:
# Check if the category is for internal use only.
if category.name is None:
@ -355,8 +354,7 @@ class ShortcutListForm(QtWidgets.QDialog, Ui_ShortcutListDialog, RegistryPropert
old_shortcuts = list(map(self.get_shortcut_string, action.shortcuts()))
action.setShortcuts(self.changed_actions[action])
self.action_list.update_shortcut_map(action, old_shortcuts)
self.settings.setValue(action.objectName(), action.shortcuts())
self.settings.endGroup()
self.settings.setValue('shortcuts/' + action.objectName(), action.shortcuts())
def on_clear_primary_button_clicked(self, toggled):
"""

View File

@ -355,7 +355,7 @@ class SlideController(QtWidgets.QWidget, LogMixin, RegistryProperties):
self.play_slides_once = create_action(self, 'playSlidesOnce', text=UiStrings().PlaySlidesToEnd,
icon=UiIcons().play_slides, checked=False, can_shortcuts=True,
category=self.category, triggers=self.on_play_slides_once)
if self.settings.value(self.main_window.advanced_settings_section + '/slide limits') == SlideLimits.Wrap:
if self.settings.value('advanced/slide limits') == SlideLimits.Wrap:
self.play_slides_menu.setDefaultAction(self.play_slides_loop)
else:
self.play_slides_menu.setDefaultAction(self.play_slides_once)
@ -741,7 +741,7 @@ class SlideController(QtWidgets.QWidget, LogMixin, RegistryProperties):
"""
Updates the Slide Limits variable from the settings.
"""
self.slide_limits = self.settings.value(self.main_window.advanced_settings_section + '/slide limits')
self.slide_limits = self.settings.value('advanced/slide limits')
def enable_tool_bar(self, item):
"""
@ -775,8 +775,7 @@ class SlideController(QtWidgets.QWidget, LogMixin, RegistryProperties):
self.play_slides_loop.setIcon(UiIcons().loop)
self.play_slides_loop.setText(UiStrings().PlaySlidesInLoop)
if item.is_text():
if (self.settings.value(self.main_window.songs_settings_section + '/display songbar') and
not self.song_menu.menu().isEmpty()):
if (self.settings.value('songs/display songbar') and not self.song_menu.menu().isEmpty()):
self.toolbar.set_widget_visible('song_menu', True)
if item.is_capable(ItemCapabilities.CanLoop) and len(item.slides) > 1:
self.toolbar.set_widget_visible(LOOP_LIST)
@ -1111,10 +1110,10 @@ class SlideController(QtWidgets.QWidget, LogMixin, RegistryProperties):
# Update ui buttons
if hide_mode is None:
self.hide_menu.setDefaultAction(self.blank_screen)
self.settings.setValue(self.main_window.general_settings_section + '/screen blank', False)
self.settings.setValue('core/screen blank', False)
else:
self.hide_menu.setDefaultAction(self.show_screen)
self.settings.setValue(self.main_window.general_settings_section + '/screen blank', True)
self.settings.setValue('core/screen blank', True)
self.show_screen.setChecked(hide_mode is None)
self.blank_screen.setChecked(hide_mode == HideMode.Blank)
self.theme_screen.setChecked(hide_mode == HideMode.Theme)

View File

@ -135,11 +135,9 @@ class ThemesTab(SettingsTab):
"""
Load the theme settings into the tab
"""
self.settings.beginGroup(self.settings_section)
self.theme_level = self.settings.value('theme level')
self.global_theme = self.settings.value('global theme')
self.item_transitions_check_box.setChecked(self.settings.value('item transitions'))
self.settings.endGroup()
self.theme_level = self.settings.value('themes/theme level')
self.global_theme = self.settings.value('themes/global theme')
self.item_transitions_check_box.setChecked(self.settings.value('themes/item transitions'))
if self.theme_level == ThemeLevel.Global:
self.global_level_radio_button.setChecked(True)
elif self.theme_level == ThemeLevel.Service:
@ -151,11 +149,9 @@ class ThemesTab(SettingsTab):
"""
Save the settings
"""
self.settings.beginGroup(self.settings_section)
self.settings.setValue('theme level', self.theme_level)
self.settings.setValue('global theme', self.global_theme)
self.settings.setValue('item transitions', self.item_transitions_check_box.isChecked())
self.settings.endGroup()
self.settings.setValue('themes/theme level', self.theme_level)
self.settings.setValue('themes/global theme', self.global_theme)
self.settings.setValue('themes/item transitions', self.item_transitions_check_box.isChecked())
self.renderer.set_theme_level(self.theme_level)
if self.tab_visited:
self.settings_form.register_post_process('theme_update_global')

View File

@ -171,7 +171,7 @@ class AlertsPlugin(Plugin):
Switch the alerts state
"""
self.alerts_active = not self.alerts_active
self.settings.setValue(self.settings_section + '/active', self.alerts_active)
self.settings.setValue('alerts/active', self.alerts_active)
def on_alerts_trigger(self):
"""

View File

@ -26,7 +26,7 @@ from openlp.core.lib.ui import create_button, create_button_box
from openlp.core.ui.icons import UiIcons
class Ui_AlertDialog(object):
class AlertDialog(object):
"""
Alert UI Class
"""

View File

@ -25,10 +25,10 @@ from openlp.core.common.i18n import translate
from openlp.core.common.registry import Registry
from openlp.plugins.alerts.lib.db import AlertItem
from .alertdialog import Ui_AlertDialog
from openlp.plugins.alerts.forms.alertdialog import AlertDialog
class AlertForm(QtWidgets.QDialog, Ui_AlertDialog):
class AlertForm(QtWidgets.QDialog, AlertDialog):
"""
Provide UI for the alert system
"""

View File

@ -187,16 +187,14 @@ class AlertsTab(SettingsTab):
"""
Load the settings into the UI.
"""
self.settings.beginGroup(self.settings_section)
self.timeout = self.settings.value('timeout')
self.font_color = self.settings.value('font color')
self.font_size = self.settings.value('font size')
self.background_color = self.settings.value('background color')
self.font_face = self.settings.value('font face')
self.location = self.settings.value('location')
self.repeat = self.settings.value('repeat')
self.scroll = self.settings.value('scroll')
self.settings.endGroup()
self.timeout = self.settings.value('alerts/timeout')
self.font_color = self.settings.value('alerts/font color')
self.font_size = self.settings.value('alerts/font size')
self.background_color = self.settings.value('alerts/background color')
self.font_face = self.settings.value('alerts/font face')
self.location = self.settings.value('alerts/location')
self.repeat = self.settings.value('alerts/repeat')
self.scroll = self.settings.value('alerts/scroll')
self.font_size_spin_box.setValue(self.font_size)
self.timeout_spin_box.setValue(self.timeout)
self.font_color_button.color = self.font_color
@ -215,21 +213,19 @@ class AlertsTab(SettingsTab):
"""
Save the changes on exit of the Settings dialog.
"""
self.settings.beginGroup(self.settings_section)
# Check value has changed as no event handles this field
if self.settings.value('location') != self.vertical_combo_box.currentIndex():
if self.settings.value('alerts/location') != self.vertical_combo_box.currentIndex():
self.changed = True
self.settings.setValue('background color', self.background_color)
self.settings.setValue('font color', self.font_color)
self.settings.setValue('font size', self.font_size)
self.settings.setValue('alerts/background color', self.background_color)
self.settings.setValue('alerts/font color', self.font_color)
self.settings.setValue('alerts/font size', self.font_size)
self.font_face = self.font_combo_box.currentFont().family()
self.settings.setValue('font face', self.font_face)
self.settings.setValue('timeout', self.timeout)
self.settings.setValue('alerts/font face', self.font_face)
self.settings.setValue('alerts/timeout', self.timeout)
self.location = self.vertical_combo_box.currentIndex()
self.settings.setValue('location', self.location)
self.settings.setValue('repeat', self.repeat)
self.settings.setValue('scroll', self.scroll_check_box.isChecked())
self.settings.endGroup()
self.settings.setValue('alerts/location', self.location)
self.settings.setValue('alerts/repeat', self.repeat)
self.settings.setValue('alerts/scroll', self.scroll_check_box.isChecked())
if self.changed:
self.settings_form.register_post_process('update_display_css')
self.changed = False

View File

@ -662,7 +662,6 @@ class BibleImportForm(OpenLPWizard):
"""
Set default values for the wizard pages.
"""
self.settings.beginGroup(self.plugin.settings_section)
self.restart()
self.finish_button.setVisible(False)
self.cancel_button.setVisible(True)
@ -685,7 +684,6 @@ class BibleImportForm(OpenLPWizard):
self.setField('license_full_license', self.full_license_edit.toPlainText())
self.full_license_edit.setPlaceholderText(UiStrings().OptionalHideInFooter)
self.on_web_source_combo_box_index_changed(WebDownload.Crosswalk)
self.settings.endGroup()
def pre_wizard(self):
"""

View File

@ -114,10 +114,10 @@ class BibleManager(LogMixin, RegistryProperties):
"""
log.debug('Bible Initialising')
self.parent = parent
self.settings_section = 'bibles'
self.web = 'Web'
self.db_cache = None
self.path = AppLocation.get_section_data_path(self.settings_section)
self.path = AppLocation.get_section_data_path('bibles')
self.suffix = '.sqlite'
self.import_wizard = None
self.reload_bibles()
@ -129,7 +129,7 @@ class BibleManager(LogMixin, RegistryProperties):
of HTTPBible is loaded instead of the BibleDB class.
"""
log.debug('Reload bibles')
file_paths = AppLocation.get_files(self.settings_section, self.suffix)
file_paths = AppLocation.get_files('bibles', self.suffix)
if Path('alternative_book_names.sqlite') in file_paths:
file_paths.remove(Path('alternative_book_names.sqlite'))
log.debug('Bible Files {text}'.format(text=file_paths))
@ -296,7 +296,7 @@ class BibleManager(LogMixin, RegistryProperties):
if not language_selection or language_selection.value == "None" or language_selection.value == "-1":
# If None is returned, it's not the singleton object but a
# BibleMeta object with the value "None"
language_selection = Registry().get('settings').value(self.settings_section + '/book name language')
language_selection = Registry().get('settings').value('bibles/book name language')
else:
language_selection = language_selection.value
try:

View File

@ -149,7 +149,7 @@ class BibleMediaItem(MediaManagerItem):
self.search_tab.setSizePolicy(QtWidgets.QSizePolicy.Minimum, QtWidgets.QSizePolicy.Minimum)
self.search_tab_bar.addTab(translate('BiblesPlugin.MediaItem', 'Find'))
self.search_layout = QtWidgets.QFormLayout(self.search_tab)
self.search_edit = SearchEdit(self.search_tab, self.settings_section)
self.search_edit = SearchEdit(self.search_tab, 'bibles')
self.search_layout.addRow(translate('BiblesPlugin.MediaItem', 'Find:'), self.search_edit)
self.search_tab.setVisible(True)
self.page_layout.addWidget(self.search_tab)
@ -292,7 +292,7 @@ class BibleMediaItem(MediaManagerItem):
:return: None
"""
log.debug('config_update')
visible = self.settings.value('{settings_section}/second bibles'.format(settings_section=self.settings_section))
visible = self.settings.value('bibles/second bibles')
self.general_bible_layout.labelForField(self.second_combo_box).setVisible(visible)
self.second_combo_box.setVisible(visible)
@ -316,8 +316,7 @@ class BibleMediaItem(MediaManagerItem):
translate('BiblesPlugin.MediaItem', 'Text Search'),
translate('BiblesPlugin.MediaItem', 'Search Text...'))
])
if self.settings.value(
'{settings_section}/reset to combined quick search'.format(settings_section=self.settings_section)):
if self.settings.value('bibles/reset to combined quick search'):
self.search_edit.set_current_search_type(BibleSearch.Combined)
self.config_update()
log.debug('bible manager initialise complete')
@ -340,7 +339,7 @@ class BibleMediaItem(MediaManagerItem):
self.version_combo_box.addItem(bible[0], bible[1])
self.second_combo_box.addItem(bible[0], bible[1])
# set the default value
bible = self.settings.value('{settings_section}/primary bible'.format(settings_section=self.settings_section))
bible = self.settings.value('bibles/primary bible')
find_and_set_in_combo_box(self.version_combo_box, bible)
def reload_bibles(self):
@ -548,7 +547,7 @@ class BibleMediaItem(MediaManagerItem):
# TODO: Change layout_style to a property
self.settings_tab.layout_style = index
self.settings_tab.layout_style_combo_box.setCurrentIndex(index)
self.settings.setValue('{section}/verse layout style'.format(section=self.settings_section), index)
self.settings.setValue('bibles/verse layout style')
def on_version_combo_box_index_changed(self):
"""
@ -558,7 +557,7 @@ class BibleMediaItem(MediaManagerItem):
"""
self.bible = self.version_combo_box.currentData()
if self.bible is not None:
self.settings.setValue('{section}/primary bible'.format(section=self.settings_section), self.bible.name)
self.settings.setValue('bibles/primary bible', self.bible.name)
self.initialise_advanced_bible(self.select_book_combo_box.currentData())
def on_second_combo_box_index_changed(self, selection):

View File

@ -81,21 +81,17 @@ class CustomTab(SettingsTab):
Load the settings into the dialog
"""
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 = self.settings.value('custom/display footer')
self.update_load = self.settings.value('custom/add custom from service')
self.display_footer_check_box.setChecked(self.display_footer)
self.add_from_service_checkbox.setChecked(self.update_load)
self.settings.endGroup()
def save(self):
"""
Save the Dialog settings
"""
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()
self.settings.setValue('custom/display footer', self.display_footer)
self.settings.setValue('custom/add custom from service', self.update_load)
if self.tab_visited:
self.settings_form.register_post_process('custom_config_updated')
self.tab_visited = False

View File

@ -91,7 +91,7 @@ class CustomMediaItem(MediaManagerItem):
Config has been updated so reload values
"""
log.debug('Config loaded')
self.add_custom_from_service = self.settings.value(self.settings_section + '/add custom from service')
self.add_custom_from_service = self.settings.value('custom/add custom from service')
self.is_search_as_you_type_enabled = self.settings.value('advanced/search as type')
def retranslate_ui(self):
@ -237,7 +237,7 @@ class CustomMediaItem(MediaManagerItem):
service_item.title = title
for slide in raw_slides:
service_item.add_from_text(slide)
if self.settings.value(self.settings_section + '/display footer') or credit:
if self.settings.value('custom/display footer') or credit:
service_item.raw_footer.append(' '.join([title, credit]))
else:
service_item.raw_footer.append('')

View File

@ -66,15 +66,11 @@ class ImageTab(SettingsTab):
self.background_color = color
def load(self):
self.settings.beginGroup(self.settings_section)
self.background_color = self.settings.value('background color')
self.background_color = self.settings.value('images/background color')
self.initial_color = self.background_color
self.settings.endGroup()
self.background_color_button.color = self.background_color
def save(self):
self.settings.beginGroup(self.settings_section)
self.settings.setValue('background color', self.background_color)
self.settings.endGroup()
self.settings.setValue('images/background color', self.background_color)
if self.initial_color != self.background_color:
self.settings_form.register_post_process('images_config_updated')

View File

@ -407,7 +407,7 @@ class ImageMediaItem(MediaManagerItem):
self.application.set_normal_cursor()
self.load_list(file_paths, target_group)
last_dir = file_paths[0].parent
self.settings.setValue(self.settings_section + '/last directory', last_dir)
self.settings.setValue('images/last directory', last_dir)
def load_list(self, image_paths, target_group=None, initial_load=False):
"""
@ -553,7 +553,7 @@ class ImageMediaItem(MediaManagerItem):
:param context: Why is it being generated
:param kwargs: Consume other unused args specified by the base implementation, but not use by this one.
"""
background = QtGui.QColor(self.settings.value(self.settings_section + '/background color'))
background = QtGui.QColor(self.settings.value('images/background color'))
if item:
items = [item]
else:
@ -680,7 +680,7 @@ class ImageMediaItem(MediaManagerItem):
if check_item_selected(
self.list_view,
translate('ImagePlugin.MediaItem', 'You must select an image to replace the background with.')):
background = QtGui.QColor(self.settings.value(self.settings_section + '/background color'))
background = QtGui.QColor(self.settings.value('images/background color'))
bitem = self.list_view.selectedItems()[0]
if not isinstance(bitem.data(0, QtCore.Qt.UserRole), ImageFilenames):
# Only continue when an image is selected.

View File

@ -197,7 +197,7 @@ class MediaMediaItem(MediaManagerItem, RegistryProperties):
service_item.add_capability(ItemCapabilities.CanAutoStartForLive)
service_item.add_capability(ItemCapabilities.CanEditTitle)
service_item.add_capability(ItemCapabilities.RequiresMedia)
if self.settings.value(self.settings_section + '/media auto start') == QtCore.Qt.Checked:
if self.settings.value('media/media auto start') == QtCore.Qt.Checked:
service_item.will_auto_start = True
# force a non-existent theme
service_item.theme = -1
@ -210,9 +210,9 @@ class MediaMediaItem(MediaManagerItem, RegistryProperties):
Initialize media item.
"""
self.list_view.clear()
self.service_path = AppLocation.get_section_data_path(self.settings_section) / 'thumbnails'
self.service_path = AppLocation.get_section_data_path('media') / 'thumbnails'
create_paths(self.service_path)
self.load_list([path_to_str(file) for file in self.settings.value(self.settings_section + '/media files')])
self.load_list([path_to_str(file) for file in self.settings.value('media/media files')])
self.rebuild_players()
def rebuild_players(self):
@ -236,7 +236,7 @@ class MediaMediaItem(MediaManagerItem, RegistryProperties):
row_list.sort(reverse=True)
for row in row_list:
self.list_view.takeItem(row)
self.settings.setValue(self.settings_section + '/media files', self.get_file_list())
self.settings.setValue('media/media files', self.get_file_list())
def load_list(self, media, target_group=None):
"""
@ -296,7 +296,7 @@ class MediaMediaItem(MediaManagerItem, RegistryProperties):
:param media_type: Type to get, defaults to audio.
:return: The media list
"""
media_file_paths = self.settings.value(self.settings_section + '/media files')
media_file_paths = self.settings.value('media/media files')
media_file_paths.sort(key=lambda file_path: get_natural_key(os.path.split(str(file_path))[1]))
if media_type == MediaType.Audio:
extension = AUDIO_EXT
@ -316,7 +316,7 @@ class MediaMediaItem(MediaManagerItem, RegistryProperties):
"""
results = []
string = string.lower()
for file_path in self.settings.value(self.settings_section + '/media files'):
for file_path in self.settings.value('media/media files'):
file_name = file_path.name
if file_name.lower().find(string) > -1:
results.append([str(file_path), file_name])
@ -349,7 +349,7 @@ class MediaMediaItem(MediaManagerItem, RegistryProperties):
# Append the optical string to the media list
file_paths.append(optical)
self.load_list([str(optical)])
self.settings.setValue(self.settings_section + '/media files', file_paths)
self.settings.setValue('media/media files', file_paths)
def on_open_device_stream(self):
"""
@ -378,7 +378,7 @@ class MediaMediaItem(MediaManagerItem, RegistryProperties):
# Append the device stream string to the media list
file_paths.append(stream)
self.load_list([str(stream)])
self.settings.setValue(self.settings_section + '/media files', file_paths)
self.settings.setValue('media/media files', file_paths)
def on_open_network_stream(self):
"""
@ -407,4 +407,4 @@ class MediaMediaItem(MediaManagerItem, RegistryProperties):
# Append the device stream string to the media list
file_paths.append(stream)
self.load_list([str(stream)])
self.settings.setValue(self.settings_section + '/media files', file_paths)
self.settings.setValue('media/media files', file_paths)

View File

@ -104,10 +104,8 @@ below. Personal Access Tokens are created by doing the following:
"""
Load the settings into the UI.
"""
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 = self.settings.value('planningcenter/application_id')
self.secret = self.settings.value('planningcenter/secret')
self.application_id_line_edit.setText(self.application_id)
self.secret_line_edit.setText(self.secret)
@ -115,10 +113,8 @@ below. Personal Access Tokens are created by doing the following:
"""
Save the changes on exit of the Settings dialog.
"""
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()
self.settings.setValue('planningcenter/application_id', self.application_id_line_edit.text())
self.settings.setValue('planningcenter/secret', self.secret_line_edit.text())
def on_test_credentials_button_clicked(self):
"""

View File

@ -129,7 +129,7 @@ class PresentationMediaItem(MediaManagerItem):
Populate the media manager tab
"""
self.list_view.setIconSize(QtCore.QSize(88, 50))
file_paths = self.settings.value(self.settings_section + '/presentations files')
file_paths = self.settings.value('presentations/presentations files')
self.load_list(file_paths, initial_load=True)
self.populate_display_types()
@ -149,7 +149,7 @@ class PresentationMediaItem(MediaManagerItem):
if self.display_type_combo_box.count() > 1:
self.display_type_combo_box.insertItem(0, self.automatic, userData='automatic')
self.display_type_combo_box.setCurrentIndex(0)
if self.settings.value(self.settings_section + '/override app') == QtCore.Qt.Checked:
if self.settings.value('presentations/override app') == QtCore.Qt.Checked:
self.presentation_widget.show()
else:
self.presentation_widget.hide()
@ -237,7 +237,7 @@ class PresentationMediaItem(MediaManagerItem):
self.main_window.finished_progress_bar()
for row in row_list:
self.list_view.takeItem(row)
self.settings.setValue(self.settings_section + '/presentations files', self.get_file_list())
self.settings.setValue('presentations/presentations files', self.get_file_list())
self.application.set_normal_cursor()
def clean_up_thumbnails(self, file_path, clean_for_update=False):
@ -451,7 +451,7 @@ class PresentationMediaItem(MediaManagerItem):
:param show_error: not used
:return:
"""
file_paths = self.settings.value(self.settings_section + '/presentations files')
file_paths = self.settings.value('presentations/presentations files')
results = []
string = string.lower()
for file_path in file_paths:

View File

@ -460,10 +460,10 @@ class PresentationController(object):
self.name = name
self.display_name = display_name if display_name is not None else name
self.document_class = document_class
self.settings_section = self.plugin.settings_section
self.available = None
self.temp_folder = AppLocation.get_section_data_path(self.settings_section) / name
self.thumbnail_folder = AppLocation.get_section_data_path(self.settings_section) / 'thumbnails'
self.temp_folder = AppLocation.get_section_data_path('presentations') / name
self.thumbnail_folder = AppLocation.get_section_data_path('presentations') / 'thumbnails'
self.thumbnail_prefix = 'slide'
create_paths(self.thumbnail_folder, self.temp_folder)
@ -471,7 +471,7 @@ class PresentationController(object):
"""
Return whether the controller is currently enabled
"""
if Registry().get('settings').value(self.settings_section + '/' + self.name) == QtCore.Qt.Checked:
if Registry().get('settings').value('presentations/' + self.name) == QtCore.Qt.Checked:
return self.is_available()
else:
return False

View File

@ -138,21 +138,20 @@ class PresentationTab(SettingsTab):
for key in self.controllers:
controller = self.controllers[key]
checkbox = self.presenter_check_boxes[controller.name]
checkbox.setChecked(self.settings.value(self.settings_section + '/' + controller.name))
checkbox.setChecked(self.settings.value('presentations/' + controller.name))
if controller.name == 'Powerpoint' and controller.is_available():
powerpoint_available = True
self.override_app_check_box.setChecked(self.settings.value(self.settings_section + '/override app'))
self.override_app_check_box.setChecked(self.settings.value('presentations/override app'))
# Load PowerPoint settings
self.ppt_slide_click_check_box.setChecked(self.settings.value(self.settings_section +
'/powerpoint slide click advance'))
self.ppt_slide_click_check_box.setChecked(self.settings.value('presentations/powerpoint slide click advance'))
self.ppt_slide_click_check_box.setEnabled(powerpoint_available)
self.ppt_window_check_box.setChecked(self.settings.value(self.settings_section + '/powerpoint control window'))
self.ppt_window_check_box.setChecked(self.settings.value('presentations/powerpoint control window'))
self.ppt_window_check_box.setEnabled(powerpoint_available)
# load pdf-program settings
enable_pdf_program = self.settings.value(self.settings_section + '/enable_pdf_program')
enable_pdf_program = self.settings.value('presentations/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 = self.settings.value(self.settings_section + '/pdf_program')
self.program_path_edit.path = self.settings.value('presentations/pdf_program')
def save(self):
"""
@ -166,7 +165,7 @@ class PresentationTab(SettingsTab):
controller = self.controllers[key]
if controller.is_available():
checkbox = self.presenter_check_boxes[controller.name]
setting_key = self.settings_section + '/' + controller.name
setting_key = 'presentations/' + controller.name
if self.settings.value(setting_key) != checkbox.checkState():
changed = True
self.settings.setValue(setting_key, checkbox.checkState())
@ -174,16 +173,16 @@ class PresentationTab(SettingsTab):
controller.start_process()
else:
controller.kill()
setting_key = self.settings_section + '/override app'
setting_key = 'presentations/override app'
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'
setting_key = 'presentations/powerpoint slide click advance'
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'
setting_key = 'presentations/powerpoint control window'
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
@ -193,11 +192,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 != self.settings.value(self.settings_section + '/pdf_program'):
self.settings.setValue(self.settings_section + '/pdf_program', pdf_program_path)
if pdf_program_path != self.settings.value('presentations/pdf_program'):
self.settings.setValue('presentations/pdf_program', pdf_program_path)
changed = True
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)
if enable_pdf_program != self.settings.value('presentations/enable_pdf_program'):
self.settings.setValue('presentations/enable_pdf_program', enable_pdf_program)
changed = True
if changed:
self.settings_form.register_post_process('mediaitem_suffix_reset')

View File

@ -231,13 +231,13 @@ class SongImportForm(OpenLPWizard, RegistryProperties):
filters += '{text} (*)'.format(text=UiStrings().AllFiles)
file_paths, filter_used = FileDialog.getOpenFileNames(
self, title,
self.settings.value(self.plugin.settings_section + '/last directory import'), filters)
self.settings.value('presentations/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:
self.settings.setValue(self.plugin.settings_section + '/last directory import', file_paths[0].parent)
self.settings.setValue('song/last directory import', file_paths[0].parent)
def get_list_of_paths(self, list_box):
"""

View File

@ -117,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 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'))
if self.settings.contains('songs/songselect password'):
self.username_edit.setText(self.settings.value('songs/songselect username'))
self.password_edit.setText(self.settings.value('songs/songselect password'))
self.save_password_checkbox.setChecked(True)
if self.settings.contains(self.plugin.settings_section + '/songselect searches'):
if self.settings.contains('songs/songselect searches'):
self.search_combobox.addItems(
self.settings.value(self.plugin.settings_section + '/songselect searches').split('|'))
self.settings.value('songs/songselect searches').split('|'))
self.username_edit.setFocus()
return QtWidgets.QDialog.exec(self)
@ -280,11 +280,11 @@ class SongSelectForm(QtWidgets.QDialog, Ui_SongSelectDialog, RegistryProperties)
'in the public domain.')
)
if self.save_password_checkbox.isChecked():
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())
self.settings.setValue('songs/songselect username', self.username_edit.text())
self.settings.setValue('songs/songselect password', self.password_edit.text())
else:
self.settings.remove(self.plugin.settings_section + '/songselect username')
self.settings.remove(self.plugin.settings_section + '/songselect password')
self.settings.remove('songs/songselect username')
self.settings.remove('songs/songselect password')
self.stacked_widget.setCurrentIndex(1)
self.login_progress_bar.setVisible(False)
self.login_progress_bar.setValue(0)
@ -314,7 +314,7 @@ class SongSelectForm(QtWidgets.QDialog, Ui_SongSelectDialog, RegistryProperties)
self.application.process_events()
self.song_count = 0
search_history = self.search_combobox.getItems()
self.settings.setValue(self.plugin.settings_section + '/songselect searches', '|'.join(search_history))
self.settings.setValue('songs/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)

View File

@ -115,8 +115,8 @@ class SongMediaItem(MediaManagerItem):
"""
log.debug('config_updated')
self.is_search_as_you_type_enabled = self.settings.value('advanced/search as type')
self.update_service_on_edit = self.settings.value(self.settings_section + '/update service on edit')
self.add_song_from_service = self.settings.value(self.settings_section + '/add song from service')
self.update_service_on_edit = self.settings.value('songs/update service on edit')
self.add_song_from_service = self.settings.value('songs/add song from service')
def retranslate_ui(self):
self.search_text_label.setText('{text}:'.format(text=UiStrings().Search))

View File

@ -201,17 +201,16 @@ class SongsTab(SettingsTab):
self.chord_notation = 'neo-latin'
def on_footer_reset_button_clicked(self):
self.footer_edit_box.setPlainText(self.settings.get_default_value(self.settings_section + '/footer template'))
self.footer_edit_box.setPlainText(self.settings.get_default_value('songs/footer template'))
def load(self):
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.disable_chords_import = self.settings.value('disable chords import')
self.tool_bar = self.settings.value('songs/display songbar')
self.update_edit = self.settings.value('songs/update service on edit')
self.update_load = self.settings.value('songs/add song from service')
self.songbook_slide = self.settings.value('songs/add songbook slide')
self.enable_chords = self.settings.value('songs/enable chords')
self.chord_notation = self.settings.value('songs/chord notation')
self.disable_chords_import = self.settings.value('songs/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)
@ -223,22 +222,19 @@ class SongsTab(SettingsTab):
self.neolatin_notation_radio_button.setChecked(True)
else:
self.english_notation_radio_button.setChecked(True)
self.footer_edit_box.setPlainText(self.settings.value('footer template'))
self.settings.endGroup()
self.footer_edit_box.setPlainText(self.settings.value('songs/footer template'))
def save(self):
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('disable chords import', self.disable_chords_import)
self.settings.setValue('chord notation', self.chord_notation)
self.settings.setValue('songs/display songbar', self.tool_bar)
self.settings.setValue('songs/update service on edit', self.update_edit)
self.settings.setValue('songs/add song from service', self.update_load)
self.settings.setValue('songs/enable chords', self.chords_group_box.isChecked())
self.settings.setValue('songs/disable chords import', self.disable_chords_import)
self.settings.setValue('songs/chord notation', self.chord_notation)
# Only save footer template if it has been changed. This allows future updates
if self.footer_edit_box.toPlainText() != self.settings.get_default_value('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.footer_edit_box.toPlainText() != self.settings.get_default_value('songs/footer template'):
self.settings.setValue('songs/footer template', self.footer_edit_box.toPlainText())
self.settings.setValue('songs/add songbook slide', self.songbook_slide)
if self.tab_visited:
self.settings_form.register_post_process('songs_config_updated')
self.tab_visited = False

View File

@ -54,15 +54,15 @@ class SongUsageDetailForm(QtWidgets.QDialog, Ui_SongUsageDetailDialog, RegistryP
"""
We need to set up the screen
"""
to_date = self.settings.value(self.plugin.settings_section + '/to date')
to_date = self.settings.value('songusage/to date')
if not (isinstance(to_date, QtCore.QDate) and to_date.isValid()):
to_date = QtCore.QDate.currentDate()
from_date = self.settings.value(self.plugin.settings_section + '/from date')
from_date = self.settings.value('songusage/from date')
if not (isinstance(from_date, QtCore.QDate) and from_date.isValid()):
from_date = to_date.addYears(-1)
self.from_date_calendar.setSelectedDate(from_date)
self.to_date_calendar.setSelectedDate(to_date)
self.report_path_edit.path = self.settings.value(self.plugin.settings_section + '/last directory export')
self.report_path_edit.path = self.settings.value('songusage/last directory export')
def on_report_path_edit_path_changed(self, file_path):
"""
@ -71,7 +71,7 @@ class SongUsageDetailForm(QtWidgets.QDialog, Ui_SongUsageDetailDialog, RegistryP
:param pathlib.Path file_path: The new path.
:rtype: None
"""
self.settings.setValue(self.plugin.settings_section + '/last directory export', file_path)
self.settings.setValue('songusage/last directory export', file_path)
def accept(self):
"""
@ -91,8 +91,8 @@ class SongUsageDetailForm(QtWidgets.QDialog, Ui_SongUsageDetailDialog, RegistryP
'usage_detail_{old}_{new}.txt'
).format(old=self.from_date_calendar.selectedDate().toString('ddMMyyyy'),
new=self.to_date_calendar.selectedDate().toString('ddMMyyyy'))
self.settings.setValue(self.plugin.settings_section + '/from date', self.from_date_calendar.selectedDate())
self.settings.setValue(self.plugin.settings_section + '/to date', self.to_date_calendar.selectedDate())
self.settings.setValue('songusage/from date', self.from_date_calendar.selectedDate())
self.settings.setValue('songusage/to date', self.to_date_calendar.selectedDate())
usage = self.plugin.manager.get_all_objects(
SongUsageItem, and_(SongUsageItem.usagedate >= self.from_date_calendar.selectedDate().toPyDate(),
SongUsageItem.usagedate < self.to_date_calendar.selectedDate().toPyDate()),

View File

@ -115,7 +115,7 @@ class SongUsagePlugin(Plugin):
super(SongUsagePlugin, self).initialise()
Registry().register_function('slidecontroller_live_started', self.display_song_usage)
Registry().register_function('print_service_started', self.print_song_usage)
self.song_usage_active = self.settings.value(self.settings_section + '/active')
self.song_usage_active = self.settings.value('songusage/active')
# Set the button and checkbox state
self.set_button_state()
action_list = ActionList.get_instance()
@ -149,7 +149,7 @@ class SongUsagePlugin(Plugin):
the UI when necessary,
"""
self.song_usage_active = not self.song_usage_active
self.settings.setValue(self.settings_section + '/active', self.song_usage_active)
self.settings.setValue('songusage/active', self.song_usage_active)
self.set_button_state()
def set_button_state(self):

View File

@ -122,8 +122,7 @@ def test_settings_override_with_group():
# WHEN reading a setting for the first time
settings = Settings()
settings.beginGroup('test')
extend = settings.value('extend')
extend = settings.value('test/extend')
# THEN the default value is returned
assert 'very wide' == extend, 'The default value defined should be returned'

View File

@ -635,7 +635,6 @@ def test_save_file_raises_permission_error(mocked_os, mocked_save_file_as, mocke
"""
# GIVEN: A service manager, a service to save
mocked_main_window = MagicMock()
mocked_main_window.service_manager_settings_section = 'servicemanager'
Registry().register('main_window', mocked_main_window)
Registry().register('application', MagicMock())
service_manager = ServiceManager(None)

View File

@ -411,7 +411,7 @@ def test_update_slide_limits(mock_settings):
"""
# GIVEN: A mocked out Settings object, a new SlideController and a mocked out main_window
mock_settings.value.return_value = 10
mocked_main_window = MagicMock(advanced_settings_section='advanced')
mocked_main_window = MagicMock()
Registry().register('main_window', mocked_main_window)
slide_controller = SlideController(None)

View File

@ -21,9 +21,21 @@
"""
This module contains tests for the plugin class Alerts plugin.
"""
import pytest
from unittest.mock import MagicMock, patch
from openlp.plugins.alerts.alertsplugin import AlertsPlugin
@pytest.fixture
@patch('openlp.plugins.alerts.alertsplugin.Manager')
def plugin_env(MockedManager, settings, state, registry):
"""An instance of the AlertsPlugin"""
mocked_manager = MagicMock()
MockedManager.return_value = mocked_manager
return AlertsPlugin(), settings
def test_plugin_about():
result = AlertsPlugin.about()
@ -31,3 +43,11 @@ def test_plugin_about():
'<strong>Alerts Plugin</strong>'
'<br />The alert plugin controls the displaying of alerts on the display screen.'
)
def test_plugin_state(plugin_env):
plugin = plugin_env[0]
settings = plugin_env[1]
plugin.alerts_active = settings.value('alerts/status')
plugin.toggle_alerts_state()
assert settings.value('alerts/status') != plugin.alerts_active

View File

@ -40,7 +40,6 @@ def media_item(mock_settings):
patch('openlp.plugins.bibles.lib.mediaitem.BibleMediaItem.setup_item'):
m_item = BibleMediaItem(None, MagicMock())
media_item.plugin = MagicMock()
m_item.settings_section = 'bibles'
m_item.results_view_tab = MagicMock()
return m_item

View File

@ -40,7 +40,6 @@ def media_item(settings):
with patch('openlp.plugins.media.lib.mediaitem.MediaManagerItem._setup'), \
patch('openlp.plugins.media.lib.mediaitem.MediaMediaItem.setup_item'):
m_item = MediaMediaItem(None, mocked_plugin)
m_item.settings_section = 'media'
return m_item
@ -49,7 +48,7 @@ def test_search_found(media_item):
Media Remote Search Successful find
"""
# GIVEN: The Mediaitem set up a list of media
media_item.settings.setValue(media_item.settings_section + '/media files', [Path('test.mp3'), Path('test.mp4')])
media_item.settings.setValue('media/media files', [Path('test.mp3'), Path('test.mp4')])
# WHEN: Retrieving the test file
result = media_item.search('test.mp4', False)
# THEN: a file should be found
@ -61,7 +60,7 @@ def test_search_not_found(media_item):
Media Remote Search not find
"""
# GIVEN: The Mediaitem set up a list of media
media_item.settings.setValue(media_item.settings_section + '/media files', [Path('test.mp3'), Path('test.mp4')])
media_item.settings.setValue('media/media files', [Path('test.mp3'), Path('test.mp4')])
# WHEN: Retrieving the test file
result = media_item.search('test.mpx', False)
# THEN: a file should be found

View File

@ -59,7 +59,6 @@ class TestMacLOController(TestCase, TestMixin):
Registry().register('settings', Settings())
self.mock_plugin = MagicMock()
self.temp_folder = mkdtemp()
self.mock_plugin.settings_section = self.temp_folder
def tearDown(self):
"""

View File

@ -142,7 +142,6 @@ def test_search(mock_setup, mock_item, registry):
mocked_returned_settings.value.return_value = [path_1, path_2, path_3]
Registry().register('settings', mocked_returned_settings)
media_item = PresentationMediaItem(None, MagicMock(), None)
media_item.settings_section = ''
# WHEN: Calling search
results = media_item.search('IMPRE', False)

View File

@ -31,7 +31,6 @@ from unittest.mock import MagicMock, patch
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.display.screens import ScreenList
from openlp.plugins.presentations.lib.pdfcontroller import PdfController, PdfDocument
from tests.utils.constants import RESOURCE_PATH
@ -127,10 +126,11 @@ def load_pdf_pictures(exe_path, pdf_env):
test_file_path = RESOURCE_PATH / 'presentations' / 'pdf_test1.pdf'
# WHEN: The Pdf is loaded
settings = pdf_env[0]
mock_plugin = pdf_env[1]
temp_folder_path = pdf_env[2]
thumbnail_folder_path = pdf_env[3]
Settings().setValue('presentations/pdf_program', exe_path)
settings.setValue('presentations/pdf_program', exe_path)
controller = PdfController(plugin=mock_plugin)
controller.temp_folder = temp_folder_path
controller.thumbnail_folder = thumbnail_folder_path

View File

@ -90,5 +90,5 @@ def test_toggle_song_usage_state(MockedManager, settings, state):
# WHEN: calling toggle_song_usage_state
song_usage.toggle_song_usage_state()
# THEN: song_usage_state should have been toogled
# THEN: song_usage_state should have been toggled
assert song_usage.song_usage_active is False

View File

@ -56,7 +56,7 @@ class TestServiceManager(TestCase, TestMixin):
Registry.create()
self.setup_application()
Registry().register('application', MagicMock())
Registry().register('main_window', MagicMock(service_manager_settings_section='servicemanager'))
Registry().register('main_window', MagicMock())
Registry().register('settings', Settings())
self.service_manager = ServiceManager()
self.add_toolbar_action_patcher = patch('openlp.core.ui.servicemanager.OpenLPToolbar.add_toolbar_action')

View File

@ -64,7 +64,7 @@ class TestSelectPlanForm(TestCase, TestMixin):
self.build_settings()
State().load_settings()
Registry().register('settings', Settings())
Registry().register('main_window', MagicMock(service_manager_settings_section='servicemanager'))
Registry().register('main_window', MagicMock())
self.application_id = 'abc'
self.secret = '123'
Settings().setValue('planningcenter/application_id', self.application_id)
@ -358,7 +358,6 @@ class TestSelectPlanForm(TestCase, TestMixin):
songs_plugin = SongsPlugin()
song_media_item = SongMediaItem(None, songs_plugin)
song_media_item.search_text_edit = MagicMock()
song_media_item.settings_section = 'songs'
song_media_item.initialise()
# init custom plugin
custom_plugin = CustomPlugin()

View File

@ -123,9 +123,7 @@ class TestPlanningCenterTab(TestCase, TestMixin):
self.tab.save()
# THEN: The settings version of application_id and secret should reflect the new values
settings = Settings()
settings.beginGroup(self.tab.settings_section)
application_id = settings.value('application_id')
secret = settings.value('secret')
application_id = settings.value('planningcenter/application_id')
secret = settings.value('planningcenter/secret')
self.assertEqual(application_id, new_application_id)
self.assertEqual(secret, new_secret)
settings.endGroup()