Beispiel #1
0
 def set_defaults(self):
     """
     Set default values for the wizard pages.
     """
     settings = Settings()
     settings.beginGroup(self.plugin.settings_section)
     self.restart()
     self.finish_button.setVisible(False)
     self.cancel_button.setVisible(True)
     self.setField('source_format', 0)
     self.setField('osis_location', '')
     self.setField('csv_booksfile', '')
     self.setField('csv_versefile', '')
     self.setField('opensong_file', '')
     self.setField('zefania_file', '')
     self.setField('web_location', WebDownload.Crosswalk)
     self.setField('web_biblename',
                   self.web_translation_combo_box.currentIndex())
     self.setField('proxy_server', settings.value('proxy address'))
     self.setField('proxy_username', settings.value('proxy username'))
     self.setField('proxy_password', settings.value('proxy password'))
     self.setField('license_version', self.version_name_edit.text())
     self.setField('license_copyright', self.copyright_edit.text())
     self.setField('license_permissions', self.permissions_edit.text())
     self.on_web_source_combo_box_index_changed(WebDownload.Crosswalk)
     settings.endGroup()
 def set_defaults(self):
     """
     Set default values for the wizard pages.
     """
     settings = Settings()
     settings.beginGroup(self.plugin.settings_section)
     self.restart()
     self.finish_button.setVisible(False)
     self.cancel_button.setVisible(True)
     self.setField("source_format", 0)
     self.setField("osis_location", "")
     self.setField("csv_booksfile", "")
     self.setField("csv_versefile", "")
     self.setField("opensong_file", "")
     self.setField("zefania_file", "")
     self.setField("web_location", WebDownload.Crosswalk)
     self.setField("web_biblename", self.web_translation_combo_box.currentIndex())
     self.setField("proxy_server", settings.value("proxy address"))
     self.setField("proxy_username", settings.value("proxy username"))
     self.setField("proxy_password", settings.value("proxy password"))
     self.setField("license_version", self.version_name_edit.text())
     self.setField("license_copyright", self.copyright_edit.text())
     self.setField("license_permissions", self.permissions_edit.text())
     self.on_web_source_combo_box_index_changed(WebDownload.Crosswalk)
     settings.endGroup()
 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()
Beispiel #4
0
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)
Beispiel #5
0
 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()
Beispiel #6
0
 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()
Beispiel #7
0
 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
Beispiel #8
0
    def load(self):
        """

        Load the settings into the dialog
        """
        settings = Settings()
        settings.beginGroup(self.settings_section)
        self.display_footer = settings.value('display footer')
        self.update_load = settings.value('add custom from service')
        self.display_footer_check_box.setChecked(self.display_footer)
        self.add_from_service_checkbox.setChecked(self.update_load)
        settings.endGroup()
Beispiel #9
0
 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
Beispiel #10
0
    def load(self):
        """

        Load the settings into the dialog
        """
        settings = Settings()
        settings.beginGroup(self.settings_section)
        self.display_footer = settings.value('display footer')
        self.update_load = settings.value('add custom from service')
        self.display_footer_check_box.setChecked(self.display_footer)
        self.add_from_service_checkbox.setChecked(self.update_load)
        settings.endGroup()
Beispiel #11
0
 def load(self):
     settings = Settings()
     settings.beginGroup(self.settings_section)
     self.tool_bar = settings.value('display songbar')
     self.update_edit = settings.value('update service on edit')
     self.update_load = settings.value('add song from service')
     self.display_songbook = settings.value('display songbook')
     self.display_copyright_symbol = settings.value('display copyright symbol')
     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)
     self.display_songbook_check_box.setChecked(self.display_songbook)
     self.display_copyright_check_box.setChecked(self.display_copyright_symbol)
     settings.endGroup()
Beispiel #12
0
 def load(self):
     settings = Settings()
     settings.beginGroup(self.settings_section)
     self.background_color = settings.value('background color')
     self.initial_color = self.background_color
     settings.endGroup()
     self.background_color_button.color = self.background_color
