From 3ed9dcaae3301d85673be03f700f6860f1c5f6ab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Armin=20K=C3=B6hler?= Date: Wed, 29 Feb 2012 12:47:21 +0100 Subject: [PATCH 01/28] add possibility to switch the booknames of bibles - fix bug #822363 --- openlp/plugins/bibles/lib/__init__.py | 7 ++ openlp/plugins/bibles/lib/biblestab.py | 50 +++++++++- openlp/plugins/bibles/lib/manager.py | 13 +++ openlp/plugins/bibles/lib/mediaitem.py | 56 ++++++++++-- openlp/plugins/bibles/lib/ui.py | 121 +++++++++++++++++++++++++ 5 files changed, 235 insertions(+), 12 deletions(-) create mode 100644 openlp/plugins/bibles/lib/ui.py diff --git a/openlp/plugins/bibles/lib/__init__.py b/openlp/plugins/bibles/lib/__init__.py index 6189f108f..e9e6ad5d3 100644 --- a/openlp/plugins/bibles/lib/__init__.py +++ b/openlp/plugins/bibles/lib/__init__.py @@ -58,6 +58,13 @@ class DisplayStyle(object): Curly = 2 Square = 3 +class LanguageSelection(object): + """ + An enumeration for bible bookname language. + """ + Bible = 0 + Application = 1 + English = 2 def update_reference_separators(): """ diff --git a/openlp/plugins/bibles/lib/biblestab.py b/openlp/plugins/bibles/lib/biblestab.py index e8e0d9e2c..c7028b577 100644 --- a/openlp/plugins/bibles/lib/biblestab.py +++ b/openlp/plugins/bibles/lib/biblestab.py @@ -32,7 +32,7 @@ from PyQt4 import QtCore, QtGui from openlp.core.lib import Receiver, SettingsTab, translate from openlp.core.lib.ui import UiStrings, find_and_set_in_combo_box from openlp.plugins.bibles.lib import LayoutStyle, DisplayStyle, \ - update_reference_separators, get_reference_separator + update_reference_separators, get_reference_separator, LanguageSelection log = logging.getLogger(__name__) @@ -140,9 +140,25 @@ class BiblesTab(SettingsTab): self.scriptureReferenceLayout.addWidget(self.endSeparatorLineEdit, 3, 1) self.leftLayout.addWidget(self.scriptureReferenceGroupBox) - self.leftLayout.addStretch() self.rightColumn.setSizePolicy( QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Preferred) + self.languageSelectionGroupBox = QtGui.QGroupBox(self.rightColumn) + self.languageSelectionGroupBox.setObjectName( + u'languageSelectionGroupBox') + self.languageSelectionLayout = QtGui.QVBoxLayout( + self.languageSelectionGroupBox) + self.languageSelectionLabel = QtGui.QLabel( + self.languageSelectionGroupBox) + self.languageSelectionLabel.setObjectName(u'languageSelectionLabel') + self.languageSelectionComboBox = QtGui.QComboBox( + self.languageSelectionGroupBox) + self.languageSelectionComboBox.setObjectName( + u'languageSelectionComboBox') + self.languageSelectionComboBox.addItems([u'', u'', u'']) + self.languageSelectionLayout.addWidget(self.languageSelectionLabel) + self.languageSelectionLayout.addWidget(self.languageSelectionComboBox) + self.rightLayout.addWidget(self.languageSelectionGroupBox) + self.leftLayout.addStretch() self.rightLayout.addStretch() # Signals and slots QtCore.QObject.connect( @@ -198,6 +214,9 @@ class BiblesTab(SettingsTab): self.onEndSeparatorLineEditFinished) QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'theme_update_list'), self.updateThemeList) + QtCore.QObject.connect( + self.languageSelectionComboBox, QtCore.SIGNAL(u'activated(int)'), + self.onLanguageSelectionComboBoxChanged) def retranslateUi(self): self.verseDisplayGroupBox.setTitle( @@ -257,6 +276,24 @@ class BiblesTab(SettingsTab): 'end marks may be defined.\nThey have to be separated by a ' 'vertical bar "|".\nPlease clear this edit line to use the ' 'default value.')) + self.languageSelectionGroupBox.setTitle( + translate('BiblesPlugin.BiblesTab', 'Preferred Bookname Language')) + self.languageSelectionLabel.setText(translate('BiblesPlugin.BiblesTab', + 'Choose the language in which the book names of the\nbible should ' + 'be displayed in advanced search or on\nautocompleter in quick ' + 'search:')) + self.languageSelectionComboBox.setItemText(LanguageSelection.Bible, + translate('BiblesPlugin.BiblesTab', 'Bible language')) + self.languageSelectionComboBox.setItemText( + LanguageSelection.Application, + translate('BiblesPlugin.BiblesTab', 'Application language')) + self.languageSelectionComboBox.setItemText(LanguageSelection.English, + translate('BiblesPlugin.BiblesTab', 'English')) + self.languageSelectionComboBox.setToolTip( + translate('BiblesPlugin.BiblesTab', 'Multiple options:\n ' + 'Bible language - the language in which the bible book names ' + 'was imported\n Application language - the language you have ' + 'choosen for Openlp\n English - use always English booknames')) def onBibleThemeComboBoxChanged(self): self.bible_theme = self.bibleThemeComboBox.currentText() @@ -267,6 +304,9 @@ class BiblesTab(SettingsTab): def onLayoutStyleComboBoxChanged(self): self.layout_style = self.layoutStyleComboBox.currentIndex() + def onLanguageSelectionComboBoxChanged(self): + self.language_selection = self.languageSelectionComboBox.currentIndex() + def onNewChaptersCheckBoxChanged(self, check_state): self.show_new_chapters = False # We have a set value convert to True/False. @@ -448,6 +488,9 @@ class BiblesTab(SettingsTab): self.endSeparatorLineEdit.setPalette( self.getGreyTextPalette(False)) self.endSeparatorCheckBox.setChecked(True) + self.language_selection = settings.value( + u'bookname language', QtCore.QVariant(0)).toInt()[0] + self.languageSelectionComboBox.setCurrentIndex(self.language_selection) settings.endGroup() def save(self): @@ -459,6 +502,8 @@ class BiblesTab(SettingsTab): QtCore.QVariant(self.display_style)) settings.setValue(u'verse layout style', QtCore.QVariant(self.layout_style)) + settings.setValue(u'bookname language', + QtCore.QVariant(self.language_selection)) settings.setValue(u'second bibles', QtCore.QVariant(self.second_bibles)) settings.setValue(u'bible theme', QtCore.QVariant(self.bible_theme)) if self.verseSeparatorCheckBox.isChecked(): @@ -482,6 +527,7 @@ class BiblesTab(SettingsTab): else: settings.remove(u'end separator') update_reference_separators() + Receiver.send_message(u'bibles_load_list') settings.endGroup() def updateThemeList(self, theme_list): diff --git a/openlp/plugins/bibles/lib/manager.py b/openlp/plugins/bibles/lib/manager.py index c231f2062..411e25367 100644 --- a/openlp/plugins/bibles/lib/manager.py +++ b/openlp/plugins/bibles/lib/manager.py @@ -227,6 +227,19 @@ class BibleManager(object): for book in self.db_cache[bible].get_books() ] + def get_book_by_id(self, bible, id): + """ + Returns a book object by given id. + + ``bible`` + Unicode. The Bible to get the list of books from. + + ``id`` + Unicode. The book_reference_id to get the book for. + """ + log.debug(u'BibleManager.get_book_by_id("%s", "%s")', bible, id) + return self.db_cache[bible].get_book_by_book_ref_id(id) + def get_chapter_count(self, bible, book): """ Returns the number of Chapters for a given book. diff --git a/openlp/plugins/bibles/lib/mediaitem.py b/openlp/plugins/bibles/lib/mediaitem.py index 29172a334..50872aef3 100644 --- a/openlp/plugins/bibles/lib/mediaitem.py +++ b/openlp/plugins/bibles/lib/mediaitem.py @@ -38,7 +38,9 @@ from openlp.core.lib.ui import UiStrings, add_widget_completer, \ find_and_set_in_combo_box, build_icon from openlp.plugins.bibles.forms import BibleImportForm from openlp.plugins.bibles.lib import LayoutStyle, DisplayStyle, \ - VerseReferenceList, get_reference_separator + VerseReferenceList, get_reference_separator, LanguageSelection +from openlp.plugins.bibles.lib.ui import BibleStrings +from openlp.plugins.bibles.lib.db import BiblesResourcesDB log = logging.getLogger(__name__) @@ -424,20 +426,37 @@ class BibleMediaItem(MediaManagerItem): book_data = book_data_temp self.advancedBookComboBox.clear() first = True + language_selection = QtCore.QSettings().value( + self.settingsSection + u'/bookname language', + QtCore.QVariant(0)).toInt()[0] for book in book_data: row = self.advancedBookComboBox.count() - self.advancedBookComboBox.addItem(book[u'name']) + if language_selection == LanguageSelection.Bible: + self.advancedBookComboBox.addItem(book[u'name']) + elif language_selection == LanguageSelection.Application: + data = BiblesResourcesDB.get_book_by_id( + book[u'book_reference_id']) + abbr = data[u'abbreviation'].replace(u'1', u'First').\ + replace(u'2', u'Second').replace(u'3', u'Third').\ + replace(u'4', u'Fourth') + self.advancedBookComboBox.addItem(getattr(BibleStrings, abbr)) + elif language_selection == LanguageSelection.English: + data = BiblesResourcesDB.get_book_by_id( + book[u'book_reference_id']) + self.advancedBookComboBox.addItem(data[u'name']) self.advancedBookComboBox.setItemData( - row, QtCore.QVariant(book[u'chapters'])) + row, QtCore.QVariant(book[u'book_reference_id'])) if first: first = False self.initialiseChapterVerse(bible, book[u'name'], - book[u'chapters']) + book[u'book_reference_id']) - def initialiseChapterVerse(self, bible, book, chapter_count): - log.debug(u'initialiseChapterVerse %s, %s', bible, book) - self.chapter_count = chapter_count - verse_count = self.plugin.manager.get_verse_count(bible, book, 1) + def initialiseChapterVerse(self, bible, book, book_ref_id): + log.debug(u'initialiseChapterVerse %s, %s, %s', bible, book, + book_ref_id) + book = self.plugin.manager.get_book_by_id(bible, book_ref_id) + self.chapter_count = self.plugin.manager.get_chapter_count(bible, book) + verse_count = self.plugin.manager.get_verse_count(bible, book.name, 1) if verse_count == 0: self.advancedSearchButton.setEnabled(False) critical_error_message_box( @@ -480,7 +499,24 @@ class BibleMediaItem(MediaManagerItem): secondbook.book_reference_id: book_data_temp.append(book) book_data = book_data_temp - books = [book.name + u' ' for book in book_data] + language_selection = QtCore.QSettings().value( + self.settingsSection + u'/bookname language', + QtCore.QVariant(0)).toInt()[0] + if language_selection == LanguageSelection.Bible: + books = [book.name + u' ' for book in book_data] + elif language_selection == LanguageSelection.Application: + for book in book_data: + data = BiblesResourcesDB.get_book_by_id( + book.book_reference_id) + abbr = data[u'abbreviation'].replace(u'1', u'First').\ + replace(u'2', u'Second').replace(u'3', u'Third').\ + replace(u'4', u'Fourth') + books.append(getattr(BibleStrings, abbr) + u' ') + elif language_selection == LanguageSelection.English: + for book in book_data: + data = BiblesResourcesDB.get_book_by_id( + book.book_reference_id) + books.append(data[u'name'] + u' ') books.sort(cmp=locale.strcoll) add_widget_completer(books, self.quickSearchEdit) @@ -547,7 +583,7 @@ class BibleMediaItem(MediaManagerItem): self.initialiseChapterVerse( unicode(self.advancedVersionComboBox.currentText()), unicode(self.advancedBookComboBox.currentText()), - self.advancedBookComboBox.itemData(item).toInt()[0]) + unicode(self.advancedBookComboBox.itemData(item).toString())) def onAdvancedFromVerse(self): chapter_from = int(self.advancedFromChapter.currentText()) diff --git a/openlp/plugins/bibles/lib/ui.py b/openlp/plugins/bibles/lib/ui.py new file mode 100644 index 000000000..ca9c35785 --- /dev/null +++ b/openlp/plugins/bibles/lib/ui.py @@ -0,0 +1,121 @@ +# -*- coding: utf-8 -*- +# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4 + +############################################################################### +# OpenLP - Open Source Lyrics Projection # +# --------------------------------------------------------------------------- # +# Copyright (c) Second008-2012 Raoul Snyman # +# Portions copyright (c) Second008-2012 Tim Bentley, Gerald Britton, Jonathan # +# Corwin, Michael Gorven, Scott Guerrieri, Matthias Hub, Meinert Jordan, # +# Armin Köhler, Joshua Miller, Stevan Pettit, Andreas Preikschat, Mattias # +# Põldaru, Christian Richter, Philip Ridout, Simon Scudder, Jeffrey Smith, # +# Maikel Stuivenberg, Martin Thompson, Jon Tibble, 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 Second 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:`openlp.plugins.bibles.lib.ui` module provides standard UI components +for the bibles plugin. +""" +from openlp.core.lib import translate + +class BibleStrings(object): + """ + Provide standard strings for use throughout the bibles plugin. + """ + # These strings should need a good reason to be retranslated elsewhere. + Gen = translate('OpenLP.Ui','Genesis') + Exod = translate('OpenLP.Ui','Exodus') + Lev = translate('OpenLP.Ui','Leviticus') + Num = translate('OpenLP.Ui','Numbers') + Deut = translate('OpenLP.Ui','Deuteronomy') + Josh = translate('OpenLP.Ui','Joshua') + Judg = translate('OpenLP.Ui','Judges') + Ruth = translate('OpenLP.Ui','Ruth') + FirstSam = translate('OpenLP.Ui','1 Samuel') + SecondSam = translate('OpenLP.Ui','2 Samuel') + FirstKgs = translate('OpenLP.Ui','1 Kings') + SecondKgs = translate('OpenLP.Ui','2 Kings') + FirstChr = translate('OpenLP.Ui','1 Chronicles') + SecondChr = translate('OpenLP.Ui','2 Chronicles') + Esra = translate('OpenLP.Ui','Ezra') + Neh = translate('OpenLP.Ui','Nehemiah') + Esth = translate('OpenLP.Ui','Esther') + Job = translate('OpenLP.Ui','Job') + Ps = translate('OpenLP.Ui','Psalms') + Prov = translate('OpenLP.Ui','Proverbs') + Eccl = translate('OpenLP.Ui','Ecclesiastes') + Song = translate('OpenLP.Ui','Song of Solomon') + Isa = translate('OpenLP.Ui','Isaiah') + Jer = translate('OpenLP.Ui','Jeremiah') + Lam = translate('OpenLP.Ui','Lamentations') + Ezek = translate('OpenLP.Ui','Ezekiel') + Dan = translate('OpenLP.Ui','Daniel') + Hos = translate('OpenLP.Ui','Hosea') + Joel = translate('OpenLP.Ui','Joel') + Amos= translate('OpenLP.Ui','Amos') + Obad = translate('OpenLP.Ui','Obadiah') + Jonah = translate('OpenLP.Ui','Jonah') + Mic = translate('OpenLP.Ui','Micah') + Nah = translate('OpenLP.Ui','Nahum') + Hab = translate('OpenLP.Ui','Habakkuk') + Zeph = translate('OpenLP.Ui','Zephaniah') + Hag = translate('OpenLP.Ui','Haggai') + Zech = translate('OpenLP.Ui','Zechariah') + Mal = translate('OpenLP.Ui','Malachi') + Matt = translate('OpenLP.Ui','Matthew') + Mark = translate('OpenLP.Ui','Mark') + Luke = translate('OpenLP.Ui','Luke') + John = translate('OpenLP.Ui','John') + Acts = translate('OpenLP.Ui','Acts') + Rom = translate('OpenLP.Ui','Romans') + FirstCor = translate('OpenLP.Ui','1 Corinthians') + SecondCor = translate('OpenLP.Ui','2 Corinthians') + Gal = translate('OpenLP.Ui','Galatians') + Eph = translate('OpenLP.Ui','Ephesians') + Phil = translate('OpenLP.Ui','Philippians') + Col = translate('OpenLP.Ui','Colossians') + FirstThess = translate('OpenLP.Ui','1 Thessalonians') + SecondThess = translate('OpenLP.Ui','2 Thessalonians') + FirstTim = translate('OpenLP.Ui','1 Timothy') + SecondTim = translate('OpenLP.Ui','2 Timothy') + Titus = translate('OpenLP.Ui','Titus') + Phlm = translate('OpenLP.Ui','Philemon') + Heb = translate('OpenLP.Ui','Hebrews') + Jas = translate('OpenLP.Ui','James') + FirstPet = translate('OpenLP.Ui','1 Peter') + SecondPet = translate('OpenLP.Ui','2 Peter') + FirstJohn = translate('OpenLP.Ui','1 John') + SecondJohn = translate('OpenLP.Ui','2 John') + ThirdJohn = translate('OpenLP.Ui','3 John') + Jude = translate('OpenLP.Ui','Jude') + Rev = translate('OpenLP.Ui','Revelation') + Jdt = translate('OpenLP.Ui','Judith') + Wis = translate('OpenLP.Ui','Wisdom') + Tob = translate('OpenLP.Ui','Tobit') + Sir = translate('OpenLP.Ui','Sirach') + Bar = translate('OpenLP.Ui','Baruch') + FirstMacc = translate('OpenLP.Ui','1 Maccabees') + SecondMacc = translate('OpenLP.Ui','2 Maccabees') + ThirdMacc = translate('OpenLP.Ui','3 Maccabees') + FourthMacc = translate('OpenLP.Ui','4 Maccabees') + AddDan = translate('OpenLP.Ui','Rest of Daniel') + AddEsth = translate('OpenLP.Ui','Rest of Esther') + PrMan = translate('OpenLP.Ui','Prayer of Manasses') + LetJer = translate('OpenLP.Ui','Letter of Jeremiah') + PrAza = translate('OpenLP.Ui','Prayer of Azariah') + Sus = translate('OpenLP.Ui','Susanna') + Bel = translate('OpenLP.Ui','Bel') + FirstEsdr = translate('OpenLP.Ui','1 Esdras') + SecondEsdr = translate('OpenLP.Ui','2 Esdras') From 371e624ea237e661b43873246b9097ba94f11906 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Armin=20K=C3=B6hler?= Date: Sun, 4 Mar 2012 21:10:17 +0100 Subject: [PATCH 02/28] improve possibility to switch booknames - fix some bugs - move translation string to a dict --- openlp/plugins/bibles/lib/__init__.py | 155 +++++++++++++++++++++++-- openlp/plugins/bibles/lib/db.py | 61 +++++++--- openlp/plugins/bibles/lib/manager.py | 46 ++++---- openlp/plugins/bibles/lib/mediaitem.py | 55 +++++---- 4 files changed, 244 insertions(+), 73 deletions(-) diff --git a/openlp/plugins/bibles/lib/__init__.py b/openlp/plugins/bibles/lib/__init__.py index e9e6ad5d3..51d7f483a 100644 --- a/openlp/plugins/bibles/lib/__init__.py +++ b/openlp/plugins/bibles/lib/__init__.py @@ -34,6 +34,7 @@ import re from PyQt4 import QtCore from openlp.core.lib import translate +from openlp.plugins.bibles.lib.db import BiblesResourcesDB log = logging.getLogger(__name__) @@ -61,10 +62,98 @@ class DisplayStyle(object): class LanguageSelection(object): """ An enumeration for bible bookname language. + And standard strings for use throughout the bibles plugin. """ Bible = 0 Application = 1 English = 2 + + Booknames = { + u'Gen': translate('BiblesPlugin','Genesis'), + u'Exod': translate('BiblesPlugin','Exodus'), + u'Lev': translate('BiblesPlugin','Leviticus'), + u'Num': translate('BiblesPlugin','Numbers'), + u'Deut': translate('BiblesPlugin','Deuteronomy'), + u'Josh': translate('BiblesPlugin','Joshua'), + u'Judg': translate('BiblesPlugin','Judges'), + u'Ruth': translate('BiblesPlugin','Ruth'), + u'1Sam': translate('BiblesPlugin','1 Samuel'), + u'2Sam': translate('BiblesPlugin','2 Samuel'), + u'1Kgs': translate('BiblesPlugin','1 Kings'), + u'2Kgs': translate('BiblesPlugin','2 Kings'), + u'1Chr': translate('BiblesPlugin','1 Chronicles'), + u'2Chr': translate('BiblesPlugin','2 Chronicles'), + u'Esra': translate('BiblesPlugin','Ezra'), + u'Neh': translate('BiblesPlugin','Nehemiah'), + u'Esth': translate('BiblesPlugin','Esther'), + u'Job': translate('BiblesPlugin','Job'), + u'Ps': translate('BiblesPlugin','Psalms'), + u'Prov': translate('BiblesPlugin','Proverbs'), + u'Eccl': translate('BiblesPlugin','Ecclesiastes'), + u'Song': translate('BiblesPlugin','Song of Solomon'), + u'Isa': translate('BiblesPlugin','Isaiah'), + u'Jer': translate('BiblesPlugin','Jeremiah'), + u'Lam': translate('BiblesPlugin','Lamentations'), + u'Ezek': translate('BiblesPlugin','Ezekiel'), + u'Dan': translate('BiblesPlugin','Daniel'), + u'Hos': translate('BiblesPlugin','Hosea'), + u'Joel': translate('BiblesPlugin','Joel'), + u'Amos': translate('BiblesPlugin','Amos'), + u'Obad': translate('BiblesPlugin','Obadiah'), + u'Jonah': translate('BiblesPlugin','Jonah'), + u'Mic': translate('BiblesPlugin','Micah'), + u'Nah': translate('BiblesPlugin','Nahum'), + u'Hab': translate('BiblesPlugin','Habakkuk'), + u'Zeph': translate('BiblesPlugin','Zephaniah'), + u'Hag': translate('BiblesPlugin','Haggai'), + u'Zech': translate('BiblesPlugin','Zechariah'), + u'Mal': translate('BiblesPlugin','Malachi'), + u'Matt': translate('BiblesPlugin','Matthew'), + u'Mark': translate('BiblesPlugin','Mark'), + u'Luke': translate('BiblesPlugin','Luke'), + u'John': translate('BiblesPlugin','John'), + u'Acts': translate('BiblesPlugin','Acts'), + u'Rom': translate('BiblesPlugin','Romans'), + u'1Cor': translate('BiblesPlugin','1 Corinthians'), + u'2Cor': translate('BiblesPlugin','2 Corinthians'), + u'Gal': translate('BiblesPlugin','Galatians'), + u'Eph': translate('BiblesPlugin','Ephesians'), + u'Phil': translate('BiblesPlugin','Philippians'), + u'Col': translate('BiblesPlugin','Colossians'), + u'1Thess': translate('BiblesPlugin','1 Thessalonians'), + u'2Thess': translate('BiblesPlugin','2 Thessalonians'), + u'1Tim': translate('BiblesPlugin','1 Timothy'), + u'2Tim': translate('BiblesPlugin','2 Timothy'), + u'Titus': translate('BiblesPlugin','Titus'), + u'Phlm': translate('BiblesPlugin','Philemon'), + u'Heb': translate('BiblesPlugin','Hebrews'), + u'Jas': translate('BiblesPlugin','James'), + u'1Pet': translate('BiblesPlugin','1 Peter'), + u'2Pet': translate('BiblesPlugin','2 Peter'), + u'1John': translate('BiblesPlugin','1 John'), + u'2John': translate('BiblesPlugin','2 John'), + u'3John': translate('BiblesPlugin','3 John'), + u'Jude': translate('BiblesPlugin','Jude'), + u'Rev': translate('BiblesPlugin','Revelation'), + u'Jdt': translate('BiblesPlugin','Judith'), + u'Wis': translate('BiblesPlugin','Wisdom'), + u'Tob': translate('BiblesPlugin','Tobit'), + u'Sir': translate('BiblesPlugin','Sirach'), + u'Bar': translate('BiblesPlugin','Baruch'), + u'1Macc': translate('BiblesPlugin','1 Maccabees'), + u'2Macc': translate('BiblesPlugin','2 Maccabees'), + u'3Macc': translate('BiblesPlugin','3 Maccabees'), + u'4Macc': translate('BiblesPlugin','4 Maccabees'), + u'AddDan': translate('BiblesPlugin','Rest of Daniel'), + u'AddEsth': translate('BiblesPlugin','Rest of Esther'), + u'PrMan': translate('BiblesPlugin','Prayer of Manasses'), + u'LetJer': translate('BiblesPlugin','Letter of Jeremiah'), + u'PrAza': translate('BiblesPlugin','Prayer of Azariah'), + u'Sus': translate('BiblesPlugin','Susanna'), + u'Bel': translate('BiblesPlugin','Bel'), + u'1Esdr': translate('BiblesPlugin','1 Esdras'), + u'2Esdr': translate('BiblesPlugin','2 Esdras') + } def update_reference_separators(): """ @@ -146,7 +235,7 @@ def get_reference_match(match_type): update_reference_separators() return REFERENCE_MATCHES[match_type] -def parse_reference(reference): +def parse_reference(reference, bible, language_selection, book_ref_id=False): """ This is the next generation über-awesome function that takes a person's typed in string and converts it to a list of references to be queried from @@ -154,6 +243,16 @@ def parse_reference(reference): ``reference`` A string. The Bible reference to parse. + + ``bible`` + A object. The Bible database object. + + ``language_selection`` + An int. The language selection the user has choosen in settings + section. + + ``book_ref_id`` + A string. The book reference id. Returns ``None`` or a reference list. @@ -239,6 +338,46 @@ def parse_reference(reference): if match: log.debug(u'Matched reference %s' % reference) book = match.group(u'book') + if not book_ref_id: + booknames = LanguageSelection.Booknames + regex_book = re.compile(u'^[1-4]?[\. ]{0,2}%s' % book.lower(), + re.UNICODE) + if language_selection == LanguageSelection.Bible: + db_book = bible.get_book(book) + if db_book: + book_ref_id = db_book.book_reference_id + elif language_selection == LanguageSelection.Application: + book_list = [] + for k, v in booknames.iteritems(): + if regex_book.search(unicode(v).lower()): + book_list.append(k) + books = [] + if book_list: + for v in book_list: + value = BiblesResourcesDB.get_book(v) + if value: + books.append(value) + if books: + for v in books: + if bible.get_book_by_book_ref_id(v[u'id']): + book_ref_id = v[u'id'] + break + elif language_selection == LanguageSelection.English: + books = BiblesResourcesDB.get_books_like(book) + if books: + book_list = [] + for v in books: + if regex_book.search(v[u'name'].lower()): + book_list.append(v) + if not book_list: + book_list = books + for v in book_list: + if bible.get_book_by_book_ref_id(v[u'id']): + book_ref_id = v[u'id'] + break + else: + if not bible.get_book_by_book_ref_id(book_ref_id): + book_ref_id = False ranges = match.group(u'ranges') range_list = get_reference_match(u'range_separator').split(ranges) ref_list = [] @@ -284,16 +423,18 @@ def parse_reference(reference): if not to_verse: to_verse = -1 if to_chapter > from_chapter: - ref_list.append((book, from_chapter, from_verse, -1)) + ref_list.append((book_ref_id, from_chapter, from_verse, -1)) for i in range(from_chapter + 1, to_chapter): - ref_list.append((book, i, 1, -1)) - ref_list.append((book, to_chapter, 1, to_verse)) + ref_list.append((book_ref_id, i, 1, -1)) + ref_list.append((book_ref_id, to_chapter, 1, to_verse)) elif to_verse >= from_verse or to_verse == -1: - ref_list.append((book, from_chapter, from_verse, to_verse)) + ref_list.append((book_ref_id, from_chapter, + from_verse, to_verse)) elif from_verse: - ref_list.append((book, from_chapter, from_verse, from_verse)) + ref_list.append((book_ref_id, from_chapter, + from_verse, from_verse)) else: - ref_list.append((book, from_chapter, 1, -1)) + ref_list.append((book_ref_id, from_chapter, 1, -1)) return ref_list else: log.debug(u'Invalid reference: %s' % reference) diff --git a/openlp/plugins/bibles/lib/db.py b/openlp/plugins/bibles/lib/db.py index 5f3b7a6c9..b419bebc0 100644 --- a/openlp/plugins/bibles/lib/db.py +++ b/openlp/plugins/bibles/lib/db.py @@ -435,19 +435,19 @@ class BibleDB(QtCore.QObject, Manager): else: return count - def get_verse_count(self, book_id, chapter): + def get_verse_count(self, book_ref_id, chapter): """ Return the number of verses in a chapter. - ``book`` - The book containing the chapter. + ``book_ref_id`` + The book reference id. ``chapter`` The chapter to get the verse count for. """ - log.debug(u'BibleDB.get_verse_count("%s", "%s")', book_id, chapter) + log.debug(u'BibleDB.get_verse_count("%s", "%s")', book_ref_id, chapter) count = self.session.query(Verse).join(Book)\ - .filter(Book.book_reference_id==book_id)\ + .filter(Book.book_reference_id==book_ref_id)\ .filter(Verse.chapter==chapter)\ .count() if not count: @@ -595,6 +595,35 @@ class BiblesResourcesDB(QtCore.QObject, Manager): else: return None + @staticmethod + def get_books_like(string): + """ + Return the books which include string. + + ``string`` + The string to search for in the booknames or abbreviations. + """ + log.debug(u'BiblesResourcesDB.get_book_like("%s")', string) + if not isinstance(string, unicode): + name = unicode(string) + books = BiblesResourcesDB.run_sql(u'SELECT id, testament_id, name, ' + u'abbreviation, chapters FROM book_reference WHERE ' + u'LOWER(name) LIKE ? OR LOWER(abbreviation) LIKE ?', + (u'%'+string.lower()+u'%', u'%'+string.lower()+u'%')) + if books: + return [ + { + u'id': book[0], + u'testament_id': book[1], + u'name': unicode(book[2]), + u'abbreviation': unicode(book[3]), + u'chapters': book[4] + } + for book in books + ] + else: + return None + @staticmethod def get_book_by_id(id): """ @@ -621,23 +650,23 @@ class BiblesResourcesDB(QtCore.QObject, Manager): return None @staticmethod - def get_chapter(book_id, chapter): + def get_chapter(book_ref_id, chapter): """ Return the chapter details for a specific chapter of a book. - ``book_id`` + ``book_ref_id`` The id of a book. ``chapter`` The chapter number. """ - log.debug(u'BiblesResourcesDB.get_chapter("%s", "%s")', book_id, + log.debug(u'BiblesResourcesDB.get_chapter("%s", "%s")', book_ref_id, chapter) if not isinstance(chapter, int): chapter = int(chapter) chapters = BiblesResourcesDB.run_sql(u'SELECT id, book_reference_id, ' u'chapter, verse_count FROM chapters WHERE book_reference_id = ?', - (book_id,)) + (book_ref_id,)) try: return { u'id': chapters[chapter-1][0], @@ -649,21 +678,21 @@ class BiblesResourcesDB(QtCore.QObject, Manager): return None @staticmethod - def get_chapter_count(book_id): + def get_chapter_count(book_ref_id): """ Return the number of chapters in a book. - ``book_id`` + ``book_ref_id`` The id of the book. """ - log.debug(u'BiblesResourcesDB.get_chapter_count("%s")', book_id) - details = BiblesResourcesDB.get_book_by_id(book_id) + log.debug(u'BiblesResourcesDB.get_chapter_count("%s")', book_ref_id) + details = BiblesResourcesDB.get_book_by_id(book_ref_id) if details: return details[u'chapters'] return 0 @staticmethod - def get_verse_count(book_id, chapter): + def get_verse_count(book_ref_id, chapter): """ Return the number of verses in a chapter. @@ -673,9 +702,9 @@ class BiblesResourcesDB(QtCore.QObject, Manager): ``chapter`` The number of the chapter. """ - log.debug(u'BiblesResourcesDB.get_verse_count("%s", "%s")', book_id, + log.debug(u'BiblesResourcesDB.get_verse_count("%s", "%s")', book_ref_id, chapter) - details = BiblesResourcesDB.get_chapter(book_id, chapter) + details = BiblesResourcesDB.get_chapter(book_ref_id, chapter) if details: return details[u'verse_count'] return 0 diff --git a/openlp/plugins/bibles/lib/manager.py b/openlp/plugins/bibles/lib/manager.py index 411e25367..c9f564b2c 100644 --- a/openlp/plugins/bibles/lib/manager.py +++ b/openlp/plugins/bibles/lib/manager.py @@ -33,7 +33,8 @@ from PyQt4 import QtCore from openlp.core.lib import Receiver, SettingsManager, translate from openlp.core.lib.ui import critical_error_message_box from openlp.core.utils import AppLocation, delete_file -from openlp.plugins.bibles.lib import parse_reference, get_reference_separator +from openlp.plugins.bibles.lib import parse_reference, \ + get_reference_separator, LanguageSelection from openlp.plugins.bibles.lib.db import BibleDB, BibleMeta from csvbible import CSVBible from http import HTTPBible @@ -265,7 +266,16 @@ class BibleManager(object): book_ref_id = db_book.book_reference_id return self.db_cache[bible].get_verse_count(book_ref_id, chapter) - def get_verses(self, bible, versetext, firstbible=False, show_error=True): + def get_verse_count_by_book_ref_id(self, bible, book_ref_id, chapter): + """ + Returns all the number of verses for a given + book_ref_id and chapterMaxBibleBookVerses. + """ + log.debug(u'BibleManager.get_verse_count_by_book_ref_id("%s", "%s", ' + u'"%s")', bible, book_ref_id, chapter) + return self.db_cache[bible].get_verse_count(book_ref_id, chapter) + + def get_verses(self, bible, versetext, book_ref_id=False, show_error=True): """ Parses a scripture reference, fetches the verses from the Bible specified, and returns a list of ``Verse`` objects. @@ -283,6 +293,10 @@ class BibleManager(object): - Genesis 1:1-10,15-20 - Genesis 1:1-2:10 - Genesis 1:1-10,2:1-10 + + ``book_ref_id`` + Unicode. The book referece id from the book in versetext. + For second bible this is necessary. """ log.debug(u'BibleManager.get_verses("%s", "%s")', bible, versetext) if not bible: @@ -295,30 +309,12 @@ class BibleManager(object): 'Import Wizard to install one or more Bibles.') }) return None - reflist = parse_reference(versetext) + language_selection = QtCore.QSettings().value( + self.settingsSection + u'/bookname language', + QtCore.QVariant(0)).toInt()[0] + reflist = parse_reference(versetext, self.db_cache[bible], + language_selection, book_ref_id) if reflist: - new_reflist = [] - for item in reflist: - if item: - if firstbible: - db_book = self.db_cache[firstbible].get_book(item[0]) - db_book = self.db_cache[bible].get_book_by_book_ref_id( - db_book.book_reference_id) - else: - db_book = self.db_cache[bible].get_book(item[0]) - if db_book: - book_id = db_book.book_reference_id - log.debug(u'Book name corrected to "%s"', db_book.name) - new_reflist.append((book_id, item[1], item[2], - item[3])) - else: - log.debug(u'OpenLP failed to find book %s', item[0]) - critical_error_message_box( - translate('BiblesPlugin', 'No Book Found'), - translate('BiblesPlugin', 'No matching book ' - 'could be found in this Bible. Check that you have ' - 'spelled the name of the book correctly.')) - reflist = new_reflist return self.db_cache[bible].get_verses(reflist, show_error) else: if show_error: diff --git a/openlp/plugins/bibles/lib/mediaitem.py b/openlp/plugins/bibles/lib/mediaitem.py index 50872aef3..2025b4187 100644 --- a/openlp/plugins/bibles/lib/mediaitem.py +++ b/openlp/plugins/bibles/lib/mediaitem.py @@ -428,7 +428,8 @@ class BibleMediaItem(MediaManagerItem): first = True language_selection = QtCore.QSettings().value( self.settingsSection + u'/bookname language', - QtCore.QVariant(0)).toInt()[0] + QtCore.QVariant(0)).toInt()[0] + booknames = LanguageSelection.Booknames for book in book_data: row = self.advancedBookComboBox.count() if language_selection == LanguageSelection.Bible: @@ -436,10 +437,8 @@ class BibleMediaItem(MediaManagerItem): elif language_selection == LanguageSelection.Application: data = BiblesResourcesDB.get_book_by_id( book[u'book_reference_id']) - abbr = data[u'abbreviation'].replace(u'1', u'First').\ - replace(u'2', u'Second').replace(u'3', u'Third').\ - replace(u'4', u'Fourth') - self.advancedBookComboBox.addItem(getattr(BibleStrings, abbr)) + self.advancedBookComboBox.addItem( + booknames[data[u'abbreviation']]) elif language_selection == LanguageSelection.English: data = BiblesResourcesDB.get_book_by_id( book[u'book_reference_id']) @@ -456,7 +455,8 @@ class BibleMediaItem(MediaManagerItem): book_ref_id) book = self.plugin.manager.get_book_by_id(bible, book_ref_id) self.chapter_count = self.plugin.manager.get_chapter_count(bible, book) - verse_count = self.plugin.manager.get_verse_count(bible, book.name, 1) + verse_count = self.plugin.manager.get_verse_count_by_book_ref_id(bible, + book_ref_id, 1) if verse_count == 0: self.advancedSearchButton.setEnabled(False) critical_error_message_box( @@ -475,6 +475,7 @@ class BibleMediaItem(MediaManagerItem): completion depends on the bible. It is only updated when we are doing a reference search, otherwise the auto completion list is removed. """ + log.debug(u'updateAutoCompleter') # Save the current search type to the configuration. QtCore.QSettings().setValue(u'%s/last search type' % self.settingsSection, @@ -501,17 +502,15 @@ class BibleMediaItem(MediaManagerItem): book_data = book_data_temp language_selection = QtCore.QSettings().value( self.settingsSection + u'/bookname language', - QtCore.QVariant(0)).toInt()[0] + QtCore.QVariant(0)).toInt()[0] if language_selection == LanguageSelection.Bible: books = [book.name + u' ' for book in book_data] elif language_selection == LanguageSelection.Application: + booknames = LanguageSelection.Booknames for book in book_data: data = BiblesResourcesDB.get_book_by_id( book.book_reference_id) - abbr = data[u'abbreviation'].replace(u'1', u'First').\ - replace(u'2', u'Second').replace(u'3', u'Third').\ - replace(u'4', u'Fourth') - books.append(getattr(BibleStrings, abbr) + u' ') + books.append(data[u'name'] + u' ') elif language_selection == LanguageSelection.English: for book in book_data: data = BiblesResourcesDB.get_book_by_id( @@ -590,22 +589,24 @@ class BibleMediaItem(MediaManagerItem): chapter_to = int(self.advancedToChapter.currentText()) if chapter_from == chapter_to: bible = unicode(self.advancedVersionComboBox.currentText()) - book = unicode(self.advancedBookComboBox.currentText()) + book_ref_id = unicode(self.advancedBookComboBox.itemData( + int(self.advancedBookComboBox.currentIndex())).toString()) verse_from = int(self.advancedFromVerse.currentText()) - verse_count = self.plugin.manager.get_verse_count(bible, book, - chapter_to) + verse_count = self.plugin.manager.get_verse_count_by_book_ref_id( + bible, book_ref_id, chapter_to) self.adjustComboBox(verse_from, verse_count, self.advancedToVerse, True) def onAdvancedToChapter(self): bible = unicode(self.advancedVersionComboBox.currentText()) - book = unicode(self.advancedBookComboBox.currentText()) + book_ref_id = unicode(self.advancedBookComboBox.itemData( + int(self.advancedBookComboBox.currentIndex())).toString()) chapter_from = int(self.advancedFromChapter.currentText()) chapter_to = int(self.advancedToChapter.currentText()) verse_from = int(self.advancedFromVerse.currentText()) verse_to = int(self.advancedToVerse.currentText()) - verse_count = self.plugin.manager.get_verse_count(bible, book, - chapter_to) + verse_count = self.plugin.manager.get_verse_count_by_book_ref_id(bible, + book_ref_id, chapter_to) if chapter_from == chapter_to and verse_from > verse_to: self.adjustComboBox(verse_from, verse_count, self.advancedToVerse) else: @@ -613,11 +614,12 @@ class BibleMediaItem(MediaManagerItem): def onAdvancedFromChapter(self): bible = unicode(self.advancedVersionComboBox.currentText()) - book = unicode(self.advancedBookComboBox.currentText()) + book_ref_id = unicode(self.advancedBookComboBox.itemData( + int(self.advancedBookComboBox.currentIndex())).toString()) chapter_from = int(self.advancedFromChapter.currentText()) chapter_to = int(self.advancedToChapter.currentText()) - verse_count = self.plugin.manager.get_verse_count(bible, book, - chapter_from) + verse_count = self.plugin.manager.get_verse_count_by_book_ref_id(bible, + book_ref_id, chapter_from) self.adjustComboBox(1, verse_count, self.advancedFromVerse) if chapter_from > chapter_to: self.adjustComboBox(1, verse_count, self.advancedToVerse) @@ -666,6 +668,8 @@ class BibleMediaItem(MediaManagerItem): bible = unicode(self.advancedVersionComboBox.currentText()) second_bible = unicode(self.advancedSecondComboBox.currentText()) book = unicode(self.advancedBookComboBox.currentText()) + book_ref_id = unicode(self.advancedBookComboBox.itemData( + int(self.advancedBookComboBox.currentIndex())).toString()) chapter_from = self.advancedFromChapter.currentText() chapter_to = self.advancedToChapter.currentText() verse_from = self.advancedFromVerse.currentText() @@ -676,10 +680,11 @@ class BibleMediaItem(MediaManagerItem): range_separator + chapter_to + verse_separator + verse_to versetext = u'%s %s' % (book, verse_range) Receiver.send_message(u'cursor_busy') - self.search_results = self.plugin.manager.get_verses(bible, versetext) + self.search_results = self.plugin.manager.get_verses(bible, versetext, + book_ref_id) if second_bible: self.second_search_results = self.plugin.manager.get_verses( - second_bible, versetext, bible) + second_bible, versetext, book_ref_id) if not self.advancedLockButton.isChecked(): self.listView.clear() if self.listView.count() != 0: @@ -707,7 +712,8 @@ class BibleMediaItem(MediaManagerItem): self.search_results = self.plugin.manager.get_verses(bible, text) if second_bible and self.search_results: self.second_search_results = self.plugin.manager.get_verses( - second_bible, text, bible) + second_bible, text, + self.search_results[0].book.book_reference_id) else: # We are doing a 'Text Search'. Receiver.send_message(u'cursor_busy') @@ -1025,8 +1031,7 @@ class BibleMediaItem(MediaManagerItem): Search for some Bible verses (by reference). """ bible = unicode(self.quickVersionComboBox.currentText()) - search_results = self.plugin.manager.get_verses(bible, string, False, - False) + search_results = self.plugin.manager.get_verses(bible, string, False) if search_results: versetext = u' '.join([verse.text for verse in search_results]) return [[string, versetext]] From c850d4fecd73a2b2e82961fb444d8a90808bdb10 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Armin=20K=C3=B6hler?= Date: Sun, 4 Mar 2012 21:39:52 +0100 Subject: [PATCH 03/28] remove unnecessary code --- openlp/plugins/bibles/lib/mediaitem.py | 1 - openlp/plugins/bibles/lib/ui.py | 121 ------------------------- 2 files changed, 122 deletions(-) delete mode 100644 openlp/plugins/bibles/lib/ui.py diff --git a/openlp/plugins/bibles/lib/mediaitem.py b/openlp/plugins/bibles/lib/mediaitem.py index 2025b4187..c327d1da0 100644 --- a/openlp/plugins/bibles/lib/mediaitem.py +++ b/openlp/plugins/bibles/lib/mediaitem.py @@ -39,7 +39,6 @@ from openlp.core.lib.ui import UiStrings, add_widget_completer, \ from openlp.plugins.bibles.forms import BibleImportForm from openlp.plugins.bibles.lib import LayoutStyle, DisplayStyle, \ VerseReferenceList, get_reference_separator, LanguageSelection -from openlp.plugins.bibles.lib.ui import BibleStrings from openlp.plugins.bibles.lib.db import BiblesResourcesDB log = logging.getLogger(__name__) diff --git a/openlp/plugins/bibles/lib/ui.py b/openlp/plugins/bibles/lib/ui.py deleted file mode 100644 index ca9c35785..000000000 --- a/openlp/plugins/bibles/lib/ui.py +++ /dev/null @@ -1,121 +0,0 @@ -# -*- coding: utf-8 -*- -# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4 - -############################################################################### -# OpenLP - Open Source Lyrics Projection # -# --------------------------------------------------------------------------- # -# Copyright (c) Second008-2012 Raoul Snyman # -# Portions copyright (c) Second008-2012 Tim Bentley, Gerald Britton, Jonathan # -# Corwin, Michael Gorven, Scott Guerrieri, Matthias Hub, Meinert Jordan, # -# Armin Köhler, Joshua Miller, Stevan Pettit, Andreas Preikschat, Mattias # -# Põldaru, Christian Richter, Philip Ridout, Simon Scudder, Jeffrey Smith, # -# Maikel Stuivenberg, Martin Thompson, Jon Tibble, 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 Second 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:`openlp.plugins.bibles.lib.ui` module provides standard UI components -for the bibles plugin. -""" -from openlp.core.lib import translate - -class BibleStrings(object): - """ - Provide standard strings for use throughout the bibles plugin. - """ - # These strings should need a good reason to be retranslated elsewhere. - Gen = translate('OpenLP.Ui','Genesis') - Exod = translate('OpenLP.Ui','Exodus') - Lev = translate('OpenLP.Ui','Leviticus') - Num = translate('OpenLP.Ui','Numbers') - Deut = translate('OpenLP.Ui','Deuteronomy') - Josh = translate('OpenLP.Ui','Joshua') - Judg = translate('OpenLP.Ui','Judges') - Ruth = translate('OpenLP.Ui','Ruth') - FirstSam = translate('OpenLP.Ui','1 Samuel') - SecondSam = translate('OpenLP.Ui','2 Samuel') - FirstKgs = translate('OpenLP.Ui','1 Kings') - SecondKgs = translate('OpenLP.Ui','2 Kings') - FirstChr = translate('OpenLP.Ui','1 Chronicles') - SecondChr = translate('OpenLP.Ui','2 Chronicles') - Esra = translate('OpenLP.Ui','Ezra') - Neh = translate('OpenLP.Ui','Nehemiah') - Esth = translate('OpenLP.Ui','Esther') - Job = translate('OpenLP.Ui','Job') - Ps = translate('OpenLP.Ui','Psalms') - Prov = translate('OpenLP.Ui','Proverbs') - Eccl = translate('OpenLP.Ui','Ecclesiastes') - Song = translate('OpenLP.Ui','Song of Solomon') - Isa = translate('OpenLP.Ui','Isaiah') - Jer = translate('OpenLP.Ui','Jeremiah') - Lam = translate('OpenLP.Ui','Lamentations') - Ezek = translate('OpenLP.Ui','Ezekiel') - Dan = translate('OpenLP.Ui','Daniel') - Hos = translate('OpenLP.Ui','Hosea') - Joel = translate('OpenLP.Ui','Joel') - Amos= translate('OpenLP.Ui','Amos') - Obad = translate('OpenLP.Ui','Obadiah') - Jonah = translate('OpenLP.Ui','Jonah') - Mic = translate('OpenLP.Ui','Micah') - Nah = translate('OpenLP.Ui','Nahum') - Hab = translate('OpenLP.Ui','Habakkuk') - Zeph = translate('OpenLP.Ui','Zephaniah') - Hag = translate('OpenLP.Ui','Haggai') - Zech = translate('OpenLP.Ui','Zechariah') - Mal = translate('OpenLP.Ui','Malachi') - Matt = translate('OpenLP.Ui','Matthew') - Mark = translate('OpenLP.Ui','Mark') - Luke = translate('OpenLP.Ui','Luke') - John = translate('OpenLP.Ui','John') - Acts = translate('OpenLP.Ui','Acts') - Rom = translate('OpenLP.Ui','Romans') - FirstCor = translate('OpenLP.Ui','1 Corinthians') - SecondCor = translate('OpenLP.Ui','2 Corinthians') - Gal = translate('OpenLP.Ui','Galatians') - Eph = translate('OpenLP.Ui','Ephesians') - Phil = translate('OpenLP.Ui','Philippians') - Col = translate('OpenLP.Ui','Colossians') - FirstThess = translate('OpenLP.Ui','1 Thessalonians') - SecondThess = translate('OpenLP.Ui','2 Thessalonians') - FirstTim = translate('OpenLP.Ui','1 Timothy') - SecondTim = translate('OpenLP.Ui','2 Timothy') - Titus = translate('OpenLP.Ui','Titus') - Phlm = translate('OpenLP.Ui','Philemon') - Heb = translate('OpenLP.Ui','Hebrews') - Jas = translate('OpenLP.Ui','James') - FirstPet = translate('OpenLP.Ui','1 Peter') - SecondPet = translate('OpenLP.Ui','2 Peter') - FirstJohn = translate('OpenLP.Ui','1 John') - SecondJohn = translate('OpenLP.Ui','2 John') - ThirdJohn = translate('OpenLP.Ui','3 John') - Jude = translate('OpenLP.Ui','Jude') - Rev = translate('OpenLP.Ui','Revelation') - Jdt = translate('OpenLP.Ui','Judith') - Wis = translate('OpenLP.Ui','Wisdom') - Tob = translate('OpenLP.Ui','Tobit') - Sir = translate('OpenLP.Ui','Sirach') - Bar = translate('OpenLP.Ui','Baruch') - FirstMacc = translate('OpenLP.Ui','1 Maccabees') - SecondMacc = translate('OpenLP.Ui','2 Maccabees') - ThirdMacc = translate('OpenLP.Ui','3 Maccabees') - FourthMacc = translate('OpenLP.Ui','4 Maccabees') - AddDan = translate('OpenLP.Ui','Rest of Daniel') - AddEsth = translate('OpenLP.Ui','Rest of Esther') - PrMan = translate('OpenLP.Ui','Prayer of Manasses') - LetJer = translate('OpenLP.Ui','Letter of Jeremiah') - PrAza = translate('OpenLP.Ui','Prayer of Azariah') - Sus = translate('OpenLP.Ui','Susanna') - Bel = translate('OpenLP.Ui','Bel') - FirstEsdr = translate('OpenLP.Ui','1 Esdras') - SecondEsdr = translate('OpenLP.Ui','2 Esdras') From 5391301b9768051c7fd559b7ab6d5ab12c9d20dd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Armin=20K=C3=B6hler?= Date: Sun, 4 Mar 2012 22:50:32 +0100 Subject: [PATCH 04/28] change BibleStrings object --- openlp/plugins/bibles/lib/__init__.py | 197 ++++++++++++++----------- openlp/plugins/bibles/lib/mediaitem.py | 6 +- 2 files changed, 112 insertions(+), 91 deletions(-) diff --git a/openlp/plugins/bibles/lib/__init__.py b/openlp/plugins/bibles/lib/__init__.py index 51d7f483a..acbff1964 100644 --- a/openlp/plugins/bibles/lib/__init__.py +++ b/openlp/plugins/bibles/lib/__init__.py @@ -59,6 +59,7 @@ class DisplayStyle(object): Curly = 2 Square = 3 + class LanguageSelection(object): """ An enumeration for bible bookname language. @@ -67,93 +68,113 @@ class LanguageSelection(object): Bible = 0 Application = 1 English = 2 - - Booknames = { - u'Gen': translate('BiblesPlugin','Genesis'), - u'Exod': translate('BiblesPlugin','Exodus'), - u'Lev': translate('BiblesPlugin','Leviticus'), - u'Num': translate('BiblesPlugin','Numbers'), - u'Deut': translate('BiblesPlugin','Deuteronomy'), - u'Josh': translate('BiblesPlugin','Joshua'), - u'Judg': translate('BiblesPlugin','Judges'), - u'Ruth': translate('BiblesPlugin','Ruth'), - u'1Sam': translate('BiblesPlugin','1 Samuel'), - u'2Sam': translate('BiblesPlugin','2 Samuel'), - u'1Kgs': translate('BiblesPlugin','1 Kings'), - u'2Kgs': translate('BiblesPlugin','2 Kings'), - u'1Chr': translate('BiblesPlugin','1 Chronicles'), - u'2Chr': translate('BiblesPlugin','2 Chronicles'), - u'Esra': translate('BiblesPlugin','Ezra'), - u'Neh': translate('BiblesPlugin','Nehemiah'), - u'Esth': translate('BiblesPlugin','Esther'), - u'Job': translate('BiblesPlugin','Job'), - u'Ps': translate('BiblesPlugin','Psalms'), - u'Prov': translate('BiblesPlugin','Proverbs'), - u'Eccl': translate('BiblesPlugin','Ecclesiastes'), - u'Song': translate('BiblesPlugin','Song of Solomon'), - u'Isa': translate('BiblesPlugin','Isaiah'), - u'Jer': translate('BiblesPlugin','Jeremiah'), - u'Lam': translate('BiblesPlugin','Lamentations'), - u'Ezek': translate('BiblesPlugin','Ezekiel'), - u'Dan': translate('BiblesPlugin','Daniel'), - u'Hos': translate('BiblesPlugin','Hosea'), - u'Joel': translate('BiblesPlugin','Joel'), - u'Amos': translate('BiblesPlugin','Amos'), - u'Obad': translate('BiblesPlugin','Obadiah'), - u'Jonah': translate('BiblesPlugin','Jonah'), - u'Mic': translate('BiblesPlugin','Micah'), - u'Nah': translate('BiblesPlugin','Nahum'), - u'Hab': translate('BiblesPlugin','Habakkuk'), - u'Zeph': translate('BiblesPlugin','Zephaniah'), - u'Hag': translate('BiblesPlugin','Haggai'), - u'Zech': translate('BiblesPlugin','Zechariah'), - u'Mal': translate('BiblesPlugin','Malachi'), - u'Matt': translate('BiblesPlugin','Matthew'), - u'Mark': translate('BiblesPlugin','Mark'), - u'Luke': translate('BiblesPlugin','Luke'), - u'John': translate('BiblesPlugin','John'), - u'Acts': translate('BiblesPlugin','Acts'), - u'Rom': translate('BiblesPlugin','Romans'), - u'1Cor': translate('BiblesPlugin','1 Corinthians'), - u'2Cor': translate('BiblesPlugin','2 Corinthians'), - u'Gal': translate('BiblesPlugin','Galatians'), - u'Eph': translate('BiblesPlugin','Ephesians'), - u'Phil': translate('BiblesPlugin','Philippians'), - u'Col': translate('BiblesPlugin','Colossians'), - u'1Thess': translate('BiblesPlugin','1 Thessalonians'), - u'2Thess': translate('BiblesPlugin','2 Thessalonians'), - u'1Tim': translate('BiblesPlugin','1 Timothy'), - u'2Tim': translate('BiblesPlugin','2 Timothy'), - u'Titus': translate('BiblesPlugin','Titus'), - u'Phlm': translate('BiblesPlugin','Philemon'), - u'Heb': translate('BiblesPlugin','Hebrews'), - u'Jas': translate('BiblesPlugin','James'), - u'1Pet': translate('BiblesPlugin','1 Peter'), - u'2Pet': translate('BiblesPlugin','2 Peter'), - u'1John': translate('BiblesPlugin','1 John'), - u'2John': translate('BiblesPlugin','2 John'), - u'3John': translate('BiblesPlugin','3 John'), - u'Jude': translate('BiblesPlugin','Jude'), - u'Rev': translate('BiblesPlugin','Revelation'), - u'Jdt': translate('BiblesPlugin','Judith'), - u'Wis': translate('BiblesPlugin','Wisdom'), - u'Tob': translate('BiblesPlugin','Tobit'), - u'Sir': translate('BiblesPlugin','Sirach'), - u'Bar': translate('BiblesPlugin','Baruch'), - u'1Macc': translate('BiblesPlugin','1 Maccabees'), - u'2Macc': translate('BiblesPlugin','2 Maccabees'), - u'3Macc': translate('BiblesPlugin','3 Maccabees'), - u'4Macc': translate('BiblesPlugin','4 Maccabees'), - u'AddDan': translate('BiblesPlugin','Rest of Daniel'), - u'AddEsth': translate('BiblesPlugin','Rest of Esther'), - u'PrMan': translate('BiblesPlugin','Prayer of Manasses'), - u'LetJer': translate('BiblesPlugin','Letter of Jeremiah'), - u'PrAza': translate('BiblesPlugin','Prayer of Azariah'), - u'Sus': translate('BiblesPlugin','Susanna'), - u'Bel': translate('BiblesPlugin','Bel'), - u'1Esdr': translate('BiblesPlugin','1 Esdras'), - u'2Esdr': translate('BiblesPlugin','2 Esdras') - } + + +class BibleStrings(object): + """ + Provide standard strings for objects to use. + """ + __instance__ = None + + def __new__(cls): + """ + Override the default object creation method to return a single instance. + """ + if not cls.__instance__: + cls.__instance__ = object.__new__(cls) + return cls.__instance__ + + def __init__(self): + """ + These strings should need a good reason to be retranslated elsewhere. + """ + self.Booknames = { + u'Gen': translate('BiblesPlugin','Genesis'), + u'Exod': translate('BiblesPlugin','Exodus'), + u'Lev': translate('BiblesPlugin','Leviticus'), + u'Num': translate('BiblesPlugin','Numbers'), + u'Deut': translate('BiblesPlugin','Deuteronomy'), + u'Josh': translate('BiblesPlugin','Joshua'), + u'Judg': translate('BiblesPlugin','Judges'), + u'Ruth': translate('BiblesPlugin','Ruth'), + u'1Sam': translate('BiblesPlugin','1 Samuel'), + u'2Sam': translate('BiblesPlugin','2 Samuel'), + u'1Kgs': translate('BiblesPlugin','1 Kings'), + u'2Kgs': translate('BiblesPlugin','2 Kings'), + u'1Chr': translate('BiblesPlugin','1 Chronicles'), + u'2Chr': translate('BiblesPlugin','2 Chronicles'), + u'Esra': translate('BiblesPlugin','Ezra'), + u'Neh': translate('BiblesPlugin','Nehemiah'), + u'Esth': translate('BiblesPlugin','Esther'), + u'Job': translate('BiblesPlugin','Job'), + u'Ps': translate('BiblesPlugin','Psalms'), + u'Prov': translate('BiblesPlugin','Proverbs'), + u'Eccl': translate('BiblesPlugin','Ecclesiastes'), + u'Song': translate('BiblesPlugin','Song of Solomon'), + u'Isa': translate('BiblesPlugin','Isaiah'), + u'Jer': translate('BiblesPlugin','Jeremiah'), + u'Lam': translate('BiblesPlugin','Lamentations'), + u'Ezek': translate('BiblesPlugin','Ezekiel'), + u'Dan': translate('BiblesPlugin','Daniel'), + u'Hos': translate('BiblesPlugin','Hosea'), + u'Joel': translate('BiblesPlugin','Joel'), + u'Amos': translate('BiblesPlugin','Amos'), + u'Obad': translate('BiblesPlugin','Obadiah'), + u'Jonah': translate('BiblesPlugin','Jonah'), + u'Mic': translate('BiblesPlugin','Micah'), + u'Nah': translate('BiblesPlugin','Nahum'), + u'Hab': translate('BiblesPlugin','Habakkuk'), + u'Zeph': translate('BiblesPlugin','Zephaniah'), + u'Hag': translate('BiblesPlugin','Haggai'), + u'Zech': translate('BiblesPlugin','Zechariah'), + u'Mal': translate('BiblesPlugin','Malachi'), + u'Matt': translate('BiblesPlugin','Matthew'), + u'Mark': translate('BiblesPlugin','Mark'), + u'Luke': translate('BiblesPlugin','Luke'), + u'John': translate('BiblesPlugin','John'), + u'Acts': translate('BiblesPlugin','Acts'), + u'Rom': translate('BiblesPlugin','Romans'), + u'1Cor': translate('BiblesPlugin','1 Corinthians'), + u'2Cor': translate('BiblesPlugin','2 Corinthians'), + u'Gal': translate('BiblesPlugin','Galatians'), + u'Eph': translate('BiblesPlugin','Ephesians'), + u'Phil': translate('BiblesPlugin','Philippians'), + u'Col': translate('BiblesPlugin','Colossians'), + u'1Thess': translate('BiblesPlugin','1 Thessalonians'), + u'2Thess': translate('BiblesPlugin','2 Thessalonians'), + u'1Tim': translate('BiblesPlugin','1 Timothy'), + u'2Tim': translate('BiblesPlugin','2 Timothy'), + u'Titus': translate('BiblesPlugin','Titus'), + u'Phlm': translate('BiblesPlugin','Philemon'), + u'Heb': translate('BiblesPlugin','Hebrews'), + u'Jas': translate('BiblesPlugin','James'), + u'1Pet': translate('BiblesPlugin','1 Peter'), + u'2Pet': translate('BiblesPlugin','2 Peter'), + u'1John': translate('BiblesPlugin','1 John'), + u'2John': translate('BiblesPlugin','2 John'), + u'3John': translate('BiblesPlugin','3 John'), + u'Jude': translate('BiblesPlugin','Jude'), + u'Rev': translate('BiblesPlugin','Revelation'), + u'Jdt': translate('BiblesPlugin','Judith'), + u'Wis': translate('BiblesPlugin','Wisdom'), + u'Tob': translate('BiblesPlugin','Tobit'), + u'Sir': translate('BiblesPlugin','Sirach'), + u'Bar': translate('BiblesPlugin','Baruch'), + u'1Macc': translate('BiblesPlugin','1 Maccabees'), + u'2Macc': translate('BiblesPlugin','2 Maccabees'), + u'3Macc': translate('BiblesPlugin','3 Maccabees'), + u'4Macc': translate('BiblesPlugin','4 Maccabees'), + u'AddDan': translate('BiblesPlugin','Rest of Daniel'), + u'AddEsth': translate('BiblesPlugin','Rest of Esther'), + u'PrMan': translate('BiblesPlugin','Prayer of Manasses'), + u'LetJer': translate('BiblesPlugin','Letter of Jeremiah'), + u'PrAza': translate('BiblesPlugin','Prayer of Azariah'), + u'Sus': translate('BiblesPlugin','Susanna'), + u'Bel': translate('BiblesPlugin','Bel'), + u'1Esdr': translate('BiblesPlugin','1 Esdras'), + u'2Esdr': translate('BiblesPlugin','2 Esdras') + } + def update_reference_separators(): """ @@ -339,7 +360,7 @@ def parse_reference(reference, bible, language_selection, book_ref_id=False): log.debug(u'Matched reference %s' % reference) book = match.group(u'book') if not book_ref_id: - booknames = LanguageSelection.Booknames + booknames = BibleStrings().Booknames regex_book = re.compile(u'^[1-4]?[\. ]{0,2}%s' % book.lower(), re.UNICODE) if language_selection == LanguageSelection.Bible: diff --git a/openlp/plugins/bibles/lib/mediaitem.py b/openlp/plugins/bibles/lib/mediaitem.py index c327d1da0..976ff6106 100644 --- a/openlp/plugins/bibles/lib/mediaitem.py +++ b/openlp/plugins/bibles/lib/mediaitem.py @@ -38,7 +38,7 @@ from openlp.core.lib.ui import UiStrings, add_widget_completer, \ find_and_set_in_combo_box, build_icon from openlp.plugins.bibles.forms import BibleImportForm from openlp.plugins.bibles.lib import LayoutStyle, DisplayStyle, \ - VerseReferenceList, get_reference_separator, LanguageSelection + VerseReferenceList, get_reference_separator, LanguageSelection, BibleStrings from openlp.plugins.bibles.lib.db import BiblesResourcesDB log = logging.getLogger(__name__) @@ -428,7 +428,7 @@ class BibleMediaItem(MediaManagerItem): language_selection = QtCore.QSettings().value( self.settingsSection + u'/bookname language', QtCore.QVariant(0)).toInt()[0] - booknames = LanguageSelection.Booknames + booknames = BibleStrings().Booknames for book in book_data: row = self.advancedBookComboBox.count() if language_selection == LanguageSelection.Bible: @@ -505,7 +505,7 @@ class BibleMediaItem(MediaManagerItem): if language_selection == LanguageSelection.Bible: books = [book.name + u' ' for book in book_data] elif language_selection == LanguageSelection.Application: - booknames = LanguageSelection.Booknames + booknames = BibleStrings().Booknames for book in book_data: data = BiblesResourcesDB.get_book_by_id( book.book_reference_id) From 5823bfbed54d015f30519a14129827bbeda184ee Mon Sep 17 00:00:00 2001 From: Raoul Snyman Date: Mon, 5 Mar 2012 21:45:32 +0200 Subject: [PATCH 05/28] Added label to warn of missing verses. --- openlp/plugins/songs/forms/editsongdialog.py | 18 ++++++++++--- openlp/plugins/songs/forms/editsongform.py | 28 +++++++++++--------- 2 files changed, 31 insertions(+), 15 deletions(-) diff --git a/openlp/plugins/songs/forms/editsongdialog.py b/openlp/plugins/songs/forms/editsongdialog.py index b1f8e4c6a..747541952 100644 --- a/openlp/plugins/songs/forms/editsongdialog.py +++ b/openlp/plugins/songs/forms/editsongdialog.py @@ -280,8 +280,15 @@ class Ui_EditSongDialog(object): self.songTabWidget.addTab(self.audioTab, u'') # Last few bits self.dialogLayout.addWidget(self.songTabWidget) + self.bottomLayout = QtGui.QHBoxLayout() + self.bottomLayout.setObjectName(u'bottomLayout') + self.warningLabel = QtGui.QLabel(editSongDialog) + self.warningLabel.setObjectName(u'warningLabel') + self.warningLabel.setVisible(False) + self.bottomLayout.addWidget(self.warningLabel) self.buttonBox = create_accept_reject_button_box(editSongDialog) - self.dialogLayout.addWidget(self.buttonBox) + self.bottomLayout.addWidget(self.buttonBox) + self.dialogLayout.addLayout(self.bottomLayout) self.retranslateUi(editSongDialog) QtCore.QMetaObject.connectSlotsByName(editSongDialog) @@ -349,14 +356,19 @@ class Ui_EditSongDialog(object): translate('SongsPlugin.EditSongForm', '&Remove')) self.audioRemoveAllButton.setText( translate('SongsPlugin.EditSongForm', 'Remove &All')) + self.warningLabel.setText( + translate('SongsPlugin.EditSongForm', 'Warning:' + ' Not all of the verses are in use.')) def editSongDialogComboBox(parent, name): """ Utility method to generate a standard combo box for this dialog. """ comboBox = QtGui.QComboBox(parent) - comboBox.setSizeAdjustPolicy(QtGui.QComboBox.AdjustToMinimumContentsLength) - comboBox.setSizePolicy(QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Fixed) + comboBox.setSizeAdjustPolicy( + QtGui.QComboBox.AdjustToMinimumContentsLength) + comboBox.setSizePolicy( + QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Fixed) comboBox.setEditable(True) comboBox.setInsertPolicy(QtGui.QComboBox.NoInsert) comboBox.setObjectName(name) diff --git a/openlp/plugins/songs/forms/editsongform.py b/openlp/plugins/songs/forms/editsongform.py index 62a76851c..2bcbc3811 100644 --- a/openlp/plugins/songs/forms/editsongform.py +++ b/openlp/plugins/songs/forms/editsongform.py @@ -641,19 +641,23 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog): 'corresponding to %s. Valid entries are %s.')) % \ (order_names[count], valid)) return False + verses_not_used = [] for count, verse in enumerate(verses): - if verse not in order: - self.songTabWidget.setCurrentIndex(0) - self.verseOrderEdit.setFocus() - answer = QtGui.QMessageBox.warning(self, - translate('SongsPlugin.EditSongForm', 'Warning'), - unicode(translate('SongsPlugin.EditSongForm', - 'You have not used %s anywhere in the verse ' - 'order. Are you sure you want to save the song ' - 'like this?')) % verse_names[count], - QtGui.QMessageBox.Yes | QtGui.QMessageBox.No) - if answer == QtGui.QMessageBox.No: - return False + if not verse in order: + verses_not_used.append(verse) + #self.songTabWidget.setCurrentIndex(0) + #self.verseOrderEdit.setFocus() + #answer = QtGui.QMessageBox.warning(self, + # translate('SongsPlugin.EditSongForm', 'Warning'), + # unicode(translate('SongsPlugin.EditSongForm', + # 'You have not used %s anywhere in the verse ' + # 'order. Are you sure you want to save the song ' + # 'like this?')) % verse_names[count], + # QtGui.QMessageBox.Yes | QtGui.QMessageBox.No) + #if answer == QtGui.QMessageBox.No: + # return False + if len(verses_in_use) < len(verses): + self.warningLabel.setVisible(True) item = int(self.songBookComboBox.currentIndex()) text = unicode(self.songBookComboBox.currentText()) if self.songBookComboBox.findText(text, QtCore.Qt.MatchExactly) < 0: From 619251193efe74ee47046508eeb8ff032a61e077 Mon Sep 17 00:00:00 2001 From: Raoul Snyman Date: Mon, 5 Mar 2012 21:45:57 +0200 Subject: [PATCH 06/28] Updated ignore --- .bzrignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.bzrignore b/.bzrignore index 1d2bb8267..080f03088 100644 --- a/.bzrignore +++ b/.bzrignore @@ -21,3 +21,4 @@ openlp/core/resources.py.old *.qm resources/windows/warnOpenLP.txt openlp.cfg +.idea From 8e54dcb1ee0ceefe2710ae2acafcd5047892050c Mon Sep 17 00:00:00 2001 From: Raoul Snyman Date: Mon, 5 Mar 2012 22:34:23 +0200 Subject: [PATCH 07/28] The message appears when your verse list is incomplete, and disappears when it is complete. --- openlp/plugins/songs/forms/editsongform.py | 109 +++++++++++---------- 1 file changed, 55 insertions(+), 54 deletions(-) diff --git a/openlp/plugins/songs/forms/editsongform.py b/openlp/plugins/songs/forms/editsongform.py index 2bcbc3811..94d8f60f1 100644 --- a/openlp/plugins/songs/forms/editsongform.py +++ b/openlp/plugins/songs/forms/editsongform.py @@ -92,6 +92,9 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog): QtCore.QObject.connect(self.verseListWidget, QtCore.SIGNAL(u'itemClicked(QTableWidgetItem*)'), self.onVerseListViewPressed) + QtCore.QObject.connect(self.verseOrderEdit, + QtCore.SIGNAL(u'textChanged(QString)'), + self.onVerseOrderTextChanged) QtCore.QObject.connect(self.themeAddButton, QtCore.SIGNAL(u'clicked()'), self.mediaitem.plugin.renderer.themeManager.onAddTheme) @@ -574,6 +577,54 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog): self.verseEditButton.setEnabled(False) self.verseDeleteButton.setEnabled(False) + def onVerseOrderTextChanged(self, text): + self._validate_verse_list(text, self.verseListWidget.rowCount()) + + def _validate_verse_list(self, verse_list, verse_count): + errors = [] + order = [] + order_names = unicode(verse_list).split() + for item in order_names: + if len(item) == 1: + verse_index = VerseType.from_translated_tag(item, None) + if verse_index is not None: + order.append(VerseType.Tags[verse_index] + u'1') + else: + # it matches no verses anyway + order.append(u'') + else: + verse_index = VerseType.from_translated_tag(item[0], None) + if verse_index is None: + # it matches no verses anyway + order.append(u'') + else: + verse_tag = VerseType.Tags[verse_index] + verse_num = item[1:].lower() + order.append(verse_tag + verse_num) + verses = [] + verse_names = [] + for index in range(0, verse_count): + verse = self.verseListWidget.item(index, 0) + verse = unicode(verse.data(QtCore.Qt.UserRole).toString()) + if verse not in verse_names: + verses.append(verse) + verse_names.append(u'%s%s' % ( + VerseType.translated_tag(verse[0]), verse[1:])) + for count, item in enumerate(order): + if item not in verses: + valid = create_separated_list(verse_names) + errors.append(unicode(translate('SongsPlugin.EditSongForm', + 'The verse order is invalid. There is no verse ' + 'corresponding to %s. Valid entries are %s.')) % \ + (order_names[count], valid)) + return False + verses_not_used = [] + for count, verse in enumerate(verses): + if not verse in order: + verses_not_used.append(verse) + self.warningLabel.setVisible(len(verses_not_used) > 0) + return errors + def _validate_song(self): """ Check the validity of the song. @@ -604,60 +655,10 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog): 'You need to have an author for this song.')) return False if self.verseOrderEdit.text(): - order = [] - order_names = unicode(self.verseOrderEdit.text()).split() - for item in order_names: - if len(item) == 1: - verse_index = VerseType.from_translated_tag(item, None) - if verse_index is not None: - order.append(VerseType.Tags[verse_index] + u'1') - else: - # it matches no verses anyway - order.append(u'') - else: - verse_index = VerseType.from_translated_tag(item[0], None) - if verse_index is None: - # it matches no verses anyway - order.append(u'') - else: - verse_tag = VerseType.Tags[verse_index] - verse_num = item[1:].lower() - order.append(verse_tag + verse_num) - verses = [] - verse_names = [] - for index in range(0, self.verseListWidget.rowCount()): - verse = self.verseListWidget.item(index, 0) - verse = unicode(verse.data(QtCore.Qt.UserRole).toString()) - if verse not in verse_names: - verses.append(verse) - verse_names.append(u'%s%s' % ( - VerseType.translated_tag(verse[0]), verse[1:])) - for count, item in enumerate(order): - if item not in verses: - valid = create_separated_list(verse_names) - critical_error_message_box( - 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)) - return False - verses_not_used = [] - for count, verse in enumerate(verses): - if not verse in order: - verses_not_used.append(verse) - #self.songTabWidget.setCurrentIndex(0) - #self.verseOrderEdit.setFocus() - #answer = QtGui.QMessageBox.warning(self, - # translate('SongsPlugin.EditSongForm', 'Warning'), - # unicode(translate('SongsPlugin.EditSongForm', - # 'You have not used %s anywhere in the verse ' - # 'order. Are you sure you want to save the song ' - # 'like this?')) % verse_names[count], - # QtGui.QMessageBox.Yes | QtGui.QMessageBox.No) - #if answer == QtGui.QMessageBox.No: - # return False - if len(verses_in_use) < len(verses): - self.warningLabel.setVisible(True) + errors = self._validate_verse_list(self.verseOrderEdit.text(), + self.verseListWidget.rowCount()) + if errors: + critical_error_message_box(message=u'\n\n'.join(errors)) item = int(self.songBookComboBox.currentIndex()) text = unicode(self.songBookComboBox.currentText()) if self.songBookComboBox.findText(text, QtCore.Qt.MatchExactly) < 0: From 1600e002cb464a1bea429ca3965c81481d0b0495 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mattias=20P=C3=B5ldaru?= Date: Mon, 5 Mar 2012 23:09:31 +0200 Subject: [PATCH 08/28] Make media backend names translatable. Fixes: https://launchpad.net/bugs/903683 --- openlp/core/ui/media/phononplayer.py | 3 ++- openlp/core/ui/media/vlcplayer.py | 3 ++- openlp/core/ui/media/webkitplayer.py | 2 ++ openlp/plugins/media/lib/mediatab.py | 15 ++++++++------- 4 files changed, 14 insertions(+), 9 deletions(-) diff --git a/openlp/core/ui/media/phononplayer.py b/openlp/core/ui/media/phononplayer.py index 5a9a5f67d..5ba17f72a 100644 --- a/openlp/core/ui/media/phononplayer.py +++ b/openlp/core/ui/media/phononplayer.py @@ -31,7 +31,7 @@ from datetime import datetime from PyQt4.phonon import Phonon -from openlp.core.lib import Receiver +from openlp.core.lib import Receiver, Translate from openlp.core.lib.mediaplayer import MediaPlayer from openlp.core.ui.media import MediaState @@ -63,6 +63,7 @@ class PhononPlayer(MediaPlayer): def __init__(self, parent): MediaPlayer.__init__(self, parent, u'phonon') + self.display_name = translate('MediaPlugin.MediaTab', 'Phonon') self.parent = parent self.additional_extensions = ADDITIONAL_EXT mimetypes.init() diff --git a/openlp/core/ui/media/vlcplayer.py b/openlp/core/ui/media/vlcplayer.py index 2adf0a2d1..6b404cfde 100644 --- a/openlp/core/ui/media/vlcplayer.py +++ b/openlp/core/ui/media/vlcplayer.py @@ -43,7 +43,7 @@ except OSError, e: raise from PyQt4 import QtCore, QtGui -from openlp.core.lib import Receiver +from openlp.core.lib import Receiver, translate from openlp.core.lib.mediaplayer import MediaPlayer from openlp.core.ui.media import MediaState @@ -89,6 +89,7 @@ class VlcPlayer(MediaPlayer): def __init__(self, parent): MediaPlayer.__init__(self, parent, u'vlc') + self.display_name = translate('MediaPlugin.MediaTab', 'VLC') self.parent = parent self.canFolder = True self.audio_extensions_list = AUDIO_EXT diff --git a/openlp/core/ui/media/webkitplayer.py b/openlp/core/ui/media/webkitplayer.py index abb5355d0..7420b8bf1 100644 --- a/openlp/core/ui/media/webkitplayer.py +++ b/openlp/core/ui/media/webkitplayer.py @@ -27,6 +27,7 @@ import logging +from openlp.core.lib import translate from openlp.core.lib.mediaplayer import MediaPlayer from openlp.core.ui.media import MediaState @@ -260,6 +261,7 @@ class WebkitPlayer(MediaPlayer): def __init__(self, parent): MediaPlayer.__init__(self, parent, u'webkit') + self.display_name = translate('MediaPlugin.MediaTab', 'WebKit') self.parent = parent self.canBackground = True self.audio_extensions_list = AUDIO_EXT diff --git a/openlp/plugins/media/lib/mediatab.py b/openlp/plugins/media/lib/mediatab.py index aed6b96cc..4dbefbffd 100644 --- a/openlp/plugins/media/lib/mediatab.py +++ b/openlp/plugins/media/lib/mediatab.py @@ -117,11 +117,11 @@ class MediaTab(SettingsTab): player = self.mediaPlayers[key] checkbox = self.playerCheckBoxes[player.name] if player.available: - checkbox.setText(player.name) + checkbox.setText(player.display_name) else: checkbox.setText( unicode(translate('MediaPlugin.MediaTab', - '%s (unavailable)')) % player.name) + '%s (unavailable)')) % player.display_name) self.playerOrderGroupBox.setTitle( translate('MediaPlugin.MediaTab', 'Player Order')) self.orderingDownButton.setText( @@ -134,7 +134,10 @@ class MediaTab(SettingsTab): 'Allow media player to be overriden')) def onPlayerCheckBoxChanged(self, check_state): - player = self.sender().text() + display_name = self.sender().text() + for key in self.mediaPlayers: + if self.mediaPlayers[key].display_name == display_name: + player = key if check_state == QtCore.Qt.Checked: if player not in self.usedPlayers: self.usedPlayers.append(player) @@ -152,7 +155,8 @@ class MediaTab(SettingsTab): self.playerCheckBoxes[u'%s' % player].setEnabled(False) else: self.playerCheckBoxes[u'%s' % player].setEnabled(True) - self.playerOrderlistWidget.addItem(player) + self.playerOrderlistWidget.addItem( + self.mediaPlayers[unicode(player)].display_name) def onOrderingUpButtonPressed(self): currentRow = self.playerOrderlistWidget.currentRow() @@ -171,9 +175,6 @@ class MediaTab(SettingsTab): self.usedPlayers.move(currentRow, currentRow + 1) def load(self): - if self.savedUsedPlayers: - self.usedPlayers = self.savedUsedPlayers - self.savedUsedPlayers = None self.usedPlayers = QtCore.QSettings().value( self.settingsSection + u'/players', QtCore.QVariant(u'webkit')).toString().split(u',') From e0766fa0181fb89ab090bdf77952d1892af51777 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mattias=20P=C3=B5ldaru?= Date: Tue, 6 Mar 2012 20:42:59 +0200 Subject: [PATCH 09/28] Extended QCheckBox class to contan an extra data bit so we don't rely on translations to be different. --- openlp/plugins/media/lib/mediatab.py | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/openlp/plugins/media/lib/mediatab.py b/openlp/plugins/media/lib/mediatab.py index 4dbefbffd..2c5755593 100644 --- a/openlp/plugins/media/lib/mediatab.py +++ b/openlp/plugins/media/lib/mediatab.py @@ -30,6 +30,14 @@ from PyQt4 import QtCore, QtGui from openlp.core.lib import SettingsTab, translate, Receiver from openlp.core.lib.ui import UiStrings +class MediaQCheckBox(QtGui.QCheckBox): + """ + MediaQCheckBox adds an extra property, playerName to the QCheckBox class. + """ + def setPlayerName(self, name): + self.playerName = name + + class MediaTab(SettingsTab): """ MediaTab is the Media settings tab in the settings dialog. @@ -49,7 +57,7 @@ class MediaTab(SettingsTab): self.playerCheckBoxes = {} for key, player in self.mediaPlayers.iteritems(): player = self.mediaPlayers[key] - checkbox = QtGui.QCheckBox(self.mediaPlayerGroupBox) + checkbox = MediaQCheckBox(self.mediaPlayerGroupBox) checkbox.setEnabled(player.available) checkbox.setObjectName(player.name + u'CheckBox') self.playerCheckBoxes[player.name] = checkbox @@ -116,6 +124,7 @@ class MediaTab(SettingsTab): for key in self.mediaPlayers: player = self.mediaPlayers[key] checkbox = self.playerCheckBoxes[player.name] + checkbox.setPlayerName(key) if player.available: checkbox.setText(player.display_name) else: @@ -134,10 +143,7 @@ class MediaTab(SettingsTab): 'Allow media player to be overriden')) def onPlayerCheckBoxChanged(self, check_state): - display_name = self.sender().text() - for key in self.mediaPlayers: - if self.mediaPlayers[key].display_name == display_name: - player = key + player = self.sender().playerName if check_state == QtCore.Qt.Checked: if player not in self.usedPlayers: self.usedPlayers.append(player) From 17233f2d900d57344d7a1732a867615199be7d9c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mattias=20P=C3=B5ldaru?= Date: Tue, 6 Mar 2012 20:46:08 +0200 Subject: [PATCH 10/28] Use another alias for the same content. --- openlp/plugins/media/lib/mediatab.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openlp/plugins/media/lib/mediatab.py b/openlp/plugins/media/lib/mediatab.py index 2c5755593..41dc1ea40 100644 --- a/openlp/plugins/media/lib/mediatab.py +++ b/openlp/plugins/media/lib/mediatab.py @@ -124,7 +124,7 @@ class MediaTab(SettingsTab): for key in self.mediaPlayers: player = self.mediaPlayers[key] checkbox = self.playerCheckBoxes[player.name] - checkbox.setPlayerName(key) + checkbox.setPlayerName(player.name) if player.available: checkbox.setText(player.display_name) else: From 905fc6d91fc4b07dd50a3ea4c2159e07632ef5b3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Armin=20K=C3=B6hler?= Date: Wed, 7 Mar 2012 20:15:38 +0100 Subject: [PATCH 11/28] adapt regex and some variable names --- openlp/plugins/bibles/lib/__init__.py | 41 +++++++++++++++------------ 1 file changed, 23 insertions(+), 18 deletions(-) diff --git a/openlp/plugins/bibles/lib/__init__.py b/openlp/plugins/bibles/lib/__init__.py index acbff1964..987f7e79e 100644 --- a/openlp/plugins/bibles/lib/__init__.py +++ b/openlp/plugins/bibles/lib/__init__.py @@ -361,40 +361,45 @@ def parse_reference(reference, bible, language_selection, book_ref_id=False): book = match.group(u'book') if not book_ref_id: booknames = BibleStrings().Booknames - regex_book = re.compile(u'^[1-4]?[\. ]{0,2}%s' % book.lower(), - re.UNICODE) + # escape reserved characters + book_escaped = book + for character in u'\\.^$*+?{}[]()': + book_escaped = book_escaped.replace( + character, u'\\' + character) + regex_book = re.compile(u'\s*%s\s*' % u'\s*'.join( + book_escaped.split()), re.UNICODE | re.IGNORECASE) if language_selection == LanguageSelection.Bible: db_book = bible.get_book(book) if db_book: book_ref_id = db_book.book_reference_id elif language_selection == LanguageSelection.Application: book_list = [] - for k, v in booknames.iteritems(): - if regex_book.search(unicode(v).lower()): - book_list.append(k) + for key, value in booknames.iteritems(): + if regex_book.match(unicode(value)): + book_list.append(key) books = [] if book_list: - for v in book_list: - value = BiblesResourcesDB.get_book(v) - if value: - books.append(value) + for value in book_list: + item = BiblesResourcesDB.get_book(value) + if item: + books.append(item) if books: - for v in books: - if bible.get_book_by_book_ref_id(v[u'id']): - book_ref_id = v[u'id'] + for value in books: + if bible.get_book_by_book_ref_id(value[u'id']): + book_ref_id = value[u'id'] break elif language_selection == LanguageSelection.English: books = BiblesResourcesDB.get_books_like(book) if books: book_list = [] - for v in books: - if regex_book.search(v[u'name'].lower()): - book_list.append(v) + for value in books: + if regex_book.match(value[u'name']): + book_list.append(value) if not book_list: book_list = books - for v in book_list: - if bible.get_book_by_book_ref_id(v[u'id']): - book_ref_id = v[u'id'] + for value in book_list: + if bible.get_book_by_book_ref_id(value[u'id']): + book_ref_id = value[u'id'] break else: if not bible.get_book_by_book_ref_id(book_ref_id): From 5d8c2aae177114574dee65858f10eb9bde4f9a66 Mon Sep 17 00:00:00 2001 From: Philip Ridout Date: Wed, 7 Mar 2012 22:14:58 +0000 Subject: [PATCH 12/28] Fixes bug https://bugs.launchpad.net/openlp/+bug/883056 Adds radio buttons, and disables monitor selection when override display is on. --- openlp/core/ui/generaltab.py | 123 ++++++++++++++++++----------------- 1 file changed, 63 insertions(+), 60 deletions(-) diff --git a/openlp/core/ui/generaltab.py b/openlp/core/ui/generaltab.py index b1d44b3dd..56ff22609 100644 --- a/openlp/core/ui/generaltab.py +++ b/openlp/core/ui/generaltab.py @@ -53,20 +53,56 @@ class GeneralTab(SettingsTab): """ self.setObjectName(u'GeneralTab') SettingsTab.setupUi(self) + # Monitors self.monitorGroupBox = QtGui.QGroupBox(self.leftColumn) self.monitorGroupBox.setObjectName(u'monitorGroupBox') - self.monitorLayout = QtGui.QFormLayout(self.monitorGroupBox) + self.monitorLayout = QtGui.QGridLayout(self.monitorGroupBox) self.monitorLayout.setObjectName(u'monitorLayout') - self.monitorLabel = QtGui.QLabel(self.monitorGroupBox) - self.monitorLabel.setObjectName(u'monitorLabel') - self.monitorLayout.addRow(self.monitorLabel) + self.monitorRadioButton = QtGui.QRadioButton(self.monitorGroupBox) + self.monitorRadioButton.setObjectName(u'monitorRadioButton') + self.monitorLayout.addWidget(self.monitorRadioButton, 0, 0, 1, 5) self.monitorComboBox = QtGui.QComboBox(self.monitorGroupBox) self.monitorComboBox.setObjectName(u'monitorComboBox') - self.monitorLayout.addRow(self.monitorComboBox) + self.monitorLayout.addWidget(self.monitorComboBox, 1, 1, 1, 4) self.displayOnMonitorCheck = QtGui.QCheckBox(self.monitorGroupBox) self.displayOnMonitorCheck.setObjectName(u'monitorComboBox') - self.monitorLayout.addRow(self.displayOnMonitorCheck) + self.monitorLayout.addWidget(self.displayOnMonitorCheck, 2, 1, 1, 4) + # Display Position + self.overrideRadioButton = QtGui.QRadioButton(self.monitorGroupBox) + self.overrideRadioButton.setObjectName(u'overrideRadioButton') + self.monitorLayout.addWidget(self.overrideRadioButton, 3, 0, 1, 5) self.leftLayout.addWidget(self.monitorGroupBox) + # Custom position + self.customXLabel = QtGui.QLabel(self.monitorGroupBox) + self.customXLabel.setObjectName(u'customXLabel') + self.monitorLayout.addWidget(self.customXLabel, 4, 1) + self.customXValueEdit = QtGui.QSpinBox(self.monitorGroupBox) + self.customXValueEdit.setObjectName(u'customXValueEdit') + self.customXValueEdit.setRange(-9999, 9999) + self.monitorLayout.addWidget(self.customXValueEdit, 5, 1) + self.customYLabel = QtGui.QLabel(self.monitorGroupBox) + self.customYLabel.setObjectName(u'customYLabel') + self.monitorLayout.addWidget(self.customYLabel, 4, 2) + self.customYValueEdit = QtGui.QSpinBox(self.monitorGroupBox) + self.customYValueEdit.setObjectName(u'customYValueEdit') + self.customYValueEdit.setRange(-9999, 9999) + self.monitorLayout.addWidget(self.customYValueEdit, 5, 2) + self.customWidthLabel = QtGui.QLabel(self.monitorGroupBox) + self.customWidthLabel.setObjectName(u'customWidthLabel') + self.monitorLayout.addWidget(self.customWidthLabel, 4, 3) + self.customWidthValueEdit = QtGui.QSpinBox(self.monitorGroupBox) + self.customWidthValueEdit.setObjectName(u'customWidthValueEdit') + self.customWidthValueEdit.setMaximum(9999) + self.monitorLayout.addWidget(self.customWidthValueEdit, 5, 3) + self.customHeightLabel = QtGui.QLabel(self.monitorGroupBox) + self.customHeightLabel.setObjectName(u'customHeightLabel') + self.monitorLayout.addWidget(self.customHeightLabel, 4, 4) + self.customHeightValueEdit = QtGui.QSpinBox(self.monitorGroupBox) + self.customHeightValueEdit.setObjectName(u'customHeightValueEdit') + self.customHeightValueEdit.setMaximum(9999) + self.monitorLayout.addWidget(self.customHeightValueEdit, 5, 4) + self.leftLayout.addWidget(self.monitorGroupBox) + # Application Startup self.startupGroupBox = QtGui.QGroupBox(self.leftColumn) self.startupGroupBox.setObjectName(u'startupGroupBox') self.startupLayout = QtGui.QVBoxLayout(self.startupGroupBox) @@ -84,6 +120,7 @@ class GeneralTab(SettingsTab): self.checkForUpdatesCheckBox.setObjectName(u'checkForUpdatesCheckBox') self.startupLayout.addWidget(self.checkForUpdatesCheckBox) self.leftLayout.addWidget(self.startupGroupBox) + # Application Settings self.settingsGroupBox = QtGui.QGroupBox(self.leftColumn) self.settingsGroupBox.setObjectName(u'settingsGroupBox') self.settingsLayout = QtGui.QFormLayout(self.settingsGroupBox) @@ -106,6 +143,7 @@ class GeneralTab(SettingsTab): self.settingsLayout.addRow(self.timeoutLabel, self.timeoutSpinBox) self.leftLayout.addWidget(self.settingsGroupBox) self.leftLayout.addStretch() + # CCLI Details self.ccliGroupBox = QtGui.QGroupBox(self.rightColumn) self.ccliGroupBox.setObjectName(u'ccliGroupBox') self.ccliLayout = QtGui.QFormLayout(self.ccliGroupBox) @@ -128,45 +166,6 @@ class GeneralTab(SettingsTab): self.passwordEdit.setObjectName(u'passwordEdit') self.ccliLayout.addRow(self.passwordLabel, self.passwordEdit) self.rightLayout.addWidget(self.ccliGroupBox) - # Moved here from display tab - self.displayGroupBox = QtGui.QGroupBox(self.rightColumn) - self.displayGroupBox.setObjectName(u'displayGroupBox') - self.displayLayout = QtGui.QGridLayout(self.displayGroupBox) - self.displayLayout.setObjectName(u'displayLayout') - self.overrideCheckBox = QtGui.QCheckBox(self.displayGroupBox) - self.overrideCheckBox.setObjectName(u'overrideCheckBox') - self.displayLayout.addWidget(self.overrideCheckBox, 2, 0, 1, 4) - self.rightLayout.addWidget(self.displayGroupBox) - # Custom position - self.customXLabel = QtGui.QLabel(self.displayGroupBox) - self.customXLabel.setObjectName(u'customXLabel') - self.displayLayout.addWidget(self.customXLabel, 3, 0) - self.customXValueEdit = QtGui.QSpinBox(self.displayGroupBox) - self.customXValueEdit.setObjectName(u'customXValueEdit') - self.customXValueEdit.setRange(-9999, 9999) - self.displayLayout.addWidget(self.customXValueEdit, 4, 0) - self.customYLabel = QtGui.QLabel(self.displayGroupBox) - self.customYLabel.setObjectName(u'customYLabel') - self.displayLayout.addWidget(self.customYLabel, 3, 1) - self.customYValueEdit = QtGui.QSpinBox(self.displayGroupBox) - self.customYValueEdit.setObjectName(u'customYValueEdit') - self.customYValueEdit.setRange(-9999, 9999) - self.displayLayout.addWidget(self.customYValueEdit, 4, 1) - self.customWidthLabel = QtGui.QLabel(self.displayGroupBox) - self.customWidthLabel.setObjectName(u'customWidthLabel') - self.displayLayout.addWidget(self.customWidthLabel, 3, 2) - self.customWidthValueEdit = QtGui.QSpinBox(self.displayGroupBox) - self.customWidthValueEdit.setObjectName(u'customWidthValueEdit') - self.customWidthValueEdit.setMaximum(9999) - self.displayLayout.addWidget(self.customWidthValueEdit, 4, 2) - self.customHeightLabel = QtGui.QLabel(self.displayGroupBox) - self.customHeightLabel.setObjectName(u'customHeightLabel') - self.displayLayout.addWidget(self.customHeightLabel, 3, 3) - self.customHeightValueEdit = QtGui.QSpinBox(self.displayGroupBox) - self.customHeightValueEdit.setObjectName(u'customHeightValueEdit') - self.customHeightValueEdit.setMaximum(9999) - self.displayLayout.addWidget(self.customHeightValueEdit, 4, 3) - self.rightLayout.addWidget(self.displayGroupBox) # Background audio self.audioGroupBox = QtGui.QGroupBox(self.rightColumn) self.audioGroupBox.setObjectName(u'audioGroupBox') @@ -181,8 +180,8 @@ class GeneralTab(SettingsTab): self.rightLayout.addWidget(self.audioGroupBox) self.rightLayout.addStretch() # Signals and slots - QtCore.QObject.connect(self.overrideCheckBox, - QtCore.SIGNAL(u'toggled(bool)'), self.onOverrideCheckBoxToggled) + QtCore.QObject.connect(self.overrideRadioButton, + QtCore.SIGNAL(u'toggled(bool)'), self.onOverrideRadioButtonPressed) QtCore.QObject.connect(self.customHeightValueEdit, QtCore.SIGNAL(u'valueChanged(int)'), self.onDisplayChanged) QtCore.QObject.connect(self.customWidthValueEdit, @@ -209,7 +208,7 @@ class GeneralTab(SettingsTab): self.tabTitleVisible = translate('OpenLP.GeneralTab', 'General') self.monitorGroupBox.setTitle(translate('OpenLP.GeneralTab', 'Monitors')) - self.monitorLabel.setText(translate('OpenLP.GeneralTab', + self.monitorRadioButton.setText(translate('OpenLP.GeneralTab', 'Select monitor for output display:')) self.displayOnMonitorCheck.setText( translate('OpenLP.GeneralTab', 'Display if a single screen')) @@ -242,10 +241,8 @@ class GeneralTab(SettingsTab): self.passwordLabel.setText( translate('OpenLP.GeneralTab', 'SongSelect password:')) # Moved from display tab - self.displayGroupBox.setTitle( - translate('OpenLP.GeneralTab', 'Display Position')) - self.overrideCheckBox.setText(translate('OpenLP.GeneralTab', - 'Override display position')) + self.overrideRadioButton.setText(translate('OpenLP.GeneralTab', + 'Override display position:')) self.customXLabel.setText(translate('OpenLP.GeneralTab', 'X')) self.customYLabel.setText(translate('OpenLP.GeneralTab', 'Y')) self.customHeightLabel.setText(translate('OpenLP.GeneralTab', 'Height')) @@ -291,7 +288,9 @@ class GeneralTab(SettingsTab): QtCore.QVariant(False)).toBool()) self.timeoutSpinBox.setValue(settings.value(u'loop delay', QtCore.QVariant(5)).toInt()[0]) - self.overrideCheckBox.setChecked(settings.value(u'override position', + self.monitorRadioButton.setChecked(not settings.value(u'override position', + QtCore.QVariant(False)).toBool()) + self.overrideRadioButton.setChecked(settings.value(u'override position', QtCore.QVariant(False)).toBool()) self.customXValueEdit.setValue(settings.value(u'x position', QtCore.QVariant(self.screens.current[u'size'].x())).toInt()[0]) @@ -306,10 +305,12 @@ class GeneralTab(SettingsTab): self.repeatListCheckBox.setChecked(settings.value( u'audio repeat list', QtCore.QVariant(False)).toBool()) settings.endGroup() - self.customXValueEdit.setEnabled(self.overrideCheckBox.isChecked()) - self.customYValueEdit.setEnabled(self.overrideCheckBox.isChecked()) - self.customHeightValueEdit.setEnabled(self.overrideCheckBox.isChecked()) - self.customWidthValueEdit.setEnabled(self.overrideCheckBox.isChecked()) + self.monitorComboBox.setDisabled(self.overrideRadioButton.isChecked()) + self.displayOnMonitorCheck.setDisabled(self.overrideRadioButton.isChecked()) + self.customXValueEdit.setEnabled(self.overrideRadioButton.isChecked()) + self.customYValueEdit.setEnabled(self.overrideRadioButton.isChecked()) + self.customHeightValueEdit.setEnabled(self.overrideRadioButton.isChecked()) + self.customWidthValueEdit.setEnabled(self.overrideRadioButton.isChecked()) self.display_changed = False settings.beginGroup(self.settingsSection) @@ -354,7 +355,7 @@ class GeneralTab(SettingsTab): settings.setValue(u'width', QtCore.QVariant(self.customWidthValueEdit.value())) settings.setValue(u'override position', - QtCore.QVariant(self.overrideCheckBox.isChecked())) + QtCore.QVariant(self.overrideRadioButton.isChecked())) settings.setValue(u'audio start paused', QtCore.QVariant(self.startPausedCheckBox.isChecked())) settings.setValue(u'audio repeat list', @@ -380,7 +381,7 @@ class GeneralTab(SettingsTab): self.customYValueEdit.value(), self.customWidthValueEdit.value(), self.customHeightValueEdit.value()) - if self.overrideCheckBox.isChecked(): + if self.overrideRadioButton.isChecked(): self.screens.set_override_display() else: self.screens.reset_current_display() @@ -388,13 +389,15 @@ class GeneralTab(SettingsTab): Receiver.send_message(u'config_screen_changed') self.display_changed = False - def onOverrideCheckBoxToggled(self, checked): + def onOverrideRadioButtonPressed(self, checked): """ Toggle screen state depending on check box state. ``checked`` The state of the check box (boolean). """ + self.monitorComboBox.setDisabled(checked) + self.displayOnMonitorCheck.setDisabled(checked) self.customXValueEdit.setEnabled(checked) self.customYValueEdit.setEnabled(checked) self.customHeightValueEdit.setEnabled(checked) From 67cd90d5bfcb905c27fff1438f37f157c782fb5e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mattias=20P=C3=B5ldaru?= Date: Fri, 9 Mar 2012 08:09:19 +0200 Subject: [PATCH 13/28] Don't translate player names. Added some keyboard shortcuts. --- openlp/core/ui/media/phononplayer.py | 3 ++- openlp/core/ui/media/vlcplayer.py | 3 ++- openlp/core/ui/media/webkitplayer.py | 3 ++- openlp/plugins/media/lib/mediatab.py | 10 +++++----- 4 files changed, 11 insertions(+), 8 deletions(-) diff --git a/openlp/core/ui/media/phononplayer.py b/openlp/core/ui/media/phononplayer.py index 5ba17f72a..98cc598f7 100644 --- a/openlp/core/ui/media/phononplayer.py +++ b/openlp/core/ui/media/phononplayer.py @@ -63,7 +63,8 @@ class PhononPlayer(MediaPlayer): def __init__(self, parent): MediaPlayer.__init__(self, parent, u'phonon') - self.display_name = translate('MediaPlugin.MediaTab', 'Phonon') + self.original_name = u'Phonon' + self.display_name = u'&Phonon' self.parent = parent self.additional_extensions = ADDITIONAL_EXT mimetypes.init() diff --git a/openlp/core/ui/media/vlcplayer.py b/openlp/core/ui/media/vlcplayer.py index 6b404cfde..6bbcff2a5 100644 --- a/openlp/core/ui/media/vlcplayer.py +++ b/openlp/core/ui/media/vlcplayer.py @@ -89,7 +89,8 @@ class VlcPlayer(MediaPlayer): def __init__(self, parent): MediaPlayer.__init__(self, parent, u'vlc') - self.display_name = translate('MediaPlugin.MediaTab', 'VLC') + self.original_name = u'VLC' + self.display_name = u'&VLC' self.parent = parent self.canFolder = True self.audio_extensions_list = AUDIO_EXT diff --git a/openlp/core/ui/media/webkitplayer.py b/openlp/core/ui/media/webkitplayer.py index 7420b8bf1..86e96bf67 100644 --- a/openlp/core/ui/media/webkitplayer.py +++ b/openlp/core/ui/media/webkitplayer.py @@ -261,7 +261,8 @@ class WebkitPlayer(MediaPlayer): def __init__(self, parent): MediaPlayer.__init__(self, parent, u'webkit') - self.display_name = translate('MediaPlugin.MediaTab', 'WebKit') + self.original_name = u'WebKit' + self.display_name = u'&WebKit' self.parent = parent self.canBackground = True self.audio_extensions_list = AUDIO_EXT diff --git a/openlp/plugins/media/lib/mediatab.py b/openlp/plugins/media/lib/mediatab.py index 41dc1ea40..fe76dc4ce 100644 --- a/openlp/plugins/media/lib/mediatab.py +++ b/openlp/plugins/media/lib/mediatab.py @@ -132,15 +132,15 @@ class MediaTab(SettingsTab): unicode(translate('MediaPlugin.MediaTab', '%s (unavailable)')) % player.display_name) self.playerOrderGroupBox.setTitle( - translate('MediaPlugin.MediaTab', 'Player Order')) + translate('MediaPlugin.MediaTab', 'Player O&rder')) self.orderingDownButton.setText( - translate('MediaPlugin.MediaTab', 'Down')) + translate('MediaPlugin.MediaTab', '&Down')) self.orderingUpButton.setText( - translate('MediaPlugin.MediaTab', 'Up')) + translate('MediaPlugin.MediaTab', '&Up')) self.advancedGroupBox.setTitle(UiStrings().Advanced) self.overridePlayerCheckBox.setText( translate('MediaPlugin.MediaTab', - 'Allow media player to be overriden')) + '&Allow media player to be overriden')) def onPlayerCheckBoxChanged(self, check_state): player = self.sender().playerName @@ -162,7 +162,7 @@ class MediaTab(SettingsTab): else: self.playerCheckBoxes[u'%s' % player].setEnabled(True) self.playerOrderlistWidget.addItem( - self.mediaPlayers[unicode(player)].display_name) + self.mediaPlayers[unicode(player)].original_name) def onOrderingUpButtonPressed(self): currentRow = self.playerOrderlistWidget.currentRow() From 74db5acaa376860d9309fb6f57053e91ab9ec5ec Mon Sep 17 00:00:00 2001 From: Philip Ridout Date: Fri, 9 Mar 2012 21:41:13 +0000 Subject: [PATCH 14/28] Re-ordered group boxes as per Raouls request, and applied his radiobox code --- openlp/core/ui/generaltab.py | 98 +++++++++++++++++++----------------- 1 file changed, 52 insertions(+), 46 deletions(-) diff --git a/openlp/core/ui/generaltab.py b/openlp/core/ui/generaltab.py index 56ff22609..538c2a545 100644 --- a/openlp/core/ui/generaltab.py +++ b/openlp/core/ui/generaltab.py @@ -71,7 +71,6 @@ class GeneralTab(SettingsTab): self.overrideRadioButton = QtGui.QRadioButton(self.monitorGroupBox) self.overrideRadioButton.setObjectName(u'overrideRadioButton') self.monitorLayout.addWidget(self.overrideRadioButton, 3, 0, 1, 5) - self.leftLayout.addWidget(self.monitorGroupBox) # Custom position self.customXLabel = QtGui.QLabel(self.monitorGroupBox) self.customXLabel.setObjectName(u'customXLabel') @@ -101,50 +100,16 @@ class GeneralTab(SettingsTab): self.customHeightValueEdit.setObjectName(u'customHeightValueEdit') self.customHeightValueEdit.setMaximum(9999) self.monitorLayout.addWidget(self.customHeightValueEdit, 5, 4) + # Set up the stretchiness of each column, so that the first column + # less stretchy (and therefore smaller) than the others + self.monitorLayout.setColumnStretch(0, 1) + self.monitorLayout.setColumnStretch(1, 3) + self.monitorLayout.setColumnStretch(2, 3) + self.monitorLayout.setColumnStretch(3, 3) + self.monitorLayout.setColumnStretch(4, 3) self.leftLayout.addWidget(self.monitorGroupBox) - # Application Startup - self.startupGroupBox = QtGui.QGroupBox(self.leftColumn) - self.startupGroupBox.setObjectName(u'startupGroupBox') - self.startupLayout = QtGui.QVBoxLayout(self.startupGroupBox) - self.startupLayout.setObjectName(u'startupLayout') - self.warningCheckBox = QtGui.QCheckBox(self.startupGroupBox) - self.warningCheckBox.setObjectName(u'warningCheckBox') - self.startupLayout.addWidget(self.warningCheckBox) - self.autoOpenCheckBox = QtGui.QCheckBox(self.startupGroupBox) - self.autoOpenCheckBox.setObjectName(u'autoOpenCheckBox') - self.startupLayout.addWidget(self.autoOpenCheckBox) - self.showSplashCheckBox = QtGui.QCheckBox(self.startupGroupBox) - self.showSplashCheckBox.setObjectName(u'showSplashCheckBox') - self.startupLayout.addWidget(self.showSplashCheckBox) - self.checkForUpdatesCheckBox = QtGui.QCheckBox(self.startupGroupBox) - self.checkForUpdatesCheckBox.setObjectName(u'checkForUpdatesCheckBox') - self.startupLayout.addWidget(self.checkForUpdatesCheckBox) - self.leftLayout.addWidget(self.startupGroupBox) - # Application Settings - self.settingsGroupBox = QtGui.QGroupBox(self.leftColumn) - self.settingsGroupBox.setObjectName(u'settingsGroupBox') - self.settingsLayout = QtGui.QFormLayout(self.settingsGroupBox) - self.settingsLayout.setObjectName(u'settingsLayout') - self.saveCheckServiceCheckBox = QtGui.QCheckBox(self.settingsGroupBox) - self.saveCheckServiceCheckBox.setObjectName(u'saveCheckServiceCheckBox') - self.settingsLayout.addRow(self.saveCheckServiceCheckBox) - self.autoUnblankCheckBox = QtGui.QCheckBox(self.settingsGroupBox) - self.autoUnblankCheckBox.setObjectName(u'autoUnblankCheckBox') - self.settingsLayout.addRow(self.autoUnblankCheckBox) - self.autoPreviewCheckBox = QtGui.QCheckBox(self.settingsGroupBox) - self.autoPreviewCheckBox.setObjectName(u'autoPreviewCheckBox') - self.settingsLayout.addRow(self.autoPreviewCheckBox) - # Moved here from image tab - self.timeoutLabel = QtGui.QLabel(self.settingsGroupBox) - self.timeoutLabel.setObjectName(u'timeoutLabel') - self.timeoutSpinBox = QtGui.QSpinBox(self.settingsGroupBox) - self.timeoutSpinBox.setObjectName(u'timeoutSpinBox') - self.timeoutSpinBox.setRange(1, 180) - self.settingsLayout.addRow(self.timeoutLabel, self.timeoutSpinBox) - self.leftLayout.addWidget(self.settingsGroupBox) - self.leftLayout.addStretch() # CCLI Details - self.ccliGroupBox = QtGui.QGroupBox(self.rightColumn) + self.ccliGroupBox = QtGui.QGroupBox(self.leftColumn) self.ccliGroupBox.setObjectName(u'ccliGroupBox') self.ccliLayout = QtGui.QFormLayout(self.ccliGroupBox) self.ccliLayout.setObjectName(u'ccliLayout') @@ -165,9 +130,9 @@ class GeneralTab(SettingsTab): self.passwordEdit.setEchoMode(QtGui.QLineEdit.Password) self.passwordEdit.setObjectName(u'passwordEdit') self.ccliLayout.addRow(self.passwordLabel, self.passwordEdit) - self.rightLayout.addWidget(self.ccliGroupBox) + self.leftLayout.addWidget(self.ccliGroupBox) # Background audio - self.audioGroupBox = QtGui.QGroupBox(self.rightColumn) + self.audioGroupBox = QtGui.QGroupBox(self.leftColumn) self.audioGroupBox.setObjectName(u'audioGroupBox') self.audioLayout = QtGui.QVBoxLayout(self.audioGroupBox) self.audioLayout.setObjectName(u'audioLayout') @@ -177,7 +142,48 @@ class GeneralTab(SettingsTab): self.repeatListCheckBox = QtGui.QCheckBox(self.audioGroupBox) self.repeatListCheckBox.setObjectName(u'repeatListCheckBox') self.audioLayout.addWidget(self.repeatListCheckBox) - self.rightLayout.addWidget(self.audioGroupBox) + self.leftLayout.addWidget(self.audioGroupBox) + self.leftLayout.addStretch() + # Application Startup + self.startupGroupBox = QtGui.QGroupBox(self.rightColumn) + self.startupGroupBox.setObjectName(u'startupGroupBox') + self.startupLayout = QtGui.QVBoxLayout(self.startupGroupBox) + self.startupLayout.setObjectName(u'startupLayout') + self.warningCheckBox = QtGui.QCheckBox(self.startupGroupBox) + self.warningCheckBox.setObjectName(u'warningCheckBox') + self.startupLayout.addWidget(self.warningCheckBox) + self.autoOpenCheckBox = QtGui.QCheckBox(self.startupGroupBox) + self.autoOpenCheckBox.setObjectName(u'autoOpenCheckBox') + self.startupLayout.addWidget(self.autoOpenCheckBox) + self.showSplashCheckBox = QtGui.QCheckBox(self.startupGroupBox) + self.showSplashCheckBox.setObjectName(u'showSplashCheckBox') + self.startupLayout.addWidget(self.showSplashCheckBox) + self.checkForUpdatesCheckBox = QtGui.QCheckBox(self.startupGroupBox) + self.checkForUpdatesCheckBox.setObjectName(u'checkForUpdatesCheckBox') + self.startupLayout.addWidget(self.checkForUpdatesCheckBox) + self.rightLayout.addWidget(self.startupGroupBox) + # Application Settings + self.settingsGroupBox = QtGui.QGroupBox(self.rightColumn) + self.settingsGroupBox.setObjectName(u'settingsGroupBox') + self.settingsLayout = QtGui.QFormLayout(self.settingsGroupBox) + self.settingsLayout.setObjectName(u'settingsLayout') + self.saveCheckServiceCheckBox = QtGui.QCheckBox(self.settingsGroupBox) + self.saveCheckServiceCheckBox.setObjectName(u'saveCheckServiceCheckBox') + self.settingsLayout.addRow(self.saveCheckServiceCheckBox) + self.autoUnblankCheckBox = QtGui.QCheckBox(self.settingsGroupBox) + self.autoUnblankCheckBox.setObjectName(u'autoUnblankCheckBox') + self.settingsLayout.addRow(self.autoUnblankCheckBox) + self.autoPreviewCheckBox = QtGui.QCheckBox(self.settingsGroupBox) + self.autoPreviewCheckBox.setObjectName(u'autoPreviewCheckBox') + self.settingsLayout.addRow(self.autoPreviewCheckBox) + # Moved here from image tab + self.timeoutLabel = QtGui.QLabel(self.settingsGroupBox) + self.timeoutLabel.setObjectName(u'timeoutLabel') + self.timeoutSpinBox = QtGui.QSpinBox(self.settingsGroupBox) + self.timeoutSpinBox.setObjectName(u'timeoutSpinBox') + self.timeoutSpinBox.setRange(1, 180) + self.settingsLayout.addRow(self.timeoutLabel, self.timeoutSpinBox) + self.rightLayout.addWidget(self.settingsGroupBox) self.rightLayout.addStretch() # Signals and slots QtCore.QObject.connect(self.overrideRadioButton, From e9caa194f5f40a9cce0c40b660313ece4636a744 Mon Sep 17 00:00:00 2001 From: Philip Ridout Date: Fri, 9 Mar 2012 21:43:27 +0000 Subject: [PATCH 15/28] Adds a dialouge asking if the user wants to replace an existing theme when importing. It works, but I dont know, it just feels like my code is a little bit "rough 'n' ready" let me know what you think! --- openlp/core/ui/thememanager.py | 58 ++++++++++++++++++++++++---------- 1 file changed, 42 insertions(+), 16 deletions(-) diff --git a/openlp/core/ui/thememanager.py b/openlp/core/ui/thememanager.py index 3585e5c97..d4a861e44 100644 --- a/openlp/core/ui/thememanager.py +++ b/openlp/core/ui/thememanager.py @@ -511,6 +511,20 @@ class ThemeManager(QtGui.QWidget): return ThemeXML() else: return self._createThemeFromXml(xml, self.path) + + def overWriteMessageBox(self, themeName): + ret = QtGui.QMessageBox.question(self, + translate('OpenLP.ThemeManager', 'Theme Already Exists!'), + translate('OpenLP.ThemeManager', + 'The theme %s already exists. Do you want to replace it?' + % themeName), + QtGui.QMessageBox.StandardButtons(QtGui.QMessageBox.Yes | + QtGui.QMessageBox.No), + QtGui.QMessageBox.No) + if ret == QtGui.QMessageBox.Yes: + return True + elif ret == QtGui.QMessageBox.No: + return False def unzipTheme(self, filename, dir): """ @@ -522,7 +536,7 @@ class ThemeManager(QtGui.QWidget): filename = unicode(filename) zip = None outfile = None - filexml = None + filexml = None try: zip = zipfile.ZipFile(filename) xmlfile = filter(lambda name: @@ -533,10 +547,17 @@ class ThemeManager(QtGui.QWidget): xml_tree = ElementTree(element=XML(zip.read(xmlfile[0]))).getroot() v1_background = xml_tree.find(u'BackgroundType') if v1_background is not None: - (themename, filexml, outfile) = self.unzipVersion122(dir, zip, + (themename, filexml, outfile, abortimport) = self.unzipVersion122(dir, zip, xmlfile[0], xml_tree, v1_background, outfile) else: themename = xml_tree.find(u'name').text.strip() + themefolder = os.path.join(dir, themename) + themeexists = os.path.exists(themefolder) + if themeexists and not self.overWriteMessageBox(themename): + abortimport = True + return + else: + abortimport = False for name in zip.namelist(): try: uname = unicode(name, u'utf-8') @@ -575,19 +596,20 @@ class ThemeManager(QtGui.QWidget): zip.close() if outfile: outfile.close() - # As all files are closed, we can create the Theme. - if filexml: - theme = self._createThemeFromXml(filexml, self.path) - self.generateAndSaveImage(dir, themename, theme) - # Only show the error message, when IOError was not raised (in this - # case the error message has already been shown). - elif zip is not None: - critical_error_message_box( - translate('OpenLP.ThemeManager', 'Validation Error'), - translate('OpenLP.ThemeManager', - 'File is not a valid theme.')) - log.exception(u'Theme file does not contain XML data %s' % - filename) + if not abortimport: + # As all files are closed, we can create the Theme. + if filexml: + theme = self._createThemeFromXml(filexml, self.path) + self.generateAndSaveImage(dir, themename, theme) + # Only show the error message, when IOError was not raised (in this + # case the error message has already been shown). + elif zip is not None: + critical_error_message_box( + translate('OpenLP.ThemeManager', 'Validation Error'), + translate('OpenLP.ThemeManager', + 'File is not a valid theme.')) + log.exception(u'Theme file does not contain XML data %s' % + filename) def unzipVersion122(self, dir, zip, xmlfile, xml_tree, background, outfile): """ @@ -596,6 +618,10 @@ class ThemeManager(QtGui.QWidget): """ themename = xml_tree.find(u'Name').text.strip() themename = self.bad_v1_name_chars.sub(u'', themename) + themefolder = os.path.join(dir, themename) + themeexists = os.path.exists(themefolder) + if themeexists and not self.overWriteMessageBox(themename): + return ( '', '', '', True) themedir = os.path.join(dir, themename) check_directory_exists(themedir) filexml = unicode(zip.read(xmlfile), u'utf-8') @@ -617,7 +643,7 @@ class ThemeManager(QtGui.QWidget): log.exception(u'Theme file does not contain image file "%s"' % imagename.decode(u'utf-8', u'replace')) raise Exception(u'validation') - return (themename, filexml, outfile) + return (themename, filexml, outfile, False) def checkIfThemeExists(self, themeName): """ From a40717c16f98b95465e69a3ea9f997e57b6f883c Mon Sep 17 00:00:00 2001 From: Philip Ridout Date: Sat, 10 Mar 2012 08:22:52 +0000 Subject: [PATCH 16/28] Fixed up to Raouls guidelines --- openlp/core/ui/thememanager.py | 183 ++++++++++++++++----------------- 1 file changed, 90 insertions(+), 93 deletions(-) diff --git a/openlp/core/ui/thememanager.py b/openlp/core/ui/thememanager.py index d4a861e44..0b86faca6 100644 --- a/openlp/core/ui/thememanager.py +++ b/openlp/core/ui/thememanager.py @@ -178,10 +178,10 @@ class ThemeManager(QtGui.QWidget): """ if item is None: return - realThemeName = unicode(item.data(QtCore.Qt.UserRole).toString()) - themeName = unicode(item.text()) + realtheme_name = unicode(item.data(QtCore.Qt.UserRole).toString()) + theme_name = unicode(item.text()) # If default theme restrict actions - if realThemeName == themeName: + if realtheme_name == theme_name: self.deleteToolbarAction.setVisible(True) else: self.deleteToolbarAction.setVisible(False) @@ -194,24 +194,24 @@ class ThemeManager(QtGui.QWidget): item = self.themeListWidget.itemAt(point) if item is None: return - realThemeName = unicode(item.data(QtCore.Qt.UserRole).toString()) - themeName = unicode(item.text()) + realtheme_name = unicode(item.data(QtCore.Qt.UserRole).toString()) + theme_name = unicode(item.text()) self.deleteAction.setVisible(False) self.renameAction.setVisible(False) self.globalAction.setVisible(False) # If default theme restrict actions - if realThemeName == themeName: + if realtheme_name == theme_name: self.deleteAction.setVisible(True) self.renameAction.setVisible(True) self.globalAction.setVisible(True) self.menu.exec_(self.themeListWidget.mapToGlobal(point)) - def changeGlobalFromTab(self, themeName): + def changeGlobalFromTab(self, theme_name): """ Change the global theme when it is changed through the Themes settings tab """ - log.debug(u'changeGlobalFromTab %s', themeName) + log.debug(u'changeGlobalFromTab %s', theme_name) for count in range (0, self.themeListWidget.count()): # reset the old name item = self.themeListWidget.item(count) @@ -220,7 +220,7 @@ class ThemeManager(QtGui.QWidget): if oldName != newName: self.themeListWidget.item(count).setText(newName) # Set the new name - if themeName == newName: + if theme_name == newName: name = unicode(translate('OpenLP.ThemeManager', '%s (default)')) % newName self.themeListWidget.item(count).setText(name) @@ -272,19 +272,19 @@ class ThemeManager(QtGui.QWidget): unicode(translate('OpenLP.ThemeManager', 'Rename %s theme?')), False, False): item = self.themeListWidget.currentItem() - oldThemeName = unicode(item.data(QtCore.Qt.UserRole).toString()) - self.fileRenameForm.fileNameEdit.setText(oldThemeName) + oldtheme_name = unicode(item.data(QtCore.Qt.UserRole).toString()) + self.fileRenameForm.fileNameEdit.setText(oldtheme_name) if self.fileRenameForm.exec_(): - newThemeName = unicode(self.fileRenameForm.fileNameEdit.text()) - if oldThemeName == newThemeName: + newtheme_name = unicode(self.fileRenameForm.fileNameEdit.text()) + if oldtheme_name == newtheme_name: return - if self.checkIfThemeExists(newThemeName): - oldThemeData = self.getThemeData(oldThemeName) - self.cloneThemeData(oldThemeData, newThemeName) - self.deleteTheme(oldThemeName) + if self.checkIfThemeExists(newtheme_name): + oldThemeData = self.getThemeData(oldtheme_name) + self.cloneThemeData(oldThemeData, newtheme_name) + self.deleteTheme(oldtheme_name) for plugin in self.mainwindow.pluginManager.plugins: - if plugin.usesTheme(oldThemeName): - plugin.renameTheme(oldThemeName, newThemeName) + if plugin.usesTheme(oldtheme_name): + plugin.renameTheme(oldtheme_name, newtheme_name) self.loadThemes() def onCopyTheme(self): @@ -292,17 +292,17 @@ class ThemeManager(QtGui.QWidget): Copies an existing theme to a new name """ item = self.themeListWidget.currentItem() - oldThemeName = unicode(item.data(QtCore.Qt.UserRole).toString()) + oldtheme_name = unicode(item.data(QtCore.Qt.UserRole).toString()) self.fileRenameForm.fileNameEdit.setText( unicode(translate('OpenLP.ThemeManager', - 'Copy of %s','Copy of ')) % oldThemeName) + 'Copy of %s','Copy of ')) % oldtheme_name) if self.fileRenameForm.exec_(True): - newThemeName = unicode(self.fileRenameForm.fileNameEdit.text()) - if self.checkIfThemeExists(newThemeName): - themeData = self.getThemeData(oldThemeName) - self.cloneThemeData(themeData, newThemeName) + newtheme_name = unicode(self.fileRenameForm.fileNameEdit.text()) + if self.checkIfThemeExists(newtheme_name): + themeData = self.getThemeData(oldtheme_name) + self.cloneThemeData(themeData, newtheme_name) - def cloneThemeData(self, themeData, newThemeName): + def cloneThemeData(self, themeData, newtheme_name): """ Takes a theme and makes a new copy of it as well as saving it. """ @@ -310,10 +310,10 @@ class ThemeManager(QtGui.QWidget): saveTo = None saveFrom = None if themeData.background_type == u'image': - saveTo = os.path.join(self.path, newThemeName, + saveTo = os.path.join(self.path, newtheme_name, os.path.split(unicode(themeData.background_filename))[1]) saveFrom = themeData.background_filename - themeData.theme_name = newThemeName + themeData.theme_name = newtheme_name themeData.extend_image_filename(self.path) self.saveTheme(themeData, saveFrom, saveTo) @@ -458,7 +458,7 @@ class ThemeManager(QtGui.QWidget): files = SettingsManager.get_files(self.settingsSection, u'.png') # Sort the themes by its name considering language specific characters. # lower() is needed for windows! - files.sort(key=lambda filename: unicode(filename).lower(), + files.sort(key=lambda file_name: unicode(file_name).lower(), cmp=locale.strcoll) # now process the file list of png files for name in files: @@ -495,16 +495,16 @@ class ThemeManager(QtGui.QWidget): """ return self.themelist - def getThemeData(self, themeName): + def getThemeData(self, theme_name): """ Returns a theme object from an XML file - ``themeName`` + ``theme_name`` Name of the theme to load from file """ - log.debug(u'getthemedata for theme %s', themeName) - xmlFile = os.path.join(self.path, unicode(themeName), - unicode(themeName) + u'.xml') + log.debug(u'getthemedata for theme %s', theme_name) + xmlFile = os.path.join(self.path, unicode(theme_name), + unicode(theme_name) + u'.xml') xml = get_text_file_string(xmlFile) if not xml: log.debug("No theme data - using default theme") @@ -512,33 +512,30 @@ class ThemeManager(QtGui.QWidget): else: return self._createThemeFromXml(xml, self.path) - def overWriteMessageBox(self, themeName): + def overWriteMessageBox(self, theme_name): ret = QtGui.QMessageBox.question(self, translate('OpenLP.ThemeManager', 'Theme Already Exists!'), translate('OpenLP.ThemeManager', 'The theme %s already exists. Do you want to replace it?' - % themeName), + % theme_name), QtGui.QMessageBox.StandardButtons(QtGui.QMessageBox.Yes | QtGui.QMessageBox.No), QtGui.QMessageBox.No) - if ret == QtGui.QMessageBox.Yes: - return True - elif ret == QtGui.QMessageBox.No: - return False + return ret == QtGui.QMessageBox.Yes - def unzipTheme(self, filename, dir): + def unzipTheme(self, file_name, dir): """ Unzip the theme, remove the preview file if stored Generate a new preview file. Check the XML theme version and upgrade if necessary. """ - log.debug(u'Unzipping theme %s', filename) - filename = unicode(filename) + log.debug(u'Unzipping theme %s', file_name) + file_name = unicode(file_name) zip = None - outfile = None - filexml = None + out_file = None + file_xml = None try: - zip = zipfile.ZipFile(filename) + zip = zipfile.ZipFile(file_name) xmlfile = filter(lambda name: os.path.splitext(name)[1].lower() == u'.xml', zip.namelist()) if len(xmlfile) != 1: @@ -547,17 +544,17 @@ class ThemeManager(QtGui.QWidget): xml_tree = ElementTree(element=XML(zip.read(xmlfile[0]))).getroot() v1_background = xml_tree.find(u'BackgroundType') if v1_background is not None: - (themename, filexml, outfile, abortimport) = self.unzipVersion122(dir, zip, - xmlfile[0], xml_tree, v1_background, outfile) + theme_name, file_xml, out_file, abort_import = self.unzipVersion122(dir, zip, + xmlfile[0], xml_tree, v1_background, out_file) else: - themename = xml_tree.find(u'name').text.strip() - themefolder = os.path.join(dir, themename) - themeexists = os.path.exists(themefolder) - if themeexists and not self.overWriteMessageBox(themename): - abortimport = True + theme_name = xml_tree.find(u'name').text.strip() + theme_folder = os.path.join(dir, theme_name) + theme_exists = os.path.exists(theme_folder) + if theme_exists and not self.overWriteMessageBox(theme_name): + abort_import = True return else: - abortimport = False + abort_import = False for name in zip.namelist(): try: uname = unicode(name, u'utf-8') @@ -573,15 +570,15 @@ class ThemeManager(QtGui.QWidget): fullname = os.path.join(dir, uname) check_directory_exists(os.path.dirname(fullname)) if os.path.splitext(uname)[1].lower() == u'.xml': - filexml = unicode(zip.read(name), u'utf-8') - outfile = open(fullname, u'w') - outfile.write(filexml.encode(u'utf-8')) + file_xml = unicode(zip.read(name), u'utf-8') + out_file = open(fullname, u'w') + out_file.write(file_xml.encode(u'utf-8')) else: - outfile = open(fullname, u'wb') - outfile.write(zip.read(name)) - outfile.close() + out_file = open(fullname, u'wb') + out_file.write(zip.read(name)) + out_file.close() except (IOError, zipfile.BadZipfile): - log.exception(u'Importing theme from zip failed %s' % filename) + log.exception(u'Importing theme from zip failed %s' % file_name) raise Exception(u'validation') except Exception as info: if unicode(info) == u'validation': @@ -594,13 +591,13 @@ class ThemeManager(QtGui.QWidget): # Close the files, to be able to continue creating the theme. if zip: zip.close() - if outfile: - outfile.close() - if not abortimport: + if out_file: + out_file.close() + if not abort_import: # As all files are closed, we can create the Theme. - if filexml: - theme = self._createThemeFromXml(filexml, self.path) - self.generateAndSaveImage(dir, themename, theme) + if file_xml: + theme = self._createThemeFromXml(file_xml, self.path) + self.generateAndSaveImage(dir, theme_name, theme) # Only show the error message, when IOError was not raised (in this # case the error message has already been shown). elif zip is not None: @@ -609,26 +606,26 @@ class ThemeManager(QtGui.QWidget): translate('OpenLP.ThemeManager', 'File is not a valid theme.')) log.exception(u'Theme file does not contain XML data %s' % - filename) + file_name) - def unzipVersion122(self, dir, zip, xmlfile, xml_tree, background, outfile): + def unzipVersion122(self, dir, zip, xmlfile, xml_tree, background, out_file): """ Unzip openlp.org 1.2x theme file and upgrade the theme xml. When calling this method, please keep in mind, that some parameters are redundant. """ - themename = xml_tree.find(u'Name').text.strip() - themename = self.bad_v1_name_chars.sub(u'', themename) - themefolder = os.path.join(dir, themename) - themeexists = os.path.exists(themefolder) - if themeexists and not self.overWriteMessageBox(themename): - return ( '', '', '', True) - themedir = os.path.join(dir, themename) + theme_name = xml_tree.find(u'Name').text.strip() + theme_name = self.bad_v1_name_chars.sub(u'', theme_name) + theme_folder = os.path.join(dir, theme_name) + theme_exists = os.path.exists(theme_folder) + if theme_exists and not self.overWriteMessageBox(theme_name): + return '', '', '', True + themedir = os.path.join(dir, theme_name) check_directory_exists(themedir) - filexml = unicode(zip.read(xmlfile), u'utf-8') - filexml = self._migrateVersion122(filexml) - outfile = open(os.path.join(themedir, themename + u'.xml'), u'w') - outfile.write(filexml.encode(u'utf-8')) - outfile.close() + file_xml = unicode(zip.read(xmlfile), u'utf-8') + file_xml = self._migrateVersion122(file_xml) + out_file = open(os.path.join(themedir, theme_name + u'.xml'), u'w') + out_file.write(file_xml.encode(u'utf-8')) + out_file.close() if background.text.strip() == u'2': imagename = xml_tree.find(u'BackgroundParameter1').text.strip() # image file has same extension and is in subfolder @@ -636,23 +633,23 @@ class ThemeManager(QtGui.QWidget): == os.path.splitext(imagename)[1].lower() and name.find(r'/'), zip.namelist()) if len(imagefile) >= 1: - outfile = open(os.path.join(themedir, imagename), u'wb') - outfile.write(zip.read(imagefile[0])) - outfile.close() + out_file = open(os.path.join(themedir, imagename), u'wb') + out_file.write(zip.read(imagefile[0])) + out_file.close() else: log.exception(u'Theme file does not contain image file "%s"' % imagename.decode(u'utf-8', u'replace')) raise Exception(u'validation') - return (themename, filexml, outfile, False) + return theme_name, file_xml, out_file, False - def checkIfThemeExists(self, themeName): + def checkIfThemeExists(self, theme_name): """ Check if theme already exists and displays error message - ``themeName`` + ``theme_name`` Name of the Theme to test """ - theme_dir = os.path.join(self.path, themeName) + theme_dir = os.path.join(self.path, theme_name) if os.path.exists(theme_dir): critical_error_message_box( translate('OpenLP.ThemeManager', 'Validation Error'), @@ -688,15 +685,15 @@ class ThemeManager(QtGui.QWidget): if self.oldBackgroundImage and \ imageTo != self.oldBackgroundImage: delete_file(self.oldBackgroundImage) - outfile = None + out_file = None try: - outfile = open(theme_file, u'w') - outfile.write(theme_pretty_xml) + out_file = open(theme_file, u'w') + out_file.write(theme_pretty_xml) except IOError: log.exception(u'Saving theme to file failed') finally: - if outfile: - outfile.close() + if out_file: + out_file.close() if imageFrom and imageFrom != imageTo: try: encoding = get_filesystem_encoding() From 7d7e76fd9b5c04a7a770f3c29f381f1184d35ed8 Mon Sep 17 00:00:00 2001 From: Philip Ridout Date: Sat, 10 Mar 2012 16:03:58 +0000 Subject: [PATCH 17/28] renaming variables, if your going to open a can of worms, might as well eat them all! --- openlp/core/ui/thememanager.py | 271 ++++++++++++++++----------------- 1 file changed, 135 insertions(+), 136 deletions(-) diff --git a/openlp/core/ui/thememanager.py b/openlp/core/ui/thememanager.py index 0b86faca6..eb022bb25 100644 --- a/openlp/core/ui/thememanager.py +++ b/openlp/core/ui/thememanager.py @@ -52,9 +52,9 @@ class ThemeManager(QtGui.QWidget): """ Manages the orders of Theme. """ - def __init__(self, mainwindow, parent=None): + def __init__(self, mainWindow, parent=None): QtGui.QWidget.__init__(self, parent) - self.mainwindow = mainwindow + self.mainWindow = mainWindow self.settingsSection = u'themes' self.themeForm = ThemeForm(self) self.fileRenameForm = FileRenameForm(self) @@ -140,13 +140,13 @@ class ThemeManager(QtGui.QWidget): QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'config_updated'), self.configUpdated) # Variables - self.themelist = [] + self.theme_list = [] self.path = AppLocation.get_section_data_path(self.settingsSection) check_directory_exists(self.path) - self.thumbPath = os.path.join(self.path, u'thumbnails') - check_directory_exists(self.thumbPath) + self.thumb_path = os.path.join(self.path, u'thumbnails') + check_directory_exists(self.thumb_path) self.themeForm.path = self.path - self.oldBackgroundImage = None + self.old_background_image = None self.bad_v1_name_chars = re.compile(r'[%+\[\]]') # Last little bits of setting up self.configUpdated() @@ -178,10 +178,10 @@ class ThemeManager(QtGui.QWidget): """ if item is None: return - realtheme_name = unicode(item.data(QtCore.Qt.UserRole).toString()) + real_theme_name = unicode(item.data(QtCore.Qt.UserRole).toString()) theme_name = unicode(item.text()) # If default theme restrict actions - if realtheme_name == theme_name: + if real_theme_name == theme_name: self.deleteToolbarAction.setVisible(True) else: self.deleteToolbarAction.setVisible(False) @@ -194,13 +194,13 @@ class ThemeManager(QtGui.QWidget): item = self.themeListWidget.itemAt(point) if item is None: return - realtheme_name = unicode(item.data(QtCore.Qt.UserRole).toString()) + real_theme_name = unicode(item.data(QtCore.Qt.UserRole).toString()) theme_name = unicode(item.text()) self.deleteAction.setVisible(False) self.renameAction.setVisible(False) self.globalAction.setVisible(False) # If default theme restrict actions - if realtheme_name == theme_name: + if real_theme_name == theme_name: self.deleteAction.setVisible(True) self.renameAction.setVisible(True) self.globalAction.setVisible(True) @@ -215,14 +215,14 @@ class ThemeManager(QtGui.QWidget): for count in range (0, self.themeListWidget.count()): # reset the old name item = self.themeListWidget.item(count) - oldName = item.text() - newName = unicode(item.data(QtCore.Qt.UserRole).toString()) - if oldName != newName: - self.themeListWidget.item(count).setText(newName) + old_name = item.text() + new_name = unicode(item.data(QtCore.Qt.UserRole).toString()) + if old_name != new_name: + self.themeListWidget.item(count).setText(new_name) # Set the new name - if theme_name == newName: + if theme_name == new_name: name = unicode(translate('OpenLP.ThemeManager', - '%s (default)')) % newName + '%s (default)')) % new_name self.themeListWidget.item(count).setText(name) def changeGlobalFromScreen(self, index=-1): @@ -234,9 +234,9 @@ class ThemeManager(QtGui.QWidget): selected_row = self.themeListWidget.currentRow() for count in range (0, self.themeListWidget.count()): item = self.themeListWidget.item(count) - oldName = item.text() + old_name = item.text() # reset the old name - if oldName != unicode(item.data(QtCore.Qt.UserRole).toString()): + if old_name != unicode(item.data(QtCore.Qt.UserRole).toString()): self.themeListWidget.item(count).setText( unicode(item.data(QtCore.Qt.UserRole).toString())) # Set the new name @@ -272,19 +272,19 @@ class ThemeManager(QtGui.QWidget): unicode(translate('OpenLP.ThemeManager', 'Rename %s theme?')), False, False): item = self.themeListWidget.currentItem() - oldtheme_name = unicode(item.data(QtCore.Qt.UserRole).toString()) - self.fileRenameForm.fileNameEdit.setText(oldtheme_name) + old_theme_name = unicode(item.data(QtCore.Qt.UserRole).toString()) + self.fileRenameForm.fileNameEdit.setText(old_theme_name) if self.fileRenameForm.exec_(): - newtheme_name = unicode(self.fileRenameForm.fileNameEdit.text()) - if oldtheme_name == newtheme_name: + new_theme_name = unicode(self.fileRenameForm.fileNameEdit.text()) + if old_theme_name == new_theme_name: return - if self.checkIfThemeExists(newtheme_name): - oldThemeData = self.getThemeData(oldtheme_name) - self.cloneThemeData(oldThemeData, newtheme_name) - self.deleteTheme(oldtheme_name) - for plugin in self.mainwindow.pluginManager.plugins: - if plugin.usesTheme(oldtheme_name): - plugin.renameTheme(oldtheme_name, newtheme_name) + if self.checkIfThemeExists(new_theme_name): + old_theme_data = self.getThemeData(old_theme_name) + self.cloneThemeData(old_theme_data, new_theme_name) + self.deleteTheme(old_theme_name) + for plugin in self.mainWindow.pluginManager.plugins: + if plugin.usesTheme(old_theme_name): + plugin.renameTheme(old_theme_name, new_theme_name) self.loadThemes() def onCopyTheme(self): @@ -292,30 +292,30 @@ class ThemeManager(QtGui.QWidget): Copies an existing theme to a new name """ item = self.themeListWidget.currentItem() - oldtheme_name = unicode(item.data(QtCore.Qt.UserRole).toString()) + old_theme_name = unicode(item.data(QtCore.Qt.UserRole).toString()) self.fileRenameForm.fileNameEdit.setText( unicode(translate('OpenLP.ThemeManager', - 'Copy of %s','Copy of ')) % oldtheme_name) + 'Copy of %s','Copy of ')) % old_theme_name) if self.fileRenameForm.exec_(True): - newtheme_name = unicode(self.fileRenameForm.fileNameEdit.text()) - if self.checkIfThemeExists(newtheme_name): - themeData = self.getThemeData(oldtheme_name) - self.cloneThemeData(themeData, newtheme_name) + new_theme_name = unicode(self.fileRenameForm.fileNameEdit.text()) + if self.checkIfThemeExists(new_theme_name): + theme_data = self.getThemeData(old_theme_name) + self.cloneThemeData(theme_data, new_theme_name) - def cloneThemeData(self, themeData, newtheme_name): + def cloneThemeData(self, theme_data, new_theme_name): """ Takes a theme and makes a new copy of it as well as saving it. """ log.debug(u'cloneThemeData') - saveTo = None - saveFrom = None - if themeData.background_type == u'image': - saveTo = os.path.join(self.path, newtheme_name, - os.path.split(unicode(themeData.background_filename))[1]) - saveFrom = themeData.background_filename - themeData.theme_name = newtheme_name - themeData.extend_image_filename(self.path) - self.saveTheme(themeData, saveFrom, saveTo) + save_to = None + save_from = None + if theme_data.background_type == u'image': + save_to = os.path.join(self.path, new_theme_name, + os.path.split(unicode(theme_data.background_filename))[1]) + save_from = theme_data.background_filename + theme_data.theme_name = new_theme_name + theme_data.extend_image_filename(self.path) + self.saveTheme(theme_data, save_from, save_to) def onEditTheme(self): """ @@ -329,10 +329,10 @@ class ThemeManager(QtGui.QWidget): theme = self.getThemeData( unicode(item.data(QtCore.Qt.UserRole).toString())) if theme.background_type == u'image': - self.oldBackgroundImage = theme.background_filename + self.old_background_image = theme.background_filename self.themeForm.theme = theme self.themeForm.exec_(True) - self.oldBackgroundImage = None + self.old_background_image = None def onDeleteTheme(self): """ @@ -358,10 +358,10 @@ class ThemeManager(QtGui.QWidget): ``theme`` The theme to delete. """ - self.themelist.remove(theme) + self.theme_list.remove(theme) thumb = u'%s.png' % theme delete_file(os.path.join(self.path, thumb)) - delete_file(os.path.join(self.thumbPath, thumb)) + delete_file(os.path.join(self.thumb_path, thumb)) try: encoding = get_filesystem_encoding() shutil.rmtree(os.path.join(self.path, theme).encode(encoding)) @@ -386,10 +386,10 @@ class ThemeManager(QtGui.QWidget): Receiver.send_message(u'cursor_busy') if path: SettingsManager.set_last_dir(self.settingsSection, path, 1) - themePath = os.path.join(path, theme + u'.otz') + theme_path = os.path.join(path, theme + u'.otz') zip = None try: - zip = zipfile.ZipFile(themePath, u'w') + zip = zipfile.ZipFile(theme_path, u'w') source = os.path.join(self.path, theme) for files in os.walk(source): for name in files[2]: @@ -439,9 +439,8 @@ class ThemeManager(QtGui.QWidget): The plugins will call back in to get the real list if they want it. """ log.debug(u'Load themes from dir') - self.themelist = [] + self.theme_list = [] self.themeListWidget.clear() - dirList = os.listdir(self.path) files = SettingsManager.get_files(self.settingsSection, u'.png') if firstTime: self.firstTime() @@ -465,22 +464,22 @@ class ThemeManager(QtGui.QWidget): # check to see file is in theme root directory theme = os.path.join(self.path, name) if os.path.exists(theme): - textName = os.path.splitext(name)[0] - if textName == self.global_theme: + text_name = os.path.splitext(name)[0] + if text_name == self.global_theme: name = unicode(translate('OpenLP.ThemeManager', - '%s (default)')) % textName + '%s (default)')) % text_name else: - name = textName - thumb = os.path.join(self.thumbPath, u'%s.png' % textName) + name = text_name + thumb = os.path.join(self.thumb_path, u'%s.png' % text_name) item_name = QtGui.QListWidgetItem(name) if validate_thumb(theme, thumb): icon = build_icon(thumb) else: icon = create_thumb(theme, thumb) item_name.setIcon(icon) - item_name.setData(QtCore.Qt.UserRole, QtCore.QVariant(textName)) + item_name.setData(QtCore.Qt.UserRole, QtCore.QVariant(text_name)) self.themeListWidget.addItem(item_name) - self.themelist.append(textName) + self.theme_list.append(text_name) self._pushThemes() def _pushThemes(self): @@ -493,7 +492,7 @@ class ThemeManager(QtGui.QWidget): """ Return the list of loaded themes """ - return self.themelist + return self.theme_list def getThemeData(self, theme_name): """ @@ -503,9 +502,9 @@ class ThemeManager(QtGui.QWidget): Name of the theme to load from file """ log.debug(u'getthemedata for theme %s', theme_name) - xmlFile = os.path.join(self.path, unicode(theme_name), + xml_file = os.path.join(self.path, unicode(theme_name), unicode(theme_name) + u'.xml') - xml = get_text_file_string(xmlFile) + xml = get_text_file_string(xml_file) if not xml: log.debug("No theme data - using default theme") return ThemeXML() @@ -536,16 +535,16 @@ class ThemeManager(QtGui.QWidget): file_xml = None try: zip = zipfile.ZipFile(file_name) - xmlfile = filter(lambda name: + xml_file = filter(lambda name: os.path.splitext(name)[1].lower() == u'.xml', zip.namelist()) - if len(xmlfile) != 1: - log.exception(u'Theme contains "%s" XML files' % len(xmlfile)) + if len(xml_file) != 1: + log.exception(u'Theme contains "%s" XML files' % len(xml_file)) raise Exception(u'validation') - xml_tree = ElementTree(element=XML(zip.read(xmlfile[0]))).getroot() + xml_tree = ElementTree(element=XML(zip.read(xml_file[0]))).getroot() v1_background = xml_tree.find(u'BackgroundType') if v1_background is not None: theme_name, file_xml, out_file, abort_import = self.unzipVersion122(dir, zip, - xmlfile[0], xml_tree, v1_background, out_file) + xml_file[0], xml_tree, v1_background, out_file) else: theme_name = xml_tree.find(u'name').text.strip() theme_folder = os.path.join(dir, theme_name) @@ -563,18 +562,18 @@ class ThemeManager(QtGui.QWidget): u' "%s"' % name.decode(u'utf-8', u'replace')) raise Exception(u'validation') uname = unicode(QtCore.QDir.toNativeSeparators(uname)) - splitname = uname.split(os.path.sep) - if splitname[-1] == u'' or len(splitname) == 1: + spli_tname = uname.split(os.path.sep) + if spli_tname[-1] == u'' or len(spli_tname) == 1: # is directory or preview file continue - fullname = os.path.join(dir, uname) - check_directory_exists(os.path.dirname(fullname)) + full_name = os.path.join(dir, uname) + check_directory_exists(os.path.dirname(full_name)) if os.path.splitext(uname)[1].lower() == u'.xml': file_xml = unicode(zip.read(name), u'utf-8') - out_file = open(fullname, u'w') + out_file = open(full_name, u'w') out_file.write(file_xml.encode(u'utf-8')) else: - out_file = open(fullname, u'wb') + out_file = open(full_name, u'wb') out_file.write(zip.read(name)) out_file.close() except (IOError, zipfile.BadZipfile): @@ -608,7 +607,7 @@ class ThemeManager(QtGui.QWidget): log.exception(u'Theme file does not contain XML data %s' % file_name) - def unzipVersion122(self, dir, zip, xmlfile, xml_tree, background, out_file): + def unzipVersion122(self, dir, zip, xml_file, xml_tree, background, out_file): """ Unzip openlp.org 1.2x theme file and upgrade the theme xml. When calling this method, please keep in mind, that some parameters are redundant. @@ -621,24 +620,24 @@ class ThemeManager(QtGui.QWidget): return '', '', '', True themedir = os.path.join(dir, theme_name) check_directory_exists(themedir) - file_xml = unicode(zip.read(xmlfile), u'utf-8') + file_xml = unicode(zip.read(xml_file), u'utf-8') file_xml = self._migrateVersion122(file_xml) out_file = open(os.path.join(themedir, theme_name + u'.xml'), u'w') out_file.write(file_xml.encode(u'utf-8')) out_file.close() if background.text.strip() == u'2': - imagename = xml_tree.find(u'BackgroundParameter1').text.strip() + image_name = xml_tree.find(u'BackgroundParameter1').text.strip() # image file has same extension and is in subfolder imagefile = filter(lambda name: os.path.splitext(name)[1].lower() - == os.path.splitext(imagename)[1].lower() and name.find(r'/'), + == os.path.splitext(image_name)[1].lower() and name.find(r'/'), zip.namelist()) if len(imagefile) >= 1: - out_file = open(os.path.join(themedir, imagename), u'wb') + out_file = open(os.path.join(themedir, image_name), u'wb') out_file.write(zip.read(imagefile[0])) out_file.close() else: log.exception(u'Theme file does not contain image file "%s"' % - imagename.decode(u'utf-8', u'replace')) + image_name.decode(u'utf-8', u'replace')) raise Exception(u'validation') return theme_name, file_xml, out_file, False @@ -658,20 +657,20 @@ class ThemeManager(QtGui.QWidget): return False return True - def saveTheme(self, theme, imageFrom, imageTo): + def saveTheme(self, theme, image_from, image_to): """ Called by thememaintenance Dialog to save the theme and to trigger the reload of the theme list """ - self._writeTheme(theme, imageFrom, imageTo) + self._writeTheme(theme, image_from, image_to) if theme.background_type == \ BackgroundType.to_string(BackgroundType.Image): - self.mainwindow.imageManager.update_image(theme.theme_name, + self.mainWindow.imageManager.update_image(theme.theme_name, u'theme', QtGui.QColor(theme.background_border_color)) - self.mainwindow.imageManager.process_updates() + self.mainWindow.imageManager.process_updates() self.loadThemes() - def _writeTheme(self, theme, imageFrom, imageTo): + def _writeTheme(self, theme, image_from, image_to): """ Writes the theme to the disk and handles the background image if necessary @@ -682,9 +681,9 @@ class ThemeManager(QtGui.QWidget): theme_dir = os.path.join(self.path, name) check_directory_exists(theme_dir) theme_file = os.path.join(theme_dir, name + u'.xml') - if self.oldBackgroundImage and \ - imageTo != self.oldBackgroundImage: - delete_file(self.oldBackgroundImage) + if self.old_background_image and \ + image_to != self.old_background_image: + delete_file(self.old_background_image) out_file = None try: out_file = open(theme_file, u'w') @@ -694,12 +693,12 @@ class ThemeManager(QtGui.QWidget): finally: if out_file: out_file.close() - if imageFrom and imageFrom != imageTo: + if image_from and image_from != image_to: try: encoding = get_filesystem_encoding() shutil.copyfile( - unicode(imageFrom).encode(encoding), - unicode(imageTo).encode(encoding)) + unicode(image_from).encode(encoding), + unicode(image_to).encode(encoding)) except IOError: log.exception(u'Failed to save theme image') self.generateAndSaveImage(self.path, name, theme) @@ -707,39 +706,39 @@ class ThemeManager(QtGui.QWidget): def generateAndSaveImage(self, dir, name, theme): log.debug(u'generateAndSaveImage %s %s', dir, name) 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) - create_thumb(samplepathname, thumb, False) - log.debug(u'Theme image written to %s', samplepathname) + sample_path_name = os.path.join(self.path, name + u'.png') + if os.path.exists(sample_path_name): + os.unlink(sample_path_name) + frame.save(sample_path_name, u'png') + thumb = os.path.join(self.thumb_path, u'%s.png' % name) + create_thumb(sample_path_name, thumb, False) + log.debug(u'Theme image written to %s', sample_path_name) def updatePreviewImages(self): """ Called to update the themes' preview images. """ - self.mainwindow.displayProgressBar(len(self.themelist)) - for theme in self.themelist: - self.mainwindow.incrementProgressBar() + self.mainWindow.displayProgressBar(len(self.theme_list)) + for theme in self.theme_list: + self.mainWindow.incrementProgressBar() self.generateAndSaveImage( self.path, theme, self.getThemeData(theme)) - self.mainwindow.finishedProgressBar() + self.mainWindow.finishedProgressBar() self.loadThemes() - def generateImage(self, themeData, forcePage=False): + def generateImage(self, theme_data, forcePage=False): """ Call the renderer to build a Sample Image - ``themeData`` + ``theme_data`` 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.renderer.generate_preview( - themeData, forcePage) + log.debug(u'generateImage \n%s ', theme_data) + return self.mainWindow.renderer.generate_preview( + theme_data, forcePage) def getPreviewImage(self, theme): """ @@ -752,15 +751,15 @@ class ThemeManager(QtGui.QWidget): image = os.path.join(self.path, theme + u'.png') return image - def _createThemeFromXml(self, themeXml, path): + def _createThemeFromXml(self, theme_xml, path): """ Return a theme object using information parsed from XML - ``themeXml`` + ``theme_xml`` The XML data to load into the theme """ theme = ThemeXML() - theme.parse(themeXml) + theme.parse(theme_xml) theme.extend_image_filename(path) return theme @@ -792,7 +791,7 @@ class ThemeManager(QtGui.QWidget): return False # check for use in the system else where. if testPlugin: - for plugin in self.mainwindow.pluginManager.plugins: + for plugin in self.mainWindow.pluginManager.plugins: if plugin.usesTheme(theme): critical_error_message_box( translate('OpenLP.ThemeManager', @@ -815,53 +814,53 @@ class ThemeManager(QtGui.QWidget): Version 1 theme to convert """ theme = Theme(xml_data) - newtheme = ThemeXML() - newtheme.theme_name = self.bad_v1_name_chars.sub(u'', theme.Name) + new_theme = ThemeXML() + new_theme.theme_name = self.bad_v1_name_chars.sub(u'', theme.Name) if theme.BackgroundType == 0: - newtheme.background_type = \ + new_theme.background_type = \ BackgroundType.to_string(BackgroundType.Solid) - newtheme.background_color = \ + new_theme.background_color = \ unicode(theme.BackgroundParameter1.name()) elif theme.BackgroundType == 1: - newtheme.background_type = \ + new_theme.background_type = \ BackgroundType.to_string(BackgroundType.Gradient) - newtheme.background_direction = \ + new_theme.background_direction = \ BackgroundGradientType. \ to_string(BackgroundGradientType.Horizontal) if theme.BackgroundParameter3.name() == 1: - newtheme.background_direction = \ + new_theme.background_direction = \ BackgroundGradientType. \ to_string(BackgroundGradientType.Horizontal) - newtheme.background_start_color = \ + new_theme.background_start_color = \ unicode(theme.BackgroundParameter1.name()) - newtheme.background_end_color = \ + new_theme.background_end_color = \ unicode(theme.BackgroundParameter2.name()) elif theme.BackgroundType == 2: - newtheme.background_type = \ + new_theme.background_type = \ BackgroundType.to_string(BackgroundType.Image) - newtheme.background_filename = unicode(theme.BackgroundParameter1) + new_theme.background_filename = unicode(theme.BackgroundParameter1) elif theme.BackgroundType == 3: - newtheme.background_type = \ + new_theme.background_type = \ BackgroundType.to_string(BackgroundType.Transparent) - newtheme.font_main_name = theme.FontName - newtheme.font_main_color = unicode(theme.FontColor.name()) - newtheme.font_main_size = theme.FontProportion * 3 - newtheme.font_footer_name = theme.FontName - newtheme.font_footer_color = unicode(theme.FontColor.name()) - newtheme.font_main_shadow = False + new_theme.font_main_name = theme.FontName + new_theme.font_main_color = unicode(theme.FontColor.name()) + new_theme.font_main_size = theme.FontProportion * 3 + new_theme.font_footer_name = theme.FontName + new_theme.font_footer_color = unicode(theme.FontColor.name()) + new_theme.font_main_shadow = False if theme.Shadow == 1: - newtheme.font_main_shadow = True - newtheme.font_main_shadow_color = unicode(theme.ShadowColor.name()) + new_theme.font_main_shadow = True + new_theme.font_main_shadow_color = unicode(theme.ShadowColor.name()) if theme.Outline == 1: - newtheme.font_main_outline = True - newtheme.font_main_outline_color = \ + new_theme.font_main_outline = True + new_theme.font_main_outline_color = \ unicode(theme.OutlineColor.name()) vAlignCorrection = VerticalType.Top if theme.VerticalAlign == 2: vAlignCorrection = VerticalType.Middle elif theme.VerticalAlign == 1: vAlignCorrection = VerticalType.Bottom - newtheme.display_horizontal_align = theme.HorizontalAlign - newtheme.display_vertical_align = vAlignCorrection - return newtheme.extract_xml() + new_theme.display_horizontal_align = theme.HorizontalAlign + new_theme.display_vertical_align = vAlignCorrection + return new_theme.extract_xml() From 24b817cccf63072b332f2ef4347644467c9499fd Mon Sep 17 00:00:00 2001 From: Philip Ridout Date: Sat, 10 Mar 2012 16:14:07 +0000 Subject: [PATCH 18/28] More minor fixes --- openlp/core/ui/thememanager.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/openlp/core/ui/thememanager.py b/openlp/core/ui/thememanager.py index eb022bb25..d3762654d 100644 --- a/openlp/core/ui/thememanager.py +++ b/openlp/core/ui/thememanager.py @@ -513,9 +513,9 @@ class ThemeManager(QtGui.QWidget): def overWriteMessageBox(self, theme_name): ret = QtGui.QMessageBox.question(self, - translate('OpenLP.ThemeManager', 'Theme Already Exists!'), + translate('OpenLP.ThemeManager', 'Theme Already Exists.'), translate('OpenLP.ThemeManager', - 'The theme %s already exists. Do you want to replace it?' + 'Theme %s already exists. Do you want to replace it?' % theme_name), QtGui.QMessageBox.StandardButtons(QtGui.QMessageBox.Yes | QtGui.QMessageBox.No), @@ -617,7 +617,7 @@ class ThemeManager(QtGui.QWidget): theme_folder = os.path.join(dir, theme_name) theme_exists = os.path.exists(theme_folder) if theme_exists and not self.overWriteMessageBox(theme_name): - return '', '', '', True + return '', '', '', True themedir = os.path.join(dir, theme_name) check_directory_exists(themedir) file_xml = unicode(zip.read(xml_file), u'utf-8') From df5447098868c76cf54502324ab4b366d67b6dc3 Mon Sep 17 00:00:00 2001 From: Philip Ridout Date: Sat, 10 Mar 2012 16:44:58 +0000 Subject: [PATCH 19/28] Few more minor fixes --- openlp/core/ui/thememanager.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/openlp/core/ui/thememanager.py b/openlp/core/ui/thememanager.py index d3762654d..a9ef4be14 100644 --- a/openlp/core/ui/thememanager.py +++ b/openlp/core/ui/thememanager.py @@ -52,9 +52,9 @@ class ThemeManager(QtGui.QWidget): """ Manages the orders of Theme. """ - def __init__(self, mainWindow, parent=None): + def __init__(self, main_window, parent=None): QtGui.QWidget.__init__(self, parent) - self.mainWindow = mainWindow + self.main_window = main_window self.settingsSection = u'themes' self.themeForm = ThemeForm(self) self.fileRenameForm = FileRenameForm(self) @@ -282,7 +282,7 @@ class ThemeManager(QtGui.QWidget): old_theme_data = self.getThemeData(old_theme_name) self.cloneThemeData(old_theme_data, new_theme_name) self.deleteTheme(old_theme_name) - for plugin in self.mainWindow.pluginManager.plugins: + for plugin in self.main_window.pluginManager.plugins: if plugin.usesTheme(old_theme_name): plugin.renameTheme(old_theme_name, new_theme_name) self.loadThemes() @@ -295,7 +295,7 @@ class ThemeManager(QtGui.QWidget): old_theme_name = unicode(item.data(QtCore.Qt.UserRole).toString()) self.fileRenameForm.fileNameEdit.setText( unicode(translate('OpenLP.ThemeManager', - 'Copy of %s','Copy of ')) % old_theme_name) + 'Copy of %s', 'Copy of ')) % old_theme_name) if self.fileRenameForm.exec_(True): new_theme_name = unicode(self.fileRenameForm.fileNameEdit.text()) if self.checkIfThemeExists(new_theme_name): @@ -513,7 +513,7 @@ class ThemeManager(QtGui.QWidget): def overWriteMessageBox(self, theme_name): ret = QtGui.QMessageBox.question(self, - translate('OpenLP.ThemeManager', 'Theme Already Exists.'), + translate('OpenLP.ThemeManager', 'Theme Already Exists'), translate('OpenLP.ThemeManager', 'Theme %s already exists. Do you want to replace it?' % theme_name), @@ -562,8 +562,8 @@ class ThemeManager(QtGui.QWidget): u' "%s"' % name.decode(u'utf-8', u'replace')) raise Exception(u'validation') uname = unicode(QtCore.QDir.toNativeSeparators(uname)) - spli_tname = uname.split(os.path.sep) - if spli_tname[-1] == u'' or len(spli_tname) == 1: + split_name = uname.split(os.path.sep) + if split_name[-1] == u'' or len(split_name) == 1: # is directory or preview file continue full_name = os.path.join(dir, uname) @@ -614,7 +614,7 @@ class ThemeManager(QtGui.QWidget): """ theme_name = xml_tree.find(u'Name').text.strip() theme_name = self.bad_v1_name_chars.sub(u'', theme_name) - theme_folder = os.path.join(dir, theme_name) + theme_folder = os.path.join(dir, theme_name) theme_exists = os.path.exists(theme_folder) if theme_exists and not self.overWriteMessageBox(theme_name): return '', '', '', True From f8021d315ea8045be1abcef31c3f6ab54a39417e Mon Sep 17 00:00:00 2001 From: Philip Ridout Date: Sat, 10 Mar 2012 17:13:19 +0000 Subject: [PATCH 20/28] fixed mainWindow this time! --- openlp/core/ui/thememanager.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/openlp/core/ui/thememanager.py b/openlp/core/ui/thememanager.py index a9ef4be14..5782ea39f 100644 --- a/openlp/core/ui/thememanager.py +++ b/openlp/core/ui/thememanager.py @@ -665,9 +665,9 @@ class ThemeManager(QtGui.QWidget): self._writeTheme(theme, image_from, image_to) if theme.background_type == \ BackgroundType.to_string(BackgroundType.Image): - self.mainWindow.imageManager.update_image(theme.theme_name, + self.main_window.imageManager.update_image(theme.theme_name, u'theme', QtGui.QColor(theme.background_border_color)) - self.mainWindow.imageManager.process_updates() + self.main_window.imageManager.process_updates() self.loadThemes() def _writeTheme(self, theme, image_from, image_to): @@ -718,12 +718,12 @@ class ThemeManager(QtGui.QWidget): """ Called to update the themes' preview images. """ - self.mainWindow.displayProgressBar(len(self.theme_list)) + self.main_window.displayProgressBar(len(self.theme_list)) for theme in self.theme_list: - self.mainWindow.incrementProgressBar() + self.main_window.incrementProgressBar() self.generateAndSaveImage( self.path, theme, self.getThemeData(theme)) - self.mainWindow.finishedProgressBar() + self.main_window.finishedProgressBar() self.loadThemes() def generateImage(self, theme_data, forcePage=False): @@ -737,7 +737,7 @@ class ThemeManager(QtGui.QWidget): Flag to tell message lines per page need to be generated. """ log.debug(u'generateImage \n%s ', theme_data) - return self.mainWindow.renderer.generate_preview( + return self.main_window.renderer.generate_preview( theme_data, forcePage) def getPreviewImage(self, theme): @@ -791,7 +791,7 @@ class ThemeManager(QtGui.QWidget): return False # check for use in the system else where. if testPlugin: - for plugin in self.mainWindow.pluginManager.plugins: + for plugin in self.main_window.pluginManager.plugins: if plugin.usesTheme(theme): critical_error_message_box( translate('OpenLP.ThemeManager', From 06cce54788c99ead15597af36a34949ab4eb52a2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Armin=20K=C3=B6hler?= Date: Sat, 10 Mar 2012 20:12:03 +0100 Subject: [PATCH 21/28] fix some mission spaces and addapt some strings --- openlp/plugins/bibles/lib/__init__.py | 168 ++++++++++++------------- openlp/plugins/bibles/lib/biblestab.py | 11 +- openlp/plugins/bibles/lib/db.py | 2 +- 3 files changed, 90 insertions(+), 91 deletions(-) diff --git a/openlp/plugins/bibles/lib/__init__.py b/openlp/plugins/bibles/lib/__init__.py index 987f7e79e..65fd3d543 100644 --- a/openlp/plugins/bibles/lib/__init__.py +++ b/openlp/plugins/bibles/lib/__init__.py @@ -89,90 +89,90 @@ class BibleStrings(object): These strings should need a good reason to be retranslated elsewhere. """ self.Booknames = { - u'Gen': translate('BiblesPlugin','Genesis'), - u'Exod': translate('BiblesPlugin','Exodus'), - u'Lev': translate('BiblesPlugin','Leviticus'), - u'Num': translate('BiblesPlugin','Numbers'), - u'Deut': translate('BiblesPlugin','Deuteronomy'), - u'Josh': translate('BiblesPlugin','Joshua'), - u'Judg': translate('BiblesPlugin','Judges'), - u'Ruth': translate('BiblesPlugin','Ruth'), - u'1Sam': translate('BiblesPlugin','1 Samuel'), - u'2Sam': translate('BiblesPlugin','2 Samuel'), - u'1Kgs': translate('BiblesPlugin','1 Kings'), - u'2Kgs': translate('BiblesPlugin','2 Kings'), - u'1Chr': translate('BiblesPlugin','1 Chronicles'), - u'2Chr': translate('BiblesPlugin','2 Chronicles'), - u'Esra': translate('BiblesPlugin','Ezra'), - u'Neh': translate('BiblesPlugin','Nehemiah'), - u'Esth': translate('BiblesPlugin','Esther'), - u'Job': translate('BiblesPlugin','Job'), - u'Ps': translate('BiblesPlugin','Psalms'), - u'Prov': translate('BiblesPlugin','Proverbs'), - u'Eccl': translate('BiblesPlugin','Ecclesiastes'), - u'Song': translate('BiblesPlugin','Song of Solomon'), - u'Isa': translate('BiblesPlugin','Isaiah'), - u'Jer': translate('BiblesPlugin','Jeremiah'), - u'Lam': translate('BiblesPlugin','Lamentations'), - u'Ezek': translate('BiblesPlugin','Ezekiel'), - u'Dan': translate('BiblesPlugin','Daniel'), - u'Hos': translate('BiblesPlugin','Hosea'), - u'Joel': translate('BiblesPlugin','Joel'), - u'Amos': translate('BiblesPlugin','Amos'), - u'Obad': translate('BiblesPlugin','Obadiah'), - u'Jonah': translate('BiblesPlugin','Jonah'), - u'Mic': translate('BiblesPlugin','Micah'), - u'Nah': translate('BiblesPlugin','Nahum'), - u'Hab': translate('BiblesPlugin','Habakkuk'), - u'Zeph': translate('BiblesPlugin','Zephaniah'), - u'Hag': translate('BiblesPlugin','Haggai'), - u'Zech': translate('BiblesPlugin','Zechariah'), - u'Mal': translate('BiblesPlugin','Malachi'), - u'Matt': translate('BiblesPlugin','Matthew'), - u'Mark': translate('BiblesPlugin','Mark'), - u'Luke': translate('BiblesPlugin','Luke'), - u'John': translate('BiblesPlugin','John'), - u'Acts': translate('BiblesPlugin','Acts'), - u'Rom': translate('BiblesPlugin','Romans'), - u'1Cor': translate('BiblesPlugin','1 Corinthians'), - u'2Cor': translate('BiblesPlugin','2 Corinthians'), - u'Gal': translate('BiblesPlugin','Galatians'), - u'Eph': translate('BiblesPlugin','Ephesians'), - u'Phil': translate('BiblesPlugin','Philippians'), - u'Col': translate('BiblesPlugin','Colossians'), - u'1Thess': translate('BiblesPlugin','1 Thessalonians'), - u'2Thess': translate('BiblesPlugin','2 Thessalonians'), - u'1Tim': translate('BiblesPlugin','1 Timothy'), - u'2Tim': translate('BiblesPlugin','2 Timothy'), - u'Titus': translate('BiblesPlugin','Titus'), - u'Phlm': translate('BiblesPlugin','Philemon'), - u'Heb': translate('BiblesPlugin','Hebrews'), - u'Jas': translate('BiblesPlugin','James'), - u'1Pet': translate('BiblesPlugin','1 Peter'), - u'2Pet': translate('BiblesPlugin','2 Peter'), - u'1John': translate('BiblesPlugin','1 John'), - u'2John': translate('BiblesPlugin','2 John'), - u'3John': translate('BiblesPlugin','3 John'), - u'Jude': translate('BiblesPlugin','Jude'), - u'Rev': translate('BiblesPlugin','Revelation'), - u'Jdt': translate('BiblesPlugin','Judith'), - u'Wis': translate('BiblesPlugin','Wisdom'), - u'Tob': translate('BiblesPlugin','Tobit'), - u'Sir': translate('BiblesPlugin','Sirach'), - u'Bar': translate('BiblesPlugin','Baruch'), - u'1Macc': translate('BiblesPlugin','1 Maccabees'), - u'2Macc': translate('BiblesPlugin','2 Maccabees'), - u'3Macc': translate('BiblesPlugin','3 Maccabees'), - u'4Macc': translate('BiblesPlugin','4 Maccabees'), - u'AddDan': translate('BiblesPlugin','Rest of Daniel'), - u'AddEsth': translate('BiblesPlugin','Rest of Esther'), - u'PrMan': translate('BiblesPlugin','Prayer of Manasses'), - u'LetJer': translate('BiblesPlugin','Letter of Jeremiah'), - u'PrAza': translate('BiblesPlugin','Prayer of Azariah'), - u'Sus': translate('BiblesPlugin','Susanna'), - u'Bel': translate('BiblesPlugin','Bel'), - u'1Esdr': translate('BiblesPlugin','1 Esdras'), - u'2Esdr': translate('BiblesPlugin','2 Esdras') + u'Gen': translate('BiblesPlugin', 'Genesis'), + u'Exod': translate('BiblesPlugin', 'Exodus'), + u'Lev': translate('BiblesPlugin', 'Leviticus'), + u'Num': translate('BiblesPlugin', 'Numbers'), + u'Deut': translate('BiblesPlugin', 'Deuteronomy'), + u'Josh': translate('BiblesPlugin', 'Joshua'), + u'Judg': translate('BiblesPlugin', 'Judges'), + u'Ruth': translate('BiblesPlugin', 'Ruth'), + u'1Sam': translate('BiblesPlugin', '1 Samuel'), + u'2Sam': translate('BiblesPlugin', '2 Samuel'), + u'1Kgs': translate('BiblesPlugin', '1 Kings'), + u'2Kgs': translate('BiblesPlugin', '2 Kings'), + u'1Chr': translate('BiblesPlugin', '1 Chronicles'), + u'2Chr': translate('BiblesPlugin', '2 Chronicles'), + u'Esra': translate('BiblesPlugin', 'Ezra'), + u'Neh': translate('BiblesPlugin', 'Nehemiah'), + u'Esth': translate('BiblesPlugin', 'Esther'), + u'Job': translate('BiblesPlugin', 'Job'), + u'Ps': translate('BiblesPlugin', 'Psalms'), + u'Prov': translate('BiblesPlugin', 'Proverbs'), + u'Eccl': translate('BiblesPlugin', 'Ecclesiastes'), + u'Song': translate('BiblesPlugin', 'Song of Solomon'), + u'Isa': translate('BiblesPlugin', 'Isaiah'), + u'Jer': translate('BiblesPlugin', 'Jeremiah'), + u'Lam': translate('BiblesPlugin', 'Lamentations'), + u'Ezek': translate('BiblesPlugin', 'Ezekiel'), + u'Dan': translate('BiblesPlugin', 'Daniel'), + u'Hos': translate('BiblesPlugin', 'Hosea'), + u'Joel': translate('BiblesPlugin', 'Joel'), + u'Amos': translate('BiblesPlugin', 'Amos'), + u'Obad': translate('BiblesPlugin', 'Obadiah'), + u'Jonah': translate('BiblesPlugin', 'Jonah'), + u'Mic': translate('BiblesPlugin', 'Micah'), + u'Nah': translate('BiblesPlugin', 'Nahum'), + u'Hab': translate('BiblesPlugin', 'Habakkuk'), + u'Zeph': translate('BiblesPlugin', 'Zephaniah'), + u'Hag': translate('BiblesPlugin', 'Haggai'), + u'Zech': translate('BiblesPlugin', 'Zechariah'), + u'Mal': translate('BiblesPlugin', 'Malachi'), + u'Matt': translate('BiblesPlugin', 'Matthew'), + u'Mark': translate('BiblesPlugin', 'Mark'), + u'Luke': translate('BiblesPlugin', 'Luke'), + u'John': translate('BiblesPlugin', 'John'), + u'Acts': translate('BiblesPlugin', 'Acts'), + u'Rom': translate('BiblesPlugin', 'Romans'), + u'1Cor': translate('BiblesPlugin', '1 Corinthians'), + u'2Cor': translate('BiblesPlugin', '2 Corinthians'), + u'Gal': translate('BiblesPlugin', 'Galatians'), + u'Eph': translate('BiblesPlugin', 'Ephesians'), + u'Phil': translate('BiblesPlugin', 'Philippians'), + u'Col': translate('BiblesPlugin', 'Colossians'), + u'1Thess': translate('BiblesPlugin', '1 Thessalonians'), + u'2Thess': translate('BiblesPlugin', '2 Thessalonians'), + u'1Tim': translate('BiblesPlugin', '1 Timothy'), + u'2Tim': translate('BiblesPlugin', '2 Timothy'), + u'Titus': translate('BiblesPlugin', 'Titus'), + u'Phlm': translate('BiblesPlugin', 'Philemon'), + u'Heb': translate('BiblesPlugin', 'Hebrews'), + u'Jas': translate('BiblesPlugin', 'James'), + u'1Pet': translate('BiblesPlugin', '1 Peter'), + u'2Pet': translate('BiblesPlugin', '2 Peter'), + u'1John': translate('BiblesPlugin', '1 John'), + u'2John': translate('BiblesPlugin', '2 John'), + u'3John': translate('BiblesPlugin', '3 John'), + u'Jude': translate('BiblesPlugin', 'Jude'), + u'Rev': translate('BiblesPlugin', 'Revelation'), + u'Jdt': translate('BiblesPlugin', 'Judith'), + u'Wis': translate('BiblesPlugin', 'Wisdom'), + u'Tob': translate('BiblesPlugin', 'Tobit'), + u'Sir': translate('BiblesPlugin', 'Sirach'), + u'Bar': translate('BiblesPlugin', 'Baruch'), + u'1Macc': translate('BiblesPlugin', '1 Maccabees'), + u'2Macc': translate('BiblesPlugin', '2 Maccabees'), + u'3Macc': translate('BiblesPlugin', '3 Maccabees'), + u'4Macc': translate('BiblesPlugin', '4 Maccabees'), + u'AddDan': translate('BiblesPlugin', 'Rest of Daniel'), + u'AddEsth': translate('BiblesPlugin', 'Rest of Esther'), + u'PrMan': translate('BiblesPlugin', 'Prayer of Manasses'), + u'LetJer': translate('BiblesPlugin', 'Letter of Jeremiah'), + u'PrAza': translate('BiblesPlugin', 'Prayer of Azariah'), + u'Sus': translate('BiblesPlugin', 'Susanna'), + u'Bel': translate('BiblesPlugin', 'Bel'), + u'1Esdr': translate('BiblesPlugin', '1 Esdras'), + u'2Esdr': translate('BiblesPlugin', '2 Esdras') } diff --git a/openlp/plugins/bibles/lib/biblestab.py b/openlp/plugins/bibles/lib/biblestab.py index c7028b577..09d340ad4 100644 --- a/openlp/plugins/bibles/lib/biblestab.py +++ b/openlp/plugins/bibles/lib/biblestab.py @@ -279,9 +279,8 @@ class BiblesTab(SettingsTab): self.languageSelectionGroupBox.setTitle( translate('BiblesPlugin.BiblesTab', 'Preferred Bookname Language')) self.languageSelectionLabel.setText(translate('BiblesPlugin.BiblesTab', - 'Choose the language in which the book names of the\nbible should ' - 'be displayed in advanced search or on\nautocompleter in quick ' - 'search:')) + 'Choose the language in which the book names of the\nBible should ' + 'be displayed in the Bible search:')) self.languageSelectionComboBox.setItemText(LanguageSelection.Bible, translate('BiblesPlugin.BiblesTab', 'Bible language')) self.languageSelectionComboBox.setItemText( @@ -291,9 +290,9 @@ class BiblesTab(SettingsTab): translate('BiblesPlugin.BiblesTab', 'English')) self.languageSelectionComboBox.setToolTip( translate('BiblesPlugin.BiblesTab', 'Multiple options:\n ' - 'Bible language - the language in which the bible book names ' - 'was imported\n Application language - the language you have ' - 'choosen for Openlp\n English - use always English booknames')) + 'Bible language - the language in which the Bible book names ' + 'were imported\n Application language - the language you have ' + 'chosen for OpenLP\n English - always use English book names')) def onBibleThemeComboBoxChanged(self): self.bible_theme = self.bibleThemeComboBox.currentText() diff --git a/openlp/plugins/bibles/lib/db.py b/openlp/plugins/bibles/lib/db.py index b419bebc0..c6c2ddac6 100644 --- a/openlp/plugins/bibles/lib/db.py +++ b/openlp/plugins/bibles/lib/db.py @@ -609,7 +609,7 @@ class BiblesResourcesDB(QtCore.QObject, Manager): books = BiblesResourcesDB.run_sql(u'SELECT id, testament_id, name, ' u'abbreviation, chapters FROM book_reference WHERE ' u'LOWER(name) LIKE ? OR LOWER(abbreviation) LIKE ?', - (u'%'+string.lower()+u'%', u'%'+string.lower()+u'%')) + (u'%' + string.lower() + u'%', u'%' + string.lower() + u'%')) if books: return [ { From 8f0e2ba8ec72f4cd36c7bf3785dbda3a8ec2eeb4 Mon Sep 17 00:00:00 2001 From: Philip Ridout Date: Sat, 10 Mar 2012 22:18:52 +0000 Subject: [PATCH 22/28] Fixed mainwindow bug --- openlp/core/ui/thememanager.py | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/openlp/core/ui/thememanager.py b/openlp/core/ui/thememanager.py index 5782ea39f..6ba2e87c2 100644 --- a/openlp/core/ui/thememanager.py +++ b/openlp/core/ui/thememanager.py @@ -52,9 +52,9 @@ class ThemeManager(QtGui.QWidget): """ Manages the orders of Theme. """ - def __init__(self, main_window, parent=None): + def __init__(self, mainwindow, parent=None): QtGui.QWidget.__init__(self, parent) - self.main_window = main_window + self.mainwindow = mainwindow self.settingsSection = u'themes' self.themeForm = ThemeForm(self) self.fileRenameForm = FileRenameForm(self) @@ -282,7 +282,7 @@ class ThemeManager(QtGui.QWidget): old_theme_data = self.getThemeData(old_theme_name) self.cloneThemeData(old_theme_data, new_theme_name) self.deleteTheme(old_theme_name) - for plugin in self.main_window.pluginManager.plugins: + for plugin in self.mainwindow.pluginManager.plugins: if plugin.usesTheme(old_theme_name): plugin.renameTheme(old_theme_name, new_theme_name) self.loadThemes() @@ -665,9 +665,9 @@ class ThemeManager(QtGui.QWidget): self._writeTheme(theme, image_from, image_to) if theme.background_type == \ BackgroundType.to_string(BackgroundType.Image): - self.main_window.imageManager.update_image(theme.theme_name, + self.mainwindow.imageManager.update_image(theme.theme_name, u'theme', QtGui.QColor(theme.background_border_color)) - self.main_window.imageManager.process_updates() + self.mainwindow.imageManager.process_updates() self.loadThemes() def _writeTheme(self, theme, image_from, image_to): @@ -718,12 +718,12 @@ class ThemeManager(QtGui.QWidget): """ Called to update the themes' preview images. """ - self.main_window.displayProgressBar(len(self.theme_list)) + self.mainwindow.displayProgressBar(len(self.theme_list)) for theme in self.theme_list: - self.main_window.incrementProgressBar() + self.mainwindow.incrementProgressBar() self.generateAndSaveImage( self.path, theme, self.getThemeData(theme)) - self.main_window.finishedProgressBar() + self.mainwindow.finishedProgressBar() self.loadThemes() def generateImage(self, theme_data, forcePage=False): @@ -737,7 +737,7 @@ class ThemeManager(QtGui.QWidget): Flag to tell message lines per page need to be generated. """ log.debug(u'generateImage \n%s ', theme_data) - return self.main_window.renderer.generate_preview( + return self.mainwindow.renderer.generate_preview( theme_data, forcePage) def getPreviewImage(self, theme): @@ -791,7 +791,7 @@ class ThemeManager(QtGui.QWidget): return False # check for use in the system else where. if testPlugin: - for plugin in self.main_window.pluginManager.plugins: + for plugin in self.mainwindow.pluginManager.plugins: if plugin.usesTheme(theme): critical_error_message_box( translate('OpenLP.ThemeManager', From bad057e725479f9882f75e737c864cd752200f07 Mon Sep 17 00:00:00 2001 From: Philip Ridout Date: Sat, 10 Mar 2012 22:59:38 +0000 Subject: [PATCH 23/28] Added Raouls fix --- openlp/core/ui/generaltab.py | 1 + 1 file changed, 1 insertion(+) diff --git a/openlp/core/ui/generaltab.py b/openlp/core/ui/generaltab.py index 538c2a545..7c1156078 100644 --- a/openlp/core/ui/generaltab.py +++ b/openlp/core/ui/generaltab.py @@ -53,6 +53,7 @@ class GeneralTab(SettingsTab): """ self.setObjectName(u'GeneralTab') SettingsTab.setupUi(self) + self.tabLayout.setStretch(1, 1) # Monitors self.monitorGroupBox = QtGui.QGroupBox(self.leftColumn) self.monitorGroupBox.setObjectName(u'monitorGroupBox') From 530ac62f32bea8735fb055389318b33f33196730 Mon Sep 17 00:00:00 2001 From: Jonathan Corwin Date: Sun, 11 Mar 2012 16:03:18 +0000 Subject: [PATCH 24/28] Pick a new variable name --- openlp/plugins/songs/lib/xml.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/openlp/plugins/songs/lib/xml.py b/openlp/plugins/songs/lib/xml.py index 4ed3f97d0..abbc58bfc 100644 --- a/openlp/plugins/songs/lib/xml.py +++ b/openlp/plugins/songs/lib/xml.py @@ -681,14 +681,14 @@ class OpenLyrics(object): unicode(translate('OpenLP.OpenLyricsImportError', ' tag is missing.'))) try: - verses = lyrics.verse + verse_list = lyrics.verse except AttributeError: raise OpenLyricsError(OpenLyricsError.VerseError, ' tag is missing.', unicode(translate('OpenLP.OpenLyricsImportError', ' tag is missing.'))) # Loop over the "verse" elements. - for verse in verses: + for verse in verse_list: text = u'' # Loop over the "lines" elements. for lines in verse.lines: From 03f22ae1503a50046c0a609c3652445e56102e5f Mon Sep 17 00:00:00 2001 From: Raoul Snyman Date: Sun, 11 Mar 2012 23:32:43 +0200 Subject: [PATCH 25/28] Refactored things a bit so that I don't rewrite too much code, and fixed up some issues with invalid verses. --- openlp/plugins/songs/forms/editsongform.py | 63 ++++++++++++++-------- 1 file changed, 42 insertions(+), 21 deletions(-) diff --git a/openlp/plugins/songs/forms/editsongform.py b/openlp/plugins/songs/forms/editsongform.py index 94d8f60f1..02b464497 100644 --- a/openlp/plugins/songs/forms/editsongform.py +++ b/openlp/plugins/songs/forms/editsongform.py @@ -578,12 +578,25 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog): self.verseDeleteButton.setEnabled(False) def onVerseOrderTextChanged(self, text): - self._validate_verse_list(text, self.verseListWidget.rowCount()) + verses = [] + verse_names = [] + order = self.__extractVerseOrder(text) + for index in range(0, self.verseListWidget.rowCount()): + verse = self.verseListWidget.item(index, 0) + verse = unicode(verse.data(QtCore.Qt.UserRole).toString()) + if verse not in verse_names: + verses.append(verse) + verse_names.append(u'%s%s' % ( + VerseType.translated_tag(verse[0]), verse[1:])) + verses_not_used = [] + for count, verse in enumerate(verses): + if not verse in order: + verses_not_used.append(verse) + self.warningLabel.setVisible(len(verses_not_used) > 0) - def _validate_verse_list(self, verse_list, verse_count): - errors = [] + def __extractVerseOrder(self, verse_order): order = [] - order_names = unicode(verse_list).split() + order_names = unicode(verse_order).split() for item in order_names: if len(item) == 1: verse_index = VerseType.from_translated_tag(item, None) @@ -601,8 +614,14 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog): verse_tag = VerseType.Tags[verse_index] verse_num = item[1:].lower() order.append(verse_tag + verse_num) + return order + + def __validateVerseList(self, verse_order, verse_count): verses = [] + invalid_verses = [] verse_names = [] + order_names = unicode(verse_order).split() + order = self.__extractVerseOrder(verse_order) for index in range(0, verse_count): verse = self.verseListWidget.item(index, 0) verse = unicode(verse.data(QtCore.Qt.UserRole).toString()) @@ -612,20 +631,22 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog): VerseType.translated_tag(verse[0]), verse[1:])) for count, item in enumerate(order): if item not in verses: - valid = create_separated_list(verse_names) - errors.append(unicode(translate('SongsPlugin.EditSongForm', - 'The verse order is invalid. There is no verse ' - 'corresponding to %s. Valid entries are %s.')) % \ - (order_names[count], valid)) - return False - verses_not_used = [] - for count, verse in enumerate(verses): - if not verse in order: - verses_not_used.append(verse) - self.warningLabel.setVisible(len(verses_not_used) > 0) - return errors + invalid_verses.append(order_names[count]) + if invalid_verses: + valid = create_separated_list(verse_names) + if len(invalid_verses) > 1: + critical_error_message_box(message=unicode(translate( + 'SongsPlugin.EditSongForm', 'The verse order is invalid. ' + 'There are no verses corresponding to %s. Valid entries ' + 'are %s.')) % (u', '.join(invalid_verses), valid)) + else: + critical_error_message_box(message=unicode(translate( + 'SongsPlugin.EditSongForm', 'The verse order is invalid. ' + 'There is no verse corresponding to %s. Valid entries ' + 'are %s.')) % (invalid_verses[0], valid)) + return len(invalid_verses) == 0 - def _validate_song(self): + def __validateSong(self): """ Check the validity of the song. """ @@ -655,10 +676,10 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog): 'You need to have an author for this song.')) return False if self.verseOrderEdit.text(): - errors = self._validate_verse_list(self.verseOrderEdit.text(), + result = self.__validateVerseList(self.verseOrderEdit.text(), self.verseListWidget.rowCount()) - if errors: - critical_error_message_box(message=u'\n\n'.join(errors)) + if not result: + return False item = int(self.songBookComboBox.currentIndex()) text = unicode(self.songBookComboBox.currentText()) if self.songBookComboBox.findText(text, QtCore.Qt.MatchExactly) < 0: @@ -795,7 +816,7 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog): """ log.debug(u'SongEditForm.accept') self.clearCaches() - if self._validate_song(): + if self.__validateSong(): self.saveSong() self.song = None QtGui.QDialog.accept(self) From f188e213913bc851137f00d3609aa8c0a9858b0b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mattias=20P=C3=B5ldaru?= Date: Mon, 12 Mar 2012 10:17:20 +0200 Subject: [PATCH 26/28] Fix mediaPlayer override ComboBox items case. --- openlp/core/ui/media/mediacontroller.py | 7 ++++--- openlp/core/ui/media/phononplayer.py | 2 +- openlp/core/ui/media/vlcplayer.py | 2 +- openlp/core/ui/media/webkitplayer.py | 1 - openlp/plugins/media/lib/mediaitem.py | 10 ++++++---- 5 files changed, 12 insertions(+), 10 deletions(-) diff --git a/openlp/core/ui/media/mediacontroller.py b/openlp/core/ui/media/mediacontroller.py index 3beffbf36..ef15f0721 100644 --- a/openlp/core/ui/media/mediacontroller.py +++ b/openlp/core/ui/media/mediacontroller.py @@ -578,12 +578,13 @@ class MediaController(object): video_list.append(item) return video_list - def override_player(self, override_player): + def override_player(self, override_player_index): playerSettings = str(QtCore.QSettings().value(u'media/players', QtCore.QVariant(u'webkit')).toString()) usedPlayers = playerSettings.split(u',') - if override_player in usedPlayers: - self.overridenPlayer = override_player + if override_player_index >= 0 and \ + override_player_index < len(usedPlayers): + self.overridenPlayer = usedPlayers[override_player_index] else: self.overridenPlayer = '' diff --git a/openlp/core/ui/media/phononplayer.py b/openlp/core/ui/media/phononplayer.py index 98cc598f7..ea4d16260 100644 --- a/openlp/core/ui/media/phononplayer.py +++ b/openlp/core/ui/media/phononplayer.py @@ -31,7 +31,7 @@ from datetime import datetime from PyQt4.phonon import Phonon -from openlp.core.lib import Receiver, Translate +from openlp.core.lib import Receiver from openlp.core.lib.mediaplayer import MediaPlayer from openlp.core.ui.media import MediaState diff --git a/openlp/core/ui/media/vlcplayer.py b/openlp/core/ui/media/vlcplayer.py index 6bbcff2a5..da43c9839 100644 --- a/openlp/core/ui/media/vlcplayer.py +++ b/openlp/core/ui/media/vlcplayer.py @@ -43,7 +43,7 @@ except OSError, e: raise from PyQt4 import QtCore, QtGui -from openlp.core.lib import Receiver, translate +from openlp.core.lib import Receiver from openlp.core.lib.mediaplayer import MediaPlayer from openlp.core.ui.media import MediaState diff --git a/openlp/core/ui/media/webkitplayer.py b/openlp/core/ui/media/webkitplayer.py index 86e96bf67..2c2619dbd 100644 --- a/openlp/core/ui/media/webkitplayer.py +++ b/openlp/core/ui/media/webkitplayer.py @@ -27,7 +27,6 @@ import logging -from openlp.core.lib import translate from openlp.core.lib.mediaplayer import MediaPlayer from openlp.core.ui.media import MediaState diff --git a/openlp/plugins/media/lib/mediaitem.py b/openlp/plugins/media/lib/mediaitem.py index 111a86209..eaf6f0edc 100644 --- a/openlp/plugins/media/lib/mediaitem.py +++ b/openlp/plugins/media/lib/mediaitem.py @@ -104,7 +104,7 @@ class MediaMediaItem(MediaManagerItem): self.automatic = translate('MediaPlugin.MediaItem', 'Automatic') self.displayTypeLabel.setText( - translate('MediaPlugin.MediaItem', 'Use Player:')) + translate('MediaPlugin.MediaItem', 'Use &Player:')) def requiredIcons(self): MediaManagerItem.requiredIcons(self) @@ -142,8 +142,8 @@ class MediaMediaItem(MediaManagerItem): self.overridePlayerChanged) def overridePlayerChanged(self, index): - Receiver.send_message(u'media_override_player', \ - u'%s' % self.displayTypeComboBox.currentText()) + # index - 1, because the first item is "Automatic". + Receiver.send_message(u'media_override_player', index - 1) def onResetClick(self): """ @@ -249,8 +249,10 @@ class MediaMediaItem(MediaManagerItem): playerSettings = str(QtCore.QSettings().value(u'media/players', QtCore.QVariant(u'webkit')).toString()) usedPlayers = playerSettings.split(u',') - for title in usedPlayers: + mediaPlayers = self.plugin.mediaController.mediaPlayers + for player in usedPlayers: # load the drop down selection + title = mediaPlayers[player].original_name self.displayTypeComboBox.addItem(title) if self.displayTypeComboBox.count() > 1: self.displayTypeComboBox.insertItem(0, self.automatic) From 83341b704c8d27aed54431d91ff867429fbbd6c4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mattias=20P=C3=B5ldaru?= Date: Mon, 12 Mar 2012 12:53:17 +0200 Subject: [PATCH 27/28] Revert string changes. --- openlp/plugins/media/lib/mediaitem.py | 5 ++--- openlp/plugins/media/lib/mediatab.py | 4 ++-- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/openlp/plugins/media/lib/mediaitem.py b/openlp/plugins/media/lib/mediaitem.py index 1d995d84a..d0aec2691 100644 --- a/openlp/plugins/media/lib/mediaitem.py +++ b/openlp/plugins/media/lib/mediaitem.py @@ -104,7 +104,7 @@ class MediaMediaItem(MediaManagerItem): self.automatic = translate('MediaPlugin.MediaItem', 'Automatic') self.displayTypeLabel.setText( - translate('MediaPlugin.MediaItem', 'Use &Player:')) + translate('MediaPlugin.MediaItem', 'Use Player:')) def requiredIcons(self): MediaManagerItem.requiredIcons(self) @@ -252,8 +252,7 @@ class MediaMediaItem(MediaManagerItem): mediaPlayers = self.plugin.mediaController.mediaPlayers for player in usedPlayers: # load the drop down selection - title = mediaPlayers[player].original_name - self.displayTypeComboBox.addItem(title) + self.displayTypeComboBox.addItem(mediaPlayers[player].original_name) if self.displayTypeComboBox.count() > 1: self.displayTypeComboBox.insertItem(0, self.automatic) self.displayTypeComboBox.setCurrentIndex(0) diff --git a/openlp/plugins/media/lib/mediatab.py b/openlp/plugins/media/lib/mediatab.py index f245229c4..a93dcf5a9 100644 --- a/openlp/plugins/media/lib/mediatab.py +++ b/openlp/plugins/media/lib/mediatab.py @@ -125,11 +125,11 @@ class MediaTab(SettingsTab): unicode(translate('MediaPlugin.MediaTab', '%s (unavailable)')) % player.display_name) self.playerOrderGroupBox.setTitle( - translate('MediaPlugin.MediaTab', 'Player O&rder')) + translate('MediaPlugin.MediaTab', 'Player Order')) self.advancedGroupBox.setTitle(UiStrings().Advanced) self.overridePlayerCheckBox.setText( translate('MediaPlugin.MediaTab', - '&Allow media player to be overridden')) + 'Allow media player to be overridden')) def onPlayerCheckBoxChanged(self, check_state): player = self.sender().playerName From ccba9e7df53e6e26da8c6a01d39ed0981a9a5645 Mon Sep 17 00:00:00 2001 From: Raoul Snyman Date: Mon, 12 Mar 2012 23:05:39 +0200 Subject: [PATCH 28/28] Fixed bug #888815 where the files were not being loaded into the audio player because their paths were not absolute. Now when the files are loaded from the saved service file, the paths recreated properly. Fixes: https://launchpad.net/bugs/888815 --- openlp/core/lib/serviceitem.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/openlp/core/lib/serviceitem.py b/openlp/core/lib/serviceitem.py index 9878e1f24..42e140381 100644 --- a/openlp/core/lib/serviceitem.py +++ b/openlp/core/lib/serviceitem.py @@ -325,7 +325,10 @@ class ServiceItem(object): if u'media_length' in header: self.media_length = header[u'media_length'] if u'background_audio' in header: - self.background_audio = header[u'background_audio'] + self.background_audio = [] + for filename in header[u'background_audio']: + # Give them real file paths + self.background_audio.append(os.path.join(path, filename)) self.theme_overwritten = header.get(u'theme_overwritten', False) if self.service_item_type == ServiceItemType.Text: for slide in serviceitem[u'serviceitem'][u'data']: