Пример #1
0
 def __init__(self):
     """
     Constructor
     """
     super(PrintServiceForm, self).__init__(Registry().get('main_window'), QtCore.Qt.WindowSystemMenuHint |
                                            QtCore.Qt.WindowTitleHint | QtCore.Qt.WindowCloseButtonHint)
     self.printer = QtPrintSupport.QPrinter()
     self.print_dialog = QtPrintSupport.QPrintDialog(self.printer, self)
     self.document = QtGui.QTextDocument()
     self.zoom = 0
     self.setup_ui(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()
Пример #2
0
def get_proxy_settings(mode=None):
    """
    Create a dictionary containing the proxy settings.

    :param ProxyMode | None mode: Specify the source of the proxy settings
    :return: A dict using the format expected by the requests library.
    :rtype: dict | None
    """
    settings = Settings()
    if mode is None:
        mode = settings.value('advanced/proxy mode')
    if mode == ProxyMode.NO_PROXY:
        return {'http': None, 'https': None}
    elif mode == ProxyMode.SYSTEM_PROXY:
        # The requests library defaults to using the proxy settings in the environment variables
        return
    elif mode == ProxyMode.MANUAL_PROXY:
        http_addr = settings.value('advanced/proxy http')
        https_addr = settings.value('advanced/proxy https')
        username = settings.value('advanced/proxy username')
        password = settings.value('advanced/proxy password')
        basic_auth = ''
        if username:
            basic_auth = '{username}:{password}@'.format(username=username, password=password)
        http_value = None
        https_value = None
        if http_addr:
            http_value = 'http://{basic_auth}{http_addr}'.format(basic_auth=basic_auth, http_addr=http_addr)
        if https_addr:
            https_value = 'https://{basic_auth}{https_addr}'.format(basic_auth=basic_auth, https_addr=https_addr)
        return {'http': http_value, 'https': https_value}
Пример #3
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()
Пример #4
0
 def load(self):
     """
     Load the data from the settings to the widget.
     """
     settings = Settings()
     checked_radio = self.radio_group.button(
         settings.value('advanced/proxy mode'))
     checked_radio.setChecked(True)
     self.http_edit.setText(settings.value('advanced/proxy http'))
     self.https_edit.setText(settings.value('advanced/proxy https'))
     self.username_edit.setText(settings.value('advanced/proxy username'))
     self.password_edit.setText(settings.value('advanced/proxy password'))
Пример #5
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)
Пример #6
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
Пример #7
0
 def test_save_credentials(self):
     """
     Test that credentials are saved in settings when the save function is called
     """
     # GIVEN: A PlanningCenterTab Class
     # WHEN: application id and secret values are set to something and the save function is called
     new_application_id = 'planningcenter'
     new_secret = 'woohoo'
     self.tab.application_id_line_edit.setText(new_application_id)
     self.tab.secret_line_edit.setText(new_secret)
     self.tab.save()
     # THEN: The settings version of application_id and secret should reflect the new values
     settings = Settings()
     settings.beginGroup(self.tab.settings_section)
     application_id = settings.value('application_id')
     secret = settings.value('secret')
     self.assertEqual(application_id, new_application_id)
     self.assertEqual(secret, new_secret)
     settings.endGroup()
Пример #8
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
Пример #9
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()
Пример #10
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
Пример #11
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.setValue('reset to combined quick search',
                       self.reset_to_combined_quick_search)
     settings.setValue('hide combined quick error',
                       self.hide_combined_quick_error)
     settings.setValue('is search while typing enabled',
                       self.bible_search_while_typing)
     settings.endGroup()
     if self.tab_visited:
         self.settings_form.register_post_process('bibles_config_updated')
     self.tab_visited = False
Пример #12
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
Пример #13
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
Пример #14
0
 def load(self):
     """
     Load the settings to populate the form
     """
     settings = Settings()
     settings.beginGroup(self.settings_section)
     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.click_live_slide_to_unblank_check_box.setChecked(
         settings.value('click live slide to unblank'))
     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.logo_background_color = settings.value('logo background color')
     self.logo_file_path_edit.path = settings.value('logo file')
     self.logo_hide_on_startup_check_box.setChecked(
         settings.value('logo hide on startup'))
     self.logo_color_button.color = self.logo_background_color
     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'))
     settings.endGroup()
Пример #15
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(
         'single click service preview',
         self.single_click_service_preview_check_box.isChecked())
     settings.setValue('expand service item',
                       self.expand_service_item_check_box.isChecked())
     slide_max_height_index = self.slide_max_height_combo_box.currentIndex()
     slide_max_height_value = self.slide_max_height_combo_box.itemData(
         slide_max_height_index)
     settings.setValue('slide max height', slide_max_height_value)
     settings.setValue(
         'autoscrolling',
         self.autoscroll_map[self.autoscroll_combo_box.currentIndex()])
     settings.setValue('experimental',
                       self.experimental_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('slide limits', self.slide_limits)
     settings.setValue('ignore aspect ratio',
                       self.ignore_aspect_ratio_check_box.isChecked())
     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)
     if HAS_DARK_STYLE:
         settings.setValue('use_dark_style',
                           self.use_dark_style_checkbox.isChecked())
     settings.endGroup()
     self.proxy_widget.save()
Пример #16
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.experimental_check_box.setChecked(settings.value('experimental'))
     if HAS_DARK_STYLE:
         self.use_dark_style_checkbox.setChecked(
             settings.value('use_dark_style'))
     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.ignore_aspect_ratio_check_box.setChecked(
         settings.value('ignore aspect ratio'))
     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.data_directory_path_edit.path = AppLocation.get_data_path()
     # Don't allow data directory move if running portable.
     if settings.value('advanced/is portable'):
         self.data_directory_group_box.hide()
Пример #17
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.songbook_slide = settings.value('add songbook slide')
     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.enable_chords = settings.value('enable chords')
     self.chord_notation = settings.value('chord notation')
     self.mainview_chords = settings.value('mainview chords')
     self.disable_chords_import = settings.value('disable chords import')
     self.tool_bar_active_check_box.setChecked(self.tool_bar)
     self.update_on_edit_check_box.setChecked(self.update_edit)
     self.add_from_service_check_box.setChecked(self.update_load)
     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)
     self.chords_group_box.setChecked(self.enable_chords)
     self.mainview_chords_check_box.setChecked(self.mainview_chords)
     self.disable_chords_import_check_box.setChecked(self.disable_chords_import)
     if self.chord_notation == 'german':
         self.german_notation_radio_button.setChecked(True)
     elif self.chord_notation == 'neo-latin':
         self.neolatin_notation_radio_button.setChecked(True)
     else:
         self.english_notation_radio_button.setChecked(True)
     settings.endGroup()
