forked from openlp/openlp
r1222
This commit is contained in:
commit
166867544e
@ -1,17 +0,0 @@
|
||||
<?xml version="1.0" encoding="iso-8859-1"?>
|
||||
<Theme>
|
||||
<Name>openlp.org 2.0 Demo Theme</Name>
|
||||
<BackgroundType>2</BackgroundType>
|
||||
<BackgroundParameter1>./openlp/core/test/data_for_tests/treesbig.jpg</BackgroundParameter1>
|
||||
<BackgroundParameter2>clBlack</BackgroundParameter2>
|
||||
<BackgroundParameter3/>
|
||||
<FontName>Tahoma</FontName>
|
||||
<FontColor>clWhite</FontColor>
|
||||
<FontProportion>16</FontProportion>
|
||||
<Shadow>-1</Shadow>
|
||||
<ShadowColor>$00000001</ShadowColor>
|
||||
<Outline>-1</Outline>
|
||||
<OutlineColor>clRed</OutlineColor>
|
||||
<HorizontalAlign>2</HorizontalAlign>
|
||||
<VerticalAlign>2</VerticalAlign>
|
||||
</Theme>
|
@ -72,9 +72,6 @@ Song Importers
|
||||
.. automodule:: openlp.plugins.songs.lib.cclifileimport
|
||||
:members:
|
||||
|
||||
.. autoclass:: openlp.plugins.songs.lib.cclifileimport.CCLIFileImportError
|
||||
:members:
|
||||
|
||||
.. automodule:: openlp.plugins.songs.lib.ewimport
|
||||
:members:
|
||||
|
||||
|
19
openlp.pyw
19
openlp.pyw
@ -34,7 +34,7 @@ from subprocess import Popen, PIPE
|
||||
|
||||
from PyQt4 import QtCore, QtGui
|
||||
|
||||
from openlp.core.lib import Receiver
|
||||
from openlp.core.lib import Receiver, check_directory_exists
|
||||
from openlp.core.resources import qInitResources
|
||||
from openlp.core.ui.mainwindow import MainWindow
|
||||
from openlp.core.ui.exceptionform import ExceptionForm
|
||||
@ -150,16 +150,16 @@ class OpenLP(QtGui.QApplication):
|
||||
log.info(u'Openlp version %s' % app_version[u'version'])
|
||||
return app_version
|
||||
|
||||
def notify(self, obj, evt):
|
||||
#TODO needed for presentation exceptions
|
||||
return QtGui.QApplication.notify(self, obj, evt)
|
||||
# def notify(self, obj, evt):
|
||||
# #TODO needed for presentation exceptions
|
||||
# return QtGui.QApplication.notify(self, obj, evt)
|
||||
|
||||
def run(self):
|
||||
"""
|
||||
Run the OpenLP application.
|
||||
"""
|
||||
app_version = self._get_version()
|
||||
#provide a listener for widgets to reqest a screen update.
|
||||
# provide a listener for widgets to reqest a screen update.
|
||||
QtCore.QObject.connect(Receiver.get_receiver(),
|
||||
QtCore.SIGNAL(u'openlp_process_events'), self.processEvents)
|
||||
QtCore.QObject.connect(Receiver.get_receiver(),
|
||||
@ -182,7 +182,7 @@ class OpenLP(QtGui.QApplication):
|
||||
screens = ScreenList()
|
||||
# Decide how many screens we have and their size
|
||||
for screen in xrange(0, self.desktop().numScreens()):
|
||||
size = self.desktop().screenGeometry(screen);
|
||||
size = self.desktop().screenGeometry(screen)
|
||||
screens.add_screen({u'number': screen,
|
||||
u'size': size,
|
||||
u'primary': (self.desktop().primaryScreen() == screen)})
|
||||
@ -216,7 +216,7 @@ class OpenLP(QtGui.QApplication):
|
||||
|
||||
def setNormalCursor(self):
|
||||
"""
|
||||
Sets the Normal Cursor forthe Application
|
||||
Sets the Normal Cursor for the Application
|
||||
"""
|
||||
self.restoreOverrideCursor()
|
||||
|
||||
@ -243,8 +243,7 @@ def main():
|
||||
help='Set the Qt4 style (passed directly to Qt4).')
|
||||
# Set up logging
|
||||
log_path = AppLocation.get_directory(AppLocation.CacheDir)
|
||||
if not os.path.exists(log_path):
|
||||
os.makedirs(log_path)
|
||||
check_directory_exists(log_path)
|
||||
filename = os.path.join(log_path, u'openlp.log')
|
||||
logfile = logging.FileHandler(filename, u'w')
|
||||
logfile.setFormatter(logging.Formatter(
|
||||
@ -281,4 +280,4 @@ if __name__ == u'__main__':
|
||||
"""
|
||||
Instantiate and run the application.
|
||||
"""
|
||||
main()
|
||||
main()
|
@ -35,52 +35,51 @@ from PyQt4 import QtCore, QtGui
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
# TODO make external and configurable in alpha 4 via a settings dialog
|
||||
html_expands = []
|
||||
base_html_expands = []
|
||||
|
||||
html_expands.append({u'desc': u'Red', u'start tag': u'{r}',
|
||||
base_html_expands.append({u'desc': u'Red', u'start tag': u'{r}',
|
||||
u'start html': u'<span style="-webkit-text-fill-color:red">',
|
||||
u'end tag': u'{/r}', u'end html': u'</span>', u'protected': False})
|
||||
html_expands.append({u'desc': u'Black', u'start tag': u'{b}',
|
||||
u'end tag': u'{/r}', u'end html': u'</span>', u'protected': True})
|
||||
base_html_expands.append({u'desc': u'Black', u'start tag': u'{b}',
|
||||
u'start html': u'<span style="-webkit-text-fill-color:black">',
|
||||
u'end tag': u'{/b}', u'end html': u'</span>', u'protected': False})
|
||||
html_expands.append({u'desc': u'Blue', u'start tag': u'{bl}',
|
||||
u'end tag': u'{/b}', u'end html': u'</span>', u'protected': True})
|
||||
base_html_expands.append({u'desc': u'Blue', u'start tag': u'{bl}',
|
||||
u'start html': u'<span style="-webkit-text-fill-color:blue">',
|
||||
u'end tag': u'{/bl}', u'end html': u'</span>', u'protected': False})
|
||||
html_expands.append({u'desc': u'Yellow', u'start tag': u'{y}',
|
||||
u'end tag': u'{/bl}', u'end html': u'</span>', u'protected': True})
|
||||
base_html_expands.append({u'desc': u'Yellow', u'start tag': u'{y}',
|
||||
u'start html': u'<span style="-webkit-text-fill-color:yellow">',
|
||||
u'end tag': u'{/y}', u'end html': u'</span>', u'protected': False})
|
||||
html_expands.append({u'desc': u'Green', u'start tag': u'{g}',
|
||||
u'end tag': u'{/y}', u'end html': u'</span>', u'protected': True})
|
||||
base_html_expands.append({u'desc': u'Green', u'start tag': u'{g}',
|
||||
u'start html': u'<span style="-webkit-text-fill-color:green">',
|
||||
u'end tag': u'{/g}', u'end html': u'</span>', u'protected': False})
|
||||
html_expands.append({u'desc': u'Pink', u'start tag': u'{pk}',
|
||||
u'end tag': u'{/g}', u'end html': u'</span>', u'protected': True})
|
||||
base_html_expands.append({u'desc': u'Pink', u'start tag': u'{pk}',
|
||||
u'start html': u'<span style="-webkit-text-fill-color:#CC33CC">',
|
||||
u'end tag': u'{/pk}', u'end html': u'</span>', u'protected': False})
|
||||
html_expands.append({u'desc': u'Orange', u'start tag': u'{o}',
|
||||
u'end tag': u'{/pk}', u'end html': u'</span>', u'protected': True})
|
||||
base_html_expands.append({u'desc': u'Orange', u'start tag': u'{o}',
|
||||
u'start html': u'<span style="-webkit-text-fill-color:#CC0033">',
|
||||
u'end tag': u'{/o}', u'end html': u'</span>', u'protected': False})
|
||||
html_expands.append({u'desc': u'Purple', u'start tag': u'{pp}',
|
||||
u'end tag': u'{/o}', u'end html': u'</span>', u'protected': True})
|
||||
base_html_expands.append({u'desc': u'Purple', u'start tag': u'{pp}',
|
||||
u'start html': u'<span style="-webkit-text-fill-color:#9900FF">',
|
||||
u'end tag': u'{/pp}', u'end html': u'</span>', u'protected': False})
|
||||
html_expands.append({u'desc': u'White', u'start tag': u'{w}',
|
||||
u'end tag': u'{/pp}', u'end html': u'</span>', u'protected': True})
|
||||
base_html_expands.append({u'desc': u'White', u'start tag': u'{w}',
|
||||
u'start html': u'<span style="-webkit-text-fill-color:white">',
|
||||
u'end tag': u'{/w}', u'end html': u'</span>', u'protected': False})
|
||||
html_expands.append({u'desc': u'Superscript', u'start tag': u'{su}',
|
||||
u'end tag': u'{/w}', u'end html': u'</span>', u'protected': True})
|
||||
base_html_expands.append({u'desc': u'Superscript', u'start tag': u'{su}',
|
||||
u'start html': u'<sup>', u'end tag': u'{/su}', u'end html': u'</sup>',
|
||||
u'protected': True})
|
||||
html_expands.append({u'desc': u'Subscript', u'start tag': u'{sb}',
|
||||
base_html_expands.append({u'desc': u'Subscript', u'start tag': u'{sb}',
|
||||
u'start html': u'<sub>', u'end tag': u'{/sb}', u'end html': u'</sub>',
|
||||
u'protected': True})
|
||||
html_expands.append({u'desc': u'Paragraph', u'start tag': u'{p}',
|
||||
base_html_expands.append({u'desc': u'Paragraph', u'start tag': u'{p}',
|
||||
u'start html': u'<p>', u'end tag': u'{/p}', u'end html': u'</p>',
|
||||
u'protected': True})
|
||||
html_expands.append({u'desc': u'Bold', u'start tag': u'{st}',
|
||||
base_html_expands.append({u'desc': u'Bold', u'start tag': u'{st}',
|
||||
u'start html': u'<strong>', u'end tag': u'{/st}', u'end html': u'</strong>',
|
||||
u'protected': True})
|
||||
html_expands.append({u'desc': u'Italics', u'start tag': u'{it}',
|
||||
base_html_expands.append({u'desc': u'Italics', u'start tag': u'{it}',
|
||||
u'start html': u'<em>', u'end tag': u'{/it}', u'end html': u'</em>',
|
||||
u'protected': True})
|
||||
html_expands.append({u'desc': u'Underline', u'start tag': u'{u}',
|
||||
base_html_expands.append({u'desc': u'Underline', u'start tag': u'{u}',
|
||||
u'start html': u'<span style="text-decoration: underline;">',
|
||||
u'end tag': u'{/u}', u'end html': u'</span>', u'protected': True})
|
||||
|
||||
@ -102,7 +101,8 @@ def translate(context, text, comment=None,
|
||||
An identifying string for when the same text is used in different roles
|
||||
within the same context.
|
||||
"""
|
||||
return QtCore.QCoreApplication.translate(context, text, comment, encoding, n)
|
||||
return QtCore.QCoreApplication.translate(
|
||||
context, text, comment, encoding, n)
|
||||
|
||||
def get_text_file_string(text_file):
|
||||
"""
|
||||
@ -293,7 +293,8 @@ def clean_tags(text):
|
||||
Remove Tags from text for display
|
||||
"""
|
||||
text = text.replace(u'<br>', u'\n')
|
||||
for tag in html_expands:
|
||||
text = text.replace(u' ', u' ')
|
||||
for tag in DisplayTags.get_html_tags():
|
||||
text = text.replace(tag[u'start tag'], u'')
|
||||
text = text.replace(tag[u'end tag'], u'')
|
||||
return text
|
||||
@ -302,13 +303,25 @@ def expand_tags(text):
|
||||
"""
|
||||
Expand tags HTML for display
|
||||
"""
|
||||
for tag in html_expands:
|
||||
for tag in DisplayTags.get_html_tags():
|
||||
text = text.replace(tag[u'start tag'], tag[u'start html'])
|
||||
text = text.replace(tag[u'end tag'], tag[u'end html'])
|
||||
return text
|
||||
|
||||
def check_directory_exists(dir):
|
||||
"""
|
||||
Check a theme directory exists and if not create it
|
||||
|
||||
``dir``
|
||||
Theme directory to make sure exists
|
||||
"""
|
||||
log.debug(u'check_directory_exists')
|
||||
if not os.path.exists(dir):
|
||||
os.makedirs(dir)
|
||||
|
||||
from theme import ThemeLevel, ThemeXML, BackgroundGradientType, \
|
||||
BackgroundType, HorizontalType, VerticalType
|
||||
from displaytags import DisplayTags
|
||||
from spelltextedit import SpellTextEdit
|
||||
from eventreceiver import Receiver
|
||||
from imagemanager import ImageManager
|
||||
|
@ -34,7 +34,7 @@ from sqlalchemy import create_engine, MetaData
|
||||
from sqlalchemy.exceptions import InvalidRequestError
|
||||
from sqlalchemy.orm import scoped_session, sessionmaker
|
||||
|
||||
from openlp.core.utils import AppLocation
|
||||
from openlp.core.utils import AppLocation, delete_file
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
@ -75,11 +75,7 @@ def delete_database(plugin_name, db_file_name=None):
|
||||
else:
|
||||
db_file_path = os.path.join(
|
||||
AppLocation.get_section_data_path(plugin_name), plugin_name)
|
||||
try:
|
||||
os.remove(db_file_path)
|
||||
return True
|
||||
except OSError:
|
||||
return False
|
||||
return delete_file(db_file_path)
|
||||
|
||||
class BaseModel(object):
|
||||
"""
|
||||
@ -295,4 +291,4 @@ class Manager(object):
|
||||
if self.is_dirty:
|
||||
engine = create_engine(self.db_url)
|
||||
if self.db_url.startswith(u'sqlite'):
|
||||
engine.execute("vacuum")
|
||||
engine.execute("vacuum")
|
||||
|
67
openlp/core/lib/displaytags.py
Normal file
67
openlp/core/lib/displaytags.py
Normal file
@ -0,0 +1,67 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4
|
||||
|
||||
###############################################################################
|
||||
# OpenLP - Open Source Lyrics Projection #
|
||||
# --------------------------------------------------------------------------- #
|
||||
# Copyright (c) 2008-2011 Raoul Snyman #
|
||||
# Portions copyright (c) 2008-2011 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 #
|
||||
###############################################################################
|
||||
"""
|
||||
Provide Html Tag management and Display Tag access class
|
||||
"""
|
||||
|
||||
from openlp.core.lib import base_html_expands
|
||||
|
||||
class DisplayTags(object):
|
||||
"""
|
||||
Static Class to HTML Tags to be access around the code the list is managed
|
||||
by the Options Tab.
|
||||
"""
|
||||
html_expands = []
|
||||
|
||||
@staticmethod
|
||||
def get_html_tags():
|
||||
"""
|
||||
Provide access to the html_expands list.
|
||||
"""
|
||||
return DisplayTags.html_expands
|
||||
|
||||
@staticmethod
|
||||
def reset_html_tags():
|
||||
"""
|
||||
Resets the html_expands list.
|
||||
"""
|
||||
DisplayTags.html_expands = []
|
||||
for html in base_html_expands:
|
||||
DisplayTags.html_expands.append(html)
|
||||
|
||||
@staticmethod
|
||||
def add_html_tag(tag):
|
||||
"""
|
||||
Add a new tag to the list
|
||||
"""
|
||||
DisplayTags.html_expands.append(tag)
|
||||
|
||||
@staticmethod
|
||||
def remove_html_tag(id):
|
||||
"""
|
||||
Removes amd individual html_expands list.
|
||||
"""
|
||||
DisplayTags.html_expands.pop(id)
|
@ -207,14 +207,8 @@ class EventReceiver(QtCore.QObject):
|
||||
``bibles_nobook``
|
||||
Attempt to find book resulted in no match
|
||||
|
||||
``bibles_showprogress``
|
||||
Show progress of bible verse import
|
||||
|
||||
``bibles_hideprogress``
|
||||
Hide progress of bible verse import
|
||||
|
||||
``bibles_stop_import``
|
||||
Stops the Bible Import
|
||||
``openlp_stop_wizard``
|
||||
Stops a wizard before completion
|
||||
|
||||
``remotes_poll_request``
|
||||
Waits for openlp to do something "interesting" and sends a
|
||||
|
@ -641,4 +641,4 @@ def build_alert_css(alertTab, width):
|
||||
align = u'top'
|
||||
alert = style % (width, align, alertTab.font_face, alertTab.font_size,
|
||||
alertTab.font_color, alertTab.bg_color)
|
||||
return alert
|
||||
return alert
|
||||
|
@ -30,7 +30,6 @@ A Thread is used to convert the image to a byte array so the user does not need
|
||||
to wait for the conversion to happen.
|
||||
"""
|
||||
import logging
|
||||
import os
|
||||
import time
|
||||
|
||||
from PyQt4 import QtCore
|
||||
@ -86,8 +85,7 @@ class ImageManager(QtCore.QObject):
|
||||
for key in self._cache.keys():
|
||||
image = self._cache[key]
|
||||
image.dirty = True
|
||||
fullpath = os.path.join(image.path, image.name)
|
||||
image.image = resize_image(fullpath,
|
||||
image.image = resize_image(image.path,
|
||||
self.width, self.height)
|
||||
self._cache_dirty = True
|
||||
# only one thread please
|
||||
@ -165,4 +163,4 @@ class ImageManager(QtCore.QObject):
|
||||
image = self._cache[key]
|
||||
if image.dirty:
|
||||
image.image_bytes = image_to_byte(image.image)
|
||||
image.dirty = False
|
||||
image.dirty = False
|
||||
|
@ -230,7 +230,7 @@ def open(filename):
|
||||
return _open(filename)
|
||||
|
||||
|
||||
def _fix_addersses(**kwargs):
|
||||
def _fix_addresses(**kwargs):
|
||||
for headername in (u'address', u'to', u'cc', u'bcc'):
|
||||
try:
|
||||
headervalue = kwargs[headername]
|
||||
@ -260,7 +260,7 @@ def mailto_format(**kwargs):
|
||||
"""
|
||||
# @TODO: implement utf8 option
|
||||
|
||||
kwargs = _fix_addersses(**kwargs)
|
||||
kwargs = _fix_addresses(**kwargs)
|
||||
parts = []
|
||||
for headername in (u'to', u'cc', u'bcc', u'subject', u'body', u'attach'):
|
||||
if kwargs.has_key(headername):
|
||||
|
@ -176,7 +176,8 @@ class MediaManagerItem(QtGui.QWidget):
|
||||
# break compatability), but it makes sense for the icon to
|
||||
# come before the tooltip (as you have to have an icon, but
|
||||
# not neccesarily a tooltip)
|
||||
return self.toolbar.addToolbarButton(title, icon, tooltip, slot, checkable)
|
||||
return self.toolbar.addToolbarButton(title, icon, tooltip, slot,
|
||||
checkable)
|
||||
|
||||
def addToolbarSeparator(self):
|
||||
"""
|
||||
@ -265,7 +266,7 @@ class MediaManagerItem(QtGui.QWidget):
|
||||
"""
|
||||
Creates the main widget for listing items the media item is tracking
|
||||
"""
|
||||
#Add the List widget
|
||||
# Add the List widget
|
||||
self.listView = self.ListViewWithDnD_class(self)
|
||||
self.listView.uniformItemSizes = True
|
||||
self.listView.setSpacing(1)
|
||||
@ -274,9 +275,9 @@ class MediaManagerItem(QtGui.QWidget):
|
||||
self.listView.setAlternatingRowColors(True)
|
||||
self.listView.setDragEnabled(True)
|
||||
self.listView.setObjectName(u'%sListView' % self.plugin.name)
|
||||
#Add to pageLayout
|
||||
# Add to pageLayout
|
||||
self.pageLayout.addWidget(self.listView)
|
||||
#define and add the context menu
|
||||
# define and add the context menu
|
||||
self.listView.setContextMenuPolicy(QtCore.Qt.ActionsContextMenu)
|
||||
name_string = self.plugin.getString(StringContent.Name)
|
||||
if self.hasEditIcon:
|
||||
@ -313,7 +314,7 @@ class MediaManagerItem(QtGui.QWidget):
|
||||
context_menu_action(
|
||||
self.listView, u':/general/general_add.png',
|
||||
translate('OpenLP.MediaManagerItem',
|
||||
'&Add to selected Service Item'),
|
||||
'&Add to selected Service Item'),
|
||||
self.onAddEditClick))
|
||||
QtCore.QObject.connect(self.listView,
|
||||
QtCore.SIGNAL(u'doubleClicked(QModelIndex)'),
|
||||
@ -440,7 +441,7 @@ class MediaManagerItem(QtGui.QWidget):
|
||||
QtGui.QMessageBox.information(self,
|
||||
translate('OpenLP.MediaManagerItem', 'No Items Selected'),
|
||||
translate('OpenLP.MediaManagerItem',
|
||||
'You must select one or more items to preview.'))
|
||||
'You must select one or more items to preview.'))
|
||||
else:
|
||||
log.debug(u'%s Preview requested', self.plugin.name)
|
||||
serviceItem = self.buildServiceItem()
|
||||
|
@ -175,6 +175,10 @@ class Plugin(QtCore.QObject):
|
||||
self.status = new_status
|
||||
QtCore.QSettings().setValue(
|
||||
self.settingsSection + u'/status', QtCore.QVariant(self.status))
|
||||
if new_status == PluginStatus.Active:
|
||||
self.initialise()
|
||||
elif new_status == PluginStatus.Inactive:
|
||||
self.finalise()
|
||||
|
||||
def isActive(self):
|
||||
"""
|
||||
@ -314,4 +318,4 @@ class Plugin(QtCore.QObject):
|
||||
"""
|
||||
Called to define all translatable texts of the plugin
|
||||
"""
|
||||
pass
|
||||
pass
|
||||
|
@ -78,7 +78,7 @@ class SearchEdit(QtGui.QLineEdit):
|
||||
else:
|
||||
self.setStyleSheet(u'QLineEdit { padding-right: %spx; } ' % \
|
||||
rightPadding)
|
||||
msz = self.minimumSizeHint();
|
||||
msz = self.minimumSizeHint()
|
||||
self.setMinimumSize(
|
||||
max(msz.width(),
|
||||
self.clearButton.width() + (frameWidth * 2) + 2),
|
||||
|
@ -60,6 +60,7 @@ class ItemCapabilities(object):
|
||||
AddIfNewItem = 9
|
||||
ProvidesOwnDisplay = 10
|
||||
|
||||
|
||||
class ServiceItem(object):
|
||||
"""
|
||||
The service item is a base class for the plugins to use to interact with
|
||||
|
@ -114,6 +114,12 @@ class SettingsTab(QtGui.QWidget):
|
||||
"""
|
||||
pass
|
||||
|
||||
def cancel(self):
|
||||
"""
|
||||
Reset any settings
|
||||
"""
|
||||
pass
|
||||
|
||||
def postSetUp(self, postUpdate=False):
|
||||
"""
|
||||
Changes which need to be made after setup of application
|
||||
|
@ -36,7 +36,7 @@ except ImportError:
|
||||
# http://john.nachtimwald.com/2009/08/22/qplaintextedit-with-in-line-spell-check
|
||||
|
||||
from PyQt4 import QtCore, QtGui
|
||||
from openlp.core.lib import html_expands, translate
|
||||
from openlp.core.lib import translate, DisplayTags
|
||||
|
||||
class SpellTextEdit(QtGui.QPlainTextEdit):
|
||||
"""
|
||||
@ -88,7 +88,7 @@ class SpellTextEdit(QtGui.QPlainTextEdit):
|
||||
popupMenu.insertMenu(popupMenu.actions()[0], spell_menu)
|
||||
tagMenu = QtGui.QMenu(translate('OpenLP.SpellTextEdit',
|
||||
'Formatting Tags'))
|
||||
for html in html_expands:
|
||||
for html in DisplayTags.get_html_tags():
|
||||
action = SpellAction( html[u'desc'], tagMenu)
|
||||
action.correct.connect(self.htmlTag)
|
||||
tagMenu.addAction(action)
|
||||
@ -110,7 +110,7 @@ class SpellTextEdit(QtGui.QPlainTextEdit):
|
||||
"""
|
||||
Replaces the selected text with word.
|
||||
"""
|
||||
for html in html_expands:
|
||||
for html in DisplayTags.get_html_tags():
|
||||
if tag == html[u'desc']:
|
||||
cursor = self.textCursor()
|
||||
if self.textCursor().hasSelection():
|
||||
@ -158,4 +158,4 @@ class SpellAction(QtGui.QAction):
|
||||
def __init__(self, *args):
|
||||
QtGui.QAction.__init__(self, *args)
|
||||
self.triggered.connect(lambda x: self.correct.emit(
|
||||
unicode(self.text())))
|
||||
unicode(self.text())))
|
||||
|
@ -598,4 +598,4 @@ class ThemeXML(object):
|
||||
self.font_footer_shadow_size)
|
||||
self.add_display(self.display_horizontal_align,
|
||||
self.display_vertical_align,
|
||||
self.display_slide_transition)
|
||||
self.display_slide_transition)
|
||||
|
@ -26,6 +26,9 @@
|
||||
"""
|
||||
The :mod:`ui` module provides the core user interface for OpenLP
|
||||
"""
|
||||
from PyQt4 import QtGui
|
||||
|
||||
from openlp.core.lib import translate, Receiver
|
||||
|
||||
class HideMode(object):
|
||||
"""
|
||||
@ -35,11 +38,11 @@ class HideMode(object):
|
||||
``Blank``
|
||||
This mode is used to hide all output, specifically by covering the
|
||||
display with a black screen.
|
||||
|
||||
|
||||
``Theme``
|
||||
This mode is used to hide all output, but covers the display with the
|
||||
current theme background, as opposed to black.
|
||||
|
||||
|
||||
``Desktop``
|
||||
This mode hides all output by minimising the display, leaving the user's
|
||||
desktop showing.
|
||||
@ -48,6 +51,34 @@ class HideMode(object):
|
||||
Theme = 2
|
||||
Screen = 3
|
||||
|
||||
|
||||
def criticalErrorMessageBox(title=None, message=None, parent=None,
|
||||
question=False):
|
||||
"""
|
||||
Provides a standard critical message box for errors that OpenLP displays
|
||||
to users.
|
||||
|
||||
``title``
|
||||
The title for the message box.
|
||||
|
||||
``message``
|
||||
The message to display to the user.
|
||||
|
||||
``parent``
|
||||
The parent UI element to attach the dialog to.
|
||||
|
||||
``question``
|
||||
Should this message box question the user.
|
||||
"""
|
||||
error = translate('OpenLP.Ui', 'Error')
|
||||
if question:
|
||||
return QtGui.QMessageBox.critical(parent, error, message,
|
||||
QtGui.QMessageBox.StandardButtons(
|
||||
QtGui.QMessageBox.Yes | QtGui.QMessageBox.No))
|
||||
data = {u'message': message}
|
||||
data[u'title'] = title if title else error
|
||||
return Receiver.send_message(u'openlp_error_message', data)
|
||||
|
||||
from themeform import ThemeForm
|
||||
from filerenameform import FileRenameForm
|
||||
from maindisplay import MainDisplay
|
||||
@ -59,6 +90,7 @@ from splashscreen import SplashScreen
|
||||
from generaltab import GeneralTab
|
||||
from themestab import ThemesTab
|
||||
from advancedtab import AdvancedTab
|
||||
from displaytagtab import DisplayTagTab
|
||||
from aboutform import AboutForm
|
||||
from pluginform import PluginForm
|
||||
from settingsform import SettingsForm
|
||||
@ -67,6 +99,6 @@ from mediadockmanager import MediaDockManager
|
||||
from servicemanager import ServiceManager
|
||||
from thememanager import ThemeManager
|
||||
|
||||
__all__ = ['SplashScreen', 'AboutForm', 'SettingsForm',
|
||||
'MainDisplay', 'SlideController', 'ServiceManager', 'ThemeManager',
|
||||
'MediaDockManager', 'ServiceItemEditForm']
|
||||
__all__ = ['criticalErrorMessageBox', 'SplashScreen', 'AboutForm',
|
||||
'SettingsForm', 'MainDisplay', 'SlideController', 'ServiceManager',
|
||||
'ThemeManager', 'MediaDockManager', 'ServiceItemEditForm']
|
||||
|
347
openlp/core/ui/displaytagtab.py
Normal file
347
openlp/core/ui/displaytagtab.py
Normal file
@ -0,0 +1,347 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4
|
||||
|
||||
###############################################################################
|
||||
# OpenLP - Open Source Lyrics Projection #
|
||||
# --------------------------------------------------------------------------- #
|
||||
# Copyright (c) 2008-2011 Raoul Snyman #
|
||||
# Portions copyright (c) 2008-2011 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 #
|
||||
###############################################################################
|
||||
'''
|
||||
The :mod:`DisplayTagTab` provides an Tag Edit facility. The Base set are
|
||||
protected and included each time loaded. Custom tags can be defined and saved.
|
||||
The Custom Tag arrays are saved in a pickle so QSettings works on them. Base
|
||||
Tags cannot be changed.
|
||||
|
||||
'''
|
||||
import cPickle
|
||||
from PyQt4 import QtCore, QtGui
|
||||
|
||||
from openlp.core.lib import SettingsTab, translate, DisplayTags
|
||||
from openlp.core.ui import criticalErrorMessageBox
|
||||
|
||||
class DisplayTagTab(SettingsTab):
|
||||
'''
|
||||
The :class:`DisplayTagTab` manages the settings tab .
|
||||
'''
|
||||
def __init__(self):
|
||||
'''
|
||||
Initialise the settings tab
|
||||
'''
|
||||
SettingsTab.__init__(self, u'Display Tags')
|
||||
|
||||
def resizeEvent(self, event=None):
|
||||
pass
|
||||
|
||||
def preLoad(self):
|
||||
"""
|
||||
Initialise values before the Load takes place
|
||||
"""
|
||||
# Create initial copy from master
|
||||
DisplayTags.reset_html_tags()
|
||||
user_expands = QtCore.QSettings().value(u'displayTags/html_tags',
|
||||
QtCore.QVariant(u'')).toString()
|
||||
# cPickle only accepts str not unicode strings
|
||||
user_expands_string = str(unicode(user_expands).encode(u'utf8'))
|
||||
if user_expands_string:
|
||||
user_tags = cPickle.loads(user_expands_string)
|
||||
# If we have some user ones added them as well
|
||||
for t in user_tags:
|
||||
DisplayTags.add_html_tag(t)
|
||||
self.selected = -1
|
||||
|
||||
def setupUi(self):
|
||||
'''
|
||||
Configure the UI elements for the tab.
|
||||
'''
|
||||
self.setObjectName(u'DisplayTagTab')
|
||||
self.tabTitleVisible = \
|
||||
translate(u'OpenLP.DisplayTagTab', 'Display Tags')
|
||||
self.displayTagEdit = QtGui.QWidget(self)
|
||||
self.editGroupBox = QtGui.QGroupBox(self.displayTagEdit)
|
||||
self.editGroupBox.setGeometry(QtCore.QRect(10, 220, 650, 181))
|
||||
self.editGroupBox.setObjectName(u'editGroupBox')
|
||||
self.updatePushButton = QtGui.QPushButton(self.editGroupBox)
|
||||
self.updatePushButton.setGeometry(QtCore.QRect(550, 140, 71, 26))
|
||||
self.updatePushButton.setObjectName(u'updatePushButton')
|
||||
self.layoutWidget = QtGui.QWidget(self.editGroupBox)
|
||||
self.layoutWidget.setGeometry(QtCore.QRect(5, 20, 571, 114))
|
||||
self.layoutWidget.setObjectName(u'layoutWidget')
|
||||
self.formLayout = QtGui.QFormLayout(self.layoutWidget)
|
||||
self.formLayout.setObjectName(u'formLayout')
|
||||
self.descriptionLabel = QtGui.QLabel(self.layoutWidget)
|
||||
self.descriptionLabel.setAlignment(QtCore.Qt.AlignCenter)
|
||||
self.descriptionLabel.setObjectName(u'descriptionLabel')
|
||||
self.formLayout.setWidget(0, QtGui.QFormLayout.LabelRole,
|
||||
self.descriptionLabel)
|
||||
self.descriptionLineEdit = QtGui.QLineEdit(self.layoutWidget)
|
||||
self.descriptionLineEdit.setObjectName(u'descriptionLineEdit')
|
||||
self.formLayout.setWidget(0, QtGui.QFormLayout.FieldRole,
|
||||
self.descriptionLineEdit)
|
||||
self.tagLabel = QtGui.QLabel(self.layoutWidget)
|
||||
self.tagLabel.setAlignment(QtCore.Qt.AlignCenter)
|
||||
self.tagLabel.setObjectName(u'tagLabel')
|
||||
self.formLayout.setWidget(1, QtGui.QFormLayout.LabelRole, self.tagLabel)
|
||||
self.tagLineEdit = QtGui.QLineEdit(self.layoutWidget)
|
||||
self.tagLineEdit.setMaximumSize(QtCore.QSize(50, 16777215))
|
||||
self.tagLineEdit.setMaxLength(5)
|
||||
self.tagLineEdit.setObjectName(u'tagLineEdit')
|
||||
self.formLayout.setWidget(1, QtGui.QFormLayout.FieldRole,
|
||||
self.tagLineEdit)
|
||||
self.startTagLabel = QtGui.QLabel(self.layoutWidget)
|
||||
self.startTagLabel.setAlignment(QtCore.Qt.AlignCenter)
|
||||
self.startTagLabel.setObjectName(u'startTagLabel')
|
||||
self.formLayout.setWidget(2, QtGui.QFormLayout.LabelRole,
|
||||
self.startTagLabel)
|
||||
self.startTagLineEdit = QtGui.QLineEdit(self.layoutWidget)
|
||||
self.startTagLineEdit.setObjectName(u'startTagLineEdit')
|
||||
self.formLayout.setWidget(2, QtGui.QFormLayout.FieldRole,
|
||||
self.startTagLineEdit)
|
||||
self.endTagLabel = QtGui.QLabel(self.layoutWidget)
|
||||
self.endTagLabel.setAlignment(QtCore.Qt.AlignCenter)
|
||||
self.endTagLabel.setObjectName(u'endTagLabel')
|
||||
self.formLayout.setWidget(3, QtGui.QFormLayout.LabelRole,
|
||||
self.endTagLabel)
|
||||
self.endTagLineEdit = QtGui.QLineEdit(self.layoutWidget)
|
||||
self.endTagLineEdit.setObjectName(u'endTagLineEdit')
|
||||
self.formLayout.setWidget(3, QtGui.QFormLayout.FieldRole,
|
||||
self.endTagLineEdit)
|
||||
self.defaultPushButton = QtGui.QPushButton(self.displayTagEdit)
|
||||
self.defaultPushButton.setGeometry(QtCore.QRect(430, 188, 71, 26))
|
||||
self.defaultPushButton.setObjectName(u'updatePushButton')
|
||||
self.deletePushButton = QtGui.QPushButton(self.displayTagEdit)
|
||||
self.deletePushButton.setGeometry(QtCore.QRect(510, 188, 71, 26))
|
||||
self.deletePushButton.setObjectName(u'deletePushButton')
|
||||
self.newPushButton = QtGui.QPushButton(self.displayTagEdit)
|
||||
self.newPushButton.setGeometry(QtCore.QRect(600, 188, 71, 26))
|
||||
self.newPushButton.setObjectName(u'newPushButton')
|
||||
self.tagTableWidget = QtGui.QTableWidget(self.displayTagEdit)
|
||||
self.tagTableWidget.setGeometry(QtCore.QRect(10, 10, 650, 171))
|
||||
self.tagTableWidget.setHorizontalScrollBarPolicy(
|
||||
QtCore.Qt.ScrollBarAlwaysOff)
|
||||
self.tagTableWidget.setEditTriggers(
|
||||
QtGui.QAbstractItemView.NoEditTriggers)
|
||||
self.tagTableWidget.setAlternatingRowColors(True)
|
||||
self.tagTableWidget.setSelectionMode(
|
||||
QtGui.QAbstractItemView.SingleSelection)
|
||||
self.tagTableWidget.setSelectionBehavior(
|
||||
QtGui.QAbstractItemView.SelectRows)
|
||||
self.tagTableWidget.setCornerButtonEnabled(False)
|
||||
self.tagTableWidget.setObjectName(u'tagTableWidget')
|
||||
self.tagTableWidget.setColumnCount(4)
|
||||
self.tagTableWidget.setRowCount(0)
|
||||
item = QtGui.QTableWidgetItem()
|
||||
self.tagTableWidget.setHorizontalHeaderItem(0, item)
|
||||
item = QtGui.QTableWidgetItem()
|
||||
self.tagTableWidget.setHorizontalHeaderItem(1, item)
|
||||
item = QtGui.QTableWidgetItem()
|
||||
self.tagTableWidget.setHorizontalHeaderItem(2, item)
|
||||
item = QtGui.QTableWidgetItem()
|
||||
self.tagTableWidget.setHorizontalHeaderItem(3, item)
|
||||
self.editGroupBox.setTitle(
|
||||
translate('OpenLP.DisplayTagTab', 'Edit Selection'))
|
||||
self.updatePushButton.setText(
|
||||
translate('OpenLP.DisplayTagTab', 'Update'))
|
||||
self.descriptionLabel.setText(
|
||||
translate('OpenLP.DisplayTagTab', 'Description'))
|
||||
self.tagLabel.setText(translate('OpenLP.DisplayTagTab', 'Tag'))
|
||||
self.startTagLabel.setText(
|
||||
translate('OpenLP.DisplayTagTab', 'Start tag'))
|
||||
self.endTagLabel.setText(translate('OpenLP.DisplayTagTab', 'End tag'))
|
||||
self.deletePushButton.setText(
|
||||
translate('OpenLP.DisplayTagTab', 'Delete'))
|
||||
self.defaultPushButton.setText(
|
||||
translate('OpenLP.DisplayTagTab', 'Default'))
|
||||
self.newPushButton.setText(translate('OpenLP.DisplayTagTab', 'New'))
|
||||
self.tagTableWidget.horizontalHeaderItem(0)\
|
||||
.setText(translate('OpenLP.DisplayTagTab', 'Description'))
|
||||
self.tagTableWidget.horizontalHeaderItem(1)\
|
||||
.setText(translate('OpenLP.DisplayTagTab', 'Tag id'))
|
||||
self.tagTableWidget.horizontalHeaderItem(2)\
|
||||
.setText(translate('OpenLP.DisplayTagTab', 'Start Html'))
|
||||
self.tagTableWidget.horizontalHeaderItem(3)\
|
||||
.setText(translate('OpenLP.DisplayTagTab', 'End Html'))
|
||||
QtCore.QMetaObject.connectSlotsByName(self.displayTagEdit)
|
||||
self.tagTableWidget.setColumnWidth(0, 120)
|
||||
self.tagTableWidget.setColumnWidth(1, 40)
|
||||
self.tagTableWidget.setColumnWidth(2, 240)
|
||||
self.tagTableWidget.setColumnWidth(3, 200)
|
||||
QtCore.QObject.connect(self.tagTableWidget,
|
||||
QtCore.SIGNAL(u'clicked(QModelIndex)'), self.onRowSelected)
|
||||
QtCore.QObject.connect(self.defaultPushButton,
|
||||
QtCore.SIGNAL(u'pressed()'), self.onDefaultPushed)
|
||||
QtCore.QObject.connect(self.newPushButton,
|
||||
QtCore.SIGNAL(u'pressed()'), self.onNewPushed)
|
||||
QtCore.QObject.connect(self.updatePushButton,
|
||||
QtCore.SIGNAL(u'pressed()'), self.onUpdatePushed)
|
||||
QtCore.QObject.connect(self.deletePushButton,
|
||||
QtCore.SIGNAL(u'pressed()'), self.onDeletePushed)
|
||||
|
||||
def load(self):
|
||||
"""
|
||||
Load Display and set field state.
|
||||
"""
|
||||
self.newPushButton.setEnabled(True)
|
||||
self.updatePushButton.setEnabled(False)
|
||||
self.deletePushButton.setEnabled(False)
|
||||
for linenumber, html in enumerate(DisplayTags.get_html_tags()):
|
||||
self.tagTableWidget.setRowCount(
|
||||
self.tagTableWidget.rowCount() + 1)
|
||||
self.tagTableWidget.setItem(linenumber, 0,
|
||||
QtGui.QTableWidgetItem(html[u'desc']))
|
||||
self.tagTableWidget.setItem(linenumber, 1,
|
||||
QtGui.QTableWidgetItem(self._strip(html[u'start tag'])))
|
||||
self.tagTableWidget.setItem(linenumber, 2,
|
||||
QtGui.QTableWidgetItem(html[u'start html']))
|
||||
self.tagTableWidget.setItem(linenumber, 3,
|
||||
QtGui.QTableWidgetItem(html[u'end html']))
|
||||
self.tagTableWidget.resizeRowsToContents()
|
||||
self.descriptionLineEdit.setText(u'')
|
||||
self.tagLineEdit.setText(u'')
|
||||
self.startTagLineEdit.setText(u'')
|
||||
self.endTagLineEdit.setText(u'')
|
||||
self.descriptionLineEdit.setEnabled(False)
|
||||
self.tagLineEdit.setEnabled(False)
|
||||
self.startTagLineEdit.setEnabled(False)
|
||||
self.endTagLineEdit.setEnabled(False)
|
||||
|
||||
def save(self):
|
||||
"""
|
||||
Save Custom tags in a pickle .
|
||||
"""
|
||||
temp = []
|
||||
for tag in DisplayTags.get_html_tags():
|
||||
if not tag[u'protected']:
|
||||
temp.append(tag)
|
||||
if temp:
|
||||
ctemp = cPickle.dumps(temp)
|
||||
QtCore.QSettings().setValue(u'displayTags/html_tags',
|
||||
QtCore.QVariant(ctemp))
|
||||
else:
|
||||
QtCore.QSettings().setValue(u'displayTags/html_tags',
|
||||
QtCore.QVariant(u''))
|
||||
|
||||
def cancel(self):
|
||||
"""
|
||||
Reset Custom tags from Settings.
|
||||
"""
|
||||
self.preLoad()
|
||||
self._resetTable()
|
||||
|
||||
def onRowSelected(self):
|
||||
"""
|
||||
Table Row selected so display items and set field state.
|
||||
"""
|
||||
row = self.tagTableWidget.currentRow()
|
||||
html = DisplayTags.get_html_tags()[row]
|
||||
self.selected = row
|
||||
self.descriptionLineEdit.setText(html[u'desc'])
|
||||
self.tagLineEdit.setText(self._strip(html[u'start tag']))
|
||||
self.startTagLineEdit.setText(html[u'start html'])
|
||||
self.endTagLineEdit.setText(html[u'end html'])
|
||||
if html[u'protected']:
|
||||
self.descriptionLineEdit.setEnabled(False)
|
||||
self.tagLineEdit.setEnabled(False)
|
||||
self.startTagLineEdit.setEnabled(False)
|
||||
self.endTagLineEdit.setEnabled(False)
|
||||
self.updatePushButton.setEnabled(False)
|
||||
self.deletePushButton.setEnabled(False)
|
||||
else:
|
||||
self.descriptionLineEdit.setEnabled(True)
|
||||
self.tagLineEdit.setEnabled(True)
|
||||
self.startTagLineEdit.setEnabled(True)
|
||||
self.endTagLineEdit.setEnabled(True)
|
||||
self.updatePushButton.setEnabled(True)
|
||||
self.deletePushButton.setEnabled(True)
|
||||
|
||||
def onNewPushed(self):
|
||||
"""
|
||||
Add a new tag to list only if it is not a duplicate.
|
||||
"""
|
||||
for html in DisplayTags.get_html_tags():
|
||||
if self._strip(html[u'start tag']) == u'n':
|
||||
criticalErrorMessageBox(
|
||||
translate('OpenLP.DisplayTagTab', 'Update Error'),
|
||||
translate('OpenLP.DisplayTagTab',
|
||||
'Tag "n" already defined.'))
|
||||
return
|
||||
# Add new tag to list
|
||||
tag = {u'desc': u'New Item', u'start tag': u'{n}',
|
||||
u'start html': u'<Html_here>', u'end tag': u'{/n}',
|
||||
u'end html': u'</and here>', u'protected': False}
|
||||
DisplayTags.add_html_tag(tag)
|
||||
self._resetTable()
|
||||
# Highlight new row
|
||||
self.tagTableWidget.selectRow(self.tagTableWidget.rowCount() - 1)
|
||||
|
||||
def onDefaultPushed(self):
|
||||
"""
|
||||
Remove all Custom Tags and reset to base set only.
|
||||
"""
|
||||
DisplayTags.reset_html_tags()
|
||||
self._resetTable()
|
||||
|
||||
def onDeletePushed(self):
|
||||
"""
|
||||
Delete selected custom tag.
|
||||
"""
|
||||
if self.selected != -1:
|
||||
DisplayTags.remove_html_tag(self.selected)
|
||||
self.selected = -1
|
||||
self._resetTable()
|
||||
|
||||
def onUpdatePushed(self):
|
||||
"""
|
||||
Update Custom Tag details if not duplicate.
|
||||
"""
|
||||
html_expands = DisplayTags.get_html_tags()
|
||||
if self.selected != -1:
|
||||
html = html_expands[self.selected]
|
||||
tag = unicode(self.tagLineEdit.text())
|
||||
for linenumber, html1 in enumerate(html_expands):
|
||||
if self._strip(html1[u'start tag']) == tag and \
|
||||
linenumber != self.selected:
|
||||
criticalErrorMessageBox(
|
||||
translate('OpenLP.DisplayTagTab', 'Update Error'),
|
||||
unicode(translate('OpenLP.DisplayTagTab',
|
||||
'Tag %s already defined.')) % tag)
|
||||
return
|
||||
html[u'desc'] = unicode(self.descriptionLineEdit.text())
|
||||
html[u'start html'] = unicode(self.startTagLineEdit.text())
|
||||
html[u'end html'] = unicode(self.endTagLineEdit.text())
|
||||
html[u'start tag'] = u'{%s}' % tag
|
||||
html[u'end tag'] = u'{/%s}' % tag
|
||||
self.selected = -1
|
||||
self._resetTable()
|
||||
|
||||
def _resetTable(self):
|
||||
"""
|
||||
Reset List for loading.
|
||||
"""
|
||||
self.tagTableWidget.clearContents()
|
||||
self.tagTableWidget.setRowCount(0)
|
||||
self.load()
|
||||
|
||||
def _strip(self, tag):
|
||||
"""
|
||||
Remove tag wrappers for editing.
|
||||
"""
|
||||
tag = tag.replace(u'{', u'')
|
||||
tag = tag.replace(u'}', u'')
|
||||
return tag
|
@ -38,6 +38,8 @@ class Ui_FileRenameDialog(object):
|
||||
self.fileNameLabel.setObjectName(u'fileNameLabel')
|
||||
self.dialogLayout.addWidget(self.fileNameLabel, 0, 0)
|
||||
self.fileNameEdit = QtGui.QLineEdit(FileRenameDialog)
|
||||
self.fileNameEdit.setValidator(QtGui.QRegExpValidator(
|
||||
QtCore.QRegExp(r'[^/\\?*|<>\[\]":<>+%]+'), self))
|
||||
self.fileNameEdit.setObjectName(u'fileNameEdit')
|
||||
self.dialogLayout.addWidget(self.fileNameEdit, 0, 1)
|
||||
self.buttonBox = QtGui.QDialogButtonBox(FileRenameDialog)
|
||||
|
@ -139,6 +139,7 @@ class GeneralTab(SettingsTab):
|
||||
self.numberLabel = QtGui.QLabel(self.ccliGroupBox)
|
||||
self.numberLabel.setObjectName(u'numberLabel')
|
||||
self.numberEdit = QtGui.QLineEdit(self.ccliGroupBox)
|
||||
self.numberEdit.setValidator(QtGui.QIntValidator())
|
||||
self.numberEdit.setObjectName(u'numberEdit')
|
||||
self.ccliLayout.addRow(self.numberLabel, self.numberEdit)
|
||||
self.usernameLabel = QtGui.QLabel(self.ccliGroupBox)
|
||||
|
@ -24,6 +24,8 @@
|
||||
# Temple Place, Suite 330, Boston, MA 02111-1307 USA #
|
||||
###############################################################################
|
||||
"""
|
||||
The :mod:`maindisplay` module provides the functionality to display screens
|
||||
and play multimedia within OpenLP.
|
||||
"""
|
||||
import logging
|
||||
import os
|
||||
@ -32,7 +34,8 @@ from PyQt4 import QtCore, QtGui, QtWebKit
|
||||
from PyQt4.phonon import Phonon
|
||||
|
||||
from openlp.core.lib import Receiver, build_html, ServiceItem, image_to_byte, \
|
||||
translate
|
||||
build_icon, translate
|
||||
|
||||
from openlp.core.ui import HideMode
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
@ -91,6 +94,7 @@ class DisplayWidget(QtGui.QGraphicsView):
|
||||
else:
|
||||
event.ignore()
|
||||
|
||||
|
||||
class MainDisplay(DisplayWidget):
|
||||
"""
|
||||
This is the display screen.
|
||||
@ -102,6 +106,8 @@ class MainDisplay(DisplayWidget):
|
||||
self.isLive = live
|
||||
self.alertTab = None
|
||||
self.hideMode = None
|
||||
mainIcon = build_icon(u':/icon/openlp-logo-16x16.png')
|
||||
self.setWindowIcon(mainIcon)
|
||||
self.retranslateUi()
|
||||
self.setStyleSheet(u'border: 0px; margin: 0px; padding: 0px;')
|
||||
self.setWindowFlags(QtCore.Qt.FramelessWindowHint |
|
||||
@ -195,7 +201,7 @@ class MainDisplay(DisplayWidget):
|
||||
The slide text to be displayed
|
||||
"""
|
||||
log.debug(u'text to display')
|
||||
# Wait for the webview to update before displayiong text.
|
||||
# Wait for the webview to update before displaying text.
|
||||
while not self.loaded:
|
||||
Receiver.send_message(u'openlp_process_events')
|
||||
self.frame.evaluateJavaScript(u'show_text("%s")' % \
|
||||
@ -265,6 +271,8 @@ class MainDisplay(DisplayWidget):
|
||||
else:
|
||||
js = u'show_image("");'
|
||||
self.frame.evaluateJavaScript(js)
|
||||
# Update the preview frame.
|
||||
Receiver.send_message(u'maindisplay_active')
|
||||
|
||||
def resetImage(self):
|
||||
"""
|
||||
@ -273,6 +281,8 @@ class MainDisplay(DisplayWidget):
|
||||
"""
|
||||
log.debug(u'resetImage')
|
||||
self.displayImage(self.serviceItem.bg_image_bytes)
|
||||
# Update the preview frame.
|
||||
Receiver.send_message(u'maindisplay_active')
|
||||
|
||||
def resetVideo(self):
|
||||
"""
|
||||
@ -287,6 +297,8 @@ class MainDisplay(DisplayWidget):
|
||||
self.phononActive = False
|
||||
else:
|
||||
self.frame.evaluateJavaScript(u'show_video("close");')
|
||||
# Update the preview frame.
|
||||
Receiver.send_message(u'maindisplay_active')
|
||||
|
||||
def videoPlay(self):
|
||||
"""
|
||||
@ -354,6 +366,8 @@ class MainDisplay(DisplayWidget):
|
||||
self.webView.setVisible(False)
|
||||
self.videoWidget.setVisible(True)
|
||||
self.audio.setVolume(vol)
|
||||
# Update the preview frame.
|
||||
Receiver.send_message(u'maindisplay_active')
|
||||
return self.preview()
|
||||
|
||||
def isLoaded(self):
|
||||
@ -470,6 +484,7 @@ class MainDisplay(DisplayWidget):
|
||||
# Trigger actions when display is active again
|
||||
Receiver.send_message(u'maindisplay_active')
|
||||
|
||||
|
||||
class AudioPlayer(QtCore.QObject):
|
||||
"""
|
||||
This Class will play audio only allowing components to work with a
|
||||
|
@ -142,7 +142,8 @@ class Ui_MainWindow(object):
|
||||
build_icon(u':/system/system_servicemanager.png'))
|
||||
self.ServiceManagerDock.setMinimumWidth(
|
||||
self.settingsmanager.mainwindow_right)
|
||||
self.ServiceManagerContents = ServiceManager(MainWindow)
|
||||
self.ServiceManagerContents = ServiceManager(MainWindow,
|
||||
self.ServiceManagerDock)
|
||||
self.ServiceManagerDock.setWidget(self.ServiceManagerContents)
|
||||
MainWindow.addDockWidget(QtCore.Qt.RightDockWidgetArea,
|
||||
self.ServiceManagerDock)
|
||||
@ -152,7 +153,8 @@ class Ui_MainWindow(object):
|
||||
build_icon(u':/system/system_thememanager.png'))
|
||||
self.ThemeManagerDock.setMinimumWidth(
|
||||
self.settingsmanager.mainwindow_right)
|
||||
self.ThemeManagerContents = ThemeManager(MainWindow)
|
||||
self.ThemeManagerContents = ThemeManager(MainWindow,
|
||||
self.ThemeManagerDock)
|
||||
self.ThemeManagerContents.setObjectName(u'ThemeManagerContents')
|
||||
self.ThemeManagerDock.setWidget(self.ThemeManagerContents)
|
||||
MainWindow.addDockWidget(QtCore.Qt.RightDockWidgetArea,
|
||||
|
@ -61,6 +61,7 @@ class PluginForm(QtGui.QDialog, Ui_PluginViewDialog):
|
||||
self.programaticChange = True
|
||||
self._clearDetails()
|
||||
self.programaticChange = True
|
||||
pluginListWidth = 0
|
||||
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
|
||||
@ -83,8 +84,11 @@ class PluginForm(QtGui.QDialog, Ui_PluginViewDialog):
|
||||
if plugin.icon:
|
||||
item.setIcon(plugin.icon)
|
||||
self.pluginListWidget.addItem(item)
|
||||
self.pluginListWidget.setFixedWidth(
|
||||
self.pluginListWidget.sizeHint().width())
|
||||
pluginListWidth = max(pluginListWidth, self.fontMetrics().width(
|
||||
unicode(translate('OpenLP.PluginForm', '%s (Inactive)')) %
|
||||
name_string[u'singular']))
|
||||
self.pluginListWidget.setFixedWidth(pluginListWidth +
|
||||
self.pluginListWidget.iconSize().width() + 48)
|
||||
|
||||
def _clearDetails(self):
|
||||
self.statusComboBox.setCurrentIndex(-1)
|
||||
@ -126,10 +130,8 @@ class PluginForm(QtGui.QDialog, Ui_PluginViewDialog):
|
||||
return
|
||||
if status == 0:
|
||||
self.activePlugin.toggleStatus(PluginStatus.Active)
|
||||
self.activePlugin.initialise()
|
||||
else:
|
||||
self.activePlugin.toggleStatus(PluginStatus.Inactive)
|
||||
self.activePlugin.finalise()
|
||||
status_text = unicode(
|
||||
translate('OpenLP.PluginForm', '%s (Inactive)'))
|
||||
if self.activePlugin.status == PluginStatus.Active:
|
||||
|
@ -28,7 +28,6 @@ import os
|
||||
import logging
|
||||
import cPickle
|
||||
import zipfile
|
||||
from pprint import pformat
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
@ -37,40 +36,42 @@ from PyQt4 import QtCore, QtGui
|
||||
from openlp.core.lib import OpenLPToolbar, ServiceItem, context_menu_action, \
|
||||
Receiver, build_icon, ItemCapabilities, SettingsManager, translate, \
|
||||
ThemeLevel
|
||||
from openlp.core.ui import ServiceNoteForm, ServiceItemEditForm
|
||||
from openlp.core.utils import AppLocation, split_filename
|
||||
from openlp.core.ui import criticalErrorMessageBox, ServiceNoteForm, \
|
||||
ServiceItemEditForm
|
||||
from openlp.core.utils import AppLocation, delete_file, file_is_unicode, \
|
||||
split_filename
|
||||
|
||||
class ServiceManagerList(QtGui.QTreeWidget):
|
||||
"""
|
||||
Set up key bindings and mouse behaviour for the service list
|
||||
"""
|
||||
def __init__(self, parent=None, name=None):
|
||||
def __init__(self, mainwindow, parent=None, name=None):
|
||||
QtGui.QTreeWidget.__init__(self, parent)
|
||||
self.parent = parent
|
||||
self.mainwindow = mainwindow
|
||||
|
||||
def keyPressEvent(self, event):
|
||||
if isinstance(event, QtGui.QKeyEvent):
|
||||
#here accept the event and do something
|
||||
if event.key() == QtCore.Qt.Key_Enter:
|
||||
self.parent.makeLive()
|
||||
self.mainwindow.makeLive()
|
||||
event.accept()
|
||||
elif event.key() == QtCore.Qt.Key_Home:
|
||||
self.parent.onServiceTop()
|
||||
self.mainwindow.onServiceTop()
|
||||
event.accept()
|
||||
elif event.key() == QtCore.Qt.Key_End:
|
||||
self.parent.onServiceEnd()
|
||||
self.mainwindow.onServiceEnd()
|
||||
event.accept()
|
||||
elif event.key() == QtCore.Qt.Key_PageUp:
|
||||
self.parent.onServiceUp()
|
||||
self.mainwindow.onServiceUp()
|
||||
event.accept()
|
||||
elif event.key() == QtCore.Qt.Key_PageDown:
|
||||
self.parent.onServiceDown()
|
||||
self.mainwindow.onServiceDown()
|
||||
event.accept()
|
||||
elif event.key() == QtCore.Qt.Key_Up:
|
||||
self.parent.onMoveSelectionUp()
|
||||
self.mainwindow.onMoveSelectionUp()
|
||||
event.accept()
|
||||
elif event.key() == QtCore.Qt.Key_Down:
|
||||
self.parent.onMoveSelectionDown()
|
||||
self.mainwindow.onMoveSelectionDown()
|
||||
event.accept()
|
||||
event.ignore()
|
||||
else:
|
||||
@ -99,12 +100,12 @@ class ServiceManager(QtGui.QWidget):
|
||||
the resources used into one OSZ file for use on any OpenLP v2 installation.
|
||||
Also handles the UI tasks of moving things up and down etc.
|
||||
"""
|
||||
def __init__(self, parent):
|
||||
def __init__(self, mainwindow, parent=None):
|
||||
"""
|
||||
Sets up the service manager, toolbars, list view, et al.
|
||||
"""
|
||||
QtGui.QWidget.__init__(self, parent)
|
||||
self.parent = parent
|
||||
self.mainwindow = mainwindow
|
||||
self.serviceItems = []
|
||||
self.serviceName = u''
|
||||
self.suffixes = []
|
||||
@ -113,8 +114,8 @@ class ServiceManager(QtGui.QWidget):
|
||||
# is a new service and has not been saved
|
||||
self._modified = False
|
||||
self._fileName = u''
|
||||
self.serviceNoteForm = ServiceNoteForm(self.parent)
|
||||
self.serviceItemEditForm = ServiceItemEditForm(self.parent)
|
||||
self.serviceNoteForm = ServiceNoteForm(self.mainwindow)
|
||||
self.serviceItemEditForm = ServiceItemEditForm(self.mainwindow)
|
||||
# start with the layout
|
||||
self.layout = QtGui.QVBoxLayout(self)
|
||||
self.layout.setSpacing(0)
|
||||
@ -145,8 +146,10 @@ class ServiceManager(QtGui.QWidget):
|
||||
self.themeComboBox = QtGui.QComboBox(self.toolbar)
|
||||
self.themeComboBox.setToolTip(translate('OpenLP.ServiceManager',
|
||||
'Select a theme for the service'))
|
||||
self.themeComboBox.setSizePolicy(QtGui.QSizePolicy.Expanding,
|
||||
QtGui.QSizePolicy.Fixed)
|
||||
self.themeComboBox.setSizeAdjustPolicy(
|
||||
QtGui.QComboBox.AdjustToMinimumContentsLength)
|
||||
self.themeComboBox.setSizePolicy(
|
||||
QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Fixed)
|
||||
self.themeComboBox.setObjectName(u'themeComboBox')
|
||||
self.toolbar.addToolbarWidget(u'ThemeWidget', self.themeComboBox)
|
||||
self.toolbar.setObjectName(u'toolbar')
|
||||
@ -248,10 +251,10 @@ class ServiceManager(QtGui.QWidget):
|
||||
QtCore.SIGNAL(u'service_item_update'), self.serviceItemUpdate)
|
||||
# Last little bits of setting up
|
||||
self.service_theme = unicode(QtCore.QSettings().value(
|
||||
self.parent.serviceSettingsSection + u'/service theme',
|
||||
self.mainwindow.serviceSettingsSection + u'/service theme',
|
||||
QtCore.QVariant(u'')).toString())
|
||||
self.servicePath = AppLocation.get_section_data_path(u'servicemanager')
|
||||
#build the drag and drop context menu
|
||||
# build the drag and drop context menu
|
||||
self.dndMenu = QtGui.QMenu()
|
||||
self.newAction = self.dndMenu.addAction(
|
||||
translate('OpenLP.ServiceManager', '&Add New Item'))
|
||||
@ -295,7 +298,7 @@ class ServiceManager(QtGui.QWidget):
|
||||
"""
|
||||
self._modified = modified
|
||||
serviceFile = self.shortFileName() or u'Untitled Service'
|
||||
self.parent.setServiceModified(modified, serviceFile)
|
||||
self.mainwindow.setServiceModified(modified, serviceFile)
|
||||
|
||||
def isModified(self):
|
||||
"""
|
||||
@ -308,7 +311,8 @@ class ServiceManager(QtGui.QWidget):
|
||||
Setter for service file.
|
||||
"""
|
||||
self._fileName = unicode(fileName)
|
||||
self.parent.setServiceModified(self.isModified(), self.shortFileName())
|
||||
self.mainwindow.setServiceModified(self.isModified(),
|
||||
self.shortFileName())
|
||||
QtCore.QSettings(). \
|
||||
setValue(u'service/last file',QtCore.QVariant(fileName))
|
||||
|
||||
@ -342,7 +346,7 @@ class ServiceManager(QtGui.QWidget):
|
||||
Create a new service.
|
||||
"""
|
||||
if self.isModified():
|
||||
result = QtGui.QMessageBox.question(self.parent,
|
||||
result = QtGui.QMessageBox.question(self.mainwindow,
|
||||
translate('OpenLP.ServiceManager', 'Save Changes'),
|
||||
translate('OpenLP.ServiceManager', 'The current service has '
|
||||
'been modified, would you like to save it?'),
|
||||
@ -357,7 +361,7 @@ class ServiceManager(QtGui.QWidget):
|
||||
|
||||
def onLoadServiceClicked(self):
|
||||
if self.isModified():
|
||||
result = QtGui.QMessageBox.question(self.parent,
|
||||
result = QtGui.QMessageBox.question(self.mainwindow,
|
||||
translate('OpenLP.ServiceManager', 'Save Changes'),
|
||||
translate('OpenLP.ServiceManager', 'The current service has '
|
||||
'been modified, would you like to save it?'),
|
||||
@ -367,14 +371,14 @@ class ServiceManager(QtGui.QWidget):
|
||||
return False
|
||||
elif result == QtGui.QMessageBox.Save:
|
||||
self.saveFile()
|
||||
fileName = unicode(QtGui.QFileDialog.getOpenFileName(self.parent,
|
||||
fileName = unicode(QtGui.QFileDialog.getOpenFileName(self.mainwindow,
|
||||
translate('OpenLP.ServiceManager', 'Open File'),
|
||||
SettingsManager.get_last_dir(self.parent.serviceSettingsSection),
|
||||
translate('OpenLP.ServiceManager',
|
||||
'OpenLP Service Files (*.osz)')))
|
||||
SettingsManager.get_last_dir(
|
||||
self.mainwindow.serviceSettingsSection),
|
||||
translate('OpenLP.ServiceManager', 'OpenLP Service Files (*.osz)')))
|
||||
if not fileName:
|
||||
return False
|
||||
SettingsManager.set_last_dir(self.parent.serviceSettingsSection,
|
||||
SettingsManager.set_last_dir(self.mainwindow.serviceSettingsSection,
|
||||
split_filename(fileName)[0])
|
||||
self.loadFile(fileName)
|
||||
|
||||
@ -408,7 +412,7 @@ class ServiceManager(QtGui.QWidget):
|
||||
else:
|
||||
fileName = self.fileName()
|
||||
log.debug(u'ServiceManager.saveFile - %s' % fileName)
|
||||
SettingsManager.set_last_dir(self.parent.serviceSettingsSection,
|
||||
SettingsManager.set_last_dir(self.mainwindow.serviceSettingsSection,
|
||||
split_filename(fileName)[0])
|
||||
service = []
|
||||
serviceFileName = fileName.replace(u'.osz', u'.osd')
|
||||
@ -443,12 +447,8 @@ class ServiceManager(QtGui.QWidget):
|
||||
file.close()
|
||||
if zip:
|
||||
zip.close()
|
||||
try:
|
||||
os.remove(serviceFileName)
|
||||
except (IOError, OSError):
|
||||
# if not present do not worry
|
||||
pass
|
||||
self.parent.addRecentFile(fileName)
|
||||
delete_file(serviceFileName)
|
||||
self.mainwindow.addRecentFile(fileName)
|
||||
self.setModified(False)
|
||||
return True
|
||||
|
||||
@ -457,11 +457,11 @@ class ServiceManager(QtGui.QWidget):
|
||||
Get a file name and then call :function:`ServiceManager.saveFile` to
|
||||
save the file.
|
||||
"""
|
||||
fileName = unicode(QtGui.QFileDialog.getSaveFileName(self.parent,
|
||||
fileName = unicode(QtGui.QFileDialog.getSaveFileName(self.mainwindow,
|
||||
translate('OpenLP.ServiceManager', 'Save Service'),
|
||||
SettingsManager.get_last_dir(self.parent.serviceSettingsSection),
|
||||
translate('OpenLP.ServiceManager',
|
||||
'OpenLP Service Files (*.osz)')))
|
||||
SettingsManager.get_last_dir(
|
||||
self.mainwindow.serviceSettingsSection),
|
||||
translate('OpenLP.ServiceManager', 'OpenLP Service Files (*.osz)')))
|
||||
if not fileName:
|
||||
return False
|
||||
if os.path.splitext(fileName)[1] == u'':
|
||||
@ -480,18 +480,14 @@ class ServiceManager(QtGui.QWidget):
|
||||
zip = None
|
||||
fileTo = None
|
||||
try:
|
||||
zip = zipfile.ZipFile(unicode(fileName))
|
||||
zip = zipfile.ZipFile(fileName)
|
||||
for file in zip.namelist():
|
||||
try:
|
||||
ucsfile = file.decode(u'utf-8')
|
||||
except UnicodeDecodeError:
|
||||
QtGui.QMessageBox.critical(
|
||||
self, translate('OpenLP.ServiceManager', 'Error'),
|
||||
translate('OpenLP.ServiceManager',
|
||||
'File is not a valid service.\n'
|
||||
'The content encoding is not UTF-8.'))
|
||||
log.exception(u'Filename "%s" is not valid UTF-8' %
|
||||
file.decode(u'utf-8', u'replace'))
|
||||
ucsfile = file_is_unicode(file)
|
||||
if not ucsfile:
|
||||
criticalErrorMessageBox(
|
||||
message=translate('OpenLP.ServiceManager',
|
||||
'File is not a valid service.\n'
|
||||
'The content encoding is not UTF-8.'))
|
||||
continue
|
||||
osfile = unicode(QtCore.QDir.toNativeSeparators(ucsfile))
|
||||
filePath = os.path.join(self.servicePath,
|
||||
@ -509,24 +505,18 @@ class ServiceManager(QtGui.QWidget):
|
||||
self.newFile()
|
||||
for item in items:
|
||||
serviceItem = ServiceItem()
|
||||
serviceItem.render_manager = self.parent.renderManager
|
||||
serviceItem.render_manager = self.mainwindow.renderManager
|
||||
serviceItem.set_from_service(item, self.servicePath)
|
||||
self.validateItem(serviceItem)
|
||||
self.addServiceItem(serviceItem)
|
||||
if serviceItem.is_capable(
|
||||
ItemCapabilities.OnLoadUpdate):
|
||||
if serviceItem.is_capable(ItemCapabilities.OnLoadUpdate):
|
||||
Receiver.send_message(u'%s_service_load' %
|
||||
serviceItem.name.lower(), serviceItem)
|
||||
try:
|
||||
if os.path.isfile(p_file):
|
||||
os.remove(p_file)
|
||||
except (IOError, OSError):
|
||||
log.exception(u'Failed to remove osd file')
|
||||
delete_file(p_file)
|
||||
else:
|
||||
QtGui.QMessageBox.critical(
|
||||
self, translate('OpenLP.ServiceManager', 'Error'),
|
||||
translate('OpenLP.ServiceManager',
|
||||
'File is not a valid service.'))
|
||||
criticalErrorMessageBox(
|
||||
message=translate('OpenLP.ServiceManager',
|
||||
'File is not a valid service.'))
|
||||
log.exception(u'File contains no service data')
|
||||
except (IOError, NameError):
|
||||
log.exception(u'Problem loading a service file')
|
||||
@ -536,7 +526,7 @@ class ServiceManager(QtGui.QWidget):
|
||||
if zip:
|
||||
zip.close()
|
||||
self.setFileName(fileName)
|
||||
self.parent.addRecentFile(fileName)
|
||||
self.mainwindow.addRecentFile(fileName)
|
||||
self.setModified(False)
|
||||
QtCore.QSettings(). \
|
||||
setValue(u'service/last file',QtCore.QVariant(fileName))
|
||||
@ -875,11 +865,7 @@ class ServiceManager(QtGui.QWidget):
|
||||
"""
|
||||
for file in os.listdir(self.servicePath):
|
||||
file_path = os.path.join(self.servicePath, file)
|
||||
try:
|
||||
if os.path.isfile(file_path):
|
||||
os.remove(file_path)
|
||||
except OSError:
|
||||
log.exception(u'Failed to clean up servicePath')
|
||||
delete_file(file_path)
|
||||
|
||||
def onThemeComboBoxSelected(self, currentIndex):
|
||||
"""
|
||||
@ -887,9 +873,9 @@ class ServiceManager(QtGui.QWidget):
|
||||
"""
|
||||
log.debug(u'onThemeComboBoxSelected')
|
||||
self.service_theme = unicode(self.themeComboBox.currentText())
|
||||
self.parent.renderManager.set_service_theme(self.service_theme)
|
||||
self.mainwindow.renderManager.set_service_theme(self.service_theme)
|
||||
QtCore.QSettings().setValue(
|
||||
self.parent.serviceSettingsSection + u'/service theme',
|
||||
self.mainwindow.serviceSettingsSection + u'/service theme',
|
||||
QtCore.QVariant(self.service_theme))
|
||||
self.regenerateServiceItems()
|
||||
|
||||
@ -899,7 +885,7 @@ class ServiceManager(QtGui.QWidget):
|
||||
sure the theme combo box is in the correct state.
|
||||
"""
|
||||
log.debug(u'themeChange')
|
||||
if self.parent.renderManager.theme_level == ThemeLevel.Global:
|
||||
if self.mainwindow.renderManager.theme_level == ThemeLevel.Global:
|
||||
self.toolbar.actions[u'ThemeLabel'].setVisible(False)
|
||||
self.toolbar.actions[u'ThemeWidget'].setVisible(False)
|
||||
else:
|
||||
@ -914,7 +900,7 @@ class ServiceManager(QtGui.QWidget):
|
||||
Receiver.send_message(u'cursor_busy')
|
||||
log.debug(u'regenerateServiceItems')
|
||||
# force reset of renderer as theme data has changed
|
||||
self.parent.renderManager.themedata = None
|
||||
self.mainwindow.renderManager.themedata = None
|
||||
if self.serviceItems:
|
||||
tempServiceItems = self.serviceItems
|
||||
self.serviceManagerList.clear()
|
||||
@ -949,7 +935,8 @@ 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.mainwindow.liveController.replaceServiceManagerItem(
|
||||
newItem)
|
||||
self.setModified(True)
|
||||
|
||||
def addServiceItem(self, item, rebuild=False, expand=None, replace=False):
|
||||
@ -971,7 +958,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.mainwindow.liveController.replaceServiceManagerItem(item)
|
||||
else:
|
||||
# nothing selected for dnd
|
||||
if self.dropPosition == 0:
|
||||
@ -986,13 +973,13 @@ class ServiceManager(QtGui.QWidget):
|
||||
u'expanded':expand})
|
||||
self.repaintServiceList(len(self.serviceItems) + 1, 0)
|
||||
else:
|
||||
self.serviceItems.insert(self.dropPosition, {u'service_item': item,
|
||||
u'order': self.dropPosition,
|
||||
self.serviceItems.insert(self.dropPosition,
|
||||
{u'service_item': item, u'order': self.dropPosition,
|
||||
u'expanded':expand})
|
||||
self.repaintServiceList(self.dropPosition, 0)
|
||||
# if rebuilding list make sure live is fixed.
|
||||
if rebuild:
|
||||
self.parent.liveController.replaceServiceManagerItem(item)
|
||||
self.mainwindow.liveController.replaceServiceManagerItem(item)
|
||||
self.dropPosition = 0
|
||||
self.setModified(True)
|
||||
|
||||
@ -1002,10 +989,10 @@ class ServiceManager(QtGui.QWidget):
|
||||
"""
|
||||
item, count = self.findServiceItem()
|
||||
if self.serviceItems[item][u'service_item'].is_valid:
|
||||
self.parent.previewController.addServiceManagerItem(
|
||||
self.mainwindow.previewController.addServiceManagerItem(
|
||||
self.serviceItems[item][u'service_item'], count)
|
||||
else:
|
||||
QtGui.QMessageBox.critical(self,
|
||||
criticalErrorMessageBox(
|
||||
translate('OpenLP.ServiceManager', 'Missing Display Handler'),
|
||||
translate('OpenLP.ServiceManager', 'Your item cannot be '
|
||||
'displayed as there is no handler to display it'))
|
||||
@ -1026,24 +1013,24 @@ class ServiceManager(QtGui.QWidget):
|
||||
"""
|
||||
item, count = self.findServiceItem()
|
||||
if self.serviceItems[item][u'service_item'].is_valid:
|
||||
self.parent.liveController.addServiceManagerItem(
|
||||
self.mainwindow.liveController.addServiceManagerItem(
|
||||
self.serviceItems[item][u'service_item'], count)
|
||||
if QtCore.QSettings().value(
|
||||
self.parent.generalSettingsSection + u'/auto preview',
|
||||
self.mainwindow.generalSettingsSection + u'/auto preview',
|
||||
QtCore.QVariant(False)).toBool():
|
||||
item += 1
|
||||
if self.serviceItems and item < len(self.serviceItems) and \
|
||||
self.serviceItems[item][u'service_item'].is_capable(
|
||||
ItemCapabilities.AllowsPreview):
|
||||
self.parent.previewController.addServiceManagerItem(
|
||||
self.mainwindow.previewController.addServiceManagerItem(
|
||||
self.serviceItems[item][u'service_item'], 0)
|
||||
self.parent.liveController.PreviewListWidget.setFocus()
|
||||
self.mainwindow.liveController.PreviewListWidget.setFocus()
|
||||
else:
|
||||
QtGui.QMessageBox.critical(self,
|
||||
criticalErrorMessageBox(
|
||||
translate('OpenLP.ServiceManager', 'Missing Display Handler'),
|
||||
translate('OpenLP.ServiceManager', 'Your item cannot be '
|
||||
'displayed as the plugin required to display it is missing '
|
||||
'or inactive'))
|
||||
'displayed as the plugin required to display it is missing '
|
||||
'or inactive'))
|
||||
|
||||
def remoteEdit(self):
|
||||
"""
|
||||
@ -1157,7 +1144,7 @@ class ServiceManager(QtGui.QWidget):
|
||||
index = 0
|
||||
self.service_theme = u''
|
||||
self.themeComboBox.setCurrentIndex(index)
|
||||
self.parent.renderManager.set_service_theme(self.service_theme)
|
||||
self.mainwindow.renderManager.set_service_theme(self.service_theme)
|
||||
self.regenerateServiceItems()
|
||||
|
||||
def onThemeChangeAction(self):
|
||||
|
@ -31,7 +31,7 @@ from openlp.core.lib import translate, build_icon
|
||||
class Ui_SettingsDialog(object):
|
||||
def setupUi(self, settingsDialog):
|
||||
settingsDialog.setObjectName(u'settingsDialog')
|
||||
settingsDialog.resize(700, 300)
|
||||
settingsDialog.resize(700, 500)
|
||||
settingsDialog.setWindowIcon(
|
||||
build_icon(u':/system/system_settings.png'))
|
||||
self.settingsLayout = QtGui.QVBoxLayout(settingsDialog)
|
||||
|
@ -31,7 +31,7 @@ import logging
|
||||
from PyQt4 import QtGui
|
||||
|
||||
from openlp.core.lib import Receiver
|
||||
from openlp.core.ui import AdvancedTab, GeneralTab, ThemesTab
|
||||
from openlp.core.ui import AdvancedTab, GeneralTab, ThemesTab, DisplayTagTab
|
||||
from settingsdialog import Ui_SettingsDialog
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
@ -55,6 +55,9 @@ class SettingsForm(QtGui.QDialog, Ui_SettingsDialog):
|
||||
# Advanced tab
|
||||
self.advancedTab = AdvancedTab()
|
||||
self.addTab(u'Advanced', self.advancedTab)
|
||||
# Edit Display Tags tab
|
||||
self.displayTagTab = DisplayTagTab()
|
||||
self.addTab(u'Display Tags', self.displayTagTab)
|
||||
|
||||
def addTab(self, name, tab):
|
||||
"""
|
||||
@ -68,9 +71,9 @@ class SettingsForm(QtGui.QDialog, Ui_SettingsDialog):
|
||||
Add a tab to the form at a specific location
|
||||
"""
|
||||
log.debug(u'Inserting %s tab' % tab.tabTitle)
|
||||
# 14 : There are 3 tables currently and locations starts at -10
|
||||
# 15 : There are 4 tables currently and locations starts at -10
|
||||
self.settingsTabWidget.insertTab(
|
||||
location + 14, tab, tab.tabTitleVisible)
|
||||
location + 15, tab, tab.tabTitleVisible)
|
||||
|
||||
def removeTab(self, tab):
|
||||
"""
|
||||
@ -93,6 +96,14 @@ class SettingsForm(QtGui.QDialog, Ui_SettingsDialog):
|
||||
Receiver.send_message(u'config_updated')
|
||||
return QtGui.QDialog.accept(self)
|
||||
|
||||
def reject(self):
|
||||
"""
|
||||
Process the form saving the settings
|
||||
"""
|
||||
for tabIndex in range(0, self.settingsTabWidget.count()):
|
||||
self.settingsTabWidget.widget(tabIndex).cancel()
|
||||
return QtGui.QDialog.reject(self)
|
||||
|
||||
def postSetUp(self):
|
||||
"""
|
||||
Run any post-setup code for the tabs on the form
|
||||
|
@ -399,7 +399,8 @@ class SlideController(QtGui.QWidget):
|
||||
def previewSizeChanged(self):
|
||||
"""
|
||||
Takes care of the SlidePreview's size. Is called when one of the the
|
||||
splitters is moved or when the screen size is changed.
|
||||
splitters is moved or when the screen size is changed. Note, that this
|
||||
method is (also) called frequently from the mainwindow *paintEvent*.
|
||||
"""
|
||||
if self.ratio < float(self.PreviewFrame.width()) / float(
|
||||
self.PreviewFrame.height()):
|
||||
@ -412,13 +413,19 @@ class SlideController(QtGui.QWidget):
|
||||
max_width = self.PreviewFrame.width() - self.grid.margin() * 2
|
||||
self.SlidePreview.setFixedSize(QtCore.QSize(max_width,
|
||||
max_width / self.ratio))
|
||||
width = self.parent.ControlSplitter.sizes()[self.split]
|
||||
self.PreviewListWidget.setColumnWidth(0, width)
|
||||
# Sort out image heights (Songs, bibles excluded)
|
||||
if self.serviceItem and not self.serviceItem.is_text():
|
||||
for framenumber in range(len(self.serviceItem.get_frames())):
|
||||
self.PreviewListWidget.setRowHeight(
|
||||
framenumber, width / self.ratio)
|
||||
# Make sure that the frames have the correct size.
|
||||
self.PreviewListWidget.setColumnWidth(0,
|
||||
self.PreviewListWidget.viewport().size().width())
|
||||
if self.serviceItem:
|
||||
# Sort out songs, bibles, etc.
|
||||
if self.serviceItem.is_text():
|
||||
self.PreviewListWidget.resizeRowsToContents()
|
||||
else:
|
||||
# Sort out image heights.
|
||||
width = self.parent.ControlSplitter.sizes()[self.split]
|
||||
for framenumber in range(len(self.serviceItem.get_frames())):
|
||||
self.PreviewListWidget.setRowHeight(
|
||||
framenumber, width / self.ratio)
|
||||
|
||||
def onSongBarHandler(self):
|
||||
request = unicode(self.sender().text())
|
||||
@ -590,7 +597,7 @@ class SlideController(QtGui.QWidget):
|
||||
self.parent.renderManager.height)
|
||||
else:
|
||||
image = self.parent.renderManager.image_manager. \
|
||||
get_image(frame[u'title'])
|
||||
get_image(frame[u'title'])
|
||||
label.setPixmap(QtGui.QPixmap.fromImage(image))
|
||||
self.PreviewListWidget.setCellWidget(framenumber, 0, label)
|
||||
slideHeight = width * self.parent.renderManager.screen_ratio
|
||||
@ -680,8 +687,17 @@ class SlideController(QtGui.QWidget):
|
||||
Allow the main display to blank the main display at startup time
|
||||
"""
|
||||
log.debug(u'mainDisplaySetBackground live = %s' % self.isLive)
|
||||
display_type = QtCore.QSettings().value(
|
||||
self.parent.generalSettingsSection + u'/screen blank',
|
||||
QtCore.QVariant(u'')).toString()
|
||||
if not self.display.primary:
|
||||
self.onBlankDisplay(True)
|
||||
# Order done to handle initial conversion
|
||||
if display_type == u'themed':
|
||||
self.onThemeDisplay(True)
|
||||
elif display_type == u'hidden':
|
||||
self.onHideDisplay(True)
|
||||
else:
|
||||
self.onBlankDisplay(True)
|
||||
|
||||
def onSlideBlank(self):
|
||||
"""
|
||||
@ -705,13 +721,15 @@ class SlideController(QtGui.QWidget):
|
||||
self.ThemeScreen.setChecked(False)
|
||||
if self.screens.display_count > 1:
|
||||
self.DesktopScreen.setChecked(False)
|
||||
QtCore.QSettings().setValue(
|
||||
self.parent.generalSettingsSection + u'/screen blank',
|
||||
QtCore.QVariant(checked))
|
||||
if checked:
|
||||
Receiver.send_message(u'maindisplay_hide', HideMode.Blank)
|
||||
QtCore.QSettings().setValue(
|
||||
self.parent.generalSettingsSection + u'/screen blank',
|
||||
QtCore.QVariant(u'blanked'))
|
||||
else:
|
||||
Receiver.send_message(u'maindisplay_show')
|
||||
QtCore.QSettings().remove(
|
||||
self.parent.generalSettingsSection + u'/screen blank')
|
||||
self.blankPlugin(checked)
|
||||
|
||||
def onThemeDisplay(self, checked):
|
||||
@ -726,8 +744,13 @@ class SlideController(QtGui.QWidget):
|
||||
self.DesktopScreen.setChecked(False)
|
||||
if checked:
|
||||
Receiver.send_message(u'maindisplay_hide', HideMode.Theme)
|
||||
QtCore.QSettings().setValue(
|
||||
self.parent.generalSettingsSection + u'/screen blank',
|
||||
QtCore.QVariant(u'themed'))
|
||||
else:
|
||||
Receiver.send_message(u'maindisplay_show')
|
||||
QtCore.QSettings().remove(
|
||||
self.parent.generalSettingsSection + u'/screen blank')
|
||||
self.blankPlugin(checked)
|
||||
|
||||
def onHideDisplay(self, checked):
|
||||
@ -738,12 +761,19 @@ class SlideController(QtGui.QWidget):
|
||||
self.HideMenu.setDefaultAction(self.DesktopScreen)
|
||||
self.BlankScreen.setChecked(False)
|
||||
self.ThemeScreen.setChecked(False)
|
||||
if self.screens.display_count > 1:
|
||||
self.DesktopScreen.setChecked(checked)
|
||||
# On valid if more than 1 display
|
||||
if self.screens.display_count <= 1:
|
||||
return
|
||||
self.DesktopScreen.setChecked(checked)
|
||||
if checked:
|
||||
Receiver.send_message(u'maindisplay_hide', HideMode.Screen)
|
||||
QtCore.QSettings().setValue(
|
||||
self.parent.generalSettingsSection + u'/screen blank',
|
||||
QtCore.QVariant(u'hidden'))
|
||||
else:
|
||||
Receiver.send_message(u'maindisplay_show')
|
||||
QtCore.QSettings().remove(
|
||||
self.parent.generalSettingsSection + u'/screen blank')
|
||||
self.hidePlugin(checked)
|
||||
|
||||
def blankPlugin(self, blank):
|
||||
@ -1033,9 +1063,8 @@ class SlideController(QtGui.QWidget):
|
||||
if self.BlankScreen.isChecked:
|
||||
self.BlankScreen.setChecked(False)
|
||||
self.HideMenu.setDefaultAction(self.BlankScreen)
|
||||
QtCore.QSettings().setValue(
|
||||
self.parent.generalSettingsSection + u'/screen blank',
|
||||
QtCore.QVariant(False))
|
||||
QtCore.QSettings().remove(
|
||||
self.parent.generalSettingsSection + u'/screen blank')
|
||||
if self.ThemeScreen.isChecked:
|
||||
self.ThemeScreen.setChecked(False)
|
||||
self.HideMenu.setDefaultAction(self.ThemeScreen)
|
||||
|
@ -31,6 +31,7 @@ from PyQt4 import QtCore, QtGui
|
||||
|
||||
from openlp.core.lib import translate, BackgroundType, BackgroundGradientType, \
|
||||
Receiver
|
||||
from openlp.core.ui import criticalErrorMessageBox
|
||||
from openlp.core.utils import get_images_filter
|
||||
from themewizard import Ui_ThemeWizard
|
||||
|
||||
@ -212,8 +213,8 @@ class ThemeForm(QtGui.QWizard, Ui_ThemeWizard):
|
||||
"""
|
||||
Updates the lines on a page on the wizard
|
||||
"""
|
||||
self.mainLineCountLabel.setText(unicode(translate('OpenLP.ThemeForm', \
|
||||
'(%d lines per slide)' % int(lines))))
|
||||
self.mainLineCountLabel.setText(unicode(translate('OpenLP.ThemeForm',
|
||||
'(%d lines per slide)')) % int(lines))
|
||||
|
||||
def resizeEvent(self, event=None):
|
||||
"""
|
||||
@ -291,9 +292,10 @@ class ThemeForm(QtGui.QWizard, Ui_ThemeWizard):
|
||||
self.updateThemeAllowed = True
|
||||
self.themeNameLabel.setVisible(not edit)
|
||||
self.themeNameEdit.setVisible(not edit)
|
||||
self.edit_mode = edit
|
||||
if edit:
|
||||
self.setWindowTitle(unicode(translate('OpenLP.ThemeWizard',
|
||||
'Edit Theme %s')) % self.theme.theme_name)
|
||||
'Edit Theme - %s')) % self.theme.theme_name)
|
||||
self.next()
|
||||
else:
|
||||
self.setWindowTitle(translate('OpenLP.ThemeWizard', 'New Theme'))
|
||||
@ -566,22 +568,17 @@ class ThemeForm(QtGui.QWizard, Ui_ThemeWizard):
|
||||
self.theme.theme_name = \
|
||||
unicode(self.field(u'name').toString())
|
||||
if not self.theme.theme_name:
|
||||
QtGui.QMessageBox.critical(self,
|
||||
criticalErrorMessageBox(
|
||||
translate('OpenLP.ThemeForm', 'Theme Name Missing'),
|
||||
translate('OpenLP.ThemeForm',
|
||||
'There is no name for this theme. Please enter one.'),
|
||||
(QtGui.QMessageBox.Ok),
|
||||
QtGui.QMessageBox.Ok)
|
||||
'There is no name for this theme. Please enter one.'))
|
||||
return
|
||||
if self.theme.theme_name == u'-1' or self.theme.theme_name == u'None':
|
||||
QtGui.QMessageBox.critical(self,
|
||||
criticalErrorMessageBox(
|
||||
translate('OpenLP.ThemeForm', 'Theme Name Invalid'),
|
||||
translate('OpenLP.ThemeForm',
|
||||
'Invalid theme name. Please enter one.'),
|
||||
(QtGui.QMessageBox.Ok),
|
||||
QtGui.QMessageBox.Ok)
|
||||
'Invalid theme name. Please enter one.'))
|
||||
return
|
||||
self.accepted = True
|
||||
saveFrom = None
|
||||
saveTo = None
|
||||
if self.theme.background_type == \
|
||||
@ -590,8 +587,12 @@ class ThemeForm(QtGui.QWizard, Ui_ThemeWizard):
|
||||
os.path.split(unicode(self.theme.background_filename))[1]
|
||||
saveTo = os.path.join(self.path, self.theme.theme_name, filename)
|
||||
saveFrom = self.theme.background_filename
|
||||
if self.thememanager.saveTheme(self.theme, saveFrom, saveTo):
|
||||
return QtGui.QDialog.accept(self)
|
||||
if not self.edit_mode and \
|
||||
not self.thememanager.checkIfThemeExists(self.theme.theme_name):
|
||||
return
|
||||
self.accepted = True
|
||||
self.thememanager.saveTheme(self.theme, saveFrom, saveTo)
|
||||
return QtGui.QDialog.accept(self)
|
||||
|
||||
def _colorButton(self, field):
|
||||
"""
|
||||
|
@ -32,12 +32,13 @@ import logging
|
||||
from xml.etree.ElementTree import ElementTree, XML
|
||||
from PyQt4 import QtCore, QtGui
|
||||
|
||||
from openlp.core.ui import FileRenameForm, ThemeForm
|
||||
from openlp.core.ui import criticalErrorMessageBox, FileRenameForm, ThemeForm
|
||||
from openlp.core.theme import Theme
|
||||
from openlp.core.lib import OpenLPToolbar, ThemeXML, get_text_file_string, \
|
||||
build_icon, Receiver, SettingsManager, translate, check_item_selected, \
|
||||
BackgroundType, BackgroundGradientType
|
||||
from openlp.core.utils import AppLocation, get_filesystem_encoding
|
||||
BackgroundType, BackgroundGradientType, check_directory_exists
|
||||
from openlp.core.utils import AppLocation, delete_file, file_is_unicode, \
|
||||
get_filesystem_encoding
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
@ -45,13 +46,14 @@ class ThemeManager(QtGui.QWidget):
|
||||
"""
|
||||
Manages the orders of Theme.
|
||||
"""
|
||||
def __init__(self, parent):
|
||||
def __init__(self, mainwindow, parent=None):
|
||||
QtGui.QWidget.__init__(self, parent)
|
||||
self.parent = parent
|
||||
self.mainwindow = mainwindow
|
||||
self.settingsSection = u'themes'
|
||||
self.themeForm = ThemeForm(self)
|
||||
self.fileRenameForm = FileRenameForm(self)
|
||||
self.serviceComboBox = self.parent.ServiceManagerContents.themeComboBox
|
||||
self.serviceComboBox = \
|
||||
self.mainwindow.ServiceManagerContents.themeComboBox
|
||||
# start with the layout
|
||||
self.layout = QtGui.QVBoxLayout(self)
|
||||
self.layout.setSpacing(0)
|
||||
@ -68,7 +70,7 @@ class ThemeManager(QtGui.QWidget):
|
||||
u':/themes/theme_edit.png',
|
||||
translate('OpenLP.ThemeManager', 'Edit a theme.'),
|
||||
self.onEditTheme)
|
||||
self.toolbar.addToolbarButton(
|
||||
self.deleteToolbarAction = self.toolbar.addToolbarButton(
|
||||
translate('OpenLP.ThemeManager', 'Delete Theme'),
|
||||
u':/general/general_delete.png',
|
||||
translate('OpenLP.ThemeManager', 'Delete a theme.'),
|
||||
@ -119,27 +121,53 @@ class ThemeManager(QtGui.QWidget):
|
||||
self.exportAction = self.menu.addAction(
|
||||
translate('OpenLP.ThemeManager', '&Export Theme'))
|
||||
self.exportAction.setIcon(build_icon(u':/general/general_export.png'))
|
||||
#Signals
|
||||
# Signals
|
||||
QtCore.QObject.connect(self.themeListWidget,
|
||||
QtCore.SIGNAL(u'doubleClicked(QModelIndex)'),
|
||||
self.changeGlobalFromScreen)
|
||||
QtCore.QObject.connect(self.themeListWidget,
|
||||
QtCore.SIGNAL(u'itemClicked(QListWidgetItem *)'),
|
||||
self.checkListState)
|
||||
QtCore.QObject.connect(Receiver.get_receiver(),
|
||||
QtCore.SIGNAL(u'theme_update_global'), self.changeGlobalFromTab)
|
||||
#Variables
|
||||
QtCore.QObject.connect(Receiver.get_receiver(),
|
||||
QtCore.SIGNAL(u'config_updated'), self.configUpdated)
|
||||
# Variables
|
||||
self.themelist = []
|
||||
self.path = AppLocation.get_section_data_path(self.settingsSection)
|
||||
self.checkThemesExists(self.path)
|
||||
check_directory_exists(self.path)
|
||||
self.thumbPath = os.path.join(self.path, u'thumbnails')
|
||||
self.checkThemesExists(self.thumbPath)
|
||||
check_directory_exists(self.thumbPath)
|
||||
self.themeForm.path = self.path
|
||||
self.oldBackgroundImage = None
|
||||
self.editingDefault = False
|
||||
# Last little bits of setting up
|
||||
self.configUpdated()
|
||||
|
||||
def configUpdated(self, firstTime=False):
|
||||
"""
|
||||
Triggered when Config dialog is updated.
|
||||
"""
|
||||
self.global_theme = unicode(QtCore.QSettings().value(
|
||||
self.settingsSection + u'/global theme',
|
||||
QtCore.QVariant(u'')).toString())
|
||||
|
||||
def checkListState(self, item):
|
||||
"""
|
||||
If Default theme selected remove delete button.
|
||||
"""
|
||||
realThemeName = unicode(item.data(QtCore.Qt.UserRole).toString())
|
||||
themeName = unicode(item.text())
|
||||
# If default theme restrict actions
|
||||
if realThemeName == themeName:
|
||||
self.deleteToolbarAction.setVisible(True)
|
||||
else:
|
||||
self.deleteToolbarAction.setVisible(False)
|
||||
|
||||
def contextMenu(self, point):
|
||||
"""
|
||||
Build the Right Click Context menu and set state depending on
|
||||
the type of theme.
|
||||
"""
|
||||
item = self.themeListWidget.itemAt(point)
|
||||
if item is None:
|
||||
return
|
||||
@ -220,7 +248,6 @@ class ThemeManager(QtGui.QWidget):
|
||||
editing form for the user to make their customisations.
|
||||
"""
|
||||
theme = ThemeXML()
|
||||
self.saveThemeName = u''
|
||||
self.themeForm.theme = theme
|
||||
self.themeForm.exec_()
|
||||
|
||||
@ -236,12 +263,15 @@ class ThemeManager(QtGui.QWidget):
|
||||
item = self.themeListWidget.currentItem()
|
||||
oldThemeName = unicode(item.data(QtCore.Qt.UserRole).toString())
|
||||
self.fileRenameForm.fileNameEdit.setText(oldThemeName)
|
||||
self.saveThemeName = oldThemeName
|
||||
if self.fileRenameForm.exec_():
|
||||
newThemeName = unicode(self.fileRenameForm.fileNameEdit.text())
|
||||
oldThemeData = self.getThemeData(oldThemeName)
|
||||
self.deleteTheme(oldThemeName)
|
||||
self.cloneThemeData(oldThemeData, newThemeName)
|
||||
newThemeName = unicode(self.fileRenameForm.fileNameEdit.text())
|
||||
if self.checkIfThemeExists(newThemeName):
|
||||
oldThemeData = self.getThemeData(oldThemeName)
|
||||
self.deleteTheme(oldThemeName)
|
||||
self.cloneThemeData(oldThemeData, newThemeName)
|
||||
for plugin in self.mainwindow.pluginManager.plugins:
|
||||
if plugin.usesTheme(oldThemeName):
|
||||
plugin.renameTheme(oldThemeName, newThemeName)
|
||||
|
||||
def onCopyTheme(self):
|
||||
"""
|
||||
@ -250,12 +280,12 @@ class ThemeManager(QtGui.QWidget):
|
||||
item = self.themeListWidget.currentItem()
|
||||
oldThemeName = unicode(item.data(QtCore.Qt.UserRole).toString())
|
||||
self.fileRenameForm.fileNameEdit.setText(oldThemeName)
|
||||
self.saveThemeName = u''
|
||||
if self.fileRenameForm.exec_(True):
|
||||
newThemeName = unicode(self.fileRenameForm.fileNameEdit.text())
|
||||
themeData = self.getThemeData(oldThemeName)
|
||||
self.cloneThemeData(themeData, newThemeName)
|
||||
self.loadThemes()
|
||||
newThemeName = unicode(self.fileRenameForm.fileNameEdit.text())
|
||||
if self.checkIfThemeExists(newThemeName):
|
||||
themeData = self.getThemeData(oldThemeName)
|
||||
self.cloneThemeData(themeData, newThemeName)
|
||||
self.loadThemes()
|
||||
|
||||
def cloneThemeData(self, themeData, newThemeName):
|
||||
"""
|
||||
@ -281,14 +311,10 @@ class ThemeManager(QtGui.QWidget):
|
||||
'You must select a theme to edit.')):
|
||||
item = self.themeListWidget.currentItem()
|
||||
themeName = unicode(item.text())
|
||||
if themeName != unicode(item.data(QtCore.Qt.UserRole).toString()):
|
||||
self.editingDefault = True
|
||||
theme = self.getThemeData(
|
||||
unicode(item.data(QtCore.Qt.UserRole).toString()))
|
||||
if theme.background_type == u'image':
|
||||
self.oldBackgroundImage = theme.background_filename
|
||||
self.saveThemeName = unicode(
|
||||
item.data(QtCore.Qt.UserRole).toString())
|
||||
self.themeForm.theme = theme
|
||||
self.themeForm.exec_(True)
|
||||
|
||||
@ -315,9 +341,9 @@ class ThemeManager(QtGui.QWidget):
|
||||
"""
|
||||
self.themelist.remove(theme)
|
||||
thumb = theme + u'.png'
|
||||
delete_file(os.path.join(self.path, thumb))
|
||||
delete_file(os.path.join(self.thumbPath, thumb))
|
||||
try:
|
||||
os.remove(os.path.join(self.path, thumb))
|
||||
os.remove(os.path.join(self.thumbPath, thumb))
|
||||
encoding = get_filesystem_encoding()
|
||||
shutil.rmtree(os.path.join(self.path, theme).encode(encoding))
|
||||
except OSError:
|
||||
@ -333,9 +359,7 @@ class ThemeManager(QtGui.QWidget):
|
||||
"""
|
||||
item = self.themeListWidget.currentItem()
|
||||
if item is None:
|
||||
QtGui.QMessageBox.critical(self,
|
||||
translate('OpenLP.ThemeManager', 'Error'),
|
||||
translate('OpenLP.ThemeManager',
|
||||
criticalErrorMessageBox(message=translate('OpenLP.ThemeManager',
|
||||
'You have not selected a theme.'))
|
||||
return
|
||||
theme = unicode(item.data(QtCore.Qt.UserRole).toString())
|
||||
@ -362,10 +386,10 @@ class ThemeManager(QtGui.QWidget):
|
||||
'Your theme has been successfully exported.'))
|
||||
except (IOError, OSError):
|
||||
log.exception(u'Export Theme Failed')
|
||||
QtGui.QMessageBox.critical(self,
|
||||
criticalErrorMessageBox(
|
||||
translate('OpenLP.ThemeManager', 'Theme Export Failed'),
|
||||
translate('OpenLP.ThemeManager',
|
||||
'Your theme could not be exported due to an error.'))
|
||||
'Your theme could not be exported due to an error.'))
|
||||
finally:
|
||||
if zip:
|
||||
zip.close()
|
||||
@ -379,7 +403,8 @@ class ThemeManager(QtGui.QWidget):
|
||||
files = QtGui.QFileDialog.getOpenFileNames(self,
|
||||
translate('OpenLP.ThemeManager', 'Select Theme Import File'),
|
||||
SettingsManager.get_last_dir(self.settingsSection),
|
||||
translate('OpenLP.ThemeManager', 'Theme (*.*)'))
|
||||
translate('OpenLP.ThemeManager', 'Theme v1 (*.theme);;'
|
||||
'Theme v2 (*.otz);;All Files (*.*)'))
|
||||
log.info(u'New Themes %s', unicode(files))
|
||||
if files:
|
||||
for file in files:
|
||||
@ -449,20 +474,10 @@ class ThemeManager(QtGui.QWidget):
|
||||
unicode(themeName) + u'.xml')
|
||||
xml = get_text_file_string(xmlFile)
|
||||
if not xml:
|
||||
return self.baseTheme()
|
||||
log.debug("No theme data - using default theme")
|
||||
return ThemeXML()
|
||||
else:
|
||||
return self.createThemeFromXml(xml, self.path)
|
||||
|
||||
def checkThemesExists(self, dir):
|
||||
"""
|
||||
Check a theme directory exists and if not create it
|
||||
|
||||
``dir``
|
||||
Theme directory to make sure exists
|
||||
"""
|
||||
log.debug(u'check themes')
|
||||
if not os.path.exists(dir):
|
||||
os.mkdir(dir)
|
||||
return self._createThemeFromXml(xml, self.path)
|
||||
|
||||
def unzipTheme(self, filename, dir):
|
||||
"""
|
||||
@ -479,23 +494,18 @@ class ThemeManager(QtGui.QWidget):
|
||||
filexml = None
|
||||
themename = None
|
||||
for file in zip.namelist():
|
||||
try:
|
||||
ucsfile = file.decode(u'utf-8')
|
||||
except UnicodeDecodeError:
|
||||
QtGui.QMessageBox.critical(
|
||||
self, translate('OpenLP.ThemeManager', 'Error'),
|
||||
translate('OpenLP.ThemeManager',
|
||||
'File is not a valid theme.\n'
|
||||
'The content encoding is not UTF-8.'))
|
||||
log.exception(u'Filename "%s" is not valid UTF-8' %
|
||||
file.decode(u'utf-8', u'replace'))
|
||||
ucsfile = file_is_unicode(file)
|
||||
if not ucsfile:
|
||||
criticalErrorMessageBox(
|
||||
message=translate('OpenLP.ThemeManager',
|
||||
'File is not a valid theme.\n'
|
||||
'The content encoding is not UTF-8.'))
|
||||
continue
|
||||
osfile = unicode(QtCore.QDir.toNativeSeparators(ucsfile))
|
||||
theme_dir = None
|
||||
if osfile.endswith(os.path.sep):
|
||||
theme_dir = os.path.join(dir, osfile)
|
||||
if not os.path.exists(theme_dir):
|
||||
os.mkdir(os.path.join(dir, osfile))
|
||||
check_directory_exists(theme_dir)
|
||||
else:
|
||||
fullpath = os.path.join(dir, osfile)
|
||||
names = osfile.split(os.path.sep)
|
||||
@ -505,36 +515,33 @@ class ThemeManager(QtGui.QWidget):
|
||||
themename = names[0]
|
||||
if theme_dir is None:
|
||||
theme_dir = os.path.join(dir, names[0])
|
||||
if not os.path.exists(theme_dir):
|
||||
os.mkdir(os.path.join(dir, names[0]))
|
||||
check_directory_exists(theme_dir)
|
||||
if os.path.splitext(ucsfile)[1].lower() in [u'.xml']:
|
||||
xml_data = zip.read(file)
|
||||
try:
|
||||
xml_data = xml_data.decode(u'utf-8')
|
||||
except UnicodeDecodeError:
|
||||
log.exception(u'Theme XML is not UTF-8 '
|
||||
u'encoded.')
|
||||
xml_data = file_is_unicode(xml_data)
|
||||
if not xml_data:
|
||||
break
|
||||
filexml = self.checkVersionAndConvert(xml_data)
|
||||
filexml = self._checkVersionAndConvert(xml_data)
|
||||
outfile = open(fullpath, u'w')
|
||||
outfile.write(filexml.encode(u'utf-8'))
|
||||
else:
|
||||
outfile = open(fullpath, u'wb')
|
||||
outfile.write(zip.read(file))
|
||||
if filexml:
|
||||
theme = self.createThemeFromXml(filexml, self.path)
|
||||
theme = self._createThemeFromXml(filexml, self.path)
|
||||
self.generateAndSaveImage(dir, themename, theme)
|
||||
else:
|
||||
QtGui.QMessageBox.critical(self,
|
||||
translate('OpenLP.ThemeManager', 'Error'),
|
||||
criticalErrorMessageBox(
|
||||
translate('OpenLP.ThemeManager', 'Validation Error'),
|
||||
translate('OpenLP.ThemeManager',
|
||||
'File is not a valid theme.'))
|
||||
'File is not a valid theme.'))
|
||||
log.exception(u'Theme file does not contain XML data %s' %
|
||||
filename)
|
||||
except (IOError, NameError):
|
||||
QtGui.QMessageBox.critical(self,
|
||||
translate('OpenLP.ThemeManager', 'Error'),
|
||||
translate('OpenLP.ThemeManager', 'File is not a valid theme.'))
|
||||
criticalErrorMessageBox(
|
||||
translate('OpenLP.ThemeManager', 'Validation Error'),
|
||||
translate('OpenLP.ThemeManager',
|
||||
'File is not a valid theme.'))
|
||||
log.exception(u'Importing theme from zip failed %s' % filename)
|
||||
finally:
|
||||
if zip:
|
||||
@ -542,7 +549,97 @@ class ThemeManager(QtGui.QWidget):
|
||||
if outfile:
|
||||
outfile.close()
|
||||
|
||||
def checkVersionAndConvert(self, xml_data):
|
||||
def checkIfThemeExists(self, themeName):
|
||||
"""
|
||||
Check if theme already exists and displays error message
|
||||
|
||||
``themeName``
|
||||
Name of the Theme to test
|
||||
"""
|
||||
theme_dir = os.path.join(self.path, themeName)
|
||||
if os.path.exists(theme_dir):
|
||||
criticalErrorMessageBox(
|
||||
translate('OpenLP.ThemeManager', 'Validation Error'),
|
||||
translate('OpenLP.ThemeManager',
|
||||
'A theme with this name already exists.'))
|
||||
return False
|
||||
return True
|
||||
|
||||
def saveTheme(self, theme, imageFrom, imageTo):
|
||||
"""
|
||||
Called by thememaintenance Dialog to save the theme
|
||||
and to trigger the reload of the theme list
|
||||
"""
|
||||
name = theme.theme_name
|
||||
theme_pretty_xml = theme.extract_formatted_xml()
|
||||
log.debug(u'saveTheme %s %s', name, theme_pretty_xml)
|
||||
theme_dir = os.path.join(self.path, name)
|
||||
check_directory_exists(theme_dir)
|
||||
theme_file = os.path.join(theme_dir, name + u'.xml')
|
||||
if imageTo and self.oldBackgroundImage and \
|
||||
imageTo != self.oldBackgroundImage:
|
||||
delete_file(self.oldBackgroundImage)
|
||||
outfile = None
|
||||
try:
|
||||
outfile = open(theme_file, u'w')
|
||||
outfile.write(theme_pretty_xml)
|
||||
except IOError:
|
||||
log.exception(u'Saving theme to file failed')
|
||||
finally:
|
||||
if outfile:
|
||||
outfile.close()
|
||||
if imageFrom and imageFrom != imageTo:
|
||||
try:
|
||||
encoding = get_filesystem_encoding()
|
||||
shutil.copyfile(
|
||||
unicode(imageFrom).encode(encoding),
|
||||
unicode(imageTo).encode(encoding))
|
||||
except IOError:
|
||||
log.exception(u'Failed to save theme image')
|
||||
self.generateAndSaveImage(self.path, name, theme)
|
||||
self.loadThemes()
|
||||
self.pushThemes()
|
||||
|
||||
def generateAndSaveImage(self, dir, name, theme):
|
||||
log.debug(u'generateAndSaveImage %s %s', dir, name)
|
||||
theme_xml = theme.extract_xml()
|
||||
frame = self.generateImage(theme)
|
||||
samplepathname = os.path.join(self.path, name + u'.png')
|
||||
if os.path.exists(samplepathname):
|
||||
os.unlink(samplepathname)
|
||||
frame.save(samplepathname, u'png')
|
||||
thumb = os.path.join(self.thumbPath, u'%s.png' % name)
|
||||
icon = build_icon(frame)
|
||||
pixmap = icon.pixmap(QtCore.QSize(88, 50))
|
||||
pixmap.save(thumb, u'png')
|
||||
log.debug(u'Theme image written to %s', samplepathname)
|
||||
|
||||
def generateImage(self, themeData, forcePage=False):
|
||||
"""
|
||||
Call the RenderManager to build a Sample Image
|
||||
|
||||
``themeData``
|
||||
The theme to generated a preview for.
|
||||
|
||||
``forcePage``
|
||||
Flag to tell message lines per page need to be generated.
|
||||
"""
|
||||
log.debug(u'generateImage \n%s ', themeData)
|
||||
return self.mainwindow.renderManager.generate_preview(
|
||||
themeData, forcePage)
|
||||
|
||||
def getPreviewImage(self, theme):
|
||||
"""
|
||||
Return an image representing the look of the theme
|
||||
|
||||
``theme``
|
||||
The theme to return the image for
|
||||
"""
|
||||
log.debug(u'getPreviewImage %s ', theme)
|
||||
image = os.path.join(self.path, theme + u'.png')
|
||||
return image
|
||||
|
||||
def _checkVersionAndConvert(self, xml_data):
|
||||
"""
|
||||
Check if a theme is from OpenLP version 1
|
||||
|
||||
@ -556,9 +653,58 @@ class ThemeManager(QtGui.QWidget):
|
||||
if tree.find(u'BackgroundType') is None:
|
||||
return xml_data
|
||||
else:
|
||||
return self.migrateVersion122(xml_data)
|
||||
return self._migrateVersion122(xml_data)
|
||||
|
||||
def migrateVersion122(self, xml_data):
|
||||
def _createThemeFromXml(self, themeXml, path):
|
||||
"""
|
||||
Return a theme object using information parsed from XML
|
||||
|
||||
``themeXml``
|
||||
The XML data to load into the theme
|
||||
"""
|
||||
theme = ThemeXML()
|
||||
theme.parse(themeXml)
|
||||
theme.extend_image_filename(path)
|
||||
return theme
|
||||
|
||||
def _validate_theme_action(self, select_text, confirm_title, confirm_text,
|
||||
testPlugin=True):
|
||||
"""
|
||||
Check to see if theme has been selected and the destructive action
|
||||
is allowed.
|
||||
"""
|
||||
self.global_theme = unicode(QtCore.QSettings().value(
|
||||
self.settingsSection + u'/global theme',
|
||||
QtCore.QVariant(u'')).toString())
|
||||
if check_item_selected(self.themeListWidget, select_text):
|
||||
item = self.themeListWidget.currentItem()
|
||||
theme = unicode(item.text())
|
||||
# confirm deletion
|
||||
answer = QtGui.QMessageBox.question(self, confirm_title,
|
||||
confirm_text % theme, QtGui.QMessageBox.StandardButtons(
|
||||
QtGui.QMessageBox.Yes | QtGui.QMessageBox.No),
|
||||
QtGui.QMessageBox.No)
|
||||
if answer == QtGui.QMessageBox.No:
|
||||
return False
|
||||
# should be the same unless default
|
||||
if theme != unicode(item.data(QtCore.Qt.UserRole).toString()):
|
||||
criticalErrorMessageBox(
|
||||
message=translate('OpenLP.ThemeManager',
|
||||
'You are unable to delete the default theme.'))
|
||||
return False
|
||||
# check for use in the system else where.
|
||||
if testPlugin:
|
||||
for plugin in self.mainwindow.pluginManager.plugins:
|
||||
if plugin.usesTheme(theme):
|
||||
criticalErrorMessageBox(translate('OpenLP.ThemeManager',
|
||||
'Validation Error'),
|
||||
unicode(translate('OpenLP.ThemeManager',
|
||||
'Theme %s is used in the %s plugin.')) % \
|
||||
(theme, plugin.name))
|
||||
return False
|
||||
return True
|
||||
|
||||
def _migrateVersion122(self, xml_data):
|
||||
"""
|
||||
Convert the xml data from version 1 format to the current format.
|
||||
|
||||
@ -615,191 +761,3 @@ class ThemeManager(QtGui.QWidget):
|
||||
newtheme.display_horizontal_align = theme.HorizontalAlign
|
||||
newtheme.display_vertical_align = vAlignCorrection
|
||||
return newtheme.extract_xml()
|
||||
|
||||
def saveTheme(self, theme, imageFrom, imageTo):
|
||||
"""
|
||||
Called by thememaintenance Dialog to save the theme
|
||||
and to trigger the reload of the theme list
|
||||
"""
|
||||
name = theme.theme_name
|
||||
theme_pretty_xml = theme.extract_formatted_xml()
|
||||
log.debug(u'saveTheme %s %s', name, theme_pretty_xml)
|
||||
theme_dir = os.path.join(self.path, name)
|
||||
if not os.path.exists(theme_dir):
|
||||
os.mkdir(os.path.join(self.path, name))
|
||||
theme_file = os.path.join(theme_dir, name + u'.xml')
|
||||
log.debug(theme_file)
|
||||
editedServiceTheme = False
|
||||
result = QtGui.QMessageBox.Yes
|
||||
if self.saveThemeName != name:
|
||||
if os.path.exists(theme_file):
|
||||
result = QtGui.QMessageBox.question(self,
|
||||
translate('OpenLP.ThemeManager', 'Theme Exists'),
|
||||
translate('OpenLP.ThemeManager',
|
||||
'A theme with this name already '
|
||||
'exists. Would you like to overwrite it?'),
|
||||
(QtGui.QMessageBox.Yes | QtGui.QMessageBox.No),
|
||||
QtGui.QMessageBox.No)
|
||||
if self.saveThemeName != u'':
|
||||
for plugin in self.parent.pluginManager.plugins:
|
||||
if plugin.usesTheme(self.saveThemeName):
|
||||
plugin.renameTheme(self.saveThemeName, name)
|
||||
if unicode(self.serviceComboBox.currentText()) == name:
|
||||
editedServiceTheme = True
|
||||
if result == QtGui.QMessageBox.Yes:
|
||||
# Save the theme, overwriting the existing theme if necessary.
|
||||
if imageTo and self.oldBackgroundImage and \
|
||||
imageTo != self.oldBackgroundImage:
|
||||
try:
|
||||
os.remove(self.oldBackgroundImage)
|
||||
except OSError:
|
||||
log.exception(u'Unable to remove old theme background')
|
||||
outfile = None
|
||||
try:
|
||||
outfile = open(theme_file, u'w')
|
||||
outfile.write(theme_pretty_xml)
|
||||
except IOError:
|
||||
log.exception(u'Saving theme to file failed')
|
||||
finally:
|
||||
if outfile:
|
||||
outfile.close()
|
||||
if imageFrom and imageFrom != imageTo:
|
||||
try:
|
||||
encoding = get_filesystem_encoding()
|
||||
shutil.copyfile(
|
||||
unicode(imageFrom).encode(encoding),
|
||||
unicode(imageTo).encode(encoding))
|
||||
except IOError:
|
||||
log.exception(u'Failed to save theme image')
|
||||
self.generateAndSaveImage(self.path, name, theme)
|
||||
self.loadThemes()
|
||||
# Check if we need to set a new service theme
|
||||
if editedServiceTheme:
|
||||
newThemeIndex = self.serviceComboBox.findText(name)
|
||||
if newThemeIndex != -1:
|
||||
self.serviceComboBox.setCurrentIndex(newThemeIndex)
|
||||
if self.editingDefault:
|
||||
if self.saveThemeName != name:
|
||||
newThemeItem = self.themeListWidget.findItems(name,
|
||||
QtCore.Qt.MatchExactly)[0]
|
||||
newThemeIndex = self.themeListWidget.indexFromItem(
|
||||
newThemeItem).row()
|
||||
self.global_theme = unicode(
|
||||
self.themeListWidget.item(newThemeIndex).text())
|
||||
newName = unicode(translate('OpenLP.ThemeManager',
|
||||
'%s (default)')) % self.global_theme
|
||||
self.themeListWidget.item(newThemeIndex).setText(newName)
|
||||
QtCore.QSettings().setValue(
|
||||
self.settingsSection + u'/global theme',
|
||||
QtCore.QVariant(self.global_theme))
|
||||
Receiver.send_message(u'theme_update_global',
|
||||
self.global_theme)
|
||||
self.editingDefault = False
|
||||
self.pushThemes()
|
||||
return True
|
||||
else:
|
||||
# Don't close the dialog - allow the user to change the name of
|
||||
# the theme or to cancel the theme dialog completely.
|
||||
return False
|
||||
|
||||
def generateAndSaveImage(self, dir, name, theme):
|
||||
log.debug(u'generateAndSaveImage %s %s', dir, name)
|
||||
theme_xml = theme.extract_xml()
|
||||
frame = self.generateImage(theme)
|
||||
samplepathname = os.path.join(self.path, name + u'.png')
|
||||
if os.path.exists(samplepathname):
|
||||
os.unlink(samplepathname)
|
||||
frame.save(samplepathname, u'png')
|
||||
thumb = os.path.join(self.thumbPath, u'%s.png' % name)
|
||||
icon = build_icon(frame)
|
||||
pixmap = icon.pixmap(QtCore.QSize(88, 50))
|
||||
pixmap.save(thumb, u'png')
|
||||
log.debug(u'Theme image written to %s', samplepathname)
|
||||
|
||||
def generateImage(self, themeData, forcePage=False):
|
||||
"""
|
||||
Call the RenderManager to build a Sample Image
|
||||
|
||||
``themeData``
|
||||
The theme to generated a preview for.
|
||||
|
||||
``forcePage``
|
||||
Flag to tell message lines per page need to be generated.
|
||||
"""
|
||||
log.debug(u'generateImage \n%s ', themeData)
|
||||
return self.parent.renderManager.generate_preview(themeData, forcePage)
|
||||
|
||||
def getPreviewImage(self, theme):
|
||||
"""
|
||||
Return an image representing the look of the theme
|
||||
|
||||
``theme``
|
||||
The theme to return the image for
|
||||
"""
|
||||
log.debug(u'getPreviewImage %s ', theme)
|
||||
image = os.path.join(self.path, theme + u'.png')
|
||||
return image
|
||||
|
||||
def baseTheme(self):
|
||||
"""
|
||||
Provide a base theme with sensible defaults
|
||||
"""
|
||||
log.debug(u'base theme created')
|
||||
newtheme = ThemeXML()
|
||||
return newtheme
|
||||
|
||||
def createThemeFromXml(self, themeXml, path):
|
||||
"""
|
||||
Return a theme object using information parsed from XML
|
||||
|
||||
``themeXml``
|
||||
The XML data to load into the theme
|
||||
"""
|
||||
theme = ThemeXML()
|
||||
theme.parse(themeXml)
|
||||
theme.extend_image_filename(path)
|
||||
return theme
|
||||
|
||||
def _validate_theme_action(self, select_text, confirm_title, confirm_text,
|
||||
testPlugin=True):
|
||||
"""
|
||||
Check to see if theme has been selected and the destructive action
|
||||
is allowed.
|
||||
"""
|
||||
self.global_theme = unicode(QtCore.QSettings().value(
|
||||
self.settingsSection + u'/global theme',
|
||||
QtCore.QVariant(u'')).toString())
|
||||
if check_item_selected(self.themeListWidget, select_text):
|
||||
item = self.themeListWidget.currentItem()
|
||||
theme = unicode(item.text())
|
||||
# confirm deletion
|
||||
answer = QtGui.QMessageBox.question(self, confirm_title,
|
||||
confirm_text % theme, QtGui.QMessageBox.StandardButtons(
|
||||
QtGui.QMessageBox.Yes | QtGui.QMessageBox.No),
|
||||
QtGui.QMessageBox.No)
|
||||
if answer == QtGui.QMessageBox.No:
|
||||
return False
|
||||
# should be the same unless default
|
||||
if theme != unicode(item.data(QtCore.Qt.UserRole).toString()):
|
||||
QtGui.QMessageBox.critical(self,
|
||||
translate('OpenLP.ThemeManager', 'Error'),
|
||||
translate('OpenLP.ThemeManager',
|
||||
'You are unable to delete the default theme.'))
|
||||
return False
|
||||
else:
|
||||
if testPlugin:
|
||||
for plugin in self.parent.pluginManager.plugins:
|
||||
if plugin.usesTheme(theme):
|
||||
QtGui.QMessageBox.critical(self,
|
||||
translate('OpenLP.ThemeManager', 'Error'),
|
||||
unicode(translate('OpenLP.ThemeManager',
|
||||
'Theme %s is used in the %s plugin.')) % \
|
||||
(theme, plugin.name))
|
||||
return False
|
||||
if unicode(self.serviceComboBox.currentText()) == theme:
|
||||
QtGui.QMessageBox.critical(self,
|
||||
translate('OpenLP.ThemeManager', 'Error'),
|
||||
unicode(translate('OpenLP.ThemeManager',
|
||||
'Theme %s is used by the service manager.')) % theme)
|
||||
return False
|
||||
return True
|
||||
|
@ -46,8 +46,8 @@ class ThemesTab(SettingsTab):
|
||||
self.DefaultComboBox = QtGui.QComboBox(self.GlobalGroupBox)
|
||||
self.DefaultComboBox.setSizeAdjustPolicy(
|
||||
QtGui.QComboBox.AdjustToMinimumContentsLength)
|
||||
self.DefaultComboBox.setSizePolicy(QtGui.QSizePolicy.Expanding,
|
||||
QtGui.QSizePolicy.Fixed)
|
||||
self.DefaultComboBox.setSizePolicy(
|
||||
QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Fixed)
|
||||
self.DefaultComboBox.setObjectName(u'DefaultComboBox')
|
||||
self.GlobalGroupBoxLayout.addWidget(self.DefaultComboBox)
|
||||
self.DefaultListView = QtGui.QLabel(self.GlobalGroupBox)
|
||||
|
@ -249,7 +249,8 @@ class Ui_ThemeWizard(object):
|
||||
self.footerSizeSpinBox.setMaximum(999)
|
||||
self.footerSizeSpinBox.setValue(10)
|
||||
self.footerSizeSpinBox.setObjectName(u'FooterSizeSpinBox')
|
||||
self.footerAreaLayout.addRow(self.footerSizeLabel, self.footerSizeSpinBox)
|
||||
self.footerAreaLayout.addRow(self.footerSizeLabel,
|
||||
self.footerSizeSpinBox)
|
||||
ThemeWizard.addPage(self.footerAreaPage)
|
||||
# Alignment Page
|
||||
self.alignmentPage = QtGui.QWizardPage()
|
||||
@ -317,9 +318,11 @@ class Ui_ThemeWizard(object):
|
||||
self.areaPositionLayout.addWidget(self.mainPositionGroupBox)
|
||||
self.footerPositionGroupBox = QtGui.QGroupBox(self.areaPositionPage)
|
||||
self.footerPositionGroupBox.setObjectName(u'FooterPositionGroupBox')
|
||||
self.footerPositionLayout = QtGui.QFormLayout(self.footerPositionGroupBox)
|
||||
self.footerPositionLayout = QtGui.QFormLayout(
|
||||
self.footerPositionGroupBox)
|
||||
self.footerPositionLayout.setObjectName(u'FooterPositionLayout')
|
||||
self.footerPositionCheckBox = QtGui.QCheckBox(self.footerPositionGroupBox)
|
||||
self.footerPositionCheckBox = QtGui.QCheckBox(
|
||||
self.footerPositionGroupBox)
|
||||
self.footerPositionCheckBox.setObjectName(u'FooterPositionCheckBox')
|
||||
self.footerPositionLayout.addRow(self.footerPositionCheckBox)
|
||||
self.footerXLabel = QtGui.QLabel(self.footerPositionGroupBox)
|
||||
@ -360,6 +363,8 @@ class Ui_ThemeWizard(object):
|
||||
self.themeNameLabel = QtGui.QLabel(self.previewPage)
|
||||
self.themeNameLabel.setObjectName(u'ThemeNameLabel')
|
||||
self.themeNameEdit = QtGui.QLineEdit(self.previewPage)
|
||||
self.themeNameEdit.setValidator(QtGui.QRegExpValidator(
|
||||
QtCore.QRegExp(r'[^/\\?*|<>\[\]":<>+%]+'), self))
|
||||
self.themeNameEdit.setObjectName(u'ThemeNameEdit')
|
||||
self.themeNameLayout.addRow(self.themeNameLabel, self.themeNameEdit)
|
||||
self.previewLayout.addLayout(self.themeNameLayout)
|
||||
@ -471,8 +476,6 @@ class Ui_ThemeWizard(object):
|
||||
self.mainColorLabel.setText(translate('OpenLP.ThemeWizard', 'Color:'))
|
||||
self.mainSizeLabel.setText(translate('OpenLP.ThemeWizard', 'Size:'))
|
||||
self.mainSizeSpinBox.setSuffix(translate('OpenLP.ThemeWizard', 'pt'))
|
||||
self.mainLineCountLabel.setText(
|
||||
translate('OpenLP.ThemeWizard', '(%d lines per slide)'))
|
||||
self.lineSpacingLabel.setText(
|
||||
translate('OpenLP.ThemeWizard', 'Line Spacing:'))
|
||||
self.lineSpacingSpinBox.setSuffix(translate('OpenLP.ThemeWizard', 'pt'))
|
||||
@ -564,17 +567,17 @@ class Ui_ThemeWizard(object):
|
||||
self.themeNameLabel.setText(
|
||||
translate('OpenLP.ThemeWizard', 'Theme name:'))
|
||||
# Align all QFormLayouts towards each other.
|
||||
width = max(self.backgroundLabel.minimumSizeHint().width(),
|
||||
self.colorLabel.minimumSizeHint().width())
|
||||
width = max(width, self.gradientStartLabel.minimumSizeHint().width())
|
||||
width = max(width, self.gradientEndLabel.minimumSizeHint().width())
|
||||
width = max(width, self.gradientTypeLabel.minimumSizeHint().width())
|
||||
width = max(width, self.imageLabel.minimumSizeHint().width())
|
||||
self.backgroundTypeSpacer.changeSize(width, 0, QtGui.QSizePolicy.Fixed,
|
||||
QtGui.QSizePolicy.Fixed)
|
||||
self.colorSpacer.changeSize(width, 0, QtGui.QSizePolicy.Fixed,
|
||||
QtGui.QSizePolicy.Fixed)
|
||||
self.gradientSpacer.changeSize(width, 0, QtGui.QSizePolicy.Fixed,
|
||||
QtGui.QSizePolicy.Fixed)
|
||||
self.imageSpacer.changeSize(width, 0, QtGui.QSizePolicy.Fixed,
|
||||
QtGui.QSizePolicy.Fixed)
|
||||
labelWidth = max(self.backgroundLabel.minimumSizeHint().width(),
|
||||
self.colorLabel.minimumSizeHint().width(),
|
||||
self.gradientStartLabel.minimumSizeHint().width(),
|
||||
self.gradientEndLabel.minimumSizeHint().width(),
|
||||
self.gradientTypeLabel.minimumSizeHint().width(),
|
||||
self.imageLabel.minimumSizeHint().width())
|
||||
self.backgroundTypeSpacer.changeSize(labelWidth, 0,
|
||||
QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Fixed)
|
||||
self.colorSpacer.changeSize(labelWidth, 0,
|
||||
QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Fixed)
|
||||
self.gradientSpacer.changeSize(labelWidth, 0,
|
||||
QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Fixed)
|
||||
self.imageSpacer.changeSize(labelWidth, 0,
|
||||
QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Fixed)
|
||||
|
171
openlp/core/ui/wizard.py
Normal file
171
openlp/core/ui/wizard.py
Normal file
@ -0,0 +1,171 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4
|
||||
|
||||
###############################################################################
|
||||
# OpenLP - Open Source Lyrics Projection #
|
||||
# --------------------------------------------------------------------------- #
|
||||
# Copyright (c) 2008-2011 Raoul Snyman #
|
||||
# Portions copyright (c) 2008-2011 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 #
|
||||
###############################################################################
|
||||
"""
|
||||
The :mod:``wizard`` module provides generic wizard tools for OpenLP.
|
||||
"""
|
||||
import logging
|
||||
|
||||
from PyQt4 import QtCore, QtGui
|
||||
|
||||
from openlp.core.lib import build_icon, Receiver
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
class OpenLPWizard(QtGui.QWizard):
|
||||
"""
|
||||
Generic OpenLP wizard to provide generic functionality and a unified look
|
||||
and feel.
|
||||
"""
|
||||
def __init__(self, parent, plugin, name, image):
|
||||
QtGui.QWizard.__init__(self, parent)
|
||||
self.setObjectName(name)
|
||||
self.openIcon = build_icon(u':/general/general_open.png')
|
||||
self.deleteIcon = build_icon(u':/general/general_delete.png')
|
||||
self.finishButton = self.button(QtGui.QWizard.FinishButton)
|
||||
self.cancelButton = self.button(QtGui.QWizard.CancelButton)
|
||||
self.setupUi(image)
|
||||
self.registerFields()
|
||||
self.plugin = plugin
|
||||
self.customInit()
|
||||
self.customSignals()
|
||||
QtCore.QObject.connect(self, QtCore.SIGNAL(u'currentIdChanged(int)'),
|
||||
self.onCurrentIdChanged)
|
||||
|
||||
def setupUi(self, image):
|
||||
"""
|
||||
Set up the wizard UI
|
||||
"""
|
||||
self.setModal(True)
|
||||
self.setWizardStyle(QtGui.QWizard.ModernStyle)
|
||||
self.setOptions(QtGui.QWizard.IndependentPages |
|
||||
QtGui.QWizard.NoBackButtonOnStartPage |
|
||||
QtGui.QWizard.NoBackButtonOnLastPage)
|
||||
self.addWelcomePage(image)
|
||||
self.addCustomPages()
|
||||
self.addProgressPage()
|
||||
self.retranslateUi()
|
||||
QtCore.QMetaObject.connectSlotsByName(self)
|
||||
|
||||
def addWelcomePage(self, image):
|
||||
"""
|
||||
Add the opening welcome page to the wizard.
|
||||
|
||||
``image``
|
||||
A splash image for the wizard
|
||||
"""
|
||||
self.welcomePage = QtGui.QWizardPage()
|
||||
self.welcomePage.setPixmap(QtGui.QWizard.WatermarkPixmap,
|
||||
QtGui.QPixmap(image))
|
||||
self.welcomePage.setObjectName(u'WelcomePage')
|
||||
self.welcomeLayout = QtGui.QVBoxLayout(self.welcomePage)
|
||||
self.welcomeLayout.setObjectName(u'WelcomeLayout')
|
||||
self.titleLabel = QtGui.QLabel(self.welcomePage)
|
||||
self.titleLabel.setObjectName(u'TitleLabel')
|
||||
self.welcomeLayout.addWidget(self.titleLabel)
|
||||
self.welcomeLayout.addSpacing(40)
|
||||
self.informationLabel = QtGui.QLabel(self.welcomePage)
|
||||
self.informationLabel.setWordWrap(True)
|
||||
self.informationLabel.setObjectName(u'InformationLabel')
|
||||
self.welcomeLayout.addWidget(self.informationLabel)
|
||||
self.welcomeLayout.addStretch()
|
||||
self.addPage(self.welcomePage)
|
||||
|
||||
def addProgressPage(self):
|
||||
"""
|
||||
Add the progress page for the wizard. This page informs the user how
|
||||
the wizard is progressing with its task.
|
||||
"""
|
||||
self.progressPage = QtGui.QWizardPage()
|
||||
self.progressPage.setObjectName(u'progressPage')
|
||||
self.progressLayout = QtGui.QVBoxLayout(self.progressPage)
|
||||
self.progressLayout.setMargin(48)
|
||||
self.progressLayout.setObjectName(u'progressLayout')
|
||||
self.progressLabel = QtGui.QLabel(self.progressPage)
|
||||
self.progressLabel.setObjectName(u'progressLabel')
|
||||
self.progressLayout.addWidget(self.progressLabel)
|
||||
self.progressBar = QtGui.QProgressBar(self.progressPage)
|
||||
self.progressBar.setObjectName(u'progressBar')
|
||||
self.progressLayout.addWidget(self.progressBar)
|
||||
self.addPage(self.progressPage)
|
||||
|
||||
def exec_(self):
|
||||
"""
|
||||
Run the wizard.
|
||||
"""
|
||||
self.setDefaults()
|
||||
return QtGui.QWizard.exec_(self)
|
||||
|
||||
def reject(self):
|
||||
"""
|
||||
Stop the wizard on cancel button, close button or ESC key.
|
||||
"""
|
||||
log.debug(u'Wizard cancelled by user.')
|
||||
if self.currentPage() == self.progressPage:
|
||||
Receiver.send_message(u'openlp_stop_wizard')
|
||||
self.done(QtGui.QDialog.Rejected)
|
||||
|
||||
def onCurrentIdChanged(self, pageId):
|
||||
"""
|
||||
Perform necessary functions depending on which wizard page is active.
|
||||
"""
|
||||
if self.page(pageId) == self.progressPage:
|
||||
self.preWizard()
|
||||
self.performWizard()
|
||||
self.postWizard()
|
||||
|
||||
def incrementProgressBar(self, status_text, increment=1):
|
||||
"""
|
||||
Update the wizard progress page.
|
||||
|
||||
``status_text``
|
||||
Current status information to display.
|
||||
|
||||
``increment``
|
||||
The value to increment the progress bar by.
|
||||
"""
|
||||
log.debug(u'IncrementBar %s', status_text)
|
||||
self.progressLabel.setText(status_text)
|
||||
if increment > 0:
|
||||
self.progressBar.setValue(self.progressBar.value() + increment)
|
||||
Receiver.send_message(u'openlp_process_events')
|
||||
|
||||
def preWizard(self):
|
||||
"""
|
||||
Prepare the UI for the import.
|
||||
"""
|
||||
self.finishButton.setVisible(False)
|
||||
self.progressBar.setMinimum(0)
|
||||
self.progressBar.setMaximum(1188)
|
||||
self.progressBar.setValue(0)
|
||||
|
||||
def postWizard(self):
|
||||
"""
|
||||
Clean up the UI after the import has finished.
|
||||
"""
|
||||
self.progressBar.setValue(self.progressBar.maximum())
|
||||
self.finishButton.setVisible(True)
|
||||
self.cancelButton.setVisible(False)
|
||||
Receiver.send_message(u'openlp_process_events')
|
@ -207,7 +207,7 @@ def check_latest_version(current_version):
|
||||
The current version of OpenLP.
|
||||
"""
|
||||
version_string = current_version[u'full']
|
||||
#set to prod in the distribution config file.
|
||||
# set to prod in the distribution config file.
|
||||
settings = QtCore.QSettings()
|
||||
settings.beginGroup(u'general')
|
||||
last_test = unicode(settings.value(u'last version test',
|
||||
@ -282,8 +282,100 @@ def split_filename(path):
|
||||
else:
|
||||
return os.path.split(path)
|
||||
|
||||
def delete_file(file_path_name):
|
||||
"""
|
||||
Deletes a file from the system.
|
||||
|
||||
``file_path_name``
|
||||
The file, including path, to delete.
|
||||
"""
|
||||
if not file_path_name:
|
||||
return False
|
||||
try:
|
||||
if os.path.exists(file_path_name):
|
||||
os.remove(file_path_name)
|
||||
return True
|
||||
except (IOError, OSError):
|
||||
log.exception("Unable to delete file %s" % file_path_name)
|
||||
return False
|
||||
|
||||
def get_web_page(url, header=None, update_openlp=False):
|
||||
"""
|
||||
Attempts to download the webpage at url and returns that page or None.
|
||||
|
||||
``url``
|
||||
The URL to be downloaded.
|
||||
|
||||
``header``
|
||||
An optional HTTP header to pass in the request to the web server.
|
||||
|
||||
``update_openlp``
|
||||
Tells OpenLP to update itself if the page is successfully downloaded.
|
||||
Defaults to False.
|
||||
"""
|
||||
# TODO: Add proxy usage. Get proxy info from OpenLP settings, add to a
|
||||
# proxy_handler, build into an opener and install the opener into urllib2.
|
||||
# http://docs.python.org/library/urllib2.html
|
||||
if not url:
|
||||
return None
|
||||
req = urllib2.Request(url)
|
||||
if header:
|
||||
req.add_header(header[0], header[1])
|
||||
page = None
|
||||
log.debug(u'Downloading URL = %s' % url)
|
||||
try:
|
||||
page = urllib2.urlopen(req)
|
||||
log.debug(u'Downloaded URL = %s' % page.geturl())
|
||||
except urllib2.URLError:
|
||||
log.exception(u'The web page could not be downloaded')
|
||||
if not page:
|
||||
return None
|
||||
if update_openlp:
|
||||
Receiver.send_message(u'openlp_process_events')
|
||||
return page
|
||||
|
||||
def file_is_unicode(filename):
|
||||
"""
|
||||
Checks if a file is valid unicode and returns the unicode decoded file or
|
||||
None.
|
||||
|
||||
``filename``
|
||||
File to check is valid unicode.
|
||||
"""
|
||||
if not filename:
|
||||
return None
|
||||
ucsfile = None
|
||||
try:
|
||||
ucsfile = filename.decode(u'utf-8')
|
||||
except UnicodeDecodeError:
|
||||
log.exception(u'Filename "%s" is not valid UTF-8' %
|
||||
filename.decode(u'utf-8', u'replace'))
|
||||
if not ucsfile:
|
||||
return None
|
||||
return ucsfile
|
||||
|
||||
def string_is_unicode(test_string):
|
||||
"""
|
||||
Makes sure a string is unicode.
|
||||
|
||||
``test_string``
|
||||
The string to confirm is unicode.
|
||||
"""
|
||||
return_string = u''
|
||||
if not test_string:
|
||||
return return_string
|
||||
if isinstance(test_string, unicode):
|
||||
return_string = test_string
|
||||
if not isinstance(test_string, unicode):
|
||||
try:
|
||||
return_string = unicode(test_string, u'utf-8')
|
||||
except UnicodeError:
|
||||
log.exception("Error encoding string to unicode")
|
||||
return return_string
|
||||
|
||||
from languagemanager import LanguageManager
|
||||
from actions import ActionList
|
||||
|
||||
__all__ = [u'AppLocation', u'check_latest_version', u'add_actions',
|
||||
u'get_filesystem_encoding', u'LanguageManager', u'ActionList']
|
||||
u'get_filesystem_encoding', u'LanguageManager', u'ActionList',
|
||||
u'get_web_page', u'file_is_unicode', u'string_is_unicode']
|
||||
|
@ -73,7 +73,7 @@ class AlertsPlugin(Plugin):
|
||||
self.toolsAlertItem.setStatusTip(
|
||||
translate('AlertsPlugin', 'Show an alert message.'))
|
||||
self.toolsAlertItem.setShortcut(u'F7')
|
||||
self.serviceManager.parent.ToolsMenu.addAction(self.toolsAlertItem)
|
||||
self.serviceManager.mainwindow.ToolsMenu.addAction(self.toolsAlertItem)
|
||||
QtCore.QObject.connect(self.toolsAlertItem,
|
||||
QtCore.SIGNAL(u'triggered()'), self.onAlertsTrigger)
|
||||
self.toolsAlertItem.setVisible(False)
|
||||
|
@ -177,8 +177,8 @@ class AlertForm(QtGui.QDialog, Ui_AlertDialog):
|
||||
'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
|
||||
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 \
|
||||
@ -188,8 +188,8 @@ class AlertForm(QtGui.QDialog, Ui_AlertDialog):
|
||||
' contain \'<>\'.\nDo want to continue anyway?'),
|
||||
QtGui.QMessageBox.StandardButtons(QtGui.QMessageBox.No |
|
||||
QtGui.QMessageBox.Yes)) == QtGui.QMessageBox.No:
|
||||
self.parameterEdit.setFocus()
|
||||
return False
|
||||
self.parameterEdit.setFocus()
|
||||
return False
|
||||
text = text.replace(u'<>', unicode(self.parameterEdit.text()))
|
||||
self.parent.alertsmanager.displayAlert(text)
|
||||
return True
|
||||
|
@ -23,7 +23,9 @@
|
||||
# with this program; if not, write to the Free Software Foundation, Inc., 59 #
|
||||
# Temple Place, Suite 330, Boston, MA 02111-1307 USA #
|
||||
###############################################################################
|
||||
|
||||
"""
|
||||
The bible import functions for OpenLP
|
||||
"""
|
||||
import csv
|
||||
import logging
|
||||
import os
|
||||
@ -31,15 +33,19 @@ import os.path
|
||||
|
||||
from PyQt4 import QtCore, QtGui
|
||||
|
||||
from bibleimportwizard import Ui_BibleImportWizard
|
||||
from openlp.core.lib import Receiver, SettingsManager, translate
|
||||
from openlp.core.lib.db import delete_database
|
||||
from openlp.core.utils import AppLocation
|
||||
from openlp.core.ui import criticalErrorMessageBox
|
||||
from openlp.core.ui.wizard import OpenLPWizard
|
||||
from openlp.core.utils import AppLocation, string_is_unicode
|
||||
from openlp.plugins.bibles.lib.manager import BibleFormat
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
class WebDownload(object):
|
||||
"""
|
||||
Provides an enumeration for the web bible types available to OpenLP.
|
||||
"""
|
||||
Unknown = -1
|
||||
Crosswalk = 0
|
||||
BibleGateway = 1
|
||||
@ -53,10 +59,13 @@ class WebDownload(object):
|
||||
|
||||
@classmethod
|
||||
def get_name(cls, name):
|
||||
"""
|
||||
Get the web bible type name.
|
||||
"""
|
||||
return cls.Names[name]
|
||||
|
||||
|
||||
class BibleImportForm(QtGui.QWizard, Ui_BibleImportWizard):
|
||||
class BibleImportForm(OpenLPWizard):
|
||||
"""
|
||||
This is the Bible Import Wizard, which allows easy importing of Bibles
|
||||
into OpenLP from other formats like OSIS, CSV and OpenSong.
|
||||
@ -76,27 +85,42 @@ class BibleImportForm(QtGui.QWizard, Ui_BibleImportWizard):
|
||||
``bibleplugin``
|
||||
The Bible plugin.
|
||||
"""
|
||||
QtGui.QWizard.__init__(self, parent)
|
||||
self.setupUi(self)
|
||||
self.registerFields()
|
||||
self.manager = manager
|
||||
self.web_bible_list = {}
|
||||
OpenLPWizard.__init__(self, parent, bibleplugin, u'bibleImportWizard',
|
||||
u':/wizards/wizard_importbible.bmp')
|
||||
|
||||
def setupUi(self, image):
|
||||
"""
|
||||
Set up the UI for the bible wizard.
|
||||
"""
|
||||
OpenLPWizard.setupUi(self, image)
|
||||
QtCore.QObject.connect(self.formatComboBox,
|
||||
QtCore.SIGNAL(u'currentIndexChanged(int)'), self.selectStack,
|
||||
QtCore.SLOT(u'setCurrentIndex(int)'))
|
||||
|
||||
def customInit(self):
|
||||
"""
|
||||
Perform any custom initialisation for bible importing.
|
||||
"""
|
||||
if BibleFormat.get_availability(BibleFormat.OpenLP1):
|
||||
self.openlp1DisabledLabel.hide()
|
||||
else:
|
||||
self.openlp1FileLabel.hide()
|
||||
self.openlp1FileEdit.hide()
|
||||
self.openlp1BrowseButton.hide()
|
||||
self.finishButton = self.button(QtGui.QWizard.FinishButton)
|
||||
self.cancelButton = self.button(QtGui.QWizard.CancelButton)
|
||||
self.manager = manager
|
||||
self.bibleplugin = bibleplugin
|
||||
self.manager.set_process_dialog(self)
|
||||
self.web_bible_list = {}
|
||||
self.loadWebBibles()
|
||||
self.restart()
|
||||
self.selectStack.setCurrentIndex(0)
|
||||
|
||||
def customSignals(self):
|
||||
"""
|
||||
Set up the signals used in the bible importer.
|
||||
"""
|
||||
QtCore.QObject.connect(self.webSourceComboBox,
|
||||
QtCore.SIGNAL(u'currentIndexChanged(int)'),
|
||||
self.onWebSourceComboBoxCurrentIndexChanged)
|
||||
self.onWebSourceComboBoxIndexChanged)
|
||||
QtCore.QObject.connect(self.osisBrowseButton,
|
||||
QtCore.SIGNAL(u'clicked()'),
|
||||
self.onOsisBrowseButtonClicked)
|
||||
@ -112,25 +136,329 @@ class BibleImportForm(QtGui.QWizard, Ui_BibleImportWizard):
|
||||
QtCore.QObject.connect(self.openlp1BrowseButton,
|
||||
QtCore.SIGNAL(u'clicked()'),
|
||||
self.onOpenlp1BrowseButtonClicked)
|
||||
QtCore.QObject.connect(self,
|
||||
QtCore.SIGNAL(u'currentIdChanged(int)'),
|
||||
self.onCurrentIdChanged)
|
||||
|
||||
def exec_(self):
|
||||
def addCustomPages(self):
|
||||
"""
|
||||
Run the wizard.
|
||||
Add the bible import specific wizard pages.
|
||||
"""
|
||||
self.setDefaults()
|
||||
return QtGui.QWizard.exec_(self)
|
||||
# Select Page
|
||||
self.selectPage = QtGui.QWizardPage()
|
||||
self.selectPage.setObjectName(u'SelectPage')
|
||||
self.selectPageLayout = QtGui.QVBoxLayout(self.selectPage)
|
||||
self.selectPageLayout.setObjectName(u'SelectPageLayout')
|
||||
self.formatLayout = QtGui.QFormLayout()
|
||||
self.formatLayout.setObjectName(u'FormatLayout')
|
||||
self.formatLabel = QtGui.QLabel(self.selectPage)
|
||||
self.formatLabel.setObjectName(u'FormatLabel')
|
||||
self.formatComboBox = QtGui.QComboBox(self.selectPage)
|
||||
self.formatComboBox.addItems([u'', u'', u'', u'', u''])
|
||||
self.formatComboBox.setObjectName(u'FormatComboBox')
|
||||
self.formatLayout.addRow(self.formatLabel, self.formatComboBox)
|
||||
self.formatSpacer = QtGui.QSpacerItem(10, 0, QtGui.QSizePolicy.Fixed,
|
||||
QtGui.QSizePolicy.Minimum)
|
||||
self.formatLayout.setItem(1, QtGui.QFormLayout.LabelRole,
|
||||
self.formatSpacer)
|
||||
self.selectPageLayout.addLayout(self.formatLayout)
|
||||
self.selectStack = QtGui.QStackedLayout()
|
||||
self.selectStack.setObjectName(u'SelectStack')
|
||||
self.osisWidget = QtGui.QWidget(self.selectPage)
|
||||
self.osisWidget.setObjectName(u'OsisWidget')
|
||||
self.osisLayout = QtGui.QFormLayout(self.osisWidget)
|
||||
self.osisLayout.setMargin(0)
|
||||
self.osisLayout.setObjectName(u'OsisLayout')
|
||||
self.osisFileLabel = QtGui.QLabel(self.osisWidget)
|
||||
self.osisFileLabel.setObjectName(u'OsisFileLabel')
|
||||
self.osisFileLayout = QtGui.QHBoxLayout()
|
||||
self.osisFileLayout.setObjectName(u'OsisFileLayout')
|
||||
self.osisFileEdit = QtGui.QLineEdit(self.osisWidget)
|
||||
self.osisFileEdit.setObjectName(u'OsisFileEdit')
|
||||
self.osisFileLayout.addWidget(self.osisFileEdit)
|
||||
self.osisBrowseButton = QtGui.QToolButton(self.osisWidget)
|
||||
self.osisBrowseButton.setIcon(self.openIcon)
|
||||
self.osisBrowseButton.setObjectName(u'OsisBrowseButton')
|
||||
self.osisFileLayout.addWidget(self.osisBrowseButton)
|
||||
self.osisLayout.addRow(self.osisFileLabel, self.osisFileLayout)
|
||||
self.osisSpacer = QtGui.QSpacerItem(10, 0, QtGui.QSizePolicy.Fixed,
|
||||
QtGui.QSizePolicy.Minimum)
|
||||
self.osisLayout.setItem(1, QtGui.QFormLayout.LabelRole, self.osisSpacer)
|
||||
self.selectStack.addWidget(self.osisWidget)
|
||||
self.csvWidget = QtGui.QWidget(self.selectPage)
|
||||
self.csvWidget.setObjectName(u'CsvWidget')
|
||||
self.csvLayout = QtGui.QFormLayout(self.csvWidget)
|
||||
self.csvLayout.setMargin(0)
|
||||
self.csvLayout.setObjectName(u'CsvLayout')
|
||||
self.csvBooksLabel = QtGui.QLabel(self.csvWidget)
|
||||
self.csvBooksLabel.setObjectName(u'CsvBooksLabel')
|
||||
self.csvBooksLayout = QtGui.QHBoxLayout()
|
||||
self.csvBooksLayout.setObjectName(u'CsvBooksLayout')
|
||||
self.csvBooksEdit = QtGui.QLineEdit(self.csvWidget)
|
||||
self.csvBooksEdit.setObjectName(u'CsvBooksEdit')
|
||||
self.csvBooksLayout.addWidget(self.csvBooksEdit)
|
||||
self.csvBooksButton = QtGui.QToolButton(self.csvWidget)
|
||||
self.csvBooksButton.setIcon(self.openIcon)
|
||||
self.csvBooksButton.setObjectName(u'CsvBooksButton')
|
||||
self.csvBooksLayout.addWidget(self.csvBooksButton)
|
||||
self.csvLayout.addRow(self.csvBooksLabel, self.csvBooksLayout)
|
||||
self.csvVersesLabel = QtGui.QLabel(self.csvWidget)
|
||||
self.csvVersesLabel.setObjectName(u'CsvVersesLabel')
|
||||
self.csvVersesLayout = QtGui.QHBoxLayout()
|
||||
self.csvVersesLayout.setObjectName(u'CsvVersesLayout')
|
||||
self.csvVersesEdit = QtGui.QLineEdit(self.csvWidget)
|
||||
self.csvVersesEdit.setObjectName(u'CsvVersesEdit')
|
||||
self.csvVersesLayout.addWidget(self.csvVersesEdit)
|
||||
self.csvVersesButton = QtGui.QToolButton(self.csvWidget)
|
||||
self.csvVersesButton.setIcon(self.openIcon)
|
||||
self.csvVersesButton.setObjectName(u'CsvVersesButton')
|
||||
self.csvVersesLayout.addWidget(self.csvVersesButton)
|
||||
self.csvLayout.addRow(self.csvVersesLabel, self.csvVersesLayout)
|
||||
self.csvSpacer = QtGui.QSpacerItem(10, 0, QtGui.QSizePolicy.Fixed,
|
||||
QtGui.QSizePolicy.Minimum)
|
||||
self.csvLayout.setItem(2, QtGui.QFormLayout.LabelRole, self.csvSpacer)
|
||||
self.selectStack.addWidget(self.csvWidget)
|
||||
self.openSongWidget = QtGui.QWidget(self.selectPage)
|
||||
self.openSongWidget.setObjectName(u'OpenSongWidget')
|
||||
self.openSongLayout = QtGui.QFormLayout(self.openSongWidget)
|
||||
self.openSongLayout.setMargin(0)
|
||||
self.openSongLayout.setObjectName(u'OpenSongLayout')
|
||||
self.openSongFileLabel = QtGui.QLabel(self.openSongWidget)
|
||||
self.openSongFileLabel.setObjectName(u'OpenSongFileLabel')
|
||||
self.openSongFileLayout = QtGui.QHBoxLayout()
|
||||
self.openSongFileLayout.setObjectName(u'OpenSongFileLayout')
|
||||
self.openSongFileEdit = QtGui.QLineEdit(self.openSongWidget)
|
||||
self.openSongFileEdit.setObjectName(u'OpenSongFileEdit')
|
||||
self.openSongFileLayout.addWidget(self.openSongFileEdit)
|
||||
self.openSongBrowseButton = QtGui.QToolButton(self.openSongWidget)
|
||||
self.openSongBrowseButton.setIcon(self.openIcon)
|
||||
self.openSongBrowseButton.setObjectName(u'OpenSongBrowseButton')
|
||||
self.openSongFileLayout.addWidget(self.openSongBrowseButton)
|
||||
self.openSongLayout.addRow(self.openSongFileLabel,
|
||||
self.openSongFileLayout)
|
||||
self.openSongSpacer = QtGui.QSpacerItem(10, 0, QtGui.QSizePolicy.Fixed,
|
||||
QtGui.QSizePolicy.Minimum)
|
||||
self.openSongLayout.setItem(1, QtGui.QFormLayout.LabelRole,
|
||||
self.openSongSpacer)
|
||||
self.selectStack.addWidget(self.openSongWidget)
|
||||
self.webTabWidget = QtGui.QTabWidget(self.selectPage)
|
||||
self.webTabWidget.setObjectName(u'WebTabWidget')
|
||||
self.webBibleTab = QtGui.QWidget()
|
||||
self.webBibleTab.setObjectName(u'WebBibleTab')
|
||||
self.webBibleLayout = QtGui.QFormLayout(self.webBibleTab)
|
||||
self.webBibleLayout.setObjectName(u'WebBibleLayout')
|
||||
self.webSourceLabel = QtGui.QLabel(self.webBibleTab)
|
||||
self.webSourceLabel.setObjectName(u'WebSourceLabel')
|
||||
self.webBibleLayout.setWidget(0, QtGui.QFormLayout.LabelRole,
|
||||
self.webSourceLabel)
|
||||
self.webSourceComboBox = QtGui.QComboBox(self.webBibleTab)
|
||||
self.webSourceComboBox.setObjectName(u'WebSourceComboBox')
|
||||
self.webSourceComboBox.addItems([u'', u'', u''])
|
||||
self.webBibleLayout.setWidget(0, QtGui.QFormLayout.FieldRole,
|
||||
self.webSourceComboBox)
|
||||
self.webTranslationLabel = QtGui.QLabel(self.webBibleTab)
|
||||
self.webTranslationLabel.setObjectName(u'webTranslationLabel')
|
||||
self.webBibleLayout.setWidget(1, QtGui.QFormLayout.LabelRole,
|
||||
self.webTranslationLabel)
|
||||
self.webTranslationComboBox = QtGui.QComboBox(self.webBibleTab)
|
||||
self.webTranslationComboBox.setSizeAdjustPolicy(
|
||||
QtGui.QComboBox.AdjustToContents)
|
||||
self.webTranslationComboBox.setObjectName(u'WebTranslationComboBox')
|
||||
self.webBibleLayout.setWidget(1, QtGui.QFormLayout.FieldRole,
|
||||
self.webTranslationComboBox)
|
||||
self.webTabWidget.addTab(self.webBibleTab, u'')
|
||||
self.webProxyTab = QtGui.QWidget()
|
||||
self.webProxyTab.setObjectName(u'WebProxyTab')
|
||||
self.webProxyLayout = QtGui.QFormLayout(self.webProxyTab)
|
||||
self.webProxyLayout.setObjectName(u'WebProxyLayout')
|
||||
self.webServerLabel = QtGui.QLabel(self.webProxyTab)
|
||||
self.webServerLabel.setObjectName(u'WebServerLabel')
|
||||
self.webProxyLayout.setWidget(0, QtGui.QFormLayout.LabelRole,
|
||||
self.webServerLabel)
|
||||
self.webServerEdit = QtGui.QLineEdit(self.webProxyTab)
|
||||
self.webServerEdit.setObjectName(u'WebServerEdit')
|
||||
self.webProxyLayout.setWidget(0, QtGui.QFormLayout.FieldRole,
|
||||
self.webServerEdit)
|
||||
self.webUserLabel = QtGui.QLabel(self.webProxyTab)
|
||||
self.webUserLabel.setObjectName(u'WebUserLabel')
|
||||
self.webProxyLayout.setWidget(1, QtGui.QFormLayout.LabelRole,
|
||||
self.webUserLabel)
|
||||
self.webUserEdit = QtGui.QLineEdit(self.webProxyTab)
|
||||
self.webUserEdit.setObjectName(u'WebUserEdit')
|
||||
self.webProxyLayout.setWidget(1, QtGui.QFormLayout.FieldRole,
|
||||
self.webUserEdit)
|
||||
self.webPasswordLabel = QtGui.QLabel(self.webProxyTab)
|
||||
self.webPasswordLabel.setObjectName(u'WebPasswordLabel')
|
||||
self.webProxyLayout.setWidget(2, QtGui.QFormLayout.LabelRole,
|
||||
self.webPasswordLabel)
|
||||
self.webPasswordEdit = QtGui.QLineEdit(self.webProxyTab)
|
||||
self.webPasswordEdit.setObjectName(u'WebPasswordEdit')
|
||||
self.webProxyLayout.setWidget(2, QtGui.QFormLayout.FieldRole,
|
||||
self.webPasswordEdit)
|
||||
self.webTabWidget.addTab(self.webProxyTab, u'')
|
||||
self.selectStack.addWidget(self.webTabWidget)
|
||||
self.openlp1Widget = QtGui.QWidget(self.selectPage)
|
||||
self.openlp1Widget.setObjectName(u'Openlp1Widget')
|
||||
self.openlp1Layout = QtGui.QFormLayout(self.openlp1Widget)
|
||||
self.openlp1Layout.setMargin(0)
|
||||
self.openlp1Layout.setObjectName(u'Openlp1Layout')
|
||||
self.openlp1FileLabel = QtGui.QLabel(self.openlp1Widget)
|
||||
self.openlp1FileLabel.setObjectName(u'Openlp1FileLabel')
|
||||
self.openlp1FileLayout = QtGui.QHBoxLayout()
|
||||
self.openlp1FileLayout.setObjectName(u'Openlp1FileLayout')
|
||||
self.openlp1FileEdit = QtGui.QLineEdit(self.openlp1Widget)
|
||||
self.openlp1FileEdit.setObjectName(u'Openlp1FileEdit')
|
||||
self.openlp1FileLayout.addWidget(self.openlp1FileEdit)
|
||||
self.openlp1BrowseButton = QtGui.QToolButton(self.openlp1Widget)
|
||||
self.openlp1BrowseButton.setIcon(self.openIcon)
|
||||
self.openlp1BrowseButton.setObjectName(u'Openlp1BrowseButton')
|
||||
self.openlp1FileLayout.addWidget(self.openlp1BrowseButton)
|
||||
self.openlp1Layout.addRow(self.openlp1FileLabel, self.openlp1FileLayout)
|
||||
self.openlp1DisabledLabel = QtGui.QLabel(self.openlp1Widget)
|
||||
self.openlp1DisabledLabel.setWordWrap(True)
|
||||
self.openlp1DisabledLabel.setObjectName(u'Openlp1DisabledLabel')
|
||||
self.openlp1Layout.addRow(self.openlp1DisabledLabel)
|
||||
self.openlp1Spacer = QtGui.QSpacerItem(10, 0, QtGui.QSizePolicy.Fixed,
|
||||
QtGui.QSizePolicy.Minimum)
|
||||
self.openlp1Layout.setItem(1, QtGui.QFormLayout.LabelRole,
|
||||
self.openlp1Spacer)
|
||||
self.selectStack.addWidget(self.openlp1Widget)
|
||||
self.selectPageLayout.addLayout(self.selectStack)
|
||||
self.addPage(self.selectPage)
|
||||
# License Page
|
||||
self.licenseDetailsPage = QtGui.QWizardPage()
|
||||
self.licenseDetailsPage.setObjectName(u'LicenseDetailsPage')
|
||||
self.licenseDetailsLayout = QtGui.QFormLayout(self.licenseDetailsPage)
|
||||
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)
|
||||
self.addPage(self.licenseDetailsPage)
|
||||
|
||||
def reject(self):
|
||||
def retranslateUi(self):
|
||||
"""
|
||||
Stop the import on cancel button, close button or ESC key.
|
||||
Allow for localisation of the bible import wizard.
|
||||
"""
|
||||
log.debug(u'Import canceled by user.')
|
||||
if self.currentPage() == self.importPage:
|
||||
Receiver.send_message(u'bibles_stop_import')
|
||||
self.done(QtGui.QDialog.Rejected)
|
||||
self.setWindowTitle(
|
||||
translate('BiblesPlugin.ImportWizardForm', 'Bible Import Wizard'))
|
||||
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(
|
||||
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(
|
||||
translate('BiblesPlugin.ImportWizardForm',
|
||||
'Select the import format, and where to import from.'))
|
||||
self.formatLabel.setText(
|
||||
translate('BiblesPlugin.ImportWizardForm', 'Format:'))
|
||||
self.formatComboBox.setItemText(0,
|
||||
translate('BiblesPlugin.ImportWizardForm', 'OSIS'))
|
||||
self.formatComboBox.setItemText(1,
|
||||
translate('BiblesPlugin.ImportWizardForm', 'CSV'))
|
||||
self.formatComboBox.setItemText(2,
|
||||
translate('BiblesPlugin.ImportWizardForm', 'OpenSong'))
|
||||
self.formatComboBox.setItemText(3,
|
||||
translate('BiblesPlugin.ImportWizardForm', 'Web Download'))
|
||||
self.formatComboBox.setItemText(4,
|
||||
translate('BiblesPlugin.ImportWizardForm', 'openlp.org 1.x'))
|
||||
self.openlp1FileLabel.setText(
|
||||
translate('BiblesPlugin.ImportWizardForm', 'File location:'))
|
||||
self.osisFileLabel.setText(
|
||||
translate('BiblesPlugin.ImportWizardForm', 'File location:'))
|
||||
self.csvBooksLabel.setText(
|
||||
translate('BiblesPlugin.ImportWizardForm', 'Books location:'))
|
||||
self.csvVersesLabel.setText(
|
||||
translate('BiblesPlugin.ImportWizardForm', 'Verse location:'))
|
||||
self.openSongFileLabel.setText(
|
||||
translate('BiblesPlugin.ImportWizardForm', 'Bible filename:'))
|
||||
self.webSourceLabel.setText(
|
||||
translate('BiblesPlugin.ImportWizardForm', 'Location:'))
|
||||
self.webSourceComboBox.setItemText(0,
|
||||
translate('BiblesPlugin.ImportWizardForm', 'Crosswalk'))
|
||||
self.webSourceComboBox.setItemText(1,
|
||||
translate('BiblesPlugin.ImportWizardForm', 'BibleGateway'))
|
||||
self.webSourceComboBox.setItemText(2,
|
||||
translate('BiblesPlugin.ImportWizardForm', 'Bibleserver'))
|
||||
self.webTranslationLabel.setText(
|
||||
translate('BiblesPlugin.ImportWizardForm', 'Bible:'))
|
||||
self.webTabWidget.setTabText(
|
||||
self.webTabWidget.indexOf(self.webBibleTab),
|
||||
translate('BiblesPlugin.ImportWizardForm', 'Download Options'))
|
||||
self.webServerLabel.setText(
|
||||
translate('BiblesPlugin.ImportWizardForm', 'Server:'))
|
||||
self.webUserLabel.setText(
|
||||
translate('BiblesPlugin.ImportWizardForm', 'Username:'))
|
||||
self.webPasswordLabel.setText(
|
||||
translate('BiblesPlugin.ImportWizardForm', 'Password:'))
|
||||
self.webTabWidget.setTabText(
|
||||
self.webTabWidget.indexOf(self.webProxyTab),
|
||||
translate('BiblesPlugin.ImportWizardForm',
|
||||
'Proxy Server (Optional)'))
|
||||
self.licenseDetailsPage.setTitle(
|
||||
translate('BiblesPlugin.ImportWizardForm', 'License Details'))
|
||||
self.licenseDetailsPage.setSubTitle(
|
||||
translate('BiblesPlugin.ImportWizardForm',
|
||||
'Set up the Bible\'s license details.'))
|
||||
self.versionNameLabel.setText(
|
||||
translate('BiblesPlugin.ImportWizardForm', 'Version name:'))
|
||||
self.copyrightLabel.setText(
|
||||
translate('BiblesPlugin.ImportWizardForm', 'Copyright:'))
|
||||
self.permissionsLabel.setText(
|
||||
translate('BiblesPlugin.ImportWizardForm', 'Permissions:'))
|
||||
self.progressPage.setTitle(
|
||||
translate('BiblesPlugin.ImportWizardForm', 'Importing'))
|
||||
self.progressPage.setSubTitle(
|
||||
translate('BiblesPlugin.ImportWizardForm',
|
||||
'Please wait while your Bible is imported.'))
|
||||
self.progressLabel.setText(
|
||||
translate('BiblesPlugin.ImportWizardForm', 'Ready.'))
|
||||
self.progressBar.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.'))
|
||||
# Align all QFormLayouts towards each other.
|
||||
labelWidth = max(self.formatLabel.minimumSizeHint().width(),
|
||||
self.osisFileLabel.minimumSizeHint().width(),
|
||||
self.csvBooksLabel.minimumSizeHint().width(),
|
||||
self.csvVersesLabel.minimumSizeHint().width(),
|
||||
self.openSongFileLabel.minimumSizeHint().width(),
|
||||
self.openlp1FileLabel.minimumSizeHint().width())
|
||||
self.formatSpacer.changeSize(labelWidth, 0,
|
||||
QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Fixed)
|
||||
self.osisSpacer.changeSize(labelWidth, 0,
|
||||
QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Fixed)
|
||||
self.csvSpacer.changeSize(labelWidth, 0,
|
||||
QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Fixed)
|
||||
self.openSongSpacer.changeSize(labelWidth, 0,
|
||||
QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Fixed)
|
||||
self.openlp1Spacer.changeSize(labelWidth, 0,
|
||||
QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Fixed)
|
||||
|
||||
def validateCurrentPage(self):
|
||||
"""
|
||||
@ -141,7 +469,7 @@ class BibleImportForm(QtGui.QWizard, Ui_BibleImportWizard):
|
||||
elif self.currentPage() == self.selectPage:
|
||||
if self.field(u'source_format').toInt()[0] == BibleFormat.OSIS:
|
||||
if not self.field(u'osis_location').toString():
|
||||
QtGui.QMessageBox.critical(self,
|
||||
criticalErrorMessageBox(
|
||||
translate('BiblesPlugin.ImportWizardForm',
|
||||
'Invalid Bible Location'),
|
||||
translate('BiblesPlugin.ImportWizardForm',
|
||||
@ -151,7 +479,7 @@ class BibleImportForm(QtGui.QWizard, Ui_BibleImportWizard):
|
||||
return False
|
||||
elif self.field(u'source_format').toInt()[0] == BibleFormat.CSV:
|
||||
if not self.field(u'csv_booksfile').toString():
|
||||
QtGui.QMessageBox.critical(self,
|
||||
criticalErrorMessageBox(
|
||||
translate('BiblesPlugin.ImportWizardForm',
|
||||
'Invalid Books File'),
|
||||
translate('BiblesPlugin.ImportWizardForm',
|
||||
@ -160,7 +488,7 @@ class BibleImportForm(QtGui.QWizard, Ui_BibleImportWizard):
|
||||
self.csvBooksEdit.setFocus()
|
||||
return False
|
||||
elif not self.field(u'csv_versefile').toString():
|
||||
QtGui.QMessageBox.critical(self,
|
||||
criticalErrorMessageBox(
|
||||
translate('BiblesPlugin.ImportWizardForm',
|
||||
'Invalid Verse File'),
|
||||
translate('BiblesPlugin.ImportWizardForm',
|
||||
@ -171,7 +499,7 @@ class BibleImportForm(QtGui.QWizard, Ui_BibleImportWizard):
|
||||
elif self.field(u'source_format').toInt()[0] == \
|
||||
BibleFormat.OpenSong:
|
||||
if not self.field(u'opensong_file').toString():
|
||||
QtGui.QMessageBox.critical(self,
|
||||
criticalErrorMessageBox(
|
||||
translate('BiblesPlugin.ImportWizardForm',
|
||||
'Invalid OpenSong Bible'),
|
||||
translate('BiblesPlugin.ImportWizardForm',
|
||||
@ -181,7 +509,7 @@ class BibleImportForm(QtGui.QWizard, Ui_BibleImportWizard):
|
||||
return False
|
||||
elif self.field(u'source_format').toInt()[0] == BibleFormat.OpenLP1:
|
||||
if not self.field(u'openlp1_location').toString():
|
||||
QtGui.QMessageBox.critical(self,
|
||||
criticalErrorMessageBox(
|
||||
translate('BiblesPlugin.ImportWizardForm',
|
||||
'Invalid Bible Location'),
|
||||
translate('BiblesPlugin.ImportWizardForm',
|
||||
@ -195,7 +523,7 @@ class BibleImportForm(QtGui.QWizard, Ui_BibleImportWizard):
|
||||
license_copyright = \
|
||||
unicode(self.field(u'license_copyright').toString())
|
||||
if not license_version:
|
||||
QtGui.QMessageBox.critical(self,
|
||||
criticalErrorMessageBox(
|
||||
translate('BiblesPlugin.ImportWizardForm',
|
||||
'Empty Version Name'),
|
||||
translate('BiblesPlugin.ImportWizardForm',
|
||||
@ -203,7 +531,7 @@ class BibleImportForm(QtGui.QWizard, Ui_BibleImportWizard):
|
||||
self.versionNameEdit.setFocus()
|
||||
return False
|
||||
elif not license_copyright:
|
||||
QtGui.QMessageBox.critical(self,
|
||||
criticalErrorMessageBox(
|
||||
translate('BiblesPlugin.ImportWizardForm',
|
||||
'Empty Copyright'),
|
||||
translate('BiblesPlugin.ImportWizardForm',
|
||||
@ -212,7 +540,7 @@ class BibleImportForm(QtGui.QWizard, Ui_BibleImportWizard):
|
||||
self.copyrightEdit.setFocus()
|
||||
return False
|
||||
elif self.manager.exists(license_version):
|
||||
QtGui.QMessageBox.critical(self,
|
||||
criticalErrorMessageBox(
|
||||
translate('BiblesPlugin.ImportWizardForm', 'Bible Exists'),
|
||||
translate('BiblesPlugin.ImportWizardForm',
|
||||
'This Bible already exists. Please import '
|
||||
@ -220,10 +548,10 @@ class BibleImportForm(QtGui.QWizard, Ui_BibleImportWizard):
|
||||
self.versionNameEdit.setFocus()
|
||||
return False
|
||||
return True
|
||||
if self.currentPage() == self.importPage:
|
||||
if self.currentPage() == self.progressPage:
|
||||
return True
|
||||
|
||||
def onWebSourceComboBoxCurrentIndexChanged(self, index):
|
||||
def onWebSourceComboBoxIndexChanged(self, index):
|
||||
"""
|
||||
Setup the list of Bibles when you select a different source on the web
|
||||
download page.
|
||||
@ -279,13 +607,10 @@ class BibleImportForm(QtGui.QWizard, Ui_BibleImportWizard):
|
||||
u'%s (*.bible)' % translate('BiblesPlugin.ImportWizardForm',
|
||||
'openlp.org 1.x bible'))
|
||||
|
||||
def onCurrentIdChanged(self, pageId):
|
||||
if self.page(pageId) == self.importPage:
|
||||
self.preImport()
|
||||
self.performImport()
|
||||
self.postImport()
|
||||
|
||||
def registerFields(self):
|
||||
"""
|
||||
Register the bible import wizard fields.
|
||||
"""
|
||||
self.selectPage.registerField(u'source_format', self.formatComboBox)
|
||||
self.selectPage.registerField(u'osis_location', self.osisFileEdit)
|
||||
self.selectPage.registerField(u'csv_booksfile', self.csvBooksEdit)
|
||||
@ -306,8 +631,11 @@ class BibleImportForm(QtGui.QWizard, Ui_BibleImportWizard):
|
||||
u'license_permissions', self.permissionsEdit)
|
||||
|
||||
def setDefaults(self):
|
||||
"""
|
||||
Set default values for the wizard pages.
|
||||
"""
|
||||
settings = QtCore.QSettings()
|
||||
settings.beginGroup(self.bibleplugin.settingsSection)
|
||||
settings.beginGroup(self.plugin.settingsSection)
|
||||
self.restart()
|
||||
self.finishButton.setVisible(False)
|
||||
self.cancelButton.setVisible(True)
|
||||
@ -332,72 +660,50 @@ class BibleImportForm(QtGui.QWizard, Ui_BibleImportWizard):
|
||||
QtCore.QVariant(self.copyrightEdit.text()))
|
||||
self.setField(u'license_permissions',
|
||||
QtCore.QVariant(self.permissionsEdit.text()))
|
||||
self.onWebSourceComboBoxCurrentIndexChanged(WebDownload.Crosswalk)
|
||||
self.onWebSourceComboBoxIndexChanged(WebDownload.Crosswalk)
|
||||
settings.endGroup()
|
||||
|
||||
def loadWebBibles(self):
|
||||
"""
|
||||
Load the list of Crosswalk and BibleGateway bibles.
|
||||
Load the lists of Crosswalk, BibleGateway and Bibleserver bibles.
|
||||
"""
|
||||
filepath = AppLocation.get_directory(AppLocation.PluginsDir)
|
||||
filepath = os.path.join(filepath, u'bibles', u'resources')
|
||||
# Load Crosswalk Bibles.
|
||||
filepath = AppLocation.get_directory(AppLocation.PluginsDir)
|
||||
filepath = os.path.join(filepath, u'bibles', u'resources')
|
||||
books_file = None
|
||||
try:
|
||||
self.web_bible_list[WebDownload.Crosswalk] = {}
|
||||
books_file = open(
|
||||
os.path.join(filepath, u'crosswalkbooks.csv'), 'rb')
|
||||
dialect = csv.Sniffer().sniff(books_file.read(1024))
|
||||
books_file.seek(0)
|
||||
books_reader = csv.reader(books_file, dialect)
|
||||
for line in books_reader:
|
||||
ver = unicode(line[0], u'utf-8')
|
||||
name = unicode(line[1], u'utf-8')
|
||||
self.web_bible_list[WebDownload.Crosswalk][ver] = name.strip()
|
||||
except IOError:
|
||||
log.exception(u'Crosswalk resources missing')
|
||||
finally:
|
||||
if books_file:
|
||||
books_file.close()
|
||||
self.loadBibleResourceFile(
|
||||
os.path.join(filepath, u'crosswalkbooks.csv'),
|
||||
WebDownload.Crosswalk)
|
||||
# Load BibleGateway Bibles.
|
||||
books_file = None
|
||||
try:
|
||||
self.web_bible_list[WebDownload.BibleGateway] = {}
|
||||
books_file = open(os.path.join(filepath, u'biblegateway.csv'), 'r')
|
||||
dialect = csv.Sniffer().sniff(books_file.read(1024))
|
||||
books_file.seek(0)
|
||||
books_reader = csv.reader(books_file, dialect)
|
||||
for line in books_reader:
|
||||
ver = line[0]
|
||||
name = line[1]
|
||||
if not isinstance(ver, unicode):
|
||||
ver = unicode(ver, u'utf8')
|
||||
if not isinstance(name, unicode):
|
||||
name = unicode(name, u'utf8')
|
||||
self.web_bible_list[WebDownload.BibleGateway][ver] = \
|
||||
name.strip()
|
||||
except IOError:
|
||||
log.exception(u'Biblegateway resources missing')
|
||||
finally:
|
||||
if books_file:
|
||||
books_file.close()
|
||||
self.loadBibleResourceFile(os.path.join(filepath, u'biblegateway.csv'),
|
||||
WebDownload.BibleGateway)
|
||||
# Load and Bibleserver Bibles.
|
||||
filepath = AppLocation.get_directory(AppLocation.PluginsDir)
|
||||
filepath = os.path.join(filepath, u'bibles', u'resources')
|
||||
self.loadBibleResourceFile(os.path.join(filepath, u'bibleserver.csv'),
|
||||
WebDownload.Bibleserver)
|
||||
|
||||
def loadBibleResourceFile(self, file_path_name, download_type):
|
||||
"""
|
||||
Loads a web bible resource file.
|
||||
|
||||
``file_path_name``
|
||||
The file to load including the file's path.
|
||||
|
||||
``download_type``
|
||||
The WebDownload type this file is for.
|
||||
"""
|
||||
self.web_bible_list[download_type] = {}
|
||||
books_file = None
|
||||
try:
|
||||
self.web_bible_list[WebDownload.Bibleserver] = {}
|
||||
books_file = open(
|
||||
os.path.join(filepath, u'bibleserver.csv'), 'rb')
|
||||
books_file = open(file_path_name, 'rb')
|
||||
dialect = csv.Sniffer().sniff(books_file.read(1024))
|
||||
books_file.seek(0)
|
||||
books_reader = csv.reader(books_file, dialect)
|
||||
for line in books_reader:
|
||||
ver = unicode(line[0], u'utf-8')
|
||||
name = unicode(line[1], u'utf-8')
|
||||
self.web_bible_list[WebDownload.Bibleserver][ver] = name.strip()
|
||||
except IOError, UnicodeError:
|
||||
log.exception(u'Bibleserver resources missing')
|
||||
ver = string_is_unicode(line[0])
|
||||
name = string_is_unicode(line[1])
|
||||
self.web_bible_list[download_type][ver] = name.strip()
|
||||
except IOError:
|
||||
log.exception(u'%s resources missing' %
|
||||
WebDownload.get_name(download_type))
|
||||
finally:
|
||||
if books_file:
|
||||
books_file.close()
|
||||
@ -413,8 +719,8 @@ class BibleImportForm(QtGui.QWizard, Ui_BibleImportWizard):
|
||||
A editbox (QLineEdit).
|
||||
|
||||
``filters``
|
||||
The file extension filters. It should contain the file description as
|
||||
well as the file extension. For example::
|
||||
The file extension filters. It should contain the file description
|
||||
as well as the file extension. For example::
|
||||
|
||||
u'openlp.org 1.x bible (*.bible)'
|
||||
"""
|
||||
@ -424,37 +730,28 @@ class BibleImportForm(QtGui.QWizard, Ui_BibleImportWizard):
|
||||
'All Files')
|
||||
filename = QtGui.QFileDialog.getOpenFileName(self, title,
|
||||
os.path.dirname(SettingsManager.get_last_dir(
|
||||
self.bibleplugin.settingsSection, 1)), filters)
|
||||
self.plugin.settingsSection, 1)), filters)
|
||||
if filename:
|
||||
editbox.setText(filename)
|
||||
SettingsManager.set_last_dir(
|
||||
self.bibleplugin.settingsSection, filename, 1)
|
||||
self.plugin.settingsSection, filename, 1)
|
||||
|
||||
def incrementProgressBar(self, status_text):
|
||||
log.debug(u'IncrementBar %s', status_text)
|
||||
self.importProgressLabel.setText(status_text)
|
||||
self.importProgressBar.setValue(self.importProgressBar.value() + 1)
|
||||
Receiver.send_message(u'openlp_process_events')
|
||||
|
||||
def preImport(self):
|
||||
def preWizard(self):
|
||||
"""
|
||||
Prepare the UI for the import.
|
||||
"""
|
||||
OpenLPWizard.preWizard(self)
|
||||
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)
|
||||
if bible_type == BibleFormat.WebDownload:
|
||||
self.importProgressLabel.setText(translate(
|
||||
self.progressLabel.setText(translate(
|
||||
'BiblesPlugin.ImportWizardForm',
|
||||
'Starting Registering bible...'))
|
||||
else:
|
||||
self.importProgressLabel.setText(translate(
|
||||
self.progressLabel.setText(translate(
|
||||
'BiblesPlugin.ImportWizardForm', 'Starting import...'))
|
||||
Receiver.send_message(u'openlp_process_events')
|
||||
|
||||
def performImport(self):
|
||||
def performWizard(self):
|
||||
"""
|
||||
Perform the actual import.
|
||||
"""
|
||||
@ -485,7 +782,7 @@ class BibleImportForm(QtGui.QWizard, Ui_BibleImportWizard):
|
||||
)
|
||||
elif bible_type == BibleFormat.WebDownload:
|
||||
# Import a bible from the web.
|
||||
self.importProgressBar.setMaximum(1)
|
||||
self.progressBar.setMaximum(1)
|
||||
download_location = self.field(u'web_location').toInt()[0]
|
||||
bible_version = unicode(self.webTranslationComboBox.currentText())
|
||||
if download_location == WebDownload.Crosswalk:
|
||||
@ -518,20 +815,14 @@ class BibleImportForm(QtGui.QWizard, Ui_BibleImportWizard):
|
||||
license_copyright, license_permissions)
|
||||
self.manager.reload_bibles()
|
||||
if bible_type == BibleFormat.WebDownload:
|
||||
self.importProgressLabel.setText(
|
||||
self.progressLabel.setText(
|
||||
translate('BiblesPlugin.ImportWizardForm', 'Registered '
|
||||
'bible. Please note, that verses will be downloaded on\n'
|
||||
'demand and thus an internet connection is required.'))
|
||||
else:
|
||||
self.importProgressLabel.setText(translate(
|
||||
self.progressLabel.setText(translate(
|
||||
'BiblesPlugin.ImportWizardForm', 'Finished import.'))
|
||||
else:
|
||||
self.importProgressLabel.setText(translate(
|
||||
self.progressLabel.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.finishButton.setVisible(True)
|
||||
self.cancelButton.setVisible(False)
|
||||
Receiver.send_message(u'openlp_process_events')
|
||||
delete_database(self.plugin.settingsSection, importer.file)
|
||||
|
@ -1,391 +0,0 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4
|
||||
|
||||
###############################################################################
|
||||
# OpenLP - Open Source Lyrics Projection #
|
||||
# --------------------------------------------------------------------------- #
|
||||
# Copyright (c) 2008-2011 Raoul Snyman #
|
||||
# Portions copyright (c) 2008-2011 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 #
|
||||
###############################################################################
|
||||
|
||||
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.setModal(True)
|
||||
bibleImportWizard.setWizardStyle(QtGui.QWizard.ModernStyle)
|
||||
bibleImportWizard.setOptions(
|
||||
QtGui.QWizard.IndependentPages |
|
||||
QtGui.QWizard.NoBackButtonOnStartPage |
|
||||
QtGui.QWizard.NoBackButtonOnLastPage)
|
||||
# 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.setObjectName(u'WelcomeLayout')
|
||||
self.titleLabel = QtGui.QLabel(self.welcomePage)
|
||||
self.titleLabel.setObjectName(u'TitleLabel')
|
||||
self.welcomeLayout.addWidget(self.titleLabel)
|
||||
self.welcomeLayout.addSpacing(40)
|
||||
self.informationLabel = QtGui.QLabel(self.welcomePage)
|
||||
self.informationLabel.setWordWrap(True)
|
||||
self.informationLabel.setObjectName(u'InformationLabel')
|
||||
self.welcomeLayout.addWidget(self.informationLabel)
|
||||
self.welcomeLayout.addStretch()
|
||||
bibleImportWizard.addPage(self.welcomePage)
|
||||
# Select Page
|
||||
self.selectPage = QtGui.QWizardPage()
|
||||
self.selectPage.setObjectName(u'SelectPage')
|
||||
self.selectPageLayout = QtGui.QVBoxLayout(self.selectPage)
|
||||
self.selectPageLayout.setObjectName(u'SelectPageLayout')
|
||||
self.formatLayout = QtGui.QFormLayout()
|
||||
self.formatLayout.setObjectName(u'FormatLayout')
|
||||
self.formatLabel = QtGui.QLabel(self.selectPage)
|
||||
self.formatLabel.setObjectName(u'FormatLabel')
|
||||
self.formatComboBox = QtGui.QComboBox(self.selectPage)
|
||||
self.formatComboBox.addItems([u'', u'', u'', u'', u''])
|
||||
self.formatComboBox.setObjectName(u'FormatComboBox')
|
||||
self.formatLayout.addRow(self.formatLabel, self.formatComboBox)
|
||||
self.formatSpacer = QtGui.QSpacerItem(10, 0, QtGui.QSizePolicy.Fixed,
|
||||
QtGui.QSizePolicy.Minimum)
|
||||
self.formatLayout.setItem(1, QtGui.QFormLayout.LabelRole,
|
||||
self.formatSpacer)
|
||||
self.selectPageLayout.addLayout(self.formatLayout)
|
||||
self.selectStack = QtGui.QStackedLayout()
|
||||
self.selectStack.setObjectName(u'SelectStack')
|
||||
self.osisWidget = QtGui.QWidget(self.selectPage)
|
||||
self.osisWidget.setObjectName(u'OsisWidget')
|
||||
self.osisLayout = QtGui.QFormLayout(self.osisWidget)
|
||||
self.osisLayout.setMargin(0)
|
||||
self.osisLayout.setObjectName(u'OsisLayout')
|
||||
self.osisFileLabel = QtGui.QLabel(self.osisWidget)
|
||||
self.osisFileLabel.setObjectName(u'OsisFileLabel')
|
||||
self.osisFileLayout = QtGui.QHBoxLayout()
|
||||
self.osisFileLayout.setObjectName(u'OsisFileLayout')
|
||||
self.osisFileEdit = QtGui.QLineEdit(self.osisWidget)
|
||||
self.osisFileEdit.setObjectName(u'OsisFileEdit')
|
||||
self.osisFileLayout.addWidget(self.osisFileEdit)
|
||||
self.osisBrowseButton = QtGui.QToolButton(self.osisWidget)
|
||||
self.osisBrowseButton.setIcon(build_icon(u':/general/general_open.png'))
|
||||
self.osisBrowseButton.setObjectName(u'OsisBrowseButton')
|
||||
self.osisFileLayout.addWidget(self.osisBrowseButton)
|
||||
self.osisLayout.addRow(self.osisFileLabel, self.osisFileLayout)
|
||||
self.osisSpacer = QtGui.QSpacerItem(10, 0, QtGui.QSizePolicy.Fixed,
|
||||
QtGui.QSizePolicy.Minimum)
|
||||
self.osisLayout.setItem(1, QtGui.QFormLayout.LabelRole, self.osisSpacer)
|
||||
self.selectStack.addWidget(self.osisWidget)
|
||||
self.csvWidget = QtGui.QWidget(self.selectPage)
|
||||
self.csvWidget.setObjectName(u'CsvWidget')
|
||||
self.csvLayout = QtGui.QFormLayout(self.csvWidget)
|
||||
self.csvLayout.setMargin(0)
|
||||
self.csvLayout.setObjectName(u'CsvLayout')
|
||||
self.csvBooksLabel = QtGui.QLabel(self.csvWidget)
|
||||
self.csvBooksLabel.setObjectName(u'CsvBooksLabel')
|
||||
self.csvBooksLayout = QtGui.QHBoxLayout()
|
||||
self.csvBooksLayout.setObjectName(u'CsvBooksLayout')
|
||||
self.csvBooksEdit = QtGui.QLineEdit(self.csvWidget)
|
||||
self.csvBooksEdit.setObjectName(u'CsvBooksEdit')
|
||||
self.csvBooksLayout.addWidget(self.csvBooksEdit)
|
||||
self.csvBooksButton = QtGui.QToolButton(self.csvWidget)
|
||||
self.csvBooksButton.setIcon(build_icon(u':/general/general_open.png'))
|
||||
self.csvBooksButton.setObjectName(u'CsvBooksButton')
|
||||
self.csvBooksLayout.addWidget(self.csvBooksButton)
|
||||
self.csvLayout.addRow(self.csvBooksLabel, self.csvBooksLayout)
|
||||
self.csvVersesLabel = QtGui.QLabel(self.csvWidget)
|
||||
self.csvVersesLabel.setObjectName(u'CsvVersesLabel')
|
||||
self.csvVersesLayout = QtGui.QHBoxLayout()
|
||||
self.csvVersesLayout.setObjectName(u'CsvVersesLayout')
|
||||
self.csvVersesEdit = QtGui.QLineEdit(self.csvWidget)
|
||||
self.csvVersesEdit.setObjectName(u'CsvVersesEdit')
|
||||
self.csvVersesLayout.addWidget(self.csvVersesEdit)
|
||||
self.csvVersesButton = QtGui.QToolButton(self.csvWidget)
|
||||
self.csvVersesButton.setIcon(build_icon(u':/general/general_open.png'))
|
||||
self.csvVersesButton.setObjectName(u'CsvVersesButton')
|
||||
self.csvVersesLayout.addWidget(self.csvVersesButton)
|
||||
self.csvLayout.addRow(self.csvVersesLabel, self.csvVersesLayout)
|
||||
self.csvSpacer = QtGui.QSpacerItem(10, 0, QtGui.QSizePolicy.Fixed,
|
||||
QtGui.QSizePolicy.Minimum)
|
||||
self.csvLayout.setItem(2, QtGui.QFormLayout.LabelRole, self.csvSpacer)
|
||||
self.selectStack.addWidget(self.csvWidget)
|
||||
self.openSongWidget = QtGui.QWidget(self.selectPage)
|
||||
self.openSongWidget.setObjectName(u'OpenSongWidget')
|
||||
self.openSongLayout = QtGui.QFormLayout(self.openSongWidget)
|
||||
self.openSongLayout.setMargin(0)
|
||||
self.openSongLayout.setObjectName(u'OpenSongLayout')
|
||||
self.openSongFileLabel = QtGui.QLabel(self.openSongWidget)
|
||||
self.openSongFileLabel.setObjectName(u'OpenSongFileLabel')
|
||||
self.openSongFileLayout = QtGui.QHBoxLayout()
|
||||
self.openSongFileLayout.setObjectName(u'OpenSongFileLayout')
|
||||
self.openSongFileEdit = QtGui.QLineEdit(self.openSongWidget)
|
||||
self.openSongFileEdit.setObjectName(u'OpenSongFileEdit')
|
||||
self.openSongFileLayout.addWidget(self.openSongFileEdit)
|
||||
self.openSongBrowseButton = QtGui.QToolButton(self.openSongWidget)
|
||||
self.openSongBrowseButton.setIcon(
|
||||
build_icon(u':/general/general_open.png'))
|
||||
self.openSongBrowseButton.setObjectName(u'OpenSongBrowseButton')
|
||||
self.openSongFileLayout.addWidget(self.openSongBrowseButton)
|
||||
self.openSongLayout.addRow(self.openSongFileLabel,
|
||||
self.openSongFileLayout)
|
||||
self.openSongSpacer = QtGui.QSpacerItem(10, 0, QtGui.QSizePolicy.Fixed,
|
||||
QtGui.QSizePolicy.Minimum)
|
||||
self.openSongLayout.setItem(1, QtGui.QFormLayout.LabelRole,
|
||||
self.openSongSpacer)
|
||||
self.selectStack.addWidget(self.openSongWidget)
|
||||
self.webTabWidget = QtGui.QTabWidget(self.selectPage)
|
||||
self.webTabWidget.setObjectName(u'WebTabWidget')
|
||||
self.webBibleTab = QtGui.QWidget()
|
||||
self.webBibleTab.setObjectName(u'WebBibleTab')
|
||||
self.webBibleLayout = QtGui.QFormLayout(self.webBibleTab)
|
||||
self.webBibleLayout.setObjectName(u'WebBibleLayout')
|
||||
self.webSourceLabel = QtGui.QLabel(self.webBibleTab)
|
||||
self.webSourceLabel.setObjectName(u'WebSourceLabel')
|
||||
self.webBibleLayout.setWidget(0, QtGui.QFormLayout.LabelRole,
|
||||
self.webSourceLabel)
|
||||
self.webSourceComboBox = QtGui.QComboBox(self.webBibleTab)
|
||||
self.webSourceComboBox.setObjectName(u'WebSourceComboBox')
|
||||
self.webSourceComboBox.addItems([u'', u'', u''])
|
||||
self.webBibleLayout.setWidget(0, QtGui.QFormLayout.FieldRole,
|
||||
self.webSourceComboBox)
|
||||
self.webTranslationLabel = QtGui.QLabel(self.webBibleTab)
|
||||
self.webTranslationLabel.setObjectName(u'webTranslationLabel')
|
||||
self.webBibleLayout.setWidget(1, QtGui.QFormLayout.LabelRole,
|
||||
self.webTranslationLabel)
|
||||
self.webTranslationComboBox = QtGui.QComboBox(self.webBibleTab)
|
||||
self.webTranslationComboBox.setSizeAdjustPolicy(
|
||||
QtGui.QComboBox.AdjustToContents)
|
||||
self.webTranslationComboBox.setObjectName(u'WebTranslationComboBox')
|
||||
self.webBibleLayout.setWidget(1, QtGui.QFormLayout.FieldRole,
|
||||
self.webTranslationComboBox)
|
||||
self.webTabWidget.addTab(self.webBibleTab, u'')
|
||||
self.webProxyTab = QtGui.QWidget()
|
||||
self.webProxyTab.setObjectName(u'WebProxyTab')
|
||||
self.webProxyLayout = QtGui.QFormLayout(self.webProxyTab)
|
||||
self.webProxyLayout.setObjectName(u'WebProxyLayout')
|
||||
self.webServerLabel = QtGui.QLabel(self.webProxyTab)
|
||||
self.webServerLabel.setObjectName(u'WebServerLabel')
|
||||
self.webProxyLayout.setWidget(0, QtGui.QFormLayout.LabelRole,
|
||||
self.webServerLabel)
|
||||
self.webServerEdit = QtGui.QLineEdit(self.webProxyTab)
|
||||
self.webServerEdit.setObjectName(u'WebServerEdit')
|
||||
self.webProxyLayout.setWidget(0, QtGui.QFormLayout.FieldRole,
|
||||
self.webServerEdit)
|
||||
self.webUserLabel = QtGui.QLabel(self.webProxyTab)
|
||||
self.webUserLabel.setObjectName(u'WebUserLabel')
|
||||
self.webProxyLayout.setWidget(1, QtGui.QFormLayout.LabelRole,
|
||||
self.webUserLabel)
|
||||
self.webUserEdit = QtGui.QLineEdit(self.webProxyTab)
|
||||
self.webUserEdit.setObjectName(u'WebUserEdit')
|
||||
self.webProxyLayout.setWidget(1, QtGui.QFormLayout.FieldRole,
|
||||
self.webUserEdit)
|
||||
self.webPasswordLabel = QtGui.QLabel(self.webProxyTab)
|
||||
self.webPasswordLabel.setObjectName(u'WebPasswordLabel')
|
||||
self.webProxyLayout.setWidget(2, QtGui.QFormLayout.LabelRole,
|
||||
self.webPasswordLabel)
|
||||
self.webPasswordEdit = QtGui.QLineEdit(self.webProxyTab)
|
||||
self.webPasswordEdit.setObjectName(u'WebPasswordEdit')
|
||||
self.webProxyLayout.setWidget(2, QtGui.QFormLayout.FieldRole,
|
||||
self.webPasswordEdit)
|
||||
self.webTabWidget.addTab(self.webProxyTab, u'')
|
||||
self.selectStack.addWidget(self.webTabWidget)
|
||||
self.openlp1Widget = QtGui.QWidget(self.selectPage)
|
||||
self.openlp1Widget.setObjectName(u'Openlp1Widget')
|
||||
self.openlp1Layout = QtGui.QFormLayout(self.openlp1Widget)
|
||||
self.openlp1Layout.setMargin(0)
|
||||
self.openlp1Layout.setObjectName(u'Openlp1Layout')
|
||||
self.openlp1FileLabel = QtGui.QLabel(self.openlp1Widget)
|
||||
self.openlp1FileLabel.setObjectName(u'Openlp1FileLabel')
|
||||
self.openlp1FileLayout = QtGui.QHBoxLayout()
|
||||
self.openlp1FileLayout.setObjectName(u'Openlp1FileLayout')
|
||||
self.openlp1FileEdit = QtGui.QLineEdit(self.openlp1Widget)
|
||||
self.openlp1FileEdit.setObjectName(u'Openlp1FileEdit')
|
||||
self.openlp1FileLayout.addWidget(self.openlp1FileEdit)
|
||||
self.openlp1BrowseButton = QtGui.QToolButton(self.openlp1Widget)
|
||||
self.openlp1BrowseButton.setIcon(
|
||||
build_icon(u':/general/general_open.png'))
|
||||
self.openlp1BrowseButton.setObjectName(u'Openlp1BrowseButton')
|
||||
self.openlp1FileLayout.addWidget(self.openlp1BrowseButton)
|
||||
self.openlp1Layout.addRow(self.openlp1FileLabel, self.openlp1FileLayout)
|
||||
self.openlp1DisabledLabel = QtGui.QLabel(self.openlp1Widget)
|
||||
self.openlp1DisabledLabel.setWordWrap(True)
|
||||
self.openlp1DisabledLabel.setObjectName(u'Openlp1DisabledLabel')
|
||||
self.openlp1Layout.addRow(self.openlp1DisabledLabel)
|
||||
self.openlp1Spacer = QtGui.QSpacerItem(10, 0, QtGui.QSizePolicy.Fixed,
|
||||
QtGui.QSizePolicy.Minimum)
|
||||
self.openlp1Layout.setItem(1, QtGui.QFormLayout.LabelRole,
|
||||
self.openlp1Spacer)
|
||||
self.selectStack.addWidget(self.openlp1Widget)
|
||||
self.selectPageLayout.addLayout(self.selectStack)
|
||||
bibleImportWizard.addPage(self.selectPage)
|
||||
# License Page
|
||||
self.licenseDetailsPage = QtGui.QWizardPage()
|
||||
self.licenseDetailsPage.setObjectName(u'LicenseDetailsPage')
|
||||
self.licenseDetailsLayout = QtGui.QFormLayout(self.licenseDetailsPage)
|
||||
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.setMargin(48)
|
||||
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.setObjectName(u'ImportProgressBar')
|
||||
self.importLayout.addWidget(self.importProgressBar)
|
||||
bibleImportWizard.addPage(self.importPage)
|
||||
self.retranslateUi(bibleImportWizard)
|
||||
QtCore.QMetaObject.connectSlotsByName(bibleImportWizard)
|
||||
QtCore.QObject.connect(self.formatComboBox,
|
||||
QtCore.SIGNAL(u'currentIndexChanged(int)'), self.selectStack,
|
||||
QtCore.SLOT(u'setCurrentIndex(int)'))
|
||||
|
||||
def retranslateUi(self, bibleImportWizard):
|
||||
bibleImportWizard.setWindowTitle(
|
||||
translate('BiblesPlugin.ImportWizardForm', 'Bible Import Wizard'))
|
||||
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(
|
||||
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(
|
||||
translate('BiblesPlugin.ImportWizardForm',
|
||||
'Select the import format, and where to import from.'))
|
||||
self.formatLabel.setText(
|
||||
translate('BiblesPlugin.ImportWizardForm', 'Format:'))
|
||||
self.formatComboBox.setItemText(0,
|
||||
translate('BiblesPlugin.ImportWizardForm', 'OSIS'))
|
||||
self.formatComboBox.setItemText(1,
|
||||
translate('BiblesPlugin.ImportWizardForm', 'CSV'))
|
||||
self.formatComboBox.setItemText(2,
|
||||
translate('BiblesPlugin.ImportWizardForm', 'OpenSong'))
|
||||
self.formatComboBox.setItemText(3,
|
||||
translate('BiblesPlugin.ImportWizardForm', 'Web Download'))
|
||||
self.formatComboBox.setItemText(4,
|
||||
translate('BiblesPlugin.ImportWizardForm', 'openlp.org 1.x'))
|
||||
self.openlp1FileLabel.setText(
|
||||
translate('BiblesPlugin.ImportWizardForm', 'File location:'))
|
||||
self.osisFileLabel.setText(
|
||||
translate('BiblesPlugin.ImportWizardForm', 'File location:'))
|
||||
self.csvBooksLabel.setText(
|
||||
translate('BiblesPlugin.ImportWizardForm', 'Books location:'))
|
||||
self.csvVersesLabel.setText(
|
||||
translate('BiblesPlugin.ImportWizardForm', 'Verse location:'))
|
||||
self.openSongFileLabel.setText(
|
||||
translate('BiblesPlugin.ImportWizardForm', 'Bible filename:'))
|
||||
self.webSourceLabel.setText(
|
||||
translate('BiblesPlugin.ImportWizardForm', 'Location:'))
|
||||
self.webSourceComboBox.setItemText(0,
|
||||
translate('BiblesPlugin.ImportWizardForm', 'Crosswalk'))
|
||||
self.webSourceComboBox.setItemText(1,
|
||||
translate('BiblesPlugin.ImportWizardForm', 'BibleGateway'))
|
||||
self.webSourceComboBox.setItemText(2,
|
||||
translate('BiblesPlugin.ImportWizardForm', 'Bibleserver'))
|
||||
self.webTranslationLabel.setText(
|
||||
translate('BiblesPlugin.ImportWizardForm', 'Bible:'))
|
||||
self.webTabWidget.setTabText(
|
||||
self.webTabWidget.indexOf(self.webBibleTab),
|
||||
translate('BiblesPlugin.ImportWizardForm', 'Download Options'))
|
||||
self.webServerLabel.setText(
|
||||
translate('BiblesPlugin.ImportWizardForm', 'Server:'))
|
||||
self.webUserLabel.setText(
|
||||
translate('BiblesPlugin.ImportWizardForm', 'Username:'))
|
||||
self.webPasswordLabel.setText(
|
||||
translate('BiblesPlugin.ImportWizardForm', 'Password:'))
|
||||
self.webTabWidget.setTabText(
|
||||
self.webTabWidget.indexOf(self.webProxyTab),
|
||||
translate('BiblesPlugin.ImportWizardForm',
|
||||
'Proxy Server (Optional)'))
|
||||
self.licenseDetailsPage.setTitle(
|
||||
translate('BiblesPlugin.ImportWizardForm', 'License Details'))
|
||||
self.licenseDetailsPage.setSubTitle(
|
||||
translate('BiblesPlugin.ImportWizardForm',
|
||||
'Set up the Bible\'s license details.'))
|
||||
self.versionNameLabel.setText(
|
||||
translate('BiblesPlugin.ImportWizardForm', 'Version name:'))
|
||||
self.copyrightLabel.setText(
|
||||
translate('BiblesPlugin.ImportWizardForm', 'Copyright:'))
|
||||
self.permissionsLabel.setText(
|
||||
translate('BiblesPlugin.ImportWizardForm', 'Permissions:'))
|
||||
self.importPage.setTitle(
|
||||
translate('BiblesPlugin.ImportWizardForm', 'Importing'))
|
||||
self.importPage.setSubTitle(
|
||||
translate('BiblesPlugin.ImportWizardForm',
|
||||
'Please wait while your Bible is imported.'))
|
||||
self.importProgressLabel.setText(
|
||||
translate('BiblesPlugin.ImportWizardForm', 'Ready.'))
|
||||
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.'))
|
||||
# Align all QFormLayouts towards each other.
|
||||
width = max(self.formatLabel.minimumSizeHint().width(),
|
||||
self.osisFileLabel.minimumSizeHint().width())
|
||||
width = max(width, self.csvBooksLabel.minimumSizeHint().width())
|
||||
width = max(width, self.csvVersesLabel.minimumSizeHint().width())
|
||||
width = max(width, self.openSongFileLabel.minimumSizeHint().width())
|
||||
width = max(width, self.openlp1FileLabel.minimumSizeHint().width())
|
||||
self.formatSpacer.changeSize(width, 0, QtGui.QSizePolicy.Fixed,
|
||||
QtGui.QSizePolicy.Fixed)
|
||||
self.osisSpacer.changeSize(width, 0, QtGui.QSizePolicy.Fixed,
|
||||
QtGui.QSizePolicy.Fixed)
|
||||
self.csvSpacer.changeSize(width, 0, QtGui.QSizePolicy.Fixed,
|
||||
QtGui.QSizePolicy.Fixed)
|
||||
self.openSongSpacer.changeSize(width, 0, QtGui.QSizePolicy.Fixed,
|
||||
QtGui.QSizePolicy.Fixed)
|
||||
self.openlp1Spacer.changeSize(width, 0, QtGui.QSizePolicy.Fixed,
|
||||
QtGui.QSizePolicy.Fixed)
|
@ -76,8 +76,8 @@ class BiblesTab(SettingsTab):
|
||||
self.BibleThemeComboBox = QtGui.QComboBox(self.VerseDisplayGroupBox)
|
||||
self.BibleThemeComboBox.setSizeAdjustPolicy(
|
||||
QtGui.QComboBox.AdjustToMinimumContentsLength)
|
||||
self.BibleThemeComboBox.setSizePolicy(QtGui.QSizePolicy.Expanding,
|
||||
QtGui.QSizePolicy.Fixed)
|
||||
self.BibleThemeComboBox.setSizePolicy(
|
||||
QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Fixed)
|
||||
self.BibleThemeComboBox.addItem(u'')
|
||||
self.BibleThemeComboBox.setObjectName(u'BibleThemeComboBox')
|
||||
self.VerseDisplayLayout.addRow(self.BibleThemeLabel,
|
||||
@ -88,8 +88,8 @@ class BiblesTab(SettingsTab):
|
||||
self.VerseDisplayLayout.addRow(self.ChangeNoteLabel)
|
||||
self.leftLayout.addWidget(self.VerseDisplayGroupBox)
|
||||
self.leftLayout.addStretch()
|
||||
self.rightColumn.setSizePolicy(QtGui.QSizePolicy.Expanding,
|
||||
QtGui.QSizePolicy.Preferred)
|
||||
self.rightColumn.setSizePolicy(
|
||||
QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Preferred)
|
||||
self.rightLayout.addStretch()
|
||||
# Signals and slots
|
||||
QtCore.QObject.connect(
|
||||
|
@ -31,7 +31,7 @@ import csv
|
||||
from PyQt4 import QtCore
|
||||
|
||||
from openlp.core.lib import Receiver, translate
|
||||
from db import BibleDB
|
||||
from openlp.plugins.bibles.lib.db import BibleDB
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
@ -51,7 +51,7 @@ class CSVBible(BibleDB):
|
||||
self.booksfile = kwargs[u'booksfile']
|
||||
self.versesfile = kwargs[u'versefile']
|
||||
QtCore.QObject.connect(Receiver.get_receiver(),
|
||||
QtCore.SIGNAL(u'bibles_stop_import'), self.stop_import)
|
||||
QtCore.SIGNAL(u'openlp_stop_wizard'), self.stop_import)
|
||||
|
||||
def do_import(self):
|
||||
success = True
|
||||
@ -72,7 +72,7 @@ class CSVBible(BibleDB):
|
||||
self.create_book(unicode(line[1], details['encoding']),
|
||||
line[2], int(line[0]))
|
||||
Receiver.send_message(u'openlp_process_events')
|
||||
except IOError, IndexError:
|
||||
except (IOError, IndexError):
|
||||
log.exception(u'Loading books from file failed')
|
||||
success = False
|
||||
finally:
|
||||
|
@ -28,13 +28,14 @@ import logging
|
||||
import chardet
|
||||
import re
|
||||
|
||||
from PyQt4 import QtCore, QtGui
|
||||
from PyQt4 import QtCore
|
||||
from sqlalchemy import Column, ForeignKey, or_, Table, types
|
||||
from sqlalchemy.orm import class_mapper, mapper, relation
|
||||
from sqlalchemy.orm.exc import UnmappedClassError
|
||||
|
||||
from openlp.core.lib import Receiver, translate
|
||||
from openlp.core.lib import translate
|
||||
from openlp.core.lib.db import BaseModel, init_db, Manager
|
||||
from openlp.core.ui import criticalErrorMessageBox
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
@ -339,11 +340,11 @@ class BibleDB(QtCore.QObject, Manager):
|
||||
verse_list = []
|
||||
for book, chapter, start_verse, end_verse in reference_list:
|
||||
db_book = self.get_book(book)
|
||||
if end_verse == -1:
|
||||
end_verse = self.get_verse_count(book, chapter)
|
||||
if db_book:
|
||||
book = db_book.name
|
||||
log.debug(u'Book name corrected to "%s"', book)
|
||||
if end_verse == -1:
|
||||
end_verse = self.get_verse_count(book, chapter)
|
||||
verses = self.session.query(Verse)\
|
||||
.filter_by(book_id=db_book.id)\
|
||||
.filter_by(chapter=chapter)\
|
||||
@ -354,12 +355,11 @@ class BibleDB(QtCore.QObject, Manager):
|
||||
verse_list.extend(verses)
|
||||
else:
|
||||
log.debug(u'OpenLP failed to find book %s', book)
|
||||
Receiver.send_message(u'openlp_error_message', {
|
||||
u'title': translate('BiblesPlugin', 'No Book Found'),
|
||||
u'message': translate('BiblesPlugin', 'No matching book '
|
||||
criticalErrorMessageBox(
|
||||
translate('BiblesPlugin', 'No Book Found'),
|
||||
translate('BiblesPlugin', 'No matching book '
|
||||
'could be found in this Bible. Check that you have '
|
||||
'spelled the name of the book correctly.')
|
||||
})
|
||||
'spelled the name of the book correctly.'))
|
||||
return verse_list
|
||||
|
||||
def verse_search(self, text):
|
||||
|
@ -23,20 +23,23 @@
|
||||
# with this program; if not, write to the Free Software Foundation, Inc., 59 #
|
||||
# Temple Place, Suite 330, Boston, MA 02111-1307 USA #
|
||||
###############################################################################
|
||||
|
||||
"""
|
||||
The :mod:`http` module enables OpenLP to retrieve scripture from bible
|
||||
websites.
|
||||
"""
|
||||
import logging
|
||||
import os
|
||||
import re
|
||||
import sqlite3
|
||||
import socket
|
||||
import urllib
|
||||
import urllib2
|
||||
from HTMLParser import HTMLParseError
|
||||
|
||||
from BeautifulSoup import BeautifulSoup, NavigableString
|
||||
|
||||
from openlp.core.lib import Receiver, translate
|
||||
from openlp.core.utils import AppLocation
|
||||
from openlp.core.ui import criticalErrorMessageBox
|
||||
from openlp.core.utils import AppLocation, get_web_page
|
||||
from openlp.plugins.bibles.lib import SearchResults
|
||||
from openlp.plugins.bibles.lib.db import BibleDB, Book
|
||||
|
||||
@ -204,33 +207,19 @@ class BGExtract(object):
|
||||
url_params = urllib.urlencode(
|
||||
{u'search': u'%s %s' % (bookname, chapter),
|
||||
u'version': u'%s' % version})
|
||||
page = None
|
||||
try:
|
||||
page = urllib2.urlopen(
|
||||
u'http://www.biblegateway.com/passage/?%s' % url_params)
|
||||
log.debug(u'BibleGateway url = %s' % page.geturl())
|
||||
Receiver.send_message(u'openlp_process_events')
|
||||
except urllib2.URLError:
|
||||
log.exception(u'The web bible page could not be downloaded.')
|
||||
send_error_message(u'download')
|
||||
finally:
|
||||
if not page:
|
||||
return None
|
||||
cleaner = [(re.compile(' |<br />|\'\+\''), lambda match: '')]
|
||||
soup = None
|
||||
try:
|
||||
soup = BeautifulSoup(page, markupMassage=cleaner)
|
||||
except HTMLParseError:
|
||||
log.exception(u'BeautifulSoup could not parse the bible page.')
|
||||
Receiver.send_message(u'bibles_download_error')
|
||||
send_error_message(u'parse')
|
||||
finally:
|
||||
if not soup:
|
||||
return None
|
||||
soup = get_soup_for_bible_ref(
|
||||
u'http://www.biblegateway.com/passage/?%s' % url_params,
|
||||
cleaner=cleaner)
|
||||
if not soup:
|
||||
return None
|
||||
Receiver.send_message(u'openlp_process_events')
|
||||
footnotes = soup.findAll(u'sup', u'footnote')
|
||||
if footnotes:
|
||||
[footnote.extract() for footnote in footnotes]
|
||||
[footnote.extract() for footnote in footnotes]
|
||||
crossrefs = soup.findAll(u'sup', u'xref')
|
||||
if crossrefs:
|
||||
[crossref.extract() for crossref in crossrefs]
|
||||
cleanup = [(re.compile('\s+'), lambda match: ' ')]
|
||||
verses = BeautifulSoup(str(soup), markupMassage=cleanup)
|
||||
content = verses.find(u'div', u'result-text-style-normal')
|
||||
@ -277,36 +266,18 @@ class BSExtract(object):
|
||||
log.debug(u'get_bible_chapter %s,%s,%s', version, bookname, chapter)
|
||||
chapter_url = u'http://m.bibleserver.com/text/%s/%s%s' % \
|
||||
(version, bookname, chapter)
|
||||
|
||||
log.debug(u'URL: %s', chapter_url)
|
||||
page = None
|
||||
try:
|
||||
page = urllib2.urlopen(chapter_url)
|
||||
Receiver.send_message(u'openlp_process_events')
|
||||
except urllib2.URLError:
|
||||
log.exception(u'The web bible page could not be downloaded.')
|
||||
send_error_message(u'download')
|
||||
finally:
|
||||
if not page:
|
||||
return None
|
||||
soup = None
|
||||
try:
|
||||
soup = BeautifulSoup(page)
|
||||
except HTMLParseError:
|
||||
log.exception(u'BeautifulSoup could not parse the bible page.')
|
||||
send_error_message(u'parse')
|
||||
header = (u'Accept-Language', u'en')
|
||||
soup = get_soup_for_bible_ref(chapter_url, header)
|
||||
if not soup:
|
||||
return None
|
||||
Receiver.send_message(u'openlp_process_events')
|
||||
content = None
|
||||
try:
|
||||
content = soup.find(u'div', u'content').find(u'div').findAll(u'div')
|
||||
except:
|
||||
content = soup.find(u'div', u'content')
|
||||
if not content:
|
||||
log.exception(u'No verses found in the Bibleserver response.')
|
||||
send_error_message(u'parse')
|
||||
finally:
|
||||
if not content:
|
||||
return None
|
||||
verse_number = re.compile(r'v(\d{2})(\d{3})(\d{3}) verse')
|
||||
return None
|
||||
content = content.find(u'div').findAll(u'div')
|
||||
verse_number = re.compile(r'v(\d{1,2})(\d{3})(\d{3}) verse')
|
||||
verses = {}
|
||||
for verse in content:
|
||||
Receiver.send_message(u'openlp_process_events')
|
||||
@ -341,21 +312,8 @@ class CWExtract(object):
|
||||
urlbookname = bookname.replace(u' ', u'-')
|
||||
chapter_url = u'http://www.biblestudytools.com/%s/%s/%s.html' % \
|
||||
(version, urlbookname.lower(), chapter)
|
||||
log.debug(u'URL: %s', chapter_url)
|
||||
page = None
|
||||
try:
|
||||
page = urllib2.urlopen(chapter_url)
|
||||
Receiver.send_message(u'openlp_process_events')
|
||||
except urllib2.URLError:
|
||||
log.exception(u'The web bible page could not be downloaded.')
|
||||
send_error_message(u'download')
|
||||
return None
|
||||
soup = None
|
||||
try:
|
||||
soup = BeautifulSoup(page)
|
||||
except HTMLParseError:
|
||||
log.exception(u'BeautifulSoup could not parse the bible page.')
|
||||
send_error_message(u'parse')
|
||||
soup = get_soup_for_bible_ref(chapter_url)
|
||||
if not soup:
|
||||
return None
|
||||
Receiver.send_message(u'openlp_process_events')
|
||||
htmlverses = soup.findAll(u'span', u'versetext')
|
||||
@ -413,6 +371,8 @@ class HTTPBible(BibleDB):
|
||||
BibleDB.__init__(self, parent, **kwargs)
|
||||
self.download_source = kwargs[u'download_source']
|
||||
self.download_name = kwargs[u'download_name']
|
||||
# TODO: Clean up proxy stuff. We probably want one global proxy per
|
||||
# connection type (HTTP and HTTPS) at most.
|
||||
self.proxy_server = None
|
||||
self.proxy_username = None
|
||||
self.proxy_password = None
|
||||
@ -428,7 +388,7 @@ class HTTPBible(BibleDB):
|
||||
Run the import. This method overrides the parent class method. Returns
|
||||
``True`` on success, ``False`` on failure.
|
||||
"""
|
||||
self.wizard.importProgressBar.setMaximum(2)
|
||||
self.wizard.progressBar.setMaximum(2)
|
||||
self.wizard.incrementProgressBar('Registering bible...')
|
||||
self.create_meta(u'download source', self.download_source)
|
||||
self.create_meta(u'download name', self.download_name)
|
||||
@ -468,21 +428,20 @@ class HTTPBible(BibleDB):
|
||||
book = reference[0]
|
||||
db_book = self.get_book(book)
|
||||
if not db_book:
|
||||
book_details = self.lookup_book(book)
|
||||
book_details = HTTPBooks.get_book(book)
|
||||
if not book_details:
|
||||
Receiver.send_message(u'openlp_error_message', {
|
||||
u'title': translate('BiblesPlugin', 'No Book Found'),
|
||||
u'message': translate('BiblesPlugin', 'No matching '
|
||||
criticalErrorMessageBox(
|
||||
translate('BiblesPlugin', 'No Book Found'),
|
||||
translate('BiblesPlugin', 'No matching '
|
||||
'book could be found in this Bible. Check that you '
|
||||
'have spelled the name of the book correctly.')
|
||||
})
|
||||
'have spelled the name of the book correctly.'))
|
||||
return []
|
||||
db_book = self.create_book(book_details[u'name'],
|
||||
book_details[u'abbreviation'],
|
||||
book_details[u'testament_id'])
|
||||
book = db_book.name
|
||||
if BibleDB.get_verse_count(self, book, reference[1]) == 0:
|
||||
Receiver.send_message(u'bibles_showprogress')
|
||||
Receiver.send_message(u'cursor_busy')
|
||||
Receiver.send_message(u'openlp_process_events')
|
||||
search_results = self.get_chapter(book, reference[1])
|
||||
if search_results and search_results.has_verselist():
|
||||
@ -497,7 +456,7 @@ class HTTPBible(BibleDB):
|
||||
self.create_chapter(db_book.id, search_results.chapter,
|
||||
search_results.verselist)
|
||||
Receiver.send_message(u'openlp_process_events')
|
||||
Receiver.send_message(u'bibles_hideprogress')
|
||||
Receiver.send_message(u'cursor_normal')
|
||||
Receiver.send_message(u'openlp_process_events')
|
||||
return BibleDB.get_verses(self, reference_list)
|
||||
|
||||
@ -508,12 +467,12 @@ class HTTPBible(BibleDB):
|
||||
log.debug(u'get_chapter %s, %s', book, chapter)
|
||||
log.debug(u'source = %s', self.download_source)
|
||||
if self.download_source.lower() == u'crosswalk':
|
||||
ev = CWExtract(self.proxy_server)
|
||||
handler = CWExtract(self.proxy_server)
|
||||
elif self.download_source.lower() == u'biblegateway':
|
||||
ev = BGExtract(self.proxy_server)
|
||||
handler = BGExtract(self.proxy_server)
|
||||
elif self.download_source.lower() == u'bibleserver':
|
||||
ev = BSExtract(self.proxy_server)
|
||||
return ev.get_bible_chapter(self.download_name, book, chapter)
|
||||
handler = BSExtract(self.proxy_server)
|
||||
return handler.get_bible_chapter(self.download_name, book, chapter)
|
||||
|
||||
def get_books(self):
|
||||
"""
|
||||
@ -522,12 +481,6 @@ class HTTPBible(BibleDB):
|
||||
return [Book.populate(name=book['name'])
|
||||
for book in HTTPBooks.get_books()]
|
||||
|
||||
def lookup_book(self, book):
|
||||
"""
|
||||
Look up the name of a book.
|
||||
"""
|
||||
return HTTPBooks.get_book(book)
|
||||
|
||||
def get_chapter_count(self, book):
|
||||
"""
|
||||
Return the number of chapters in a particular book.
|
||||
@ -546,19 +499,56 @@ class HTTPBible(BibleDB):
|
||||
"""
|
||||
return HTTPBooks.get_verse_count(book, chapter)
|
||||
|
||||
def send_error_message(reason):
|
||||
if reason == u'downoad':
|
||||
Receiver.send_message(u'openlp_error_message', {
|
||||
u'title': translate('BiblePlugin.HTTPBible', 'Download Error'),
|
||||
u'message': translate('BiblePlugin.HTTPBible', 'There was a '
|
||||
def get_soup_for_bible_ref(reference_url, header=None, cleaner=None):
|
||||
"""
|
||||
Gets a webpage and returns a parsed and optionally cleaned soup or None.
|
||||
|
||||
``reference_url``
|
||||
The URL to obtain the soup from.
|
||||
|
||||
``header``
|
||||
An optional HTTP header to pass to the bible web server.
|
||||
|
||||
``cleaner``
|
||||
An optional regex to use during webpage parsing.
|
||||
"""
|
||||
if not reference_url:
|
||||
return None
|
||||
page = get_web_page(reference_url, header, True)
|
||||
if not page:
|
||||
send_error_message(u'download')
|
||||
return None
|
||||
soup = None
|
||||
try:
|
||||
if cleaner:
|
||||
soup = BeautifulSoup(page, markupMassage=cleaner)
|
||||
else:
|
||||
soup = BeautifulSoup(page)
|
||||
except HTMLParseError:
|
||||
log.exception(u'BeautifulSoup could not parse the bible page.')
|
||||
if not soup:
|
||||
send_error_message(u'parse')
|
||||
return None
|
||||
Receiver.send_message(u'openlp_process_events')
|
||||
return soup
|
||||
|
||||
def send_error_message(error_type):
|
||||
"""
|
||||
Send a standard error message informing the user of an issue.
|
||||
|
||||
``error_type``
|
||||
The type of error that occured for the issue.
|
||||
"""
|
||||
if error_type == u'download':
|
||||
criticalErrorMessageBox(
|
||||
translate('BiblePlugin.HTTPBible', 'Download Error'),
|
||||
translate('BiblePlugin.HTTPBible', 'There was a '
|
||||
'problem downloading your verse selection. Please check your '
|
||||
'Internet connection, and if this error continues to occur '
|
||||
'consider reporting a bug.')
|
||||
})
|
||||
elif reason == u'parse':
|
||||
Receiver.send_message(u'openlp_error_message', {
|
||||
u'title': translate('BiblePlugin.HTTPBible', 'Parse Error'),
|
||||
u'message': translate('BiblePlugin.HTTPBible', 'There was a '
|
||||
'please consider reporting a bug.'))
|
||||
elif error_type == u'parse':
|
||||
criticalErrorMessageBox(
|
||||
translate('BiblePlugin.HTTPBible', 'Parse Error'),
|
||||
translate('BiblePlugin.HTTPBible', 'There was a '
|
||||
'problem extracting your verse selection. If this error continues '
|
||||
'continues to occur consider reporting a bug.')
|
||||
})
|
||||
'to occur please consider reporting a bug.'))
|
||||
|
@ -26,7 +26,7 @@
|
||||
|
||||
import logging
|
||||
|
||||
from PyQt4 import QtCore, QtGui
|
||||
from PyQt4 import QtCore
|
||||
|
||||
from openlp.core.lib import Receiver, SettingsManager, translate
|
||||
from openlp.core.utils import AppLocation
|
||||
@ -273,10 +273,10 @@ class BibleManager(object):
|
||||
Receiver.send_message(u'openlp_information_message', {
|
||||
u'title': translate('BiblesPlugin.BibleManager',
|
||||
'Scripture Reference Error'),
|
||||
u'message': translate('BiblesPlugin.BibleManager', 'Your scripture '
|
||||
'reference is either not supported by OpenLP or is invalid. '
|
||||
'Please make sure your reference conforms to one of the '
|
||||
'following patterns:\n\n'
|
||||
u'message': translate('BiblesPlugin.BibleManager',
|
||||
'Your scripture reference is either not supported by OpenLP '
|
||||
'or is invalid. Please make sure your reference conforms to '
|
||||
'one of the following patterns:\n\n'
|
||||
'Book Chapter\n'
|
||||
'Book Chapter-Chapter\n'
|
||||
'Book Chapter:Verse-Verse\n'
|
||||
|
@ -25,12 +25,12 @@
|
||||
###############################################################################
|
||||
|
||||
import logging
|
||||
import time
|
||||
|
||||
from PyQt4 import QtCore, QtGui
|
||||
|
||||
from openlp.core.lib import MediaManagerItem, Receiver, BaseListWithDnD, \
|
||||
ItemCapabilities, translate
|
||||
from openlp.core.ui import criticalErrorMessageBox
|
||||
from openlp.plugins.bibles.forms import BibleImportForm
|
||||
from openlp.plugins.bibles.lib import get_reference_match
|
||||
|
||||
@ -44,10 +44,6 @@ class BibleListView(BaseListWithDnD):
|
||||
self.PluginName = u'Bibles'
|
||||
BaseListWithDnD.__init__(self, parent)
|
||||
|
||||
def resizeEvent(self, event):
|
||||
self.parent().onListViewResize(event.size().width(),
|
||||
event.size().width())
|
||||
|
||||
|
||||
class BibleMediaItem(MediaManagerItem):
|
||||
"""
|
||||
@ -86,6 +82,8 @@ class BibleMediaItem(MediaManagerItem):
|
||||
self.quickVersionLabel = QtGui.QLabel(self.quickTab)
|
||||
self.quickVersionLabel.setObjectName(u'quickVersionLabel')
|
||||
self.quickVersionComboBox = QtGui.QComboBox(self.quickTab)
|
||||
self.quickVersionComboBox.setSizeAdjustPolicy(
|
||||
QtGui.QComboBox.AdjustToMinimumContentsLength)
|
||||
self.quickVersionComboBox.setSizePolicy(
|
||||
QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Fixed)
|
||||
self.quickVersionComboBox.setObjectName(u'quickVersionComboBox')
|
||||
@ -95,6 +93,8 @@ class BibleMediaItem(MediaManagerItem):
|
||||
self.quickSecondLabel = QtGui.QLabel(self.quickTab)
|
||||
self.quickSecondLabel.setObjectName(u'quickSecondLabel')
|
||||
self.quickSecondComboBox = QtGui.QComboBox(self.quickTab)
|
||||
self.quickSecondComboBox.setSizeAdjustPolicy(
|
||||
QtGui.QComboBox.AdjustToMinimumContentsLength)
|
||||
self.quickSecondComboBox.setSizePolicy(
|
||||
QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Fixed)
|
||||
self.quickSecondComboBox.setObjectName(u'quickSecondComboBox')
|
||||
@ -103,6 +103,8 @@ class BibleMediaItem(MediaManagerItem):
|
||||
self.quickSearchTypeLabel = QtGui.QLabel(self.quickTab)
|
||||
self.quickSearchTypeLabel.setObjectName(u'quickSearchTypeLabel')
|
||||
self.quickSearchComboBox = QtGui.QComboBox(self.quickTab)
|
||||
self.quickSearchComboBox.setSizeAdjustPolicy(
|
||||
QtGui.QComboBox.AdjustToMinimumContentsLength)
|
||||
self.quickSearchComboBox.setSizePolicy(
|
||||
QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Fixed)
|
||||
self.quickSearchComboBox.setObjectName(u'quickSearchComboBox')
|
||||
@ -118,6 +120,8 @@ class BibleMediaItem(MediaManagerItem):
|
||||
self.quickClearLabel = QtGui.QLabel(self.quickTab)
|
||||
self.quickClearLabel.setObjectName(u'quickClearLabel')
|
||||
self.quickClearComboBox = QtGui.QComboBox(self.quickTab)
|
||||
self.quickClearComboBox.setSizeAdjustPolicy(
|
||||
QtGui.QComboBox.AdjustToMinimumContentsLength)
|
||||
self.quickClearComboBox.setSizePolicy(
|
||||
QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Fixed)
|
||||
self.quickClearComboBox.setObjectName(u'quickClearComboBox')
|
||||
@ -129,9 +133,6 @@ class BibleMediaItem(MediaManagerItem):
|
||||
self.quickSearchButton.setObjectName(u'quickSearchButton')
|
||||
self.quickSearchButtonLayout.addWidget(self.quickSearchButton)
|
||||
self.quickLayout.addRow(self.quickSearchButtonLayout)
|
||||
self.quickMessage = QtGui.QLabel(self.quickTab)
|
||||
self.quickMessage.setObjectName(u'quickMessage')
|
||||
self.quickLayout.addRow(self.quickMessage)
|
||||
self.searchTabWidget.addTab(self.quickTab,
|
||||
translate('BiblesPlugin.MediaItem', 'Quick'))
|
||||
# Add the Advanced Search tab.
|
||||
@ -144,6 +145,8 @@ class BibleMediaItem(MediaManagerItem):
|
||||
self.advancedLayout.addWidget(self.advancedVersionLabel, 0, 0,
|
||||
QtCore.Qt.AlignRight)
|
||||
self.advancedVersionComboBox = QtGui.QComboBox(self.advancedTab)
|
||||
self.advancedVersionComboBox.setSizeAdjustPolicy(
|
||||
QtGui.QComboBox.AdjustToMinimumContentsLength)
|
||||
self.advancedVersionComboBox.setSizePolicy(
|
||||
QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Fixed)
|
||||
self.advancedVersionComboBox.setObjectName(u'advancedVersionComboBox')
|
||||
@ -154,6 +157,8 @@ class BibleMediaItem(MediaManagerItem):
|
||||
self.advancedLayout.addWidget(self.advancedSecondLabel, 1, 0,
|
||||
QtCore.Qt.AlignRight)
|
||||
self.advancedSecondComboBox = QtGui.QComboBox(self.advancedTab)
|
||||
self.advancedSecondComboBox.setSizeAdjustPolicy(
|
||||
QtGui.QComboBox.AdjustToMinimumContentsLength)
|
||||
self.advancedSecondComboBox.setSizePolicy(
|
||||
QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Fixed)
|
||||
self.advancedSecondComboBox.setObjectName(u'advancedSecondComboBox')
|
||||
@ -164,6 +169,8 @@ class BibleMediaItem(MediaManagerItem):
|
||||
self.advancedLayout.addWidget(self.advancedBookLabel, 2, 0,
|
||||
QtCore.Qt.AlignRight)
|
||||
self.advancedBookComboBox = QtGui.QComboBox(self.advancedTab)
|
||||
self.advancedBookComboBox.setSizeAdjustPolicy(
|
||||
QtGui.QComboBox.AdjustToMinimumContentsLength)
|
||||
self.advancedBookComboBox.setSizePolicy(
|
||||
QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Fixed)
|
||||
self.advancedBookComboBox.setObjectName(u'advancedBookComboBox')
|
||||
@ -201,6 +208,8 @@ class BibleMediaItem(MediaManagerItem):
|
||||
self.advancedLayout.addWidget(self.advancedClearLabel, 6, 0,
|
||||
QtCore.Qt.AlignRight)
|
||||
self.advancedClearComboBox = QtGui.QComboBox(self.quickTab)
|
||||
self.advancedClearComboBox.setSizeAdjustPolicy(
|
||||
QtGui.QComboBox.AdjustToMinimumContentsLength)
|
||||
self.advancedClearComboBox.setSizePolicy(
|
||||
QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Fixed)
|
||||
self.advancedClearComboBox.setObjectName(u'advancedClearComboBox')
|
||||
@ -215,9 +224,6 @@ class BibleMediaItem(MediaManagerItem):
|
||||
self.advancedSearchButtonLayout.addWidget(self.advancedSearchButton)
|
||||
self.advancedLayout.addLayout(
|
||||
self.advancedSearchButtonLayout, 7, 0, 1, 3)
|
||||
self.advancedMessage = QtGui.QLabel(self.advancedTab)
|
||||
self.advancedMessage.setObjectName(u'advancedMessage')
|
||||
self.advancedLayout.addWidget(self.advancedMessage, 8, 0, 1, 3)
|
||||
self.searchTabWidget.addTab(self.advancedTab,
|
||||
translate('BiblesPlugin.MediaItem', 'Advanced'))
|
||||
# Add the search tab widget to the page layout.
|
||||
@ -247,22 +253,9 @@ class BibleMediaItem(MediaManagerItem):
|
||||
# Other stuff
|
||||
QtCore.QObject.connect(self.quickSearchEdit,
|
||||
QtCore.SIGNAL(u'returnPressed()'), self.onQuickSearchButton)
|
||||
QtCore.QObject.connect(Receiver.get_receiver(),
|
||||
QtCore.SIGNAL(u'bibles_showprogress'), self.onSearchProgressShow)
|
||||
QtCore.QObject.connect(Receiver.get_receiver(),
|
||||
QtCore.SIGNAL(u'bibles_hideprogress'), self.onSearchProgressHide)
|
||||
|
||||
def addListViewToToolBar(self):
|
||||
MediaManagerItem.addListViewToToolBar(self)
|
||||
# Progress Bar
|
||||
self.SearchProgress = QtGui.QProgressBar(self)
|
||||
self.SearchProgress.setFormat('')
|
||||
self.SearchProgress.setMinimum(0)
|
||||
self.SearchProgress.setMaximum(0)
|
||||
self.SearchProgress.setGeometry(self.listView.geometry().left(),
|
||||
self.listView.geometry().top(), 81, 23)
|
||||
self.SearchProgress.setVisible(False)
|
||||
self.SearchProgress.setObjectName(u'SearchProgress')
|
||||
|
||||
def configUpdated(self):
|
||||
log.debug(u'configUpdated')
|
||||
@ -331,30 +324,11 @@ class BibleMediaItem(MediaManagerItem):
|
||||
self.configUpdated()
|
||||
log.debug(u'bible manager initialise complete')
|
||||
|
||||
def setQuickMessage(self, text):
|
||||
self.quickMessage.setText(text)
|
||||
self.advancedMessage.setText(text)
|
||||
Receiver.send_message(u'openlp_process_events')
|
||||
# Minor delay to get the events processed.
|
||||
time.sleep(0.1)
|
||||
|
||||
def onListViewResize(self, width, height):
|
||||
listViewGeometry = self.listView.geometry()
|
||||
self.SearchProgress.setGeometry(listViewGeometry.x(),
|
||||
(listViewGeometry.y() + listViewGeometry.height()) - 23, 81, 23)
|
||||
|
||||
def onSearchProgressShow(self):
|
||||
self.SearchProgress.setVisible(True)
|
||||
Receiver.send_message(u'openlp_process_events')
|
||||
|
||||
def onSearchProgressHide(self):
|
||||
self.SearchProgress.setVisible(False)
|
||||
|
||||
def onImportClick(self):
|
||||
if not hasattr(self, u'import_wizard'):
|
||||
self.import_wizard = BibleImportForm(self, self.parent.manager,
|
||||
self.parent)
|
||||
# If the import was not canceled then reload.
|
||||
# If the import was not cancelled then reload.
|
||||
if self.import_wizard.exec_():
|
||||
self.reloadBibles()
|
||||
|
||||
@ -416,11 +390,10 @@ class BibleMediaItem(MediaManagerItem):
|
||||
verse_count = self.parent.manager.get_verse_count(bible, book, 1)
|
||||
if verse_count == 0:
|
||||
self.advancedSearchButton.setEnabled(False)
|
||||
self.advancedMessage.setText(
|
||||
translate('BiblesPlugin.MediaItem', 'Bible not fully loaded.'))
|
||||
criticalErrorMessageBox(message=translate('BiblePlugin.MediaItem',
|
||||
'Bible not fully loaded'))
|
||||
else:
|
||||
self.advancedSearchButton.setEnabled(True)
|
||||
self.advancedMessage.setText(u'')
|
||||
self.adjustComboBox(1, self.chapter_count, self.advancedFromChapter)
|
||||
self.adjustComboBox(1, self.chapter_count, self.advancedToChapter)
|
||||
self.adjustComboBox(1, verse_count, self.advancedFromVerse)
|
||||
@ -559,13 +532,11 @@ class BibleMediaItem(MediaManagerItem):
|
||||
if item_second_bible and second_bible or not item_second_bible and \
|
||||
not second_bible:
|
||||
self.displayResults(bible, second_bible)
|
||||
elif QtGui.QMessageBox.critical(self,
|
||||
translate('BiblePlugin.MediaItem', 'Error'),
|
||||
translate('BiblePlugin.MediaItem', 'You cannot combine single '
|
||||
'and second bible verses. Do you want to delete your search '
|
||||
'results and start a new search?'),
|
||||
QtGui.QMessageBox.StandardButtons(QtGui.QMessageBox.No |
|
||||
QtGui.QMessageBox.Yes)) == QtGui.QMessageBox.Yes:
|
||||
elif criticalErrorMessageBox(
|
||||
message=translate('BiblePlugin.MediaItem',
|
||||
'You cannot combine single and second bible verses. Do you '
|
||||
'want to delete your search results and start a new search?'),
|
||||
parent=self, question=True) == QtGui.QMessageBox.Yes:
|
||||
self.listView.clear()
|
||||
self.displayResults(bible, second_bible)
|
||||
else:
|
||||
@ -590,6 +561,7 @@ class BibleMediaItem(MediaManagerItem):
|
||||
second_bible, text)
|
||||
else:
|
||||
# We are doing a 'Text Search'.
|
||||
Receiver.send_message(u'cursor_busy')
|
||||
bibles = self.parent.manager.get_bibles()
|
||||
self.search_results = self.parent.manager.verse_search(bible,
|
||||
second_bible, text)
|
||||
@ -608,18 +580,17 @@ class BibleMediaItem(MediaManagerItem):
|
||||
if item_second_bible and second_bible or not item_second_bible and \
|
||||
not second_bible:
|
||||
self.displayResults(bible, second_bible)
|
||||
elif QtGui.QMessageBox.critical(self,
|
||||
translate('BiblePlugin.MediaItem', 'Error'),
|
||||
translate('BiblePlugin.MediaItem', 'You cannot combine single '
|
||||
'and second bible verses. Do you want to delete your search '
|
||||
'results and start a new search?'),
|
||||
QtGui.QMessageBox.StandardButtons(QtGui.QMessageBox.No |
|
||||
QtGui.QMessageBox.Yes)) == QtGui.QMessageBox.Yes:
|
||||
elif criticalErrorMessageBox(
|
||||
message=translate('BiblePlugin.MediaItem',
|
||||
'You cannot combine single and second bible verses. Do you '
|
||||
'want to delete your search results and start a new search?'),
|
||||
parent=self, question=True) == QtGui.QMessageBox.Yes:
|
||||
self.listView.clear()
|
||||
self.displayResults(bible, second_bible)
|
||||
elif self.search_results:
|
||||
self.displayResults(bible, second_bible)
|
||||
self.quickSearchButton.setEnabled(True)
|
||||
Receiver.send_message(u'cursor_normal')
|
||||
|
||||
def displayResults(self, bible, second_bible=u''):
|
||||
"""
|
||||
@ -709,11 +680,11 @@ class BibleMediaItem(MediaManagerItem):
|
||||
if len(items) == 0:
|
||||
return False
|
||||
bible_text = u''
|
||||
old_item = None
|
||||
old_chapter = -1
|
||||
raw_footer = []
|
||||
raw_slides = []
|
||||
raw_title = []
|
||||
first_item = True
|
||||
for item in items:
|
||||
bitem = self.listView.item(item.row())
|
||||
book = self._decodeQtObject(bitem, 'book')
|
||||
@ -739,24 +710,23 @@ class BibleMediaItem(MediaManagerItem):
|
||||
second_copyright, second_permissions)
|
||||
if footer not in raw_footer:
|
||||
raw_footer.append(footer)
|
||||
bible_text = u'%s\u00a0%s\n\n%s\u00a0%s' % (verse_text, text,
|
||||
bible_text = u'%s %s\n\n%s %s' % (verse_text, text,
|
||||
verse_text, second_text)
|
||||
raw_slides.append(bible_text)
|
||||
raw_slides.append(bible_text.rstrip())
|
||||
bible_text = u''
|
||||
# If we are 'Verse Per Slide' then create a new slide.
|
||||
elif self.parent.settings_tab.layout_style == 0:
|
||||
bible_text = u'%s\u00a0%s' % (verse_text, text)
|
||||
raw_slides.append(bible_text)
|
||||
bible_text = u'%s %s' % (verse_text, text)
|
||||
raw_slides.append(bible_text.rstrip())
|
||||
bible_text = u''
|
||||
# If we are 'Verse Per Line' then force a new line.
|
||||
elif self.parent.settings_tab.layout_style == 1:
|
||||
bible_text = u'%s %s\u00a0%s\n' % (bible_text, verse_text, text)
|
||||
bible_text = u'%s %s %s\n' % (bible_text, verse_text, text)
|
||||
# We have to be 'Continuous'.
|
||||
else:
|
||||
bible_text = u'%s %s\u00a0%s\n' % (bible_text, verse_text, text)
|
||||
if first_item:
|
||||
bible_text = u'%s %s %s\n' % (bible_text, verse_text, text)
|
||||
if not old_item:
|
||||
start_item = item
|
||||
first_item = False
|
||||
elif self.checkTitle(item, old_item):
|
||||
raw_title.append(self.formatTitle(start_item, old_item))
|
||||
start_item = item
|
||||
@ -765,7 +735,7 @@ class BibleMediaItem(MediaManagerItem):
|
||||
raw_title.append(self.formatTitle(start_item, item))
|
||||
# If there are no more items we check whether we have to add bible_text.
|
||||
if bible_text:
|
||||
raw_slides.append(bible_text)
|
||||
raw_slides.append(bible_text.lstrip())
|
||||
bible_text = u''
|
||||
# Service Item: Capabilities
|
||||
if self.parent.settings_tab.layout_style == 2 and not second_bible:
|
||||
|
@ -30,7 +30,7 @@ import sqlite
|
||||
from PyQt4 import QtCore
|
||||
|
||||
from openlp.core.lib import Receiver, translate
|
||||
from db import BibleDB
|
||||
from openlp.plugins.bibles.lib.db import BibleDB
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
@ -46,7 +46,7 @@ class OpenLP1Bible(BibleDB):
|
||||
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)
|
||||
QtCore.SIGNAL(u'openlp_stop_wizard'), self.stop_import)
|
||||
|
||||
def do_import(self):
|
||||
"""
|
||||
@ -62,7 +62,7 @@ class OpenLP1Bible(BibleDB):
|
||||
# Create all books.
|
||||
cursor.execute(u'SELECT id, testament_id, name, abbreviation FROM book')
|
||||
books = cursor.fetchall()
|
||||
self.wizard.importProgressBar.setMaximum(len(books) + 1)
|
||||
self.wizard.progressBar.setMaximum(len(books) + 1)
|
||||
for book in books:
|
||||
if self.stop_import_flag:
|
||||
connection.close()
|
||||
|
@ -30,7 +30,7 @@ from lxml import objectify
|
||||
from PyQt4 import QtCore
|
||||
|
||||
from openlp.core.lib import Receiver, translate
|
||||
from db import BibleDB
|
||||
from openlp.plugins.bibles.lib.db import BibleDB
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
@ -48,7 +48,7 @@ class OpenSongBible(BibleDB):
|
||||
BibleDB.__init__(self, parent, **kwargs)
|
||||
self.filename = kwargs['filename']
|
||||
QtCore.QObject.connect(Receiver.get_receiver(),
|
||||
QtCore.SIGNAL(u'bibles_stop_import'), self.stop_import)
|
||||
QtCore.SIGNAL(u'openlp_stop_wizard'), self.stop_import)
|
||||
|
||||
def do_import(self):
|
||||
"""
|
||||
@ -79,7 +79,7 @@ class OpenSongBible(BibleDB):
|
||||
break
|
||||
self.create_verse(
|
||||
db_book.id,
|
||||
int(chapter.attrib[u'n']),
|
||||
int(chapter.attrib[u'n'].split()[-1]),
|
||||
int(verse.attrib[u'n']),
|
||||
unicode(verse.text)
|
||||
)
|
||||
@ -87,9 +87,9 @@ class OpenSongBible(BibleDB):
|
||||
self.wizard.incrementProgressBar(unicode(translate(
|
||||
'BiblesPlugin.Opensong', 'Importing %s %s...',
|
||||
'Importing <book name> <chapter>...')) %
|
||||
(db_book.name, int(chapter.attrib[u'n'])))
|
||||
(db_book.name, int(chapter.attrib[u'n'].split()[-1])))
|
||||
self.session.commit()
|
||||
except IOError, AttributeError:
|
||||
except (IOError, AttributeError):
|
||||
log.exception(u'Loading bible from OpenSong file failed')
|
||||
success = False
|
||||
finally:
|
||||
|
@ -35,7 +35,7 @@ from PyQt4 import QtCore
|
||||
|
||||
from openlp.core.lib import Receiver, translate
|
||||
from openlp.core.utils import AppLocation
|
||||
from db import BibleDB
|
||||
from openlp.plugins.bibles.lib.db import BibleDB
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
@ -87,7 +87,7 @@ class OSISBible(BibleDB):
|
||||
if fbibles:
|
||||
fbibles.close()
|
||||
QtCore.QObject.connect(Receiver.get_receiver(),
|
||||
QtCore.SIGNAL(u'bibles_stop_import'), self.stop_import)
|
||||
QtCore.SIGNAL(u'openlp_stop_wizard'), self.stop_import)
|
||||
|
||||
def do_import(self):
|
||||
"""
|
||||
@ -134,9 +134,9 @@ class OSISBible(BibleDB):
|
||||
testament)
|
||||
if last_chapter == 0:
|
||||
if book == u'Gen':
|
||||
self.wizard.importProgressBar.setMaximum(1188)
|
||||
self.wizard.progressBar.setMaximum(1188)
|
||||
else:
|
||||
self.wizard.importProgressBar.setMaximum(260)
|
||||
self.wizard.progressBar.setMaximum(260)
|
||||
if last_chapter != chapter:
|
||||
if last_chapter != 0:
|
||||
self.session.commit()
|
||||
|
@ -29,6 +29,7 @@ import logging
|
||||
from PyQt4 import QtCore, QtGui
|
||||
|
||||
from openlp.core.lib import Receiver, translate
|
||||
from openlp.core.ui import criticalErrorMessageBox
|
||||
from openlp.plugins.custom.lib import CustomXMLBuilder, CustomXMLParser
|
||||
from openlp.plugins.custom.lib.db import CustomSlide
|
||||
from editcustomdialog import Ui_CustomEditDialog
|
||||
@ -151,8 +152,7 @@ class EditCustomForm(QtGui.QDialog, Ui_CustomEditDialog):
|
||||
"""
|
||||
valid, message = self._validate()
|
||||
if not valid:
|
||||
QtGui.QMessageBox.critical(self,
|
||||
translate('CustomPlugin.EditCustomForm', 'Error'), message)
|
||||
criticalErrorMessageBox(message=message)
|
||||
return False
|
||||
sxml = CustomXMLBuilder()
|
||||
sxml.new_document()
|
||||
@ -265,4 +265,4 @@ class EditCustomForm(QtGui.QDialog, Ui_CustomEditDialog):
|
||||
if self.slideListView.count() == 0:
|
||||
return False, translate('CustomPlugin.EditCustomForm',
|
||||
'You need to add at least one slide')
|
||||
return True, u''
|
||||
return True, u''
|
||||
|
@ -30,9 +30,10 @@ import os
|
||||
from PyQt4 import QtCore, QtGui
|
||||
|
||||
from openlp.core.lib import MediaManagerItem, BaseListWithDnD, build_icon, \
|
||||
context_menu_action, ItemCapabilities, SettingsManager, translate, \
|
||||
check_item_selected, Receiver
|
||||
from openlp.core.utils import AppLocation, get_images_filter
|
||||
ItemCapabilities, SettingsManager, translate, check_item_selected, \
|
||||
check_directory_exists
|
||||
from openlp.core.ui import criticalErrorMessageBox
|
||||
from openlp.core.utils import AppLocation, delete_file, get_images_filter
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
@ -88,8 +89,7 @@ class ImageMediaItem(MediaManagerItem):
|
||||
self.servicePath = os.path.join(
|
||||
AppLocation.get_section_data_path(self.settingsSection),
|
||||
u'thumbnails')
|
||||
if not os.path.exists(self.servicePath):
|
||||
os.mkdir(self.servicePath)
|
||||
check_directory_exists(self.servicePath)
|
||||
self.loadList(SettingsManager.load_list(
|
||||
self.settingsSection, self.settingsSection))
|
||||
|
||||
@ -116,12 +116,8 @@ class ImageMediaItem(MediaManagerItem):
|
||||
for row in row_list:
|
||||
text = self.listView.item(row)
|
||||
if text:
|
||||
try:
|
||||
os.remove(os.path.join(self.servicePath,
|
||||
unicode(text.text())))
|
||||
except OSError:
|
||||
# if not present do not worry
|
||||
pass
|
||||
delete_file(os.path.join(self.servicePath,
|
||||
unicode(text.text())))
|
||||
self.listView.takeItem(row)
|
||||
SettingsManager.set_list(self.settingsSection,
|
||||
self.settingsSection, self.getFileList())
|
||||
@ -165,7 +161,7 @@ class ImageMediaItem(MediaManagerItem):
|
||||
items.remove(item)
|
||||
# We cannot continue, as all images do not exist.
|
||||
if not items:
|
||||
QtGui.QMessageBox.critical(self,
|
||||
criticalErrorMessageBox(
|
||||
translate('ImagePlugin.MediaItem', 'Missing Image(s)'),
|
||||
unicode(translate('ImagePlugin.MediaItem',
|
||||
'The following image(s) no longer exist: %s')) %
|
||||
@ -191,12 +187,15 @@ class ImageMediaItem(MediaManagerItem):
|
||||
return False
|
||||
|
||||
def onResetClick(self):
|
||||
"""
|
||||
Called to reset the Live backgound with the image selected,
|
||||
"""
|
||||
self.resetAction.setVisible(False)
|
||||
self.parent.liveController.display.resetImage()
|
||||
|
||||
def onReplaceClick(self):
|
||||
"""
|
||||
Called to replace Live backgound with the video selected
|
||||
Called to replace Live backgound with the image selected.
|
||||
"""
|
||||
if check_item_selected(self.listView,
|
||||
translate('ImagePlugin.MediaItem',
|
||||
@ -209,12 +208,11 @@ class ImageMediaItem(MediaManagerItem):
|
||||
self.parent.liveController.display.directImage(name, filename)
|
||||
self.resetAction.setVisible(True)
|
||||
else:
|
||||
Receiver.send_message(u'openlp_error_message', {
|
||||
u'title': translate('ImagePlugin.MediaItem',
|
||||
'Live Background Error'),
|
||||
u'message': unicode(translate('ImagePlugin.MediaItem',
|
||||
criticalErrorMessageBox(
|
||||
translate('ImagePlugin.MediaItem', 'Live Background Error'),
|
||||
unicode(translate('ImagePlugin.MediaItem',
|
||||
'There was a problem replacing your background, '
|
||||
'the image file "%s" no longer exists.')) % filename})
|
||||
'the image file "%s" no longer exists.')) % filename)
|
||||
|
||||
def onPreviewClick(self):
|
||||
MediaManagerItem.onPreviewClick(self)
|
||||
|
@ -30,8 +30,8 @@ import os
|
||||
from PyQt4 import QtCore, QtGui
|
||||
|
||||
from openlp.core.lib import MediaManagerItem, BaseListWithDnD, build_icon, \
|
||||
ItemCapabilities, SettingsManager, translate, check_item_selected, \
|
||||
context_menu_action, Receiver
|
||||
ItemCapabilities, SettingsManager, translate, check_item_selected
|
||||
from openlp.core.ui import criticalErrorMessageBox
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
@ -40,6 +40,7 @@ class MediaListView(BaseListWithDnD):
|
||||
self.PluginName = u'Media'
|
||||
BaseListWithDnD.__init__(self, parent)
|
||||
|
||||
|
||||
class MediaMediaItem(MediaManagerItem):
|
||||
"""
|
||||
This is the custom media manager item for Media Slides.
|
||||
@ -92,10 +93,16 @@ class MediaMediaItem(MediaManagerItem):
|
||||
self.resetAction.setVisible(False)
|
||||
|
||||
def onResetClick(self):
|
||||
"""
|
||||
Called to reset the Live backgound with the media selected,
|
||||
"""
|
||||
self.resetAction.setVisible(False)
|
||||
self.parent.liveController.display.resetVideo()
|
||||
|
||||
def onReplaceClick(self):
|
||||
"""
|
||||
Called to replace Live backgound with the media selected.
|
||||
"""
|
||||
if check_item_selected(self.listView,
|
||||
translate('MediaPlugin.MediaItem',
|
||||
'You must select a media file to replace the background with.')):
|
||||
@ -106,12 +113,11 @@ class MediaMediaItem(MediaManagerItem):
|
||||
self.parent.liveController.display.video(filename, 0, True)
|
||||
self.resetAction.setVisible(True)
|
||||
else:
|
||||
Receiver.send_message(u'openlp_error_message', {
|
||||
u'title': translate('MediaPlugin.MediaItem',
|
||||
criticalErrorMessageBox(translate('MediaPlugin.MediaItem',
|
||||
'Live Background Error'),
|
||||
u'message': unicode(translate('MediaPlugin.MediaItem',
|
||||
unicode(translate('MediaPlugin.MediaItem',
|
||||
'There was a problem replacing your background, '
|
||||
'the media file "%s" no longer exists.')) % filename})
|
||||
'the media file "%s" no longer exists.')) % filename)
|
||||
|
||||
def generateSlideData(self, service_item, item=None, xmlVersion=False):
|
||||
if item is None:
|
||||
@ -131,9 +137,8 @@ class MediaMediaItem(MediaManagerItem):
|
||||
return True
|
||||
else:
|
||||
# File is no longer present
|
||||
QtGui.QMessageBox.critical(
|
||||
self, translate('MediaPlugin.MediaItem',
|
||||
'Missing Media File'),
|
||||
criticalErrorMessageBox(
|
||||
translate('MediaPlugin.MediaItem', 'Missing Media File'),
|
||||
unicode(translate('MediaPlugin.MediaItem',
|
||||
'The file %s no longer exists.')) % filename)
|
||||
return False
|
||||
|
@ -51,6 +51,7 @@ else:
|
||||
|
||||
from PyQt4 import QtCore
|
||||
|
||||
from openlp.core.utils import delete_file
|
||||
from presentationcontroller import PresentationController, PresentationDocument
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
@ -169,7 +170,7 @@ class ImpressController(PresentationController):
|
||||
try:
|
||||
return Dispatch(u'com.sun.star.ServiceManager')
|
||||
except pywintypes.com_error:
|
||||
log.warn(u'Failed to get COM service manager. '
|
||||
log.exception(u'Failed to get COM service manager. '
|
||||
u'Impress Controller has been disabled')
|
||||
return None
|
||||
|
||||
@ -257,7 +258,6 @@ class ImpressDocument(PresentationDocument):
|
||||
except:
|
||||
log.exception(u'Failed to load presentation %s' % url)
|
||||
return False
|
||||
|
||||
self.presentation = self.document.getPresentation()
|
||||
self.presentation.Display = \
|
||||
self.controller.plugin.renderManager.screens.current_display + 1
|
||||
@ -293,8 +293,7 @@ class ImpressDocument(PresentationDocument):
|
||||
try:
|
||||
doc.storeToURL(urlpath, props)
|
||||
self.convert_thumbnail(path, idx + 1)
|
||||
if os.path.exists(path):
|
||||
os.remove(path)
|
||||
delete_file(path)
|
||||
except:
|
||||
log.exception(u'%s - Unable to store openoffice preview' % path)
|
||||
|
||||
@ -327,8 +326,7 @@ class ImpressDocument(PresentationDocument):
|
||||
self.presentation = None
|
||||
self.document.dispose()
|
||||
except:
|
||||
#We tried!
|
||||
pass
|
||||
log.exception("Closing presentation failed")
|
||||
self.document = None
|
||||
self.controller.remove_doc(self)
|
||||
|
||||
@ -339,13 +337,14 @@ class ImpressDocument(PresentationDocument):
|
||||
log.debug(u'is loaded OpenOffice')
|
||||
#print "is_loaded "
|
||||
if self.presentation is None or self.document is None:
|
||||
#print "no present or document"
|
||||
log.debug("is_loaded: no presentation or document")
|
||||
return False
|
||||
try:
|
||||
if self.document.getPresentation() is None:
|
||||
#print "no getPresentation"
|
||||
log.debug("getPresentation failed to find a presentation")
|
||||
return False
|
||||
except:
|
||||
log.exception("getPresentation failed to find a presentation")
|
||||
return False
|
||||
return True
|
||||
|
||||
|
@ -31,6 +31,7 @@ from PyQt4 import QtCore, QtGui
|
||||
|
||||
from openlp.core.lib import MediaManagerItem, BaseListWithDnD, build_icon, \
|
||||
SettingsManager, translate, check_item_selected, Receiver, ItemCapabilities
|
||||
from openlp.core.ui import criticalErrorMessageBox
|
||||
from openlp.plugins.presentations.lib import MessageListener
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
@ -116,8 +117,10 @@ class PresentationMediaItem(MediaManagerItem):
|
||||
self.displayTypeLabel = QtGui.QLabel(self.presentationWidget)
|
||||
self.displayTypeLabel.setObjectName(u'displayTypeLabel')
|
||||
self.displayTypeComboBox = QtGui.QComboBox(self.presentationWidget)
|
||||
self.displayTypeComboBox.setSizePolicy(QtGui.QSizePolicy.Expanding,
|
||||
QtGui.QSizePolicy.Fixed)
|
||||
self.displayTypeComboBox.setSizeAdjustPolicy(
|
||||
QtGui.QComboBox.AdjustToMinimumContentsLength)
|
||||
self.displayTypeComboBox.setSizePolicy(
|
||||
QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Fixed)
|
||||
self.displayTypeComboBox.setObjectName(u'displayTypeComboBox')
|
||||
self.displayTypeLabel.setBuddy(self.displayTypeComboBox)
|
||||
self.displayLayout.addRow(self.displayTypeLabel,
|
||||
@ -178,7 +181,7 @@ class PresentationMediaItem(MediaManagerItem):
|
||||
filename = os.path.split(unicode(file))[1]
|
||||
if titles.count(filename) > 0:
|
||||
if not initialLoad:
|
||||
QtGui.QMessageBox.critical(self,
|
||||
criticalErrorMessageBox(
|
||||
translate('PresentationPlugin.MediaItem',
|
||||
'File Exists'),
|
||||
translate('PresentationPlugin.MediaItem',
|
||||
@ -202,7 +205,7 @@ class PresentationMediaItem(MediaManagerItem):
|
||||
if initialLoad:
|
||||
icon = build_icon(u':/general/general_delete.png')
|
||||
else:
|
||||
QtGui.QMessageBox.critical(
|
||||
criticalErrorMessageBox(
|
||||
self, translate('PresentationPlugin.MediaItem',
|
||||
'Unsupported File'),
|
||||
translate('PresentationPlugin.MediaItem',
|
||||
@ -273,8 +276,8 @@ class PresentationMediaItem(MediaManagerItem):
|
||||
return True
|
||||
else:
|
||||
# File is no longer present
|
||||
QtGui.QMessageBox.critical(
|
||||
self, translate('PresentationPlugin.MediaItem',
|
||||
criticalErrorMessageBox(
|
||||
translate('PresentationPlugin.MediaItem',
|
||||
'Missing Presentation'),
|
||||
unicode(translate('PresentationPlugin.MediaItem',
|
||||
'The Presentation %s no longer exists.')) % filename)
|
||||
|
@ -79,7 +79,12 @@ class PresentationTab(SettingsTab):
|
||||
for key in self.controllers:
|
||||
controller = self.controllers[key]
|
||||
checkbox = self.PresenterCheckboxes[controller.name]
|
||||
checkbox.setText(controller.name)
|
||||
if controller.available:
|
||||
checkbox.setText(controller.name)
|
||||
else:
|
||||
checkbox.setText(
|
||||
unicode(translate('PresentationPlugin.PresentationTab',
|
||||
'%s (unvailable)')) % controller.name)
|
||||
self.AdvancedGroupBox.setTitle(
|
||||
translate('PresentationPlugin.PresentationTab',
|
||||
'Advanced'))
|
||||
@ -93,11 +98,10 @@ class PresentationTab(SettingsTab):
|
||||
"""
|
||||
for key in self.controllers:
|
||||
controller = self.controllers[key]
|
||||
if controller.available:
|
||||
checkbox = self.PresenterCheckboxes[controller.name]
|
||||
checkbox.setChecked(QtCore.QSettings().value(
|
||||
self.settingsSection + u'/' + controller.name,
|
||||
QtCore.QVariant(QtCore.Qt.Checked)).toInt()[0])
|
||||
checkbox = self.PresenterCheckboxes[controller.name]
|
||||
checkbox.setChecked(QtCore.QSettings().value(
|
||||
self.settingsSection + u'/' + controller.name,
|
||||
QtCore.QVariant(QtCore.Qt.Checked)).toInt()[0])
|
||||
self.OverrideAppCheckBox.setChecked(QtCore.QSettings().value(
|
||||
self.settingsSection + u'/override app',
|
||||
QtCore.QVariant(QtCore.Qt.Unchecked)).toInt()[0])
|
||||
@ -109,16 +113,18 @@ class PresentationTab(SettingsTab):
|
||||
changed = False
|
||||
for key in self.controllers:
|
||||
controller = self.controllers[key]
|
||||
checkbox = self.PresenterCheckboxes[controller.name]
|
||||
setting_key = self.settingsSection + u'/' + controller.name
|
||||
if QtCore.QSettings().value(setting_key) != checkbox.checkState():
|
||||
changed = True
|
||||
QtCore.QSettings().setValue(setting_key,
|
||||
QtCore.QVariant(checkbox.checkState()))
|
||||
if checkbox.checkState() == QtCore.Qt.Checked:
|
||||
controller.start_process()
|
||||
else:
|
||||
controller.kill()
|
||||
if controller.available:
|
||||
checkbox = self.PresenterCheckboxes[controller.name]
|
||||
setting_key = self.settingsSection + u'/' + controller.name
|
||||
if QtCore.QSettings().value(setting_key) != \
|
||||
checkbox.checkState():
|
||||
changed = True
|
||||
QtCore.QSettings().setValue(setting_key,
|
||||
QtCore.QVariant(checkbox.checkState()))
|
||||
if checkbox.isChecked():
|
||||
controller.start_process()
|
||||
else:
|
||||
controller.kill()
|
||||
setting_key = self.settingsSection + u'/override app'
|
||||
if QtCore.QSettings().value(setting_key) != \
|
||||
self.OverrideAppCheckBox.checkState():
|
||||
|
@ -46,8 +46,8 @@ class RemoteTab(SettingsTab):
|
||||
self.addressLabel = QtGui.QLabel(self.serverSettingsGroupBox)
|
||||
self.addressLabel.setObjectName(u'addressLabel')
|
||||
self.addressEdit = QtGui.QLineEdit(self.serverSettingsGroupBox)
|
||||
self.addressEdit.setSizePolicy(QtGui.QSizePolicy.Preferred,
|
||||
QtGui.QSizePolicy.Fixed)
|
||||
self.addressEdit.setSizePolicy(
|
||||
QtGui.QSizePolicy.Preferred, QtGui.QSizePolicy.Fixed)
|
||||
self.addressEdit.setValidator(QtGui.QRegExpValidator(QtCore.QRegExp(
|
||||
u'\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}'), self))
|
||||
self.addressEdit.setObjectName(u'addressEdit')
|
||||
|
@ -54,7 +54,7 @@ class Ui_AuthorsDialog(object):
|
||||
self.displayEdit.setObjectName(u'displayEdit')
|
||||
self.displayLabel.setBuddy(self.displayEdit)
|
||||
self.authorLayout.addRow(self.displayLabel, self.displayEdit)
|
||||
self.dialogLayout.addLayout(self.authorLayout)
|
||||
self.dialogLayout.addLayout(self.authorLayout)
|
||||
self.buttonBox = QtGui.QDialogButtonBox(authorsDialog)
|
||||
self.buttonBox.setStandardButtons(
|
||||
QtGui.QDialogButtonBox.Save | QtGui.QDialogButtonBox.Cancel)
|
||||
|
@ -27,6 +27,7 @@
|
||||
from PyQt4 import QtGui, QtCore
|
||||
|
||||
from openlp.core.lib import translate
|
||||
from openlp.core.ui import criticalErrorMessageBox
|
||||
from openlp.plugins.songs.forms.authorsdialog import Ui_AuthorsDialog
|
||||
|
||||
class AuthorsForm(QtGui.QDialog, Ui_AuthorsDialog):
|
||||
@ -79,28 +80,21 @@ class AuthorsForm(QtGui.QDialog, Ui_AuthorsDialog):
|
||||
|
||||
def accept(self):
|
||||
if not self.firstNameEdit.text():
|
||||
QtGui.QMessageBox.critical(
|
||||
self, translate('SongsPlugin.AuthorsForm', 'Error'),
|
||||
translate('SongsPlugin.AuthorsForm',
|
||||
'You need to type in the first name of the author.'))
|
||||
criticalErrorMessageBox(message=translate('SongsPlugin.AuthorsForm',
|
||||
'You need to type in the first name of the author.'))
|
||||
self.firstNameEdit.setFocus()
|
||||
return False
|
||||
elif not self.lastNameEdit.text():
|
||||
QtGui.QMessageBox.critical(
|
||||
self, translate('SongsPlugin.AuthorsForm', 'Error'),
|
||||
translate('SongsPlugin.AuthorsForm',
|
||||
'You need to type in the last name of the author.'))
|
||||
criticalErrorMessageBox(message=translate('SongsPlugin.AuthorsForm',
|
||||
'You need to type in the last name of the author.'))
|
||||
self.lastNameEdit.setFocus()
|
||||
return False
|
||||
elif not self.displayEdit.text():
|
||||
if QtGui.QMessageBox.critical(
|
||||
self, translate('SongsPlugin.AuthorsForm', 'Error'),
|
||||
translate('SongsPlugin.AuthorsForm',
|
||||
'You have not set a display name for the '
|
||||
'author, combine the first and last names?'),
|
||||
QtGui.QMessageBox.StandardButtons(
|
||||
QtGui.QMessageBox.Yes | QtGui.QMessageBox.No)
|
||||
) == QtGui.QMessageBox.Yes:
|
||||
if criticalErrorMessageBox(
|
||||
message=translate('SongsPlugin.AuthorsForm',
|
||||
'You have not set a display name for the '
|
||||
'author, combine the first and last names?'),
|
||||
parent=self, question=True) == QtGui.QMessageBox.Yes:
|
||||
self.displayEdit.setText(self.firstNameEdit.text() + \
|
||||
u' ' + self.lastNameEdit.text())
|
||||
return QtGui.QDialog.accept(self)
|
||||
|
@ -114,8 +114,8 @@ class Ui_EditSongDialog(object):
|
||||
self.authorsComboBox = QtGui.QComboBox(self.authorsGroupBox)
|
||||
self.authorsComboBox.setSizeAdjustPolicy(
|
||||
QtGui.QComboBox.AdjustToMinimumContentsLength)
|
||||
self.authorsComboBox.setSizePolicy(QtGui.QSizePolicy.Expanding,
|
||||
QtGui.QSizePolicy.Fixed)
|
||||
self.authorsComboBox.setSizePolicy(
|
||||
QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Fixed)
|
||||
self.authorsComboBox.setEditable(True)
|
||||
self.authorsComboBox.setInsertPolicy(QtGui.QComboBox.NoInsert)
|
||||
self.authorsComboBox.setObjectName(u'authorsComboBox')
|
||||
@ -155,8 +155,8 @@ class Ui_EditSongDialog(object):
|
||||
self.topicsComboBox = QtGui.QComboBox(self.topicsGroupBox)
|
||||
self.topicsComboBox.setSizeAdjustPolicy(
|
||||
QtGui.QComboBox.AdjustToMinimumContentsLength)
|
||||
self.topicsComboBox.setSizePolicy(QtGui.QSizePolicy.Expanding,
|
||||
QtGui.QSizePolicy.Fixed)
|
||||
self.topicsComboBox.setSizePolicy(
|
||||
QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Fixed)
|
||||
self.topicsComboBox.setEditable(True)
|
||||
self.topicsComboBox.setInsertPolicy(QtGui.QComboBox.NoInsert)
|
||||
self.topicsComboBox.setObjectName(u'topicsComboBox')
|
||||
@ -184,8 +184,10 @@ class Ui_EditSongDialog(object):
|
||||
self.songBookNameLabel = QtGui.QLabel(self.songBookGroupBox)
|
||||
self.songBookNameLabel.setObjectName(u'songBookNameLabel')
|
||||
self.songBookComboBox = QtGui.QComboBox(self.songBookGroupBox)
|
||||
self.songBookComboBox.setSizePolicy(QtGui.QSizePolicy.Expanding,
|
||||
QtGui.QSizePolicy.Fixed)
|
||||
self.songBookComboBox.setSizeAdjustPolicy(
|
||||
QtGui.QComboBox.AdjustToMinimumContentsLength)
|
||||
self.songBookComboBox.setSizePolicy(
|
||||
QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Fixed)
|
||||
self.songBookComboBox.setEditable(True)
|
||||
self.songBookComboBox.setInsertPolicy(QtGui.QComboBox.NoInsert)
|
||||
self.songBookComboBox.setObjectName(u'songBookComboBox')
|
||||
@ -216,8 +218,8 @@ class Ui_EditSongDialog(object):
|
||||
self.themeComboBox = QtGui.QComboBox(self.themeGroupBox)
|
||||
self.themeComboBox.setSizeAdjustPolicy(
|
||||
QtGui.QComboBox.AdjustToMinimumContentsLength)
|
||||
self.themeComboBox.setSizePolicy(QtGui.QSizePolicy.Expanding,
|
||||
QtGui.QSizePolicy.Fixed)
|
||||
self.themeComboBox.setSizePolicy(
|
||||
QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Fixed)
|
||||
self.themeComboBox.setEditable(True)
|
||||
self.themeComboBox.setInsertPolicy(QtGui.QComboBox.NoInsert)
|
||||
self.themeComboBox.setObjectName(u'themeComboBox')
|
||||
@ -245,6 +247,7 @@ class Ui_EditSongDialog(object):
|
||||
self.CCLILabel.setObjectName(u'CCLILabel')
|
||||
self.CCLILayout.addWidget(self.CCLILabel)
|
||||
self.CCLNumberEdit = QtGui.QLineEdit(self.rightsGroupBox)
|
||||
self.CCLNumberEdit.setValidator(QtGui.QIntValidator())
|
||||
self.CCLNumberEdit.setObjectName(u'CCLNumberEdit')
|
||||
self.CCLILayout.addWidget(self.CCLNumberEdit)
|
||||
self.rightsLayout.addLayout(self.CCLILayout)
|
||||
|
@ -30,8 +30,9 @@ import re
|
||||
from PyQt4 import QtCore, QtGui
|
||||
|
||||
from openlp.core.lib import Receiver, translate
|
||||
from openlp.core.ui import criticalErrorMessageBox
|
||||
from openlp.plugins.songs.forms import EditVerseForm
|
||||
from openlp.plugins.songs.lib import SongXMLBuilder, SongXMLParser, VerseType
|
||||
from openlp.plugins.songs.lib import SongXML, VerseType
|
||||
from openlp.plugins.songs.lib.db import Book, Song, Author, Topic
|
||||
from editsongdialog import Ui_EditSongDialog
|
||||
|
||||
@ -263,8 +264,8 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog):
|
||||
if isinstance(self.song.lyrics, buffer):
|
||||
self.song.lyrics = unicode(self.song.lyrics)
|
||||
if self.song.lyrics.startswith(u'<?xml version='):
|
||||
songXML = SongXMLParser(self.song.lyrics)
|
||||
verseList = songXML.get_verses()
|
||||
songXML = SongXML()
|
||||
verseList = songXML.get_verses(self.song.lyrics)
|
||||
for count, verse in enumerate(verseList):
|
||||
self.verseListWidget.setRowCount(
|
||||
self.verseListWidget.rowCount() + 1)
|
||||
@ -346,10 +347,9 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog):
|
||||
author = self.manager.get_object(Author, item_id)
|
||||
if self.authorsListView.findItems(unicode(author.display_name),
|
||||
QtCore.Qt.MatchExactly):
|
||||
QtGui.QMessageBox.warning(self,
|
||||
translate('SongsPlugin.EditSongForm', 'Error'),
|
||||
translate('SongsPlugin.EditSongForm', 'This author is '
|
||||
'already in the list.'))
|
||||
criticalErrorMessageBox(
|
||||
message=translate('SongsPlugin.EditSongForm',
|
||||
'This author is already in the list.'))
|
||||
else:
|
||||
author_item = QtGui.QListWidgetItem(unicode(
|
||||
author.display_name))
|
||||
@ -400,10 +400,9 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog):
|
||||
topic = self.manager.get_object(Topic, item_id)
|
||||
if self.topicsListView.findItems(unicode(topic.name),
|
||||
QtCore.Qt.MatchExactly):
|
||||
QtGui.QMessageBox.warning(self,
|
||||
translate('SongsPlugin.EditSongForm', 'Error'),
|
||||
translate('SongsPlugin.EditSongForm', 'This topic is '
|
||||
'already in the list.'))
|
||||
criticalErrorMessageBox(
|
||||
message=translate('SongsPlugin.EditSongForm',
|
||||
'This topic is already in the list.'))
|
||||
else:
|
||||
topic_item = QtGui.QListWidgetItem(unicode(topic.name))
|
||||
topic_item.setData(QtCore.Qt.UserRole,
|
||||
@ -525,38 +524,36 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog):
|
||||
|
||||
def _validate_song(self):
|
||||
"""
|
||||
Check the validity of the form. Only display the 'save' if the data
|
||||
can be saved.
|
||||
Check the validity of the song.
|
||||
"""
|
||||
# This checks data in the form *not* self.song. self.song is still
|
||||
# None at this point.
|
||||
log.debug(u'Validate Song')
|
||||
# Lets be nice and assume the data is correct.
|
||||
if len(self.titleEdit.displayText()) == 0:
|
||||
if not self.titleEdit.text():
|
||||
self.songTabWidget.setCurrentIndex(0)
|
||||
self.titleEdit.setFocus()
|
||||
QtGui.QMessageBox.critical(self,
|
||||
translate('SongsPlugin.EditSongForm', 'Error'),
|
||||
translate('SongsPlugin.EditSongForm',
|
||||
criticalErrorMessageBox(
|
||||
message=translate('SongsPlugin.EditSongForm',
|
||||
'You need to type in a song title.'))
|
||||
return False
|
||||
if self.verseListWidget.rowCount() == 0:
|
||||
self.songTabWidget.setCurrentIndex(0)
|
||||
self.verseListWidget.setFocus()
|
||||
QtGui.QMessageBox.critical(self,
|
||||
translate('SongsPlugin.EditSongForm', 'Error'),
|
||||
translate('SongsPlugin.EditSongForm',
|
||||
criticalErrorMessageBox(
|
||||
message=translate('SongsPlugin.EditSongForm',
|
||||
'You need to type in at least one verse.'))
|
||||
return False
|
||||
if self.authorsListView.count() == 0:
|
||||
self.songTabWidget.setCurrentIndex(1)
|
||||
self.authorsListView.setFocus()
|
||||
QtGui.QMessageBox.critical(self,
|
||||
translate('SongsPlugin.EditSongForm', 'Warning'),
|
||||
translate('SongsPlugin.EditSongForm',
|
||||
criticalErrorMessageBox(
|
||||
message=translate('SongsPlugin.EditSongForm',
|
||||
'You need to have an author for this song.'))
|
||||
return False
|
||||
if self.song.verse_order:
|
||||
if self.verseOrderEdit.text():
|
||||
order = []
|
||||
order_names = self.song.verse_order.split()
|
||||
order_names = self.verseOrderEdit.text().split()
|
||||
for item in order_names:
|
||||
if len(item) == 1:
|
||||
order.append(item.lower() + u'1')
|
||||
@ -578,9 +575,8 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog):
|
||||
valid = verses.pop(0)
|
||||
for verse in verses:
|
||||
valid = valid + u', ' + verse
|
||||
QtGui.QMessageBox.critical(self,
|
||||
translate('SongsPlugin.EditSongForm', 'Error'),
|
||||
unicode(translate('SongsPlugin.EditSongForm',
|
||||
criticalErrorMessageBox(
|
||||
message=unicode(translate('SongsPlugin.EditSongForm',
|
||||
'The verse order is invalid. There is no verse '
|
||||
'corresponding to %s. Valid entries are %s.')) % \
|
||||
(order_names[count], valid))
|
||||
@ -598,6 +594,19 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog):
|
||||
QtGui.QMessageBox.Yes | QtGui.QMessageBox.No)
|
||||
if answer == QtGui.QMessageBox.No:
|
||||
return False
|
||||
item = int(self.songBookComboBox.currentIndex())
|
||||
text = unicode(self.songBookComboBox.currentText())
|
||||
if self.songBookComboBox.findText(text, QtCore.Qt.MatchExactly) < 0:
|
||||
if QtGui.QMessageBox.question(self,
|
||||
translate('SongsPlugin.EditSongForm', 'Add Book'),
|
||||
translate('SongsPlugin.EditSongForm', 'This song book does '
|
||||
'not exist, do you want to add it?'),
|
||||
QtGui.QMessageBox.Yes | QtGui.QMessageBox.No,
|
||||
QtGui.QMessageBox.Yes) == QtGui.QMessageBox.Yes:
|
||||
book = Book.populate(name=text, publisher=u'')
|
||||
self.manager.save_object(book)
|
||||
else:
|
||||
return False
|
||||
return True
|
||||
|
||||
def onCopyrightInsertButtonTriggered(self):
|
||||
@ -654,37 +663,29 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog):
|
||||
|
||||
def accept(self):
|
||||
"""
|
||||
Exit Dialog and save soong if valid
|
||||
Exit Dialog and save song if valid
|
||||
"""
|
||||
log.debug(u'accept')
|
||||
self.clearCaches()
|
||||
if not self.song:
|
||||
self.song = Song()
|
||||
item = int(self.songBookComboBox.currentIndex())
|
||||
text = unicode(self.songBookComboBox.currentText())
|
||||
if self.songBookComboBox.findText(text, QtCore.Qt.MatchExactly) < 0:
|
||||
if QtGui.QMessageBox.question(self,
|
||||
translate('SongsPlugin.EditSongForm', 'Add Book'),
|
||||
translate('SongsPlugin.EditSongForm', 'This song book does '
|
||||
'not exist, do you want to add it?'),
|
||||
QtGui.QMessageBox.Yes | QtGui.QMessageBox.No,
|
||||
QtGui.QMessageBox.Yes) == QtGui.QMessageBox.Yes:
|
||||
book = Book.populate(name=text, publisher=u'')
|
||||
self.manager.save_object(book)
|
||||
else:
|
||||
return
|
||||
if self.saveSong():
|
||||
if self._validate_song():
|
||||
self.saveSong()
|
||||
Receiver.send_message(u'songs_load_list')
|
||||
self.close()
|
||||
|
||||
def saveSong(self, preview=False):
|
||||
"""
|
||||
Get all the data from the widgets on the form, and then save it to the
|
||||
database.
|
||||
database. The form has been validated and all reference items
|
||||
(Authors, Books and Topics) have been saved before this function is
|
||||
called.
|
||||
|
||||
``preview``
|
||||
Should be ``True`` if the song is also previewed (boolean).
|
||||
"""
|
||||
# The Song() assignment. No database calls should be made while a
|
||||
# Song() is in a partially complete state.
|
||||
if not self.song:
|
||||
self.song = Song()
|
||||
self.song.title = unicode(self.titleEdit.text())
|
||||
self.song.alternate_title = unicode(self.alternativeEdit.text())
|
||||
self.song.copyright = unicode(self.copyrightEdit.text())
|
||||
@ -708,30 +709,30 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog):
|
||||
self.song.theme_name = theme_name
|
||||
else:
|
||||
self.song.theme_name = None
|
||||
if self._validate_song():
|
||||
self.processLyrics()
|
||||
self.processTitle()
|
||||
self.song.authors = []
|
||||
for row in range(self.authorsListView.count()):
|
||||
item = self.authorsListView.item(row)
|
||||
authorId = (item.data(QtCore.Qt.UserRole)).toInt()[0]
|
||||
self.song.authors.append(self.manager.get_object(Author,
|
||||
authorId))
|
||||
self.song.topics = []
|
||||
for row in range(self.topicsListView.count()):
|
||||
item = self.topicsListView.item(row)
|
||||
topicId = (item.data(QtCore.Qt.UserRole)).toInt()[0]
|
||||
self.song.topics.append(self.manager.get_object(Topic, topicId))
|
||||
self.manager.save_object(self.song)
|
||||
if not preview:
|
||||
self.song = None
|
||||
return True
|
||||
return False
|
||||
self.processLyrics()
|
||||
self.processTitle()
|
||||
self.song.authors = []
|
||||
for row in range(self.authorsListView.count()):
|
||||
item = self.authorsListView.item(row)
|
||||
authorId = (item.data(QtCore.Qt.UserRole)).toInt()[0]
|
||||
self.song.authors.append(self.manager.get_object(Author, authorId))
|
||||
self.song.topics = []
|
||||
for row in range(self.topicsListView.count()):
|
||||
item = self.topicsListView.item(row)
|
||||
topicId = (item.data(QtCore.Qt.UserRole)).toInt()[0]
|
||||
self.song.topics.append(self.manager.get_object(Topic, topicId))
|
||||
self.manager.save_object(self.song)
|
||||
if not preview:
|
||||
self.song = None
|
||||
|
||||
def processLyrics(self):
|
||||
"""
|
||||
Process the lyric data entered by the user into the OpenLP XML format.
|
||||
"""
|
||||
# This method must only be run after the self.song = Song() assignment.
|
||||
log.debug(u'processLyrics')
|
||||
try:
|
||||
sxml = SongXMLBuilder()
|
||||
sxml = SongXML()
|
||||
text = u''
|
||||
multiple = []
|
||||
for i in range(0, self.verseListWidget.rowCount()):
|
||||
@ -754,6 +755,11 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog):
|
||||
sxml.dump_xml())
|
||||
|
||||
def processTitle(self):
|
||||
"""
|
||||
Process the song title entered by the user to remove stray punctuation
|
||||
characters.
|
||||
"""
|
||||
# This method must only be run after the self.song = Song() assignment.
|
||||
log.debug(u'processTitle')
|
||||
self.song.search_title = re.sub(r'[\'"`,;:(){}?]+', u'',
|
||||
unicode(self.song.search_title)).lower()
|
||||
|
@ -29,6 +29,7 @@ import logging
|
||||
|
||||
from PyQt4 import QtCore, QtGui
|
||||
|
||||
from openlp.core.ui import criticalErrorMessageBox
|
||||
from openlp.plugins.songs.lib import VerseType, translate
|
||||
|
||||
from editversedialog import Ui_EditVerseDialog
|
||||
@ -167,9 +168,8 @@ class EditVerseForm(QtGui.QDialog, Ui_EditVerseDialog):
|
||||
else:
|
||||
value = self.getVerse()[0].split(u'\n')[1]
|
||||
if len(value) == 0:
|
||||
QtGui.QMessageBox.critical(self,
|
||||
translate('SongsPlugin.EditSongForm', 'Error'),
|
||||
translate('SongsPlugin.EditSongForm',
|
||||
criticalErrorMessageBox(
|
||||
message=translate('SongsPlugin.EditSongForm',
|
||||
'You need to type some text in to the verse.'))
|
||||
return False
|
||||
QtGui.QDialog.accept(self)
|
||||
|
@ -27,6 +27,7 @@
|
||||
from PyQt4 import QtGui
|
||||
|
||||
from openlp.core.lib import translate
|
||||
from openlp.core.ui import criticalErrorMessageBox
|
||||
from openlp.plugins.songs.forms.songbookdialog import Ui_SongBookDialog
|
||||
|
||||
class SongBookForm(QtGui.QDialog, Ui_SongBookDialog):
|
||||
@ -49,10 +50,9 @@ class SongBookForm(QtGui.QDialog, Ui_SongBookDialog):
|
||||
|
||||
def accept(self):
|
||||
if not self.nameEdit.text():
|
||||
QtGui.QMessageBox.critical(
|
||||
self, translate('SongsPlugin.SongBookForm', 'Error'),
|
||||
translate('SongsPlugin.SongBookForm',
|
||||
'You need to type in a name for the book.'))
|
||||
criticalErrorMessageBox(
|
||||
message=translate('SongsPlugin.SongBookForm',
|
||||
'You need to type in a name for the book.'))
|
||||
self.nameEdit.setFocus()
|
||||
return False
|
||||
else:
|
||||
|
@ -23,19 +23,22 @@
|
||||
# with this program; if not, write to the Free Software Foundation, Inc., 59 #
|
||||
# Temple Place, Suite 330, Boston, MA 02111-1307 USA #
|
||||
###############################################################################
|
||||
|
||||
"""
|
||||
The song import functions for OpenLP.
|
||||
"""
|
||||
import logging
|
||||
import os
|
||||
|
||||
from PyQt4 import QtCore, QtGui
|
||||
|
||||
from songimportwizard import Ui_SongImportWizard
|
||||
from openlp.core.lib import Receiver, SettingsManager, translate
|
||||
from openlp.core.ui import criticalErrorMessageBox
|
||||
from openlp.core.ui.wizard import OpenLPWizard
|
||||
from openlp.plugins.songs.lib.importer import SongFormat
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
class SongImportForm(QtGui.QWizard, Ui_SongImportWizard):
|
||||
class SongImportForm(OpenLPWizard):
|
||||
"""
|
||||
This is the Song Import Wizard, which allows easy importing of Songs
|
||||
into OpenLP from other formats like OpenLyrics, OpenSong and CCLI.
|
||||
@ -52,11 +55,23 @@ class SongImportForm(QtGui.QWizard, Ui_SongImportWizard):
|
||||
``plugin``
|
||||
The songs plugin.
|
||||
"""
|
||||
QtGui.QWizard.__init__(self, parent)
|
||||
self.setupUi(self)
|
||||
self.registerFields()
|
||||
self.finishButton = self.button(QtGui.QWizard.FinishButton)
|
||||
self.cancelButton = self.button(QtGui.QWizard.CancelButton)
|
||||
OpenLPWizard.__init__(self, parent, plugin, u'songImportWizard',
|
||||
u':/wizards/wizard_importsong.bmp')
|
||||
|
||||
def setupUi(self, image):
|
||||
"""
|
||||
Set up the song wizard UI.
|
||||
"""
|
||||
OpenLPWizard.setupUi(self, image)
|
||||
self.formatStack.setCurrentIndex(0)
|
||||
QtCore.QObject.connect(self.formatComboBox,
|
||||
QtCore.SIGNAL(u'currentIndexChanged(int)'),
|
||||
self.formatStack.setCurrentIndex)
|
||||
|
||||
def customInit(self):
|
||||
"""
|
||||
Song wizard specific initialisation.
|
||||
"""
|
||||
if not SongFormat.get_availability(SongFormat.OpenLP1):
|
||||
self.openLP1DisabledWidget.setVisible(True)
|
||||
self.openLP1ImportWidget.setVisible(False)
|
||||
@ -66,19 +81,23 @@ class SongImportForm(QtGui.QWizard, Ui_SongImportWizard):
|
||||
if not SongFormat.get_availability(SongFormat.Generic):
|
||||
self.genericDisabledWidget.setVisible(True)
|
||||
self.genericImportWidget.setVisible(False)
|
||||
self.plugin = plugin
|
||||
|
||||
def customSignals(self):
|
||||
"""
|
||||
Song wizard specific signals.
|
||||
"""
|
||||
QtCore.QObject.connect(self.openLP2BrowseButton,
|
||||
QtCore.SIGNAL(u'clicked()'),
|
||||
self.onOpenLP2BrowseButtonClicked)
|
||||
QtCore.QObject.connect(self.openLP1BrowseButton,
|
||||
QtCore.SIGNAL(u'clicked()'),
|
||||
self.onOpenLP1BrowseButtonClicked)
|
||||
#QtCore.QObject.connect(self.openLyricsAddButton,
|
||||
# QtCore.SIGNAL(u'clicked()'),
|
||||
# self.onOpenLyricsAddButtonClicked)
|
||||
#QtCore.QObject.connect(self.openLyricsRemoveButton,
|
||||
# QtCore.SIGNAL(u'clicked()'),
|
||||
# self.onOpenLyricsRemoveButtonClicked)
|
||||
QtCore.QObject.connect(self.openLyricsAddButton,
|
||||
QtCore.SIGNAL(u'clicked()'),
|
||||
self.onOpenLyricsAddButtonClicked)
|
||||
QtCore.QObject.connect(self.openLyricsRemoveButton,
|
||||
QtCore.SIGNAL(u'clicked()'),
|
||||
self.onOpenLyricsRemoveButtonClicked)
|
||||
QtCore.QObject.connect(self.openSongAddButton,
|
||||
QtCore.SIGNAL(u'clicked()'),
|
||||
self.onOpenSongAddButtonClicked)
|
||||
@ -118,25 +137,184 @@ class SongImportForm(QtGui.QWizard, Ui_SongImportWizard):
|
||||
QtCore.QObject.connect(self.songBeamerRemoveButton,
|
||||
QtCore.SIGNAL(u'clicked()'),
|
||||
self.onSongBeamerRemoveButtonClicked)
|
||||
QtCore.QObject.connect(self,
|
||||
QtCore.SIGNAL(u'currentIdChanged(int)'),
|
||||
self.onCurrentIdChanged)
|
||||
|
||||
def exec_(self):
|
||||
def addCustomPages(self):
|
||||
"""
|
||||
Run the wizard.
|
||||
Add song wizard specific pages.
|
||||
"""
|
||||
self.setDefaults()
|
||||
return QtGui.QWizard.exec_(self)
|
||||
# Source Page
|
||||
self.sourcePage = QtGui.QWizardPage()
|
||||
self.sourcePage.setObjectName(u'SourcePage')
|
||||
self.sourceLayout = QtGui.QVBoxLayout(self.sourcePage)
|
||||
self.sourceLayout.setObjectName(u'SourceLayout')
|
||||
self.formatLayout = QtGui.QFormLayout()
|
||||
self.formatLayout.setObjectName(u'FormatLayout')
|
||||
self.formatLabel = QtGui.QLabel(self.sourcePage)
|
||||
self.formatLabel.setObjectName(u'FormatLabel')
|
||||
self.formatComboBox = QtGui.QComboBox(self.sourcePage)
|
||||
self.formatComboBox.setObjectName(u'FormatComboBox')
|
||||
self.formatLayout.addRow(self.formatLabel, self.formatComboBox)
|
||||
self.formatSpacer = QtGui.QSpacerItem(10, 0, QtGui.QSizePolicy.Fixed,
|
||||
QtGui.QSizePolicy.Minimum)
|
||||
self.formatLayout.setItem(1, QtGui.QFormLayout.LabelRole,
|
||||
self.formatSpacer)
|
||||
self.sourceLayout.addLayout(self.formatLayout)
|
||||
self.formatStack = QtGui.QStackedLayout()
|
||||
self.formatStack.setObjectName(u'FormatStack')
|
||||
# OpenLP 2.0
|
||||
self.addSingleFileSelectItem(u'openLP2')
|
||||
# openlp.org 1.x
|
||||
self.addSingleFileSelectItem(u'openLP1', None, True)
|
||||
# OpenLyrics
|
||||
self.addMultiFileSelectItem(u'openLyrics', u'OpenLyrics', True)
|
||||
# Open Song
|
||||
self.addMultiFileSelectItem(u'openSong', u'OpenSong')
|
||||
# Words of Worship
|
||||
self.addMultiFileSelectItem(u'wordsOfWorship')
|
||||
# CCLI File import
|
||||
self.addMultiFileSelectItem(u'ccli')
|
||||
# Songs of Fellowship
|
||||
self.addMultiFileSelectItem(u'songsOfFellowship', None, True)
|
||||
# Generic Document/Presentation import
|
||||
self.addMultiFileSelectItem(u'generic', None, True)
|
||||
# EasyWorship
|
||||
self.addSingleFileSelectItem(u'ew')
|
||||
# Words of Worship
|
||||
self.addMultiFileSelectItem(u'songBeamer')
|
||||
# Commented out for future use.
|
||||
# self.addSingleFileSelectItem(u'csv', u'CSV')
|
||||
self.sourceLayout.addLayout(self.formatStack)
|
||||
self.addPage(self.sourcePage)
|
||||
|
||||
def reject(self):
|
||||
def retranslateUi(self):
|
||||
"""
|
||||
Stop the import on cancel button, close button or ESC key.
|
||||
Song wizard localisation.
|
||||
"""
|
||||
log.debug(u'Import canceled by user.')
|
||||
if self.currentPage() == self.importPage:
|
||||
Receiver.send_message(u'songs_stop_import')
|
||||
self.done(QtGui.QDialog.Rejected)
|
||||
self.setWindowTitle(
|
||||
translate('SongsPlugin.ImportWizardForm', 'Song Import Wizard'))
|
||||
self.titleLabel.setText(
|
||||
u'<span style="font-size:14pt; font-weight:600;">%s</span>' % \
|
||||
translate('SongsPlugin.ImportWizardForm',
|
||||
'Welcome to the Song Import Wizard'))
|
||||
self.informationLabel.setText(
|
||||
translate('SongsPlugin.ImportWizardForm',
|
||||
'This wizard will help you to import songs from a variety of '
|
||||
'formats. Click the next button below to start the process by '
|
||||
'selecting a format to import from.'))
|
||||
self.sourcePage.setTitle(
|
||||
translate('SongsPlugin.ImportWizardForm', 'Select Import Source'))
|
||||
self.sourcePage.setSubTitle(
|
||||
translate('SongsPlugin.ImportWizardForm',
|
||||
'Select the import format, and where to import from.'))
|
||||
self.formatLabel.setText(
|
||||
translate('SongsPlugin.ImportWizardForm', 'Format:'))
|
||||
self.formatComboBox.setItemText(0,
|
||||
translate('SongsPlugin.ImportWizardForm', 'OpenLP 2.0'))
|
||||
self.formatComboBox.setItemText(1,
|
||||
translate('SongsPlugin.ImportWizardForm', 'openlp.org 1.x'))
|
||||
self.formatComboBox.setItemText(2,
|
||||
translate('SongsPlugin.ImportWizardForm', 'OpenLyrics'))
|
||||
self.formatComboBox.setItemText(3,
|
||||
translate('SongsPlugin.ImportWizardForm', 'OpenSong'))
|
||||
self.formatComboBox.setItemText(4,
|
||||
translate('SongsPlugin.ImportWizardForm', 'Words of Worship'))
|
||||
self.formatComboBox.setItemText(5,
|
||||
translate('SongsPlugin.ImportWizardForm', 'CCLI/SongSelect'))
|
||||
self.formatComboBox.setItemText(6,
|
||||
translate('SongsPlugin.ImportWizardForm', 'Songs of Fellowship'))
|
||||
self.formatComboBox.setItemText(7,
|
||||
translate('SongsPlugin.ImportWizardForm',
|
||||
'Generic Document/Presentation'))
|
||||
self.formatComboBox.setItemText(8,
|
||||
translate('SongsPlugin.ImportWizardForm', 'EasyWorship'))
|
||||
self.formatComboBox.setItemText(9,
|
||||
translate('SongsPlugin.ImportWizardForm', 'SongBeamer'))
|
||||
# self.formatComboBox.setItemText(9,
|
||||
# translate('SongsPlugin.ImportWizardForm', 'CSV'))
|
||||
self.openLP2FilenameLabel.setText(
|
||||
translate('SongsPlugin.ImportWizardForm', 'Filename:'))
|
||||
self.openLP2BrowseButton.setText(
|
||||
translate('SongsPlugin.ImportWizardForm', 'Browse...'))
|
||||
self.openLP1FilenameLabel.setText(
|
||||
translate('SongsPlugin.ImportWizardForm', 'Filename:'))
|
||||
self.openLP1BrowseButton.setText(
|
||||
translate('SongsPlugin.ImportWizardForm', 'Browse...'))
|
||||
self.openLP1DisabledLabel.setText(
|
||||
translate('SongsPlugin.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.'))
|
||||
self.openLyricsAddButton.setText(
|
||||
translate('SongsPlugin.ImportWizardForm', 'Add Files...'))
|
||||
self.openLyricsRemoveButton.setText(
|
||||
translate('SongsPlugin.ImportWizardForm', 'Remove File(s)'))
|
||||
self.openLyricsDisabledLabel.setText(
|
||||
translate('SongsPlugin.ImportWizardForm', 'The OpenLyrics '
|
||||
'importer has not yet been developed, but as you can see, we are '
|
||||
'still intending to do so. Hopefully it will be in the next '
|
||||
'release.'))
|
||||
self.openSongAddButton.setText(
|
||||
translate('SongsPlugin.ImportWizardForm', 'Add Files...'))
|
||||
self.openSongRemoveButton.setText(
|
||||
translate('SongsPlugin.ImportWizardForm', 'Remove File(s)'))
|
||||
self.wordsOfWorshipAddButton.setText(
|
||||
translate('SongsPlugin.ImportWizardForm', 'Add Files...'))
|
||||
self.wordsOfWorshipRemoveButton.setText(
|
||||
translate('SongsPlugin.ImportWizardForm', 'Remove File(s)'))
|
||||
self.ccliAddButton.setText(
|
||||
translate('SongsPlugin.ImportWizardForm', 'Add Files...'))
|
||||
self.ccliRemoveButton.setText(
|
||||
translate('SongsPlugin.ImportWizardForm', 'Remove File(s)'))
|
||||
self.songsOfFellowshipAddButton.setText(
|
||||
translate('SongsPlugin.ImportWizardForm', 'Add Files...'))
|
||||
self.songsOfFellowshipRemoveButton.setText(
|
||||
translate('SongsPlugin.ImportWizardForm', 'Remove File(s)'))
|
||||
self.songsOfFellowshipDisabledLabel.setText(
|
||||
translate('SongsPlugin.ImportWizardForm', 'The Songs of '
|
||||
'Fellowship importer has been disabled because OpenLP cannot '
|
||||
'find OpenOffice.org on your computer.'))
|
||||
self.genericAddButton.setText(
|
||||
translate('SongsPlugin.ImportWizardForm', 'Add Files...'))
|
||||
self.genericRemoveButton.setText(
|
||||
translate('SongsPlugin.ImportWizardForm', 'Remove File(s)'))
|
||||
self.genericDisabledLabel.setText(
|
||||
translate('SongsPlugin.ImportWizardForm', 'The generic document/'
|
||||
'presentation importer has been disabled because OpenLP cannot '
|
||||
'find OpenOffice.org on your computer.'))
|
||||
self.ewFilenameLabel.setText(
|
||||
translate('SongsPlugin.ImportWizardForm', 'Filename:'))
|
||||
self.ewBrowseButton.setText(
|
||||
translate('SongsPlugin.ImportWizardForm', 'Browse...'))
|
||||
self.songBeamerAddButton.setText(
|
||||
translate('SongsPlugin.ImportWizardForm', 'Add Files...'))
|
||||
self.songBeamerRemoveButton.setText(
|
||||
translate('SongsPlugin.ImportWizardForm', 'Remove File(s)'))
|
||||
# self.csvFilenameLabel.setText(
|
||||
# translate('SongsPlugin.ImportWizardForm', 'Filename:'))
|
||||
# self.csvBrowseButton.setText(
|
||||
# translate('SongsPlugin.ImportWizardForm', 'Browse...'))
|
||||
self.progressPage.setTitle(
|
||||
translate('SongsPlugin.ImportWizardForm', 'Importing'))
|
||||
self.progressPage.setSubTitle(
|
||||
translate('SongsPlugin.ImportWizardForm',
|
||||
'Please wait while your songs are imported.'))
|
||||
self.progressLabel.setText(
|
||||
translate('SongsPlugin.ImportWizardForm', 'Ready.'))
|
||||
self.progressBar.setFormat(
|
||||
translate('SongsPlugin.ImportWizardForm', '%p%'))
|
||||
# Align all QFormLayouts towards each other.
|
||||
width = max(self.formatLabel.minimumSizeHint().width(),
|
||||
self.openLP2FilenameLabel.minimumSizeHint().width())
|
||||
self.formatSpacer.changeSize(width, 0, QtGui.QSizePolicy.Fixed,
|
||||
QtGui.QSizePolicy.Fixed)
|
||||
self.openLP2FormLabelSpacer.changeSize(width, 0,
|
||||
QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Fixed)
|
||||
self.openLP1FormLabelSpacer.changeSize(width, 0,
|
||||
QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Fixed)
|
||||
self.ewFormLabelSpacer.changeSize(width, 0, QtGui.QSizePolicy.Fixed,
|
||||
QtGui.QSizePolicy.Fixed)
|
||||
# self.csvFormLabelSpacer.changeSize(width, 0, QtGui.QSizePolicy.Fixed,
|
||||
# QtGui.QSizePolicy.Fixed)
|
||||
|
||||
def validateCurrentPage(self):
|
||||
"""
|
||||
@ -148,7 +326,7 @@ class SongImportForm(QtGui.QWizard, Ui_SongImportWizard):
|
||||
source_format = self.formatComboBox.currentIndex()
|
||||
if source_format == SongFormat.OpenLP2:
|
||||
if self.openLP2FilenameEdit.text().isEmpty():
|
||||
QtGui.QMessageBox.critical(self,
|
||||
criticalErrorMessageBox(
|
||||
translate('SongsPlugin.ImportWizardForm',
|
||||
'No OpenLP 2.0 Song Database Selected'),
|
||||
translate('SongsPlugin.ImportWizardForm',
|
||||
@ -158,7 +336,7 @@ class SongImportForm(QtGui.QWizard, Ui_SongImportWizard):
|
||||
return False
|
||||
elif source_format == SongFormat.OpenLP1:
|
||||
if self.openLP1FilenameEdit.text().isEmpty():
|
||||
QtGui.QMessageBox.critical(self,
|
||||
criticalErrorMessageBox(
|
||||
translate('SongsPlugin.ImportWizardForm',
|
||||
'No openlp.org 1.x Song Database Selected'),
|
||||
translate('SongsPlugin.ImportWizardForm',
|
||||
@ -167,19 +345,18 @@ class SongImportForm(QtGui.QWizard, Ui_SongImportWizard):
|
||||
self.openLP1BrowseButton.setFocus()
|
||||
return False
|
||||
elif source_format == SongFormat.OpenLyrics:
|
||||
# if self.openLyricsFileListWidget.count() == 0:
|
||||
# QtGui.QMessageBox.critical(self,
|
||||
# translate('SongsPlugin.ImportWizardForm',
|
||||
# 'No OpenLyrics Files Selected'),
|
||||
# translate('SongsPlugin.ImportWizardForm',
|
||||
# 'You need to add at least one OpenLyrics '
|
||||
# 'song file to import from.'))
|
||||
# self.openLyricsAddButton.setFocus()
|
||||
# return False
|
||||
return False
|
||||
if self.openLyricsFileListWidget.count() == 0:
|
||||
criticalErrorMessageBox(
|
||||
translate('SongsPlugin.ImportWizardForm',
|
||||
'No OpenLyrics Files Selected'),
|
||||
translate('SongsPlugin.ImportWizardForm',
|
||||
'You need to add at least one OpenLyrics '
|
||||
'song file to import from.'))
|
||||
self.openLyricsAddButton.setFocus()
|
||||
return False
|
||||
elif source_format == SongFormat.OpenSong:
|
||||
if self.openSongFileListWidget.count() == 0:
|
||||
QtGui.QMessageBox.critical(self,
|
||||
criticalErrorMessageBox(
|
||||
translate('SongsPlugin.ImportWizardForm',
|
||||
'No OpenSong Files Selected'),
|
||||
translate('SongsPlugin.ImportWizardForm',
|
||||
@ -189,7 +366,7 @@ class SongImportForm(QtGui.QWizard, Ui_SongImportWizard):
|
||||
return False
|
||||
elif source_format == SongFormat.WordsOfWorship:
|
||||
if self.wordsOfWorshipFileListWidget.count() == 0:
|
||||
QtGui.QMessageBox.critical(self,
|
||||
criticalErrorMessageBox(
|
||||
translate('SongsPlugin.ImportWizardForm',
|
||||
'No Words of Worship Files Selected'),
|
||||
translate('SongsPlugin.ImportWizardForm',
|
||||
@ -199,7 +376,7 @@ class SongImportForm(QtGui.QWizard, Ui_SongImportWizard):
|
||||
return False
|
||||
elif source_format == SongFormat.CCLI:
|
||||
if self.ccliFileListWidget.count() == 0:
|
||||
QtGui.QMessageBox.critical(self,
|
||||
criticalErrorMessageBox(
|
||||
translate('SongsPlugin.ImportWizardForm',
|
||||
'No CCLI Files Selected'),
|
||||
translate('SongsPlugin.ImportWizardForm',
|
||||
@ -209,7 +386,7 @@ class SongImportForm(QtGui.QWizard, Ui_SongImportWizard):
|
||||
return False
|
||||
elif source_format == SongFormat.SongsOfFellowship:
|
||||
if self.songsOfFellowshipFileListWidget.count() == 0:
|
||||
QtGui.QMessageBox.critical(self,
|
||||
criticalErrorMessageBox(
|
||||
translate('SongsPlugin.ImportWizardForm',
|
||||
'No Songs of Fellowship File Selected'),
|
||||
translate('SongsPlugin.ImportWizardForm',
|
||||
@ -219,7 +396,7 @@ class SongImportForm(QtGui.QWizard, Ui_SongImportWizard):
|
||||
return False
|
||||
elif source_format == SongFormat.Generic:
|
||||
if self.genericFileListWidget.count() == 0:
|
||||
QtGui.QMessageBox.critical(self,
|
||||
criticalErrorMessageBox(
|
||||
translate('SongsPlugin.ImportWizardForm',
|
||||
'No Document/Presentation Selected'),
|
||||
translate('SongsPlugin.ImportWizardForm',
|
||||
@ -229,7 +406,7 @@ class SongImportForm(QtGui.QWizard, Ui_SongImportWizard):
|
||||
return False
|
||||
elif source_format == SongFormat.EasyWorship:
|
||||
if self.ewFilenameEdit.text().isEmpty():
|
||||
QtGui.QMessageBox.critical(self,
|
||||
criticalErrorMessageBox(
|
||||
translate('SongsPlugin.ImportWizardForm',
|
||||
'No EasyWorship Song Database Selected'),
|
||||
translate('SongsPlugin.ImportWizardForm',
|
||||
@ -239,7 +416,7 @@ class SongImportForm(QtGui.QWizard, Ui_SongImportWizard):
|
||||
return False
|
||||
elif source_format == SongFormat.SongBeamer:
|
||||
if self.songBeamerFileListWidget.count() == 0:
|
||||
QtGui.QMessageBox.critical(self,
|
||||
criticalErrorMessageBox(
|
||||
translate('SongsPlugin.ImportWizardForm',
|
||||
'No SongBeamer File Selected'),
|
||||
translate('SongsPlugin.ImportWizardForm',
|
||||
@ -248,7 +425,7 @@ class SongImportForm(QtGui.QWizard, Ui_SongImportWizard):
|
||||
self.songBeamerAddButton.setFocus()
|
||||
return False
|
||||
return True
|
||||
elif self.currentPage() == self.importPage:
|
||||
elif self.currentPage() == self.progressPage:
|
||||
return True
|
||||
|
||||
def getFileName(self, title, editbox, filters=u''):
|
||||
@ -309,17 +486,26 @@ class SongImportForm(QtGui.QWizard, Ui_SongImportWizard):
|
||||
os.path.split(unicode(filenames[0]))[0], 1)
|
||||
|
||||
def getListOfFiles(self, listbox):
|
||||
"""
|
||||
Return a list of file from the listbox
|
||||
"""
|
||||
files = []
|
||||
for row in range(0, listbox.count()):
|
||||
files.append(unicode(listbox.item(row).text()))
|
||||
return files
|
||||
|
||||
def removeSelectedItems(self, listbox):
|
||||
"""
|
||||
Remove selected listbox items
|
||||
"""
|
||||
for item in listbox.selectedItems():
|
||||
item = listbox.takeItem(listbox.row(item))
|
||||
del item
|
||||
|
||||
def onOpenLP2BrowseButtonClicked(self):
|
||||
"""
|
||||
Get OpenLP v2 song database file
|
||||
"""
|
||||
self.getFileName(
|
||||
translate('SongsPlugin.ImportWizardForm',
|
||||
'Select OpenLP 2.0 Database File'),
|
||||
@ -329,6 +515,9 @@ class SongImportForm(QtGui.QWizard, Ui_SongImportWizard):
|
||||
)
|
||||
|
||||
def onOpenLP1BrowseButtonClicked(self):
|
||||
"""
|
||||
Get OpenLP v1 song database file
|
||||
"""
|
||||
self.getFileName(
|
||||
translate('SongsPlugin.ImportWizardForm',
|
||||
'Select openlp.org 1.x Database File'),
|
||||
@ -337,27 +526,41 @@ class SongImportForm(QtGui.QWizard, Ui_SongImportWizard):
|
||||
'openlp.org v1.x Databases')
|
||||
)
|
||||
|
||||
#def onOpenLyricsAddButtonClicked(self):
|
||||
# self.getFiles(
|
||||
# translate('SongsPlugin.ImportWizardForm',
|
||||
# 'Select OpenLyrics Files'),
|
||||
# self.openLyricsFileListWidget
|
||||
# )
|
||||
|
||||
#def onOpenLyricsRemoveButtonClicked(self):
|
||||
# self.removeSelectedItems(self.openLyricsFileListWidget)
|
||||
|
||||
def onOpenSongAddButtonClicked(self):
|
||||
def onOpenLyricsAddButtonClicked(self):
|
||||
"""
|
||||
Get OpenLyrics song database files
|
||||
"""
|
||||
self.getFiles(
|
||||
translate('SongsPlugin.ImportWizardForm',
|
||||
'Select Open Song Files'),
|
||||
'Select OpenLyrics Files'),
|
||||
self.openLyricsFileListWidget
|
||||
)
|
||||
|
||||
def onOpenLyricsRemoveButtonClicked(self):
|
||||
"""
|
||||
Remove selected OpenLyrics files from the import list
|
||||
"""
|
||||
self.removeSelectedItems(self.openLyricsFileListWidget)
|
||||
|
||||
def onOpenSongAddButtonClicked(self):
|
||||
"""
|
||||
Get OpenSong song database files
|
||||
"""
|
||||
self.getFiles(
|
||||
translate('SongsPlugin.ImportWizardForm', 'Select Open Song Files'),
|
||||
self.openSongFileListWidget
|
||||
)
|
||||
|
||||
def onOpenSongRemoveButtonClicked(self):
|
||||
"""
|
||||
Remove selected OpenSong files from the import list
|
||||
"""
|
||||
self.removeSelectedItems(self.openSongFileListWidget)
|
||||
|
||||
def onWordsOfWorshipAddButtonClicked(self):
|
||||
"""
|
||||
Get Words of Worship song database files
|
||||
"""
|
||||
self.getFiles(
|
||||
translate('SongsPlugin.ImportWizardForm',
|
||||
'Select Words of Worship Files'),
|
||||
@ -367,9 +570,15 @@ class SongImportForm(QtGui.QWizard, Ui_SongImportWizard):
|
||||
)
|
||||
|
||||
def onWordsOfWorshipRemoveButtonClicked(self):
|
||||
"""
|
||||
Remove selected Words of Worship files from the import list
|
||||
"""
|
||||
self.removeSelectedItems(self.wordsOfWorshipFileListWidget)
|
||||
|
||||
def onCCLIAddButtonClicked(self):
|
||||
"""
|
||||
Get CCLI song database files
|
||||
"""
|
||||
self.getFiles(
|
||||
translate('SongsPlugin.ImportWizardForm',
|
||||
'Select CCLI Files'),
|
||||
@ -377,9 +586,15 @@ class SongImportForm(QtGui.QWizard, Ui_SongImportWizard):
|
||||
)
|
||||
|
||||
def onCCLIRemoveButtonClicked(self):
|
||||
"""
|
||||
Remove selected CCLI files from the import list
|
||||
"""
|
||||
self.removeSelectedItems(self.ccliFileListWidget)
|
||||
|
||||
def onSongsOfFellowshipAddButtonClicked(self):
|
||||
"""
|
||||
Get Songs of Fellowship song database files
|
||||
"""
|
||||
self.getFiles(
|
||||
translate('SongsPlugin.ImportWizardForm',
|
||||
'Select Songs of Fellowship Files'),
|
||||
@ -389,9 +604,15 @@ class SongImportForm(QtGui.QWizard, Ui_SongImportWizard):
|
||||
)
|
||||
|
||||
def onSongsOfFellowshipRemoveButtonClicked(self):
|
||||
"""
|
||||
Remove selected Songs of Fellowship files from the import list
|
||||
"""
|
||||
self.removeSelectedItems(self.songsOfFellowshipFileListWidget)
|
||||
|
||||
def onGenericAddButtonClicked(self):
|
||||
"""
|
||||
Get song database files
|
||||
"""
|
||||
self.getFiles(
|
||||
translate('SongsPlugin.ImportWizardForm',
|
||||
'Select Document/Presentation Files'),
|
||||
@ -399,9 +620,15 @@ class SongImportForm(QtGui.QWizard, Ui_SongImportWizard):
|
||||
)
|
||||
|
||||
def onGenericRemoveButtonClicked(self):
|
||||
"""
|
||||
Remove selected files from the import list
|
||||
"""
|
||||
self.removeSelectedItems(self.genericFileListWidget)
|
||||
|
||||
def onEWBrowseButtonClicked(self):
|
||||
"""
|
||||
Get EasyWorship song database files
|
||||
"""
|
||||
self.getFileName(
|
||||
translate('SongsPlugin.ImportWizardForm',
|
||||
'Select EasyWorship Database File'),
|
||||
@ -409,6 +636,9 @@ class SongImportForm(QtGui.QWizard, Ui_SongImportWizard):
|
||||
)
|
||||
|
||||
def onSongBeamerAddButtonClicked(self):
|
||||
"""
|
||||
Get SongBeamer song database files
|
||||
"""
|
||||
self.getFiles(
|
||||
translate('SongsPlugin.ImportWizardForm',
|
||||
'Select SongBeamer Files'),
|
||||
@ -417,25 +647,28 @@ class SongImportForm(QtGui.QWizard, Ui_SongImportWizard):
|
||||
)
|
||||
|
||||
def onSongBeamerRemoveButtonClicked(self):
|
||||
"""
|
||||
Remove selected SongBeamer files from the import list
|
||||
"""
|
||||
self.removeSelectedItems(self.songBeamerFileListWidget)
|
||||
|
||||
def onCurrentIdChanged(self, id):
|
||||
if self.page(id) == self.importPage:
|
||||
self.preImport()
|
||||
self.performImport()
|
||||
self.postImport()
|
||||
|
||||
def registerFields(self):
|
||||
"""
|
||||
Register song import wizard fields.
|
||||
"""
|
||||
pass
|
||||
|
||||
def setDefaults(self):
|
||||
"""
|
||||
Set default form values for the song import wizard.
|
||||
"""
|
||||
self.restart()
|
||||
self.finishButton.setVisible(False)
|
||||
self.cancelButton.setVisible(True)
|
||||
self.formatComboBox.setCurrentIndex(0)
|
||||
self.openLP2FilenameEdit.setText(u'')
|
||||
self.openLP1FilenameEdit.setText(u'')
|
||||
#self.openLyricsFileListWidget.clear()
|
||||
self.openLyricsFileListWidget.clear()
|
||||
self.openSongFileListWidget.clear()
|
||||
self.wordsOfWorshipFileListWidget.clear()
|
||||
self.ccliFileListWidget.clear()
|
||||
@ -445,25 +678,16 @@ class SongImportForm(QtGui.QWizard, Ui_SongImportWizard):
|
||||
self.songBeamerFileListWidget.clear()
|
||||
#self.csvFilenameEdit.setText(u'')
|
||||
|
||||
def incrementProgressBar(self, status_text, increment=1):
|
||||
log.debug(u'IncrementBar %s', status_text)
|
||||
if status_text:
|
||||
self.importProgressLabel.setText(status_text)
|
||||
if increment > 0:
|
||||
self.importProgressBar.setValue(self.importProgressBar.value() +
|
||||
increment)
|
||||
Receiver.send_message(u'openlp_process_events')
|
||||
|
||||
def preImport(self):
|
||||
self.finishButton.setVisible(False)
|
||||
self.importProgressBar.setMinimum(0)
|
||||
self.importProgressBar.setMaximum(1188)
|
||||
self.importProgressBar.setValue(0)
|
||||
self.importProgressLabel.setText(
|
||||
def preWizard(self):
|
||||
"""
|
||||
Perform pre import tasks
|
||||
"""
|
||||
OpenLPWizard.preWizard(self)
|
||||
self.progressLabel.setText(
|
||||
translate('SongsPlugin.ImportWizardForm', 'Starting import...'))
|
||||
Receiver.send_message(u'openlp_process_events')
|
||||
|
||||
def performImport(self):
|
||||
def performWizard(self):
|
||||
"""
|
||||
Perform the actual import. This method pulls in the correct importer
|
||||
class, and then runs the ``do_import`` method of the importer to do
|
||||
@ -521,20 +745,128 @@ class SongImportForm(QtGui.QWizard, Ui_SongImportWizard):
|
||||
elif source_format == SongFormat.SongBeamer:
|
||||
# Import SongBeamer songs
|
||||
importer = self.plugin.importSongs(SongFormat.SongBeamer,
|
||||
filenames=self.getListOfFiles(
|
||||
self.songBeamerFileListWidget)
|
||||
filenames=self.getListOfFiles(self.songBeamerFileListWidget)
|
||||
)
|
||||
if importer.do_import():
|
||||
# reload songs
|
||||
self.importProgressLabel.setText(
|
||||
self.progressLabel.setText(
|
||||
translate('SongsPlugin.SongImportForm', 'Finished import.'))
|
||||
else:
|
||||
self.importProgressLabel.setText(
|
||||
self.progressLabel.setText(
|
||||
translate('SongsPlugin.SongImportForm',
|
||||
'Your song import failed.'))
|
||||
|
||||
def postImport(self):
|
||||
self.importProgressBar.setValue(self.importProgressBar.maximum())
|
||||
self.finishButton.setVisible(True)
|
||||
self.cancelButton.setVisible(False)
|
||||
Receiver.send_message(u'openlp_process_events')
|
||||
def addSingleFileSelectItem(self, prefix, obj_prefix=None,
|
||||
can_disable=False):
|
||||
if not obj_prefix:
|
||||
obj_prefix = prefix
|
||||
page = QtGui.QWidget()
|
||||
page.setObjectName(obj_prefix + u'Page')
|
||||
if can_disable:
|
||||
importWidget = self.disablableWidget(page, prefix, obj_prefix)
|
||||
else:
|
||||
importWidget = page
|
||||
importLayout = QtGui.QFormLayout(importWidget)
|
||||
importLayout.setMargin(0)
|
||||
if can_disable:
|
||||
importLayout.setObjectName(obj_prefix + u'ImportLayout')
|
||||
else:
|
||||
importLayout.setObjectName(obj_prefix + u'Layout')
|
||||
filenameLabel = QtGui.QLabel(importWidget)
|
||||
filenameLabel.setObjectName(obj_prefix + u'FilenameLabel')
|
||||
fileLayout = QtGui.QHBoxLayout()
|
||||
fileLayout.setObjectName(obj_prefix + u'FileLayout')
|
||||
filenameEdit = QtGui.QLineEdit(importWidget)
|
||||
filenameEdit.setObjectName(obj_prefix + u'FilenameEdit')
|
||||
fileLayout.addWidget(filenameEdit)
|
||||
browseButton = QtGui.QToolButton(importWidget)
|
||||
browseButton.setIcon(self.openIcon)
|
||||
browseButton.setObjectName(obj_prefix + u'BrowseButton')
|
||||
fileLayout.addWidget(browseButton)
|
||||
importLayout.addRow(filenameLabel, fileLayout)
|
||||
formSpacer = QtGui.QSpacerItem(10, 0, QtGui.QSizePolicy.Fixed,
|
||||
QtGui.QSizePolicy.Minimum)
|
||||
importLayout.setItem(1, QtGui.QFormLayout.LabelRole, formSpacer)
|
||||
self.formatStack.addWidget(page)
|
||||
setattr(self, prefix + u'Page', page)
|
||||
setattr(self, prefix + u'FilenameLabel', filenameLabel)
|
||||
setattr(self, prefix + u'FormLabelSpacer', formSpacer)
|
||||
setattr(self, prefix + u'FileLayout', fileLayout)
|
||||
setattr(self, prefix + u'FilenameEdit', filenameEdit)
|
||||
setattr(self, prefix + u'BrowseButton', browseButton)
|
||||
if can_disable:
|
||||
setattr(self, prefix + u'ImportLayout', importLayout)
|
||||
else:
|
||||
setattr(self, prefix + u'Layout', importLayout)
|
||||
self.formatComboBox.addItem(u'')
|
||||
|
||||
def addMultiFileSelectItem(self, prefix, obj_prefix=None,
|
||||
can_disable=False):
|
||||
if not obj_prefix:
|
||||
obj_prefix = prefix
|
||||
page = QtGui.QWidget()
|
||||
page.setObjectName(obj_prefix + u'Page')
|
||||
if can_disable:
|
||||
importWidget = self.disablableWidget(page, prefix, obj_prefix)
|
||||
else:
|
||||
importWidget = page
|
||||
importLayout = QtGui.QVBoxLayout(importWidget)
|
||||
importLayout.setMargin(0)
|
||||
if can_disable:
|
||||
importLayout.setObjectName(obj_prefix + u'ImportLayout')
|
||||
else:
|
||||
importLayout.setObjectName(obj_prefix + u'Layout')
|
||||
fileListWidget = QtGui.QListWidget(importWidget)
|
||||
fileListWidget.setSelectionMode(
|
||||
QtGui.QAbstractItemView.ExtendedSelection)
|
||||
fileListWidget.setObjectName(obj_prefix + u'FileListWidget')
|
||||
importLayout.addWidget(fileListWidget)
|
||||
buttonLayout = QtGui.QHBoxLayout()
|
||||
buttonLayout.setObjectName(obj_prefix + u'ButtonLayout')
|
||||
addButton = QtGui.QPushButton(importWidget)
|
||||
addButton.setIcon(self.openIcon)
|
||||
addButton.setObjectName(obj_prefix + u'AddButton')
|
||||
buttonLayout.addWidget(addButton)
|
||||
buttonLayout.addStretch()
|
||||
removeButton = QtGui.QPushButton(importWidget)
|
||||
removeButton.setIcon(self.deleteIcon)
|
||||
removeButton.setObjectName(obj_prefix + u'RemoveButton')
|
||||
buttonLayout.addWidget(removeButton)
|
||||
importLayout.addLayout(buttonLayout)
|
||||
self.formatStack.addWidget(page)
|
||||
setattr(self, prefix + u'Page', page)
|
||||
setattr(self, prefix + u'FileListWidget', fileListWidget)
|
||||
setattr(self, prefix + u'ButtonLayout', buttonLayout)
|
||||
setattr(self, prefix + u'AddButton', addButton)
|
||||
setattr(self, prefix + u'RemoveButton', removeButton)
|
||||
if can_disable:
|
||||
setattr(self, prefix + u'ImportLayout', importLayout)
|
||||
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)
|
||||
layout.setSpacing(0)
|
||||
layout.setObjectName(obj_prefix + u'Layout')
|
||||
disabledWidget = QtGui.QWidget(page)
|
||||
disabledWidget.setVisible(False)
|
||||
disabledWidget.setObjectName(obj_prefix + u'DisabledWidget')
|
||||
disabledLayout = QtGui.QVBoxLayout(disabledWidget)
|
||||
disabledLayout.setMargin(0)
|
||||
disabledLayout.setObjectName(obj_prefix + u'DisabledLayout')
|
||||
disabledLabel = QtGui.QLabel(disabledWidget)
|
||||
disabledLabel.setWordWrap(True)
|
||||
disabledLabel.setObjectName(obj_prefix + u'DisabledLabel')
|
||||
disabledLayout.addWidget(disabledLabel)
|
||||
layout.addWidget(disabledWidget)
|
||||
importWidget = QtGui.QWidget(page)
|
||||
importWidget.setObjectName(obj_prefix + u'ImportWidget')
|
||||
layout.addWidget(importWidget)
|
||||
setattr(self, prefix + u'Layout', layout)
|
||||
setattr(self, prefix + u'DisabledWidget', disabledWidget)
|
||||
setattr(self, prefix + u'DisabledLayout', disabledLayout)
|
||||
setattr(self, prefix + u'DisabledLabel', disabledLabel)
|
||||
setattr(self, prefix + u'ImportWidget', importWidget)
|
||||
return importWidget
|
||||
|
@ -1,365 +0,0 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4
|
||||
|
||||
###############################################################################
|
||||
# OpenLP - Open Source Lyrics Projection #
|
||||
# --------------------------------------------------------------------------- #
|
||||
# Copyright (c) 2008-2011 Raoul Snyman #
|
||||
# Portions copyright (c) 2008-2011 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 #
|
||||
###############################################################################
|
||||
|
||||
from PyQt4 import QtCore, QtGui
|
||||
|
||||
from openlp.core.lib import build_icon, translate
|
||||
|
||||
class Ui_SongImportWizard(object):
|
||||
def setupUi(self, songImportWizard):
|
||||
self.openIcon = build_icon(u':/general/general_open.png')
|
||||
self.deleteIcon = build_icon(u':/general/general_delete.png')
|
||||
songImportWizard.setObjectName(u'songImportWizard')
|
||||
songImportWizard.setModal(True)
|
||||
songImportWizard.setWizardStyle(QtGui.QWizard.ModernStyle)
|
||||
songImportWizard.setOptions(
|
||||
QtGui.QWizard.IndependentPages |
|
||||
QtGui.QWizard.NoBackButtonOnStartPage |
|
||||
QtGui.QWizard.NoBackButtonOnLastPage)
|
||||
# Welcome Page
|
||||
self.welcomePage = QtGui.QWizardPage()
|
||||
self.welcomePage.setPixmap(QtGui.QWizard.WatermarkPixmap,
|
||||
QtGui.QPixmap(u':/wizards/wizard_importsong.bmp'))
|
||||
self.welcomePage.setObjectName(u'WelcomePage')
|
||||
self.welcomeLayout = QtGui.QVBoxLayout(self.welcomePage)
|
||||
self.welcomeLayout.setObjectName(u'WelcomeLayout')
|
||||
self.titleLabel = QtGui.QLabel(self.welcomePage)
|
||||
self.titleLabel.setObjectName(u'TitleLabel')
|
||||
self.welcomeLayout.addWidget(self.titleLabel)
|
||||
self.welcomeLayout.addSpacing(40)
|
||||
self.informationLabel = QtGui.QLabel(self.welcomePage)
|
||||
self.informationLabel.setWordWrap(True)
|
||||
self.informationLabel.setObjectName(u'InformationLabel')
|
||||
self.welcomeLayout.addWidget(self.informationLabel)
|
||||
self.welcomeLayout.addStretch()
|
||||
songImportWizard.addPage(self.welcomePage)
|
||||
# Source Page
|
||||
self.sourcePage = QtGui.QWizardPage()
|
||||
self.sourcePage.setObjectName(u'SourcePage')
|
||||
self.sourceLayout = QtGui.QVBoxLayout(self.sourcePage)
|
||||
self.sourceLayout.setObjectName(u'SourceLayout')
|
||||
self.formatLayout = QtGui.QFormLayout()
|
||||
self.formatLayout.setObjectName(u'FormatLayout')
|
||||
self.formatLabel = QtGui.QLabel(self.sourcePage)
|
||||
self.formatLabel.setObjectName(u'FormatLabel')
|
||||
self.formatComboBox = QtGui.QComboBox(self.sourcePage)
|
||||
self.formatComboBox.setObjectName(u'FormatComboBox')
|
||||
self.formatLayout.addRow(self.formatLabel, self.formatComboBox)
|
||||
self.formatSpacer = QtGui.QSpacerItem(10, 0, QtGui.QSizePolicy.Fixed,
|
||||
QtGui.QSizePolicy.Minimum)
|
||||
self.formatLayout.setItem(1, QtGui.QFormLayout.LabelRole,
|
||||
self.formatSpacer)
|
||||
self.sourceLayout.addLayout(self.formatLayout)
|
||||
self.formatStack = QtGui.QStackedLayout()
|
||||
self.formatStack.setObjectName(u'FormatStack')
|
||||
# OpenLP 2.0
|
||||
self.addSingleFileSelectItem(u'openLP2')
|
||||
# openlp.org 1.x
|
||||
self.addSingleFileSelectItem(u'openLP1', None, True)
|
||||
# OpenLyrics
|
||||
self.addMultiFileSelectItem(u'openLyrics', u'OpenLyrics', True)
|
||||
# set OpenLyrics to disabled by default
|
||||
self.openLyricsDisabledWidget.setVisible(True)
|
||||
self.openLyricsImportWidget.setVisible(False)
|
||||
# Open Song
|
||||
self.addMultiFileSelectItem(u'openSong', u'OpenSong')
|
||||
# Words of Worship
|
||||
self.addMultiFileSelectItem(u'wordsOfWorship')
|
||||
# CCLI File import
|
||||
self.addMultiFileSelectItem(u'ccli')
|
||||
# Songs of Fellowship
|
||||
self.addMultiFileSelectItem(u'songsOfFellowship', None, True)
|
||||
# Generic Document/Presentation import
|
||||
self.addMultiFileSelectItem(u'generic', None, True)
|
||||
# EasyWorship
|
||||
self.addSingleFileSelectItem(u'ew')
|
||||
# Words of Worship
|
||||
self.addMultiFileSelectItem(u'songBeamer')
|
||||
# Commented out for future use.
|
||||
# self.addSingleFileSelectItem(u'csv', u'CSV')
|
||||
self.sourceLayout.addLayout(self.formatStack)
|
||||
songImportWizard.addPage(self.sourcePage)
|
||||
# Import Page
|
||||
self.importPage = QtGui.QWizardPage()
|
||||
self.importPage.setObjectName(u'ImportPage')
|
||||
self.importLayout = QtGui.QVBoxLayout(self.importPage)
|
||||
self.importLayout.setMargin(48)
|
||||
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.setObjectName(u'ImportProgressBar')
|
||||
self.importLayout.addWidget(self.importProgressBar)
|
||||
songImportWizard.addPage(self.importPage)
|
||||
self.retranslateUi(songImportWizard)
|
||||
self.formatStack.setCurrentIndex(0)
|
||||
QtCore.QObject.connect(self.formatComboBox,
|
||||
QtCore.SIGNAL(u'currentIndexChanged(int)'),
|
||||
self.formatStack.setCurrentIndex)
|
||||
QtCore.QMetaObject.connectSlotsByName(songImportWizard)
|
||||
|
||||
def retranslateUi(self, songImportWizard):
|
||||
songImportWizard.setWindowTitle(
|
||||
translate('SongsPlugin.ImportWizardForm', 'Song Import Wizard'))
|
||||
self.titleLabel.setText(
|
||||
u'<span style="font-size:14pt; font-weight:600;">%s</span>' % \
|
||||
translate('SongsPlugin.ImportWizardForm',
|
||||
'Welcome to the Song Import Wizard'))
|
||||
self.informationLabel.setText(
|
||||
translate('SongsPlugin.ImportWizardForm',
|
||||
'This wizard will help you to import songs from a variety of '
|
||||
'formats. Click the next button below to start the process by '
|
||||
'selecting a format to import from.'))
|
||||
self.sourcePage.setTitle(
|
||||
translate('SongsPlugin.ImportWizardForm', 'Select Import Source'))
|
||||
self.sourcePage.setSubTitle(
|
||||
translate('SongsPlugin.ImportWizardForm',
|
||||
'Select the import format, and where to import from.'))
|
||||
self.formatLabel.setText(
|
||||
translate('SongsPlugin.ImportWizardForm', 'Format:'))
|
||||
self.formatComboBox.setItemText(0,
|
||||
translate('SongsPlugin.ImportWizardForm', 'OpenLP 2.0'))
|
||||
self.formatComboBox.setItemText(1,
|
||||
translate('SongsPlugin.ImportWizardForm', 'openlp.org 1.x'))
|
||||
self.formatComboBox.setItemText(2,
|
||||
translate('SongsPlugin.ImportWizardForm', 'OpenLyrics'))
|
||||
self.formatComboBox.setItemText(3,
|
||||
translate('SongsPlugin.ImportWizardForm', 'OpenSong'))
|
||||
self.formatComboBox.setItemText(4,
|
||||
translate('SongsPlugin.ImportWizardForm', 'Words of Worship'))
|
||||
self.formatComboBox.setItemText(5,
|
||||
translate('SongsPlugin.ImportWizardForm', 'CCLI/SongSelect'))
|
||||
self.formatComboBox.setItemText(6,
|
||||
translate('SongsPlugin.ImportWizardForm', 'Songs of Fellowship'))
|
||||
self.formatComboBox.setItemText(7,
|
||||
translate('SongsPlugin.ImportWizardForm',
|
||||
'Generic Document/Presentation'))
|
||||
self.formatComboBox.setItemText(8,
|
||||
translate('SongsPlugin.ImportWizardForm', 'EasyWorship'))
|
||||
self.formatComboBox.setItemText(9,
|
||||
translate('SongsPlugin.ImportWizardForm', 'SongBeamer'))
|
||||
# self.formatComboBox.setItemText(9,
|
||||
# translate('SongsPlugin.ImportWizardForm', 'CSV'))
|
||||
self.openLP2FilenameLabel.setText(
|
||||
translate('SongsPlugin.ImportWizardForm', 'Filename:'))
|
||||
self.openLP2BrowseButton.setText(
|
||||
translate('SongsPlugin.ImportWizardForm', 'Browse...'))
|
||||
self.openLP1FilenameLabel.setText(
|
||||
translate('SongsPlugin.ImportWizardForm', 'Filename:'))
|
||||
self.openLP1BrowseButton.setText(
|
||||
translate('SongsPlugin.ImportWizardForm', 'Browse...'))
|
||||
self.openLP1DisabledLabel.setText(
|
||||
translate('SongsPlugin.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.'))
|
||||
#self.openLyricsAddButton.setText(
|
||||
# translate('SongsPlugin.ImportWizardForm', 'Add Files...'))
|
||||
#self.openLyricsRemoveButton.setText(
|
||||
# translate('SongsPlugin.ImportWizardForm', 'Remove File(s)'))
|
||||
self.openLyricsDisabledLabel.setText(
|
||||
translate('SongsPlugin.ImportWizardForm', 'The OpenLyrics '
|
||||
'importer has not yet been developed, but as you can see, we are '
|
||||
'still intending to do so. Hopefully it will be in the next '
|
||||
'release.'))
|
||||
self.openSongAddButton.setText(
|
||||
translate('SongsPlugin.ImportWizardForm', 'Add Files...'))
|
||||
self.openSongRemoveButton.setText(
|
||||
translate('SongsPlugin.ImportWizardForm', 'Remove File(s)'))
|
||||
self.wordsOfWorshipAddButton.setText(
|
||||
translate('SongsPlugin.ImportWizardForm', 'Add Files...'))
|
||||
self.wordsOfWorshipRemoveButton.setText(
|
||||
translate('SongsPlugin.ImportWizardForm', 'Remove File(s)'))
|
||||
self.ccliAddButton.setText(
|
||||
translate('SongsPlugin.ImportWizardForm', 'Add Files...'))
|
||||
self.ccliRemoveButton.setText(
|
||||
translate('SongsPlugin.ImportWizardForm', 'Remove File(s)'))
|
||||
self.songsOfFellowshipAddButton.setText(
|
||||
translate('SongsPlugin.ImportWizardForm', 'Add Files...'))
|
||||
self.songsOfFellowshipRemoveButton.setText(
|
||||
translate('SongsPlugin.ImportWizardForm', 'Remove File(s)'))
|
||||
self.songsOfFellowshipDisabledLabel.setText(
|
||||
translate('SongsPlugin.ImportWizardForm', 'The Songs of '
|
||||
'Fellowship importer has been disabled because OpenLP cannot '
|
||||
'find OpenOffice.org on your computer.'))
|
||||
self.genericAddButton.setText(
|
||||
translate('SongsPlugin.ImportWizardForm', 'Add Files...'))
|
||||
self.genericRemoveButton.setText(
|
||||
translate('SongsPlugin.ImportWizardForm', 'Remove File(s)'))
|
||||
self.genericDisabledLabel.setText(
|
||||
translate('SongsPlugin.ImportWizardForm', 'The generic document/'
|
||||
'presentation importer has been disabled because OpenLP cannot '
|
||||
'find OpenOffice.org on your computer.'))
|
||||
self.ewFilenameLabel.setText(
|
||||
translate('SongsPlugin.ImportWizardForm', 'Filename:'))
|
||||
self.ewBrowseButton.setText(
|
||||
translate('SongsPlugin.ImportWizardForm', 'Browse...'))
|
||||
self.songBeamerAddButton.setText(
|
||||
translate('SongsPlugin.ImportWizardForm', 'Add Files...'))
|
||||
self.songBeamerRemoveButton.setText(
|
||||
translate('SongsPlugin.ImportWizardForm', 'Remove File(s)'))
|
||||
# self.csvFilenameLabel.setText(
|
||||
# translate('SongsPlugin.ImportWizardForm', 'Filename:'))
|
||||
# self.csvBrowseButton.setText(
|
||||
# translate('SongsPlugin.ImportWizardForm', 'Browse...'))
|
||||
self.importPage.setTitle(
|
||||
translate('SongsPlugin.ImportWizardForm', 'Importing'))
|
||||
self.importPage.setSubTitle(
|
||||
translate('SongsPlugin.ImportWizardForm',
|
||||
'Please wait while your songs are imported.'))
|
||||
self.importProgressLabel.setText(
|
||||
translate('SongsPlugin.ImportWizardForm', 'Ready.'))
|
||||
self.importProgressBar.setFormat(
|
||||
translate('SongsPlugin.ImportWizardForm', '%p%'))
|
||||
# Align all QFormLayouts towards each other.
|
||||
width = max(self.formatLabel.minimumSizeHint().width(),
|
||||
self.openLP2FilenameLabel.minimumSizeHint().width())
|
||||
self.formatSpacer.changeSize(width, 0, QtGui.QSizePolicy.Fixed,
|
||||
QtGui.QSizePolicy.Fixed)
|
||||
self.openLP2FormLabelSpacer.changeSize(width, 0,
|
||||
QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Fixed)
|
||||
self.openLP1FormLabelSpacer.changeSize(width, 0,
|
||||
QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Fixed)
|
||||
self.ewFormLabelSpacer.changeSize(width, 0, QtGui.QSizePolicy.Fixed,
|
||||
QtGui.QSizePolicy.Fixed)
|
||||
# self.csvFormLabelSpacer.changeSize(width, 0, QtGui.QSizePolicy.Fixed,
|
||||
# QtGui.QSizePolicy.Fixed)
|
||||
|
||||
def addSingleFileSelectItem(self, prefix, obj_prefix=None,
|
||||
can_disable=False):
|
||||
if not obj_prefix:
|
||||
obj_prefix = prefix
|
||||
page = QtGui.QWidget()
|
||||
page.setObjectName(obj_prefix + u'Page')
|
||||
if can_disable:
|
||||
importWidget = self.disablableWidget(page, prefix, obj_prefix)
|
||||
else:
|
||||
importWidget = page
|
||||
importLayout = QtGui.QFormLayout(importWidget)
|
||||
importLayout.setMargin(0)
|
||||
if can_disable:
|
||||
importLayout.setObjectName(obj_prefix + u'ImportLayout')
|
||||
else:
|
||||
importLayout.setObjectName(obj_prefix + u'Layout')
|
||||
filenameLabel = QtGui.QLabel(importWidget)
|
||||
filenameLabel.setObjectName(obj_prefix + u'FilenameLabel')
|
||||
fileLayout = QtGui.QHBoxLayout()
|
||||
fileLayout.setObjectName(obj_prefix + u'FileLayout')
|
||||
filenameEdit = QtGui.QLineEdit(importWidget)
|
||||
filenameEdit.setObjectName(obj_prefix + u'FilenameEdit')
|
||||
fileLayout.addWidget(filenameEdit)
|
||||
browseButton = QtGui.QToolButton(importWidget)
|
||||
browseButton.setIcon(self.openIcon)
|
||||
browseButton.setObjectName(obj_prefix + u'BrowseButton')
|
||||
fileLayout.addWidget(browseButton)
|
||||
importLayout.addRow(filenameLabel, fileLayout)
|
||||
formSpacer = QtGui.QSpacerItem(10, 0, QtGui.QSizePolicy.Fixed,
|
||||
QtGui.QSizePolicy.Minimum)
|
||||
importLayout.setItem(1, QtGui.QFormLayout.LabelRole, formSpacer)
|
||||
self.formatStack.addWidget(page)
|
||||
setattr(self, prefix + u'Page', page)
|
||||
setattr(self, prefix + u'FilenameLabel', filenameLabel)
|
||||
setattr(self, prefix + u'FormLabelSpacer', formSpacer)
|
||||
setattr(self, prefix + u'FileLayout', fileLayout)
|
||||
setattr(self, prefix + u'FilenameEdit', filenameEdit)
|
||||
setattr(self, prefix + u'BrowseButton', browseButton)
|
||||
if can_disable:
|
||||
setattr(self, prefix + u'ImportLayout', importLayout)
|
||||
else:
|
||||
setattr(self, prefix + u'Layout', importLayout)
|
||||
self.formatComboBox.addItem(u'')
|
||||
|
||||
def addMultiFileSelectItem(self, prefix, obj_prefix=None,
|
||||
can_disable=False):
|
||||
if not obj_prefix:
|
||||
obj_prefix = prefix
|
||||
page = QtGui.QWidget()
|
||||
page.setObjectName(obj_prefix + u'Page')
|
||||
if can_disable:
|
||||
importWidget = self.disablableWidget(page, prefix, obj_prefix)
|
||||
else:
|
||||
importWidget = page
|
||||
importLayout = QtGui.QVBoxLayout(importWidget)
|
||||
importLayout.setMargin(0)
|
||||
if can_disable:
|
||||
importLayout.setObjectName(obj_prefix + u'ImportLayout')
|
||||
else:
|
||||
importLayout.setObjectName(obj_prefix + u'Layout')
|
||||
fileListWidget = QtGui.QListWidget(importWidget)
|
||||
fileListWidget.setSelectionMode(
|
||||
QtGui.QAbstractItemView.ExtendedSelection)
|
||||
fileListWidget.setObjectName(obj_prefix + u'FileListWidget')
|
||||
importLayout.addWidget(fileListWidget)
|
||||
buttonLayout = QtGui.QHBoxLayout()
|
||||
buttonLayout.setObjectName(obj_prefix + u'ButtonLayout')
|
||||
addButton = QtGui.QPushButton(importWidget)
|
||||
addButton.setIcon(self.openIcon)
|
||||
addButton.setObjectName(obj_prefix + u'AddButton')
|
||||
buttonLayout.addWidget(addButton)
|
||||
buttonLayout.addStretch()
|
||||
removeButton = QtGui.QPushButton(importWidget)
|
||||
removeButton.setIcon(self.deleteIcon)
|
||||
removeButton.setObjectName(obj_prefix + u'RemoveButton')
|
||||
buttonLayout.addWidget(removeButton)
|
||||
importLayout.addLayout(buttonLayout)
|
||||
self.formatStack.addWidget(page)
|
||||
setattr(self, prefix + u'Page', page)
|
||||
setattr(self, prefix + u'FileListWidget', fileListWidget)
|
||||
setattr(self, prefix + u'ButtonLayout', buttonLayout)
|
||||
setattr(self, prefix + u'AddButton', addButton)
|
||||
setattr(self, prefix + u'RemoveButton', removeButton)
|
||||
if can_disable:
|
||||
setattr(self, prefix + u'ImportLayout', importLayout)
|
||||
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)
|
||||
layout.setSpacing(0)
|
||||
layout.setObjectName(obj_prefix + u'Layout')
|
||||
disabledWidget = QtGui.QWidget(page)
|
||||
disabledWidget.setVisible(False)
|
||||
disabledWidget.setObjectName(obj_prefix + u'DisabledWidget')
|
||||
disabledLayout = QtGui.QVBoxLayout(disabledWidget)
|
||||
disabledLayout.setMargin(0)
|
||||
disabledLayout.setObjectName(obj_prefix + u'DisabledLayout')
|
||||
disabledLabel = QtGui.QLabel(disabledWidget)
|
||||
disabledLabel.setWordWrap(True)
|
||||
disabledLabel.setObjectName(obj_prefix + u'DisabledLabel')
|
||||
disabledLayout.addWidget(disabledLabel)
|
||||
layout.addWidget(disabledWidget)
|
||||
importWidget = QtGui.QWidget(page)
|
||||
importWidget.setObjectName(obj_prefix + u'ImportWidget')
|
||||
layout.addWidget(importWidget)
|
||||
setattr(self, prefix + u'Layout', layout)
|
||||
setattr(self, prefix + u'DisabledWidget', disabledWidget)
|
||||
setattr(self, prefix + u'DisabledLayout', disabledLayout)
|
||||
setattr(self, prefix + u'DisabledLabel', disabledLabel)
|
||||
setattr(self, prefix + u'ImportWidget', importWidget)
|
||||
return importWidget
|
@ -36,8 +36,6 @@ class Ui_SongMaintenanceDialog(object):
|
||||
self.dialogLayout = QtGui.QGridLayout(songMaintenanceDialog)
|
||||
self.dialogLayout.setObjectName(u'dialogLayout')
|
||||
self.typeListWidget = QtGui.QListWidget(songMaintenanceDialog)
|
||||
# Caution: fixed widget width
|
||||
self.typeListWidget.setFixedWidth(172)
|
||||
self.typeListWidget.setIconSize(QtCore.QSize(32, 32))
|
||||
self.typeListWidget.setUniformItemSizes(True)
|
||||
self.typeListWidget.setObjectName(u'typeListWidget')
|
||||
@ -147,12 +145,12 @@ class Ui_SongMaintenanceDialog(object):
|
||||
def retranslateUi(self, songMaintenanceDialog):
|
||||
songMaintenanceDialog.setWindowTitle(
|
||||
translate('SongsPlugin.SongMaintenanceForm', 'Song Maintenance'))
|
||||
self.listItemAuthors.setText(
|
||||
translate('SongsPlugin.SongMaintenanceForm', 'Authors'))
|
||||
self.listItemTopics.setText(
|
||||
translate('SongsPlugin.SongMaintenanceForm', 'Topics'))
|
||||
self.listItemBooks.setText(
|
||||
translate('SongsPlugin.SongMaintenanceForm', 'Song Books'))
|
||||
authorsString = translate('SongsPlugin.SongMaintenanceForm', 'Authors')
|
||||
topicsString = translate('SongsPlugin.SongMaintenanceForm', 'Topics')
|
||||
booksString = translate('SongsPlugin.SongMaintenanceForm', 'Song Books')
|
||||
self.listItemAuthors.setText(authorsString)
|
||||
self.listItemTopics.setText(topicsString)
|
||||
self.listItemBooks.setText(booksString)
|
||||
self.authorsAddButton.setText(
|
||||
translate('SongsPlugin.SongMaintenanceForm', '&Add'))
|
||||
self.authorsEditButton.setText(
|
||||
@ -171,3 +169,8 @@ class Ui_SongMaintenanceDialog(object):
|
||||
translate('SongsPlugin.SongMaintenanceForm', '&Edit'))
|
||||
self.booksDeleteButton.setText(
|
||||
translate('SongsPlugin.SongMaintenanceForm', '&Delete'))
|
||||
typeListWidth = max(self.fontMetrics().width(authorsString),
|
||||
self.fontMetrics().width(topicsString),
|
||||
self.fontMetrics().width(booksString))
|
||||
self.typeListWidget.setFixedWidth(typeListWidth +
|
||||
self.typeListWidget.iconSize().width() + 32)
|
||||
|
@ -23,15 +23,19 @@
|
||||
# with this program; if not, write to the Free Software Foundation, Inc., 59 #
|
||||
# Temple Place, Suite 330, Boston, MA 02111-1307 USA #
|
||||
###############################################################################
|
||||
import logging
|
||||
|
||||
from PyQt4 import QtGui, QtCore
|
||||
from sqlalchemy.sql import and_
|
||||
|
||||
from openlp.core.lib import Receiver, translate
|
||||
from openlp.core.ui import criticalErrorMessageBox
|
||||
from openlp.plugins.songs.forms import AuthorsForm, TopicsForm, SongBookForm
|
||||
from openlp.plugins.songs.lib.db import Author, Book, Topic, Song
|
||||
from songmaintenancedialog import Ui_SongMaintenanceDialog
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
class SongMaintenanceForm(QtGui.QDialog, Ui_SongMaintenanceDialog):
|
||||
"""
|
||||
Class documentation goes here.
|
||||
@ -87,15 +91,14 @@ class SongMaintenanceForm(QtGui.QDialog, Ui_SongMaintenanceDialog):
|
||||
if item_id != -1:
|
||||
item = self.manager.get_object(item_class, item_id)
|
||||
if item and len(item.songs) == 0:
|
||||
if QtGui.QMessageBox.warning(self, dlg_title, del_text,
|
||||
QtGui.QMessageBox.StandardButtons(QtGui.QMessageBox.No |
|
||||
QtGui.QMessageBox.Yes)) == QtGui.QMessageBox.Yes:
|
||||
if criticalErrorMessageBox(title=dlg_title, message=del_text,
|
||||
parent=self, question=True) == QtGui.QMessageBox.Yes:
|
||||
self.manager.delete_object(item_class, item.id)
|
||||
reset_func()
|
||||
else:
|
||||
QtGui.QMessageBox.critical(self, dlg_title, err_text)
|
||||
criticalErrorMessageBox(dlg_title, err_text)
|
||||
else:
|
||||
QtGui.QMessageBox.critical(self, dlg_title, sel_text)
|
||||
criticalErrorMessageBox(dlg_title, sel_text)
|
||||
|
||||
def resetAuthors(self):
|
||||
"""
|
||||
@ -229,14 +232,12 @@ class SongMaintenanceForm(QtGui.QDialog, Ui_SongMaintenanceDialog):
|
||||
if self.manager.save_object(author):
|
||||
self.resetAuthors()
|
||||
else:
|
||||
QtGui.QMessageBox.critical(self,
|
||||
translate('SongsPlugin.SongMaintenanceForm', 'Error'),
|
||||
translate('SongsPlugin.SongMaintenanceForm',
|
||||
criticalErrorMessageBox(
|
||||
message=translate('SongsPlugin.SongMaintenanceForm',
|
||||
'Could not add your author.'))
|
||||
else:
|
||||
QtGui.QMessageBox.critical(self,
|
||||
translate('SongsPlugin.SongMaintenanceForm', 'Error'),
|
||||
translate('SongsPlugin.SongMaintenanceForm',
|
||||
criticalErrorMessageBox(
|
||||
message=translate('SongsPlugin.SongMaintenanceForm',
|
||||
'This author already exists.'))
|
||||
|
||||
def onTopicAddButtonClick(self):
|
||||
@ -246,14 +247,12 @@ class SongMaintenanceForm(QtGui.QDialog, Ui_SongMaintenanceDialog):
|
||||
if self.manager.save_object(topic):
|
||||
self.resetTopics()
|
||||
else:
|
||||
QtGui.QMessageBox.critical(self,
|
||||
translate('SongsPlugin.SongMaintenanceForm', 'Error'),
|
||||
translate('SongsPlugin.SongMaintenanceForm',
|
||||
criticalErrorMessageBox(
|
||||
message=translate('SongsPlugin.SongMaintenanceForm',
|
||||
'Could not add your topic.'))
|
||||
else:
|
||||
QtGui.QMessageBox.critical(self,
|
||||
translate('SongsPlugin.SongMaintenanceForm', 'Error'),
|
||||
translate('SongsPlugin.SongMaintenanceForm',
|
||||
criticalErrorMessageBox(
|
||||
message=translate('SongsPlugin.SongMaintenanceForm',
|
||||
'This topic already exists.'))
|
||||
|
||||
def onBookAddButtonClick(self):
|
||||
@ -264,14 +263,12 @@ class SongMaintenanceForm(QtGui.QDialog, Ui_SongMaintenanceDialog):
|
||||
if self.manager.save_object(book):
|
||||
self.resetBooks()
|
||||
else:
|
||||
QtGui.QMessageBox.critical(self,
|
||||
translate('SongsPlugin.SongMaintenanceForm', 'Error'),
|
||||
translate('SongsPlugin.SongMaintenanceForm',
|
||||
criticalErrorMessageBox(
|
||||
message=translate('SongsPlugin.SongMaintenanceForm',
|
||||
'Could not add your book.'))
|
||||
else:
|
||||
QtGui.QMessageBox.critical(self,
|
||||
translate('SongsPlugin.SongMaintenanceForm', 'Error'),
|
||||
translate('SongsPlugin.SongMaintenanceForm',
|
||||
criticalErrorMessageBox(
|
||||
message=translate('SongsPlugin.SongMaintenanceForm',
|
||||
'This book already exists.'))
|
||||
|
||||
def onAuthorEditButtonClick(self):
|
||||
@ -298,20 +295,15 @@ class SongMaintenanceForm(QtGui.QDialog, Ui_SongMaintenanceDialog):
|
||||
self.resetAuthors()
|
||||
Receiver.send_message(u'songs_load_list')
|
||||
else:
|
||||
QtGui.QMessageBox.critical(self,
|
||||
translate('SongsPlugin.SongMaintenanceForm',
|
||||
'Error'),
|
||||
translate('SongsPlugin.SongMaintenanceForm',
|
||||
criticalErrorMessageBox(
|
||||
message=translate('SongsPlugin.SongMaintenanceForm',
|
||||
'Could not save your changes.'))
|
||||
elif QtGui.QMessageBox.critical(self,
|
||||
translate('SongsPlugin.SongMaintenanceForm', 'Error'),
|
||||
unicode(translate('SongsPlugin.SongMaintenanceForm',
|
||||
'The author %s already exists. Would you like to make songs'
|
||||
' with author %s use the existing author %s?')) %
|
||||
(author.display_name, temp_display_name,
|
||||
author.display_name), QtGui.QMessageBox.StandardButtons(
|
||||
QtGui.QMessageBox.No | QtGui.QMessageBox.Yes)) == \
|
||||
QtGui.QMessageBox.Yes:
|
||||
elif criticalErrorMessageBox(message=unicode(translate(
|
||||
'SongsPlugin.SongMaintenanceForm', 'The author %s already '
|
||||
'exists. Would you like to make songs with author %s use '
|
||||
'the existing author %s?')) % (author.display_name,
|
||||
temp_display_name, author.display_name),
|
||||
parent=self, question=True) == QtGui.QMessageBox.Yes:
|
||||
self.mergeAuthors(author)
|
||||
self.resetAuthors()
|
||||
Receiver.send_message(u'songs_load_list')
|
||||
@ -321,9 +313,8 @@ class SongMaintenanceForm(QtGui.QDialog, Ui_SongMaintenanceDialog):
|
||||
author.first_name = temp_first_name
|
||||
author.last_name = temp_last_name
|
||||
author.display_name = temp_display_name
|
||||
QtGui.QMessageBox.critical(self,
|
||||
translate('SongsPlugin.SongMaintenanceForm', 'Error'),
|
||||
translate('SongsPlugin.SongMaintenanceForm',
|
||||
criticalErrorMessageBox(
|
||||
message=translate('SongsPlugin.SongMaintenanceForm',
|
||||
'Could not save your modified author, because the '
|
||||
'author already exists.'))
|
||||
|
||||
@ -340,27 +331,22 @@ class SongMaintenanceForm(QtGui.QDialog, Ui_SongMaintenanceDialog):
|
||||
if self.manager.save_object(topic):
|
||||
self.resetTopics()
|
||||
else:
|
||||
QtGui.QMessageBox.critical(self,
|
||||
translate('SongsPlugin.SongMaintenanceForm',
|
||||
'Error'),
|
||||
translate('SongsPlugin.SongMaintenanceForm',
|
||||
criticalErrorMessageBox(
|
||||
message=translate('SongsPlugin.SongMaintenanceForm',
|
||||
'Could not save your changes.'))
|
||||
elif QtGui.QMessageBox.critical(self,
|
||||
translate('SongsPlugin.SongMaintenanceForm', 'Error'),
|
||||
unicode(translate('SongsPlugin.SongMaintenanceForm',
|
||||
elif criticalErrorMessageBox(
|
||||
message=unicode(translate('SongsPlugin.SongMaintenanceForm',
|
||||
'The topic %s already exists. Would you like to make songs '
|
||||
'with topic %s use the existing topic %s?')) % (topic.name,
|
||||
temp_name, topic.name), QtGui.QMessageBox.StandardButtons(
|
||||
QtGui.QMessageBox.No | QtGui.QMessageBox.Yes)) == \
|
||||
QtGui.QMessageBox.Yes:
|
||||
temp_name, topic.name),
|
||||
parent=self, question=True) == QtGui.QMessageBox.Yes:
|
||||
self.mergeTopics(topic)
|
||||
self.resetTopics()
|
||||
else:
|
||||
# We restore the topics's old name.
|
||||
topic.name = temp_name
|
||||
QtGui.QMessageBox.critical(self,
|
||||
translate('SongsPlugin.SongMaintenanceForm', 'Error'),
|
||||
translate('SongsPlugin.SongMaintenanceForm',
|
||||
criticalErrorMessageBox(
|
||||
message=translate('SongsPlugin.SongMaintenanceForm',
|
||||
'Could not save your modified topic, because it '
|
||||
'already exists.'))
|
||||
|
||||
@ -383,19 +369,15 @@ class SongMaintenanceForm(QtGui.QDialog, Ui_SongMaintenanceDialog):
|
||||
if self.manager.save_object(book):
|
||||
self.resetBooks()
|
||||
else:
|
||||
QtGui.QMessageBox.critical(self,
|
||||
translate('SongsPlugin.SongMaintenanceForm',
|
||||
'Error'),
|
||||
translate('SongsPlugin.SongMaintenanceForm',
|
||||
criticalErrorMessageBox(
|
||||
message=translate('SongsPlugin.SongMaintenanceForm',
|
||||
'Could not save your changes.'))
|
||||
elif QtGui.QMessageBox.critical(self,
|
||||
translate('SongsPlugin.SongMaintenanceForm', 'Error'),
|
||||
unicode(translate('SongsPlugin.SongMaintenanceForm',
|
||||
elif criticalErrorMessageBox(
|
||||
message=unicode(translate('SongsPlugin.SongMaintenanceForm',
|
||||
'The book %s already exists. Would you like to make songs '
|
||||
'with book %s use the existing book %s?')) % (book.name,
|
||||
temp_name, book.name), QtGui.QMessageBox.StandardButtons(
|
||||
QtGui.QMessageBox.No | QtGui.QMessageBox.Yes)) == \
|
||||
QtGui.QMessageBox.Yes:
|
||||
temp_name, book.name),
|
||||
parent=self, question=True) == QtGui.QMessageBox.Yes:
|
||||
self.mergeBooks(book)
|
||||
self.resetBooks()
|
||||
else:
|
||||
|
@ -27,6 +27,7 @@
|
||||
from PyQt4 import QtGui
|
||||
|
||||
from openlp.core.lib import translate
|
||||
from openlp.core.ui import criticalErrorMessageBox
|
||||
from openlp.plugins.songs.forms.topicsdialog import Ui_TopicsDialog
|
||||
|
||||
class TopicsForm(QtGui.QDialog, Ui_TopicsDialog):
|
||||
@ -48,10 +49,8 @@ class TopicsForm(QtGui.QDialog, Ui_TopicsDialog):
|
||||
|
||||
def accept(self):
|
||||
if not self.nameEdit.text():
|
||||
QtGui.QMessageBox.critical(
|
||||
self, translate('SongsPlugin.TopicsForm', 'Error'),
|
||||
translate('SongsPlugin.TopicsForm',
|
||||
'You need to type in a topic name.'))
|
||||
criticalErrorMessageBox(message=translate('SongsPlugin.TopicsForm',
|
||||
'You need to type in a topic name.'))
|
||||
self.nameEdit.setFocus()
|
||||
return False
|
||||
else:
|
||||
|
@ -175,6 +175,6 @@ def retrieve_windows_encoding(recommendation=None):
|
||||
return None
|
||||
return filter(lambda item: item[1] == choice[0], encodings)[0][0]
|
||||
|
||||
from xml import LyricsXML, SongXMLBuilder, SongXMLParser, OpenLyricsParser
|
||||
from xml import OpenLyrics, SongXML
|
||||
from songstab import SongsTab
|
||||
from mediaitem import SongMediaItem
|
||||
|
@ -34,9 +34,6 @@ from songimport import SongImport
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
class CCLIFileImportError(Exception):
|
||||
pass
|
||||
|
||||
class CCLIFileImport(SongImport):
|
||||
"""
|
||||
The :class:`CCLIFileImport` class provides OpenLP with the ability to
|
||||
@ -67,7 +64,7 @@ class CCLIFileImport(SongImport):
|
||||
"""
|
||||
log.debug(u'Starting CCLI File Import')
|
||||
song_total = len(self.filenames)
|
||||
self.import_wizard.importProgressBar.setMaximum(song_total)
|
||||
self.import_wizard.progressBar.setMaximum(song_total)
|
||||
song_count = 1
|
||||
for filename in self.filenames:
|
||||
self.import_wizard.incrementProgressBar(unicode(translate(
|
||||
@ -152,7 +149,6 @@ class CCLIFileImport(SongImport):
|
||||
|
||||
"""
|
||||
log.debug(u'USR file text: %s', textList)
|
||||
lyrics = []
|
||||
self.set_defaults()
|
||||
for line in textList:
|
||||
if line.startswith(u'Title='):
|
||||
|
@ -181,4 +181,4 @@ def init_schema(url):
|
||||
mapper(Topic, topics_table)
|
||||
|
||||
metadata.create_all(checkfirst=True)
|
||||
return session
|
||||
return session
|
||||
|
@ -186,7 +186,7 @@ class EasyWorshipSongImport(SongImport):
|
||||
# There does not appear to be a _reliable_ way of getting the number
|
||||
# of songs/records, so let's use file blocks for measuring progress.
|
||||
total_blocks = (db_size - header_size) / (block_size * 1024)
|
||||
self.import_wizard.importProgressBar.setMaximum(total_blocks)
|
||||
self.import_wizard.progressBar.setMaximum(total_blocks)
|
||||
# Read the field description information
|
||||
db_file.seek(120)
|
||||
field_info = db_file.read(num_fields * 2)
|
||||
|
@ -26,6 +26,7 @@
|
||||
|
||||
from opensongimport import OpenSongImport
|
||||
from olpimport import OpenLPSongImport
|
||||
from openlyricsimport import OpenLyricsImport
|
||||
from wowimport import WowImport
|
||||
from cclifileimport import CCLIFileImport
|
||||
from ewimport import EasyWorshipSongImport
|
||||
@ -77,8 +78,10 @@ class SongFormat(object):
|
||||
"""
|
||||
if format == SongFormat.OpenLP2:
|
||||
return OpenLPSongImport
|
||||
if format == SongFormat.OpenLP1:
|
||||
elif format == SongFormat.OpenLP1:
|
||||
return OpenLP1SongImport
|
||||
elif format == SongFormat.OpenLyrics:
|
||||
return OpenLyricsImport
|
||||
elif format == SongFormat.OpenSong:
|
||||
return OpenSongImport
|
||||
elif format == SongFormat.SongsOfFellowship:
|
||||
@ -93,7 +96,6 @@ class SongFormat(object):
|
||||
return EasyWorshipSongImport
|
||||
elif format == SongFormat.SongBeamer:
|
||||
return SongBeamerImport
|
||||
# else:
|
||||
return None
|
||||
|
||||
@staticmethod
|
||||
|
@ -35,7 +35,7 @@ from openlp.core.lib import MediaManagerItem, BaseListWithDnD, Receiver, \
|
||||
ItemCapabilities, translate, check_item_selected
|
||||
from openlp.plugins.songs.forms import EditSongForm, SongMaintenanceForm, \
|
||||
SongImportForm
|
||||
from openlp.plugins.songs.lib import SongXMLParser, OpenLyricsParser
|
||||
from openlp.plugins.songs.lib import OpenLyrics, SongXML
|
||||
from openlp.plugins.songs.lib.db import Author, Song
|
||||
from openlp.core.lib.searchedit import SearchEdit
|
||||
|
||||
@ -58,7 +58,7 @@ class SongMediaItem(MediaManagerItem):
|
||||
self.ListViewWithDnD_class = SongListView
|
||||
MediaManagerItem.__init__(self, parent, self, icon)
|
||||
self.edit_song_form = EditSongForm(self, self.parent.manager)
|
||||
self.openLyrics = OpenLyricsParser(self.parent.manager)
|
||||
self.openLyrics = OpenLyrics(self.parent.manager)
|
||||
self.singleServiceItem = False
|
||||
self.song_maintenance_form = SongMaintenanceForm(
|
||||
self.parent.manager, self)
|
||||
@ -153,7 +153,11 @@ class SongMediaItem(MediaManagerItem):
|
||||
(3, u':/songs/song_search_lyrics.png',
|
||||
translate('SongsPlugin.MediaItem', 'Lyrics')),
|
||||
(4, u':/songs/song_search_author.png',
|
||||
translate('SongsPlugin.MediaItem', 'Authors'))])
|
||||
translate('SongsPlugin.MediaItem', 'Authors')),
|
||||
(5, u':/slides/slide_theme.png',
|
||||
translate('SongsPlugin.MediaItem', 'Themes'))
|
||||
])
|
||||
|
||||
self.configUpdated()
|
||||
|
||||
def onSearchTextButtonClick(self):
|
||||
@ -187,6 +191,12 @@ class SongMediaItem(MediaManagerItem):
|
||||
Author.display_name.like(u'%' + search_keywords + u'%'),
|
||||
Author.display_name.asc())
|
||||
self.displayResultsAuthor(search_results)
|
||||
elif search_type == 5:
|
||||
log.debug(u'Theme Search')
|
||||
search_results = self.parent.manager.get_all_objects(Song,
|
||||
Song.theme_name == search_keywords,
|
||||
Song.search_lyrics.asc())
|
||||
self.displayResultsSong(search_results)
|
||||
|
||||
def onSongListLoad(self):
|
||||
"""
|
||||
@ -312,15 +322,14 @@ class SongMediaItem(MediaManagerItem):
|
||||
translate('SongsPlugin.MediaItem',
|
||||
'You must select an item to delete.')):
|
||||
items = self.listView.selectedIndexes()
|
||||
ans = QtGui.QMessageBox.question(self,
|
||||
if QtGui.QMessageBox.question(self,
|
||||
translate('SongsPlugin.MediaItem', 'Delete Song(s)?'),
|
||||
translate('SongsPlugin.MediaItem',
|
||||
'Are you sure you want to delete the %n selected song(s)?', '',
|
||||
QtCore.QCoreApplication.CodecForTr, len(items)),
|
||||
QtGui.QMessageBox.StandardButtons(QtGui.QMessageBox.Ok|
|
||||
QtGui.QMessageBox.Cancel),
|
||||
QtGui.QMessageBox.Ok)
|
||||
if ans == QtGui.QMessageBox.Cancel:
|
||||
QtGui.QMessageBox.StandardButtons(QtGui.QMessageBox.Ok |
|
||||
QtGui.QMessageBox.Cancel),
|
||||
QtGui.QMessageBox.Ok) == QtGui.QMessageBox.Cancel:
|
||||
return
|
||||
for item in items:
|
||||
item_id = (item.data(QtCore.Qt.UserRole)).toInt()[0]
|
||||
@ -352,8 +361,7 @@ class SongMediaItem(MediaManagerItem):
|
||||
service_item.theme = song.theme_name
|
||||
service_item.edit_id = item_id
|
||||
if song.lyrics.startswith(u'<?xml version='):
|
||||
songXML = SongXMLParser(song.lyrics)
|
||||
verseList = songXML.get_verses()
|
||||
verseList = SongXML().get_verses(song.lyrics)
|
||||
# no verse list or only 1 space (in error)
|
||||
if not song.verse_order or not song.verse_order.strip():
|
||||
for verse in verseList:
|
||||
@ -394,8 +402,8 @@ class SongMediaItem(MediaManagerItem):
|
||||
service_item.audit = [
|
||||
song.title, author_audit, song.copyright, unicode(song.ccli_number)
|
||||
]
|
||||
service_item.data_string = {u'title':song.search_title,
|
||||
u'authors':author_list}
|
||||
service_item.data_string = {u'title': song.search_title,
|
||||
u'authors': author_list}
|
||||
service_item.xml_version = self.openLyrics.song_to_xml(song)
|
||||
return True
|
||||
|
||||
@ -406,8 +414,8 @@ class SongMediaItem(MediaManagerItem):
|
||||
log.debug(u'serviceLoad')
|
||||
if item.data_string:
|
||||
search_results = self.parent.manager.get_all_objects(Song,
|
||||
Song.search_title ==
|
||||
item.data_string[u'title'].split(u'@')[0].lower() ,
|
||||
Song.search_title == re.compile(r'\W+', re.UNICODE).sub(u' ',
|
||||
item.data_string[u'title'].split(u'@')[0].lower()).strip(),
|
||||
Song.search_title.asc())
|
||||
author_list = item.data_string[u'authors'].split(u', ')
|
||||
# The service item always has an author (at least it has u'' as
|
||||
@ -416,7 +424,6 @@ class SongMediaItem(MediaManagerItem):
|
||||
if u'' in author_list:
|
||||
author_list.remove(u'')
|
||||
editId = 0
|
||||
uuid = item._uuid
|
||||
add_song = True
|
||||
if search_results:
|
||||
for song in search_results:
|
||||
@ -441,9 +448,9 @@ class SongMediaItem(MediaManagerItem):
|
||||
if self.addSongFromService:
|
||||
editId = self.openLyrics.xml_to_song(item.xml_version)
|
||||
# Update service with correct song id.
|
||||
if editId != 0:
|
||||
if editId:
|
||||
Receiver.send_message(u'service_item_update',
|
||||
u'%s:%s' %(editId, uuid))
|
||||
u'%s:%s' % (editId, item._uuid))
|
||||
|
||||
def collateSongTitles(self, song_1, song_2):
|
||||
"""
|
||||
|
@ -78,7 +78,7 @@ class OpenLP1SongImport(SongImport):
|
||||
cursor.execute(u'SELECT COUNT(songid) FROM songs')
|
||||
count = cursor.fetchone()[0]
|
||||
success = True
|
||||
self.import_wizard.importProgressBar.setMaximum(count)
|
||||
self.import_wizard.progressBar.setMaximum(count)
|
||||
# "cache" our list of authors
|
||||
cursor.execute(u'-- types int, unicode')
|
||||
cursor.execute(u'SELECT authorid, authorname FROM authors')
|
||||
|
@ -146,7 +146,7 @@ class OpenLPSongImport(SongImport):
|
||||
|
||||
source_songs = self.source_session.query(OldSong).all()
|
||||
song_total = len(source_songs)
|
||||
self.import_wizard.importProgressBar.setMaximum(song_total)
|
||||
self.import_wizard.progressBar.setMaximum(song_total)
|
||||
song_count = 1
|
||||
for song in source_songs:
|
||||
self.import_wizard.incrementProgressBar(unicode(translate(
|
||||
|
@ -23,7 +23,7 @@
|
||||
# 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 os
|
||||
|
||||
from PyQt4 import QtCore
|
||||
@ -31,6 +31,8 @@ from PyQt4 import QtCore
|
||||
from openlp.core.lib import Receiver
|
||||
from songimport import SongImport
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
if os.name == u'nt':
|
||||
from win32com.client import Dispatch
|
||||
PAGE_BEFORE = 4
|
||||
@ -61,11 +63,11 @@ class OooImport(SongImport):
|
||||
self.filenames = kwargs[u'filenames']
|
||||
self.uno_connection_type = u'pipe' #u'socket'
|
||||
QtCore.QObject.connect(Receiver.get_receiver(),
|
||||
QtCore.SIGNAL(u'song_stop_import'), self.stop_import)
|
||||
QtCore.SIGNAL(u'openlp_stop_wizard'), self.stop_import)
|
||||
|
||||
def do_import(self):
|
||||
self.abort = False
|
||||
self.import_wizard.importProgressBar.setMaximum(0)
|
||||
self.import_wizard.progressBar.setMaximum(0)
|
||||
self.start_ooo()
|
||||
for filename in self.filenames:
|
||||
if self.abort:
|
||||
@ -83,7 +85,7 @@ class OooImport(SongImport):
|
||||
self.process_doc()
|
||||
self.close_ooo_file()
|
||||
self.close_ooo()
|
||||
self.import_wizard.importProgressBar.setMaximum(1)
|
||||
self.import_wizard.progressBar.setMaximum(1)
|
||||
self.import_wizard.incrementProgressBar(u'', 1)
|
||||
return True
|
||||
|
||||
@ -116,7 +118,7 @@ class OooImport(SongImport):
|
||||
+ u'socket,host=localhost,port=2002;' \
|
||||
+ u'urp;StarOffice.ComponentContext')
|
||||
except:
|
||||
pass
|
||||
log.exception("Failed to resolve uno connection")
|
||||
self.start_ooo_process()
|
||||
loop += 1
|
||||
manager = ctx.ServiceManager
|
||||
@ -143,7 +145,7 @@ class OooImport(SongImport):
|
||||
process.waitForStarted()
|
||||
self.process_started = True
|
||||
except:
|
||||
pass
|
||||
log.exception("start_ooo_process failed")
|
||||
|
||||
def open_ooo_file(self, filepath):
|
||||
"""
|
||||
@ -167,7 +169,7 @@ class OooImport(SongImport):
|
||||
self.import_wizard.incrementProgressBar(
|
||||
u'Processing file ' + filepath, 0)
|
||||
except:
|
||||
pass
|
||||
log.exception("open_ooo_file failed")
|
||||
return
|
||||
|
||||
def close_ooo_file(self):
|
||||
@ -232,4 +234,4 @@ class OooImport(SongImport):
|
||||
text += paratext + u'\n'
|
||||
songs = SongImport.process_songs_text(self.manager, text)
|
||||
for song in songs:
|
||||
song.finish()
|
||||
song.finish()
|
||||
|
77
openlp/plugins/songs/lib/openlyricsimport.py
Normal file
77
openlp/plugins/songs/lib/openlyricsimport.py
Normal file
@ -0,0 +1,77 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4
|
||||
|
||||
###############################################################################
|
||||
# OpenLP - Open Source Lyrics Projection #
|
||||
# --------------------------------------------------------------------------- #
|
||||
# Copyright (c) 2008-2011 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 #
|
||||
###############################################################################
|
||||
"""
|
||||
The :mod:`openlyricsimport` module provides the functionality for importing
|
||||
songs which are saved as OpenLyrics files.
|
||||
"""
|
||||
|
||||
import logging
|
||||
import os
|
||||
|
||||
from lxml import etree
|
||||
|
||||
from openlp.core.lib import translate
|
||||
from openlp.plugins.songs.lib.songimport import SongImport
|
||||
from openlp.plugins.songs.lib import OpenLyrics
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
class OpenLyricsImport(SongImport):
|
||||
"""
|
||||
This provides the Openlyrics import.
|
||||
"""
|
||||
def __init__(self, master_manager, **kwargs):
|
||||
"""
|
||||
Initialise the import.
|
||||
"""
|
||||
log.debug(u'initialise OpenLyricsImport')
|
||||
SongImport.__init__(self, master_manager)
|
||||
self.master_manager = master_manager
|
||||
self.openLyrics = OpenLyrics(master_manager)
|
||||
if kwargs.has_key(u'filename'):
|
||||
self.import_source = kwargs[u'filename']
|
||||
if kwargs.has_key(u'filenames'):
|
||||
self.import_source = kwargs[u'filenames']
|
||||
|
||||
def do_import(self):
|
||||
"""
|
||||
Imports the songs.
|
||||
"""
|
||||
self.import_wizard.progressBar.setMaximum(len(self.import_source))
|
||||
for file_path in self.import_source:
|
||||
if self.stop_import_flag:
|
||||
return False
|
||||
self.import_wizard.incrementProgressBar(unicode(translate(
|
||||
'SongsPlugin.OpenLyricsImport', 'Importing %s...')) %
|
||||
os.path.basename(file_path))
|
||||
parser = etree.XMLParser(remove_blank_text=True)
|
||||
parsed_file = etree.parse(file_path, parser)
|
||||
xml = unicode(etree.tostring(parsed_file))
|
||||
if self.openLyrics.xml_to_song(xml) is None:
|
||||
log.debug(u'File could not be imported: %s' % file_path)
|
||||
# Importing this song failed! For now we stop import.
|
||||
return False
|
||||
return True
|
@ -129,7 +129,7 @@ class OpenSongImport(SongImport):
|
||||
else:
|
||||
numfiles += 1
|
||||
log.debug(u'Total number of files: %d', numfiles)
|
||||
self.import_wizard.importProgressBar.setMaximum(numfiles)
|
||||
self.import_wizard.progressBar.setMaximum(numfiles)
|
||||
for filename in self.filenames:
|
||||
if self.stop_import_flag:
|
||||
success = False
|
||||
|
@ -89,7 +89,7 @@ class SofImport(OooImport):
|
||||
self.process_sof_file()
|
||||
self.close_ooo_file()
|
||||
self.close_ooo()
|
||||
self.import_wizard.importProgressBar.setMaximum(1)
|
||||
self.import_wizard.progressBar.setMaximum(1)
|
||||
self.import_wizard.incrementProgressBar(u'', 1)
|
||||
return True
|
||||
|
||||
@ -550,4 +550,4 @@ class SofImport(OooImport):
|
||||
return 6
|
||||
if song_number == 1119:
|
||||
return 7
|
||||
return None
|
||||
return None
|
||||
|
@ -75,7 +75,6 @@ class SongBeamerImport(SongImport):
|
||||
The song manager for the running OpenLP installation.
|
||||
"""
|
||||
SongImport.__init__(self, master_manager)
|
||||
self.master_manager = master_manager
|
||||
if kwargs.has_key(u'filename'):
|
||||
self.import_source = kwargs[u'filename']
|
||||
if kwargs.has_key(u'filenames'):
|
||||
@ -87,7 +86,7 @@ class SongBeamerImport(SongImport):
|
||||
Recieve a single file, or a list of files to import.
|
||||
"""
|
||||
if isinstance(self.import_source, list):
|
||||
self.import_wizard.importProgressBar.setMaximum(
|
||||
self.import_wizard.progressBar.setMaximum(
|
||||
len(self.import_source))
|
||||
for file in self.import_source:
|
||||
# TODO: check that it is a valid SongBeamer file
|
||||
|
@ -31,7 +31,7 @@ from PyQt4 import QtCore
|
||||
from openlp.core.lib import Receiver, translate
|
||||
from openlp.plugins.songs.lib import VerseType
|
||||
from openlp.plugins.songs.lib.db import Song, Author, Topic, Book, MediaFile
|
||||
from openlp.plugins.songs.lib.xml import SongXMLBuilder
|
||||
from openlp.plugins.songs.lib.xml import SongXML
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
@ -55,7 +55,7 @@ class SongImport(QtCore.QObject):
|
||||
self.stop_import_flag = False
|
||||
self.set_defaults()
|
||||
QtCore.QObject.connect(Receiver.get_receiver(),
|
||||
QtCore.SIGNAL(u'songs_stop_import'), self.stop_import)
|
||||
QtCore.SIGNAL(u'openlp_stop_wizard'), self.stop_import)
|
||||
|
||||
def set_defaults(self):
|
||||
"""
|
||||
@ -270,7 +270,7 @@ class SongImport(QtCore.QObject):
|
||||
song.song_number = self.song_number
|
||||
song.search_lyrics = u''
|
||||
verses_changed_to_other = {}
|
||||
sxml = SongXMLBuilder()
|
||||
sxml = SongXML()
|
||||
other_count = 1
|
||||
for (versetag, versetext) in self.verses:
|
||||
if versetag[0] == u'C':
|
||||
@ -364,4 +364,4 @@ class SongImport(QtCore.QObject):
|
||||
if self.theme_name:
|
||||
print u'THEME: ' + self.theme_name
|
||||
if self.ccli_number:
|
||||
print u'CCLI: ' + self.ccli_number
|
||||
print u'CCLI: ' + self.ccli_number
|
||||
|
@ -35,7 +35,7 @@ logging.basicConfig(filename=LOG_FILENAME,level=logging.INFO)
|
||||
# Stubs to replace the UI functions for raw testing
|
||||
class wizard_stub:
|
||||
def __init__(self):
|
||||
self.importProgressBar=progbar_stub()
|
||||
self.progressBar=progbar_stub()
|
||||
def incrementProgressBar(self, str):
|
||||
pass
|
||||
class progbar_stub:
|
||||
|
@ -99,7 +99,6 @@ class WowImport(SongImport):
|
||||
The song manager for the running OpenLP installation.
|
||||
"""
|
||||
SongImport.__init__(self, master_manager)
|
||||
self.master_manager = master_manager
|
||||
if kwargs.has_key(u'filename'):
|
||||
self.import_source = kwargs[u'filename']
|
||||
if kwargs.has_key(u'filenames'):
|
||||
@ -112,8 +111,7 @@ class WowImport(SongImport):
|
||||
"""
|
||||
|
||||
if isinstance(self.import_source, list):
|
||||
self.import_wizard.importProgressBar.setMaximum(
|
||||
len(self.import_source))
|
||||
self.import_wizard.progressBar.setMaximum(len(self.import_source))
|
||||
for file in self.import_source:
|
||||
self.author = u''
|
||||
self.copyright = u''
|
||||
|
@ -24,55 +24,73 @@
|
||||
# Temple Place, Suite 330, Boston, MA 02111-1307 USA #
|
||||
###############################################################################
|
||||
"""
|
||||
The :mod:`xml` module provides the XML functionality for songs
|
||||
The :mod:`xml` module provides the XML functionality.
|
||||
|
||||
The basic XML is of the format::
|
||||
The basic XML for storing the lyrics in the song database is of the format::
|
||||
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<song version="1.0">
|
||||
<lyrics language="en">
|
||||
<lyrics>
|
||||
<verse type="chorus" label="1">
|
||||
<![CDATA[ ... ]]>
|
||||
</verse>
|
||||
</lyrics>
|
||||
</song>
|
||||
|
||||
|
||||
The XML of `OpenLyrics <http://openlyrics.info/>`_ songs is of the format::
|
||||
|
||||
<song xmlns="http://openlyrics.info/namespace/2009/song"
|
||||
version="0.7"
|
||||
createdIn="OpenLP 1.9.0"
|
||||
modifiedIn="ChangingSong 0.0.1"
|
||||
modifiedDate="2010-01-28T13:15:30+01:00">
|
||||
<properties>
|
||||
<titles>
|
||||
<title>Amazing Grace</title>
|
||||
</titles>
|
||||
</properties>
|
||||
<lyrics>
|
||||
<verse name="v1">
|
||||
<lines>
|
||||
<line>Amazing grace how sweet the sound</line>
|
||||
</lines>
|
||||
</verse>
|
||||
</lyrics>
|
||||
</song>
|
||||
"""
|
||||
|
||||
import logging
|
||||
import re
|
||||
|
||||
from lxml import etree, objectify
|
||||
|
||||
from openlp.core.lib import translate
|
||||
from openlp.plugins.songs.lib import VerseType
|
||||
from openlp.plugins.songs.lib.db import Author, Song
|
||||
from openlp.plugins.songs.lib.db import Author, Book, Song, Topic
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
class SongXMLBuilder(object):
|
||||
class SongXML(object):
|
||||
"""
|
||||
This class builds the XML used to describe songs.
|
||||
This class builds and parses the XML used to describe songs.
|
||||
"""
|
||||
log.info(u'SongXMLBuilder Loaded')
|
||||
log.info(u'SongXML Loaded')
|
||||
|
||||
def __init__(self, song_language=None):
|
||||
def __init__(self):
|
||||
"""
|
||||
Set up the song builder.
|
||||
|
||||
``song_language``
|
||||
The language used in this song
|
||||
Set up the default variables.
|
||||
"""
|
||||
lang = u'en'
|
||||
if song_language:
|
||||
lang = song_language
|
||||
self.song_xml = objectify.fromstring(u'<song version="1.0" />')
|
||||
self.lyrics = etree.SubElement(self.song_xml, u'lyrics', language=lang)
|
||||
self.lyrics = etree.SubElement(self.song_xml, u'lyrics')
|
||||
|
||||
def add_verse_to_lyrics(self, type, number, content):
|
||||
"""
|
||||
Add a verse to the ``<lyrics>`` tag.
|
||||
Add a verse to the *<lyrics>* tag.
|
||||
|
||||
``type``
|
||||
A string denoting the type of verse. Possible values are "Chorus",
|
||||
"Verse", "Bridge", and "Custom".
|
||||
A string denoting the type of verse. Possible values are "V",
|
||||
"C", "B", "P", "I", "E" and "O".
|
||||
|
||||
``number``
|
||||
An integer denoting the number of the item, for example: verse 1.
|
||||
@ -80,18 +98,11 @@ class SongXMLBuilder(object):
|
||||
``content``
|
||||
The actual text of the verse to be stored.
|
||||
"""
|
||||
verse = etree.Element(u'verse', type = unicode(type),
|
||||
label = unicode(number))
|
||||
verse = etree.Element(u'verse', type=unicode(type),
|
||||
label=unicode(number))
|
||||
verse.text = etree.CDATA(content)
|
||||
self.lyrics.append(verse)
|
||||
|
||||
def dump_xml(self):
|
||||
"""
|
||||
Debugging aid to dump XML so that we can see what we have.
|
||||
"""
|
||||
return etree.tostring(self.song_xml, encoding=u'UTF-8',
|
||||
xml_declaration=True, pretty_print=True)
|
||||
|
||||
def extract_xml(self):
|
||||
"""
|
||||
Extract our newly created XML song.
|
||||
@ -99,16 +110,10 @@ class SongXMLBuilder(object):
|
||||
return etree.tostring(self.song_xml, encoding=u'UTF-8',
|
||||
xml_declaration=True)
|
||||
|
||||
|
||||
class SongXMLParser(object):
|
||||
"""
|
||||
A class to read in and parse a song's XML.
|
||||
"""
|
||||
log.info(u'SongXMLParser Loaded')
|
||||
|
||||
def __init__(self, xml):
|
||||
def get_verses(self, xml):
|
||||
"""
|
||||
Set up our song XML parser.
|
||||
Iterates through the verses in the XML and returns a list of verses
|
||||
and their attributes.
|
||||
|
||||
``xml``
|
||||
The XML of the song to be parsed.
|
||||
@ -120,12 +125,6 @@ class SongXMLParser(object):
|
||||
self.song_xml = objectify.fromstring(xml)
|
||||
except etree.XMLSyntaxError:
|
||||
log.exception(u'Invalid xml %s', xml)
|
||||
|
||||
def get_verses(self):
|
||||
"""
|
||||
Iterates through the verses in the XML and returns a list of verses
|
||||
and their attributes.
|
||||
"""
|
||||
xml_iter = self.song_xml.getiterator()
|
||||
verse_list = []
|
||||
for element in xml_iter:
|
||||
@ -142,137 +141,110 @@ class SongXMLParser(object):
|
||||
return etree.dump(self.song_xml)
|
||||
|
||||
|
||||
class LyricsXML(object):
|
||||
class OpenLyrics(object):
|
||||
"""
|
||||
This class represents the XML in the ``lyrics`` field of a song.
|
||||
"""
|
||||
def __init__(self, song=None):
|
||||
if song:
|
||||
if song.lyrics.startswith(u'<?xml'):
|
||||
self.parse(song.lyrics)
|
||||
else:
|
||||
self.extract(song.lyrics)
|
||||
else:
|
||||
self.languages = []
|
||||
This class represents the converter for OpenLyrics XML (version 0.7)
|
||||
to/from a song.
|
||||
|
||||
def parse(self, xml):
|
||||
"""
|
||||
Parse XML from the ``lyrics`` field in the database, and set the list
|
||||
of verses from it.
|
||||
As OpenLyrics has a rich set of different features, we cannot support them
|
||||
all. The following features are supported by the :class:`OpenLyrics`::
|
||||
|
||||
``xml``
|
||||
The XML to parse.
|
||||
"""
|
||||
try:
|
||||
self.languages = []
|
||||
song = objectify.fromstring(xml)
|
||||
for lyrics in song.lyrics:
|
||||
language = {
|
||||
u'language': lyrics.attrib[u'language'],
|
||||
u'verses': []
|
||||
}
|
||||
for verse in lyrics.verse:
|
||||
language[u'verses'].append({
|
||||
u'type': verse.attrib[u'type'],
|
||||
u'label': verse.attrib[u'label'],
|
||||
u'text': unicode(verse.text)
|
||||
})
|
||||
self.lyrics.append(language)
|
||||
return True
|
||||
except etree.XMLSyntaxError:
|
||||
return False
|
||||
*<authors>*
|
||||
OpenLP does not support the attribute *type* and *lang*.
|
||||
|
||||
def extract(self, text):
|
||||
"""
|
||||
If the ``lyrics`` field in the database is not XML, this method is
|
||||
called and used to construct the verse structure similar to the output
|
||||
of the ``parse`` function.
|
||||
*<chord>*
|
||||
This property is not supported.
|
||||
|
||||
``text``
|
||||
The text to pull verses out of.
|
||||
"""
|
||||
text = text.replace('\r\n', '\n')
|
||||
verses = text.split('\n\n')
|
||||
self.languages = [{u'language': u'en', u'verses': []}]
|
||||
counter = 0
|
||||
for verse in verses:
|
||||
counter = counter + 1
|
||||
self.languages[0][u'verses'].append({
|
||||
u'type': u'verse',
|
||||
u'label': unicode(counter),
|
||||
u'text': verse
|
||||
})
|
||||
return True
|
||||
*<comments>*
|
||||
The *<comments>* property is fully supported. But comments in lyrics
|
||||
are not supported.
|
||||
|
||||
def add_verse(self, type, label, text):
|
||||
"""
|
||||
Add a verse to the list of verses.
|
||||
*<copyright>*
|
||||
This property is fully supported.
|
||||
|
||||
``type``
|
||||
The type of list, one of "verse", "chorus", "bridge", "pre-chorus",
|
||||
"intro", "outtro".
|
||||
*<customVersion>*
|
||||
This property is not supported.
|
||||
|
||||
``label``
|
||||
The number associated with this verse, like 1 or 2.
|
||||
*<key>*
|
||||
This property is not supported.
|
||||
|
||||
``text``
|
||||
The text of the verse.
|
||||
"""
|
||||
self.verses.append({
|
||||
u'type': type,
|
||||
u'label': label,
|
||||
u'text': text
|
||||
})
|
||||
*<keywords>*
|
||||
This property is not supported.
|
||||
|
||||
def export(self):
|
||||
"""
|
||||
Build up the XML for the verse structure.
|
||||
"""
|
||||
lyrics_output = u''
|
||||
for language in self.languages:
|
||||
verse_output = u''
|
||||
for verse in language[u'verses']:
|
||||
verse_output = verse_output + \
|
||||
u'<verse type="%s" label="%s"><![CDATA[%s]]></verse>' % \
|
||||
(verse[u'type'], verse[u'label'], verse[u'text'])
|
||||
lyrics_output = lyrics_output + \
|
||||
u'<lyrics language="%s">%s</lyrics>' % \
|
||||
(language[u'language'], verse_output)
|
||||
song_output = u'<?xml version="1.0" encoding="UTF-8"?>' + \
|
||||
u'<song version="1.0">%s</song>' % lyrics_output
|
||||
return song_output
|
||||
*<lines>*
|
||||
The attribute *part* is not supported.
|
||||
|
||||
*<publisher>*
|
||||
This property is not supported.
|
||||
|
||||
class OpenLyricsParser(object):
|
||||
"""
|
||||
This class represents the converter for Song to/from OpenLyrics XML.
|
||||
*<songbooks>*
|
||||
As OpenLP does only support one songbook, we cannot consider more than
|
||||
one songbook.
|
||||
|
||||
*<tempo>*
|
||||
This property is not supported.
|
||||
|
||||
*<themes>*
|
||||
Topics, as they are called in OpenLP, are fully supported, whereby only
|
||||
the topic text (e. g. Grace) is considered, but neither the *id* nor
|
||||
*lang*.
|
||||
|
||||
*<transposition>*
|
||||
This property is not supported.
|
||||
|
||||
*<variant>*
|
||||
This property is not supported.
|
||||
|
||||
*<verse name="v1a" lang="he" translit="en">*
|
||||
The attribute *translit* and *lang* are not supported.
|
||||
|
||||
*<verseOrder>*
|
||||
OpenLP supports this property.
|
||||
"""
|
||||
def __init__(self, manager):
|
||||
self.manager = manager
|
||||
|
||||
def song_to_xml(self, song):
|
||||
"""
|
||||
Convert the song to OpenLyrics Format
|
||||
Convert the song to OpenLyrics Format.
|
||||
"""
|
||||
song_xml_parser = SongXMLParser(song.lyrics)
|
||||
verse_list = song_xml_parser.get_verses()
|
||||
sxml = SongXML()
|
||||
verse_list = sxml.get_verses(song.lyrics)
|
||||
song_xml = objectify.fromstring(
|
||||
u'<song version="0.7" createdIn="OpenLP 2.0"/>')
|
||||
properties = etree.SubElement(song_xml, u'properties')
|
||||
titles = etree.SubElement(properties, u'titles')
|
||||
self._add_text_to_element(u'title', titles, song.title)
|
||||
self._add_text_to_element(u'title', titles, song.title.strip())
|
||||
if song.alternate_title:
|
||||
self._add_text_to_element(u'title', titles, song.alternate_title)
|
||||
if song.theme_name:
|
||||
themes = etree.SubElement(properties, u'themes')
|
||||
self._add_text_to_element(u'theme', themes, song.theme_name)
|
||||
self._add_text_to_element(u'copyright', properties, song.copyright)
|
||||
self._add_text_to_element(u'verseOrder', properties, song.verse_order)
|
||||
self._add_text_to_element(
|
||||
u'title', titles, song.alternate_title.strip())
|
||||
if song.comments:
|
||||
comments = etree.SubElement(properties, u'comments')
|
||||
self._add_text_to_element(u'comment', comments, song.comments)
|
||||
if song.copyright:
|
||||
self._add_text_to_element(u'copyright', properties, song.copyright)
|
||||
if song.verse_order:
|
||||
self._add_text_to_element(
|
||||
u'verseOrder', properties, song.verse_order)
|
||||
if song.ccli_number:
|
||||
self._add_text_to_element(u'ccliNo', properties, song.ccli_number)
|
||||
authors = etree.SubElement(properties, u'authors')
|
||||
for author in song.authors:
|
||||
self._add_text_to_element(u'author', authors, author.display_name)
|
||||
if song.authors:
|
||||
authors = etree.SubElement(properties, u'authors')
|
||||
for author in song.authors:
|
||||
self._add_text_to_element(
|
||||
u'author', authors, author.display_name)
|
||||
book = self.manager.get_object_filtered(
|
||||
Book, Book.id == song.song_book_id)
|
||||
if book is not None:
|
||||
book = book.name
|
||||
songbooks = etree.SubElement(properties, u'songbooks')
|
||||
element = self._add_text_to_element(
|
||||
u'songbook', songbooks, None, book)
|
||||
element.set(u'entry', song.song_number)
|
||||
if song.topics:
|
||||
themes = etree.SubElement(properties, u'themes')
|
||||
for topic in song.topics:
|
||||
self._add_text_to_element(u'theme', themes, topic.name)
|
||||
lyrics = etree.SubElement(song_xml, u'lyrics')
|
||||
for verse in verse_list:
|
||||
verse_tag = u'%s%s' % (
|
||||
@ -286,74 +258,32 @@ class OpenLyricsParser(object):
|
||||
|
||||
def xml_to_song(self, xml):
|
||||
"""
|
||||
Create a Song from OpenLyrics format xml
|
||||
Create and save a song from OpenLyrics format xml to the database. Since
|
||||
we also export XML from external sources (e. g. OpenLyrics import), we
|
||||
cannot ensure, that it completely conforms to the OpenLyrics standard.
|
||||
|
||||
``xml``
|
||||
The XML to parse (unicode).
|
||||
"""
|
||||
# No xml get out of here
|
||||
# No xml get out of here.
|
||||
if not xml:
|
||||
return 0
|
||||
return None
|
||||
song = Song()
|
||||
if xml[:5] == u'<?xml':
|
||||
xml = xml[38:]
|
||||
# Remove chords from xml.
|
||||
xml = re.compile(u'<chord name=".*?"/>').sub(u'', xml)
|
||||
song_xml = objectify.fromstring(xml)
|
||||
properties = song_xml.properties
|
||||
song.copyright = unicode(properties.copyright.text)
|
||||
if song.copyright == u'None':
|
||||
song.copyright = u''
|
||||
song.verse_order = unicode(properties.verseOrder.text)
|
||||
if song.verse_order == u'None':
|
||||
song.verse_order = u''
|
||||
song.topics = []
|
||||
song.book = None
|
||||
theme_name = None
|
||||
try:
|
||||
song.ccli_number = unicode(properties.ccliNo.text)
|
||||
except:
|
||||
song.ccli_number = u''
|
||||
try:
|
||||
theme_name = unicode(properties.themes.theme)
|
||||
except:
|
||||
pass
|
||||
if theme_name:
|
||||
song.theme_name = theme_name
|
||||
else:
|
||||
song.theme_name = u''
|
||||
# Process Titles
|
||||
for title in properties.titles.title:
|
||||
if not song.title:
|
||||
song.title = unicode(title.text)
|
||||
song.search_title = unicode(song.title)
|
||||
song.alternate_title = u''
|
||||
else:
|
||||
song.alternate_title = unicode(title.text)
|
||||
song.search_title += u'@' + song.alternate_title
|
||||
song.search_title = re.sub(r'[\'"`,;:(){}?]+', u'',
|
||||
unicode(song.search_title)).lower()
|
||||
# Process Lyrics
|
||||
sxml = SongXMLBuilder()
|
||||
search_text = u''
|
||||
for lyrics in song_xml.lyrics:
|
||||
for verse in song_xml.lyrics.verse:
|
||||
text = u''
|
||||
for line in verse.lines.line:
|
||||
line = unicode(line)
|
||||
if not text:
|
||||
text = line
|
||||
else:
|
||||
text += u'\n' + line
|
||||
type = VerseType.expand_string(verse.attrib[u'name'][0])
|
||||
sxml.add_verse_to_lyrics(type, verse.attrib[u'name'][1], text)
|
||||
search_text = search_text + text
|
||||
song.search_lyrics = search_text.lower()
|
||||
song.lyrics = unicode(sxml.extract_xml(), u'utf-8')
|
||||
song.comments = u''
|
||||
song.song_number = u''
|
||||
# Process Authors
|
||||
try:
|
||||
for author in properties.authors.author:
|
||||
self._process_author(author.text, song)
|
||||
except:
|
||||
# No Author in XML so ignore
|
||||
pass
|
||||
self._process_copyright(properties, song)
|
||||
self._process_cclinumber(properties, song)
|
||||
self._process_titles(properties, song)
|
||||
# The verse order is processed with the lyrics!
|
||||
self._process_lyrics(properties, song_xml.lyrics, song)
|
||||
self._process_comments(properties, song)
|
||||
self._process_authors(properties, song)
|
||||
self._process_songbooks(properties, song)
|
||||
self._process_topics(properties, song)
|
||||
self.manager.save_object(song)
|
||||
return song.id
|
||||
|
||||
@ -367,13 +297,6 @@ class OpenLyricsParser(object):
|
||||
parent.append(element)
|
||||
return element
|
||||
|
||||
def _dump_xml(self, xml):
|
||||
"""
|
||||
Debugging aid to dump XML so that we can see what we have.
|
||||
"""
|
||||
return etree.tostring(xml, encoding=u'UTF-8',
|
||||
xml_declaration=True, pretty_print=True)
|
||||
|
||||
def _extract_xml(self, xml):
|
||||
"""
|
||||
Extract our newly created XML song.
|
||||
@ -381,19 +304,251 @@ class OpenLyricsParser(object):
|
||||
return etree.tostring(xml, encoding=u'UTF-8',
|
||||
xml_declaration=True)
|
||||
|
||||
def _process_author(self, name, song):
|
||||
def _get(self, element, attribute):
|
||||
"""
|
||||
Find or create an Author from display_name.
|
||||
This returns the element's attribute as unicode string.
|
||||
|
||||
``element``
|
||||
The element.
|
||||
|
||||
``attribute``
|
||||
The element's attribute (unicode).
|
||||
"""
|
||||
name = unicode(name)
|
||||
author = self.manager.get_object_filtered(Author,
|
||||
Author.display_name == name)
|
||||
if author:
|
||||
# should only be one! so take the first
|
||||
if element.get(attribute) is not None:
|
||||
return unicode(element.get(attribute))
|
||||
return u''
|
||||
|
||||
def _text(self, element):
|
||||
"""
|
||||
This returns the text of an element as unicode string.
|
||||
|
||||
``element``
|
||||
The element.
|
||||
"""
|
||||
if element.text is not None:
|
||||
return unicode(element.text)
|
||||
return u''
|
||||
|
||||
def _process_authors(self, properties, song):
|
||||
"""
|
||||
Adds the authors specified in the XML to the song.
|
||||
|
||||
``properties``
|
||||
The property object (lxml.objectify.ObjectifiedElement).
|
||||
|
||||
``song``
|
||||
The song object.
|
||||
"""
|
||||
authors = []
|
||||
try:
|
||||
for author in properties.authors.author:
|
||||
display_name = self._text(author)
|
||||
if display_name:
|
||||
authors.append(display_name)
|
||||
except AttributeError:
|
||||
pass
|
||||
if not authors:
|
||||
# Add "Author unknown" (can be translated).
|
||||
authors.append((unicode(translate('SongsPlugin.XML',
|
||||
'Author unknown'))))
|
||||
for display_name in authors:
|
||||
author = self.manager.get_object_filtered(Author,
|
||||
Author.display_name == display_name)
|
||||
if author is None:
|
||||
# We need to create a new author, as the author does not exist.
|
||||
author = Author.populate(display_name=display_name,
|
||||
last_name=display_name.split(u' ')[-1],
|
||||
first_name=u' '.join(display_name.split(u' ')[:-1]))
|
||||
self.manager.save_object(author)
|
||||
song.authors.append(author)
|
||||
else:
|
||||
# Need a new author
|
||||
new_author = Author.populate(first_name=name.rsplit(u' ', 1)[0],
|
||||
last_name=name.rsplit(u' ', 1)[1], display_name=name)
|
||||
self.manager.save_object(new_author)
|
||||
song.authors.append(new_author)
|
||||
|
||||
def _process_cclinumber(self, properties, song):
|
||||
"""
|
||||
Adds the CCLI number to the song.
|
||||
|
||||
``properties``
|
||||
The property object (lxml.objectify.ObjectifiedElement).
|
||||
|
||||
``song``
|
||||
The song object.
|
||||
"""
|
||||
try:
|
||||
song.ccli_number = self._text(properties.ccliNo)
|
||||
except AttributeError:
|
||||
song.ccli_number = u''
|
||||
|
||||
def _process_comments(self, properties, song):
|
||||
"""
|
||||
Joins the comments specified in the XML and add it to the song.
|
||||
|
||||
``properties``
|
||||
The property object (lxml.objectify.ObjectifiedElement).
|
||||
|
||||
``song``
|
||||
The song object.
|
||||
"""
|
||||
try:
|
||||
comments_list = []
|
||||
for comment in properties.comments.comment:
|
||||
commenttext = self._text(comment)
|
||||
if commenttext:
|
||||
comments_list.append(commenttext)
|
||||
song.comments = u'\n'.join(comments_list)
|
||||
except AttributeError:
|
||||
song.comments = u''
|
||||
|
||||
def _process_copyright(self, properties, song):
|
||||
"""
|
||||
Adds the copyright to the song.
|
||||
|
||||
``properties``
|
||||
The property object (lxml.objectify.ObjectifiedElement).
|
||||
|
||||
``song``
|
||||
The song object.
|
||||
"""
|
||||
try:
|
||||
song.copyright = self._text(properties.copyright)
|
||||
except AttributeError:
|
||||
song.copyright = u''
|
||||
|
||||
def _process_lyrics(self, properties, lyrics, song):
|
||||
"""
|
||||
Processes the verses and search_lyrics for the song.
|
||||
|
||||
``properties``
|
||||
The properties object (lxml.objectify.ObjectifiedElement).
|
||||
|
||||
``lyrics``
|
||||
The lyrics object (lxml.objectify.ObjectifiedElement).
|
||||
|
||||
``song``
|
||||
The song object.
|
||||
"""
|
||||
sxml = SongXML()
|
||||
search_text = u''
|
||||
temp_verse_order = []
|
||||
for verse in lyrics.verse:
|
||||
text = u''
|
||||
for lines in verse.lines:
|
||||
if text:
|
||||
text += u'\n'
|
||||
text += u'\n'.join([unicode(line) for line in lines.line])
|
||||
verse_name = self._get(verse, u'name')
|
||||
verse_type = unicode(VerseType.expand_string(verse_name[0]))[0]
|
||||
verse_number = re.compile(u'[a-zA-Z]*').sub(u'', verse_name)
|
||||
verse_part = re.compile(u'[0-9]*').sub(u'', verse_name[1:])
|
||||
# OpenLyrics allows e. g. "c", but we need "c1".
|
||||
if not verse_number:
|
||||
verse_number = u'1'
|
||||
temp_verse_order.append((verse_type, verse_number, verse_part))
|
||||
sxml.add_verse_to_lyrics(verse_type, verse_number, text)
|
||||
search_text = search_text + text
|
||||
song.search_lyrics = search_text.lower()
|
||||
song.lyrics = unicode(sxml.extract_xml(), u'utf-8')
|
||||
# Process verse order
|
||||
try:
|
||||
song.verse_order = self._text(properties.verseOrder)
|
||||
except AttributeError:
|
||||
# We have to process the temp_verse_order, as the verseOrder
|
||||
# property is not present.
|
||||
previous_type = u''
|
||||
previous_number = u''
|
||||
previous_part = u''
|
||||
verse_order = []
|
||||
# Currently we do not support different "parts"!
|
||||
for name in temp_verse_order:
|
||||
if name[0] == previous_type:
|
||||
if name[1] != previous_number:
|
||||
verse_order.append(u''.join((name[0], name[1])))
|
||||
else:
|
||||
verse_order.append(u''.join((name[0], name[1])))
|
||||
previous_type = name[0]
|
||||
previous_number = name[1]
|
||||
previous_part = name[2]
|
||||
song.verse_order = u' '.join(verse_order)
|
||||
|
||||
def _process_songbooks(self, properties, song):
|
||||
"""
|
||||
Adds the song book and song number specified in the XML to the song.
|
||||
|
||||
``properties``
|
||||
The property object (lxml.objectify.ObjectifiedElement).
|
||||
|
||||
``song``
|
||||
The song object.
|
||||
"""
|
||||
song.song_book_id = 0
|
||||
song.song_number = u''
|
||||
try:
|
||||
for songbook in properties.songbooks.songbook:
|
||||
bookname = self._get(songbook, u'name')
|
||||
if bookname:
|
||||
book = self.manager.get_object_filtered(Book,
|
||||
Book.name == bookname)
|
||||
if book is None:
|
||||
# We need to create a book, because it does not exist.
|
||||
book = Book.populate(name=bookname, publisher=u'')
|
||||
self.manager.save_object(book)
|
||||
song.song_book_id = book.id
|
||||
try:
|
||||
if self._get(songbook, u'entry'):
|
||||
song.song_number = self._get(songbook, u'entry')
|
||||
except AttributeError:
|
||||
pass
|
||||
# We only support one song book, so take the first one.
|
||||
break
|
||||
except AttributeError:
|
||||
pass
|
||||
|
||||
def _process_titles(self, properties, song):
|
||||
"""
|
||||
Processes the titles specified in the song's XML.
|
||||
|
||||
``properties``
|
||||
The property object (lxml.objectify.ObjectifiedElement).
|
||||
|
||||
``song``
|
||||
The song object.
|
||||
"""
|
||||
for title in properties.titles.title:
|
||||
if not song.title:
|
||||
song.title = self._text(title)
|
||||
song.search_title = unicode(song.title)
|
||||
song.alternate_title = u''
|
||||
else:
|
||||
song.alternate_title = self._text(title)
|
||||
song.search_title += u'@' + song.alternate_title
|
||||
song.search_title = re.sub(r'[\'"`,;:(){}?]+', u'',
|
||||
unicode(song.search_title)).lower()
|
||||
|
||||
def _process_topics(self, properties, song):
|
||||
"""
|
||||
Adds the topics to the song.
|
||||
|
||||
``properties``
|
||||
The property object (lxml.objectify.ObjectifiedElement).
|
||||
|
||||
``song``
|
||||
The song object.
|
||||
"""
|
||||
try:
|
||||
for topictext in properties.themes.theme:
|
||||
topictext = self._text(topictext)
|
||||
if topictext:
|
||||
topic = self.manager.get_object_filtered(Topic,
|
||||
Topic.name == topictext)
|
||||
if topic is None:
|
||||
# We need to create a topic, because it does not exist.
|
||||
topic = Topic.populate(name=topictext)
|
||||
self.manager.save_object(topic)
|
||||
song.topics.append(topic)
|
||||
except AttributeError:
|
||||
pass
|
||||
|
||||
def _dump_xml(self, xml):
|
||||
"""
|
||||
Debugging aid to dump XML so that we can see what we have.
|
||||
"""
|
||||
return etree.tostring(xml, encoding=u'UTF-8',
|
||||
xml_declaration=True, pretty_print=True)
|
||||
|
@ -31,7 +31,7 @@ from PyQt4 import QtCore, QtGui
|
||||
|
||||
from openlp.core.lib import Plugin, StringContent, build_icon, translate
|
||||
from openlp.core.lib.db import Manager
|
||||
from openlp.plugins.songs.lib import SongMediaItem, SongsTab, SongXMLParser
|
||||
from openlp.plugins.songs.lib import SongMediaItem, SongsTab, SongXML
|
||||
from openlp.plugins.songs.lib.db import init_schema, Song
|
||||
from openlp.plugins.songs.lib.importer import SongFormat
|
||||
|
||||
@ -153,7 +153,7 @@ class SongsPlugin(Plugin):
|
||||
song.search_title = self.whitespace.sub(u' ', song.title.lower() + \
|
||||
u' ' + song.alternate_title.lower())
|
||||
lyrics = u''
|
||||
verses = SongXMLParser(song.lyrics).get_verses()
|
||||
verses = SongXML().get_verses(song.lyrics)
|
||||
for verse in verses:
|
||||
lyrics = lyrics + self.whitespace.sub(u' ', verse[1]) + u' '
|
||||
song.search_lyrics = lyrics.lower()
|
||||
|
209
resources/forms/displaytabeditdialog.ui
Normal file
209
resources/forms/displaytabeditdialog.ui
Normal file
@ -0,0 +1,209 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>displayTagEdit</class>
|
||||
<widget class="QWidget" name="displayTagEdit">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>717</width>
|
||||
<height>554</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Form</string>
|
||||
</property>
|
||||
<widget class="QGroupBox" name="editGroupBox">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>10</x>
|
||||
<y>320</y>
|
||||
<width>691</width>
|
||||
<height>181</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="title">
|
||||
<string>Edit Selection</string>
|
||||
</property>
|
||||
<widget class="QPushButton" name="updatePushButton">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>600</x>
|
||||
<y>140</y>
|
||||
<width>73</width>
|
||||
<height>26</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Update</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QWidget" name="layoutWidget">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>20</x>
|
||||
<y>50</y>
|
||||
<width>571</width>
|
||||
<height>114</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QFormLayout" name="formLayout">
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="descriptionLabel">
|
||||
<property name="text">
|
||||
<string>Description</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QLineEdit" name="descriptionLineEdit"/>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="tagLabel">
|
||||
<property name="text">
|
||||
<string>Tag</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QLineEdit" name="tagLineEdit">
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>50</width>
|
||||
<height>16777215</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maxLength">
|
||||
<number>5</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="startTagLabel">
|
||||
<property name="text">
|
||||
<string>Start tag</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<widget class="QLineEdit" name="startTagLineEdit"/>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<widget class="QLabel" name="endTagLabel">
|
||||
<property name="text">
|
||||
<string>End tag</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="1">
|
||||
<widget class="QLineEdit" name="endTagLineEdit"/>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</widget>
|
||||
<widget class="QDialogButtonBox" name="buttonBox">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>540</x>
|
||||
<y>510</y>
|
||||
<width>162</width>
|
||||
<height>26</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="standardButtons">
|
||||
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QPushButton" name="deletePushButton">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>530</x>
|
||||
<y>280</y>
|
||||
<width>71</width>
|
||||
<height>26</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Delete</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QPushButton" name="addPushButton">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>610</x>
|
||||
<y>280</y>
|
||||
<width>71</width>
|
||||
<height>26</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Add</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QTableWidget" name="tagTableWidget">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>10</x>
|
||||
<y>10</y>
|
||||
<width>691</width>
|
||||
<height>271</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="horizontalScrollBarPolicy">
|
||||
<enum>Qt::ScrollBarAlwaysOff</enum>
|
||||
</property>
|
||||
<property name="editTriggers">
|
||||
<set>QAbstractItemView::NoEditTriggers</set>
|
||||
</property>
|
||||
<property name="alternatingRowColors">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="selectionMode">
|
||||
<enum>QAbstractItemView::SingleSelection</enum>
|
||||
</property>
|
||||
<property name="selectionBehavior">
|
||||
<enum>QAbstractItemView::SelectRows</enum>
|
||||
</property>
|
||||
<property name="cornerButtonEnabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<column>
|
||||
<property name="text">
|
||||
<string>Description</string>
|
||||
</property>
|
||||
</column>
|
||||
<column>
|
||||
<property name="text">
|
||||
<string>Key</string>
|
||||
</property>
|
||||
<property name="textAlignment">
|
||||
<set>AlignHCenter|AlignVCenter|AlignCenter</set>
|
||||
</property>
|
||||
</column>
|
||||
<column>
|
||||
<property name="text">
|
||||
<string>Start Tag</string>
|
||||
</property>
|
||||
</column>
|
||||
<column>
|
||||
<property name="text">
|
||||
<string>End Tag</string>
|
||||
</property>
|
||||
</column>
|
||||
</widget>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
Loading…
Reference in New Issue
Block a user