25
from PyQt5 import QtWidgets
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, \
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))
95
91
def finalise(self):
104
100
self.import_bible_item.setVisible(False)
105
101
self.export_bible_item.setVisible(False)
107
def app_startup(self):
109
Perform tasks on application startup
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()
121
103
def add_import_menu_item(self, import_menu):
123
105
Add an import menu item
139
121
text=translate('BiblesPlugin', '&Bible'), visible=False)
140
122
export_menu.addAction(self.export_bible_item)
142
def add_tools_menu_item(self, tools_menu):
144
Give the bible plugin the opportunity to add items to the **Tools** menu.
146
:param tools_menu: The actual **Tools** menu item, so that your actions can use it as their parent.
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)
156
def on_tools_upgrade_item_triggered(self):
158
Upgrade older bible databases.
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()
166
124
def on_bible_import_click(self):
168
126
Show the Bible Import wizard