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


Python common.Settings类代码示例

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


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

示例1: test_add_action_different_parent

    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,代码行数:29,代码来源:test_actions.py

示例2: build_settings

 def build_settings(self):
     """
     Build the settings Object and initialise it
     """
     Settings.setDefaultFormat(Settings.IniFormat)
     self.fd, self.ini_file = mkstemp('.ini')
     Settings().set_filename(self.ini_file)
开发者ID:crossroadchurch,项目名称:paul,代码行数:7,代码来源:testmixin.py

示例3: test_add_action_different_context

    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,代码行数:31,代码来源:test_actions.py

示例4: __init__

 def __init__(self):
     """
     Constructor
     """
     super(PrintServiceForm, self).__init__(Registry().get('main_window'))
     self.printer = QtGui.QPrinter()
     self.print_dialog = QtGui.QPrintDialog(self.printer, self)
     self.document = QtGui.QTextDocument()
     self.zoom = 0
     self.setupUi(self)
     # Load the settings for the dialog.
     settings = Settings()
     settings.beginGroup('advanced')
     self.slide_text_check_box.setChecked(settings.value('print slide text'))
     self.page_break_after_text.setChecked(settings.value('add page break'))
     if not self.slide_text_check_box.isChecked():
         self.page_break_after_text.setDisabled(True)
     self.meta_data_check_box.setChecked(settings.value('print file meta data'))
     self.notes_check_box.setChecked(settings.value('print notes'))
     self.zoom_combo_box.setCurrentIndex(settings.value('display size'))
     settings.endGroup()
     # Signals
     self.print_button.triggered.connect(self.print_service_order)
     self.zoom_out_button.clicked.connect(self.zoom_out)
     self.zoom_in_button.clicked.connect(self.zoom_in)
     self.zoom_original_button.clicked.connect(self.zoom_original)
     self.preview_widget.paintRequested.connect(self.paint_requested)
     self.zoom_combo_box.currentIndexChanged.connect(self.display_size_changed)
     self.plain_copy.triggered.connect(self.copy_text)
     self.html_copy.triggered.connect(self.copy_html_text)
     self.slide_text_check_box.stateChanged.connect(self.on_slide_text_check_box_changed)
     self.update_preview_text()
开发者ID:crossroadchurch,项目名称:paul,代码行数:32,代码来源:printserviceform.py

示例5: build_settings

 def build_settings(self):
     """
     Build the settings Object and initialise it
     """
     self.fd, self.ini_file = mkstemp('.ini')
     Settings.set_filename(self.ini_file)
     Settings().setDefaultFormat(Settings.IniFormat)
     # Needed on windows to make sure a Settings object is available during the tests
     self.setting = Settings()
     Settings().setValue('themes/global theme', 'my_theme')
开发者ID:imkernel,项目名称:openlp,代码行数:10,代码来源:testmixin.py

示例6: setUp

 def setUp(self):
     """
     Some pre-test setup required.
     """
     Settings.setDefaultFormat(Settings.IniFormat)
     self.build_settings()
     self.temp_dir = mkdtemp('openlp')
     Settings().setValue('advanced/data path', self.temp_dir)
     Registry.create()
     Registry().register('service_list', MagicMock())
     self.setup_application()
     self.main_window = QtGui.QMainWindow()
     Registry().register('main_window', self.main_window)
开发者ID:crossroadchurch,项目名称:paul,代码行数:13,代码来源:test_pluginmanager.py

示例7: update_reference_separators

