forked from openlp/openlp
Head
This commit is contained in:
commit
1f436534d3
|
@ -141,10 +141,21 @@ class Settings(QtCore.QSettings):
|
|||
if defaultValue is None and not super(Settings, self).contains(key):
|
||||
return None
|
||||
setting = super(Settings, self).value(key, defaultValue)
|
||||
# An empty list saved to the settings results in a None type being
|
||||
# returned.
|
||||
# On OS X (and probably on other platforms too) empty value from QSettings
|
||||
# is represented as type PyQt4.QtCore.QPyNullVariant. This type has to be
|
||||
# converted to proper 'None' Python type.
|
||||
if isinstance(setting, QtCore.QPyNullVariant) and setting.isNull():
|
||||
setting = None
|
||||
# Handle 'None' type (empty value) properly.
|
||||
if setting is None:
|
||||
return []
|
||||
# An empty string saved to the settings results in a None type being
|
||||
# returned. Convert it to empty unicode string.
|
||||
if isinstance(defaultValue, unicode):
|
||||
return u''
|
||||
# An empty list saved to the settings results in a None type being
|
||||
# returned.
|
||||
else:
|
||||
return []
|
||||
# Convert the setting to the correct type.
|
||||
if isinstance(defaultValue, bool):
|
||||
if isinstance(setting, bool):
|
||||
|
|
|
@ -468,6 +468,7 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow):
|
|||
self.serviceManagerSettingsSection = u'servicemanager'
|
||||
self.songsSettingsSection = u'songs'
|
||||
self.themesSettingsSection = u'themes'
|
||||
self.playersSettingsSection = u'players'
|
||||
self.displayTagsSection = u'displayTags'
|
||||
self.headerSection = u'SettingsImport'
|
||||
self.serviceNotSaved = False
|
||||
|
@ -824,6 +825,7 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow):
|
|||
setting_sections.extend([self.shortcutsSettingsSection])
|
||||
setting_sections.extend([self.serviceManagerSettingsSection])
|
||||
setting_sections.extend([self.themesSettingsSection])
|
||||
setting_sections.extend([self.playersSettingsSection])
|
||||
setting_sections.extend([self.displayTagsSection])
|
||||
setting_sections.extend([self.headerSection])
|
||||
setting_sections.extend([u'crashreport'])
|
||||
|
@ -832,6 +834,15 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow):
|
|||
setting_sections.extend([plugin.name])
|
||||
settings = Settings()
|
||||
import_settings = Settings(import_file_name, Settings.IniFormat)
|
||||
# Lets do a basic sanity check. If it contains this string we can
|
||||
# assume it was created by OpenLP and so we'll load what we can
|
||||
# from it, and just silently ignore anything we don't recognise
|
||||
if import_settings.value(u'SettingsImport/type', u'') != u'OpenLP_settings_export':
|
||||
QtGui.QMessageBox.critical(self, translate('OpenLP.MainWindow', 'Import settings'),
|
||||
translate('OpenLP.MainWindow', 'The file you have selected does not appear to be a valid OpenLP '
|
||||
'settings file.\n\nProcessing has terminated and no changes have been made.'),
|
||||
QtGui.QMessageBox.StandardButtons(QtGui.QMessageBox.Ok))
|
||||
return
|
||||
import_keys = import_settings.allKeys()
|
||||
for section_key in import_keys:
|
||||
# We need to handle the really bad files.
|
||||
|
@ -841,17 +852,12 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow):
|
|||
section = u'unknown'
|
||||
key = u''
|
||||
# Switch General back to lowercase.
|
||||
if section == u'General':
|
||||
if section == u'General' or section == u'%General':
|
||||
section = u'general'
|
||||
section_key = section + "/" + key
|
||||
# Make sure it's a valid section for us.
|
||||
if not section in setting_sections:
|
||||
QtGui.QMessageBox.critical(self, translate('OpenLP.MainWindow', 'Import settings'),
|
||||
translate('OpenLP.MainWindow', 'The file you selected does appear to be a valid OpenLP '
|
||||
'settings file.\n\nSection [%s] is not valid \n\n'
|
||||
'Processing has terminated and no changed have been made.').replace('%s', section),
|
||||
QtGui.QMessageBox.StandardButtons(QtGui.QMessageBox.Ok))
|
||||
return
|
||||
continue
|
||||
# We have a good file, import it.
|
||||
for section_key in import_keys:
|
||||
value = import_settings.value(section_key, None)
|
||||
|
|
|
@ -40,7 +40,7 @@ log = logging.getLogger(__name__)
|
|||
from PyQt4 import QtCore, QtGui
|
||||
|
||||
from openlp.core.lib import OpenLPToolbar, ServiceItem, Receiver, build_icon, ItemCapabilities, SettingsManager, \
|
||||
translate, str_to_bool, check_directory_exists, Settings
|
||||
translate, str_to_bool, check_directory_exists, Settings, PluginStatus
|
||||
from openlp.core.lib.theme import ThemeLevel
|
||||
from openlp.core.lib.ui import UiStrings, critical_error_message_box, create_widget_action, find_and_set_in_combo_box
|
||||
from openlp.core.ui import ServiceNoteForm, ServiceItemEditForm, StartTimeForm
|
||||
|
@ -252,6 +252,9 @@ class ServiceManager(QtGui.QWidget):
|
|||
icon=u':/media/auto-start_active.png', triggers=self.onAutoStart)
|
||||
# Add already existing delete action to the menu.
|
||||
self.menu.addAction(self.serviceManagerList.delete)
|
||||
self.create_custom_action = create_widget_action(self.menu,
|
||||
text=translate('OpenLP.ServiceManager', 'Create New &Custom Slide'),
|
||||
icon=u':/general/general_edit.png', triggers=self.create_custom)
|
||||
self.menu.addSeparator()
|
||||
self.previewAction = create_widget_action(self.menu, text=translate('OpenLP.ServiceManager', 'Show &Preview'),
|
||||
icon=u':/general/general_preview.png', triggers=self.makePreview)
|
||||
|
@ -751,6 +754,7 @@ class ServiceManager(QtGui.QWidget):
|
|||
pos = item.data(0, QtCore.Qt.UserRole)
|
||||
serviceItem = self.serviceItems[pos - 1]
|
||||
self.editAction.setVisible(False)
|
||||
self.create_custom_action.setVisible(False)
|
||||
self.maintainAction.setVisible(False)
|
||||
self.notesAction.setVisible(False)
|
||||
self.timeAction.setVisible(False)
|
||||
|
@ -770,6 +774,11 @@ class ServiceManager(QtGui.QWidget):
|
|||
if serviceItem[u'service_item'].will_auto_start:
|
||||
self.autoStartAction.setText(translate('OpenLP.ServiceManager', '&Auto Start - active'))
|
||||
self.autoStartAction.setIcon(self.active)
|
||||
if serviceItem[u'service_item'].is_text():
|
||||
for plugin in self.mainwindow.pluginManager.plugins:
|
||||
if plugin.name == u'custom' and plugin.status == PluginStatus.Active:
|
||||
self.create_custom_action.setVisible(True)
|
||||
break
|
||||
self.themeMenu.menuAction().setVisible(False)
|
||||
# Set up the theme menu.
|
||||
if serviceItem[u'service_item'].is_text() and self.mainwindow.renderer.theme_level == ThemeLevel.Song:
|
||||
|
@ -1306,6 +1315,13 @@ class ServiceManager(QtGui.QWidget):
|
|||
Receiver.send_message(u'%s_edit' % self.serviceItems[item][u'service_item'].name.lower(),
|
||||
u'L:%s' % self.serviceItems[item][u'service_item'].edit_id)
|
||||
|
||||
def create_custom(self):
|
||||
"""
|
||||
Saves the current text item as a custom slide
|
||||
"""
|
||||
item = self.findServiceItem()[0]
|
||||
Receiver.send_message(u'custom_create_from_service', self.serviceItems[item][u'service_item'])
|
||||
|
||||
def findServiceItem(self):
|
||||
"""
|
||||
Finds the first selected ServiceItem in the list and returns the
|
||||
|
|
|
@ -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 #
|
||||
|
|
|
@ -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 #
|
||||
|
|
|
@ -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):
|
||||
|
@ -187,8 +182,7 @@ class AlertsPlugin(Plugin):
|
|||
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 +196,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):
|
||||
|
|
|
@ -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 #
|
||||
|
|
|
@ -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'))
|
||||
|
|
|
@ -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,
|
||||
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:
|
||||
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.\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,
|
||||
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:
|
||||
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 \'<>\'.\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())
|
||||
|
|
|
@ -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 #
|
||||
|
|
|
@ -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()
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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 #
|
||||
|
|
|
@ -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,32 +425,27 @@ 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. '
|
||||
'Bibles in the Public Domain need to be marked as such.'))
|
||||
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 '
|
||||
'a different Bible or first delete the existing one.'))
|
||||
translate('BiblesPlugin.ImportWizardForm', 'This Bible already exists. Please import '
|
||||
'a different Bible or first delete the existing one.'))
|
||||
self.versionNameEdit.setFocus()
|
||||
return False
|
||||
return True
|
||||
|
@ -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)
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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'))
|
||||
|
|
|
@ -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']
|
||||
|
|
|
@ -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']]))
|
||||
|
|
|
@ -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".') %
|
||||
self.book_names[abbreviation])
|
||||
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.')
|
||||
% new_book_name)
|
||||
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
|
||||
|
|
|
@ -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:'))
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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()
|
||||
|
|
|
@ -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:
|
||||
|
|
|
@ -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]),
|
||||
|
|
|
@ -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(' |<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')
|
||||
|
|
|
@ -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,11 +307,10 @@ 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.')
|
||||
'There are no Bibles currently installed. Please use the '
|
||||
'Import Wizard to install one or more Bibles.')
|
||||
})
|
||||
return None
|
||||
language_selection = self.get_language_selection(bible)
|
||||
|
@ -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,11 +383,10 @@ 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.')
|
||||
'There are no Bibles currently installed. Please use the '
|
||||
'Import Wizard to install one or more Bibles.')
|
||||
})
|
||||
return None
|
||||
# Check if the bible or second_bible is a web bible.
|
||||
|
@ -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.')
|
||||
|
|
|
@ -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?'),
|
||||
'You cannot combine single and dual Bible verse search results. '
|
||||
'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)
|
||||
|
@ -352,15 +306,13 @@ class BibleMediaItem(MediaManagerItem):
|
|||
self.loadBibles()
|
||||
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', '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...'))
|
||||
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 %s\n\n%s %s' % (verse_text, text,
|
||||
verse_text, second_text)
|
||||
bible_text = u'%s %s\n\n%s %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]]
|
||||
|
|
|
@ -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,11 @@ 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, '
|
||||
'therefore not an openlp.org 1.x database either' % self.filename)
|
||||
'therefore not an openlp.org 1.x database either' % self.filename)
|
||||
# Please add an user error here!
|
||||
# This file is not an openlp.org 1.x bible database.
|
||||
return False
|
||||
|
@ -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.
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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 #
|
||||
|
|
|
@ -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()
|
||||
|
|
|
@ -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 #
|
||||
|
|
|
@ -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 #
|
||||
|
@ -48,19 +48,16 @@ class CustomPlugin(Plugin):
|
|||
log.info(u'Custom Plugin loaded')
|
||||
|
||||
def __init__(self, plugin_helpers):
|
||||
Plugin.__init__(self, u'custom', plugin_helpers,
|
||||
CustomMediaItem, CustomTab)
|
||||
Plugin.__init__(self, u'custom', plugin_helpers, CustomMediaItem, CustomTab)
|
||||
self.weight = -5
|
||||
self.manager = Manager(u'custom', init_schema)
|
||||
self.iconPath = u':/plugins/plugin_custom.png'
|
||||
self.icon = build_icon(self.iconPath)
|
||||
|
||||
def about(self):
|
||||
about_text = translate('CustomPlugin', '<strong>Custom Slide Plugin'
|
||||
'</strong><br />The custom slide plugin provides the ability to '
|
||||
'set up custom text slides that can be displayed on the screen '
|
||||
'the same way songs are. This plugin provides greater freedom '
|
||||
'over the songs plugin.')
|
||||
about_text = translate('CustomPlugin', '<strong>Custom Slide Plugin </strong><br />The custom slide plugin '
|
||||
'provides the ability to set up custom text slides that can be displayed on the screen '
|
||||
'the same way songs are. This plugin provides greater freedom over the songs plugin.')
|
||||
return about_text
|
||||
|
||||
def usesTheme(self, theme):
|
||||
|
@ -69,8 +66,7 @@ class CustomPlugin(Plugin):
|
|||
|
||||
Returns True if the theme is being used, otherwise returns False.
|
||||
"""
|
||||
if self.manager.get_all_objects(CustomSlide,
|
||||
CustomSlide.theme_name == theme):
|
||||
if self.manager.get_all_objects(CustomSlide, CustomSlide.theme_name == theme):
|
||||
return True
|
||||
return False
|
||||
|
||||
|
@ -85,8 +81,7 @@ class CustomPlugin(Plugin):
|
|||
``newTheme``
|
||||
The new name the plugin should now use.
|
||||
"""
|
||||
customsUsingTheme = self.manager.get_all_objects(CustomSlide,
|
||||
CustomSlide.theme_name == oldTheme)
|
||||
customsUsingTheme = self.manager.get_all_objects(CustomSlide, CustomSlide.theme_name == oldTheme)
|
||||
for custom in customsUsingTheme:
|
||||
custom.theme_name = newTheme
|
||||
self.manager.save_object(custom)
|
||||
|
@ -97,31 +92,23 @@ class CustomPlugin(Plugin):
|
|||
"""
|
||||
## Name PluginList ##
|
||||
self.textStrings[StringContent.Name] = {
|
||||
u'singular': translate('CustomPlugin', 'Custom Slide',
|
||||
'name singular'),
|
||||
u'plural': translate('CustomPlugin', 'Custom Slides',
|
||||
'name plural')
|
||||
u'singular': translate('CustomPlugin', 'Custom Slide', 'name singular'),
|
||||
u'plural': translate('CustomPlugin', 'Custom Slides', 'name plural')
|
||||
}
|
||||
## Name for MediaDockManager, SettingsManager ##
|
||||
self.textStrings[StringContent.VisibleName] = {
|
||||
u'title': translate('CustomPlugin', 'Custom Slides',
|
||||
'container title')
|
||||
u'title': translate('CustomPlugin', 'Custom Slides', 'container title')
|
||||
}
|
||||
# Middle Header Bar
|
||||
tooltips = {
|
||||
u'load': translate('CustomPlugin', 'Load a new custom slide.'),
|
||||
u'import': translate('CustomPlugin', 'Import a custom slide.'),
|
||||
u'new': translate('CustomPlugin', 'Add a new custom slide.'),
|
||||
u'edit': translate('CustomPlugin',
|
||||
'Edit the selected custom slide.'),
|
||||
u'delete': translate('CustomPlugin',
|
||||
'Delete the selected custom slide.'),
|
||||
u'preview': translate('CustomPlugin',
|
||||
'Preview the selected custom slide.'),
|
||||
u'live': translate('CustomPlugin',
|
||||
'Send the selected custom slide live.'),
|
||||
u'service': translate('CustomPlugin',
|
||||
'Add the selected custom slide to the service.')
|
||||
u'edit': translate('CustomPlugin', 'Edit the selected custom slide.'),
|
||||
u'delete': translate('CustomPlugin', 'Delete the selected custom slide.'),
|
||||
u'preview': translate('CustomPlugin', 'Preview the selected custom slide.'),
|
||||
u'live': translate('CustomPlugin', 'Send the selected custom slide live.'),
|
||||
u'service': translate('CustomPlugin', 'Add the selected custom slide to the service.')
|
||||
}
|
||||
self.setPluginUiTextStrings(tooltips)
|
||||
|
||||
|
|
|
@ -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 #
|
||||
|
|
|
@ -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,8 +36,7 @@ class Ui_CustomEditDialog(object):
|
|||
def setupUi(self, customEditDialog):
|
||||
customEditDialog.setObjectName(u'customEditDialog')
|
||||
customEditDialog.resize(450, 350)
|
||||
customEditDialog.setWindowIcon(
|
||||
build_icon(u':/icon/openlp-logo-16x16.png'))
|
||||
customEditDialog.setWindowIcon(build_icon(u':/icon/openlp-logo-16x16.png'))
|
||||
self.dialogLayout = QtGui.QVBoxLayout(customEditDialog)
|
||||
self.dialogLayout.setObjectName(u'dialogLayout')
|
||||
self.titleLayout = QtGui.QHBoxLayout()
|
||||
|
@ -68,15 +67,14 @@ class Ui_CustomEditDialog(object):
|
|||
self.editAllButton = QtGui.QPushButton(customEditDialog)
|
||||
self.editAllButton.setObjectName(u'editAllButton')
|
||||
self.buttonLayout.addWidget(self.editAllButton)
|
||||
self.deleteButton = create_button(customEditDialog, u'deleteButton',
|
||||
role=u'delete', click=customEditDialog.onDeleteButtonClicked)
|
||||
self.deleteButton = create_button(customEditDialog, u'deleteButton', role=u'delete',
|
||||
click=customEditDialog.onDeleteButtonClicked)
|
||||
self.deleteButton.setEnabled(False)
|
||||
self.buttonLayout.addWidget(self.deleteButton)
|
||||
self.buttonLayout.addStretch()
|
||||
self.upButton = create_button(customEditDialog, u'upButton', role=u'up',
|
||||
enabled=False, click=customEditDialog.onUpButtonClicked)
|
||||
self.downButton = create_button(customEditDialog, u'downButton',
|
||||
role=u'down', enabled=False,
|
||||
self.upButton = create_button(customEditDialog, u'upButton', role=u'up', enabled=False,
|
||||
click=customEditDialog.onUpButtonClicked)
|
||||
self.downButton = create_button(customEditDialog, u'downButton', role=u'down', enabled=False,
|
||||
click=customEditDialog.onDownButtonClicked)
|
||||
self.buttonLayout.addWidget(self.upButton)
|
||||
self.buttonLayout.addWidget(self.downButton)
|
||||
|
@ -99,31 +97,19 @@ class Ui_CustomEditDialog(object):
|
|||
self.bottomFormLayout.addRow(self.creditLabel, self.creditEdit)
|
||||
self.dialogLayout.addLayout(self.bottomFormLayout)
|
||||
self.previewButton = QtGui.QPushButton()
|
||||
self.buttonBox = create_button_box(customEditDialog, u'buttonBox',
|
||||
[u'cancel', u'save'], [self.previewButton])
|
||||
self.buttonBox = create_button_box(customEditDialog, u'buttonBox', [u'cancel', u'save'], [self.previewButton])
|
||||
self.dialogLayout.addWidget(self.buttonBox)
|
||||
self.retranslateUi(customEditDialog)
|
||||
|
||||
def retranslateUi(self, customEditDialog):
|
||||
customEditDialog.setWindowTitle(
|
||||
translate('CustomPlugin.EditCustomForm', 'Edit Custom Slides'))
|
||||
self.titleLabel.setText(
|
||||
translate('CustomPlugin.EditCustomForm', '&Title:'))
|
||||
customEditDialog.setWindowTitle(translate('CustomPlugin.EditCustomForm', 'Edit Custom Slides'))
|
||||
self.titleLabel.setText(translate('CustomPlugin.EditCustomForm', '&Title:'))
|
||||
self.addButton.setText(UiStrings().Add)
|
||||
self.addButton.setToolTip(
|
||||
translate('CustomPlugin.EditCustomForm', 'Add a new slide at '
|
||||
'bottom.'))
|
||||
self.addButton.setToolTip(translate('CustomPlugin.EditCustomForm', 'Add a new slide at bottom.'))
|
||||
self.editButton.setText(UiStrings().Edit)
|
||||
self.editButton.setToolTip(
|
||||
translate('CustomPlugin.EditCustomForm', 'Edit the selected '
|
||||
'slide.'))
|
||||
self.editAllButton.setText(
|
||||
translate('CustomPlugin.EditCustomForm', 'Ed&it All'))
|
||||
self.editAllButton.setToolTip(
|
||||
translate('CustomPlugin.EditCustomForm', 'Edit all the slides at '
|
||||
'once.'))
|
||||
self.themeLabel.setText(
|
||||
translate('CustomPlugin.EditCustomForm', 'The&me:'))
|
||||
self.creditLabel.setText(
|
||||
translate('CustomPlugin.EditCustomForm', '&Credits:'))
|
||||
self.editButton.setToolTip(translate('CustomPlugin.EditCustomForm', 'Edit the selected slide.'))
|
||||
self.editAllButton.setText(translate('CustomPlugin.EditCustomForm', 'Ed&it All'))
|
||||
self.editAllButton.setToolTip(translate('CustomPlugin.EditCustomForm', 'Edit all the slides at once.'))
|
||||
self.themeLabel.setText(translate('CustomPlugin.EditCustomForm', 'The&me:'))
|
||||
self.creditLabel.setText(translate('CustomPlugin.EditCustomForm', '&Credits:'))
|
||||
self.previewButton.setText(UiStrings().SaveAndPreview)
|
||||
|
|
|
@ -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 #
|
||||
|
@ -57,20 +57,13 @@ class EditCustomForm(QtGui.QDialog, Ui_CustomEditDialog):
|
|||
# Create other objects and forms.
|
||||
self.editSlideForm = EditCustomSlideForm(self)
|
||||
# Connecting signals and slots
|
||||
QtCore.QObject.connect(self.previewButton,
|
||||
QtCore.SIGNAL(u'clicked()'), self.onPreviewButtonClicked)
|
||||
QtCore.QObject.connect(self.addButton,
|
||||
QtCore.SIGNAL(u'clicked()'), self.onAddButtonClicked)
|
||||
QtCore.QObject.connect(self.editButton,
|
||||
QtCore.SIGNAL(u'clicked()'), self.onEditButtonClicked)
|
||||
QtCore.QObject.connect(self.editAllButton,
|
||||
QtCore.SIGNAL(u'clicked()'), self.onEditAllButtonClicked)
|
||||
QtCore.QObject.connect(Receiver.get_receiver(),
|
||||
QtCore.SIGNAL(u'theme_update_list'), self.loadThemes)
|
||||
QtCore.QObject.connect(self.slideListView,
|
||||
QtCore.SIGNAL(u'currentRowChanged(int)'), self.onCurrentRowChanged)
|
||||
QtCore.QObject.connect(self.slideListView,
|
||||
QtCore.SIGNAL(u'doubleClicked(QModelIndex)'),
|
||||
QtCore.QObject.connect(self.previewButton, QtCore.SIGNAL(u'clicked()'), self.onPreviewButtonClicked)
|
||||
QtCore.QObject.connect(self.addButton, QtCore.SIGNAL(u'clicked()'), self.onAddButtonClicked)
|
||||
QtCore.QObject.connect(self.editButton, QtCore.SIGNAL(u'clicked()'), self.onEditButtonClicked)
|
||||
QtCore.QObject.connect(self.editAllButton, QtCore.SIGNAL(u'clicked()'), self.onEditAllButtonClicked)
|
||||
QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'theme_update_list'), self.loadThemes)
|
||||
QtCore.QObject.connect(self.slideListView, QtCore.SIGNAL(u'currentRowChanged(int)'), self.onCurrentRowChanged)
|
||||
QtCore.QObject.connect(self.slideListView, QtCore.SIGNAL(u'doubleClicked(QModelIndex)'),
|
||||
self.onEditButtonClicked)
|
||||
|
||||
def loadThemes(self, themelist):
|
||||
|
@ -125,11 +118,8 @@ class EditCustomForm(QtGui.QDialog, Ui_CustomEditDialog):
|
|||
if not self._validate():
|
||||
return False
|
||||
sxml = CustomXMLBuilder()
|
||||
sxml.new_document()
|
||||
sxml.add_lyrics_to_song()
|
||||
for count in range(self.slideListView.count()):
|
||||
sxml.add_verse_to_lyrics(u'custom', unicode(count + 1),
|
||||
self.slideListView.item(count).text())
|
||||
sxml.add_verse_to_lyrics(u'custom', unicode(count + 1), self.slideListView.item(count).text())
|
||||
self.customSlide.title = self.titleEdit.text()
|
||||
self.customSlide.text = unicode(sxml.extract_xml(), u'utf-8')
|
||||
self.customSlide.credits = self.creditEdit.text()
|
||||
|
@ -246,14 +236,11 @@ class EditCustomForm(QtGui.QDialog, Ui_CustomEditDialog):
|
|||
# We must have a title.
|
||||
if not self.titleEdit.displayText():
|
||||
self.titleEdit.setFocus()
|
||||
critical_error_message_box(
|
||||
message=translate('CustomPlugin.EditCustomForm',
|
||||
'You need to type in a title.'))
|
||||
critical_error_message_box(message=translate('CustomPlugin.EditCustomForm', 'You need to type in a title.'))
|
||||
return False
|
||||
# We must have at least one slide.
|
||||
if self.slideListView.count() == 0:
|
||||
critical_error_message_box(
|
||||
message=translate('CustomPlugin.EditCustomForm',
|
||||
critical_error_message_box(message=translate('CustomPlugin.EditCustomForm',
|
||||
'You need to add at least one slide'))
|
||||
return False
|
||||
return True
|
||||
|
|
|
@ -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,22 +40,17 @@ class Ui_CustomSlideEditDialog(object):
|
|||
self.slideTextEdit = SpellTextEdit(self)
|
||||
self.slideTextEdit.setObjectName(u'slideTextEdit')
|
||||
self.dialogLayout.addWidget(self.slideTextEdit)
|
||||
self.splitButton = create_button(customSlideEditDialog, u'splitButton',
|
||||
icon=u':/general/general_add.png')
|
||||
self.insertButton = create_button(customSlideEditDialog,
|
||||
u'insertButton', icon=u':/general/general_add.png')
|
||||
self.buttonBox = create_button_box(customSlideEditDialog, u'buttonBox',
|
||||
[u'cancel', u'save'], [self.splitButton, self.insertButton])
|
||||
self.splitButton = create_button(customSlideEditDialog, u'splitButton', icon=u':/general/general_add.png')
|
||||
self.insertButton = create_button(customSlideEditDialog, u'insertButton', icon=u':/general/general_add.png')
|
||||
self.buttonBox = create_button_box(customSlideEditDialog, u'buttonBox', [u'cancel', u'save'],
|
||||
[self.splitButton, self.insertButton])
|
||||
self.dialogLayout.addWidget(self.buttonBox)
|
||||
self.retranslateUi(customSlideEditDialog)
|
||||
|
||||
def retranslateUi(self, customSlideEditDialog):
|
||||
customSlideEditDialog.setWindowTitle(
|
||||
translate('CustomPlugin.EditVerseForm', 'Edit Slide'))
|
||||
customSlideEditDialog.setWindowTitle(translate('CustomPlugin.EditVerseForm', 'Edit Slide'))
|
||||
self.splitButton.setText(UiStrings().Split)
|
||||
self.splitButton.setToolTip(UiStrings().SplitToolTip)
|
||||
self.insertButton.setText(
|
||||
translate('CustomPlugin.EditCustomForm', 'Insert Slide'))
|
||||
self.insertButton.setToolTip(
|
||||
translate('CustomPlugin.EditCustomForm', 'Split a slide into two '
|
||||
'by inserting a slide splitter.'))
|
||||
self.insertButton.setText(translate('CustomPlugin.EditCustomForm', 'Insert Slide'))
|
||||
self.insertButton.setToolTip(translate('CustomPlugin.EditCustomForm',
|
||||
'Split a slide into two by inserting a slide splitter.'))
|
||||
|
|
|
@ -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,10 +47,8 @@ class EditCustomSlideForm(QtGui.QDialog, Ui_CustomSlideEditDialog):
|
|||
QtGui.QDialog.__init__(self, parent)
|
||||
self.setupUi(self)
|
||||
# Connecting signals and slots
|
||||
QtCore.QObject.connect(self.insertButton,
|
||||
QtCore.SIGNAL(u'clicked()'), self.onInsertButtonClicked)
|
||||
QtCore.QObject.connect(self.splitButton,
|
||||
QtCore.SIGNAL(u'clicked()'), self.onSplitButtonClicked)
|
||||
QtCore.QObject.connect(self.insertButton, QtCore.SIGNAL(u'clicked()'), self.onInsertButtonClicked)
|
||||
QtCore.QObject.connect(self.splitButton, QtCore.SIGNAL(u'clicked()'), self.onSplitButtonClicked)
|
||||
|
||||
def setText(self, text):
|
||||
"""
|
||||
|
|
|
@ -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 #
|
||||
|
|
|
@ -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 #
|
||||
|
@ -48,18 +48,22 @@ class CustomTab(SettingsTab):
|
|||
self.displayFooterCheckBox = QtGui.QCheckBox(self.customModeGroupBox)
|
||||
self.displayFooterCheckBox.setObjectName(u'displayFooterCheckBox')
|
||||
self.customModeLayout.addRow(self.displayFooterCheckBox)
|
||||
self.add_from_service_checkbox = QtGui.QCheckBox(self.customModeGroupBox)
|
||||
self.add_from_service_checkbox.setObjectName(u'add_from_service_checkbox')
|
||||
self.customModeLayout.addRow(self.add_from_service_checkbox)
|
||||
self.leftLayout.addWidget(self.customModeGroupBox)
|
||||
self.leftLayout.addStretch()
|
||||
self.rightLayout.addStretch()
|
||||
QtCore.QObject.connect(self.displayFooterCheckBox,
|
||||
QtCore.SIGNAL(u'stateChanged(int)'),
|
||||
QtCore.QObject.connect(self.displayFooterCheckBox, QtCore.SIGNAL(u'stateChanged(int)'),
|
||||
self.onDisplayFooterCheckBoxChanged)
|
||||
QtCore.QObject.connect(self.add_from_service_checkbox, QtCore.SIGNAL(u'stateChanged(int)'),
|
||||
self.on_add_from_service_check_box_changed)
|
||||
|
||||
def retranslateUi(self):
|
||||
self.customModeGroupBox.setTitle(translate('CustomPlugin.CustomTab',
|
||||
'Custom Display'))
|
||||
self.displayFooterCheckBox.setText(
|
||||
translate('CustomPlugin.CustomTab', 'Display footer'))
|
||||
self.customModeGroupBox.setTitle(translate('CustomPlugin.CustomTab', 'Custom Display'))
|
||||
self.displayFooterCheckBox.setText(translate('CustomPlugin.CustomTab', 'Display footer'))
|
||||
self.add_from_service_checkbox.setText(translate('CustomPlugin.CustomTab',
|
||||
'Import missing custom slides from service files'))
|
||||
|
||||
def onDisplayFooterCheckBoxChanged(self, check_state):
|
||||
self.displayFooter = False
|
||||
|
@ -67,11 +71,21 @@ class CustomTab(SettingsTab):
|
|||
if check_state == QtCore.Qt.Checked:
|
||||
self.displayFooter = True
|
||||
|
||||
def on_add_from_service_check_box_changed(self, check_state):
|
||||
self.update_load = (check_state == QtCore.Qt.Checked)
|
||||
|
||||
def load(self):
|
||||
self.displayFooter = Settings().value(
|
||||
self.settingsSection + u'/display footer', True)
|
||||
settings = Settings()
|
||||
settings.beginGroup(self.settingsSection)
|
||||
self.displayFooter = settings.value(u'display footer', True)
|
||||
self.update_load = settings.value(u'add custom from service', True)
|
||||
self.displayFooterCheckBox.setChecked(self.displayFooter)
|
||||
self.add_from_service_checkbox.setChecked(self.update_load)
|
||||
settings.endGroup()
|
||||
|
||||
def save(self):
|
||||
Settings().setValue(self.settingsSection + u'/display footer',
|
||||
self.displayFooter)
|
||||
settings = Settings()
|
||||
settings.beginGroup(self.settingsSection)
|
||||
settings.setValue(u'display footer', self.displayFooter)
|
||||
settings.setValue(u'add custom from service', self.update_load)
|
||||
settings.endGroup()
|
||||
|
|
|
@ -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 #
|
||||
|
@ -62,6 +62,8 @@ class CustomXMLBuilder(object):
|
|||
"""
|
||||
# Create the minidom document
|
||||
self.custom_xml = Document()
|
||||
self.new_document()
|
||||
self.add_lyrics_to_song()
|
||||
|
||||
def new_document(self):
|
||||
"""
|
||||
|
|
|
@ -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 #
|
||||
|
|
|
@ -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 #
|
||||
|
@ -30,13 +30,13 @@
|
|||
import logging
|
||||
|
||||
from PyQt4 import QtCore, QtGui
|
||||
from sqlalchemy.sql import or_, func
|
||||
from sqlalchemy.sql import or_, func, and_
|
||||
|
||||
from openlp.core.lib import MediaManagerItem, Receiver, ItemCapabilities, \
|
||||
check_item_selected, translate, ServiceItemContext, Settings
|
||||
from openlp.core.lib import MediaManagerItem, Receiver, ItemCapabilities, check_item_selected, translate, \
|
||||
ServiceItemContext, Settings, PluginStatus
|
||||
from openlp.core.lib.ui import UiStrings
|
||||
from openlp.plugins.custom.forms import EditCustomForm
|
||||
from openlp.plugins.custom.lib import CustomXMLParser
|
||||
from openlp.plugins.custom.lib import CustomXMLParser, CustomXMLBuilder
|
||||
from openlp.plugins.custom.lib.db import CustomSlide
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
|
@ -58,12 +58,11 @@ class CustomMediaItem(MediaManagerItem):
|
|||
def __init__(self, parent, plugin, icon):
|
||||
self.IconPath = u'custom/custom'
|
||||
MediaManagerItem.__init__(self, parent, plugin, icon)
|
||||
self.edit_custom_form = EditCustomForm(self, self.plugin.formParent,
|
||||
self.plugin.manager)
|
||||
self.edit_custom_form = EditCustomForm(self, self.plugin.formParent, self.plugin.manager)
|
||||
self.singleServiceItem = False
|
||||
self.quickPreviewAllowed = True
|
||||
self.hasSearch = True
|
||||
# Holds information about whether the edit is remotly triggered and
|
||||
# Holds information about whether the edit is remotely triggered and
|
||||
# which Custom is required.
|
||||
self.remoteCustom = -1
|
||||
self.manager = plugin.manager
|
||||
|
@ -72,19 +71,19 @@ class CustomMediaItem(MediaManagerItem):
|
|||
self.toolbar.addSeparator()
|
||||
self.addSearchToToolBar()
|
||||
# Signals and slots
|
||||
QtCore.QObject.connect(self.searchTextEdit,
|
||||
QtCore.SIGNAL(u'cleared()'), self.onClearTextButtonClick)
|
||||
QtCore.QObject.connect(self.searchTextEdit,
|
||||
QtCore.SIGNAL(u'searchTypeChanged(int)'),
|
||||
QtCore.QObject.connect(self.searchTextEdit, QtCore.SIGNAL(u'cleared()'), self.onClearTextButtonClick)
|
||||
QtCore.QObject.connect(self.searchTextEdit, QtCore.SIGNAL(u'searchTypeChanged(int)'),
|
||||
self.onSearchTextButtonClicked)
|
||||
QtCore.QObject.connect(Receiver.get_receiver(),
|
||||
QtCore.SIGNAL(u'custom_edit'), self.onRemoteEdit)
|
||||
QtCore.QObject.connect(Receiver.get_receiver(),
|
||||
QtCore.SIGNAL(u'custom_edit_clear'), self.onRemoteEditClear)
|
||||
QtCore.QObject.connect(Receiver.get_receiver(),
|
||||
QtCore.SIGNAL(u'custom_load_list'), self.loadList)
|
||||
QtCore.QObject.connect(Receiver.get_receiver(),
|
||||
QtCore.SIGNAL(u'custom_preview'), self.onPreviewClick)
|
||||
QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'custom_edit'), self.onRemoteEdit)
|
||||
QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'custom_edit_clear'), self.onRemoteEditClear)
|
||||
QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'custom_load_list'), self.loadList)
|
||||
QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'custom_preview'), self.onPreviewClick)
|
||||
QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'config_updated'), self.config_updated)
|
||||
QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'custom_create_from_service'),
|
||||
self.create_from_service_item)
|
||||
|
||||
def config_updated(self):
|
||||
self.add_custom_from_service = Settings().value(self.settingsSection + u'/add custom from service', True)
|
||||
|
||||
def retranslateUi(self):
|
||||
self.searchTextLabel.setText(u'%s:' % UiStrings().Search)
|
||||
|
@ -95,13 +94,12 @@ class CustomMediaItem(MediaManagerItem):
|
|||
(CustomSearch.Titles, u':/songs/song_search_title.png',
|
||||
translate('SongsPlugin.MediaItem', 'Titles'),
|
||||
translate('SongsPlugin.MediaItem', 'Search Titles...')),
|
||||
(CustomSearch.Themes, u':/slides/slide_theme.png',
|
||||
UiStrings().Themes, UiStrings().SearchThemes)
|
||||
(CustomSearch.Themes, u':/slides/slide_theme.png', UiStrings().Themes, UiStrings().SearchThemes)
|
||||
])
|
||||
self.loadList(self.manager.get_all_objects(
|
||||
CustomSlide, order_by_ref=CustomSlide.title))
|
||||
self.searchTextEdit.setCurrentSearchType(Settings().value(
|
||||
u'%s/last search type' % self.settingsSection, CustomSearch.Titles))
|
||||
self.loadList(self.manager.get_all_objects(CustomSlide, order_by_ref=CustomSlide.title))
|
||||
self.searchTextEdit.setCurrentSearchType(Settings().value( u'%s/last search type' % self.settingsSection,
|
||||
CustomSearch.Titles))
|
||||
self.config_updated()
|
||||
|
||||
def loadList(self, custom_slides):
|
||||
# Sort out what custom we want to select after loading the list.
|
||||
|
@ -173,11 +171,9 @@ class CustomMediaItem(MediaManagerItem):
|
|||
if QtGui.QMessageBox.question(self,
|
||||
UiStrings().ConfirmDelete,
|
||||
translate('CustomPlugin.MediaItem',
|
||||
'Are you sure you want to delete the %n selected custom'
|
||||
' slide(s)?', '',
|
||||
'Are you sure you want to delete the %n selected custom slide(s)?', '',
|
||||
QtCore.QCoreApplication.CodecForTr, len(items)),
|
||||
QtGui.QMessageBox.StandardButtons(QtGui.QMessageBox.Yes |
|
||||
QtGui.QMessageBox.No),
|
||||
QtGui.QMessageBox.StandardButtons(QtGui.QMessageBox.Yes | QtGui.QMessageBox.No),
|
||||
QtGui.QMessageBox.Yes) == QtGui.QMessageBox.No:
|
||||
return
|
||||
row_list = [item.row() for item in self.listView.selectedIndexes()]
|
||||
|
@ -198,6 +194,7 @@ class CustomMediaItem(MediaManagerItem):
|
|||
service_item.add_capability(ItemCapabilities.CanPreview)
|
||||
service_item.add_capability(ItemCapabilities.CanLoop)
|
||||
service_item.add_capability(ItemCapabilities.CanSoftBreak)
|
||||
service_item.add_capability(ItemCapabilities.OnLoadUpdate)
|
||||
customSlide = self.plugin.manager.get_object(CustomSlide, item_id)
|
||||
title = customSlide.title
|
||||
credit = customSlide.credits
|
||||
|
@ -211,8 +208,7 @@ class CustomMediaItem(MediaManagerItem):
|
|||
service_item.title = title
|
||||
for slide in raw_slides:
|
||||
service_item.add_from_text(slide)
|
||||
if Settings().value(self.settingsSection + u'/display footer',
|
||||
True) or credit:
|
||||
if Settings().value(self.settingsSection + u'/display footer', True) or credit:
|
||||
service_item.raw_footer.append(u' '.join([title, credit]))
|
||||
else:
|
||||
service_item.raw_footer.append(u'')
|
||||
|
@ -220,8 +216,7 @@ class CustomMediaItem(MediaManagerItem):
|
|||
|
||||
def onSearchTextButtonClicked(self):
|
||||
# Save the current search type to the configuration.
|
||||
Settings().setValue(u'%s/last search type' %
|
||||
self.settingsSection, self.searchTextEdit.currentSearchType())
|
||||
Settings().setValue(u'%s/last search type' % self.settingsSection, self.searchTextEdit.currentSearchType())
|
||||
# Reload the list considering the new search type.
|
||||
search_keywords = self.searchTextEdit.displayText()
|
||||
search_results = []
|
||||
|
@ -229,14 +224,14 @@ class CustomMediaItem(MediaManagerItem):
|
|||
if search_type == CustomSearch.Titles:
|
||||
log.debug(u'Titles Search')
|
||||
search_results = self.plugin.manager.get_all_objects(CustomSlide,
|
||||
CustomSlide.title.like(u'%' + self.whitespace.sub(u' ',
|
||||
search_keywords) + u'%'), order_by_ref=CustomSlide.title)
|
||||
CustomSlide.title.like(u'%' + self.whitespace.sub(u' ', search_keywords) + u'%'),
|
||||
order_by_ref=CustomSlide.title)
|
||||
self.loadList(search_results)
|
||||
elif search_type == CustomSearch.Themes:
|
||||
log.debug(u'Theme Search')
|
||||
search_results = self.plugin.manager.get_all_objects(CustomSlide,
|
||||
CustomSlide.theme_name.like(u'%' + self.whitespace.sub(u' ',
|
||||
search_keywords) + u'%'), order_by_ref=CustomSlide.title)
|
||||
CustomSlide.theme_name.like(u'%' + self.whitespace.sub(u' ', search_keywords) + u'%'),
|
||||
order_by_ref=CustomSlide.title)
|
||||
self.loadList(search_results)
|
||||
self.checkSearchResult()
|
||||
|
||||
|
@ -252,6 +247,49 @@ class CustomMediaItem(MediaManagerItem):
|
|||
elif not text:
|
||||
self.onClearTextButtonClick()
|
||||
|
||||
def serviceLoad(self, item):
|
||||
"""
|
||||
Triggered by a song being loaded by the service manager.
|
||||
"""
|
||||
log.debug(u'serviceLoad')
|
||||
if self.plugin.status != PluginStatus.Active:
|
||||
return
|
||||
custom = self.plugin.manager.get_object_filtered(CustomSlide,
|
||||
and_(CustomSlide.title == item.title, CustomSlide.theme_name == item.theme,
|
||||
CustomSlide.credits == item.raw_footer[0][len(item.title) + 1:]))
|
||||
if custom:
|
||||
Receiver.send_message(u'service_item_update', u'%s:%s:%s' % (custom.id, item._uuid, False))
|
||||
else:
|
||||
if self.add_custom_from_service:
|
||||
self.create_from_service_item(item)
|
||||
|
||||
def create_from_service_item(self, item):
|
||||
"""
|
||||
Create a custom slide from a text service item
|
||||
"""
|
||||
custom = CustomSlide()
|
||||
custom.title = item.title
|
||||
if item.theme:
|
||||
custom.theme_name = item.theme
|
||||
else:
|
||||
custom.theme_name = u''
|
||||
footer = u' '.join(item.raw_footer)
|
||||
if footer:
|
||||
if footer.startswith(item.title):
|
||||
custom.credits = footer[len(item.title) + 1:]
|
||||
else:
|
||||
custom.credits = footer
|
||||
else:
|
||||
custom.credits = u''
|
||||
custom_xml = CustomXMLBuilder()
|
||||
for (idx, slide) in enumerate(item._raw_frames):
|
||||
custom_xml.add_verse_to_lyrics(u'custom', unicode(idx + 1), slide['raw_slide'])
|
||||
custom.text = unicode(custom_xml.extract_xml(), u'utf-8')
|
||||
self.plugin.manager.save_object(custom)
|
||||
self.onSearchTextButtonClicked()
|
||||
if item.name.lower() == u'custom':
|
||||
Receiver.send_message(u'service_item_update', u'%s:%s:%s' % (custom.id, item._uuid, False))
|
||||
|
||||
def onClearTextButtonClick(self):
|
||||
"""
|
||||
Clear the search text.
|
||||
|
@ -261,10 +299,8 @@ class CustomMediaItem(MediaManagerItem):
|
|||
|
||||
def search(self, string, showError):
|
||||
search_results = self.manager.get_all_objects(CustomSlide,
|
||||
or_(func.lower(CustomSlide.title).like(u'%' +
|
||||
string.lower() + u'%'),
|
||||
func.lower(CustomSlide.text).like(u'%' +
|
||||
string.lower() + u'%')),
|
||||
or_(func.lower(CustomSlide.title).like(u'%' + string.lower() + u'%'),
|
||||
func.lower(CustomSlide.text).like(u'%' + string.lower() + u'%')),
|
||||
order_by_ref=CustomSlide.title)
|
||||
return [[custom.id, custom.title] for custom in search_results]
|
||||
|
||||
|
|
|
@ -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 #
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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 #
|
||||
|
|
|
@ -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()
|
||||
|
|
|
@ -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') %
|
||||
u'\n'.join(missing_items_filenames))
|
||||
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,26 +204,21 @@ 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, '
|
||||
'the image file "%s" no longer exists.') % filename)
|
||||
translate('ImagePlugin.MediaItem', 'There was a problem replacing your background, '
|
||||
'the image file "%s" no longer exists.') % filename)
|
||||
|
||||
def search(self, string, showError):
|
||||
files = SettingsManager.load_list(self.settingsSection, u'images')
|
||||
|
|
|
@ -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 #
|
||||
|
|
|
@ -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 #
|
||||
|
|
|
@ -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 #
|
||||
|
@ -76,8 +76,7 @@ class ImpressController(PresentationController):
|
|||
Initialise the class
|
||||
"""
|
||||
log.debug(u'Initialising')
|
||||
PresentationController.__init__(self, plugin, u'Impress',
|
||||
ImpressDocument)
|
||||
PresentationController.__init__(self, plugin, u'Impress', ImpressDocument)
|
||||
self.supports = [u'odp']
|
||||
self.alsosupports = [u'ppt', u'pps', u'pptx', u'ppsx']
|
||||
self.process = None
|
||||
|
@ -121,10 +120,8 @@ class ImpressController(PresentationController):
|
|||
loop = 0
|
||||
log.debug(u'get UNO Desktop Openoffice - getComponentContext')
|
||||
context = uno.getComponentContext()
|
||||
log.debug(u'get UNO Desktop Openoffice - createInstaneWithContext - '
|
||||
u'UnoUrlResolver')
|
||||
resolver = context.ServiceManager.createInstanceWithContext(
|
||||
u'com.sun.star.bridge.UnoUrlResolver', context)
|
||||
log.debug(u'get UNO Desktop Openoffice - createInstaneWithContext - UnoUrlResolver')
|
||||
resolver = context.ServiceManager.createInstanceWithContext(u'com.sun.star.bridge.UnoUrlResolver', context)
|
||||
while uno_instance is None and loop < 3:
|
||||
try:
|
||||
uno_instance = get_uno_instance(resolver)
|
||||
|
@ -136,8 +133,7 @@ class ImpressController(PresentationController):
|
|||
self.manager = uno_instance.ServiceManager
|
||||
log.debug(u'get UNO Desktop Openoffice - createInstanceWithContext'
|
||||
u' - Desktop')
|
||||
desktop = self.manager.createInstanceWithContext(
|
||||
"com.sun.star.frame.Desktop", uno_instance)
|
||||
desktop = self.manager.createInstanceWithContext("com.sun.star.frame.Desktop", uno_instance)
|
||||
return desktop
|
||||
except:
|
||||
log.warn(u'Failed to get UNO desktop')
|
||||
|
@ -166,8 +162,7 @@ class ImpressController(PresentationController):
|
|||
try:
|
||||
return Dispatch(u'com.sun.star.ServiceManager')
|
||||
except pywintypes.com_error:
|
||||
log.warn(u'Failed to get COM service manager. '
|
||||
u'Impress Controller has been disabled')
|
||||
log.warn(u'Failed to get COM service manager. Impress Controller has been disabled')
|
||||
return None
|
||||
|
||||
def kill(self):
|
||||
|
@ -193,8 +188,7 @@ class ImpressController(PresentationController):
|
|||
list = docs.createEnumeration()
|
||||
while list.hasMoreElements():
|
||||
doc = list.nextElement()
|
||||
if doc.getImplementationName() != \
|
||||
u'com.sun.star.comp.framework.BackingComp':
|
||||
if doc.getImplementationName() != u'com.sun.star.comp.framework.BackingComp':
|
||||
cnt = cnt + 1
|
||||
if cnt > 0:
|
||||
log.debug(u'OpenOffice not terminated as docs are still open')
|
||||
|
@ -235,8 +229,7 @@ class ImpressDocument(PresentationDocument):
|
|||
if desktop is None:
|
||||
self.controller.start_process()
|
||||
desktop = self.controller.get_com_desktop()
|
||||
url = u'file:///' + self.filepath.replace(u'\\', u'/').replace(
|
||||
u':', u'|').replace(u' ', u'%20')
|
||||
url = u'file:///' + self.filepath.replace(u'\\', u'/').replace(u':', u'|').replace(u' ', u'%20')
|
||||
else:
|
||||
desktop = self.controller.get_uno_desktop()
|
||||
url = uno.systemPathToFileUrl(self.filepath)
|
||||
|
@ -258,12 +251,10 @@ class ImpressDocument(PresentationDocument):
|
|||
if os.name == u'nt':
|
||||
# As we can't start minimized the Impress window gets in the way.
|
||||
# Either window.setPosSize(0, 0, 200, 400, 12) or .setVisible(False)
|
||||
window = self.document.getCurrentController().getFrame() \
|
||||
.getContainerWindow()
|
||||
window = self.document.getCurrentController().getFrame().getContainerWindow()
|
||||
window.setVisible(False)
|
||||
self.presentation = self.document.getPresentation()
|
||||
self.presentation.Display = \
|
||||
self.controller.plugin.renderer.screens.current[u'number'] + 1
|
||||
self.presentation.Display = self.controller.plugin.renderer.screens.current[u'number'] + 1
|
||||
self.control = None
|
||||
self.create_thumbnails()
|
||||
return True
|
||||
|
@ -276,8 +267,8 @@ class ImpressDocument(PresentationDocument):
|
|||
if self.check_thumbnails():
|
||||
return
|
||||
if os.name == u'nt':
|
||||
thumbdirurl = u'file:///' + self.get_temp_folder().replace(
|
||||
u'\\', u'/').replace(u':', u'|').replace(u' ', u'%20')
|
||||
thumbdirurl = u'file:///' + self.get_temp_folder().replace(u'\\', u'/') \
|
||||
.replace(u':', u'|').replace(u' ', u'%20')
|
||||
else:
|
||||
thumbdirurl = uno.systemPathToFileUrl(self.get_temp_folder())
|
||||
props = []
|
||||
|
@ -293,15 +284,13 @@ class ImpressDocument(PresentationDocument):
|
|||
page = pages.getByIndex(idx)
|
||||
doc.getCurrentController().setCurrentPage(page)
|
||||
urlpath = u'%s/%s.png' % (thumbdirurl, unicode(idx + 1))
|
||||
path = os.path.join(self.get_temp_folder(),
|
||||
unicode(idx + 1) + u'.png')
|
||||
path = os.path.join(self.get_temp_folder(), unicode(idx + 1) + u'.png')
|
||||
try:
|
||||
doc.storeToURL(urlpath, props)
|
||||
self.convert_thumbnail(path, idx + 1)
|
||||
delete_file(path)
|
||||
except ErrorCodeIOException, exception:
|
||||
log.exception(u'ERROR! ErrorCodeIOException %d' %
|
||||
exception.ErrCode)
|
||||
log.exception(u'ERROR! ErrorCodeIOException %d' % exception.ErrCode)
|
||||
except:
|
||||
log.exception(u'%s - Unable to store openoffice preview' % path)
|
||||
|
||||
|
@ -312,8 +301,7 @@ class ImpressDocument(PresentationDocument):
|
|||
"""
|
||||
log.debug(u'create property OpenOffice')
|
||||
if os.name == u'nt':
|
||||
prop = self.controller.manager.\
|
||||
Bridge_GetStruct(u'com.sun.star.beans.PropertyValue')
|
||||
prop = self.controller.manager.Bridge_GetStruct(u'com.sun.star.beans.PropertyValue')
|
||||
else:
|
||||
prop = PropertyValue()
|
||||
prop.Name = name
|
||||
|
|
|
@ -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,11 +32,9 @@ import os
|
|||
|
||||
from PyQt4 import QtCore, QtGui
|
||||
|
||||
from openlp.core.lib import MediaManagerItem, build_icon, SettingsManager, \
|
||||
translate, check_item_selected, Receiver, ItemCapabilities, create_thumb, \
|
||||
validate_thumb, ServiceItemContext, Settings
|
||||
from openlp.core.lib.ui import UiStrings, critical_error_message_box, \
|
||||
create_horizontal_adjusting_combo_box
|
||||
from openlp.core.lib import MediaManagerItem, build_icon, SettingsManager, translate, check_item_selected, Receiver, \
|
||||
ItemCapabilities, create_thumb, validate_thumb, ServiceItemContext, Settings
|
||||
from openlp.core.lib.ui import UiStrings, critical_error_message_box, create_horizontal_adjusting_combo_box
|
||||
from openlp.core.utils import locale_compare
|
||||
from openlp.plugins.presentations.lib import MessageListener
|
||||
|
||||
|
@ -62,11 +60,9 @@ class PresentationMediaItem(MediaManagerItem):
|
|||
self.message_listener = MessageListener(self)
|
||||
self.hasSearch = True
|
||||
self.singleServiceItem = False
|
||||
QtCore.QObject.connect(Receiver.get_receiver(),
|
||||
QtCore.SIGNAL(u'mediaitem_presentation_rebuild'),
|
||||
QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'mediaitem_presentation_rebuild'),
|
||||
self.populateDisplayTypes)
|
||||
QtCore.QObject.connect(Receiver.get_receiver(),
|
||||
QtCore.SIGNAL(u'mediaitem_suffixes'), self.buildFileMaskString)
|
||||
QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'mediaitem_suffixes'), self.buildFileMaskString)
|
||||
# Allow DnD from the desktop
|
||||
self.listView.activateDnD()
|
||||
|
||||
|
@ -74,12 +70,9 @@ class PresentationMediaItem(MediaManagerItem):
|
|||
"""
|
||||
The name of the plugin media displayed in UI
|
||||
"""
|
||||
self.onNewPrompt = translate('PresentationPlugin.MediaItem',
|
||||
'Select Presentation(s)')
|
||||
self.Automatic = translate('PresentationPlugin.MediaItem',
|
||||
'Automatic')
|
||||
self.displayTypeLabel.setText(
|
||||
translate('PresentationPlugin.MediaItem', 'Present using:'))
|
||||
self.onNewPrompt = translate('PresentationPlugin.MediaItem', 'Select Presentation(s)')
|
||||
self.Automatic = translate('PresentationPlugin.MediaItem', 'Automatic')
|
||||
self.displayTypeLabel.setText(translate('PresentationPlugin.MediaItem', 'Present using:'))
|
||||
|
||||
def buildFileMaskString(self):
|
||||
"""
|
||||
|
@ -88,14 +81,12 @@ class PresentationMediaItem(MediaManagerItem):
|
|||
fileType = u''
|
||||
for controller in self.controllers:
|
||||
if self.controllers[controller].enabled():
|
||||
types = self.controllers[controller].supports + \
|
||||
self.controllers[controller].alsosupports
|
||||
types = self.controllers[controller].supports + self.controllers[controller].alsosupports
|
||||
for type in types:
|
||||
if fileType.find(type) == -1:
|
||||
fileType += u'*.%s ' % type
|
||||
self.plugin.serviceManager.supportedSuffixes(type)
|
||||
self.onNewFileMasks = translate('PresentationPlugin.MediaItem',
|
||||
'Presentations (%s)') % fileType
|
||||
self.onNewFileMasks = translate('PresentationPlugin.MediaItem', 'Presentations (%s)') % fileType
|
||||
|
||||
def requiredIcons(self):
|
||||
"""
|
||||
|
@ -117,11 +108,10 @@ class PresentationMediaItem(MediaManagerItem):
|
|||
self.displayLayout.setObjectName(u'displayLayout')
|
||||
self.displayTypeLabel = QtGui.QLabel(self.presentationWidget)
|
||||
self.displayTypeLabel.setObjectName(u'displayTypeLabel')
|
||||
self.displayTypeComboBox = create_horizontal_adjusting_combo_box(
|
||||
self.presentationWidget, u'displayTypeComboBox')
|
||||
self.displayTypeComboBox = create_horizontal_adjusting_combo_box(self.presentationWidget,
|
||||
u'displayTypeComboBox')
|
||||
self.displayTypeLabel.setBuddy(self.displayTypeComboBox)
|
||||
self.displayLayout.addRow(self.displayTypeLabel,
|
||||
self.displayTypeComboBox)
|
||||
self.displayLayout.addRow(self.displayTypeLabel, self.displayTypeComboBox)
|
||||
# Add the Presentation widget to the page layout
|
||||
self.pageLayout.addWidget(self.presentationWidget)
|
||||
|
||||
|
@ -130,8 +120,7 @@ class PresentationMediaItem(MediaManagerItem):
|
|||
Populate the media manager tab
|
||||
"""
|
||||
self.listView.setIconSize(QtCore.QSize(88, 50))
|
||||
files = SettingsManager.load_list(
|
||||
self.settingsSection, u'presentations')
|
||||
files = SettingsManager.load_list(self.settingsSection, u'presentations')
|
||||
self.loadList(files, True)
|
||||
self.populateDisplayTypes()
|
||||
|
||||
|
@ -166,8 +155,7 @@ class PresentationMediaItem(MediaManagerItem):
|
|||
if not initialLoad:
|
||||
Receiver.send_message(u'cursor_busy')
|
||||
self.plugin.formParent.displayProgressBar(len(files))
|
||||
# Sort the presentations by its filename considering language specific
|
||||
# characters.
|
||||
# Sort the presentations by its filename considering language specific characters.
|
||||
files.sort(cmp=locale_compare,
|
||||
key=lambda filename: os.path.split(unicode(filename))[1])
|
||||
for file in files:
|
||||
|
@ -185,19 +173,16 @@ class PresentationMediaItem(MediaManagerItem):
|
|||
else:
|
||||
if titles.count(filename) > 0:
|
||||
if not initialLoad:
|
||||
critical_error_message_box(
|
||||
critical_error_message_box(translate('PresentationPlugin.MediaItem', 'File Exists'),
|
||||
translate('PresentationPlugin.MediaItem',
|
||||
'File Exists'),
|
||||
translate('PresentationPlugin.MediaItem',
|
||||
'A presentation with that filename already exists.')
|
||||
'A presentation with that filename already exists.')
|
||||
)
|
||||
continue
|
||||
controller_name = self.findControllerByType(filename)
|
||||
if controller_name:
|
||||
controller = self.controllers[controller_name]
|
||||
doc = controller.add_document(unicode(file))
|
||||
thumb = os.path.join(doc.get_thumbnail_folder(),
|
||||
u'icon.png')
|
||||
thumb = os.path.join(doc.get_thumbnail_folder(), u'icon.png')
|
||||
preview = doc.get_thumbnail_path(1, True)
|
||||
if not preview and not initialLoad:
|
||||
doc.load_presentation()
|
||||
|
@ -215,8 +200,7 @@ class PresentationMediaItem(MediaManagerItem):
|
|||
icon = build_icon(u':/general/general_delete.png')
|
||||
else:
|
||||
critical_error_message_box(UiStrings().UnsupportedFile,
|
||||
translate('PresentationPlugin.MediaItem',
|
||||
'This type of presentation is not supported.'))
|
||||
translate('PresentationPlugin.MediaItem', 'This type of presentation is not supported.'))
|
||||
continue
|
||||
item_name = QtGui.QListWidgetItem(filename)
|
||||
item_name.setData(QtCore.Qt.UserRole, file)
|
||||
|
@ -249,8 +233,7 @@ class PresentationMediaItem(MediaManagerItem):
|
|||
Receiver.send_message(u'cursor_normal')
|
||||
for row in row_list:
|
||||
self.listView.takeItem(row)
|
||||
SettingsManager.set_list(self.settingsSection,
|
||||
u'presentations', self.getFileList())
|
||||
SettingsManager.set_list(self.settingsSection, u'presentations', self.getFileList())
|
||||
|
||||
def generateSlideData(self, service_item, item=None, xmlVersion=False,
|
||||
remote=False, context=ServiceItemContext.Service):
|
||||
|
@ -296,21 +279,15 @@ class PresentationMediaItem(MediaManagerItem):
|
|||
else:
|
||||
# File is no longer present
|
||||
if not remote:
|
||||
critical_error_message_box(
|
||||
critical_error_message_box(translate('PresentationPlugin.MediaItem', 'Missing Presentation'),
|
||||
translate('PresentationPlugin.MediaItem',
|
||||
'Missing Presentation'),
|
||||
translate('PresentationPlugin.MediaItem',
|
||||
'The presentation %s is incomplete,'
|
||||
' please reload.') % filename)
|
||||
'The presentation %s is incomplete, please reload.') % filename)
|
||||
return False
|
||||
else:
|
||||
# File is no longer present
|
||||
if not remote:
|
||||
critical_error_message_box(
|
||||
translate('PresentationPlugin.MediaItem',
|
||||
'Missing Presentation'),
|
||||
translate('PresentationPlugin.MediaItem',
|
||||
'The presentation %s no longer exists.') % filename)
|
||||
critical_error_message_box(translate('PresentationPlugin.MediaItem', 'Missing Presentation'),
|
||||
translate('PresentationPlugin.MediaItem', 'The presentation %s no longer exists.') % filename)
|
||||
return False
|
||||
|
||||
def findControllerByType(self, filename):
|
||||
|
|
|
@ -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 #
|
||||
|
@ -271,8 +271,7 @@ class Controller(object):
|
|||
return
|
||||
if not self.activate():
|
||||
return
|
||||
if self.doc.slidenumber and \
|
||||
self.doc.slidenumber != self.doc.get_slide_number():
|
||||
if self.doc.slidenumber and self.doc.slidenumber != self.doc.get_slide_number():
|
||||
self.doc.goto_slide(self.doc.slidenumber)
|
||||
self.doc.unblank_screen()
|
||||
Receiver.send_message(u'live_display_hide', HideMode.Screen)
|
||||
|
@ -296,30 +295,19 @@ class MessageListener(object):
|
|||
self.preview_handler = Controller(False)
|
||||
self.live_handler = Controller(True)
|
||||
# messages are sent from core.ui.slidecontroller
|
||||
QtCore.QObject.connect(Receiver.get_receiver(),
|
||||
QtCore.SIGNAL(u'presentations_start'), self.startup)
|
||||
QtCore.QObject.connect(Receiver.get_receiver(),
|
||||
QtCore.SIGNAL(u'presentations_stop'), self.shutdown)
|
||||
QtCore.QObject.connect(Receiver.get_receiver(),
|
||||
QtCore.SIGNAL(u'presentations_hide'), self.hide)
|
||||
QtCore.QObject.connect(Receiver.get_receiver(),
|
||||
QtCore.SIGNAL(u'presentations_first'), self.first)
|
||||
QtCore.QObject.connect(Receiver.get_receiver(),
|
||||
QtCore.SIGNAL(u'presentations_previous'), self.previous)
|
||||
QtCore.QObject.connect(Receiver.get_receiver(),
|
||||
QtCore.SIGNAL(u'presentations_next'), self.next)
|
||||
QtCore.QObject.connect(Receiver.get_receiver(),
|
||||
QtCore.SIGNAL(u'presentations_last'), self.last)
|
||||
QtCore.QObject.connect(Receiver.get_receiver(),
|
||||
QtCore.SIGNAL(u'presentations_slide'), self.slide)
|
||||
QtCore.QObject.connect(Receiver.get_receiver(),
|
||||
QtCore.SIGNAL(u'presentations_blank'), self.blank)
|
||||
QtCore.QObject.connect(Receiver.get_receiver(),
|
||||
QtCore.SIGNAL(u'presentations_unblank'), self.unblank)
|
||||
QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'presentations_start'), self.startup)
|
||||
QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'presentations_stop'), self.shutdown)
|
||||
QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'presentations_hide'), self.hide)
|
||||
QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'presentations_first'), self.first)
|
||||
QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'presentations_previous'), self.previous)
|
||||
QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'presentations_next'), self.next)
|
||||
QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'presentations_last'), self.last)
|
||||
QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'presentations_slide'), self.slide)
|
||||
QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'presentations_blank'), self.blank)
|
||||
QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'presentations_unblank'), self.unblank)
|
||||
self.timer = QtCore.QTimer()
|
||||
self.timer.setInterval(500)
|
||||
QtCore.QObject.connect(
|
||||
self.timer, QtCore.SIGNAL(u'timeout()'), self.timeout)
|
||||
QtCore.QObject.connect(self.timer, QtCore.SIGNAL(u'timeout()'), self.timeout)
|
||||
|
||||
def startup(self, message):
|
||||
"""
|
||||
|
@ -340,8 +328,7 @@ class MessageListener(object):
|
|||
controller = self.live_handler
|
||||
else:
|
||||
controller = self.preview_handler
|
||||
controller.add_handler(self.controllers[self.handler], file, hide_mode,
|
||||
message[3])
|
||||
controller.add_handler(self.controllers[self.handler], file, hide_mode, message[3])
|
||||
|
||||
def slide(self, message):
|
||||
"""
|
||||
|
@ -433,7 +420,7 @@ class MessageListener(object):
|
|||
def timeout(self):
|
||||
"""
|
||||
The presentation may be timed or might be controlled by the
|
||||
application directly, rather than through OpenLP. Poll occassionally
|
||||
application directly, rather than through OpenLP. Poll occasionally
|
||||
to check which slide is currently displayed so the slidecontroller
|
||||
view can be updated
|
||||
"""
|
||||
|
|
|
@ -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 PowerpointController(PresentationController):
|
|||
Initialise the class
|
||||
"""
|
||||
log.debug(u'Initialising')
|
||||
PresentationController.__init__(self, plugin, u'Powerpoint',
|
||||
PowerpointDocument)
|
||||
PresentationController.__init__(self, plugin, u'Powerpoint', PowerpointDocument)
|
||||
self.supports = [u'ppt', u'pps', u'pptx', u'ppsx']
|
||||
self.process = None
|
||||
|
||||
|
@ -68,8 +67,7 @@ class PowerpointController(PresentationController):
|
|||
log.debug(u'check_available')
|
||||
if os.name == u'nt':
|
||||
try:
|
||||
_winreg.OpenKey(_winreg.HKEY_CLASSES_ROOT,
|
||||
u'PowerPoint.Application').Close()
|
||||
_winreg.OpenKey(_winreg.HKEY_CLASSES_ROOT, u'PowerPoint.Application').Close()
|
||||
return True
|
||||
except WindowsError:
|
||||
pass
|
||||
|
@ -126,13 +124,11 @@ class PowerpointDocument(PresentationDocument):
|
|||
if not self.controller.process or not self.controller.process.Visible:
|
||||
self.controller.start_process()
|
||||
try:
|
||||
self.controller.process.Presentations.Open(self.filepath, False,
|
||||
False, True)
|
||||
self.controller.process.Presentations.Open(self.filepath, False, False, True)
|
||||
except pywintypes.com_error:
|
||||
log.debug(u'PPT open failed')
|
||||
return False
|
||||
self.presentation = self.controller.process.Presentations(
|
||||
self.controller.process.Presentations.Count)
|
||||
self.presentation = self.controller.process.Presentations(self.controller.process.Presentations.Count)
|
||||
self.create_thumbnails()
|
||||
return True
|
||||
|
||||
|
@ -153,8 +149,7 @@ class PowerpointDocument(PresentationDocument):
|
|||
return
|
||||
for num in range(self.presentation.Slides.Count):
|
||||
self.presentation.Slides(num + 1).Export(os.path.join(
|
||||
self.get_thumbnail_folder(), 'slide%d.png' % (num + 1)),
|
||||
'png', 320, 240)
|
||||
self.get_thumbnail_folder(), 'slide%d.png' % (num + 1)), 'png', 320, 240)
|
||||
|
||||
def close_presentation(self):
|
||||
"""
|
||||
|
@ -254,8 +249,7 @@ class PowerpointDocument(PresentationDocument):
|
|||
dpi = win32ui.GetActiveWindow().GetDC().GetDeviceCaps(88)
|
||||
except win32ui.error:
|
||||
try:
|
||||
dpi = \
|
||||
win32ui.GetForegroundWindow().GetDC().GetDeviceCaps(88)
|
||||
dpi = win32ui.GetForegroundWindow().GetDC().GetDeviceCaps(88)
|
||||
except win32ui.error:
|
||||
dpi = 96
|
||||
renderer = self.controller.plugin.renderer
|
||||
|
@ -322,8 +316,7 @@ class PowerpointDocument(PresentationDocument):
|
|||
``slide_no``
|
||||
The slide the notes are required for, starting at 1.
|
||||
"""
|
||||
return _get_text_from_shapes(
|
||||
self.presentation.Slides(slide_no).NotesPage.Shapes)
|
||||
return _get_text_from_shapes(self.presentation.Slides(slide_no).NotesPage.Shapes)
|
||||
|
||||
def _get_text_from_shapes(shapes):
|
||||
"""
|
||||
|
|
|
@ -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,7 +40,7 @@ log = logging.getLogger(__name__)
|
|||
|
||||
class PptviewController(PresentationController):
|
||||
"""
|
||||
Class to control interactions with PowerPOint Viewer Presentations
|
||||
Class to control interactions with PowerPoint Viewer Presentations
|
||||
It creates the runtime Environment , Loads the and Closes the Presentation
|
||||
As well as triggering the correct activities based on the users input
|
||||
"""
|
||||
|
@ -52,8 +52,7 @@ class PptviewController(PresentationController):
|
|||
"""
|
||||
log.debug(u'Initialising')
|
||||
self.process = None
|
||||
PresentationController.__init__(self, plugin, u'Powerpoint Viewer',
|
||||
PptviewDocument)
|
||||
PresentationController.__init__(self, plugin, u'Powerpoint Viewer', PptviewDocument)
|
||||
self.supports = [u'ppt', u'pps', u'pptx', u'ppsx']
|
||||
|
||||
def check_available(self):
|
||||
|
@ -84,8 +83,8 @@ class PptviewController(PresentationController):
|
|||
if self.process:
|
||||
return
|
||||
log.debug(u'start PPTView')
|
||||
dllpath = os.path.join(self.plugin.pluginManager.basepath,
|
||||
u'presentations', u'lib', u'pptviewlib', u'pptviewlib.dll')
|
||||
dllpath = os.path.join(self.plugin.pluginManager.basepath, u'presentations', u'lib', u'pptviewlib',
|
||||
u'pptviewlib.dll')
|
||||
self.process = cdll.LoadLibrary(dllpath)
|
||||
if log.isEnabledFor(logging.DEBUG):
|
||||
self.process.SetDebug(1)
|
||||
|
@ -117,7 +116,7 @@ class PptviewDocument(PresentationDocument):
|
|||
def load_presentation(self):
|
||||
"""
|
||||
Called when a presentation is added to the SlideController.
|
||||
It builds the environment, starts communcations with the background
|
||||
It builds the environment, starts communication with the background
|
||||
PptView task started earlier.
|
||||
"""
|
||||
log.debug(u'LoadPresentation')
|
||||
|
@ -127,8 +126,7 @@ class PptviewDocument(PresentationDocument):
|
|||
filepath = str(self.filepath.replace(u'/', u'\\'))
|
||||
if not os.path.isdir(self.get_temp_folder()):
|
||||
os.makedirs(self.get_temp_folder())
|
||||
self.pptid = self.controller.process.OpenPPT(filepath, None, rect,
|
||||
str(self.get_temp_folder()) + '\\slide')
|
||||
self.pptid = self.controller.process.OpenPPT(filepath, None, rect, str(self.get_temp_folder()) + '\\slide')
|
||||
if self.pptid >= 0:
|
||||
self.create_thumbnails()
|
||||
self.stop_presentation()
|
||||
|
@ -146,14 +144,13 @@ class PptviewDocument(PresentationDocument):
|
|||
return
|
||||
log.debug(u'create_thumbnails proceeding')
|
||||
for idx in range(self.get_slide_count()):
|
||||
path = u'%s\\slide%s.bmp' % (self.get_temp_folder(),
|
||||
unicode(idx + 1))
|
||||
path = u'%s\\slide%s.bmp' % (self.get_temp_folder(), unicode(idx + 1))
|
||||
self.convert_thumbnail(path, idx + 1)
|
||||
|
||||
def close_presentation(self):
|
||||
"""
|
||||
Close presentation and clean up objects
|
||||
Triggerent by new object being added to SlideController orOpenLP
|
||||
Triggered by new object being added to SlideController orOpenLP
|
||||
being shut down
|
||||
"""
|
||||
log.debug(u'ClosePresentation')
|
||||
|
@ -187,7 +184,7 @@ class PptviewDocument(PresentationDocument):
|
|||
|
||||
def unblank_screen(self):
|
||||
"""
|
||||
Unblanks (restores) the presentationn
|
||||
Unblanks (restores) the presentation
|
||||
"""
|
||||
self.controller.process.Unblank(self.pptid)
|
||||
self.blanked = False
|
||||
|
|
|
@ -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,7 @@ import shutil
|
|||
|
||||
from PyQt4 import QtCore
|
||||
|
||||
from openlp.core.lib import Receiver, check_directory_exists, create_thumb, \
|
||||
validate_thumb, Settings
|
||||
from openlp.core.lib import Receiver, check_directory_exists, create_thumb, validate_thumb, Settings
|
||||
from openlp.core.utils import AppLocation
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
|
@ -124,7 +123,7 @@ class PresentationDocument(object):
|
|||
|
||||
def get_file_name(self):
|
||||
"""
|
||||
Return just the filename of the presention, without the directory
|
||||
Return just the filename of the presentation, without the directory
|
||||
"""
|
||||
return os.path.split(self.filepath)[1]
|
||||
|
||||
|
@ -179,7 +178,7 @@ class PresentationDocument(object):
|
|||
|
||||
def unblank_screen(self):
|
||||
"""
|
||||
Unblanks (restores) the presentationn
|
||||
Unblanks (restores) the presentation
|
||||
"""
|
||||
pass
|
||||
|
||||
|
@ -275,8 +274,7 @@ class PresentationDocument(object):
|
|||
prefix = u'live'
|
||||
else:
|
||||
prefix = u'preview'
|
||||
Receiver.send_message(u'slidecontroller_%s_change' % prefix,
|
||||
self.slidenumber - 1)
|
||||
Receiver.send_message(u'slidecontroller_%s_change' % prefix, self.slidenumber - 1)
|
||||
|
||||
def get_slide_text(self, slide_no):
|
||||
"""
|
||||
|
@ -379,11 +377,8 @@ class PresentationController(object):
|
|||
self.document_class = document_class
|
||||
self.settings_section = self.plugin.settingsSection
|
||||
self.available = None
|
||||
self.temp_folder = os.path.join(
|
||||
AppLocation.get_section_data_path(self.settings_section), name)
|
||||
self.thumbnail_folder = os.path.join(
|
||||
AppLocation.get_section_data_path(self.settings_section),
|
||||
u'thumbnails')
|
||||
self.temp_folder = os.path.join(AppLocation.get_section_data_path(self.settings_section), name)
|
||||
self.thumbnail_folder = os.path.join(AppLocation.get_section_data_path(self.settings_section), u'thumbnails')
|
||||
self.thumbnail_prefix = u'slide'
|
||||
check_directory_exists(self.thumbnail_folder)
|
||||
check_directory_exists(self.temp_folder)
|
||||
|
@ -392,8 +387,7 @@ class PresentationController(object):
|
|||
"""
|
||||
Return whether the controller is currently enabled
|
||||
"""
|
||||
if Settings().value(self.settings_section + u'/' + self.name,
|
||||
QtCore.Qt.Checked) == QtCore.Qt.Checked:
|
||||
if Settings().value(self.settings_section + u'/' + self.name, QtCore.Qt.Checked) == QtCore.Qt.Checked:
|
||||
return self.is_available()
|
||||
else:
|
||||
return False
|
||||
|
|
|
@ -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,25 +78,21 @@ class PresentationTab(SettingsTab):
|
|||
"""
|
||||
Make any translation changes
|
||||
"""
|
||||
self.ControllersGroupBox.setTitle(
|
||||
translate('PresentationPlugin.PresentationTab',
|
||||
'Available Controllers'))
|
||||
self.ControllersGroupBox.setTitle(translate('PresentationPlugin.PresentationTab', 'Available Controllers'))
|
||||
for key in self.controllers:
|
||||
controller = self.controllers[key]
|
||||
checkbox = self.PresenterCheckboxes[controller.name]
|
||||
self.setControllerText(checkbox, controller)
|
||||
self.AdvancedGroupBox.setTitle(UiStrings().Advanced)
|
||||
self.OverrideAppCheckBox.setText(
|
||||
translate('PresentationPlugin.PresentationTab',
|
||||
'Allow presentation application to be overridden'))
|
||||
translate('PresentationPlugin.PresentationTab', 'Allow presentation application to be overridden'))
|
||||
|
||||
def setControllerText(self, checkbox, controller):
|
||||
if checkbox.isEnabled():
|
||||
checkbox.setText(controller.name)
|
||||
else:
|
||||
checkbox.setText(
|
||||
translate('PresentationPlugin.PresentationTab',
|
||||
'%s (unavailable)') % controller.name)
|
||||
translate('PresentationPlugin.PresentationTab', '%s (unavailable)') % controller.name)
|
||||
|
||||
def load(self):
|
||||
"""
|
||||
|
@ -105,11 +101,9 @@ class PresentationTab(SettingsTab):
|
|||
for key in self.controllers:
|
||||
controller = self.controllers[key]
|
||||
checkbox = self.PresenterCheckboxes[controller.name]
|
||||
checkbox.setChecked(Settings().value(
|
||||
self.settingsSection + u'/' + controller.name,
|
||||
QtCore.Qt.Checked))
|
||||
self.OverrideAppCheckBox.setChecked(Settings().value(
|
||||
self.settingsSection + u'/override app', QtCore.Qt.Unchecked))
|
||||
checkbox.setChecked(Settings().value(self.settingsSection + u'/' + controller.name, QtCore.Qt.Checked))
|
||||
self.OverrideAppCheckBox.setChecked(Settings().value(self.settingsSection + u'/override app',
|
||||
QtCore.Qt.Unchecked))
|
||||
|
||||
def save(self):
|
||||
"""
|
||||
|
@ -125,8 +119,7 @@ class PresentationTab(SettingsTab):
|
|||
if controller.is_available():
|
||||
checkbox = self.PresenterCheckboxes[controller.name]
|
||||
setting_key = self.settingsSection + u'/' + controller.name
|
||||
if Settings().value(setting_key, QtCore.Qt.Checked) != \
|
||||
checkbox.checkState():
|
||||
if Settings().value(setting_key, QtCore.Qt.Checked) != checkbox.checkState():
|
||||
changed = True
|
||||
Settings().setValue(setting_key, checkbox.checkState())
|
||||
if checkbox.isChecked():
|
||||
|
@ -134,10 +127,8 @@ class PresentationTab(SettingsTab):
|
|||
else:
|
||||
controller.kill()
|
||||
setting_key = self.settingsSection + u'/override app'
|
||||
if Settings().value(setting_key, QtCore.Qt.Checked) != \
|
||||
self.OverrideAppCheckBox.checkState():
|
||||
Settings().setValue(setting_key,
|
||||
self.OverrideAppCheckBox.checkState())
|
||||
if Settings().value(setting_key, QtCore.Qt.Checked) != self.OverrideAppCheckBox.checkState():
|
||||
Settings().setValue(setting_key, self.OverrideAppCheckBox.checkState())
|
||||
changed = True
|
||||
if changed:
|
||||
self.parent.resetSupportedSuffixes()
|
||||
|
|
|
@ -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 #
|
||||
|
@ -64,8 +64,7 @@ class PresentationPlugin(Plugin):
|
|||
Create the settings Tab
|
||||
"""
|
||||
visible_name = self.getString(StringContent.VisibleName)
|
||||
self.settingsTab = PresentationTab(parent, self.name,
|
||||
visible_name[u'title'], self.controllers, self.iconPath)
|
||||
self.settingsTab = PresentationTab(parent, self.name, visible_name[u'title'], self.controllers, self.iconPath)
|
||||
|
||||
def initialise(self):
|
||||
"""
|
||||
|
@ -120,12 +119,10 @@ class PresentationPlugin(Plugin):
|
|||
AppLocation.get_directory(AppLocation.PluginsDir),
|
||||
u'presentations', u'lib')
|
||||
for filename in os.listdir(controller_dir):
|
||||
if filename.endswith(u'controller.py') and \
|
||||
not filename == 'presentationcontroller.py':
|
||||
if filename.endswith(u'controller.py') and not filename == 'presentationcontroller.py':
|
||||
path = os.path.join(controller_dir, filename)
|
||||
if os.path.isfile(path):
|
||||
modulename = u'openlp.plugins.presentations.lib.' + \
|
||||
os.path.splitext(filename)[0]
|
||||
modulename = u'openlp.plugins.presentations.lib.' + os.path.splitext(filename)[0]
|
||||
log.debug(u'Importing controller %s', modulename)
|
||||
try:
|
||||
__import__(modulename, globals(), locals(), [])
|
||||
|
@ -155,30 +152,22 @@ class PresentationPlugin(Plugin):
|
|||
"""
|
||||
## Name PluginList ##
|
||||
self.textStrings[StringContent.Name] = {
|
||||
u'singular': translate('PresentationPlugin', 'Presentation',
|
||||
'name singular'),
|
||||
u'plural': translate('PresentationPlugin', 'Presentations',
|
||||
'name plural')
|
||||
u'singular': translate('PresentationPlugin', 'Presentation', 'name singular'),
|
||||
u'plural': translate('PresentationPlugin', 'Presentations', 'name plural')
|
||||
}
|
||||
## Name for MediaDockManager, SettingsManager ##
|
||||
self.textStrings[StringContent.VisibleName] = {
|
||||
u'title': translate('PresentationPlugin', 'Presentations',
|
||||
'container title')
|
||||
u'title': translate('PresentationPlugin', 'Presentations', 'container title')
|
||||
}
|
||||
# Middle Header Bar
|
||||
tooltips = {
|
||||
u'load': translate('PresentationPlugin',
|
||||
'Load a new presentation.'),
|
||||
u'load': translate('PresentationPlugin', 'Load a new presentation.'),
|
||||
u'import': u'',
|
||||
u'new': u'',
|
||||
u'edit': u'',
|
||||
u'delete': translate('PresentationPlugin',
|
||||
'Delete the selected presentation.'),
|
||||
u'preview': translate('PresentationPlugin',
|
||||
'Preview the selected presentation.'),
|
||||
u'live': translate('PresentationPlugin',
|
||||
'Send the selected presentation live.'),
|
||||
u'service': translate('PresentationPlugin',
|
||||
'Add the selected presentation to the service.')
|
||||
u'delete': translate('PresentationPlugin', 'Delete the selected presentation.'),
|
||||
u'preview': translate('PresentationPlugin', 'Preview the selected presentation.'),
|
||||
u'live': translate('PresentationPlugin', 'Send the selected presentation live.'),
|
||||
u'service': translate('PresentationPlugin', 'Add the selected presentation to the service.')
|
||||
}
|
||||
self.setPluginUiTextStrings(tooltips)
|
||||
|
|
|
@ -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 #
|
||||
|
|
|
@ -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 #
|
||||
|
@ -156,9 +156,7 @@ class HttpServer(object):
|
|||
"""
|
||||
log.debug(u'Initialise httpserver')
|
||||
self.plugin = plugin
|
||||
self.html_dir = os.path.join(
|
||||
AppLocation.get_directory(AppLocation.PluginsDir),
|
||||
u'remotes', u'html')
|
||||
self.html_dir = os.path.join(AppLocation.get_directory(AppLocation.PluginsDir), u'remotes', u'html')
|
||||
self.connections = []
|
||||
self.current_item = None
|
||||
self.current_slide = None
|
||||
|
@ -171,20 +169,15 @@ class HttpServer(object):
|
|||
clients. Listen out for socket connections.
|
||||
"""
|
||||
log.debug(u'Start TCP server')
|
||||
port = Settings().value(
|
||||
self.plugin.settingsSection + u'/port', 4316)
|
||||
address = Settings().value(
|
||||
self.plugin.settingsSection + u'/ip address', u'0.0.0.0')
|
||||
port = Settings().value(self.plugin.settingsSection + u'/port', 4316)
|
||||
address = Settings().value(self.plugin.settingsSection + u'/ip address', u'0.0.0.0')
|
||||
self.server = QtNetwork.QTcpServer()
|
||||
self.server.listen(QtNetwork.QHostAddress(address), port)
|
||||
QtCore.QObject.connect(Receiver.get_receiver(),
|
||||
QtCore.SIGNAL(u'slidecontroller_live_changed'),
|
||||
QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'slidecontroller_live_changed'),
|
||||
self.slide_change)
|
||||
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.item_change)
|
||||
QtCore.QObject.connect(self.server,
|
||||
QtCore.SIGNAL(u'newConnection()'), self.new_connection)
|
||||
QtCore.QObject.connect(self.server, QtCore.SIGNAL(u'newConnection()'), self.new_connection)
|
||||
log.debug(u'TCP listening on port %d' % port)
|
||||
|
||||
def slide_change(self, row):
|
||||
|
@ -234,8 +227,7 @@ class HttpConnection(object):
|
|||
"""
|
||||
Initialise the http connection. Listen out for socket signals.
|
||||
"""
|
||||
log.debug(u'Initialise HttpConnection: %s' %
|
||||
socket.peerAddress())
|
||||
log.debug(u'Initialise HttpConnection: %s' % socket.peerAddress())
|
||||
self.socket = socket
|
||||
self.parent = parent
|
||||
self.routes = [
|
||||
|
@ -252,10 +244,8 @@ class HttpConnection(object):
|
|||
(r'^/api/(.*)/live$', self.go_live),
|
||||
(r'^/api/(.*)/add$', self.add_to_service)
|
||||
]
|
||||
QtCore.QObject.connect(self.socket, QtCore.SIGNAL(u'readyRead()'),
|
||||
self.ready_read)
|
||||
QtCore.QObject.connect(self.socket, QtCore.SIGNAL(u'disconnected()'),
|
||||
self.disconnected)
|
||||
QtCore.QObject.connect(self.socket, QtCore.SIGNAL(u'readyRead()'), self.ready_read)
|
||||
QtCore.QObject.connect(self.socket, QtCore.SIGNAL(u'disconnected()'), self.disconnected)
|
||||
self.translate()
|
||||
|
||||
def _get_service_items(self):
|
||||
|
@ -281,13 +271,10 @@ class HttpConnection(object):
|
|||
Translate various strings in the mobile app.
|
||||
"""
|
||||
self.template_vars = {
|
||||
'app_title': translate('RemotePlugin.Mobile', 'OpenLP 2.0 Remote'),
|
||||
'stage_title': translate('RemotePlugin.Mobile',
|
||||
'OpenLP 2.0 Stage View'),
|
||||
'service_manager': translate('RemotePlugin.Mobile',
|
||||
'Service Manager'),
|
||||
'slide_controller': translate('RemotePlugin.Mobile',
|
||||
'Slide Controller'),
|
||||
'app_title': translate('RemotePlugin.Mobile', 'OpenLP 2.1 Remote'),
|
||||
'stage_title': translate('RemotePlugin.Mobile', 'OpenLP 2.1 Stage View'),
|
||||
'service_manager': translate('RemotePlugin.Mobile', 'Service Manager'),
|
||||
'slide_controller': translate('RemotePlugin.Mobile', 'Slide Controller'),
|
||||
'alerts': translate('RemotePlugin.Mobile', 'Alerts'),
|
||||
'search': translate('RemotePlugin.Mobile', 'Search'),
|
||||
'home': translate('RemotePlugin.Mobile', 'Home'),
|
||||
|
@ -301,10 +288,8 @@ class HttpConnection(object):
|
|||
'text': translate('RemotePlugin.Mobile', 'Text'),
|
||||
'show_alert': translate('RemotePlugin.Mobile', 'Show Alert'),
|
||||
'go_live': translate('RemotePlugin.Mobile', 'Go Live'),
|
||||
'add_to_service': translate('RemotePlugin.Mobile',
|
||||
'Add to Service'),
|
||||
'add_and_go_to_service': translate('RemotePlugin.Mobile',
|
||||
'Add & Go to Service'),
|
||||
'add_to_service': translate('RemotePlugin.Mobile', 'Add to Service'),
|
||||
'add_and_go_to_service': translate('RemotePlugin.Mobile', 'Add & Go to Service'),
|
||||
'no_results': translate('RemotePlugin.Mobile', 'No Results'),
|
||||
'options': translate('RemotePlugin.Mobile', 'Options'),
|
||||
'service': translate('RemotePlugin.Mobile', 'Service'),
|
||||
|
@ -367,8 +352,7 @@ class HttpConnection(object):
|
|||
if ext == u'.html':
|
||||
mimetype = u'text/html'
|
||||
variables = self.template_vars
|
||||
html = Template(filename=path, input_encoding=u'utf-8',
|
||||
output_encoding=u'utf-8').render(**variables)
|
||||
html = Template(filename=path, input_encoding=u'utf-8', output_encoding=u'utf-8').render(**variables)
|
||||
elif ext == u'.css':
|
||||
mimetype = u'text/css'
|
||||
elif ext == u'.js':
|
||||
|
@ -404,13 +388,11 @@ class HttpConnection(object):
|
|||
result = {
|
||||
u'service': self.parent.plugin.serviceManager.serviceId,
|
||||
u'slide': self.parent.current_slide or 0,
|
||||
u'item': self.parent.current_item._uuid \
|
||||
if self.parent.current_item else u'',
|
||||
u'item': self.parent.current_item._uuid if self.parent.current_item else u'',
|
||||
u'twelve':Settings().value(u'remotes/twelve hour', True),
|
||||
u'blank': self.parent.plugin.liveController.blankScreen.isChecked(),
|
||||
u'theme': self.parent.plugin.liveController.themeScreen.isChecked(),
|
||||
u'display': \
|
||||
self.parent.plugin.liveController.desktopScreen.isChecked()
|
||||
u'display': self.parent.plugin.liveController.desktopScreen.isChecked()
|
||||
}
|
||||
return HttpResponse(json.dumps({u'results': result}),
|
||||
{u'Content-Type': u'application/json'})
|
||||
|
@ -433,8 +415,7 @@ class HttpConnection(object):
|
|||
plugin = self.parent.plugin.pluginManager.get_plugin_by_name("alerts")
|
||||
if plugin.status == PluginStatus.Active:
|
||||
try:
|
||||
text = json.loads(
|
||||
self.url_params[u'data'][0])[u'request'][u'text']
|
||||
text = json.loads(self.url_params[u'data'][0])[u'request'][u'text']
|
||||
except KeyError, ValueError:
|
||||
return HttpResponse(code=u'400 Bad Request')
|
||||
text = urllib.unquote(text)
|
||||
|
@ -498,8 +479,7 @@ class HttpConnection(object):
|
|||
def service(self, action):
|
||||
event = u'servicemanager_%s' % action
|
||||
if action == u'list':
|
||||
return HttpResponse(
|
||||
json.dumps({u'results': {u'items': self._get_service_items()}}),
|
||||
return HttpResponse(json.dumps({u'results': {u'items': self._get_service_items()}}),
|
||||
{u'Content-Type': u'application/json'})
|
||||
else:
|
||||
event += u'_item'
|
||||
|
@ -525,10 +505,8 @@ class HttpConnection(object):
|
|||
if action == u'search':
|
||||
searches = []
|
||||
for plugin in self.parent.plugin.pluginManager.plugins:
|
||||
if plugin.status == PluginStatus.Active and \
|
||||
plugin.mediaItem and plugin.mediaItem.hasSearch:
|
||||
searches.append([plugin.name, unicode(
|
||||
plugin.textStrings[StringContent.Name][u'plural'])])
|
||||
if plugin.status == PluginStatus.Active and plugin.mediaItem and plugin.mediaItem.hasSearch:
|
||||
searches.append([plugin.name, unicode(plugin.textStrings[StringContent.Name][u'plural'])])
|
||||
return HttpResponse(
|
||||
json.dumps({u'results': {u'items': searches}}),
|
||||
{u'Content-Type': u'application/json'})
|
||||
|
@ -546,13 +524,11 @@ class HttpConnection(object):
|
|||
return HttpResponse(code=u'400 Bad Request')
|
||||
text = urllib.unquote(text)
|
||||
plugin = self.parent.plugin.pluginManager.get_plugin_by_name(type)
|
||||
if plugin.status == PluginStatus.Active and \
|
||||
plugin.mediaItem and plugin.mediaItem.hasSearch:
|
||||
if plugin.status == PluginStatus.Active and plugin.mediaItem and plugin.mediaItem.hasSearch:
|
||||
results = plugin.mediaItem.search(text, False)
|
||||
else:
|
||||
results = []
|
||||
return HttpResponse(
|
||||
json.dumps({u'results': {u'items': results}}),
|
||||
return HttpResponse(json.dumps({u'results': {u'items': results}}),
|
||||
{u'Content-Type': u'application/json'})
|
||||
|
||||
def go_live(self, type):
|
||||
|
|
|
@ -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 #
|
||||
|
@ -45,19 +45,16 @@ class RemoteTab(SettingsTab):
|
|||
SettingsTab.setupUi(self)
|
||||
self.serverSettingsGroupBox = QtGui.QGroupBox(self.leftColumn)
|
||||
self.serverSettingsGroupBox.setObjectName(u'serverSettingsGroupBox')
|
||||
self.serverSettingsLayout = QtGui.QFormLayout(
|
||||
self.serverSettingsGroupBox)
|
||||
self.serverSettingsLayout = QtGui.QFormLayout(self.serverSettingsGroupBox)
|
||||
self.serverSettingsLayout.setObjectName(u'serverSettingsLayout')
|
||||
self.addressLabel = QtGui.QLabel(self.serverSettingsGroupBox)
|
||||
self.addressLabel.setObjectName(u'addressLabel')
|
||||
self.addressEdit = QtGui.QLineEdit(self.serverSettingsGroupBox)
|
||||
self.addressEdit.setSizePolicy(
|
||||
QtGui.QSizePolicy.Preferred, QtGui.QSizePolicy.Fixed)
|
||||
self.addressEdit.setSizePolicy(QtGui.QSizePolicy.Preferred, QtGui.QSizePolicy.Fixed)
|
||||
self.addressEdit.setValidator(QtGui.QRegExpValidator(QtCore.QRegExp(
|
||||
u'\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}'), self))
|
||||
self.addressEdit.setObjectName(u'addressEdit')
|
||||
QtCore.QObject.connect(self.addressEdit,
|
||||
QtCore.SIGNAL(u'textChanged(const QString&)'), self.setUrls)
|
||||
QtCore.QObject.connect(self.addressEdit, QtCore.SIGNAL(u'textChanged(const QString&)'), self.setUrls)
|
||||
self.serverSettingsLayout.addRow(self.addressLabel, self.addressEdit)
|
||||
self.twelveHourCheckBox = QtGui.QCheckBox(self.serverSettingsGroupBox)
|
||||
self.twelveHourCheckBox.setObjectName(u'twelveHourCheckBox')
|
||||
|
@ -67,8 +64,7 @@ class RemoteTab(SettingsTab):
|
|||
self.portSpinBox = QtGui.QSpinBox(self.serverSettingsGroupBox)
|
||||
self.portSpinBox.setMaximum(32767)
|
||||
self.portSpinBox.setObjectName(u'portSpinBox')
|
||||
QtCore.QObject.connect(self.portSpinBox,
|
||||
QtCore.SIGNAL(u'valueChanged(int)'), self.setUrls)
|
||||
QtCore.QObject.connect(self.portSpinBox, QtCore.SIGNAL(u'valueChanged(int)'), self.setUrls)
|
||||
self.serverSettingsLayout.addRow(self.portLabel, self.portSpinBox)
|
||||
self.remoteUrlLabel = QtGui.QLabel(self.serverSettingsGroupBox)
|
||||
self.remoteUrlLabel.setObjectName(u'remoteUrlLabel')
|
||||
|
@ -89,8 +85,7 @@ class RemoteTab(SettingsTab):
|
|||
self.qrLayout = QtGui.QVBoxLayout(self.androidAppGroupBox)
|
||||
self.qrLayout.setObjectName(u'qrLayout')
|
||||
self.qrCodeLabel = QtGui.QLabel(self.androidAppGroupBox)
|
||||
self.qrCodeLabel.setPixmap(QtGui.QPixmap(
|
||||
u':/remotes/android_app_qr.png'))
|
||||
self.qrCodeLabel.setPixmap(QtGui.QPixmap(u':/remotes/android_app_qr.png'))
|
||||
self.qrCodeLabel.setAlignment(QtCore.Qt.AlignCenter)
|
||||
self.qrCodeLabel.setObjectName(u'qrCodeLabel')
|
||||
self.qrLayout.addWidget(self.qrCodeLabel)
|
||||
|
@ -101,26 +96,18 @@ class RemoteTab(SettingsTab):
|
|||
self.qrLayout.addWidget(self.qrDescriptionLabel)
|
||||
self.leftLayout.addStretch()
|
||||
self.rightLayout.addStretch()
|
||||
QtCore.QObject.connect(self.twelveHourCheckBox,
|
||||
QtCore.SIGNAL(u'stateChanged(int)'),
|
||||
QtCore.QObject.connect(self.twelveHourCheckBox, QtCore.SIGNAL(u'stateChanged(int)'),
|
||||
self.onTwelveHourCheckBoxChanged)
|
||||
|
||||
def retranslateUi(self):
|
||||
self.serverSettingsGroupBox.setTitle(
|
||||
translate('RemotePlugin.RemoteTab', 'Server Settings'))
|
||||
self.addressLabel.setText(translate('RemotePlugin.RemoteTab',
|
||||
'Serve on IP address:'))
|
||||
self.portLabel.setText(translate('RemotePlugin.RemoteTab',
|
||||
'Port number:'))
|
||||
self.remoteUrlLabel.setText(translate('RemotePlugin.RemoteTab',
|
||||
'Remote URL:'))
|
||||
self.stageUrlLabel.setText(translate('RemotePlugin.RemoteTab',
|
||||
'Stage view URL:'))
|
||||
self.twelveHourCheckBox.setText(
|
||||
translate('RemotePlugin.RemoteTab',
|
||||
'Display stage time in 12h format'))
|
||||
self.androidAppGroupBox.setTitle(
|
||||
translate('RemotePlugin.RemoteTab', 'Android App'))
|
||||
self.addressLabel.setText(translate('RemotePlugin.RemoteTab', 'Serve on IP address:'))
|
||||
self.portLabel.setText(translate('RemotePlugin.RemoteTab', 'Port number:'))
|
||||
self.remoteUrlLabel.setText(translate('RemotePlugin.RemoteTab', 'Remote URL:'))
|
||||
self.stageUrlLabel.setText(translate('RemotePlugin.RemoteTab', 'Stage view URL:'))
|
||||
self.twelveHourCheckBox.setText(translate('RemotePlugin.RemoteTab', 'Display stage time in 12h format'))
|
||||
self.androidAppGroupBox.setTitle(translate('RemotePlugin.RemoteTab', 'Android App'))
|
||||
self.qrDescriptionLabel.setText(translate('RemotePlugin.RemoteTab',
|
||||
'Scan the QR code or click <a href="https://play.google.com/store/'
|
||||
'apps/details?id=org.openlp.android">download</a> to install the '
|
||||
|
@ -133,13 +120,11 @@ class RemoteTab(SettingsTab):
|
|||
for iface in ifaces:
|
||||
if not iface.isValid():
|
||||
continue
|
||||
if not (iface.flags() & (QtNetwork.QNetworkInterface.IsUp |
|
||||
QtNetwork.QNetworkInterface.IsRunning)):
|
||||
if not (iface.flags() & (QtNetwork.QNetworkInterface.IsUp | QtNetwork.QNetworkInterface.IsRunning)):
|
||||
continue
|
||||
for addr in iface.addressEntries():
|
||||
ip = addr.ip()
|
||||
if ip.protocol() == 0 and \
|
||||
ip != QtNetwork.QHostAddress.LocalHost:
|
||||
if ip.protocol() == 0 and ip != QtNetwork.QHostAddress.LocalHost:
|
||||
ipAddress = ip
|
||||
break
|
||||
else:
|
||||
|
@ -150,27 +135,20 @@ class RemoteTab(SettingsTab):
|
|||
self.stageUrl.setText(u'<a href="%s">%s</a>' % (url, url))
|
||||
|
||||
def load(self):
|
||||
self.portSpinBox.setValue(
|
||||
Settings().value(self.settingsSection + u'/port', 4316))
|
||||
self.addressEdit.setText(
|
||||
Settings().value(self.settingsSection + u'/ip address', ZERO_URL))
|
||||
self.twelveHour = Settings().value(
|
||||
self.settingsSection + u'/twelve hour', True)
|
||||
self.portSpinBox.setValue(Settings().value(self.settingsSection + u'/port', 4316))
|
||||
self.addressEdit.setText(Settings().value(self.settingsSection + u'/ip address', ZERO_URL))
|
||||
self.twelveHour = Settings().value(self.settingsSection + u'/twelve hour', True)
|
||||
self.twelveHourCheckBox.setChecked(self.twelveHour)
|
||||
self.setUrls()
|
||||
|
||||
def save(self):
|
||||
changed = False
|
||||
if Settings().value(self.settingsSection + u'/ip address', ZERO_URL !=
|
||||
self.addressEdit.text() or Settings().value(self.settingsSection +
|
||||
u'/port', 4316) != self.portSpinBox.value()):
|
||||
if Settings().value(self.settingsSection + u'/ip address', ZERO_URL != self.addressEdit.text() or
|
||||
Settings().value(self.settingsSection + u'/port', 4316) != self.portSpinBox.value()):
|
||||
changed = True
|
||||
Settings().setValue(self.settingsSection + u'/port',
|
||||
self.portSpinBox.value())
|
||||
Settings().setValue(self.settingsSection + u'/ip address',
|
||||
self.addressEdit.text())
|
||||
Settings().setValue(self.settingsSection + u'/twelve hour',
|
||||
self.twelveHour)
|
||||
Settings().setValue(self.settingsSection + u'/port', self.portSpinBox.value())
|
||||
Settings().setValue(self.settingsSection + u'/ip address', self.addressEdit.text())
|
||||
Settings().setValue(self.settingsSection + u'/twelve hour', self.twelveHour)
|
||||
if changed:
|
||||
Receiver.send_message(u'remotes_config_updated')
|
||||
|
||||
|
|
|
@ -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 #
|
||||
|
@ -41,8 +41,7 @@ class RemotesPlugin(Plugin):
|
|||
"""
|
||||
remotes constructor
|
||||
"""
|
||||
Plugin.__init__(self, u'remotes', plugin_helpers,
|
||||
settings_tab_class=RemoteTab)
|
||||
Plugin.__init__(self, u'remotes', plugin_helpers, settings_tab_class=RemoteTab)
|
||||
self.iconPath = u':/plugins/plugin_remote.png'
|
||||
self.icon = build_icon(self.iconPath)
|
||||
self.weight = -1
|
||||
|
|
|
@ -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 #
|
||||
|
|
|
@ -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 #
|
||||
|
|
|
@ -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 #
|
||||
|
@ -59,18 +59,13 @@ class Ui_AuthorsDialog(object):
|
|||
self.displayLabel.setBuddy(self.displayEdit)
|
||||
self.authorLayout.addRow(self.displayLabel, self.displayEdit)
|
||||
self.dialogLayout.addLayout(self.authorLayout)
|
||||
self.buttonBox = create_button_box(authorsDialog, u'buttonBox',
|
||||
[u'cancel', u'save'])
|
||||
self.buttonBox = create_button_box(authorsDialog, u'buttonBox', [u'cancel', u'save'])
|
||||
self.dialogLayout.addWidget(self.buttonBox)
|
||||
self.retranslateUi(authorsDialog)
|
||||
authorsDialog.setMaximumHeight(authorsDialog.sizeHint().height())
|
||||
|
||||
def retranslateUi(self, authorsDialog):
|
||||
authorsDialog.setWindowTitle(
|
||||
translate('SongsPlugin.AuthorsForm', 'Author Maintenance'))
|
||||
self.displayLabel.setText(
|
||||
translate('SongsPlugin.AuthorsForm', 'Display name:'))
|
||||
self.firstNameLabel.setText(
|
||||
translate('SongsPlugin.AuthorsForm', 'First name:'))
|
||||
self.lastNameLabel.setText(
|
||||
translate('SongsPlugin.AuthorsForm', 'Last name:'))
|
||||
authorsDialog.setWindowTitle(translate('SongsPlugin.AuthorsForm', 'Author Maintenance'))
|
||||
self.displayLabel.setText(translate('SongsPlugin.AuthorsForm', 'Display name:'))
|
||||
self.firstNameLabel.setText(translate('SongsPlugin.AuthorsForm', 'First name:'))
|
||||
self.lastNameLabel.setText(translate('SongsPlugin.AuthorsForm', 'Last name:'))
|
||||
|
|
|
@ -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,11 +44,9 @@ class AuthorsForm(QtGui.QDialog, Ui_AuthorsDialog):
|
|||
QtGui.QDialog.__init__(self, parent)
|
||||
self.setupUi(self)
|
||||
self._autoDisplayName = False
|
||||
QtCore.QObject.connect(self.firstNameEdit,
|
||||
QtCore.SIGNAL(u'textEdited(QString)'),
|
||||
QtCore.QObject.connect(self.firstNameEdit, QtCore.SIGNAL(u'textEdited(QString)'),
|
||||
self.onFirstNameEditTextEdited)
|
||||
QtCore.QObject.connect(self.lastNameEdit,
|
||||
QtCore.SIGNAL(u'textEdited(QString)'),
|
||||
QtCore.QObject.connect(self.lastNameEdit, QtCore.SIGNAL(u'textEdited(QString)'),
|
||||
self.onLastNameEditTextEdited)
|
||||
|
||||
def exec_(self, clear=True):
|
||||
|
@ -82,24 +80,20 @@ class AuthorsForm(QtGui.QDialog, Ui_AuthorsDialog):
|
|||
def accept(self):
|
||||
if not self.firstNameEdit.text():
|
||||
critical_error_message_box(
|
||||
message=translate('SongsPlugin.AuthorsForm',
|
||||
'You need to type in the first name of the author.'))
|
||||
message=translate('SongsPlugin.AuthorsForm', 'You need to type in the first name of the author.'))
|
||||
self.firstNameEdit.setFocus()
|
||||
return False
|
||||
elif not self.lastNameEdit.text():
|
||||
critical_error_message_box(
|
||||
message=translate('SongsPlugin.AuthorsForm',
|
||||
'You need to type in the last name of the author.'))
|
||||
message=translate('SongsPlugin.AuthorsForm', 'You need to type in the last name of the author.'))
|
||||
self.lastNameEdit.setFocus()
|
||||
return False
|
||||
elif not self.displayEdit.text():
|
||||
if critical_error_message_box(
|
||||
message=translate('SongsPlugin.AuthorsForm',
|
||||
'You have not set a display name for the '
|
||||
'author, combine the first and last names?'),
|
||||
'You have not set a display name for the author, combine the first and last names?'),
|
||||
parent=self, question=True) == QtGui.QMessageBox.Yes:
|
||||
self.displayEdit.setText(self.firstNameEdit.text() + \
|
||||
u' ' + self.lastNameEdit.text())
|
||||
self.displayEdit.setText(self.firstNameEdit.text() + u' ' + self.lastNameEdit.text())
|
||||
return QtGui.QDialog.accept(self)
|
||||
else:
|
||||
self.displayEdit.setFocus()
|
||||
|
|
|
@ -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 #
|
||||
|
@ -37,8 +37,7 @@ class Ui_EditSongDialog(object):
|
|||
def setupUi(self, editSongDialog):
|
||||
editSongDialog.setObjectName(u'editSongDialog')
|
||||
editSongDialog.resize(650, 400)
|
||||
editSongDialog.setWindowIcon(
|
||||
build_icon(u':/icon/openlp-logo-16x16.png'))
|
||||
editSongDialog.setWindowIcon(build_icon(u':/icon/openlp-logo-16x16.png'))
|
||||
editSongDialog.setModal(True)
|
||||
self.dialogLayout = QtGui.QVBoxLayout(editSongDialog)
|
||||
self.dialogLayout.setSpacing(8)
|
||||
|
@ -68,16 +67,12 @@ class Ui_EditSongDialog(object):
|
|||
self.lyricsLabel = QtGui.QLabel(self.lyricsTab)
|
||||
self.lyricsLabel.setFixedHeight(self.titleEdit.sizeHint().height())
|
||||
self.lyricsLabel.setObjectName(u'lyricsLabel')
|
||||
self.lyricsTabLayout.addWidget(self.lyricsLabel, 2, 0,
|
||||
QtCore.Qt.AlignTop)
|
||||
self.lyricsTabLayout.addWidget(self.lyricsLabel, 2, 0, QtCore.Qt.AlignTop)
|
||||
self.verseListWidget = SingleColumnTableWidget(self.lyricsTab)
|
||||
self.verseListWidget.setAlternatingRowColors(True)
|
||||
self.verseListWidget.setSelectionBehavior(
|
||||
QtGui.QAbstractItemView.SelectRows)
|
||||
self.verseListWidget.setSelectionMode(
|
||||
QtGui.QAbstractItemView.SingleSelection)
|
||||
self.verseListWidget.setEditTriggers(
|
||||
QtGui.QAbstractItemView.NoEditTriggers)
|
||||
self.verseListWidget.setSelectionBehavior(QtGui.QAbstractItemView.SelectRows)
|
||||
self.verseListWidget.setSelectionMode(QtGui.QAbstractItemView.SingleSelection)
|
||||
self.verseListWidget.setEditTriggers(QtGui.QAbstractItemView.NoEditTriggers)
|
||||
self.verseListWidget.setObjectName(u'verseListWidget')
|
||||
self.lyricsLabel.setBuddy(self.verseListWidget)
|
||||
self.lyricsTabLayout.addWidget(self.verseListWidget, 2, 1)
|
||||
|
@ -118,8 +113,7 @@ class Ui_EditSongDialog(object):
|
|||
self.authorsLayout.setObjectName(u'authorsLayout')
|
||||
self.authorAddLayout = QtGui.QHBoxLayout()
|
||||
self.authorAddLayout.setObjectName(u'authorAddLayout')
|
||||
self.authorsComboBox = editSongDialogComboBox(
|
||||
self.authorsGroupBox, u'authorsComboBox')
|
||||
self.authorsComboBox = editSongDialogComboBox(self.authorsGroupBox, u'authorsComboBox')
|
||||
self.authorAddLayout.addWidget(self.authorsComboBox)
|
||||
self.authorAddButton = QtGui.QPushButton(self.authorsGroupBox)
|
||||
self.authorAddButton.setObjectName(u'authorAddButton')
|
||||
|
@ -153,8 +147,7 @@ class Ui_EditSongDialog(object):
|
|||
self.topicsLayout.setObjectName(u'topicsLayout')
|
||||
self.topicAddLayout = QtGui.QHBoxLayout()
|
||||
self.topicAddLayout.setObjectName(u'topicAddLayout')
|
||||
self.topicsComboBox = editSongDialogComboBox(
|
||||
self.topicsGroupBox, u'topicsComboBox')
|
||||
self.topicsComboBox = editSongDialogComboBox(self.topicsGroupBox, u'topicsComboBox')
|
||||
self.topicAddLayout.addWidget(self.topicsComboBox)
|
||||
self.topicAddButton = QtGui.QPushButton(self.topicsGroupBox)
|
||||
self.topicAddButton.setObjectName(u'topicAddButton')
|
||||
|
@ -178,18 +171,15 @@ class Ui_EditSongDialog(object):
|
|||
self.songBookLayout.setObjectName(u'songBookLayout')
|
||||
self.songBookNameLabel = QtGui.QLabel(self.songBookGroupBox)
|
||||
self.songBookNameLabel.setObjectName(u'songBookNameLabel')
|
||||
self.songBookComboBox = editSongDialogComboBox(
|
||||
self.songBookGroupBox, u'songBookComboBox')
|
||||
self.songBookComboBox = editSongDialogComboBox(self.songBookGroupBox, u'songBookComboBox')
|
||||
self.songBookNameLabel.setBuddy(self.songBookComboBox)
|
||||
self.songBookLayout.addRow(self.songBookNameLabel,
|
||||
self.songBookComboBox)
|
||||
self.songBookLayout.addRow(self.songBookNameLabel, self.songBookComboBox)
|
||||
self.songBookNumberLabel = QtGui.QLabel(self.songBookGroupBox)
|
||||
self.songBookNumberLabel.setObjectName(u'songBookNumberLabel')
|
||||
self.songBookNumberEdit = QtGui.QLineEdit(self.songBookGroupBox)
|
||||
self.songBookNumberEdit.setObjectName(u'songBookNumberEdit')
|
||||
self.songBookNumberLabel.setBuddy(self.songBookNumberEdit)
|
||||
self.songBookLayout.addRow(self.songBookNumberLabel,
|
||||
self.songBookNumberEdit)
|
||||
self.songBookLayout.addRow(self.songBookNumberLabel, self.songBookNumberEdit)
|
||||
self.authorsRightLayout.addWidget(self.songBookGroupBox)
|
||||
self.authorsTabLayout.addLayout(self.authorsRightLayout)
|
||||
self.songTabWidget.addTab(self.authorsTab, u'')
|
||||
|
@ -204,8 +194,7 @@ class Ui_EditSongDialog(object):
|
|||
self.themeGroupBox.setObjectName(u'themeGroupBox')
|
||||
self.themeLayout = QtGui.QHBoxLayout(self.themeGroupBox)
|
||||
self.themeLayout.setObjectName(u'themeLayout')
|
||||
self.themeComboBox = editSongDialogComboBox(
|
||||
self.themeGroupBox, u'themeComboBox')
|
||||
self.themeComboBox = editSongDialogComboBox(self.themeGroupBox, u'themeComboBox')
|
||||
self.themeLayout.addWidget(self.themeComboBox)
|
||||
self.themeAddButton = QtGui.QPushButton(self.themeGroupBox)
|
||||
self.themeAddButton.setObjectName(u'themeAddButton')
|
||||
|
@ -269,10 +258,8 @@ class Ui_EditSongDialog(object):
|
|||
self.audioRemoveAllButton.setObjectName(u'audioRemoveAllButton')
|
||||
self.audioButtonsLayout.addWidget(self.audioRemoveAllButton)
|
||||
self.audioButtonsLayout.addStretch(1)
|
||||
self.upButton = create_button(self, u'upButton', role=u'up',
|
||||
click=self.onUpButtonClicked)
|
||||
self.downButton = create_button(self, u'downButton', role=u'down',
|
||||
click=self.onDownButtonClicked)
|
||||
self.upButton = create_button(self, u'upButton', role=u'up', click=self.onUpButtonClicked)
|
||||
self.downButton = create_button(self, u'downButton', role=u'down', click=self.onDownButtonClicked)
|
||||
self.audioButtonsLayout.addWidget(self.upButton)
|
||||
self.audioButtonsLayout.addWidget(self.downButton)
|
||||
self.audioLayout.addLayout(self.audioButtonsLayout)
|
||||
|
@ -285,89 +272,59 @@ class Ui_EditSongDialog(object):
|
|||
self.warningLabel.setObjectName(u'warningLabel')
|
||||
self.warningLabel.setVisible(False)
|
||||
self.bottomLayout.addWidget(self.warningLabel)
|
||||
self.buttonBox = create_button_box(editSongDialog, u'buttonBox',
|
||||
[u'cancel', u'save'])
|
||||
self.buttonBox = create_button_box(editSongDialog, u'buttonBox', [u'cancel', u'save'])
|
||||
self.bottomLayout.addWidget(self.buttonBox)
|
||||
self.dialogLayout.addLayout(self.bottomLayout)
|
||||
self.retranslateUi(editSongDialog)
|
||||
|
||||
def retranslateUi(self, editSongDialog):
|
||||
editSongDialog.setWindowTitle(
|
||||
translate('SongsPlugin.EditSongForm', 'Song Editor'))
|
||||
self.titleLabel.setText(
|
||||
translate('SongsPlugin.EditSongForm', '&Title:'))
|
||||
self.alternativeTitleLabel.setText(
|
||||
translate('SongsPlugin.EditSongForm', 'Alt&ernate title:'))
|
||||
self.lyricsLabel.setText(
|
||||
translate('SongsPlugin.EditSongForm', '&Lyrics:'))
|
||||
self.verseOrderLabel.setText(
|
||||
translate('SongsPlugin.EditSongForm', '&Verse order:'))
|
||||
editSongDialog.setWindowTitle(translate('SongsPlugin.EditSongForm', 'Song Editor'))
|
||||
self.titleLabel.setText(translate('SongsPlugin.EditSongForm', '&Title:'))
|
||||
self.alternativeTitleLabel.setText(translate('SongsPlugin.EditSongForm', 'Alt&ernate title:'))
|
||||
self.lyricsLabel.setText(translate('SongsPlugin.EditSongForm', '&Lyrics:'))
|
||||
self.verseOrderLabel.setText(translate('SongsPlugin.EditSongForm', '&Verse order:'))
|
||||
self.verseAddButton.setText(UiStrings().Add)
|
||||
self.verseEditButton.setText(UiStrings().Edit)
|
||||
self.verseEditAllButton.setText(
|
||||
translate('SongsPlugin.EditSongForm', 'Ed&it All'))
|
||||
self.verseEditAllButton.setText(translate('SongsPlugin.EditSongForm', 'Ed&it All'))
|
||||
self.verseDeleteButton.setText(UiStrings().Delete)
|
||||
self.songTabWidget.setTabText(
|
||||
self.songTabWidget.indexOf(self.lyricsTab),
|
||||
self.songTabWidget.setTabText(self.songTabWidget.indexOf(self.lyricsTab),
|
||||
translate('SongsPlugin.EditSongForm', 'Title && Lyrics'))
|
||||
self.authorsGroupBox.setTitle(SongStrings.Authors)
|
||||
self.authorAddButton.setText(
|
||||
translate('SongsPlugin.EditSongForm', '&Add to Song'))
|
||||
self.authorRemoveButton.setText(
|
||||
translate('SongsPlugin.EditSongForm', '&Remove'))
|
||||
self.maintenanceButton.setText(translate('SongsPlugin.EditSongForm',
|
||||
'&Manage Authors, Topics, Song Books'))
|
||||
self.authorAddButton.setText(translate('SongsPlugin.EditSongForm', '&Add to Song'))
|
||||
self.authorRemoveButton.setText(translate('SongsPlugin.EditSongForm', '&Remove'))
|
||||
self.maintenanceButton.setText(translate('SongsPlugin.EditSongForm', '&Manage Authors, Topics, Song Books'))
|
||||
self.topicsGroupBox.setTitle(SongStrings.Topic)
|
||||
self.topicAddButton.setText(
|
||||
translate('SongsPlugin.EditSongForm', 'A&dd to Song'))
|
||||
self.topicRemoveButton.setText(
|
||||
translate('SongsPlugin.EditSongForm', 'R&emove'))
|
||||
self.topicAddButton.setText(translate('SongsPlugin.EditSongForm', 'A&dd to Song'))
|
||||
self.topicRemoveButton.setText(translate('SongsPlugin.EditSongForm', 'R&emove'))
|
||||
self.songBookGroupBox.setTitle(SongStrings.SongBook)
|
||||
self.songBookNameLabel.setText(translate('SongsPlugin.EditSongForm',
|
||||
'Book:'))
|
||||
self.songBookNumberLabel.setText(translate('SongsPlugin.EditSongForm',
|
||||
'Number:'))
|
||||
self.songTabWidget.setTabText(
|
||||
self.songTabWidget.indexOf(self.authorsTab),
|
||||
translate('SongsPlugin.EditSongForm',
|
||||
'Authors, Topics && Song Book'))
|
||||
self.songBookNameLabel.setText(translate('SongsPlugin.EditSongForm', 'Book:'))
|
||||
self.songBookNumberLabel.setText(translate('SongsPlugin.EditSongForm', 'Number:'))
|
||||
self.songTabWidget.setTabText(self.songTabWidget.indexOf(self.authorsTab),
|
||||
translate('SongsPlugin.EditSongForm', 'Authors, Topics && Song Book'))
|
||||
self.themeGroupBox.setTitle(UiStrings().Theme)
|
||||
self.themeAddButton.setText(
|
||||
translate('SongsPlugin.EditSongForm', 'New &Theme'))
|
||||
self.rightsGroupBox.setTitle(
|
||||
translate('SongsPlugin.EditSongForm', 'Copyright Information'))
|
||||
self.themeAddButton.setText(translate('SongsPlugin.EditSongForm', 'New &Theme'))
|
||||
self.rightsGroupBox.setTitle(translate('SongsPlugin.EditSongForm', 'Copyright Information'))
|
||||
self.copyrightInsertButton.setText(SongStrings.CopyrightSymbol)
|
||||
self.CCLILabel.setText(UiStrings().CCLINumberLabel)
|
||||
self.commentsGroupBox.setTitle(
|
||||
translate('SongsPlugin.EditSongForm', 'Comments'))
|
||||
self.songTabWidget.setTabText(
|
||||
self.songTabWidget.indexOf(self.themeTab),
|
||||
translate('SongsPlugin.EditSongForm',
|
||||
'Theme, Copyright Info && Comments'))
|
||||
self.songTabWidget.setTabText(
|
||||
self.songTabWidget.indexOf(self.audioTab),
|
||||
self.commentsGroupBox.setTitle(translate('SongsPlugin.EditSongForm', 'Comments'))
|
||||
self.songTabWidget.setTabText(self.songTabWidget.indexOf(self.themeTab),
|
||||
translate('SongsPlugin.EditSongForm', 'Theme, Copyright Info && Comments'))
|
||||
self.songTabWidget.setTabText(self.songTabWidget.indexOf(self.audioTab),
|
||||
translate('SongsPlugin.EditSongForm', 'Linked Audio'))
|
||||
self.audioAddFromFileButton.setText(
|
||||
translate('SongsPlugin.EditSongForm', 'Add &File(s)'))
|
||||
self.audioAddFromMediaButton.setText(
|
||||
translate('SongsPlugin.EditSongForm', 'Add &Media'))
|
||||
self.audioRemoveButton.setText(
|
||||
translate('SongsPlugin.EditSongForm', '&Remove'))
|
||||
self.audioRemoveAllButton.setText(
|
||||
translate('SongsPlugin.EditSongForm', 'Remove &All'))
|
||||
self.audioAddFromFileButton.setText(translate('SongsPlugin.EditSongForm', 'Add &File(s)'))
|
||||
self.audioAddFromMediaButton.setText(translate('SongsPlugin.EditSongForm', 'Add &Media'))
|
||||
self.audioRemoveButton.setText(translate('SongsPlugin.EditSongForm', '&Remove'))
|
||||
self.audioRemoveAllButton.setText(translate('SongsPlugin.EditSongForm', 'Remove &All'))
|
||||
self.warningLabel.setText(
|
||||
translate('SongsPlugin.EditSongForm', '<strong>Warning:</strong>'
|
||||
' Not all of the verses are in use.'))
|
||||
translate('SongsPlugin.EditSongForm', '<strong>Warning:</strong> Not all of the verses are in use.'))
|
||||
|
||||
def editSongDialogComboBox(parent, name):
|
||||
"""
|
||||
Utility method to generate a standard combo box for this dialog.
|
||||
"""
|
||||
comboBox = QtGui.QComboBox(parent)
|
||||
comboBox.setSizeAdjustPolicy(
|
||||
QtGui.QComboBox.AdjustToMinimumContentsLength)
|
||||
comboBox.setSizePolicy(
|
||||
QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Fixed)
|
||||
comboBox.setSizeAdjustPolicy(QtGui.QComboBox.AdjustToMinimumContentsLength)
|
||||
comboBox.setSizePolicy(QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Fixed)
|
||||
comboBox.setEditable(True)
|
||||
comboBox.setInsertPolicy(QtGui.QComboBox.NoInsert)
|
||||
comboBox.setObjectName(name)
|
||||
|
|
|
@ -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,10 +34,9 @@ import shutil
|
|||
|
||||
from PyQt4 import QtCore, QtGui
|
||||
|
||||
from openlp.core.lib import PluginStatus, Receiver, MediaType, translate, \
|
||||
create_separated_list, check_directory_exists
|
||||
from openlp.core.lib.ui import UiStrings, set_case_insensitive_completer, \
|
||||
critical_error_message_box, find_and_set_in_combo_box
|
||||
from openlp.core.lib import PluginStatus, Receiver, MediaType, translate, create_separated_list, check_directory_exists
|
||||
from openlp.core.lib.ui import UiStrings, set_case_insensitive_completer, critical_error_message_box, \
|
||||
find_and_set_in_combo_box
|
||||
from openlp.core.utils import AppLocation
|
||||
from openlp.plugins.songs.forms import EditVerseForm, MediaFilesForm
|
||||
from openlp.plugins.songs.lib import SongXML, VerseType, clean_song
|
||||
|
@ -64,61 +63,42 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog):
|
|||
self.width = 400
|
||||
self.setupUi(self)
|
||||
# Connecting signals and slots
|
||||
QtCore.QObject.connect(self.authorAddButton,
|
||||
QtCore.SIGNAL(u'clicked()'), self.onAuthorAddButtonClicked)
|
||||
QtCore.QObject.connect(self.authorRemoveButton,
|
||||
QtCore.SIGNAL(u'clicked()'), self.onAuthorRemoveButtonClicked)
|
||||
QtCore.QObject.connect(self.authorsListView,
|
||||
QtCore.SIGNAL(u'itemClicked(QListWidgetItem*)'),
|
||||
QtCore.QObject.connect(self.authorAddButton, QtCore.SIGNAL(u'clicked()'), self.onAuthorAddButtonClicked)
|
||||
QtCore.QObject.connect(self.authorRemoveButton, QtCore.SIGNAL(u'clicked()'), self.onAuthorRemoveButtonClicked)
|
||||
QtCore.QObject.connect(self.authorsListView, QtCore.SIGNAL(u'itemClicked(QListWidgetItem*)'),
|
||||
self.onAuthorsListViewClicked)
|
||||
QtCore.QObject.connect(self.topicAddButton,
|
||||
QtCore.SIGNAL(u'clicked()'), self.onTopicAddButtonClicked)
|
||||
QtCore.QObject.connect(self.topicRemoveButton,
|
||||
QtCore.SIGNAL(u'clicked()'), self.onTopicRemoveButtonClicked)
|
||||
QtCore.QObject.connect(self.topicsListView,
|
||||
QtCore.SIGNAL(u'itemClicked(QListWidgetItem*)'),
|
||||
QtCore.QObject.connect(self.topicAddButton, QtCore.SIGNAL(u'clicked()'), self.onTopicAddButtonClicked)
|
||||
QtCore.QObject.connect(self.topicRemoveButton, QtCore.SIGNAL(u'clicked()'), self.onTopicRemoveButtonClicked)
|
||||
QtCore.QObject.connect(self.topicsListView, QtCore.SIGNAL(u'itemClicked(QListWidgetItem*)'),
|
||||
self.onTopicListViewClicked)
|
||||
QtCore.QObject.connect(self.copyrightInsertButton,
|
||||
QtCore.SIGNAL(u'clicked()'), self.onCopyrightInsertButtonTriggered)
|
||||
QtCore.QObject.connect(self.verseAddButton,
|
||||
QtCore.SIGNAL(u'clicked()'), self.onVerseAddButtonClicked)
|
||||
QtCore.QObject.connect(self.verseListWidget,
|
||||
QtCore.SIGNAL(u'doubleClicked(QModelIndex)'),
|
||||
QtCore.QObject.connect(self.copyrightInsertButton, QtCore.SIGNAL(u'clicked()'),
|
||||
self.onCopyrightInsertButtonTriggered)
|
||||
QtCore.QObject.connect(self.verseAddButton, QtCore.SIGNAL(u'clicked()'), self.onVerseAddButtonClicked)
|
||||
QtCore.QObject.connect(self.verseListWidget, QtCore.SIGNAL(u'doubleClicked(QModelIndex)'),
|
||||
self.onVerseEditButtonClicked)
|
||||
QtCore.QObject.connect(self.verseEditButton,
|
||||
QtCore.SIGNAL(u'clicked()'), self.onVerseEditButtonClicked)
|
||||
QtCore.QObject.connect(self.verseEditAllButton,
|
||||
QtCore.SIGNAL(u'clicked()'), self.onVerseEditAllButtonClicked)
|
||||
QtCore.QObject.connect(self.verseDeleteButton,
|
||||
QtCore.SIGNAL(u'clicked()'), self.onVerseDeleteButtonClicked)
|
||||
QtCore.QObject.connect(self.verseListWidget,
|
||||
QtCore.SIGNAL(u'itemClicked(QTableWidgetItem*)'),
|
||||
QtCore.QObject.connect(self.verseEditButton, QtCore.SIGNAL(u'clicked()'), self.onVerseEditButtonClicked)
|
||||
QtCore.QObject.connect(self.verseEditAllButton, QtCore.SIGNAL(u'clicked()'), self.onVerseEditAllButtonClicked)
|
||||
QtCore.QObject.connect(self.verseDeleteButton, QtCore.SIGNAL(u'clicked()'), self.onVerseDeleteButtonClicked)
|
||||
QtCore.QObject.connect(self.verseListWidget, QtCore.SIGNAL(u'itemClicked(QTableWidgetItem*)'),
|
||||
self.onVerseListViewClicked)
|
||||
QtCore.QObject.connect(self.verseOrderEdit,
|
||||
QtCore.SIGNAL(u'textChanged(QString)'),
|
||||
QtCore.QObject.connect(self.verseOrderEdit, QtCore.SIGNAL(u'textChanged(QString)'),
|
||||
self.onVerseOrderTextChanged)
|
||||
QtCore.QObject.connect(self.themeAddButton,
|
||||
QtCore.SIGNAL(u'clicked()'),
|
||||
QtCore.QObject.connect(self.themeAddButton, QtCore.SIGNAL(u'clicked()'),
|
||||
self.mediaitem.plugin.renderer.theme_manager.onAddTheme)
|
||||
QtCore.QObject.connect(self.maintenanceButton,
|
||||
QtCore.SIGNAL(u'clicked()'), self.onMaintenanceButtonClicked)
|
||||
QtCore.QObject.connect(self.audioAddFromFileButton,
|
||||
QtCore.SIGNAL(u'clicked()'), self.onAudioAddFromFileButtonClicked)
|
||||
QtCore.QObject.connect(self.audioAddFromMediaButton,
|
||||
QtCore.SIGNAL(u'clicked()'), self.onAudioAddFromMediaButtonClicked)
|
||||
QtCore.QObject.connect(self.audioRemoveButton,
|
||||
QtCore.SIGNAL(u'clicked()'), self.onAudioRemoveButtonClicked)
|
||||
QtCore.QObject.connect(self.audioRemoveAllButton,
|
||||
QtCore.SIGNAL(u'clicked()'), self.onAudioRemoveAllButtonClicked)
|
||||
QtCore.QObject.connect(Receiver.get_receiver(),
|
||||
QtCore.SIGNAL(u'theme_update_list'), self.loadThemes)
|
||||
QtCore.QObject.connect(self.maintenanceButton, QtCore.SIGNAL(u'clicked()'), self.onMaintenanceButtonClicked)
|
||||
QtCore.QObject.connect(self.audioAddFromFileButton, QtCore.SIGNAL(u'clicked()'),
|
||||
self.onAudioAddFromFileButtonClicked)
|
||||
QtCore.QObject.connect(self.audioAddFromMediaButton, QtCore.SIGNAL(u'clicked()'),
|
||||
self.onAudioAddFromMediaButtonClicked)
|
||||
QtCore.QObject.connect(self.audioRemoveButton, QtCore.SIGNAL(u'clicked()'), self.onAudioRemoveButtonClicked)
|
||||
QtCore.QObject.connect(self.audioRemoveAllButton, QtCore.SIGNAL(u'clicked()'),
|
||||
self.onAudioRemoveAllButtonClicked)
|
||||
QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'theme_update_list'), self.loadThemes)
|
||||
self.previewButton = QtGui.QPushButton()
|
||||
self.previewButton.setObjectName(u'previewButton')
|
||||
self.previewButton.setText(UiStrings().SaveAndPreview)
|
||||
self.buttonBox.addButton(
|
||||
self.previewButton, QtGui.QDialogButtonBox.ActionRole)
|
||||
QtCore.QObject.connect(self.buttonBox,
|
||||
QtCore.SIGNAL(u'clicked(QAbstractButton*)'), self.onPreview)
|
||||
self.buttonBox.addButton(self.previewButton, QtGui.QDialogButtonBox.ActionRole)
|
||||
QtCore.QObject.connect(self.buttonBox, QtCore.SIGNAL(u'clicked(QAbstractButton*)'), self.onPreview)
|
||||
# Create other objects and forms
|
||||
self.manager = manager
|
||||
self.verseForm = EditVerseForm(self)
|
||||
|
@ -234,19 +214,13 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog):
|
|||
self.song.alternate_title if self.song.alternate_title else u'')
|
||||
if self.song.song_book_id != 0:
|
||||
book_name = self.manager.get_object(Book, self.song.song_book_id)
|
||||
find_and_set_in_combo_box(
|
||||
self.songBookComboBox, unicode(book_name.name))
|
||||
find_and_set_in_combo_box(self.songBookComboBox, unicode(book_name.name))
|
||||
if self.song.theme_name:
|
||||
find_and_set_in_combo_box(
|
||||
self.themeComboBox, unicode(self.song.theme_name))
|
||||
self.copyrightEdit.setText(
|
||||
self.song.copyright if self.song.copyright else u'')
|
||||
self.commentsEdit.setPlainText(
|
||||
self.song.comments if self.song.comments else u'')
|
||||
self.CCLNumberEdit.setText(
|
||||
self.song.ccli_number if self.song.ccli_number else u'')
|
||||
self.songBookNumberEdit.setText(
|
||||
self.song.song_number if self.song.song_number else u'')
|
||||
find_and_set_in_combo_box(self.themeComboBox, unicode(self.song.theme_name))
|
||||
self.copyrightEdit.setText(self.song.copyright if self.song.copyright else u'')
|
||||
self.commentsEdit.setPlainText(self.song.comments if self.song.comments else u'')
|
||||
self.CCLNumberEdit.setText(self.song.ccli_number if self.song.ccli_number else u'')
|
||||
self.songBookNumberEdit.setText(self.song.song_number if self.song.song_number else u'')
|
||||
# lazy xml migration for now
|
||||
self.verseListWidget.clear()
|
||||
self.verseListWidget.setRowCount(0)
|
||||
|
@ -282,11 +256,9 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog):
|
|||
else:
|
||||
verses = self.song.lyrics.split(u'\n\n')
|
||||
for count, verse in enumerate(verses):
|
||||
self.verseListWidget.setRowCount(
|
||||
self.verseListWidget.rowCount() + 1)
|
||||
self.verseListWidget.setRowCount(self.verseListWidget.rowCount() + 1)
|
||||
item = QtGui.QTableWidgetItem(verse)
|
||||
verse_def = u'%s%s' % \
|
||||
(VerseType.Tags[VerseType.Verse], unicode(count + 1))
|
||||
verse_def = u'%s%s' % (VerseType.Tags[VerseType.Verse], unicode(count + 1))
|
||||
item.setData(QtCore.Qt.UserRole, verse_def)
|
||||
self.verseListWidget.setItem(count, 0, item)
|
||||
if self.song.verse_order:
|
||||
|
@ -295,8 +267,7 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog):
|
|||
for verse_def in self.song.verse_order.split():
|
||||
verse_index = None
|
||||
if verse_tags_translated:
|
||||
verse_index = VerseType.from_translated_tag(verse_def[0],
|
||||
None)
|
||||
verse_index = VerseType.from_translated_tag(verse_def[0], None)
|
||||
if verse_index is None:
|
||||
verse_index = VerseType.from_tag(verse_def[0])
|
||||
verse_tag = VerseType.TranslatedTags[verse_index].upper()
|
||||
|
@ -319,8 +290,7 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog):
|
|||
self.topicsListView.addItem(topic_name)
|
||||
self.audioListWidget.clear()
|
||||
for media in self.song.media_files:
|
||||
media_file = QtGui.QListWidgetItem(
|
||||
os.path.split(media.file_name)[1])
|
||||
media_file = QtGui.QListWidgetItem(os.path.split(media.file_name)[1])
|
||||
media_file.setData(QtCore.Qt.UserRole, media.file_name)
|
||||
self.audioListWidget.addItem(media_file)
|
||||
self.titleEdit.setFocus()
|
||||
|
@ -353,13 +323,10 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog):
|
|||
if item == 0 and text:
|
||||
if QtGui.QMessageBox.question(self,
|
||||
translate('SongsPlugin.EditSongForm', 'Add Author'),
|
||||
translate('SongsPlugin.EditSongForm', 'This author does not '
|
||||
'exist, do you want to add them?'),
|
||||
QtGui.QMessageBox.Yes | QtGui.QMessageBox.No,
|
||||
QtGui.QMessageBox.Yes) == QtGui.QMessageBox.Yes:
|
||||
translate('SongsPlugin.EditSongForm', 'This author does not exist, do you want to add them?'),
|
||||
QtGui.QMessageBox.Yes | QtGui.QMessageBox.No, QtGui.QMessageBox.Yes) == QtGui.QMessageBox.Yes:
|
||||
if text.find(u' ') == -1:
|
||||
author = Author.populate(first_name=u'', last_name=u'',
|
||||
display_name=text)
|
||||
author = Author.populate(first_name=u'', last_name=u'', display_name=text)
|
||||
else:
|
||||
author = Author.populate(first_name=text.rsplit(u' ', 1)[0],
|
||||
last_name=text.rsplit(u' ', 1)[1], display_name=text)
|
||||
|
@ -375,17 +342,15 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog):
|
|||
if self.authorsListView.findItems(unicode(author.display_name),
|
||||
QtCore.Qt.MatchExactly):
|
||||
critical_error_message_box(
|
||||
message=translate('SongsPlugin.EditSongForm',
|
||||
'This author is already in the list.'))
|
||||
message=translate('SongsPlugin.EditSongForm', 'This author is already in the list.'))
|
||||
else:
|
||||
self.__addAuthorToList(author)
|
||||
self.authorsComboBox.setCurrentIndex(0)
|
||||
else:
|
||||
QtGui.QMessageBox.warning(self, UiStrings().NISs,
|
||||
translate('SongsPlugin.EditSongForm', 'You have not selected '
|
||||
'a valid author. Either select an author from the list, '
|
||||
'or type in a new author and click the "Add Author to '
|
||||
'Song" button to add the new author.'))
|
||||
translate('SongsPlugin.EditSongForm', 'You have not selected a valid author. Either select an author '
|
||||
'from the list, or type in a new author and click the "Add Author to Song" button to add '
|
||||
'the new author.'))
|
||||
|
||||
def __addAuthorToList(self, author):
|
||||
"""
|
||||
|
@ -409,12 +374,9 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog):
|
|||
item = int(self.topicsComboBox.currentIndex())
|
||||
text = self.topicsComboBox.currentText()
|
||||
if item == 0 and text:
|
||||
if QtGui.QMessageBox.question(self,
|
||||
translate('SongsPlugin.EditSongForm', 'Add Topic'),
|
||||
translate('SongsPlugin.EditSongForm', 'This topic does not '
|
||||
'exist, do you want to add it?'),
|
||||
QtGui.QMessageBox.Yes | QtGui.QMessageBox.No,
|
||||
QtGui.QMessageBox.Yes) == QtGui.QMessageBox.Yes:
|
||||
if QtGui.QMessageBox.question(self, translate('SongsPlugin.EditSongForm', 'Add Topic'),
|
||||
translate('SongsPlugin.EditSongForm', 'This topic does not exist, do you want to add it?'),
|
||||
QtGui.QMessageBox.Yes | QtGui.QMessageBox.No, QtGui.QMessageBox.Yes) == QtGui.QMessageBox.Yes:
|
||||
topic = Topic.populate(name=text)
|
||||
self.manager.save_object(topic)
|
||||
topic_item = QtGui.QListWidgetItem(unicode(topic.name))
|
||||
|
@ -430,8 +392,7 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog):
|
|||
if self.topicsListView.findItems(unicode(topic.name),
|
||||
QtCore.Qt.MatchExactly):
|
||||
critical_error_message_box(
|
||||
message=translate('SongsPlugin.EditSongForm',
|
||||
'This topic is already in the list.'))
|
||||
message=translate('SongsPlugin.EditSongForm', 'This topic is already in the list.'))
|
||||
else:
|
||||
topic_item = QtGui.QListWidgetItem(unicode(topic.name))
|
||||
topic_item.setData(QtCore.Qt.UserRole, topic.id)
|
||||
|
@ -439,10 +400,8 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog):
|
|||
self.topicsComboBox.setCurrentIndex(0)
|
||||
else:
|
||||
QtGui.QMessageBox.warning(self, UiStrings().NISs,
|
||||
translate('SongsPlugin.EditSongForm', 'You have not selected '
|
||||
'a valid topic. Either select a topic from the list, or '
|
||||
'type in a new topic and click the "Add Topic to Song" '
|
||||
'button to add the new topic.'))
|
||||
translate('SongsPlugin.EditSongForm', 'You have not selected a valid topic. Either select a topic '
|
||||
'from the list, or type in a new topic and click the "Add Topic to Song" button to add the new topic.'))
|
||||
|
||||
def onTopicListViewClicked(self):
|
||||
self.topicRemoveButton.setEnabled(True)
|
||||
|
@ -465,10 +424,8 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog):
|
|||
item = QtGui.QTableWidgetItem(after_text)
|
||||
item.setData(QtCore.Qt.UserRole, verse_def)
|
||||
item.setText(after_text)
|
||||
self.verseListWidget.setRowCount(
|
||||
self.verseListWidget.rowCount() + 1)
|
||||
self.verseListWidget.setItem(
|
||||
self.verseListWidget.rowCount() - 1, 0, item)
|
||||
self.verseListWidget.setRowCount(self.verseListWidget.rowCount() + 1)
|
||||
self.verseListWidget.setItem(self.verseListWidget.rowCount() - 1, 0, item)
|
||||
self.tagRows()
|
||||
# Check if all verse tags are used.
|
||||
self.onVerseOrderTextChanged(self.verseOrderEdit.text())
|
||||
|
@ -551,10 +508,8 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog):
|
|||
parts = parts.rstrip(u'\n')
|
||||
item = QtGui.QTableWidgetItem(parts)
|
||||
item.setData(QtCore.Qt.UserRole, verse_def)
|
||||
self.verseListWidget.setRowCount(
|
||||
self.verseListWidget.rowCount() + 1)
|
||||
self.verseListWidget.setItem(
|
||||
self.verseListWidget.rowCount() - 1, 0, item)
|
||||
self.verseListWidget.setRowCount(self.verseListWidget.rowCount() + 1)
|
||||
self.verseListWidget.setItem(self.verseListWidget.rowCount() - 1, 0, item)
|
||||
self.tagRows()
|
||||
self.verseEditButton.setEnabled(False)
|
||||
self.verseDeleteButton.setEnabled(False)
|
||||
|
@ -576,8 +531,7 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog):
|
|||
verse = verse.data(QtCore.Qt.UserRole)
|
||||
if verse not in verse_names:
|
||||
verses.append(verse)
|
||||
verse_names.append(u'%s%s' % (
|
||||
VerseType.translated_tag(verse[0]), verse[1:]))
|
||||
verse_names.append(u'%s%s' % (VerseType.translated_tag(verse[0]), verse[1:]))
|
||||
verses_not_used = []
|
||||
for verse in verses:
|
||||
if not verse in order:
|
||||
|
@ -617,23 +571,20 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog):
|
|||
verse = verse.data(QtCore.Qt.UserRole)
|
||||
if verse not in verse_names:
|
||||
verses.append(verse)
|
||||
verse_names.append(u'%s%s' % (
|
||||
VerseType.translated_tag(verse[0]), verse[1:]))
|
||||
verse_names.append(u'%s%s' % (VerseType.translated_tag(verse[0]), verse[1:]))
|
||||
for count, item in enumerate(order):
|
||||
if item not in verses:
|
||||
invalid_verses.append(order_names[count])
|
||||
if invalid_verses:
|
||||
valid = create_separated_list(verse_names)
|
||||
if len(invalid_verses) > 1:
|
||||
critical_error_message_box(message=translate(
|
||||
'SongsPlugin.EditSongForm', 'The verse order is invalid. '
|
||||
'There are no verses corresponding to %s. Valid entries '
|
||||
'are %s.') % (u', '.join(invalid_verses), valid))
|
||||
critical_error_message_box(message=translate('SongsPlugin.EditSongForm',
|
||||
'The verse order is invalid. There are no verses corresponding to %s. Valid entries are %s.') %
|
||||
(u', '.join(invalid_verses), valid))
|
||||
else:
|
||||
critical_error_message_box(message=translate(
|
||||
'SongsPlugin.EditSongForm', 'The verse order is invalid. '
|
||||
'There is no verse corresponding to %s. Valid entries '
|
||||
'are %s.') % (invalid_verses[0], valid))
|
||||
critical_error_message_box(message=translate('SongsPlugin.EditSongForm',
|
||||
'The verse order is invalid. There is no verse corresponding to %s. Valid entries are %s.') %
|
||||
(invalid_verses[0], valid))
|
||||
return len(invalid_verses) == 0
|
||||
|
||||
def __validateSong(self):
|
||||
|
@ -648,22 +599,19 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog):
|
|||
self.songTabWidget.setCurrentIndex(0)
|
||||
self.titleEdit.setFocus()
|
||||
critical_error_message_box(
|
||||
message=translate('SongsPlugin.EditSongForm',
|
||||
'You need to type in a song title.'))
|
||||
message=translate('SongsPlugin.EditSongForm', 'You need to type in a song title.'))
|
||||
return False
|
||||
if self.verseListWidget.rowCount() == 0:
|
||||
self.songTabWidget.setCurrentIndex(0)
|
||||
self.verseListWidget.setFocus()
|
||||
critical_error_message_box(
|
||||
message=translate('SongsPlugin.EditSongForm',
|
||||
'You need to type in at least one verse.'))
|
||||
message=translate('SongsPlugin.EditSongForm', 'You need to type in at least one verse.'))
|
||||
return False
|
||||
if self.authorsListView.count() == 0:
|
||||
self.songTabWidget.setCurrentIndex(1)
|
||||
self.authorsListView.setFocus()
|
||||
critical_error_message_box(
|
||||
message=translate('SongsPlugin.EditSongForm',
|
||||
'You need to have an author for this song.'))
|
||||
message=translate('SongsPlugin.EditSongForm', 'You need to have an author for this song.'))
|
||||
return False
|
||||
if self.verseOrderEdit.text():
|
||||
result = self.__validateVerseList(self.verseOrderEdit.text(),
|
||||
|
@ -672,12 +620,9 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog):
|
|||
return False
|
||||
text = self.songBookComboBox.currentText()
|
||||
if self.songBookComboBox.findText(text, QtCore.Qt.MatchExactly) < 0:
|
||||
if QtGui.QMessageBox.question(self,
|
||||
translate('SongsPlugin.EditSongForm', 'Add Book'),
|
||||
translate('SongsPlugin.EditSongForm', 'This song book does '
|
||||
'not exist, do you want to add it?'),
|
||||
QtGui.QMessageBox.Yes | QtGui.QMessageBox.No,
|
||||
QtGui.QMessageBox.Yes) == QtGui.QMessageBox.Yes:
|
||||
if QtGui.QMessageBox.question(self, translate('SongsPlugin.EditSongForm', 'Add Book'),
|
||||
translate('SongsPlugin.EditSongForm', 'This song book does not exist, do you want to add it?'),
|
||||
QtGui.QMessageBox.Yes | QtGui.QMessageBox.No, QtGui.QMessageBox.Yes) == QtGui.QMessageBox.Yes:
|
||||
book = Book.populate(name=text, publisher=u'')
|
||||
self.manager.save_object(book)
|
||||
else:
|
||||
|
@ -737,8 +682,7 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog):
|
|||
"""
|
||||
if self.mediaForm.exec_():
|
||||
for filename in self.mediaForm.getSelectedFiles():
|
||||
item = QtGui.QListWidgetItem(
|
||||
os.path.split(unicode(filename))[1])
|
||||
item = QtGui.QListWidgetItem(os.path.split(unicode(filename))[1])
|
||||
item.setData(QtCore.Qt.UserRole, filename)
|
||||
self.audioListWidget.addItem(item)
|
||||
|
||||
|
@ -871,9 +815,8 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog):
|
|||
self.manager.save_object(self.song)
|
||||
audio_files = map(lambda a: a.file_name, self.song.media_files)
|
||||
log.debug(audio_files)
|
||||
save_path = os.path.join(
|
||||
AppLocation.get_section_data_path(self.mediaitem.plugin.name),
|
||||
'audio', str(self.song.id))
|
||||
save_path = os.path.join(AppLocation.get_section_data_path(self.mediaitem.plugin.name), 'audio',
|
||||
str(self.song.id))
|
||||
check_directory_exists(save_path)
|
||||
self.song.media_files = []
|
||||
files = []
|
||||
|
@ -881,8 +824,7 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog):
|
|||
item = self.audioListWidget.item(row)
|
||||
filename = item.data(QtCore.Qt.UserRole)
|
||||
if not filename.startswith(save_path):
|
||||
oldfile, filename = filename, os.path.join(save_path,
|
||||
os.path.split(filename)[1])
|
||||
oldfile, filename = filename, os.path.join(save_path, os.path.split(filename)[1])
|
||||
shutil.copyfile(oldfile, filename)
|
||||
files.append(filename)
|
||||
media_file = MediaFile()
|
||||
|
@ -924,10 +866,8 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog):
|
|||
multiple.append(verse_tag)
|
||||
self.song.lyrics = unicode(sxml.extract_xml(), u'utf-8')
|
||||
for verse in multiple:
|
||||
self.song.verse_order = re.sub(u'([' + verse.upper() +
|
||||
verse.lower() + u'])(\W|$)', r'\g<1>1\2',
|
||||
self.song.verse_order = re.sub(u'([' + verse.upper() + verse.lower() + u'])(\W|$)', r'\g<1>1\2',
|
||||
self.song.verse_order)
|
||||
except:
|
||||
log.exception(u'Problem processing song Lyrics \n%s',
|
||||
sxml.dump_xml())
|
||||
log.exception(u'Problem processing song Lyrics \n%s', sxml.dump_xml())
|
||||
|
||||
|
|
|
@ -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 #
|
||||
|
@ -67,34 +67,22 @@ class Ui_EditVerseDialog(object):
|
|||
self.verseTypeLayout.addWidget(self.insertButton)
|
||||
self.verseTypeLayout.addStretch()
|
||||
self.dialogLayout.addLayout(self.verseTypeLayout)
|
||||
self.buttonBox = create_button_box(editVerseDialog, u'buttonBox',
|
||||
[u'cancel', u'ok'])
|
||||
self.buttonBox = create_button_box(editVerseDialog, u'buttonBox', [u'cancel', u'ok'])
|
||||
self.dialogLayout.addWidget(self.buttonBox)
|
||||
self.retranslateUi(editVerseDialog)
|
||||
|
||||
def retranslateUi(self, editVerseDialog):
|
||||
editVerseDialog.setWindowTitle(
|
||||
translate('SongsPlugin.EditVerseForm', 'Edit Verse'))
|
||||
self.verseTypeLabel.setText(
|
||||
translate('SongsPlugin.EditVerseForm', '&Verse type:'))
|
||||
self.verseTypeComboBox.setItemText(VerseType.Verse,
|
||||
VerseType.TranslatedNames[VerseType.Verse])
|
||||
self.verseTypeComboBox.setItemText(VerseType.Chorus,
|
||||
VerseType.TranslatedNames[VerseType.Chorus])
|
||||
self.verseTypeComboBox.setItemText(VerseType.Bridge,
|
||||
VerseType.TranslatedNames[VerseType.Bridge])
|
||||
self.verseTypeComboBox.setItemText(VerseType.PreChorus,
|
||||
VerseType.TranslatedNames[VerseType.PreChorus])
|
||||
self.verseTypeComboBox.setItemText(VerseType.Intro,
|
||||
VerseType.TranslatedNames[VerseType.Intro])
|
||||
self.verseTypeComboBox.setItemText(VerseType.Ending,
|
||||
VerseType.TranslatedNames[VerseType.Ending])
|
||||
self.verseTypeComboBox.setItemText(VerseType.Other,
|
||||
VerseType.TranslatedNames[VerseType.Other])
|
||||
editVerseDialog.setWindowTitle(translate('SongsPlugin.EditVerseForm', 'Edit Verse'))
|
||||
self.verseTypeLabel.setText(translate('SongsPlugin.EditVerseForm', '&Verse type:'))
|
||||
self.verseTypeComboBox.setItemText(VerseType.Verse, VerseType.TranslatedNames[VerseType.Verse])
|
||||
self.verseTypeComboBox.setItemText(VerseType.Chorus, VerseType.TranslatedNames[VerseType.Chorus])
|
||||
self.verseTypeComboBox.setItemText(VerseType.Bridge, VerseType.TranslatedNames[VerseType.Bridge])
|
||||
self.verseTypeComboBox.setItemText(VerseType.PreChorus, VerseType.TranslatedNames[VerseType.PreChorus])
|
||||
self.verseTypeComboBox.setItemText(VerseType.Intro, VerseType.TranslatedNames[VerseType.Intro])
|
||||
self.verseTypeComboBox.setItemText(VerseType.Ending, VerseType.TranslatedNames[VerseType.Ending])
|
||||
self.verseTypeComboBox.setItemText(VerseType.Other, VerseType.TranslatedNames[VerseType.Other])
|
||||
self.splitButton.setText(UiStrings().Split)
|
||||
self.splitButton.setToolTip(UiStrings().SplitToolTip)
|
||||
self.insertButton.setText(
|
||||
translate('SongsPlugin.EditVerseForm', '&Insert'))
|
||||
self.insertButton.setToolTip(
|
||||
translate('SongsPlugin.EditVerseForm', 'Split a slide into two '
|
||||
'by inserting a verse splitter.'))
|
||||
self.insertButton.setText(translate('SongsPlugin.EditVerseForm', '&Insert'))
|
||||
self.insertButton.setToolTip(translate('SongsPlugin.EditVerseForm',
|
||||
'Split a slide into two by inserting a verse splitter.'))
|
||||
|
|
|
@ -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 #
|
||||
|
@ -51,18 +51,13 @@ class EditVerseForm(QtGui.QDialog, Ui_EditVerseDialog):
|
|||
"""
|
||||
QtGui.QDialog.__init__(self, parent)
|
||||
self.setupUi(self)
|
||||
QtCore.QObject.connect(self.verseTextEdit,
|
||||
QtCore.SIGNAL('customContextMenuRequested(QPoint)'),
|
||||
QtCore.QObject.connect(self.verseTextEdit, QtCore.SIGNAL('customContextMenuRequested(QPoint)'),
|
||||
self.contextMenu)
|
||||
QtCore.QObject.connect(self.insertButton, QtCore.SIGNAL(u'clicked()'),
|
||||
self.onInsertButtonClicked)
|
||||
QtCore.QObject.connect(self.splitButton, QtCore.SIGNAL(u'clicked()'),
|
||||
self.onSplitButtonClicked)
|
||||
QtCore.QObject.connect(self.verseTextEdit,
|
||||
QtCore.SIGNAL(u'cursorPositionChanged()'),
|
||||
QtCore.QObject.connect(self.insertButton, QtCore.SIGNAL(u'clicked()'), self.onInsertButtonClicked)
|
||||
QtCore.QObject.connect(self.splitButton, QtCore.SIGNAL(u'clicked()'), self.onSplitButtonClicked)
|
||||
QtCore.QObject.connect(self.verseTextEdit, QtCore.SIGNAL(u'cursorPositionChanged()'),
|
||||
self.onCursorPositionChanged)
|
||||
QtCore.QObject.connect(self.verseTypeComboBox,
|
||||
QtCore.SIGNAL(u'currentIndexChanged(int)'),
|
||||
QtCore.QObject.connect(self.verseTypeComboBox, QtCore.SIGNAL(u'currentIndexChanged(int)'),
|
||||
self.onVerseTypeComboBoxChanged)
|
||||
|
||||
def contextMenu(self, point):
|
||||
|
@ -72,8 +67,7 @@ class EditVerseForm(QtGui.QDialog, Ui_EditVerseDialog):
|
|||
if self.verseTextEdit.textCursor().columnNumber() != 0:
|
||||
self.verseTextEdit.insertPlainText(u'\n')
|
||||
verse_tag = VerseType.translated_name(verse_tag)
|
||||
self.verseTextEdit.insertPlainText(u'---[%s:%s]---\n' %
|
||||
(verse_tag, verse_num))
|
||||
self.verseTextEdit.insertPlainText(u'---[%s:%s]---\n' % (verse_tag, verse_num))
|
||||
self.verseTextEdit.setFocus()
|
||||
|
||||
def onSplitButtonClicked(self):
|
||||
|
@ -93,6 +87,12 @@ class EditVerseForm(QtGui.QDialog, Ui_EditVerseDialog):
|
|||
self.verseNumberBox.value())
|
||||
|
||||
def onVerseTypeComboBoxChanged(self):
|
||||
self.updateSuggestedVerseNumber()
|
||||
|
||||
def onCursorPositionChanged(self):
|
||||
self.updateSuggestedVerseNumber()
|
||||
|
||||
def updateSuggestedVerseNumber(self):
|
||||
"""
|
||||
Adjusts the verse number SpinBox in regard to the selected verse type
|
||||
and the cursor's position.
|
||||
|
@ -116,43 +116,10 @@ class EditVerseForm(QtGui.QDialog, Ui_EditVerseDialog):
|
|||
if match:
|
||||
verse_tag = match.group(1)
|
||||
try:
|
||||
verse_num = int(match.group(2))
|
||||
verse_num = int(match.group(2)) + 1
|
||||
except ValueError:
|
||||
verse_num = 1
|
||||
if VerseType.from_loose_input(verse_tag, False):
|
||||
self.verseNumberBox.setValue(verse_num)
|
||||
|
||||
def onCursorPositionChanged(self):
|
||||
"""
|
||||
Determines the previous verse type and number in regard to the cursor's
|
||||
position and adjusts the ComboBox and SpinBox to these values.
|
||||
"""
|
||||
position = self.verseTextEdit.textCursor().position()
|
||||
text = self.verseTextEdit.toPlainText()
|
||||
if not text:
|
||||
return
|
||||
if text.rfind(u'[', 0, position) > text.rfind(u']', 0, position) and \
|
||||
text.find(u']', position) < text.find(u'[', position):
|
||||
return
|
||||
position = text.rfind(u'---[', 0, position)
|
||||
if position == -1:
|
||||
return
|
||||
text = text[position:]
|
||||
position = text.find(u']---')
|
||||
if position == -1:
|
||||
return
|
||||
text = text[:position + 4]
|
||||
match = VERSE_REGEX.match(text)
|
||||
if match:
|
||||
verse_type = match.group(1)
|
||||
verse_type_index = VerseType.from_loose_input(verse_type, None)
|
||||
try:
|
||||
verse_number = int(match.group(2))
|
||||
except ValueError:
|
||||
verse_number = 1
|
||||
if verse_type_index is not None:
|
||||
self.verseTypeComboBox.setCurrentIndex(verse_type_index)
|
||||
self.verseNumberBox.setValue(verse_number)
|
||||
self.verseNumberBox.setValue(verse_num)
|
||||
|
||||
def setVerse(self, text, single=False,
|
||||
tag=u'%s1' % VerseType.Tags[VerseType.Verse]):
|
||||
|
@ -166,8 +133,7 @@ class EditVerseForm(QtGui.QDialog, Ui_EditVerseDialog):
|
|||
self.insertButton.setVisible(False)
|
||||
else:
|
||||
if not text:
|
||||
text = u'---[%s:1]---\n' % \
|
||||
VerseType.TranslatedNames[VerseType.Verse]
|
||||
text = u'---[%s:1]---\n' % VerseType.TranslatedNames[VerseType.Verse]
|
||||
self.verseTypeComboBox.setCurrentIndex(0)
|
||||
self.verseNumberBox.setValue(1)
|
||||
self.insertButton.setVisible(True)
|
||||
|
@ -176,14 +142,12 @@ class EditVerseForm(QtGui.QDialog, Ui_EditVerseDialog):
|
|||
self.verseTextEdit.moveCursor(QtGui.QTextCursor.End)
|
||||
|
||||
def getVerse(self):
|
||||
return self.verseTextEdit.toPlainText(), \
|
||||
VerseType.Tags[self.verseTypeComboBox.currentIndex()], \
|
||||
return self.verseTextEdit.toPlainText(), VerseType.Tags[self.verseTypeComboBox.currentIndex()], \
|
||||
unicode(self.verseNumberBox.value())
|
||||
|
||||
def getVerseAll(self):
|
||||
text = self.verseTextEdit.toPlainText()
|
||||
if not text.startswith(u'---['):
|
||||
text = u'---[%s:1]---\n%s' % \
|
||||
(VerseType.TranslatedNames[VerseType.Verse], text)
|
||||
text = u'---[%s:1]---\n%s' % (VerseType.TranslatedNames[VerseType.Verse], text)
|
||||
return text
|
||||
|
||||
|
|
|
@ -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 @@ class Ui_MediaFilesDialog(object):
|
|||
mediaFilesDialog.setWindowModality(QtCore.Qt.ApplicationModal)
|
||||
mediaFilesDialog.resize(400, 300)
|
||||
mediaFilesDialog.setModal(True)
|
||||
mediaFilesDialog.setWindowIcon(
|
||||
build_icon(u':/icon/openlp-logo-16x16.png'))
|
||||
mediaFilesDialog.setWindowIcon(build_icon(u':/icon/openlp-logo-16x16.png'))
|
||||
self.filesVerticalLayout = QtGui.QVBoxLayout(mediaFilesDialog)
|
||||
self.filesVerticalLayout.setSpacing(8)
|
||||
self.filesVerticalLayout.setMargin(8)
|
||||
|
@ -50,21 +49,15 @@ class Ui_MediaFilesDialog(object):
|
|||
self.filesVerticalLayout.addWidget(self.selectLabel)
|
||||
self.fileListWidget = QtGui.QListWidget(mediaFilesDialog)
|
||||
self.fileListWidget.setAlternatingRowColors(True)
|
||||
self.fileListWidget.setSelectionMode(
|
||||
QtGui.QAbstractItemView.ExtendedSelection)
|
||||
self.fileListWidget.setSelectionMode(QtGui.QAbstractItemView.ExtendedSelection)
|
||||
self.fileListWidget.setObjectName(u'fileListWidget')
|
||||
self.filesVerticalLayout.addWidget(self.fileListWidget)
|
||||
self.buttonBox = create_button_box(mediaFilesDialog, u'buttonBox',
|
||||
[u'cancel', u'ok'])
|
||||
self.buttonBox = create_button_box(mediaFilesDialog, u'buttonBox', [u'cancel', u'ok'])
|
||||
self.filesVerticalLayout.addWidget(self.buttonBox)
|
||||
|
||||
self.retranslateUi(mediaFilesDialog)
|
||||
|
||||
def retranslateUi(self, mediaFilesDialog):
|
||||
mediaFilesDialog.setWindowTitle(
|
||||
translate('SongsPlugin.MediaFilesForm', 'Select Media File(s)'))
|
||||
self.selectLabel.setText(
|
||||
translate('SongsPlugin.MediaFilesForm', u'Select one or more '
|
||||
'audio files from the list below, and click OK to import them '
|
||||
'into this song.'))
|
||||
mediaFilesDialog.setWindowTitle(translate('SongsPlugin.MediaFilesForm', 'Select Media File(s)'))
|
||||
self.selectLabel.setText(translate('SongsPlugin.MediaFilesForm',
|
||||
'Select one or more audio files from the list below, and click OK to import them into this song.'))
|
||||
|
||||
|
|
|
@ -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 #
|
||||
|
|
|
@ -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 #
|
||||
|
@ -53,15 +53,12 @@ class Ui_SongBookDialog(object):
|
|||
self.publisherLabel.setBuddy(self.publisherEdit)
|
||||
self.bookLayout.addRow(self.publisherLabel, self.publisherEdit)
|
||||
self.dialogLayout.addLayout(self.bookLayout)
|
||||
self.buttonBox = create_button_box(songBookDialog, u'buttonBox',
|
||||
[u'cancel', u'save'])
|
||||
self.buttonBox = create_button_box(songBookDialog, u'buttonBox', [u'cancel', u'save'])
|
||||
self.dialogLayout.addWidget(self.buttonBox)
|
||||
self.retranslateUi(songBookDialog)
|
||||
songBookDialog.setMaximumHeight(songBookDialog.sizeHint().height())
|
||||
|
||||
def retranslateUi(self, songBookDialog):
|
||||
songBookDialog.setWindowTitle(
|
||||
translate('SongsPlugin.SongBookForm', 'Song Book Maintenance'))
|
||||
songBookDialog.setWindowTitle(translate('SongsPlugin.SongBookForm', 'Song Book Maintenance'))
|
||||
self.nameLabel.setText(translate('SongsPlugin.SongBookForm', '&Name:'))
|
||||
self.publisherLabel.setText(
|
||||
translate('SongsPlugin.SongBookForm', '&Publisher:'))
|
||||
self.publisherLabel.setText(translate('SongsPlugin.SongBookForm', '&Publisher:'))
|
||||
|
|
|
@ -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,8 +54,7 @@ class SongBookForm(QtGui.QDialog, Ui_SongBookDialog):
|
|||
def accept(self):
|
||||
if not self.nameEdit.text():
|
||||
critical_error_message_box(
|
||||
message=translate('SongsPlugin.SongBookForm',
|
||||
'You need to type in a name for the book.'))
|
||||
message=translate('SongsPlugin.SongBookForm', 'You need to type in a name for the book.'))
|
||||
self.nameEdit.setFocus()
|
||||
return False
|
||||
else:
|
||||
|
|
|
@ -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 @@ import logging
|
|||
|
||||
from PyQt4 import QtCore, QtGui
|
||||
|
||||
from openlp.core.lib import build_icon, Receiver, translate, \
|
||||
create_separated_list
|
||||
from openlp.core.lib import build_icon, Receiver, translate, create_separated_list
|
||||
from openlp.core.lib.ui import UiStrings, critical_error_message_box
|
||||
from openlp.core.ui.wizard import OpenLPWizard, WizardStrings
|
||||
from openlp.plugins.songs.lib import natcmp
|
||||
|
@ -61,11 +60,9 @@ class SongExportForm(OpenLPWizard):
|
|||
``plugin``
|
||||
The songs plugin.
|
||||
"""
|
||||
OpenLPWizard.__init__(self, parent, plugin, u'songExportWizard',
|
||||
u':/wizards/wizard_exportsong.bmp')
|
||||
OpenLPWizard.__init__(self, parent, plugin, u'songExportWizard', u':/wizards/wizard_exportsong.bmp')
|
||||
self.stop_export_flag = False
|
||||
QtCore.QObject.connect(Receiver.get_receiver(),
|
||||
QtCore.SIGNAL(u'openlp_stop_wizard'), self.stop_export)
|
||||
QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'openlp_stop_wizard'), self.stop_export)
|
||||
|
||||
def stop_export(self):
|
||||
"""
|
||||
|
@ -90,18 +87,13 @@ class SongExportForm(OpenLPWizard):
|
|||
"""
|
||||
Song wizard specific signals.
|
||||
"""
|
||||
QtCore.QObject.connect(self.availableListWidget,
|
||||
QtCore.SIGNAL(u'itemActivated(QListWidgetItem*)'),
|
||||
QtCore.QObject.connect(self.availableListWidget, QtCore.SIGNAL(u'itemActivated(QListWidgetItem*)'),
|
||||
self.onItemActivated)
|
||||
QtCore.QObject.connect(self.searchLineEdit,
|
||||
QtCore.SIGNAL(u'textEdited(const QString&)'),
|
||||
QtCore.QObject.connect(self.searchLineEdit, QtCore.SIGNAL(u'textEdited(const QString&)'),
|
||||
self.onSearchLineEditChanged)
|
||||
QtCore.QObject.connect(self.uncheckButton,
|
||||
QtCore.SIGNAL(u'clicked()'), self.onUncheckButtonClicked)
|
||||
QtCore.QObject.connect(self.checkButton,
|
||||
QtCore.SIGNAL(u'clicked()'), self.onCheckButtonClicked)
|
||||
QtCore.QObject.connect(self.directoryButton,
|
||||
QtCore.SIGNAL(u'clicked()'), self.onDirectoryButtonClicked)
|
||||
QtCore.QObject.connect(self.uncheckButton, QtCore.SIGNAL(u'clicked()'), self.onUncheckButtonClicked)
|
||||
QtCore.QObject.connect(self.checkButton, QtCore.SIGNAL(u'clicked()'), self.onCheckButtonClicked)
|
||||
QtCore.QObject.connect(self.directoryButton, QtCore.SIGNAL(u'clicked()'), self.onDirectoryButtonClicked)
|
||||
|
||||
def addCustomPages(self):
|
||||
"""
|
||||
|
@ -125,8 +117,7 @@ class SongExportForm(OpenLPWizard):
|
|||
self.searchLineEdit = QtGui.QLineEdit(self.availableSongsPage)
|
||||
self.searchLineEdit.setObjectName(u'searchLineEdit')
|
||||
self.horizontalLayout.addWidget(self.searchLineEdit)
|
||||
spacerItem = QtGui.QSpacerItem(40, 20,
|
||||
QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum)
|
||||
spacerItem = QtGui.QSpacerItem(40, 20, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum)
|
||||
self.horizontalLayout.addItem(spacerItem)
|
||||
self.uncheckButton = QtGui.QPushButton(self.availableSongsPage)
|
||||
self.uncheckButton.setObjectName(u'uncheckButton')
|
||||
|
@ -167,35 +158,23 @@ class SongExportForm(OpenLPWizard):
|
|||
"""
|
||||
Song wizard localisation.
|
||||
"""
|
||||
self.setWindowTitle(
|
||||
translate('SongsPlugin.ExportWizardForm', 'Song Export Wizard'))
|
||||
self.setWindowTitle(translate('SongsPlugin.ExportWizardForm', 'Song Export Wizard'))
|
||||
self.titleLabel.setText(WizardStrings.HeaderStyle %
|
||||
translate('OpenLP.Ui', 'Welcome to the Song Export Wizard'))
|
||||
self.informationLabel.setText(
|
||||
translate('SongsPlugin.ExportWizardForm', 'This wizard will help to'
|
||||
' export your songs to the open and free <strong>OpenLyrics'
|
||||
'</strong> worship song format.'))
|
||||
self.availableSongsPage.setTitle(
|
||||
translate('SongsPlugin.ExportWizardForm', 'Select Songs'))
|
||||
self.availableSongsPage.setSubTitle(
|
||||
translate('SongsPlugin.ExportWizardForm',
|
||||
self.informationLabel.setText(translate('SongsPlugin.ExportWizardForm', 'This wizard will help to'
|
||||
' export your songs to the open and free <strong>OpenLyrics </strong> worship song format.'))
|
||||
self.availableSongsPage.setTitle(translate('SongsPlugin.ExportWizardForm', 'Select Songs'))
|
||||
self.availableSongsPage.setSubTitle(translate('SongsPlugin.ExportWizardForm',
|
||||
'Check the songs you want to export.'))
|
||||
self.searchLabel.setText(u'%s:' % UiStrings().Search)
|
||||
self.uncheckButton.setText(
|
||||
translate('SongsPlugin.ExportWizardForm', 'Uncheck All'))
|
||||
self.checkButton.setText(
|
||||
translate('SongsPlugin.ExportWizardForm', 'Check All'))
|
||||
self.exportSongPage.setTitle(
|
||||
translate('SongsPlugin.ExportWizardForm', 'Select Directory'))
|
||||
self.exportSongPage.setSubTitle(
|
||||
translate('SongsPlugin.ExportWizardForm',
|
||||
self.uncheckButton.setText(translate('SongsPlugin.ExportWizardForm', 'Uncheck All'))
|
||||
self.checkButton.setText(translate('SongsPlugin.ExportWizardForm', 'Check All'))
|
||||
self.exportSongPage.setTitle(translate('SongsPlugin.ExportWizardForm', 'Select Directory'))
|
||||
self.exportSongPage.setSubTitle(translate('SongsPlugin.ExportWizardForm',
|
||||
'Select the directory where you want the songs to be saved.'))
|
||||
self.directoryLabel.setText(
|
||||
translate('SongsPlugin.ExportWizardForm', 'Directory:'))
|
||||
self.progressPage.setTitle(
|
||||
translate('SongsPlugin.ExportWizardForm', 'Exporting'))
|
||||
self.progressPage.setSubTitle(
|
||||
translate('SongsPlugin.ExportWizardForm',
|
||||
self.directoryLabel.setText(translate('SongsPlugin.ExportWizardForm', 'Directory:'))
|
||||
self.progressPage.setTitle(translate('SongsPlugin.ExportWizardForm', 'Exporting'))
|
||||
self.progressPage.setSubTitle(translate('SongsPlugin.ExportWizardForm',
|
||||
'Please wait while your songs are exported.'))
|
||||
self.progressLabel.setText(WizardStrings.Ready)
|
||||
self.progressBar.setFormat(WizardStrings.PercentSymbolFormat)
|
||||
|
@ -213,8 +192,7 @@ class SongExportForm(OpenLPWizard):
|
|||
]
|
||||
if not items:
|
||||
critical_error_message_box(UiStrings().NISp,
|
||||
translate('SongsPlugin.ExportWizardForm',
|
||||
'You need to add at least one Song to export.'))
|
||||
translate('SongsPlugin.ExportWizardForm', 'You need to add at least one Song to export.'))
|
||||
return False
|
||||
self.selectedListWidget.clear()
|
||||
# Add the songs to the list of selected songs.
|
||||
|
@ -227,10 +205,8 @@ class SongExportForm(OpenLPWizard):
|
|||
elif self.currentPage() == self.exportSongPage:
|
||||
if not self.directoryLineEdit.text():
|
||||
critical_error_message_box(
|
||||
translate('SongsPlugin.ExportWizardForm',
|
||||
'No Save Location specified'),
|
||||
translate('SongsPlugin.ExportWizardForm',
|
||||
'You need to specify a directory.'))
|
||||
translate('SongsPlugin.ExportWizardForm', 'No Save Location specified'),
|
||||
translate('SongsPlugin.ExportWizardForm', 'You need to specify a directory.'))
|
||||
return False
|
||||
return True
|
||||
elif self.currentPage() == self.progressPage:
|
||||
|
@ -257,13 +233,11 @@ class SongExportForm(OpenLPWizard):
|
|||
# No need to export temporary songs.
|
||||
if song.temporary:
|
||||
continue
|
||||
authors = create_separated_list([author.display_name
|
||||
for author in song.authors])
|
||||
authors = create_separated_list([author.display_name for author in song.authors])
|
||||
title = u'%s (%s)' % (unicode(song.title), authors)
|
||||
item = QtGui.QListWidgetItem(title)
|
||||
item.setData(QtCore.Qt.UserRole, song)
|
||||
item.setFlags(QtCore.Qt.ItemIsSelectable|
|
||||
QtCore.Qt.ItemIsUserCheckable | QtCore.Qt.ItemIsEnabled)
|
||||
item.setFlags(QtCore.Qt.ItemIsSelectable | QtCore.Qt.ItemIsUserCheckable | QtCore.Qt.ItemIsEnabled)
|
||||
item.setCheckState(QtCore.Qt.Unchecked)
|
||||
self.availableListWidget.addItem(item)
|
||||
Receiver.send_message(u'cursor_normal')
|
||||
|
@ -273,8 +247,7 @@ class SongExportForm(OpenLPWizard):
|
|||
Perform pre export tasks.
|
||||
"""
|
||||
OpenLPWizard.preWizard(self)
|
||||
self.progressLabel.setText(
|
||||
translate('SongsPlugin.ExportWizardForm', 'Starting export...'))
|
||||
self.progressLabel.setText(translate('SongsPlugin.ExportWizardForm', 'Starting export...'))
|
||||
Receiver.send_message(u'openlp_process_events')
|
||||
|
||||
def performWizard(self):
|
||||
|
@ -288,14 +261,10 @@ class SongExportForm(OpenLPWizard):
|
|||
]
|
||||
exporter = OpenLyricsExport(self, songs, self.directoryLineEdit.text())
|
||||
if exporter.do_export():
|
||||
self.progressLabel.setText(
|
||||
translate('SongsPlugin.SongExportForm', 'Finished export. To '
|
||||
'import these files use the <strong>OpenLyrics</strong> '
|
||||
'importer.'))
|
||||
self.progressLabel.setText(translate('SongsPlugin.SongExportForm',
|
||||
'Finished export. To import these files use the <strong>OpenLyrics</strong> importer.'))
|
||||
else:
|
||||
self.progressLabel.setText(
|
||||
translate('SongsPlugin.SongExportForm',
|
||||
'Your song export failed.'))
|
||||
self.progressLabel.setText(translate('SongsPlugin.SongExportForm', 'Your song export failed.'))
|
||||
|
||||
def _findListWidgetItems(self, listWidget, text=u''):
|
||||
"""
|
||||
|
@ -334,8 +303,7 @@ class SongExportForm(OpenLPWizard):
|
|||
The text of the *searchLineEdit*.
|
||||
"""
|
||||
search_result = [
|
||||
song for song in self._findListWidgetItems(
|
||||
self.availableListWidget, text)
|
||||
song for song in self._findListWidgetItems(self.availableListWidget, text)
|
||||
]
|
||||
for item in self._findListWidgetItems(self.availableListWidget):
|
||||
item.setHidden(item not in search_result)
|
||||
|
@ -363,5 +331,4 @@ class SongExportForm(OpenLPWizard):
|
|||
Called when the *directoryButton* was clicked. Opens a dialog and writes
|
||||
the path to *directoryLineEdit*.
|
||||
"""
|
||||
self.getFolder(translate('SongsPlugin.ExportWizardForm',
|
||||
'Select Destination Folder'), self.directoryLineEdit)
|
||||
self.getFolder(translate('SongsPlugin.ExportWizardForm', 'Select Destination Folder'), self.directoryLineEdit)
|
||||
|
|
|
@ -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,20 +60,17 @@ class SongImportForm(OpenLPWizard):
|
|||
The songs plugin.
|
||||
"""
|
||||
self.clipboard = plugin.formParent.clipboard
|
||||
OpenLPWizard.__init__(self, parent, plugin, u'songImportWizard',
|
||||
u':/wizards/wizard_importsong.bmp')
|
||||
OpenLPWizard.__init__(self, parent, plugin, u'songImportWizard', u':/wizards/wizard_importsong.bmp')
|
||||
|
||||
def setupUi(self, image):
|
||||
"""
|
||||
Set up the song wizard UI.
|
||||
"""
|
||||
self.formatWidgets = dict([(format, {}) for format in
|
||||
SongFormat.get_format_list()])
|
||||
self.formatWidgets = dict([(format, {}) for format in SongFormat.get_format_list()])
|
||||
OpenLPWizard.setupUi(self, image)
|
||||
self.currentFormat = SongFormat.OpenLyrics
|
||||
self.formatStack.setCurrentIndex(self.currentFormat)
|
||||
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):
|
||||
|
@ -102,17 +99,13 @@ class SongImportForm(OpenLPWizard):
|
|||
if select_mode == SongFormatSelect.MultipleFiles:
|
||||
QtCore.QObject.connect(self.formatWidgets[format][u'addButton'],
|
||||
QtCore.SIGNAL(u'clicked()'), self.onAddButtonClicked)
|
||||
QtCore.QObject.connect(
|
||||
self.formatWidgets[format][u'removeButton'],
|
||||
QtCore.QObject.connect(self.formatWidgets[format][u'removeButton'],
|
||||
QtCore.SIGNAL(u'clicked()'), self.onRemoveButtonClicked)
|
||||
else:
|
||||
QtCore.QObject.connect(
|
||||
self.formatWidgets[format][u'browseButton'],
|
||||
QtCore.QObject.connect(self.formatWidgets[format][u'browseButton'],
|
||||
QtCore.SIGNAL(u'clicked()'), self.onBrowseButtonClicked)
|
||||
QtCore.QObject.connect(
|
||||
self.formatWidgets[format][u'filepathEdit'],
|
||||
QtCore.SIGNAL(u'textChanged (const QString&)'),
|
||||
self.onFilepathEditTextChanged)
|
||||
QtCore.QObject.connect(self.formatWidgets[format][u'filepathEdit'],
|
||||
QtCore.SIGNAL(u'textChanged (const QString&)'), self.onFilepathEditTextChanged)
|
||||
|
||||
def addCustomPages(self):
|
||||
"""
|
||||
|
@ -130,16 +123,13 @@ class SongImportForm(OpenLPWizard):
|
|||
self.formatComboBox = QtGui.QComboBox(self.sourcePage)
|
||||
self.formatComboBox.setObjectName(u'FormatComboBox')
|
||||
self.formatLayout.addRow(self.formatLabel, self.formatComboBox)
|
||||
self.formatSpacer = QtGui.QSpacerItem(10, 0, QtGui.QSizePolicy.Fixed,
|
||||
QtGui.QSizePolicy.Minimum)
|
||||
self.formatLayout.setItem(1, QtGui.QFormLayout.LabelRole,
|
||||
self.formatSpacer)
|
||||
self.formatSpacer = QtGui.QSpacerItem(10, 0, QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Minimum)
|
||||
self.formatLayout.setItem(1, QtGui.QFormLayout.LabelRole, self.formatSpacer)
|
||||
self.sourceLayout.addLayout(self.formatLayout)
|
||||
self.formatHSpacing = self.formatLayout.horizontalSpacing()
|
||||
self.formatVSpacing = self.formatLayout.verticalSpacing()
|
||||
self.formatLayout.setVerticalSpacing(0)
|
||||
self.stackSpacer = QtGui.QSpacerItem(10, 0, QtGui.QSizePolicy.Fixed,
|
||||
QtGui.QSizePolicy.Expanding)
|
||||
self.stackSpacer = QtGui.QSpacerItem(10, 0, QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Expanding)
|
||||
self.formatStack = QtGui.QStackedLayout()
|
||||
self.formatStack.setObjectName(u'FormatStack')
|
||||
self.disablableFormats = []
|
||||
|
@ -152,63 +142,48 @@ class SongImportForm(OpenLPWizard):
|
|||
"""
|
||||
Song wizard localisation.
|
||||
"""
|
||||
self.setWindowTitle(
|
||||
translate('SongsPlugin.ImportWizardForm', 'Song Import Wizard'))
|
||||
self.titleLabel.setText(WizardStrings.HeaderStyle %
|
||||
translate('OpenLP.Ui', 'Welcome to the Song Import Wizard'))
|
||||
self.informationLabel.setText(
|
||||
translate('SongsPlugin.ImportWizardForm',
|
||||
self.setWindowTitle(translate('SongsPlugin.ImportWizardForm', 'Song Import Wizard'))
|
||||
self.titleLabel.setText(WizardStrings.HeaderStyle % translate('OpenLP.Ui', 'Welcome to the Song Import Wizard'))
|
||||
self.informationLabel.setText(translate('SongsPlugin.ImportWizardForm',
|
||||
'This wizard will help you to import songs from a variety of '
|
||||
'formats. Click the next button below to start the process by '
|
||||
'selecting a format to import from.'))
|
||||
'formats. Click the next button below to start the process by selecting a format to import from.'))
|
||||
self.sourcePage.setTitle(WizardStrings.ImportSelect)
|
||||
self.sourcePage.setSubTitle(WizardStrings.ImportSelectLong)
|
||||
self.formatLabel.setText(WizardStrings.FormatLabel)
|
||||
for format in SongFormat.get_format_list():
|
||||
format_name, custom_combo_text, description_text, select_mode = \
|
||||
SongFormat.get(format, u'name', u'comboBoxText',
|
||||
u'descriptionText', u'selectMode')
|
||||
combo_box_text = (custom_combo_text if custom_combo_text else
|
||||
format_name)
|
||||
SongFormat.get(format, u'name', u'comboBoxText', u'descriptionText', u'selectMode')
|
||||
combo_box_text = (custom_combo_text if custom_combo_text else format_name)
|
||||
self.formatComboBox.setItemText(format, combo_box_text)
|
||||
if description_text is not None:
|
||||
self.formatWidgets[format][u'descriptionLabel'].setText(
|
||||
description_text)
|
||||
self.formatWidgets[format][u'descriptionLabel'].setText(description_text)
|
||||
if select_mode == SongFormatSelect.MultipleFiles:
|
||||
self.formatWidgets[format][u'addButton'].setText(
|
||||
translate('SongsPlugin.ImportWizardForm', 'Add Files...'))
|
||||
self.formatWidgets[format][u'removeButton'].setText(
|
||||
translate('SongsPlugin.ImportWizardForm', 'Remove File(s)'))
|
||||
else:
|
||||
self.formatWidgets[format][u'browseButton'].setText(
|
||||
UiStrings().Browse)
|
||||
self.formatWidgets[format][u'browseButton'].setText(UiStrings().Browse)
|
||||
f_label = 'Filename:'
|
||||
if select_mode == SongFormatSelect.SingleFolder:
|
||||
f_label = 'Folder:'
|
||||
self.formatWidgets[format][u'filepathLabel'].setText(
|
||||
translate('SongsPlugin.ImportWizardForm', f_label))
|
||||
self.formatWidgets[format][u'filepathLabel'].setText(translate('SongsPlugin.ImportWizardForm', f_label))
|
||||
for format in self.disablableFormats:
|
||||
self.formatWidgets[format][u'disabledLabel'].setText(
|
||||
SongFormat.get(format, u'disabledLabelText'))
|
||||
self.formatWidgets[format][u'disabledLabel'].setText(SongFormat.get(format, u'disabledLabelText'))
|
||||
self.progressPage.setTitle(WizardStrings.Importing)
|
||||
self.progressPage.setSubTitle(
|
||||
translate('SongsPlugin.ImportWizardForm',
|
||||
'Please wait while your songs are imported.'))
|
||||
translate('SongsPlugin.ImportWizardForm', 'Please wait while your songs are imported.'))
|
||||
self.progressLabel.setText(WizardStrings.Ready)
|
||||
self.progressBar.setFormat(WizardStrings.PercentSymbolFormat)
|
||||
self.errorCopyToButton.setText(translate('SongsPlugin.ImportWizardForm',
|
||||
'Copy'))
|
||||
self.errorSaveToButton.setText(translate('SongsPlugin.ImportWizardForm',
|
||||
'Save to File'))
|
||||
self.errorCopyToButton.setText(translate('SongsPlugin.ImportWizardForm', 'Copy'))
|
||||
self.errorSaveToButton.setText(translate('SongsPlugin.ImportWizardForm', 'Save to File'))
|
||||
# Align all QFormLayouts towards each other.
|
||||
formats = filter(lambda f: u'filepathLabel' in self.formatWidgets[f],
|
||||
SongFormat.get_format_list())
|
||||
formats = filter(lambda f: u'filepathLabel' in self.formatWidgets[f], SongFormat.get_format_list())
|
||||
labels = [self.formatWidgets[f][u'filepathLabel'] for f in formats]
|
||||
# Get max width of all labels
|
||||
max_label_width = max(self.formatLabel.minimumSizeHint().width(),
|
||||
max([label.minimumSizeHint().width() for label in labels]))
|
||||
self.formatSpacer.changeSize(max_label_width, 0,
|
||||
QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Fixed)
|
||||
self.formatSpacer.changeSize(max_label_width, 0, QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Fixed)
|
||||
spacers = [self.formatWidgets[f][u'filepathSpacer'] for f in formats]
|
||||
for index, spacer in enumerate(spacers):
|
||||
spacer.changeSize(
|
||||
|
@ -218,8 +193,7 @@ class SongImportForm(OpenLPWizard):
|
|||
for format in SongFormat.get_format_list():
|
||||
if SongFormat.get(format, u'descriptionText') is not None:
|
||||
self.formatWidgets[format][u'descriptionSpacer'].changeSize(
|
||||
max_label_width + self.formatHSpacing, 0,
|
||||
QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Fixed)
|
||||
max_label_width + self.formatHSpacing, 0, QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Fixed)
|
||||
|
||||
def customPageChanged(self, pageId):
|
||||
"""
|
||||
|
@ -239,18 +213,14 @@ class SongImportForm(OpenLPWizard):
|
|||
elif self.currentPage() == self.sourcePage:
|
||||
format = self.currentFormat
|
||||
Settings().setValue(u'songs/last import type', format)
|
||||
select_mode, class_, error_msg = SongFormat.get(format,
|
||||
u'selectMode', u'class', u'invalidSourceMsg')
|
||||
select_mode, class_, error_msg = SongFormat.get(format, u'selectMode', u'class', u'invalidSourceMsg')
|
||||
if select_mode == SongFormatSelect.MultipleFiles:
|
||||
import_source = self.getListOfFiles(
|
||||
self.formatWidgets[format][u'fileListWidget'])
|
||||
import_source = self.getListOfFiles(self.formatWidgets[format][u'fileListWidget'])
|
||||
error_title = UiStrings().IFSp
|
||||
focus_button = self.formatWidgets[format][u'addButton']
|
||||
else:
|
||||
import_source = \
|
||||
self.formatWidgets[format][u'filepathEdit'].text()
|
||||
error_title = (UiStrings().IFSs if select_mode ==
|
||||
SongFormatSelect.SingleFile else UiStrings().IFdSs)
|
||||
import_source = self.formatWidgets[format][u'filepathEdit'].text()
|
||||
error_title = (UiStrings().IFSs if select_mode == SongFormatSelect.SingleFile else UiStrings().IFdSs)
|
||||
focus_button = self.formatWidgets[format][u'browseButton']
|
||||
if not class_.isValidSource(import_source):
|
||||
critical_error_message_box(error_title, error_msg)
|
||||
|
@ -280,12 +250,10 @@ class SongImportForm(OpenLPWizard):
|
|||
filters += u';;'
|
||||
filters += u'%s (*)' % UiStrings().AllFiles
|
||||
filenames = QtGui.QFileDialog.getOpenFileNames(self, title,
|
||||
SettingsManager.get_last_dir(self.plugin.settingsSection, 1),
|
||||
filters)
|
||||
SettingsManager.get_last_dir(self.plugin.settingsSection, 1), filters)
|
||||
if filenames:
|
||||
listbox.addItems(filenames)
|
||||
SettingsManager.set_last_dir(self.plugin.settingsSection,
|
||||
os.path.split(unicode(filenames[0]))[0], 1)
|
||||
SettingsManager.set_last_dir(self.plugin.settingsSection, os.path.split(unicode(filenames[0]))[0], 1)
|
||||
|
||||
def getListOfFiles(self, listbox):
|
||||
"""
|
||||
|
@ -307,22 +275,17 @@ class SongImportForm(OpenLPWizard):
|
|||
u'name', u'filter')
|
||||
filepathEdit = self.formatWidgets[format][u'filepathEdit']
|
||||
if select_mode == SongFormatSelect.SingleFile:
|
||||
self.getFileName(WizardStrings.OpenTypeFile % format_name,
|
||||
filepathEdit, filter)
|
||||
self.getFileName(WizardStrings.OpenTypeFile % format_name, filepathEdit, filter)
|
||||
elif select_mode == SongFormatSelect.SingleFolder:
|
||||
self.getFolder(WizardStrings.OpenTypeFolder % format_name,
|
||||
filepathEdit)
|
||||
self.getFolder(WizardStrings.OpenTypeFolder % format_name, filepathEdit)
|
||||
|
||||
def onAddButtonClicked(self):
|
||||
format = self.currentFormat
|
||||
select_mode, format_name, filter, custom_title = SongFormat.get(format,
|
||||
u'selectMode', u'name', u'filter',
|
||||
u'getFilesTitle')
|
||||
title = custom_title if custom_title \
|
||||
else WizardStrings.OpenTypeFile % format_name
|
||||
select_mode, format_name, filter, custom_title = \
|
||||
SongFormat.get(format, u'selectMode', u'name', u'filter', u'getFilesTitle')
|
||||
title = custom_title if custom_title else WizardStrings.OpenTypeFile % format_name
|
||||
if select_mode == SongFormatSelect.MultipleFiles:
|
||||
self.getFiles(title, self.formatWidgets[format][u'fileListWidget'],
|
||||
filter)
|
||||
self.getFiles(title, self.formatWidgets[format][u'fileListWidget'], filter)
|
||||
self.sourcePage.emit(QtCore.SIGNAL(u'completeChanged()'))
|
||||
|
||||
def onRemoveButtonClicked(self):
|
||||
|
@ -343,10 +306,8 @@ class SongImportForm(OpenLPWizard):
|
|||
self.restart()
|
||||
self.finishButton.setVisible(False)
|
||||
self.cancelButton.setVisible(True)
|
||||
last_import_type = Settings().value(
|
||||
u'songs/last import type', SongFormat.OpenLyrics)
|
||||
if last_import_type < 0 or \
|
||||
last_import_type >= self.formatComboBox.count():
|
||||
last_import_type = Settings().value(u'songs/last import type', SongFormat.OpenLyrics)
|
||||
if last_import_type < 0 or last_import_type >= self.formatComboBox.count():
|
||||
last_import_type = 0
|
||||
self.formatComboBox.setCurrentIndex(last_import_type)
|
||||
for format in SongFormat.get_format_list():
|
||||
|
@ -377,15 +338,14 @@ class SongImportForm(OpenLPWizard):
|
|||
source_format = self.currentFormat
|
||||
select_mode = SongFormat.get(source_format, u'selectMode')
|
||||
if select_mode == SongFormatSelect.SingleFile:
|
||||
importer = self.plugin.importSongs(source_format, filename=
|
||||
self.formatWidgets[source_format][u'filepathEdit'].text())
|
||||
importer = self.plugin.importSongs(source_format,
|
||||
filename = self.formatWidgets[source_format][u'filepathEdit'].text())
|
||||
elif select_mode == SongFormatSelect.SingleFolder:
|
||||
importer = self.plugin.importSongs(source_format, folder=
|
||||
self.formatWidgets[source_format][u'filepathEdit'].text())
|
||||
importer = self.plugin.importSongs(source_format,
|
||||
folder = self.formatWidgets[source_format][u'filepathEdit'].text())
|
||||
else:
|
||||
importer = self.plugin.importSongs(source_format,
|
||||
filenames=self.getListOfFiles(
|
||||
self.formatWidgets[source_format][u'fileListWidget']))
|
||||
filenames=self.getListOfFiles(self.formatWidgets[source_format][u'fileListWidget']))
|
||||
importer.doImport()
|
||||
self.progressLabel.setText(WizardStrings.FinishedImport)
|
||||
|
||||
|
@ -409,8 +369,8 @@ class SongImportForm(OpenLPWizard):
|
|||
|
||||
def addFileSelectItem(self):
|
||||
format = self.currentFormat
|
||||
prefix, can_disable, description_text, select_mode = SongFormat.get(
|
||||
format, u'prefix', u'canDisable', u'descriptionText', u'selectMode')
|
||||
prefix, can_disable, description_text, select_mode = \
|
||||
SongFormat.get(format, u'prefix', u'canDisable', u'descriptionText', u'selectMode')
|
||||
page = QtGui.QWidget()
|
||||
page.setObjectName(prefix + u'Page')
|
||||
if can_disable:
|
||||
|
@ -423,8 +383,7 @@ class SongImportForm(OpenLPWizard):
|
|||
if description_text is not None:
|
||||
descriptionLayout = QtGui.QHBoxLayout()
|
||||
descriptionLayout.setObjectName(prefix + u'DescriptionLayout')
|
||||
descriptionSpacer = QtGui.QSpacerItem(0, 0, QtGui.QSizePolicy.Fixed,
|
||||
QtGui.QSizePolicy.Fixed)
|
||||
descriptionSpacer = QtGui.QSpacerItem(0, 0, QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Fixed)
|
||||
descriptionLayout.addSpacerItem(descriptionSpacer)
|
||||
descriptionLabel = QtGui.QLabel(importWidget)
|
||||
descriptionLabel.setWordWrap(True)
|
||||
|
@ -434,16 +393,14 @@ class SongImportForm(OpenLPWizard):
|
|||
importLayout.addLayout(descriptionLayout)
|
||||
self.formatWidgets[format][u'descriptionLabel'] = descriptionLabel
|
||||
self.formatWidgets[format][u'descriptionSpacer'] = descriptionSpacer
|
||||
if select_mode == SongFormatSelect.SingleFile or \
|
||||
select_mode == SongFormatSelect.SingleFolder:
|
||||
if select_mode == SongFormatSelect.SingleFile or select_mode == SongFormatSelect.SingleFolder:
|
||||
filepathLayout = QtGui.QHBoxLayout()
|
||||
filepathLayout.setObjectName(prefix + u'FilepathLayout')
|
||||
filepathLayout.setContentsMargins(0, self.formatVSpacing, 0, 0)
|
||||
filepathLabel = QtGui.QLabel(importWidget)
|
||||
filepathLabel.setObjectName(prefix + u'FilepathLabel')
|
||||
filepathLayout.addWidget(filepathLabel)
|
||||
filepathSpacer = QtGui.QSpacerItem(0, 0, QtGui.QSizePolicy.Fixed,
|
||||
QtGui.QSizePolicy.Fixed)
|
||||
filepathSpacer = QtGui.QSpacerItem(0, 0, QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Fixed)
|
||||
filepathLayout.addSpacerItem(filepathSpacer)
|
||||
filepathEdit = QtGui.QLineEdit(importWidget)
|
||||
filepathEdit.setObjectName(prefix + u'FilepathEdit')
|
||||
|
@ -461,8 +418,7 @@ class SongImportForm(OpenLPWizard):
|
|||
self.formatWidgets[format][u'browseButton'] = browseButton
|
||||
elif select_mode == SongFormatSelect.MultipleFiles:
|
||||
fileListWidget = QtGui.QListWidget(importWidget)
|
||||
fileListWidget.setSelectionMode(
|
||||
QtGui.QAbstractItemView.ExtendedSelection)
|
||||
fileListWidget.setSelectionMode(QtGui.QAbstractItemView.ExtendedSelection)
|
||||
fileListWidget.setObjectName(prefix + u'FileListWidget')
|
||||
importLayout.addWidget(fileListWidget)
|
||||
buttonLayout = QtGui.QHBoxLayout()
|
||||
|
@ -533,20 +489,16 @@ class SongImportSourcePage(QtGui.QWizardPage):
|
|||
"""
|
||||
wizard = self.wizard()
|
||||
format = wizard.currentFormat
|
||||
select_mode, format_available = SongFormat.get(format, u'selectMode',
|
||||
u'availability')
|
||||
select_mode, format_available = SongFormat.get(format, u'selectMode', u'availability')
|
||||
if format_available:
|
||||
if select_mode == SongFormatSelect.MultipleFiles:
|
||||
if wizard.formatWidgets[format][u'fileListWidget'].count() > 0:
|
||||
return True
|
||||
else:
|
||||
filepath = unicode(
|
||||
wizard.formatWidgets[format][u'filepathEdit'].text())
|
||||
filepath = unicode(wizard.formatWidgets[format][u'filepathEdit'].text())
|
||||
if filepath:
|
||||
if select_mode == SongFormatSelect.SingleFile and \
|
||||
os.path.isfile(filepath):
|
||||
if select_mode == SongFormatSelect.SingleFile and os.path.isfile(filepath):
|
||||
return True
|
||||
elif select_mode == SongFormatSelect.SingleFolder and \
|
||||
os.path.isdir(filepath):
|
||||
elif select_mode == SongFormatSelect.SingleFolder and os.path.isdir(filepath):
|
||||
return True
|
||||
return False
|
||||
|
|
|
@ -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 #
|
||||
|
@ -45,14 +45,11 @@ class Ui_SongMaintenanceDialog(object):
|
|||
self.typeListWidget.setUniformItemSizes(True)
|
||||
self.typeListWidget.setObjectName(u'typeListWidget')
|
||||
self.listItemAuthors = QtGui.QListWidgetItem(self.typeListWidget)
|
||||
self.listItemAuthors.setIcon(
|
||||
build_icon(u':/songs/author_maintenance.png'))
|
||||
self.listItemAuthors.setIcon(build_icon(u':/songs/author_maintenance.png'))
|
||||
self.listItemTopics = QtGui.QListWidgetItem(self.typeListWidget)
|
||||
self.listItemTopics.setIcon(
|
||||
build_icon(u':/songs/topic_maintenance.png'))
|
||||
self.listItemTopics.setIcon(build_icon(u':/songs/topic_maintenance.png'))
|
||||
self.listItemBooks = QtGui.QListWidgetItem(self.typeListWidget)
|
||||
self.listItemBooks.setIcon(
|
||||
build_icon(u':/songs/book_maintenance.png'))
|
||||
self.listItemBooks.setIcon(build_icon(u':/songs/book_maintenance.png'))
|
||||
self.dialogLayout.addWidget(self.typeListWidget, 0, 0)
|
||||
self.stackedLayout = QtGui.QStackedLayout()
|
||||
self.stackedLayout.setObjectName(u'stackedLayout')
|
||||
|
@ -76,8 +73,7 @@ class Ui_SongMaintenanceDialog(object):
|
|||
self.authorsEditButton.setObjectName(u'authorsEditButton')
|
||||
self.authorsButtonsLayout.addWidget(self.authorsEditButton)
|
||||
self.authorsDeleteButton = QtGui.QPushButton(self.authorsPage)
|
||||
self.authorsDeleteButton.setIcon(
|
||||
build_icon(u':/songs/author_delete.png'))
|
||||
self.authorsDeleteButton.setIcon(build_icon(u':/songs/author_delete.png'))
|
||||
self.authorsDeleteButton.setObjectName(u'authorsDeleteButton')
|
||||
self.authorsButtonsLayout.addWidget(self.authorsDeleteButton)
|
||||
self.authorsLayout.addLayout(self.authorsButtonsLayout)
|
||||
|
@ -134,13 +130,11 @@ class Ui_SongMaintenanceDialog(object):
|
|||
self.stackedLayout.addWidget(self.booksPage)
|
||||
#
|
||||
self.dialogLayout.addLayout(self.stackedLayout, 0, 1)
|
||||
self.buttonBox = create_button_box(songMaintenanceDialog, u'buttonBox',
|
||||
[u'close'])
|
||||
self.buttonBox = create_button_box(songMaintenanceDialog, u'buttonBox', [u'close'])
|
||||
self.dialogLayout.addWidget(self.buttonBox, 1, 0, 1, 2)
|
||||
self.retranslateUi(songMaintenanceDialog)
|
||||
self.stackedLayout.setCurrentIndex(0)
|
||||
QtCore.QObject.connect(self.typeListWidget,
|
||||
QtCore.SIGNAL(u'currentRowChanged(int)'),
|
||||
QtCore.QObject.connect(self.typeListWidget, QtCore.SIGNAL(u'currentRowChanged(int)'),
|
||||
self.stackedLayout.setCurrentIndex)
|
||||
|
||||
def retranslateUi(self, songMaintenanceDialog):
|
||||
|
@ -158,7 +152,5 @@ class Ui_SongMaintenanceDialog(object):
|
|||
self.booksEditButton.setText(UiStrings().Edit)
|
||||
self.booksDeleteButton.setText(UiStrings().Delete)
|
||||
typeListWidth = max(self.fontMetrics().width(SongStrings.Authors),
|
||||
self.fontMetrics().width(SongStrings.Topics),
|
||||
self.fontMetrics().width(SongStrings.SongBooks))
|
||||
self.typeListWidget.setFixedWidth(typeListWidth +
|
||||
self.typeListWidget.iconSize().width() + 32)
|
||||
self.fontMetrics().width(SongStrings.Topics), self.fontMetrics().width(SongStrings.SongBooks))
|
||||
self.typeListWidget.setFixedWidth(typeListWidth + self.typeListWidget.iconSize().width() + 32)
|
||||
|
|
|
@ -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,32 +61,20 @@ class SongMaintenanceForm(QtGui.QDialog, Ui_SongMaintenanceDialog):
|
|||
self.booksDeleteButton.setEnabled(False)
|
||||
self.booksEditButton.setEnabled(False)
|
||||
# Signals
|
||||
QtCore.QObject.connect(self.authorsAddButton,
|
||||
QtCore.SIGNAL(u'clicked()'), self.onAuthorAddButtonClicked)
|
||||
QtCore.QObject.connect(self.topicsAddButton,
|
||||
QtCore.SIGNAL(u'clicked()'), self.onTopicAddButtonClicked)
|
||||
QtCore.QObject.connect(self.booksAddButton,
|
||||
QtCore.SIGNAL(u'clicked()'), self.onBookAddButtonClicked)
|
||||
QtCore.QObject.connect(self.authorsEditButton,
|
||||
QtCore.SIGNAL(u'clicked()'), self.onAuthorEditButtonClicked)
|
||||
QtCore.QObject.connect(self.topicsEditButton,
|
||||
QtCore.SIGNAL(u'clicked()'), self.onTopicEditButtonClicked)
|
||||
QtCore.QObject.connect(self.booksEditButton,
|
||||
QtCore.SIGNAL(u'clicked()'), self.onBookEditButtonClicked)
|
||||
QtCore.QObject.connect(self.authorsDeleteButton,
|
||||
QtCore.SIGNAL(u'clicked()'), self.onAuthorDeleteButtonClicked)
|
||||
QtCore.QObject.connect(self.topicsDeleteButton,
|
||||
QtCore.SIGNAL(u'clicked()'), self.onTopicDeleteButtonClicked)
|
||||
QtCore.QObject.connect(self.booksDeleteButton,
|
||||
QtCore.SIGNAL(u'clicked()'), self.onBookDeleteButtonClicked)
|
||||
QtCore.QObject.connect(self.authorsListWidget,
|
||||
QtCore.SIGNAL(u'currentRowChanged(int)'),
|
||||
QtCore.QObject.connect(self.authorsAddButton, QtCore.SIGNAL(u'clicked()'), self.onAuthorAddButtonClicked)
|
||||
QtCore.QObject.connect(self.topicsAddButton, QtCore.SIGNAL(u'clicked()'), self.onTopicAddButtonClicked)
|
||||
QtCore.QObject.connect(self.booksAddButton, QtCore.SIGNAL(u'clicked()'), self.onBookAddButtonClicked)
|
||||
QtCore.QObject.connect(self.authorsEditButton, QtCore.SIGNAL(u'clicked()'), self.onAuthorEditButtonClicked)
|
||||
QtCore.QObject.connect(self.topicsEditButton, QtCore.SIGNAL(u'clicked()'), self.onTopicEditButtonClicked)
|
||||
QtCore.QObject.connect(self.booksEditButton, QtCore.SIGNAL(u'clicked()'), self.onBookEditButtonClicked)
|
||||
QtCore.QObject.connect(self.authorsDeleteButton, QtCore.SIGNAL(u'clicked()'), self.onAuthorDeleteButtonClicked)
|
||||
QtCore.QObject.connect(self.topicsDeleteButton, QtCore.SIGNAL(u'clicked()'), self.onTopicDeleteButtonClicked)
|
||||
QtCore.QObject.connect(self.booksDeleteButton, QtCore.SIGNAL(u'clicked()'), self.onBookDeleteButtonClicked)
|
||||
QtCore.QObject.connect(self.authorsListWidget, QtCore.SIGNAL(u'currentRowChanged(int)'),
|
||||
self.onAuthorsListRowChanged)
|
||||
QtCore.QObject.connect(self.topicsListWidget,
|
||||
QtCore.SIGNAL(u'currentRowChanged(int)'),
|
||||
QtCore.QObject.connect(self.topicsListWidget, QtCore.SIGNAL(u'currentRowChanged(int)'),
|
||||
self.onTopicsListRowChanged)
|
||||
QtCore.QObject.connect(self.booksListWidget,
|
||||
QtCore.SIGNAL(u'currentRowChanged(int)'),
|
||||
QtCore.QObject.connect(self.booksListWidget, QtCore.SIGNAL(u'currentRowChanged(int)'),
|
||||
self.onBooksListRowChanged)
|
||||
|
||||
def exec_(self, fromSongEdit=False):
|
||||
|
@ -113,14 +101,12 @@ class SongMaintenanceForm(QtGui.QDialog, Ui_SongMaintenanceDialog):
|
|||
else:
|
||||
return -1
|
||||
|
||||
def _deleteItem(self, itemClass, listWidget, resetFunc, dlgTitle,
|
||||
del_text, err_text):
|
||||
def _deleteItem(self, itemClass, listWidget, resetFunc, dlgTitle, del_text, err_text):
|
||||
item_id = self._getCurrentItemId(listWidget)
|
||||
if item_id != -1:
|
||||
item = self.manager.get_object(itemClass, item_id)
|
||||
if item and not item.songs:
|
||||
if critical_error_message_box(dlgTitle, del_text, self,
|
||||
True) == QtGui.QMessageBox.Yes:
|
||||
if critical_error_message_box(dlgTitle, del_text, self, True) == QtGui.QMessageBox.Yes:
|
||||
self.manager.delete_object(itemClass, item.id)
|
||||
resetFunc()
|
||||
else:
|
||||
|
@ -133,14 +119,12 @@ class SongMaintenanceForm(QtGui.QDialog, Ui_SongMaintenanceDialog):
|
|||
Reloads the Authors list.
|
||||
"""
|
||||
self.authorsListWidget.clear()
|
||||
authors = self.manager.get_all_objects(Author,
|
||||
order_by_ref=Author.display_name)
|
||||
authors = self.manager.get_all_objects(Author, order_by_ref=Author.display_name)
|
||||
for author in authors:
|
||||
if author.display_name:
|
||||
author_name = QtGui.QListWidgetItem(author.display_name)
|
||||
else:
|
||||
author_name = QtGui.QListWidgetItem(
|
||||
u' '.join([author.first_name, author.last_name]))
|
||||
author_name = QtGui.QListWidgetItem(u' '.join([author.first_name, author.last_name]))
|
||||
author_name.setData(QtCore.Qt.UserRole, author.id)
|
||||
self.authorsListWidget.addItem(author_name)
|
||||
|
||||
|
@ -162,8 +146,7 @@ class SongMaintenanceForm(QtGui.QDialog, Ui_SongMaintenanceDialog):
|
|||
self.booksListWidget.clear()
|
||||
books = self.manager.get_all_objects(Book, order_by_ref=Book.name)
|
||||
for book in books:
|
||||
book_name = QtGui.QListWidgetItem(u'%s (%s)' % (book.name,
|
||||
book.publisher))
|
||||
book_name = QtGui.QListWidgetItem(u'%s (%s)' % (book.name, book.publisher))
|
||||
book_name.setData(QtCore.Qt.UserRole, book.id)
|
||||
self.booksListWidget.addItem(book_name)
|
||||
|
||||
|
@ -181,8 +164,7 @@ class SongMaintenanceForm(QtGui.QDialog, Ui_SongMaintenanceDialog):
|
|||
"""
|
||||
Returns *False* if the given Topic already exists, otherwise *True*.
|
||||
"""
|
||||
topics = self.manager.get_all_objects(Topic,
|
||||
Topic.name == newTopic.name)
|
||||
topics = self.manager.get_all_objects(Topic, Topic.name == newTopic.name)
|
||||
return self.__checkObject(topics, newTopic, edit)
|
||||
|
||||
def checkBook(self, newBook, edit=False):
|
||||
|
@ -190,8 +172,7 @@ class SongMaintenanceForm(QtGui.QDialog, Ui_SongMaintenanceDialog):
|
|||
Returns *False* if the given Topic already exists, otherwise *True*.
|
||||
"""
|
||||
books = self.manager.get_all_objects(Book,
|
||||
and_(Book.name == newBook.name,
|
||||
Book.publisher == newBook.publisher))
|
||||
and_(Book.name == newBook.name, Book.publisher == newBook.publisher))
|
||||
return self.__checkObject(books, newBook, edit)
|
||||
|
||||
def __checkObject(self, objects, newObject, edit):
|
||||
|
@ -226,12 +207,10 @@ class SongMaintenanceForm(QtGui.QDialog, Ui_SongMaintenanceDialog):
|
|||
self.resetAuthors()
|
||||
else:
|
||||
critical_error_message_box(
|
||||
message=translate('SongsPlugin.SongMaintenanceForm',
|
||||
'Could not add your author.'))
|
||||
message=translate('SongsPlugin.SongMaintenanceForm', 'Could not add your author.'))
|
||||
else:
|
||||
critical_error_message_box(
|
||||
message=translate('SongsPlugin.SongMaintenanceForm',
|
||||
'This author already exists.'))
|
||||
message=translate('SongsPlugin.SongMaintenanceForm', 'This author already exists.'))
|
||||
|
||||
def onTopicAddButtonClicked(self):
|
||||
if self.topicform.exec_():
|
||||
|
@ -241,12 +220,10 @@ class SongMaintenanceForm(QtGui.QDialog, Ui_SongMaintenanceDialog):
|
|||
self.resetTopics()
|
||||
else:
|
||||
critical_error_message_box(
|
||||
message=translate('SongsPlugin.SongMaintenanceForm',
|
||||
'Could not add your topic.'))
|
||||
message=translate('SongsPlugin.SongMaintenanceForm', 'Could not add your topic.'))
|
||||
else:
|
||||
critical_error_message_box(
|
||||
message=translate('SongsPlugin.SongMaintenanceForm',
|
||||
'This topic already exists.'))
|
||||
message=translate('SongsPlugin.SongMaintenanceForm', 'This topic already exists.'))
|
||||
|
||||
def onBookAddButtonClicked(self):
|
||||
if self.bookform.exec_():
|
||||
|
@ -257,12 +234,10 @@ class SongMaintenanceForm(QtGui.QDialog, Ui_SongMaintenanceDialog):
|
|||
self.resetBooks()
|
||||
else:
|
||||
critical_error_message_box(
|
||||
message=translate('SongsPlugin.SongMaintenanceForm',
|
||||
'Could not add your book.'))
|
||||
message=translate('SongsPlugin.SongMaintenanceForm', 'Could not add your book.'))
|
||||
else:
|
||||
critical_error_message_box(
|
||||
message=translate('SongsPlugin.SongMaintenanceForm',
|
||||
'This book already exists.'))
|
||||
message=translate('SongsPlugin.SongMaintenanceForm', 'This book already exists.'))
|
||||
|
||||
def onAuthorEditButtonClicked(self):
|
||||
author_id = self._getCurrentItemId(self.authorsListWidget)
|
||||
|
@ -289,14 +264,12 @@ class SongMaintenanceForm(QtGui.QDialog, Ui_SongMaintenanceDialog):
|
|||
Receiver.send_message(u'songs_load_list')
|
||||
else:
|
||||
critical_error_message_box(
|
||||
message=translate('SongsPlugin.SongMaintenanceForm',
|
||||
'Could not save your changes.'))
|
||||
message=translate('SongsPlugin.SongMaintenanceForm', 'Could not save your changes.'))
|
||||
elif critical_error_message_box(message=translate(
|
||||
'SongsPlugin.SongMaintenanceForm', 'The author %s already '
|
||||
'exists. Would you like to make songs with author %s use '
|
||||
'the existing author %s?') % (author.display_name,
|
||||
temp_display_name, author.display_name),
|
||||
parent=self, question=True) == QtGui.QMessageBox.Yes:
|
||||
'SongsPlugin.SongMaintenanceForm', 'The author %s already exists. Would you like to make songs with '
|
||||
'author %s use the existing author %s?') %
|
||||
(author.display_name, temp_display_name, author.display_name), parent=self, question=True) == \
|
||||
QtGui.QMessageBox.Yes:
|
||||
self.__mergeObjects(author, self.mergeAuthors,
|
||||
self.resetAuthors)
|
||||
else:
|
||||
|
@ -307,8 +280,7 @@ class SongMaintenanceForm(QtGui.QDialog, Ui_SongMaintenanceDialog):
|
|||
author.display_name = temp_display_name
|
||||
critical_error_message_box(
|
||||
message=translate('SongsPlugin.SongMaintenanceForm',
|
||||
'Could not save your modified author, because the '
|
||||
'author already exists.'))
|
||||
'Could not save your modified author, because the author already exists.'))
|
||||
|
||||
def onTopicEditButtonClicked(self):
|
||||
topic_id = self._getCurrentItemId(self.topicsListWidget)
|
||||
|
@ -325,22 +297,18 @@ class SongMaintenanceForm(QtGui.QDialog, Ui_SongMaintenanceDialog):
|
|||
self.resetTopics()
|
||||
else:
|
||||
critical_error_message_box(
|
||||
message=translate('SongsPlugin.SongMaintenanceForm',
|
||||
'Could not save your changes.'))
|
||||
message=translate('SongsPlugin.SongMaintenanceForm', 'Could not save your changes.'))
|
||||
elif critical_error_message_box(
|
||||
message=translate('SongsPlugin.SongMaintenanceForm',
|
||||
'The topic %s already exists. Would you like to make songs '
|
||||
'with topic %s use the existing topic %s?') % (topic.name,
|
||||
temp_name, topic.name),
|
||||
parent=self, question=True) == QtGui.QMessageBox.Yes:
|
||||
'The topic %s already exists. Would you like to make songs with topic %s use the existing topic %s?') %
|
||||
(topic.name, temp_name, topic.name), parent=self, question=True) == QtGui.QMessageBox.Yes:
|
||||
self.__mergeObjects(topic, self.mergeTopics, self.resetTopics)
|
||||
else:
|
||||
# We restore the topics's old name.
|
||||
topic.name = temp_name
|
||||
critical_error_message_box(
|
||||
message=translate('SongsPlugin.SongMaintenanceForm',
|
||||
'Could not save your modified topic, because it '
|
||||
'already exists.'))
|
||||
'Could not save your modified topic, because it already exists.'))
|
||||
|
||||
def onBookEditButtonClicked(self):
|
||||
book_id = self._getCurrentItemId(self.booksListWidget)
|
||||
|
@ -363,14 +331,11 @@ class SongMaintenanceForm(QtGui.QDialog, Ui_SongMaintenanceDialog):
|
|||
self.resetBooks()
|
||||
else:
|
||||
critical_error_message_box(
|
||||
message=translate('SongsPlugin.SongMaintenanceForm',
|
||||
'Could not save your changes.'))
|
||||
message=translate('SongsPlugin.SongMaintenanceForm', 'Could not save your changes.'))
|
||||
elif critical_error_message_box(
|
||||
message=translate('SongsPlugin.SongMaintenanceForm',
|
||||
'The book %s already exists. Would you like to make songs '
|
||||
'with book %s use the existing book %s?') % (book.name,
|
||||
temp_name, book.name),
|
||||
parent=self, question=True) == QtGui.QMessageBox.Yes:
|
||||
'The book %s already exists. Would you like to make songs with book %s use the existing book %s?') %
|
||||
(book.name, temp_name, book.name), parent=self, question=True) == QtGui.QMessageBox.Yes:
|
||||
self.__mergeObjects(book, self.mergeBooks, self.resetBooks)
|
||||
else:
|
||||
# We restore the book's old name and publisher.
|
||||
|
@ -424,8 +389,7 @@ class SongMaintenanceForm(QtGui.QDialog, Ui_SongMaintenanceDialog):
|
|||
existing_topic = self.manager.get_object_filtered(Topic,
|
||||
and_(Topic.name == oldTopic.name, Topic.id != oldTopic.id))
|
||||
# Find the songs, which have the oldTopic as topic.
|
||||
songs = self.manager.get_all_objects(Song,
|
||||
Song.topics.contains(oldTopic))
|
||||
songs = self.manager.get_all_objects(Song, Song.topics.contains(oldTopic))
|
||||
for song in songs:
|
||||
# We check if the song has already existing_topic as topic. If that
|
||||
# is not the case we add it.
|
||||
|
@ -461,10 +425,9 @@ class SongMaintenanceForm(QtGui.QDialog, Ui_SongMaintenanceDialog):
|
|||
"""
|
||||
self._deleteItem(Author, self.authorsListWidget, self.resetAuthors,
|
||||
translate('SongsPlugin.SongMaintenanceForm', 'Delete Author'),
|
||||
translate('SongsPlugin.SongMaintenanceForm', 'Are you sure you want to delete the selected author?'),
|
||||
translate('SongsPlugin.SongMaintenanceForm',
|
||||
'Are you sure you want to delete the selected author?'),
|
||||
translate('SongsPlugin.SongMaintenanceForm', 'This author cannot '
|
||||
'be deleted, they are currently assigned to at least one song.'))
|
||||
'This author cannot be deleted, they are currently assigned to at least one song.'))
|
||||
|
||||
def onTopicDeleteButtonClicked(self):
|
||||
"""
|
||||
|
@ -472,10 +435,9 @@ class SongMaintenanceForm(QtGui.QDialog, Ui_SongMaintenanceDialog):
|
|||
"""
|
||||
self._deleteItem(Topic, self.topicsListWidget, self.resetTopics,
|
||||
translate('SongsPlugin.SongMaintenanceForm', 'Delete Topic'),
|
||||
translate('SongsPlugin.SongMaintenanceForm', 'Are you sure you want to delete the selected topic?'),
|
||||
translate('SongsPlugin.SongMaintenanceForm',
|
||||
'Are you sure you want to delete the selected topic?'),
|
||||
translate('SongsPlugin.SongMaintenanceForm', 'This topic cannot '
|
||||
'be deleted, it is currently assigned to at least one song.'))
|
||||
'This topic cannot be deleted, it is currently assigned to at least one song.'))
|
||||
|
||||
def onBookDeleteButtonClicked(self):
|
||||
"""
|
||||
|
@ -483,10 +445,9 @@ class SongMaintenanceForm(QtGui.QDialog, Ui_SongMaintenanceDialog):
|
|||
"""
|
||||
self._deleteItem(Book, self.booksListWidget, self.resetBooks,
|
||||
translate('SongsPlugin.SongMaintenanceForm', 'Delete Book'),
|
||||
translate('SongsPlugin.SongMaintenanceForm', 'Are you sure you want to delete the selected book?'),
|
||||
translate('SongsPlugin.SongMaintenanceForm',
|
||||
'Are you sure you want to delete the selected book?'),
|
||||
translate('SongsPlugin.SongMaintenanceForm', 'This book cannot be '
|
||||
'deleted, it is currently assigned to at least one song.'))
|
||||
'This book cannot be deleted, it is currently assigned to at least one song.'))
|
||||
|
||||
def onAuthorsListRowChanged(self, row):
|
||||
"""
|
||||
|
|
|
@ -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,14 +47,11 @@ class Ui_TopicsDialog(object):
|
|||
self.nameLabel.setBuddy(self.nameEdit)
|
||||
self.nameLayout.addRow(self.nameLabel, self.nameEdit)
|
||||
self.dialogLayout.addLayout(self.nameLayout)
|
||||
self.buttonBox = create_button_box(topicsDialog, u'buttonBox',
|
||||
[u'cancel', u'save'])
|
||||
self.buttonBox = create_button_box(topicsDialog, u'buttonBox', [u'cancel', u'save'])
|
||||
self.dialogLayout.addWidget(self.buttonBox)
|
||||
self.retranslateUi(topicsDialog)
|
||||
topicsDialog.setMaximumHeight(topicsDialog.sizeHint().height())
|
||||
|
||||
def retranslateUi(self, topicsDialog):
|
||||
topicsDialog.setWindowTitle(
|
||||
translate('SongsPlugin.TopicsForm', 'Topic Maintenance'))
|
||||
self.nameLabel.setText(
|
||||
translate('SongsPlugin.TopicsForm', 'Topic name:'))
|
||||
topicsDialog.setWindowTitle(translate('SongsPlugin.TopicsForm', 'Topic Maintenance'))
|
||||
self.nameLabel.setText(translate('SongsPlugin.TopicsForm', 'Topic name:'))
|
||||
|
|
|
@ -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 #
|
||||
|
@ -52,8 +52,7 @@ class TopicsForm(QtGui.QDialog, Ui_TopicsDialog):
|
|||
|
||||
def accept(self):
|
||||
if not self.nameEdit.text():
|
||||
critical_error_message_box(
|
||||
message=translate('SongsPlugin.TopicsForm',
|
||||
critical_error_message_box(message=translate('SongsPlugin.TopicsForm',
|
||||
'You need to type in a topic name.'))
|
||||
self.nameEdit.setFocus()
|
||||
return False
|
||||
|
|
|
@ -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 #
|
||||
|
@ -340,15 +340,14 @@ def retrieve_windows_encoding(recommendation=None):
|
|||
choice = QtGui.QInputDialog.getItem(None,
|
||||
translate('SongsPlugin', 'Character Encoding'),
|
||||
translate('SongsPlugin', 'The codepage setting is responsible\n'
|
||||
'for the correct character representation.\n'
|
||||
'Usually you are fine with the preselected choice.'),
|
||||
'for the correct character representation.\nUsually you are fine with the preselected choice.'),
|
||||
[pair[1] for pair in encodings], recommended_index, False)
|
||||
else:
|
||||
choice = QtGui.QInputDialog.getItem(None,
|
||||
translate('SongsPlugin', 'Character Encoding'),
|
||||
translate('SongsPlugin', 'Please choose the character encoding.\n'
|
||||
'The encoding is responsible for the correct character '
|
||||
'representation.'), [pair[1] for pair in encodings], 0, False)
|
||||
'The encoding is responsible for the correct character representation.'),
|
||||
[pair[1] for pair in encodings], 0, False)
|
||||
if not choice[1]:
|
||||
return None
|
||||
return filter(lambda item: item[1] == choice[0], encodings)[0][0]
|
||||
|
@ -395,15 +394,13 @@ def clean_song(manager, song):
|
|||
song.alternate_title = clean_title(song.alternate_title)
|
||||
else:
|
||||
song.alternate_title = u''
|
||||
song.search_title = clean_string(song.title) + u'@' + \
|
||||
clean_string(song.alternate_title)
|
||||
song.search_title = clean_string(song.title) + u'@' + clean_string(song.alternate_title)
|
||||
# Only do this, if we the song is a 1.9.4 song (or older).
|
||||
if song.lyrics.find(u'<lyrics language="en">') != -1:
|
||||
# Remove the old "language" attribute from lyrics tag (prior to 1.9.5).
|
||||
# This is not very important, but this keeps the database clean. This
|
||||
# can be removed when everybody has cleaned his songs.
|
||||
song.lyrics = song.lyrics.replace(
|
||||
u'<lyrics language="en">', u'<lyrics>')
|
||||
song.lyrics = song.lyrics.replace(u'<lyrics language="en">', u'<lyrics>')
|
||||
verses = SongXML().get_verses(song.lyrics)
|
||||
song.search_lyrics = u' '.join([clean_string(verse[1])
|
||||
for verse in verses])
|
||||
|
@ -414,16 +411,14 @@ def clean_song(manager, song):
|
|||
# List for later comparison.
|
||||
compare_order = []
|
||||
for verse in verses:
|
||||
verse_type = VerseType.Tags[VerseType.from_loose_input(
|
||||
verse[0][u'type'])]
|
||||
verse_type = VerseType.Tags[VerseType.from_loose_input(verse[0][u'type'])]
|
||||
sxml.add_verse_to_lyrics(
|
||||
verse_type,
|
||||
verse[0][u'label'],
|
||||
verse[1],
|
||||
verse[0].get(u'lang')
|
||||
)
|
||||
compare_order.append((u'%s%s' % (verse_type, verse[0][u'label'])
|
||||
).upper())
|
||||
compare_order.append((u'%s%s' % (verse_type, verse[0][u'label'])).upper())
|
||||
if verse[0][u'label'] == u'1':
|
||||
compare_order.append(verse_type.upper())
|
||||
song.lyrics = unicode(sxml.extract_xml(), u'utf-8')
|
||||
|
@ -438,8 +433,7 @@ def clean_song(manager, song):
|
|||
verse_type = VerseType.Tags[
|
||||
VerseType.from_loose_input(verse_def[0])]
|
||||
if len(verse_def) > 1:
|
||||
new_order.append(
|
||||
(u'%s%s' % (verse_type, verse_def[1:])).upper())
|
||||
new_order.append((u'%s%s' % (verse_type, verse_def[1:])).upper())
|
||||
else:
|
||||
new_order.append(verse_type.upper())
|
||||
song.verse_order = u' '.join(new_order)
|
||||
|
@ -456,11 +450,9 @@ def clean_song(manager, song):
|
|||
# The song does not have any author, add one.
|
||||
if not song.authors:
|
||||
name = SongStrings.AuthorUnknown
|
||||
author = manager.get_object_filtered(
|
||||
Author, Author.display_name == name)
|
||||
author = manager.get_object_filtered(Author, Author.display_name == name)
|
||||
if author is None:
|
||||
author = Author.populate(
|
||||
display_name=name, last_name=u'', first_name=u'')
|
||||
author = Author.populate(display_name=name, last_name=u'', first_name=u'')
|
||||
song.authors.append(author)
|
||||
if song.copyright:
|
||||
song.copyright = CONTROL_CHARS.sub(u'', song.copyright).strip()
|
||||
|
@ -566,8 +558,7 @@ def strip_rtf(text, default_encoding=None):
|
|||
font = arg
|
||||
elif word == u'ansicpg':
|
||||
font_table[font] = 'cp' + arg
|
||||
elif word == u'fcharset' and font not in font_table and \
|
||||
word + arg in CHARSET_MAPPING:
|
||||
elif word == u'fcharset' and font not in font_table and word + arg in CHARSET_MAPPING:
|
||||
# \ansicpg overrides \fcharset, if present.
|
||||
font_table[font] = CHARSET_MAPPING[word + arg]
|
||||
# \'xx
|
||||
|
@ -579,8 +570,7 @@ def strip_rtf(text, default_encoding=None):
|
|||
failed = False
|
||||
while True:
|
||||
try:
|
||||
encoding, default_encoding = get_encoding(font,
|
||||
font_table, default_encoding, failed=failed)
|
||||
encoding, default_encoding = get_encoding(font, font_table, default_encoding, failed=failed)
|
||||
out.append(chr(charcode).decode(encoding))
|
||||
except UnicodeDecodeError:
|
||||
failed = True
|
||||
|
|
|
@ -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 #
|
||||
|
@ -93,8 +93,7 @@ class CCLIFileImport(SongImport):
|
|||
self.logError(filename)
|
||||
else:
|
||||
self.logError(filename,
|
||||
translate('SongsPlugin.CCLIFileImport',
|
||||
'The file does not have a valid extension.'))
|
||||
translate('SongsPlugin.CCLIFileImport', 'The file does not have a valid extension.'))
|
||||
log.info(u'Extension %s is not valid', filename)
|
||||
if self.stopImportFlag:
|
||||
return
|
||||
|
|
|
@ -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 #
|
||||
|
@ -53,8 +53,7 @@ class Book(BaseModel):
|
|||
Book model
|
||||
"""
|
||||
def __repr__(self):
|
||||
return u'<Book id="%s" name="%s" publisher="%s" />' % (
|
||||
str(self.id), self.name, self.publisher)
|
||||
return u'<Book id="%s" name="%s" publisher="%s" />' % (str(self.id), self.name, self.publisher)
|
||||
|
||||
|
||||
class MediaFile(BaseModel):
|
||||
|
@ -88,6 +87,7 @@ class Song(BaseModel):
|
|||
|
||||
# This decorator tells sqlalchemy to call this method everytime
|
||||
# any data on this object is updated.
|
||||
|
||||
@reconstructor
|
||||
def init_on_load(self):
|
||||
"""
|
||||
|
|
|
@ -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 #
|
||||
|
@ -107,8 +107,7 @@ class DreamBeamImport(SongImport):
|
|||
if song_xml.tag != u'DreamSong':
|
||||
self.logError(file, unicode(
|
||||
translate('SongsPlugin.DreamBeamImport',
|
||||
('Invalid DreamBeam song file. Missing '
|
||||
'DreamSong tag.'))))
|
||||
('Invalid DreamBeam song file. Missing DreamSong tag.'))))
|
||||
continue
|
||||
if hasattr(song_xml, u'Version'):
|
||||
self.version = float(song_xml.Version.text)
|
||||
|
@ -125,17 +124,14 @@ class DreamBeamImport(SongImport):
|
|||
verse_type = lyrics_item.get(u'Type')
|
||||
verse_number = lyrics_item.get(u'Number')
|
||||
verse_text = unicode(lyrics_item.text)
|
||||
self.addVerse(verse_text,
|
||||
(u'%s%s' % (verse_type[:1], verse_number)))
|
||||
self.addVerse(verse_text, (u'%s%s' % (verse_type[:1], verse_number)))
|
||||
if hasattr(song_xml, u'Collection'):
|
||||
self.songBookName = unicode(song_xml.Collection.text)
|
||||
if hasattr(song_xml, u'Number'):
|
||||
self.songNumber = unicode(song_xml.Number.text)
|
||||
if hasattr(song_xml, u'Sequence'):
|
||||
for LyricsSequenceItem in (
|
||||
song_xml.Sequence.iterchildren()):
|
||||
self.verseOrderList.append(
|
||||
"%s%s" % (LyricsSequenceItem.get(u'Type')[:1],
|
||||
for LyricsSequenceItem in (song_xml.Sequence.iterchildren()):
|
||||
self.verseOrderList.append("%s%s" % (LyricsSequenceItem.get(u'Type')[:1],
|
||||
LyricsSequenceItem.get(u'Number')))
|
||||
if hasattr(song_xml, u'Notes'):
|
||||
self.comments = unicode(song_xml.Notes.text)
|
||||
|
|
|
@ -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 #
|
||||
|
@ -87,8 +87,7 @@ class EasySlidesImport(SongImport):
|
|||
else:
|
||||
self.setDefaults()
|
||||
|
||||
def _addUnicodeAttribute(self, self_attribute, import_attribute,
|
||||
mandatory=False):
|
||||
def _addUnicodeAttribute(self, self_attribute, import_attribute, mandatory=False):
|
||||
"""
|
||||
Add imported values to the song model converting them to unicode at the
|
||||
same time. If the unicode decode fails or a mandatory attribute is not
|
||||
|
@ -117,8 +116,7 @@ class EasySlidesImport(SongImport):
|
|||
def _addAuthors(self, song):
|
||||
try:
|
||||
authors = unicode(song.Writer).split(u',')
|
||||
self.authors = \
|
||||
[author.strip() for author in authors if author.strip()]
|
||||
self.authors = [author.strip() for author in authors if author.strip()]
|
||||
except UnicodeDecodeError:
|
||||
log.exception(u'Unicode decode error while decoding Writer')
|
||||
self._success = False
|
||||
|
@ -170,8 +168,7 @@ class EasySlidesImport(SongImport):
|
|||
# the number of different regions in song - 1
|
||||
if len(regionlines) > 1:
|
||||
log.info(u'EasySlidesImport: the file contained a song named "%s"'
|
||||
u'with more than two regions, but only two regions are',
|
||||
u'tested, encountered regions were: %s',
|
||||
u'with more than two regions, but only two regions are tested, encountered regions were: %s',
|
||||
self.title, u','.join(regionlines.keys()))
|
||||
# if the song has regions
|
||||
regions = (len(regionlines) > 0)
|
||||
|
@ -276,8 +273,8 @@ class EasySlidesImport(SongImport):
|
|||
if tag in versetags:
|
||||
self.verseOrderList.append(tag)
|
||||
else:
|
||||
log.info(u'Got order item %s, which is not in versetags,'
|
||||
u'dropping item from presentation order', tag)
|
||||
log.info(u'Got order item %s, which is not in versetags, dropping item from presentation order',
|
||||
tag)
|
||||
except UnicodeDecodeError:
|
||||
log.exception(u'Unicode decode error while decoding Sequence')
|
||||
self._success = False
|
||||
|
|
|
@ -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 #
|
||||
|
@ -75,8 +75,7 @@ class EasyWorshipSongImport(SongImport):
|
|||
db_file = open(self.importSource, 'rb')
|
||||
self.memoFile = open(import_source_mb, 'rb')
|
||||
# Don't accept files that are clearly not paradox files
|
||||
record_size, header_size, block_size, first_block, num_fields \
|
||||
= struct.unpack('<hhxb8xh17xh', db_file.read(35))
|
||||
record_size, header_size, block_size, first_block, num_fields = struct.unpack('<hhxb8xh17xh', db_file.read(35))
|
||||
if header_size != 0x800 or block_size < 1 or block_size > 4:
|
||||
db_file.close()
|
||||
self.memoFile.close()
|
||||
|
@ -116,15 +115,12 @@ class EasyWorshipSongImport(SongImport):
|
|||
db_file.seek(120)
|
||||
field_info = db_file.read(num_fields * 2)
|
||||
db_file.seek(4 + (num_fields * 4) + 261, os.SEEK_CUR)
|
||||
field_names = db_file.read(header_size - db_file.tell()).split('\0',
|
||||
num_fields)
|
||||
field_names = db_file.read(header_size - db_file.tell()).split('\0', num_fields)
|
||||
field_names.pop()
|
||||
field_descs = []
|
||||
for i, field_name in enumerate(field_names):
|
||||
field_type, field_size = struct.unpack_from('BB',
|
||||
field_info, i * 2)
|
||||
field_descs.append(FieldDescEntry(field_name, field_type,
|
||||
field_size))
|
||||
field_type, field_size = struct.unpack_from('BB', field_info, i * 2)
|
||||
field_descs.append(FieldDescEntry(field_name, field_type, field_size))
|
||||
self.setRecordStruct(field_descs)
|
||||
# Pick out the field description indexes we will need
|
||||
try:
|
||||
|
@ -164,9 +160,7 @@ class EasyWorshipSongImport(SongImport):
|
|||
if admin:
|
||||
if copy:
|
||||
self.copyright += u', '
|
||||
self.copyright += \
|
||||
translate('SongsPlugin.EasyWorshipSongImport',
|
||||
'Administered by %s') % admin
|
||||
self.copyright += translate('SongsPlugin.EasyWorshipSongImport', 'Administered by %s') % admin
|
||||
if ccli:
|
||||
self.ccliNumber = ccli
|
||||
if authors:
|
||||
|
@ -217,10 +211,8 @@ class EasyWorshipSongImport(SongImport):
|
|||
if first_line_is_tag else verse,
|
||||
verse_type)
|
||||
if len(self.comments) > 5:
|
||||
self.comments += unicode(
|
||||
translate('SongsPlugin.EasyWorshipSongImport',
|
||||
'\n[above are Song Tags with notes imported from \
|
||||
EasyWorship]'))
|
||||
self.comments += unicode(translate('SongsPlugin.EasyWorshipSongImport',
|
||||
'\n[above are Song Tags with notes imported from EasyWorship]'))
|
||||
if self.stopImportFlag:
|
||||
break
|
||||
if not self.finish():
|
||||
|
@ -286,8 +278,7 @@ class EasyWorshipSongImport(SongImport):
|
|||
return (field ^ 0x80 == 1)
|
||||
elif field_desc.type == 0x0c or field_desc.type == 0x0d:
|
||||
# Memo or Blob
|
||||
block_start, blob_size = \
|
||||
struct.unpack_from('<II', field, len(field)-10)
|
||||
block_start, blob_size = struct.unpack_from('<II', field, len(field)-10)
|
||||
sub_block = block_start & 0xff
|
||||
block_start &= ~0xff
|
||||
self.memoFile.seek(block_start)
|
||||
|
|
|
@ -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 #
|
||||
|
@ -335,9 +335,7 @@ class FoilPresenter(object):
|
|||
author)
|
||||
author = re.compile(u'[N|n]ach.*$').sub(u'', author)
|
||||
author = author.strip()
|
||||
if re.search(
|
||||
u'\w+\.?\s+\w{3,}\s+[a|u]nd\s|\w+\.?\s+\w{3,}\s+&\s',
|
||||
author, re.U):
|
||||
if re.search(u'\w+\.?\s+\w{3,}\s+[a|u]nd\s|\w+\.?\s+\w{3,}\s+&\s', author, re.U):
|
||||
temp = re.split(u'\s[a|u]nd\s|\s&\s', author)
|
||||
for tempx in temp:
|
||||
tempx = tempx.strip()
|
||||
|
@ -345,12 +343,10 @@ class FoilPresenter(object):
|
|||
elif len(author) > 2:
|
||||
authors.append(author)
|
||||
for display_name in authors:
|
||||
author = self.manager.get_object_filtered(Author,
|
||||
Author.display_name == display_name)
|
||||
author = self.manager.get_object_filtered(Author, Author.display_name == display_name)
|
||||
if author is None:
|
||||
# We need to create a new author, as the author does not exist.
|
||||
author = Author.populate(display_name=display_name,
|
||||
last_name=display_name.split(u' ')[-1],
|
||||
author = Author.populate(display_name=display_name, last_name=display_name.split(u' ')[-1],
|
||||
first_name=u' '.join(display_name.split(u' ')[:-1]))
|
||||
self.manager.save_object(author)
|
||||
song.authors.append(author)
|
||||
|
@ -425,8 +421,7 @@ class FoilPresenter(object):
|
|||
VerseType.Tags[VerseType.PreChorus]: 1
|
||||
}
|
||||
for strophe in foilpresenterfolie.strophen.strophe:
|
||||
text = self._child(strophe.text_) if hasattr(strophe, u'text_') \
|
||||
else u''
|
||||
text = self._child(strophe.text_) if hasattr(strophe, u'text_') else u''
|
||||
verse_name = self._child(strophe.key)
|
||||
children = strophe.getchildren()
|
||||
sortnr = False
|
||||
|
|
|
@ -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 #
|
||||
|
@ -170,8 +170,7 @@ class SongFormat(object):
|
|||
u'selectMode': SongFormatSelect.MultipleFiles,
|
||||
u'filter': u'',
|
||||
u'comboBoxText': None,
|
||||
u'disabledLabelText': translate('SongsPlugin.ImportWizardForm',
|
||||
'This importer has been disabled.'),
|
||||
u'disabledLabelText': translate('SongsPlugin.ImportWizardForm', 'This importer has been disabled.'),
|
||||
u'getFilesTitle': None,
|
||||
u'invalidSourceMsg': None,
|
||||
u'descriptionText': None
|
||||
|
@ -183,75 +182,64 @@ class SongFormat(object):
|
|||
u'class': OpenLyricsImport,
|
||||
u'name': u'OpenLyrics',
|
||||
u'prefix': u'openLyrics',
|
||||
u'filter': u'%s (*.xml)' % translate('SongsPlugin.ImportWizardForm',
|
||||
'OpenLyrics Files'),
|
||||
u'comboBoxText': translate('SongsPlugin.ImportWizardForm',
|
||||
'OpenLyrics or OpenLP 2.0 Exported Song')
|
||||
u'filter': u'%s (*.xml)' % translate('SongsPlugin.ImportWizardForm', 'OpenLyrics Files'),
|
||||
u'comboBoxText': translate('SongsPlugin.ImportWizardForm', 'OpenLyrics or OpenLP 2.0 Exported Song')
|
||||
},
|
||||
OpenLP2: {
|
||||
u'class': OpenLPSongImport,
|
||||
u'name': UiStrings().OLPV2,
|
||||
u'prefix': u'openLP2',
|
||||
u'selectMode': SongFormatSelect.SingleFile,
|
||||
u'filter': u'%s (*.sqlite)' % (translate(
|
||||
'SongsPlugin.ImportWizardForm', 'OpenLP 2.0 Databases'))
|
||||
u'filter': u'%s (*.sqlite)' % (translate('SongsPlugin.ImportWizardForm', 'OpenLP 2.0 Databases'))
|
||||
},
|
||||
OpenLP1: {
|
||||
u'name': UiStrings().OLPV1,
|
||||
u'prefix': u'openLP1',
|
||||
u'canDisable': True,
|
||||
u'selectMode': SongFormatSelect.SingleFile,
|
||||
u'filter': u'%s (*.olp)' % translate('SongsPlugin.ImportWizardForm',
|
||||
'openlp.org v1.x Databases'),
|
||||
u'filter': u'%s (*.olp)' % translate('SongsPlugin.ImportWizardForm', 'openlp.org v1.x Databases'),
|
||||
u'disabledLabelText': WizardStrings.NoSqlite
|
||||
},
|
||||
Generic: {
|
||||
u'name': translate('SongsPlugin.ImportWizardForm',
|
||||
'Generic Document/Presentation'),
|
||||
u'name': translate('SongsPlugin.ImportWizardForm', 'Generic Document/Presentation'),
|
||||
u'prefix': u'generic',
|
||||
u'canDisable': True,
|
||||
u'disabledLabelText': translate('SongsPlugin.ImportWizardForm',
|
||||
'The generic document/presentation importer has been disabled '
|
||||
'because OpenLP cannot access OpenOffice or LibreOffice.'),
|
||||
u'getFilesTitle': translate('SongsPlugin.ImportWizardForm',
|
||||
'Select Document/Presentation Files')
|
||||
u'getFilesTitle': translate('SongsPlugin.ImportWizardForm', 'Select Document/Presentation Files')
|
||||
},
|
||||
CCLI: {
|
||||
u'class': CCLIFileImport,
|
||||
u'name': u'CCLI/SongSelect',
|
||||
u'prefix': u'ccli',
|
||||
u'filter': u'%s (*.usr *.txt)' % translate(
|
||||
'SongsPlugin.ImportWizardForm', 'CCLI SongSelect Files')
|
||||
u'filter': u'%s (*.usr *.txt)' % translate('SongsPlugin.ImportWizardForm', 'CCLI SongSelect Files')
|
||||
},
|
||||
DreamBeam: {
|
||||
u'class': DreamBeamImport,
|
||||
u'name': u'DreamBeam',
|
||||
u'prefix': u'dreamBeam',
|
||||
u'filter': u'%s (*.xml)' % translate('SongsPlugin.ImportWizardForm',
|
||||
'DreamBeam Song Files')
|
||||
u'filter': u'%s (*.xml)' % translate('SongsPlugin.ImportWizardForm', 'DreamBeam Song Files')
|
||||
},
|
||||
EasySlides: {
|
||||
u'class': EasySlidesImport,
|
||||
u'name': u'EasySlides',
|
||||
u'prefix': u'easySlides',
|
||||
u'selectMode': SongFormatSelect.SingleFile,
|
||||
u'filter': u'%s (*.xml)' % translate('SongsPlugin.ImportWizardForm',
|
||||
'EasySlides XML File')
|
||||
u'filter': u'%s (*.xml)' % translate('SongsPlugin.ImportWizardForm', 'EasySlides XML File')
|
||||
},
|
||||
EasyWorship: {
|
||||
u'class': EasyWorshipSongImport,
|
||||
u'name': u'EasyWorship',
|
||||
u'prefix': u'ew',
|
||||
u'selectMode': SongFormatSelect.SingleFile,
|
||||
u'filter': u'%s (*.db)' % translate('SongsPlugin.ImportWizardForm',
|
||||
'EasyWorship Song Database')
|
||||
u'filter': u'%s (*.db)' % translate('SongsPlugin.ImportWizardForm', 'EasyWorship Song Database')
|
||||
},
|
||||
FoilPresenter: {
|
||||
u'class': FoilPresenterImport,
|
||||
u'name': u'Foilpresenter',
|
||||
u'prefix': u'foilPresenter',
|
||||
u'filter': u'%s (*.foil)' % translate(
|
||||
'SongsPlugin.ImportWizardForm', 'Foilpresenter Song Files')
|
||||
u'filter': u'%s (*.foil)' % translate('SongsPlugin.ImportWizardForm', 'Foilpresenter Song Files')
|
||||
},
|
||||
MediaShout: {
|
||||
u'name': u'MediaShout',
|
||||
|
@ -291,10 +279,8 @@ class SongFormat(object):
|
|||
u'name': u'SongPro',
|
||||
u'prefix': u'songPro',
|
||||
u'selectMode': SongFormatSelect.SingleFile,
|
||||
u'filter': u'%s (*.txt)' % translate('SongsPlugin.ImportWizardForm',
|
||||
'SongPro Text Files'),
|
||||
u'comboBoxText': translate('SongsPlugin.ImportWizardForm',
|
||||
'SongPro (Export File)'),
|
||||
u'filter': u'%s (*.txt)' % translate('SongsPlugin.ImportWizardForm', 'SongPro Text Files'),
|
||||
u'comboBoxText': translate('SongsPlugin.ImportWizardForm', 'SongPro (Export File)'),
|
||||
u'descriptionText': translate('SongsPlugin.ImportWizardForm',
|
||||
'In SongPro, export your songs using the File -> Export menu')
|
||||
},
|
||||
|
@ -302,15 +288,13 @@ class SongFormat(object):
|
|||
u'class': SongShowPlusImport,
|
||||
u'name': u'SongShow Plus',
|
||||
u'prefix': u'songShowPlus',
|
||||
u'filter': u'%s (*.sbsong)' % translate(
|
||||
'SongsPlugin.ImportWizardForm', 'SongShow Plus Song Files')
|
||||
u'filter': u'%s (*.sbsong)' % translate('SongsPlugin.ImportWizardForm', 'SongShow Plus Song Files')
|
||||
},
|
||||
SongsOfFellowship: {
|
||||
u'name': u'Songs of Fellowship',
|
||||
u'prefix': u'songsOfFellowship',
|
||||
u'canDisable': True,
|
||||
u'filter': u'%s (*.rtf)' % translate('SongsPlugin.ImportWizardForm',
|
||||
'Songs Of Fellowship Song Files'),
|
||||
u'filter': u'%s (*.rtf)' % translate('SongsPlugin.ImportWizardForm', 'Songs Of Fellowship Song Files'),
|
||||
u'disabledLabelText': translate('SongsPlugin.ImportWizardForm',
|
||||
'The Songs of Fellowship importer has been disabled because '
|
||||
'OpenLP cannot access OpenOffice or LibreOffice.')
|
||||
|
@ -319,23 +303,21 @@ class SongFormat(object):
|
|||
u'class': SundayPlusImport,
|
||||
u'name': u'SundayPlus',
|
||||
u'prefix': u'sundayPlus',
|
||||
u'filter': u'%s (*.ptf)' % translate(
|
||||
'SongsPlugin.ImportWizardForm', 'SundayPlus Song Files')
|
||||
u'filter': u'%s (*.ptf)' % translate('SongsPlugin.ImportWizardForm', 'SundayPlus Song Files')
|
||||
},
|
||||
WordsOfWorship: {
|
||||
u'class': WowImport,
|
||||
u'name': u'Words of Worship',
|
||||
u'prefix': u'wordsOfWorship',
|
||||
u'filter': u'%s (*.wsg *.wow-song)' % translate(
|
||||
'SongsPlugin.ImportWizardForm', 'Words Of Worship Song Files')
|
||||
u'filter': u'%s (*.wsg *.wow-song)' %
|
||||
translate('SongsPlugin.ImportWizardForm', 'Words Of Worship Song Files')
|
||||
},
|
||||
ZionWorx: {
|
||||
u'class': ZionWorxImport,
|
||||
u'name': u'ZionWorx',
|
||||
u'prefix': u'zionWorx',
|
||||
u'selectMode': SongFormatSelect.SingleFile,
|
||||
u'comboBoxText': translate('SongsPlugin.ImportWizardForm',
|
||||
'ZionWorx (CSV)'),
|
||||
u'comboBoxText': translate('SongsPlugin.ImportWizardForm', 'ZionWorx (CSV)'),
|
||||
u'descriptionText': translate('SongsPlugin.ImportWizardForm',
|
||||
'First convert your ZionWorx database to a CSV text file, as '
|
||||
'explained in the <a href="http://manual.openlp.org/songs.html'
|
||||
|
@ -391,14 +373,12 @@ class SongFormat(object):
|
|||
return SongFormat.__attributes__.get(format)
|
||||
elif len(attributes) == 1:
|
||||
default = SongFormat.__defaults__.get(attributes[0])
|
||||
return SongFormat.__attributes__[format].get(attributes[0],
|
||||
default)
|
||||
return SongFormat.__attributes__[format].get(attributes[0], default)
|
||||
else:
|
||||
values = []
|
||||
for attr in attributes:
|
||||
default = SongFormat.__defaults__.get(attr)
|
||||
values.append(SongFormat.__attributes__[format].get(attr,
|
||||
default))
|
||||
values.append(SongFormat.__attributes__[format].get(attr, default))
|
||||
return tuple(values)
|
||||
|
||||
@staticmethod
|
||||
|
|
|
@ -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 #
|
||||
|
@ -75,9 +75,8 @@ class SongMediaItem(MediaManagerItem):
|
|||
self.plugin.manager)
|
||||
self.openLyrics = OpenLyrics(self.plugin.manager)
|
||||
self.singleServiceItem = False
|
||||
self.songMaintenanceForm = SongMaintenanceForm(
|
||||
self.plugin.manager, self)
|
||||
# Holds information about whether the edit is remotly triggered and
|
||||
self.songMaintenanceForm = SongMaintenanceForm(self.plugin.manager, self)
|
||||
# Holds information about whether the edit is remotely triggered and
|
||||
# which Song is required.
|
||||
self.remoteSong = -1
|
||||
self.editItem = None
|
||||
|
@ -88,12 +87,9 @@ class SongMediaItem(MediaManagerItem):
|
|||
song.media_files = []
|
||||
for i, bga in enumerate(item.background_audio):
|
||||
dest_file = os.path.join(
|
||||
AppLocation.get_section_data_path(self.plugin.name),
|
||||
u'audio', str(song.id), os.path.split(bga)[1])
|
||||
AppLocation.get_section_data_path(self.plugin.name), u'audio', str(song.id), os.path.split(bga)[1])
|
||||
check_directory_exists(os.path.split(dest_file)[0])
|
||||
shutil.copyfile(os.path.join(
|
||||
AppLocation.get_section_data_path(
|
||||
u'servicemanager'), bga),
|
||||
shutil.copyfile(os.path.join(AppLocation.get_section_data_path(u'servicemanager'), bga),
|
||||
dest_file)
|
||||
song.media_files.append(MediaFile.populate(
|
||||
weight=i, file_name=dest_file))
|
||||
|
@ -102,43 +98,33 @@ class SongMediaItem(MediaManagerItem):
|
|||
def addEndHeaderBar(self):
|
||||
self.toolbar.addSeparator()
|
||||
## Song Maintenance Button ##
|
||||
self.maintenanceAction = self.toolbar.addToolbarAction(
|
||||
u'maintenanceAction', icon=':/songs/song_maintenance.png',
|
||||
self.maintenanceAction = self.toolbar.addToolbarAction('maintenanceAction',
|
||||
icon=':/songs/song_maintenance.png',
|
||||
triggers=self.onSongMaintenanceClick)
|
||||
self.addSearchToToolBar()
|
||||
# Signals and slots
|
||||
QtCore.QObject.connect(Receiver.get_receiver(),
|
||||
QtCore.SIGNAL(u'songs_load_list'), self.onSongListLoad)
|
||||
QtCore.QObject.connect(Receiver.get_receiver(),
|
||||
QtCore.SIGNAL(u'config_updated'), self.configUpdated)
|
||||
QtCore.QObject.connect(Receiver.get_receiver(),
|
||||
QtCore.SIGNAL(u'songs_preview'), self.onPreviewClick)
|
||||
QtCore.QObject.connect(Receiver.get_receiver(),
|
||||
QtCore.SIGNAL(u'songs_edit'), self.onRemoteEdit)
|
||||
QtCore.QObject.connect(Receiver.get_receiver(),
|
||||
QtCore.SIGNAL(u'songs_edit_clear'), self.onRemoteEditClear)
|
||||
QtCore.QObject.connect(self.searchTextEdit,
|
||||
QtCore.SIGNAL(u'cleared()'), self.onClearTextButtonClick)
|
||||
QtCore.QObject.connect(self.searchTextEdit,
|
||||
QtCore.SIGNAL(u'searchTypeChanged(int)'),
|
||||
QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'songs_load_list'), self.onSongListLoad)
|
||||
QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'config_updated'), self.configUpdated)
|
||||
QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'songs_preview'), self.onPreviewClick)
|
||||
QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'songs_edit'), self.onRemoteEdit)
|
||||
QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'songs_edit_clear'), self.onRemoteEditClear)
|
||||
QtCore.QObject.connect(self.searchTextEdit, QtCore.SIGNAL(u'cleared()'), self.onClearTextButtonClick)
|
||||
QtCore.QObject.connect(self.searchTextEdit, QtCore.SIGNAL(u'searchTypeChanged(int)'),
|
||||
self.onSearchTextButtonClicked)
|
||||
|
||||
def addCustomContextActions(self):
|
||||
create_widget_action(self.listView, separator=True)
|
||||
create_widget_action(self.listView,
|
||||
text=translate('OpenLP.MediaManagerItem', '&Clone'),
|
||||
icon=u':/general/general_clone.png', triggers=self.onCloneClick)
|
||||
text=translate('OpenLP.MediaManagerItem', '&Clone'), icon=u':/general/general_clone.png',
|
||||
triggers=self.onCloneClick)
|
||||
|
||||
def onFocus(self):
|
||||
self.searchTextEdit.setFocus()
|
||||
|
||||
def configUpdated(self):
|
||||
self.searchAsYouType = Settings().value(
|
||||
self.settingsSection + u'/search as type', False)
|
||||
self.updateServiceOnEdit = Settings().value(
|
||||
self.settingsSection + u'/update service on edit', False)
|
||||
self.addSongFromService = Settings().value(
|
||||
self.settingsSection + u'/add song from service', True)
|
||||
self.searchAsYouType = Settings().value(self.settingsSection + u'/search as type', False)
|
||||
self.updateServiceOnEdit = Settings().value(self.settingsSection + u'/update service on edit', False)
|
||||
self.addSongFromService = Settings().value(self.settingsSection + u'/add song from service', True)
|
||||
|
||||
def retranslateUi(self):
|
||||
self.searchTextLabel.setText(u'%s:' % UiStrings().Search)
|
||||
|
@ -158,11 +144,9 @@ class SongMediaItem(MediaManagerItem):
|
|||
(SongSearch.Lyrics, u':/songs/song_search_lyrics.png',
|
||||
translate('SongsPlugin.MediaItem', 'Lyrics'),
|
||||
translate('SongsPlugin.MediaItem', 'Search Lyrics...')),
|
||||
(SongSearch.Authors, u':/songs/song_search_author.png',
|
||||
SongStrings.Authors,
|
||||
(SongSearch.Authors, u':/songs/song_search_author.png', SongStrings.Authors,
|
||||
translate('SongsPlugin.MediaItem', 'Search Authors...')),
|
||||
(SongSearch.Books, u':/songs/song_book_edit.png',
|
||||
SongStrings.SongBooks,
|
||||
(SongSearch.Books, u':/songs/song_book_edit.png', SongStrings.SongBooks,
|
||||
translate('SongsPlugin.MediaItem', 'Search Song Books...')),
|
||||
(SongSearch.Themes, u':/slides/slide_theme.png',
|
||||
UiStrings().Themes, UiStrings().SearchThemes)
|
||||
|
@ -173,8 +157,7 @@ class SongMediaItem(MediaManagerItem):
|
|||
|
||||
def onSearchTextButtonClicked(self):
|
||||
# Save the current search type to the configuration.
|
||||
Settings().setValue(u'%s/last search type' %
|
||||
self.settingsSection, self.searchTextEdit.currentSearchType())
|
||||
Settings().setValue(u'%s/last search type' % self.settingsSection, self.searchTextEdit.currentSearchType())
|
||||
# Reload the list considering the new search type.
|
||||
search_keywords = unicode(self.searchTextEdit.displayText())
|
||||
search_results = []
|
||||
|
@ -186,32 +169,27 @@ class SongMediaItem(MediaManagerItem):
|
|||
elif search_type == SongSearch.Titles:
|
||||
log.debug(u'Titles Search')
|
||||
search_results = self.plugin.manager.get_all_objects(Song,
|
||||
Song.search_title.like(u'%' + clean_string(search_keywords) +
|
||||
u'%'))
|
||||
Song.search_title.like(u'%' + clean_string(search_keywords) + u'%'))
|
||||
self.displayResultsSong(search_results)
|
||||
elif search_type == SongSearch.Lyrics:
|
||||
log.debug(u'Lyrics Search')
|
||||
search_results = self.plugin.manager.get_all_objects(Song,
|
||||
Song.search_lyrics.like(u'%' + clean_string(search_keywords) +
|
||||
u'%'))
|
||||
Song.search_lyrics.like(u'%' + clean_string(search_keywords) + u'%'))
|
||||
self.displayResultsSong(search_results)
|
||||
elif search_type == SongSearch.Authors:
|
||||
log.debug(u'Authors Search')
|
||||
search_results = self.plugin.manager.get_all_objects(Author,
|
||||
Author.display_name.like(u'%' + search_keywords + u'%'),
|
||||
Author.display_name.asc())
|
||||
Author.display_name.like(u'%' + search_keywords + u'%'), Author.display_name.asc())
|
||||
self.displayResultsAuthor(search_results)
|
||||
elif search_type == SongSearch.Books:
|
||||
log.debug(u'Books Search')
|
||||
search_results = self.plugin.manager.get_all_objects(Book,
|
||||
Book.name.like(u'%' + search_keywords + u'%'),
|
||||
Book.name.asc())
|
||||
Book.name.like(u'%' + search_keywords + u'%'), Book.name.asc())
|
||||
song_number = False
|
||||
if not search_results:
|
||||
search_keywords = search_keywords.rpartition(' ')
|
||||
search_results = self.plugin.manager.get_all_objects(Book,
|
||||
Book.name.like(u'%' + search_keywords[0] + u'%'),
|
||||
Book.name.asc())
|
||||
Book.name.like(u'%' + search_keywords[0] + u'%'), Book.name.asc())
|
||||
song_number = re.sub(r'[^0-9]', u'', search_keywords[2])
|
||||
self.displayResultsBook(search_results, song_number)
|
||||
elif search_type == SongSearch.Themes:
|
||||
|
@ -223,11 +201,9 @@ class SongMediaItem(MediaManagerItem):
|
|||
|
||||
def searchEntire(self, search_keywords):
|
||||
return self.plugin.manager.get_all_objects(Song,
|
||||
or_(Song.search_title.like(u'%' + clean_string(search_keywords)
|
||||
+ u'%'),
|
||||
Song.search_lyrics.like(u'%' + clean_string(search_keywords)
|
||||
+ u'%'),
|
||||
Song.comments.like(u'%' + search_keywords.lower() + u'%')))
|
||||
or_(Song.search_title.like(u'%' + clean_string(search_keywords) + u'%'),
|
||||
Song.search_lyrics.like(u'%' + clean_string(search_keywords) + u'%'),
|
||||
Song.comments.like(u'%' + search_keywords.lower() + u'%')))
|
||||
|
||||
def onSongListLoad(self):
|
||||
"""
|
||||
|
@ -243,8 +219,7 @@ class SongMediaItem(MediaManagerItem):
|
|||
if self.remoteTriggered == u'P':
|
||||
self.onPreviewClick()
|
||||
# Push edits to the service manager to update items
|
||||
if self.editItem and self.updateServiceOnEdit and \
|
||||
not self.remoteTriggered:
|
||||
if self.editItem and self.updateServiceOnEdit and not self.remoteTriggered:
|
||||
item = self.buildServiceItem(self.editItem)
|
||||
self.plugin.serviceManager.replaceServiceItem(item)
|
||||
self.onRemoteEditClear()
|
||||
|
@ -262,8 +237,7 @@ class SongMediaItem(MediaManagerItem):
|
|||
continue
|
||||
author_list = [author.display_name for author in song.authors]
|
||||
song_title = unicode(song.title)
|
||||
song_detail = u'%s (%s)' % (song_title,
|
||||
create_separated_list(author_list))
|
||||
song_detail = u'%s (%s)' % (song_title, create_separated_list(author_list))
|
||||
song_name = QtGui.QListWidgetItem(song_detail)
|
||||
song_name.setData(QtCore.Qt.UserRole, song.id)
|
||||
self.listView.addItem(song_name)
|
||||
|
@ -297,8 +271,7 @@ class SongMediaItem(MediaManagerItem):
|
|||
continue
|
||||
if song_number and not song_number in song.song_number:
|
||||
continue
|
||||
song_detail = u'%s - %s (%s)' % (book.name, song.song_number,
|
||||
song.title)
|
||||
song_detail = u'%s - %s (%s)' % (book.name, song.song_number, song.title)
|
||||
song_name = QtGui.QListWidgetItem(song_detail)
|
||||
song_name.setData(QtCore.Qt.UserRole, song.id)
|
||||
self.listView.addItem(song_name)
|
||||
|
@ -395,28 +368,23 @@ class SongMediaItem(MediaManagerItem):
|
|||
items = self.listView.selectedIndexes()
|
||||
if QtGui.QMessageBox.question(self,
|
||||
UiStrings().ConfirmDelete,
|
||||
translate('SongsPlugin.MediaItem',
|
||||
'Are you sure you want to delete the %n selected song(s)?', '',
|
||||
translate('SongsPlugin.MediaItem', 'Are you sure you want to delete the %n selected song(s)?', '',
|
||||
QtCore.QCoreApplication.CodecForTr, len(items)),
|
||||
QtGui.QMessageBox.StandardButtons(QtGui.QMessageBox.Yes |
|
||||
QtGui.QMessageBox.No),
|
||||
QtGui.QMessageBox.StandardButtons(QtGui.QMessageBox.Yes | QtGui.QMessageBox.No),
|
||||
QtGui.QMessageBox.Yes) == QtGui.QMessageBox.No:
|
||||
return
|
||||
Receiver.send_message(u'cursor_busy')
|
||||
self.plugin.formParent.displayProgressBar(len(items))
|
||||
for item in items:
|
||||
item_id = item.data(QtCore.Qt.UserRole)
|
||||
media_files = self.plugin.manager.get_all_objects(MediaFile,
|
||||
MediaFile.song_id == item_id)
|
||||
media_files = self.plugin.manager.get_all_objects(MediaFile, MediaFile.song_id == item_id)
|
||||
for media_file in media_files:
|
||||
try:
|
||||
os.remove(media_file.file_name)
|
||||
except:
|
||||
log.exception('Could not remove file: %s',
|
||||
media_file.file_name)
|
||||
log.exception('Could not remove file: %s', media_file.file_name)
|
||||
try:
|
||||
save_path = os.path.join(AppLocation.get_section_data_path(
|
||||
self.plugin.name), 'audio', str(item_id))
|
||||
save_path = os.path.join(AppLocation.get_section_data_path(self.plugin.name), 'audio', str(item_id))
|
||||
if os.path.exists(save_path):
|
||||
os.rmdir(save_path)
|
||||
except OSError:
|
||||
|
@ -439,15 +407,13 @@ class SongMediaItem(MediaManagerItem):
|
|||
song_xml = self.openLyrics.song_to_xml(old_song)
|
||||
new_song = self.openLyrics.xml_to_song(song_xml)
|
||||
new_song.title = u'%s <%s>' % (new_song.title,
|
||||
translate('SongsPlugin.MediaItem', 'copy',
|
||||
'For song cloning'))
|
||||
translate('SongsPlugin.MediaItem', 'copy', 'For song cloning'))
|
||||
self.plugin.manager.save_object(new_song)
|
||||
self.onSongListLoad()
|
||||
|
||||
def generateSlideData(self, service_item, item=None, xmlVersion=False,
|
||||
remote=False, context=ServiceItemContext.Service):
|
||||
log.debug(u'generateSlideData: %s, %s, %s' %
|
||||
(service_item, item, self.remoteSong))
|
||||
log.debug(u'generateSlideData: %s, %s, %s' % (service_item, item, self.remoteSong))
|
||||
item_id = self._getIdOfItemToGenerate(item, self.remoteSong)
|
||||
service_item.add_capability(ItemCapabilities.CanEdit)
|
||||
service_item.add_capability(ItemCapabilities.CanPreview)
|
||||
|
@ -472,8 +438,7 @@ class SongMediaItem(MediaManagerItem):
|
|||
verse_tag = verse[0][u'type']
|
||||
verse_index = None
|
||||
if len(verse_tag) > 1:
|
||||
verse_index = \
|
||||
VerseType.from_translated_string(verse_tag)
|
||||
verse_index = VerseType.from_translated_string(verse_tag)
|
||||
if verse_index is None:
|
||||
verse_index = VerseType.from_string(verse_tag, None)
|
||||
if verse_index is None:
|
||||
|
@ -487,18 +452,14 @@ class SongMediaItem(MediaManagerItem):
|
|||
if not order:
|
||||
break
|
||||
for verse in verse_list:
|
||||
if verse[0][u'type'][0].lower() == order[0] and \
|
||||
(verse[0][u'label'].lower() == order[1:] or \
|
||||
not order[1:]):
|
||||
if verse[0][u'type'][0].lower() == order[0] and (verse[0][u'label'].lower() == order[1:] or \
|
||||
not order[1:]):
|
||||
if verse_tags_translated:
|
||||
verse_index = VerseType.from_translated_tag(
|
||||
verse[0][u'type'])
|
||||
verse_index = VerseType.from_translated_tag(verse[0][u'type'])
|
||||
else:
|
||||
verse_index = VerseType.from_tag(
|
||||
verse[0][u'type'])
|
||||
verse_index = VerseType.from_tag(verse[0][u'type'])
|
||||
verse_tag = VerseType.TranslatedTags[verse_index]
|
||||
verse_def = u'%s%s' % (verse_tag,
|
||||
verse[0][u'label'])
|
||||
verse_def = u'%s%s' % (verse_tag, verse[0][u'label'])
|
||||
service_item.add_from_text(verse[1], verse_def)
|
||||
else:
|
||||
verses = song.lyrics.split(u'\n\n')
|
||||
|
@ -510,20 +471,17 @@ class SongMediaItem(MediaManagerItem):
|
|||
service_item.raw_footer.append(create_separated_list(author_list))
|
||||
service_item.raw_footer.append(song.copyright)
|
||||
if Settings().value(u'general/ccli number', u''):
|
||||
service_item.raw_footer.append(
|
||||
translate('SongsPlugin.MediaItem', 'CCLI License: ') +
|
||||
service_item.raw_footer.append(translate('SongsPlugin.MediaItem', 'CCLI License: ') +
|
||||
Settings().value(u'general/ccli number', u''))
|
||||
service_item.audit = [
|
||||
song.title, author_list, song.copyright, unicode(song.ccli_number)
|
||||
]
|
||||
service_item.data_string = {u'title': song.search_title,
|
||||
u'authors': u', '.join(author_list)}
|
||||
service_item.data_string = {u'title': song.search_title, u'authors': u', '.join(author_list)}
|
||||
service_item.xml_version = self.openLyrics.song_to_xml(song)
|
||||
# Add the audio file to the service item.
|
||||
if song.media_files:
|
||||
service_item.add_capability(ItemCapabilities.HasBackgroundAudio)
|
||||
service_item.background_audio = \
|
||||
[m.file_name for m in song.media_files]
|
||||
service_item.background_audio = [m.file_name for m in song.media_files]
|
||||
return True
|
||||
|
||||
def serviceLoad(self, item):
|
||||
|
@ -540,12 +498,10 @@ class SongMediaItem(MediaManagerItem):
|
|||
# duplicate. This should work for songs without alternate title.
|
||||
search_results = self.plugin.manager.get_all_objects(Song,
|
||||
Song.search_title == (re.compile(r'\W+', re.UNICODE).sub(u' ',
|
||||
item.data_string[u'title'].strip()) + u'@').strip().lower(),
|
||||
Song.search_title.asc())
|
||||
item.data_string[u'title'].strip()) + u'@').strip().lower(), Song.search_title.asc())
|
||||
else:
|
||||
search_results = self.plugin.manager.get_all_objects(Song,
|
||||
Song.search_title == item.data_string[u'title'],
|
||||
Song.search_title.asc())
|
||||
Song.search_title == item.data_string[u'title'], Song.search_title.asc())
|
||||
editId = 0
|
||||
add_song = True
|
||||
temporary = False
|
||||
|
@ -555,8 +511,7 @@ class SongMediaItem(MediaManagerItem):
|
|||
same_authors = True
|
||||
for author in song.authors:
|
||||
if author.display_name in author_list:
|
||||
author_list = author_list.replace(author.display_name,
|
||||
u'', 1)
|
||||
author_list = author_list.replace(author.display_name, u'', 1)
|
||||
else:
|
||||
same_authors = False
|
||||
break
|
||||
|
@ -584,8 +539,7 @@ class SongMediaItem(MediaManagerItem):
|
|||
temporary = True
|
||||
# Update service with correct song id.
|
||||
if editId:
|
||||
Receiver.send_message(u'service_item_update',
|
||||
u'%s:%s:%s' % (editId, item._uuid, temporary))
|
||||
Receiver.send_message(u'service_item_update%s:%s:%s' % (editId, item._uuid, temporary))
|
||||
|
||||
def search(self, string, showError):
|
||||
"""
|
||||
|
|
|
@ -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,8 +60,7 @@ class MediaShoutImport(SongImport):
|
|||
except:
|
||||
# Unfortunately no specific exception type
|
||||
self.logError(self.importSource,
|
||||
translate('SongsPlugin.MediaShoutImport',
|
||||
'Unable to open the MediaShout database.'))
|
||||
translate('SongsPlugin.MediaShoutImport', 'Unable to open the MediaShout database.'))
|
||||
return
|
||||
cursor = conn.cursor()
|
||||
cursor.execute(u'SELECT Record, Title, Author, Copyright, '
|
||||
|
@ -82,8 +81,8 @@ class MediaShoutImport(SongImport):
|
|||
u'WHERE SongThemes.Record = %s' % song.Record)
|
||||
topics = cursor.fetchall()
|
||||
cursor.execute(u'SELECT Name FROM Groups INNER JOIN SongGroups '
|
||||
u'ON SongGroups.GroupId = Groups.GroupId '
|
||||
u'WHERE SongGroups.Record = %s' % song.Record)
|
||||
u'ON SongGroups.GroupId = Groups.GroupId '
|
||||
u'WHERE SongGroups.Record = %s' % song.Record)
|
||||
topics += cursor.fetchall()
|
||||
self.processSong(song, verses, verse_order, topics)
|
||||
|
||||
|
@ -103,11 +102,9 @@ class MediaShoutImport(SongImport):
|
|||
else:
|
||||
self.songBookName = song.SongID
|
||||
for verse in verses:
|
||||
tag = VERSE_TAGS[verse.Type] + unicode(verse.Number) \
|
||||
if verse.Type < len(VERSE_TAGS) else u'O'
|
||||
tag = VERSE_TAGS[verse.Type] + unicode(verse.Number) if verse.Type < len(VERSE_TAGS) else u'O'
|
||||
self.addVerse(verse.Text, tag)
|
||||
for order in verse_order:
|
||||
if order.Type < len(VERSE_TAGS):
|
||||
self.verseOrderList.append(VERSE_TAGS[order.Type]
|
||||
+ unicode(order.Number))
|
||||
self.verseOrderList.append(VERSE_TAGS[order.Type] + unicode(order.Number))
|
||||
self.finish()
|
||||
|
|
|
@ -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 #
|
||||
|
@ -70,15 +70,13 @@ class OpenLP1SongImport(SongImport):
|
|||
"""
|
||||
if not self.importSource.endswith(u'.olp'):
|
||||
self.logError(self.importSource,
|
||||
translate('SongsPlugin.OpenLP1SongImport',
|
||||
'Not a valid openlp.org 1.x song database.'))
|
||||
translate('SongsPlugin.OpenLP1SongImport', 'Not a valid openlp.org 1.x song database.'))
|
||||
return
|
||||
encoding = self.getEncoding()
|
||||
if not encoding:
|
||||
return
|
||||
# Connect to the database.
|
||||
connection = sqlite.connect(self.importSource, mode=0444,
|
||||
encoding=(encoding, 'replace'))
|
||||
connection = sqlite.connect(self.importSource, mode=0444, encoding=(encoding, 'replace'))
|
||||
cursor = connection.cursor()
|
||||
# Determine if the db supports linking audio to songs.
|
||||
cursor.execute(u'SELECT name FROM sqlite_master '
|
||||
|
@ -212,9 +210,7 @@ class OpenLP1SongImport(SongImport):
|
|||
``filename``
|
||||
The filename to expand.
|
||||
"""
|
||||
if sys.platform != u'win32' and \
|
||||
not os.environ.get(u'ALLUSERSPROFILE') and \
|
||||
not os.environ.get(u'APPDATA'):
|
||||
if sys.platform != u'win32' and not os.environ.get(u'ALLUSERSPROFILE') and not os.environ.get(u'APPDATA'):
|
||||
return filename
|
||||
common_app_data = os.path.join(os.environ[u'ALLUSERSPROFILE'],
|
||||
os.path.split(os.environ[u'APPDATA'])[1])
|
||||
|
|
|
@ -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,7 @@ song databases into the current installation database.
|
|||
import logging
|
||||
|
||||
from sqlalchemy import create_engine, MetaData, Table
|
||||
from sqlalchemy.orm import class_mapper, mapper, relation, scoped_session, \
|
||||
sessionmaker
|
||||
from sqlalchemy.orm import class_mapper, mapper, relation, scoped_session, sessionmaker
|
||||
from sqlalchemy.orm.exc import UnmappedClassError
|
||||
|
||||
from openlp.core.lib import translate
|
||||
|
@ -109,8 +108,7 @@ class OpenLPSongImport(SongImport):
|
|||
# Check the file type
|
||||
if not self.importSource.endswith(u'.sqlite'):
|
||||
self.logError(self.importSource,
|
||||
translate('SongsPlugin.OpenLPSongImport',
|
||||
'Not a valid OpenLP 2.0 song database.'))
|
||||
translate('SongsPlugin.OpenLPSongImport', 'Not a valid OpenLP 2.0 song database.'))
|
||||
return
|
||||
self.importSource = u'sqlite:///%s' % self.importSource
|
||||
# Load the db file
|
||||
|
@ -131,8 +129,7 @@ class OpenLPSongImport(SongImport):
|
|||
source_media_files_songs_table = None
|
||||
if has_media_files:
|
||||
source_media_files_table = source_meta.tables[u'media_files']
|
||||
source_media_files_songs_table = \
|
||||
source_meta.tables.get(u'media_files_songs')
|
||||
source_media_files_songs_table = source_meta.tables.get(u'media_files_songs')
|
||||
try:
|
||||
class_mapper(OldMediaFile)
|
||||
except UnmappedClassError:
|
||||
|
@ -153,8 +150,7 @@ class OpenLPSongImport(SongImport):
|
|||
song_props['media_files'] = relation(OldMediaFile,
|
||||
backref='songs',
|
||||
foreign_keys=[source_media_files_table.c.song_id],
|
||||
primaryjoin=source_songs_table.c.id == \
|
||||
source_media_files_table.c.song_id)
|
||||
primaryjoin=source_songs_table.c.id == source_media_files_table.c.song_id)
|
||||
try:
|
||||
class_mapper(OldAuthor)
|
||||
except UnmappedClassError:
|
||||
|
@ -195,8 +191,7 @@ class OpenLPSongImport(SongImport):
|
|||
new_song.theme_name = song.theme_name
|
||||
new_song.ccli_number = song.ccli_number
|
||||
for author in song.authors:
|
||||
existing_author = self.manager.get_object_filtered(
|
||||
Author, Author.display_name == author.display_name)
|
||||
existing_author = self.manager.get_object_filtered(Author, Author.display_name == author.display_name)
|
||||
if existing_author is None:
|
||||
existing_author = Author.populate(
|
||||
first_name=author.first_name,
|
||||
|
@ -204,39 +199,32 @@ class OpenLPSongImport(SongImport):
|
|||
display_name=author.display_name)
|
||||
new_song.authors.append(existing_author)
|
||||
if song.book:
|
||||
existing_song_book = self.manager.get_object_filtered(
|
||||
Book, Book.name == song.book.name)
|
||||
existing_song_book = self.manager.get_object_filtered(Book, Book.name == song.book.name)
|
||||
if existing_song_book is None:
|
||||
existing_song_book = Book.populate(name=song.book.name,
|
||||
publisher=song.book.publisher)
|
||||
existing_song_book = Book.populate(name=song.book.name, publisher=song.book.publisher)
|
||||
new_song.book = existing_song_book
|
||||
if song.topics:
|
||||
for topic in song.topics:
|
||||
existing_topic = self.manager.get_object_filtered(
|
||||
Topic, Topic.name == topic.name)
|
||||
existing_topic = self.manager.get_object_filtered(Topic, Topic.name == topic.name)
|
||||
if existing_topic is None:
|
||||
existing_topic = Topic.populate(name=topic.name)
|
||||
new_song.topics.append(existing_topic)
|
||||
if has_media_files:
|
||||
if song.media_files:
|
||||
for media_file in song.media_files:
|
||||
existing_media_file = \
|
||||
self.manager.get_object_filtered(MediaFile,
|
||||
existing_media_file = self.manager.get_object_filtered(MediaFile,
|
||||
MediaFile.file_name == media_file.file_name)
|
||||
if existing_media_file:
|
||||
new_song.media_files.append(existing_media_file)
|
||||
else:
|
||||
new_song.media_files.append(MediaFile.populate(
|
||||
file_name=media_file.file_name))
|
||||
new_song.media_files.append(MediaFile.populate(file_name=media_file.file_name))
|
||||
clean_song(self.manager, new_song)
|
||||
self.manager.save_object(new_song)
|
||||
if progressDialog:
|
||||
progressDialog.setValue(progressDialog.value() + 1)
|
||||
progressDialog.setLabelText(
|
||||
WizardStrings.ImportingType % new_song.title)
|
||||
progressDialog.setLabelText(WizardStrings.ImportingType % new_song.title)
|
||||
else:
|
||||
self.importWizard.incrementProgressBar(
|
||||
WizardStrings.ImportingType % new_song.title)
|
||||
self.importWizard.incrementProgressBar(WizardStrings.ImportingType % new_song.title)
|
||||
if self.stopImportFlag:
|
||||
break
|
||||
engine.dispose()
|
||||
|
|
|
@ -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 OooImport(SongImport):
|
|||
except NoConnectException as exc:
|
||||
self.logError(
|
||||
self.importSource[0],
|
||||
translate('SongsPlugin.SongImport',
|
||||
'Cannot access OpenOffice or LibreOffice'))
|
||||
translate('SongsPlugin.SongImport', 'Cannot access OpenOffice or LibreOffice'))
|
||||
log.error(exc)
|
||||
return
|
||||
self.importWizard.progressBar.setMaximum(len(self.importSource))
|
||||
|
@ -87,12 +86,9 @@ class OooImport(SongImport):
|
|||
self.processOooDocument()
|
||||
self.closeOooFile()
|
||||
else:
|
||||
self.logError(self.filepath,
|
||||
translate('SongsPlugin.SongImport',
|
||||
'Unable to open file'))
|
||||
self.logError(self.filepath, translate('SongsPlugin.SongImport', 'Unable to open file'))
|
||||
else:
|
||||
self.logError(self.filepath,
|
||||
translate('SongsPlugin.SongImport', 'File not found'))
|
||||
self.logError(self.filepath, translate('SongsPlugin.SongImport', 'File not found'))
|
||||
self.closeOoo()
|
||||
|
||||
def processOooDocument(self):
|
||||
|
@ -100,8 +96,7 @@ class OooImport(SongImport):
|
|||
Handle the import process for OpenOffice files. This method facilitates
|
||||
allowing subclasses to handle specific types of OpenOffice files.
|
||||
"""
|
||||
if self.document.supportsService(
|
||||
"com.sun.star.presentation.PresentationDocument"):
|
||||
if self.document.supportsService("com.sun.star.presentation.PresentationDocument"):
|
||||
self.processPres()
|
||||
if self.document.supportsService("com.sun.star.text.TextDocument"):
|
||||
self.processDoc()
|
||||
|
@ -113,12 +108,10 @@ class OooImport(SongImport):
|
|||
"""
|
||||
if os.name == u'nt':
|
||||
self.startOooProcess()
|
||||
self.desktop = self.oooManager.createInstance(
|
||||
u'com.sun.star.frame.Desktop')
|
||||
self.desktop = self.oooManager.createInstance(u'com.sun.star.frame.Desktop')
|
||||
else:
|
||||
context = uno.getComponentContext()
|
||||
resolver = context.ServiceManager.createInstanceWithContext(
|
||||
u'com.sun.star.bridge.UnoUrlResolver', context)
|
||||
resolver = context.ServiceManager.createInstanceWithContext(u'com.sun.star.bridge.UnoUrlResolver', context)
|
||||
uno_instance = None
|
||||
loop = 0
|
||||
while uno_instance is None and loop < 5:
|
||||
|
@ -131,8 +124,7 @@ class OooImport(SongImport):
|
|||
loop += 1
|
||||
else:
|
||||
manager = uno_instance.ServiceManager
|
||||
self.desktop = manager.createInstanceWithContext(
|
||||
"com.sun.star.frame.Desktop", uno_instance)
|
||||
self.desktop = manager.createInstanceWithContext("com.sun.star.frame.Desktop", uno_instance)
|
||||
return
|
||||
raise
|
||||
|
||||
|
@ -166,13 +158,11 @@ class OooImport(SongImport):
|
|||
try:
|
||||
self.document = self.desktop.loadComponentFromURL(url, u'_blank',
|
||||
0, properties)
|
||||
if not self.document.supportsService(
|
||||
"com.sun.star.presentation.PresentationDocument") and not \
|
||||
self.document.supportsService("com.sun.star.text.TextDocument"):
|
||||
if not self.document.supportsService("com.sun.star.presentation.PresentationDocument") and not \
|
||||
self.document.supportsService("com.sun.star.text.TextDocument"):
|
||||
self.closeOooFile()
|
||||
else:
|
||||
self.importWizard.incrementProgressBar(
|
||||
u'Processing file ' + filepath, 0)
|
||||
self.importWizard.incrementProgressBar(u'Processing file ' + filepath, 0)
|
||||
except AttributeError:
|
||||
log.exception("openOooFile failed: %s", url)
|
||||
return
|
||||
|
|
|
@ -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 #
|
||||
|
@ -67,12 +67,11 @@ class OpenLyricsExport(object):
|
|||
Receiver.send_message(u'openlp_process_events')
|
||||
if self.parent.stop_export_flag:
|
||||
return False
|
||||
self.parent.incrementProgressBar(translate(
|
||||
'SongsPlugin.OpenLyricsExport', 'Exporting "%s"...') % song.title)
|
||||
self.parent.incrementProgressBar(translate('SongsPlugin.OpenLyricsExport', 'Exporting "%s"...') %
|
||||
song.title)
|
||||
xml = openLyrics.song_to_xml(song)
|
||||
tree = etree.ElementTree(etree.fromstring(xml))
|
||||
filename = u'%s (%s)' % (song.title,
|
||||
u', '.join([author.display_name for author in song.authors]))
|
||||
filename = u'%s (%s)' % (song.title, u', '.join([author.display_name for author in song.authors]))
|
||||
filename = clean_filename(filename)
|
||||
# Ensure the filename isn't too long for some filesystems
|
||||
filename = u'%s.xml' % filename[0:250 - len(self.save_path)]
|
||||
|
|
|
@ -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,8 +65,7 @@ class OpenLyricsImport(SongImport):
|
|||
for file_path in self.importSource:
|
||||
if self.stopImportFlag:
|
||||
return
|
||||
self.importWizard.incrementProgressBar(
|
||||
WizardStrings.ImportingType % os.path.basename(file_path))
|
||||
self.importWizard.incrementProgressBar(WizardStrings.ImportingType % os.path.basename(file_path))
|
||||
try:
|
||||
# Pass a file object, because lxml does not cope with some
|
||||
# special characters in the path (see lp:757673 and lp:744337).
|
||||
|
|
|
@ -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 #
|
||||
|
@ -133,9 +133,7 @@ class OpenSongImport(SongImport):
|
|||
root = tree.getroot()
|
||||
if root.tag != u'song':
|
||||
self.logError(file.name, unicode(
|
||||
translate('SongsPlugin.OpenSongImport',
|
||||
('Invalid OpenSong song file. Missing '
|
||||
'song tag.'))))
|
||||
translate('SongsPlugin.OpenSongImport', ('Invalid OpenSong song file. Missing song tag.'))))
|
||||
return
|
||||
fields = dir(root)
|
||||
decode = {
|
||||
|
@ -179,8 +177,7 @@ class OpenSongImport(SongImport):
|
|||
if not this_line:
|
||||
continue
|
||||
# skip guitar chords and page and column breaks
|
||||
if this_line.startswith(u'.') or this_line.startswith(u'---') \
|
||||
or this_line.startswith(u'-!!'):
|
||||
if this_line.startswith(u'.') or this_line.startswith(u'---') or this_line.startswith(u'-!!'):
|
||||
continue
|
||||
# verse/chorus/etc. marker
|
||||
if this_line.startswith(u'['):
|
||||
|
@ -200,12 +197,10 @@ class OpenSongImport(SongImport):
|
|||
# the verse tag
|
||||
verse_tag = content
|
||||
verse_num = u'1'
|
||||
verse_index = VerseType.from_loose_input(verse_tag) \
|
||||
if verse_tag else 0
|
||||
verse_index = VerseType.from_loose_input(verse_tag) if verse_tag else 0
|
||||
verse_tag = VerseType.Tags[verse_index]
|
||||
inst = 1
|
||||
if [verse_tag, verse_num, inst] in our_verse_order \
|
||||
and verse_num in verses.get(verse_tag, {}):
|
||||
if [verse_tag, verse_num, inst] in our_verse_order and verse_num in verses.get(verse_tag, {}):
|
||||
inst = len(verses[verse_tag][verse_num]) + 1
|
||||
continue
|
||||
# number at start of line.. it's verse number
|
||||
|
@ -232,8 +227,7 @@ class OpenSongImport(SongImport):
|
|||
while(length < len(verse_num) and verse_num[length].isnumeric()):
|
||||
length += 1
|
||||
verse_def = u'%s%s' % (verse_tag, verse_num[:length])
|
||||
verse_joints[verse_def] = \
|
||||
u'%s\n[---]\n%s' % (verse_joints[verse_def], lines) \
|
||||
verse_joints[verse_def] = u'%s\n[---]\n%s' % (verse_joints[verse_def], lines) \
|
||||
if verse_def in verse_joints else lines
|
||||
for verse_def, lines in verse_joints.iteritems():
|
||||
self.addVerse(lines, verse_def)
|
||||
|
|
|
@ -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 #
|
||||
|
@ -101,10 +101,8 @@ class PowerSongImport(SongImport):
|
|||
else:
|
||||
self.importSource = u''
|
||||
if not self.importSource or not isinstance(self.importSource, list):
|
||||
self.logError(translate('SongsPlugin.PowerSongImport',
|
||||
'No songs to import.'),
|
||||
translate('SongsPlugin.PowerSongImport',
|
||||
'No %s files found.') % PS_string)
|
||||
self.logError(translate('SongsPlugin.PowerSongImport', 'No songs to import.'),
|
||||
translate('SongsPlugin.PowerSongImport', 'No %s files found.') % PS_string)
|
||||
return
|
||||
self.importWizard.progressBar.setMaximum(len(self.importSource))
|
||||
for file in self.importSource:
|
||||
|
@ -122,9 +120,8 @@ class PowerSongImport(SongImport):
|
|||
except ValueError:
|
||||
parse_error = True
|
||||
self.logError(os.path.basename(file), unicode(
|
||||
translate('SongsPlugin.PowerSongImport',
|
||||
'Invalid %s file. Unexpected byte value.'))
|
||||
% PS_string)
|
||||
translate('SongsPlugin.PowerSongImport', 'Invalid %s file. Unexpected byte value.')) %
|
||||
PS_string)
|
||||
break
|
||||
else:
|
||||
if label == u'TITLE':
|
||||
|
@ -141,21 +138,18 @@ class PowerSongImport(SongImport):
|
|||
# Check that file had TITLE field
|
||||
if not self.title:
|
||||
self.logError(os.path.basename(file), unicode(
|
||||
translate('SongsPlugin.PowerSongImport',
|
||||
'Invalid %s file. Missing "TITLE" header.')) % PS_string)
|
||||
translate('SongsPlugin.PowerSongImport', 'Invalid %s file. Missing "TITLE" header.')) % PS_string)
|
||||
continue
|
||||
# Check that file had COPYRIGHTLINE label
|
||||
if not found_copyright:
|
||||
self.logError(self.title, unicode(
|
||||
translate('SongsPlugin.PowerSongImport',
|
||||
'Invalid %s file. Missing "COPYRIGHTLINE" '
|
||||
'header.')) % PS_string)
|
||||
translate('SongsPlugin.PowerSongImport', 'Invalid %s file. Missing "COPYRIGHTLINE" header.')) %
|
||||
PS_string)
|
||||
continue
|
||||
# Check that file had at least one verse
|
||||
if not self.verses:
|
||||
self.logError(self.title, unicode(
|
||||
translate('SongsPlugin.PowerSongImport',
|
||||
'Verses not found. Missing "PART" header.')))
|
||||
translate('SongsPlugin.PowerSongImport', 'Verses not found. Missing "PART" header.')))
|
||||
continue
|
||||
if not self.finish():
|
||||
self.logError(self.title)
|
||||
|
|
|
@ -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 #
|
||||
|
@ -169,8 +169,7 @@ class SofImport(OooImport):
|
|||
return
|
||||
if text == u'A Songs of Fellowship Worship Resource':
|
||||
return
|
||||
if text.startswith(u'(NB.') or text.startswith(u'(Regrettably') \
|
||||
or text.startswith(u'(From'):
|
||||
if text.startswith(u'(NB.') or text.startswith(u'(Regrettably') or text.startswith(u'(From'):
|
||||
self.skipToCloseBracket = True
|
||||
return
|
||||
if text.startswith(u'Copyright'):
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue