Esempio n. 1
0
 def save(self):
     settings = Settings()
     settings.beginGroup(self.settings_section)
     settings.setValue('background color', self.background_color)
     settings.endGroup()
     if self.initial_color != self.background_color:
         self.settings_form.register_post_process('images_config_updated')
Esempio n. 2
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
Esempio n. 3
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()
Esempio n. 4
0
 def save(self):
     """
     Save the settings from the form
     """
     settings = Settings()
     settings.beginGroup(self.settings_section)
     settings.setValue('blank warning', self.warning_check_box.isChecked())
     settings.setValue('auto open', self.auto_open_check_box.isChecked())
     settings.setValue('show splash',
                       self.show_splash_check_box.isChecked())
     settings.setValue('logo background color', self.logo_background_color)
     settings.setValue('logo file', self.logo_file_path_edit.path)
     settings.setValue('logo hide on startup',
                       self.logo_hide_on_startup_check_box.isChecked())
     settings.setValue('update check',
                       self.check_for_updates_check_box.isChecked())
     settings.setValue('save prompt',
                       self.save_check_service_check_box.isChecked())
     settings.setValue('auto unblank',
                       self.auto_unblank_check_box.isChecked())
     settings.setValue(
         'click live slide to unblank',
         self.click_live_slide_to_unblank_check_box.isChecked())
     settings.setValue('auto preview',
                       self.auto_preview_check_box.isChecked())
     settings.setValue('loop delay', self.timeout_spin_box.value())
     settings.setValue('ccli number', self.number_edit.displayText())
     settings.setValue('songselect username',
                       self.username_edit.displayText())
     settings.setValue('songselect password',
                       self.password_edit.displayText())
     settings.endGroup()
     self.post_set_up()
Esempio n. 5
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()
Esempio n. 6
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()
Esempio n. 7
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()
Esempio n. 8
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
Esempio n. 9
0
 def save_options(self):
     """
     Save the settings and close the dialog.
     """
     # Save the settings for this dialog.
     settings = Settings()
     settings.beginGroup('advanced')
     settings.setValue('print slide text', self.slide_text_check_box.isChecked())
     settings.setValue('add page break', self.page_break_after_text.isChecked())
     settings.setValue('print file meta data', self.meta_data_check_box.isChecked())
     settings.setValue('print notes', self.notes_check_box.isChecked())
     settings.endGroup()
Esempio n. 10
0
 def save(self):
     """
     Save the Dialog settings
     """
     settings = Settings()
     settings.beginGroup(self.settings_section)
     settings.setValue('display footer', self.display_footer)
     settings.setValue('add custom from service', self.update_load)
     settings.endGroup()
     if self.tab_visited:
         self.settings_form.register_post_process('custom_config_updated')
     self.tab_visited = False
Esempio n. 11
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()
Esempio n. 12
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
Esempio n. 13
0
 def save(self):
     """
     Save the settings
     """
     settings = Settings()
     settings.beginGroup(self.settings_section)
     settings.setValue('background color', self.background_color)
     settings.endGroup()
     old_players, override_player = get_media_players()
     if self.used_players != old_players:
         # clean old Media stuff
         set_media_players(self.used_players, override_player)
         self.settings_form.register_post_process('mediaitem_suffix_reset')
         self.settings_form.register_post_process('mediaitem_media_rebuild')
         self.settings_form.register_post_process('config_screen_changed')
Esempio n. 14
0
 def save(self):
     """
     Save the settings
     """
     settings = Settings()
     settings.beginGroup(self.settings_section)
     settings.setValue('theme level', self.theme_level)
     settings.setValue('global theme', self.global_theme)
     settings.setValue('wrap footer',
                       self.wrap_footer_check_box.isChecked())
     settings.endGroup()
     self.renderer.set_theme_level(self.theme_level)
     if self.tab_visited:
         self.settings_form.register_post_process('theme_update_global')
     self.tab_visited = False
