~openlp-core/openlp/trunk

« back to all changes in this revision

Viewing changes to openlp/plugins/bibles/bibleplugin.py

  • Committer: Tim Bentley
  • Author(s): phill.ridout at gmail
  • Date: 2016-08-12 17:26:54 UTC
  • mfrom: (2685.1.15 more-bible-refactors)
  • Revision ID: tim.bentley@gmail.com-20160812172654-8rh9bq8nz61pauph
Some more bible refactors. Mainly focusing on xml parsing and the csv importer

lp:~phill-ridout/openlp/more-bible-refactors (revision 2699)
[SUCCESS] https://ci.openlp.io/job/Branch-01-Pull/1708/
[SUCCESS] https://ci.openlp.io/job/Branch-02-Functional-Tests/1619/
[SUCCESS] https://ci.openlp.io/job/Branch-03-Interface-Tests/1557/
[SUCCESS] https://ci.openlp.io/job/Branch-04a-Windows_Functional_Tests/1319/
[SUCCESS] https://ci.openlp.io/job/Branch-04b-Windows_Interface_Tests/909/
[SUCCESS] htt...

Show diffs side-by-side

added added

removed removed

Lines of Context:
22
22
 
23
23
import logging
24
24
 
25
 
from PyQt5 import QtWidgets
26
 
 
27
25
from openlp.core.common.actions import ActionList
28
26
from openlp.core.lib import Plugin, StringContent, build_icon, translate
29
27
from openlp.core.lib.ui import UiStrings, create_action
30
 
from openlp.plugins.bibles.forms import BibleUpgradeForm
31
28
from openlp.plugins.bibles.lib import BibleManager, BiblesTab, BibleMediaItem, LayoutStyle, DisplayStyle, \
32
29
    LanguageSelection
33
30
from openlp.plugins.bibles.lib.mediaitem import BibleSearch
90
87
        action_list.add_action(self.import_bible_item, UiStrings().Import)
91
88
        # Set to invisible until we can export bibles
92
89
        self.export_bible_item.setVisible(False)
93
 
        self.tools_upgrade_item.setVisible(bool(self.manager.old_bible_databases))
94
90
 
95
91
    def finalise(self):
96
92
        """
104
100
        self.import_bible_item.setVisible(False)
105
101
        self.export_bible_item.setVisible(False)
106
102
 
107
 
    def app_startup(self):
108
 
        """
109
 
        Perform tasks on application startup
110
 
        """
111
 
        super(BiblePlugin, self).app_startup()
112
 
        if self.manager.old_bible_databases:
113
 
            if QtWidgets.QMessageBox.information(
114
 
                    self.main_window, translate('OpenLP', 'Information'),
115
 
                    translate('OpenLP', 'Bible format has changed.\nYou have to upgrade your '
116
 
                                        'existing Bibles.\nShould OpenLP upgrade now?'),
117
 
                    QtWidgets.QMessageBox.StandardButtons(QtWidgets.QMessageBox.Yes | QtWidgets.QMessageBox.No)) == \
118
 
                    QtWidgets.QMessageBox.Yes:
119
 
                self.on_tools_upgrade_item_triggered()
120
 
 
121
103
    def add_import_menu_item(self, import_menu):
122
104
        """
123
105
        Add an import menu item
139
121
                                               text=translate('BiblesPlugin', '&Bible'), visible=False)
140
122
        export_menu.addAction(self.export_bible_item)
141
123
 
142
 
    def add_tools_menu_item(self, tools_menu):
143
 
        """
144
 
        Give the bible plugin the opportunity to add items to the **Tools** menu.
145
 
 
146
 
        :param tools_menu:  The actual **Tools** menu item, so that your actions can use it as their parent.
147
 
        """
148
 
        log.debug('add tools menu')
149
 
        self.tools_upgrade_item = create_action(
150
 
            tools_menu, 'toolsUpgradeItem',
151
 
            text=translate('BiblesPlugin', '&Upgrade older Bibles'),
152
 
            statustip=translate('BiblesPlugin', 'Upgrade the Bible databases to the latest format.'),
153
 
            visible=False, triggers=self.on_tools_upgrade_item_triggered)
154
 
        tools_menu.addAction(self.tools_upgrade_item)
155
 
 
156
 
    def on_tools_upgrade_item_triggered(self):
157
 
        """
158
 
        Upgrade older bible databases.
159
 
        """
160
 
        if not hasattr(self, 'upgrade_wizard'):
161
 
            self.upgrade_wizard = BibleUpgradeForm(self.main_window, self.manager, self)
162
 
        # If the import was not cancelled then reload.
163
 
        if self.upgrade_wizard.exec():
164
 
            self.media_item.reload_bibles()
165
 
 
166
124
    def on_bible_import_click(self):
167
125
        """
168
126
        Show the Bible Import wizard