Ejemplo n.º 1
0
    def add_tools_menu_item(self, tools_menu):
        """
        Give the Songs plugin the opportunity to add items to the **Tools** menu.

        :param tools_menu: The actual **Tools** menu item, so that your actions can use it as their parent.
        """
        log.info('add tools menu')
        self.tools_reindex_item = create_action(
            tools_menu,
            'toolsReindexItem',
            text=translate('SongsPlugin', '&Re-index Songs'),
            icon=':/plugins/plugin_songs.png',
            statustip=translate(
                'SongsPlugin',
                'Re-index the songs database to improve searching and ordering.'
            ),
            visible=False,
            triggers=self.on_tools_reindex_item_triggered)
        tools_menu.addAction(self.tools_reindex_item)
        self.tools_find_duplicates = create_action(
            tools_menu,
            'toolsFindDuplicates',
            text=translate('SongsPlugin', 'Find &Duplicate Songs'),
            statustip=translate(
                'SongsPlugin',
                'Find and remove duplicate songs in the song database.'),
            visible=False,
            triggers=self.on_tools_find_duplicates_triggered,
            can_shortcuts=True)
        tools_menu.addAction(self.tools_find_duplicates)
Ejemplo n.º 2
0
    def create_action_test(self):
        """
        Test creating an action
        """
        # GIVEN: A dialog
        dialog = QtGui.QDialog()

        # WHEN: We create an action
        action = create_action(dialog, 'my_action')

        # THEN: We should get a QAction
        self.assertIsInstance(action, QtGui.QAction)
        self.assertEqual('my_action', action.objectName())

        # WHEN: We create an action with some properties
        action = create_action(dialog,
                               'my_action',
                               text='my text',
                               icon=':/wizards/wizard_firsttime.bmp',
                               tooltip='my tooltip',
                               statustip='my statustip')

        # THEN: These properties should be set
        self.assertIsInstance(action, QtGui.QAction)
        self.assertEqual('my text', action.text())
        self.assertIsInstance(action.icon(), QtGui.QIcon)
        self.assertEqual('my tooltip', action.toolTip())
        self.assertEqual('my statustip', action.statusTip())
Ejemplo n.º 3
0
    def add_tools_menu_item(self, tools_menu):
        """
        Give the Songs plugin the opportunity to add items to the **Tools** menu.

        :param tools_menu: The actual **Tools** menu item, so that your actions can use it as their parent.
        """
        log.info('add tools menu')
        self.tools_menu = tools_menu
        self.song_tools_menu = QtWidgets.QMenu(tools_menu)
        self.song_tools_menu.setObjectName('song_tools_menu')
        self.song_tools_menu.setTitle(translate('SongsPlugin', 'Songs'))
        self.tools_reindex_item = create_action(
            tools_menu, 'toolsReindexItem',
            text=translate('SongsPlugin', '&Re-index Songs'),
            icon=':/plugins/plugin_songs.png',
            statustip=translate('SongsPlugin', 'Re-index the songs database to improve searching and ordering.'),
            triggers=self.on_tools_reindex_item_triggered)
        self.tools_find_duplicates = create_action(
            tools_menu, 'toolsFindDuplicates',
            text=translate('SongsPlugin', 'Find &Duplicate Songs'),
            statustip=translate('SongsPlugin', 'Find and remove duplicate songs in the song database.'),
            triggers=self.on_tools_find_duplicates_triggered, can_shortcuts=True)
        self.tools_report_song_list = create_action(
            tools_menu, 'toolsSongListReport',
            text=translate('SongsPlugin', 'Song List Report'),
            statustip=translate('SongsPlugin', 'Produce a CSV file of all the songs in the database.'),
            triggers=self.on_tools_report_song_list_triggered)

        self.tools_menu.addAction(self.song_tools_menu.menuAction())
        self.song_tools_menu.addAction(self.tools_reindex_item)
        self.song_tools_menu.addAction(self.tools_find_duplicates)
        self.song_tools_menu.addAction(self.tools_report_song_list)

        self.song_tools_menu.menuAction().setVisible(False)
