trunk r1136

This commit is contained in:
Andreas Preikschat 2010-12-09 17:10:15 +01:00
commit 6284480055
17 changed files with 1083 additions and 757 deletions

View File

@ -306,8 +306,8 @@ def expand_tags(text):
text = text.replace(tag[u'end tag'], tag[u'end html'])
return text
from theme import ThemeLevel, ThemeXML, BackgroundGradientType, BackgroundType, \
HorizontalType, VerticalType
from theme import ThemeLevel, ThemeXML, BackgroundGradientType, \
BackgroundType, HorizontalType, VerticalType
from spelltextedit import SpellTextEdit
from eventreceiver import Receiver
from imagemanager import ImageManager

View File

@ -31,7 +31,6 @@ import re
import logging
from xml.dom.minidom import Document
from xml.etree.ElementTree import ElementTree, XML
from lxml import etree, objectify
from openlp.core.lib import str_to_bool
@ -325,7 +324,7 @@ class ThemeXML(object):
# Create Font name element
self.child_element(background, u'name', name)
# Create Font color element
self.child_element(background, u'color', color)
self.child_element(background, u'color', unicode(color))
# Create Proportion name element
self.child_element(background, u'size', unicode(size))
# Create weight name element

View File

@ -82,7 +82,8 @@ class AdvancedTab(SettingsTab):
self.doubleClickLiveCheckBox.setObjectName(u'doubleClickLiveCheckBox')
self.uiLayout.addWidget(self.doubleClickLiveCheckBox)
# self.expandServiceItemCheckBox = QtGui.QCheckBox(self.uiGroupBox)
# self.expandServiceItemCheckBox.setObjectName(u'expandServiceItemCheckBox')
# self.expandServiceItemCheckBox.setObjectName(
# u'expandServiceItemCheckBox')
# self.uiLayout.addWidget(self.expandServiceItemCheckBox)
self.leftLayout.addWidget(self.uiGroupBox)
self.expandServiceItemCheckBox = QtGui.QCheckBox(self.uiGroupBox)

View File