def update_reference_separators():
    """
    Updates separators and matches for parsing and formating scripture references.
    """
    default_separators = [
        '|'.join([
            translate('BiblesPlugin', ':', 'Verse identifier e.g. Genesis 1 : 1 = Genesis Chapter 1 Verse 1'),
            translate('BiblesPlugin', 'v', 'Verse identifier e.g. Genesis 1 v 1 = Genesis Chapter 1 Verse 1'),
            translate('BiblesPlugin', 'V', 'Verse identifier e.g. Genesis 1 V 1 = Genesis Chapter 1 Verse 1'),
            translate('BiblesPlugin', 'verse', 'Verse identifier e.g. Genesis 1 verse 1 = Genesis Chapter 1 Verse 1'),
            translate('BiblesPlugin', 'verses',
                      'Verse identifier e.g. Genesis 1 verses 1 - 2 = Genesis Chapter 1 Verses 1 to 2')]),
        '|'.join([
            translate('BiblesPlugin', '-',
                      'range identifier e.g. Genesis 1 verse 1 - 2 = Genesis Chapter 1 Verses 1 To 2'),
            translate('BiblesPlugin', 'to',
                      'range identifier e.g. Genesis 1 verse 1 - 2 = Genesis Chapter 1 Verses 1 To 2')]),
        '|'.join([
            translate('BiblesPlugin', ',', 'connecting identifier e.g. Genesis 1 verse 1 - 2, 4 - 5 = '
                                           'Genesis Chapter 1 Verses 1 To 2 And Verses 4 To 5'),
            translate('BiblesPlugin', 'and', 'connecting identifier e.g. Genesis 1 verse 1 - 2 and 4 - 5 = '
                                             'Genesis Chapter 1 Verses 1 To 2 And Verses 4 To 5')]),
        '|'.join([translate('BiblesPlugin', 'end', 'ending identifier e.g. Genesis 1 verse 1 - end = '
                                                   'Genesis Chapter 1 Verses 1 To The Last Verse')])]
    settings = Settings()
    settings.beginGroup('bibles')
    custom_separators = [
        settings.value('verse separator'),
        settings.value('range separator'),
        settings.value('list separator'),
        settings.value('end separator')]
    settings.endGroup()
    for index, role in enumerate(['v', 'r', 'l', 'e']):
        if custom_separators[index].strip('|') == '':
            source_string = default_separators[index].strip('|')
        else:
            source_string = custom_separators[index].strip('|')
        while '||' in source_string:
            source_string = source_string.replace('||', '|')
        if role != 'e':
            REFERENCE_SEPARATORS['sep_%s_display' % role] = source_string.split('|')[0]
        # escape reserved characters
        for character in '\\.^$*+?{}[]()':
            source_string = source_string.replace(character, '\\' + character)
        # add various unicode alternatives
        source_string = source_string.replace('-', '(?:[-\u00AD\u2010\u2011\u2012\u2014\u2014\u2212\uFE63\uFF0D])')
        source_string = source_string.replace(',', '(?:[,\u201A])')
        REFERENCE_SEPARATORS['sep_%s' % role] = '\s*(?:%s)\s*' % source_string
        REFERENCE_SEPARATORS['sep_%s_default' % role] = default_separators[index]
    # verse range match: (<chapter>:)?<verse>(-((<chapter>:)?<verse>|end)?)?
    range_regex = '(?:(?P<from_chapter>[0-9]+)%(sep_v)s)?' \
        '(?P<from_verse>[0-9]+)(?P<range_to>%(sep_r)s(?:(?:(?P<to_chapter>' \
        '[0-9]+)%(sep_v)s)?(?P<to_verse>[0-9]+)|%(sep_e)s)?)?' % REFERENCE_SEPARATORS
    REFERENCE_MATCHES['range'] = re.compile('^\s*%s\s*$' % range_regex, re.UNICODE)
    REFERENCE_MATCHES['range_separator'] = re.compile(REFERENCE_SEPARATORS['sep_l'], re.UNICODE)
    # full reference match: <book>(<range>(,(?!$)|(?=$)))+
    REFERENCE_MATCHES['full'] = \
        re.compile('^\s*(?!\s)(?P<book>[\d]*[^\d]+)(?<!\s)\s*'
                   '(?P<ranges>(?:%(range_regex)s(?:%(sep_l)s(?!\s*$)|(?=\s*$)))+)\s*$'
                   % dict(list(REFERENCE_SEPARATORS.items()) + [('range_regex', range_regex)]), re.UNICODE)