Ejemplo n.º 4
0
    def add_tools_menu_item(self, tools_menu):
        """
        Give the SongUsage plugin the opportunity to add items to the **Tools** menu.

        :param tools_menu: The actual **Tools** menu item, so that your actions can use it as their parent.
        """
        log.info('add tools menu')
        self.tools_menu = tools_menu
        self.song_usage_menu = QtWidgets.QMenu(tools_menu)
        self.song_usage_menu.setObjectName('song_usage_menu')
        self.song_usage_menu.setTitle(
            translate('SongUsagePlugin', '&Song Usage Tracking'))
        # SongUsage Delete
        self.song_usage_delete = create_action(
            tools_menu,
            'songUsageDelete',
            text=translate('SongUsagePlugin', '&Delete Tracking Data'),
            statustip=translate(
                'SongUsagePlugin',
                'Delete song usage data up to a specified date.'),
            triggers=self.on_song_usage_delete)
        # SongUsage Report
        self.song_usage_report = create_action(
            tools_menu,
            'songUsageReport',
            text=translate('SongUsagePlugin', '&Extract Tracking Data'),
            statustip=translate('SongUsagePlugin',
                                'Generate a report on song usage.'),
            triggers=self.on_song_usage_report)
        # SongUsage activation
        self.song_usage_status = create_action(
            tools_menu,
            'songUsageStatus',
            text=translate('SongUsagePlugin', 'Toggle Tracking'),
            statustip=translate('SongUsagePlugin',
                                'Toggle the tracking of song usage.'),
            checked=False,
            can_shortcuts=True,
            triggers=self.toggle_song_usage_state)
        # Add Menus together
        self.tools_menu.addAction(self.song_usage_menu.menuAction())
        self.song_usage_menu.addAction(self.song_usage_status)
        self.song_usage_menu.addSeparator()
        self.song_usage_menu.addAction(self.song_usage_report)
        self.song_usage_menu.addAction(self.song_usage_delete)
        self.song_usage_active_button = QtWidgets.QToolButton(
            self.main_window.status_bar)
        self.song_usage_active_button.setCheckable(True)
        self.song_usage_active_button.setAutoRaise(True)
        self.song_usage_active_button.setStatusTip(
            translate('SongUsagePlugin', 'Toggle the tracking of song usage.'))
        self.song_usage_active_button.setObjectName('song_usage_active_button')
        self.main_window.status_bar.insertPermanentWidget(
            1, self.song_usage_active_button)
        self.song_usage_active_button.hide()
        # Signals and slots
        self.song_usage_active_button.toggled.connect(
            self.toggle_song_usage_state)
        self.song_usage_menu.menuAction().setVisible(False)
Ejemplo n.º 5
0
    def test_create_action(self, mocked_log):
        """
        Test creating an action
        """
        # GIVEN: A dialog
        dialog = QtWidgets.QDialog()

        # WHEN: We create an action with some properties
        action = create_action(dialog,
                               'my_action',
                               text='my text',
                               icon=':/wizards/wizard_firsttime.bmp',
                               tooltip='my tooltip',
                               statustip='my statustip',
                               test=1)

        # THEN: These properties should be set
        assert isinstance(action, QtWidgets.QAction)
        assert action.objectName() == 'my_action'
        assert action.text() == 'my text'
        assert isinstance(action.icon(), QtGui.QIcon)
        assert action.toolTip() == 'my tooltip'
        assert action.statusTip() == 'my statustip'
        mocked_log.warning.assert_called_once_with(
            'Parameter test was not consumed in create_action().')
Ejemplo n.º 6
0
    def add_tools_menu_item(self, tools_menu):
        """
        Give the SongUsage plugin the opportunity to add items to the **Tools** menu.

        :param tools_menu: The actual **Tools** menu item, so that your actions can use it as their parent.
        """
        log.info('add tools menu')
        self.tools_menu = tools_menu
        self.song_usage_menu = QtGui.QMenu(tools_menu)
        self.song_usage_menu.setObjectName('song_usage_menu')
        self.song_usage_menu.setTitle(translate('SongUsagePlugin', '&Song Usage Tracking'))
        # SongUsage Delete
        self.song_usage_delete = create_action(
            tools_menu, 'songUsageDelete',
            text=translate('SongUsagePlugin', '&Delete Tracking Data'),
            statustip=translate('SongUsagePlugin', 'Delete song usage data up to a specified date.'),
            triggers=self.on_song_usage_delete)
        # SongUsage Report
        self.song_usage_report = create_action(
            tools_menu, 'songUsageReport',
            text=translate('SongUsagePlugin', '&Extract Tracking Data'),
            statustip=translate('SongUsagePlugin', 'Generate a report on song usage.'),
            triggers=self.on_song_usage_report)
        # SongUsage activation
        self.song_usage_status = create_action(
            tools_menu, 'songUsageStatus',
            text=translate('SongUsagePlugin', 'Toggle Tracking'),
            statustip=translate('SongUsagePlugin', 'Toggle the tracking of song usage.'), checked=False,
            can_shortcuts=True, triggers=self.toggle_song_usage_state)
        # Add Menus together
        self.tools_menu.addAction(self.song_usage_menu.menuAction())
        self.song_usage_menu.addAction(self.song_usage_status)
        self.song_usage_menu.addSeparator()
        self.song_usage_menu.addAction(self.song_usage_report)
        self.song_usage_menu.addAction(self.song_usage_delete)
        self.song_usage_active_button = QtGui.QToolButton(self.main_window.status_bar)
        self.song_usage_active_button.setCheckable(True)
        self.song_usage_active_button.setAutoRaise(True)
        self.song_usage_active_button.setStatusTip(translate('SongUsagePlugin', 'Toggle the tracking of song usage.'))
        self.song_usage_active_button.setObjectName('song_usage_active_button')
        self.main_window.status_bar.insertPermanentWidget(1, self.song_usage_active_button)
        self.song_usage_active_button.hide()
        # Signals and slots
        QtCore.QObject.connect(self.song_usage_status, QtCore.SIGNAL('visibilityChanged(bool)'),
                               self.song_usage_status.setChecked)
        self.song_usage_active_button.toggled.connect(self.toggle_song_usage_state)
        self.song_usage_menu.menuAction().setVisible(False)
Ejemplo n.º 7
0
    def test_create_action_on_mac_osx(self):
        """
        Test creating an action on OS X calls the correct method
        """
        # GIVEN: A dialog and a mocked out is_macosx() method to always return True
        with patch('openlp.core.lib.ui.is_macosx') as mocked_is_macosx, \
                patch('openlp.core.lib.ui.QtWidgets.QAction') as MockedQAction:
            mocked_is_macosx.return_value = True
            mocked_action = MagicMock()
            MockedQAction.return_value = mocked_action
            dialog = QtWidgets.QDialog()

            # WHEN: An action is created
            create_action(dialog, 'my_action')

            # THEN: setIconVisibleInMenu should be called
            mocked_action.setIconVisibleInMenu.assert_called_with(False)
Ejemplo n.º 8
0
    def create_action_on_mac_osx_test(self):
        """
        Test creating an action on OS X calls the correct method
        """
        # GIVEN: A dialog and a mocked out is_macosx() method to always return True
        with patch('openlp.core.lib.ui.is_macosx') as mocked_is_macosx, \
                patch('openlp.core.lib.ui.QtGui.QAction') as MockedQAction:
            mocked_is_macosx.return_value = True
            mocked_action = MagicMock()
            MockedQAction.return_value = mocked_action
            dialog = QtGui.QDialog()

            # WHEN: An action is created
            create_action(dialog, 'my_action')

            # THEN: setIconVisibleInMenu should be called
            mocked_action.setIconVisibleInMenu.assert_called_with(False)
Ejemplo n.º 9
0
    def add_tools_menu_item(self, tools_menu):
        """
        Give the Songs plugin the opportunity to add items to the **Tools** menu.

        :param tools_menu: The actual **Tools** menu item, so that your actions can use it as their parent.
        """
        log.info('add tools menu')
        self.tools_menu = tools_menu
        self.song_tools_menu = QtWidgets.QMenu(tools_menu)
        self.song_tools_menu.setObjectName('song_tools_menu')
        self.song_tools_menu.setTitle(translate('SongsPlugin', 'Songs'))
        self.tools_reindex_item = create_action(
            tools_menu,
            'toolsReindexItem',
            text=translate('SongsPlugin', '&Re-index Songs'),
            icon=UiIcons().music,
            statustip=translate(
                'SongsPlugin',
                'Re-index the songs database to improve searching and ordering.'
            ),
            triggers=self.on_tools_reindex_item_triggered)
        self.tools_find_duplicates = create_action(
            tools_menu,
            'toolsFindDuplicates',
            text=translate('SongsPlugin', 'Find &Duplicate Songs'),
            statustip=translate(
                'SongsPlugin',
                'Find and remove duplicate songs in the song database.'),
            triggers=self.on_tools_find_duplicates_triggered,
            can_shortcuts=True)
        self.tools_report_song_list = create_action(
            tools_menu,
            'toolsSongListReport',
            text=translate('SongsPlugin', 'Song List Report'),
            statustip=translate(
                'SongsPlugin',
                'Produce a CSV file of all the songs in the database.'),
            triggers=self.on_tools_report_song_list_triggered)

        self.tools_menu.addAction(self.song_tools_menu.menuAction())
        self.song_tools_menu.addAction(self.tools_reindex_item)
        self.song_tools_menu.addAction(self.tools_find_duplicates)
        self.song_tools_menu.addAction(self.tools_report_song_list)

        self.song_tools_menu.menuAction().setVisible(False)
