Merge changes from trunk

This commit is contained in:
Gerald Britton 2011-05-26 09:10:46 -04:00
commit c70c1a7c1a
10 changed files with 72 additions and 33 deletions

View File

@ -84,6 +84,9 @@ base_html_expands.append({u'desc': u'Italics', u'start tag': u'{it}',
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})
base_html_expands.append({u'desc': u'Break', u'start tag': u'{br}',
u'start html': u'<br>', u'end tag': u'', u'end html': u'',
u'protected': True})
def translate(context, text, comment=None,
encoding=QtCore.QCoreApplication.CodecForTr, n=-1,
@ -245,6 +248,7 @@ def clean_tags(text):
Remove Tags from text for display
"""
text = text.replace(u'<br>', u'\n')
text = text.replace(u'{br}', u'\n')
text = text.replace(u'&nbsp;', u' ')
for tag in DisplayTags.get_html_tags():
text = text.replace(tag[u'start tag'], u'')

View File

@ -431,6 +431,13 @@ class MediaManagerItem(QtGui.QWidget):
raise NotImplementedError(u'MediaManagerItem.onDeleteClick needs to '
u'be defined by the plugin')
def onFocus(self):
"""
Run when a tab in the media manager gains focus. This gives the media
item a chance to focus any elements it wants to.
"""
pass
def generateSlideData(self, serviceItem, item=None, xmlVersion=False):
raise NotImplementedError(u'MediaManagerItem.generateSlideData needs '
u'to be defined by the plugin')

View File

@ -29,6 +29,7 @@ The :mod:`serviceitem` provides the service item functionality including the
type and capability of an item.
"""
import cgi
import datetime
import logging
import os
@ -175,17 +176,18 @@ class ServiceItem(object):
formatted = self.renderer \
.format_slide(slide[u'raw_slide'], line_break, self)
for page in formatted:
page = page.replace(u'<br>', u'{br}')
self._display_frames.append({
u'title': clean_tags(page),
u'text': clean_tags(page.rstrip()),
u'html': expand_tags(page.rstrip()),
u'html': expand_tags(cgi.escape(page.rstrip())),
u'verseTag': slide[u'verseTag']
})
elif self.service_item_type == ServiceItemType.Image or \
self.service_item_type == ServiceItemType.Command:
pass
else:
log.error(u'Invalid value renderer :%s' % self.service_item_type)
log.error(u'Invalid value renderer: %s' % self.service_item_type)
self.title = clean_tags(self.title)
# The footer should never be None, but to be compatible with a few
# nightly builds between 1.9.4 and 1.9.5, we have to correct this to

View File

@ -537,6 +537,9 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow):
QtCore.SIGNAL(u'config_screen_changed'), self.screenChanged)
QtCore.QObject.connect(Receiver.get_receiver(),
QtCore.SIGNAL(u'maindisplay_status_text'), self.showStatusMessage)
# Media Manager
QtCore.QObject.connect(self.mediaToolBox,
QtCore.SIGNAL(u'currentChanged(int)'), self.onMediaToolBoxChanged)
Receiver.send_message(u'cursor_busy')
# Simple message boxes
QtCore.QObject.connect(Receiver.get_receiver(),
@ -602,6 +605,11 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow):
LanguageManager.auto_language = value
LanguageManager.set_language(self.languageGroup.checkedAction())
def onMediaToolBoxChanged(self, index):
widget = self.mediaToolBox.widget(index)
if widget:
widget.onFocus()
def versionNotice(self, version):
"""
Notifies the user that a newer version of OpenLP is available.

View File

@ -29,6 +29,7 @@ import os
import zipfile
import shutil
import logging
import locale
from xml.etree.ElementTree import ElementTree, XML
from PyQt4 import QtCore, QtGui
@ -462,7 +463,10 @@ class ThemeManager(QtGui.QWidget):
QtCore.QVariant(theme.theme_name))
self.configUpdated()
files = SettingsManager.get_files(self.settingsSection, u'.png')
files.sort()
# Sort the themes by its name considering language specific characters.
# lower() is needed for windows!
files.sort(key=lambda filename: unicode(filename).lower(),
cmp=locale.strcoll)
# now process the file list of png files
for name in files:
# check to see file is in theme root directory

View File

@ -31,6 +31,7 @@ import csv
import logging
import os
import os.path
import locale
from PyQt4 import QtCore, QtGui
@ -532,7 +533,7 @@ class BibleImportForm(OpenLPWizard):
"""
self.webTranslationComboBox.clear()
bibles = self.web_bible_list[index].keys()
bibles.sort()
bibles.sort(cmp=locale.strcoll)
self.webTranslationComboBox.addItems(bibles)
def onOsisBrowseButtonClicked(self):
@ -767,4 +768,3 @@ class BibleImportForm(OpenLPWizard):
'BiblesPlugin.ImportWizardForm', 'Your Bible import failed.'))
del self.manager.db_cache[importer.name]
delete_database(self.plugin.settingsSection, importer.file)

View File

@ -26,6 +26,7 @@
###############################################################################
import logging
import locale
from PyQt4 import QtCore, QtGui
@ -272,6 +273,12 @@ class BibleMediaItem(MediaManagerItem):
QtCore.SIGNAL(u'currentChanged(int)'),
self.onSearchTabBarCurrentChanged)
def onFocus(self):
if self.quickTab.isVisible():
self.quickSearchEdit.setFocus()
else:
self.advancedBookComboBox.setFocus()
def configUpdated(self):
log.debug(u'configUpdated')
if QtCore.QSettings().value(self.settingsSection + u'/second bibles',
@ -359,7 +366,7 @@ class BibleMediaItem(MediaManagerItem):
self.advancedSecondComboBox.addItem(u'')
# Get all bibles and sort the list.
bibles = self.parent.manager.get_bibles().keys()
bibles.sort()
bibles.sort(cmp=locale.strcoll)
# Load the bibles into the combo boxes.
for bible in bibles:
if bible:
@ -443,7 +450,7 @@ class BibleMediaItem(MediaManagerItem):
if bible:
book_data = bibles[bible].get_books()
books = [book.name + u' ' for book in book_data]
books.sort()
books.sort(cmp=locale.strcoll)
add_widget_completer(books, self.quickSearchEdit)
def onImportClick(self):
@ -462,6 +469,7 @@ class BibleMediaItem(MediaManagerItem):
else:
self.quickTab.setVisible(False)
self.advancedTab.setVisible(True)
self.advancedBookComboBox.setFocus()
def onLockButtonToggled(self, checked):
if checked:

View File

@ -199,6 +199,9 @@ class CustomMediaItem(MediaManagerItem):
for row in row_list:
self.listView.takeItem(row)
def onFocus(self):
self.searchTextEdit.setFocus()
def generateSlideData(self, service_item, item=None, xmlVersion=False):
raw_slides = []
raw_footer = []

View File

@ -125,6 +125,9 @@ class SongMediaItem(MediaManagerItem):
QtCore.SIGNAL(u'searchTypeChanged(int)'),
self.onSearchTextButtonClick)
def onFocus(self):
self.searchTextEdit.setFocus()
def configUpdated(self):
self.searchAsYouType = QtCore.QSettings().value(
self.settingsSection + u'/search as type',

View File

@ -69,6 +69,30 @@ class SongBeamerImport(SongImport):
Song Beamer file format is text based
in the beginning are one or more control tags written
"""
HTML_TAG_PAIRS = [
(re.compile(u'<b>'), u'{st}'),
(re.compile(u'</b>'), u'{/st}'),
(re.compile(u'<i>'), u'{it}'),
(re.compile(u'</i>'), u'{/it}'),
(re.compile(u'<u>'), u'{u}'),
(re.compile(u'</u>'), u'{/u}'),
(re.compile(u'<p>'), u'{p}'),
(re.compile(u'</p>'), u'{/p}'),
(re.compile(u'<super>'), u'{su}'),
(re.compile(u'</super>'), u'{/su}'),
(re.compile(u'<sub>'), u'{sb}'),
(re.compile(u'</sub>'), u'{/sb}'),
(re.compile(u'<br.*?>'), u'{br}'),
(re.compile(u'<[/]?wordwrap>'), u''),
(re.compile(u'<[/]?strike>'), u''),
(re.compile(u'<[/]?h.*?>'), u''),
(re.compile(u'<[/]?s.*?>'), u''),
(re.compile(u'<[/]?linespacing.*?>'), u''),
(re.compile(u'<[/]?c.*?>'), u''),
(re.compile(u'<align.*?>'), u''),
(re.compile(u'<valign.*?>'), u'')
]
def __init__(self, manager, **kwargs):
"""
Initialise the Song Beamer importer.
@ -134,32 +158,8 @@ class SongBeamerImport(SongImport):
This can be called to replace SongBeamer's specific (html) tags with
OpenLP's specific (html) tags.
"""
tag_pairs = [
(u'<b>', u'{st}'),
(u'</b>', u'{/st}'),
(u'<i>', u'{it}'),
(u'</i>', u'{/it}'),
(u'<u>', u'{u}'),
(u'</u>', u'{/u}'),
(u'<p>', u'{p}'),
(u'</p>', u'{/p}'),
(u'<super>', u'{su}'),
(u'</super>', u'{/su}'),
(u'<sub>', u'{sb}'),
(u'</sub>', u'{/sb}'),
(u'<[/]?br.*?>', u'{st}'),
(u'<[/]?wordwrap>', u''),
(u'<[/]?strike>', u''),
(u'<[/]?h.*?>', u''),
(u'<[/]?s.*?>', u''),
(u'<[/]?linespacing.*?>', u''),
(u'<[/]?c.*?>', u''),
(u'<align.*?>', u''),
(u'<valign.*?>', u'')
]
for pair in tag_pairs:
self.current_verse = re.compile(pair[0]).sub(pair[1],
self.current_verse)
for pair in SongBeamerImport.HTML_TAG_PAIRS:
self.current_verse = pair[0].sub(pair[1], self.current_verse)
def parse_tags(self, line):
"""