开发者ID:crossroadchurch,项目名称:paul,代码行数:60,代码来源:__init__.py

示例8: load

 def load(self):
     """
     Load the projector settings on startup
     """
     settings = Settings()
     settings.beginGroup(self.settings_section)
     self.connect_on_startup.setChecked(settings.value('connect on start'))
     self.socket_timeout_spin_box.setValue(settings.value('socket timeout'))
     self.socket_poll_spin_box.setValue(settings.value('poll time'))
     self.dialog_type_combo_box.setCurrentIndex(settings.value('source dialog type'))
     settings.endGroup()
开发者ID:imkernel,项目名称:openlp,代码行数:11,代码来源:tab.py

示例9: extend_default_settings_test

    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,代码行数:15,代码来源:test_settings.py

示例10: get_settings

 def get_settings(self):
     """
     Retrieve the saved settings
     """
     settings = Settings()
     settings.beginGroup(self.settings_section)
     self.autostart = settings.value('connect on start')
     self.poll_time = settings.value('poll time')
     self.socket_timeout = settings.value('socket timeout')
     self.source_select_dialog_type = settings.value('source dialog type')
     settings.endGroup()
     del settings
开发者ID:crossroadchurch,项目名称:paul,代码行数:12,代码来源:manager.py

示例11: save

 def save(self):
     """
     Save the Dialog settings
     """
     settings = Settings()
     settings.beginGroup(self.settings_section)
     settings.setValue('display footer', self.display_footer)
     settings.setValue('add custom from service', self.update_load)
     settings.endGroup()
     if self.tab_visited:
         self.settings_form.register_post_process('custom_config_updated')
     self.tab_visited = False
开发者ID:crossroadchurch,项目名称:paul,代码行数:12,代码来源:customtab.py

示例12: get_list

    def get_list(self, type=MediaType.Audio):
        """
        Get the list of media, optional select media type.

        :param type: Type to get, defaults to audio.
        :return: The media list
        """
        media = Settings().value(self.settings_section + '/media files')
        media.sort(key=lambda filename: get_locale_key(os.path.split(str(filename))[1]))
        if type == MediaType.Audio:
            extension = self.media_controller.audio_extensions_list
        else:
            extension = self.media_controller.video_extensions_list
        extension = [x[1:] for x in extension]
        media = [x for x in media if os.path.splitext(x)[1] in extension]
        return media
开发者ID:crossroadchurch,项目名称:paul,代码行数:16,代码来源:mediaitem.py

示例13: __init__

    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,代码行数:47,代码来源:plugin.py

示例14: setUp

 def setUp(self):
     """
     Prepare the tests
     """
     self.action_list = ActionList.get_instance()
     self.build_settings()
     self.settings = Settings()
     self.settings.beginGroup('shortcuts')
开发者ID:crossroadchurch,项目名称:paul,代码行数:8,代码来源:test_actions.py

示例15: get_media_players

def get_media_players():
    """
    This method extracts the configured media players and overridden player
    from the settings.
    """
    log.debug('get_media_players')
    saved_players = Settings().value('media/players')
    reg_ex = QtCore.QRegExp(".*\[(.*)\].*")
    if Settings().value('media/override player') == QtCore.Qt.Checked:
        if reg_ex.exactMatch(saved_players):
            overridden_player = '{text}'.format(text=reg_ex.cap(1))
        else:
            overridden_player = 'auto'
    else:
        overridden_player = ''
    saved_players_list = saved_players.replace('[', '').replace(']', '').split(',') if saved_players else []
    return saved_players_list, overridden_player
开发者ID:imkernel,项目名称:openlp,代码行数:17,代码来源:__init__.py


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