当前位置: 首页>>代码示例>>Python>>正文


Python Settings.extend_default_settings方法代码示例

本文整理汇总了Python中openlp.core.common.Settings.extend_default_settings方法的典型用法代码示例。如果您正苦于以下问题:Python Settings.extend_default_settings方法的具体用法?Python Settings.extend_default_settings怎么用?Python Settings.extend_default_settings使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在openlp.core.common.Settings的用法示例。


在下文中一共展示了Settings.extend_default_settings方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: load_screen_settings

# 需要导入模块: from openlp.core.common import Settings [as 别名]
# 或者: from openlp.core.common.Settings import extend_default_settings [as 别名]
 def load_screen_settings(self):
     """
     Loads the screen size and the monitor number from the settings.
     """
     # Add the screen settings to the settings dict. This has to be done here due to cyclic dependency.
     # Do not do this anywhere else.
     screen_settings = {
         'core/x position': self.current['size'].x(),
         'core/y position': self.current['size'].y(),
         'core/monitor': self.display_count - 1,
         'core/height': self.current['size'].height(),
         'core/width': self.current['size'].width()
     }
     Settings.extend_default_settings(screen_settings)
     settings = Settings()
     settings.beginGroup('core')
     monitor = settings.value('monitor')
     self.set_current_display(monitor)
     self.display = settings.value('display on monitor')
     override_display = settings.value('override position')
     x = settings.value('x position')
     y = settings.value('y position')
     width = settings.value('width')
     height = settings.value('height')
     self.override['size'] = QtCore.QRect(x, y, width, height)
     self.override['primary'] = False
     settings.endGroup()
     if override_display:
         self.set_override_display()
     else:
         self.reset_current_display()
开发者ID:crossroadchurch,项目名称:paul,代码行数:33,代码来源:screen.py

示例2: test_add_action_different_context

# 需要导入模块: from openlp.core.common import Settings [as 别名]
# 或者: from openlp.core.common.Settings import extend_default_settings [as 别名]
    def test_add_action_different_context(self):
        """
        ActionList test - Tests the add_action method. The actions have the different parent, the same shortcuts and
        both have the QtCore.Qt.WidgetShortcut shortcut context set.
        """
        # GIVEN: Two actions with the same shortcuts.
        parent = QtCore.QObject()
        action3 = QtGui.QAction(parent)
        action3.setObjectName('action3')
        action3.setShortcutContext(QtCore.Qt.WidgetShortcut)
        second_parent = QtCore.QObject()
        action_with_same_shortcuts3 = QtGui.QAction(second_parent)
        action_with_same_shortcuts3.setObjectName('action_with_same_shortcuts3')
        action_with_same_shortcuts3.setShortcutContext(QtCore.Qt.WidgetShortcut)
        # Add default shortcuts to Settings class.
        default_shortcuts = {
            'shortcuts/action3': [QtGui.QKeySequence('e'), QtGui.QKeySequence('f')],
            'shortcuts/action_with_same_shortcuts3': [QtGui.QKeySequence('e'), QtGui.QKeySequence('f')]
        }
        Settings.extend_default_settings(default_shortcuts)

        # WHEN: Add the two actions to the action list.
        self.action_list.add_action(action3, 'example_category2')
        self.action_list.add_action(action_with_same_shortcuts3, 'example_category2')
        # Remove the actions again.
        self.action_list.remove_action(action3, 'example_category2')
        self.action_list.remove_action(action_with_same_shortcuts3, 'example_category2')

        # THEN: Both action should keep their shortcuts.
        assert len(action3.shortcuts()) == 2, 'The action should have two shortcut assigned.'
        assert len(action_with_same_shortcuts3.shortcuts()) == 2, 'The action should have two shortcuts assigned.'
开发者ID:crossroadchurch,项目名称:paul,代码行数:33,代码来源:test_actions.py

示例3: test_add_action_different_parent

# 需要导入模块: from openlp.core.common import Settings [as 别名]
# 或者: from openlp.core.common.Settings import extend_default_settings [as 别名]
    def test_add_action_different_parent(self):
        """
        ActionList test - Tests the add_action method. The actions have the different parent, the same shortcuts and
        both have the QtCore.Qt.WindowShortcut shortcut context set.
        """
        # GIVEN: Two actions with the same shortcuts.
        parent = QtCore.QObject()
        action2 = QtGui.QAction(parent)
        action2.setObjectName('action2')
        second_parent = QtCore.QObject()
        action_with_same_shortcuts2 = QtGui.QAction(second_parent)
        action_with_same_shortcuts2.setObjectName('action_with_same_shortcuts2')
        # Add default shortcuts to Settings class.
        default_shortcuts = {
            'shortcuts/action2': [QtGui.QKeySequence('c'), QtGui.QKeySequence('d')],
            'shortcuts/action_with_same_shortcuts2': [QtGui.QKeySequence('d'), QtGui.QKeySequence('c')]
        }
        Settings.extend_default_settings(default_shortcuts)

        # WHEN: Add the two actions to the action list.
        self.action_list.add_action(action2, 'example_category')
        self.action_list.add_action(action_with_same_shortcuts2, 'example_category')
        # Remove the actions again.
        self.action_list.remove_action(action2, 'example_category')
        self.action_list.remove_action(action_with_same_shortcuts2, 'example_category')

        # THEN: As both actions have the same shortcuts, they should be removed from one action.
        assert len(action2.shortcuts()) == 2, 'The action should have two shortcut assigned.'
        assert len(action_with_same_shortcuts2.shortcuts()) == 0, 'The action should not have a shortcut assigned.'
