本文整理汇总了Python中openlp.core.lib.Settings.extend_default_settings方法的典型用法代码示例。如果您正苦于以下问题:Python Settings.extend_default_settings方法的具体用法?Python Settings.extend_default_settings怎么用?Python Settings.extend_default_settings使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类openlp.core.lib.Settings
的用法示例。
在下文中一共展示了Settings.extend_default_settings方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: load_screen_settings
# 需要导入模块: from openlp.core.lib import Settings [as 别名]
# 或者: from openlp.core.lib.Settings import extend_default_settings [as 别名]
def load_screen_settings(self):
"""
Loads the screen size and the monitor number from the settings.
"""
from openlp.core.lib import Settings
# Add the screen settings to the settings dict. This has to be done here due to crycle dependency.
# Do not do this anywhere else.
screen_settings = {
u'general/x position': self.current[u'size'].x(),
u'general/y position': self.current[u'size'].y(),
u'general/monitor': self.display_count - 1,
u'general/height': self.current[u'size'].height(),
u'general/width': self.current[u'size'].width()
}
Settings.extend_default_settings(screen_settings)
settings = Settings()
settings.beginGroup(u'general')
monitor = settings.value(u'monitor')
self.set_current_display(monitor)
self.display = settings.value(u'display on monitor')
override_display = settings.value(u'override position')
x = settings.value(u'x position')
y = settings.value(u'y position')
width = settings.value(u'width')
height = settings.value(u'height')
self.override[u'size'] = QtCore.QRect(x, y, width, height)
self.override[u'primary'] = False
settings.endGroup()
if override_display:
self.set_override_display()
else:
self.reset_current_display()
示例2: test_add_action_different_parent
# 需要导入模块: from openlp.core.lib import Settings [as 别名]
# 或者: from openlp.core.lib.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.'
示例3: test_add_action_different_context
# 需要导入模块: from openlp.core.lib import Settings [as 别名]
# 或者: from openlp.core.lib.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.'
示例4: __init__
# 需要导入模块: from openlp.core.lib import Settings [as 别名]
# 或者: from openlp.core.lib.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 descendent plugins to populate common data. This method *must*
be overridden, like so::
class MyPlugin(Plugin):
def __init__(self):
Plugin.__init__(self, u'MyPlugin', version=u'0.1')
``name``
Defaults to *None*. The name of the plugin.
``default_settings``
A dict containing the plugin's settings. The value to each key is the default value to be used.
``media_item_class``
The class name of the plugin's media item.
``settings_tab_class``
The class name of the plugin's settings tab.
``version``
Defaults to *None*, which means that the same version number is used as OpenLP's version number.
"""
log.debug(u'Plugin %s initialised' % name)
QtCore.QObject.__init__(self)
self.name = name
self.textStrings = {}
self.setPluginTextStrings()
self.nameStrings = self.textStrings[StringContent.Name]
if version:
self.version = version
else:
self.version = get_application_version()[u'version']
self.settingsSection = self.name
self.icon = None
self.mediaItemClass = media_item_class
self.settingsTabClass = settings_tab_class
self.settingsTab = None
self.mediaItem = None
self.weight = 0
self.status = PluginStatus.Inactive
# Add the default status to the default settings.
default_settings[name + u'/status'] = PluginStatus.Inactive
default_settings[name + u'/last directory'] = u''
# 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[u'%s/%s files' % (name, name)] = []
# Add settings to the dict of all settings.
Settings.extend_default_settings(default_settings)
QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'%s_add_service_item' % self.name),
self.processAddServiceEvent)
QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'%s_config_updated' % self.name),
self.configUpdated)
示例5: settings_override_with_group_test
# 需要导入模块: from openlp.core.lib import Settings [as 别名]
# 或者: from openlp.core.lib.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
assert extend == 'very wide', '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
assert Settings().value('test/extend') == 'very short', 'The saved value should be returned'