Plugin cleanups

bzr-revno: 2135
This commit is contained in:
Tim Bentley 2013-01-02 21:23:39 +00:00
commit 941b427fa6
45 changed files with 795 additions and 1491 deletions

View File

@ -1,5 +1,5 @@
# -*- coding: utf-8 -*-
# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4
# vim: autoindent shiftwidth=4 expandtab textwidth=120 tabstop=4 softtabstop=4
###############################################################################
# OpenLP - Open Source Lyrics Projection #

View File

@ -1,5 +1,5 @@
# -*- coding: utf-8 -*-
# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4
# vim: autoindent shiftwidth=4 expandtab textwidth=120 tabstop=4 softtabstop=4
###############################################################################
# OpenLP - Open Source Lyrics Projection #

View File

@ -1,5 +1,5 @@
# -*- coding: utf-8 -*-
# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4
# vim: autoindent shiftwidth=4 expandtab textwidth=120 tabstop=4 softtabstop=4
###############################################################################
# OpenLP - Open Source Lyrics Projection #
@ -31,8 +31,7 @@ import logging
from PyQt4 import QtCore
from openlp.core.lib import Plugin, StringContent, build_icon, translate, \
Settings
from openlp.core.lib import Plugin, StringContent, build_icon, translate, Settings
from openlp.core.lib.db import Manager
from openlp.core.lib.ui import create_action, UiStrings
from openlp.core.lib.theme import VerticalType
@ -118,8 +117,7 @@ class AlertsPlugin(Plugin):
log.info(u'Alerts Plugin loaded')
def __init__(self, plugin_helpers):
Plugin.__init__(self, u'alerts', plugin_helpers,
settings_tab_class=AlertsTab)
Plugin.__init__(self, u'alerts', plugin_helpers, settings_tab_class=AlertsTab)
self.weight = -3
self.iconPath = u':/plugins/plugin_alerts.png'
self.icon = build_icon(self.iconPath)
@ -138,8 +136,7 @@ class AlertsPlugin(Plugin):
"""
log.info(u'add tools menu')
self.toolsAlertItem = create_action(tools_menu, u'toolsAlertItem',
text=translate('AlertsPlugin', '&Alert'),
icon=u':/plugins/plugin_alerts.png',
text=translate('AlertsPlugin', '&Alert'), icon=u':/plugins/plugin_alerts.png',
statustip=translate('AlertsPlugin', 'Show an alert message.'),
visible=False, shortcuts=[u'F7'], triggers=self.onAlertsTrigger)
self.serviceManager.mainwindow.toolsMenu.addAction(self.toolsAlertItem)
@ -164,8 +161,7 @@ class AlertsPlugin(Plugin):
def toggleAlertsState(self):
self.alertsActive = not self.alertsActive
Settings().setValue(self.settingsSection + u'/active',
self.alertsActive)
Settings().setValue(self.settingsSection + u'/active', self.alertsActive)
def onAlertsTrigger(self):
self.alertForm.loadList()
@ -173,8 +169,7 @@ class AlertsPlugin(Plugin):
def about(self):
about_text = translate('AlertsPlugin', '<strong>Alerts Plugin</strong>'
'<br />The alert plugin controls the displaying of nursery alerts '
'on the display screen.')
'<br />The alert plugin controls the displaying of nursery alerts on the display screen.')
return about_text
def setPluginTextStrings(self):
@ -182,13 +177,11 @@ class AlertsPlugin(Plugin):
Called to define all translatable texts of the plugin
"""
## Name PluginList ##
self.textStrings[StringContent.Name] = {
u'singular': translate('AlertsPlugin', 'Alert', 'name singular'),
self.textStrings[StringContent.Name] = {u'singular': translate('AlertsPlugin', 'Alert', 'name singular'),
u'plural': translate('AlertsPlugin', 'Alerts', 'name plural')
}
## Name for MediaDockManager, SettingsManager ##
self.textStrings[StringContent.VisibleName] = {
u'title': translate('AlertsPlugin', 'Alerts', 'container title')
self.textStrings[StringContent.VisibleName] = {u'title': translate('AlertsPlugin', 'Alerts', 'container title')
}
def getDisplayJavaScript(self):
@ -202,8 +195,7 @@ class AlertsPlugin(Plugin):
Add CSS to the main display.
"""
align = VerticalType.Names[self.settingsTab.location]
return CSS % (align, self.settingsTab.font_face,
self.settingsTab.font_size, self.settingsTab.font_color,
return CSS % (align, self.settingsTab.font_face, self.settingsTab.font_size, self.settingsTab.font_color,
self.settingsTab.bg_color)
def getDisplayHtml(self):

View File

@ -1,5 +1,5 @@
# -*- coding: utf-8 -*-
# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4
# vim: autoindent shiftwidth=4 expandtab textwidth=120 tabstop=4 softtabstop=4
###############################################################################
# OpenLP - Open Source Lyrics Projection #

View File

@ -1,5 +1,5 @@
# -*- coding: utf-8 -*-
# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4
# vim: autoindent shiftwidth=4 expandtab textwidth=120 tabstop=4 softtabstop=4
###############################################################################
# OpenLP - Open Source Lyrics Projection #
@ -69,34 +69,24 @@ class Ui_AlertDialog(object):
self.saveButton.setIcon(build_icon(u':/general/general_save.png'))
self.saveButton.setObjectName(u'saveButton')
self.manageButtonLayout.addWidget(self.saveButton)
self.deleteButton = create_button(alertDialog, u'deleteButton',
role=u'delete', enabled=False,
self.deleteButton = create_button(alertDialog, u'deleteButton', role=u'delete', enabled=False,
click=alertDialog.onDeleteButtonClicked)
self.manageButtonLayout.addWidget(self.deleteButton)
self.manageButtonLayout.addStretch()
self.alertDialogLayout.addLayout(self.manageButtonLayout, 1, 1)
displayIcon = build_icon(u':/general/general_live.png')
self.displayButton = create_button(alertDialog, u'displayButton',
icon=displayIcon, enabled=False)
self.displayCloseButton = create_button(alertDialog,
u'displayCloseButton', icon=displayIcon, enabled=False)
self.buttonBox = create_button_box(alertDialog, u'buttonBox',
[u'close'], [self.displayButton, self.displayCloseButton])
self.displayButton = create_button(alertDialog, u'displayButton', icon=displayIcon, enabled=False)
self.displayCloseButton = create_button(alertDialog, u'displayCloseButton', icon=displayIcon, enabled=False)
self.buttonBox = create_button_box(alertDialog, u'buttonBox', [u'close'],
[self.displayButton, self.displayCloseButton])
self.alertDialogLayout.addWidget(self.buttonBox, 2, 0, 1, 2)
self.retranslateUi(alertDialog)
def retranslateUi(self, alertDialog):
alertDialog.setWindowTitle(
translate('AlertsPlugin.AlertForm', 'Alert Message'))
self.alertEntryLabel.setText(
translate('AlertsPlugin.AlertForm', 'Alert &text:'))
self.alertParameter.setText(
translate('AlertsPlugin.AlertForm', '&Parameter:'))
self.newButton.setText(
translate('AlertsPlugin.AlertForm', '&New'))
self.saveButton.setText(
translate('AlertsPlugin.AlertForm', '&Save'))
self.displayButton.setText(
translate('AlertsPlugin.AlertForm', 'Displ&ay'))
self.displayCloseButton.setText(
translate('AlertsPlugin.AlertForm', 'Display && Cl&ose'))
alertDialog.setWindowTitle(translate('AlertsPlugin.AlertForm', 'Alert Message'))
self.alertEntryLabel.setText(translate('AlertsPlugin.AlertForm', 'Alert &text:'))
self.alertParameter.setText(translate('AlertsPlugin.AlertForm', '&Parameter:'))
self.newButton.setText(translate('AlertsPlugin.AlertForm', '&New'))
self.saveButton.setText(translate('AlertsPlugin.AlertForm', '&Save'))
self.displayButton.setText(translate('AlertsPlugin.AlertForm', 'Displ&ay'))
self.displayCloseButton.setText(translate('AlertsPlugin.AlertForm', 'Display && Cl&ose'))

View File

@ -1,5 +1,5 @@
# -*- coding: utf-8 -*-
# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4
# vim: autoindent shiftwidth=4 expandtab textwidth=120 tabstop=4 softtabstop=4
###############################################################################
# OpenLP - Open Source Lyrics Projection #
@ -47,22 +47,14 @@ class AlertForm(QtGui.QDialog, Ui_AlertDialog):
self.item_id = None
QtGui.QDialog.__init__(self, plugin.formParent)
self.setupUi(self)
QtCore.QObject.connect(self.displayButton,
QtCore.SIGNAL(u'clicked()'), self.onDisplayClicked)
QtCore.QObject.connect(self.displayCloseButton,
QtCore.SIGNAL(u'clicked()'), self.onDisplayCloseClicked)
QtCore.QObject.connect(self.alertTextEdit,
QtCore.SIGNAL(u'textChanged(const QString&)'), self.onTextChanged)
QtCore.QObject.connect(self.newButton,
QtCore.SIGNAL(u'clicked()'), self.onNewClick)
QtCore.QObject.connect(self.saveButton,
QtCore.SIGNAL(u'clicked()'), self.onSaveClick)
QtCore.QObject.connect(self.alertListWidget,
QtCore.SIGNAL(u'doubleClicked(QModelIndex)'), self.onDoubleClick)
QtCore.QObject.connect(self.alertListWidget,
QtCore.SIGNAL(u'clicked(QModelIndex)'), self.onSingleClick)
QtCore.QObject.connect(self.alertListWidget,
QtCore.SIGNAL(u'currentRowChanged(int)'), self.onCurrentRowChanged)
QtCore.QObject.connect(self.displayButton, QtCore.SIGNAL(u'clicked()'), self.onDisplayClicked)
QtCore.QObject.connect(self.displayCloseButton, QtCore.SIGNAL(u'clicked()'), self.onDisplayCloseClicked)
QtCore.QObject.connect(self.alertTextEdit, QtCore.SIGNAL(u'textChanged(const QString&)'), self.onTextChanged)
QtCore.QObject.connect(self.newButton, QtCore.SIGNAL(u'clicked()'), self.onNewClick)
QtCore.QObject.connect(self.saveButton, QtCore.SIGNAL(u'clicked()'), self.onSaveClick)
QtCore.QObject.connect(self.alertListWidget, QtCore.SIGNAL(u'doubleClicked(QModelIndex)'), self.onDoubleClick)
QtCore.QObject.connect(self.alertListWidget, QtCore.SIGNAL(u'clicked(QModelIndex)'), self.onSingleClick)
QtCore.QObject.connect(self.alertListWidget, QtCore.SIGNAL(u'currentRowChanged(int)'), self.onCurrentRowChanged)
def exec_(self):
self.displayButton.setEnabled(False)
@ -75,16 +67,14 @@ class AlertForm(QtGui.QDialog, Ui_AlertDialog):
Loads the list with alerts.
"""
self.alertListWidget.clear()
alerts = self.manager.get_all_objects(AlertItem,
order_by_ref=AlertItem.text)
alerts = self.manager.get_all_objects(AlertItem, order_by_ref=AlertItem.text)
for alert in alerts:
item_name = QtGui.QListWidgetItem(alert.text)
item_name.setData(QtCore.Qt.UserRole, alert.id)
self.alertListWidget.addItem(item_name)
if alert.text == unicode(self.alertTextEdit.text()):
self.item_id = alert.id
self.alertListWidget.setCurrentRow(
self.alertListWidget.row(item_name))
self.alertListWidget.setCurrentRow(self.alertListWidget.row(item_name))
def onDisplayClicked(self):
self.triggerAlert(self.alertTextEdit.text())
@ -110,9 +100,8 @@ class AlertForm(QtGui.QDialog, Ui_AlertDialog):
if not self.alertTextEdit.text():
QtGui.QMessageBox.information(self,
translate('AlertsPlugin.AlertForm', 'New Alert'),
translate('AlertsPlugin.AlertForm', 'You haven\'t specified '
'any text for your alert. Please type in some text before '
'clicking New.'))
translate('AlertsPlugin.AlertForm', 'You haven\'t specified any text for your alert. \n'
'Please type in some text before clicking New.'))
else:
alert = AlertItem()
alert.text = self.alertTextEdit.text()
@ -180,24 +169,20 @@ class AlertForm(QtGui.QDialog, Ui_AlertDialog):
if not text:
return False
# We found '<>' in the alert text, but the ParameterEdit field is empty.
if text.find(u'<>') != -1 and not self.parameterEdit.text() and \
QtGui.QMessageBox.question(self,
if text.find(u'<>') != -1 and not self.parameterEdit.text() and QtGui.QMessageBox.question(self,
translate('AlertsPlugin.AlertForm', 'No Parameter Found'),
translate('AlertsPlugin.AlertForm', 'You have not entered a '
'parameter to be replaced.\nDo you want to continue anyway?'),
QtGui.QMessageBox.StandardButtons(QtGui.QMessageBox.No |
QtGui.QMessageBox.Yes)) == QtGui.QMessageBox.No:
translate('AlertsPlugin.AlertForm', 'You have not entered a parameter to be replaced.\n'
'Do you want to continue anyway?'),
QtGui.QMessageBox.StandardButtons(QtGui.QMessageBox.No | QtGui.QMessageBox.Yes)) == QtGui.QMessageBox.No:
self.parameterEdit.setFocus()
return False
# The ParameterEdit field is not empty, but we have not found '<>'
# in the alert text.
elif text.find(u'<>') == -1 and self.parameterEdit.text() and \
QtGui.QMessageBox.question(self,
elif text.find(u'<>') == -1 and self.parameterEdit.text() and QtGui.QMessageBox.question(self,
translate('AlertsPlugin.AlertForm', 'No Placeholder Found'),
translate('AlertsPlugin.AlertForm', 'The alert text does not'
' contain \'<>\'.\nDo you want to continue anyway?'),
QtGui.QMessageBox.StandardButtons(QtGui.QMessageBox.No |
QtGui.QMessageBox.Yes)) == QtGui.QMessageBox.No:
translate('AlertsPlugin.AlertForm', 'The alert text does not contain \'<>\'.\n'
'Do you want to continue anyway?'),
QtGui.QMessageBox.StandardButtons(QtGui.QMessageBox.No | QtGui.QMessageBox.Yes)) == QtGui.QMessageBox.No:
self.parameterEdit.setFocus()
return False
text = text.replace(u'<>', self.parameterEdit.text())

View File

@ -1,5 +1,5 @@
# -*- coding: utf-8 -*-
# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4
# vim: autoindent shiftwidth=4 expandtab textwidth=120 tabstop=4 softtabstop=4
###############################################################################
# OpenLP - Open Source Lyrics Projection #

View File

@ -1,5 +1,5 @@
# -*- coding: utf-8 -*-
# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4
# vim: autoindent shiftwidth=4 expandtab textwidth=120 tabstop=4 softtabstop=4
###############################################################################
# OpenLP - Open Source Lyrics Projection #
@ -46,10 +46,8 @@ class AlertsManager(QtCore.QObject):
self.screen = None
self.timer_id = 0
self.alertList = []
QtCore.QObject.connect(Receiver.get_receiver(),
QtCore.SIGNAL(u'live_display_active'), self.generateAlert)
QtCore.QObject.connect(Receiver.get_receiver(),
QtCore.SIGNAL(u'alerts_text'), self.onAlertText)
QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'live_display_active'), self.generateAlert)
QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'alerts_text'), self.onAlertText)
def onAlertText(self, message):
"""
@ -71,8 +69,7 @@ class AlertsManager(QtCore.QObject):
self.alertList.append(text)
if self.timer_id != 0:
Receiver.send_message(u'mainwindow_status_text',
translate('AlertsPlugin.AlertsManager',
'Alert message created and displayed.'))
translate('AlertsPlugin.AlertsManager', 'Alert message created and displayed.'))
return
Receiver.send_message(u'mainwindow_status_text', u'')
self.generateAlert()

View File

@ -1,5 +1,5 @@
# -*- coding: utf-8 -*-
# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4
# vim: autoindent shiftwidth=4 expandtab textwidth=120 tabstop=4 softtabstop=4
###############################################################################
# OpenLP - Open Source Lyrics Projection #
@ -78,8 +78,7 @@ class AlertsTab(SettingsTab):
self.timeoutSpinBox.setMaximum(180)
self.timeoutSpinBox.setObjectName(u'timeoutSpinBox')
self.fontLayout.addRow(self.timeoutLabel, self.timeoutSpinBox)
self.verticalLabel, self.verticalComboBox = \
create_valign_selection_widgets(self.fontGroupBox)
self.verticalLabel, self.verticalComboBox = create_valign_selection_widgets(self.fontGroupBox)
self.verticalLabel.setObjectName(u'verticalLabel')
self.verticalComboBox.setObjectName(u'verticalComboBox')
self.fontLayout.addRow(self.verticalLabel, self.verticalComboBox)
@ -95,54 +94,40 @@ class AlertsTab(SettingsTab):
self.rightLayout.addWidget(self.previewGroupBox)
self.rightLayout.addStretch()
# Signals and slots
QtCore.QObject.connect(self.backgroundColorButton,
QtCore.SIGNAL(u'clicked()'), self.onBackgroundColorButtonClicked)
QtCore.QObject.connect(self.fontColorButton,
QtCore.SIGNAL(u'clicked()'), self.onFontColorButtonClicked)
QtCore.QObject.connect(self.fontComboBox,
QtCore.SIGNAL(u'activated(int)'), self.onFontComboBoxClicked)
QtCore.QObject.connect(self.timeoutSpinBox,
QtCore.SIGNAL(u'valueChanged(int)'), self.onTimeoutSpinBoxChanged)
QtCore.QObject.connect(self.fontSizeSpinBox,
QtCore.SIGNAL(u'valueChanged(int)'), self.onFontSizeSpinBoxChanged)
QtCore.QObject.connect(self.backgroundColorButton, QtCore.SIGNAL(u'clicked()'),
self.onBackgroundColorButtonClicked)
QtCore.QObject.connect(self.fontColorButton, QtCore.SIGNAL(u'clicked()'), self.onFontColorButtonClicked)
QtCore.QObject.connect(self.fontComboBox, QtCore.SIGNAL(u'activated(int)'), self.onFontComboBoxClicked)
QtCore.QObject.connect(self.timeoutSpinBox, QtCore.SIGNAL(u'valueChanged(int)'), self.onTimeoutSpinBoxChanged)
QtCore.QObject.connect(self.fontSizeSpinBox, QtCore.SIGNAL(u'valueChanged(int)'), self.onFontSizeSpinBoxChanged)
def retranslateUi(self):
self.fontGroupBox.setTitle(
translate('AlertsPlugin.AlertsTab', 'Font'))
self.fontLabel.setText(
translate('AlertsPlugin.AlertsTab', 'Font name:'))
self.fontColorLabel.setText(
translate('AlertsPlugin.AlertsTab', 'Font color:'))
self.backgroundColorLabel.setText(
translate('AlertsPlugin.AlertsTab', 'Background color:'))
self.fontSizeLabel.setText(
translate('AlertsPlugin.AlertsTab', 'Font size:'))
self.fontGroupBox.setTitle(translate('AlertsPlugin.AlertsTab', 'Font'))
self.fontLabel.setText(translate('AlertsPlugin.AlertsTab', 'Font name:'))
self.fontColorLabel.setText(translate('AlertsPlugin.AlertsTab', 'Font color:'))
self.backgroundColorLabel.setText(translate('AlertsPlugin.AlertsTab', 'Background color:'))
self.fontSizeLabel.setText(translate('AlertsPlugin.AlertsTab', 'Font size:'))
self.fontSizeSpinBox.setSuffix(UiStrings().FontSizePtUnit)
self.timeoutLabel.setText(
translate('AlertsPlugin.AlertsTab', 'Alert timeout:'))
self.timeoutLabel.setText(translate('AlertsPlugin.AlertsTab', 'Alert timeout:'))
self.timeoutSpinBox.setSuffix(UiStrings().Seconds)
self.previewGroupBox.setTitle(UiStrings().Preview)
self.fontPreview.setText(UiStrings().OLPV2x)
def onBackgroundColorButtonClicked(self):
new_color = QtGui.QColorDialog.getColor(
QtGui.QColor(self.bg_color), self)
new_color = QtGui.QColorDialog.getColor(QtGui.QColor(self.bg_color), self)
if new_color.isValid():
self.bg_color = new_color.name()
self.backgroundColorButton.setStyleSheet(
u'background-color: %s' % self.bg_color)
self.backgroundColorButton.setStyleSheet(u'background-color: %s' % self.bg_color)
self.updateDisplay()
def onFontComboBoxClicked(self):
self.updateDisplay()
def onFontColorButtonClicked(self):
new_color = QtGui.QColorDialog.getColor(
QtGui.QColor(self.font_color), self)
new_color = QtGui.QColorDialog.getColor(QtGui.QColor(self.font_color), self)
if new_color.isValid():
self.font_color = new_color.name()
self.fontColorButton.setStyleSheet(
u'background-color: %s' % self.font_color)
self.fontColorButton.setStyleSheet(u'background-color: %s' % self.font_color)
self.updateDisplay()
def onTimeoutSpinBoxChanged(self):
@ -165,10 +150,8 @@ class AlertsTab(SettingsTab):
settings.endGroup()
self.fontSizeSpinBox.setValue(self.font_size)
self.timeoutSpinBox.setValue(self.timeout)
self.fontColorButton.setStyleSheet(
u'background-color: %s' % self.font_color)
self.backgroundColorButton.setStyleSheet(
u'background-color: %s' % self.bg_color)
self.fontColorButton.setStyleSheet(u'background-color: %s' % self.font_color)
self.backgroundColorButton.setStyleSheet(u'background-color: %s' % self.bg_color)
self.verticalComboBox.setCurrentIndex(self.location)
font = QtGui.QFont()
font.setFamily(self.font_face)
@ -180,8 +163,7 @@ class AlertsTab(SettingsTab):
settings = Settings()
settings.beginGroup(self.settingsSection)
# Check value has changed as no event handles this field
if settings.value(u'location', 1) != \
self.verticalComboBox.currentIndex():
if settings.value(u'location', 1) != self.verticalComboBox.currentIndex():
self.changed = True
settings.setValue(u'background color', self.bg_color)
settings.setValue(u'font color', self.font_color)
@ -202,7 +184,6 @@ class AlertsTab(SettingsTab):
font.setBold(True)
font.setPointSize(self.font_size)
self.fontPreview.setFont(font)
self.fontPreview.setStyleSheet(u'background-color: %s; color: %s' %
(self.bg_color, self.font_color))
self.fontPreview.setStyleSheet(u'background-color: %s; color: %s' % (self.bg_color, self.font_color))
self.changed = True

View File

@ -1,5 +1,5 @@
# -*- coding: utf-8 -*-
# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4
# vim: autoindent shiftwidth=4 expandtab textwidth=120 tabstop=4 softtabstop=4
###############################################################################
# OpenLP - Open Source Lyrics Projection #
@ -31,8 +31,7 @@ import logging
from PyQt4 import QtCore, QtGui
from openlp.core.lib import Plugin, StringContent, build_icon, translate, \
Settings
from openlp.core.lib import Plugin, StringContent, build_icon, translate, Settings
from openlp.core.lib.ui import create_action, UiStrings
from openlp.core.utils.actions import ActionList
from openlp.plugins.bibles.lib import BibleManager, BiblesTab, BibleMediaItem
@ -44,8 +43,7 @@ class BiblePlugin(Plugin):
log.info(u'Bible Plugin loaded')
def __init__(self, plugin_helpers):
Plugin.__init__(self, u'bibles', plugin_helpers,
BibleMediaItem, BiblesTab)
Plugin.__init__(self, u'bibles', plugin_helpers, BibleMediaItem, BiblesTab)
self.weight = -9
self.iconPath = u':/plugins/plugin_bibles.png'
self.icon = build_icon(self.iconPath)
@ -84,17 +82,16 @@ class BiblePlugin(Plugin):
"""
if self.manager.old_bible_databases:
if QtGui.QMessageBox.information(self.formParent,
translate('OpenLP', 'Information'), translate('OpenLP',
'Bible format has changed.\nYou have to upgrade your '
'existing Bibles.\nShould OpenLP upgrade now?'),
QtGui.QMessageBox.StandardButtons(QtGui.QMessageBox.Yes |
QtGui.QMessageBox.No)) == QtGui.QMessageBox.Yes:
translate('OpenLP', 'Information'),
translate('OpenLP', 'Bible format has changed.\nYou have to upgrade your existing Bibles.\n'
'Should OpenLP upgrade now?'),
QtGui.QMessageBox.StandardButtons(QtGui.QMessageBox.Yes | QtGui.QMessageBox.No)) == \
QtGui.QMessageBox.Yes:
self.onToolsUpgradeItemTriggered()
settings = Settings()
settings.beginGroup(self.settingsSection)
if settings.contains(u'bookname language'):
settings.setValue(u'book name language', settings.value(
u'bookname language', 0))
settings.setValue(u'book name language', settings.value(u'bookname language', 0))
settings.remove(u'bookname language')
settings.endGroup()
@ -122,8 +119,7 @@ class BiblePlugin(Plugin):
log.debug(u'add tools menu')
self.toolsUpgradeItem = create_action(tools_menu, u'toolsUpgradeItem',
text=translate('BiblesPlugin', '&Upgrade older Bibles'),
statustip=translate('BiblesPlugin',
'Upgrade the Bible databases to the latest format.'),
statustip=translate('BiblesPlugin', 'Upgrade the Bible databases to the latest format.'),
visible=False, triggers=self.onToolsUpgradeItemTriggered)
tools_menu.addAction(self.toolsUpgradeItem)
@ -132,8 +128,7 @@ class BiblePlugin(Plugin):
Upgrade older bible databases.
"""
if not hasattr(self, u'upgrade_wizard'):
self.upgrade_wizard = BibleUpgradeForm(self.formParent,
self.manager, self)
self.upgrade_wizard = BibleUpgradeForm(self.formParent, self.manager, self)
# If the import was not cancelled then reload.
if self.upgrade_wizard.exec_():
self.mediaItem.reloadBibles()
@ -194,7 +189,6 @@ class BiblePlugin(Plugin):
u'preview': translate('BiblesPlugin',
'Preview the selected Bible.'),
u'live': translate('BiblesPlugin', 'Send the selected Bible live.'),
u'service': translate('BiblesPlugin',
'Add the selected Bible to the service.')
u'service': translate('BiblesPlugin', 'Add the selected Bible to the service.')
}
self.setPluginUiTextStrings(tooltips)

View File

@ -1,5 +1,5 @@
# -*- coding: utf-8 -*-
# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4
# vim: autoindent shiftwidth=4 expandtab textwidth=120 tabstop=4 softtabstop=4
###############################################################################
# OpenLP - Open Source Lyrics Projection #

View File

@ -1,5 +1,5 @@
# -*- coding: utf-8 -*-
# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4
# vim: autoindent shiftwidth=4 expandtab textwidth=120 tabstop=4 softtabstop=4
###############################################################################
# OpenLP - Open Source Lyrics Projection #
@ -78,16 +78,14 @@ class BibleImportForm(OpenLPWizard):
"""
self.manager = manager
self.web_bible_list = {}
OpenLPWizard.__init__(self, parent, bibleplugin, u'bibleImportWizard',
u':/wizards/wizard_importbible.bmp')
OpenLPWizard.__init__(self, parent, bibleplugin, u'bibleImportWizard', u':/wizards/wizard_importbible.bmp')
def setupUi(self, image):
"""
Set up the UI for the bible wizard.
"""
OpenLPWizard.setupUi(self, image)
QtCore.QObject.connect(self.formatComboBox,
QtCore.SIGNAL(u'currentIndexChanged(int)'),
QtCore.QObject.connect(self.formatComboBox,QtCore.SIGNAL(u'currentIndexChanged(int)'),
self.onCurrentIndexChanged)
def onCurrentIndexChanged(self, index):
@ -119,23 +117,17 @@ class BibleImportForm(OpenLPWizard):
"""
Set up the signals used in the bible importer.
"""
QtCore.QObject.connect(self.webSourceComboBox,
QtCore.SIGNAL(u'currentIndexChanged(int)'),
QtCore.QObject.connect(self.webSourceComboBox, QtCore.SIGNAL(u'currentIndexChanged(int)'),
self.onWebSourceComboBoxIndexChanged)
QtCore.QObject.connect(self.osisBrowseButton,
QtCore.SIGNAL(u'clicked()'),
QtCore.QObject.connect(self.osisBrowseButton, QtCore.SIGNAL(u'clicked()'),
self.onOsisBrowseButtonClicked)
QtCore.QObject.connect(self.csvBooksButton,
QtCore.SIGNAL(u'clicked()'),
QtCore.QObject.connect(self.csvBooksButton, QtCore.SIGNAL(u'clicked()'),
self.onCsvBooksBrowseButtonClicked)
QtCore.QObject.connect(self.csvVersesButton,
QtCore.SIGNAL(u'clicked()'),
QtCore.QObject.connect(self.csvVersesButton, QtCore.SIGNAL(u'clicked()'),
self.onCsvVersesBrowseButtonClicked)
QtCore.QObject.connect(self.openSongBrowseButton,
QtCore.SIGNAL(u'clicked()'),
QtCore.QObject.connect(self.openSongBrowseButton, QtCore.SIGNAL(u'clicked()'),
self.onOpenSongBrowseButtonClicked)
QtCore.QObject.connect(self.openlp1BrowseButton,
QtCore.SIGNAL(u'clicked()'),
QtCore.QObject.connect(self.openlp1BrowseButton, QtCore.SIGNAL(u'clicked()'),
self.onOpenlp1BrowseButtonClicked)
def addCustomPages(self):
@ -155,8 +147,7 @@ class BibleImportForm(OpenLPWizard):
self.formatComboBox.addItems([u'', u'', u'', u'', u''])
self.formatComboBox.setObjectName(u'FormatComboBox')
self.formatLayout.addRow(self.formatLabel, self.formatComboBox)
self.spacer = QtGui.QSpacerItem(10, 0, QtGui.QSizePolicy.Fixed,
QtGui.QSizePolicy.Minimum)
self.spacer = QtGui.QSpacerItem(10, 0, QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Minimum)
self.formatLayout.setItem(1, QtGui.QFormLayout.LabelRole, self.spacer)
self.selectPageLayout.addLayout(self.formatLayout)
self.selectStack = QtGui.QStackedLayout()
@ -227,8 +218,7 @@ class BibleImportForm(OpenLPWizard):
self.openSongBrowseButton.setIcon(self.openIcon)
self.openSongBrowseButton.setObjectName(u'OpenSongBrowseButton')
self.openSongFileLayout.addWidget(self.openSongBrowseButton)
self.openSongLayout.addRow(self.openSongFileLabel,
self.openSongFileLayout)
self.openSongLayout.addRow(self.openSongFileLabel, self.openSongFileLayout)
self.openSongLayout.setItem(1, QtGui.QFormLayout.LabelRole, self.spacer)
self.selectStack.addWidget(self.openSongWidget)
self.webTabWidget = QtGui.QTabWidget(self.selectPage)
@ -239,23 +229,18 @@ class BibleImportForm(OpenLPWizard):
self.webBibleLayout.setObjectName(u'WebBibleLayout')
self.webSourceLabel = QtGui.QLabel(self.webBibleTab)
self.webSourceLabel.setObjectName(u'WebSourceLabel')
self.webBibleLayout.setWidget(0, QtGui.QFormLayout.LabelRole,
self.webSourceLabel)
self.webBibleLayout.setWidget(0, QtGui.QFormLayout.LabelRole, self.webSourceLabel)
self.webSourceComboBox = QtGui.QComboBox(self.webBibleTab)
self.webSourceComboBox.setObjectName(u'WebSourceComboBox')
self.webSourceComboBox.addItems([u'', u'', u''])
self.webBibleLayout.setWidget(0, QtGui.QFormLayout.FieldRole,
self.webSourceComboBox)
self.webBibleLayout.setWidget(0, QtGui.QFormLayout.FieldRole, self.webSourceComboBox)
self.webTranslationLabel = QtGui.QLabel(self.webBibleTab)
self.webTranslationLabel.setObjectName(u'webTranslationLabel')
self.webBibleLayout.setWidget(1, QtGui.QFormLayout.LabelRole,
self.webTranslationLabel)
self.webBibleLayout.setWidget(1, QtGui.QFormLayout.LabelRole, self.webTranslationLabel)
self.webTranslationComboBox = QtGui.QComboBox(self.webBibleTab)
self.webTranslationComboBox.setSizeAdjustPolicy(
QtGui.QComboBox.AdjustToContents)
self.webTranslationComboBox.setSizeAdjustPolicy(QtGui.QComboBox.AdjustToContents)
self.webTranslationComboBox.setObjectName(u'WebTranslationComboBox')
self.webBibleLayout.setWidget(1, QtGui.QFormLayout.FieldRole,
self.webTranslationComboBox)
self.webBibleLayout.setWidget(1, QtGui.QFormLayout.FieldRole, self.webTranslationComboBox)
self.webTabWidget.addTab(self.webBibleTab, u'')
self.webProxyTab = QtGui.QWidget()
self.webProxyTab.setObjectName(u'WebProxyTab')
@ -263,28 +248,22 @@ class BibleImportForm(OpenLPWizard):
self.webProxyLayout.setObjectName(u'WebProxyLayout')
self.webServerLabel = QtGui.QLabel(self.webProxyTab)
self.webServerLabel.setObjectName(u'WebServerLabel')
self.webProxyLayout.setWidget(0, QtGui.QFormLayout.LabelRole,
self.webServerLabel)
self.webProxyLayout.setWidget(0, QtGui.QFormLayout.LabelRole, self.webServerLabel)
self.webServerEdit = QtGui.QLineEdit(self.webProxyTab)
self.webServerEdit.setObjectName(u'WebServerEdit')
self.webProxyLayout.setWidget(0, QtGui.QFormLayout.FieldRole,
self.webServerEdit)
self.webProxyLayout.setWidget(0, QtGui.QFormLayout.FieldRole, self.webServerEdit)
self.webUserLabel = QtGui.QLabel(self.webProxyTab)
self.webUserLabel.setObjectName(u'WebUserLabel')
self.webProxyLayout.setWidget(1, QtGui.QFormLayout.LabelRole,
self.webUserLabel)
self.webProxyLayout.setWidget(1, QtGui.QFormLayout.LabelRole, self.webUserLabel)
self.webUserEdit = QtGui.QLineEdit(self.webProxyTab)
self.webUserEdit.setObjectName(u'WebUserEdit')
self.webProxyLayout.setWidget(1, QtGui.QFormLayout.FieldRole,
self.webUserEdit)
self.webProxyLayout.setWidget(1, QtGui.QFormLayout.FieldRole, self.webUserEdit)
self.webPasswordLabel = QtGui.QLabel(self.webProxyTab)
self.webPasswordLabel.setObjectName(u'WebPasswordLabel')
self.webProxyLayout.setWidget(2, QtGui.QFormLayout.LabelRole,
self.webPasswordLabel)
self.webProxyLayout.setWidget(2, QtGui.QFormLayout.LabelRole, self.webPasswordLabel)
self.webPasswordEdit = QtGui.QLineEdit(self.webProxyTab)
self.webPasswordEdit.setObjectName(u'WebPasswordEdit')
self.webProxyLayout.setWidget(2, QtGui.QFormLayout.FieldRole,
self.webPasswordEdit)
self.webProxyLayout.setWidget(2, QtGui.QFormLayout.FieldRole, self.webPasswordEdit)
self.webTabWidget.addTab(self.webProxyTab, u'')
self.selectStack.addWidget(self.webTabWidget)
self.openlp1Widget = QtGui.QWidget(self.selectPage)
@ -319,36 +298,30 @@ class BibleImportForm(OpenLPWizard):
self.licenseDetailsLayout.setObjectName(u'LicenseDetailsLayout')
self.versionNameLabel = QtGui.QLabel(self.licenseDetailsPage)
self.versionNameLabel.setObjectName(u'VersionNameLabel')
self.licenseDetailsLayout.setWidget(0, QtGui.QFormLayout.LabelRole,
self.versionNameLabel)
self.licenseDetailsLayout.setWidget(0, QtGui.QFormLayout.LabelRole, self.versionNameLabel)
self.versionNameEdit = QtGui.QLineEdit(self.licenseDetailsPage)
self.versionNameEdit.setObjectName(u'VersionNameEdit')
self.licenseDetailsLayout.setWidget(0, QtGui.QFormLayout.FieldRole,
self.versionNameEdit)
self.licenseDetailsLayout.setWidget(0, QtGui.QFormLayout.FieldRole, self.versionNameEdit)
self.copyrightLabel = QtGui.QLabel(self.licenseDetailsPage)
self.copyrightLabel.setObjectName(u'CopyrightLabel')
self.licenseDetailsLayout.setWidget(1, QtGui.QFormLayout.LabelRole,
self.copyrightLabel)
self.licenseDetailsLayout.setWidget(1, QtGui.QFormLayout.LabelRole, self.copyrightLabel)
self.copyrightEdit = QtGui.QLineEdit(self.licenseDetailsPage)
self.copyrightEdit.setObjectName(u'CopyrightEdit')
self.licenseDetailsLayout.setWidget(1, QtGui.QFormLayout.FieldRole,
self.copyrightEdit)
self.licenseDetailsLayout.setWidget(1, QtGui.QFormLayout.FieldRole, self.copyrightEdit)
self.permissionsLabel = QtGui.QLabel(self.licenseDetailsPage)
self.permissionsLabel.setObjectName(u'PermissionsLabel')
self.licenseDetailsLayout.setWidget(2, QtGui.QFormLayout.LabelRole,
self.permissionsLabel)
self.permissionsEdit = QtGui.QLineEdit(self.licenseDetailsPage)
self.permissionsEdit.setObjectName(u'PermissionsEdit')
self.licenseDetailsLayout.setWidget(2, QtGui.QFormLayout.FieldRole,
self.permissionsEdit)
self.licenseDetailsLayout.setWidget(2, QtGui.QFormLayout.FieldRole, self.permissionsEdit)
self.addPage(self.licenseDetailsPage)
def retranslateUi(self):
"""
Allow for localisation of the bible import wizard.
"""
self.setWindowTitle(
translate('BiblesPlugin.ImportWizardForm', 'Bible Import Wizard'))
self.setWindowTitle(translate('BiblesPlugin.ImportWizardForm', 'Bible Import Wizard'))
self.titleLabel.setText(WizardStrings.HeaderStyle %
translate('OpenLP.Ui', 'Welcome to the Bible Import Wizard'))
self.informationLabel.setText(
@ -365,53 +338,36 @@ class BibleImportForm(OpenLPWizard):
self.formatComboBox.setItemText(BibleFormat.WebDownload,
translate('BiblesPlugin.ImportWizardForm', 'Web Download'))
self.formatComboBox.setItemText(BibleFormat.OpenLP1, UiStrings().OLPV1)
self.openlp1FileLabel.setText(
translate('BiblesPlugin.ImportWizardForm', 'Bible file:'))
self.osisFileLabel.setText(
translate('BiblesPlugin.ImportWizardForm', 'Bible file:'))
self.csvBooksLabel.setText(
translate('BiblesPlugin.ImportWizardForm', 'Books file:'))
self.csvVersesLabel.setText(
translate('BiblesPlugin.ImportWizardForm', 'Verses file:'))
self.openSongFileLabel.setText(
translate('BiblesPlugin.ImportWizardForm', 'Bible file:'))
self.webSourceLabel.setText(
translate('BiblesPlugin.ImportWizardForm', 'Location:'))
self.openlp1FileLabel.setText(translate('BiblesPlugin.ImportWizardForm', 'Bible file:'))
self.osisFileLabel.setText(translate('BiblesPlugin.ImportWizardForm', 'Bible file:'))
self.csvBooksLabel.setText(translate('BiblesPlugin.ImportWizardForm', 'Books file:'))
self.csvVersesLabel.setText(translate('BiblesPlugin.ImportWizardForm', 'Verses file:'))
self.openSongFileLabel.setText(translate('BiblesPlugin.ImportWizardForm', 'Bible file:'))
self.webSourceLabel.setText(translate('BiblesPlugin.ImportWizardForm', 'Location:'))
self.webSourceComboBox.setItemText(WebDownload.Crosswalk,
translate('BiblesPlugin.ImportWizardForm', 'Crosswalk'))
self.webSourceComboBox.setItemText(WebDownload.BibleGateway,
translate('BiblesPlugin.ImportWizardForm', 'BibleGateway'))
self.webSourceComboBox.setItemText(WebDownload.Bibleserver,
translate('BiblesPlugin.ImportWizardForm', 'Bibleserver'))
self.webTranslationLabel.setText(
translate('BiblesPlugin.ImportWizardForm', 'Bible:'))
self.webTabWidget.setTabText(
self.webTabWidget.indexOf(self.webBibleTab),
self.webTranslationLabel.setText(translate('BiblesPlugin.ImportWizardForm', 'Bible:'))
self.webTabWidget.setTabText(self.webTabWidget.indexOf(self.webBibleTab),
translate('BiblesPlugin.ImportWizardForm', 'Download Options'))
self.webServerLabel.setText(
translate('BiblesPlugin.ImportWizardForm', 'Server:'))
self.webUserLabel.setText(
translate('BiblesPlugin.ImportWizardForm', 'Username:'))
self.webPasswordLabel.setText(
translate('BiblesPlugin.ImportWizardForm', 'Password:'))
self.webTabWidget.setTabText(
self.webTabWidget.indexOf(self.webProxyTab),
self.webServerLabel.setText(translate('BiblesPlugin.ImportWizardForm', 'Server:'))
self.webUserLabel.setText(translate('BiblesPlugin.ImportWizardForm', 'Username:'))
self.webPasswordLabel.setText(translate('BiblesPlugin.ImportWizardForm', 'Password:'))
self.webTabWidget.setTabText(self.webTabWidget.indexOf(self.webProxyTab),
translate('BiblesPlugin.ImportWizardForm',
'Proxy Server (Optional)'))
self.licenseDetailsPage.setTitle(
translate('BiblesPlugin.ImportWizardForm', 'License Details'))
self.licenseDetailsPage.setSubTitle(
translate('BiblesPlugin.ImportWizardForm',
self.licenseDetailsPage.setSubTitle(translate('BiblesPlugin.ImportWizardForm',
'Set up the Bible\'s license details.'))
self.versionNameLabel.setText(
translate('BiblesPlugin.ImportWizardForm', 'Version name:'))
self.copyrightLabel.setText(
translate('BiblesPlugin.ImportWizardForm', 'Copyright:'))
self.permissionsLabel.setText(
translate('BiblesPlugin.ImportWizardForm', 'Permissions:'))
self.versionNameLabel.setText(translate('BiblesPlugin.ImportWizardForm', 'Version name:'))
self.copyrightLabel.setText(translate('BiblesPlugin.ImportWizardForm', 'Copyright:'))
self.permissionsLabel.setText(translate('BiblesPlugin.ImportWizardForm', 'Permissions:'))
self.progressPage.setTitle(WizardStrings.Importing)
self.progressPage.setSubTitle(
translate('BiblesPlugin.ImportWizardForm',
self.progressPage.setSubTitle(translate('BiblesPlugin.ImportWizardForm',
'Please wait while your Bible is imported.'))
self.progressLabel.setText(WizardStrings.Ready)
self.progressBar.setFormat(u'%p%')
@ -423,8 +379,7 @@ class BibleImportForm(OpenLPWizard):
self.csvVersesLabel.minimumSizeHint().width(),
self.openSongFileLabel.minimumSizeHint().width(),
self.openlp1FileLabel.minimumSizeHint().width())
self.spacer.changeSize(labelWidth, 0,
QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Fixed)
self.spacer.changeSize(labelWidth, 0, QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Fixed)
def validateCurrentPage(self):
"""
@ -435,41 +390,32 @@ class BibleImportForm(OpenLPWizard):
elif self.currentPage() == self.selectPage:
if self.field(u'source_format') == BibleFormat.OSIS:
if not self.field(u'osis_location'):
critical_error_message_box(UiStrings().NFSs,
WizardStrings.YouSpecifyFile % WizardStrings.OSIS)
critical_error_message_box(UiStrings().NFSs, WizardStrings.YouSpecifyFile % WizardStrings.OSIS)
self.osisFileEdit.setFocus()
return False
elif self.field(u'source_format') == BibleFormat.CSV:
if not self.field(u'csv_booksfile'):
critical_error_message_box(UiStrings().NFSs,
translate('BiblesPlugin.ImportWizardForm',
'You need to specify a file with books of '
'the Bible to use in the import.'))
critical_error_message_box(UiStrings().NFSs, translate('BiblesPlugin.ImportWizardForm',
'You need to specify a file with books of the Bible to use in the import.'))
self.csvBooksEdit.setFocus()
return False
elif not self.field(u'csv_versefile'):
critical_error_message_box(UiStrings().NFSs,
translate('BiblesPlugin.ImportWizardForm',
'You need to specify a file of Bible '
'verses to import.'))
'You need to specify a file of Bible verses to import.'))
self.csvVersesEdit.setFocus()
return False
elif self.field(u'source_format') == \
BibleFormat.OpenSong:
elif self.field(u'source_format') == BibleFormat.OpenSong:
if not self.field(u'opensong_file'):
critical_error_message_box(UiStrings().NFSs,
WizardStrings.YouSpecifyFile % WizardStrings.OS)
critical_error_message_box(UiStrings().NFSs, WizardStrings.YouSpecifyFile % WizardStrings.OS)
self.openSongFileEdit.setFocus()
return False
elif self.field(u'source_format') == \
BibleFormat.WebDownload:
self.versionNameEdit.setText(
self.webTranslationComboBox.currentText())
elif self.field(u'source_format') == BibleFormat.WebDownload:
self.versionNameEdit.setText(self.webTranslationComboBox.currentText())
return True
elif self.field(u'source_format') == BibleFormat.OpenLP1:
if not self.field(u'openlp1_location'):
critical_error_message_box(UiStrings().NFSs,
WizardStrings.YouSpecifyFile % UiStrings().OLPV1)
critical_error_message_box(UiStrings().NFSs, WizardStrings.YouSpecifyFile % UiStrings().OLPV1)
self.openlp1FileEdit.setFocus()
return False
return True
@ -479,31 +425,26 @@ class BibleImportForm(OpenLPWizard):
path = AppLocation.get_section_data_path(u'bibles')
if not license_version:
critical_error_message_box(UiStrings().EmptyField,
translate('BiblesPlugin.ImportWizardForm',
'You need to specify a version name for your Bible.'))
translate('BiblesPlugin.ImportWizardForm', 'You need to specify a version name for your Bible.'))
self.versionNameEdit.setFocus()
return False
elif not license_copyright:
critical_error_message_box(UiStrings().EmptyField,
translate('BiblesPlugin.ImportWizardForm',
'You need to set a copyright for your Bible. '
translate('BiblesPlugin.ImportWizardForm', 'You need to set a copyright for your Bible. '
'Bibles in the Public Domain need to be marked as such.'))
self.copyrightEdit.setFocus()
return False
elif self.manager.exists(license_version):
critical_error_message_box(
translate('BiblesPlugin.ImportWizardForm', 'Bible Exists'),
critical_error_message_box(translate('BiblesPlugin.ImportWizardForm', 'Bible Exists'),
translate('BiblesPlugin.ImportWizardForm',
'This Bible already exists. Please import '
'a different Bible or first delete the existing one.'))
'This Bible already exists. Please import a different Bible or first delete the existing one.'))
self.versionNameEdit.setFocus()
return False
elif os.path.exists(os.path.join(path, clean_filename(
license_version))):
critical_error_message_box(
translate('BiblesPlugin.ImportWizardForm', 'Bible Exists'),
translate('BiblesPlugin.ImportWizardForm',
'This Bible already exists. Please import '
translate('BiblesPlugin.ImportWizardForm', 'This Bible already exists. Please import '
'a different Bible or first delete the existing one.'))
self.versionNameEdit.setFocus()
return False
@ -528,40 +469,34 @@ class BibleImportForm(OpenLPWizard):
"""
Show the file open dialog for the OSIS file.
"""
self.getFileName(WizardStrings.OpenTypeFile % WizardStrings.OSIS,
self.osisFileEdit)
self.getFileName(WizardStrings.OpenTypeFile % WizardStrings.OSIS, self.osisFileEdit)
def onCsvBooksBrowseButtonClicked(self):
"""
Show the file open dialog for the books CSV file.
"""
self.getFileName(WizardStrings.OpenTypeFile % WizardStrings.CSV,
self.csvBooksEdit, u'%s (*.csv)'
self.getFileName(WizardStrings.OpenTypeFile % WizardStrings.CSV, self.csvBooksEdit, u'%s (*.csv)'
% translate('BiblesPlugin.ImportWizardForm', 'CSV File'))
def onCsvVersesBrowseButtonClicked(self):
"""
Show the file open dialog for the verses CSV file.
"""
self.getFileName(WizardStrings.OpenTypeFile % WizardStrings.CSV,
self.csvVersesEdit, u'%s (*.csv)'
self.getFileName(WizardStrings.OpenTypeFile % WizardStrings.CSV, self.csvVersesEdit, u'%s (*.csv)'
% translate('BiblesPlugin.ImportWizardForm', 'CSV File'))
def onOpenSongBrowseButtonClicked(self):
"""
Show the file open dialog for the OpenSong file.
"""
self.getFileName(WizardStrings.OpenTypeFile % WizardStrings.OS,
self.openSongFileEdit)
self.getFileName(WizardStrings.OpenTypeFile % WizardStrings.OS, self.openSongFileEdit)
def onOpenlp1BrowseButtonClicked(self):
"""
Show the file open dialog for the openlp.org 1.x file.
"""
self.getFileName(WizardStrings.OpenTypeFile % UiStrings().OLPV1,
self.openlp1FileEdit, u'%s (*.bible)' %
translate('BiblesPlugin.ImportWizardForm',
'openlp.org 1.x Bible Files'))
self.getFileName(WizardStrings.OpenTypeFile % UiStrings().OLPV1, self.openlp1FileEdit, u'%s (*.bible)' %
translate('BiblesPlugin.ImportWizardForm', 'openlp.org 1.x Bible Files'))
def registerFields(self):
"""
@ -573,18 +508,14 @@ class BibleImportForm(OpenLPWizard):
self.selectPage.registerField(u'csv_versefile', self.csvVersesEdit)
self.selectPage.registerField(u'opensong_file', self.openSongFileEdit)
self.selectPage.registerField(u'web_location', self.webSourceComboBox)
self.selectPage.registerField(
u'web_biblename', self.webTranslationComboBox)
self.selectPage.registerField(u'web_biblename', self.webTranslationComboBox)
self.selectPage.registerField(u'proxy_server', self.webServerEdit)
self.selectPage.registerField(u'proxy_username', self.webUserEdit)
self.selectPage.registerField(u'proxy_password', self.webPasswordEdit)
self.selectPage.registerField(u'openlp1_location', self.openlp1FileEdit)
self.licenseDetailsPage.registerField(
u'license_version', self.versionNameEdit)
self.licenseDetailsPage.registerField(
u'license_copyright', self.copyrightEdit)
self.licenseDetailsPage.registerField(
u'license_permissions', self.permissionsEdit)
self.licenseDetailsPage.registerField(u'license_version', self.versionNameEdit)
self.licenseDetailsPage.registerField(u'license_copyright', self.copyrightEdit)
self.licenseDetailsPage.registerField(u'license_permissions', self.permissionsEdit)
def setDefaults(self):
"""
@ -601,8 +532,7 @@ class BibleImportForm(OpenLPWizard):
self.setField(u'csv_versefile', '')
self.setField(u'opensong_file', '')
self.setField(u'web_location', WebDownload.Crosswalk)
self.setField(u'web_biblename',
self.webTranslationComboBox.currentIndex())
self.setField(u'web_biblename', self.webTranslationComboBox.currentIndex())
self.setField(u'proxy_server', settings.value(u'proxy address', u''))
self.setField(u'proxy_username', settings.value(u'proxy username', u''))
self.setField(u'proxy_password', settings.value(u'proxy password', u''))
@ -632,8 +562,7 @@ class BibleImportForm(OpenLPWizard):
The WebDownload type e.g. bibleserver.
"""
self.web_bible_list[download_type] = {}
bibles = BiblesResourcesDB.get_webbibles(
WebDownload.Names[download_type])
bibles = BiblesResourcesDB.get_webbibles(WebDownload.Names[download_type])
for bible in bibles:
version = bible[u'name']
name = bible[u'abbreviation']
@ -646,9 +575,7 @@ class BibleImportForm(OpenLPWizard):
OpenLPWizard.preWizard(self)
bible_type = self.field(u'source_format')
if bible_type == BibleFormat.WebDownload:
self.progressLabel.setText(translate(
'BiblesPlugin.ImportWizardForm',
'Registering Bible...'))
self.progressLabel.setText(translate('BiblesPlugin.ImportWizardForm', 'Registering Bible...'))
else:
self.progressLabel.setText(WizardStrings.StartingImport)
Receiver.send_message(u'openlp_process_events')
@ -707,13 +634,11 @@ class BibleImportForm(OpenLPWizard):
self.manager.reload_bibles()
if bible_type == BibleFormat.WebDownload:
self.progressLabel.setText(
translate('BiblesPlugin.ImportWizardForm', 'Registered '
'Bible. Please note, that verses will be downloaded on\n'
'demand and thus an internet connection is required.'))
translate('BiblesPlugin.ImportWizardForm', 'Registered Bible. Please note, that verses will be '
'downloaded on\ndemand and thus an internet connection is required.'))
else:
self.progressLabel.setText(WizardStrings.FinishedImport)
else:
self.progressLabel.setText(translate(
'BiblesPlugin.ImportWizardForm', 'Your Bible import failed.'))
self.progressLabel.setText(translate('BiblesPlugin.ImportWizardForm', 'Your Bible import failed.'))
del self.manager.db_cache[importer.name]
delete_database(self.plugin.settingsSection, importer.file)

View File

@ -1,5 +1,5 @@
# -*- coding: utf-8 -*-
# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4
# vim: autoindent shiftwidth=4 expandtab textwidth=120 tabstop=4 softtabstop=4
###############################################################################
# OpenLP - Open Source Lyrics Projection #
@ -36,13 +36,11 @@ from tempfile import gettempdir
from PyQt4 import QtCore, QtGui
from openlp.core.lib import Receiver, SettingsManager, translate, \
check_directory_exists, Settings
from openlp.core.lib import Receiver, SettingsManager, translate, check_directory_exists, Settings
from openlp.core.lib.ui import UiStrings, critical_error_message_box
from openlp.core.ui.wizard import OpenLPWizard, WizardStrings
from openlp.core.utils import AppLocation, delete_file, get_filesystem_encoding
from openlp.plugins.bibles.lib.db import BibleDB, BibleMeta, OldBibleDB, \
BiblesResourcesDB
from openlp.plugins.bibles.lib.db import BibleDB, BibleMeta, OldBibleDB, BiblesResourcesDB
from openlp.plugins.bibles.lib.http import BSExtract, BGExtract, CWExtract
log = logging.getLogger(__name__)
@ -73,21 +71,18 @@ class BibleUpgradeForm(OpenLPWizard):
self.suffix = u'.sqlite'
self.settingsSection = u'bibles'
self.path = AppLocation.get_section_data_path(self.settingsSection)
self.temp_dir = os.path.join(
unicode(gettempdir(), get_filesystem_encoding()), u'openlp')
self.temp_dir = os.path.join(unicode(gettempdir(), get_filesystem_encoding()), u'openlp')
self.files = self.manager.old_bible_databases
self.success = {}
self.newbibles = {}
OpenLPWizard.__init__(self, parent, bibleplugin, u'bibleUpgradeWizard',
u':/wizards/wizard_importbible.bmp')
OpenLPWizard.__init__(self, parent, bibleplugin, u'bibleUpgradeWizard', u':/wizards/wizard_importbible.bmp')
def setupUi(self, image):
"""
Set up the UI for the bible wizard.
"""
OpenLPWizard.setupUi(self, image)
QtCore.QObject.connect(Receiver.get_receiver(),
QtCore.SIGNAL(u'openlp_stop_wizard'), self.stop_import)
QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'openlp_stop_wizard'), self.stop_import)
def stop_import(self):
"""
@ -120,14 +115,12 @@ class BibleUpgradeForm(OpenLPWizard):
"""
Show the file open dialog for the OSIS file.
"""
filename = QtGui.QFileDialog.getExistingDirectory(self, translate(
'BiblesPlugin.UpgradeWizardForm', 'Select a Backup Directory'),
os.path.dirname(SettingsManager.get_last_dir(
self.plugin.settingsSection, 1)))
filename = QtGui.QFileDialog.getExistingDirectory(self,
translate('BiblesPlugin.UpgradeWizardForm', 'Select a Backup Directory'),
os.path.dirname(SettingsManager.get_last_dir(self.plugin.settingsSection, 1)))
if filename:
self.backupDirectoryEdit.setText(filename)
SettingsManager.set_last_dir(self.plugin.settingsSection,
filename, 1)
SettingsManager.set_last_dir(self.plugin.settingsSection, filename, 1)
def onNoBackupCheckBoxToggled(self, checked):
"""
@ -144,8 +137,7 @@ class BibleUpgradeForm(OpenLPWizard):
success = True
for filename in self.files:
try:
shutil.copy(os.path.join(self.path, filename[0]),
backup_directory)
shutil.copy(os.path.join(self.path, filename[0]), backup_directory)
except:
success = False
return success
@ -161,10 +153,8 @@ class BibleUpgradeForm(OpenLPWizard):
"""
Set up the signals used in the bible importer.
"""
QtCore.QObject.connect(self.backupBrowseButton,
QtCore.SIGNAL(u'clicked()'), self.onBackupBrowseButtonClicked)
QtCore.QObject.connect(self.noBackupCheckBox,
QtCore.SIGNAL(u'toggled(bool)'), self.onNoBackupCheckBoxToggled)
QtCore.QObject.connect(self.backupBrowseButton, QtCore.SIGNAL(u'clicked()'), self.onBackupBrowseButtonClicked)
QtCore.QObject.connect(self.noBackupCheckBox, QtCore.SIGNAL(u'toggled(bool)'), self.onNoBackupCheckBoxToggled)
def addCustomPages(self):
"""
@ -198,14 +188,12 @@ class BibleUpgradeForm(OpenLPWizard):
self.backupBrowseButton.setIcon(self.openIcon)
self.backupBrowseButton.setObjectName(u'BackupBrowseButton')
self.backupDirectoryLayout.addWidget(self.backupBrowseButton)
self.formLayout.addRow(self.backupDirectoryLabel,
self.backupDirectoryLayout)
self.formLayout.addRow(self.backupDirectoryLabel, self.backupDirectoryLayout)
self.backupLayout.addLayout(self.formLayout)
self.noBackupCheckBox = QtGui.QCheckBox(self.backupPage)
self.noBackupCheckBox.setObjectName('NoBackupCheckBox')
self.backupLayout.addWidget(self.noBackupCheckBox)
self.spacer = QtGui.QSpacerItem(10, 0, QtGui.QSizePolicy.Fixed,
QtGui.QSizePolicy.Minimum)
self.spacer = QtGui.QSpacerItem(10, 0, QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Minimum)
self.backupLayout.addItem(self.spacer)
self.addPage(self.backupPage)
# Select Page
@ -216,8 +204,7 @@ class BibleUpgradeForm(OpenLPWizard):
self.scrollArea = QtGui.QScrollArea(self.selectPage)
self.scrollArea.setWidgetResizable(True)
self.scrollArea.setObjectName(u'scrollArea')
self.scrollArea.setHorizontalScrollBarPolicy(
QtCore.Qt.ScrollBarAlwaysOff)
self.scrollArea.setHorizontalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOff)
self.scrollAreaContents = QtGui.QWidget(self.scrollArea)
self.scrollAreaContents.setObjectName(u'scrollAreaContents')
self.formLayout = QtGui.QVBoxLayout(self.scrollAreaContents)
@ -239,8 +226,7 @@ class BibleUpgradeForm(OpenLPWizard):
self.checkBox[number].setText(bible.get_name())
self.checkBox[number].setCheckState(QtCore.Qt.Checked)
self.formLayout.addWidget(self.checkBox[number])
self.spacerItem = QtGui.QSpacerItem(20, 5, QtGui.QSizePolicy.Minimum,
QtGui.QSizePolicy.Expanding)
self.spacerItem = QtGui.QSpacerItem(20, 5, QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Expanding)
self.formLayout.addItem(self.spacerItem)
self.scrollArea.setWidget(self.scrollAreaContents)
@ -257,20 +243,14 @@ class BibleUpgradeForm(OpenLPWizard):
"""
Allow for localisation of the bible import wizard.
"""
self.setWindowTitle(translate('BiblesPlugin.UpgradeWizardForm',
'Bible Upgrade Wizard'))
self.setWindowTitle(translate('BiblesPlugin.UpgradeWizardForm', 'Bible Upgrade Wizard'))
self.titleLabel.setText(WizardStrings.HeaderStyle %
translate('OpenLP.Ui', 'Welcome to the Bible Upgrade Wizard'))
self.informationLabel.setText(
translate('BiblesPlugin.UpgradeWizardForm',
'This wizard will help you to upgrade your existing Bibles from a '
'prior version of OpenLP 2. Click the next button below to start '
'the upgrade process.'))
self.backupPage.setTitle(
translate('BiblesPlugin.UpgradeWizardForm',
'Select Backup Directory'))
self.backupPage.setSubTitle(
translate('BiblesPlugin.UpgradeWizardForm',
self.informationLabel.setText(translate('BiblesPlugin.UpgradeWizardForm',
'This wizard will help you to upgrade your existing Bibles from a prior version of OpenLP 2. '
'Click the next button below to start the upgrade process.'))
self.backupPage.setTitle(translate('BiblesPlugin.UpgradeWizardForm', 'Select Backup Directory'))
self.backupPage.setSubTitle(translate('BiblesPlugin.UpgradeWizardForm',
'Please select a backup directory for your Bibles'))
self.backupInfoLabel.setText(translate('BiblesPlugin.UpgradeWizardForm',
'Previous releases of OpenLP 2.0 are unable to use upgraded Bibles.'
@ -281,21 +261,14 @@ class BibleUpgradeForm(OpenLPWizard):
'http://wiki.openlp.org/faq">Frequently Asked Questions</a>.'))
self.selectLabel.setText(translate('BiblesPlugin.UpgradeWizardForm',
'Please select a backup location for your Bibles.'))
self.backupDirectoryLabel.setText(
translate('BiblesPlugin.UpgradeWizardForm', 'Backup Directory:'))
self.backupDirectoryLabel.setText(translate('BiblesPlugin.UpgradeWizardForm', 'Backup Directory:'))
self.noBackupCheckBox.setText(
translate('BiblesPlugin.UpgradeWizardForm',
'There is no need to backup my Bibles'))
self.selectPage.setTitle(
translate('BiblesPlugin.UpgradeWizardForm',
'Select Bibles'))
self.selectPage.setSubTitle(
translate('BiblesPlugin.UpgradeWizardForm',
translate('BiblesPlugin.UpgradeWizardForm', 'There is no need to backup my Bibles'))
self.selectPage.setTitle(translate('BiblesPlugin.UpgradeWizardForm', 'Select Bibles'))
self.selectPage.setSubTitle(translate('BiblesPlugin.UpgradeWizardForm',
'Please select the Bibles to upgrade'))
self.progressPage.setTitle(translate('BiblesPlugin.UpgradeWizardForm',
'Upgrading'))
self.progressPage.setSubTitle(
translate('BiblesPlugin.UpgradeWizardForm',
self.progressPage.setTitle(translate('BiblesPlugin.UpgradeWizardForm', 'Upgrading'))
self.progressPage.setSubTitle(translate('BiblesPlugin.UpgradeWizardForm',
'Please wait while your Bibles are upgraded.'))
self.progressLabel.setText(WizardStrings.Ready)
self.progressBar.setFormat(u'%p%')
@ -312,17 +285,14 @@ class BibleUpgradeForm(OpenLPWizard):
if not backup_path:
critical_error_message_box(UiStrings().EmptyField,
translate('BiblesPlugin.UpgradeWizardForm',
'You need to specify a backup directory for your '
'Bibles.'))
'You need to specify a backup directory for your Bibles.'))
self.backupDirectoryEdit.setFocus()
return False
else:
if not self.backupOldBibles(backup_path):
critical_error_message_box(UiStrings().Error,
translate('BiblesPlugin.UpgradeWizardForm',
'The backup was not successful.\nTo backup your '
'Bibles you need permission to write to the given '
'directory.'))
translate('BiblesPlugin.UpgradeWizardForm', 'The backup was not successful.\nTo backup your '
'Bibles you need permission to write to the given directory.'))
return False
return True
elif self.currentPage() == self.selectPage:
@ -332,8 +302,7 @@ class BibleUpgradeForm(OpenLPWizard):
continue
# Move bibles to temp dir.
if not os.path.exists(os.path.join(self.temp_dir, filename[0])):
shutil.move(
os.path.join(self.path, filename[0]), self.temp_dir)
shutil.move(os.path.join(self.path, filename[0]), self.temp_dir)
else:
delete_file(os.path.join(self.path, filename[0]))
return True
@ -367,8 +336,7 @@ class BibleUpgradeForm(OpenLPWizard):
Prepare the UI for the upgrade.
"""
OpenLPWizard.preWizard(self)
self.progressLabel.setText(
translate('BiblesPlugin.UpgradeWizardForm', 'Starting upgrade...'))
self.progressLabel.setText(translate('BiblesPlugin.UpgradeWizardForm', 'Starting upgrade...'))
Receiver.send_message(u'openlp_process_events')
def performWizard(self):
@ -378,9 +346,8 @@ class BibleUpgradeForm(OpenLPWizard):
self.includeWebBible = False
proxy_server = None
if not self.files:
self.progressLabel.setText(
translate('BiblesPlugin.UpgradeWizardForm', 'There are no '
'Bibles that need to be upgraded.'))
self.progressLabel.setText(translate('BiblesPlugin.UpgradeWizardForm',
'There are no Bibles that need to be upgraded.'))
self.progressBar.hide()
return
max_bibles = 0
@ -405,12 +372,9 @@ class BibleUpgradeForm(OpenLPWizard):
old_bible = OldBibleDB(self.mediaItem, path=self.temp_dir,
file=filename[0])
name = filename[1]
self.progressLabel.setText(translate(
'BiblesPlugin.UpgradeWizardForm',
'Upgrading Bible %s of %s: "%s"\nUpgrading ...') %
(number + 1, max_bibles, name))
self.newbibles[number] = BibleDB(self.mediaItem, path=self.path,
name=name, file=filename[0])
self.progressLabel.setText(translate('BiblesPlugin.UpgradeWizardForm',
'Upgrading Bible %s of %s: "%s"\nUpgrading ...') % (number + 1, max_bibles, name))
self.newbibles[number] = BibleDB(self.mediaItem, path=self.path, name=name, file=filename[0])
self.newbibles[number].register(self.plugin.upgrade_wizard)
metadata = old_bible.get_metadata()
web_bible = False
@ -425,8 +389,7 @@ class BibleUpgradeForm(OpenLPWizard):
# Copy the metadata
meta_data[meta[u'key']] = meta[u'value']
if meta[u'key'] != u'name' and meta[u'key'] != u'dbversion':
self.newbibles[number].save_meta(meta[u'key'],
meta[u'value'])
self.newbibles[number].save_meta(meta[u'key'], meta[u'value'])
if meta[u'key'] == u'download_source':
web_bible = True
self.includeWebBible = True
@ -440,23 +403,17 @@ class BibleUpgradeForm(OpenLPWizard):
handler = BSExtract(proxy_server)
books = handler.get_books_from_http(meta_data[u'download_name'])
if not books:
log.error(u'Upgrading books from %s - download '\
u'name: "%s" failed' % (
meta_data[u'download_source'],
meta_data[u'download_name']))
log.error(u'Upgrading books from %s - download name: "%s" failed' % (
meta_data[u'download_source'], meta_data[u'download_name']))
self.newbibles[number].session.close()
del self.newbibles[number]
critical_error_message_box(
translate('BiblesPlugin.UpgradeWizardForm', 'Download Error'),
translate('BiblesPlugin.UpgradeWizardForm',
'Download Error'),
translate('BiblesPlugin.UpgradeWizardForm',
'To upgrade your Web Bibles an Internet connection is '
'required.'))
'To upgrade your Web Bibles an Internet connection is required.'))
self.incrementProgressBar(translate(
'BiblesPlugin.UpgradeWizardForm',
'Upgrading Bible %s of %s: "%s"\nFailed') %
(number + 1, max_bibles, name),
self.progressBar.maximum() - self.progressBar.value())
'BiblesPlugin.UpgradeWizardForm', 'Upgrading Bible %s of %s: "%s"\nFailed') %
(number + 1, max_bibles, name), self.progressBar.maximum() - self.progressBar.value())
self.success[number] = False
continue
bible = BiblesResourcesDB.get_webbible(
@ -472,10 +429,8 @@ class BibleUpgradeForm(OpenLPWizard):
log.warn(u'Upgrading from "%s" failed' % filename[0])
self.newbibles[number].session.close()
del self.newbibles[number]
self.incrementProgressBar(translate(
'BiblesPlugin.UpgradeWizardForm',
'Upgrading Bible %s of %s: "%s"\nFailed') %
(number + 1, max_bibles, name),
self.incrementProgressBar(translate('BiblesPlugin.UpgradeWizardForm',
'Upgrading Bible %s of %s: "%s"\nFailed') % (number + 1, max_bibles, name),
self.progressBar.maximum() - self.progressBar.value())
self.success[number] = False
continue
@ -484,18 +439,13 @@ class BibleUpgradeForm(OpenLPWizard):
if self.stop_import_flag:
self.success[number] = False
break
self.incrementProgressBar(translate(
'BiblesPlugin.UpgradeWizardForm',
'Upgrading Bible %s of %s: "%s"\n'
'Upgrading %s ...') %
(number + 1, max_bibles, name, book))
self.incrementProgressBar(translate('BiblesPlugin.UpgradeWizardForm',
'Upgrading Bible %s of %s: "%s"\nUpgrading %s ...') % (number + 1, max_bibles, name, book))
book_ref_id = self.newbibles[number].\
get_book_ref_id_by_name(book, len(books), language_id)
if not book_ref_id:
log.warn(u'Upgrading books from %s - download '\
u'name: "%s" aborted by user' % (
meta_data[u'download_source'],
meta_data[u'download_name']))
log.warn(u'Upgrading books from %s - download name: "%s" aborted by user' % (
meta_data[u'download_source'], meta_data[u'download_name']))
self.newbibles[number].session.close()
del self.newbibles[number]
self.success[number] = False
@ -508,8 +458,7 @@ class BibleUpgradeForm(OpenLPWizard):
if oldbook:
verses = old_bible.get_verses(oldbook[u'id'])
if not verses:
log.warn(u'No verses found to import for book '
u'"%s"', book)
log.warn(u'No verses found to import for book "%s"', book)
continue
for verse in verses:
if self.stop_import_flag:
@ -521,18 +470,15 @@ class BibleUpgradeForm(OpenLPWizard):
Receiver.send_message(u'openlp_process_events')
self.newbibles[number].session.commit()
else:
language_id = self.newbibles[number].get_object(BibleMeta,
u'language_id')
language_id = self.newbibles[number].get_object(BibleMeta, u'language_id')
if not language_id:
language_id = self.newbibles[number].get_language(name)
if not language_id:
log.warn(u'Upgrading books from "%s" failed' % name)
self.newbibles[number].session.close()
del self.newbibles[number]
self.incrementProgressBar(translate(
'BiblesPlugin.UpgradeWizardForm',
'Upgrading Bible %s of %s: "%s"\nFailed') %
(number + 1, max_bibles, name),
self.incrementProgressBar(translate('BiblesPlugin.UpgradeWizardForm',
'Upgrading Bible %s of %s: "%s"\nFailed') % (number + 1, max_bibles, name),
self.progressBar.maximum() - self.progressBar.value())
self.success[number] = False
continue
@ -542,17 +488,12 @@ class BibleUpgradeForm(OpenLPWizard):
if self.stop_import_flag:
self.success[number] = False
break
self.incrementProgressBar(translate(
'BiblesPlugin.UpgradeWizardForm',
'Upgrading Bible %s of %s: "%s"\n'
'Upgrading %s ...') %
self.incrementProgressBar(translate('BiblesPlugin.UpgradeWizardForm',
'Upgrading Bible %s of %s: "%s"\nUpgrading %s ...') %
(number + 1, max_bibles, name, book[u'name']))
book_ref_id = self.newbibles[number].\
get_book_ref_id_by_name(book[u'name'], len(books),
language_id)
book_ref_id = self.newbibles[number].get_book_ref_id_by_name(book[u'name'], len(books), language_id)
if not book_ref_id:
log.warn(u'Upgrading books from %s " '\
'failed - aborted by user' % name)
log.warn(u'Upgrading books from %s " failed - aborted by user' % name)
self.newbibles[number].session.close()
del self.newbibles[number]
self.success[number] = False
@ -562,8 +503,7 @@ class BibleUpgradeForm(OpenLPWizard):
book_ref_id, book_details[u'testament_id'])
verses = old_bible.get_verses(book[u'id'])
if not verses:
log.warn(u'No verses found to import for book '
u'"%s"', book[u'name'])
log.warn(u'No verses found to import for book "%s"', book[u'name'])
self.newbibles[number].delete_book(db_book)
continue
for verse in verses:
@ -576,19 +516,14 @@ class BibleUpgradeForm(OpenLPWizard):
Receiver.send_message(u'openlp_process_events')
self.newbibles[number].session.commit()
if not self.success.get(number, True):
self.incrementProgressBar(translate(
'BiblesPlugin.UpgradeWizardForm',
'Upgrading Bible %s of %s: "%s"\nFailed') %
(number + 1, max_bibles, name),
self.incrementProgressBar(translate('BiblesPlugin.UpgradeWizardForm',
'Upgrading Bible %s of %s: "%s"\nFailed') % (number + 1, max_bibles, name),
self.progressBar.maximum() - self.progressBar.value())
else:
self.success[number] = True
self.newbibles[number].save_meta(u'name', name)
self.incrementProgressBar(translate(
'BiblesPlugin.UpgradeWizardForm',
'Upgrading Bible %s of %s: "%s"\n'
'Complete') %
(number + 1, max_bibles, name))
self.incrementProgressBar(translate('BiblesPlugin.UpgradeWizardForm',
'Upgrading Bible %s of %s: "%s"\nComplete') % (number + 1, max_bibles, name))
if number in self.newbibles:
self.newbibles[number].session.close()
# Close the last bible's connection if possible.
@ -611,26 +546,19 @@ class BibleUpgradeForm(OpenLPWizard):
# Copy not upgraded bible back.
shutil.move(os.path.join(self.temp_dir, filename[0]), self.path)
if failed_import > 0:
failed_import_text = translate('BiblesPlugin.UpgradeWizardForm',
', %s failed') % failed_import
failed_import_text = translate('BiblesPlugin.UpgradeWizardForm', ', %s failed') % failed_import
else:
failed_import_text = u''
if successful_import > 0:
if self.includeWebBible:
self.progressLabel.setText(
translate('BiblesPlugin.UpgradeWizardForm', 'Upgrading '
'Bible(s): %s successful%s\nPlease note that verses from '
'Web Bibles will be downloaded on demand and so an '
'Internet connection is required.') %
(successful_import, failed_import_text))
self.progressLabel.setText(translate('BiblesPlugin.UpgradeWizardForm',
'Upgrading Bible(s): %s successful%s\nPlease note that verses from Web Bibles will be downloaded '
'on demand and so an Internet connection is required.') % (successful_import, failed_import_text))
else:
self.progressLabel.setText(
translate('BiblesPlugin.UpgradeWizardForm', 'Upgrading '
'Bible(s): %s successful%s') % (successful_import,
failed_import_text))
self.progressLabel.setText(translate('BiblesPlugin.UpgradeWizardForm',
'Upgrading Bible(s): %s successful%s') % (successful_import, failed_import_text))
else:
self.progressLabel.setText(translate(
'BiblesPlugin.UpgradeWizardForm', 'Upgrade failed.'))
self.progressLabel.setText(translate('BiblesPlugin.UpgradeWizardForm', 'Upgrade failed.'))
# Remove temp directory.
shutil.rmtree(self.temp_dir, True)
OpenLPWizard.postWizard(self)

View File

@ -1,5 +1,5 @@
# -*- coding: utf-8 -*-
# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4
# vim: autoindent shiftwidth=4 expandtab textwidth=120 tabstop=4 softtabstop=4
###############################################################################
# OpenLP - Open Source Lyrics Projection #
@ -56,12 +56,10 @@ class Ui_BookNameDialog(object):
self.correspondingLayout.addWidget(self.currentBookLabel, 0, 1, 1, 1)
self.correspondingLabel = QtGui.QLabel(bookNameDialog)
self.correspondingLabel.setObjectName(u'correspondingLabel')
self.correspondingLayout.addWidget(
self.correspondingLabel, 1, 0, 1, 1)
self.correspondingLayout.addWidget(self.correspondingLabel, 1, 0, 1, 1)
self.correspondingComboBox = QtGui.QComboBox(bookNameDialog)
self.correspondingComboBox.setObjectName(u'correspondingComboBox')
self.correspondingLayout.addWidget(
self.correspondingComboBox, 1, 1, 1, 1)
self.correspondingLayout.addWidget(self.correspondingComboBox, 1, 1, 1, 1)
self.bookNameLayout.addLayout(self.correspondingLayout)
self.optionsGroupBox = QtGui.QGroupBox(bookNameDialog)
self.optionsGroupBox.setObjectName(u'optionsGroupBox')
@ -82,27 +80,19 @@ class Ui_BookNameDialog(object):
self.apocryphaCheckBox.setCheckState(QtCore.Qt.Checked)
self.optionsLayout.addWidget(self.apocryphaCheckBox)
self.bookNameLayout.addWidget(self.optionsGroupBox)
self.buttonBox = create_button_box(bookNameDialog, u'buttonBox',
[u'cancel', u'ok'])
self.buttonBox = create_button_box(bookNameDialog, u'buttonBox', [u'cancel', u'ok'])
self.bookNameLayout.addWidget(self.buttonBox)
self.retranslateUi(bookNameDialog)
def retranslateUi(self, bookNameDialog):
bookNameDialog.setWindowTitle(translate('BiblesPlugin.BookNameDialog',
'Select Book Name'))
bookNameDialog.setWindowTitle(translate('BiblesPlugin.BookNameDialog', 'Select Book Name'))
self.infoLabel.setText(translate('BiblesPlugin.BookNameDialog',
'The following book name cannot be matched up internally. Please '
'select the corresponding name from the list.'))
self.currentLabel.setText(translate('BiblesPlugin.BookNameDialog',
'Current name:'))
self.correspondingLabel.setText(translate(
'BiblesPlugin.BookNameDialog', 'Corresponding name:'))
self.optionsGroupBox.setTitle(translate('BiblesPlugin.BookNameDialog',
'Show Books From'))
self.oldTestamentCheckBox.setText(translate(
'BiblesPlugin.BookNameDialog', 'Old Testament'))
self.newTestamentCheckBox.setText(translate(
'BiblesPlugin.BookNameDialog', 'New Testament'))
self.apocryphaCheckBox.setText(translate('BiblesPlugin.BookNameDialog',
'Apocrypha'))
'The following book name cannot be matched up internally. '
'Please select the corresponding name from the list.'))
self.currentLabel.setText(translate('BiblesPlugin.BookNameDialog', 'Current name:'))
self.correspondingLabel.setText(translate('BiblesPlugin.BookNameDialog', 'Corresponding name:'))
self.optionsGroupBox.setTitle(translate('BiblesPlugin.BookNameDialog', 'Show Books From'))
self.oldTestamentCheckBox.setText(translate('BiblesPlugin.BookNameDialog', 'Old Testament'))
self.newTestamentCheckBox.setText(translate('BiblesPlugin.BookNameDialog', 'New Testament'))
self.apocryphaCheckBox.setText(translate('BiblesPlugin.BookNameDialog', 'Apocrypha'))

View File

@ -1,5 +1,5 @@
# -*- coding: utf-8 -*-
# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4
# vim: autoindent shiftwidth=4 expandtab textwidth=120 tabstop=4 softtabstop=4
###############################################################################
# OpenLP - Open Source Lyrics Projection #
@ -38,8 +38,7 @@ from PyQt4 import QtCore
from openlp.core.lib import translate
from openlp.core.lib.ui import critical_error_message_box
from openlp.plugins.bibles.forms.booknamedialog import \
Ui_BookNameDialog
from openlp.plugins.bibles.forms.booknamedialog import Ui_BookNameDialog
from openlp.plugins.bibles.lib import BibleStrings
from openlp.plugins.bibles.lib.db import BiblesResourcesDB
@ -66,14 +65,11 @@ class BookNameForm(QDialog, Ui_BookNameDialog):
"""
Set up the signals used in the booknameform.
"""
QtCore.QObject.connect(self.oldTestamentCheckBox,
QtCore.SIGNAL(u'stateChanged(int)'),
QtCore.QObject.connect(self.oldTestamentCheckBox, QtCore.SIGNAL(u'stateChanged(int)'),
self.onCheckBoxIndexChanged)
QtCore.QObject.connect(self.newTestamentCheckBox,
QtCore.SIGNAL(u'stateChanged(int)'),
QtCore.QObject.connect(self.newTestamentCheckBox, QtCore.SIGNAL(u'stateChanged(int)'),
self.onCheckBoxIndexChanged)
QtCore.QObject.connect(self.apocryphaCheckBox,
QtCore.SIGNAL(u'stateChanged(int)'),
QtCore.QObject.connect(self.apocryphaCheckBox, QtCore.SIGNAL(u'stateChanged(int)'),
self.onCheckBoxIndexChanged)
def onCheckBoxIndexChanged(self, index):
@ -94,18 +90,14 @@ class BookNameForm(QDialog, Ui_BookNameDialog):
if book.book_reference_id == item[u'id']:
addBook = False
break
if self.oldTestamentCheckBox.checkState() == QtCore.Qt.Unchecked \
and item[u'testament_id'] == 1:
if self.oldTestamentCheckBox.checkState() == QtCore.Qt.Unchecked and item[u'testament_id'] == 1:
addBook = False
elif self.newTestamentCheckBox.checkState() == QtCore.Qt.Unchecked \
and item[u'testament_id'] == 2:
elif self.newTestamentCheckBox.checkState() == QtCore.Qt.Unchecked and item[u'testament_id'] == 2:
addBook = False
elif self.apocryphaCheckBox.checkState() == QtCore.Qt.Unchecked \
and item[u'testament_id'] == 3:
elif self.apocryphaCheckBox.checkState() == QtCore.Qt.Unchecked and item[u'testament_id'] == 3:
addBook = False
if addBook:
self.correspondingComboBox.addItem(
self.book_names[item[u'abbreviation']])
self.correspondingComboBox.addItem(self.book_names[item[u'abbreviation']])
def exec_(self, name, books, maxbooks):
self.books = books
@ -122,9 +114,7 @@ class BookNameForm(QDialog, Ui_BookNameDialog):
def accept(self):
if self.correspondingComboBox.currentText() == u'':
critical_error_message_box(
message=translate('BiblesPlugin.BookNameForm',
'You need to select a book.'))
critical_error_message_box(message=translate('BiblesPlugin.BookNameForm', 'You need to select a book.'))
self.correspondingComboBox.setFocus()
return False
else:
@ -132,8 +122,7 @@ class BookNameForm(QDialog, Ui_BookNameDialog):
for character in u'\\.^$*+?{}[]()':
cor_book = cor_book.replace(character, u'\\' + character)
books = filter(lambda key:
re.match(cor_book, unicode(self.book_names[key]), re.UNICODE),
self.book_names.keys())
re.match(cor_book, unicode(self.book_names[key]), re.UNICODE), self.book_names.keys())
books = filter(None, map(BiblesResourcesDB.get_book, books))
if books:
self.book_id = books[0][u'id']

View File

@ -1,5 +1,5 @@
# -*- coding: utf-8 -*-
# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4
# vim: autoindent shiftwidth=4 expandtab textwidth=120 tabstop=4 softtabstop=4
###############################################################################
# OpenLP - Open Source Lyrics Projection #
@ -39,8 +39,7 @@ class Ui_EditBibleDialog(object):
def setupUi(self, editBibleDialog):
editBibleDialog.setObjectName(u'editBibleDialog')
editBibleDialog.resize(520, 400)
editBibleDialog.setWindowIcon(
build_icon(u':/icon/openlp-logo-16x16.png'))
editBibleDialog.setWindowIcon(build_icon(u':/icon/openlp-logo-16x16.png'))
editBibleDialog.setModal(True)
self.dialogLayout = QtGui.QVBoxLayout(editBibleDialog)
self.dialogLayout.setSpacing(8)
@ -55,43 +54,34 @@ class Ui_EditBibleDialog(object):
self.metaTabLayout.setObjectName(u'metaTabLayout')
self.licenseDetailsGroupBox = QtGui.QGroupBox(self.metaTab)
self.licenseDetailsGroupBox.setObjectName(u'licenseDetailsGroupBox')
self.licenseDetailsLayout = QtGui.QFormLayout(
self.licenseDetailsGroupBox)
self.licenseDetailsLayout = QtGui.QFormLayout(self.licenseDetailsGroupBox)
self.licenseDetailsLayout.setObjectName(u'licenseDetailsLayout')
self.versionNameLabel = QtGui.QLabel(self.licenseDetailsGroupBox)
self.versionNameLabel.setObjectName(u'versionNameLabel')
self.versionNameEdit = QtGui.QLineEdit(self.licenseDetailsGroupBox)
self.versionNameEdit.setObjectName(u'versionNameEdit')
self.versionNameLabel.setBuddy(self.versionNameEdit)
self.licenseDetailsLayout.addRow(self.versionNameLabel,
self.versionNameEdit)
self.licenseDetailsLayout.addRow(self.versionNameLabel, self.versionNameEdit)
self.copyrightLabel = QtGui.QLabel(self.licenseDetailsGroupBox)
self.copyrightLabel.setObjectName(u'copyrightLabel')
self.copyrightEdit = QtGui.QLineEdit(self.licenseDetailsGroupBox)
self.copyrightEdit.setObjectName(u'copyrightEdit')
self.copyrightLabel.setBuddy(self.copyrightEdit)
self.licenseDetailsLayout.addRow(self.copyrightLabel,
self.copyrightEdit)
self.licenseDetailsLayout.addRow(self.copyrightLabel, self.copyrightEdit)
self.permissionsLabel = QtGui.QLabel(self.licenseDetailsGroupBox)
self.permissionsLabel.setObjectName(u'permissionsLabel')
self.permissionsEdit = QtGui.QLineEdit(self.licenseDetailsGroupBox)
self.permissionsEdit.setObjectName(u'permissionsEdit')
self.permissionsLabel.setBuddy(self.permissionsEdit)
self.licenseDetailsLayout.addRow(self.permissionsLabel,
self.permissionsEdit)
self.licenseDetailsLayout.addRow(self.permissionsLabel, self.permissionsEdit)
self.metaTabLayout.addWidget(self.licenseDetailsGroupBox)
self.languageSelectionGroupBox = QtGui.QGroupBox(self.metaTab)
self.languageSelectionGroupBox.setObjectName(
u'languageSelectionGroupBox')
self.languageSelectionLayout = QtGui.QVBoxLayout(
self.languageSelectionGroupBox)
self.languageSelectionLabel = QtGui.QLabel(
self.languageSelectionGroupBox)
self.languageSelectionGroupBox.setObjectName(u'languageSelectionGroupBox')
self.languageSelectionLayout = QtGui.QVBoxLayout(self.languageSelectionGroupBox)
self.languageSelectionLabel = QtGui.QLabel(self.languageSelectionGroupBox)
self.languageSelectionLabel.setObjectName(u'languageSelectionLabel')
self.languageSelectionComboBox = QtGui.QComboBox(
self.languageSelectionGroupBox)
self.languageSelectionComboBox.setObjectName(
u'languageSelectionComboBox')
self.languageSelectionComboBox = QtGui.QComboBox(self.languageSelectionGroupBox)
self.languageSelectionComboBox.setObjectName(u'languageSelectionComboBox')
self.languageSelectionComboBox.addItems([u'', u'', u'', u''])
self.languageSelectionLayout.addWidget(self.languageSelectionLabel)
self.languageSelectionLayout.addWidget(self.languageSelectionComboBox)
@ -110,8 +100,7 @@ class Ui_EditBibleDialog(object):
self.scrollArea = QtGui.QScrollArea(self.bookNameTab)
self.scrollArea.setWidgetResizable(True)
self.scrollArea.setObjectName(u'scrollArea')
self.scrollArea.setHorizontalScrollBarPolicy(
QtCore.Qt.ScrollBarAlwaysOff)
self.scrollArea.setHorizontalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOff)
self.bookNameWidget = QtGui.QWidget(self.scrollArea)
self.bookNameWidget.setObjectName(u'bookNameWidget')
self.bookNameWidgetLayout = QtGui.QFormLayout(self.bookNameWidget)
@ -119,14 +108,10 @@ class Ui_EditBibleDialog(object):
self.bookNameLabel = {}
self.bookNameEdit= {}
for book in BiblesResourcesDB.get_books():
self.bookNameLabel[book[u'abbreviation']] = QtGui.QLabel(
self.bookNameWidget)
self.bookNameLabel[book[u'abbreviation']].setObjectName(
u'bookNameLabel[%s]' % book[u'abbreviation'])
self.bookNameEdit[book[u'abbreviation']] = QtGui.QLineEdit(
self.bookNameWidget)
self.bookNameEdit[book[u'abbreviation']].setObjectName(
u'bookNameEdit[%s]' % book[u'abbreviation'])
self.bookNameLabel[book[u'abbreviation']] = QtGui.QLabel(self.bookNameWidget)
self.bookNameLabel[book[u'abbreviation']].setObjectName(u'bookNameLabel[%s]' % book[u'abbreviation'])
self.bookNameEdit[book[u'abbreviation']] = QtGui.QLineEdit(self.bookNameWidget)
self.bookNameEdit[book[u'abbreviation']].setObjectName(u'bookNameEdit[%s]' % book[u'abbreviation'])
self.bookNameWidgetLayout.addRow(
self.bookNameLabel[book[u'abbreviation']],
self.bookNameEdit[book[u'abbreviation']])
@ -136,48 +121,33 @@ class Ui_EditBibleDialog(object):
self.bibleTabWidget.addTab(self.bookNameTab, u'')
# Last few bits
self.dialogLayout.addWidget(self.bibleTabWidget)
self.buttonBox = create_button_box(editBibleDialog, u'buttonBox',
[u'cancel', u'save'])
self.buttonBox = create_button_box(editBibleDialog, u'buttonBox', [u'cancel', u'save'])
self.dialogLayout.addWidget(self.buttonBox)
self.retranslateUi(editBibleDialog)
QtCore.QMetaObject.connectSlotsByName(editBibleDialog)
def retranslateUi(self, editBibleDialog):
self.book_names = BibleStrings().BookNames
editBibleDialog.setWindowTitle(
translate('BiblesPlugin.EditBibleForm', 'Bible Editor'))
editBibleDialog.setWindowTitle(translate('BiblesPlugin.EditBibleForm', 'Bible Editor'))
# Meta tab
self.bibleTabWidget.setTabText(
self.bibleTabWidget.indexOf(self.metaTab),
self.bibleTabWidget.setTabText( self.bibleTabWidget.indexOf(self.metaTab),
translate('SongsPlugin.EditBibleForm', 'Meta Data'))
self.licenseDetailsGroupBox.setTitle(
translate('BiblesPlugin.EditBibleForm', 'License Details'))
self.versionNameLabel.setText(
translate('BiblesPlugin.EditBibleForm', 'Version name:'))
self.copyrightLabel.setText(
translate('BiblesPlugin.EditBibleForm', 'Copyright:'))
self.permissionsLabel.setText(
translate('BiblesPlugin.EditBibleForm', 'Permissions:'))
self.languageSelectionGroupBox.setTitle(translate(
'BiblesPlugin.EditBibleForm', 'Default Bible Language'))
self.languageSelectionLabel.setText(
translate('BiblesPlugin.EditBibleForm',
'Book name language in search field, search results and on '
'display:'))
self.languageSelectionComboBox.setItemText(0,
translate('BiblesPlugin.EditBibleForm', 'Global Settings'))
self.licenseDetailsGroupBox.setTitle(translate('BiblesPlugin.EditBibleForm', 'License Details'))
self.versionNameLabel.setText(translate('BiblesPlugin.EditBibleForm', 'Version name:'))
self.copyrightLabel.setText(translate('BiblesPlugin.EditBibleForm', 'Copyright:'))
self.permissionsLabel.setText(translate('BiblesPlugin.EditBibleForm', 'Permissions:'))
self.languageSelectionGroupBox.setTitle(translate('BiblesPlugin.EditBibleForm', 'Default Bible Language'))
self.languageSelectionLabel.setText(translate('BiblesPlugin.EditBibleForm',
'Book name language in search field, search results and on display:'))
self.languageSelectionComboBox.setItemText(0, translate('BiblesPlugin.EditBibleForm', 'Global Settings'))
self.languageSelectionComboBox.setItemText(LanguageSelection.Bible + 1,
translate('BiblesPlugin.EditBibleForm', 'Bible Language'))
self.languageSelectionComboBox.setItemText(
LanguageSelection.Application + 1,
self.languageSelectionComboBox.setItemText(LanguageSelection.Application + 1,
translate('BiblesPlugin.EditBibleForm', 'Application Language'))
self.languageSelectionComboBox.setItemText(
LanguageSelection.English + 1,
self.languageSelectionComboBox.setItemText(LanguageSelection.English + 1,
translate('BiblesPlugin.EditBibleForm', 'English'))
# Book name tab
self.bibleTabWidget.setTabText(
self.bibleTabWidget.indexOf(self.bookNameTab),
self.bibleTabWidget.setTabText(self.bibleTabWidget.indexOf(self.bookNameTab),
translate('SongsPlugin.EditBibleForm', 'Custom Book Names'))
for book in BiblesResourcesDB.get_books():
self.bookNameLabel[book[u'abbreviation']].setText(
u'%s:' % unicode(self.book_names[book[u'abbreviation']]))
self.bookNameLabel[book[u'abbreviation']].setText(u'%s:' % unicode(self.book_names[book[u'abbreviation']]))

View File

@ -1,5 +1,5 @@
# -*- coding: utf-8 -*-
# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4
# vim: autoindent shiftwidth=4 expandtab textwidth=120 tabstop=4 softtabstop=4
###############################################################################
# OpenLP - Open Source Lyrics Projection #
@ -65,44 +65,32 @@ class EditBibleForm(QtGui.QDialog, Ui_EditBibleDialog):
"""
log.debug(u'Load Bible')
self.bible = bible
self.versionNameEdit.setText(
self.manager.get_meta_data(self.bible, u'name').value)
self.copyrightEdit.setText(
self.manager.get_meta_data(self.bible, u'copyright').value)
self.permissionsEdit.setText(
self.manager.get_meta_data(self.bible, u'permissions').value)
book_name_language = self.manager.get_meta_data(self.bible,
u'book_name_language')
self.versionNameEdit.setText(self.manager.get_meta_data(self.bible, u'name').value)
self.copyrightEdit.setText(self.manager.get_meta_data(self.bible, u'copyright').value)
self.permissionsEdit.setText(self.manager.get_meta_data(self.bible, u'permissions').value)
book_name_language = self.manager.get_meta_data(self.bible, u'book_name_language')
if book_name_language and book_name_language.value != u'None':
self.languageSelectionComboBox.setCurrentIndex(
int(book_name_language.value) + 1)
self.languageSelectionComboBox.setCurrentIndex(int(book_name_language.value) + 1)
self.books = {}
self.webbible = self.manager.get_meta_data(self.bible,
u'download_source')
self.webbible = self.manager.get_meta_data(self.bible, u'download_source')
if self.webbible:
self.bookNameNotice.setText(translate('BiblesPlugin.EditBibleForm',
'This is a Web Download Bible.\nIt is not possible to '
'customize the Book Names.'))
'This is a Web Download Bible.\nIt is not possible to customize the Book Names.'))
self.scrollArea.hide()
else:
self.bookNameNotice.setText(translate('BiblesPlugin.EditBibleForm',
'To use the customized book names, "Bible language" must be '
'selected on the Meta Data tab or, if "Global settings" is '
'selected, on the Bible page in Configure OpenLP.'))
'To use the customized book names, "Bible language" must be selected on the Meta Data tab or, '
'if "Global settings" is selected, on the Bible page in Configure OpenLP.'))
for book in BiblesResourcesDB.get_books():
self.books[book[u'abbreviation']] = self.manager.get_book_by_id(
self.bible, book[u'id'])
self.books[book[u'abbreviation']] = self.manager.get_book_by_id(self.bible, book[u'id'])
if self.books[book[u'abbreviation']] and not self.webbible:
self.bookNameEdit[book[u'abbreviation']].setText(
self.books[book[u'abbreviation']].name)
self.bookNameEdit[book[u'abbreviation']].setText(self.books[book[u'abbreviation']].name)
else:
# It is nessecary to remove the Widget otherwise there still
# It is necessary to remove the Widget otherwise there still
# exists the vertical spacing in QFormLayout
self.bookNameWidgetLayout.removeWidget(
self.bookNameLabel[book[u'abbreviation']])
self.bookNameWidgetLayout.removeWidget(self.bookNameLabel[book[u'abbreviation']])
self.bookNameLabel[book[u'abbreviation']].hide()
self.bookNameWidgetLayout.removeWidget(
self.bookNameEdit[book[u'abbreviation']])
self.bookNameWidgetLayout.removeWidget(self.bookNameEdit[book[u'abbreviation']])
self.bookNameEdit[book[u'abbreviation']].hide()
def reject(self):
@ -136,8 +124,7 @@ class EditBibleForm(QtGui.QDialog, Ui_EditBibleDialog):
return
Receiver.send_message(u'openlp_process_events')
Receiver.send_message(u'cursor_busy')
self.manager.save_meta_data(self.bible, version, copyright, permissions,
book_name_language)
self.manager.save_meta_data(self.bible, version, copyright, permissions, book_name_language)
if not self.webbible:
for abbr, book in self.books.iteritems():
if book:
@ -155,24 +142,19 @@ class EditBibleForm(QtGui.QDialog, Ui_EditBibleDialog):
if not name:
self.versionNameEdit.setFocus()
critical_error_message_box(UiStrings().EmptyField,
translate('BiblesPlugin.BibleEditForm',
'You need to specify a version name for your Bible.'))
translate('BiblesPlugin.BibleEditForm', 'You need to specify a version name for your Bible.'))
return False
elif not copyright:
self.copyrightEdit.setFocus()
critical_error_message_box(UiStrings().EmptyField,
translate('BiblesPlugin.BibleEditForm',
'You need to set a copyright for your Bible. '
'Bibles in the Public Domain need to be marked as such.'))
'You need to set a copyright for your Bible. Bibles in the Public Domain need to be marked as such.'))
return False
elif self.manager.exists(name) and \
self.manager.get_meta_data(self.bible, u'name').value != \
elif self.manager.exists(name) and self.manager.get_meta_data(self.bible, u'name').value != \
name:
self.versionNameEdit.setFocus()
critical_error_message_box(
translate('BiblesPlugin.BibleEditForm', 'Bible Exists'),
translate('BiblesPlugin.BibleEditForm',
'This Bible already exists. Please import '
critical_error_message_box(translate('BiblesPlugin.BibleEditForm', 'Bible Exists'),
translate('BiblesPlugin.BibleEditForm', 'This Bible already exists. Please import '
'a different Bible or first delete the existing one.'))
return False
return True
@ -185,17 +167,15 @@ class EditBibleForm(QtGui.QDialog, Ui_EditBibleDialog):
if not new_book_name:
self.bookNameEdit[abbreviation].setFocus()
critical_error_message_box(UiStrings().EmptyField,
translate('BiblesPlugin.BibleEditForm',
'You need to specify a book name for "%s".') %
translate('BiblesPlugin.BibleEditForm', 'You need to specify a book name for "%s".') %
self.book_names[abbreviation])
return False
elif not book_regex.match(new_book_name):
self.bookNameEdit[abbreviation].setFocus()
critical_error_message_box(UiStrings().EmptyField,
translate('BiblesPlugin.BibleEditForm',
'The book name "%s" is not correct.\nNumbers can only be used '
'at the beginning and must\nbe followed by one or more '
'non-numeric characters.') % new_book_name)
'The book name "%s" is not correct.\nNumbers can only be used at the beginning and must\nbe '
'followed by one or more non-numeric characters.') % new_book_name)
return False
for abbr, book in self.books.iteritems():
if book:
@ -204,10 +184,8 @@ class EditBibleForm(QtGui.QDialog, Ui_EditBibleDialog):
if self.bookNameEdit[abbr].text() == new_book_name:
self.bookNameEdit[abbreviation].setFocus()
critical_error_message_box(
translate('BiblesPlugin.BibleEditForm',
'Duplicate Book Name'),
translate('BiblesPlugin.BibleEditForm',
'The Book Name "%s" has been entered more than once.')
translate('BiblesPlugin.BibleEditForm', 'Duplicate Book Name'),
translate('BiblesPlugin.BibleEditForm', 'The Book Name "%s" has been entered more than once.')
% new_book_name)
return False
return True

View File

@ -1,5 +1,5 @@
# -*- coding: utf-8 -*-
# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4
# vim: autoindent shiftwidth=4 expandtab textwidth=120 tabstop=4 softtabstop=4
###############################################################################
# OpenLP - Open Source Lyrics Projection #
@ -54,28 +54,23 @@ class Ui_LanguageDialog(object):
self.languageLabel.setObjectName(u'languageLabel')
self.languageHBoxLayout.addWidget(self.languageLabel)
self.languageComboBox = QtGui.QComboBox(languageDialog)
sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.MinimumExpanding,
QtGui.QSizePolicy.Fixed)
sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.MinimumExpanding, QtGui.QSizePolicy.Fixed)
sizePolicy.setHorizontalStretch(0)
sizePolicy.setVerticalStretch(0)
sizePolicy.setHeightForWidth(
self.languageComboBox.sizePolicy().hasHeightForWidth())
sizePolicy.setHeightForWidth(self.languageComboBox.sizePolicy().hasHeightForWidth())
self.languageComboBox.setSizePolicy(sizePolicy)
self.languageComboBox.setObjectName(u'languageComboBox')
self.languageHBoxLayout.addWidget(self.languageComboBox)
self.languageLayout.addLayout(self.languageHBoxLayout)
self.buttonBox = create_button_box(languageDialog, u'buttonBox',
[u'cancel', u'ok'])
self.buttonBox = create_button_box(languageDialog, u'buttonBox', [u'cancel', u'ok'])
self.languageLayout.addWidget(self.buttonBox)
self.retranslateUi(languageDialog)
def retranslateUi(self, languageDialog):
languageDialog.setWindowTitle(
translate('BiblesPlugin.LanguageDialog', 'Select Language'))
languageDialog.setWindowTitle(translate('BiblesPlugin.LanguageDialog', 'Select Language'))
self.bibleLabel.setText(translate('BiblesPlugin.LanguageDialog', ''))
self.infoLabel.setText(translate('BiblesPlugin.LanguageDialog',
'OpenLP is unable to determine the language of this translation '
'of the Bible. Please select the language from the list below.'))
self.languageLabel.setText(translate('BiblesPlugin.LanguageDialog',
'Language:'))
'OpenLP is unable to determine the language of this translation of the Bible. Please select the language '
'from the list below.'))
self.languageLabel.setText(translate('BiblesPlugin.LanguageDialog', 'Language:'))

View File

@ -1,5 +1,5 @@
# -*- coding: utf-8 -*-
# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4
# vim: autoindent shiftwidth=4 expandtab textwidth=120 tabstop=4 softtabstop=4
###############################################################################
# OpenLP - Open Source Lyrics Projection #
@ -182,8 +182,7 @@ def update_reference_separators():
references.
"""
default_separators = translate('BiblesPlugin',
':|v|V|verse|verses;;-|to;;,|and;;end',
'Double-semicolon delimited separators for parsing references. '
':|v|V|verse|verses;;-|to;;,|and;;end Double-semicolon delimited separators for parsing references. '
'Consult the developers for further information.').split(u';;')
settings = Settings()
settings.beginGroup(u'bibles')
@ -201,8 +200,7 @@ def update_reference_separators():
while u'||' in source_string:
source_string = source_string.replace(u'||', u'|')
if role != u'e':
REFERENCE_SEPARATORS[u'sep_%s_display' % role] = \
source_string.split(u'|')[0]
REFERENCE_SEPARATORS[u'sep_%s_display' % role] = source_string.split(u'|')[0]
# escape reserved characters
for character in u'\\.^$*+?{}[]()':
source_string = source_string.replace(character, u'\\' + character)
@ -211,23 +209,17 @@ def update_reference_separators():
u'(?:[-\u00AD\u2010\u2011\u2012\u2013\u2014\u2212\uFE63\uFF0D])')
source_string = source_string.replace(u',', u'(?:[,\u201A])')
REFERENCE_SEPARATORS[u'sep_%s' % role] = u'\s*(?:%s)\s*' % source_string
REFERENCE_SEPARATORS[u'sep_%s_default' % role] = \
default_separators[index]
REFERENCE_SEPARATORS[u'sep_%s_default' % role] = default_separators[index]
# verse range match: (<chapter>:)?<verse>(-((<chapter>:)?<verse>|end)?)?
range_regex = u'(?:(?P<from_chapter>[0-9]+)%(sep_v)s)?' \
u'(?P<from_verse>[0-9]+)(?P<range_to>%(sep_r)s(?:(?:(?P<to_chapter>' \
u'[0-9]+)%(sep_v)s)?(?P<to_verse>[0-9]+)|%(sep_e)s)?)?' % \
REFERENCE_SEPARATORS
REFERENCE_MATCHES[u'range'] = re.compile(u'^\s*%s\s*$' % range_regex,
re.UNICODE)
REFERENCE_MATCHES[u'range_separator'] = re.compile(
REFERENCE_SEPARATORS[u'sep_l'], re.UNICODE)
u'[0-9]+)%(sep_v)s)?(?P<to_verse>[0-9]+)|%(sep_e)s)?)?' % REFERENCE_SEPARATORS
REFERENCE_MATCHES[u'range'] = re.compile(u'^\s*%s\s*$' % range_regex, re.UNICODE)
REFERENCE_MATCHES[u'range_separator'] = re.compile(REFERENCE_SEPARATORS[u'sep_l'], re.UNICODE)
# full reference match: <book>(<range>(,(?!$)|(?=$)))+
REFERENCE_MATCHES[u'full'] = re.compile(
u'^\s*(?!\s)(?P<book>[\d]*[^\d]+)(?<!\s)\s*'
REFERENCE_MATCHES[u'full'] = re.compile(u'^\s*(?!\s)(?P<book>[\d]*[^\d]+)(?<!\s)\s*'
u'(?P<ranges>(?:%(range_regex)s(?:%(sep_l)s(?!\s*$)|(?=\s*$)))+)\s*$' \
% dict(REFERENCE_SEPARATORS.items() + [(u'range_regex', range_regex)]),
re.UNICODE)
% dict(REFERENCE_SEPARATORS.items() + [(u'range_regex', range_regex)]), re.UNICODE)
def get_reference_separator(separator_type):
"""
@ -355,8 +347,7 @@ def parse_reference(reference, bible, language_selection, book_ref_id=False):
log.debug(u'Matched reference %s' % reference)
book = match.group(u'book')
if not book_ref_id:
book_ref_id = bible.get_book_ref_id_by_localised_name(
book, language_selection)
book_ref_id = bible.get_book_ref_id_by_localised_name(book, language_selection)
elif not bible.get_book_by_book_ref_id(book_ref_id):
book_ref_id = False
ranges = match.group(u'ranges')
@ -409,11 +400,9 @@ def parse_reference(reference, bible, language_selection, book_ref_id=False):
ref_list.append((book_ref_id, i, 1, -1))
ref_list.append((book_ref_id, to_chapter, 1, to_verse))
elif to_verse >= from_verse or to_verse == -1:
ref_list.append((book_ref_id, from_chapter,
from_verse, to_verse))
ref_list.append((book_ref_id, from_chapter, from_verse, to_verse))
elif from_verse:
ref_list.append((book_ref_id, from_chapter,
from_verse, from_verse))
ref_list.append((book_ref_id, from_chapter, from_verse, from_verse))
else:
ref_list.append((book_ref_id, from_chapter, 1, -1))
return ref_list

View File

@ -1,5 +1,5 @@
# -*- coding: utf-8 -*-
# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4
# vim: autoindent shiftwidth=4 expandtab textwidth=120 tabstop=4 softtabstop=4
###############################################################################
# OpenLP - Open Source Lyrics Projection #
@ -33,8 +33,8 @@ from PyQt4 import QtCore, QtGui
from openlp.core.lib import Receiver, SettingsTab, translate, Settings
from openlp.core.lib.ui import UiStrings, find_and_set_in_combo_box
from openlp.plugins.bibles.lib import LayoutStyle, DisplayStyle, \
update_reference_separators, get_reference_separator, LanguageSelection
from openlp.plugins.bibles.lib import LayoutStyle, DisplayStyle, update_reference_separators, \
get_reference_separator, LanguageSelection
log = logging.getLogger(__name__)
@ -65,97 +65,68 @@ class BiblesTab(SettingsTab):
self.displayStyleComboBox = QtGui.QComboBox(self.verseDisplayGroupBox)
self.displayStyleComboBox.addItems([u'', u'', u'', u''])
self.displayStyleComboBox.setObjectName(u'displayStyleComboBox')
self.verseDisplayLayout.addRow(self.displayStyleLabel,
self.displayStyleComboBox)
self.verseDisplayLayout.addRow(self.displayStyleLabel, self.displayStyleComboBox)
self.layoutStyleLabel = QtGui.QLabel(self.verseDisplayGroupBox)
self.layoutStyleLabel.setObjectName(u'layoutStyleLabel')
self.layoutStyleComboBox = QtGui.QComboBox(self.verseDisplayGroupBox)
self.layoutStyleComboBox.setObjectName(u'layoutStyleComboBox')
self.layoutStyleComboBox.addItems([u'', u'', u''])
self.verseDisplayLayout.addRow(self.layoutStyleLabel,
self.layoutStyleComboBox)
self.verseDisplayLayout.addRow(self.layoutStyleLabel, self.layoutStyleComboBox)
self.bibleSecondCheckBox = QtGui.QCheckBox(self.verseDisplayGroupBox)
self.bibleSecondCheckBox.setObjectName(u'bibleSecondCheckBox')
self.verseDisplayLayout.addRow(self.bibleSecondCheckBox)
self.bibleThemeLabel = QtGui.QLabel(self.verseDisplayGroupBox)
self.bibleThemeLabel.setObjectName(u'BibleThemeLabel')
self.bibleThemeComboBox = QtGui.QComboBox(self.verseDisplayGroupBox)
self.bibleThemeComboBox.setSizeAdjustPolicy(
QtGui.QComboBox.AdjustToMinimumContentsLength)
self.bibleThemeComboBox.setSizePolicy(
QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Fixed)
self.bibleThemeComboBox.setSizeAdjustPolicy(QtGui.QComboBox.AdjustToMinimumContentsLength)
self.bibleThemeComboBox.setSizePolicy(QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Fixed)
self.bibleThemeComboBox.addItem(u'')
self.bibleThemeComboBox.setObjectName(u'BibleThemeComboBox')
self.verseDisplayLayout.addRow(self.bibleThemeLabel,
self.bibleThemeComboBox)
self.verseDisplayLayout.addRow(self.bibleThemeLabel, self.bibleThemeComboBox)
self.changeNoteLabel = QtGui.QLabel(self.verseDisplayGroupBox)
self.changeNoteLabel.setWordWrap(True)
self.changeNoteLabel.setObjectName(u'changeNoteLabel')
self.verseDisplayLayout.addRow(self.changeNoteLabel)
self.leftLayout.addWidget(self.verseDisplayGroupBox)
self.scriptureReferenceGroupBox = QtGui.QGroupBox(self.leftColumn)
self.scriptureReferenceGroupBox.setObjectName(
u'scriptureReferenceGroupBox')
self.scriptureReferenceLayout = QtGui.QGridLayout(
self.scriptureReferenceGroupBox)
self.verseSeparatorCheckBox = QtGui.QCheckBox(
self.scriptureReferenceGroupBox)
self.scriptureReferenceGroupBox.setObjectName(u'scriptureReferenceGroupBox')
self.scriptureReferenceLayout = QtGui.QGridLayout(self.scriptureReferenceGroupBox)
self.verseSeparatorCheckBox = QtGui.QCheckBox(self.scriptureReferenceGroupBox)
self.verseSeparatorCheckBox.setObjectName(u'verseSeparatorCheckBox')
self.scriptureReferenceLayout.addWidget(self.verseSeparatorCheckBox, 0,
0)
self.verseSeparatorLineEdit = QtGui.QLineEdit(
self.scriptureReferenceGroupBox)
self.scriptureReferenceLayout.addWidget(self.verseSeparatorCheckBox, 0, 0)
self.verseSeparatorLineEdit = QtGui.QLineEdit(self.scriptureReferenceGroupBox)
# self.verseSeparatorLineEdit.setPalette
self.verseSeparatorLineEdit.setObjectName(u'verseSeparatorLineEdit')
self.scriptureReferenceLayout.addWidget(self.verseSeparatorLineEdit, 0,
1)
self.rangeSeparatorCheckBox = QtGui.QCheckBox(
self.scriptureReferenceGroupBox)
self.scriptureReferenceLayout.addWidget(self.verseSeparatorLineEdit, 0, 1)
self.rangeSeparatorCheckBox = QtGui.QCheckBox(self.scriptureReferenceGroupBox)
self.rangeSeparatorCheckBox.setObjectName(u'rangeSeparatorCheckBox')
self.scriptureReferenceLayout.addWidget(self.rangeSeparatorCheckBox, 1,
0)
self.rangeSeparatorLineEdit = QtGui.QLineEdit(
self.scriptureReferenceGroupBox)
self.scriptureReferenceLayout.addWidget(self.rangeSeparatorCheckBox, 1, 0)
self.rangeSeparatorLineEdit = QtGui.QLineEdit(self.scriptureReferenceGroupBox)
self.rangeSeparatorLineEdit.setObjectName(u'rangeSeparatorLineEdit')
self.scriptureReferenceLayout.addWidget(self.rangeSeparatorLineEdit, 1,
1)
self.listSeparatorCheckBox = QtGui.QCheckBox(
self.scriptureReferenceGroupBox)
self.scriptureReferenceLayout.addWidget(self.rangeSeparatorLineEdit, 1, 1)
self.listSeparatorCheckBox = QtGui.QCheckBox(self.scriptureReferenceGroupBox)
self.listSeparatorCheckBox.setObjectName(u'listSeparatorCheckBox')
self.scriptureReferenceLayout.addWidget(self.listSeparatorCheckBox, 2,
0)
self.listSeparatorLineEdit = QtGui.QLineEdit(
self.scriptureReferenceGroupBox)
self.scriptureReferenceLayout.addWidget(self.listSeparatorCheckBox, 2, 0)
self.listSeparatorLineEdit = QtGui.QLineEdit(self.scriptureReferenceGroupBox)
self.listSeparatorLineEdit.setObjectName(u'listSeparatorLineEdit')
self.scriptureReferenceLayout.addWidget(self.listSeparatorLineEdit, 2,
1)
self.endSeparatorCheckBox = QtGui.QCheckBox(
self.scriptureReferenceGroupBox)
self.scriptureReferenceLayout.addWidget(self.listSeparatorLineEdit, 2, 1)
self.endSeparatorCheckBox = QtGui.QCheckBox(self.scriptureReferenceGroupBox)
self.endSeparatorCheckBox.setObjectName(u'endSeparatorCheckBox')
self.scriptureReferenceLayout.addWidget(self.endSeparatorCheckBox, 3,
0)
self.endSeparatorLineEdit = QtGui.QLineEdit(
self.scriptureReferenceGroupBox)
self.scriptureReferenceLayout.addWidget(self.endSeparatorCheckBox, 3, 0)
self.endSeparatorLineEdit = QtGui.QLineEdit(self.scriptureReferenceGroupBox)
self.endSeparatorLineEdit.setObjectName(u'endSeparatorLineEdit')
self.endSeparatorLineEdit.setValidator(QtGui.QRegExpValidator(
QtCore.QRegExp(r'[^0-9]*'), self.endSeparatorLineEdit))
self.scriptureReferenceLayout.addWidget(self.endSeparatorLineEdit, 3,
1)
self.endSeparatorLineEdit.setValidator(QtGui.QRegExpValidator(QtCore.QRegExp(r'[^0-9]*'),
self.endSeparatorLineEdit))
self.scriptureReferenceLayout.addWidget(self.endSeparatorLineEdit, 3, 1)
self.leftLayout.addWidget(self.scriptureReferenceGroupBox)
self.rightColumn.setSizePolicy(
QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Preferred)
self.rightColumn.setSizePolicy(QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Preferred)
self.languageSelectionGroupBox = QtGui.QGroupBox(self.rightColumn)
self.languageSelectionGroupBox.setObjectName(
u'languageSelectionGroupBox')
self.languageSelectionLayout = QtGui.QVBoxLayout(
self.languageSelectionGroupBox)
self.languageSelectionLabel = QtGui.QLabel(
self.languageSelectionGroupBox)
self.languageSelectionGroupBox.setObjectName(u'languageSelectionGroupBox')
self.languageSelectionLayout = QtGui.QVBoxLayout(self.languageSelectionGroupBox)
self.languageSelectionLabel = QtGui.QLabel(self.languageSelectionGroupBox)
self.languageSelectionLabel.setObjectName(u'languageSelectionLabel')
self.languageSelectionComboBox = QtGui.QComboBox(
self.languageSelectionGroupBox)
self.languageSelectionComboBox.setObjectName(
u'languageSelectionComboBox')
self.languageSelectionComboBox = QtGui.QComboBox(self.languageSelectionGroupBox)
self.languageSelectionComboBox.setObjectName(u'languageSelectionComboBox')
self.languageSelectionComboBox.addItems([u'', u'', u''])
self.languageSelectionLayout.addWidget(self.languageSelectionLabel)
self.languageSelectionLayout.addWidget(self.languageSelectionComboBox)
@ -163,79 +134,53 @@ class BiblesTab(SettingsTab):
self.leftLayout.addStretch()
self.rightLayout.addStretch()
# Signals and slots
QtCore.QObject.connect(
self.newChaptersCheckBox, QtCore.SIGNAL(u'stateChanged(int)'),
QtCore.QObject.connect(self.newChaptersCheckBox, QtCore.SIGNAL(u'stateChanged(int)'),
self.onNewChaptersCheckBoxChanged)
QtCore.QObject.connect(
self.displayStyleComboBox, QtCore.SIGNAL(u'activated(int)'),
QtCore.QObject.connect(self.displayStyleComboBox, QtCore.SIGNAL(u'activated(int)'),
self.onDisplayStyleComboBoxChanged)
QtCore.QObject.connect(
self.bibleThemeComboBox, QtCore.SIGNAL(u'activated(int)'),
QtCore.QObject.connect(self.bibleThemeComboBox, QtCore.SIGNAL(u'activated(int)'),
self.onBibleThemeComboBoxChanged)
QtCore.QObject.connect(
self.layoutStyleComboBox, QtCore.SIGNAL(u'activated(int)'),
QtCore.QObject.connect(self.layoutStyleComboBox, QtCore.SIGNAL(u'activated(int)'),
self.onLayoutStyleComboBoxChanged)
QtCore.QObject.connect(
self.bibleSecondCheckBox, QtCore.SIGNAL(u'stateChanged(int)'),
QtCore.QObject.connect(self.bibleSecondCheckBox, QtCore.SIGNAL(u'stateChanged(int)'),
self.onBibleSecondCheckBox)
QtCore.QObject.connect(
self.verseSeparatorCheckBox, QtCore.SIGNAL(u'clicked(bool)'),
QtCore.QObject.connect(self.verseSeparatorCheckBox, QtCore.SIGNAL(u'clicked(bool)'),
self.onVerseSeparatorCheckBoxClicked)
QtCore.QObject.connect(
self.verseSeparatorLineEdit, QtCore.SIGNAL(u'textEdited(QString)'),
QtCore.QObject.connect(self.verseSeparatorLineEdit, QtCore.SIGNAL(u'textEdited(QString)'),
self.onVerseSeparatorLineEditEdited)
QtCore.QObject.connect(
self.verseSeparatorLineEdit, QtCore.SIGNAL(u'editingFinished()'),
QtCore.QObject.connect(self.verseSeparatorLineEdit, QtCore.SIGNAL(u'editingFinished()'),
self.onVerseSeparatorLineEditFinished)
QtCore.QObject.connect(
self.rangeSeparatorCheckBox, QtCore.SIGNAL(u'clicked(bool)'),
QtCore.QObject.connect(self.rangeSeparatorCheckBox, QtCore.SIGNAL(u'clicked(bool)'),
self.onRangeSeparatorCheckBoxClicked)
QtCore.QObject.connect(
self.rangeSeparatorLineEdit, QtCore.SIGNAL(u'textEdited(QString)'),
QtCore.QObject.connect(self.rangeSeparatorLineEdit, QtCore.SIGNAL(u'textEdited(QString)'),
self.onRangeSeparatorLineEditEdited)
QtCore.QObject.connect(
self.rangeSeparatorLineEdit, QtCore.SIGNAL(u'editingFinished()'),
QtCore.QObject.connect(self.rangeSeparatorLineEdit, QtCore.SIGNAL(u'editingFinished()'),
self.onRangeSeparatorLineEditFinished)
QtCore.QObject.connect(
self.listSeparatorCheckBox, QtCore.SIGNAL(u'clicked(bool)'),
QtCore.QObject.connect(self.listSeparatorCheckBox, QtCore.SIGNAL(u'clicked(bool)'),
self.onListSeparatorCheckBoxClicked)
QtCore.QObject.connect(
self.listSeparatorLineEdit, QtCore.SIGNAL(u'textEdited(QString)'),
QtCore.QObject.connect(self.listSeparatorLineEdit, QtCore.SIGNAL(u'textEdited(QString)'),
self.onListSeparatorLineEditEdited)
QtCore.QObject.connect(
self.listSeparatorLineEdit, QtCore.SIGNAL(u'editingFinished()'),
QtCore.QObject.connect(self.listSeparatorLineEdit, QtCore.SIGNAL(u'editingFinished()'),
self.onListSeparatorLineEditFinished)
QtCore.QObject.connect(
self.endSeparatorCheckBox, QtCore.SIGNAL(u'clicked(bool)'),
QtCore.QObject.connect(self.endSeparatorCheckBox, QtCore.SIGNAL(u'clicked(bool)'),
self.onEndSeparatorCheckBoxClicked)
QtCore.QObject.connect(
self.endSeparatorLineEdit, QtCore.SIGNAL(u'textEdited(QString)'),
QtCore.QObject.connect(self.endSeparatorLineEdit, QtCore.SIGNAL(u'textEdited(QString)'),
self.onEndSeparatorLineEditEdited)
QtCore.QObject.connect(
self.endSeparatorLineEdit, QtCore.SIGNAL(u'editingFinished()'),
QtCore.QObject.connect(self.endSeparatorLineEdit, QtCore.SIGNAL(u'editingFinished()'),
self.onEndSeparatorLineEditFinished)
QtCore.QObject.connect(Receiver.get_receiver(),
QtCore.SIGNAL(u'theme_update_list'), self.updateThemeList)
QtCore.QObject.connect(
self.languageSelectionComboBox, QtCore.SIGNAL(u'activated(int)'),
QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'theme_update_list'), self.updateThemeList)
QtCore.QObject.connect(self.languageSelectionComboBox, QtCore.SIGNAL(u'activated(int)'),
self.onLanguageSelectionComboBoxChanged)
def retranslateUi(self):
self.verseDisplayGroupBox.setTitle(
translate('BiblesPlugin.BiblesTab', 'Verse Display'))
self.newChaptersCheckBox.setText(
translate('BiblesPlugin.BiblesTab',
'Only show new chapter numbers'))
self.verseDisplayGroupBox.setTitle(translate('BiblesPlugin.BiblesTab', 'Verse Display'))
self.newChaptersCheckBox.setText(translate('BiblesPlugin.BiblesTab', 'Only show new chapter numbers'))
self.layoutStyleLabel.setText(UiStrings().LayoutStyle)
self.displayStyleLabel.setText(UiStrings().DisplayStyle)
self.bibleThemeLabel.setText(
translate('BiblesPlugin.BiblesTab', 'Bible theme:'))
self.layoutStyleComboBox.setItemText(LayoutStyle.VersePerSlide,
UiStrings().VersePerSlide)
self.layoutStyleComboBox.setItemText(LayoutStyle.VersePerLine,
UiStrings().VersePerLine)
self.layoutStyleComboBox.setItemText(LayoutStyle.Continuous,
UiStrings().Continuous)
self.bibleThemeLabel.setText(translate('BiblesPlugin.BiblesTab', 'Bible theme:'))
self.layoutStyleComboBox.setItemText(LayoutStyle.VersePerSlide, UiStrings().VersePerSlide)
self.layoutStyleComboBox.setItemText(LayoutStyle.VersePerLine, UiStrings().VersePerLine)
self.layoutStyleComboBox.setItemText(LayoutStyle.Continuous, UiStrings().Continuous)
self.displayStyleComboBox.setItemText(DisplayStyle.NoBrackets,
translate('BiblesPlugin.BiblesTab', 'No Brackets'))
self.displayStyleComboBox.setItemText(DisplayStyle.Round,
@ -246,18 +191,13 @@ class BiblesTab(SettingsTab):
translate('BiblesPlugin.BiblesTab', '[ And ]'))
self.changeNoteLabel.setText(translate('BiblesPlugin.BiblesTab',
'Note:\nChanges do not affect verses already in the service.'))
self.bibleSecondCheckBox.setText(
translate('BiblesPlugin.BiblesTab', 'Display second Bible verses'))
self.scriptureReferenceGroupBox.setTitle(
translate('BiblesPlugin.BiblesTab', 'Custom Scripture References'))
self.verseSeparatorCheckBox.setText(
translate('BiblesPlugin.BiblesTab', 'Verse Separator:'))
self.rangeSeparatorCheckBox.setText(
translate('BiblesPlugin.BiblesTab', 'Range Separator:'))
self.listSeparatorCheckBox.setText(
translate('BiblesPlugin.BiblesTab', 'List Separator:'))
self.endSeparatorCheckBox.setText(
translate('BiblesPlugin.BiblesTab', 'End Mark:'))
self.bibleSecondCheckBox.setText(translate('BiblesPlugin.BiblesTab', 'Display second Bible verses'))
self.scriptureReferenceGroupBox.setTitle(translate('BiblesPlugin.BiblesTab', 'Custom Scripture References'))
self.verseSeparatorCheckBox.setText(translate('BiblesPlugin.BiblesTab', 'Verse Separator:'))
self.rangeSeparatorCheckBox.setText(translate('BiblesPlugin.BiblesTab', 'Range Separator:'))
self.listSeparatorCheckBox.setText(translate('BiblesPlugin.BiblesTab', 'List Separator:'))
self.endSeparatorCheckBox.setText(translate('BiblesPlugin.BiblesTab', 'End Mark:'))
#@todo these are common so move to StringsUI and reuse.
self.verseSeparatorLineEdit.setToolTip(
translate('BiblesPlugin.BiblesTab', 'Multiple alternative '
'verse separators may be defined.\nThey have to be separated '
@ -278,15 +218,12 @@ class BiblesTab(SettingsTab):
'end marks may be defined.\nThey have to be separated by a '
'vertical bar "|".\nPlease clear this edit line to use the '
'default value.'))
self.languageSelectionGroupBox.setTitle(translate(
'BiblesPlugin.BiblesTab', 'Default Bible Language'))
self.languageSelectionGroupBox.setTitle(translate('BiblesPlugin.BiblesTab', 'Default Bible Language'))
self.languageSelectionLabel.setText(translate('BiblesPlugin.BiblesTab',
'Book name language in search field,\nsearch results and on '
'display:'))
'Book name language in search field,\nsearch results and on display:'))
self.languageSelectionComboBox.setItemText(LanguageSelection.Bible,
translate('BiblesPlugin.BiblesTab', 'Bible Language'))
self.languageSelectionComboBox.setItemText(
LanguageSelection.Application,
self.languageSelectionComboBox.setItemText(LanguageSelection.Application,
translate('BiblesPlugin.BiblesTab', 'Application Language'))
self.languageSelectionComboBox.setItemText(LanguageSelection.English,
translate('BiblesPlugin.BiblesTab', 'English'))
@ -319,101 +256,77 @@ class BiblesTab(SettingsTab):
if checked:
self.verseSeparatorLineEdit.setFocus()
else:
self.verseSeparatorLineEdit.setText(
get_reference_separator(u'sep_v_default'))
self.verseSeparatorLineEdit.setPalette(
self.getGreyTextPalette(not checked))
self.verseSeparatorLineEdit.setText(get_reference_separator(u'sep_v_default'))
self.verseSeparatorLineEdit.setPalette(self.getGreyTextPalette(not checked))
def onVerseSeparatorLineEditEdited(self, text):
self.verseSeparatorCheckBox.setChecked(True)
self.verseSeparatorLineEdit.setPalette(
self.getGreyTextPalette(False))
self.verseSeparatorLineEdit.setPalette(self.getGreyTextPalette(False))
def onVerseSeparatorLineEditFinished(self):
if self.verseSeparatorLineEdit.isModified():
text = self.verseSeparatorLineEdit.text()
if text == get_reference_separator(u'sep_v_default') or \
not text.replace(u'|', u''):
if text == get_reference_separator(u'sep_v_default') or not text.replace(u'|', u''):
self.verseSeparatorCheckBox.setChecked(False)
self.verseSeparatorLineEdit.setText(
get_reference_separator(u'sep_v_default'))
self.verseSeparatorLineEdit.setPalette(
self.getGreyTextPalette(True))
self.verseSeparatorLineEdit.setText(get_reference_separator(u'sep_v_default'))
self.verseSeparatorLineEdit.setPalette(self.getGreyTextPalette(True))
def onRangeSeparatorCheckBoxClicked(self, checked):
if checked:
self.rangeSeparatorLineEdit.setFocus()
else:
self.rangeSeparatorLineEdit.setText(
get_reference_separator(u'sep_r_default'))
self.rangeSeparatorLineEdit.setPalette(
self.getGreyTextPalette(not checked))
self.rangeSeparatorLineEdit.setText(get_reference_separator(u'sep_r_default'))
self.rangeSeparatorLineEdit.setPalette(self.getGreyTextPalette(not checked))
def onRangeSeparatorLineEditEdited(self, text):
self.rangeSeparatorCheckBox.setChecked(True)
self.rangeSeparatorLineEdit.setPalette(
self.getGreyTextPalette(False))
self.rangeSeparatorLineEdit.setPalette(self.getGreyTextPalette(False))
def onRangeSeparatorLineEditFinished(self):
if self.rangeSeparatorLineEdit.isModified():
text = self.rangeSeparatorLineEdit.text()
if text == get_reference_separator(u'sep_r_default') or \
not text.replace(u'|', u''):
if text == get_reference_separator(u'sep_r_default') or not text.replace(u'|', u''):
self.rangeSeparatorCheckBox.setChecked(False)
self.rangeSeparatorLineEdit.setText(
get_reference_separator(u'sep_r_default'))
self.rangeSeparatorLineEdit.setPalette(
self.getGreyTextPalette(True))
self.rangeSeparatorLineEdit.setText(get_reference_separator(u'sep_r_default'))
self.rangeSeparatorLineEdit.setPalette(self.getGreyTextPalette(True))
def onListSeparatorCheckBoxClicked(self, checked):
if checked:
self.listSeparatorLineEdit.setFocus()
else:
self.listSeparatorLineEdit.setText(
get_reference_separator(u'sep_l_default'))
self.listSeparatorLineEdit.setPalette(
self.getGreyTextPalette(not checked))
self.listSeparatorLineEdit.setText(get_reference_separator(u'sep_l_default'))
self.listSeparatorLineEdit.setPalette(self.getGreyTextPalette(not checked))
def onListSeparatorLineEditEdited(self, text):
self.listSeparatorCheckBox.setChecked(True)
self.listSeparatorLineEdit.setPalette(
self.getGreyTextPalette(False))
self.listSeparatorLineEdit.setPalette(self.getGreyTextPalette(False))
def onListSeparatorLineEditFinished(self):
if self.listSeparatorLineEdit.isModified():
text = self.listSeparatorLineEdit.text()
if text == get_reference_separator(u'sep_l_default') or \
not text.replace(u'|', u''):
if text == get_reference_separator(u'sep_l_default') or not text.replace(u'|', u''):
self.listSeparatorCheckBox.setChecked(False)
self.listSeparatorLineEdit.setText(
get_reference_separator(u'sep_l_default'))
self.listSeparatorLineEdit.setPalette(
self.getGreyTextPalette(True))
self.listSeparatorLineEdit.setText(get_reference_separator(u'sep_l_default'))
self.listSeparatorLineEdit.setPalette(self.getGreyTextPalette(True))
def onEndSeparatorCheckBoxClicked(self, checked):
if checked:
self.endSeparatorLineEdit.setFocus()
else:
self.endSeparatorLineEdit.setText(
get_reference_separator(u'sep_e_default'))
self.endSeparatorLineEdit.setPalette(
self.getGreyTextPalette(not checked))
self.endSeparatorLineEdit.setText(get_reference_separator(u'sep_e_default'))
self.endSeparatorLineEdit.setPalette(self.getGreyTextPalette(not checked))
def onEndSeparatorLineEditEdited(self, text):
self.endSeparatorCheckBox.setChecked(True)
self.endSeparatorLineEdit.setPalette(
self.getGreyTextPalette(False))
self.endSeparatorLineEdit.setPalette(self.getGreyTextPalette(False))
def onEndSeparatorLineEditFinished(self):
if self.endSeparatorLineEdit.isModified():
text = self.endSeparatorLineEdit.text()
if text == get_reference_separator(u'sep_e_default') or \
not text.replace(u'|', u''):
if text == get_reference_separator(u'sep_e_default') or not text.replace(u'|', u''):
self.endSeparatorCheckBox.setChecked(False)
self.endSeparatorLineEdit.setText(
get_reference_separator(u'sep_e_default'))
self.endSeparatorLineEdit.setPalette(
self.getGreyTextPalette(True))
self.endSeparatorLineEdit.setText(get_reference_separator(u'sep_e_default'))
self.endSeparatorLineEdit.setPalette(self.getGreyTextPalette(True))
def load(self):
settings = Settings()
@ -428,48 +341,35 @@ class BiblesTab(SettingsTab):
self.layoutStyleComboBox.setCurrentIndex(self.layout_style)
self.bibleSecondCheckBox.setChecked(self.second_bibles)
verse_separator = settings.value(u'verse separator', u'')
if (verse_separator.strip(u'|') == u'') or \
(verse_separator == get_reference_separator(u'sep_v_default')):
self.verseSeparatorLineEdit.setText(
get_reference_separator(u'sep_v_default'))
self.verseSeparatorLineEdit.setPalette(
self.getGreyTextPalette(True))
if (verse_separator.strip(u'|') == u'') or (verse_separator == get_reference_separator(u'sep_v_default')):
self.verseSeparatorLineEdit.setText(get_reference_separator(u'sep_v_default'))
self.verseSeparatorLineEdit.setPalette(self.getGreyTextPalette(True))
self.verseSeparatorCheckBox.setChecked(False)
else:
self.verseSeparatorLineEdit.setText(verse_separator)
self.verseSeparatorLineEdit.setPalette(
self.getGreyTextPalette(False))
self.verseSeparatorLineEdit.setPalette(self.getGreyTextPalette(False))
self.verseSeparatorCheckBox.setChecked(True)
range_separator = settings.value(u'range separator', u'')
if (range_separator.strip(u'|') == u'') or \
(range_separator == get_reference_separator(u'sep_r_default')):
self.rangeSeparatorLineEdit.setText(
get_reference_separator(u'sep_r_default'))
self.rangeSeparatorLineEdit.setPalette(
self.getGreyTextPalette(True))
if (range_separator.strip(u'|') == u'') or (range_separator == get_reference_separator(u'sep_r_default')):
self.rangeSeparatorLineEdit.setText(get_reference_separator(u'sep_r_default'))
self.rangeSeparatorLineEdit.setPalette(self.getGreyTextPalette(True))
self.rangeSeparatorCheckBox.setChecked(False)
else:
self.rangeSeparatorLineEdit.setText(range_separator)
self.rangeSeparatorLineEdit.setPalette(
self.getGreyTextPalette(False))
self.rangeSeparatorLineEdit.setPalette(self.getGreyTextPalette(False))
self.rangeSeparatorCheckBox.setChecked(True)
list_separator = settings.value(u'list separator', u'')
if (list_separator.strip(u'|') == u'') or \
(list_separator == get_reference_separator(u'sep_l_default')):
self.listSeparatorLineEdit.setText(
get_reference_separator(u'sep_l_default'))
if (list_separator.strip(u'|') == u'') or (list_separator == get_reference_separator(u'sep_l_default')):
self.listSeparatorLineEdit.setText(get_reference_separator(u'sep_l_default'))
self.listSeparatorLineEdit.setPalette(self.getGreyTextPalette(True))
self.listSeparatorCheckBox.setChecked(False)
else:
self.listSeparatorLineEdit.setText(list_separator)
self.listSeparatorLineEdit.setPalette(
self.getGreyTextPalette(False))
self.listSeparatorLineEdit.setPalette(self.getGreyTextPalette(False))
self.listSeparatorCheckBox.setChecked(True)
end_separator = settings.value(u'end separator', u'')
if (end_separator.strip(u'|') == u'') or \
(end_separator == get_reference_separator(u'sep_e_default')):
self.endSeparatorLineEdit.setText(
get_reference_separator(u'sep_e_default'))
if (end_separator.strip(u'|') == u'') or (end_separator == get_reference_separator(u'sep_e_default')):
self.endSeparatorLineEdit.setText(get_reference_separator(u'sep_e_default'))
self.endSeparatorLineEdit.setPalette(self.getGreyTextPalette(True))
self.endSeparatorCheckBox.setChecked(False)
else:
@ -490,23 +390,19 @@ class BiblesTab(SettingsTab):
settings.setValue(u'second bibles', self.second_bibles)
settings.setValue(u'bible theme', self.bible_theme)
if self.verseSeparatorCheckBox.isChecked():
settings.setValue(u'verse separator',
self.verseSeparatorLineEdit.text())
settings.setValue(u'verse separator', self.verseSeparatorLineEdit.text())
else:
settings.remove(u'verse separator')
if self.rangeSeparatorCheckBox.isChecked():
settings.setValue(u'range separator',
self.rangeSeparatorLineEdit.text())
settings.setValue(u'range separator', self.rangeSeparatorLineEdit.text())
else:
settings.remove(u'range separator')
if self.listSeparatorCheckBox.isChecked():
settings.setValue(u'list separator',
self.listSeparatorLineEdit.text())
settings.setValue(u'list separator', self.listSeparatorLineEdit.text())
else:
settings.remove(u'list separator')
if self.endSeparatorCheckBox.isChecked():
settings.setValue(u'end separator',
self.endSeparatorLineEdit.text())
settings.setValue(u'end separator', self.endSeparatorLineEdit.text())
else:
settings.remove(u'end separator')
update_reference_separators()

View File

@ -1,5 +1,5 @@
# -*- coding: utf-8 -*-
# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4
# vim: autoindent shiftwidth=4 expandtab textwidth=120 tabstop=4 softtabstop=4
###############################################################################
# OpenLP - Open Source Lyrics Projection #
@ -109,19 +109,14 @@ class CSVBible(BibleDB):
for line in books_reader:
if self.stop_import_flag:
break
self.wizard.incrementProgressBar(
translate('BiblesPlugin.CSVBible',
'Importing books... %s') %
self.wizard.incrementProgressBar(translate('BiblesPlugin.CSVBible', 'Importing books... %s') %
unicode(line[2], details['encoding']))
book_ref_id = self.get_book_ref_id_by_name(
unicode(line[2], details['encoding']), 67, language_id)
book_ref_id = self.get_book_ref_id_by_name(unicode(line[2], details['encoding']), 67, language_id)
if not book_ref_id:
log.exception(u'Importing books from "%s" '\
'failed' % self.booksfile)
log.exception(u'Importing books from "%s" failed' % self.booksfile)
return False
book_details = BiblesResourcesDB.get_book_by_id(book_ref_id)
self.create_book(unicode(line[2], details['encoding']),
book_ref_id, book_details[u'testament_id'])
self.create_book(unicode(line[2], details['encoding']), book_ref_id, book_details[u'testament_id'])
book_list[int(line[0])] = unicode(line[2], details['encoding'])
Receiver.send_message(u'openlp_process_events')
except (IOError, IndexError):
@ -153,17 +148,15 @@ class CSVBible(BibleDB):
if book_ptr != line_book:
book = self.get_book(line_book)
book_ptr = book.name
self.wizard.incrementProgressBar(translate(
'BiblesPlugin.CSVBible', 'Importing verses from %s...',
'Importing verses from <book name>...') % book.name)
self.wizard.incrementProgressBar(translate('BiblesPlugin.CSVBible',
'Importing verses from %s... Importing verses from <book name>...') % book.name)
self.session.commit()
try:
verse_text = unicode(line[3], details['encoding'])
except UnicodeError:
verse_text = unicode(line[3], u'cp1252')
self.create_verse(book.id, line[1], line[2], verse_text)
self.wizard.incrementProgressBar(translate('BiblesPlugin.CSVBible',
'Importing verses... done.'))
self.wizard.incrementProgressBar(translate('BiblesPlugin.CSVBible', 'Importing verses... done.'))
Receiver.send_message(u'openlp_process_events')
self.session.commit()
except IOError:

View File

@ -1,5 +1,5 @@
# -*- coding: utf-8 -*-
# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4
# vim: autoindent shiftwidth=4 expandtab textwidth=120 tabstop=4 softtabstop=4
###############################################################################
# OpenLP - Open Source Lyrics Projection #
@ -160,8 +160,7 @@ class BibleDB(QtCore.QObject, Manager):
if u'path' in kwargs:
self.path = kwargs[u'path']
self.wizard = None
QtCore.QObject.connect(Receiver.get_receiver(),
QtCore.SIGNAL(u'openlp_stop_wizard'), self.stop_import)
QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'openlp_stop_wizard'), self.stop_import)
def stop_import(self):
"""
@ -206,8 +205,7 @@ class BibleDB(QtCore.QObject, Manager):
bibles_resources.sqlite of the testament this book belongs to.
"""
log.debug(u'BibleDB.create_book("%s", "%s")', name, bk_ref_id)
book = Book.populate(name=name, book_reference_id=bk_ref_id,
testament_reference_id=testament)
book = Book.populate(name=name, book_reference_id=bk_ref_id, testament_reference_id=testament)
self.save_object(book)
return book
@ -336,8 +334,7 @@ class BibleDB(QtCore.QObject, Manager):
return self.get_object_filtered(Book, Book.book_reference_id.like(id))
def get_book_ref_id_by_name(self, book, maxbooks, language_id=None):
log.debug(u'BibleDB.get_book_ref_id_by_name:("%s", "%s")', book,
language_id)
log.debug(u'BibleDB.get_book_ref_id_by_name:("%s", "%s")', book, language_id)
book_id = None
if BiblesResourcesDB.get_book(book, True):
book_temp = BiblesResourcesDB.get_book(book, True)
@ -446,8 +443,7 @@ class BibleDB(QtCore.QObject, Manager):
critical_error_message_box(
translate('BiblesPlugin', 'No Book Found'),
translate('BiblesPlugin', 'No matching book '
'could be found in this Bible. Check that you '
'have spelled the name of the book correctly.'))
'could be found in this Bible. Check that you have spelled the name of the book correctly.'))
return verse_list
def verse_search(self, text):
@ -573,9 +569,8 @@ class BiblesResourcesDB(QtCore.QObject, Manager):
Return the cursor object. Instantiate one if it doesn't exist yet.
"""
if BiblesResourcesDB.cursor is None:
filepath = os.path.join(
AppLocation.get_directory(AppLocation.PluginsDir), u'bibles',
u'resources', u'bibles_resources.sqlite')
filepath = os.path.join(AppLocation.get_directory(AppLocation.PluginsDir),
u'bibles', u'resources', u'bibles_resources.sqlite')
conn = sqlite3.connect(filepath)
BiblesResourcesDB.cursor = conn.cursor()
return BiblesResourcesDB.cursor
@ -683,8 +678,7 @@ class BiblesResourcesDB(QtCore.QObject, Manager):
if not isinstance(id, int):
id = int(id)
books = BiblesResourcesDB.run_sql(u'SELECT id, testament_id, name, '
u'abbreviation, chapters FROM book_reference WHERE id = ?',
(id, ))
u'abbreviation, chapters FROM book_reference WHERE id = ?', (id, ))
if books:
return {
u'id': books[0][0],
@ -707,13 +701,11 @@ class BiblesResourcesDB(QtCore.QObject, Manager):
``chapter``
The chapter number.
"""
log.debug(u'BiblesResourcesDB.get_chapter("%s", "%s")', book_ref_id,
chapter)
log.debug(u'BiblesResourcesDB.get_chapter("%s", "%s")', book_ref_id, chapter)
if not isinstance(chapter, int):
chapter = int(chapter)
chapters = BiblesResourcesDB.run_sql(u'SELECT id, book_reference_id, '
u'chapter, verse_count FROM chapters WHERE book_reference_id = ?',
(book_ref_id,))
u'chapter, verse_count FROM chapters WHERE book_reference_id = ?', (book_ref_id,))
try:
return {
u'id': chapters[chapter-1][0],
@ -749,8 +741,7 @@ class BiblesResourcesDB(QtCore.QObject, Manager):
``chapter``
The number of the chapter.
"""
log.debug(u'BiblesResourcesDB.get_verse_count("%s", "%s")', book_ref_id,
chapter)
log.debug(u'BiblesResourcesDB.get_verse_count("%s", "%s")', book_ref_id, chapter)
details = BiblesResourcesDB.get_chapter(book_ref_id, chapter)
if details:
return details[u'verse_count']
@ -791,8 +782,7 @@ class BiblesResourcesDB(QtCore.QObject, Manager):
source = unicode(source)
source = BiblesResourcesDB.get_download_source(source)
bibles = BiblesResourcesDB.run_sql(u'SELECT id, name, abbreviation, '
u'language_id, download_source_id FROM webbibles WHERE '
u'download_source_id = ?', (source[u'id'],))
u'language_id, download_source_id FROM webbibles WHERE download_source_id = ?', (source[u'id'],))
if bibles:
return [{
u'id': bible[0],
@ -815,8 +805,7 @@ class BiblesResourcesDB(QtCore.QObject, Manager):
``source``
The source of the webbible.
"""
log.debug(u'BiblesResourcesDB.get_webbibles("%s", "%s")', abbreviation,
source)
log.debug(u'BiblesResourcesDB.get_webbibles("%s", "%s")', abbreviation, source)
if not isinstance(abbreviation, unicode):
abbreviation = unicode(abbreviation)
if not isinstance(source, unicode):
@ -824,8 +813,7 @@ class BiblesResourcesDB(QtCore.QObject, Manager):
source = BiblesResourcesDB.get_download_source(source)
bible = BiblesResourcesDB.run_sql(u'SELECT id, name, abbreviation, '
u'language_id, download_source_id FROM webbibles WHERE '
u'download_source_id = ? AND abbreviation = ?', (source[u'id'],
abbreviation))
u'download_source_id = ? AND abbreviation = ?', (source[u'id'], abbreviation))
try:
return {
u'id': bible[0][0],
@ -848,15 +836,12 @@ class BiblesResourcesDB(QtCore.QObject, Manager):
``language_id``
The language_id for which language should be searched
"""
log.debug(u'BiblesResourcesDB.get_alternative_book_name("%s", "%s")',
name, language_id)
log.debug(u'BiblesResourcesDB.get_alternative_book_name("%s", "%s")', name, language_id)
if language_id:
books = BiblesResourcesDB.run_sql(u'SELECT book_reference_id, name '
u'FROM alternative_book_names WHERE language_id = ? ORDER BY '
u'id', (language_id, ))
u'FROM alternative_book_names WHERE language_id = ? ORDER BY id', (language_id, ))
else:
books = BiblesResourcesDB.run_sql(u'SELECT book_reference_id, name '
u'FROM alternative_book_names ORDER BY id')
books = BiblesResourcesDB.run_sql(u'SELECT book_reference_id, name FROM alternative_book_names ORDER BY id')
for book in books:
if book[1].lower() == name.lower():
return book[0]
@ -891,8 +876,7 @@ class BiblesResourcesDB(QtCore.QObject, Manager):
Return a dict containing all languages with id, name and code.
"""
log.debug(u'BiblesResourcesDB.get_languages()')
languages = BiblesResourcesDB.run_sql(u'SELECT id, name, code FROM '
u'language ORDER by name')
languages = BiblesResourcesDB.run_sql(u'SELECT id, name, code FROM language ORDER by name')
if languages:
return [{
u'id': language[0],
@ -908,8 +892,7 @@ class BiblesResourcesDB(QtCore.QObject, Manager):
Return a list of all testaments and their id of the Bible.
"""
log.debug(u'BiblesResourcesDB.get_testament_reference()')
testaments = BiblesResourcesDB.run_sql(u'SELECT id, name FROM '
u'testament_reference ORDER BY id')
testaments = BiblesResourcesDB.run_sql(u'SELECT id, name FROM testament_reference ORDER BY id')
return [
{
u'id': testament[0],
@ -935,8 +918,7 @@ class AlternativeBookNamesDB(QtCore.QObject, Manager):
"""
if AlternativeBookNamesDB.cursor is None:
filepath = os.path.join(
AppLocation.get_directory(AppLocation.DataDir), u'bibles',
u'alternative_book_names.sqlite')
AppLocation.get_directory(AppLocation.DataDir), u'bibles', u'alternative_book_names.sqlite')
if not os.path.exists(filepath):
#create new DB, create table alternative_book_names
AlternativeBookNamesDB.conn = sqlite3.connect(filepath)
@ -981,12 +963,10 @@ class AlternativeBookNamesDB(QtCore.QObject, Manager):
``language_id``
The language_id for which language should be searched
"""
log.debug(u'AlternativeBookNamesDB.get_book_reference_id("%s", "%s")',
name, language_id)
log.debug(u'AlternativeBookNamesDB.get_book_reference_id("%s", "%s")', name, language_id)
if language_id:
books = AlternativeBookNamesDB.run_sql(u'SELECT book_reference_id, '
u'name FROM alternative_book_names WHERE language_id = ?',
(language_id, ))
u'name FROM alternative_book_names WHERE language_id = ?', (language_id, ))
else:
books = AlternativeBookNamesDB.run_sql(u'SELECT book_reference_id, '
u'name FROM alternative_book_names')
@ -1018,7 +998,7 @@ class AlternativeBookNamesDB(QtCore.QObject, Manager):
class OldBibleDB(QtCore.QObject, Manager):
"""
This class conects to the old bible databases to reimport them to the new
This class connects to the old bible databases to reimport them to the new
database scheme.
"""
cursor = None
@ -1076,8 +1056,7 @@ class OldBibleDB(QtCore.QObject, Manager):
"""
Returns the version name of the Bible.
"""
version_name = self.run_sql(u'SELECT value FROM '
u'metadata WHERE key = "name"')
version_name = self.run_sql(u'SELECT value FROM metadata WHERE key = "name"')
if version_name:
self.name = version_name[0][0]
else:
@ -1088,8 +1067,7 @@ class OldBibleDB(QtCore.QObject, Manager):
"""
Returns the metadata of the Bible.
"""
metadata = self.run_sql(u'SELECT key, value FROM metadata '
u'ORDER BY rowid')
metadata = self.run_sql(u'SELECT key, value FROM metadata ORDER BY rowid')
if metadata:
return [{
u'key': unicode(meta[0]),

View File

@ -1,5 +1,5 @@
# -*- coding: utf-8 -*-
# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4
# vim: autoindent shiftwidth=4 expandtab textwidth=120 tabstop=4 softtabstop=4
###############################################################################
# OpenLP - Open Source Lyrics Projection #
@ -42,8 +42,7 @@ from openlp.core.lib import Receiver, translate
from openlp.core.lib.ui import critical_error_message_box
from openlp.core.utils import get_web_page
from openlp.plugins.bibles.lib import SearchResults
from openlp.plugins.bibles.lib.db import BibleDB, BiblesResourcesDB, \
Book
from openlp.plugins.bibles.lib.db import BibleDB, BiblesResourcesDB, Book
UGLY_CHARS = {
u'\u2014': u' - ',
@ -94,10 +93,8 @@ class BGExtract(object):
"""
if isinstance(tag, NavigableString):
return None, unicode(tag)
elif tag.get('class') == 'versenum' or \
tag.get('class') == 'versenum mid-line':
verse = unicode(tag.string)\
.replace('[', '').replace(']', '').strip()
elif tag.get('class') == 'versenum' or tag.get('class') == 'versenum mid-line':
verse = unicode(tag.string).replace('[', '').replace(']', '').strip()
return verse, None
elif tag.get('class') == 'chapternum':
verse = '1'
@ -231,16 +228,13 @@ class BGExtract(object):
``chapter``
Chapter number.
"""
log.debug(u'BGExtract.get_bible_chapter("%s", "%s", "%s")', version,
book_name, chapter)
log.debug(u'BGExtract.get_bible_chapter("%s", "%s", "%s")', version, book_name, chapter)
url_book_name = urllib.quote(book_name.encode("utf-8"))
url_params = u'search=%s+%s&version=%s' % (url_book_name, chapter,
version)
url_params = u'search=%s+%s&version=%s' % (url_book_name, chapter, version)
cleaner = [(re.compile('&nbsp;|<br />|\'\+\''), lambda match: '')]
soup = get_soup_for_bible_ref(
u'http://www.biblegateway.com/passage/?%s' % url_params,
pre_parse_regex=r'<meta name.*?/>', pre_parse_substitute='',
cleaner=cleaner)
pre_parse_regex=r'<meta name.*?/>', pre_parse_substitute='', cleaner=cleaner)
if not soup:
return None
Receiver.send_message(u'openlp_process_events')
@ -267,10 +261,8 @@ class BGExtract(object):
The version of the Bible like NIV for New International Version
"""
log.debug(u'BGExtract.get_books_from_http("%s")', version)
url_params = urllib.urlencode(
{u'action': 'getVersionInfo', u'vid': u'%s' % version})
reference_url = u'http://www.biblegateway.com/versions/?%s#books' % \
url_params
url_params = urllib.urlencode({u'action': 'getVersionInfo', u'vid': u'%s' % version})
reference_url = u'http://www.biblegateway.com/versions/?%s#books' % url_params
page = get_web_page(reference_url)
if not page:
send_error_message(u'download')

View File

@ -1,5 +1,5 @@
# -*- coding: utf-8 -*-
# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4
# vim: autoindent shiftwidth=4 expandtab textwidth=120 tabstop=4 softtabstop=4
###############################################################################
# OpenLP - Open Source Lyrics Projection #
@ -34,8 +34,7 @@ from PyQt4 import QtCore
from openlp.core.lib import Receiver, SettingsManager, translate, Settings
from openlp.core.utils import AppLocation, delete_file
from openlp.plugins.bibles.lib import parse_reference, \
get_reference_separator, LanguageSelection
from openlp.plugins.bibles.lib import parse_reference, get_reference_separator, LanguageSelection
from openlp.plugins.bibles.lib.db import BibleDB, BibleMeta
from csvbible import CSVBible
from http import HTTPBible
@ -127,8 +126,7 @@ class BibleManager(object):
self.web = u'Web'
self.db_cache = None
self.path = AppLocation.get_section_data_path(self.settingsSection)
self.proxy_name = Settings().value(
self.settingsSection + u'/proxy name', u'')
self.proxy_name = Settings().value(self.settingsSection + u'/proxy name', u'')
self.suffix = u'.sqlite'
self.import_wizard = None
self.reload_bibles()
@ -141,8 +139,7 @@ class BibleManager(object):
BibleDB class.
"""
log.debug(u'Reload bibles')
files = SettingsManager.get_files(self.settingsSection,
self.suffix)
files = SettingsManager.get_files(self.settingsSection, self.suffix)
if u'alternative_book_names.sqlite' in files:
files.remove(u'alternative_book_names.sqlite')
log.debug(u'Bible Files %s', files)
@ -164,15 +161,11 @@ class BibleManager(object):
log.debug(u'Bible Name: "%s"', name)
self.db_cache[name] = bible
# Look to see if lazy load bible exists and get create getter.
source = self.db_cache[name].get_object(BibleMeta,
u'download_source')
source = self.db_cache[name].get_object(BibleMeta, u'download_source')
if source:
download_name = self.db_cache[name].get_object(BibleMeta,
u'download_name').value
meta_proxy = self.db_cache[name].get_object(BibleMeta,
u'proxy_server')
web_bible = HTTPBible(self.parent, path=self.path,
file=filename, download_source=source.value,
download_name = self.db_cache[name].get_object(BibleMeta, u'download_name').value
meta_proxy = self.db_cache[name].get_object(BibleMeta, u'proxy_server')
web_bible = HTTPBible(self.parent, path=self.path, file=filename, download_source=source.value,
download_name=download_name)
if meta_proxy:
web_bible.proxy_server = meta_proxy.value
@ -265,8 +258,7 @@ class BibleManager(object):
``book``
The book object to get the chapter count for.
"""
log.debug(u'BibleManager.get_book_chapter_count ("%s", "%s")', bible,
book.name)
log.debug(u'BibleManager.get_book_chapter_count ("%s", "%s")', bible, book.name)
return self.db_cache[bible].get_chapter_count(book)
def get_verse_count(self, bible, book, chapter):
@ -277,8 +269,7 @@ class BibleManager(object):
log.debug(u'BibleManager.get_verse_count("%s", "%s", %s)',
bible, book, chapter)
language_selection = self.get_language_selection(bible)
book_ref_id = self.db_cache[bible].get_book_ref_id_by_localised_name(
book, language_selection)
book_ref_id = self.db_cache[bible].get_book_ref_id_by_localised_name(book, language_selection)
return self.db_cache[bible].get_verse_count(book_ref_id, chapter)
def get_verse_count_by_book_ref_id(self, bible, book_ref_id, chapter):
@ -286,8 +277,7 @@ class BibleManager(object):
Returns all the number of verses for a given
book_ref_id and chapterMaxBibleBookVerses.
"""
log.debug(u'BibleManager.get_verse_count_by_book_ref_id("%s", "%s", '
u'"%s")', bible, book_ref_id, chapter)
log.debug(u'BibleManager.get_verse_count_by_book_ref_id("%s", "%s", "%s")', bible, book_ref_id, chapter)
return self.db_cache[bible].get_verse_count(book_ref_id, chapter)
def get_verses(self, bible, versetext, book_ref_id=False, show_error=True):
@ -317,8 +307,7 @@ class BibleManager(object):
if not bible:
if show_error:
Receiver.send_message(u'openlp_information_message', {
u'title': translate('BiblesPlugin.BibleManager',
'No Bibles Available'),
u'title': translate('BiblesPlugin.BibleManager', 'No Bibles Available'),
u'message': translate('BiblesPlugin.BibleManager',
'There are no Bibles currently installed. Please use the '
'Import Wizard to install one or more Bibles.')
@ -366,13 +355,10 @@ class BibleManager(object):
"""
log.debug(u'BibleManager.get_language_selection("%s")', bible)
language_selection = self.get_meta_data(bible, u'book_name_language')
if not language_selection or \
language_selection.value == "None" or \
language_selection.value == "-1":
if not language_selection or language_selection.value == "None" or language_selection.value == "-1":
# If None is returned, it's not the singleton object but a
# BibleMeta object with the value "None"
language_selection = Settings().value(
self.settingsSection + u'/book name language', 0)
language_selection = Settings().value(self.settingsSection + u'/book name language', 0)
else:
language_selection = language_selection.value
try:
@ -397,8 +383,7 @@ class BibleManager(object):
log.debug(u'BibleManager.verse_search("%s", "%s")', bible, text)
if not bible:
Receiver.send_message(u'openlp_information_message', {
u'title': translate('BiblesPlugin.BibleManager',
'No Bibles Available'),
u'title': translate('BiblesPlugin.BibleManager', 'No Bibles Available'),
u'message': translate('BiblesPlugin.BibleManager',
'There are no Bibles currently installed. Please use the '
'Import Wizard to install one or more Bibles.')
@ -413,20 +398,16 @@ class BibleManager(object):
u'download_source')
if webbible or second_webbible:
Receiver.send_message(u'openlp_information_message', {
u'title': translate('BiblesPlugin.BibleManager',
'Web Bible cannot be used'),
u'message': translate('BiblesPlugin.BibleManager',
'Text Search is not available with Web Bibles.')
u'title': translate('BiblesPlugin.BibleManager', 'Web Bible cannot be used'),
u'message': translate('BiblesPlugin.BibleManager', 'Text Search is not available with Web Bibles.')
})
return None
if text:
return self.db_cache[bible].verse_search(text)
else:
Receiver.send_message(u'openlp_information_message', {
u'title': translate('BiblesPlugin.BibleManager',
'Scripture Reference Error'),
u'message': translate('BiblesPlugin.BibleManager',
'You did not enter a search keyword.\n'
u'title': translate('BiblesPlugin.BibleManager', 'Scripture Reference Error'),
u'message': translate('BiblesPlugin.BibleManager', 'You did not enter a search keyword.\n'
'You can separate different keywords by a space to '
'search for all of your keywords and you can separate '
'them by a comma to search for one of them.')

View File

@ -1,5 +1,5 @@
# -*- coding: utf-8 -*-
# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4
# vim: autoindent shiftwidth=4 expandtab textwidth=120 tabstop=4 softtabstop=4
###############################################################################
# OpenLP - Open Source Lyrics Projection #
@ -34,14 +34,12 @@ from PyQt4 import QtCore, QtGui
from openlp.core.lib import MediaManagerItem, Receiver, ItemCapabilities, \
translate, create_separated_list, ServiceItemContext, Settings
from openlp.core.lib.searchedit import SearchEdit
from openlp.core.lib.ui import UiStrings, set_case_insensitive_completer, \
create_horizontal_adjusting_combo_box, critical_error_message_box, \
find_and_set_in_combo_box, build_icon
from openlp.core.lib.ui import UiStrings, set_case_insensitive_completer, create_horizontal_adjusting_combo_box, \
critical_error_message_box, find_and_set_in_combo_box, build_icon
from openlp.core.utils import locale_compare
from openlp.plugins.bibles.forms import BibleImportForm, EditBibleForm
from openlp.plugins.bibles.lib import LayoutStyle, DisplayStyle, \
VerseReferenceList, get_reference_separator, LanguageSelection, \
BibleStrings
from openlp.plugins.bibles.lib import LayoutStyle, DisplayStyle, VerseReferenceList, get_reference_separator, \
LanguageSelection, BibleStrings
from openlp.plugins.bibles.lib.db import BiblesResourcesDB
log = logging.getLogger(__name__)
@ -72,8 +70,7 @@ class BibleMediaItem(MediaManagerItem):
self.search_results = {}
self.second_search_results = {}
self.checkSearchResult()
QtCore.QObject.connect(Receiver.get_receiver(),
QtCore.SIGNAL(u'bibles_load_list'), self.reloadBibles)
QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'bibles_load_list'), self.reloadBibles)
def __checkSecondBible(self, bible, second_bible):
"""
@ -87,14 +84,12 @@ class BibleMediaItem(MediaManagerItem):
return
else:
item_second_bible = self._decodeQtObject(bitem, 'second_bible')
if item_second_bible and second_bible or not item_second_bible and \
not second_bible:
if item_second_bible and second_bible or not item_second_bible and not second_bible:
self.displayResults(bible, second_bible)
elif critical_error_message_box(
message=translate('BiblesPlugin.MediaItem',
'You cannot combine single and dual Bible verse search results. '
'Do you want to delete your search results and start a new '
'search?'),
'Do you want to delete your search results and start a new search?'),
parent=self, question=True) == QtGui.QMessageBox.Yes:
self.listView.clear()
self.displayResults(bible, second_bible)
@ -141,22 +136,19 @@ class BibleMediaItem(MediaManagerItem):
versionLabel = QtGui.QLabel(tab)
versionLabel.setObjectName(prefix + u'VersionLabel')
layout.addWidget(versionLabel, idx, 0, QtCore.Qt.AlignRight)
versionComboBox = create_horizontal_adjusting_combo_box(tab,
prefix + u'VersionComboBox')
versionComboBox = create_horizontal_adjusting_combo_box(tab, prefix + u'VersionComboBox')
versionLabel.setBuddy(versionComboBox)
layout.addWidget(versionComboBox, idx, 1, 1, 2)
secondLabel = QtGui.QLabel(tab)
secondLabel.setObjectName(prefix + u'SecondLabel')
layout.addWidget(secondLabel, idx + 1, 0, QtCore.Qt.AlignRight)
secondComboBox = create_horizontal_adjusting_combo_box(
tab, prefix + u'SecondComboBox')
secondComboBox = create_horizontal_adjusting_combo_box(tab, prefix + u'SecondComboBox')
versionLabel.setBuddy(secondComboBox)
layout.addWidget(secondComboBox, idx + 1, 1, 1, 2)
styleLabel = QtGui.QLabel(tab)
styleLabel.setObjectName(prefix + u'StyleLabel')
layout.addWidget(styleLabel, idx + 2, 0, QtCore.Qt.AlignRight)
styleComboBox = create_horizontal_adjusting_combo_box(
tab, prefix + u'StyleComboBox')
styleComboBox = create_horizontal_adjusting_combo_box(tab, prefix + u'StyleComboBox')
styleComboBox.addItems([u'', u'', u''])
layout.addWidget(styleComboBox, idx + 2, 1, 1, 2)
searchButtonLayout = QtGui.QHBoxLayout()
@ -173,8 +165,7 @@ class BibleMediaItem(MediaManagerItem):
layout.addLayout(searchButtonLayout, idx + 3, 1, 1, 2)
self.pageLayout.addWidget(tab)
tab.setVisible(False)
QtCore.QObject.connect(lockButton, QtCore.SIGNAL(u'toggled(bool)'),
self.onLockButtonToggled)
QtCore.QObject.connect(lockButton, QtCore.SIGNAL(u'toggled(bool)'), self.onLockButtonToggled)
setattr(self, prefix + u'VersionLabel', versionLabel)
setattr(self, prefix + u'VersionComboBox', versionComboBox)
setattr(self, prefix + u'SecondLabel', secondLabel)
@ -191,29 +182,23 @@ class BibleMediaItem(MediaManagerItem):
self.searchTabBar.setObjectName(u'searchTabBar')
self.pageLayout.addWidget(self.searchTabBar)
# Add the Quick Search tab.
self.addSearchTab(
u'quick', translate('BiblesPlugin.MediaItem', 'Quick'))
self.addSearchTab(u'quick', translate('BiblesPlugin.MediaItem', 'Quick'))
self.quickSearchLabel = QtGui.QLabel(self.quickTab)
self.quickSearchLabel.setObjectName(u'quickSearchLabel')
self.quickLayout.addWidget(
self.quickSearchLabel, 0, 0, QtCore.Qt.AlignRight)
self.quickLayout.addWidget(self.quickSearchLabel, 0, 0, QtCore.Qt.AlignRight)
self.quickSearchEdit = SearchEdit(self.quickTab)
self.quickSearchEdit.setSizePolicy(
QtGui.QSizePolicy.Ignored, QtGui.QSizePolicy.Fixed)
self.quickSearchEdit.setSizePolicy(QtGui.QSizePolicy.Ignored, QtGui.QSizePolicy.Fixed)
self.quickSearchEdit.setObjectName(u'quickSearchEdit')
self.quickSearchLabel.setBuddy(self.quickSearchEdit)
self.quickLayout.addWidget(self.quickSearchEdit, 0, 1, 1, 2)
self.addSearchFields(
u'quick', translate('BiblesPlugin.MediaItem', 'Quick'))
self.addSearchFields(u'quick', translate('BiblesPlugin.MediaItem', 'Quick'))
self.quickTab.setVisible(True)
# Add the Advanced Search tab.
self.addSearchTab(u'advanced', UiStrings().Advanced)
self.advancedBookLabel = QtGui.QLabel(self.advancedTab)
self.advancedBookLabel.setObjectName(u'advancedBookLabel')
self.advancedLayout.addWidget(self.advancedBookLabel, 0, 0,
QtCore.Qt.AlignRight)
self.advancedBookComboBox = create_horizontal_adjusting_combo_box(
self.advancedTab, u'advancedBookComboBox')
self.advancedLayout.addWidget(self.advancedBookLabel, 0, 0, QtCore.Qt.AlignRight)
self.advancedBookComboBox = create_horizontal_adjusting_combo_box(self.advancedTab, u'advancedBookComboBox')
self.advancedBookLabel.setBuddy(self.advancedBookComboBox)
self.advancedLayout.addWidget(self.advancedBookComboBox, 0, 1, 1, 2)
self.advancedChapterLabel = QtGui.QLabel(self.advancedTab)
@ -224,8 +209,7 @@ class BibleMediaItem(MediaManagerItem):
self.advancedLayout.addWidget(self.advancedVerseLabel, 1, 2)
self.advancedFromLabel = QtGui.QLabel(self.advancedTab)
self.advancedFromLabel.setObjectName(u'advancedFromLabel')
self.advancedLayout.addWidget(self.advancedFromLabel, 3, 0,
QtCore.Qt.AlignRight)
self.advancedLayout.addWidget(self.advancedFromLabel, 3, 0, QtCore.Qt.AlignRight)
self.advancedFromChapter = QtGui.QComboBox(self.advancedTab)
self.advancedFromChapter.setObjectName(u'advancedFromChapter')
self.advancedLayout.addWidget(self.advancedFromChapter, 3, 1)
@ -234,8 +218,7 @@ class BibleMediaItem(MediaManagerItem):
self.advancedLayout.addWidget(self.advancedFromVerse, 3, 2)
self.advancedToLabel = QtGui.QLabel(self.advancedTab)
self.advancedToLabel.setObjectName(u'advancedToLabel')
self.advancedLayout.addWidget(self.advancedToLabel, 4, 0,
QtCore.Qt.AlignRight)
self.advancedLayout.addWidget(self.advancedToLabel, 4, 0, QtCore.Qt.AlignRight)
self.advancedToChapter = QtGui.QComboBox(self.advancedTab)
self.advancedToChapter.setObjectName(u'advancedToChapter')
self.advancedLayout.addWidget(self.advancedToChapter, 4, 1)
@ -244,44 +227,29 @@ class BibleMediaItem(MediaManagerItem):
self.advancedLayout.addWidget(self.advancedToVerse, 4, 2)
self.addSearchFields(u'advanced', UiStrings().Advanced)
# Combo Boxes
QtCore.QObject.connect(self.quickVersionComboBox,
QtCore.SIGNAL(u'activated(int)'), self.updateAutoCompleter)
QtCore.QObject.connect(self.quickSecondComboBox,
QtCore.SIGNAL(u'activated(int)'), self.updateAutoCompleter)
QtCore.QObject.connect(self.advancedVersionComboBox,
QtCore.SIGNAL(u'activated(int)'), self.onAdvancedVersionComboBox)
QtCore.QObject.connect(self.advancedSecondComboBox,
QtCore.SIGNAL(u'activated(int)'), self.onAdvancedSecondComboBox)
QtCore.QObject.connect(self.advancedBookComboBox,
QtCore.SIGNAL(u'activated(int)'), self.onAdvancedBookComboBox)
QtCore.QObject.connect(self.advancedFromChapter,
QtCore.SIGNAL(u'activated(int)'), self.onAdvancedFromChapter)
QtCore.QObject.connect(self.advancedFromVerse,
QtCore.SIGNAL(u'activated(int)'), self.onAdvancedFromVerse)
QtCore.QObject.connect(self.advancedToChapter,
QtCore.SIGNAL(u'activated(int)'), self.onAdvancedToChapter)
QtCore.QObject.connect(self.quickSearchEdit,
QtCore.SIGNAL(u'searchTypeChanged(int)'), self.updateAutoCompleter)
QtCore.QObject.connect(self.quickVersionComboBox,
QtCore.SIGNAL(u'activated(int)'), self.updateAutoCompleter)
QtCore.QObject.connect(
self.quickStyleComboBox, QtCore.SIGNAL(u'activated(int)'),
QtCore.QObject.connect(self.quickVersionComboBox, QtCore.SIGNAL(u'activated(int)'), self.updateAutoCompleter)
QtCore.QObject.connect(self.quickSecondComboBox, QtCore.SIGNAL(u'activated(int)'), self.updateAutoCompleter)
QtCore.QObject.connect(self.advancedVersionComboBox,QtCore.SIGNAL(u'activated(int)'),
self.onAdvancedVersionComboBox)
QtCore.QObject.connect(self.advancedSecondComboBox, QtCore.SIGNAL(u'activated(int)'),
self.onAdvancedSecondComboBox)
QtCore.QObject.connect(self.advancedBookComboBox, QtCore.SIGNAL(u'activated(int)'), self.onAdvancedBookComboBox)
QtCore.QObject.connect(self.advancedFromChapter, QtCore.SIGNAL(u'activated(int)'), self.onAdvancedFromChapter)
QtCore.QObject.connect(self.advancedFromVerse, QtCore.SIGNAL(u'activated(int)'), self.onAdvancedFromVerse)
QtCore.QObject.connect(self.advancedToChapter, QtCore.SIGNAL(u'activated(int)'), self.onAdvancedToChapter)
QtCore.QObject.connect(self.quickSearchEdit, QtCore.SIGNAL(u'searchTypeChanged(int)'), self.updateAutoCompleter)
QtCore.QObject.connect(self.quickVersionComboBox, QtCore.SIGNAL(u'activated(int)'), self.updateAutoCompleter)
QtCore.QObject.connect(self.quickStyleComboBox, QtCore.SIGNAL(u'activated(int)'),
self.onQuickStyleComboBoxChanged)
QtCore.QObject.connect(
self.advancedStyleComboBox, QtCore.SIGNAL(u'activated(int)'),
QtCore.QObject.connect( self.advancedStyleComboBox, QtCore.SIGNAL(u'activated(int)'),
self.onAdvancedStyleComboBoxChanged)
# Buttons
QtCore.QObject.connect(self.advancedSearchButton,
QtCore.SIGNAL(u'clicked()'), self.onAdvancedSearchButton)
QtCore.QObject.connect(self.quickSearchButton,
QtCore.SIGNAL(u'clicked()'), self.onQuickSearchButton)
QtCore.QObject.connect(Receiver.get_receiver(),
QtCore.SIGNAL(u'config_updated'), self.configUpdated)
QtCore.QObject.connect(self.advancedSearchButton, QtCore.SIGNAL(u'clicked()'), self.onAdvancedSearchButton)
QtCore.QObject.connect(self.quickSearchButton, QtCore.SIGNAL(u'clicked()'), self.onQuickSearchButton)
QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'config_updated'), self.configUpdated)
# Other stuff
QtCore.QObject.connect(self.quickSearchEdit,
QtCore.SIGNAL(u'returnPressed()'), self.onQuickSearchButton)
QtCore.QObject.connect(self.searchTabBar,
QtCore.SIGNAL(u'currentChanged(int)'),
QtCore.QObject.connect(self.quickSearchEdit, QtCore.SIGNAL(u'returnPressed()'), self.onQuickSearchButton)
QtCore.QObject.connect(self.searchTabBar, QtCore.SIGNAL(u'currentChanged(int)'),
self.onSearchTabBarCurrentChanged)
def onFocus(self):
@ -307,41 +275,27 @@ class BibleMediaItem(MediaManagerItem):
def retranslateUi(self):
log.debug(u'retranslateUi')
self.quickSearchLabel.setText(
translate('BiblesPlugin.MediaItem', 'Find:'))
self.quickSearchLabel.setText(translate('BiblesPlugin.MediaItem', 'Find:'))
self.quickVersionLabel.setText(u'%s:' % UiStrings().Version)
self.quickSecondLabel.setText(
translate('BiblesPlugin.MediaItem', 'Second:'))
self.quickSecondLabel.setText(translate('BiblesPlugin.MediaItem', 'Second:'))
self.quickStyleLabel.setText(UiStrings().LayoutStyle)
self.quickStyleComboBox.setItemText(LayoutStyle.VersePerSlide,
UiStrings().VersePerSlide)
self.quickStyleComboBox.setItemText(LayoutStyle.VersePerLine,
UiStrings().VersePerLine)
self.quickStyleComboBox.setItemText(LayoutStyle.Continuous,
UiStrings().Continuous)
self.quickStyleComboBox.setItemText(LayoutStyle.VersePerSlide, UiStrings().VersePerSlide)
self.quickStyleComboBox.setItemText(LayoutStyle.VersePerLine, UiStrings().VersePerLine)
self.quickStyleComboBox.setItemText(LayoutStyle.Continuous, UiStrings().Continuous)
self.quickLockButton.setToolTip(translate('BiblesPlugin.MediaItem',
'Toggle to keep or clear the previous results.'))
self.quickSearchButton.setText(UiStrings().Search)
self.advancedBookLabel.setText(
translate('BiblesPlugin.MediaItem', 'Book:'))
self.advancedChapterLabel.setText(
translate('BiblesPlugin.MediaItem', 'Chapter:'))
self.advancedVerseLabel.setText(
translate('BiblesPlugin.MediaItem', 'Verse:'))
self.advancedFromLabel.setText(
translate('BiblesPlugin.MediaItem', 'From:'))
self.advancedToLabel.setText(
translate('BiblesPlugin.MediaItem', 'To:'))
self.advancedBookLabel.setText(translate('BiblesPlugin.MediaItem', 'Book:'))
self.advancedChapterLabel.setText(translate('BiblesPlugin.MediaItem', 'Chapter:'))
self.advancedVerseLabel.setText(translate('BiblesPlugin.MediaItem', 'Verse:'))
self.advancedFromLabel.setText(translate('BiblesPlugin.MediaItem', 'From:'))
self.advancedToLabel.setText(translate('BiblesPlugin.MediaItem', 'To:'))
self.advancedVersionLabel.setText(u'%s:' % UiStrings().Version)
self.advancedSecondLabel.setText(
translate('BiblesPlugin.MediaItem', 'Second:'))
self.advancedSecondLabel.setText(translate('BiblesPlugin.MediaItem', 'Second:'))
self.advancedStyleLabel.setText(UiStrings().LayoutStyle)
self.advancedStyleComboBox.setItemText(LayoutStyle.VersePerSlide,
UiStrings().VersePerSlide)
self.advancedStyleComboBox.setItemText(LayoutStyle.VersePerLine,
UiStrings().VersePerLine)
self.advancedStyleComboBox.setItemText(LayoutStyle.Continuous,
UiStrings().Continuous)
self.advancedStyleComboBox.setItemText(LayoutStyle.VersePerSlide, UiStrings().VersePerSlide)
self.advancedStyleComboBox.setItemText(LayoutStyle.VersePerLine, UiStrings().VersePerLine)
self.advancedStyleComboBox.setItemText(LayoutStyle.Continuous, UiStrings().Continuous)
self.advancedLockButton.setToolTip(translate('BiblesPlugin.MediaItem',
'Toggle to keep or clear the previous results.'))
self.advancedSearchButton.setText(UiStrings().Search)
@ -353,14 +307,12 @@ class BibleMediaItem(MediaManagerItem):
self.quickSearchEdit.setSearchTypes([
(BibleSearch.Reference, u':/bibles/bibles_search_reference.png',
translate('BiblesPlugin.MediaItem', 'Scripture Reference'),
translate(
'BiblesPlugin.MediaItem', 'Search Scripture Reference...')),
translate('BiblesPlugin.MediaItem', 'Search Scripture Reference...')),
(BibleSearch.Text, u':/bibles/bibles_search_text.png',
translate('BiblesPlugin.MediaItem', 'Text Search'),
translate('BiblesPlugin.MediaItem', 'Search Text...'))
])
self.quickSearchEdit.setCurrentSearchType(Settings().value(
u'%s/last search type' % self.settingsSection,
self.quickSearchEdit.setCurrentSearchType(Settings().value(u'%s/last search type' % self.settingsSection,
BibleSearch.Reference))
self.configUpdated()
log.debug(u'bible manager initialise complete')
@ -389,9 +341,7 @@ class BibleMediaItem(MediaManagerItem):
self.initialiseAdvancedBible(unicode(bible))
elif bibles:
self.initialiseAdvancedBible(bibles[0])
bible = Settings().value(
self.settingsSection + u'/quick bible',
self.quickVersionComboBox.currentText())
bible = Settings().value(self.settingsSection + u'/quick bible', self.quickVersionComboBox.currentText())
find_and_set_in_combo_box(self.quickVersionComboBox, bible)
def reloadBibles(self, process=False):
@ -439,23 +389,18 @@ class BibleMediaItem(MediaManagerItem):
if language_selection == LanguageSelection.Bible:
self.advancedBookComboBox.addItem(book[u'name'])
elif language_selection == LanguageSelection.Application:
data = BiblesResourcesDB.get_book_by_id(
book[u'book_reference_id'])
self.advancedBookComboBox.addItem(
book_names[data[u'abbreviation']])
data = BiblesResourcesDB.get_book_by_id(book[u'book_reference_id'])
self.advancedBookComboBox.addItem(book_names[data[u'abbreviation']])
elif language_selection == LanguageSelection.English:
data = BiblesResourcesDB.get_book_by_id(
book[u'book_reference_id'])
data = BiblesResourcesDB.get_book_by_id(book[u'book_reference_id'])
self.advancedBookComboBox.addItem(data[u'name'])
self.advancedBookComboBox.setItemData(
row, book[u'book_reference_id'])
self.advancedBookComboBox.setItemData(row, book[u'book_reference_id'])
if first:
first = False
first_book = book
initialise_chapter_verse = True
if last_book_id and last_book_id == int(book[u'book_reference_id']):
index = self.advancedBookComboBox.findData(
book[u'book_reference_id'])
index = self.advancedBookComboBox.findData(book[u'book_reference_id'])
if index == -1:
# Not Found.
index = 0
@ -466,17 +411,13 @@ class BibleMediaItem(MediaManagerItem):
first_book[u'book_reference_id'])
def initialiseChapterVerse(self, bible, book, book_ref_id):
log.debug(u'initialiseChapterVerse %s, %s, %s', bible, book,
book_ref_id)
log.debug(u'initialiseChapterVerse %s, %s, %s', bible, book, book_ref_id)
book = self.plugin.manager.get_book_by_id(bible, book_ref_id)
self.chapter_count = self.plugin.manager.get_chapter_count(bible, book)
verse_count = self.plugin.manager.get_verse_count_by_book_ref_id(bible,
book_ref_id, 1)
verse_count = self.plugin.manager.get_verse_count_by_book_ref_id(bible, book_ref_id, 1)
if verse_count == 0:
self.advancedSearchButton.setEnabled(False)
critical_error_message_box(
message=translate('BiblesPlugin.MediaItem',
'Bible not fully loaded.'))
critical_error_message_box(message=translate('BiblesPlugin.MediaItem', 'Bible not fully loaded.'))
else:
self.advancedSearchButton.setEnabled(True)
self.adjustComboBox(1, self.chapter_count, self.advancedFromChapter)
@ -492,11 +433,9 @@ class BibleMediaItem(MediaManagerItem):
"""
log.debug(u'updateAutoCompleter')
# Save the current search type to the configuration.
Settings().setValue(u'%s/last search type' %
self.settingsSection, self.quickSearchEdit.currentSearchType())
Settings().setValue(u'%s/last search type' % self.settingsSection, self.quickSearchEdit.currentSearchType())
# Save the current bible to the configuration.
Settings().setValue(self.settingsSection + u'/quick bible',
self.quickVersionComboBox.currentText())
Settings().setValue(self.settingsSection + u'/quick bible', self.quickVersionComboBox.currentText())
books = []
# We have to do a 'Reference Search'.
if self.quickSearchEdit.currentSearchType() == BibleSearch.Reference:
@ -510,33 +449,27 @@ class BibleMediaItem(MediaManagerItem):
book_data_temp = []
for book in book_data:
for secondbook in secondbook_data:
if book.book_reference_id == \
secondbook.book_reference_id:
if book.book_reference_id == secondbook.book_reference_id:
book_data_temp.append(book)
book_data = book_data_temp
language_selection = self.plugin.manager.get_language_selection(
bible)
language_selection = self.plugin.manager.get_language_selection(bible)
if language_selection == LanguageSelection.Bible:
books = [book.name + u' ' for book in book_data]
elif language_selection == LanguageSelection.Application:
book_names = BibleStrings().BookNames
for book in book_data:
data = BiblesResourcesDB.get_book_by_id(
book.book_reference_id)
books.append(unicode(
book_names[data[u'abbreviation']]) + u' ')
data = BiblesResourcesDB.get_book_by_id(book.book_reference_id)
books.append(unicode(book_names[data[u'abbreviation']]) + u' ')
elif language_selection == LanguageSelection.English:
for book in book_data:
data = BiblesResourcesDB.get_book_by_id(
book.book_reference_id)
data = BiblesResourcesDB.get_book_by_id(book.book_reference_id)
books.append(data[u'name'] + u' ')
books.sort(cmp=locale_compare)
set_case_insensitive_completer(books, self.quickSearchEdit)
def onImportClick(self):
if not hasattr(self, u'import_wizard'):
self.import_wizard = BibleImportForm(self, self.plugin.manager,
self.plugin)
self.import_wizard = BibleImportForm(self, self.plugin.manager, self.plugin)
# If the import was not cancelled then reload.
if self.import_wizard.exec_():
self.reloadBibles()
@ -547,8 +480,7 @@ class BibleMediaItem(MediaManagerItem):
elif self.advancedTab.isVisible():
bible = self.advancedVersionComboBox.currentText()
if bible:
self.editBibleForm = EditBibleForm(self, self.plugin.formParent,
self.plugin.manager)
self.editBibleForm = EditBibleForm(self, self.plugin.formParent, self.plugin.manager)
self.editBibleForm.loadBible(bible)
if self.editBibleForm.exec_():
self.reloadBibles()
@ -560,12 +492,9 @@ class BibleMediaItem(MediaManagerItem):
bible = self.advancedVersionComboBox.currentText()
if bible:
if QtGui.QMessageBox.question(self, UiStrings().ConfirmDelete,
translate('BiblesPlugin.MediaItem',
'Are you sure you want to completely delete "%s" Bible from '
'OpenLP?\n\nYou will need to re-import this Bible to use it '
'again.') % bible,
QtGui.QMessageBox.StandardButtons(QtGui.QMessageBox.Yes |
QtGui.QMessageBox.No),
translate('BiblesPlugin.MediaItem', 'Are you sure you want to completely delete "%s" Bible from '
'OpenLP?\n\nYou will need to re-import this Bible to use it again.') % bible,
QtGui.QMessageBox.StandardButtons(QtGui.QMessageBox.Yes | QtGui.QMessageBox.No),
QtGui.QMessageBox.Yes) == QtGui.QMessageBox.No:
return
self.plugin.manager.delete_bible(bible)
@ -590,33 +519,23 @@ class BibleMediaItem(MediaManagerItem):
def onQuickStyleComboBoxChanged(self):
self.settings.layout_style = self.quickStyleComboBox.currentIndex()
self.advancedStyleComboBox.setCurrentIndex(self.settings.layout_style)
self.settings.layoutStyleComboBox.setCurrentIndex(
self.settings.layout_style)
Settings().setValue(
self.settingsSection + u'/verse layout style',
self.settings.layout_style)
self.settings.layoutStyleComboBox.setCurrentIndex(self.settings.layout_style)
Settings().setValue(self.settingsSection + u'/verse layout style', self.settings.layout_style)
def onAdvancedStyleComboBoxChanged(self):
self.settings.layout_style = self.advancedStyleComboBox.currentIndex()
self.quickStyleComboBox.setCurrentIndex(self.settings.layout_style)
self.settings.layoutStyleComboBox.setCurrentIndex(
self.settings.layout_style)
Settings().setValue(
self.settingsSection + u'/verse layout style',
self.settings.layout_style)
self.settings.layoutStyleComboBox.setCurrentIndex(self.settings.layout_style)
Settings().setValue(self.settingsSection + u'/verse layout style', self.settings.layout_style)
def onAdvancedVersionComboBox(self):
Settings().setValue(self.settingsSection + u'/advanced bible',
self.advancedVersionComboBox.currentText())
Settings().setValue(self.settingsSection + u'/advanced bible', self.advancedVersionComboBox.currentText())
self.initialiseAdvancedBible(self.advancedVersionComboBox.currentText(),
self.advancedBookComboBox.itemData(
int(self.advancedBookComboBox.currentIndex())))
self.advancedBookComboBox.itemData(int(self.advancedBookComboBox.currentIndex())))
def onAdvancedSecondComboBox(self):
self.initialiseAdvancedBible(
self.advancedVersionComboBox.currentText(),
self.advancedBookComboBox.itemData(
int(self.advancedBookComboBox.currentIndex())))
self.initialiseAdvancedBible(self.advancedVersionComboBox.currentText(),
self.advancedBookComboBox.itemData(int(self.advancedBookComboBox.currentIndex())))
def onAdvancedBookComboBox(self):
item = int(self.advancedBookComboBox.currentIndex())
@ -630,24 +549,19 @@ class BibleMediaItem(MediaManagerItem):
chapter_to = int(self.advancedToChapter.currentText())
if chapter_from == chapter_to:
bible = self.advancedVersionComboBox.currentText()
book_ref_id = self.advancedBookComboBox.itemData(
int(self.advancedBookComboBox.currentIndex()))
book_ref_id = self.advancedBookComboBox.itemData(int(self.advancedBookComboBox.currentIndex()))
verse_from = int(self.advancedFromVerse.currentText())
verse_count = self.plugin.manager.get_verse_count_by_book_ref_id(
bible, book_ref_id, chapter_to)
self.adjustComboBox(verse_from, verse_count,
self.advancedToVerse, True)
verse_count = self.plugin.manager.get_verse_count_by_book_ref_id(bible, book_ref_id, chapter_to)
self.adjustComboBox(verse_from, verse_count, self.advancedToVerse, True)
def onAdvancedToChapter(self):
bible = self.advancedVersionComboBox.currentText()
book_ref_id = self.advancedBookComboBox.itemData(
int(self.advancedBookComboBox.currentIndex()))
book_ref_id = self.advancedBookComboBox.itemData(int(self.advancedBookComboBox.currentIndex()))
chapter_from = int(self.advancedFromChapter.currentText())
chapter_to = int(self.advancedToChapter.currentText())
verse_from = int(self.advancedFromVerse.currentText())
verse_to = int(self.advancedToVerse.currentText())
verse_count = self.plugin.manager.get_verse_count_by_book_ref_id(bible,
book_ref_id, chapter_to)
verse_count = self.plugin.manager.get_verse_count_by_book_ref_id(bible, book_ref_id, chapter_to)
if chapter_from == chapter_to and verse_from > verse_to:
self.adjustComboBox(verse_from, verse_count, self.advancedToVerse)
else:
@ -659,20 +573,16 @@ class BibleMediaItem(MediaManagerItem):
int(self.advancedBookComboBox.currentIndex()))
chapter_from = int(self.advancedFromChapter.currentText())
chapter_to = int(self.advancedToChapter.currentText())
verse_count = self.plugin.manager.get_verse_count_by_book_ref_id(bible,
book_ref_id, chapter_from)
verse_count = self.plugin.manager.get_verse_count_by_book_ref_id(bible, book_ref_id, chapter_from)
self.adjustComboBox(1, verse_count, self.advancedFromVerse)
if chapter_from > chapter_to:
self.adjustComboBox(1, verse_count, self.advancedToVerse)
self.adjustComboBox(chapter_from, self.chapter_count,
self.advancedToChapter)
self.adjustComboBox(chapter_from, self.chapter_count, self.advancedToChapter)
elif chapter_from == chapter_to:
self.adjustComboBox(chapter_from, self.chapter_count,
self.advancedToChapter)
self.adjustComboBox(chapter_from, self.chapter_count, self.advancedToChapter)
self.adjustComboBox(1, verse_count, self.advancedToVerse, True)
else:
self.adjustComboBox(chapter_from, self.chapter_count,
self.advancedToChapter, True)
self.adjustComboBox(chapter_from, self.chapter_count, self.advancedToChapter, True)
def adjustComboBox(self, range_from, range_to, combo, restore=False):
"""
@ -709,23 +619,20 @@ class BibleMediaItem(MediaManagerItem):
bible = self.advancedVersionComboBox.currentText()
second_bible = self.advancedSecondComboBox.currentText()
book = self.advancedBookComboBox.currentText()
book_ref_id = self.advancedBookComboBox.itemData(
int(self.advancedBookComboBox.currentIndex()))
book_ref_id = self.advancedBookComboBox.itemData(int(self.advancedBookComboBox.currentIndex()))
chapter_from = self.advancedFromChapter.currentText()
chapter_to = self.advancedToChapter.currentText()
verse_from = self.advancedFromVerse.currentText()
verse_to = self.advancedToVerse.currentText()
verse_separator = get_reference_separator(u'sep_v_display')
range_separator = get_reference_separator(u'sep_r_display')
verse_range = chapter_from + verse_separator + verse_from + \
range_separator + chapter_to + verse_separator + verse_to
verse_range = chapter_from + verse_separator + verse_from + range_separator + chapter_to + \
verse_separator + verse_to
versetext = u'%s %s' % (book, verse_range)
Receiver.send_message(u'cursor_busy')
self.search_results = self.plugin.manager.get_verses(bible, versetext,
book_ref_id)
self.search_results = self.plugin.manager.get_verses(bible, versetext, book_ref_id)
if second_bible:
self.second_search_results = self.plugin.manager.get_verses(
second_bible, versetext, book_ref_id)
self.second_search_results = self.plugin.manager.get_verses(second_bible, versetext, book_ref_id)
if not self.advancedLockButton.isChecked():
self.listView.clear()
if self.listView.count() != 0:
@ -752,27 +659,23 @@ class BibleMediaItem(MediaManagerItem):
# We are doing a 'Reference Search'.
self.search_results = self.plugin.manager.get_verses(bible, text)
if second_bible and self.search_results:
self.second_search_results = self.plugin.manager.get_verses(
second_bible, text,
self.second_search_results = self.plugin.manager.get_verses(second_bible, text,
self.search_results[0].book.book_reference_id)
else:
# We are doing a 'Text Search'.
Receiver.send_message(u'cursor_busy')
bibles = self.plugin.manager.get_bibles()
self.search_results = self.plugin.manager.verse_search(bible,
second_bible, text)
self.search_results = self.plugin.manager.verse_search(bible, second_bible, text)
if second_bible and self.search_results:
text = []
new_search_results = []
count = 0
passage_not_found = False
for verse in self.search_results:
db_book = bibles[second_bible].get_book_by_book_ref_id(
verse.book.book_reference_id)
db_book = bibles[second_bible].get_book_by_book_ref_id(verse.book.book_reference_id)
if not db_book:
log.debug(u'Passage "%s %d:%d" not found in Second '
u'Bible' % (verse.book.name, verse.chapter,
verse.verse))
log.debug(u'Passage "%s %d:%d" not found in Second Bible' %
(verse.book.name, verse.chapter, verse.verse))
passage_not_found = True
count += 1
continue
@ -780,17 +683,13 @@ class BibleMediaItem(MediaManagerItem):
text.append((verse.book.book_reference_id, verse.chapter,
verse.verse, verse.verse))
if passage_not_found:
QtGui.QMessageBox.information(self,
translate('BiblesPlugin.MediaItem', 'Information'),
translate('BiblesPlugin.MediaItem',
'The second Bible does not contain all the verses '
'that are in the main Bible. Only verses found in both '
'Bibles will be shown. %d verses have not been '
'included in the results.') % count,
QtGui.QMessageBox.information(self, translate('BiblesPlugin.MediaItem', 'Information'),
translate('BiblesPlugin.MediaItem', 'The second Bible does not contain all the verses '
'that are in the main Bible. Only verses found in both Bibles will be shown. %d verses '
'have not been included in the results.') % count,
QtGui.QMessageBox.StandardButtons(QtGui.QMessageBox.Ok))
self.search_results = new_search_results
self.second_search_results = \
bibles[second_bible].get_verses(text)
self.second_search_results = bibles[second_bible].get_verses(text)
if not self.quickLockButton.isChecked():
self.listView.clear()
if self.listView.count() != 0 and self.search_results:
@ -807,8 +706,7 @@ class BibleMediaItem(MediaManagerItem):
Displays the search results in the media manager. All data needed for
further action is saved for/in each row.
"""
items = self.buildDisplayResults(bible, second_bible,
self.search_results)
items = self.buildDisplayResults(bible, second_bible, self.search_results)
for bible_verse in items:
self.listView.addItem(bible_verse)
self.listView.selectAll()
@ -823,18 +721,14 @@ class BibleMediaItem(MediaManagerItem):
verse_separator = get_reference_separator(u'sep_v_display')
version = self.plugin.manager.get_meta_data(bible, u'name').value
copyright = self.plugin.manager.get_meta_data(bible, u'copyright').value
permissions = \
self.plugin.manager.get_meta_data(bible, u'permissions').value
permissions = self.plugin.manager.get_meta_data(bible, u'permissions').value
second_version = u''
second_copyright = u''
second_permissions = u''
if second_bible:
second_version = self.plugin.manager.get_meta_data(
second_bible, u'name').value
second_copyright = self.plugin.manager.get_meta_data(
second_bible, u'copyright').value
second_permissions = self.plugin.manager.get_meta_data(
second_bible, u'permissions').value
second_version = self.plugin.manager.get_meta_data(second_bible, u'name').value
second_copyright = self.plugin.manager.get_meta_data(second_bible, u'copyright').value
second_permissions = self.plugin.manager.get_meta_data(second_bible, u'permissions').value
items = []
language_selection = self.plugin.manager.get_language_selection(bible)
for count, verse in enumerate(search_results):
@ -843,12 +737,10 @@ class BibleMediaItem(MediaManagerItem):
book = verse.book.name
elif language_selection == LanguageSelection.Application:
book_names = BibleStrings().BookNames
data = BiblesResourcesDB.get_book_by_id(
verse.book.book_reference_id)
data = BiblesResourcesDB.get_book_by_id(verse.book.book_reference_id)
book = unicode(book_names[data[u'abbreviation']])
elif language_selection == LanguageSelection.English:
data = BiblesResourcesDB.get_book_by_id(
verse.book.book_reference_id)
data = BiblesResourcesDB.get_book_by_id(verse.book.book_reference_id)
book = data[u'name']
data = {
'book': book,
@ -867,17 +759,14 @@ class BibleMediaItem(MediaManagerItem):
}
if second_bible:
try:
data[u'second_text'] = \
self.second_search_results[count].text
data[u'second_text'] = self.second_search_results[count].text
except IndexError:
log.exception(u'The second_search_results does not have as '
'many verses as the search_results.')
log.exception(u'The second_search_results does not have as many verses as the search_results.')
break
bible_text = u'%s %d%s%d (%s, %s)' % (book, verse.chapter,
verse_separator, verse.verse, version, second_version)
bible_text = u'%s %d%s%d (%s, %s)' % (book, verse.chapter, verse_separator, verse.verse, version,
second_version)
else:
bible_text = u'%s %d%s%d (%s)' % (book, verse.chapter,
verse_separator, verse.verse, version)
bible_text = u'%s %d%s%d (%s)' % (book, verse.chapter, verse_separator, verse.verse, version)
bible_verse = QtGui.QListWidgetItem(bible_text)
bible_verse.setData(QtCore.Qt.UserRole, data)
items.append(bible_verse)
@ -914,14 +803,12 @@ class BibleMediaItem(MediaManagerItem):
second_bible = self._decodeQtObject(bitem, 'second_bible')
second_version = self._decodeQtObject(bitem, 'second_version')
second_copyright = self._decodeQtObject(bitem, 'second_copyright')
second_permissions = \
self._decodeQtObject(bitem, 'second_permissions')
second_permissions = self._decodeQtObject(bitem, 'second_permissions')
second_text = self._decodeQtObject(bitem, 'second_text')
verses.add(book, chapter, verse, version, copyright, permissions)
verse_text = self.formatVerse(old_chapter, chapter, verse)
if second_bible:
bible_text = u'%s&nbsp;%s\n\n%s&nbsp;%s' % (verse_text, text,
verse_text, second_text)
bible_text = u'%s&nbsp;%s\n\n%s&nbsp;%s' % (verse_text, text, verse_text, second_text)
raw_slides.append(bible_text.rstrip())
bible_text = u''
# If we are 'Verse Per Slide' then create a new slide.
@ -946,8 +833,7 @@ class BibleMediaItem(MediaManagerItem):
# Add footer
service_item.raw_footer.append(verses.format_verses())
if second_bible:
verses.add_version(second_version, second_copyright,
second_permissions)
verses.add_version(second_version, second_copyright, second_permissions)
service_item.raw_footer.append(verses.format_versions())
raw_title.append(self.formatTitle(start_item, bitem))
# If there are no more items we check whether we have to add bible_text.
@ -955,8 +841,7 @@ class BibleMediaItem(MediaManagerItem):
raw_slides.append(bible_text.lstrip())
bible_text = u''
# Service Item: Capabilities
if self.settings.layout_style == LayoutStyle.Continuous and \
not second_bible:
if self.settings.layout_style == LayoutStyle.Continuous and not second_bible:
# Split the line but do not replace line breaks in renderer.
service_item.add_capability(ItemCapabilities.NoLineBreaks)
service_item.add_capability(ItemCapabilities.CanPreview)
@ -1002,8 +887,7 @@ class BibleMediaItem(MediaManagerItem):
if start_verse == old_verse:
verse_range = start_chapter + verse_separator + start_verse
else:
verse_range = start_chapter + verse_separator + start_verse + \
range_separator + old_verse
verse_range = start_chapter + verse_separator + start_verse + range_separator + old_verse
else:
verse_range = start_chapter + verse_separator + start_verse + \
range_separator + old_chapter + verse_separator + old_verse
@ -1032,16 +916,14 @@ class BibleMediaItem(MediaManagerItem):
old_verse = int(self._decodeQtObject(old_bitem, 'verse'))
old_bible = self._decodeQtObject(old_bitem, 'bible')
old_second_bible = self._decodeQtObject(old_bitem, 'second_bible')
if old_bible != bible or old_second_bible != second_bible or \
old_book != book:
if old_bible != bible or old_second_bible != second_bible or old_book != book:
# The bible, second bible or book has changed.
return True
elif old_verse + 1 != verse and old_chapter == chapter:
# We are still in the same chapter, but a verse has been skipped.
return True
elif old_chapter + 1 == chapter and (verse != 1 or
old_verse != self.plugin.manager.get_verse_count(
old_bible, old_book, old_chapter)):
old_verse != self.plugin.manager.get_verse_count(old_bible, old_book, old_chapter)):
# We are in the following chapter, but the last verse was not the
# last verse of the chapter or the current verse is not the
# first one of the chapter.
@ -1083,8 +965,7 @@ class BibleMediaItem(MediaManagerItem):
Search for some Bible verses (by reference).
"""
bible = self.quickVersionComboBox.currentText()
search_results = self.plugin.manager.get_verses(bible, string, False,
showError)
search_results = self.plugin.manager.get_verses(bible, string, False, showError)
if search_results:
versetext = u' '.join([verse.text for verse in search_results])
return [[string, versetext]]

View File

@ -1,5 +1,5 @@
# -*- coding: utf-8 -*-
# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4
# vim: autoindent shiftwidth=4 expandtab textwidth=120 tabstop=4 softtabstop=4
###############################################################################
# OpenLP - Open Source Lyrics Projection #
@ -56,8 +56,7 @@ class OpenLP1Bible(BibleDB):
connection = None
cursor = None
try:
connection = sqlite.connect(
self.filename.encode(sys.getfilesystemencoding()))
connection = sqlite.connect(self.filename.encode(sys.getfilesystemencoding()))
cursor = connection.cursor()
except sqlite.DatabaseError:
log.exception(u'File "%s" is encrypted or not a sqlite database, '
@ -72,8 +71,7 @@ class OpenLP1Bible(BibleDB):
return False
# Create all books.
try:
cursor.execute(
u'SELECT id, testament_id, name, abbreviation FROM book')
cursor.execute(u'SELECT id, testament_id, name, abbreviation FROM book')
except sqlite.DatabaseError as error:
log.exception(u'DatabaseError: %s' % error)
# Please add an user error here!
@ -92,12 +90,10 @@ class OpenLP1Bible(BibleDB):
book_ref_id = self.get_book_ref_id_by_name(name, len(books),
language_id)
if not book_ref_id:
log.exception(u'Importing books from "%s" '\
'failed' % self.filename)
log.exception(u'Importing books from "%s" failed' % self.filename)
return False
book_details = BiblesResourcesDB.get_book_by_id(book_ref_id)
db_book = self.create_book(name, book_ref_id,
book_details[u'testament_id'])
db_book = self.create_book(name, book_ref_id, book_details[u'testament_id'])
# Update the progess bar.
self.wizard.incrementProgressBar(WizardStrings.ImportingType % name)
# Import the verses for this book.

View File

@ -1,5 +1,5 @@
# -*- coding: utf-8 -*-
# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4
# vim: autoindent shiftwidth=4 expandtab textwidth=120 tabstop=4 softtabstop=4
###############################################################################
# OpenLP - Open Source Lyrics Projection #
@ -83,21 +83,17 @@ class OpenSongBible(BibleDB):
bible = opensong.getroot()
language_id = self.get_language(bible_name)
if not language_id:
log.exception(u'Importing books from "%s" '\
'failed' % self.filename)
log.exception(u'Importing books from "%s" failed' % self.filename)
return False
for book in bible.b:
if self.stop_import_flag:
break
book_ref_id = self.get_book_ref_id_by_name(
unicode(book.attrib[u'n']), len(bible.b), language_id)
book_ref_id = self.get_book_ref_id_by_name(unicode(book.attrib[u'n']), len(bible.b), language_id)
if not book_ref_id:
log.exception(u'Importing books from "%s" '\
'failed' % self.filename)
log.exception(u'Importing books from "%s" failed' % self.filename)
return False
book_details = BiblesResourcesDB.get_book_by_id(book_ref_id)
db_book = self.create_book(unicode(book.attrib[u'n']),
book_ref_id, book_details[u'testament_id'])
db_book = self.create_book(unicode(book.attrib[u'n']), book_ref_id, book_details[u'testament_id'])
chapter_number = 0
for chapter in book.c:
if self.stop_import_flag:
@ -130,15 +126,12 @@ class OpenSongBible(BibleDB):
chapter_number,
verse_number,
self.get_text(verse))
self.wizard.incrementProgressBar(translate(
'BiblesPlugin.Opensong', 'Importing %s %s...',
'Importing <book name> <chapter>...')) % \
(db_book.name, chapter_number)
self.wizard.incrementProgressBar(translate('BiblesPlugin.Opensong', 'Importing %s %s...',
'Importing <book name> <chapter>...')) % (db_book.name, chapter_number)
self.session.commit()
Receiver.send_message(u'openlp_process_events')
except etree.XMLSyntaxError as inst:
critical_error_message_box(
message=translate('BiblesPlugin.OpenSongImport',
critical_error_message_box(message=translate('BiblesPlugin.OpenSongImport',
'Incorrect Bible file type supplied. OpenSong Bibles may be '
'compressed. You must decompress them before import.'))
log.exception(inst)

View File

@ -1,5 +1,5 @@
# -*- coding: utf-8 -*-
# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4
# vim: autoindent shiftwidth=4 expandtab textwidth=120 tabstop=4 softtabstop=4
###############################################################################
# OpenLP - Open Source Lyrics Projection #
@ -72,8 +72,7 @@ class OSISBible(BibleDB):
r'<divineName(.*?)>(.*?)</divineName>')
self.spaces_regex = re.compile(r'([ ]{2,})')
filepath = os.path.join(
AppLocation.get_directory(AppLocation.PluginsDir), u'bibles',
u'resources', u'osisbooks.csv')
AppLocation.get_directory(AppLocation.PluginsDir), u'bibles', u'resources', u'osisbooks.csv')
def do_import(self, bible_name=None):
"""
@ -133,19 +132,16 @@ class OSISBible(BibleDB):
if not language_id:
language_id = self.get_language(bible_name)
if not language_id:
log.exception(u'Importing books from "%s" failed'
% self.filename)
log.exception(u'Importing books from "%s" failed' % self.filename)
return False
match_count += 1
book = unicode(match.group(1))
chapter = int(match.group(2))
verse = int(match.group(3))
verse_text = match.group(4)
book_ref_id = self.get_book_ref_id_by_name(book, book_count,
language_id)
book_ref_id = self.get_book_ref_id_by_name(book, book_count, language_id)
if not book_ref_id:
log.exception(u'Importing books from "%s" failed' %
self.filename)
log.exception(u'Importing books from "%s" failed' % self.filename)
return False
book_details = BiblesResourcesDB.get_book_by_id(book_ref_id)
if not db_book or db_book.name != book_details[u'name']:
@ -159,10 +155,8 @@ class OSISBible(BibleDB):
if last_chapter != chapter:
if last_chapter != 0:
self.session.commit()
self.wizard.incrementProgressBar(translate(
'BiblesPlugin.OsisImport', 'Importing %s %s...',
'Importing <book name> <chapter>...') %
(book_details[u'name'], chapter))
self.wizard.incrementProgressBar(translate('BiblesPlugin.OsisImport', 'Importing %s %s...',
'Importing <book name> <chapter>...') % (book_details[u'name'], chapter))
last_chapter = chapter
# All of this rigmarol below is because the mod2osis
# tool from the Sword library embeds XML in the OSIS
@ -182,9 +176,9 @@ class OSISBible(BibleDB):
verse_text = self.q_regex.sub(u'', verse_text)
verse_text = self.divine_name_regex.sub(repl, verse_text)
verse_text = self.trans_regex.sub(u'', verse_text)
verse_text = verse_text.replace(u'</lb>', u'')\
.replace(u'</l>', u'').replace(u'<lg>', u'')\
.replace(u'</lg>', u'').replace(u'</q>', u'')\
verse_text = verse_text.replace(u'</lb>', u'') \
.replace(u'</l>', u'').replace(u'<lg>', u'') \
.replace(u'</lg>', u'').replace(u'</q>', u'') \
.replace(u'</div>', u'').replace(u'</w>', u'')
verse_text = self.spaces_regex.sub(u' ', verse_text)
self.create_verse(db_book.id, chapter, verse, verse_text)

View File

@ -1,5 +1,5 @@
# -*- coding: utf-8 -*-
# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4
# vim: autoindent shiftwidth=4 expandtab textwidth=120 tabstop=4 softtabstop=4
###############################################################################
# OpenLP - Open Source Lyrics Projection #

View File

@ -1,5 +1,5 @@
# -*- coding: utf-8 -*-
# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4
# vim: autoindent shiftwidth=4 expandtab textwidth=120 tabstop=4 softtabstop=4
###############################################################################
# OpenLP - Open Source Lyrics Projection #
@ -40,8 +40,7 @@ class VerseReferenceList(object):
def add(self, book, chapter, verse, version, copyright, permission):
self.add_version(version, copyright, permission)
if not self.verse_list or \
self.verse_list[self.current_index][u'book'] != book:
if not self.verse_list or self.verse_list[self.current_index][u'book'] != book:
self.verse_list.append({u'version': version, u'book': book,
u'chapter': chapter, u'start': verse, u'end': verse})
self.current_index += 1
@ -60,26 +59,22 @@ class VerseReferenceList(object):
for bible_version in self.version_list:
if bible_version[u'version'] == version:
return
self.version_list.append({u'version': version, u'copyright': copyright,
u'permission': permission})
self.version_list.append({u'version': version, u'copyright': copyright, u'permission': permission})
def format_verses(self):
result = u''
for index, verse in enumerate(self.verse_list):
if index == 0:
result = u'%s %s:%s' % (verse[u'book'], verse[u'chapter'],
verse[u'start'])
result = u'%s %s:%s' % (verse[u'book'], verse[u'chapter'], verse[u'start'])
if verse[u'start'] != verse[u'end']:
result = u'%s-%s' % (result, verse[u'end'])
continue
prev = index - 1
if self.verse_list[prev][u'version'] != verse[u'version']:
result = u'%s (%s)' % (result,
self.verse_list[prev][u'version'])
result = u'%s (%s)' % (result, self.verse_list[prev][u'version'])
result = result + u', '
if self.verse_list[prev][u'book'] != verse[u'book']:
result = u'%s%s %s:' % (result, verse[u'book'],
verse[u'chapter'])
result = u'%s%s %s:' % (result, verse[u'book'], verse[u'chapter'])
elif self.verse_list[prev][u'chapter'] != verse[u'chapter']:
result = u'%s%s:' % (result, verse[u'chapter'])
result = result + str(verse[u'start'])
@ -96,8 +91,7 @@ class VerseReferenceList(object):
if result[-1] not in [u';', u',', u'.']:
result = result + u';'
result = result + u' '
result = u'%s%s, %s' % (result, version[u'version'],
version[u'copyright'])
result = u'%s%s, %s' % (result, version[u'version'], version[u'copyright'])
if version[u'permission'].strip():
result = result + u', ' + version[u'permission']
result = result.rstrip()

View File

@ -1,5 +1,5 @@
# -*- coding: utf-8 -*-
# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4
# vim: autoindent shiftwidth=4 expandtab textwidth=120 tabstop=4 softtabstop=4
###############################################################################
# OpenLP - Open Source Lyrics Projection #

View File

@ -1,5 +1,5 @@
# -*- coding: utf-8 -*-
# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4
# vim: autoindent shiftwidth=4 expandtab textwidth=120 tabstop=4 softtabstop=4
###############################################################################
# OpenLP - Open Source Lyrics Projection #
@ -31,8 +31,7 @@ from PyQt4 import QtCore, QtGui
import logging
from openlp.core.lib import Plugin, StringContent, build_icon, translate, \
Receiver, ImageSource, Settings
from openlp.core.lib import Plugin, StringContent, build_icon, translate, Receiver, ImageSource, Settings
from openlp.plugins.images.lib import ImageMediaItem, ImageTab
log = logging.getLogger(__name__)
@ -41,13 +40,11 @@ class ImagePlugin(Plugin):
log.info(u'Image Plugin loaded')
def __init__(self, plugin_helpers):
Plugin.__init__(self, u'images', plugin_helpers, ImageMediaItem,
ImageTab)
Plugin.__init__(self, u'images', plugin_helpers, ImageMediaItem, ImageTab)
self.weight = -7
self.iconPath = u':/plugins/plugin_images.png'
self.icon = build_icon(self.iconPath)
QtCore.QObject.connect(Receiver.get_receiver(),
QtCore.SIGNAL(u'image_updated'), self.image_updated)
QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'image_updated'), self.image_updated)
def about(self):
about_text = translate('ImagePlugin', '<strong>Image Plugin</strong>'
@ -73,8 +70,7 @@ class ImagePlugin(Plugin):
u'plural': translate('ImagePlugin', 'Images', 'name plural')
}
## Name for MediaDockManager, SettingsManager ##
self.textStrings[StringContent.VisibleName] = {
u'title': translate('ImagePlugin', 'Images', 'container title')
self.textStrings[StringContent.VisibleName] = {u'title': translate('ImagePlugin', 'Images', 'container title')
}
# Middle Header Bar
tooltips = {
@ -85,8 +81,7 @@ class ImagePlugin(Plugin):
u'delete': translate('ImagePlugin', 'Delete the selected image.'),
u'preview': translate('ImagePlugin', 'Preview the selected image.'),
u'live': translate('ImagePlugin', 'Send the selected image live.'),
u'service': translate('ImagePlugin',
'Add the selected image to the service.')
u'service': translate('ImagePlugin', 'Add the selected image to the service.')
}
self.setPluginUiTextStrings(tooltips)
@ -96,7 +91,5 @@ class ImagePlugin(Plugin):
image manager to require updates. Actual update is triggered by the
last part of saving the config.
"""
background = QtGui.QColor(Settings().value(self.settingsSection
+ u'/background color', u'#000000'))
self.liveController.imageManager.updateImagesBorder(
ImageSource.ImagePlugin, background)
background = QtGui.QColor(Settings().value(self.settingsSection + u'/background color', u'#000000'))
self.liveController.imageManager.updateImagesBorder(ImageSource.ImagePlugin, background)

View File

@ -1,5 +1,5 @@
# -*- coding: utf-8 -*-
# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4
# vim: autoindent shiftwidth=4 expandtab textwidth=120 tabstop=4 softtabstop=4
###############################################################################
# OpenLP - Open Source Lyrics Projection #

View File

@ -1,5 +1,5 @@
# -*- coding: utf-8 -*-
# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4
# vim: autoindent shiftwidth=4 expandtab textwidth=120 tabstop=4 softtabstop=4
###############################################################################
# OpenLP - Open Source Lyrics Projection #
@ -60,27 +60,23 @@ class ImageTab(SettingsTab):
self.formLayout.addRow(self.informationLabel)
self.leftLayout.addWidget(self.bgColorGroupBox)
self.leftLayout.addStretch()
self.rightColumn.setSizePolicy(
QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Preferred)
self.rightColumn.setSizePolicy(QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Preferred)
self.rightLayout.addStretch()
# Signals and slots
QtCore.QObject.connect(self.backgroundColorButton,
QtCore.SIGNAL(u'clicked()'), self.onbackgroundColorButtonClicked)
QtCore.QObject.connect(self.backgroundColorButton, QtCore.SIGNAL(u'clicked()'),
self.onbackgroundColorButtonClicked)
def retranslateUi(self):
self.bgColorGroupBox.setTitle(UiStrings().BackgroundColor)
self.backgroundColorLabel.setText(UiStrings().DefaultColor)
self.informationLabel.setText(
translate('ImagesPlugin.ImageTab', 'Visible background for images '
'with aspect ratio different to screen.'))
translate('ImagesPlugin.ImageTab', 'Visible background for images with aspect ratio different to screen.'))
def onbackgroundColorButtonClicked(self):
new_color = QtGui.QColorDialog.getColor(
QtGui.QColor(self.bg_color), self)
new_color = QtGui.QColorDialog.getColor(QtGui.QColor(self.bg_color), self)
if new_color.isValid():
self.bg_color = new_color.name()
self.backgroundColorButton.setStyleSheet(
u'background-color: %s' % self.bg_color)
self.backgroundColorButton.setStyleSheet(u'background-color: %s' % self.bg_color)
def load(self):
settings = Settings()
@ -88,8 +84,7 @@ class ImageTab(SettingsTab):
self.bg_color = settings.value(u'background color', u'#000000')
self.initial_color = self.bg_color
settings.endGroup()
self.backgroundColorButton.setStyleSheet(
u'background-color: %s' % self.bg_color)
self.backgroundColorButton.setStyleSheet(u'background-color: %s' % self.bg_color)
def save(self):
settings = Settings()

View File

@ -1,5 +1,5 @@
# -*- coding: utf-8 -*-
# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4
# vim: autoindent shiftwidth=4 expandtab textwidth=120 tabstop=4 softtabstop=4
###############################################################################
# OpenLP - Open Source Lyrics Projection #
@ -32,12 +32,10 @@ import os
from PyQt4 import QtCore, QtGui
from openlp.core.lib import MediaManagerItem, build_icon, ItemCapabilities, \
SettingsManager, translate, check_item_selected, check_directory_exists, \
Receiver, create_thumb, validate_thumb, ServiceItemContext, Settings
from openlp.core.lib import MediaManagerItem, build_icon, ItemCapabilities, SettingsManager, translate, \
check_item_selected, check_directory_exists, Receiver, create_thumb, validate_thumb, ServiceItemContext, Settings
from openlp.core.lib.ui import UiStrings, critical_error_message_box
from openlp.core.utils import AppLocation, delete_file, locale_compare, \
get_images_filter
from openlp.core.utils import AppLocation, delete_file, locale_compare, get_images_filter
log = logging.getLogger(__name__)
@ -52,8 +50,7 @@ class ImageMediaItem(MediaManagerItem):
MediaManagerItem.__init__(self, parent, plugin, icon)
self.quickPreviewAllowed = True
self.hasSearch = True
QtCore.QObject.connect(Receiver.get_receiver(),
QtCore.SIGNAL(u'live_theme_changed'), self.liveThemeChanged)
QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'live_theme_changed'), self.liveThemeChanged)
# Allow DnD from the desktop
self.listView.activateDnD()
@ -61,8 +58,7 @@ class ImageMediaItem(MediaManagerItem):
self.onNewPrompt = translate('ImagePlugin.MediaItem',
'Select Image(s)')
file_formats = get_images_filter()
self.onNewFileMasks = u'%s;;%s (*.*) (*)' % (file_formats,
UiStrings().AllFiles)
self.onNewFileMasks = u'%s;;%s (*.*) (*)' % (file_formats, UiStrings().AllFiles)
self.replaceAction.setText(UiStrings().ReplaceBG)
self.replaceAction.setToolTip(UiStrings().ReplaceLiveBG)
self.resetAction.setText(UiStrings().ResetBG)
@ -79,12 +75,9 @@ class ImageMediaItem(MediaManagerItem):
log.debug(u'initialise')
self.listView.clear()
self.listView.setIconSize(QtCore.QSize(88, 50))
self.servicePath = os.path.join(
AppLocation.get_section_data_path(self.settingsSection),
u'thumbnails')
self.servicePath = os.path.join(AppLocation.get_section_data_path(self.settingsSection), u'thumbnails')
check_directory_exists(self.servicePath)
self.loadList(SettingsManager.load_list(
self.settingsSection, u'images'), True)
self.loadList(SettingsManager.load_list(self.settingsSection, u'images'), True)
def addListViewToToolBar(self):
MediaManagerItem.addListViewToToolBar(self)
@ -94,8 +87,7 @@ class ImageMediaItem(MediaManagerItem):
self.replaceAction = self.toolbar.addToolbarAction(u'replaceAction',
icon=u':/slides/slide_blank.png', triggers=self.onReplaceClick)
self.resetAction = self.toolbar.addToolbarAction(u'resetAction',
icon=u':/system/system_close.png', visible=False,
triggers=self.onResetClick)
icon=u':/system/system_close.png', visible=False, triggers=self.onResetClick)
def onDeleteClick(self):
"""
@ -103,8 +95,7 @@ class ImageMediaItem(MediaManagerItem):
"""
# Turn off auto preview triggers.
self.listView.blockSignals(True)
if check_item_selected(self.listView, translate('ImagePlugin.MediaItem',
'You must select an image to delete.')):
if check_item_selected(self.listView, translate('ImagePlugin.MediaItem','You must select an image to delete.')):
row_list = [item.row() for item in self.listView.selectedIndexes()]
row_list.sort(reverse=True)
Receiver.send_message(u'cursor_busy')
@ -115,8 +106,7 @@ class ImageMediaItem(MediaManagerItem):
delete_file(os.path.join(self.servicePath, text.text()))
self.listView.takeItem(row)
self.plugin.formParent.incrementProgressBar()
SettingsManager.set_list(self.settingsSection,
u'images', self.getFileList())
SettingsManager.set_list(self.settingsSection, u'images', self.getFileList())
self.plugin.formParent.finishedProgressBar()
Receiver.send_message(u'cursor_normal')
self.listView.blockSignals(False)
@ -127,8 +117,7 @@ class ImageMediaItem(MediaManagerItem):
self.plugin.formParent.displayProgressBar(len(images))
# Sort the images by its filename considering language specific
# characters.
images.sort(cmp=locale_compare,
key=lambda filename: os.path.split(unicode(filename))[1])
images.sort(cmp=locale_compare, key=lambda filename: os.path.split(unicode(filename))[1])
for imageFile in images:
filename = os.path.split(unicode(imageFile))[1]
thumb = os.path.join(self.servicePath, filename)
@ -152,8 +141,7 @@ class ImageMediaItem(MediaManagerItem):
def generateSlideData(self, service_item, item=None, xmlVersion=False,
remote=False, context=ServiceItemContext.Service):
background = QtGui.QColor(Settings().value(self.settingsSection
+ u'/background color', u'#000000'))
background = QtGui.QColor(Settings().value(self.settingsSection + u'/background color', u'#000000'))
if item:
items = [item]
else:
@ -181,18 +169,15 @@ class ImageMediaItem(MediaManagerItem):
if not remote:
critical_error_message_box(
translate('ImagePlugin.MediaItem', 'Missing Image(s)'),
translate('ImagePlugin.MediaItem',
'The following image(s) no longer exist: %s') %
translate('ImagePlugin.MediaItem', 'The following image(s) no longer exist: %s') %
u'\n'.join(missing_items_filenames))
return False
# We have missing as well as existing images. We ask what to do.
elif missing_items and QtGui.QMessageBox.question(self,
translate('ImagePlugin.MediaItem', 'Missing Image(s)'),
translate('ImagePlugin.MediaItem', 'The following '
'image(s) no longer exist: %s\nDo you want to add the other '
'images anyway?') % u'\n'.join(missing_items_filenames),
QtGui.QMessageBox.StandardButtons(QtGui.QMessageBox.No |
QtGui.QMessageBox.Yes)) == QtGui.QMessageBox.No:
translate('ImagePlugin.MediaItem', 'The following image(s) no longer exist: %s\n'
'Do you want to add the other images anyway?') % u'\n'.join(missing_items_filenames),
QtGui.QMessageBox.StandardButtons(QtGui.QMessageBox.No | QtGui.QMessageBox.Yes)) == QtGui.QMessageBox.No:
return False
# Continue with the existing images.
for bitem in items:
@ -219,25 +204,20 @@ class ImageMediaItem(MediaManagerItem):
Called to replace Live backgound with the image selected.
"""
if check_item_selected(self.listView,
translate('ImagePlugin.MediaItem',
'You must select an image to replace the background with.')):
background = QtGui.QColor(Settings().value(
self.settingsSection + u'/background color', u'#000000'))
translate('ImagePlugin.MediaItem', 'You must select an image to replace the background with.')):
background = QtGui.QColor(Settings().value(self.settingsSection + u'/background color', u'#000000'))
item = self.listView.selectedIndexes()[0]
bitem = self.listView.item(item.row())
filename = bitem.data(QtCore.Qt.UserRole)
if os.path.exists(filename):
if self.plugin.liveController.display.directImage(
filename, background):
if self.plugin.liveController.display.directImage(filename, background):
self.resetAction.setVisible(True)
else:
critical_error_message_box(UiStrings().LiveBGError,
translate('ImagePlugin.MediaItem',
'There was no display item to amend.'))
translate('ImagePlugin.MediaItem', 'There was no display item to amend.'))
else:
critical_error_message_box(UiStrings().LiveBGError,
translate('ImagePlugin.MediaItem',
'There was a problem replacing your background, '
translate('ImagePlugin.MediaItem', 'There was a problem replacing your background, '
'the image file "%s" no longer exists.') % filename)
def search(self, string, showError):

View File

@ -1,5 +1,5 @@
# -*- coding: utf-8 -*-
# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4
# vim: autoindent shiftwidth=4 expandtab textwidth=120 tabstop=4 softtabstop=4
###############################################################################
# OpenLP - Open Source Lyrics Projection #

View File

@ -1,5 +1,5 @@
# -*- coding: utf-8 -*-
# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4
# vim: autoindent shiftwidth=4 expandtab textwidth=120 tabstop=4 softtabstop=4
###############################################################################
# OpenLP - Open Source Lyrics Projection #

View File

@ -1,5 +1,5 @@
# -*- coding: utf-8 -*-
# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4
# vim: autoindent shiftwidth=4 expandtab textwidth=120 tabstop=4 softtabstop=4
###############################################################################
# OpenLP - Open Source Lyrics Projection #
@ -46,21 +46,15 @@ class Ui_SongUsageDeleteDialog(object):
self.deleteCalendar = QtGui.QCalendarWidget(songUsageDeleteDialog)
self.deleteCalendar.setFirstDayOfWeek(QtCore.Qt.Sunday)
self.deleteCalendar.setGridVisible(True)
self.deleteCalendar.setVerticalHeaderFormat(
QtGui.QCalendarWidget.NoVerticalHeader)
self.deleteCalendar.setVerticalHeaderFormat(QtGui.QCalendarWidget.NoVerticalHeader)
self.deleteCalendar.setObjectName(u'deleteCalendar')
self.verticalLayout.addWidget(self.deleteCalendar)
self.buttonBox = create_button_box(songUsageDeleteDialog, u'buttonBox',
[u'cancel', u'ok'])
self.buttonBox = create_button_box(songUsageDeleteDialog, u'buttonBox', [u'cancel', u'ok'])
self.verticalLayout.addWidget(self.buttonBox)
self.retranslateUi(songUsageDeleteDialog)
def retranslateUi(self, songUsageDeleteDialog):
songUsageDeleteDialog.setWindowTitle(
translate('SongUsagePlugin.SongUsageDeleteForm',
'Delete Song Usage Data'))
songUsageDeleteDialog.setWindowTitle(translate('SongUsagePlugin.SongUsageDeleteForm', 'Delete Song Usage Data'))
self.deleteLabel.setText(
translate('SongUsagePlugin.SongUsageDeleteForm',
'Select the date up to which the song usage data should be '
'deleted. All data recorded before this date will be '
'permanently deleted.'))
translate('SongUsagePlugin.SongUsageDeleteForm', 'Select the date up to which the song usage data '
'should be deleted. All data recorded before this date will be permanently deleted.'))

View File

@ -1,5 +1,5 @@
# -*- coding: utf-8 -*-
# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4
# vim: autoindent shiftwidth=4 expandtab textwidth=120 tabstop=4 softtabstop=4
###############################################################################
# OpenLP - Open Source Lyrics Projection #
@ -44,31 +44,23 @@ class SongUsageDeleteForm(QtGui.QDialog, Ui_SongUsageDeleteDialog):
self.manager = manager
QtGui.QDialog.__init__(self, parent)
self.setupUi(self)
QtCore.QObject.connect(
self.buttonBox, QtCore.SIGNAL(u'clicked(QAbstractButton*)'),
QtCore.QObject.connect(self.buttonBox, QtCore.SIGNAL(u'clicked(QAbstractButton*)'),
self.onButtonBoxClicked)
def onButtonBoxClicked(self, button):
if self.buttonBox.standardButton(button) == QtGui.QDialogButtonBox.Ok:
ret = QtGui.QMessageBox.question(self,
translate('SongUsagePlugin.SongUsageDeleteForm', 'Delete Selected Song Usage Events?'),
translate('SongUsagePlugin.SongUsageDeleteForm',
'Delete Selected Song Usage Events?'),
translate('SongUsagePlugin.SongUsageDeleteForm',
'Are you sure you want to delete selected Song Usage '
'data?'),
QtGui.QMessageBox.StandardButtons(QtGui.QMessageBox.Yes |
QtGui.QMessageBox.No),
QtGui.QMessageBox.No)
'Are you sure you want to delete selected Song Usage data?'),
QtGui.QMessageBox.StandardButtons(QtGui.QMessageBox.Yes | QtGui.QMessageBox.No), QtGui.QMessageBox.No)
if ret == QtGui.QMessageBox.Yes:
deleteDate = self.deleteCalendar.selectedDate().toPyDate()
self.manager.delete_all_objects(SongUsageItem,
SongUsageItem.usagedate <= deleteDate)
self.manager.delete_all_objects(SongUsageItem, SongUsageItem.usagedate <= deleteDate)
Receiver.send_message(u'openlp_information_message', {
u'title': translate('SongUsagePlugin.SongUsageDeleteForm',
'Deletion Successful'),
u'title': translate('SongUsagePlugin.SongUsageDeleteForm', 'Deletion Successful'),
u'message': translate(
'SongUsagePlugin.SongUsageDeleteForm',
'All requested data has been deleted successfully. ')}
'SongUsagePlugin.SongUsageDeleteForm', 'All requested data has been deleted successfully. ')}
)
self.accept()
else:

View File

@ -1,5 +1,5 @@
# -*- coding: utf-8 -*-
# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4
# vim: autoindent shiftwidth=4 expandtab textwidth=120 tabstop=4 softtabstop=4
###############################################################################
# OpenLP - Open Source Lyrics Projection #
@ -69,30 +69,19 @@ class Ui_SongUsageDetailDialog(object):
self.fileLineEdit.setReadOnly(True)
self.fileHorizontalLayout.addWidget(self.fileLineEdit)
self.saveFilePushButton = QtGui.QPushButton(self.fileGroupBox)
self.saveFilePushButton.setMaximumWidth(
self.saveFilePushButton.size().height())
self.saveFilePushButton.setIcon(
build_icon(u':/general/general_open.png'))
self.saveFilePushButton.setMaximumWidth(self.saveFilePushButton.size().height())
self.saveFilePushButton.setIcon(build_icon(u':/general/general_open.png'))
self.saveFilePushButton.setObjectName(u'saveFilePushButton')
self.fileHorizontalLayout.addWidget(self.saveFilePushButton)
self.verticalLayout.addWidget(self.fileGroupBox)
self.buttonBox = create_button_box(songUsageDetailDialog, u'buttonBox',
[u'cancel', u'ok'])
self.buttonBox = create_button_box(songUsageDetailDialog, u'buttonBox', [u'cancel', u'ok'])
self.verticalLayout.addWidget(self.buttonBox)
self.retranslateUi(songUsageDetailDialog)
QtCore.QObject.connect(self.saveFilePushButton,
QtCore.SIGNAL(u'clicked()'),
QtCore.QObject.connect(self.saveFilePushButton, QtCore.SIGNAL(u'clicked()'),
songUsageDetailDialog.defineOutputLocation)
def retranslateUi(self, songUsageDetailDialog):
songUsageDetailDialog.setWindowTitle(
translate('SongUsagePlugin.SongUsageDetailForm',
'Song Usage Extraction'))
self.dateRangeGroupBox.setTitle(
translate('SongUsagePlugin.SongUsageDetailForm',
'Select Date Range'))
self.toLabel.setText(
translate('SongUsagePlugin.SongUsageDetailForm', 'to'))
self.fileGroupBox.setTitle(
translate('SongUsagePlugin.SongUsageDetailForm',
'Report Location'))
songUsageDetailDialog.setWindowTitle(translate('SongUsagePlugin.SongUsageDetailForm', 'Song Usage Extraction'))
self.dateRangeGroupBox.setTitle(translate('SongUsagePlugin.SongUsageDetailForm', 'Select Date Range'))
self.toLabel.setText(translate('SongUsagePlugin.SongUsageDetailForm', 'to'))
self.fileGroupBox.setTitle(translate('SongUsagePlugin.SongUsageDetailForm', 'Report Location'))

View File

@ -1,5 +1,5 @@
# -*- coding: utf-8 -*-
# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4
# vim: autoindent shiftwidth=4 expandtab textwidth=120 tabstop=4 softtabstop=4
###############################################################################
# OpenLP - Open Source Lyrics Projection #
@ -61,22 +61,18 @@ class SongUsageDetailForm(QtGui.QDialog, Ui_SongUsageDetailDialog):
year = QtCore.QDate().currentDate().year()
if QtCore.QDate().currentDate().month() < 9:
year -= 1
toDate = Settings().value(self.plugin.settingsSection +
u'/to date', QtCore.QDate(year, 8, 31))
fromDate = Settings().value(self.plugin.settingsSection +
u'/from date', QtCore.QDate(year - 1, 9, 1))
toDate = Settings().value(self.plugin.settingsSection + u'/to date', QtCore.QDate(year, 8, 31))
fromDate = Settings().value(self.plugin.settingsSection + u'/from date', QtCore.QDate(year - 1, 9, 1))
self.fromDate.setSelectedDate(fromDate)
self.toDate.setSelectedDate(toDate)
self.fileLineEdit.setText(
SettingsManager.get_last_dir(self.plugin.settingsSection, 1))
self.fileLineEdit.setText(SettingsManager.get_last_dir(self.plugin.settingsSection, 1))
def defineOutputLocation(self):
"""
Triggered when the Directory selection button is clicked
"""
path = QtGui.QFileDialog.getExistingDirectory(self,
translate('SongUsagePlugin.SongUsageDetailForm',
'Output File Location'),
translate('SongUsagePlugin.SongUsageDetailForm', 'Output File Location'),
SettingsManager.get_last_dir(self.plugin.settingsSection, 1))
path = unicode(path)
if path:
@ -91,20 +87,16 @@ class SongUsageDetailForm(QtGui.QDialog, Ui_SongUsageDetailDialog):
path = self.fileLineEdit.text()
if not path:
Receiver.send_message(u'openlp_error_message', {
u'title': translate('SongUsagePlugin.SongUsageDetailForm',
'Output Path Not Selected'),
u'title': translate('SongUsagePlugin.SongUsageDetailForm', 'Output Path Not Selected'),
u'message': translate(
'SongUsagePlugin.SongUsageDetailForm', 'You have not set a '
'valid output location for your song usage report. Please '
'select an existing path on your computer.')})
'SongUsagePlugin.SongUsageDetailForm', 'You have not set a valid output location for your song usage '
'report. Please select an existing path on your computer.')})
return
check_directory_exists(path)
filename = translate('SongUsagePlugin.SongUsageDetailForm',
'usage_detail_%s_%s.txt') % (
filename = translate('SongUsagePlugin.SongUsageDetailForm', 'usage_detail_%s_%s.txt') % (
self.fromDate.selectedDate().toString(u'ddMMyyyy'),
self.toDate.selectedDate().toString(u'ddMMyyyy'))
Settings().setValue(u'songusage/from date',
self.fromDate.selectedDate())
Settings().setValue(u'songusage/from date', self.fromDate.selectedDate())
Settings().setValue(u'songusage/to date', self.toDate.selectedDate())
usage = self.plugin.manager.get_all_objects(
SongUsageItem, and_(
@ -119,14 +111,11 @@ class SongUsageDetailForm(QtGui.QDialog, Ui_SongUsageDetailDialog):
record = u'\"%s\",\"%s\",\"%s\",\"%s\",\"%s\",\"%s\",' \
u'\"%s\",\"%s\"\n' % (instance.usagedate,
instance.usagetime, instance.title, instance.copyright,
instance.ccl_number, instance.authors,
instance.plugin_name, instance.source)
instance.ccl_number, instance.authors, instance.plugin_name, instance.source)
fileHandle.write(record.encode(u'utf-8'))
Receiver.send_message(u'openlp_information_message', {
u'title': translate('SongUsagePlugin.SongUsageDetailForm',
'Report Creation'),
u'message': translate(
'SongUsagePlugin.SongUsageDetailForm', 'Report \n%s \n'
u'title': translate('SongUsagePlugin.SongUsageDetailForm', 'Report Creation'),
u'message': translate('SongUsagePlugin.SongUsageDetailForm', 'Report \n%s \n'
'has been successfully created. ') % outname})
except IOError:
log.exception(u'Failed to write out song usage records')

View File

@ -1,5 +1,5 @@
# -*- coding: utf-8 -*-
# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4
# vim: autoindent shiftwidth=4 expandtab textwidth=120 tabstop=4 softtabstop=4
###############################################################################
# OpenLP - Open Source Lyrics Projection #

View File

@ -1,5 +1,5 @@
# -*- coding: utf-8 -*-
# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4
# vim: autoindent shiftwidth=4 expandtab textwidth=120 tabstop=4 softtabstop=4
###############################################################################
# OpenLP - Open Source Lyrics Projection #

View File

@ -1,5 +1,5 @@
# -*- coding: utf-8 -*-
# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4
# vim: autoindent shiftwidth=4 expandtab textwidth=120 tabstop=4 softtabstop=4
###############################################################################
# OpenLP - Open Source Lyrics Projection #

View File

@ -1,5 +1,5 @@
# -*- coding: utf-8 -*-
# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4
# vim: autoindent shiftwidth=4 expandtab textwidth=120 tabstop=4 softtabstop=4
###############################################################################
# OpenLP - Open Source Lyrics Projection #
@ -32,13 +32,11 @@ from datetime import datetime
from PyQt4 import QtCore, QtGui
from openlp.core.lib import build_icon, Plugin, Receiver, Settings, \
StringContent, translate
from openlp.core.lib import build_icon, Plugin, Receiver, Settings, StringContent, translate
from openlp.core.lib.db import Manager
from openlp.core.lib.ui import create_action
from openlp.core.utils.actions import ActionList
from openlp.plugins.songusage.forms import SongUsageDetailForm, \
SongUsageDeleteForm
from openlp.plugins.songusage.forms import SongUsageDetailForm, SongUsageDeleteForm
from openlp.plugins.songusage.lib import upgrade
from openlp.plugins.songusage.lib.db import init_schema, SongUsageItem
@ -72,73 +70,56 @@ class SongUsagePlugin(Plugin):
self.toolsMenu = tools_menu
self.songUsageMenu = QtGui.QMenu(tools_menu)
self.songUsageMenu.setObjectName(u'songUsageMenu')
self.songUsageMenu.setTitle(translate(
'SongUsagePlugin', '&Song Usage Tracking'))
self.songUsageMenu.setTitle(translate('SongUsagePlugin', '&Song Usage Tracking'))
# SongUsage Delete
self.songUsageDelete = create_action(tools_menu, u'songUsageDelete',
text=translate('SongUsagePlugin', '&Delete Tracking Data'),
statustip=translate('SongUsagePlugin',
'Delete song usage data up to a specified date.'),
statustip=translate('SongUsagePlugin', 'Delete song usage data up to a specified date.'),
triggers=self.onSongUsageDelete)
# SongUsage Report
self.songUsageReport = create_action(tools_menu, u'songUsageReport',
text=translate('SongUsagePlugin', '&Extract Tracking Data'),
statustip=translate('SongUsagePlugin',
'Generate a report on song usage.'),
statustip=translate('SongUsagePlugin', 'Generate a report on song usage.'),
triggers=self.onSongUsageReport)
# SongUsage activation
self.songUsageStatus = create_action(tools_menu, u'songUsageStatus',
text=translate('SongUsagePlugin', 'Toggle Tracking'),
statustip=translate('SongUsagePlugin',
'Toggle the tracking of song usage.'), checked=False,
shortcuts=[QtCore.Qt.Key_F4],
triggers=self.toggleSongUsageState)
statustip=translate('SongUsagePlugin', 'Toggle the tracking of song usage.'), checked=False,
shortcuts=[QtCore.Qt.Key_F4], triggers=self.toggleSongUsageState)
# Add Menus together
self.toolsMenu.addAction(self.songUsageMenu.menuAction())
self.songUsageMenu.addAction(self.songUsageStatus)
self.songUsageMenu.addSeparator()
self.songUsageMenu.addAction(self.songUsageReport)
self.songUsageMenu.addAction(self.songUsageDelete)
self.songUsageActiveButton = QtGui.QToolButton(
self.formParent.statusBar)
self.songUsageActiveButton = QtGui.QToolButton(self.formParent.statusBar)
self.songUsageActiveButton.setCheckable(True)
self.songUsageActiveButton.setAutoRaise(True)
self.songUsageActiveButton.setStatusTip(translate('SongUsagePlugin',
'Toggle the tracking of song usage.'))
self.songUsageActiveButton.setStatusTip(translate('SongUsagePlugin', 'Toggle the tracking of song usage.'))
self.songUsageActiveButton.setObjectName(u'songUsageActiveButton')
self.formParent.statusBar.insertPermanentWidget(1,
self.songUsageActiveButton)
self.formParent.statusBar.insertPermanentWidget(1, self.songUsageActiveButton)
self.songUsageActiveButton.hide()
# Signals and slots
QtCore.QObject.connect(self.songUsageStatus,
QtCore.SIGNAL(u'visibilityChanged(bool)'),
QtCore.QObject.connect(self.songUsageStatus, QtCore.SIGNAL(u'visibilityChanged(bool)'),
self.songUsageStatus.setChecked)
QtCore.QObject.connect(self.songUsageActiveButton,
QtCore.SIGNAL(u'toggled(bool)'), self.toggleSongUsageState)
QtCore.QObject.connect(self.songUsageActiveButton, QtCore.SIGNAL(u'toggled(bool)'), self.toggleSongUsageState)
self.songUsageMenu.menuAction().setVisible(False)
def initialise(self):
log.info(u'SongUsage Initialising')
Plugin.initialise(self)
QtCore.QObject.connect(Receiver.get_receiver(),
QtCore.SIGNAL(u'slidecontroller_live_started'),
QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'slidecontroller_live_started'),
self.displaySongUsage)
QtCore.QObject.connect(Receiver.get_receiver(),
QtCore.SIGNAL(u'print_service_started'),
QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'print_service_started'),
self.printSongUsage)
self.songUsageActive = Settings().value(
self.settingsSection + u'/active', False)
self.songUsageActive = Settings().value(self.settingsSection + u'/active', False)
# Set the button and checkbox state
self.setButtonState()
action_list = ActionList.get_instance()
action_list.add_action(self.songUsageStatus,
translate('SongUsagePlugin', 'Song Usage'))
action_list.add_action(self.songUsageDelete,
translate('SongUsagePlugin', 'Song Usage'))
action_list.add_action(self.songUsageReport,
translate('SongUsagePlugin', 'Song Usage'))
self.songUsageDeleteForm = SongUsageDeleteForm(self.manager,
self.formParent)
action_list.add_action(self.songUsageStatus, translate('SongUsagePlugin', 'Song Usage'))
action_list.add_action(self.songUsageDelete, translate('SongUsagePlugin', 'Song Usage'))
action_list.add_action(self.songUsageReport, translate('SongUsagePlugin', 'Song Usage'))
self.songUsageDeleteForm = SongUsageDeleteForm(self.manager, self.formParent)
self.songUsageDetailForm = SongUsageDetailForm(self, self.formParent)
self.songUsageMenu.menuAction().setVisible(True)
self.songUsageActiveButton.show()
@ -152,12 +133,9 @@ class SongUsagePlugin(Plugin):
Plugin.finalise(self)
self.songUsageMenu.menuAction().setVisible(False)
action_list = ActionList.get_instance()
action_list.remove_action(self.songUsageStatus,
translate('SongUsagePlugin', 'Song Usage'))
action_list.remove_action(self.songUsageDelete,
translate('SongUsagePlugin', 'Song Usage'))
action_list.remove_action(self.songUsageReport,
translate('SongUsagePlugin', 'Song Usage'))
action_list.remove_action(self.songUsageStatus, translate('SongUsagePlugin', 'Song Usage'))
action_list.remove_action(self.songUsageDelete, translate('SongUsagePlugin', 'Song Usage'))
action_list.remove_action(self.songUsageReport, translate('SongUsagePlugin', 'Song Usage'))
self.songUsageActiveButton.hide()
# stop any events being processed
self.songUsageActive = False
@ -168,8 +146,7 @@ class SongUsagePlugin(Plugin):
the UI when necessary,
"""
self.songUsageActive = not self.songUsageActive
Settings().setValue(self.settingsSection + u'/active',
self.songUsageActive)
Settings().setValue(self.settingsSection + u'/active', self.songUsageActive)
self.setButtonState()
def setButtonState(self):
@ -183,14 +160,12 @@ class SongUsagePlugin(Plugin):
self.songUsageActiveButton.setIcon(self.activeIcon)
self.songUsageStatus.setChecked(True)
self.songUsageActiveButton.setChecked(True)
self.songUsageActiveButton.setToolTip(translate('SongUsagePlugin',
'Song usage tracking is active.'))
self.songUsageActiveButton.setToolTip(translate('SongUsagePlugin', 'Song usage tracking is active.'))
else:
self.songUsageActiveButton.setIcon(self.inactiveIcon)
self.songUsageStatus.setChecked(False)
self.songUsageActiveButton.setChecked(False)
self.songUsageActiveButton.setToolTip(translate('SongUsagePlugin',
'Song usage tracking is inactive.'))
self.songUsageActiveButton.setToolTip(translate('SongUsagePlugin', 'Song usage tracking is inactive.'))
self.songUsageActiveButton.blockSignals(False)
self.songUsageStatus.blockSignals(False)
@ -230,8 +205,7 @@ class SongUsagePlugin(Plugin):
def about(self):
about_text = translate('SongUsagePlugin', '<strong>SongUsage Plugin'
'</strong><br />This plugin tracks the usage of songs in '
'services.')
'</strong><br />This plugin tracks the usage of songs in services.')
return about_text
def setPluginTextStrings(self):
@ -240,13 +214,10 @@ class SongUsagePlugin(Plugin):
"""
## Name PluginList ##
self.textStrings[StringContent.Name] = {
u'singular': translate('SongUsagePlugin', 'SongUsage',
'name singular'),
u'plural': translate('SongUsagePlugin', 'SongUsage',
'name plural')
u'singular': translate('SongUsagePlugin', 'SongUsage', 'name singular'),
u'plural': translate('SongUsagePlugin', 'SongUsage', 'name plural')
}
## Name for MediaDockManager, SettingsManager ##
self.textStrings[StringContent.VisibleName] = {
u'title': translate('SongUsagePlugin', 'SongUsage',
'container title')
u'title': translate('SongUsagePlugin', 'SongUsage', 'container title')
}