Пример #18
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, 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])
Пример #19
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.click_live_slide_to_unblank_check_box.setChecked(
         settings.value('click live slide to 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.logo_background_color = settings.value('logo background color')
     self.logo_file_path_edit.path = settings.value('logo file')
     self.logo_hide_on_startup_check_box.setChecked(
         settings.value('logo hide on startup'))
     self.logo_color_button.color = self.logo_background_color
     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
Пример #20
0
def update_reference_separators():
    """
    Updates separators and matches for parsing and formatting 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_{role}_display'.format(
                role=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_{role}'.format(
            role=role)] = r'\s*(?:{source})\s*'.format(source=source_string)
        REFERENCE_SEPARATORS['sep_{role}_default'.format(
            role=role)] = default_separators[index]
    # verse range match: (<chapter>:)?<verse>(-((<chapter>:)?<verse>|end)?)?
    range_regex = '(?:(?P<from_chapter>[0-9]+){sep_v})?' \
        '(?P<from_verse>[0-9]+)(?P<range_to>{sep_r}(?:(?:(?P<to_chapter>' \
        '[0-9]+){sep_v})?(?P<to_verse>[0-9]+)|{sep_e})?)?'.format_map(REFERENCE_SEPARATORS)
    REFERENCE_MATCHES['range'] = re.compile(
        r'^\s*{range}\s*$'.format(range=range_regex))
    REFERENCE_MATCHES['range_separator'] = re.compile(
        REFERENCE_SEPARATORS['sep_l'])
    # full reference match: <book>(<range>(,(?!$)|(?=$)))+
    REFERENCE_MATCHES['full'] = \
        re.compile(r'^\s*(?!\s)(?P<book>[\d]*[.]?[^\d\.]+)\.*(?<!\s)\s*'
                   r'(?P<ranges>(?:{range_regex}(?:{sep_l}(?!\s*$)|(?=\s*$)))+)\s*$'.format(
                       range_regex=range_regex, sep_l=REFERENCE_SEPARATORS['sep_l']))
Пример #21
0
def main(args=None):
    """
    The main function which parses command line options and then runs

    :param args: Some args
    """
    args = parse_options(args)
    qt_args = []
    if args and args.loglevel.lower() in ['d', 'debug']:
        log.setLevel(logging.DEBUG)
    elif args and args.loglevel.lower() in ['w', 'warning']:
        log.setLevel(logging.WARNING)
    else:
        log.setLevel(logging.INFO)
    # Throw the rest of the arguments at Qt, just in case.
    qt_args.extend(args.rargs)
    # Bug #1018855: Set the WM_CLASS property in X11
    if not is_win() and not is_macosx():
        qt_args.append('OpenLP')
    # Initialise the resources
    qInitResources()
    # Now create and actually run the application.
    application = OpenLP(qt_args)
    application.setOrganizationName('OpenLP')
    application.setOrganizationDomain('openlp.org')
    application.setAttribute(QtCore.Qt.AA_UseHighDpiPixmaps, True)
    application.setAttribute(QtCore.Qt.AA_DontCreateNativeWidgetSiblings, True)
    if args.portable:
        application.setApplicationName('OpenLPPortable')
        Settings.setDefaultFormat(Settings.IniFormat)
        # Get location OpenLPPortable.ini
        portable_path = (AppLocation.get_directory(AppLocation.AppDir) / '..' /
                         '..').resolve()
        data_path = portable_path / 'Data'
        set_up_logging(portable_path / 'Other')
        log.info('Running portable')
        portable_settings_path = data_path / 'OpenLP.ini'
        # Make this our settings file
        log.info('INI file: {name}'.format(name=portable_settings_path))
        Settings.set_filename(str(portable_settings_path))
        portable_settings = Settings()
        # Set our data path
        log.info('Data path: {name}'.format(name=data_path))
        # Point to our data path
        portable_settings.setValue('advanced/data path', data_path)
        portable_settings.setValue('advanced/is portable', True)
        portable_settings.sync()
    else:
        application.setApplicationName('OpenLP')
        set_up_logging(AppLocation.get_directory(AppLocation.CacheDir))
    Registry.create()
    Registry().register('application', application)
    Registry().set_flag('no_web_server', args.no_web_server)
    application.setApplicationVersion(get_version()['version'])
    # Check if an instance of OpenLP is already running. Quit if there is a running instance and the user only wants one
    server = Server()
    if server.is_another_instance_running():
        application.is_already_running()
        server.post_to_server(qt_args)
        sys.exit()
    else:
        server.start_server()
        application.server = server
    # If the custom data path is missing and the user wants to restore the data path, quit OpenLP.
    if application.is_data_path_missing():
        server.close_server()
        sys.exit()
    # Upgrade settings.
    settings = Settings()
    if settings.can_upgrade():
        now = datetime.now()
        # Only back up if OpenLP has previously run.
        if settings.value('core/has run wizard'):
            back_up_path = AppLocation.get_data_path() / (
                now.strftime('%Y-%m-%d %H-%M') + '.conf')
            log.info(
                'Settings about to be upgraded. Existing settings are being backed up to {back_up_path}'
                .format(back_up_path=back_up_path))
            QtWidgets.QMessageBox.information(
                None, translate('OpenLP', 'Settings Upgrade'),
                translate(
                    'OpenLP',
                    'Your settings are about to be upgraded. A backup will be created at '
                    '{back_up_path}').format(back_up_path=back_up_path))
            settings.export(back_up_path)
        settings.upgrade_settings()
    # First time checks in settings
    if not Settings().value('core/has run wizard'):
        if not FirstTimeLanguageForm().exec():
            # if cancel then stop processing
            server.close_server()
            sys.exit()
    # i18n Set Language
    language = LanguageManager.get_language()
    translators = LanguageManager.get_translators(language)
    for translator in translators:
        if not translator.isEmpty():
            application.installTranslator(translator)
    if not translators:
        log.debug('Could not find translators.')
    if args and not args.no_error_form:
        sys.excepthook = application.hook_exception
    sys.exit(application.run(qt_args))
Пример #22
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()