开发者ID:crossroadchurch,项目名称:paul,代码行数:31,代码来源:test_actions.py

示例4: extend_default_settings_test

# 需要导入模块: from openlp.core.common import Settings [as 别名]
# 或者: from openlp.core.common.Settings import extend_default_settings [as 别名]
    def extend_default_settings_test(self):
        """
        Test that the extend_default_settings method extends the default settings
        """
        # GIVEN: A patched __default_settings__ dictionary
        with patch.dict(Settings.__default_settings__,
                        {'test/setting 1': 1, 'test/setting 2': 2, 'test/setting 3': 3}, True):

            # WHEN: Calling extend_default_settings
            Settings.extend_default_settings({'test/setting 3': 4, 'test/extended 1': 1, 'test/extended 2': 2})

            # THEN: The _default_settings__ dictionary_ should have the new keys
            self.assertEqual(
                Settings.__default_settings__, {'test/setting 1': 1, 'test/setting 2': 2, 'test/setting 3': 4,
                                                'test/extended 1': 1, 'test/extended 2': 2})
开发者ID:crossroadchurch,项目名称:paul,代码行数:17,代码来源:test_settings.py

示例5: __init__

# 需要导入模块: from openlp.core.common import Settings [as 别名]
# 或者: from openlp.core.common.Settings import extend_default_settings [as 别名]
    def __init__(self, name, default_settings, media_item_class=None, settings_tab_class=None, version=None):
        """
        This is the constructor for the plugin object. This provides an easy way for descendant plugins to populate
         common data. This method *must*

        be overridden, like so::

            class MyPlugin(Plugin):
                def __init__(self):
                    super(MyPlugin, self).__init__('MyPlugin', version='0.1')

        :param name: Defaults to *None*. The name of the plugin.
        :param default_settings: A dict containing the plugin's settings. The value to each key is the default value
        to be used.
        :param media_item_class: The class name of the plugin's media item.
        :param settings_tab_class: The class name of the plugin's settings tab.
        :param version: Defaults to *None*, which means that the same version number is used as OpenLP's version number.
        """
        log.debug('Plugin %s initialised' % name)
        super(Plugin, self).__init__()
        self.name = name
        self.text_strings = {}
        self.set_plugin_text_strings()
        self.name_strings = self.text_strings[StringContent.Name]
        if version:
            self.version = version
        else:
            self.version = get_application_version()['version']
        self.settings_section = self.name
        self.icon = None
        self.media_item_class = media_item_class
        self.settings_tab_class = settings_tab_class
        self.settings_tab = None
        self.media_item = None
        self.weight = 0
        self.status = PluginStatus.Inactive
        # Add the default status to the default settings.
        default_settings[name + '/status'] = PluginStatus.Inactive
        default_settings[name + '/last directory'] = ''
        # Append a setting for files in the mediamanager (note not all plugins
        # which have a mediamanager need this).
        if media_item_class is not None:
            default_settings['%s/%s files' % (name, name)] = []
        # Add settings to the dict of all settings.
        Settings.extend_default_settings(default_settings)
        Registry().register_function('%s_add_service_item' % self.name, self.process_add_service_event)
        Registry().register_function('%s_config_updated' % self.name, self.config_update)
开发者ID:crossroadchurch,项目名称:paul,代码行数:49,代码来源:plugin.py

示例6: settings_override_with_group_test

# 需要导入模块: from openlp.core.common import Settings [as 别名]
# 或者: from openlp.core.common.Settings import extend_default_settings [as 别名]
    def settings_override_with_group_test(self):
        """
        Test the Settings creation and its override usage - with groups
        """
        # GIVEN: an override for the settings
        screen_settings = {
            'test/extend': 'very wide',
        }
        Settings.extend_default_settings(screen_settings)

        # WHEN reading a setting for the first time
        settings = Settings()
        settings.beginGroup('test')
        extend = settings.value('extend')

        # THEN the default value is returned
        self.assertEqual('very wide', extend, 'The default value defined should be returned')

        # WHEN a new value is saved into config
        Settings().setValue('test/extend', 'very short')

        # THEN the new value is returned when re-read
        self.assertEqual('very short', Settings().value('test/extend'), 'The saved value should be returned')
开发者ID:crossroadchurch,项目名称:paul,代码行数:25,代码来源:test_settings.py


注:本文中的openlp.core.common.Settings.extend_default_settings方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。