Esempio n. 15
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)
Esempio n. 16
0
 def save(self):
     """
     Save the settings from the form
     """
     settings = Settings()
     settings.beginGroup(self.settings_section)
     settings.setValue('monitor', self.monitor_combo_box.currentIndex())
     settings.setValue('display on monitor',
                       self.display_on_monitor_check.isChecked())
     settings.setValue('blank warning', self.warning_check_box.isChecked())
     settings.setValue('auto open', self.auto_open_check_box.isChecked())
     settings.setValue('show splash',
                       self.show_splash_check_box.isChecked())
     settings.setValue('logo background color', self.logo_background_color)
     settings.setValue('logo file', self.logo_file_path_edit.path)
     settings.setValue('logo hide on startup',
                       self.logo_hide_on_startup_check_box.isChecked())
     settings.setValue('update check',
                       self.check_for_updates_check_box.isChecked())
     settings.setValue('save prompt',
                       self.save_check_service_check_box.isChecked())
     settings.setValue('auto unblank',
                       self.auto_unblank_check_box.isChecked())
     settings.setValue(
         'click live slide to unblank',
         self.click_live_slide_to_unblank_check_box.isChecked())
     settings.setValue('auto preview',
                       self.auto_preview_check_box.isChecked())
     settings.setValue('loop delay', self.timeout_spin_box.value())
     settings.setValue('ccli number', self.number_edit.displayText())
     settings.setValue('songselect username',
                       self.username_edit.displayText())
     settings.setValue('songselect password',
                       self.password_edit.displayText())
     settings.setValue('x position', self.custom_X_value_edit.value())
     settings.setValue('y position', self.custom_Y_value_edit.value())
     settings.setValue('height', self.custom_height_value_edit.value())
     settings.setValue('width', self.custom_width_value_edit.value())
     settings.setValue('override position',
                       self.override_radio_button.isChecked())
     settings.setValue('audio start paused',
                       self.start_paused_check_box.isChecked())
     settings.setValue('audio repeat list',
                       self.repeat_list_check_box.isChecked())
     settings.endGroup()
     # On save update the screens as well
     self.post_set_up(True)
Esempio n. 17
0
 def save(self):
     settings = Settings()
     settings.beginGroup(self.settings_section)
     settings.setValue('display songbar', self.tool_bar)
     settings.setValue('update service on edit', self.update_edit)
     settings.setValue('add song from service', self.update_load)
     settings.setValue('display songbook', self.display_songbook)
     settings.setValue('display written by', self.display_written_by)
     settings.setValue('display copyright symbol', self.display_copyright_symbol)
     settings.setValue('enable chords', self.chords_group_box.isChecked())
     settings.setValue('mainview chords', self.mainview_chords)
     settings.setValue('disable chords import', self.disable_chords_import)
     settings.setValue('chord notation', self.chord_notation)
     settings.setValue('add songbook slide', self.songbook_slide)
     settings.endGroup()
     if self.tab_visited:
         self.settings_form.register_post_process('songs_config_updated')
     self.tab_visited = False
Esempio n. 18
0
 def save(self):
     """
     Save the shortcuts. **Note**, that we do not have to load the shortcuts, as they are loaded in
     :class:`~openlp.core.utils.ActionList`.
     """
     settings = Settings()
     settings.beginGroup('shortcuts')
     for category in self.action_list.categories:
         # Check if the category is for internal use only.
         if category.name is None:
             continue
         for action in category.actions:
             if action in self.changed_actions:
                 old_shortcuts = list(map(self.get_shortcut_string, action.shortcuts()))
                 action.setShortcuts(self.changed_actions[action])
                 self.action_list.update_shortcut_map(action, old_shortcuts)
             settings.setValue(action.objectName(), action.shortcuts())
     settings.endGroup()
Esempio n. 19
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
Esempio n. 20
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()
Esempio n. 21
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
Esempio n. 22
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
Esempio n. 23
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
Esempio n. 24
0
 def display_size_changed(self, display):
     """
     The Zoom Combo box has changed so set up the size.
     """
     if display == ZoomSize.Page:
         self.preview_widget.fitInView()
     elif display == ZoomSize.Width:
         self.preview_widget.fitToWidth()
     elif display == ZoomSize.OneHundred:
         self.preview_widget.fitToWidth()
         self.preview_widget.zoomIn(1)
     elif display == ZoomSize.SeventyFive:
         self.preview_widget.fitToWidth()
         self.preview_widget.zoomIn(0.75)
     elif display == ZoomSize.Fifty:
         self.preview_widget.fitToWidth()
         self.preview_widget.zoomIn(0.5)
     elif display == ZoomSize.TwentyFive:
         self.preview_widget.fitToWidth()
         self.preview_widget.zoomIn(0.25)
     settings = Settings()
     settings.beginGroup('advanced')
     settings.setValue('display size', display)
     settings.endGroup()
Esempio n. 25
0
class TestActionList(TestCase, TestMixin):
    """
    Test the ActionList class
    """
    def setUp(self):
        """
        Prepare the tests
        """
        self.setup_application()
        self.action_list = ActionList.get_instance()
        self.build_settings()
        self.settings = Settings()
        self.settings.beginGroup('shortcuts')

    def tearDown(self):
        """
        Clean up
        """
        self.settings.endGroup()
        self.destroy_settings()

    def test_add_action_same_parent(self):
        """
        ActionList test - Tests the add_action method. The actions have the same parent, the same shortcuts and both
        have the QtCore.Qt.WindowShortcut shortcut context set.
        """
        # GIVEN: Two actions with the same shortcuts.
        parent = QtCore.QObject()
        action1 = QtWidgets.QAction(parent)
        action1.setObjectName('action1')
        action_with_same_shortcuts1 = QtWidgets.QAction(parent)
        action_with_same_shortcuts1.setObjectName(
            'action_with_same_shortcuts1')
        # Add default shortcuts to Settings class.
        default_shortcuts = {
            'shortcuts/action1': [
                QtGui.QKeySequence(QtCore.Qt.Key_A),
                QtGui.QKeySequence(QtCore.Qt.Key_B)
            ],
            'shortcuts/action_with_same_shortcuts1': [
                QtGui.QKeySequence(QtCore.Qt.Key_B),
                QtGui.QKeySequence(QtCore.Qt.Key_A)
            ]
        }
        Settings.extend_default_settings(default_shortcuts)

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

        # THEN: As both actions have the same shortcuts, they should be removed from one action.
        assert len(action1.shortcuts()
                   ) == 2, 'The action should have two shortcut assigned.'
        assert len(action_with_same_shortcuts1.shortcuts()
                   ) == 0, 'The action should not have a shortcut assigned.'

    def test_add_action_different_parent(self):
        """
        ActionList test - Tests the add_action method. The actions have the different parent, the same shortcuts and
        both have the QtCore.Qt.WindowShortcut shortcut context set.
        """
        # GIVEN: Two actions with the same shortcuts.
        parent = QtCore.QObject()
        action2 = QtWidgets.QAction(parent)
        action2.setObjectName('action2')
        second_parent = QtCore.QObject()
        action_with_same_shortcuts2 = QtWidgets.QAction(second_parent)
        action_with_same_shortcuts2.setObjectName(
            'action_with_same_shortcuts2')
        # Add default shortcuts to Settings class.
        default_shortcuts = {
            'shortcuts/action2': [
                QtGui.QKeySequence(QtCore.Qt.Key_C),
                QtGui.QKeySequence(QtCore.Qt.Key_D)
            ],
            'shortcuts/action_with_same_shortcuts2': [
                QtGui.QKeySequence(QtCore.Qt.Key_D),
                QtGui.QKeySequence(QtCore.Qt.Key_C)
            ]
        }
        Settings.extend_default_settings(default_shortcuts)

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

        # THEN: As both actions have the same shortcuts, they should be removed from one action.
        assert len(action2.shortcuts()
                   ) == 2, 'The action should have two shortcut assigned.'
        assert len(action_with_same_shortcuts2.shortcuts()
                   ) == 0, 'The action should not have a shortcut assigned.'

    def test_add_action_different_context(self):
        """
        ActionList test - Tests the add_action method. The actions have the different parent, the same shortcuts and
        both have the QtCore.Qt.WidgetShortcut shortcut context set.
        """
        # GIVEN: Two actions with the same shortcuts.
        parent = QtCore.QObject()
        action3 = QtWidgets.QAction(parent)
        action3.setObjectName('action3')
        action3.setShortcutContext(QtCore.Qt.WidgetShortcut)
        second_parent = QtCore.QObject()
        action_with_same_shortcuts3 = QtWidgets.QAction(second_parent)
        action_with_same_shortcuts3.setObjectName(
            'action_with_same_shortcuts3')
        action_with_same_shortcuts3.setShortcutContext(
            QtCore.Qt.WidgetShortcut)
        # Add default shortcuts to Settings class.
        default_shortcuts = {
            'shortcuts/action3': [
                QtGui.QKeySequence(QtCore.Qt.Key_E),
                QtGui.QKeySequence(QtCore.Qt.Key_F)
            ],
            'shortcuts/action_with_same_shortcuts3': [
                QtGui.QKeySequence(QtCore.Qt.Key_E),
                QtGui.QKeySequence(QtCore.Qt.Key_F)
            ]
        }
        Settings.extend_default_settings(default_shortcuts)

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

        # THEN: Both action should keep their shortcuts.
        assert len(action3.shortcuts()
                   ) == 2, 'The action should have two shortcut assigned.'
        assert len(action_with_same_shortcuts3.shortcuts()
                   ) == 2, 'The action should have two shortcuts assigned.'
Esempio n. 26
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()
Esempio n. 27
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()
Esempio n. 28
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])
Esempio n. 29
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']))
Esempio n. 30
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()