Ejemplo n.º 10
0
    def test_create_action_not_on_mac_osx(self):
        """
        Test creating an action on something other than OS X doesn't call the method
        """
        # GIVEN: A dialog and a mocked out is_macosx() method to always return True
        with patch('openlp.core.lib.ui.is_macosx') as mocked_is_macosx, \
                patch('openlp.core.lib.ui.QtWidgets.QAction') as MockedQAction:
            mocked_is_macosx.return_value = False
            mocked_action = MagicMock()
            MockedQAction.return_value = mocked_action
            dialog = QtWidgets.QDialog()

            # WHEN: An action is created
            create_action(dialog, 'my_action')

            # THEN: setIconVisibleInMenu should not be called
            self.assertEqual(0, mocked_action.setIconVisibleInMenu.call_count,
                             'setIconVisibleInMenu should not have been called')
Ejemplo n.º 11
0
    def test_create_action_not_on_mac_osx(self):
        """
        Test creating an action on something other than OS X doesn't call the method
        """
        # GIVEN: A dialog and a mocked out is_macosx() method to always return True
        with patch('openlp.core.lib.ui.is_macosx') as mocked_is_macosx, \
                patch('openlp.core.lib.ui.QtWidgets.QAction') as MockedQAction:
            mocked_is_macosx.return_value = False
            mocked_action = MagicMock()
            MockedQAction.return_value = mocked_action
            dialog = QtWidgets.QDialog()

            # WHEN: An action is created
            create_action(dialog, 'my_action')

            # THEN: setIconVisibleInMenu should not be called
            self.assertEqual(0, mocked_action.setIconVisibleInMenu.call_count,
                             'setIconVisibleInMenu should not have been called')
Ejemplo n.º 12
0
    def add_export_menu_item(self, export_menu):
        """
        Add an export menu item

        :param export_menu: The menu to insert the menu item into.
        """
        self.export_bible_item = create_action(export_menu, 'exportBibleItem',
                                               text=translate('BiblesPlugin', '&Bible'), visible=False)
        export_menu.addAction(self.export_bible_item)
Ejemplo n.º 13
0
    def add_export_menu_item(self, export_menu):
        """
        Add an export menu item

        :param export_menu: The menu to insert the menu item into.
        """
        self.export_bible_item = create_action(export_menu, 'exportBibleItem',
                                               text=translate('BiblesPlugin', '&Bible'), visible=False)
        export_menu.addAction(self.export_bible_item)
Ejemplo n.º 14
0
    def add_import_menu_item(self, import_menu):
        """
        Add an import menu item

        :param import_menu: The menu to insert the menu item into.
        """
        self.import_bible_item = create_action(import_menu, 'importBibleItem',
                                               text=translate('BiblesPlugin', '&Bible'), visible=False,
                                               triggers=self.on_bible_import_click)
        import_menu.addAction(self.import_bible_item)
Ejemplo n.º 15
0
    def add_import_menu_item(self, import_menu):
        """
        Add an import menu item

        :param import_menu: The menu to insert the menu item into.
        """
        self.import_bible_item = create_action(import_menu, 'importBibleItem',
                                               text=translate('BiblesPlugin', '&Bible'), visible=False,
                                               triggers=self.on_bible_import_click)
        import_menu.addAction(self.import_bible_item)
Ejemplo n.º 16
0
    def add_import_menu_item(self, import_menu):
        """
        Give the Songs plugin the opportunity to add items to the **Import** menu.

        :param import_menu: The actual **Import** menu item, so that your actions can use it as their parent.
        """
        # Main song import menu item - will eventually be the only one
        self.song_import_item = create_action(
            import_menu, 'songImportItem',
            text=translate('SongsPlugin', '&Song'),
            tooltip=translate('SongsPlugin', 'Import songs using the import wizard.'),
            triggers=self.on_song_import_item_clicked)
        import_menu.addAction(self.song_import_item)
        self.import_songselect_item = create_action(
            import_menu, 'import_songselect_item', text=translate('SongsPlugin', 'CCLI SongSelect'),
            statustip=translate('SongsPlugin', 'Import songs from CCLI\'s SongSelect service.'),
            triggers=self.on_import_songselect_item_triggered
        )
        import_menu.addAction(self.import_songselect_item)
Ejemplo n.º 17
0
    def add_tools_menu_item(self, tools_menu):
        """
        Give the Songs plugin the opportunity to add items to the **Tools** menu.

        :param tools_menu: The actual **Tools** menu item, so that your actions can use it as their parent.
        """
        log.info('add tools menu')
        self.tools_reindex_item = create_action(
            tools_menu, 'toolsReindexItem',
            text=translate('SongsPlugin', '&Re-index Songs'),
            icon=':/plugins/plugin_songs.png',
            statustip=translate('SongsPlugin', 'Re-index the songs database to improve searching and ordering.'),
            visible=False, triggers=self.on_tools_reindex_item_triggered)
        tools_menu.addAction(self.tools_reindex_item)
        self.tools_find_duplicates = create_action(
            tools_menu, 'toolsFindDuplicates',
            text=translate('SongsPlugin', 'Find &Duplicate Songs'),
            statustip=translate('SongsPlugin', 'Find and remove duplicate songs in the song database.'),
            visible=False, triggers=self.on_tools_find_duplicates_triggered, can_shortcuts=True)
        tools_menu.addAction(self.tools_find_duplicates)
Ejemplo n.º 18
0
    def test_create_action_separator(self):
        """
        Test creating an action as separator
        """
        # GIVEN: A dialog
        dialog = QtWidgets.QDialog()

        # WHEN: We create an action as a separator
        action = create_action(dialog, 'my_action', separator=True)

        # THEN: The action should be a separator
        self.assertTrue(action.isSeparator(), 'The action should be a separator')
Ejemplo n.º 19
0
    def test_create_action_separator(self):
        """
        Test creating an action as separator
        """
        # GIVEN: A dialog
        dialog = QtWidgets.QDialog()

        # WHEN: We create an action as a separator
        action = create_action(dialog, 'my_action', separator=True)

        # THEN: The action should be a separator
        self.assertTrue(action.isSeparator(), 'The action should be a separator')
Ejemplo n.º 20
0
    def add_tools_menu_item(self, tools_menu):
        """
        Give the alerts plugin the opportunity to add items to the **Tools** menu.

        :param tools_menu: The actual **Tools** menu item, so that your actions can use it as their parent.
        """
        log.info('add tools menu')
        self.tools_alert_item = create_action(tools_menu, 'toolsAlertItem',
                                              text=translate('AlertsPlugin', '&Alert'),
                                              icon=':/plugins/plugin_alerts.png',
                                              statustip=translate('AlertsPlugin', 'Show an alert message.'),
                                              visible=False, can_shortcuts=True, triggers=self.on_alerts_trigger)
        self.main_window.tools_menu.addAction(self.tools_alert_item)
Ejemplo n.º 21
0
    def add_tools_menu_item(self, tools_menu):
        """
        Give the bible plugin the opportunity to add items to the **Tools** menu.

        :param tools_menu:  The actual **Tools** menu item, so that your actions can use it as their parent.
        """
        log.debug('add tools menu')
        self.tools_upgrade_item = create_action(
            tools_menu, 'toolsUpgradeItem',
            text=translate('BiblesPlugin', '&Upgrade older Bibles'),
            statustip=translate('BiblesPlugin', 'Upgrade the Bible databases to the latest format.'),
            visible=False, triggers=self.on_tools_upgrade_item_triggered)
        tools_menu.addAction(self.tools_upgrade_item)
Ejemplo n.º 22
0
    def add_tools_menu_item(self, tools_menu):
        """
        Give the alerts plugin the opportunity to add items to the **Tools** menu.

        ``tools_menu``
            The actual **Tools** menu item, so that your actions can use it as their parent.
        """
        log.info('add tools menu')
        self.tools_alert_item = create_action(tools_menu, 'toolsAlertItem',
            text=translate('AlertsPlugin', '&Alert'), icon=':/plugins/plugin_alerts.png',
            statustip=translate('AlertsPlugin', 'Show an alert message.'),
            visible=False, can_shortcuts=True, triggers=self.on_alerts_trigger)
        self.main_window.tools_menu.addAction(self.tools_alert_item)
Ejemplo n.º 23
0
    def add_export_menu_item(self, export_menu):
        """
        Give the Songs plugin the opportunity to add items to the **Export** menu.

        :param export_menu: The actual **Export** menu item, so that your actions can use it as their parent.
        """
        # Main song import menu item - will eventually be the only one
        self.song_export_item = create_action(
            export_menu, 'songExportItem',
            text=translate('SongsPlugin', '&Song'),
            tooltip=translate('SongsPlugin', 'Exports songs using the export wizard.'),
            triggers=self.on_song_export_item_clicked)
        export_menu.addAction(self.song_export_item)
Ejemplo n.º 24
0
 def accept(self):
     """
     Run when the dialog is OKed.
     """
     # It's the first row so must be Automatic
     if self.language_combo_box.currentIndex() == 0:
         LanguageManager.auto_language = True
         LanguageManager.set_language(False, False)
     else:
         LanguageManager.auto_language = False
         action = create_action(None, self.language_combo_box.currentText())
         LanguageManager.set_language(action, False)
     return QtWidgets.QDialog.accept(self)
Ejemplo n.º 25
0
 def accept(self):
     """
     Run when the dialog is OKed.
     """
     # It's the first row so must be Automatic
     if self.language_combo_box.currentIndex() == 0:
         LanguageManager.auto_language = True
         LanguageManager.set_language(False, False)
     else:
         LanguageManager.auto_language = False
         action = create_action(None, self.language_combo_box.currentText())
         LanguageManager.set_language(action, False)
     return QtGui.QDialog.accept(self)
Ejemplo n.º 26
0
    def test_create_checked_disabled_invisible_action(self):
        """
        Test that an invisible, disabled, checked action is created correctly
        """
        # GIVEN: A dialog
        dialog = QtWidgets.QDialog()

        # WHEN: We create an action with some properties
        action = create_action(dialog, 'my_action', checked=True, enabled=False, visible=False)

        # THEN: These properties should be set
        self.assertTrue(action.isChecked(), 'The action should be checked')
        self.assertFalse(action.isEnabled(), 'The action should be disabled')
        self.assertFalse(action.isVisible(), 'The action should be invisble')
Ejemplo n.º 27
0
    def test_create_checked_disabled_invisible_action(self):
        """
        Test that an invisible, disabled, checked action is created correctly
        """
        # GIVEN: A dialog
        dialog = QtWidgets.QDialog()

        # WHEN: We create an action with some properties
        action = create_action(dialog, 'my_action', checked=True, enabled=False, visible=False)

        # THEN: These properties should be set
        self.assertTrue(action.isChecked(), 'The action should be checked')
        self.assertFalse(action.isEnabled(), 'The action should be disabled')
        self.assertFalse(action.isVisible(), 'The action should be invisble')
Ejemplo n.º 28
0
    def add_export_menu_item(self, export_menu):
        """
        Give the Songs plugin the opportunity to add items to the **Export** menu.

        :param export_menu: The actual **Export** menu item, so that your actions can use it as their parent.
        """
        # Main song import menu item - will eventually be the only one
        self.song_export_item = create_action(
            export_menu,
            'songExportItem',
            text=translate('SongsPlugin', '&Song'),
            tooltip=translate('SongsPlugin',
                              'Exports songs using the export wizard.'),
            triggers=self.on_song_export_item_clicked)
        export_menu.addAction(self.song_export_item)
Ejemplo n.º 29
0
    def add_import_menu_item(self, import_menu):
        """
        Give the Songs plugin the opportunity to add items to the **Import** menu.

        :param import_menu: The actual **Import** menu item, so that your actions can use it as their parent.
        """
        # Main song import menu item - will eventually be the only one
        self.song_import_item = create_action(
            import_menu,
            'songImportItem',
            text=translate('SongsPlugin', '&Song'),
            tooltip=translate('SongsPlugin',
                              'Import songs using the import wizard.'),
            triggers=self.on_song_import_item_clicked)
        import_menu.addAction(self.song_import_item)
        self.import_songselect_item = create_action(
            import_menu,
            'import_songselect_item',
            text=translate('SongsPlugin', 'CCLI SongSelect'),
            statustip=translate(
                'SongsPlugin',
                'Import songs from CCLI\'s SongSelect service.'),
            triggers=self.on_import_songselect_item_triggered)
        import_menu.addAction(self.import_songselect_item)
