HEAD 1147

This commit is contained in:
M2j 2010-12-16 12:07:39 +01:00
commit 008043d17b
45 changed files with 1339 additions and 602 deletions

View File

@ -0,0 +1,38 @@
PSF LICENSE AGREEMENT FOR PYTHON 2.7.1
1. This LICENSE AGREEMENT is between the Python Software Foundation ("PSF"),
and the Individual or Organization ("Licensee") accessing and otherwise
using Python 2.7.1 software in source or binary form and its associated
documentation.
2. Subject to the terms and conditions of this License Agreement, PSF hereby
grants Licensee a nonexclusive, royalty-free, world-wide license to
reproduce, analyze, test, perform and/or display publicly, prepare
derivative works, distribute, and otherwise use Python 2.7.1 alone or in any
derivative version, provided, however, that PSF's License Agreement and
PSF's notice of copyright, i.e., "Copyright (c) 2001-2010 Python Software
Foundation; All Rights Reserved" are retained in Python 2.7.1 alone or in
any derivative version prepared by Licensee.
3. In the event Licensee prepares a derivative work that is based on or
incorporates Python 2.7.1 or any part thereof, and wants to make the
derivative work available to others as provided herein, then Licensee hereby
agrees to include in any such work a brief summary of the changes made to
Python 2.7.1.
4. PSF is making Python 2.7.1 available to Licensee on an "AS IS" basis. PSF
MAKES NO REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED. BY WAY OF
EXAMPLE, BUT NOT LIMITATION, PSF MAKES NO AND DISCLAIMS ANY REPRESENTATION
OR WARRANTY OF MERCHANTABILITY OR FITNESS FOR ANY PARTICULAR PURPOSE OR THAT
THE USE OF PYTHON 2.7.1 WILL NOT INFRINGE ANY THIRD PARTY RIGHTS.
5. PSF SHALL NOT BE LIABLE TO LICENSEE OR ANY OTHER USERS OF PYTHON 2.7.1 FOR
ANY INCIDENTAL, SPECIAL, OR CONSEQUENTIAL DAMAGES OR LOSS AS A RESULT OF
MODIFYING, DISTRIBUTING, OR OTHERWISE USING PYTHON 2.7.1, OR ANY DERIVATIVE
THEREOF, EVEN IF ADVISED OF THE POSSIBILITY THEREOF.
6. This License Agreement will automatically terminate upon a material breach
of its terms and conditions.
7. Nothing in this License Agreement shall be deemed to create any relationship
of agency, partnership, or joint venture between PSF and Licensee. This
License Agreement does not grant permission to use PSF trademarks or trade
name in a trademark sense to endorse or promote products or services of
Licensee, or any third party.
8. By copying, installing or otherwise using Python 2.7.1, Licensee agrees to
be bound by the terms and conditions of this License Agreement.

View File

@ -0,0 +1,321 @@
# -*- coding: utf-8 -*-
# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4
###############################################################################
# Utilities for opening files or URLs in the registered default application #
# and for sending e-mail using the user's preferred composer. #
# --------------------------------------------------------------------------- #
# Copyright (c) 2007 Antonio Valentino #
# All rights reserved. #
# --------------------------------------------------------------------------- #
# This program offered under the PSF License as published by the Python #
# Software Foundation. #
# #
# The license text can be found at http://docs.python.org/license.html #
# #
# This code is taken from: http://code.activestate.com/recipes/511443 #
# Modified for use in OpenLP #
###############################################################################
__version__ = u'1.1'
__all__ = [u'open', u'mailto']
import os
import sys
import webbrowser
import subprocess
from email.Utils import encode_rfc2231
_controllers = {}
_open = None
class BaseController(object):
"""
Base class for open program controllers.
"""
def __init__(self, name):
self.name = name
def open(self, filename):
raise NotImplementedError
class Controller(BaseController):
"""
Controller for a generic open program.
"""
def __init__(self, *args):
super(Controller, self).__init__(os.path.basename(args[0]))
self.args = list(args)
def _invoke(self, cmdline):
if sys.platform[:3] == u'win':
closefds = False
startupinfo = subprocess.STARTUPINFO()
startupinfo.dwFlags |= subprocess.STARTF_USESHOWWINDOW
else:
closefds = True
startupinfo = None
if (os.environ.get(u'DISPLAY') or sys.platform[:3] == u'win' or \
sys.platform == u'darwin'):
inout = file(os.devnull, u'r+')
else:
# for TTY programs, we need stdin/out
inout = None
# if possible, put the child precess in separate process group,
# so keyboard interrupts don't affect child precess as well as
# Python
setsid = getattr(os, u'setsid', None)
if not setsid:
setsid = getattr(os, u'setpgrp', None)
pipe = subprocess.Popen(cmdline, stdin=inout, stdout=inout,
stderr=inout, close_fds=closefds, preexec_fn=setsid,
startupinfo=startupinfo)
# It is assumed that this kind of tools (gnome-open, kfmclient,
# exo-open, xdg-open and open for OSX) immediately exit after lauching
# the specific application
returncode = pipe.wait()
if hasattr(self, u'fixreturncode'):
returncode = self.fixreturncode(returncode)
return not returncode
def open(self, filename):
if isinstance(filename, basestring):
cmdline = self.args + [filename]
else:
# assume it is a sequence
cmdline = self.args + filename
try:
return self._invoke(cmdline)
except OSError:
return False
# Platform support for Windows
if sys.platform[:3] == u'win':
class Start(BaseController):
"""
Controller for the win32 start progam through os.startfile.
"""
def open(self, filename):
try:
os.startfile(filename)
except WindowsError:
# [Error 22] No application is associated with the specified
# file for this operation: '<URL>'
return False
else:
return True
_controllers[u'windows-default'] = Start(u'start')
_open = _controllers[u'windows-default'].open
# Platform support for MacOS
elif sys.platform == u'darwin':
_controllers[u'open']= Controller(u'open')
_open = _controllers[u'open'].open
# Platform support for Unix
else:
import commands
# @WARNING: use the private API of the webbrowser module
from webbrowser import _iscommand
class KfmClient(Controller):
"""
Controller for the KDE kfmclient program.
"""
def __init__(self, kfmclient=u'kfmclient'):
super(KfmClient, self).__init__(kfmclient, u'exec')
self.kde_version = self.detect_kde_version()
def detect_kde_version(self):
kde_version = None
try:
info = commands.getoutput(u'kfmclient --version')
for line in info.splitlines():
if line.startswith(u'KDE'):
kde_version = line.split(u':')[-1].strip()
break
except (OSError, RuntimeError):
pass
return kde_version
def fixreturncode(self, returncode):
if returncode is not None and self.kde_version > u'3.5.4':
return returncode
else:
return os.EX_OK
def detect_desktop_environment():
"""
Checks for known desktop environments
Return the desktop environments name, lowercase (kde, gnome, xfce)
or "generic"
"""
desktop_environment = u'generic'
if os.environ.get(u'KDE_FULL_SESSION') == u'true':
desktop_environment = u'kde'
elif os.environ.get(u'GNOME_DESKTOP_SESSION_ID'):
desktop_environment = u'gnome'
else:
try:
info = commands.getoutput(u'xprop -root _DT_SAVE_MODE')
if u' = "xfce4"' in info:
desktop_environment = u'xfce'
except (OSError, RuntimeError):
pass
return desktop_environment
def register_X_controllers():
if _iscommand(u'kfmclient'):
_controllers[u'kde-open'] = KfmClient()
for command in (u'gnome-open', u'exo-open', u'xdg-open'):
if _iscommand(command):
_controllers[command] = Controller(command)
def get():
controllers_map = {
u'gnome': u'gnome-open',
u'kde': u'kde-open',
u'xfce': u'exo-open',
}
desktop_environment = detect_desktop_environment()
try:
controller_name = controllers_map[desktop_environment]
return _controllers[controller_name].open
except KeyError:
if _controllers.has_key(u'xdg-open'):
return _controllers[u'xdg-open'].open
else:
return webbrowser.open
if os.environ.get(u'DISPLAY'):
register_X_controllers()
_open = get()
def open(filename):
"""
Open a file or an URL in the registered default application.
"""
return _open(filename)
def _fix_addersses(**kwargs):
for headername in (u'address', u'to', u'cc', u'bcc'):
try:
headervalue = kwargs[headername]
if not headervalue:
del kwargs[headername]
continue
elif not isinstance(headervalue, basestring):
# assume it is a sequence
headervalue = u','.join(headervalue)
except KeyError:
pass
except TypeError:
raise TypeError(u'string or sequence expected for "%s", %s '
u'found' % (headername, type(headervalue).__name__))
else:
translation_map = {u'%': u'%25', u'&': u'%26', u'?': u'%3F'}
for char, replacement in translation_map.items():
headervalue = headervalue.replace(char, replacement)
kwargs[headername] = headervalue
return kwargs
def mailto_format(**kwargs):
"""
Compile mailto string from call parameters
"""
# @TODO: implement utf8 option
kwargs = _fix_addersses(**kwargs)
parts = []
for headername in (u'to', u'cc', u'bcc', u'subject', u'body', u'attach'):
if kwargs.has_key(headername):
headervalue = kwargs[headername]
if not headervalue:
continue
if headername in (u'address', u'to', u'cc', u'bcc'):
parts.append(u'%s=%s' % (headername, headervalue))
else:
headervalue = encode_rfc2231(headervalue) # @TODO: check
parts.append(u'%s=%s' % (headername, headervalue))
mailto_string = u'mailto:%s' % kwargs.get(u'address', '')
if parts:
mailto_string = u'%s?%s' % (mailto_string, u'&'.join(parts))
return mailto_string
def mailto(address, to=None, cc=None, bcc=None, subject=None, body=None,
attach=None):
"""
Send an e-mail using the user's preferred composer.
Open the user's preferred e-mail composer in order to send a mail to
address(es) that must follow the syntax of RFC822. Multiple addresses
may be provided (for address, cc and bcc parameters) as separate
arguments.
All parameters provided are used to prefill corresponding fields in
the user's e-mail composer. The user will have the opportunity to
change any of this information before actually sending the e-mail.
``address``
specify the destination recipient
``cc``
specify a recipient to be copied on the e-mail
``bcc``
specify a recipient to be blindly copied on the e-mail
``subject``
specify a subject for the e-mail
``body``
specify a body for the e-mail. Since the user will be able to make
changes before actually sending the e-mail, this can be used to provide
the user with a template for the e-mail text may contain linebreaks
``attach``
specify an attachment for the e-mail. file must point to an existing
file
"""
mailto_string = mailto_format(**locals())
return open(mailto_string)

View File

@ -108,7 +108,7 @@ class Plugin(QtCore.QObject):
"""
log.info(u'loaded')
def __init__(self, name, version=None, plugin_helpers=None):
def __init__(self, name, version=None, pluginHelpers=None):
"""
This is the constructor for the plugin object. This provides an easy
way for descendent plugins to populate common data. This method *must*
@ -124,7 +124,7 @@ class Plugin(QtCore.QObject):
``version``
Defaults to *None*. The version of the plugin.
``plugin_helpers``
``pluginHelpers``
Defaults to *None*. A list of helper objects.
"""
QtCore.QObject.__init__(self)
@ -139,14 +139,14 @@ class Plugin(QtCore.QObject):
self.status = PluginStatus.Inactive
# Set up logging
self.log = logging.getLogger(self.name)
self.previewController = plugin_helpers[u'preview']
self.liveController = plugin_helpers[u'live']
self.renderManager = plugin_helpers[u'render']
self.serviceManager = plugin_helpers[u'service']
self.settingsForm = plugin_helpers[u'settings form']
self.mediadock = plugin_helpers[u'toolbox']
self.pluginManager = plugin_helpers[u'pluginmanager']
self.formparent = plugin_helpers[u'formparent']
self.previewController = pluginHelpers[u'preview']
self.liveController = pluginHelpers[u'live']
self.renderManager = pluginHelpers[u'render']
self.serviceManager = pluginHelpers[u'service']
self.settingsForm = pluginHelpers[u'settings form']
self.mediadock = pluginHelpers[u'toolbox']
self.pluginManager = pluginHelpers[u'pluginmanager']
self.formparent = pluginHelpers[u'formparent']
QtCore.QObject.connect(Receiver.get_receiver(),
QtCore.SIGNAL(u'%s_add_service_item' % self.name),
self.processAddServiceEvent)

View File

@ -26,7 +26,7 @@
from PyQt4 import QtCore, QtGui
from openlp.core.lib import translate
from openlp.core.lib import translate, build_icon
class Ui_ExceptionDialog(object):
def setupUi(self, exceptionDialog):
@ -63,12 +63,27 @@ class Ui_ExceptionDialog(object):
self.exceptionButtonBox.setStandardButtons(QtGui.QDialogButtonBox.Close)
self.exceptionButtonBox.setObjectName(u'exceptionButtonBox')
self.exceptionLayout.addWidget(self.exceptionButtonBox)
self.sendReportButton = QtGui.QPushButton(exceptionDialog)
self.sendReportButton.setIcon(build_icon(
u':/general/general_email.png'))
self.sendReportButton.setObjectName(u'sendReportButton')
self.exceptionButtonBox.addButton(self.sendReportButton,
QtGui.QDialogButtonBox.ActionRole)
self.saveReportButton = QtGui.QPushButton(exceptionDialog)
self.saveReportButton.setIcon(build_icon(u':/general/general_save.png'))
self.saveReportButton.setObjectName(u'saveReportButton')
self.exceptionButtonBox.addButton(self.saveReportButton,
QtGui.QDialogButtonBox.ActionRole)
self.retranslateUi(exceptionDialog)
QtCore.QObject.connect(self.exceptionButtonBox,
QtCore.SIGNAL(u'accepted()'), exceptionDialog.accept)
QtCore.QObject.connect(self.exceptionButtonBox,
QtCore.SIGNAL(u'rejected()'), exceptionDialog.reject)
QtCore.QObject.connect(self.sendReportButton,
QtCore.SIGNAL(u'pressed()'), self.onSendReportButtonPressed)
QtCore.QObject.connect(self.saveReportButton,
QtCore.SIGNAL(u'pressed()'), self.onSaveReportButtonPressed)
QtCore.QMetaObject.connectSlotsByName(exceptionDialog)
def retranslateUi(self, exceptionDialog):
@ -80,3 +95,7 @@ class Ui_ExceptionDialog(object):
'developers, so please e-mail it to bugs@openlp.org, along with a '
'detailed description of what you were doing when the problem '
'occurred.'))
self.sendReportButton.setText(translate('OpenLP.ExceptionDialog',
'Send E-Mail'))
self.saveReportButton.setText(translate('OpenLP.ExceptionDialog',
'Save to File'))

View File

@ -24,7 +24,38 @@
# Temple Place, Suite 330, Boston, MA 02111-1307 USA #
###############################################################################
from PyQt4 import QtGui
import re
import os
import platform
import sqlalchemy
import BeautifulSoup
from lxml import etree
from PyQt4 import Qt, QtCore, QtGui
try:
from PyQt4.phonon import Phonon
phonon_version = Phonon.phononVersion()
except ImportError:
phonon_version = u'-'
try:
import chardet
chardet_version = chardet.__version__
except ImportError:
chardet_version = u'-'
try:
import enchant
enchant_version = enchant.__version__
except ImportError:
enchant_version = u'-'
try:
import sqlite
sqlite_version = sqlite.version
except ImportError:
sqlite_version = u'-'
from openlp.core.lib import translate, SettingsManager
from openlp.core.lib.mailto import mailto
from exceptiondialog import Ui_ExceptionDialog
@ -35,3 +66,78 @@ class ExceptionForm(QtGui.QDialog, Ui_ExceptionDialog):
def __init__(self, parent):
QtGui.QDialog.__init__(self, parent)
self.setupUi(self)
self.settingsSection = u'crashreport'
def _createReport(self):
openlp_version = self.parent().applicationVersion[u'full']
traceback = unicode(self.exceptionTextEdit.toPlainText())
system = unicode(translate('OpenLP.ExceptionForm',
'Platform: %s\n')) % platform.platform()
libraries = u'Python: %s\n' % platform.python_version() + \
u'Qt4: %s\n' % Qt.qVersion() + \
u'Phonon: %s\n' % phonon_version + \
u'PyQt4: %s\n' % Qt.PYQT_VERSION_STR + \
u'SQLAlchemy: %s\n' % sqlalchemy.__version__ + \
u'BeautifulSoup: %s\n' % BeautifulSoup.__version__ + \
u'lxml: %s\n' % etree.__version__ + \
u'Chardet: %s\n' % chardet_version + \
u'PyEnchant: %s\n' % enchant_version + \
u'PySQLite: %s\n' % sqlite_version
if platform.system() == u'Linux':
if os.environ.get(u'KDE_FULL_SESSION') == u'true':
system = system + u'Desktop: KDE SC\n'
elif os.environ.get(u'GNOME_DESKTOP_SESSION_ID'):
system = system + u'Desktop: GNOME\n'
return (openlp_version, traceback, system, libraries)
def onSaveReportButtonPressed(self):
"""
Saving exception log and system informations to a file.
"""
report = unicode(translate('OpenLP.ExceptionForm',
'**OpenLP Bug Report**\n'
'Version: %s\n\n'
'--- Exception Traceback ---\n%s\n'
'--- System information ---\n%s\n'
'--- Library Versions ---\n%s\n'))
filename = QtGui.QFileDialog.getSaveFileName(self,
translate('OpenLP.ExceptionForm', 'Save Crash Report'),
SettingsManager.get_last_dir(self.settingsSection),
translate('OpenLP.ExceptionForm', 'Text files (*.txt *.log *.text)'))
if filename:
filename = unicode(QtCore.QDir.toNativeSeparators(filename))
SettingsManager.set_last_dir(self.settingsSection, os.path.dirname(
filename))
report = report % self._createReport()
try:
file = open(filename, u'w')
try:
file.write(report)
except UnicodeError:
file.close()
file = open(filename, u'wb')
file.write(report.encode(u'utf-8'))
file.close()
except IOError:
log.exception(u'Failed to write crash report')
def onSendReportButtonPressed(self):
"""
Opening systems default email client and inserting exception log and
system informations.
"""
body = unicode(translate('OpenLP.ExceptionForm',
'*OpenLP Bug Report*\n'
'Version: %s\n\n'
'--- Please enter the report below this line. ---\n\n\n'
'--- Exception Traceback ---\n%s\n'
'--- System information ---\n%s\n'
'--- Library Versions ---\n%s\n'))
content = self._createReport()
for line in content[1].split(u'\n'):
if re.search(r'[/\\]openlp[/\\]', line):
source = re.sub(r'.*[/\\]openlp[/\\](.*)".*', r'\1', line)
if u':' in line:
exception = line.split(u'\n')[-1].split(u':')[0]
subject = u'Bug report: %s in %s' % (exception, source)
mailto(address=u'bugs@openlp.org', subject=subject, body=body % content)

View File

@ -97,16 +97,16 @@ class Ui_MainWindow(object):
self.ControlSplitter.setObjectName(u'ControlSplitter')
self.MainContentLayout.addWidget(self.ControlSplitter)
# Create slide controllers
self.PreviewController = SlideController(self, self.settingsmanager,
self.previewController = SlideController(self, self.settingsmanager,
self.screens)
self.LiveController = SlideController(self, self.settingsmanager,
self.liveController = SlideController(self, self.settingsmanager,
self.screens, True)
previewVisible = QtCore.QSettings().value(
u'user interface/preview panel', QtCore.QVariant(True)).toBool()
self.PreviewController.Panel.setVisible(previewVisible)
self.previewController.Panel.setVisible(previewVisible)
liveVisible = QtCore.QSettings().value(u'user interface/live panel',
QtCore.QVariant(True)).toBool()
self.LiveController.Panel.setVisible(liveVisible)
self.liveController.Panel.setVisible(liveVisible)
# Create menu
self.MenuBar = QtGui.QMenuBar(MainWindow)
self.MenuBar.setGeometry(QtCore.QRect(0, 0, 1087, 27))
@ -362,8 +362,8 @@ class Ui_MainWindow(object):
"""
Splitter between the Preview and Live Controllers.
"""
self.LiveController.widthChanged()
self.PreviewController.widthChanged()
self.liveController.widthChanged()
self.previewController.widthChanged()
def retranslateUi(self, MainWindow):
"""
@ -548,8 +548,8 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow):
self.recentFiles = QtCore.QStringList()
# Set up the path with plugins
pluginpath = AppLocation.get_directory(AppLocation.PluginsDir)
self.plugin_manager = PluginManager(pluginpath)
self.plugin_helpers = {}
self.pluginManager = PluginManager(pluginpath)
self.pluginHelpers = {}
# Set up the interface
self.setupUi(self)
# Load settings after setupUi so default UI sizes are overwritten
@ -633,33 +633,33 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow):
self.mediaDockManager = MediaDockManager(self.MediaToolBox)
log.info(u'Load Plugins')
# make the controllers available to the plugins
self.plugin_helpers[u'preview'] = self.PreviewController
self.plugin_helpers[u'live'] = self.LiveController
self.plugin_helpers[u'render'] = self.renderManager
self.plugin_helpers[u'service'] = self.ServiceManagerContents
self.plugin_helpers[u'settings form'] = self.settingsForm
self.plugin_helpers[u'toolbox'] = self.mediaDockManager
self.plugin_helpers[u'pluginmanager'] = self.plugin_manager
self.plugin_helpers[u'formparent'] = self
self.plugin_manager.find_plugins(pluginpath, self.plugin_helpers)
self.pluginHelpers[u'preview'] = self.previewController
self.pluginHelpers[u'live'] = self.liveController
self.pluginHelpers[u'render'] = self.renderManager
self.pluginHelpers[u'service'] = self.ServiceManagerContents
self.pluginHelpers[u'settings form'] = self.settingsForm
self.pluginHelpers[u'toolbox'] = self.mediaDockManager
self.pluginHelpers[u'pluginmanager'] = self.pluginManager
self.pluginHelpers[u'formparent'] = self
self.pluginManager.find_plugins(pluginpath, self.pluginHelpers)
# hook methods have to happen after find_plugins. Find plugins needs
# the controllers hence the hooks have moved from setupUI() to here
# Find and insert settings tabs
log.info(u'hook settings')
self.plugin_manager.hook_settings_tabs(self.settingsForm)
self.pluginManager.hook_settings_tabs(self.settingsForm)
# Find and insert media manager items
log.info(u'hook media')
self.plugin_manager.hook_media_manager(self.mediaDockManager)
self.pluginManager.hook_media_manager(self.mediaDockManager)
# Call the hook method to pull in import menus.
log.info(u'hook menus')
self.plugin_manager.hook_import_menu(self.FileImportMenu)
self.pluginManager.hook_import_menu(self.FileImportMenu)
# Call the hook method to pull in export menus.
self.plugin_manager.hook_export_menu(self.FileExportMenu)
self.pluginManager.hook_export_menu(self.FileExportMenu)
# Call the hook method to pull in tools menus.
self.plugin_manager.hook_tools_menu(self.ToolsMenu)
self.pluginManager.hook_tools_menu(self.ToolsMenu)
# Call the initialise method to setup plugins.
log.info(u'initialise plugins')
self.plugin_manager.initialise_plugins()
self.pluginManager.initialise_plugins()
# Once all components are initialised load the Themes
log.info(u'Load Themes')
self.ThemeManagerContents.loadThemes()
@ -695,10 +695,10 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow):
Show the main form, as well as the display form
"""
QtGui.QWidget.show(self)
self.LiveController.display.setup()
self.PreviewController.display.setup()
if self.LiveController.display.isVisible():
self.LiveController.display.setFocus()
self.liveController.display.setup()
self.previewController.display.setup()
if self.liveController.display.isVisible():
self.liveController.display.setFocus()
self.activateWindow()
if QtCore.QSettings().value(
self.generalSettingsSection + u'/auto open',
@ -723,7 +723,7 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow):
settings = QtCore.QSettings()
if settings.value(u'%s/screen blank' % self.generalSettingsSection,
QtCore.QVariant(False)).toBool():
self.LiveController.mainDisplaySetBackground()
self.liveController.mainDisplaySetBackground()
if settings.value(u'blank warning',
QtCore.QVariant(False)).toBool():
QtGui.QMessageBox.question(self,
@ -852,11 +852,11 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow):
QtCore.QVariant(self.MediaToolBox.currentIndex()))
# Call the cleanup method to shutdown plugins.
log.info(u'cleanup plugins')
self.plugin_manager.finalise_plugins()
self.pluginManager.finalise_plugins()
# Save settings
self.saveSettings()
# Close down the display
self.LiveController.display.close()
self.liveController.display.close()
def serviceChanged(self, reset=False, serviceName=None):
"""
@ -910,7 +910,7 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow):
True - Visible
False - Hidden
"""
self.PreviewController.Panel.setVisible(visible)
self.previewController.Panel.setVisible(visible)
QtCore.QSettings().setValue(u'user interface/preview panel',
QtCore.QVariant(visible))
self.ViewPreviewPanel.setChecked(visible)
@ -925,7 +925,7 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow):
True - Visible
False - Hidden
"""
self.LiveController.Panel.setVisible(visible)
self.liveController.Panel.setVisible(visible)
QtCore.QSettings().setValue(u'user interface/live panel',
QtCore.QVariant(visible))
self.ViewLivePanel.setChecked(visible)

View File

@ -61,7 +61,7 @@ class PluginForm(QtGui.QDialog, Ui_PluginViewDialog):
self.programaticChange = True
self._clearDetails()
self.programaticChange = True
for plugin in self.parent.plugin_manager.plugins:
for plugin in self.parent.pluginManager.plugins:
item = QtGui.QListWidgetItem(self.pluginListWidget)
# We do this just to make 100% sure the status is an integer as
# sometimes when it's loaded from the config, it isn't cast to int.
@ -110,7 +110,7 @@ class PluginForm(QtGui.QDialog, Ui_PluginViewDialog):
plugin_name_plural = \
self.pluginListWidget.currentItem().text().split(u' ')[0]
self.activePlugin = None
for plugin in self.parent.plugin_manager.plugins:
for plugin in self.parent.pluginManager.plugins:
name_string = plugin.getString(StringContent.Name)
if name_string[u'plural'] == plugin_name_plural:
self.activePlugin = plugin

View File

@ -880,7 +880,7 @@ class ServiceManager(QtGui.QWidget):
newItem.merge(item[u'service_item'])
item[u'service_item'] = newItem
self.repaintServiceList(itemcount + 1, 0)
self.parent.LiveController.replaceServiceManagerItem(newItem)
self.parent.liveController.replaceServiceManagerItem(newItem)
self.parent.serviceChanged(False, self.serviceName)
def addServiceItem(self, item, rebuild=False, expand=None, replace=False):
@ -902,7 +902,7 @@ class ServiceManager(QtGui.QWidget):
item.merge(self.serviceItems[sitem][u'service_item'])
self.serviceItems[sitem][u'service_item'] = item
self.repaintServiceList(sitem + 1, 0)
self.parent.LiveController.replaceServiceManagerItem(item)
self.parent.liveController.replaceServiceManagerItem(item)
else:
# nothing selected for dnd
if self.droppos == 0:
@ -923,7 +923,7 @@ class ServiceManager(QtGui.QWidget):
self.repaintServiceList(self.droppos, 0)
# if rebuilding list make sure live is fixed.
if rebuild:
self.parent.LiveController.replaceServiceManagerItem(item)
self.parent.liveController.replaceServiceManagerItem(item)
self.droppos = 0
self.parent.serviceChanged(False, self.serviceName)
@ -933,7 +933,7 @@ class ServiceManager(QtGui.QWidget):
"""
item, count = self.findServiceItem()
if self.serviceItems[item][u'service_item'].is_valid:
self.parent.PreviewController.addServiceManagerItem(
self.parent.previewController.addServiceManagerItem(
self.serviceItems[item][u'service_item'], count)
else:
QtGui.QMessageBox.critical(self,
@ -957,7 +957,7 @@ class ServiceManager(QtGui.QWidget):
"""
item, count = self.findServiceItem()
if self.serviceItems[item][u'service_item'].is_valid:
self.parent.LiveController.addServiceManagerItem(
self.parent.liveController.addServiceManagerItem(
self.serviceItems[item][u'service_item'], count)
if QtCore.QSettings().value(
self.parent.generalSettingsSection + u'/auto preview',
@ -966,9 +966,9 @@ class ServiceManager(QtGui.QWidget):
if self.serviceItems and item < len(self.serviceItems) and \
self.serviceItems[item][u'service_item'].is_capable(
ItemCapabilities.AllowsPreview):
self.parent.PreviewController.addServiceManagerItem(
self.parent.previewController.addServiceManagerItem(
self.serviceItems[item][u'service_item'], 0)
self.parent.LiveController.PreviewListWidget.setFocus()
self.parent.liveController.PreviewListWidget.setFocus()
else:
QtGui.QMessageBox.critical(self,
translate('OpenLP.ServiceManager', 'Missing Display Handler'),

View File

@ -957,7 +957,7 @@ class SlideController(QtGui.QWidget):
"""
row = self.PreviewListWidget.currentRow()
if row > -1 and row < self.PreviewListWidget.rowCount():
self.parent.LiveController.addServiceManagerItem(
self.parent.liveController.addServiceManagerItem(
self.serviceItem, row)
def onMediaStart(self, item):

View File

@ -310,7 +310,7 @@ class ThemeManager(QtGui.QWidget):
translate('OpenLP.ThemeManager',
'You are unable to delete the default theme.'))
else:
for plugin in self.parent.plugin_manager.plugins:
for plugin in self.parent.pluginManager.plugins:
if plugin.usesTheme(theme):
QtGui.QMessageBox.critical(self,
translate('OpenLP.ThemeManager', 'Error'),
@ -663,7 +663,7 @@ class ThemeManager(QtGui.QWidget):
(QtGui.QMessageBox.Yes | QtGui.QMessageBox.No),
QtGui.QMessageBox.No)
if self.saveThemeName != u'':
for plugin in self.parent.plugin_manager.plugins:
for plugin in self.parent.pluginManager.plugins:
if plugin.usesTheme(self.saveThemeName):
plugin.renameTheme(self.saveThemeName, name)
if unicode(self.serviceComboBox.currentText()) == name:

View File

@ -128,7 +128,7 @@ class Ui_AlertDialog(object):
self.AlertEntryLabel.setText(
translate('AlertsPlugin.AlertForm', 'Alert &text:'))
self.AlertParameter.setText(
translate('AlertsPlugin.AlertForm', '&Parameter(s):'))
translate('AlertsPlugin.AlertForm', '&Parameter:'))
self.NewButton.setText(
translate('AlertsPlugin.AlertForm', '&New'))
self.SaveButton.setText(

View File

@ -62,6 +62,9 @@ class AlertForm(QtGui.QDialog, Ui_AlertDialog):
QtCore.SIGNAL(u'clicked(QModelIndex)'), self.onSingleClick)
def loadList(self):
"""
Loads the list with alerts.
"""
self.AlertListWidget.clear()
alerts = self.manager.get_all_objects(AlertItem,
order_by_ref=AlertItem.text)
@ -81,12 +84,16 @@ class AlertForm(QtGui.QDialog, Ui_AlertDialog):
self.close()
def onDeleteClick(self):
"""
Deletes the selected item.
"""
item = self.AlertListWidget.currentItem()
if item:
item_id = (item.data(QtCore.Qt.UserRole)).toInt()[0]
self.manager.delete_object(AlertItem, item_id)
row = self.AlertListWidget.row(item)
self.AlertListWidget.takeItem(row)
self.item_id = None
self.AlertTextEdit.setText(u'')
self.SaveButton.setEnabled(False)
self.DeleteButton.setEnabled(False)
@ -96,8 +103,8 @@ class AlertForm(QtGui.QDialog, Ui_AlertDialog):
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.'))
'any text for your alert. Please type in some text before '
'clicking New.'))
else:
alert = AlertItem()
alert.text = unicode(self.AlertTextEdit.text())
@ -107,7 +114,7 @@ class AlertForm(QtGui.QDialog, Ui_AlertDialog):
def onSaveClick(self):
"""
Save an alert
Save the alert, we are editing.
"""
if self.item_id:
alert = self.manager.get_object(AlertItem, self.item_id)
@ -115,14 +122,14 @@ class AlertForm(QtGui.QDialog, Ui_AlertDialog):
self.manager.save_object(alert)
self.item_id = None
self.loadList()
else:
self.onNewClick()
def onTextChanged(self):
"""
Enable save button when data has been changed by editing the form
"""
self.SaveButton.setEnabled(True)
# Only enable the button, if we are editing an item.
if self.item_id:
self.SaveButton.setEnabled(True)
def onDoubleClick(self):
"""
@ -131,8 +138,8 @@ class AlertForm(QtGui.QDialog, Ui_AlertDialog):
items = self.AlertListWidget.selectedIndexes()
for item in items:
bitem = self.AlertListWidget.item(item.row())
self.triggerAlert(bitem.text())
self.AlertTextEdit.setText(bitem.text())
self.triggerAlert(unicode(bitem.text()))
self.AlertTextEdit.setText(unicode(bitem.text()))
self.item_id = (bitem.data(QtCore.Qt.UserRole)).toInt()[0]
self.SaveButton.setEnabled(False)
self.DeleteButton.setEnabled(True)
@ -145,13 +152,45 @@ class AlertForm(QtGui.QDialog, Ui_AlertDialog):
items = self.AlertListWidget.selectedIndexes()
for item in items:
bitem = self.AlertListWidget.item(item.row())
self.AlertTextEdit.setText(bitem.text())
self.AlertTextEdit.setText(unicode(bitem.text()))
self.item_id = (bitem.data(QtCore.Qt.UserRole)).toInt()[0]
# If the alert does not contain '<>' we clear the ParameterEdit field.
if unicode(self.AlertTextEdit.text()).find(u'<>') == -1:
self.ParameterEdit.setText(u'')
self.SaveButton.setEnabled(False)
self.DeleteButton.setEnabled(True)
def triggerAlert(self, text):
"""
Prepares the alert text for displaying.
``text``
The alert text (unicode).
"""
if text:
# 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(
'AlertPlugin.AlertForm', 'No Parameter found'),
translate('AlertPlugin.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:
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(
'AlertPlugin.AlertForm', 'No Placeholder found'),
translate('AlertPlugin.AlertForm', 'The alert text does not'
' contain \'<>\'.\nDo 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'<>', unicode(self.ParameterEdit.text()))
self.parent.alertsmanager.displayAlert(text)
return True

View File

@ -86,7 +86,7 @@ class AlertsManager(QtCore.QObject):
text = self.alertList.pop(0)
alertTab = self.parent.alertsTab
self.parent.liveController.display.alert(text)
# check to see if we have a timer running
# Check to see if we have a timer running.
if self.timer_id == 0:
self.timer_id = self.startTimer(int(alertTab.timeout) * 1000)
@ -94,9 +94,9 @@ class AlertsManager(QtCore.QObject):
"""
Time has finished so if our time then request the next Alert
if there is one and reset the timer.
``event``
the QT event that has been triggered.
"""
log.debug(u'timer event')
if event.timerId() == self.timer_id:

View File

@ -77,6 +77,12 @@ class BibleImportForm(QtGui.QWizard, Ui_BibleImportWizard):
QtGui.QWizard.__init__(self, parent)
self.setupUi(self)
self.registerFields()
if not BibleFormat.get_availability(BibleFormat.OpenLP1):
self.openlp1Page.setVisible(False)
self.openlp1LocationLabel.setVisible(False)
self.openlp1LocationEdit.setVisible(False)
self.openlp1FileButton.setVisible(False)
self.openlp1DisabledLabel.setVisible(True)
self.finishButton = self.button(QtGui.QWizard.FinishButton)
self.cancelButton = self.button(QtGui.QWizard.CancelButton)
self.manager = manager
@ -84,24 +90,24 @@ class BibleImportForm(QtGui.QWizard, Ui_BibleImportWizard):
self.manager.set_process_dialog(self)
self.web_bible_list = {}
self.loadWebBibles()
QtCore.QObject.connect(self.LocationComboBox,
QtCore.QObject.connect(self.locationComboBox,
QtCore.SIGNAL(u'currentIndexChanged(int)'),
self.onLocationComboBoxChanged)
QtCore.QObject.connect(self.OsisFileButton,
QtCore.QObject.connect(self.osisFileButton,
QtCore.SIGNAL(u'clicked()'),
self.onOsisFileButtonClicked)
QtCore.QObject.connect(self.BooksFileButton,
QtCore.QObject.connect(self.booksFileButton,
QtCore.SIGNAL(u'clicked()'),
self.onBooksFileButtonClicked)
QtCore.QObject.connect(self.CsvVersesFileButton,
QtCore.QObject.connect(self.csvVersesFileButton,
QtCore.SIGNAL(u'clicked()'),
self.onCsvVersesFileButtonClicked)
QtCore.QObject.connect(self.OpenSongBrowseButton,
QtCore.QObject.connect(self.openSongBrowseButton,
QtCore.SIGNAL(u'clicked()'),
self.onOpenSongBrowseButtonClicked)
QtCore.QObject.connect(self.cancelButton,
QtCore.SIGNAL(u'clicked(bool)'),
self.onCancelButtonClicked)
QtCore.QObject.connect(self.openlp1FileButton,
QtCore.SIGNAL(u'clicked()'),
self.onOpenlp1FileButtonClicked)
QtCore.QObject.connect(self,
QtCore.SIGNAL(u'currentIdChanged(int)'),
self.onCurrentIdChanged)
@ -113,6 +119,15 @@ class BibleImportForm(QtGui.QWizard, Ui_BibleImportWizard):
self.setDefaults()
return QtGui.QWizard.exec_(self)
def reject(self):
"""
Stop the import on cancel button, close button or ESC key.
"""
log.debug('Import canceled by user.')
if self.currentId() == 3:
Receiver.send_message(u'bibles_stop_import')
self.done(QtGui.QDialog.Rejected)
def validateCurrentPage(self):
"""
Validate the current page before moving on to the next page.
@ -123,7 +138,7 @@ class BibleImportForm(QtGui.QWizard, Ui_BibleImportWizard):
elif self.currentId() == 1:
# Select page
if self.field(u'source_format').toInt()[0] == BibleFormat.OSIS:
if self.field(u'osis_location').toString() == u'':
if not self.field(u'osis_location').toString():
QtGui.QMessageBox.critical(self,
translate('BiblesPlugin.ImportWizardForm',
'Invalid Bible Location'),
@ -140,7 +155,7 @@ class BibleImportForm(QtGui.QWizard, Ui_BibleImportWizard):
translate('BiblesPlugin.ImportWizardForm',
'You need to specify a file with books of '
'the Bible to use in the import.'))
self.BooksLocationEdit.setFocus()
self.booksLocationEdit.setFocus()
return False
elif not self.field(u'csv_versefile').toString():
QtGui.QMessageBox.critical(self,
@ -149,7 +164,7 @@ class BibleImportForm(QtGui.QWizard, Ui_BibleImportWizard):
translate('BiblesPlugin.ImportWizardForm',
'You need to specify a file of Bible '
'verses to import.'))
self.CsvVerseLocationEdit.setFocus()
self.csvVerseLocationEdit.setFocus()
return False
elif self.field(u'source_format').toInt()[0] == \
BibleFormat.OpenSong:
@ -160,7 +175,17 @@ class BibleImportForm(QtGui.QWizard, Ui_BibleImportWizard):
translate('BiblesPlugin.ImportWizardForm',
'You need to specify an OpenSong Bible '
'file to import.'))
self.OpenSongFileEdit.setFocus()
self.openSongFileEdit.setFocus()
return False
elif self.field(u'source_format').toInt()[0] == BibleFormat.OpenLP1:
if not self.field(u'openlp1_location').toString():
QtGui.QMessageBox.critical(self,
translate('BiblesPlugin.ImportWizardForm',
'Invalid Bible Location'),
translate('BiblesPlugin.ImportWizardForm',
'You need to specify a file to import your '
'Bible from.'))
self.openlp1LocationEdit.setFocus()
return False
return True
elif self.currentId() == 2:
@ -174,7 +199,7 @@ class BibleImportForm(QtGui.QWizard, Ui_BibleImportWizard):
'Empty Version Name'),
translate('BiblesPlugin.ImportWizardForm',
'You need to specify a version name for your Bible.'))
self.VersionNameEdit.setFocus()
self.versionNameEdit.setFocus()
return False
elif not license_copyright:
QtGui.QMessageBox.critical(self,
@ -183,7 +208,7 @@ class BibleImportForm(QtGui.QWizard, Ui_BibleImportWizard):
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()
self.copyrightEdit.setFocus()
return False
elif self.manager.exists(license_version):
QtGui.QMessageBox.critical(self,
@ -191,7 +216,7 @@ class BibleImportForm(QtGui.QWizard, Ui_BibleImportWizard):
translate('BiblesPlugin.ImportWizardForm',
'This Bible already exists. Please import '
'a different Bible or first delete the existing one.'))
self.VersionNameEdit.setFocus()
self.versionNameEdit.setFocus()
return False
return True
if self.currentId() == 3:
@ -206,12 +231,12 @@ class BibleImportForm(QtGui.QWizard, Ui_BibleImportWizard):
``index``
The index of the combo box.
"""
self.BibleComboBox.clear()
self.bibleComboBox.clear()
bibles = [unicode(translate('BiblesPlugin.ImportWizardForm', bible)) for
bible in self.web_bible_list[index].keys()]
bibles.sort()
for bible in bibles:
self.BibleComboBox.addItem(bible)
self.bibleComboBox.addItem(bible)
def onOsisFileButtonClicked(self):
"""
@ -227,14 +252,14 @@ class BibleImportForm(QtGui.QWizard, Ui_BibleImportWizard):
"""
self.getFileName(
translate('BiblesPlugin.ImportWizardForm', 'Open Books CSV File'),
self.BooksLocationEdit)
self.booksLocationEdit)
def onCsvVersesFileButtonClicked(self):
"""
Show the file open dialog for the verses CSV file.
"""
self.getFileName(translate('BiblesPlugin.ImportWizardForm',
'Open Verses CSV File'), self.CsvVerseLocationEdit)
'Open Verses CSV File'), self.csvVerseLocationEdit)
def onOpenSongBrowseButtonClicked(self):
"""
@ -242,15 +267,15 @@ class BibleImportForm(QtGui.QWizard, Ui_BibleImportWizard):
"""
self.getFileName(
translate('BiblesPlugin.ImportWizardForm', 'Open OpenSong Bible'),
self.OpenSongFileEdit)
self.openSongFileEdit)
def onCancelButtonClicked(self, checked):
def onOpenlp1FileButtonClicked(self):
"""
Stop the import on pressing the cancel button.
Show the file open dialog for the openlp.org 1.x file.
"""
log.debug('Cancel button pressed!')
if self.currentId() == 3:
Receiver.send_message(u'bibles_stop_import')
self.getFileName(
translate('BiblesPlugin.ImportWizardForm',
'Open openlp.org 1.x Bible'), self.openlp1LocationEdit)
def onCurrentIdChanged(self, pageId):
if pageId == 3:
@ -259,32 +284,25 @@ class BibleImportForm(QtGui.QWizard, Ui_BibleImportWizard):
self.postImport()
def registerFields(self):
self.SelectPage.registerField(
u'source_format', self.FormatComboBox)
self.SelectPage.registerField(
u'osis_location', self.OSISLocationEdit)
self.SelectPage.registerField(
u'csv_booksfile', self.BooksLocationEdit)
self.SelectPage.registerField(
u'csv_versefile', self.CsvVerseLocationEdit)
self.SelectPage.registerField(
u'opensong_file', self.OpenSongFileEdit)
self.SelectPage.registerField(
u'web_location', self.LocationComboBox)
self.SelectPage.registerField(
u'web_biblename', self.BibleComboBox)
self.SelectPage.registerField(
u'proxy_server', self.AddressEdit)
self.SelectPage.registerField(
u'proxy_username', self.UsernameEdit)
self.SelectPage.registerField(
u'proxy_password', self.PasswordEdit)
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.selectPage.registerField(u'source_format', self.formatComboBox)
self.selectPage.registerField(u'osis_location', self.OSISLocationEdit)
self.selectPage.registerField(u'csv_booksfile', self.booksLocationEdit)
self.selectPage.registerField(
u'csv_versefile', self.csvVerseLocationEdit)
self.selectPage.registerField(u'opensong_file', self.openSongFileEdit)
self.selectPage.registerField(u'web_location', self.locationComboBox)
self.selectPage.registerField(u'web_biblename', self.bibleComboBox)
self.selectPage.registerField(u'proxy_server', self.addressEdit)
self.selectPage.registerField(u'proxy_username', self.usernameEdit)
self.selectPage.registerField(u'proxy_password', self.passwordEdit)
self.selectPage.registerField(
u'openlp1_location', self.openlp1LocationEdit)
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):
settings = QtCore.QSettings()
@ -299,19 +317,20 @@ class BibleImportForm(QtGui.QWizard, Ui_BibleImportWizard):
self.setField(u'opensong_file', QtCore.QVariant(''))
self.setField(u'web_location', QtCore.QVariant(WebDownload.Crosswalk))
self.setField(u'web_biblename',
QtCore.QVariant(self.BibleComboBox.currentIndex()))
QtCore.QVariant(self.bibleComboBox.currentIndex()))
self.setField(u'proxy_server',
settings.value(u'proxy address', QtCore.QVariant(u'')))
self.setField(u'proxy_username',
settings.value(u'proxy username', QtCore.QVariant(u'')))
self.setField(u'proxy_password',
settings.value(u'proxy password', QtCore.QVariant(u'')))
self.setField(u'openlp1_location', QtCore.QVariant(''))
self.setField(u'license_version',
QtCore.QVariant(self.VersionNameEdit.text()))
QtCore.QVariant(self.versionNameEdit.text()))
self.setField(u'license_copyright',
QtCore.QVariant(self.CopyrightEdit.text()))
QtCore.QVariant(self.copyrightEdit.text()))
self.setField(u'license_permissions',
QtCore.QVariant(self.PermissionsEdit.text()))
QtCore.QVariant(self.permissionsEdit.text()))
self.onLocationComboBoxChanged(WebDownload.Crosswalk)
settings.endGroup()
@ -376,26 +395,32 @@ class BibleImportForm(QtGui.QWizard, Ui_BibleImportWizard):
def incrementProgressBar(self, status_text):
log.debug(u'IncrementBar %s', status_text)
self.ImportProgressLabel.setText(status_text)
self.ImportProgressBar.setValue(self.ImportProgressBar.value() + 1)
self.importProgressLabel.setText(status_text)
self.importProgressBar.setValue(self.importProgressBar.value() + 1)
Receiver.send_message(u'openlp_process_events')
def preImport(self):
"""
Prepare the UI for the import.
"""
bible_type = self.field(u'source_format').toInt()[0]
self.finishButton.setVisible(False)
self.ImportProgressBar.setMinimum(0)
self.ImportProgressBar.setMaximum(1188)
self.ImportProgressBar.setValue(0)
self.importProgressBar.setMinimum(0)
self.importProgressBar.setMaximum(1188)
self.importProgressBar.setValue(0)
if bible_type == BibleFormat.WebDownload:
self.ImportProgressLabel.setText(translate(
self.importProgressLabel.setText(translate(
'BiblesPlugin.ImportWizardForm',
'Starting Registering bible...'))
else:
self.ImportProgressLabel.setText(translate(
self.importProgressLabel.setText(translate(
'BiblesPlugin.ImportWizardForm', 'Starting import...'))
Receiver.send_message(u'openlp_process_events')
def performImport(self):
"""
Perform the actual import.
"""
bible_type = self.field(u'source_format').toInt()[0]
license_version = unicode(self.field(u'license_version').toString())
license_copyright = unicode(self.field(u'license_copyright').toString())
@ -423,9 +448,9 @@ class BibleImportForm(QtGui.QWizard, Ui_BibleImportWizard):
)
elif bible_type == BibleFormat.WebDownload:
# Import a bible from the web.
self.ImportProgressBar.setMaximum(1)
self.importProgressBar.setMaximum(1)
download_location = self.field(u'web_location').toInt()[0]
bible_version = unicode(self.BibleComboBox.currentText())
bible_version = unicode(self.bibleComboBox.currentText())
if download_location == WebDownload.Crosswalk:
bible = \
self.web_bible_list[WebDownload.Crosswalk][bible_version]
@ -442,26 +467,31 @@ class BibleImportForm(QtGui.QWizard, Ui_BibleImportWizard):
unicode(self.field(u'proxy_username').toString()),
proxy_password=unicode(self.field(u'proxy_password').toString())
)
elif bible_type == BibleFormat.OpenLP1:
# Import an openlp.org 1.x bible.
importer = self.manager.import_bible(BibleFormat.OpenLP1,
name=license_version,
filename=unicode(self.field(u'openlp1_location').toString())
)
if importer.do_import():
self.manager.save_meta_data(license_version, license_version,
license_copyright, license_permissions)
self.manager.reload_bibles()
if bible_type == BibleFormat.WebDownload:
self.ImportProgressLabel.setText(
self.importProgressLabel.setText(
translate('BiblesPlugin.ImportWizardForm', 'Registered '
'bible. Please note, that verses will be downloaded on\n'
'demand and thus an internet connection is required.'))
else:
self.ImportProgressLabel.setText(translate(
self.importProgressLabel.setText(translate(
'BiblesPlugin.ImportWizardForm', 'Finished import.'))
else:
self.ImportProgressLabel.setText(
translate('BiblesPlugin.ImportWizardForm',
'Your Bible import failed.'))
self.importProgressLabel.setText(translate(
'BiblesPlugin.ImportWizardForm', 'Your Bible import failed.'))
delete_database(self.bibleplugin.settingsSection, importer.file)
def postImport(self):
self.ImportProgressBar.setValue(self.ImportProgressBar.maximum())
self.importProgressBar.setValue(self.importProgressBar.maximum())
self.finishButton.setVisible(True)
self.cancelButton.setVisible(False)
Receiver.send_message(u'openlp_process_events')

View File

@ -29,356 +29,401 @@ from PyQt4 import QtCore, QtGui
from openlp.core.lib import build_icon, translate
class Ui_BibleImportWizard(object):
def setupUi(self, BibleImportWizard):
BibleImportWizard.setObjectName(u'BibleImportWizard')
BibleImportWizard.resize(550, 386)
BibleImportWizard.setModal(True)
BibleImportWizard.setWizardStyle(QtGui.QWizard.ModernStyle)
BibleImportWizard.setOptions(
def setupUi(self, bibleImportWizard):
bibleImportWizard.setObjectName(u'bibleImportWizard')
bibleImportWizard.resize(550, 386)
bibleImportWizard.setModal(True)
bibleImportWizard.setWizardStyle(QtGui.QWizard.ModernStyle)
bibleImportWizard.setOptions(
QtGui.QWizard.IndependentPages |
QtGui.QWizard.NoBackButtonOnStartPage |
QtGui.QWizard.NoBackButtonOnLastPage)
self.WelcomePage = QtGui.QWizardPage()
self.WelcomePage.setPixmap(QtGui.QWizard.WatermarkPixmap,
# Welcome page
self.welcomePage = QtGui.QWizardPage()
self.welcomePage.setPixmap(QtGui.QWizard.WatermarkPixmap,
QtGui.QPixmap(u':/wizards/wizard_importbible.bmp'))
self.WelcomePage.setObjectName(u'WelcomePage')
self.WelcomeLayout = QtGui.QVBoxLayout(self.WelcomePage)
self.WelcomeLayout.setSpacing(8)
self.WelcomeLayout.setMargin(0)
self.WelcomeLayout.setObjectName(u'WelcomeLayout')
self.TitleLabel = QtGui.QLabel(self.WelcomePage)
self.TitleLabel.setObjectName(u'TitleLabel')
self.WelcomeLayout.addWidget(self.TitleLabel)
self.welcomePage.setObjectName(u'WelcomePage')
self.welcomeLayout = QtGui.QVBoxLayout(self.welcomePage)
self.welcomeLayout.setSpacing(8)
self.welcomeLayout.setMargin(0)
self.welcomeLayout.setObjectName(u'WelcomeLayout')
self.titleLabel = QtGui.QLabel(self.welcomePage)
self.titleLabel.setObjectName(u'TitleLabel')
self.welcomeLayout.addWidget(self.titleLabel)
spacerItem = QtGui.QSpacerItem(20, 40,
QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Fixed)
self.WelcomeLayout.addItem(spacerItem)
self.InformationLabel = QtGui.QLabel(self.WelcomePage)
self.InformationLabel.setWordWrap(True)
self.InformationLabel.setMargin(10)
self.InformationLabel.setObjectName(u'InformationLabel')
self.WelcomeLayout.addWidget(self.InformationLabel)
self.welcomeLayout.addItem(spacerItem)
self.informationLabel = QtGui.QLabel(self.welcomePage)
self.informationLabel.setWordWrap(True)
self.informationLabel.setMargin(10)
self.informationLabel.setObjectName(u'InformationLabel')
self.welcomeLayout.addWidget(self.informationLabel)
spacerItem1 = QtGui.QSpacerItem(20, 40,
QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Expanding)
self.WelcomeLayout.addItem(spacerItem1)
BibleImportWizard.addPage(self.WelcomePage)
self.SelectPage = QtGui.QWizardPage()
self.SelectPage.setObjectName(u'SelectPage')
self.selectPageLayout = QtGui.QVBoxLayout(self.SelectPage)
self.welcomeLayout.addItem(spacerItem1)
bibleImportWizard.addPage(self.welcomePage)
# Select page
self.selectPage = QtGui.QWizardPage()
self.selectPage.setObjectName(u'SelectPage')
self.selectPageLayout = QtGui.QVBoxLayout(self.selectPage)
self.selectPageLayout.setSpacing(8)
self.selectPageLayout.setMargin(20)
self.selectPageLayout.setObjectName(u'selectPageLayout')
self.FormatSelectLayout = QtGui.QHBoxLayout()
self.FormatSelectLayout.setSpacing(8)
self.FormatSelectLayout.setObjectName(u'FormatSelectLayout')
self.FormatLabel = QtGui.QLabel(self.SelectPage)
self.FormatLabel.setObjectName(u'FormatLabel')
self.FormatSelectLayout.addWidget(self.FormatLabel)
self.FormatComboBox = QtGui.QComboBox(self.SelectPage)
self.FormatComboBox.setObjectName(u'FormatComboBox')
self.FormatComboBox.addItem(u'')
self.FormatComboBox.addItem(u'')
self.FormatComboBox.addItem(u'')
self.FormatComboBox.addItem(u'')
self.FormatSelectLayout.addWidget(self.FormatComboBox)
self.formatSelectLayout = QtGui.QHBoxLayout()
self.formatSelectLayout.setSpacing(8)
self.formatSelectLayout.setObjectName(u'FormatSelectLayout')
self.formatLabel = QtGui.QLabel(self.selectPage)
self.formatLabel.setObjectName(u'FormatLabel')
self.formatSelectLayout.addWidget(self.formatLabel)
self.formatComboBox = QtGui.QComboBox(self.selectPage)
self.formatComboBox.setObjectName(u'FormatComboBox')
self.formatComboBox.addItem(u'')
self.formatComboBox.addItem(u'')
self.formatComboBox.addItem(u'')
self.formatComboBox.addItem(u'')
self.formatComboBox.addItem(u'')
self.formatSelectLayout.addWidget(self.formatComboBox)
spacerItem2 = QtGui.QSpacerItem(40, 20,
QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum)
self.FormatSelectLayout.addItem(spacerItem2)
self.selectPageLayout.addLayout(self.FormatSelectLayout)
self.FormatWidget = QtGui.QStackedWidget(self.SelectPage)
self.FormatWidget.setObjectName(u'FormatWidget')
self.OsisPage = QtGui.QWidget()
self.OsisPage.setObjectName(u'OsisPage')
self.OsisLayout = QtGui.QFormLayout(self.OsisPage)
self.OsisLayout.setFieldGrowthPolicy(
QtGui.QFormLayout.ExpandingFieldsGrow)
self.OsisLayout.setMargin(0)
self.OsisLayout.setSpacing(8)
self.OsisLayout.setObjectName(u'OsisLayout')
self.OsisLocationLabel = QtGui.QLabel(self.OsisPage)
self.OsisLocationLabel.setObjectName(u'OsisLocationLabel')
self.OsisLayout.setWidget(1, QtGui.QFormLayout.LabelRole,
self.OsisLocationLabel)
self.OsisLocationLayout = QtGui.QHBoxLayout()
self.OsisLocationLayout.setSpacing(8)
self.OsisLocationLayout.setObjectName(u'OsisLocationLayout')
self.OSISLocationEdit = QtGui.QLineEdit(self.OsisPage)
self.OSISLocationEdit.setObjectName(u'OSISLocationEdit')
self.OsisLocationLayout.addWidget(self.OSISLocationEdit)
self.OsisFileButton = QtGui.QToolButton(self.OsisPage)
self.OsisFileButton.setMaximumSize(QtCore.QSize(32, 16777215))
self.formatSelectLayout.addItem(spacerItem2)
self.selectPageLayout.addLayout(self.formatSelectLayout)
self.formatWidget = QtGui.QStackedWidget(self.selectPage)
self.formatWidget.setObjectName(u'FormatWidget')
generalIcon = build_icon(u':/general/general_open.png')
self.OsisFileButton.setIcon(generalIcon)
self.OsisFileButton.setObjectName(u'OsisFileButton')
self.OsisLocationLayout.addWidget(self.OsisFileButton)
self.OsisLayout.setLayout(1, QtGui.QFormLayout.FieldRole,
self.OsisLocationLayout)
self.FormatWidget.addWidget(self.OsisPage)
self.CsvPage = QtGui.QWidget()
self.CsvPage.setObjectName(u'CsvPage')
self.CsvSourceLayout = QtGui.QFormLayout(self.CsvPage)
self.CsvSourceLayout.setFieldGrowthPolicy(
self.osisPage = QtGui.QWidget()
self.osisPage.setObjectName(u'OsisPage')
self.osisLayout = QtGui.QFormLayout(self.osisPage)
self.osisLayout.setFieldGrowthPolicy(
QtGui.QFormLayout.ExpandingFieldsGrow)
self.CsvSourceLayout.setLabelAlignment(QtCore.Qt.AlignBottom |
self.osisLayout.setMargin(0)
self.osisLayout.setSpacing(8)
self.osisLayout.setObjectName(u'OsisLayout')
self.osisLocationLabel = QtGui.QLabel(self.osisPage)
self.osisLocationLabel.setObjectName(u'OsisLocationLabel')
self.osisLayout.setWidget(1, QtGui.QFormLayout.LabelRole,
self.osisLocationLabel)
self.osisLocationLayout = QtGui.QHBoxLayout()
self.osisLocationLayout.setSpacing(8)
self.osisLocationLayout.setObjectName(u'OsisLocationLayout')
self.OSISLocationEdit = QtGui.QLineEdit(self.osisPage)
self.OSISLocationEdit.setObjectName(u'OSISLocationEdit')
self.osisLocationLayout.addWidget(self.OSISLocationEdit)
self.osisFileButton = QtGui.QToolButton(self.osisPage)
self.osisFileButton.setMaximumSize(QtCore.QSize(32, 16777215))
self.osisFileButton.setIcon(generalIcon)
self.osisFileButton.setObjectName(u'OsisFileButton')
self.osisLocationLayout.addWidget(self.osisFileButton)
self.osisLayout.setLayout(1, QtGui.QFormLayout.FieldRole,
self.osisLocationLayout)
self.formatWidget.addWidget(self.osisPage)
self.csvPage = QtGui.QWidget()
self.csvPage.setObjectName(u'CsvPage')
self.csvSourceLayout = QtGui.QFormLayout(self.csvPage)
self.csvSourceLayout.setFieldGrowthPolicy(
QtGui.QFormLayout.ExpandingFieldsGrow)
self.csvSourceLayout.setLabelAlignment(QtCore.Qt.AlignBottom |
QtCore.Qt.AlignRight | QtCore.Qt.AlignTrailing)
self.CsvSourceLayout.setFormAlignment(QtCore.Qt.AlignLeading |
self.csvSourceLayout.setFormAlignment(QtCore.Qt.AlignLeading |
QtCore.Qt.AlignLeft | QtCore.Qt.AlignTop)
self.CsvSourceLayout.setMargin(0)
self.CsvSourceLayout.setSpacing(8)
self.CsvSourceLayout.setObjectName(u'CsvSourceLayout')
self.BooksLocationLabel = QtGui.QLabel(self.CsvPage)
self.BooksLocationLabel.setObjectName(u'BooksLocationLabel')
self.CsvSourceLayout.setWidget(0, QtGui.QFormLayout.LabelRole,
self.BooksLocationLabel)
self.CsvBooksLayout = QtGui.QHBoxLayout()
self.CsvBooksLayout.setSpacing(8)
self.CsvBooksLayout.setObjectName(u'CsvBooksLayout')
self.BooksLocationEdit = QtGui.QLineEdit(self.CsvPage)
self.BooksLocationEdit.setObjectName(u'BooksLocationEdit')
self.CsvBooksLayout.addWidget(self.BooksLocationEdit)
self.BooksFileButton = QtGui.QToolButton(self.CsvPage)
self.BooksFileButton.setMaximumSize(QtCore.QSize(32, 16777215))
self.BooksFileButton.setIcon(generalIcon)
self.BooksFileButton.setObjectName(u'BooksFileButton')
self.CsvBooksLayout.addWidget(self.BooksFileButton)
self.CsvSourceLayout.setLayout(0, QtGui.QFormLayout.FieldRole,
self.CsvBooksLayout)
self.VerseLocationLabel = QtGui.QLabel(self.CsvPage)
self.VerseLocationLabel.setObjectName(u'VerseLocationLabel')
self.CsvSourceLayout.setWidget(1, QtGui.QFormLayout.LabelRole,
self.VerseLocationLabel)
self.CsvVerseLayout = QtGui.QHBoxLayout()
self.CsvVerseLayout.setSpacing(8)
self.CsvVerseLayout.setObjectName(u'CsvVerseLayout')
self.CsvVerseLocationEdit = QtGui.QLineEdit(self.CsvPage)
self.CsvVerseLocationEdit.setObjectName(u'CsvVerseLocationEdit')
self.CsvVerseLayout.addWidget(self.CsvVerseLocationEdit)
self.CsvVersesFileButton = QtGui.QToolButton(self.CsvPage)
self.CsvVersesFileButton.setMaximumSize(QtCore.QSize(32, 16777215))
self.CsvVersesFileButton.setIcon(generalIcon)
self.CsvVersesFileButton.setObjectName(u'CsvVersesFileButton')
self.CsvVerseLayout.addWidget(self.CsvVersesFileButton)
self.CsvSourceLayout.setLayout(1, QtGui.QFormLayout.FieldRole,
self.CsvVerseLayout)
self.FormatWidget.addWidget(self.CsvPage)
self.OpenSongPage = QtGui.QWidget()
self.OpenSongPage.setObjectName(u'OpenSongPage')
self.OpenSongLayout = QtGui.QFormLayout(self.OpenSongPage)
self.OpenSongLayout.setMargin(0)
self.OpenSongLayout.setSpacing(8)
self.OpenSongLayout.setObjectName(u'OpenSongLayout')
self.OpenSongFileLabel = QtGui.QLabel(self.OpenSongPage)
self.OpenSongFileLabel.setObjectName(u'OpenSongFileLabel')
self.OpenSongLayout.setWidget(0, QtGui.QFormLayout.LabelRole,
self.OpenSongFileLabel)
self.OpenSongFileLayout = QtGui.QHBoxLayout()
self.OpenSongFileLayout.setSpacing(8)
self.OpenSongFileLayout.setObjectName(u'OpenSongFileLayout')
self.OpenSongFileEdit = QtGui.QLineEdit(self.OpenSongPage)
self.OpenSongFileEdit.setObjectName(u'OpenSongFileEdit')
self.OpenSongFileLayout.addWidget(self.OpenSongFileEdit)
self.OpenSongBrowseButton = QtGui.QToolButton(self.OpenSongPage)
self.OpenSongBrowseButton.setIcon(generalIcon)
self.OpenSongBrowseButton.setObjectName(u'OpenSongBrowseButton')
self.OpenSongFileLayout.addWidget(self.OpenSongBrowseButton)
self.OpenSongLayout.setLayout(0, QtGui.QFormLayout.FieldRole,
self.OpenSongFileLayout)
self.FormatWidget.addWidget(self.OpenSongPage)
self.WebDownloadPage = QtGui.QWidget()
self.WebDownloadPage.setObjectName(u'WebDownloadPage')
self.WebDownloadLayout = QtGui.QVBoxLayout(self.WebDownloadPage)
self.WebDownloadLayout.setSpacing(8)
self.WebDownloadLayout.setMargin(0)
self.WebDownloadLayout.setObjectName(u'WebDownloadLayout')
self.WebDownloadTabWidget = QtGui.QTabWidget(self.WebDownloadPage)
self.WebDownloadTabWidget.setObjectName(u'WebDownloadTabWidget')
self.DownloadOptionsTab = QtGui.QWidget()
self.DownloadOptionsTab.setObjectName(u'DownloadOptionsTab')
self.DownloadOptionsLayout = QtGui.QFormLayout(self.DownloadOptionsTab)
self.DownloadOptionsLayout.setMargin(8)
self.DownloadOptionsLayout.setSpacing(8)
self.DownloadOptionsLayout.setObjectName(u'DownloadOptionsLayout')
self.LocationLabel = QtGui.QLabel(self.DownloadOptionsTab)
self.LocationLabel.setObjectName(u'LocationLabel')
self.DownloadOptionsLayout.setWidget(0, QtGui.QFormLayout.LabelRole,
self.LocationLabel)
self.LocationComboBox = QtGui.QComboBox(self.DownloadOptionsTab)
self.LocationComboBox.setObjectName(u'LocationComboBox')
self.LocationComboBox.addItem(u'')
self.LocationComboBox.addItem(u'')
self.DownloadOptionsLayout.setWidget(0, QtGui.QFormLayout.FieldRole,
self.LocationComboBox)
self.BibleLabel = QtGui.QLabel(self.DownloadOptionsTab)
self.BibleLabel.setObjectName(u'BibleLabel')
self.DownloadOptionsLayout.setWidget(1, QtGui.QFormLayout.LabelRole,
self.BibleLabel)
self.BibleComboBox = QtGui.QComboBox(self.DownloadOptionsTab)
self.BibleComboBox.setSizeAdjustPolicy(QtGui.QComboBox.AdjustToContents)
self.BibleComboBox.setObjectName(u'BibleComboBox')
self.BibleComboBox.addItem(u'')
self.BibleComboBox.addItem(u'')
self.BibleComboBox.addItem(u'')
self.DownloadOptionsLayout.setWidget(1, QtGui.QFormLayout.FieldRole,
self.BibleComboBox)
self.WebDownloadTabWidget.addTab(self.DownloadOptionsTab, u'')
self.ProxyServerTab = QtGui.QWidget()
self.ProxyServerTab.setObjectName(u'ProxyServerTab')
self.ProxyServerLayout = QtGui.QFormLayout(self.ProxyServerTab)
self.ProxyServerLayout.setObjectName(u'ProxyServerLayout')
self.AddressLabel = QtGui.QLabel(self.ProxyServerTab)
self.AddressLabel.setObjectName(u'AddressLabel')
self.ProxyServerLayout.setWidget(0, QtGui.QFormLayout.LabelRole,
self.AddressLabel)
self.AddressEdit = QtGui.QLineEdit(self.ProxyServerTab)
self.AddressEdit.setObjectName(u'AddressEdit')
self.ProxyServerLayout.setWidget(0, QtGui.QFormLayout.FieldRole,
self.AddressEdit)
self.UsernameLabel = QtGui.QLabel(self.ProxyServerTab)
self.UsernameLabel.setObjectName(u'UsernameLabel')
self.ProxyServerLayout.setWidget(1, QtGui.QFormLayout.LabelRole,
self.UsernameLabel)
self.UsernameEdit = QtGui.QLineEdit(self.ProxyServerTab)
self.UsernameEdit.setObjectName(u'UsernameEdit')
self.ProxyServerLayout.setWidget(1, QtGui.QFormLayout.FieldRole,
self.UsernameEdit)
self.PasswordLabel = QtGui.QLabel(self.ProxyServerTab)
self.PasswordLabel.setObjectName(u'PasswordLabel')
self.ProxyServerLayout.setWidget(2, QtGui.QFormLayout.LabelRole,
self.PasswordLabel)
self.PasswordEdit = QtGui.QLineEdit(self.ProxyServerTab)
self.PasswordEdit.setObjectName(u'PasswordEdit')
self.ProxyServerLayout.setWidget(2, QtGui.QFormLayout.FieldRole,
self.PasswordEdit)
self.WebDownloadTabWidget.addTab(self.ProxyServerTab, u'')
self.WebDownloadLayout.addWidget(self.WebDownloadTabWidget)
self.FormatWidget.addWidget(self.WebDownloadPage)
self.selectPageLayout.addWidget(self.FormatWidget)
BibleImportWizard.addPage(self.SelectPage)
self.LicenseDetailsPage = QtGui.QWizardPage()
self.LicenseDetailsPage.setObjectName(u'LicenseDetailsPage')
self.LicenseDetailsLayout = QtGui.QFormLayout(self.LicenseDetailsPage)
self.LicenseDetailsLayout.setMargin(20)
self.LicenseDetailsLayout.setSpacing(8)
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.VersionNameEdit = QtGui.QLineEdit(self.LicenseDetailsPage)
self.VersionNameEdit.setObjectName(u'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.CopyrightEdit = QtGui.QLineEdit(self.LicenseDetailsPage)
self.CopyrightEdit.setObjectName(u'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)
BibleImportWizard.addPage(self.LicenseDetailsPage)
self.ImportPage = QtGui.QWizardPage()
self.ImportPage.setObjectName(u'ImportPage')
self.ImportLayout = QtGui.QVBoxLayout(self.ImportPage)
self.ImportLayout.setSpacing(8)
self.ImportLayout.setMargin(50)
self.ImportLayout.setObjectName(u'ImportLayout')
self.ImportProgressLabel = QtGui.QLabel(self.ImportPage)
self.ImportProgressLabel.setObjectName(u'ImportProgressLabel')
self.ImportLayout.addWidget(self.ImportProgressLabel)
self.ImportProgressBar = QtGui.QProgressBar(self.ImportPage)
self.ImportProgressBar.setValue(0)
self.ImportProgressBar.setObjectName(u'ImportProgressBar')
self.ImportLayout.addWidget(self.ImportProgressBar)
BibleImportWizard.addPage(self.ImportPage)
self.csvSourceLayout.setMargin(0)
self.csvSourceLayout.setSpacing(8)
self.csvSourceLayout.setObjectName(u'CsvSourceLayout')
self.booksLocationLabel = QtGui.QLabel(self.csvPage)
self.booksLocationLabel.setObjectName(u'BooksLocationLabel')
self.csvSourceLayout.setWidget(0, QtGui.QFormLayout.LabelRole,
self.booksLocationLabel)
self.csvBooksLayout = QtGui.QHBoxLayout()
self.csvBooksLayout.setSpacing(8)
self.csvBooksLayout.setObjectName(u'CsvBooksLayout')
self.booksLocationEdit = QtGui.QLineEdit(self.csvPage)
self.booksLocationEdit.setObjectName(u'BooksLocationEdit')
self.csvBooksLayout.addWidget(self.booksLocationEdit)
self.booksFileButton = QtGui.QToolButton(self.csvPage)
self.booksFileButton.setMaximumSize(QtCore.QSize(32, 16777215))
self.booksFileButton.setIcon(generalIcon)
self.booksFileButton.setObjectName(u'BooksFileButton')
self.csvBooksLayout.addWidget(self.booksFileButton)
self.csvSourceLayout.setLayout(0, QtGui.QFormLayout.FieldRole,
self.csvBooksLayout)
self.verseLocationLabel = QtGui.QLabel(self.csvPage)
self.verseLocationLabel.setObjectName(u'VerseLocationLabel')
self.csvSourceLayout.setWidget(1, QtGui.QFormLayout.LabelRole,
self.verseLocationLabel)
self.csvVerseLayout = QtGui.QHBoxLayout()
self.csvVerseLayout.setSpacing(8)
self.csvVerseLayout.setObjectName(u'CsvVerseLayout')
self.csvVerseLocationEdit = QtGui.QLineEdit(self.csvPage)
self.csvVerseLocationEdit.setObjectName(u'CsvVerseLocationEdit')
self.csvVerseLayout.addWidget(self.csvVerseLocationEdit)
self.csvVersesFileButton = QtGui.QToolButton(self.csvPage)
self.csvVersesFileButton.setMaximumSize(QtCore.QSize(32, 16777215))
self.csvVersesFileButton.setIcon(generalIcon)
self.csvVersesFileButton.setObjectName(u'CsvVersesFileButton')
self.csvVerseLayout.addWidget(self.csvVersesFileButton)
self.csvSourceLayout.setLayout(1, QtGui.QFormLayout.FieldRole,
self.csvVerseLayout)
self.formatWidget.addWidget(self.csvPage)
self.openSongPage = QtGui.QWidget()
self.openSongPage.setObjectName(u'OpenSongPage')
self.openSongLayout = QtGui.QFormLayout(self.openSongPage)
self.openSongLayout.setMargin(0)
self.openSongLayout.setSpacing(8)
self.openSongLayout.setObjectName(u'OpenSongLayout')
self.openSongFileLabel = QtGui.QLabel(self.openSongPage)
self.openSongFileLabel.setObjectName(u'OpenSongFileLabel')
self.openSongLayout.setWidget(0, QtGui.QFormLayout.LabelRole,
self.openSongFileLabel)
self.openSongFileLayout = QtGui.QHBoxLayout()
self.openSongFileLayout.setSpacing(8)
self.openSongFileLayout.setObjectName(u'OpenSongFileLayout')
self.openSongFileEdit = QtGui.QLineEdit(self.openSongPage)
self.openSongFileEdit.setObjectName(u'OpenSongFileEdit')
self.openSongFileLayout.addWidget(self.openSongFileEdit)
self.openSongBrowseButton = QtGui.QToolButton(self.openSongPage)
self.openSongBrowseButton.setIcon(generalIcon)
self.openSongBrowseButton.setObjectName(u'OpenSongBrowseButton')
self.openSongFileLayout.addWidget(self.openSongBrowseButton)
self.openSongLayout.setLayout(0, QtGui.QFormLayout.FieldRole,
self.openSongFileLayout)
self.formatWidget.addWidget(self.openSongPage)
self.webDownloadPage = QtGui.QWidget()
self.webDownloadPage.setObjectName(u'WebDownloadPage')
self.webDownloadLayout = QtGui.QVBoxLayout(self.webDownloadPage)
self.webDownloadLayout.setSpacing(8)
self.webDownloadLayout.setMargin(0)
self.webDownloadLayout.setObjectName(u'WebDownloadLayout')
self.webDownloadTabWidget = QtGui.QTabWidget(self.webDownloadPage)
self.webDownloadTabWidget.setObjectName(u'WebDownloadTabWidget')
self.downloadOptionsTab = QtGui.QWidget()
self.downloadOptionsTab.setObjectName(u'DownloadOptionsTab')
self.downloadOptionsLayout = QtGui.QFormLayout(self.downloadOptionsTab)
self.downloadOptionsLayout.setMargin(8)
self.downloadOptionsLayout.setSpacing(8)
self.downloadOptionsLayout.setObjectName(u'DownloadOptionsLayout')
self.locationLabel = QtGui.QLabel(self.downloadOptionsTab)
self.locationLabel.setObjectName(u'LocationLabel')
self.downloadOptionsLayout.setWidget(0, QtGui.QFormLayout.LabelRole,
self.locationLabel)
self.locationComboBox = QtGui.QComboBox(self.downloadOptionsTab)
self.locationComboBox.setObjectName(u'LocationComboBox')
self.locationComboBox.addItem(u'')
self.locationComboBox.addItem(u'')
self.downloadOptionsLayout.setWidget(0, QtGui.QFormLayout.FieldRole,
self.locationComboBox)
self.bibleLabel = QtGui.QLabel(self.downloadOptionsTab)
self.bibleLabel.setObjectName(u'BibleLabel')
self.downloadOptionsLayout.setWidget(1, QtGui.QFormLayout.LabelRole,
self.bibleLabel)
self.bibleComboBox = QtGui.QComboBox(self.downloadOptionsTab)
self.bibleComboBox.setSizeAdjustPolicy(QtGui.QComboBox.AdjustToContents)
self.bibleComboBox.setObjectName(u'BibleComboBox')
self.bibleComboBox.addItem(u'')
self.bibleComboBox.addItem(u'')
self.bibleComboBox.addItem(u'')
self.downloadOptionsLayout.setWidget(1, QtGui.QFormLayout.FieldRole,
self.bibleComboBox)
self.webDownloadTabWidget.addTab(self.downloadOptionsTab, u'')
self.proxyServerTab = QtGui.QWidget()
self.proxyServerTab.setObjectName(u'ProxyServerTab')
self.proxyServerLayout = QtGui.QFormLayout(self.proxyServerTab)
self.proxyServerLayout.setObjectName(u'ProxyServerLayout')
self.addressLabel = QtGui.QLabel(self.proxyServerTab)
self.addressLabel.setObjectName(u'AddressLabel')
self.proxyServerLayout.setWidget(0, QtGui.QFormLayout.LabelRole,
self.addressLabel)
self.addressEdit = QtGui.QLineEdit(self.proxyServerTab)
self.addressEdit.setObjectName(u'AddressEdit')
self.proxyServerLayout.setWidget(0, QtGui.QFormLayout.FieldRole,
self.addressEdit)
self.usernameLabel = QtGui.QLabel(self.proxyServerTab)
self.usernameLabel.setObjectName(u'UsernameLabel')
self.proxyServerLayout.setWidget(1, QtGui.QFormLayout.LabelRole,
self.usernameLabel)
self.usernameEdit = QtGui.QLineEdit(self.proxyServerTab)
self.usernameEdit.setObjectName(u'UsernameEdit')
self.proxyServerLayout.setWidget(1, QtGui.QFormLayout.FieldRole,
self.usernameEdit)
self.passwordLabel = QtGui.QLabel(self.proxyServerTab)
self.passwordLabel.setObjectName(u'PasswordLabel')
self.proxyServerLayout.setWidget(2, QtGui.QFormLayout.LabelRole,
self.passwordLabel)
self.passwordEdit = QtGui.QLineEdit(self.proxyServerTab)
self.passwordEdit.setObjectName(u'PasswordEdit')
self.proxyServerLayout.setWidget(2, QtGui.QFormLayout.FieldRole,
self.passwordEdit)
self.webDownloadTabWidget.addTab(self.proxyServerTab, u'')
self.webDownloadLayout.addWidget(self.webDownloadTabWidget)
self.formatWidget.addWidget(self.webDownloadPage)
self.openlp1Page = QtGui.QWidget()
self.openlp1Page.setObjectName(u'Openlp1Page')
self.openlp1Layout = QtGui.QFormLayout(self.openlp1Page)
self.openlp1Layout.setFieldGrowthPolicy(
QtGui.QFormLayout.ExpandingFieldsGrow)
self.openlp1Layout.setMargin(0)
self.openlp1Layout.setSpacing(8)
self.openlp1Layout.setObjectName(u'Openlp1Layout')
self.openlp1LocationLabel = QtGui.QLabel(self.openlp1Page)
self.openlp1LocationLabel.setObjectName(u'Openlp1LocationLabel')
self.openlp1Layout.setWidget(1, QtGui.QFormLayout.LabelRole,
self.openlp1LocationLabel)
self.openlp1LocationLayout = QtGui.QHBoxLayout()
self.openlp1LocationLayout.setSpacing(8)
self.openlp1LocationLayout.setObjectName(u'Openlp1LocationLayout')
self.openlp1LocationEdit = QtGui.QLineEdit(self.openlp1Page)
self.openlp1LocationEdit.setObjectName(u'Openlp1LocationEdit')
self.openlp1LocationLayout.addWidget(self.openlp1LocationEdit)
self.openlp1FileButton = QtGui.QToolButton(self.openlp1Page)
self.openlp1FileButton.setMaximumSize(QtCore.QSize(32, 16777215))
self.openlp1FileButton.setIcon(generalIcon)
self.openlp1FileButton.setObjectName(u'Openlp1FileButton')
self.openlp1LocationLayout.addWidget(self.openlp1FileButton)
self.openlp1Layout.setLayout(1, QtGui.QFormLayout.FieldRole,
self.openlp1LocationLayout)
self.openlp1DisabledLabel = QtGui.QLabel(self.openlp1Page)
self.openlp1DisabledLabel.setObjectName(u'openlp1DisabledLabel')
self.openlp1DisabledLabel.setVisible(False)
self.openlp1DisabledLabel.setWordWrap(True)
self.openlp1Layout.addWidget(self.openlp1DisabledLabel)
self.formatWidget.addWidget(self.openlp1Page)
self.selectPageLayout.addWidget(self.formatWidget)
bibleImportWizard.addPage(self.selectPage)
# License page
self.licenseDetailsPage = QtGui.QWizardPage()
self.licenseDetailsPage.setObjectName(u'LicenseDetailsPage')
self.licenseDetailsLayout = QtGui.QFormLayout(self.licenseDetailsPage)
self.licenseDetailsLayout.setMargin(20)
self.licenseDetailsLayout.setSpacing(8)
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.versionNameEdit = QtGui.QLineEdit(self.licenseDetailsPage)
self.versionNameEdit.setObjectName(u'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.copyrightEdit = QtGui.QLineEdit(self.licenseDetailsPage)
self.copyrightEdit.setObjectName(u'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)
bibleImportWizard.addPage(self.licenseDetailsPage)
# Progress page
self.importPage = QtGui.QWizardPage()
self.importPage.setObjectName(u'ImportPage')
self.importLayout = QtGui.QVBoxLayout(self.importPage)
self.importLayout.setSpacing(8)
self.importLayout.setMargin(50)
self.importLayout.setObjectName(u'ImportLayout')
self.importProgressLabel = QtGui.QLabel(self.importPage)
self.importProgressLabel.setObjectName(u'ImportProgressLabel')
self.importLayout.addWidget(self.importProgressLabel)
self.importProgressBar = QtGui.QProgressBar(self.importPage)
self.importProgressBar.setValue(0)
self.importProgressBar.setObjectName(u'ImportProgressBar')
self.importLayout.addWidget(self.importProgressBar)
bibleImportWizard.addPage(self.importPage)
self.retranslateUi(BibleImportWizard)
self.FormatWidget.setCurrentIndex(0)
self.WebDownloadTabWidget.setCurrentIndex(0)
QtCore.QObject.connect(self.FormatComboBox,
self.retranslateUi(bibleImportWizard)
self.formatWidget.setCurrentIndex(0)
self.webDownloadTabWidget.setCurrentIndex(0)
QtCore.QObject.connect(self.formatComboBox,
QtCore.SIGNAL(u'currentIndexChanged(int)'),
self.FormatWidget.setCurrentIndex)
QtCore.QMetaObject.connectSlotsByName(BibleImportWizard)
self.formatWidget.setCurrentIndex)
QtCore.QMetaObject.connectSlotsByName(bibleImportWizard)
def retranslateUi(self, BibleImportWizard):
BibleImportWizard.setWindowTitle(
def retranslateUi(self, bibleImportWizard):
bibleImportWizard.setWindowTitle(
translate('BiblesPlugin.ImportWizardForm', 'Bible Import Wizard'))
self.TitleLabel.setText(
self.titleLabel.setText(
u'<span style="font-size:14pt; font-weight:600;">%s</span>' % \
translate('BiblesPlugin.ImportWizardForm',
'Welcome to the Bible Import Wizard'))
self.InformationLabel.setText(
'Welcome to the Bible Import Wizard'))
self.informationLabel.setText(
translate('BiblesPlugin.ImportWizardForm',
'This wizard will help you to import Bibles from a '
'variety of formats. Click the next button below to start the '
'process by selecting a format to import from.'))
self.SelectPage.setTitle(translate('BiblesPlugin.ImportWizardForm',
'This wizard will help you to import Bibles from a '
'variety of formats. Click the next button below to start the '
'process by selecting a format to import from.'))
self.selectPage.setTitle(translate('BiblesPlugin.ImportWizardForm',
'Select Import Source'))
self.SelectPage.setSubTitle(
self.selectPage.setSubTitle(
translate('BiblesPlugin.ImportWizardForm',
'Select the import format, and where to import from.'))
self.FormatLabel.setText(
'Select the import format, and where to import from.'))
self.formatLabel.setText(
translate('BiblesPlugin.ImportWizardForm', 'Format:'))
self.FormatComboBox.setItemText(0,
self.formatComboBox.setItemText(0,
translate('BiblesPlugin.ImportWizardForm', 'OSIS'))
self.FormatComboBox.setItemText(1,
self.formatComboBox.setItemText(1,
translate('BiblesPlugin.ImportWizardForm', 'CSV'))
self.FormatComboBox.setItemText(2,
self.formatComboBox.setItemText(2,
translate('BiblesPlugin.ImportWizardForm', 'OpenSong'))
self.FormatComboBox.setItemText(3,
self.formatComboBox.setItemText(3,
translate('BiblesPlugin.ImportWizardForm', 'Web Download'))
self.OsisLocationLabel.setText(
self.formatComboBox.setItemText(4,
translate('BiblesPlugin.ImportWizardForm', 'openlp.org 1.x'))
self.openlp1LocationLabel.setText(
translate('BiblesPlugin.ImportWizardForm', 'File location:'))
self.BooksLocationLabel.setText(
self.osisLocationLabel.setText(
translate('BiblesPlugin.ImportWizardForm', 'File location:'))
self.booksLocationLabel.setText(
translate('BiblesPlugin.ImportWizardForm', 'Books location:'))
self.VerseLocationLabel.setText(
self.verseLocationLabel.setText(
translate('BiblesPlugin.ImportWizardForm', 'Verse location:'))
self.OpenSongFileLabel.setText(
self.openSongFileLabel.setText(
translate('BiblesPlugin.ImportWizardForm', 'Bible filename:'))
self.LocationLabel.setText(
self.locationLabel.setText(
translate('BiblesPlugin.ImportWizardForm', 'Location:'))
self.LocationComboBox.setItemText(0,
self.locationComboBox.setItemText(0,
translate('BiblesPlugin.ImportWizardForm', 'Crosswalk'))
self.LocationComboBox.setItemText(1,
self.locationComboBox.setItemText(1,
translate('BiblesPlugin.ImportWizardForm', 'BibleGateway'))
self.BibleLabel.setText(
self.bibleLabel.setText(
translate('BiblesPlugin.ImportWizardForm', 'Bible:'))
self.WebDownloadTabWidget.setTabText(
self.WebDownloadTabWidget.indexOf(self.DownloadOptionsTab),
self.webDownloadTabWidget.setTabText(
self.webDownloadTabWidget.indexOf(self.downloadOptionsTab),
translate('BiblesPlugin.ImportWizardForm', 'Download Options'))
self.AddressLabel.setText(
self.addressLabel.setText(
translate('BiblesPlugin.ImportWizardForm', 'Server:'))
self.UsernameLabel.setText(
self.usernameLabel.setText(
translate('BiblesPlugin.ImportWizardForm', 'Username:'))
self.PasswordLabel.setText(
self.passwordLabel.setText(
translate('BiblesPlugin.ImportWizardForm', 'Password:'))
self.WebDownloadTabWidget.setTabText(
self.WebDownloadTabWidget.indexOf(self.ProxyServerTab),
self.webDownloadTabWidget.setTabText(
self.webDownloadTabWidget.indexOf(self.proxyServerTab),
translate('BiblesPlugin.ImportWizardForm',
'Proxy Server (Optional)'))
self.LicenseDetailsPage.setTitle(
'Proxy Server (Optional)'))
self.licenseDetailsPage.setTitle(
translate('BiblesPlugin.ImportWizardForm', 'License Details'))
self.LicenseDetailsPage.setSubTitle(
self.licenseDetailsPage.setSubTitle(
translate('BiblesPlugin.ImportWizardForm',
'Set up the Bible\'s license details.'))
self.VersionNameLabel.setText(
'Set up the Bible\'s license details.'))
self.versionNameLabel.setText(
translate('BiblesPlugin.ImportWizardForm', 'Version name:'))
self.CopyrightLabel.setText(
self.copyrightLabel.setText(
translate('BiblesPlugin.ImportWizardForm', 'Copyright:'))
self.PermissionsLabel.setText(
self.permissionsLabel.setText(
translate('BiblesPlugin.ImportWizardForm', 'Permissions:'))
self.ImportPage.setTitle(
self.importPage.setTitle(
translate('BiblesPlugin.ImportWizardForm', 'Importing'))
self.ImportPage.setSubTitle(
self.importPage.setSubTitle(
translate('BiblesPlugin.ImportWizardForm',
'Please wait while your Bible is imported.'))
self.ImportProgressLabel.setText(
'Please wait while your Bible is imported.'))
self.importProgressLabel.setText(
translate('BiblesPlugin.ImportWizardForm', 'Ready.'))
self.ImportProgressBar.setFormat(u'%p%')
self.importProgressBar.setFormat(u'%p%')
self.openlp1DisabledLabel.setText(
translate('BiblesPlugin.ImportWizardForm', 'The openlp.org 1.x '
'importer has been disabled due to a missing Python module. If '
'you want to use this importer, you will need to install the '
'"python-sqlite" module.'))

View File

@ -30,7 +30,7 @@ import csv
from PyQt4 import QtCore
from openlp.core.lib import Receiver
from openlp.core.lib import Receiver, translate
from db import BibleDB
log = logging.getLogger(__name__)
@ -46,21 +46,19 @@ class CSVBible(BibleDB):
This class assumes the files contain all the information and
a clean bible is being loaded.
"""
BibleDB.__init__(self, parent, **kwargs)
log.info(self.__class__.__name__)
if u'booksfile' not in kwargs:
raise KeyError(u'You have to supply a file to import books from.')
BibleDB.__init__(self, parent, **kwargs)
self.booksfile = kwargs[u'booksfile']
if u'versefile' not in kwargs:
raise KeyError(u'You have to supply a file to import verses from.')
self.versesfile = kwargs[u'versefile']
QtCore.QObject.connect(Receiver.get_receiver(),
QtCore.SIGNAL(u'bibles_stop_import'), self.stop_import)
def do_import(self):
#Populate the Tables
success = True
books_file = None
book_ptr = None
verse_file = None
# Populate the Tables
try:
books_file = open(self.booksfile, 'r')
dialect = csv.Sniffer().sniff(books_file.read(1024))
@ -82,9 +80,7 @@ class CSVBible(BibleDB):
books_file.close()
if not success:
return False
verse_file = None
try:
book_ptr = None
verse_file = open(self.versesfile, 'r')
dialect = csv.Sniffer().sniff(verse_file.read(1024))
verse_file.seek(0)
@ -96,11 +92,12 @@ class CSVBible(BibleDB):
if book_ptr != line[0]:
book = self.get_book(line[0])
book_ptr = book.name
self.wizard.incrementProgressBar(
u'Importing %s %s' % (book.name, line[1]))
self.wizard.incrementProgressBar(u'%s %s %s...' % (
translate('BiblesPlugin.CSVImport', 'Importing'),
book.name, line[1]))
self.session.commit()
self.create_verse(book.id, line[1], line[2],
unicode(line[3], details['encoding']))
unicode(line[3], details['encoding']))
Receiver.send_message(u'openlp_process_events')
self.session.commit()
except IOError:
@ -110,7 +107,6 @@ class CSVBible(BibleDB):
if verse_file:
verse_file.close()
if self.stop_import_flag:
self.wizard.incrementProgressBar(u'Import canceled!')
return False
else:
return success

View File

@ -231,7 +231,7 @@ class BibleDB(QtCore.QObject, Manager):
def create_chapter(self, book_id, chapter, textlist):
"""
Add a chapter and it's verses to a book.
Add a chapter and its verses to a book.
``book_id``
The id of the book being appended.

View File

@ -333,24 +333,17 @@ class HTTPBible(BibleDB):
Init confirms the bible exists and stores the database path.
"""
BibleDB.__init__(self, parent, **kwargs)
if u'download_source' not in kwargs:
raise KeyError(u'Missing keyword argument "download_source"')
if u'download_name' not in kwargs:
raise KeyError(u'Missing keyword argument "download_name"')
self.download_source = kwargs[u'download_source']
self.download_name = kwargs[u'download_name']
self.proxy_server = None
self.proxy_username = None
self.proxy_password = None
if u'proxy_server' in kwargs:
self.proxy_server = kwargs[u'proxy_server']
else:
self.proxy_server = None
if u'proxy_username' in kwargs:
self.proxy_username = kwargs[u'proxy_username']
else:
self.proxy_username = None
if u'proxy_password' in kwargs:
self.proxy_password = kwargs[u'proxy_password']
else:
self.proxy_password = None
def do_import(self):
"""

View File

@ -33,10 +33,16 @@ from openlp.core.utils import AppLocation
from openlp.plugins.bibles.lib import parse_reference
from openlp.plugins.bibles.lib.db import BibleDB, BibleMeta
from opensong import OpenSongBible
from osis import OSISBible
from csvbible import CSVBible
from http import HTTPBible
from opensong import OpenSongBible
from osis import OSISBible
# Imports that might fail.
try:
from openlp1 import OpenLP1Bible
has_openlp1 = True
except ImportError:
has_openlp1 = False
log = logging.getLogger(__name__)
@ -56,11 +62,13 @@ class BibleFormat(object):
plus a few helper functions to facilitate generic handling of Bible types
for importing.
"""
_format_availability = {}
Unknown = -1
OSIS = 0
CSV = 1
OpenSong = 2
WebDownload = 3
OpenLP1 = 4
@staticmethod
def get_class(format):
@ -78,6 +86,8 @@ class BibleFormat(object):
return OpenSongBible
elif format == BibleFormat.WebDownload:
return HTTPBible
elif format == BibleFormat.OpenLP1:
return OpenLP1Bible
else:
return None
@ -90,9 +100,17 @@ class BibleFormat(object):
BibleFormat.OSIS,
BibleFormat.CSV,
BibleFormat.OpenSong,
BibleFormat.WebDownload
BibleFormat.WebDownload,
BibleFormat.OpenLP1
]
@staticmethod
def set_availability(format, available):
BibleFormat._format_availability[format] = available
@staticmethod
def get_availability(format):
return BibleFormat._format_availability.get(format, True)
class BibleManager(object):
"""
@ -334,3 +352,7 @@ class BibleManager(object):
"""
for bible in self.db_cache:
self.db_cache[bible].finalise()
BibleFormat.set_availability(BibleFormat.OpenLP1, has_openlp1)
__all__ = [u'BibleFormat']

View File

@ -875,7 +875,7 @@ class BibleMediaItem(MediaManagerItem):
old_second_bible = self._decodeQtObject(old_bitem, 'second_bible')
if old_bible != bible or old_second_bible != second_bible or \
old_book != book:
# The bible, second bible or book has changed.
# 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.

View File

@ -0,0 +1,93 @@
# -*- coding: utf-8 -*-
# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4
###############################################################################
# OpenLP - Open Source Lyrics Projection #
# --------------------------------------------------------------------------- #
# Copyright (c) 2008-2010 Raoul Snyman #
# Portions copyright (c) 2008-2010 Tim Bentley, Jonathan Corwin, Michael #
# Gorven, Scott Guerrieri, Meinert Jordan, Andreas Preikschat, Christian #
# Richter, Philip Ridout, Maikel Stuivenberg, Martin Thompson, Jon Tibble, #
# Carsten Tinggaard, Frode Woldsund #
# --------------------------------------------------------------------------- #
# This program is free software; you can redistribute it and/or modify it #
# under the terms of the GNU General Public License as published by the Free #
# Software Foundation; version 2 of the License. #
# #
# This program is distributed in the hope that it will be useful, but WITHOUT #
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or #
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for #
# more details. #
# #
# You should have received a copy of the GNU General Public License along #
# with this program; if not, write to the Free Software Foundation, Inc., 59 #
# Temple Place, Suite 330, Boston, MA 02111-1307 USA #
###############################################################################
import logging
import sqlite
from PyQt4 import QtCore
from openlp.core.lib import Receiver, translate
from db import BibleDB
log = logging.getLogger(__name__)
class OpenLP1Bible(BibleDB):
"""
This class provides the OpenLPv1 bible importer.
"""
def __init__(self, parent, **kwargs):
"""
Constructor.
"""
log.debug(self.__class__.__name__)
BibleDB.__init__(self, parent, **kwargs)
self.filename = kwargs[u'filename']
QtCore.QObject.connect(Receiver.get_receiver(),
QtCore.SIGNAL(u'bibles_stop_import'), self.stop_import)
def do_import(self):
"""
Imports an openlp.org v1 bible.
"""
connection = None
cursor = None
try:
connection = sqlite.connect(self.filename)
cursor = connection.cursor()
except:
return False
# Create all books.
cursor.execute(u'SELECT id, testament_id, name, abbreviation FROM book')
books = cursor.fetchall()
self.wizard.importProgressBar.setMaximum(len(books) + 1)
for book in books:
if self.stop_import_flag:
connection.close()
return False
book_id = int(book[0])
testament_id = int(book[1])
name = unicode(book[2], u'cp1252')
abbreviation = unicode(book[3], u'cp1252')
self.create_book(name, abbreviation, testament_id)
# Update the progess bar.
self.wizard.incrementProgressBar(u'%s %s...' % (translate(
'BiblesPlugin.OpenLP1Import', 'Importing'), name))
# Import the verses for this book.
cursor.execute(u'SELECT chapter, verse, text || \'\' AS text FROM '
'verse WHERE book_id=%s' % book_id)
verses = cursor.fetchall()
for verse in verses:
if self.stop_import_flag:
connection.close()
return False
chapter = int(verse[0])
verse_number = int(verse[1])
text = unicode(verse[2], u'cp1252')
self.create_verse(book_id, chapter, verse_number, text)
Receiver.send_message(u'openlp_process_events')
self.session.commit()
connection.close()
return True

View File

@ -44,10 +44,8 @@ class OpenSongBible(BibleDB):
Constructor to create and set up an instance of the OpenSongBible
class. This class is used to import Bibles from OpenSong's XML format.
"""
log.debug(__name__)
log.debug(self.__class__.__name__)
BibleDB.__init__(self, parent, **kwargs)
if 'filename' not in kwargs:
raise KeyError(u'You have to supply a file name to import from.')
self.filename = kwargs['filename']
QtCore.QObject.connect(Receiver.get_receiver(),
QtCore.SIGNAL(u'bibles_stop_import'), self.stop_import)
@ -59,7 +57,6 @@ class OpenSongBible(BibleDB):
log.debug(u'Starting OpenSong import from "%s"' % self.filename)
if not isinstance(self.filename, unicode):
self.filename = unicode(self.filename, u'utf8')
self.wizard.incrementProgressBar(u'Preparing for import...')
file = None
success = True
try:
@ -87,10 +84,9 @@ class OpenSongBible(BibleDB):
unicode(verse.text)
)
Receiver.send_message(u'openlp_process_events')
self.wizard.incrementProgressBar(
QtCore.QString('%s %s %s' % (
translate('BiblesPlugin.Opensong', 'Importing'),
db_book.name, chapter.attrib[u'n'])))
self.wizard.incrementProgressBar(u'%s %s %s...' % (
translate('BiblesPlugin.Opensong', 'Importing'),
db_book.name, chapter.attrib[u'n']))
self.session.commit()
except IOError:
log.exception(u'Loading bible from OpenSong file failed')
@ -99,7 +95,6 @@ class OpenSongBible(BibleDB):
if file:
file.close()
if self.stop_import_flag:
self.wizard.incrementProgressBar(u'Import canceled!')
return False
else:
return success

View File

@ -33,7 +33,7 @@ import re
from PyQt4 import QtCore
from openlp.core.lib import Receiver
from openlp.core.lib import Receiver, translate
from openlp.core.utils import AppLocation
from db import BibleDB
@ -50,11 +50,11 @@ class OSISBible(BibleDB):
Constructor to create and set up an instance of the OpenSongBible
class. This class is used to import Bibles from OpenSong's XML format.
"""
log.debug(__name__)
log.debug(self.__class__.__name__)
BibleDB.__init__(self, parent, **kwargs)
if u'filename' not in kwargs:
raise KeyError(u'You have to supply a file name to import from.')
self.filename = kwargs[u'filename']
fbibles = None
self.books = {}
self.verse_regex = re.compile(
r'<verse osisID="([a-zA-Z0-9 ]*).([0-9]*).([0-9]*)">(.*?)</verse>')
self.note_regex = re.compile(r'<note(.*?)>(.*?)</note>')
@ -72,11 +72,9 @@ class OSISBible(BibleDB):
self.divineName_regex = re.compile(
r'<divineName(.*?)>(.*?)</divineName>')
self.spaces_regex = re.compile(r'([ ]{2,})')
self.books = {}
filepath = os.path.join(
AppLocation.get_directory(AppLocation.PluginsDir), u'bibles',
u'resources', u'osisbooks.csv')
fbibles = None
try:
fbibles = open(filepath, u'r')
for line in fbibles:
@ -96,9 +94,15 @@ class OSISBible(BibleDB):
Loads a Bible from file.
"""
log.debug(u'Starting OSIS import from "%s"' % self.filename)
self.wizard.incrementProgressBar(
u'Detecting encoding (this may take a few minutes)...')
detect_file = None
db_book = None
osis = None
success = True
last_chapter = 0
testament = 1
match_count = 0
self.wizard.incrementProgressBar(translate('BiblesPlugin.OsisImport',
'Detecting encoding (this may take a few minutes)...'))
try:
detect_file = open(self.filename, u'r')
details = chardet.detect(detect_file.read(1048576))
@ -108,14 +112,8 @@ class OSISBible(BibleDB):
finally:
if detect_file:
detect_file.close()
osis = None
success = True
try:
osis = codecs.open(self.filename, u'r', details['encoding'])
last_chapter = 0
testament = 1
match_count = 0
db_book = None
for file_record in osis:
if self.stop_import_flag:
break
@ -142,9 +140,9 @@ class OSISBible(BibleDB):
if last_chapter != chapter:
if last_chapter != 0:
self.session.commit()
self.wizard.incrementProgressBar(
u'Importing %s %s...' % \
(self.books[match.group(1)][0], chapter))
self.wizard.incrementProgressBar(u'%s %s %s...' % (
translate('BiblesPlugin.OsisImport', 'Importing'),
self.books[match.group(1)][0], chapter))
last_chapter = chapter
# All of this rigmarol below is because the mod2osis
# tool from the Sword library embeds XML in the OSIS
@ -171,7 +169,6 @@ class OSISBible(BibleDB):
self.create_verse(db_book.id, chapter, verse, verse_text)
Receiver.send_message(u'openlp_process_events')
self.session.commit()
self.wizard.incrementProgressBar(u'Finishing import...')
if match_count == 0:
success = False
except (ValueError, IOError):
@ -181,7 +178,6 @@ class OSISBible(BibleDB):
if osis:
osis.close()
if self.stop_import_flag:
self.wizard.incrementProgressBar(u'Import canceled!')
return False
else:
return success

View File

@ -224,27 +224,24 @@ class EditCustomForm(QtGui.QDialog, Ui_CustomEditDialog):
``edit_all``
Indicates if all slides or only one slide has been edited.
"""
if len(slides) == 1:
self.slideListView.currentItem().setText(slides[0])
if edit_all:
self.slideListView.clear()
for slide in slides:
self.slideListView.addItem(slide)
else:
if edit_all:
self.slideListView.clear()
for slide in slides:
self.slideListView.addItem(slide)
else:
old_slides = []
old_row = self.slideListView.currentRow()
# Create a list with all (old/unedited) slides.
old_slides = [self.slideListView.item(row).text() for row in \
range(0, self.slideListView.count())]
self.slideListView.clear()
old_slides.pop(old_row)
# Insert all slides to make the old_slides list complete.
for slide in slides:
old_slides.insert(old_row, slide)
for slide in old_slides:
self.slideListView.addItem(slide)
self.slideListView.repaint()
old_slides = []
old_row = self.slideListView.currentRow()
# Create a list with all (old/unedited) slides.
old_slides = [self.slideListView.item(row).text() for row in \
range(0, self.slideListView.count())]
self.slideListView.clear()
old_slides.pop(old_row)
# Insert all slides to make the old_slides list complete.
for slide in slides:
old_slides.insert(old_row, slide)
for slide in old_slides:
self.slideListView.addItem(slide)
self.slideListView.repaint()
def onDeleteButtonPressed(self):
self.slideListView.takeItem(self.slideListView.currentRow())

View File

@ -75,42 +75,42 @@ class ImagePlugin(Plugin):
## Load Button ##
self.textStrings[StringContent.Load] = {
u'title': translate('ImagePlugin', 'Load'),
u'tooltip': translate('ImagePlugin',
u'tooltip': translate('ImagePlugin',
'Load a new Image')
}
## New Button ##
self.textStrings[StringContent.New] = {
u'title': translate('ImagePlugin', 'Add'),
u'tooltip': translate('ImagePlugin',
u'tooltip': translate('ImagePlugin',
'Add a new Image')
}
## Edit Button ##
self.textStrings[StringContent.Edit] = {
u'title': translate('ImagePlugin', 'Edit'),
u'tooltip': translate('ImagePlugin',
u'tooltip': translate('ImagePlugin',
'Edit the selected Image')
}
## Delete Button ##
self.textStrings[StringContent.Delete] = {
u'title': translate('ImagePlugin', 'Delete'),
u'tooltip': translate('ImagePlugin',
u'tooltip': translate('ImagePlugin',
'Delete the selected Image')
}
## Preview ##
self.textStrings[StringContent.Preview] = {
u'title': translate('ImagePlugin', 'Preview'),
u'tooltip': translate('ImagePlugin',
u'tooltip': translate('ImagePlugin',
'Preview the selected Image')
}
## Live Button ##
self.textStrings[StringContent.Live] = {
u'title': translate('ImagePlugin', 'Live'),
u'tooltip': translate('ImagePlugin',
u'tooltip': translate('ImagePlugin',
'Send the selected Image live')
}
## Add to service Button ##
self.textStrings[StringContent.Service] = {
u'title': translate('ImagePlugin', 'Service'),
u'tooltip': translate('ImagePlugin',
u'tooltip': translate('ImagePlugin',
'Add the selected Image to the service')
}

View File

@ -48,7 +48,7 @@ else:
uno_available = True
except ImportError:
uno_available = False
from PyQt4 import QtCore
from presentationcontroller import PresentationController, PresentationDocument
@ -210,12 +210,12 @@ class ImpressController(PresentationController):
class ImpressDocument(PresentationDocument):
"""
Class which holds information and controls a single presentation
"""
"""
def __init__(self, controller, presentation):
"""
Constructor, store information about the file and initialise
"""
Constructor, store information about the file and initialise
"""
log.debug(u'Init Presentation OpenOffice')
PresentationDocument.__init__(self, controller, presentation)
self.document = None
@ -287,7 +287,7 @@ 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(),
path = os.path.join(self.get_temp_folder(),
unicode(idx + 1) + u'.png')
try:
doc.storeToURL(urlpath, props)

View File

@ -51,7 +51,7 @@ class Controller(object):
def add_handler(self, controller, file, is_blank):
"""
Add a handler, which is an instance of a presentation and
Add a handler, which is an instance of a presentation and
slidecontroller combination. If the slidecontroller has a display
then load the presentation.
"""
@ -362,7 +362,7 @@ class MessageListener(object):
def timeout(self):
"""
The presentation may be timed or might be controlled by the
The presentation may be timed or might be controlled by the
application directly, rather than through OpenLP. Poll occassionally
to check which slide is currently displayed so the slidecontroller
view can be updated

View File

@ -108,7 +108,7 @@ class PptviewDocument(PresentationDocument):
"""
def __init__(self, controller, presentation):
"""
Constructor, store information about the file and initialise
Constructor, store information about the file and initialise
"""
log.debug(u'Init Presentation PowerPoint')
PresentationDocument.__init__(self, controller, presentation)

View File

@ -133,7 +133,7 @@ class PresentationTab(SettingsTab):
self.settingsSection + u'/' + controller.name,
QtCore.QVariant(QtCore.Qt.Checked)).toInt()[0])
self.OverrideAppCheckBox.setChecked(QtCore.QSettings().value(
self.settingsSection + u'/override app',
self.settingsSection + u'/override app',
QtCore.QVariant(QtCore.Qt.Unchecked)).toInt()[0])
def save(self):

View File

@ -163,30 +163,30 @@ class PresentationPlugin(Plugin):
## Load Button ##
self.textStrings[StringContent.Load] = {
u'title': translate('PresentationPlugin', 'Load'),
u'tooltip': translate('PresentationPlugin',
u'tooltip': translate('PresentationPlugin',
'Load a new Presentation')
}
## Delete Button ##
self.textStrings[StringContent.Delete] = {
u'title': translate('PresentationPlugin', 'Delete'),
u'tooltip': translate('PresentationPlugin',
u'tooltip': translate('PresentationPlugin',
'Delete the selected Presentation')
}
## Preview ##
self.textStrings[StringContent.Preview] = {
u'title': translate('PresentationPlugin', 'Preview'),
u'tooltip': translate('PresentationPlugin',
u'tooltip': translate('PresentationPlugin',
'Preview the selected Presentation')
}
## Live Button ##
self.textStrings[StringContent.Live] = {
u'title': translate('PresentationPlugin', 'Live'),
u'tooltip': translate('PresentationPlugin',
u'tooltip': translate('PresentationPlugin',
'Send the selected Presentation live')
}
## Add to service Button ##
self.textStrings[StringContent.Service] = {
u'title': translate('PresentationPlugin', 'Service'),
u'tooltip': translate('PresentationPlugin',
u'tooltip': translate('PresentationPlugin',
'Add the selected Presentation to the service')
}

View File

@ -77,7 +77,7 @@ class RemotesPlugin(Plugin):
'a running version of OpenLP on a different computer via a web '
'browser or through the remote API.')
return about_text
def setPluginTextStrings(self):
"""
Called to define all translatable texts of the plugin

View File

@ -120,35 +120,55 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog):
order_by_ref=Author.display_name)
self.AuthorsSelectionComboItem.clear()
self.AuthorsSelectionComboItem.addItem(u'')
self.authors = []
for author in authors:
row = self.AuthorsSelectionComboItem.count()
self.AuthorsSelectionComboItem.addItem(author.display_name)
self.AuthorsSelectionComboItem.setItemData(
row, QtCore.QVariant(author.id))
self.authors.append(author.display_name)
completer = QtGui.QCompleter(self.authors)
completer.setCaseSensitivity(QtCore.Qt.CaseInsensitive)
self.AuthorsSelectionComboItem.setCompleter(completer)
def loadTopics(self):
topics = self.manager.get_all_objects(Topic, order_by_ref=Topic.name)
self.SongTopicCombo.clear()
self.SongTopicCombo.addItem(u'')
self.topics = []
for topic in topics:
row = self.SongTopicCombo.count()
self.SongTopicCombo.addItem(topic.name)
self.topics.append(topic.name)
self.SongTopicCombo.setItemData(row, QtCore.QVariant(topic.id))
completer = QtGui.QCompleter(self.topics)
completer.setCaseSensitivity(QtCore.Qt.CaseInsensitive)
self.SongTopicCombo.setCompleter(completer)
def loadBooks(self):
books = self.manager.get_all_objects(Book, order_by_ref=Book.name)
self.SongbookCombo.clear()
self.SongbookCombo.addItem(u'')
self.books = []
for book in books:
row = self.SongbookCombo.count()
self.SongbookCombo.addItem(book.name)
self.books.append(book.name)
self.SongbookCombo.setItemData(row, QtCore.QVariant(book.id))
completer = QtGui.QCompleter(self.books)
completer.setCaseSensitivity(QtCore.Qt.CaseInsensitive)
self.SongbookCombo.setCompleter(completer)
def loadThemes(self, theme_list):
self.ThemeSelectionComboItem.clear()
self.ThemeSelectionComboItem.addItem(u'')
self.themes = []
for theme in theme_list:
self.ThemeSelectionComboItem.addItem(theme)
self.themes.append(theme)
completer = QtGui.QCompleter(self.themes)
completer.setCaseSensitivity(QtCore.Qt.CaseInsensitive)
self.ThemeSelectionComboItem.setCompleter(completer)
def newSong(self):
log.debug(u'New Song')
@ -614,12 +634,29 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog):
self.saveSong(True):
Receiver.send_message(u'songs_preview')
def clearCaches(self):
"""
Free up autocompletion memory on dialog exit
"""
self.authors = []
self.themes = []
self.books = []
self.topics = []
def closePressed(self):
"""
Exit Dialog and do not save
"""
Receiver.send_message(u'songs_edit_clear')
self.clearCaches()
self.close()
def accept(self):
"""
Exit Dialog and save soong if valid
"""
log.debug(u'accept')
self.clearCaches()
if not self.song:
self.song = Song()
item = int(self.SongbookCombo.currentIndex())
@ -644,7 +681,7 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog):
Get all the data from the widgets on the form, and then save it to the
database.
``preview``
``preview``
Should be ``True`` if the song is also previewed (boolean).
"""
self.song.title = unicode(self.TitleEditItem.text())

View File

@ -118,9 +118,6 @@ class SongImportForm(QtGui.QWizard, Ui_SongImportWizard):
QtCore.QObject.connect(self.songBeamerRemoveButton,
QtCore.SIGNAL(u'clicked()'),
self.onSongBeamerRemoveButtonClicked)
QtCore.QObject.connect(self.cancelButton,
QtCore.SIGNAL(u'clicked(bool)'),
self.onCancelButtonClicked)
QtCore.QObject.connect(self,
QtCore.SIGNAL(u'currentIdChanged(int)'),
self.onCurrentIdChanged)
@ -132,6 +129,15 @@ class SongImportForm(QtGui.QWizard, Ui_SongImportWizard):
self.setDefaults()
return QtGui.QWizard.exec_(self)
def reject(self):
"""
Stop the import on cancel button, close button or ESC key.
"""
log.debug('Import canceled by user.')
if self.currentId() == 2:
Receiver.send_message(u'songs_stop_import')
self.done(QtGui.QDialog.Rejected)
def validateCurrentPage(self):
"""
Validate the current page before moving on to the next page.
@ -394,14 +400,6 @@ class SongImportForm(QtGui.QWizard, Ui_SongImportWizard):
def onSongBeamerRemoveButtonClicked(self):
self.removeSelectedItems(self.songBeamerFileListWidget)
def onCancelButtonClicked(self, checked):
"""
Stop the import on pressing the cancel button.
"""
log.debug('Cancel button pressed!')
if self.currentId() == 2:
Receiver.send_message(u'songs_stop_import')
def onCurrentIdChanged(self, id):
if id == 2:
self.preImport()

View File

@ -350,7 +350,7 @@ class Ui_SongImportWizard(object):
else:
setattr(self, prefix + u'Layout', importLayout)
self.formatComboBox.addItem(u'')
def disablableWidget(self, page, prefix, obj_prefix):
layout = QtGui.QVBoxLayout(page)
layout.setMargin(0)

View File

@ -411,7 +411,7 @@ class SongMaintenanceForm(QtGui.QDialog, Ui_SongMaintenanceDialog):
"""
existing_author = self.manager.get_object_filtered(Author,
and_(Author.first_name == old_author.first_name,
Author.last_name == old_author.last_name,
Author.last_name == old_author.last_name,
Author.display_name == old_author.display_name))
songs = self.manager.get_all_objects(Song,
Song.authors.contains(old_author))

View File

@ -41,7 +41,7 @@ def strip_rtf(blob, encoding):
control_word = []
for c in blob:
if control:
# for delimiters, set control to False
# for delimiters, set control to False
if c == '{':
if len(control_word) > 0:
depth += 1

View File

@ -46,7 +46,7 @@ else:
class OooImport(SongImport):
"""
Import songs from Impress/Powerpoint docs using Impress
Import songs from Impress/Powerpoint docs using Impress
"""
def __init__(self, master_manager, **kwargs):
"""
@ -122,7 +122,7 @@ class OooImport(SongImport):
manager = ctx.ServiceManager
self.desktop = manager.createInstanceWithContext(
"com.sun.star.frame.Desktop", ctx)
def start_ooo_process(self):
try:
if os.name == u'nt':
@ -168,11 +168,11 @@ class OooImport(SongImport):
u'Processing file ' + filepath, 0)
except:
pass
return
return
def close_ooo_file(self):
"""
Close file.
Close file.
"""
self.document.close(True)
self.document = None
@ -187,7 +187,7 @@ class OooImport(SongImport):
def process_pres(self):
"""
Process the file
"""
"""
doc = self.document
slides = doc.getDrawPages()
text = u''
@ -195,7 +195,7 @@ class OooImport(SongImport):
if self.abort:
self.import_wizard.incrementProgressBar(u'Import cancelled', 0)
return
slide = slides.getByIndex(slide_no)
slide = slides.getByIndex(slide_no)
slidetext = u''
for idx in range(slide.getCount()):
shape = slide.getByIndex(idx)
@ -209,12 +209,12 @@ class OooImport(SongImport):
songs = SongImport.process_songs_text(self.manager, text)
for song in songs:
song.finish()
return
return
def process_doc(self):
"""
Process the doc file, a paragraph at a time
"""
"""
text = u''
paragraphs = self.document.getText().createEnumeration()
while paragraphs.hasMoreElements():

View File

@ -249,7 +249,7 @@ class OpenSongImport(SongImport):
words = thisline[1:].strip()
if words is None:
words = thisline
if not versenum:
if not versenum:
versenum = u'1'
if versenum is not None:
versetag = u'%s%s' % (versetype, versenum)
@ -298,7 +298,7 @@ class OpenSongImport(SongImport):
for tag in order:
if tag[0].isdigit():
# Assume it's a verse if it has no prefix
tag = u'V' + tag
tag = u'V' + tag
elif not re.search('\d+', tag):
# Assume it's no.1 if there's no digits
tag = tag + u'1'

View File

@ -56,13 +56,13 @@ class SofImport(OooImport):
"""
Import songs provided on disks with the Songs of Fellowship music books
VOLS1_2.RTF, sof3words.rtf and sof4words.rtf
Use OpenOffice.org Writer for processing the rtf file
The three books are not only inconsistant with each other, they are
The three books are not only inconsistant with each other, they are
inconsistant in themselves too with their formatting. Not only this, but
the 1+2 book does not space out verses correctly. This script attempts
to sort it out, but doesn't get it 100% right. But better than having to
to sort it out, but doesn't get it 100% right. But better than having to
type them all out!
It attempts to detect italiced verses, and treats these as choruses in
@ -96,7 +96,7 @@ class SofImport(OooImport):
def process_sof_file(self):
"""
Process the RTF file, a paragraph at a time
"""
"""
self.blanklines = 0
self.new_song()
paragraphs = self.document.getText().createEnumeration()
@ -113,11 +113,11 @@ class SofImport(OooImport):
def process_paragraph(self, paragraph):
"""
Process a paragraph.
Process a paragraph.
In the first book, a paragraph is a single line. In the latter ones
they may contain multiple lines.
Each paragraph contains textportions. Each textportion has it's own
styling, e.g. italics, bold etc.
styling, e.g. italics, bold etc.
Also check for page breaks, which indicates a new song in books 1+2.
In later books, there may not be line breaks, so check for 3 or more
newlines
@ -136,7 +136,7 @@ class SofImport(OooImport):
self.new_song()
text = u''
self.process_paragraph_text(text)
def process_paragraph_text(self, text):
"""
Split the paragraph text into multiple lines and process
@ -147,12 +147,12 @@ class SofImport(OooImport):
self.new_song()
def process_paragraph_line(self, text):
"""
"""
Process a single line. Throw away that text which isn't relevant, i.e.
stuff that appears at the end of the song.
Anything that is OK, append to the current verse
"""
text = text.strip()
text = text.strip()
if text == u'':
self.blanklines += 1
if self.blanklines > 1:
@ -164,7 +164,7 @@ class SofImport(OooImport):
if self.skip_to_close_bracket:
if text.endswith(u')'):
self.skip_to_close_bracket = False
return
return
if text.startswith(u'CCL Licence'):
self.italics = False
return
@ -264,7 +264,7 @@ class SofImport(OooImport):
"""
Add the author. OpenLP stores them individually so split by 'and', '&'
and comma.
However need to check for "Mr and Mrs Smith" and turn it to
However need to check for "Mr and Mrs Smith" and turn it to
"Mr Smith" and "Mrs Smith".
"""
text = text.replace(u' and ', u' & ')
@ -276,7 +276,7 @@ class SofImport(OooImport):
we're beyond the second line of first verse, then this indicates
a change of verse. Italics are a chorus
"""
if self.italics != self.is_chorus and ((len(self.song.verses) > 0) or
if self.italics != self.is_chorus and ((len(self.song.verses) > 0) or
(self.currentverse.count(u'\n') > 1)):
self.finish_verse()
if self.italics:
@ -307,7 +307,7 @@ class SofImport(OooImport):
ln = 0
if line:
verse = line + u'\n'
else:
else:
verse = u''
else:
verse += line + u'\n'
@ -320,34 +320,34 @@ class SofImport(OooImport):
def uncap_text(self, text):
"""
"""
Words in the title are in all capitals, so we lowercase them.
However some of these words, e.g. referring to God need a leading
However some of these words, e.g. referring to God need a leading
capital letter.
There is a complicated word "One", which is sometimes lower and
There is a complicated word "One", which is sometimes lower and
sometimes upper depending on context. Never mind, keep it lower.
"""
textarr = re.split(u'(\W+)', text)
textarr[0] = textarr[0].capitalize()
for i in range(1, len(textarr)):
# Do not translate these. Fixed strings in SOF song file
if textarr[i] in (u'JESUS', u'CHRIST', u'KING', u'ALMIGHTY',
u'REDEEMER', u'SHEPHERD', u'SON', u'GOD', u'LORD', u'FATHER',
u'HOLY', u'SPIRIT', u'LAMB', u'YOU', u'YOUR', u'I', u'I\'VE',
u'I\'M', u'I\'LL', u'SAVIOUR', u'O', u'YOU\'RE', u'HE', u'HIS',
u'HIM', u'ZION', u'EMMANUEL', u'MAJESTY', u'JESUS\'', u'JIREH',
u'JUDAH', u'LION', u'LORD\'S', u'ABRAHAM', u'GOD\'S',
if textarr[i] in (u'JESUS', u'CHRIST', u'KING', u'ALMIGHTY',
u'REDEEMER', u'SHEPHERD', u'SON', u'GOD', u'LORD', u'FATHER',
u'HOLY', u'SPIRIT', u'LAMB', u'YOU', u'YOUR', u'I', u'I\'VE',
u'I\'M', u'I\'LL', u'SAVIOUR', u'O', u'YOU\'RE', u'HE', u'HIS',
u'HIM', u'ZION', u'EMMANUEL', u'MAJESTY', u'JESUS\'', u'JIREH',
u'JUDAH', u'LION', u'LORD\'S', u'ABRAHAM', u'GOD\'S',
u'FATHER\'S', u'ELIJAH'):
textarr[i] = textarr[i].capitalize()
else:
textarr[i] = textarr[i].lower()
text = u''.join(textarr)
return text
def verse_splits(self, song_number):
"""
Because someone at Kingsway forgot to check the 1+2 RTF file,
Because someone at Kingsway forgot to check the 1+2 RTF file,
some verses were not formatted correctly.
"""
if song_number == 11:

View File

@ -24,7 +24,7 @@
# Temple Place, Suite 330, Boston, MA 02111-1307 USA #
###############################################################################
"""
The :mod:`songbeamerimport` module provides the functionality for importing
The :mod:`songbeamerimport` module provides the functionality for importing
SongBeamer songs into the OpenLP database.
"""
import logging
@ -32,6 +32,7 @@ import os
import chardet
import codecs
from openlp.core.lib import translate
from openlp.plugins.songs.lib.songimport import SongImport
log = logging.getLogger(__name__)
@ -42,19 +43,20 @@ class SongBeamerTypes(object):
u'Chorus': u'C',
u'Vers': u'V',
u'Verse': u'V',
u'Strophe': u'V',
u'Strophe': u'V',
u'Intro': u'I',
u'Coda': u'E',
u'Ending': u'E',
u'Bridge': u'B',
u'Interlude': u'B',
u'Interlude': u'B',
u'Zwischenspiel': u'B',
u'Pre-Chorus': u'P',
u'Pre-Refrain': u'P',
u'Pre-Refrain': u'P',
u'Pre-Bridge': u'O',
u'Pre-Coda': u'O',
u'Unbekannt': u'O',
u'Unknown': u'O'
u'Unbekannt': u'O',
u'Unknown': u'O',
u'Unbenannt': u'O'
}
@ -88,7 +90,7 @@ class SongBeamerImport(SongImport):
len(self.import_source))
for file in self.import_source:
# TODO: check that it is a valid SongBeamer file
self.current_verse = u''
self.current_verse = u''
self.current_verse_type = u'V'
read_verses = False
self.file_name = os.path.split(file)[1]
@ -100,6 +102,7 @@ class SongBeamerImport(SongImport):
detect_file.close()
infile = codecs.open(file, u'r', details['encoding'])
self.songData = infile.readlines()
infile.close()
else:
return False
for line in self.songData:
@ -112,7 +115,7 @@ class SongBeamerImport(SongImport):
self.replace_html_tags()
self.add_verse(self.current_verse,
self.current_verse_type)
self.current_verse = u''
self.current_verse = u''
self.current_verse_type = u'V'
read_verses = True
verse_start = True
@ -127,8 +130,9 @@ class SongBeamerImport(SongImport):
self.replace_html_tags()
self.add_verse(self.current_verse, self.current_verse_type)
self.finish()
self.import_wizard.incrementProgressBar(
"Importing %s" % (self.file_name))
self.import_wizard.incrementProgressBar(u'%s %s...' %
(translate('SongsPlugin.SongBeamerImport', 'Importing'),
self.file_name))
return True
def replace_html_tags(self):
@ -263,6 +267,9 @@ class SongBeamerImport(SongImport):
pass
elif tag_val[0] == u'#Version':
pass
elif tag_val[0] == u'#VerseOrder':
# TODO: add the verse order.
pass
def check_verse_marks(self, line):
"""

View File

@ -346,8 +346,12 @@ class OpenLyricsParser(object):
song.comments = u''
song.song_number = u''
# Process Authors
for author in properties.authors.author:
self._process_author(author.text, song)
try:
for author in properties.authors.author:
self._process_author(author.text, song)
except:
# No Author in XML so ignore
pass
self.manager.save_object(song)
return song.id

View File

@ -57,7 +57,7 @@
<item row="1" column="0">
<widget class="QLabel" name="AlertParameter">
<property name="text">
<string>&amp;Parameter(s):</string>
<string>&amp;Parameter:</string>
</property>
<property name="buddy">
<cstring>ParameterEdit</cstring>

Binary file not shown.

After

Width:  |  Height:  |  Size: 833 B

View File

@ -39,6 +39,7 @@
<file>general_new.png</file>
<file>general_open.png</file>
<file>general_save.png</file>
<file>general_email.png</file>
</qresource>
<qresource prefix="slides">
<file>slide_close.png</file>

2
scripts/openlp-remoteclient.py Executable file → Normal file
View File

@ -47,7 +47,7 @@ def main():
help="Recipient address ",
default="localhost")
parser.add_option("-e", "--event",
help="Action to be performed",
help="Action to be performed",
default="alerts_text")
parser.add_option("-m", "--message",
help="Message to be passed for the action",