@ -23,11 +23,34 @@
# 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 QtCore, QtGui
from openlp.core.lib import SettingsTab, Receiver, translate
log = logging.getLogger(__name__)
class ValidEdit(QtGui.QLineEdit):
"""
Only allow numeric characters to be edited
"""
def __init__(self, parent):
"""
Set up Override and Validator
"""
QtGui.QLineEdit.__init__(self, parent)
self.setValidator(QtGui.QIntValidator(0, 9999, self))
def validText(self):
"""
Only return Integers. Space is 0
"""
if self.text().isEmpty():
return QtCore.QString(u'0')
else:
return self.text()
class GeneralTab(SettingsTab):
"""
GeneralTab is the general settings tab in the settings dialog.
@ -240,7 +263,7 @@ class GeneralTab(SettingsTab):
self.customXLabel.setAlignment(QtCore.Qt.AlignCenter)
self.customXLabel.setObjectName(u'customXLabel')
self.customXLayout.addWidget(self.customXLabel)
self.customXValueEdit = QtGui.QLineEdit(self.displayGroupBox)
self.customXValueEdit = ValidEdit(self.displayGroupBox)
self.customXValueEdit.setObjectName(u'customXValueEdit')
self.customXLayout.addWidget(self.customXValueEdit)
self.customLayout.addLayout(self.customXLayout)
@ -252,7 +275,7 @@ class GeneralTab(SettingsTab):
self.customYLabel.setAlignment(QtCore.Qt.AlignCenter)
self.customYLabel.setObjectName(u'customYLabel')
self.customYLayout.addWidget(self.customYLabel)
self.customYValueEdit = QtGui.QLineEdit(self.displayGroupBox)
self.customYValueEdit = ValidEdit(self.displayGroupBox)
self.customYValueEdit.setObjectName(u'customYValueEdit')
self.customYLayout.addWidget(self.customYValueEdit)
self.customLayout.addLayout(self.customYLayout)
@ -265,7 +288,7 @@ class GeneralTab(SettingsTab):
self.customWidthLabel.setAlignment(QtCore.Qt.AlignCenter)
self.customWidthLabel.setObjectName(u'customWidthLabel')
self.customWidthLayout.addWidget(self.customWidthLabel)
self.customWidthValueEdit = QtGui.QLineEdit(self.displayGroupBox)
self.customWidthValueEdit = ValidEdit(self.displayGroupBox)
self.customWidthValueEdit.setObjectName(u'customWidthValueEdit')
self.customWidthLayout.addWidget(self.customWidthValueEdit)
self.customLayout.addLayout(self.customWidthLayout)
@ -277,7 +300,7 @@ class GeneralTab(SettingsTab):
self.customHeightLabel.setAlignment(QtCore.Qt.AlignCenter)
self.customHeightLabel.setObjectName(u'customHeightLabel')
self.customHeightLayout.addWidget(self.customHeightLabel)
self.customHeightValueEdit = QtGui.QLineEdit(self.displayGroupBox)
self.customHeightValueEdit = ValidEdit(self.displayGroupBox)
self.customHeightValueEdit.setObjectName(u'customHeightValueEdit')
self.customHeightLayout.addWidget(self.customHeightValueEdit)
self.customLayout.addLayout(self.customHeightLayout)
@ -465,10 +488,10 @@ class GeneralTab(SettingsTab):
# Reset screens after initial definition
if self.overrideChanged:
self.screens.override[u'size'] = QtCore.QRect(
int(self.customXValueEdit.text()),
int(self.customYValueEdit.text()),
int(self.customWidthValueEdit.text()),
int(self.customHeightValueEdit.text()))
int(self.customXValueEdit.validText()),
int(self.customYValueEdit.validText()),
int(self.customWidthValueEdit.validText()),
int(self.customHeightValueEdit.validText()))
if self.overrideCheckBox.isChecked():
self.screens.set_override_display()
else:

View File

@ -23,7 +23,8 @@
# 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

View File

@ -62,24 +62,27 @@ class ThemeForm(QtGui.QWizard, Ui_ThemeWizard):
QtCore.QObject.connect(self.gradientComboBox,
QtCore.SIGNAL(u'currentIndexChanged(int)'),
self.onGradientComboBox)
QtCore.QObject.connect(self.color1PushButton,
QtCore.QObject.connect(self.colorButton,
QtCore.SIGNAL(u'pressed()'),
self.onColor1PushButtonClicked)
QtCore.QObject.connect(self.color2PushButton,
self.onColorButtonClicked)
QtCore.QObject.connect(self.gradientStartButton,
QtCore.SIGNAL(u'pressed()'),
self.onColor2PushButtonClicked)
self.onGradientStartButtonClicked)
QtCore.QObject.connect(self.gradientEndButton,
QtCore.SIGNAL(u'pressed()'),
self.onGradientEndButtonClicked)
QtCore.QObject.connect(self.imageBrowseButton,
QtCore.SIGNAL(u'pressed()'),
self.onImageBrowseButtonClicked)
self.onImageBrowseButtonClicked)
QtCore.QObject.connect(self.mainColorPushButton,
QtCore.SIGNAL(u'pressed()'),
self.onMainColourPushButtonClicked)
self.onMainColourPushButtonClicked)
QtCore.QObject.connect(self.outlineColorPushButton,
QtCore.SIGNAL(u'pressed()'),
self.onOutlineColourPushButtonClicked)
self.onOutlineColourPushButtonClicked)
QtCore.QObject.connect(self.shadowColorPushButton,
QtCore.SIGNAL(u'pressed()'),
self.onShadowColourPushButtonClicked)
self.onShadowColourPushButtonClicked)
QtCore.QObject.connect(self.outlineCheckBox,
QtCore.SIGNAL(u'stateChanged(int)'),
self.onOutlineCheckCheckBoxChanged)
@ -158,9 +161,11 @@ class ThemeForm(QtGui.QWizard, Ui_ThemeWizard):
self.backgroundPage.registerField(
u'background_type', self.backgroundTypeComboBox)
self.backgroundPage.registerField(
u'color_1', self.color1PushButton)
u'color', self.colorButton)
self.backgroundPage.registerField(
u'color_2', self.color2PushButton)
u'grandient_start', self.gradientStartButton)
self.backgroundPage.registerField(
u'grandient_end', self.gradientEndButton)
self.backgroundPage.registerField(
u'background_image', self.imageLineEdit)
self.backgroundPage.registerField(
@ -280,13 +285,15 @@ class ThemeForm(QtGui.QWizard, Ui_ThemeWizard):
self.footerHeightSpinBox.setEnabled(self.theme.font_footer_override)
self.footerWidthSpinBox.setEnabled(self.theme.font_footer_override)
def exec_(self):
def exec_(self, edit=False):
"""
Run the wizard.
"""
self.updateThemeAllowed = False
self.setDefaults()
self.updateThemeAllowed = True
if edit:
self.next()
return QtGui.QWizard.exec_(self)
def initializePage(self, id):
@ -312,54 +319,19 @@ class ThemeForm(QtGui.QWizard, Ui_ThemeWizard):
"""
if self.theme.background_type == \
BackgroundType.to_string(BackgroundType.Solid):
self.setField(u'background_type', QtCore.QVariant(0))
self.color1PushButton.setVisible(True)
self.color1Label.setVisible(True)
self.color1PushButton.setStyleSheet(u'background-color: %s' %
self.colorButton.setStyleSheet(u'background-color: %s' %
self.theme.background_color)
self.color1Label.setText(
translate('OpenLP.ThemeForm', 'Color:'))
self.color2PushButton.setVisible(False)
self.color2Label.setVisible(False)
self.gradientLabel.setVisible(False)
self.gradientComboBox.setVisible(False)
self.imageLabel.setVisible(False)
self.imageLineEdit.setVisible(False)
self.imageBrowseButton.setVisible(False)
self.imageLineEdit.setText(u'')
self.setField(u'background_type', QtCore.QVariant(0))
elif self.theme.background_type == \
BackgroundType.to_string(BackgroundType.Gradient):
self.setField(u'background_type', QtCore.QVariant(1))
self.color1PushButton.setVisible(True)
self.color1Label.setVisible(True)
self.color1PushButton.setStyleSheet(u'background-color: %s' %
self.gradientStartButton.setStyleSheet(u'background-color: %s' %
self.theme.background_start_color)
self.color1Label.setText(
translate('OpenLP.ThemeForm', 'First color:'))
self.color2PushButton.setVisible(True)
self.color2Label.setVisible(True)
self.color2PushButton.setStyleSheet(u'background-color: %s' %
self.gradientEndButton.setStyleSheet(u'background-color: %s' %
self.theme.background_end_color)
self.color2Label.setText(
translate('OpenLP.ThemeForm', 'Second color:'))
self.gradientLabel.setVisible(True)
self.gradientComboBox.setVisible(True)
self.imageLabel.setVisible(False)
self.imageLineEdit.setVisible(False)
self.imageBrowseButton.setVisible(False)
self.imageLineEdit.setText(u'')
self.setField(u'background_type', QtCore.QVariant(1))
else:
self.setField(u'background_type', QtCore.QVariant(2))
self.color1PushButton.setVisible(False)
self.color1Label.setVisible(False)
self.color2PushButton.setVisible(False)
self.color2Label.setVisible(False)
self.gradientLabel.setVisible(False)
self.gradientComboBox.setVisible(False)
self.imageLineEdit.setVisible(True)
self.imageLabel.setVisible(True)
self.imageBrowseButton.setVisible(True)
self.imageLineEdit.setText(self.theme.background_filename)
self.setField(u'background_type', QtCore.QVariant(2))
if self.theme.background_direction == \
BackgroundGradientType.to_string(BackgroundGradientType.Horizontal):
self.setField(u'gradient', QtCore.QVariant(0))
@ -492,20 +464,23 @@ class ThemeForm(QtGui.QWizard, Ui_ThemeWizard):
BackgroundGradientType.to_string(index)
self.setBackgroundTabValues()
def onColor1PushButtonClicked(self):
def onColorButtonClicked(self):
"""
Background / Gradient 1 Color button pushed.
"""
if self.theme.background_type == \
BackgroundType.to_string(BackgroundType.Solid):
self.theme.background_color = \
self._colorButton(self.theme.background_color)
else:
self.theme.background_start_color = \
self._colorButton(self.theme.background_start_color)
self.theme.background_color = \
self._colorButton(self.theme.background_color)
self.setBackgroundTabValues()
def onColor2PushButtonClicked(self):
def onGradientStartButtonClicked(self):
"""
Gradient 2 Color button pushed.
"""
self.theme.background_start_color = \
self._colorButton(self.theme.background_start_color)
self.setBackgroundTabValues()
def onGradientEndButtonClicked(self):
"""
Gradient 2 Color button pushed.
"""
@ -527,12 +502,6 @@ class ThemeForm(QtGui.QWizard, Ui_ThemeWizard):
self.theme.background_filename = unicode(filename)
self.setBackgroundTabValues()
# def onMainFontComboBox(self):
# """
# Main Font Combo box changed
# """
# self.theme.font_main_name = self.mainFontComboBox.currentFont().family()
def onMainColourPushButtonClicked(self):
self.theme.font_main_color = \
self._colorButton(self.theme.font_main_color)
@ -649,5 +618,5 @@ class ThemeForm(QtGui.QWizard, Ui_ThemeWizard):
new_color = QtGui.QColorDialog.getColor(
QtGui.QColor(field), self)
if new_color.isValid():
field = new_color.name()
field = new_color.name()
return field

View File

@ -280,7 +280,7 @@ class ThemeManager(QtGui.QWidget):
self.saveThemeName = unicode(
item.data(QtCore.Qt.UserRole).toString())
self.themeForm.theme = theme
self.themeForm.exec_()
self.themeForm.exec_(True)
def onDeleteTheme(self):
"""

File diff suppressed because it is too large Load Diff

View File

@ -42,9 +42,8 @@ The basic XML is of the format::
import logging
from xml.dom.minidom import Document
from xml.etree.ElementTree import ElementTree, XML, dump
from xml.etree.ElementTree import dump
from lxml import etree, objectify
from xml.parsers.expat import ExpatError
log = logging.getLogger(__name__)

View File

@ -536,7 +536,7 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog):
return False
if self.song.verse_order:
order = []
order_names = self.song.verse_order.split(u' ')
order_names = self.song.verse_order.split()
for item in order_names:
if len(item) == 1:
order.append(item.lower() + u'1')

46
openlp/plugins/songs/lib/cclifileimport.py Executable file → Normal file
View File

@ -76,7 +76,12 @@ class CCLIFileImport(SongImport):
lines = []
if os.path.isfile(filename):
detect_file = open(filename, u'r')
details = chardet.detect(detect_file.read(2048))
detect_content = detect_file.read(2048)
try:
unicode(detect_content, u'utf-8')
details = {'confidence': 1, 'encoding': 'utf-8'}
except UnicodeDecodeError:
details = chardet.detect(detect_content)
detect_file.close()
infile = codecs.open(filename, u'r', details['encoding'])
lines = infile.readlines()
@ -165,6 +170,7 @@ class CCLIFileImport(SongImport):
song_words = line[6:].strip()
#Unhandled usr keywords:Type,Version,Admin,Themes,Keys
#Process Fields and words sections
check_first_verse_line = False
field_list = song_fields.split(u'/t')
words_list = song_words.split(u'/t')
for counter in range(0, len(field_list)):
@ -176,10 +182,25 @@ class CCLIFileImport(SongImport):
verse_type = u'B'
else: #Other
verse_type = u'O'
check_first_verse_line = True
verse_text = unicode(words_list[counter])
verse_text = verse_text.replace("/n", "\n")
verse_lines = verse_text.split(u'\n', 1)
if check_first_verse_line:
if verse_lines[0].startswith(u'(PRE-CHORUS'):
verse_type = u'P'
log.debug(u'USR verse PRE-CHORUS: %s', verse_lines[0] )
verse_text = verse_lines[1]
elif verse_lines[0].startswith(u'(BRIDGE'):
verse_type = u'B'
log.debug(u'USR verse BRIDGE')
verse_text = verse_lines[1]
elif verse_lines[0].startswith(u'('):
verse_type = u'O'
verse_text = verse_lines[1]
if len(verse_text) > 0:
self.add_verse(verse_text, verse_type)
check_first_verse_line = False
#Handle multiple authors
author_list = song_author.split(u'/')
if len(author_list) < 2:
@ -228,6 +249,7 @@ class CCLIFileImport(SongImport):
log.debug(u'TXT file text: %s', textList)
self.set_defaults()
line_number = 0
check_first_verse_line = False
verse_text = u''
song_comments = u''
song_copyright = u''
@ -265,16 +287,32 @@ class CCLIFileImport(SongImport):
elif verse_desc_parts[0].startswith(u'Br'):
verse_type = u'B'
else:
#we need to analyse the next line for
#verse type, so set flag
verse_type = u'O'
check_first_verse_line = True
verse_number = verse_desc_parts[1]
else:
verse_type = u'O'
verse_number = 1
verse_start = True
else:
# We have verse content or the start of the
# last part. Add l so as to keep the CRLF
verse_text = verse_text + line
#check first line for verse type
if check_first_verse_line:
if line.startswith(u'(PRE-CHORUS'):
verse_type = u'P'
elif line.startswith(u'(BRIDGE'):
verse_type = u'B'
# Handle all other misc types
elif line.startswith(u'('):
verse_type = u'O'
else:
verse_text = verse_text + line
check_first_verse_line = False
else:
# We have verse content or the start of the
# last part. Add l so as to keep the CRLF
verse_text = verse_text + line
else:
#line_number=2, copyright
if line_number == 2:

View File

@ -366,7 +366,7 @@ class SongMediaItem(MediaManagerItem):
verse[1][:30], unicode(verse[1]), verseTag)
else:
# Loop through the verse list and expand the song accordingly.
for order in song.verse_order.upper().split(u' '):
for order in song.verse_order.upper().split():
if len(order) == 0:
break
for verse in verseList:
@ -390,7 +390,7 @@ class SongMediaItem(MediaManagerItem):
raw_footer.append(author_list)
raw_footer.append(song.copyright )
raw_footer.append(unicode(
translate('SongsPlugin.MediaItem', 'CCLI Licence: ') +
translate('SongsPlugin.MediaItem', 'CCLI License: ') +
QtCore.QSettings().value(u'general/ccli number',
QtCore.QVariant(u'')).toString()))
service_item.raw_footer = raw_footer

View File

@ -27,8 +27,11 @@
The :mod:`olp1import` module provides the functionality for importing
openlp.org 1.x song databases into the current installation database.
"""
from PyQt4 import QtGui
import logging
import chardet
from chardet.universaldetector import UniversalDetector
import sqlite
from openlp.core.lib import translate
@ -56,60 +59,38 @@ class OpenLP1SongImport(SongImport):
SongImport.__init__(self, manager)
self.import_source = kwargs[u'filename']
def decode_string(self, raw, guess):
"""
Use chardet to detect the encoding of the raw string, and convert it
to unicode.
``raw``
The raw bytestring to decode.
``guess``
What chardet guessed the encoding to be.
"""
if guess[u'confidence'] < 0.8:
codec = u'windows-1252'
else:
codec = guess[u'encoding']
try:
decoded = unicode(raw, codec)
self.last_encoding = codec
except UnicodeDecodeError:
log.exception(
u'Error in detecting openlp.org 1.x database encoding.')
try:
decoded = unicode(raw, self.last_encoding)
except UnicodeDecodeError:
# possibly show an error form
#self.import_wizard.showError(u'There was a problem '
# u'detecting the encoding of a string')
decoded = raw
return decoded
def do_import(self):
"""
Run the import for an openlp.org 1.x song database.
"""
# Connect to the database
connection = sqlite.connect(self.import_source)
encoding = self.get_encoding()
if not encoding:
return False
connection = sqlite.connect(self.import_source, mode=0444,
encoding=(encoding, 'replace'))
cursor = connection.cursor()
# Determine if we're using a new or an old DB
cursor.execute(u'SELECT name FROM sqlite_master '
u'WHERE type = \'table\' AND name = \'tracks\'')
table_list = cursor.fetchall()
new_db = len(table_list) > 0
new_db = len(cursor.fetchall()) > 0
# Count the number of records we need to import, for the progress bar
cursor.execute(u'-- types int')
cursor.execute(u'SELECT COUNT(songid) FROM songs')
count = int(cursor.fetchone()[0])
count = cursor.fetchone()[0]
success = True
self.import_wizard.importProgressBar.setMaximum(count)
# "cache" our list of authors
cursor.execute(u'-- types int, unicode')
cursor.execute(u'SELECT authorid, authorname FROM authors')
authors = cursor.fetchall()
if new_db:
# "cache" our list of tracks
cursor.execute(u'-- types int, unicode')
cursor.execute(u'SELECT trackid, fulltrackname FROM tracks')
tracks = cursor.fetchall()
# Import the songs
cursor.execute(u'-- types int, unicode, unicode, unicode')
cursor.execute(u'SELECT songid, songtitle, lyrics || \'\' AS lyrics, '
u'copyrightinfo FROM songs')
songs = cursor.fetchall()
@ -119,16 +100,19 @@ class OpenLP1SongImport(SongImport):
success = False
break
song_id = song[0]
guess = chardet.detect(song[2])
title = self.decode_string(song[1], guess)
lyrics = self.decode_string(song[2], guess).replace(u'\r', u'')
copyright = self.decode_string(song[3], guess)
title = song[1]
lyrics = song[2].replace(u'\r\n', u'\n')
copyright = song[3]
self.import_wizard.incrementProgressBar(
unicode(translate('SongsPlugin.ImportWizardForm',
'Importing "%s"...')) % title)
self.title = title
self.process_song_text(lyrics)
verses = lyrics.split(u'\n\n')
for verse in verses:
if verse.strip() != u'':
self.add_verse(verse.strip())
self.add_copyright(copyright)
cursor.execute(u'-- types int')
cursor.execute(u'SELECT authorid FROM songauthors '
u'WHERE songid = %s' % song_id)
author_ids = cursor.fetchall()
@ -138,12 +122,13 @@ class OpenLP1SongImport(SongImport):
break
for author in authors:
if author[0] == author_id[0]:
self.parse_author(self.decode_string(author[1], guess))
self.parse_author(author[1])
break
if self.stop_import_flag:
success = False
break
if new_db:
cursor.execute(u'-- types int')
cursor.execute(u'SELECT trackid FROM songtracks '
u'WHERE songid = %s ORDER BY listindex' % song_id)
track_ids = cursor.fetchall()
@ -153,8 +138,7 @@ class OpenLP1SongImport(SongImport):
break
for track in tracks:
if track[0] == track_id[0]:
self.add_media_file(self.decode_string(track[1],
guess))
self.add_media_file(track[1])
break
if self.stop_import_flag:
success = False
@ -162,3 +146,103 @@ class OpenLP1SongImport(SongImport):
self.finish()
return success
def get_encoding(self):
"""
Detect character encoding of an openlp.org 1.x song database.
"""
# Connect to the database
connection = sqlite.connect(self.import_source, mode=0444)
cursor = connection.cursor()
detector = UniversalDetector()
# detect charset by authors
cursor.execute(u'SELECT authorname FROM authors')
authors = cursor.fetchall()
for author in authors:
detector.feed(author[0])
if detector.done:
detector.close()
return detector.result[u'encoding']
# detect charset by songs
cursor.execute(u'SELECT songtitle, copyrightinfo, '
u'lyrics || \'\' AS lyrics FROM songs')
songs = cursor.fetchall()
for index in [0, 1, 2]:
for song in songs:
detector.feed(song[index])
if detector.done:
detector.close()
return detector.result[u'encoding']
# detect charset by songs
cursor.execute(u'SELECT name FROM sqlite_master '
u'WHERE type = \'table\' AND name = \'tracks\'')
if len(cursor.fetchall()) > 0:
cursor.execute(u'SELECT fulltrackname FROM tracks')
tracks = cursor.fetchall()
for track in tracks:
detector.feed(track[0])
if detector.done:
detector.close()
return detector.result[u'encoding']
detector.close()
guess = detector.result[u'encoding']
# map chardet result to compatible windows standard code page
codepage_mapping = {'IBM866': u'cp866', 'TIS-620': u'cp874',
'SHIFT_JIS': u'cp932', 'GB2312': u'cp936', 'HZ-GB-2312': u'cp936',
'EUC-KR': u'cp949', 'Big5': u'cp950', 'ISO-8859-2': u'cp1250',
'windows-1250': u'cp1250', 'windows-1251': u'cp1251',
'windows-1252': u'cp1252', 'ISO-8859-7': u'cp1253',
'windows-1253': u'cp1253', 'ISO-8859-8': u'cp1255',
'windows-1255': u'cp1255'}
if guess in codepage_mapping:
guess = codepage_mapping[guess]
else:
guess = u'cp1252'
# Show dialog for encoding selection
encodings = [(u'cp1256', translate('SongsPlugin.OpenLP1SongImport',
'Arabic (CP-1256)')),
(u'cp1257', translate('SongsPlugin.OpenLP1SongImport',
'Baltic (CP-1257)')),
(u'cp1250', translate('SongsPlugin.OpenLP1SongImport',
'Central European (CP-1250)')),
(u'cp1251', translate('SongsPlugin.OpenLP1SongImport',
'Cyrillic (CP-1251)')),
(u'cp1253', translate('SongsPlugin.OpenLP1SongImport',
'Greek (CP-1253)')),
(u'cp1255', translate('SongsPlugin.OpenLP1SongImport',
'Hebrew (CP-1255)')),
(u'cp932', translate('SongsPlugin.OpenLP1SongImport',
'Japanese (CP-932)')),
(u'cp949', translate('SongsPlugin.OpenLP1SongImport',
'Korean (CP-949)')),
(u'cp936', translate('SongsPlugin.OpenLP1SongImport',
'Simplified Chinese (CP-936)')),
(u'cp874', translate('SongsPlugin.OpenLP1SongImport',
'Thai (CP-874)')),
(u'cp950', translate('SongsPlugin.OpenLP1SongImport',
'Traditional Chinese (CP-950)')),
(u'cp1254', translate('SongsPlugin.OpenLP1SongImport',
'Turkish (CP-1254)')),
(u'cp1258', translate('SongsPlugin.OpenLP1SongImport',
'Vietnam (CP-1258)')),
(u'cp1252', translate('SongsPlugin.OpenLP1SongImport',
'Western European (CP-1252)'))]
encoding_index = 0
for index in range(len(encodings)):
if guess == encodings[index][0]:
encoding_index = index
break
chosen_encoding = QtGui.QInputDialog.getItem(None,
translate('SongsPlugin.OpenLP1SongImport',
'Database Character Encoding'),
translate('SongsPlugin.OpenLP1SongImport',
'The codepage setting is responsible\n'
'for the correct character representation.\n'
'Usually you are fine with the preselected choise.'),
[pair[1] for pair in encodings], encoding_index, False)
if not chosen_encoding[1]:
return None
return filter(lambda item: item[1] == chosen_encoding[0],
encodings)[0][0]

View File

@ -152,7 +152,7 @@ class OpenLPSongImport(SongImport):
u'Importing song %s of %s' % (song_count, song_total))
new_song = Song()
new_song.title = song.title
if has_media_files:
if has_media_files and hasattr(song, 'alternate_title'):
new_song.alternate_title = song.alternate_title
else:
old_titles = song.search_title.split(u'@')

View File

@ -133,138 +133,254 @@ p, li { white-space: pre-wrap; }
<property name="subTitle">
<string>Set up your theme's background according to the parameters below.</string>
</property>
<layout class="QFormLayout" name="backgroundLayout">
<property name="fieldGrowthPolicy">
<enum>QFormLayout::ExpandingFieldsGrow</enum>
</property>
<property name="labelAlignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
<property name="horizontalSpacing">
<number>8</number>
</property>
<property name="verticalSpacing">
<layout class="QVBoxLayout" name="backgroundLayout">
<property name="spacing">
<number>8</number>
</property>
<property name="margin">
<number>20</number>
</property>
<item row="0" column="0">
<widget class="QLabel" name="backgroundTypeLabel">
<property name="text">
<string>Background type:</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QComboBox" name="backgroundTypeComboBox">
<item>
<property name="text">
<string>Solid Color</string>
</property>
</item>
<item>
<property name="text">
<string>Gradient</string>
</property>
</item>
<item>
<property name="text">
<string>Image</string>
</property>
</item>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="color1Label">
<property name="text">
<string>&lt;Color1&gt;</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QPushButton" name="color1PushButton">
<property name="text">
<string/>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="color2Label">
<property name="text">
<string>&lt;Color2&gt;</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QPushButton" name="color2PushButton">
<property name="text">
<string/>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QLabel" name="imageLabel">
<property name="text">
<string>Image:</string>
</property>
</widget>
</item>
<item row="3" column="1">
<layout class="QHBoxLayout" name="imageLayout">
<item>
<layout class="QHBoxLayout" name="backgroundTypeLayout">
<property name="spacing">
<number>8</number>
</property>
<item>
<widget class="QLineEdit" name="imageLineEdit"/>
</item>
<item>
<widget class="QToolButton" name="imageBrowseButton">
<widget class="QLabel" name="backgroundTypeLabel">
<property name="text">
<string/>
</property>
<property name="icon">
<iconset resource="../images/openlp-2.qrc">
<normaloff>:/general/general_open.png</normaloff>:/general/general_open.png</iconset>
<string>Background type:</string>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="backgroundTypeComboBox">
<item>
<property name="text">
<string>Solid Color</string>
</property>
</item>
<item>
<property name="text">
<string>Gradient</string>
</property>
</item>
<item>
<property name="text">
<string>Image</string>
</property>
</item>
</widget>
</item>
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item row="4" column="0">
<widget class="QLabel" name="gradientLabel">
<property name="text">
<string>Gradient:</string>
<item>
<widget class="QStackedWidget" name="backgroundStackedWidget">
<property name="currentIndex">
<number>0</number>
</property>
</widget>
</item>
<item row="4" column="1">
<widget class="QComboBox" name="gradientComboBox">
<item>
<property name="text">
<string>Horizontal</string>
</property>
</item>
<item>
<property name="text">
<string>Vertical</string>
</property>
</item>
<item>
<property name="text">
<string>Circular</string>
</property>
</item>
<item>
<property name="text">
<string>Top Left - Bottom Right</string>
</property>
</item>
<item>
<property name="text">
<string>Bottom Left - Top Right</string>
</property>
</item>
<widget class="QWidget" name="colorPage">
<layout class="QFormLayout" name="colorLayout">
<property name="horizontalSpacing">
<number>8</number>
</property>
<property name="verticalSpacing">
<number>8</number>
</property>
<property name="margin">
<number>0</number>
</property>
<item row="0" column="0">
<widget class="QLabel" name="colorLabel">
<property name="minimumSize">
<size>
<width>103</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>Color:</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QPushButton" name="colorButton">
<property name="text">
<string/>
</property>
</widget>
</item>
</layout>
</widget>
<widget class="QWidget" name="gradientPage">
<layout class="QFormLayout" name="gradientLayout">
<property name="horizontalSpacing">
<number>8</number>
</property>
<property name="verticalSpacing">
<number>8</number>
</property>
<property name="margin">
<number>0</number>
</property>
<item row="0" column="0">
<widget class="QLabel" name="gradientStartLabel">
<property name="minimumSize">
<size>
<width>103</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>Starting color:</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QPushButton" name="gradientStartButton">
<property name="text">
<string/>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="gradientEndLabel">
<property name="minimumSize">
<size>
<width>103</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>Ending color:</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QPushButton" name="gradientEndButton">
<property name="text">
<string/>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="gradientTypeLabel">
<property name="minimumSize">
<size>
<width>103</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>Gradient:</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QComboBox" name="gradientComboBox">
<item>
<property name="text">
<string>Horizontal</string>
</property>
</item>
<item>
<property name="text">
<string>Vertical</string>
</property>
</item>
<item>
<property name="text">
<string>Circular</string>
</property>
</item>
<item>
<property name="text">
<string>Top Left - Bottom Right</string>
</property>
</item>
<item>
<property name="text">
<string>Bottom Left - Top Right</string>
</property>
</item>
</widget>
</item>
</layout>
</widget>
<widget class="QWidget" name="imagePage">
<layout class="QFormLayout" name="imageLayout">
<property name="horizontalSpacing">
<number>8</number>
</property>
<property name="verticalSpacing">
<number>8</number>
</property>
<property name="margin">
<number>0</number>
</property>
<item row="0" column="0">
<widget class="QLabel" name="imageLabel">
<property name="minimumSize">
<size>
<width>103</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>Image:</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="0" column="1">
<layout class="QHBoxLayout" name="imageFileLayout">
<property name="spacing">
<number>8</number>
</property>
<item>
<widget class="QLineEdit" name="imageLineEdit"/>
</item>
<item>
<widget class="QToolButton" name="imageBrowseButton">
<property name="text">
<string/>
</property>
<property name="icon">
<iconset resource="../images/openlp-2.qrc">
<normaloff>:/general/general_open.png</normaloff>:/general/general_open.png</iconset>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
</widget>
</item>
</layout>
@ -276,30 +392,30 @@ p, li { white-space: pre-wrap; }
<property name="subTitle">
<string>Define the font and display characteristics for the Display text</string>
</property>
<layout class="QFormLayout" name="formLayout">
<property name="formAlignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
</property>
<layout class="QFormLayout" name="mainAreaLayout">
<property name="horizontalSpacing">
<number>8</number>
</property>
<property name="verticalSpacing">
<number>8</number>
</property>
<property name="topMargin">
<number>20</number>
</property>
<property name="rightMargin">
<number>20</number>
</property>
<property name="bottomMargin">
<property name="margin">
<number>20</number>
</property>
<item row="0" column="0">
<widget class="QLabel" name="mainFontLabel">
<property name="minimumSize">
<size>
<width>103</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>Font:</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="0" column="1">
@ -313,11 +429,32 @@ p, li { white-space: pre-wrap; }
</widget>
</item>
<item row="1" column="1">
<widget class="QPushButton" name="mainColorPushButton">
<property name="text">
<string/>
<layout class="QHBoxLayout" name="fontPropertiesLayout">
<property name="spacing">
<number>24</number>
</property>
</widget>
<item>
<widget class="QPushButton" name="mainColorPushButton">
<property name="text">
<string/>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="boldCheckBox">
<property name="text">
<string>Bold</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="italicsCheckBox">
<property name="text">
<string>Italic</string>
</property>
</widget>
</item>
</layout>
</item>
<item row="2" column="0">
<widget class="QLabel" name="mainSizeLabel">
@ -458,20 +595,6 @@ p, li { white-space: pre-wrap; }
</item>
</layout>
</item>
<item row="6" column="1">
<widget class="QCheckBox" name="boldCheckBox">
<property name="text">
<string>Bold Display</string>
</property>
</widget>
</item>
<item row="7" column="1">
<widget class="QCheckBox" name="italicsCheckBox">
<property name="text">
<string>Italic Display</string>
</property>
</widget>
</item>
</layout>
</widget>
<widget class="QWizardPage" name="footerAreaPage">
@ -491,23 +614,23 @@ p, li { white-space: pre-wrap; }
<property name="verticalSpacing">
<number>8</number>
</property>
<property name="leftMargin">
<number>50</number>
</property>
<property name="topMargin">
<number>20</number>
</property>
<property name="rightMargin">
<number>20</number>
</property>
<property name="bottomMargin">
<property name="margin">
<number>20</number>
</property>
<item row="0" column="0">
<widget class="QLabel" name="footerFontLabel">
<property name="minimumSize">
<size>
<width>103</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>Font:</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="0" column="1">
@ -569,14 +692,29 @@ p, li { white-space: pre-wrap; }
<string>Allows additional display formatting information to be defined</string>
</property>
<layout class="QFormLayout" name="formLayout_2">
<property name="horizontalSpacing">
<number>8</number>
</property>
<property name="verticalSpacing">
<number>8</number>
</property>
<property name="margin">
<number>20</number>
</property>
<item row="0" column="0">
<widget class="QLabel" name="horizontalLabel">
<property name="minimumSize">
<size>
<width>103</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>Horizontal Align:</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="0" column="1">
@ -643,7 +781,7 @@ p, li { white-space: pre-wrap; }
<property name="subTitle">
<string>Allows you to change and move the Main and Footer areas.</string>
</property>
<layout class="QGridLayout" name="gridLayout_2">
<layout class="QGridLayout" name="areaPositionLayout">
<property name="margin">
<number>20</number>
</property>
@ -983,129 +1121,114 @@ p, li { white-space: pre-wrap; }
<property name="subTitle">
<string>View the theme and save it replacing the current one or change the name to create a new theme</string>
</property>
<widget class="QLabel" name="themeNameLabel">
<property name="geometry">
<rect>
<x>20</x>
<y>10</y>
<width>82</width>
<height>16</height>
</rect>
<layout class="QVBoxLayout" name="previewLayout">
<property name="spacing">
<number>8</number>
</property>
<property name="text">
<string>Theme name:</string>
<property name="margin">
<number>20</number>
</property>
<property name="textFormat">
<enum>Qt::PlainText</enum>
</property>
<property name="buddy">
<cstring>themeNameEdit</cstring>
</property>
</widget>
<widget class="QLabel" name="previewLabel">
<property name="geometry">
<rect>
<x>250</x>
<y>60</y>
<width>48</width>
<height>16</height>
</rect>
</property>
<property name="text">
<string>Preview</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
<widget class="QLineEdit" name="themeNameEdit">
<property name="geometry">
<rect>
<x>117</x>
<y>4</y>
<width>351</width>
<height>23</height>
</rect>
</property>
</widget>
<widget class="QGroupBox" name="groupBox">
<property name="geometry">
<rect>
<x>40</x>
<y>80</y>
<width>464</width>
<height>214</height>
</rect>
</property>
<property name="title">
<string/>
</property>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<spacer name="leftSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>58</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QLabel" name="previewBoxLabel">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>300</width>
<height>200</height>
</size>
</property>
<property name="frameShape">
<enum>QFrame::WinPanel</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Sunken</enum>
</property>
<property name="lineWidth">
<number>1</number>
</property>
<property name="text">
<string/>
</property>
<property name="scaledContents">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<spacer name="rightSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>78</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
<item>
<layout class="QHBoxLayout" name="themeNameLayout">
<property name="spacing">
<number>8</number>
</property>
<item>
<widget class="QLabel" name="themeNameLabel">
<property name="minimumSize">
<size>
<width>103</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>Theme name:</string>
</property>
<property name="textFormat">
<enum>Qt::PlainText</enum>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
<property name="buddy">
<cstring>themeNameEdit</cstring>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="themeNameEdit"/>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="previewPaneLayout">
<property name="spacing">
<number>0</number>
</property>
<item>
<spacer name="leftSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>58</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QLabel" name="previewBoxLabel">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>100</width>
<height>150</height>
</size>
</property>
<property name="frameShape">
<enum>QFrame::WinPanel</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Sunken</enum>
</property>
<property name="lineWidth">
<number>1</number>
</property>
<property name="text">
<string/>
</property>
<property name="scaledContents">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<spacer name="rightSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>78</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
</layout>
</widget>
</widget>
<resources>
<include location="../images/openlp-2.qrc"/>
<include location="../images/openlp-2.qrc"/>
<include location="Projects/OpenLP/trunk/resources/images/openlp-2.qrc"/>
</resources>
<connections>
<connection>
@ -1124,5 +1247,21 @@ p, li { white-space: pre-wrap; }
</hint>
</hints>
</connection>
<connection>
<sender>backgroundTypeComboBox</sender>
<signal>currentIndexChanged(int)</signal>
<receiver>backgroundStackedWidget</receiver>
<slot>setCurrentIndex(int)</slot>
<hints>
<hint type="sourcelabel">
<x>178</x>
<y>78</y>
</hint>
<hint type="destinationlabel">
<x>249</x>
<y>199</y>
</hint>
</hints>
</connection>
</connections>
</ui>

View File

@ -81,6 +81,7 @@
<qresource prefix="wizards">
<file>wizard_importsong.bmp</file>
<file>wizard_importbible.bmp</file>
<file>wizard_createtheme.bmp</file>
</qresource>
<qresource prefix="services">
<file>service_collapse_all.png</file>

Binary file not shown.

After

Width:  |  Height:  |  Size: 168 KiB