Ejemplo n.º 30
0
    def addImportMenuItem(self, import_menu):
        """
        Give the Songs plugin the opportunity to add items to the
        **Import** menu.

        ``import_menu``
            The actual **Import** menu item, so that your actions can
            use it as their parent.
        """
        # Main song import menu item - will eventually be the only one
        self.songImportItem = create_action(import_menu, u'songImportItem',
            text=translate('SongsPlugin', '&Song'),
            tooltip=translate('SongsPlugin', 'Import songs using the import wizard.'),
            triggers=self.onSongImportItemClicked)
        import_menu.addAction(self.songImportItem)
Ejemplo n.º 31
0
    def test_create_action(self):
        """
        Test creating an action
        """
        # GIVEN: A dialog
        dialog = QtWidgets.QDialog()

        # WHEN: We create an action
        action = create_action(dialog, 'my_action')

        # THEN: We should get a QAction
        self.assertIsInstance(action, QtWidgets.QAction)
        self.assertEqual('my_action', action.objectName())

        # WHEN: We create an action with some properties
        action = create_action(dialog, 'my_action', text='my text', icon=':/wizards/wizard_firsttime.bmp',
                               tooltip='my tooltip', statustip='my statustip')

        # THEN: These properties should be set
        self.assertIsInstance(action, QtWidgets.QAction)
        self.assertEqual('my text', action.text())
        self.assertIsInstance(action.icon(), QtGui.QIcon)
        self.assertEqual('my tooltip', action.toolTip())
        self.assertEqual('my statustip', action.statusTip())
Ejemplo n.º 32
0
    def addToolsMenuItem(self, tools_menu):
        """
        Give the alerts plugin the opportunity to add items to the
        **Tools** menu.

        ``tools_menu``
            The actual **Tools** menu item, so that your actions can
            use it as their parent.
        """
        log.info(u'add tools menu')
        self.toolsReindexItem = create_action(tools_menu, u'toolsReindexItem',
            text=translate('SongsPlugin', '&Re-index Songs'),
            icon=u':/plugins/plugin_songs.png',
            statustip=translate('SongsPlugin', 'Re-index the songs database to improve searching and ordering.'),
            visible=False, triggers=self.onToolsReindexItemTriggered)
        tools_menu.addAction(self.toolsReindexItem)
Ejemplo n.º 33
0
    def add_import_menu_item(self, import_menu):
        """
        Add "PlanningCenter Service" to the **Import** menu.

        :param import_menu: The actual **Import** menu item, so that your actions can use it as their parent.
        """
        self.import_planningcenterelect_item = create_action(
            import_menu,
            'import_planningcenterelect_item',
            text=translate('planningcenterplugin', 'Planning Center Service'),
            statustip=translate(
                'planningcenterplugin',
                'Import Planning Center Service Plan from Planning Center Online.'
            ),
            triggers=self.on_import_planningcenterelect_item_triggered)
        import_menu.addAction(self.import_planningcenterelect_item)
Ejemplo n.º 34
0
 def contextMenuEvent(self, event):
     """
     Provide the context menu for the text edit region.
     """
     popup_menu = self.createStandardContextMenu()
     # Select the word under the cursor.
     cursor = self.textCursor()
     # only select text if not already selected
     if not cursor.hasSelection():
         cursor.select(QtGui.QTextCursor.WordUnderCursor)
     self.setTextCursor(cursor)
     # Add menu with available languages.
     if ENCHANT_AVAILABLE:
         lang_menu = QtWidgets.QMenu(
             translate('OpenLP.SpellTextEdit', 'Language:'))
         for lang in enchant.list_languages():
             action = create_action(lang_menu,
                                    lang,
                                    text=lang,
                                    checked=lang == self.dictionary.tag)
             lang_menu.addAction(action)
         popup_menu.insertSeparator(popup_menu.actions()[0])
         popup_menu.insertMenu(popup_menu.actions()[0], lang_menu)
         lang_menu.triggered.connect(self.set_language)
     # Check if the selected word is misspelled and offer spelling suggestions if it is.
     if ENCHANT_AVAILABLE and self.textCursor().hasSelection():
         text = self.textCursor().selectedText()
         if not self.dictionary.check(text):
             spell_menu = QtWidgets.QMenu(
                 translate('OpenLP.SpellTextEdit', 'Spelling Suggestions'))
             for word in self.dictionary.suggest(text):
                 action = SpellAction(word, spell_menu)
                 action.correct.connect(self.correct_word)
                 spell_menu.addAction(action)
             # Only add the spelling suggests to the menu if there are suggestions.
             if spell_menu.actions():
                 popup_menu.insertMenu(popup_menu.actions()[0], spell_menu)
     tag_menu = QtWidgets.QMenu(
         translate('OpenLP.SpellTextEdit', 'Formatting Tags'))
     if self.formatting_tags_allowed:
         for html in FormattingTags.get_html_tags():
             action = SpellAction(html['desc'], tag_menu)
             action.correct.connect(self.html_tag)
             tag_menu.addAction(action)
         popup_menu.insertSeparator(popup_menu.actions()[0])
         popup_menu.insertMenu(popup_menu.actions()[0], tag_menu)
     popup_menu.exec(event.globalPos())
Ejemplo n.º 35
0
    def add_tools_menu_item(self, tools_menu):
        """
        Give the bible plugin the opportunity to add items to the **Tools** menu.

        :param tools_menu:  The actual **Tools** menu item, so that your actions can use it as their parent.
        """
        log.debug('add tools menu')
        self.tools_upgrade_item = create_action(
            tools_menu,
            'toolsUpgradeItem',
            text=translate('BiblesPlugin', '&Upgrade older Bibles'),
            statustip=translate(
                'BiblesPlugin',
                'Upgrade the Bible databases to the latest format.'),
            visible=False,
            triggers=self.on_tools_upgrade_item_triggered)
        tools_menu.addAction(self.tools_upgrade_item)
Ejemplo n.º 36
0
 def contextMenuEvent(self, event):
     """
     Provide the context menu for the text edit region.
     """
     popupMenu = self.createStandardContextMenu()
     # Select the word under the cursor.
     cursor = self.textCursor()
     # only select text if not already selected
     if not cursor.hasSelection():
         cursor.select(QtGui.QTextCursor.WordUnderCursor)
     self.setTextCursor(cursor)
     # Add menu with available languages.
     if ENCHANT_AVAILABLE:
         lang_menu = QtGui.QMenu(
             translate('OpenLP.SpellTextEdit', 'Language:'))
         for lang in enchant.list_languages():
             action = create_action(lang_menu, lang, text=lang, checked=lang == self.dictionary.tag)
             lang_menu.addAction(action)
         popupMenu.insertSeparator(popupMenu.actions()[0])
         popupMenu.insertMenu(popupMenu.actions()[0], lang_menu)
         QtCore.QObject.connect(lang_menu, QtCore.SIGNAL(u'triggered(QAction*)'), self.setLanguage)
     # Check if the selected word is misspelled and offer spelling
     # suggestions if it is.
     if ENCHANT_AVAILABLE and self.textCursor().hasSelection():
         text = self.textCursor().selectedText()
         if not self.dictionary.check(text):
             spell_menu = QtGui.QMenu(translate('OpenLP.SpellTextEdit', 'Spelling Suggestions'))
             for word in self.dictionary.suggest(text):
                 action = SpellAction(word, spell_menu)
                 action.correct.connect(self.correctWord)
                 spell_menu.addAction(action)
             # Only add the spelling suggests to the menu if there are
             # suggestions.
             if spell_menu.actions():
                 popupMenu.insertMenu(popupMenu.actions()[0], spell_menu)
     tagMenu = QtGui.QMenu(translate('OpenLP.SpellTextEdit', 'Formatting Tags'))
     if self.formattingTagsAllowed:
         for html in FormattingTags.get_html_tags():
             action = SpellAction(html[u'desc'], tagMenu)
             action.correct.connect(self.htmlTag)
             tagMenu.addAction(action)
         popupMenu.insertSeparator(popupMenu.actions()[0])
         popupMenu.insertMenu(popupMenu.actions()[0], tagMenu)
     popupMenu.exec_(event.globalPos())
Ejemplo n.º 37
0
 def addExportMenuItem(self, export_menu):
     self.exportBibleItem = create_action(export_menu, u'exportBibleItem',
         text=translate('BiblesPlugin', '&Bible'),
         visible=False)
     export_menu.addAction(self.exportBibleItem)
Ejemplo n.º 38
0
 def addImportMenuItem(self, import_menu):
     self.importBibleItem = create_action(import_menu, u'importBibleItem',
         text=translate('BiblesPlugin', '&Bible'), visible=False,
         triggers=self.onBibleImportClick)
     import_menu.addAction(self.importBibleItem)
Ejemplo n.º 39
0
 def add_import_menu_item(self, import_menu):
     self.import_bible_item = create_action(import_menu, 'importBibleItem',
         text=translate('BiblesPlugin', '&Bible'), visible=False,
         triggers=self.on_bible_import_click)
     import_menu.addAction(self.import_bible_item)