Beispiel #13
0
 def save(self):
     """
     Save settings to disk.
     """
     settings = Settings()
     settings.beginGroup(self.settings_section)
     settings.setValue('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:
         settings.remove('default service name')
         self.service_name_edit.setText(service_name)
     else:
         settings.setValue('default service name', service_name)
     settings.setValue('default service day', self.service_name_day.currentIndex())
     settings.setValue('default service hour', self.service_name_time.time().hour())
     settings.setValue('default service minute', self.service_name_time.time().minute())
     settings.setValue('recent file count', self.recent_spin_box.value())
     settings.setValue('save current plugin', self.media_plugin_check_box.isChecked())
     settings.setValue('double click live', self.double_click_live_check_box.isChecked())
     settings.setValue('single click preview', self.single_click_preview_check_box.isChecked())
     settings.setValue('expand service item', self.expand_service_item_check_box.isChecked())
     settings.setValue('enable exit confirmation', self.enable_auto_close_check_box.isChecked())
     settings.setValue('hide mouse', self.hide_mouse_check_box.isChecked())
     settings.setValue('alternate rows', self.alternate_rows_check_box.isChecked())
     settings.setValue('default color', self.default_color)
     settings.setValue('default image', self.default_file_edit.text())
     settings.setValue('slide limits', self.slide_limits)
     if self.x11_bypass_check_box.isChecked() != settings.value('x11 bypass wm'):
         settings.setValue('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')
     settings.setValue('search as type', self.is_search_as_you_type_enabled)
     settings.endGroup()
Beispiel #14
0
 def load(self):
     settings = Settings()
     settings.beginGroup(self.settings_section)
     self.background_color = settings.value('background color')
     self.initial_color = self.background_color
     settings.endGroup()
     self.background_color_button.color = self.background_color
Beispiel #15
0
 def save(self):
     settings = Settings()
     settings.beginGroup(self.settings_section)
     settings.setValue('is verse number visible', self.is_verse_number_visible)
     settings.setValue('display new chapter', self.show_new_chapters)
     settings.setValue('display brackets', self.display_style)
     settings.setValue('verse layout style', self.layout_style)
     settings.setValue('second bibles', self.second_bibles)
     settings.setValue('bible theme', self.bible_theme)
     if self.verse_separator_check_box.isChecked():
         settings.setValue('verse separator', self.verse_separator_line_edit.text())
     else:
         settings.remove('verse separator')
     if self.range_separator_check_box.isChecked():
         settings.setValue('range separator', self.range_separator_line_edit.text())
     else:
         settings.remove('range separator')
     if self.list_separator_check_box.isChecked():
         settings.setValue('list separator', self.list_separator_line_edit.text())
     else:
         settings.remove('list separator')
     if self.end_separator_check_box.isChecked():
         settings.setValue('end separator', self.end_separator_line_edit.text())
     else:
         settings.remove('end separator')
     update_reference_separators()
     if self.language_selection != settings.value('book name language'):
         settings.setValue('book name language', self.language_selection)
         self.settings_form.register_post_process('bibles_load_list')
     settings.endGroup()
     if self.tab_visited:
         self.settings_form.register_post_process('bibles_config_updated')
     self.tab_visited = False
Beispiel #16
0
 def save(self):
     """
     Save settings to disk.
     """
     settings = Settings()
     settings.beginGroup(self.settings_section)
     settings.setValue('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:
         settings.remove('default service name')
         self.service_name_edit.setText(service_name)
     else:
         settings.setValue('default service name', service_name)
     settings.setValue('default service day', self.service_name_day.currentIndex())
     settings.setValue('default service hour', self.service_name_time.time().hour())
     settings.setValue('default service minute', self.service_name_time.time().minute())
     settings.setValue('recent file count', self.recent_spin_box.value())
     settings.setValue('save current plugin', self.media_plugin_check_box.isChecked())
     settings.setValue('double click live', self.double_click_live_check_box.isChecked())
     settings.setValue('single click preview', self.single_click_preview_check_box.isChecked())
     settings.setValue('expand service item', self.expand_service_item_check_box.isChecked())
     settings.setValue('enable exit confirmation', self.enable_auto_close_check_box.isChecked())
     settings.setValue('hide mouse', self.hide_mouse_check_box.isChecked())
     settings.setValue('alternate rows', self.alternate_rows_check_box.isChecked())
     settings.setValue('default color', self.default_color)
     settings.setValue('default image', self.default_file_edit.text())
     settings.setValue('slide limits', self.slide_limits)
     if self.x11_bypass_check_box.isChecked() != settings.value('x11 bypass wm'):
         settings.setValue('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')
     settings.endGroup()
Beispiel #17
0
 def save(self):
     settings = Settings()
     settings.beginGroup(self.settings_section)
     settings.setValue('is verse number visible', self.is_verse_number_visible)
     settings.setValue('display new chapter', self.show_new_chapters)
     settings.setValue('display brackets', self.display_style)
     settings.setValue('verse layout style', self.layout_style)
     settings.setValue('second bibles', self.second_bibles)
     settings.setValue('bible theme', self.bible_theme)
     if self.verse_separator_check_box.isChecked():
         settings.setValue('verse separator', self.verse_separator_line_edit.text())
     else:
         settings.remove('verse separator')
     if self.range_separator_check_box.isChecked():
         settings.setValue('range separator', self.range_separator_line_edit.text())
     else:
         settings.remove('range separator')
     if self.list_separator_check_box.isChecked():
         settings.setValue('list separator', self.list_separator_line_edit.text())
     else:
         settings.remove('list separator')
     if self.end_separator_check_box.isChecked():
         settings.setValue('end separator', self.end_separator_line_edit.text())
     else:
         settings.remove('end separator')
     update_reference_separators()
     if self.language_selection != settings.value('book name language'):
         settings.setValue('book name language', self.language_selection)
         self.settings_form.register_post_process('bibles_load_list')
     settings.endGroup()
     if self.tab_visited:
         self.settings_form.register_post_process('bibles_config_updated')
     self.tab_visited = False
Beispiel #18
0
 def load(self):
     """
     Load the theme settings into the tab
     """
     settings = Settings()
     settings.beginGroup(self.settings_section)
     self.theme_level = settings.value('theme level')
     self.global_theme = settings.value('global theme')
     self.wrap_footer_check_box.setChecked(settings.value('wrap footer'))
     settings.endGroup()
     if self.theme_level == ThemeLevel.Global:
         self.global_level_radio_button.setChecked(True)
     elif self.theme_level == ThemeLevel.Service:
         self.service_level_radio_button.setChecked(True)
     else:
         self.song_level_radio_button.setChecked(True)
Beispiel #19
0
 def load(self):
     """
     Load the theme settings into the tab
     """
     settings = Settings()
     settings.beginGroup(self.settings_section)
     self.theme_level = settings.value('theme level')
     self.global_theme = settings.value('global theme')
     self.wrap_footer_check_box.setChecked(settings.value('wrap footer'))
     settings.endGroup()
     if self.theme_level == ThemeLevel.Global:
         self.global_level_radio_button.setChecked(True)
     elif self.theme_level == ThemeLevel.Service:
         self.service_level_radio_button.setChecked(True)
     else:
         self.song_level_radio_button.setChecked(True)
Beispiel #20
0
    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')
Beispiel #21
0
    def add_action(self, action, category=None, weight=None):
        """
        Add an action to the list of actions.

        **Note**: The action's objectName must be set when you want to add it!

        :param action: The action to add (QAction). **Note**, the action must not have an empty ``objectName``.
        :param category: The category this action belongs to. The category has to be a python string. . **Note**,
            if the category is ``None``, the category and its actions are being hidden in the shortcut dialog. However,
            if they are added, it is possible to avoid assigning shortcuts twice, which is important.
        :param weight: The weight specifies how important a category is. However, this only has an impact on the order
            the categories are displayed.
        """
        if category not in self.categories:
            self.categories.append(category)
        settings = Settings()
        settings.beginGroup('shortcuts')
        # Get the default shortcut from the config.
        action.default_shortcuts = settings.get_default_value(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()
        if not shortcuts:
            action.setShortcuts([])
            return
        # We have to do this to ensure that the loaded shortcut list e. g. STRG+O (German) is converted to CTRL+O,
        # which is only done when we convert the strings in this way (QKeySequencet -> uncode).
        shortcuts = list(map(QtGui.QKeySequence.toString, list(map(QtGui.QKeySequence, shortcuts))))
        # Check the alternate shortcut first, to avoid problems when the alternate shortcut becomes the primary shortcut
        #  after removing the (initial) primary shortcut due to conflicts.
        if len(shortcuts) == 2:
            existing_actions = ActionList.shortcut_map.get(shortcuts[1], [])
            # Check for conflicts with other actions considering the shortcut context.
            if self._is_shortcut_available(existing_actions, action):
                actions = ActionList.shortcut_map.get(shortcuts[1], [])
                actions.append(action)
                ActionList.shortcut_map[shortcuts[1]] = actions
            else:
                log.warning('Shortcut "{shortcut}" is removed from "{action}" because another '
                            'action already uses this shortcut.'.format(shortcut=shortcuts[1],
                                                                        action=action.objectName()))
                shortcuts.remove(shortcuts[1])
        # Check the primary shortcut.
        existing_actions = ActionList.shortcut_map.get(shortcuts[0], [])
        # Check for conflicts with other actions considering the shortcut context.
        if self._is_shortcut_available(existing_actions, action):
            actions = ActionList.shortcut_map.get(shortcuts[0], [])
            actions.append(action)
            ActionList.shortcut_map[shortcuts[0]] = actions
        else:
            log.warning('Shortcut "{shortcut}" is removed from "{action}" '
                        'because another action already uses this shortcut.'.format(shortcut=shortcuts[0],
                                                                                    action=action.objectName()))
            shortcuts.remove(shortcuts[0])
        action.setShortcuts([QtGui.QKeySequence(shortcut) for shortcut in shortcuts])
Beispiel #22
0
def check_latest_version(current_version):
    """
    Check the latest version of OpenLP against the version file on the OpenLP
    site.

    **Rules around versions and version files:**

    * If a version number has a build (i.e. -bzr1234), then it is a nightly.
    * If a version number's minor version is an odd number, it is a development release.
    * If a version number's minor version is an even number, it is a stable release.

    :param current_version: The current version of OpenLP.
    """
    version_string = current_version['full']
    # set to prod in the distribution config file.
    settings = Settings()
    settings.beginGroup('core')
    last_test = settings.value('last version test')
    this_test = str(datetime.now().date())
    settings.setValue('last version test', this_test)
    settings.endGroup()
    if last_test != this_test:
        if current_version['build']:
            req = urllib.request.Request(
                'http://www.openlp.org/files/nightly_version.txt')
        else:
            version_parts = current_version['version'].split('.')
            if int(version_parts[1]) % 2 != 0:
                req = urllib.request.Request(
                    'http://www.openlp.org/files/dev_version.txt')
            else:
                req = urllib.request.Request(
                    'http://www.openlp.org/files/version.txt')
        req.add_header(
            'User-Agent', 'OpenLP/{version} {system}/{release}; '.format(
                version=current_version['full'],
                system=platform.system(),
                release=platform.release()))
        remote_version = None
        retries = 0
        while True:
            try:
                remote_version = str(
                    urllib.request.urlopen(
                        req, None,
                        timeout=CONNECTION_TIMEOUT).read().decode()).strip()
            except (urllib.error.URLError, ConnectionError):
                if retries > CONNECTION_RETRIES:
                    log.exception(
                        'Failed to download the latest OpenLP version file')
                else:
                    retries += 1
                    time.sleep(0.1)
                    continue
            break
        if remote_version:
            version_string = remote_version
    return version_string
Beispiel #23
0
def init_url(plugin_name, db_file_name=None):
    """
    Return the database URL.

    :param plugin_name: The name of the plugin for the database creation.
    :param db_file_name: The database file name. Defaults to None resulting in the plugin_name being used.
    """
    settings = Settings()
    settings.beginGroup(plugin_name)
    db_type = settings.value('db type')
    if db_type == 'sqlite':
        db_url = get_db_path(plugin_name, db_file_name)
    else:
        db_url = '%s://%s:%s@%s/%s' % (db_type, urlquote(settings.value('db username')),
                                       urlquote(settings.value('db password')),
                                       urlquote(settings.value('db hostname')),
                                       urlquote(settings.value('db database')))
    settings.endGroup()
    return db_url
Beispiel #24
0
def init_url(plugin_name, db_file_name=None):
    """
    Return the database URL.

    :param plugin_name: The name of the plugin for the database creation.
    :param db_file_name: The database file name. Defaults to None resulting in the plugin_name being used.
    """
    settings = Settings()
    settings.beginGroup(plugin_name)
    db_type = settings.value('db type')
    if db_type == 'sqlite':
        db_url = get_db_path(plugin_name, db_file_name)
    else:
        db_url = '{type}://{user}:{password}@{host}/{db}'.format(type=db_type,
                                                                 user=urlquote(settings.value('db username')),
                                                                 password=urlquote(settings.value('db password')),
                                                                 host=urlquote(settings.value('db hostname')),
                                                                 db=urlquote(settings.value('db database')))
    settings.endGroup()
    return db_url
Beispiel #25
0
Datei: db.py Projekt: jkunle/paul
def init_url(plugin_name, db_file_name=None):
    """
    Return the database URL.

    :param plugin_name: The name of the plugin for the database creation.
    :param db_file_name: The database file name. Defaults to None resulting in the plugin_name being used.
    """
    settings = Settings()
    settings.beginGroup(plugin_name)
    db_type = settings.value('db type')
    if db_type == 'sqlite':
        db_url = get_db_path(plugin_name, db_file_name)
    else:
        db_url = '%s://%s:%s@%s/%s' % (db_type,
                                       urlquote(settings.value('db username')),
                                       urlquote(settings.value('db password')),
                                       urlquote(settings.value('db hostname')),
                                       urlquote(settings.value('db database')))
    settings.endGroup()
    return db_url
Beispiel #26
0
def init_url(plugin_name, db_file_name=None):
    """
    Return the database URL.

    :param plugin_name: The name of the plugin for the database creation.
    :param db_file_name: The database file name. Defaults to None resulting in the plugin_name being used.
    """
    settings = Settings()
    settings.beginGroup(plugin_name)
    db_type = settings.value('db type')
    if db_type == 'sqlite':
        db_url = get_db_path(plugin_name, db_file_name)
    else:
        db_url = '{type}://{user}:{password}@{host}/{db}'.format(
            type=db_type,
            user=urlquote(settings.value('db username')),
            password=urlquote(settings.value('db password')),
            host=urlquote(settings.value('db hostname')),
            db=urlquote(settings.value('db database')))
    settings.endGroup()
    return db_url
Beispiel #27
0
 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()
Beispiel #28
0
 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()
Beispiel #29
0
def check_latest_version(current_version):
    """
    Check the latest version of OpenLP against the version file on the OpenLP
    site.

    **Rules around versions and version files:**

    * If a version number has a build (i.e. -bzr1234), then it is a nightly.
    * If a version number's minor version is an odd number, it is a development release.
    * If a version number's minor version is an even number, it is a stable release.

    :param current_version: The current version of OpenLP.
    """
    version_string = current_version["full"]
    # set to prod in the distribution config file.
    settings = Settings()
    settings.beginGroup("core")
    last_test = settings.value("last version test")
    this_test = str(datetime.now().date())
    settings.setValue("last version test", this_test)
    settings.endGroup()
    if last_test != this_test:
        if current_version["build"]:
            req = urllib.request.Request("http://www.openlp.org/files/nightly_version.txt")
        else:
            version_parts = current_version["version"].split(".")
            if int(version_parts[1]) % 2 != 0:
                req = urllib.request.Request("http://www.openlp.org/files/dev_version.txt")
            else:
                req = urllib.request.Request("http://www.openlp.org/files/version.txt")
        req.add_header(
            "User-Agent", "OpenLP/%s %s/%s; " % (current_version["full"], platform.system(), platform.release())
        )
        remote_version = None
        retries = 0
        while True:
            try:
                remote_version = str(
                    urllib.request.urlopen(req, None, timeout=CONNECTION_TIMEOUT).read().decode()
                ).strip()
            except (urllib.error.URLError, ConnectionError):
                if retries > CONNECTION_RETRIES:
                    log.exception("Failed to download the latest OpenLP version file")
                else:
                    retries += 1
                    time.sleep(0.1)
                    continue
            break
        if remote_version:
            version_string = remote_version
    return version_string
Beispiel #30
0
 def __init__(self):
     """
     Constructor
     """
     super(PrintServiceForm, self).__init__(
         Registry().get('main_window'),
         QtCore.Qt.WindowSystemMenuHint | QtCore.Qt.WindowTitleHint)
     self.printer = QtPrintSupport.QPrinter()
     self.print_dialog = QtPrintSupport.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()
Beispiel #31
0
 def load(self):
     """
     Load the settings
     """
     if self.saved_used_players:
         self.used_players = self.saved_used_players
     self.used_players = get_media_players()[0]
     self.saved_used_players = self.used_players
     settings = Settings()
     settings.beginGroup(self.settings_section)
     self.update_player_list()
     self.background_color = settings.value('background color')
     self.initial_color = self.background_color
     settings.endGroup()
     self.background_color_button.color = self.background_color
Beispiel #32
0
 def load(self):
     """
     Load the settings
     """
     if self.saved_used_players:
         self.used_players = self.saved_used_players
     self.used_players = get_media_players()[0]
     self.saved_used_players = self.used_players
     settings = Settings()
     settings.beginGroup(self.settings_section)
     self.update_player_list()
     self.background_color = settings.value('background color')
     self.initial_color = self.background_color
     settings.endGroup()
     self.background_color_button.color = self.background_color
Beispiel #33
0
 def save(self):
     """
     Save the changes on exit of the Settings dialog.
     """
     settings = Settings()
     settings.beginGroup(self.settings_section)
     # Check value has changed as no event handles this field
     if settings.value('location') != self.vertical_combo_box.currentIndex():
         self.changed = True
     settings.setValue('background color', self.background_color)
     settings.setValue('font color', self.font_color)
     settings.setValue('font size', self.font_size)
     self.font_face = self.font_combo_box.currentFont().family()
     settings.setValue('font face', self.font_face)
     settings.setValue('timeout', self.timeout)
     self.location = self.vertical_combo_box.currentIndex()
     settings.setValue('location', self.location)
     settings.endGroup()
     if self.changed:
         self.settings_form.register_post_process('update_display_css')
     self.changed = False
Beispiel #34
0
 def save(self):
     """
     Save the changes on exit of the Settings dialog.
     """
     settings = Settings()
     settings.beginGroup(self.settings_section)
     # Check value has changed as no event handles this field
     if settings.value("location") != self.vertical_combo_box.currentIndex():
         self.changed = True
     settings.setValue("background color", self.background_color)
     settings.setValue("font color", self.font_color)
     settings.setValue("font size", self.font_size)
     self.font_face = self.font_combo_box.currentFont().family()
     settings.setValue("font face", self.font_face)
     settings.setValue("timeout", self.timeout)
     self.location = self.vertical_combo_box.currentIndex()
     settings.setValue("location", self.location)
     settings.endGroup()
     if self.changed:
         self.settings_form.register_post_process("update_display_css")
     self.changed = False
Beispiel #35
0
 def load(self):
     settings = Settings()
     settings.beginGroup(self.settings_section)
     self.tool_bar = settings.value('display songbar')
     self.update_edit = settings.value('update service on edit')
     self.update_load = settings.value('add song from service')
     self.display_songbook = settings.value('display songbook')
     self.display_written_by = settings.value('display written by')
     self.display_copyright_symbol = settings.value('display copyright symbol')
     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)
     self.display_songbook_check_box.setChecked(self.display_songbook)
     self.display_written_by_check_box.setChecked(self.display_written_by)
     self.display_copyright_check_box.setChecked(self.display_copyright_symbol)
     settings.endGroup()
Beispiel #36
0
    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')
Beispiel #37
0
 def load(self):
     """
     Load the settings into the UI.
     """
     settings = Settings()
     settings.beginGroup(self.settings_section)
     self.timeout = settings.value('timeout')
     self.font_color = settings.value('font color')
     self.font_size = settings.value('font size')
     self.background_color = settings.value('background color')
     self.font_face = settings.value('font face')
     self.location = settings.value('location')
     settings.endGroup()
     self.font_size_spin_box.setValue(self.font_size)
     self.timeout_spin_box.setValue(self.timeout)
     self.font_color_button.color = self.font_color
     self.background_color_button.color = self.background_color
     self.vertical_combo_box.setCurrentIndex(self.location)
     font = QtGui.QFont()
     font.setFamily(self.font_face)
     self.font_combo_box.setCurrentFont(font)
     self.update_display()
     self.changed = False
Beispiel #38
0
 def load(self):
     """
     Load the settings into the UI.
     """
     settings = Settings()
     settings.beginGroup(self.settings_section)
     self.timeout = settings.value("timeout")
     self.font_color = settings.value("font color")
     self.font_size = settings.value("font size")
     self.background_color = settings.value("background color")
     self.font_face = settings.value("font face")
     self.location = settings.value("location")
     settings.endGroup()
     self.font_size_spin_box.setValue(self.font_size)
     self.timeout_spin_box.setValue(self.timeout)
     self.font_color_button.color = self.font_color
     self.background_color_button.color = self.background_color
     self.vertical_combo_box.setCurrentIndex(self.location)
     font = QtGui.QFont()
     font.setFamily(self.font_face)
     self.font_combo_box.setCurrentFont(font)
     self.update_display()
     self.changed = False
Beispiel #39
0
 def load(self):
     settings = Settings()
     settings.beginGroup(self.settings_section)
     self.is_verse_number_visible = settings.value('is verse number visible')
     self.show_new_chapters = settings.value('display new chapter')
     self.display_style = settings.value('display brackets')
     self.layout_style = settings.value('verse layout style')
     self.bible_theme = settings.value('bible theme')
     self.second_bibles = settings.value('second bibles')
     self.is_verse_number_visible_check_box.setChecked(self.is_verse_number_visible)
     self.check_is_verse_number_visible()
     self.new_chapters_check_box.setChecked(self.show_new_chapters)
     self.display_style_combo_box.setCurrentIndex(self.display_style)
     self.layout_style_combo_box.setCurrentIndex(self.layout_style)
     self.bible_second_check_box.setChecked(self.second_bibles)
     verse_separator = settings.value('verse separator')
     if (verse_separator.strip('|') == '') or (verse_separator == get_reference_separator('sep_v_default')):
         self.verse_separator_line_edit.setText(get_reference_separator('sep_v_default'))
         self.verse_separator_line_edit.setPalette(self.get_grey_text_palette(True))
         self.verse_separator_check_box.setChecked(False)
     else:
         self.verse_separator_line_edit.setText(verse_separator)
         self.verse_separator_line_edit.setPalette(self.get_grey_text_palette(False))
         self.verse_separator_check_box.setChecked(True)
     range_separator = settings.value('range separator')
     if (range_separator.strip('|') == '') or (range_separator == get_reference_separator('sep_r_default')):
         self.range_separator_line_edit.setText(get_reference_separator('sep_r_default'))
         self.range_separator_line_edit.setPalette(self.get_grey_text_palette(True))
         self.range_separator_check_box.setChecked(False)
     else:
         self.range_separator_line_edit.setText(range_separator)
         self.range_separator_line_edit.setPalette(self.get_grey_text_palette(False))
         self.range_separator_check_box.setChecked(True)
     list_separator = settings.value('list separator')
     if (list_separator.strip('|') == '') or (list_separator == get_reference_separator('sep_l_default')):
         self.list_separator_line_edit.setText(get_reference_separator('sep_l_default'))
         self.list_separator_line_edit.setPalette(self.get_grey_text_palette(True))
         self.list_separator_check_box.setChecked(False)
     else:
         self.list_separator_line_edit.setText(list_separator)
         self.list_separator_line_edit.setPalette(self.get_grey_text_palette(False))
         self.list_separator_check_box.setChecked(True)
     end_separator = settings.value('end separator')
     if (end_separator.strip('|') == '') or (end_separator == get_reference_separator('sep_e_default')):
         self.end_separator_line_edit.setText(get_reference_separator('sep_e_default'))
         self.end_separator_line_edit.setPalette(self.get_grey_text_palette(True))
         self.end_separator_check_box.setChecked(False)
     else:
         self.end_separator_line_edit.setText(end_separator)
         self.end_separator_line_edit.setPalette(self.get_grey_text_palette(False))
         self.end_separator_check_box.setChecked(True)
     self.language_selection = settings.value('book name language')
     self.language_selection_combo_box.setCurrentIndex(self.language_selection)
     self.reset_to_combined_quick_search = settings.value('reset to combined quick search')
     self.reset_to_combined_quick_search_check_box.setChecked(self.reset_to_combined_quick_search)
     self.hide_combined_quick_error = settings.value('hide combined quick error')
     self.hide_combined_quick_error_check_box.setChecked(self.hide_combined_quick_error)
     self.bible_search_while_typing = settings.value('is search while typing enabled')
     self.bible_search_while_typing_check_box.setChecked(self.bible_search_while_typing)
     settings.endGroup()
Beispiel #40
0
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)
Beispiel #41
0
 def load(self):
     """
     Load settings from disk.
     """
     settings = Settings()
     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(settings.value('max recent files'))
     self.recent_spin_box.setValue(settings.value('recent file count'))
     self.media_plugin_check_box.setChecked(settings.value('save current plugin'))
     self.double_click_live_check_box.setChecked(settings.value('double click live'))
     self.single_click_preview_check_box.setChecked(settings.value('single click preview'))
     self.single_click_service_preview_check_box.setChecked(settings.value('single click service preview'))
     self.expand_service_item_check_box.setChecked(settings.value('expand service item'))
     slide_max_height_value = settings.value('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 = settings.value('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(settings.value('enable exit confirmation'))
     self.hide_mouse_check_box.setChecked(settings.value('hide mouse'))
     self.service_name_day.setCurrentIndex(settings.value('default service day'))
     self.service_name_time.setTime(QtCore.QTime(settings.value('default service hour'),
                                                 settings.value('default service minute')))
     self.should_update_service_name_example = True
     self.service_name_edit.setText(settings.value('default service name'))
     default_service_enabled = settings.value('default service enabled')
     self.service_name_check_box.setChecked(default_service_enabled)
     self.service_name_check_box_toggled(default_service_enabled)
     self.x11_bypass_check_box.setChecked(settings.value('x11 bypass wm'))
     self.slide_limits = settings.value('slide limits')
     self.is_search_as_you_type_enabled = settings.value('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(settings.value('alternate rows'))
     self.alternate_rows_check_box.blockSignals(False)
     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)
     settings.endGroup()
     self.data_directory_copy_check_box.hide()
     self.new_data_directory_has_files_label.hide()
     self.data_directory_cancel_button.hide()
     # Since data location can be changed, make sure the path is present.
     self.current_data_path = AppLocation.get_data_path()
     self.data_directory_label.setText(os.path.abspath(self.current_data_path))
     # Don't allow data directory move if running portable.
     if settings.value('advanced/is portable'):
         self.data_directory_group_box.hide()
Beispiel #42
0
    def add_action(self, action, category=None, weight=None):
        """
        Add an action to the list of actions.

        **Note**: The action's objectName must be set when you want to add it!

        :param action: The action to add (QAction). **Note**, the action must not have an empty ``objectName``.
        :param category: The category this action belongs to. The category has to be a python string. . **Note**,
        if the category is ``None``, the category and its actions are being hidden in the shortcut dialog. However,
        if they are added, it is possible to avoid assigning shortcuts twice, which is important.
        :param weight: The weight specifies how important a category is. However, this only has an impact on the order
        the categories are displayed.
        """
        if category not in self.categories:
            self.categories.append(category)
        settings = Settings()
        settings.beginGroup('shortcuts')
        # Get the default shortcut from the config.
        action.default_shortcuts = settings.get_default_value(
            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()
        if not shortcuts:
            action.setShortcuts([])
            return
        # We have to do this to ensure that the loaded shortcut list e. g. STRG+O (German) is converted to CTRL+O,
        # which is only done when we convert the strings in this way (QKeySequencet -> uncode).
        shortcuts = list(
            map(QtGui.QKeySequence.toString,
                list(map(QtGui.QKeySequence, shortcuts))))
        # Check the alternate shortcut first, to avoid problems when the alternate shortcut becomes the primary shortcut
        #  after removing the (initial) primary shortcut due to conflicts.
        if len(shortcuts) == 2:
            existing_actions = ActionList.shortcut_map.get(shortcuts[1], [])
            # Check for conflicts with other actions considering the shortcut context.
            if self._is_shortcut_available(existing_actions, action):
                actions = ActionList.shortcut_map.get(shortcuts[1], [])
                actions.append(action)
                ActionList.shortcut_map[shortcuts[1]] = actions
            else:
                log.warning(
                    'Shortcut "%s" is removed from "%s" because another action already uses this shortcut.'
                    % (shortcuts[1], action.objectName()))
                shortcuts.remove(shortcuts[1])
        # Check the primary shortcut.
        existing_actions = ActionList.shortcut_map.get(shortcuts[0], [])
        # Check for conflicts with other actions considering the shortcut context.
        if self._is_shortcut_available(existing_actions, action):
            actions = ActionList.shortcut_map.get(shortcuts[0], [])
            actions.append(action)
            ActionList.shortcut_map[shortcuts[0]] = actions
        else:
            log.warning(
                'Shortcut "%s" is removed from "%s" because another action already uses this shortcut.'
                % (shortcuts[0], action.objectName()))
            shortcuts.remove(shortcuts[0])
        action.setShortcuts(
            [QtGui.QKeySequence(shortcut) for shortcut in shortcuts])
Beispiel #43
0
 def load(self):
     """
     Load settings from disk.
     """
     settings = Settings()
     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(settings.value('max recent files'))
     self.recent_spin_box.setValue(settings.value('recent file count'))
     self.media_plugin_check_box.setChecked(settings.value('save current plugin'))
     self.double_click_live_check_box.setChecked(settings.value('double click live'))
     self.single_click_preview_check_box.setChecked(settings.value('single click preview'))
     self.expand_service_item_check_box.setChecked(settings.value('expand service item'))
     self.enable_auto_close_check_box.setChecked(settings.value('enable exit confirmation'))
     self.hide_mouse_check_box.setChecked(settings.value('hide mouse'))
     self.service_name_day.setCurrentIndex(settings.value('default service day'))
     self.service_name_time.setTime(QtCore.QTime(settings.value('default service hour'),
                                                 settings.value('default service minute')))
     self.should_update_service_name_example = True
     self.service_name_edit.setText(settings.value('default service name'))
     default_service_enabled = settings.value('default service enabled')
     self.service_name_check_box.setChecked(default_service_enabled)
     self.service_name_check_box_toggled(default_service_enabled)
     self.x11_bypass_check_box.setChecked(settings.value('x11 bypass wm'))
     self.default_color = settings.value('default color')
     self.default_file_edit.setText(settings.value('default image'))
     self.slide_limits = settings.value('slide limits')
     self.is_search_as_you_type_enabled = settings.value('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(settings.value('alternate rows'))
     self.alternate_rows_check_box.blockSignals(False)
     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)
     settings.endGroup()
     self.data_directory_copy_check_box.hide()
     self.new_data_directory_has_files_label.hide()
     self.data_directory_cancel_button.hide()
     # Since data location can be changed, make sure the path is present.
     self.current_data_path = AppLocation.get_data_path()
     if not os.path.exists(self.current_data_path):
         log.error('Data path not found %s' % self.current_data_path)
         answer = QtWidgets.QMessageBox.critical(
             self, translate('OpenLP.AdvancedTab', 'Data Directory Error'),
             translate('OpenLP.AdvancedTab', 'OpenLP data directory was not found\n\n%s\n\n'
                       'This data directory was previously changed from the OpenLP '
                       'default location.  If the new location was on removable '
                       'media, that media needs to be made available.\n\n'
                       'Click "No" to stop loading OpenLP. allowing you to fix the the problem.\n\n'
                       'Click "Yes" to reset the data directory to the default '
                       'location.').replace('%s', self.current_data_path),
             QtWidgets.QMessageBox.StandardButtons(QtWidgets.QMessageBox.Yes | QtWidgets.QMessageBox.No),
             QtWidgets.QMessageBox.No)
         if answer == QtWidgets.QMessageBox.No:
             log.info('User requested termination')
             self.main_window.clean_up()
             sys.exit()
         # Set data location to default.
         settings.remove('advanced/data path')
         self.current_data_path = AppLocation.get_data_path()
         log.warning('User requested data path set to default %s' % self.current_data_path)
     self.data_directory_label.setText(os.path.abspath(self.current_data_path))
     self.default_color_button.color = self.default_color
     # Don't allow data directory move if running portable.
     if settings.value('advanced/is portable'):
         self.data_directory_group_box.hide()
Beispiel #44
0
 def load(self):
     """
     Load settings from disk.
     """
     settings = Settings()
     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(settings.value('max recent files'))
     self.recent_spin_box.setValue(settings.value('recent file count'))
     self.media_plugin_check_box.setChecked(settings.value('save current plugin'))
     self.double_click_live_check_box.setChecked(settings.value('double click live'))
     self.single_click_preview_check_box.setChecked(settings.value('single click preview'))
     self.expand_service_item_check_box.setChecked(settings.value('expand service item'))
     self.enable_auto_close_check_box.setChecked(settings.value('enable exit confirmation'))
     self.hide_mouse_check_box.setChecked(settings.value('hide mouse'))
     self.service_name_day.setCurrentIndex(settings.value('default service day'))
     self.service_name_time.setTime(QtCore.QTime(settings.value('default service hour'),
                                                 settings.value('default service minute')))
     self.should_update_service_name_example = True
     self.service_name_edit.setText(settings.value('default service name'))
     default_service_enabled = settings.value('default service enabled')
     self.service_name_check_box.setChecked(default_service_enabled)
     self.service_name_check_box_toggled(default_service_enabled)
     self.x11_bypass_check_box.setChecked(settings.value('x11 bypass wm'))
     self.default_color = settings.value('default color')
     self.default_file_edit.setText(settings.value('default image'))
     self.slide_limits = settings.value('slide limits')
     # 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(settings.value('alternate rows'))
     self.alternate_rows_check_box.blockSignals(False)
     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)
     settings.endGroup()
     self.data_directory_copy_check_box.hide()
     self.new_data_directory_has_files_label.hide()
     self.data_directory_cancel_button.hide()
     # Since data location can be changed, make sure the path is present.
     self.current_data_path = AppLocation.get_data_path()
     if not os.path.exists(self.current_data_path):
         log.error('Data path not found %s' % self.current_data_path)
         answer = QtGui.QMessageBox.critical(
             self, translate('OpenLP.AdvancedTab', 'Data Directory Error'),
             translate('OpenLP.AdvancedTab', 'OpenLP data directory was not found\n\n%s\n\n'
                       'This data directory was previously changed from the OpenLP '
                       'default location.  If the new location was on removable '
                       'media, that media needs to be made available.\n\n'
                       'Click "No" to stop loading OpenLP. allowing you to fix the the problem.\n\n'
                       'Click "Yes" to reset the data directory to the default '
                       'location.').replace('%s', self.current_data_path),
             QtGui.QMessageBox.StandardButtons(QtGui.QMessageBox.Yes | QtGui.QMessageBox.No),
             QtGui.QMessageBox.No)
         if answer == QtGui.QMessageBox.No:
             log.info('User requested termination')
             self.main_window.clean_up()
             sys.exit()
         # Set data location to default.
         settings.remove('advanced/data path')
         self.current_data_path = AppLocation.get_data_path()
         log.warning('User requested data path set to default %s' % self.current_data_path)
     self.data_directory_label.setText(os.path.abspath(self.current_data_path))
     self.default_color_button.color = self.default_color
     # Don't allow data directory move if running portable.
     if settings.value('advanced/is portable'):
         self.data_directory_group_box.hide()
Beispiel #45
0
 def load(self):
     """
     Load the settings to populate the form
     """
     settings = Settings()
     settings.beginGroup(self.settings_section)
     self.monitor_combo_box.clear()
     self.monitor_combo_box.addItems(self.screens.get_screen_list())
     monitor_number = settings.value('monitor')
     self.monitor_combo_box.setCurrentIndex(monitor_number)
     self.number_edit.setText(settings.value('ccli number'))
     self.username_edit.setText(settings.value('songselect username'))
     self.password_edit.setText(settings.value('songselect password'))
     self.save_check_service_check_box.setChecked(settings.value('save prompt'))
     self.auto_unblank_check_box.setChecked(settings.value('auto unblank'))
     self.display_on_monitor_check.setChecked(self.screens.display)
     self.warning_check_box.setChecked(settings.value('blank warning'))
     self.auto_open_check_box.setChecked(settings.value('auto open'))
     self.show_splash_check_box.setChecked(settings.value('show splash'))
     self.check_for_updates_check_box.setChecked(settings.value('update check'))
     self.auto_preview_check_box.setChecked(settings.value('auto preview'))
     self.timeout_spin_box.setValue(settings.value('loop delay'))
     self.monitor_radio_button.setChecked(not settings.value('override position',))
     self.override_radio_button.setChecked(settings.value('override position'))
     self.custom_X_value_edit.setValue(settings.value('x position'))
     self.custom_Y_value_edit.setValue(settings.value('y position'))
     self.custom_height_value_edit.setValue(settings.value('height'))
     self.custom_width_value_edit.setValue(settings.value('width'))
     self.start_paused_check_box.setChecked(settings.value('audio start paused'))
     self.repeat_list_check_box.setChecked(settings.value('audio repeat list'))
     settings.endGroup()
     self.monitor_combo_box.setDisabled(self.override_radio_button.isChecked())
     self.custom_X_value_edit.setEnabled(self.override_radio_button.isChecked())
     self.custom_Y_value_edit.setEnabled(self.override_radio_button.isChecked())
     self.custom_height_value_edit.setEnabled(self.override_radio_button.isChecked())
     self.custom_width_value_edit.setEnabled(self.override_radio_button.isChecked())
     self.display_changed = False
Beispiel #46
0
 def load(self):
     """
     Load the settings to populate the form
     """
     settings = Settings()
     settings.beginGroup(self.settings_section)
     self.monitor_combo_box.clear()
     self.monitor_combo_box.addItems(self.screens.get_screen_list())
     monitor_number = settings.value('monitor')
     self.monitor_combo_box.setCurrentIndex(monitor_number)
     self.number_edit.setText(settings.value('ccli number'))
     self.username_edit.setText(settings.value('songselect username'))
     self.password_edit.setText(settings.value('songselect password'))
     self.save_check_service_check_box.setChecked(
         settings.value('save prompt'))
     self.auto_unblank_check_box.setChecked(settings.value('auto unblank'))
     self.display_on_monitor_check.setChecked(self.screens.display)
     self.warning_check_box.setChecked(settings.value('blank warning'))
     self.auto_open_check_box.setChecked(settings.value('auto open'))
     self.show_splash_check_box.setChecked(settings.value('show splash'))
     self.check_for_updates_check_box.setChecked(
         settings.value('update check'))
     self.auto_preview_check_box.setChecked(settings.value('auto preview'))
     self.timeout_spin_box.setValue(settings.value('loop delay'))
     self.monitor_radio_button.setChecked(
         not settings.value('override position', ))
     self.override_radio_button.setChecked(
         settings.value('override position'))
     self.custom_X_value_edit.setValue(settings.value('x position'))
     self.custom_Y_value_edit.setValue(settings.value('y position'))
     self.custom_height_value_edit.setValue(settings.value('height'))
     self.custom_width_value_edit.setValue(settings.value('width'))
     self.start_paused_check_box.setChecked(
         settings.value('audio start paused'))
     self.repeat_list_check_box.setChecked(
         settings.value('audio repeat list'))
     settings.endGroup()
     self.monitor_combo_box.setDisabled(
         self.override_radio_button.isChecked())
     self.custom_X_value_edit.setEnabled(
         self.override_radio_button.isChecked())
     self.custom_Y_value_edit.setEnabled(
         self.override_radio_button.isChecked())
     self.custom_height_value_edit.setEnabled(
         self.override_radio_button.isChecked())
     self.custom_width_value_edit.setEnabled(
         self.override_radio_button.isChecked())
     self.display_changed = False
Beispiel #47
0
 def load(self):
     settings = Settings()
     settings.beginGroup(self.settings_section)
     self.is_verse_number_visible = settings.value(
         'is verse number visible')
     self.show_new_chapters = settings.value('display new chapter')
     self.display_style = settings.value('display brackets')
     self.layout_style = settings.value('verse layout style')
     self.bible_theme = settings.value('bible theme')
     self.second_bibles = settings.value('second bibles')
     self.is_verse_number_visible_check_box.setChecked(
         self.is_verse_number_visible)
     self.check_is_verse_number_visible()
     self.new_chapters_check_box.setChecked(self.show_new_chapters)
     self.display_style_combo_box.setCurrentIndex(self.display_style)
     self.layout_style_combo_box.setCurrentIndex(self.layout_style)
     self.bible_second_check_box.setChecked(self.second_bibles)
     verse_separator = settings.value('verse separator')
     if (verse_separator.strip('|')
             == '') or (verse_separator
                        == get_reference_separator('sep_v_default')):
         self.verse_separator_line_edit.setText(
             get_reference_separator('sep_v_default'))
         self.verse_separator_line_edit.setPalette(
             self.get_grey_text_palette(True))
         self.verse_separator_check_box.setChecked(False)
     else:
         self.verse_separator_line_edit.setText(verse_separator)
         self.verse_separator_line_edit.setPalette(
             self.get_grey_text_palette(False))
         self.verse_separator_check_box.setChecked(True)
     range_separator = settings.value('range separator')
     if (range_separator.strip('|')
             == '') or (range_separator
                        == get_reference_separator('sep_r_default')):
         self.range_separator_line_edit.setText(
             get_reference_separator('sep_r_default'))
         self.range_separator_line_edit.setPalette(
             self.get_grey_text_palette(True))
         self.range_separator_check_box.setChecked(False)
     else:
         self.range_separator_line_edit.setText(range_separator)
         self.range_separator_line_edit.setPalette(
             self.get_grey_text_palette(False))
         self.range_separator_check_box.setChecked(True)
     list_separator = settings.value('list separator')
     if (list_separator.strip('|')
             == '') or (list_separator
                        == get_reference_separator('sep_l_default')):
         self.list_separator_line_edit.setText(
             get_reference_separator('sep_l_default'))
         self.list_separator_line_edit.setPalette(
             self.get_grey_text_palette(True))
         self.list_separator_check_box.setChecked(False)
     else:
         self.list_separator_line_edit.setText(list_separator)
         self.list_separator_line_edit.setPalette(
             self.get_grey_text_palette(False))
         self.list_separator_check_box.setChecked(True)
     end_separator = settings.value('end separator')
     if (end_separator.strip('|')
             == '') or (end_separator
                        == get_reference_separator('sep_e_default')):
         self.end_separator_line_edit.setText(
             get_reference_separator('sep_e_default'))
         self.end_separator_line_edit.setPalette(
             self.get_grey_text_palette(True))
         self.end_separator_check_box.setChecked(False)
     else:
         self.end_separator_line_edit.setText(end_separator)
         self.end_separator_line_edit.setPalette(
             self.get_grey_text_palette(False))
         self.end_separator_check_box.setChecked(True)
     self.language_selection = settings.value('book name language')
     self.language_selection_combo_box.setCurrentIndex(
         self.language_selection)
     settings.endGroup()