From fbaa6678a975045e83a5d10cae8c186a9dd28518 Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Wed, 26 Jan 2011 18:00:46 +0000 Subject: [PATCH 01/43] Up is Up and Down is Up ? --- openlp/core/ui/servicemanager.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openlp/core/ui/servicemanager.py b/openlp/core/ui/servicemanager.py index d1a3e6762..14fe7a629 100644 --- a/openlp/core/ui/servicemanager.py +++ b/openlp/core/ui/servicemanager.py @@ -179,7 +179,7 @@ class ServiceManager(QtGui.QWidget): None, translate('OpenLP.ServiceManager', 'Moves the selection up the window.'), - self.onMoveSelectionDown, shortcut=QtCore.Qt.Key_Up) + self.onMoveSelectionDown, shortcut=QtCore.Qt.Key_Down) self.serviceManagerList.down.setVisible(False) self.serviceManagerList.up = self.orderToolbar.addToolbarButton( translate('OpenLP.ServiceManager', 'Move up'), From a600e37a34fd2e8dcf9307a57ca7bd86d6363215 Mon Sep 17 00:00:00 2001 From: Jon Tibble Date: Wed, 26 Jan 2011 19:35:29 +0000 Subject: [PATCH 02/43] Remove duplicate definitions --- openlp/plugins/songs/lib/sofimport.py | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/openlp/plugins/songs/lib/sofimport.py b/openlp/plugins/songs/lib/sofimport.py index 96a514f85..cfb80caa3 100644 --- a/openlp/plugins/songs/lib/sofimport.py +++ b/openlp/plugins/songs/lib/sofimport.py @@ -39,9 +39,7 @@ from oooimport import OooImport if os.name == u'nt': BOLD = 150.0 ITALIC = 2 - PAGE_BEFORE = 4 - PAGE_AFTER = 5 - PAGE_BOTH = 6 + from oooimport import PAGE_BEFORE, PAGE_AFTER, PAGE_BOTH else: try: from com.sun.star.awt.FontWeight import BOLD @@ -306,7 +304,6 @@ class SofImport(OooImport): self.currentverse = u'' self.is_chorus = False - def uncap_text(self, text): """ Words in the title are in all capitals, so we lowercase them. From 6e435e47e642de5a4da068ef0157d036edefe5af Mon Sep 17 00:00:00 2001 From: Jon Tibble Date: Wed, 26 Jan 2011 23:26:09 +0000 Subject: [PATCH 03/43] Remove a few redundancies --- openlp/plugins/bibles/lib/mediaitem.py | 3 --- openlp/plugins/images/lib/mediaitem.py | 1 - openlp/plugins/media/lib/mediaitem.py | 1 - openlp/plugins/songs/lib/songimport.py | 5 +---- 4 files changed, 1 insertion(+), 9 deletions(-) diff --git a/openlp/plugins/bibles/lib/mediaitem.py b/openlp/plugins/bibles/lib/mediaitem.py index f5e7b3966..614990654 100644 --- a/openlp/plugins/bibles/lib/mediaitem.py +++ b/openlp/plugins/bibles/lib/mediaitem.py @@ -254,9 +254,6 @@ class BibleMediaItem(MediaManagerItem): QtCore.QObject.connect(self.quickSearchEdit, QtCore.SIGNAL(u'returnPressed()'), self.onQuickSearchButton) - def addListViewToToolBar(self): - MediaManagerItem.addListViewToToolBar(self) - def configUpdated(self): log.debug(u'configUpdated') if QtCore.QSettings().value(self.settingsSection + u'/second bibles', diff --git a/openlp/plugins/images/lib/mediaitem.py b/openlp/plugins/images/lib/mediaitem.py index d55735188..73f5b80f0 100644 --- a/openlp/plugins/images/lib/mediaitem.py +++ b/openlp/plugins/images/lib/mediaitem.py @@ -96,7 +96,6 @@ class ImageMediaItem(MediaManagerItem): def addListViewToToolBar(self): MediaManagerItem.addListViewToToolBar(self) - self.listView.setContextMenuPolicy(QtCore.Qt.ActionsContextMenu) self.listView.addAction(self.replaceAction) def addEndHeaderBar(self): diff --git a/openlp/plugins/media/lib/mediaitem.py b/openlp/plugins/media/lib/mediaitem.py index 1b5d6b8d8..e7beb81a9 100644 --- a/openlp/plugins/media/lib/mediaitem.py +++ b/openlp/plugins/media/lib/mediaitem.py @@ -84,7 +84,6 @@ class MediaMediaItem(MediaManagerItem): def addListViewToToolBar(self): MediaManagerItem.addListViewToToolBar(self) - self.listView.setContextMenuPolicy(QtCore.Qt.ActionsContextMenu) self.listView.addAction(self.replaceAction) def addEndHeaderBar(self): diff --git a/openlp/plugins/songs/lib/songimport.py b/openlp/plugins/songs/lib/songimport.py index cab0aacf6..592aa7ac1 100644 --- a/openlp/plugins/songs/lib/songimport.py +++ b/openlp/plugins/songs/lib/songimport.py @@ -227,7 +227,7 @@ class SongImport(QtCore.QObject): self.versecounts[versetag[0]] = int(versetag[1:]) self.verses.append([versetag, versetext.rstrip(), lang]) self.verse_order_list.append(versetag) - if versetag.startswith(u'V') and self.contains_verse(u'C1'): + if versetag.startswith(u'V') and u'C1' in self.verse_order_list: self.verse_order_list.append(u'C1') def repeat_verse(self): @@ -236,9 +236,6 @@ class SongImport(QtCore.QObject): """ self.verse_order_list.append(self.verse_order_list[-1]) - def contains_verse(self, versetag): - return versetag in self.verse_order_list - def check_complete(self): """ Check the mandatory fields are entered (i.e. title and a verse) From 9211c49bb2aaa79afe037eb772d6183846918e60 Mon Sep 17 00:00:00 2001 From: Jon Tibble Date: Thu, 27 Jan 2011 03:13:43 +0000 Subject: [PATCH 04/43] Fix CSV bible imports part 1 --- openlp/plugins/bibles/lib/csvbible.py | 145 +++++++++++++++++++++----- openlp/plugins/bibles/lib/db.py | 8 +- 2 files changed, 127 insertions(+), 26 deletions(-) diff --git a/openlp/plugins/bibles/lib/csvbible.py b/openlp/plugins/bibles/lib/csvbible.py index 8959167a6..87b08d8b8 100644 --- a/openlp/plugins/bibles/lib/csvbible.py +++ b/openlp/plugins/bibles/lib/csvbible.py @@ -23,7 +23,45 @@ # with this program; if not, write to the Free Software Foundation, Inc., 59 # # Temple Place, Suite 330, Boston, MA 02111-1307 USA # ############################################################################### +""" +The :mod:`cvsbible` modules provides a facility to import bibles from a set of +CSV files. +The module expects two mandatory files containing the books and the verses and +will accept an optional third file containing the testaments. + +The format of the testament file is: + + , + + For example: + + 1,Old Testament + 2,New Testament + +The format of the books file is: + + ,,, + + For example + + 1,1,Genesis,Gen + 2,1,Exodus,Exod + ... + 40,2,Matthew,Matt + +The format of the verses file is: + + ,,, + + For example: + + 1,1,1,"In the beginning God created the heaven and the earth." + 1,1,2,"And the earth was without form, and void; and darkness...." + +All CSV files are expected to use a comma (',') as the delimeter and double +quotes ('"') as the quote symbol. +""" import logging import chardet import csv @@ -39,68 +77,110 @@ class CSVBible(BibleDB): """ This class provides a specialisation for importing of CSV Bibles. """ - def __init__(self, parent, **kwargs): """ - Loads a Bible from a pair of CVS files passed in + Loads a Bible from a set of CVS files. This class assumes the files contain all the information and a clean bible is being loaded. """ log.info(self.__class__.__name__) BibleDB.__init__(self, parent, **kwargs) + try: + self.testamentsfile = kwargs[u'testamentsfile'] + except KeyError: + self.testamentsfile = None self.booksfile = kwargs[u'booksfile'] self.versesfile = kwargs[u'versefile'] QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'openlp_stop_wizard'), self.stop_import) + def setup_testaments(self): + """ + Overrides parent method so we can handle importing a testament file. + """ + if self.testamentsfile: + self.wizard.progressBar.setMinimum(0) + self.wizard.progressBar.setMaximum(2) + self.wizard.progressBar.setValue(0) + testaments_file = None + try: + details = get_file_encoding(self.testamentsfile) + testaments_file = open(self.testamentsfile, 'rb') + testaments_reader = csv.reader(testaments_file, delimiter=',', + quotechar='"') + for line in testaments_reader: + if self.stop_import_flag: + break + self.wizard.incrementProgressBar(unicode( + translate('BibleDB.Wizard', + 'Importing testaments... %s')) % + unicode(line[1], details['encoding']), 0) + self.save_object(Testament.populate( + name=unicode(line[1], details['encoding']))) + Receiver.send_message(u'openlp_process_events') + except (IOError, IndexError): + log.exception(u'Loading testaments from file failed') + finally: + if testaments_file: + testaments_file.close() + self.wizard.incrementProgressBar(unicode(translate( + 'BibleDB.Wizard', 'Importing testaments... done.')), 2) + else: + BibleDB.setup_testaments(self) + def do_import(self): + """ + Import the bible books and verses. + """ + self.wizard.progressBar.setValue(0) + self.wizard.progressBar.setMinimum(0) + self.wizard.progressBar.setMaximum(65) success = True books_file = None - book_ptr = None - verse_file = None + book_list = {} # Populate the Tables try: + details = get_file_encoding(self.booksfile) books_file = open(self.booksfile, 'r') - dialect = csv.Sniffer().sniff(books_file.read(1024)) - books_file.seek(0) - books_reader = csv.reader(books_file, dialect) + books_reader = csv.reader(books_file, delimiter=',', quotechar='"') for line in books_reader: - # cancel pressed if self.stop_import_flag: break - details = chardet.detect(line[1]) - self.create_book(unicode(line[1], details['encoding']), - line[2], int(line[0])) - Receiver.send_message(u'openlp_process_events') + self.wizard.incrementProgressBar(unicode( + translate('BibleDB.Wizard', 'Importing books... %s')) % + unicode(line[2], details['encoding'])) + self.create_book(unicode(line[2], details['encoding']), + unicode(line[3], details['encoding']), int(line[1])) + book_list[int(line[0])] = unicode(line[2], details['encoding']) + Receiver.send_message(u'openlp_process_events') except (IOError, IndexError): log.exception(u'Loading books from file failed') success = False finally: if books_file: books_file.close() - if not success: + if self.stop_import_flag or not success: return False + self.wizard.progressBar.setValue(0) + verse_file = None try: - verse_file = open(self.versesfile, 'r') - dialect = csv.Sniffer().sniff(verse_file.read(1024)) - verse_file.seek(0) - verse_reader = csv.reader(verse_file, dialect) + book_ptr = None + details = get_file_encoding(self.versesfile) + verse_file = open(self.versesfile, 'rb') + verse_reader = csv.reader(verse_file, delimiter=',', quotechar='"') for line in verse_reader: if self.stop_import_flag: - # cancel pressed break - details = chardet.detect(line[3]) - if book_ptr != line[0]: - book = self.get_book(line[0]) + if book_ptr != book_list[int(line[0])]: + book = self.get_book(book_list[int(line[0])]) book_ptr = book.name self.wizard.incrementProgressBar(unicode(translate( - 'BiblesPlugin.CSVImport', 'Importing %s %s...', - 'Importing ...')) % - (book.name, int(line[1]))) + 'BibleDB.Wizard', 'Importing verses from %s...', + 'Importing verses from ...')) % book.name) self.session.commit() self.create_verse(book.id, line[1], line[2], unicode(line[3], details['encoding'])) - Receiver.send_message(u'openlp_process_events') + Receiver.send_message(u'openlp_process_events') self.session.commit() except IOError: log.exception(u'Loading verses from file failed') @@ -112,3 +192,18 @@ class CSVBible(BibleDB): return False else: return success + +def get_file_encoding(filename): + """ + Utility function to get the file encoding. + """ + detect_file = None + try: + detect_file = open(filename, 'r') + details = chardet.detect(detect_file.read(1024)) + except IOError: + log.exception(u'Error detecting file encoding') + finally: + if detect_file: + detect_file.close() + return details diff --git a/openlp/plugins/bibles/lib/db.py b/openlp/plugins/bibles/lib/db.py index f442a9cd6..a9444d88b 100644 --- a/openlp/plugins/bibles/lib/db.py +++ b/openlp/plugins/bibles/lib/db.py @@ -206,10 +206,16 @@ class BibleDB(QtCore.QObject, Manager): """ self.wizard = wizard self.create_meta(u'dbversion', u'2') + self.setup_testaments() + return self.name + + def setup_testaments(self): + """ + Initialise the testaments section of a bible with suitable defaults. + """ self.save_object(Testament.populate(name=u'Old Testament')) self.save_object(Testament.populate(name=u'New Testament')) self.save_object(Testament.populate(name=u'Apocrypha')) - return self.name def create_book(self, name, abbrev, testament=1): """ From a2894b850ff43c3c626ccb741a33ead8eba73e5e Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Thu, 27 Jan 2011 17:40:17 +0100 Subject: [PATCH 05/43] only allow to select one slide in the slidecontrollers --- openlp/core/ui/slidecontroller.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/openlp/core/ui/slidecontroller.py b/openlp/core/ui/slidecontroller.py index 7266d197c..916bf68c3 100644 --- a/openlp/core/ui/slidecontroller.py +++ b/openlp/core/ui/slidecontroller.py @@ -119,6 +119,8 @@ class SlideController(QtGui.QWidget): self.previewListWidget.isLive = self.isLive self.previewListWidget.setObjectName(u'PreviewListWidget') self.previewListWidget.setSelectionBehavior(1) + self.previewListWidget.setSelectionMode( + QtGui.QAbstractItemView.SingleSelection) self.previewListWidget.setEditTriggers( QtGui.QAbstractItemView.NoEditTriggers) self.previewListWidget.setHorizontalScrollBarPolicy( From c3699b294fc69a74d0bee39a459dd8aae0935539 Mon Sep 17 00:00:00 2001 From: Jon Tibble Date: Thu, 27 Jan 2011 16:45:23 +0000 Subject: [PATCH 06/43] Fix CSV bible imports part 2 --- .../plugins/bibles/forms/bibleimportform.py | 55 ++++++++++++++++--- openlp/plugins/bibles/lib/csvbible.py | 2 +- 2 files changed, 47 insertions(+), 10 deletions(-) diff --git a/openlp/plugins/bibles/forms/bibleimportform.py b/openlp/plugins/bibles/forms/bibleimportform.py index d3f41804b..3e43d19aa 100644 --- a/openlp/plugins/bibles/forms/bibleimportform.py +++ b/openlp/plugins/bibles/forms/bibleimportform.py @@ -124,9 +124,12 @@ class BibleImportForm(OpenLPWizard): QtCore.QObject.connect(self.osisBrowseButton, QtCore.SIGNAL(u'clicked()'), self.onOsisBrowseButtonClicked) + QtCore.QObject.connect(self.csvTestamentsButton, + QtCore.SIGNAL(u'clicked()'), + self.onCsvTestamentsBrowseButtonClicked) QtCore.QObject.connect(self.csvBooksButton, QtCore.SIGNAL(u'clicked()'), - self.onBooksBrowseButtonClicked) + self.onCsvBooksBrowseButtonClicked) QtCore.QObject.connect(self.csvVersesButton, QtCore.SIGNAL(u'clicked()'), self.onCsvVersesBrowseButtonClicked) @@ -187,6 +190,18 @@ class BibleImportForm(OpenLPWizard): self.csvLayout = QtGui.QFormLayout(self.csvWidget) self.csvLayout.setMargin(0) self.csvLayout.setObjectName(u'CsvLayout') + self.csvTestamentsLabel = QtGui.QLabel(self.csvWidget) + self.csvTestamentsLabel.setObjectName(u'CsvTestamentsLabel') + self.csvTestamentsLayout = QtGui.QHBoxLayout() + self.csvTestamentsLayout.setObjectName(u'CsvTestamentsLayout') + self.csvTestamentsEdit = QtGui.QLineEdit(self.csvWidget) + self.csvTestamentsEdit.setObjectName(u'CsvTestamentsEdit') + self.csvTestamentsLayout.addWidget(self.csvTestamentsEdit) + self.csvTestamentsButton = QtGui.QToolButton(self.csvWidget) + self.csvTestamentsButton.setIcon(self.openIcon) + self.csvTestamentsButton.setObjectName(u'CsvTestamentsButton') + self.csvTestamentsLayout.addWidget(self.csvTestamentsButton) + self.csvLayout.addRow(self.csvTestamentsLabel, self.csvTestamentsLayout) self.csvBooksLabel = QtGui.QLabel(self.csvWidget) self.csvBooksLabel.setObjectName(u'CsvBooksLabel') self.csvBooksLayout = QtGui.QHBoxLayout() @@ -213,7 +228,7 @@ class BibleImportForm(OpenLPWizard): self.csvLayout.addRow(self.csvVersesLabel, self.csvVersesLayout) self.csvSpacer = QtGui.QSpacerItem(10, 0, QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Minimum) - self.csvLayout.setItem(2, QtGui.QFormLayout.LabelRole, self.csvSpacer) + self.csvLayout.setItem(3, QtGui.QFormLayout.LabelRole, self.csvSpacer) self.selectStack.addWidget(self.csvWidget) self.openSongWidget = QtGui.QWidget(self.selectPage) self.openSongWidget.setObjectName(u'OpenSongWidget') @@ -389,6 +404,8 @@ class BibleImportForm(OpenLPWizard): translate('BiblesPlugin.ImportWizardForm', 'File location:')) self.osisFileLabel.setText( translate('BiblesPlugin.ImportWizardForm', 'File location:')) + self.csvTestamentsLabel.setText( + translate('BiblesPlugin.ImportWizardForm', 'Testaments location:')) self.csvBooksLabel.setText( translate('BiblesPlugin.ImportWizardForm', 'Books location:')) self.csvVersesLabel.setText( @@ -478,7 +495,16 @@ class BibleImportForm(OpenLPWizard): self.osisFileEdit.setFocus() return False elif self.field(u'source_format').toInt()[0] == BibleFormat.CSV: - if not self.field(u'csv_booksfile').toString(): + if not self.field(u'csv_testamentsfile').toString(): + answer = criticalErrorMessageBox(translate( + 'BiblesPlugin.ImportWizardForm', 'No Testaments File'), + translate('BiblesPlugin.ImportWizardForm', + 'You have not specified a testaments file. Do you ' + 'want to proceed with the import?'), question=True) + if answer == QtGui.QMessageBox.No: + self.csvTestamentsEdit.setFocus() + return False + elif not self.field(u'csv_booksfile').toString(): criticalErrorMessageBox( translate('BiblesPlugin.ImportWizardForm', 'Invalid Books File'), @@ -572,7 +598,15 @@ class BibleImportForm(OpenLPWizard): translate('BiblesPlugin.ImportWizardForm', 'Open OSIS File'), self.osisFileEdit) - def onBooksBrowseButtonClicked(self): + def onCsvTestamentsBrowseButtonClicked(self): + """ + Show the file open dialog for the testaments CSV file. + """ + self.getFileName(translate('BiblesPlugin.ImportWizardForm', + 'Open Testaments CSV File'), self.csvTestamentsEdit, u'%s (*.csv)' + % translate('BiblesPlugin.ImportWizardForm', 'CSV File')) + + def onCsvBooksBrowseButtonClicked(self): """ Show the file open dialog for the books CSV file. """ @@ -613,12 +647,14 @@ class BibleImportForm(OpenLPWizard): """ self.selectPage.registerField(u'source_format', self.formatComboBox) self.selectPage.registerField(u'osis_location', self.osisFileEdit) + self.selectPage.registerField( + u'csv_testamentsfile', self.csvTestamentsEdit) self.selectPage.registerField(u'csv_booksfile', self.csvBooksEdit) self.selectPage.registerField(u'csv_versefile', self.csvVersesEdit) self.selectPage.registerField(u'opensong_file', self.openSongFileEdit) self.selectPage.registerField(u'web_location', self.webSourceComboBox) - self.selectPage.registerField(u'web_biblename', - self.webTranslationComboBox) + self.selectPage.registerField( + u'web_biblename', self.webTranslationComboBox) self.selectPage.registerField(u'proxy_server', self.webServerEdit) self.selectPage.registerField(u'proxy_username', self.webUserEdit) self.selectPage.registerField(u'proxy_password', self.webPasswordEdit) @@ -641,6 +677,7 @@ class BibleImportForm(OpenLPWizard): self.cancelButton.setVisible(True) self.setField(u'source_format', QtCore.QVariant(0)) self.setField(u'osis_location', QtCore.QVariant('')) + self.setField(u'csv_testamentsfile', QtCore.QVariant('')) self.setField(u'csv_booksfile', QtCore.QVariant('')) self.setField(u'csv_versefile', QtCore.QVariant('')) self.setField(u'opensong_file', QtCore.QVariant('')) @@ -770,7 +807,8 @@ class BibleImportForm(OpenLPWizard): elif bible_type == BibleFormat.CSV: # Import a CSV bible. importer = self.manager.import_bible(BibleFormat.CSV, - name=license_version, + name=license_version, testamentsfile=unicode( + self.field(u'csv_testamentsfile').toString()), booksfile=unicode(self.field(u'csv_booksfile').toString()), versefile=unicode(self.field(u'csv_versefile').toString()) ) @@ -795,8 +833,7 @@ class BibleImportForm(OpenLPWizard): bible = \ self.web_bible_list[WebDownload.Bibleserver][bible_version] importer = self.manager.import_bible( - BibleFormat.WebDownload, - name=license_version, + BibleFormat.WebDownload, name=license_version, download_source=WebDownload.get_name(download_location), download_name=bible, proxy_server=unicode(self.field(u'proxy_server').toString()), diff --git a/openlp/plugins/bibles/lib/csvbible.py b/openlp/plugins/bibles/lib/csvbible.py index 87b08d8b8..58b4924c3 100644 --- a/openlp/plugins/bibles/lib/csvbible.py +++ b/openlp/plugins/bibles/lib/csvbible.py @@ -69,7 +69,7 @@ import csv from PyQt4 import QtCore from openlp.core.lib import Receiver, translate -from openlp.plugins.bibles.lib.db import BibleDB +from openlp.plugins.bibles.lib.db import BibleDB, Testament log = logging.getLogger(__name__) From 0831f733067e2e45bf068540815a6ff6ed7d7bf9 Mon Sep 17 00:00:00 2001 From: Jon Tibble Date: Thu, 27 Jan 2011 16:55:49 +0000 Subject: [PATCH 07/43] CSV bible import progress bar tweaks --- openlp/plugins/bibles/lib/csvbible.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/openlp/plugins/bibles/lib/csvbible.py b/openlp/plugins/bibles/lib/csvbible.py index 58b4924c3..fd987dfdf 100644 --- a/openlp/plugins/bibles/lib/csvbible.py +++ b/openlp/plugins/bibles/lib/csvbible.py @@ -134,7 +134,7 @@ class CSVBible(BibleDB): """ self.wizard.progressBar.setValue(0) self.wizard.progressBar.setMinimum(0) - self.wizard.progressBar.setMaximum(65) + self.wizard.progressBar.setMaximum(66) success = True books_file = None book_list = {} @@ -162,6 +162,7 @@ class CSVBible(BibleDB): if self.stop_import_flag or not success: return False self.wizard.progressBar.setValue(0) + self.wizard.progressBar.setMaximum(67) verse_file = None try: book_ptr = None @@ -180,6 +181,8 @@ class CSVBible(BibleDB): self.session.commit() self.create_verse(book.id, line[1], line[2], unicode(line[3], details['encoding'])) + self.wizard.incrementProgressBar(translate('BibleDB.Wizard', + 'Importing verses... done.')) Receiver.send_message(u'openlp_process_events') self.session.commit() except IOError: From 3d510596e4cf95130b3dbf2a37a48e7886ae7984 Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Thu, 27 Jan 2011 17:59:15 +0100 Subject: [PATCH 08/43] make curosr busy when merging authors/topics/books --- .../songs/forms/songmaintenanceform.py | 200 ++++++++++-------- 1 file changed, 106 insertions(+), 94 deletions(-) diff --git a/openlp/plugins/songs/forms/songmaintenanceform.py b/openlp/plugins/songs/forms/songmaintenanceform.py index 93a01623e..6613a050b 100644 --- a/openlp/plugins/songs/forms/songmaintenanceform.py +++ b/openlp/plugins/songs/forms/songmaintenanceform.py @@ -278,117 +278,129 @@ class SongMaintenanceForm(QtGui.QDialog, Ui_SongMaintenanceDialog): def onAuthorEditButtonClick(self): author_id = self._getCurrentItemId(self.authorsListWidget) - if author_id != -1: - author = self.manager.get_object(Author, author_id) - self.authorform.setAutoDisplayName(False) - self.authorform.firstNameEdit.setText(author.first_name) - self.authorform.lastNameEdit.setText(author.last_name) - self.authorform.displayEdit.setText(author.display_name) - # Save the author's first and last name as well as the display name - # for the case that they have to be restored. - temp_first_name = author.first_name - temp_last_name = author.last_name - temp_display_name = author.display_name - if self.authorform.exec_(False): - author.first_name = unicode( - self.authorform.firstNameEdit.text()) - author.last_name = unicode(self.authorform.lastNameEdit.text()) - author.display_name = unicode( - self.authorform.displayEdit.text()) - if self.checkAuthor(author, True): - if self.manager.save_object(author): - self.resetAuthors() - Receiver.send_message(u'songs_load_list') - else: - criticalErrorMessageBox( - message=translate('SongsPlugin.SongMaintenanceForm', - 'Could not save your changes.')) - elif criticalErrorMessageBox(message=unicode(translate( - 'SongsPlugin.SongMaintenanceForm', 'The author %s already ' - 'exists. Would you like to make songs with author %s use ' - 'the existing author %s?')) % (author.display_name, - temp_display_name, author.display_name), - parent=self, question=True) == QtGui.QMessageBox.Yes: - self.mergeAuthors(author) + if author_id == -1: + return + author = self.manager.get_object(Author, author_id) + self.authorform.setAutoDisplayName(False) + self.authorform.firstNameEdit.setText(author.first_name) + self.authorform.lastNameEdit.setText(author.last_name) + self.authorform.displayEdit.setText(author.display_name) + # Save the author's first and last name as well as the display name + # for the case that they have to be restored. + temp_first_name = author.first_name + temp_last_name = author.last_name + temp_display_name = author.display_name + if self.authorform.exec_(False): + author.first_name = unicode( + self.authorform.firstNameEdit.text()) + author.last_name = unicode(self.authorform.lastNameEdit.text()) + author.display_name = unicode( + self.authorform.displayEdit.text()) + if self.checkAuthor(author, True): + if self.manager.save_object(author): self.resetAuthors() Receiver.send_message(u'songs_load_list') else: - # We restore the author's old first and last name as well as - # his display name. - author.first_name = temp_first_name - author.last_name = temp_last_name - author.display_name = temp_display_name criticalErrorMessageBox( message=translate('SongsPlugin.SongMaintenanceForm', - 'Could not save your modified author, because the ' - 'author already exists.')) + 'Could not save your changes.')) + elif criticalErrorMessageBox(message=unicode(translate( + 'SongsPlugin.SongMaintenanceForm', 'The author %s already ' + 'exists. Would you like to make songs with author %s use ' + 'the existing author %s?')) % (author.display_name, + temp_display_name, author.display_name), + parent=self, question=True) == QtGui.QMessageBox.Yes: + Receiver.send_message(u'cursor_busy') + Receiver.send_message(u'openlp_process_events') + self.mergeAuthors(author) + self.resetAuthors() + Receiver.send_message(u'songs_load_list') + Receiver.send_message(u'cursor_normal') + else: + # We restore the author's old first and last name as well as + # his display name. + author.first_name = temp_first_name + author.last_name = temp_last_name + author.display_name = temp_display_name + criticalErrorMessageBox( + message=translate('SongsPlugin.SongMaintenanceForm', + 'Could not save your modified author, because the ' + 'author already exists.')) def onTopicEditButtonClick(self): topic_id = self._getCurrentItemId(self.topicsListWidget) - if topic_id != -1: - topic = self.manager.get_object(Topic, topic_id) - self.topicform.nameEdit.setText(topic.name) - # Save the topic's name for the case that he has to be restored. - temp_name = topic.name - if self.topicform.exec_(False): - topic.name = unicode(self.topicform.nameEdit.text()) - if self.checkTopic(topic, True): - if self.manager.save_object(topic): - self.resetTopics() - else: - criticalErrorMessageBox( - message=translate('SongsPlugin.SongMaintenanceForm', - 'Could not save your changes.')) - elif criticalErrorMessageBox( - message=unicode(translate('SongsPlugin.SongMaintenanceForm', - 'The topic %s already exists. Would you like to make songs ' - 'with topic %s use the existing topic %s?')) % (topic.name, - temp_name, topic.name), - parent=self, question=True) == QtGui.QMessageBox.Yes: - self.mergeTopics(topic) + if topic_id == -1: + return + topic = self.manager.get_object(Topic, topic_id) + self.topicform.nameEdit.setText(topic.name) + # Save the topic's name for the case that he has to be restored. + temp_name = topic.name + if self.topicform.exec_(False): + topic.name = unicode(self.topicform.nameEdit.text()) + if self.checkTopic(topic, True): + if self.manager.save_object(topic): self.resetTopics() else: - # We restore the topics's old name. - topic.name = temp_name criticalErrorMessageBox( message=translate('SongsPlugin.SongMaintenanceForm', - 'Could not save your modified topic, because it ' - 'already exists.')) + 'Could not save your changes.')) + elif criticalErrorMessageBox( + message=unicode(translate('SongsPlugin.SongMaintenanceForm', + 'The topic %s already exists. Would you like to make songs ' + 'with topic %s use the existing topic %s?')) % (topic.name, + temp_name, topic.name), + parent=self, question=True) == QtGui.QMessageBox.Yes: + Receiver.send_message(u'cursor_busy') + Receiver.send_message(u'openlp_process_events') + self.mergeTopics(topic) + self.resetTopics() + Receiver.send_message(u'cursor_normal') + else: + # We restore the topics's old name. + topic.name = temp_name + criticalErrorMessageBox( + message=translate('SongsPlugin.SongMaintenanceForm', + 'Could not save your modified topic, because it ' + 'already exists.')) def onBookEditButtonClick(self): book_id = self._getCurrentItemId(self.booksListWidget) - if book_id != -1: - book = self.manager.get_object(Book, book_id) - if book.publisher is None: - book.publisher = u'' - self.bookform.nameEdit.setText(book.name) - self.bookform.publisherEdit.setText(book.publisher) - # Save the book's name and publisher for the case that they have to - # be restored. - temp_name = book.name - temp_publisher = book.publisher - if self.bookform.exec_(False): - book.name = unicode(self.bookform.nameEdit.text()) - book.publisher = unicode(self.bookform.publisherEdit.text()) - if self.checkBook(book, True): - if self.manager.save_object(book): - self.resetBooks() - else: - criticalErrorMessageBox( - message=translate('SongsPlugin.SongMaintenanceForm', - 'Could not save your changes.')) - elif criticalErrorMessageBox( - message=unicode(translate('SongsPlugin.SongMaintenanceForm', - 'The book %s already exists. Would you like to make songs ' - 'with book %s use the existing book %s?')) % (book.name, - temp_name, book.name), - parent=self, question=True) == QtGui.QMessageBox.Yes: - self.mergeBooks(book) + if book_id == -1: + return + book = self.manager.get_object(Book, book_id) + if book.publisher is None: + book.publisher = u'' + self.bookform.nameEdit.setText(book.name) + self.bookform.publisherEdit.setText(book.publisher) + # Save the book's name and publisher for the case that they have to + # be restored. + temp_name = book.name + temp_publisher = book.publisher + if self.bookform.exec_(False): + book.name = unicode(self.bookform.nameEdit.text()) + book.publisher = unicode(self.bookform.publisherEdit.text()) + if self.checkBook(book, True): + if self.manager.save_object(book): self.resetBooks() else: - # We restore the book's old name and publisher. - book.name = temp_name - book.publisher = temp_publisher + criticalErrorMessageBox( + message=translate('SongsPlugin.SongMaintenanceForm', + 'Could not save your changes.')) + elif criticalErrorMessageBox( + message=unicode(translate('SongsPlugin.SongMaintenanceForm', + 'The book %s already exists. Would you like to make songs ' + 'with book %s use the existing book %s?')) % (book.name, + temp_name, book.name), + parent=self, question=True) == QtGui.QMessageBox.Yes: + Receiver.send_message(u'cursor_busy') + Receiver.send_message(u'openlp_process_events') + self.mergeBooks(book) + self.resetBooks() + Receiver.send_message(u'cursor_normal') + else: + # We restore the book's old name and publisher. + book.name = temp_name + book.publisher = temp_publisher def mergeAuthors(self, old_author): """ From 139cf93541fd165a5b25b3e1d0dd6bbd5b15fbaa Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Fri, 28 Jan 2011 18:41:37 +0000 Subject: [PATCH 09/43] SongUsage cleanup --- openlp/core/lib/__init__.py | 2 +- .../songusage/forms/songusagedetaildialog.py | 5 ++- .../songusage/forms/songusagedetailform.py | 41 ++++++++++++++----- 3 files changed, 34 insertions(+), 14 deletions(-) diff --git a/openlp/core/lib/__init__.py b/openlp/core/lib/__init__.py index 76d7c0617..33280f83b 100644 --- a/openlp/core/lib/__init__.py +++ b/openlp/core/lib/__init__.py @@ -315,7 +315,7 @@ def check_directory_exists(dir): ``dir`` Theme directory to make sure exists """ - log.debug(u'check_directory_exists') + log.debug(u'check_directory_exists %s' % dir) if not os.path.exists(dir): os.makedirs(dir) diff --git a/openlp/plugins/songusage/forms/songusagedetaildialog.py b/openlp/plugins/songusage/forms/songusagedetaildialog.py index 9383e147d..87d2d5ffe 100644 --- a/openlp/plugins/songusage/forms/songusagedetaildialog.py +++ b/openlp/plugins/songusage/forms/songusagedetaildialog.py @@ -60,10 +60,11 @@ class Ui_SongUsageDetailDialog(object): self.horizontalLayout.setObjectName(u'horizontalLayout') self.fileLineEdit = QtGui.QLineEdit(self.fileGroupBox) self.fileLineEdit.setObjectName(u'fileLineEdit') + self.fileLineEdit.setReadOnly(True) self.horizontalLayout.addWidget(self.fileLineEdit) self.saveFilePushButton = QtGui.QPushButton(self.fileGroupBox) self.saveFilePushButton.setIcon( - build_icon(u':/general/general_load.png')) + build_icon(u':/general/general_open.png')) self.saveFilePushButton.setObjectName(u'saveFilePushButton') self.horizontalLayout.addWidget(self.saveFilePushButton) self.verticalLayout4.addLayout(self.horizontalLayout) @@ -96,4 +97,4 @@ class Ui_SongUsageDetailDialog(object): translate('SongUsagePlugin.SongUsageDetailForm', 'to')) self.fileGroupBox.setTitle( translate('SongUsagePlugin.SongUsageDetailForm', - 'Report Location')) \ No newline at end of file + 'Report Location')) diff --git a/openlp/plugins/songusage/forms/songusagedetailform.py b/openlp/plugins/songusage/forms/songusagedetailform.py index 8588ddcff..88e3b1450 100644 --- a/openlp/plugins/songusage/forms/songusagedetailform.py +++ b/openlp/plugins/songusage/forms/songusagedetailform.py @@ -30,7 +30,7 @@ import os from PyQt4 import QtCore, QtGui from sqlalchemy.sql import and_ -from openlp.core.lib import SettingsManager, translate +from openlp.core.lib import SettingsManager, translate, check_directory_exists from openlp.plugins.songusage.lib.db import SongUsageItem from songusagedetaildialog import Ui_SongUsageDetailDialog @@ -51,49 +51,68 @@ class SongUsageDetailForm(QtGui.QDialog, Ui_SongUsageDetailDialog): self.setupUi(self) def initialise(self): + """ + We need to set up the screen + """ year = QtCore.QDate().currentDate().year() if QtCore.QDate().currentDate().month() < 9: year -= 1 - toDate = QtCore.QDate(year, 8, 31) - fromDate = QtCore.QDate(year - 1, 9, 1) + toDate = QtCore.QSettings().value( + u'songusage/to date', + QtCore.QVariant(QtCore.QDate(year, 8, 31))).toDate() + fromDate = QtCore.QSettings().value( + u'songusage/from date', + QtCore.QVariant(QtCore.QDate(year - 1, 9, 1))).toDate() self.fromDate.setSelectedDate(fromDate) self.toDate.setSelectedDate(toDate) self.fileLineEdit.setText( SettingsManager.get_last_dir(self.plugin.settingsSection, 1)) def defineOutputLocation(self): + """ + Triggered when the Directory selection button is pressed + """ path = QtGui.QFileDialog.getExistingDirectory(self, translate('SongUsagePlugin.SongUsageDetailForm', 'Output File Location'), SettingsManager.get_last_dir(self.plugin.settingsSection, 1)) path = unicode(path) - if path != u'': + if path: SettingsManager.set_last_dir(self.plugin.settingsSection, path, 1) self.fileLineEdit.setText(path) def accept(self): - log.debug(u'Detailed report generated') + """ + Ok was pressed so lets save the data and run the report + """ + log.debug(u'accept') + path = unicode(self.fileLineEdit.text()) + check_directory_exists(path) filename = unicode(translate('SongUsagePlugin.SongUsageDetailForm', 'usage_detail_%s_%s.txt')) % ( self.fromDate.selectedDate().toString(u'ddMMyyyy'), self.toDate.selectedDate().toString(u'ddMMyyyy')) + QtCore.QSettings().setValue(u'songusage/from date', + QtCore.QVariant(self.fromDate.selectedDate())) + QtCore.QSettings().setValue(u'songusage/to date', + QtCore.QVariant(self.toDate.selectedDate())) usage = self.plugin.manager.get_all_objects( SongUsageItem, and_( SongUsageItem.usagedate >= self.fromDate.selectedDate().toPyDate(), SongUsageItem.usagedate < self.toDate.selectedDate().toPyDate()), [SongUsageItem.usagedate, SongUsageItem.usagetime]) - outname = os.path.join(unicode(self.fileLineEdit.text()), filename) - file = None + outname = os.path.join(path, filename) + fileHandle = None try: - file = open(outname, u'w') + fileHandle = open(outname, u'w') for instance in usage: record = u'\"%s\",\"%s\",\"%s\",\"%s\",\"%s\",\"%s\"\n' % ( instance.usagedate, instance.usagetime, instance.title, instance.copyright, instance.ccl_number, instance.authors) - file.write(record) + fileHandle.write(record.encode(u'utf-8')) except IOError: log.exception(u'Failed to write out song usage records') finally: - if file: - file.close() + if fileHandle: + fileHandle.close() self.close() From 8e7d29adf129c96d901ce753b9f10c71453ab46b Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Fri, 28 Jan 2011 19:46:55 +0000 Subject: [PATCH 10/43] Amend Service Item Title --- openlp/core/lib/serviceitem.py | 12 ++++++++++++ openlp/core/ui/servicemanager.py | 4 ++-- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/openlp/core/lib/serviceitem.py b/openlp/core/lib/serviceitem.py index 276563eba..01a5623df 100644 --- a/openlp/core/lib/serviceitem.py +++ b/openlp/core/lib/serviceitem.py @@ -314,6 +314,18 @@ class ServiceItem(object): path, text_image[u'title'], text_image[u'image'] ) self._new_item() + def get_title(self): + """ + Returns the title of the service item. + """ + if self.is_text(): + return self.title + else: + if len(self._raw_frames) > 1: + return self.title + else: + return self._raw_frames[0][u'title'] + def merge(self, other): """ Updates the _uuid with the value from the original one diff --git a/openlp/core/ui/servicemanager.py b/openlp/core/ui/servicemanager.py index 9470b419f..8ae844940 100644 --- a/openlp/core/ui/servicemanager.py +++ b/openlp/core/ui/servicemanager.py @@ -833,7 +833,7 @@ class ServiceManager(QtGui.QWidget): else: treewidgetitem.setIcon(0, build_icon(u':/general/general_delete.png')) - treewidgetitem.setText(0, serviceitem.title) + treewidgetitem.setText(0, serviceitem.get_title()) treewidgetitem.setToolTip(0, serviceitem.notes) treewidgetitem.setData(0, QtCore.Qt.UserRole, QtCore.QVariant(item[u'order'])) @@ -1176,7 +1176,7 @@ class ServiceManager(QtGui.QWidget): for item in self.serviceItems: service_item = item[u'service_item'] data_item = {} - data_item[u'title'] = unicode(service_item.title) + data_item[u'title'] = unicode(service_item.get_title()) data_item[u'plugin'] = unicode(service_item.name) data_item[u'notes'] = unicode(service_item.notes) data_item[u'selected'] = (item == curitem) From daf545bc06e5f36dc32b0e581f5db21f1e8d77fc Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Sat, 29 Jan 2011 07:53:21 +0000 Subject: [PATCH 11/43] Fix up service item display changes --- openlp/core/lib/serviceitem.py | 7 +++++-- openlp/core/ui/servicemanager.py | 4 ++-- openlp/plugins/presentations/lib/mediaitem.py | 1 + 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/openlp/core/lib/serviceitem.py b/openlp/core/lib/serviceitem.py index 01a5623df..c74b89144 100644 --- a/openlp/core/lib/serviceitem.py +++ b/openlp/core/lib/serviceitem.py @@ -59,6 +59,7 @@ class ItemCapabilities(object): OnLoadUpdate = 8 AddIfNewItem = 9 ProvidesOwnDisplay = 10 + AllowsDetailedTitleDisplay = 11 class ServiceItem(object): @@ -314,14 +315,16 @@ class ServiceItem(object): path, text_image[u'title'], text_image[u'image'] ) self._new_item() - def get_title(self): + def get_display_title(self): """ Returns the title of the service item. """ if self.is_text(): return self.title else: - if len(self._raw_frames) > 1: + if ItemCapabilities.AllowsDetailedTitleDisplay in self.capabilities: + return self._raw_frames[0][u'title'] + elif len(self._raw_frames) > 1: return self.title else: return self._raw_frames[0][u'title'] diff --git a/openlp/core/ui/servicemanager.py b/openlp/core/ui/servicemanager.py index 8ae844940..57a82722e 100644 --- a/openlp/core/ui/servicemanager.py +++ b/openlp/core/ui/servicemanager.py @@ -833,7 +833,7 @@ class ServiceManager(QtGui.QWidget): else: treewidgetitem.setIcon(0, build_icon(u':/general/general_delete.png')) - treewidgetitem.setText(0, serviceitem.get_title()) + treewidgetitem.setText(0, serviceitem.get_display_title()) treewidgetitem.setToolTip(0, serviceitem.notes) treewidgetitem.setData(0, QtCore.Qt.UserRole, QtCore.QVariant(item[u'order'])) @@ -1176,7 +1176,7 @@ class ServiceManager(QtGui.QWidget): for item in self.serviceItems: service_item = item[u'service_item'] data_item = {} - data_item[u'title'] = unicode(service_item.get_title()) + data_item[u'title'] = unicode(service_item.get_display_title()) data_item[u'plugin'] = unicode(service_item.name) data_item[u'notes'] = unicode(service_item.notes) data_item[u'selected'] = (item == curitem) diff --git a/openlp/plugins/presentations/lib/mediaitem.py b/openlp/plugins/presentations/lib/mediaitem.py index e72d97be1..43cb3dab0 100644 --- a/openlp/plugins/presentations/lib/mediaitem.py +++ b/openlp/plugins/presentations/lib/mediaitem.py @@ -250,6 +250,7 @@ class PresentationMediaItem(MediaManagerItem): service_item.title = unicode(self.displayTypeComboBox.currentText()) service_item.shortname = unicode(self.displayTypeComboBox.currentText()) service_item.add_capability(ItemCapabilities.ProvidesOwnDisplay) + service_item.add_capability(ItemCapabilities.AllowsDetailedTitleDisplay) shortname = service_item.shortname if shortname: for item in items: From 5f46426f93f149ff6013513519073d3a76c3c9bf Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Sat, 29 Jan 2011 08:26:14 +0000 Subject: [PATCH 12/43] More songusage cleanups --- openlp/plugins/songusage/forms/songusagedeleteform.py | 9 +++++++-- openlp/plugins/songusage/forms/songusagedetaildialog.py | 1 + openlp/plugins/songusage/forms/songusagedetailform.py | 9 ++++++++- 3 files changed, 16 insertions(+), 3 deletions(-) diff --git a/openlp/plugins/songusage/forms/songusagedeleteform.py b/openlp/plugins/songusage/forms/songusagedeleteform.py index f83ec8c82..a4cfd84b7 100644 --- a/openlp/plugins/songusage/forms/songusagedeleteform.py +++ b/openlp/plugins/songusage/forms/songusagedeleteform.py @@ -26,7 +26,7 @@ from PyQt4 import QtGui -from openlp.core.lib import translate +from openlp.core.lib import translate, Receiver from openlp.plugins.songusage.lib.db import SongUsageItem from songusagedeletedialog import Ui_SongUsageDeleteDialog @@ -55,4 +55,9 @@ class SongUsageDeleteForm(QtGui.QDialog, Ui_SongUsageDeleteDialog): deleteDate = self.deleteCalendar.selectedDate().toPyDate() self.manager.delete_all_objects(SongUsageItem, SongUsageItem.usagedate <= deleteDate) - self.close() \ No newline at end of file + Receiver.send_message(u'openlp_information_message', { + u'title': translate('SongUsagePlugin.SongUsageDeleteForm', + 'Deletion Sucessful'), + u'message': translate('SongUsagePlugin.SongUsageDeleteForm', + 'All requested data has been deleted sucessfully. ')}) + self.close() diff --git a/openlp/plugins/songusage/forms/songusagedetaildialog.py b/openlp/plugins/songusage/forms/songusagedetaildialog.py index 87d2d5ffe..ec1f69d7e 100644 --- a/openlp/plugins/songusage/forms/songusagedetaildialog.py +++ b/openlp/plugins/songusage/forms/songusagedetaildialog.py @@ -61,6 +61,7 @@ class Ui_SongUsageDetailDialog(object): self.fileLineEdit = QtGui.QLineEdit(self.fileGroupBox) self.fileLineEdit.setObjectName(u'fileLineEdit') self.fileLineEdit.setReadOnly(True) + self.fileLineEdit.setEnabled(False) self.horizontalLayout.addWidget(self.fileLineEdit) self.saveFilePushButton = QtGui.QPushButton(self.fileGroupBox) self.saveFilePushButton.setIcon( diff --git a/openlp/plugins/songusage/forms/songusagedetailform.py b/openlp/plugins/songusage/forms/songusagedetailform.py index 88e3b1450..f02820b0d 100644 --- a/openlp/plugins/songusage/forms/songusagedetailform.py +++ b/openlp/plugins/songusage/forms/songusagedetailform.py @@ -30,7 +30,8 @@ import os from PyQt4 import QtCore, QtGui from sqlalchemy.sql import and_ -from openlp.core.lib import SettingsManager, translate, check_directory_exists +from openlp.core.lib import SettingsManager, translate, Receiver, \ + check_directory_exists from openlp.plugins.songusage.lib.db import SongUsageItem from songusagedetaildialog import Ui_SongUsageDetailDialog @@ -110,6 +111,12 @@ class SongUsageDetailForm(QtGui.QDialog, Ui_SongUsageDetailDialog): instance.usagedate, instance.usagetime, instance.title, instance.copyright, instance.ccl_number, instance.authors) fileHandle.write(record.encode(u'utf-8')) + Receiver.send_message(u'openlp_information_message', { + u'title': translate('SongUsagePlugin.SongUsageDetailForm', + 'Report Creation'), + u'message': unicode(translate( + 'SongUsagePlugin.SongUsageDetailForm', 'Report \n%s \n' + 'has been sucessfully created. ')) % outname}) except IOError: log.exception(u'Failed to write out song usage records') finally: From 003e572896a625e881dbf4cb3b0f08c0c70a38da Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Sat, 29 Jan 2011 09:56:05 +0000 Subject: [PATCH 13/43] More Up / Down errors --- openlp/core/ui/servicemanager.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openlp/core/ui/servicemanager.py b/openlp/core/ui/servicemanager.py index 57a82722e..22a873855 100644 --- a/openlp/core/ui/servicemanager.py +++ b/openlp/core/ui/servicemanager.py @@ -178,7 +178,7 @@ class ServiceManager(QtGui.QWidget): translate('OpenLP.ServiceManager', 'Move &down'), None, translate('OpenLP.ServiceManager', - 'Moves the selection up the window.'), + 'Moves the selection down the window.'), self.onMoveSelectionDown, shortcut=QtCore.Qt.Key_Down) self.serviceManagerList.down.setVisible(False) self.serviceManagerList.up = self.orderToolbar.addToolbarButton( From 336730d943fedac66ad9fe6de41696177bf99a12 Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Sat, 29 Jan 2011 10:01:29 +0000 Subject: [PATCH 14/43] Spellings --- openlp/plugins/songusage/forms/songusagedeleteform.py | 4 ++-- openlp/plugins/songusage/forms/songusagedetailform.py | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/openlp/plugins/songusage/forms/songusagedeleteform.py b/openlp/plugins/songusage/forms/songusagedeleteform.py index a4cfd84b7..c03fe15a3 100644 --- a/openlp/plugins/songusage/forms/songusagedeleteform.py +++ b/openlp/plugins/songusage/forms/songusagedeleteform.py @@ -57,7 +57,7 @@ class SongUsageDeleteForm(QtGui.QDialog, Ui_SongUsageDeleteDialog): SongUsageItem.usagedate <= deleteDate) Receiver.send_message(u'openlp_information_message', { u'title': translate('SongUsagePlugin.SongUsageDeleteForm', - 'Deletion Sucessful'), + 'Deletion Successful'), u'message': translate('SongUsagePlugin.SongUsageDeleteForm', - 'All requested data has been deleted sucessfully. ')}) + 'All requested data has been deleted successfully. ')}) self.close() diff --git a/openlp/plugins/songusage/forms/songusagedetailform.py b/openlp/plugins/songusage/forms/songusagedetailform.py index f02820b0d..ff8ec4858 100644 --- a/openlp/plugins/songusage/forms/songusagedetailform.py +++ b/openlp/plugins/songusage/forms/songusagedetailform.py @@ -116,7 +116,7 @@ class SongUsageDetailForm(QtGui.QDialog, Ui_SongUsageDetailDialog): 'Report Creation'), u'message': unicode(translate( 'SongUsagePlugin.SongUsageDetailForm', 'Report \n%s \n' - 'has been sucessfully created. ')) % outname}) + 'has been successfully created. ')) % outname}) except IOError: log.exception(u'Failed to write out song usage records') finally: From 1083cf38be7fbd0767dcad7344c1caff345c5337 Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Sat, 29 Jan 2011 20:39:16 +0100 Subject: [PATCH 15/43] started with service order sheet printing --- openlp/core/ui/mainwindow.py | 17 +++++++++++++++-- openlp/core/ui/servicemanager.py | 28 ++++++++++++++++++++++++++++ 2 files changed, 43 insertions(+), 2 deletions(-) diff --git a/openlp/core/ui/mainwindow.py b/openlp/core/ui/mainwindow.py index d8bedade3..ea11c7d99 100644 --- a/openlp/core/ui/mainwindow.py +++ b/openlp/core/ui/mainwindow.py @@ -175,6 +175,10 @@ class Ui_MainWindow(object): self.FileSaveAsItem = QtGui.QAction(mainWindow) self.FileSaveAsItem.setObjectName(u'FileSaveAsItem') mainWindow.actionList.add_action(self.FileSaveAsItem, u'File') + self.PrintServiceOrderItem = QtGui.QAction(mainWindow) + self.PrintServiceOrderItem.setObjectName(u'PrintServiceItem') + mainWindow.actionList.add_action( + self.PrintServiceOrderItem, u'Print Service Order') self.FileExitItem = QtGui.QAction(mainWindow) self.FileExitItem.setIcon(build_icon(u':/system/system_exit.png')) self.FileExitItem.setObjectName(u'FileExitItem') @@ -302,8 +306,8 @@ class Ui_MainWindow(object): (self.ExportThemeItem, self.ExportLanguageItem)) self.FileMenuActions = (self.FileNewItem, self.FileOpenItem, self.FileSaveItem, self.FileSaveAsItem, None, - self.FileImportMenu.menuAction(), self.FileExportMenu.menuAction(), - self.FileExitItem) + self.PrintServiceOrderItem, None, self.FileImportMenu.menuAction(), + self.FileExportMenu.menuAction(), self.FileExitItem) add_actions(self.ViewModeMenu, (self.ModeDefaultItem, self.ModeSetupItem, self.ModeLiveItem)) add_actions(self.ViewMenu, (self.ViewModeMenu.menuAction(), @@ -381,6 +385,12 @@ class Ui_MainWindow(object): 'Save the current service under a new name.')) self.FileSaveAsItem.setShortcut( translate('OpenLP.MainWindow', 'Ctrl+Shift+S')) + self.PrintServiceOrderItem.setText( + translate('OpenLP.MainWindow', 'Print Service Order')) + self.PrintServiceOrderItem.setStatusTip(translate('OpenLP.MainWindow', + 'Print the current Service Order.')) + self.PrintServiceOrderItem.setShortcut( + translate('OpenLP.MainWindow', 'Ctrl+P')) self.FileExitItem.setText( translate('OpenLP.MainWindow', 'E&xit')) self.FileExitItem.setStatusTip( @@ -567,6 +577,9 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow): QtCore.QObject.connect(self.FileSaveAsItem, QtCore.SIGNAL(u'triggered()'), self.ServiceManagerContents.saveFileAs) + QtCore.QObject.connect(self.PrintServiceOrderItem, + QtCore.SIGNAL(u'triggered()'), + self.ServiceManagerContents.printServiceOrder) # i18n set signals for languages QtCore.QObject.connect(self.AutoLanguageItem, QtCore.SIGNAL(u'toggled(bool)'), self.setAutoLanguage) diff --git a/openlp/core/ui/servicemanager.py b/openlp/core/ui/servicemanager.py index 22a873855..ce400525e 100644 --- a/openlp/core/ui/servicemanager.py +++ b/openlp/core/ui/servicemanager.py @@ -1182,3 +1182,31 @@ class ServiceManager(QtGui.QWidget): data_item[u'selected'] = (item == curitem) data.append(data_item) Receiver.send_message(u'servicemanager_list_response', data) + + def printServiceOrder(self): + """ + Print a Service Order Sheet. + """ + # TODO: Add settings, consider footer. If saved service, print service + # file name. + printer = QtGui.QPrinter() + printer.setPaperSize(QtGui.QPrinter.A4) + text = u'

%s

' % translate('OpenLP.ServiceManager', + 'Service Order Sheet') + for item in self.serviceItems: + text += u'

' + item[u'service_item'].title + u'

' + if item[u'service_item'].is_text(): + for slide in item[u'service_item'].get_frames(): + text += u'

' + slide[u'text'] + u'

' + elif item[u'service_item'].is_image(): + # Get child title + pass + else: + # What to do with the other types? + pass + if item[u'service_item'].notes: + text += u'

%s ' % translate('OpenLP.ServiceManager', + 'Notes:') + item[u'service_item'].notes + u'

' + doc = QtGui.QTextDocument() + doc.setHtml(text) + doc.print_(printer) From 428edf28fb5abf3fea66b13aab61764fb7acc101 Mon Sep 17 00:00:00 2001 From: Jon Tibble Date: Sun, 30 Jan 2011 09:32:09 +0000 Subject: [PATCH 16/43] CSV testing named book format (v1?) --- openlp/plugins/bibles/lib/csvbible.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/openlp/plugins/bibles/lib/csvbible.py b/openlp/plugins/bibles/lib/csvbible.py index fd987dfdf..33a5de714 100644 --- a/openlp/plugins/bibles/lib/csvbible.py +++ b/openlp/plugins/bibles/lib/csvbible.py @@ -172,8 +172,12 @@ class CSVBible(BibleDB): for line in verse_reader: if self.stop_import_flag: break - if book_ptr != book_list[int(line[0])]: - book = self.get_book(book_list[int(line[0])]) + try: + line_book = book_list[int(line[0])] + except ValueError: + line_book = unicode(line[0], details['encoding']) + if book_ptr != line_book: + book = self.get_book(line_book) book_ptr = book.name self.wizard.incrementProgressBar(unicode(translate( 'BibleDB.Wizard', 'Importing verses from %s...', From 780a8b8b39727c8daea1a418a79c6d71d82971e8 Mon Sep 17 00:00:00 2001 From: Jon Tibble Date: Sun, 30 Jan 2011 09:43:07 +0000 Subject: [PATCH 17/43] Docstring update for CSV formats --- openlp/plugins/bibles/lib/csvbible.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/openlp/plugins/bibles/lib/csvbible.py b/openlp/plugins/bibles/lib/csvbible.py index 33a5de714..677f99e6b 100644 --- a/openlp/plugins/bibles/lib/csvbible.py +++ b/openlp/plugins/bibles/lib/csvbible.py @@ -50,14 +50,17 @@ The format of the books file is: ... 40,2,Matthew,Matt -The format of the verses file is: +There are two acceptable formats of the verses file. They are: ,,, + or + ,,, For example: 1,1,1,"In the beginning God created the heaven and the earth." - 1,1,2,"And the earth was without form, and void; and darkness...." + or + "Genesis",1,2,"And the earth was without form, and void; and...." All CSV files are expected to use a comma (',') as the delimeter and double quotes ('"') as the quote symbol. From 83ac7c6b297e5dd0a388d299195ad91b89b0b4f0 Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Sun, 30 Jan 2011 10:27:12 +0000 Subject: [PATCH 18/43] Fix up theme override position bugs Fixes: https://launchpad.net/bugs/710065 --- openlp/core/ui/maindisplay.py | 1 + openlp/core/ui/themeform.py | 8 ++++++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/openlp/core/ui/maindisplay.py b/openlp/core/ui/maindisplay.py index 3dfde8640..f6ecfc6fc 100644 --- a/openlp/core/ui/maindisplay.py +++ b/openlp/core/ui/maindisplay.py @@ -244,6 +244,7 @@ class MainDisplay(DisplayWidget): Used after Image plugin has changed the background """ log.debug(u'resetImage') + a=c if hasattr(self, u'serviceItem'): self.displayImage(self.serviceItem.bg_image_bytes) else: diff --git a/openlp/core/ui/themeform.py b/openlp/core/ui/themeform.py index 43f1034f4..8d10f21fa 100644 --- a/openlp/core/ui/themeform.py +++ b/openlp/core/ui/themeform.py @@ -272,14 +272,18 @@ class ThemeForm(QtGui.QWizard, Ui_ThemeWizard): def onMainPositionCheckBoxStateChanged(self, value): """ Change state as Main Area Position check box changed + NOTE the font_main_override is the inverse of the check box value """ - self.theme.font_main_override = (value == QtCore.Qt.Checked) + if self.updateThemeAllowed: + self.theme.font_main_override = not (value == QtCore.Qt.Checked) def onFooterPositionCheckBoxStateChanged(self, value): """ Change state as Footer Area Position check box changed + NOTE the font_footer_override is the inverse of the check box value """ - self.theme.font_footer_override = (value == QtCore.Qt.Checked) + if self.updateThemeAllowed: + self.theme.font_footer_override = not (value == QtCore.Qt.Checked) def exec_(self, edit=False): """ From 9c5d7e85912e00401db006ef07acf0d78247143d Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Sun, 30 Jan 2011 16:51:31 +0000 Subject: [PATCH 19/43] Remove debug --- openlp/core/ui/maindisplay.py | 1 - 1 file changed, 1 deletion(-) diff --git a/openlp/core/ui/maindisplay.py b/openlp/core/ui/maindisplay.py index f6ecfc6fc..3dfde8640 100644 --- a/openlp/core/ui/maindisplay.py +++ b/openlp/core/ui/maindisplay.py @@ -244,7 +244,6 @@ class MainDisplay(DisplayWidget): Used after Image plugin has changed the background """ log.debug(u'resetImage') - a=c if hasattr(self, u'serviceItem'): self.displayImage(self.serviceItem.bg_image_bytes) else: From ce49a8fe20ca5d2212fb56c1f5732358ecc435c3 Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Sun, 30 Jan 2011 20:19:24 +0100 Subject: [PATCH 20/43] print footer, display plugin icon --- openlp/core/ui/servicemanager.py | 43 ++++++++++++++++++-------------- 1 file changed, 24 insertions(+), 19 deletions(-) diff --git a/openlp/core/ui/servicemanager.py b/openlp/core/ui/servicemanager.py index ce400525e..ab1d6b5c8 100644 --- a/openlp/core/ui/servicemanager.py +++ b/openlp/core/ui/servicemanager.py @@ -1187,26 +1187,31 @@ class ServiceManager(QtGui.QWidget): """ Print a Service Order Sheet. """ - # TODO: Add settings, consider footer. If saved service, print service - # file name. - printer = QtGui.QPrinter() - printer.setPaperSize(QtGui.QPrinter.A4) + # TODO: Add settings. + if not self.serviceItems: + return + printDialog = QtGui.QPrintDialog() + if not printDialog.exec_(): + return text = u'

%s

' % translate('OpenLP.ServiceManager', 'Service Order Sheet') for item in self.serviceItems: - text += u'

' + item[u'service_item'].title + u'

' - if item[u'service_item'].is_text(): - for slide in item[u'service_item'].get_frames(): + item = item[u'service_item'] + text += u'

%s

' % (item.icon, + item.get_display_title()) + if item.is_text(): + for slide in item.get_frames(): text += u'

' + slide[u'text'] + u'

' - elif item[u'service_item'].is_image(): - # Get child title - pass - else: - # What to do with the other types? - pass - if item[u'service_item'].notes: - text += u'

%s ' % translate('OpenLP.ServiceManager', - 'Notes:') + item[u'service_item'].notes + u'

' - doc = QtGui.QTextDocument() - doc.setHtml(text) - doc.print_(printer) + elif item.is_image(): + text += u'
    ' + for slide in range(len(item.get_frames())): + text += u'
  1. %s

  2. ' % item.get_frame_title(slide) + text += u'
' + if item.foot_text: + text += u'

%s

' % item.foot_text + if item.notes: + text += u'

%s %s

' % (translate( + 'OpenLP.ServiceManager', 'Notes:'), item.notes) + serviceDocument = QtGui.QTextDocument() + serviceDocument.setHtml(text) + serviceDocument.print_(printDialog.printer()) From 54a6963f892a9c66c04fa396620f6f375fafad04 Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Sun, 30 Jan 2011 21:08:00 +0100 Subject: [PATCH 21/43] changed image title --- openlp/plugins/images/lib/mediaitem.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openlp/plugins/images/lib/mediaitem.py b/openlp/plugins/images/lib/mediaitem.py index 73f5b80f0..25d9811f1 100644 --- a/openlp/plugins/images/lib/mediaitem.py +++ b/openlp/plugins/images/lib/mediaitem.py @@ -142,7 +142,7 @@ class ImageMediaItem(MediaManagerItem): items = self.listView.selectedIndexes() if items: service_item.title = unicode( - translate('ImagePlugin.MediaItem', 'Image(s)')) + translate('ImagePlugin.MediaItem', 'Images')) service_item.add_capability(ItemCapabilities.AllowsMaintain) service_item.add_capability(ItemCapabilities.AllowsPreview) service_item.add_capability(ItemCapabilities.AllowsLoop) From b99961d669c9f71ac6d33a3d7e4411f4ad7444af Mon Sep 17 00:00:00 2001 From: Jon Tibble Date: Mon, 31 Jan 2011 01:55:25 +0000 Subject: [PATCH 22/43] Fix BG Chinese bible (Bug #706211) --- openlp/plugins/bibles/lib/http.py | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/openlp/plugins/bibles/lib/http.py b/openlp/plugins/bibles/lib/http.py index b844bbe61..e004be9df 100644 --- a/openlp/plugins/bibles/lib/http.py +++ b/openlp/plugins/bibles/lib/http.py @@ -210,7 +210,8 @@ class BGExtract(object): cleaner = [(re.compile(' |
|\'\+\''), lambda match: '')] soup = get_soup_for_bible_ref( u'http://www.biblegateway.com/passage/?%s' % url_params, - cleaner=cleaner) + pre_parse_regex=r'', pre_parse_substitute='', + cleaner=cleaner) if not soup: return None Receiver.send_message(u'openlp_process_events') @@ -499,7 +500,8 @@ class HTTPBible(BibleDB): """ return HTTPBooks.get_verse_count(book, chapter) -def get_soup_for_bible_ref(reference_url, header=None, cleaner=None): +def get_soup_for_bible_ref(reference_url, header=None, pre_parse_regex=None, + pre_parse_substitute=None, cleaner=None): """ Gets a webpage and returns a parsed and optionally cleaned soup or None. @@ -509,6 +511,13 @@ def get_soup_for_bible_ref(reference_url, header=None, cleaner=None): ``header`` An optional HTTP header to pass to the bible web server. + ``pre_parse_regex`` + A regular expression to run on the webpage. Allows manipulation of the + webpage before passing to BeautifulSoup for parsing. + + ``pre_parse_substitute`` + The text to replace any matches to the regular expression with. + ``cleaner`` An optional regex to use during webpage parsing. """ @@ -518,12 +527,15 @@ def get_soup_for_bible_ref(reference_url, header=None, cleaner=None): if not page: send_error_message(u'download') return None + page_source = page.read() + if pre_parse_regex and pre_parse_substitute is not None: + page_source = re.sub(pre_parse_regex, pre_parse_substitute, page_source) soup = None try: if cleaner: - soup = BeautifulSoup(page, markupMassage=cleaner) + soup = BeautifulSoup(page_source, markupMassage=cleaner) else: - soup = BeautifulSoup(page) + soup = BeautifulSoup(page_source) except HTMLParseError: log.exception(u'BeautifulSoup could not parse the bible page.') if not soup: From 250107073e86d399d1b792d9b2d3087e4dca72c4 Mon Sep 17 00:00:00 2001 From: Jon Tibble Date: Mon, 31 Jan 2011 02:43:37 +0000 Subject: [PATCH 23/43] Fix not quite ascii CSVs --- openlp/plugins/bibles/lib/csvbible.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/openlp/plugins/bibles/lib/csvbible.py b/openlp/plugins/bibles/lib/csvbible.py index 677f99e6b..82872e15b 100644 --- a/openlp/plugins/bibles/lib/csvbible.py +++ b/openlp/plugins/bibles/lib/csvbible.py @@ -186,8 +186,11 @@ class CSVBible(BibleDB): 'BibleDB.Wizard', 'Importing verses from %s...', 'Importing verses from ...')) % book.name) self.session.commit() - self.create_verse(book.id, line[1], line[2], - unicode(line[3], details['encoding'])) + try: + verse_text = unicode(line[3], details['encoding']) + except UnicodeError: + verse_text = unicode(line[3], u'cp1252') + self.create_verse(book.id, line[1], line[2], verse_text) self.wizard.incrementProgressBar(translate('BibleDB.Wizard', 'Importing verses... done.')) Receiver.send_message(u'openlp_process_events') From e8dce46cf95a65c144f4d183feac58f3c03f12bf Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Mon, 31 Jan 2011 18:00:56 +0100 Subject: [PATCH 24/43] --- openlp/core/lib/mediamanageritem.py | 6 +----- openlp/core/ui/servicemanager.py | 5 +++++ openlp/plugins/media/lib/mediaitem.py | 1 - 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/openlp/core/lib/mediamanageritem.py b/openlp/core/lib/mediamanageritem.py index 9565a9b37..7dd74efb0 100644 --- a/openlp/core/lib/mediamanageritem.py +++ b/openlp/core/lib/mediamanageritem.py @@ -103,7 +103,6 @@ class MediaManagerItem(QtGui.QWidget): self.icon = build_icon(icon) self.toolbar = None self.remoteTriggered = None - self.serviceItemIconName = None self.singleServiceItem = True self.pageLayout = QtGui.QVBoxLayout(self) self.pageLayout.setSpacing(0) @@ -525,10 +524,7 @@ class MediaManagerItem(QtGui.QWidget): Common method for generating a service item """ serviceItem = ServiceItem(self.parent) - if self.serviceItemIconName: - serviceItem.add_icon(self.serviceItemIconName) - else: - serviceItem.add_icon(self.parent.icon_path) + serviceItem.add_icon(self.parent.icon_path) if self.generateSlideData(serviceItem, item, xmlVersion): return serviceItem else: diff --git a/openlp/core/ui/servicemanager.py b/openlp/core/ui/servicemanager.py index ab1d6b5c8..085644b67 100644 --- a/openlp/core/ui/servicemanager.py +++ b/openlp/core/ui/servicemanager.py @@ -1197,19 +1197,24 @@ class ServiceManager(QtGui.QWidget): 'Service Order Sheet') for item in self.serviceItems: item = item[u'service_item'] + # add the title text += u'

%s

' % (item.icon, item.get_display_title()) if item.is_text(): + # Add the text of the service item. for slide in item.get_frames(): text += u'

' + slide[u'text'] + u'

' elif item.is_image(): + # Add the image names of the service item. text += u'
    ' for slide in range(len(item.get_frames())): text += u'
  1. %s

  2. ' % item.get_frame_title(slide) text += u'
' if item.foot_text: + # add footer text += u'

%s

' % item.foot_text if item.notes: + # add notes text += u'

%s %s

' % (translate( 'OpenLP.ServiceManager', 'Notes:'), item.notes) serviceDocument = QtGui.QTextDocument() diff --git a/openlp/plugins/media/lib/mediaitem.py b/openlp/plugins/media/lib/mediaitem.py index e7beb81a9..c68b11c85 100644 --- a/openlp/plugins/media/lib/mediaitem.py +++ b/openlp/plugins/media/lib/mediaitem.py @@ -57,7 +57,6 @@ class MediaMediaItem(MediaManagerItem): u':/media/media_video.png').toImage() MediaManagerItem.__init__(self, parent, self, icon) self.singleServiceItem = False - self.serviceItemIconName = u':/media/image_clapperboard.png' QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'video_background_replaced'), self.videobackgroundReplaced) From 7b3f61e93b0096c9139f20cd0f3f10dedb69c619 Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Mon, 31 Jan 2011 20:35:35 +0100 Subject: [PATCH 25/43] added setting --- openlp/core/ui/advancedtab.py | 18 ++++++++++++++++++ openlp/core/ui/generaltab.py | 1 + openlp/core/ui/servicemanager.py | 4 +++- 3 files changed, 22 insertions(+), 1 deletion(-) diff --git a/openlp/core/ui/advancedtab.py b/openlp/core/ui/advancedtab.py index 58b637bc2..10660a914 100644 --- a/openlp/core/ui/advancedtab.py +++ b/openlp/core/ui/advancedtab.py @@ -80,6 +80,16 @@ class AdvancedTab(SettingsTab): self.hideMouseCheckBox.setObjectName(u'hideMouseCheckBox') self.hideMouseLayout.addWidget(self.hideMouseCheckBox) self.leftLayout.addWidget(self.hideMouseGroupBox) + self.serviceOrderGroupBox = QtGui.QGroupBox(self.leftColumn) + self.serviceOrderGroupBox.setObjectName(u'serviceOrderGroupBox') + self.serviceOrderLayout = QtGui.QVBoxLayout(self.serviceOrderGroupBox) + self.serviceOrderLayout.setObjectName(u'serviceOrderLayout') + self.detailedServicePrintCheckBox = QtGui.QCheckBox( + self.serviceOrderGroupBox) + self.detailedServicePrintCheckBox.setObjectName( + u'detailedServicePrintCheckBox') + self.serviceOrderLayout.addWidget(self.detailedServicePrintCheckBox) + self.leftLayout.addWidget(self.serviceOrderGroupBox) # self.sharedDirGroupBox = QtGui.QGroupBox(self.leftColumn) # self.sharedDirGroupBox.setObjectName(u'sharedDirGroupBox') # self.sharedDirLayout = QtGui.QFormLayout(self.sharedDirGroupBox) @@ -129,6 +139,10 @@ class AdvancedTab(SettingsTab): 'Mouse Cursor')) self.hideMouseCheckBox.setText(translate('OpenLP.AdvancedTab', 'Hide the mouse cursor when moved over the display window')) + self.serviceOrderGroupBox.setTitle(translate('OpenLP.AdvancedTab', + 'Service Order Print')) + self.detailedServicePrintCheckBox.setText(translate('OpenLP.AdvancedTab', + 'Included detailed information')) # self.sharedDirGroupBox.setTitle( # translate('AdvancedTab', 'Central Data Store')) # self.sharedCheckBox.setText( @@ -164,6 +178,8 @@ class AdvancedTab(SettingsTab): QtCore.QVariant(True)).toBool()) self.hideMouseCheckBox.setChecked( settings.value(u'hide mouse', QtCore.QVariant(False)).toBool()) + self.detailedServicePrintCheckBox.setChecked(settings.value( + u'detailed service print', QtCore.QVariant(False)).toBool()) settings.endGroup() def save(self): @@ -184,6 +200,8 @@ class AdvancedTab(SettingsTab): QtCore.QVariant(self.enableAutoCloseCheckBox.isChecked())) settings.setValue(u'hide mouse', QtCore.QVariant(self.hideMouseCheckBox.isChecked())) + settings.setValue(u'detailed service print', + QtCore.QVariant(self.detailedServicePrintCheckBox.isChecked())) settings.endGroup() # def onSharedCheckBoxChanged(self, checked): diff --git a/openlp/core/ui/generaltab.py b/openlp/core/ui/generaltab.py index edace883f..12353fed8 100644 --- a/openlp/core/ui/generaltab.py +++ b/openlp/core/ui/generaltab.py @@ -51,6 +51,7 @@ class ValidEdit(QtGui.QLineEdit): else: return self.text() + class GeneralTab(SettingsTab): """ GeneralTab is the general settings tab in the settings dialog. diff --git a/openlp/core/ui/servicemanager.py b/openlp/core/ui/servicemanager.py index d99ccd2d5..6b0b84472 100644 --- a/openlp/core/ui/servicemanager.py +++ b/openlp/core/ui/servicemanager.py @@ -1187,7 +1187,6 @@ class ServiceManager(QtGui.QWidget): """ Print a Service Order Sheet. """ - # TODO: Add settings. if not self.serviceItems: return printDialog = QtGui.QPrintDialog() @@ -1200,6 +1199,9 @@ class ServiceManager(QtGui.QWidget): # add the title text += u'

%s

' % (item.icon, item.get_display_title()) + if not QtCore.QSettings().value(u'advanced' + + u'/detailed service print', QtCore.QVariant(True)).toBool(): + continue if item.is_text(): # Add the text of the service item. for slide in item.get_frames(): From 6ac0f162a3522ffbf0015385029f41ad5b9ce961 Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Mon, 31 Jan 2011 21:39:55 +0100 Subject: [PATCH 26/43] removed white spaces --- openlp/core/lib/toolbar.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/openlp/core/lib/toolbar.py b/openlp/core/lib/toolbar.py index f2c7f1b0d..b1aa3d96f 100644 --- a/openlp/core/lib/toolbar.py +++ b/openlp/core/lib/toolbar.py @@ -73,13 +73,13 @@ class OpenLPToolbar(QtGui.QToolBar): ``checkable`` If *True* the button has two, *off* and *on*, states. Default is *False*, which means the buttons has only one state. - + ``shortcut`` The primary shortcut for this action - + ``alternate`` The alternate shortcut for this action - + ``context`` Specify the context in which this shortcut is valid """ From 9744d246d6399692156942d72d61b7695b260d5e Mon Sep 17 00:00:00 2001 From: Jon Tibble Date: Tue, 1 Feb 2011 00:33:50 +0000 Subject: [PATCH 27/43] Deduplication --- openlp/core/lib/__init__.py | 14 ++++ openlp/core/lib/mediamanageritem.py | 22 ++++++ openlp/core/ui/serviceitemeditdialog.py | 10 +-- openlp/core/ui/serviceitemeditform.py | 27 ++++--- openlp/core/ui/servicenotedialog.py | 48 ------------- openlp/core/ui/servicenoteform.py | 22 ++++-- openlp/core/ui/slidecontroller.py | 31 ++++---- openlp/core/ui/themestab.py | 28 ++++---- openlp/plugins/bibles/lib/mediaitem.py | 43 +++++------ .../plugins/custom/forms/editcustomdialog.py | 11 +-- openlp/plugins/custom/forms/editcustomform.py | 2 +- .../custom/forms/editcustomslidedialog.py | 11 +-- openlp/plugins/custom/lib/mediaitem.py | 11 +-- .../presentations/lib/messagelistener.py | 2 +- openlp/plugins/songs/forms/authorsdialog.py | 12 +--- openlp/plugins/songs/forms/editsongdialog.py | 11 +-- openlp/plugins/songs/forms/editsongform.py | 22 +++--- openlp/plugins/songs/forms/editversedialog.py | 14 +--- openlp/plugins/songs/forms/songbookdialog.py | 12 +--- .../songs/forms/songmaintenanceform.py | 71 ++++++++----------- openlp/plugins/songs/forms/topicsdialog.py | 12 +--- openlp/plugins/songs/lib/easislidesimport.py | 50 +++++++------ openlp/plugins/songs/lib/mediaitem.py | 11 +-- 23 files changed, 205 insertions(+), 292 deletions(-) delete mode 100644 openlp/core/ui/servicenotedialog.py diff --git a/openlp/core/lib/__init__.py b/openlp/core/lib/__init__.py index 33280f83b..ee2b68c91 100644 --- a/openlp/core/lib/__init__.py +++ b/openlp/core/lib/__init__.py @@ -319,6 +319,20 @@ def check_directory_exists(dir): if not os.path.exists(dir): os.makedirs(dir) +def dialogButtonsSaveCancel(parent): + """ + Return a standard dialog button box with save and cancel buttons. + """ + button_box = QtGui.QDialogButtonBox(parent) + button_box.setStandardButtons(QtGui.QDialogButtonBox.Save | + QtGui.QDialogButtonBox.Cancel) + button_box.setObjectName(u'%sButtonBox' % parent) + QtCore.QObject.connect(button_box, QtCore.SIGNAL(u'accepted()'), + parent.accept) + QtCore.QObject.connect(button_box, QtCore.SIGNAL(u'rejected()'), + parent.reject) + return button_box + from theme import ThemeLevel, ThemeXML, BackgroundGradientType, \ BackgroundType, HorizontalType, VerticalType from displaytags import DisplayTags diff --git a/openlp/core/lib/mediamanageritem.py b/openlp/core/lib/mediamanageritem.py index 9565a9b37..f127cd998 100644 --- a/openlp/core/lib/mediamanageritem.py +++ b/openlp/core/lib/mediamanageritem.py @@ -540,3 +540,25 @@ class MediaManagerItem(QtGui.QWidget): individual service items need to be processed by the plugins """ pass + + def _getIdOfItemToGenerate(self, item, remoteItem): + """ + Utility method to check items being submitted for slide generation. + + ``item`` + The item to check. + + ``remoteItem`` + The id to assign if the slide generation was remotely triggered. + """ + if item is None: + if self.remoteTriggered is None: + item = self.listView.currentItem() + if item is None: + return False + item_id = (item.data(QtCore.Qt.UserRole)).toInt()[0] + else: + item_id = remoteItem + else: + item_id = (item.data(QtCore.Qt.UserRole)).toInt()[0] + return item_id diff --git a/openlp/core/ui/serviceitemeditdialog.py b/openlp/core/ui/serviceitemeditdialog.py index 3e1079ded..025a7d40c 100644 --- a/openlp/core/ui/serviceitemeditdialog.py +++ b/openlp/core/ui/serviceitemeditdialog.py @@ -26,7 +26,7 @@ from PyQt4 import QtCore, QtGui -from openlp.core.lib import translate, build_icon +from openlp.core.lib import translate, build_icon, dialogButtonsSaveCancel class Ui_ServiceItemEditDialog(object): def setupUi(self, serviceItemEditDialog): @@ -52,12 +52,8 @@ class Ui_ServiceItemEditDialog(object): self.downButton.setObjectName(u'downButton') self.buttonLayout.addWidget(self.downButton) self.dialogLayout.addLayout(self.buttonLayout, 0, 1) - self.buttonBox = QtGui.QDialogButtonBox(serviceItemEditDialog) - self.buttonBox.setStandardButtons( - QtGui.QDialogButtonBox.Cancel | QtGui.QDialogButtonBox.Save) - self.buttonBox.setObjectName(u'buttonBox') - self.dialogLayout.addWidget(self.buttonBox, 1, 0, 1, 2) - + self.dialogLayout.addWidget( + dialogButtonsSaveCancel(serviceItemEditDialog), 1, 0, 1, 2) self.retranslateUi(serviceItemEditDialog) QtCore.QMetaObject.connectSlotsByName(serviceItemEditDialog) diff --git a/openlp/core/ui/serviceitemeditform.py b/openlp/core/ui/serviceitemeditform.py index edd4ee29f..0621a44bd 100644 --- a/openlp/core/ui/serviceitemeditform.py +++ b/openlp/core/ui/serviceitemeditform.py @@ -46,10 +46,6 @@ class ServiceItemEditForm(QtGui.QDialog, Ui_ServiceItemEditDialog): QtCore.SIGNAL(u'clicked()'), self.onItemDown) QtCore.QObject.connect(self.deleteButton, QtCore.SIGNAL(u'clicked()'), self.onItemDelete) - QtCore.QObject.connect(self.buttonBox, - QtCore.SIGNAL(u'accepted()'), self.accept) - QtCore.QObject.connect(self.buttonBox, - QtCore.SIGNAL(u'rejected()'), self.reject) QtCore.QObject.connect(self.listWidget, QtCore.SIGNAL(u'currentRowChanged(int)'), self.onCurrentRowChanged) @@ -100,27 +96,30 @@ class ServiceItemEditForm(QtGui.QDialog, Ui_ServiceItemEditDialog): """ Move the current row up in the list. """ - item = self.listWidget.currentItem() - if not item: - return - row = self.listWidget.row(item) - temp = self.itemList[row] - self.itemList.remove(self.itemList[row]) - self.itemList.insert(row - 1, temp) - self.loadData() - self.listWidget.setCurrentRow(row - 1) + self.__moveItem(u'up') def onItemDown(self): """ Move the current row down in the list """ + self.__moveItem(u'down') + + def __moveItem(self, direction=u''): + """ + Move the current item. + """ + if not direction: + return item = self.listWidget.currentItem() if not item: return row = self.listWidget.row(item) temp = self.itemList[row] self.itemList.remove(self.itemList[row]) - self.itemList.insert(row + 1, temp) + if direction == u'up': + self.itemList.insert(row - 1, temp) + else: + self.itemList.insert(row + 1, temp) self.loadData() self.listWidget.setCurrentRow(row + 1) diff --git a/openlp/core/ui/servicenotedialog.py b/openlp/core/ui/servicenotedialog.py deleted file mode 100644 index 9a45dae7c..000000000 --- a/openlp/core/ui/servicenotedialog.py +++ /dev/null @@ -1,48 +0,0 @@ -# -*- coding: utf-8 -*- -# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4 - -############################################################################### -# OpenLP - Open Source Lyrics Projection # -# --------------------------------------------------------------------------- # -# Copyright (c) 2008-2011 Raoul Snyman # -# Portions copyright (c) 2008-2011 Tim Bentley, Jonathan Corwin, Michael # -# Gorven, Scott Guerrieri, Meinert Jordan, Andreas Preikschat, Christian # -# Richter, Philip Ridout, Maikel Stuivenberg, Martin Thompson, Jon Tibble, # -# Carsten Tinggaard, Frode Woldsund # -# --------------------------------------------------------------------------- # -# This program is free software; you can redistribute it and/or modify it # -# under the terms of the GNU General Public License as published by the Free # -# Software Foundation; version 2 of the License. # -# # -# This program is distributed in the hope that it will be useful, but WITHOUT # -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or # -# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for # -# more details. # -# # -# You should have received a copy of the GNU General Public License along # -# with this program; if not, write to the Free Software Foundation, Inc., 59 # -# Temple Place, Suite 330, Boston, MA 02111-1307 USA # -############################################################################### - -from PyQt4 import QtCore, QtGui -from openlp.core.lib import translate - -class Ui_ServiceNoteEdit(object): - def setupUi(self, serviceNoteEdit): - serviceNoteEdit.setObjectName(u'serviceNoteEdit') - self.dialogLayout = QtGui.QVBoxLayout(serviceNoteEdit) - self.dialogLayout.setObjectName(u'verticalLayout') - self.textEdit = QtGui.QTextEdit(serviceNoteEdit) - self.textEdit.setObjectName(u'textEdit') - self.dialogLayout.addWidget(self.textEdit) - self.buttonBox = QtGui.QDialogButtonBox(serviceNoteEdit) - self.buttonBox.setStandardButtons(QtGui.QDialogButtonBox.Cancel | - QtGui.QDialogButtonBox.Save) - self.buttonBox.setObjectName(u'buttonBox') - self.dialogLayout.addWidget(self.buttonBox) - self.retranslateUi(serviceNoteEdit) - QtCore.QMetaObject.connectSlotsByName(serviceNoteEdit) - - def retranslateUi(self, serviceNoteEdit): - serviceNoteEdit.setWindowTitle( - translate('OpenLP.ServiceNoteForm', 'Service Item Notes')) diff --git a/openlp/core/ui/servicenoteform.py b/openlp/core/ui/servicenoteform.py index de689e842..32e7dfe40 100644 --- a/openlp/core/ui/servicenoteform.py +++ b/openlp/core/ui/servicenoteform.py @@ -26,6 +26,7 @@ from PyQt4 import QtCore, QtGui +from openlp.core.lib import dialogButtonsSaveCancel, translate from servicenotedialog import Ui_ServiceNoteEdit class ServiceNoteForm(QtGui.QDialog, Ui_ServiceNoteEdit): @@ -37,8 +38,19 @@ class ServiceNoteForm(QtGui.QDialog, Ui_ServiceNoteEdit): Constructor """ QtGui.QDialog.__init__(self, parent) - self.setupUi(self) - QtCore.QObject.connect(self.buttonBox, QtCore.SIGNAL(u'accepted()'), - self.accept) - QtCore.QObject.connect(self.buttonBox, QtCore.SIGNAL(u'rejected()'), - self.reject) \ No newline at end of file + self.setupUi() + self.retranslateUi() + + def setupUi(self): + self.setObjectName(u'serviceNoteEdit') + self.dialogLayout = QtGui.QVBoxLayout(self) + self.dialogLayout.setObjectName(u'verticalLayout') + self.textEdit = QtGui.QTextEdit(self) + self.textEdit.setObjectName(u'textEdit') + self.dialogLayout.addWidget(self.textEdit) + self.dialogLayout.addWidget(dialogButtonsSaveCancel(self)) + QtCore.QMetaObject.connectSlotsByName(self) + + def retranslateUi(self): + self.setWindowTitle( + translate('OpenLP.ServiceNoteForm', 'Service Item Notes')) diff --git a/openlp/core/ui/slidecontroller.py b/openlp/core/ui/slidecontroller.py index 916bf68c3..223624c4f 100644 --- a/openlp/core/ui/slidecontroller.py +++ b/openlp/core/ui/slidecontroller.py @@ -482,14 +482,7 @@ class SlideController(QtGui.QWidget): def onSongBarHandler(self): request = unicode(self.sender().text()) slideno = self.slideList[request] - if slideno > self.previewListWidget.rowCount(): - self.previewListWidget.selectRow( - self.previewListWidget.rowCount() - 1) - else: - if slideno + 1 < self.previewListWidget.rowCount(): - self.previewListWidget.scrollToItem( - self.previewListWidget.item(slideno + 1, 0)) - self.previewListWidget.selectRow(slideno) + self.__updatePreviewSelection(slideno) self.onSlideSelected() def receiveSpinDelay(self, value): @@ -665,14 +658,7 @@ class SlideController(QtGui.QWidget): self.previewListWidget.resizeRowsToContents() self.previewListWidget.setColumnWidth(0, self.previewListWidget.viewport().size().width()) - if slideno > self.previewListWidget.rowCount(): - self.previewListWidget.selectRow( - self.previewListWidget.rowCount() - 1) - else: - if slideno + 1 < self.previewListWidget.rowCount(): - self.previewListWidget.scrollToItem( - self.previewListWidget.item(slideno + 1, 0)) - self.previewListWidget.selectRow(slideno) + self.__updatePreviewSelection(slideno) self.enableToolBar(serviceItem) # Pass to display for viewing self.display.buildHtml(self.serviceItem) @@ -683,6 +669,19 @@ class SlideController(QtGui.QWidget): Receiver.send_message(u'slidecontroller_%s_started' % self.typePrefix, [serviceItem]) + def __updatePreviewSelection(self, slideno): + """ + Utility method to update the selected slide in the list. + """ + if slideno > self.previewListWidget.rowCount(): + self.previewListWidget.selectRow( + self.previewListWidget.rowCount() - 1) + else: + if slideno + 1 < self.previewListWidget.rowCount(): + self.previewListWidget.scrollToItem( + self.previewListWidget.item(slideno + 1, 0)) + self.previewListWidget.selectRow(slideno) + def onTextRequest(self): """ Return the text for the current item in controller diff --git a/openlp/core/ui/themestab.py b/openlp/core/ui/themestab.py index a440a564e..441b95155 100644 --- a/openlp/core/ui/themestab.py +++ b/openlp/core/ui/themestab.py @@ -165,13 +165,7 @@ class ThemesTab(SettingsTab): self.global_theme = unicode(self.DefaultComboBox.currentText()) self.parent.renderManager.set_global_theme( self.global_theme, self.theme_level) - image = self.parent.ThemeManagerContents.getPreviewImage( - self.global_theme) - preview = QtGui.QPixmap(unicode(image)) - if not preview.isNull(): - preview = preview.scaled(300, 255, QtCore.Qt.KeepAspectRatio, - QtCore.Qt.SmoothTransformation) - self.DefaultListView.setPixmap(preview) + self.__previewGlobalTheme() def updateThemeList(self, theme_list): """ @@ -198,10 +192,16 @@ class ThemesTab(SettingsTab): self.parent.renderManager.set_global_theme( self.global_theme, self.theme_level) if self.global_theme is not u'': - image = self.parent.ThemeManagerContents.getPreviewImage( - self.global_theme) - preview = QtGui.QPixmap(unicode(image)) - if not preview.isNull(): - preview = preview.scaled(300, 255, QtCore.Qt.KeepAspectRatio, - QtCore.Qt.SmoothTransformation) - self.DefaultListView.setPixmap(preview) + self.__previewGlobalTheme() + + def __previewGlobalTheme(self): + """ + Utility method to update the global theme preview image. + """ + image = self.parent.ThemeManagerContents.getPreviewImage( + self.global_theme) + preview = QtGui.QPixmap(unicode(image)) + if not preview.isNull(): + preview = preview.scaled(300, 255, QtCore.Qt.KeepAspectRatio, + QtCore.Qt.SmoothTransformation) + self.DefaultListView.setPixmap(preview) diff --git a/openlp/plugins/bibles/lib/mediaitem.py b/openlp/plugins/bibles/lib/mediaitem.py index 614990654..009a19b60 100644 --- a/openlp/plugins/bibles/lib/mediaitem.py +++ b/openlp/plugins/bibles/lib/mediaitem.py @@ -525,19 +525,7 @@ class BibleMediaItem(MediaManagerItem): if self.advancedClearComboBox.currentIndex() == 0: self.listView.clear() if self.listView.count() != 0: - # Check if the first item is a second bible item or not. - bitem = self.listView.item(0) - item_second_bible = self._decodeQtObject(bitem, 'second_bible') - if item_second_bible and second_bible or not item_second_bible and \ - not second_bible: - self.displayResults(bible, second_bible) - elif criticalErrorMessageBox( - message=translate('BiblePlugin.MediaItem', - 'You cannot combine single and second bible verses. Do you ' - 'want to delete your search results and start a new search?'), - parent=self, question=True) == QtGui.QMessageBox.Yes: - self.listView.clear() - self.displayResults(bible, second_bible) + self.__checkSecondBible() else: self.displayResults(bible, second_bible) Receiver.send_message(u'cursor_normal') @@ -577,24 +565,29 @@ class BibleMediaItem(MediaManagerItem): if self.quickClearComboBox.currentIndex() == 0: self.listView.clear() if self.listView.count() != 0 and self.search_results: - bitem = self.listView.item(0) - item_second_bible = self._decodeQtObject(bitem, 'second_bible') - if item_second_bible and second_bible or not item_second_bible and \ - not second_bible: - self.displayResults(bible, second_bible) - elif criticalErrorMessageBox( - message=translate('BiblePlugin.MediaItem', - 'You cannot combine single and second bible verses. Do you ' - 'want to delete your search results and start a new search?'), - parent=self, question=True) == QtGui.QMessageBox.Yes: - self.listView.clear() - self.displayResults(bible, second_bible) + self.__checkSecondBible() elif self.search_results: self.displayResults(bible, second_bible) self.quickSearchButton.setEnabled(True) Receiver.send_message(u'cursor_normal') Receiver.send_message(u'openlp_process_events') + def __checkSecondBible(self): + """ + Check if the first item is a second bible item or not. + """ + bitem = self.listView.item(0) + item_second_bible = self._decodeQtObject(bitem, 'second_bible') + if item_second_bible and second_bible or not item_second_bible and \ + not second_bible: + self.displayResults(bible, second_bible) + elif criticalErrorMessageBox(message=translate('BiblePlugin.MediaItem', + 'You cannot combine single and second bible verses. Do you ' + 'want to delete your search results and start a new search?'), + parent=self, question=True) == QtGui.QMessageBox.Yes: + self.listView.clear() + self.displayResults(bible, second_bible) + def displayResults(self, bible, second_bible=u''): """ Displays the search results in the media manager. All data needed for diff --git a/openlp/plugins/custom/forms/editcustomdialog.py b/openlp/plugins/custom/forms/editcustomdialog.py index d778b1dfe..1703d3363 100644 --- a/openlp/plugins/custom/forms/editcustomdialog.py +++ b/openlp/plugins/custom/forms/editcustomdialog.py @@ -26,7 +26,7 @@ from PyQt4 import QtCore, QtGui -from openlp.core.lib import build_icon, translate +from openlp.core.lib import build_icon, translate, dialogButtonsSaveCancel class Ui_CustomEditDialog(object): def setupUi(self, customEditDialog): @@ -93,16 +93,9 @@ class Ui_CustomEditDialog(object): self.creditLabel.setBuddy(self.creditEdit) self.bottomFormLayout.addRow(self.creditLabel, self.creditEdit) self.dialogLayout.addLayout(self.bottomFormLayout) - self.buttonBox = QtGui.QDialogButtonBox(customEditDialog) - self.buttonBox.setStandardButtons(QtGui.QDialogButtonBox.Cancel | - QtGui.QDialogButtonBox.Save) - self.buttonBox.setObjectName(u'buttonBox') + self.buttonBox = dialogButtonsSaveCancel(customEditDialog) self.dialogLayout.addWidget(self.buttonBox) self.retranslateUi(customEditDialog) - QtCore.QObject.connect(self.buttonBox, QtCore.SIGNAL(u'accepted()'), - customEditDialog.accept) - QtCore.QObject.connect(self.buttonBox, QtCore.SIGNAL(u'rejected()'), - customEditDialog.closePressed) QtCore.QMetaObject.connectSlotsByName(customEditDialog) def retranslateUi(self, customEditDialog): diff --git a/openlp/plugins/custom/forms/editcustomform.py b/openlp/plugins/custom/forms/editcustomform.py index ebc917e99..e274c2395 100644 --- a/openlp/plugins/custom/forms/editcustomform.py +++ b/openlp/plugins/custom/forms/editcustomform.py @@ -136,7 +136,7 @@ class EditCustomForm(QtGui.QDialog, Ui_CustomEditDialog): if preview: self.previewButton.setVisible(True) - def closePressed(self): + def reject(self): Receiver.send_message(u'custom_edit_clear') self.close() diff --git a/openlp/plugins/custom/forms/editcustomslidedialog.py b/openlp/plugins/custom/forms/editcustomslidedialog.py index 1f4bf5b14..2f95e4755 100644 --- a/openlp/plugins/custom/forms/editcustomslidedialog.py +++ b/openlp/plugins/custom/forms/editcustomslidedialog.py @@ -26,7 +26,7 @@ from PyQt4 import QtCore, QtGui -from openlp.core.lib import translate, SpellTextEdit +from openlp.core.lib import translate, SpellTextEdit, dialogButtonsSaveCancel class Ui_CustomSlideEditDialog(object): def setupUi(self, customSlideEditDialog): @@ -36,20 +36,13 @@ class Ui_CustomSlideEditDialog(object): self.slideTextEdit = SpellTextEdit(self) self.slideTextEdit.setObjectName(u'slideTextEdit') self.dialogLayout.addWidget(self.slideTextEdit) - self.buttonBox = QtGui.QDialogButtonBox(customSlideEditDialog) - self.buttonBox.setStandardButtons(QtGui.QDialogButtonBox.Cancel | - QtGui.QDialogButtonBox.Save) - self.buttonBox.setObjectName(u'buttonBox') + self.buttonBox = dialogButtonsSaveCancel(customSlideEditDialog) self.splitButton = QtGui.QPushButton(customSlideEditDialog) self.splitButton.setObjectName(u'splitButton') self.buttonBox.addButton(self.splitButton, QtGui.QDialogButtonBox.ActionRole) self.dialogLayout.addWidget(self.buttonBox) self.retranslateUi(customSlideEditDialog) - QtCore.QObject.connect(self.buttonBox, QtCore.SIGNAL(u'accepted()'), - customSlideEditDialog.accept) - QtCore.QObject.connect(self.buttonBox, QtCore.SIGNAL(u'rejected()'), - customSlideEditDialog.reject) QtCore.QMetaObject.connectSlotsByName(customSlideEditDialog) def retranslateUi(self, customSlideEditDialog): diff --git a/openlp/plugins/custom/lib/mediaitem.py b/openlp/plugins/custom/lib/mediaitem.py index 9b8115956..ec915b0a9 100644 --- a/openlp/plugins/custom/lib/mediaitem.py +++ b/openlp/plugins/custom/lib/mediaitem.py @@ -146,16 +146,7 @@ class CustomMediaItem(MediaManagerItem): raw_footer = [] slide = None theme = None - if item is None: - if self.remoteTriggered is None: - item = self.listView.currentItem() - if item is None: - return False - item_id = (item.data(QtCore.Qt.UserRole)).toInt()[0] - else: - item_id = self.remoteCustom - else: - item_id = (item.data(QtCore.Qt.UserRole)).toInt()[0] + item_id = self._getIdOfItemToGenerate(item, self.remoteCustom) service_item.add_capability(ItemCapabilities.AllowsEdit) service_item.add_capability(ItemCapabilities.AllowsPreview) service_item.add_capability(ItemCapabilities.AllowsLoop) diff --git a/openlp/plugins/presentations/lib/messagelistener.py b/openlp/plugins/presentations/lib/messagelistener.py index 19abadf0d..4d926ad3d 100644 --- a/openlp/plugins/presentations/lib/messagelistener.py +++ b/openlp/plugins/presentations/lib/messagelistener.py @@ -116,7 +116,7 @@ class Controller(object): def last(self): """ - Based on the handler passed at startup triggers the first slide + Based on the handler passed at startup triggers the last slide """ log.debug(u'Live = %s, last' % self.is_live) if not self.is_live: diff --git a/openlp/plugins/songs/forms/authorsdialog.py b/openlp/plugins/songs/forms/authorsdialog.py index 6f1c7f2a4..860e8b5ea 100644 --- a/openlp/plugins/songs/forms/authorsdialog.py +++ b/openlp/plugins/songs/forms/authorsdialog.py @@ -26,7 +26,7 @@ from PyQt4 import QtCore, QtGui -from openlp.core.lib import translate +from openlp.core.lib import dialogButtonsSaveCancel, translate class Ui_AuthorsDialog(object): def setupUi(self, authorsDialog): @@ -55,17 +55,9 @@ class Ui_AuthorsDialog(object): self.displayLabel.setBuddy(self.displayEdit) self.authorLayout.addRow(self.displayLabel, self.displayEdit) self.dialogLayout.addLayout(self.authorLayout) - self.buttonBox = QtGui.QDialogButtonBox(authorsDialog) - self.buttonBox.setStandardButtons( - QtGui.QDialogButtonBox.Save | QtGui.QDialogButtonBox.Cancel) - self.buttonBox.setObjectName(u'buttonBox') - self.dialogLayout.addWidget(self.buttonBox) + self.dialogLayout.addWidget(dialogButtonsSaveCancel(authorsDialog)) self.retranslateUi(authorsDialog) authorsDialog.setMaximumHeight(authorsDialog.sizeHint().height()) - QtCore.QObject.connect(self.buttonBox, - QtCore.SIGNAL(u'accepted()'), authorsDialog.accept) - QtCore.QObject.connect(self.buttonBox, - QtCore.SIGNAL(u'rejected()'), authorsDialog.reject) QtCore.QMetaObject.connectSlotsByName(authorsDialog) def retranslateUi(self, authorsDialog): diff --git a/openlp/plugins/songs/forms/editsongdialog.py b/openlp/plugins/songs/forms/editsongdialog.py index 675108af7..732f8e815 100644 --- a/openlp/plugins/songs/forms/editsongdialog.py +++ b/openlp/plugins/songs/forms/editsongdialog.py @@ -26,7 +26,7 @@ from PyQt4 import QtCore, QtGui -from openlp.core.lib import build_icon, translate +from openlp.core.lib import build_icon, translate, dialogButtonsSaveCancel class Ui_EditSongDialog(object): def setupUi(self, editSongDialog): @@ -264,16 +264,9 @@ class Ui_EditSongDialog(object): self.themeTabLayout.addWidget(self.commentsGroupBox) self.songTabWidget.addTab(self.themeTab, u'') self.dialogLayout.addWidget(self.songTabWidget) - self.buttonBox = QtGui.QDialogButtonBox(editSongDialog) - self.buttonBox.setStandardButtons( - QtGui.QDialogButtonBox.Cancel | QtGui.QDialogButtonBox.Save) - self.buttonBox.setObjectName(u'buttonBox') + self.buttonBox = dialogButtonsSaveCancel(editSongDialog) self.dialogLayout.addWidget(self.buttonBox) self.retranslateUi(editSongDialog) - QtCore.QObject.connect(self.buttonBox, - QtCore.SIGNAL(u'rejected()'), editSongDialog.closePressed) - QtCore.QObject.connect(self.buttonBox, - QtCore.SIGNAL(u'accepted()'), editSongDialog.accept) QtCore.QMetaObject.connectSlotsByName(editSongDialog) def retranslateUi(self, editSongDialog): diff --git a/openlp/plugins/songs/forms/editsongform.py b/openlp/plugins/songs/forms/editsongform.py index b36ea55e1..5e9fc1711 100644 --- a/openlp/plugins/songs/forms/editsongform.py +++ b/openlp/plugins/songs/forms/editsongform.py @@ -333,11 +333,7 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog): author = Author.populate(first_name=text.rsplit(u' ', 1)[0], last_name=text.rsplit(u' ', 1)[1], display_name=text) self.manager.save_object(author) - author_item = QtGui.QListWidgetItem( - unicode(author.display_name)) - author_item.setData(QtCore.Qt.UserRole, - QtCore.QVariant(author.id)) - self.authorsListView.addItem(author_item) + self.__addAuthorToList(author) self.loadAuthors() self.authorsComboBox.setCurrentIndex(0) else: @@ -351,11 +347,7 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog): message=translate('SongsPlugin.EditSongForm', 'This author is already in the list.')) else: - author_item = QtGui.QListWidgetItem(unicode( - author.display_name)) - author_item.setData(QtCore.Qt.UserRole, - QtCore.QVariant(author.id)) - self.authorsListView.addItem(author_item) + self.__addAuthorToList(author) self.authorsComboBox.setCurrentIndex(0) else: QtGui.QMessageBox.warning(self, @@ -365,6 +357,14 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog): 'or type in a new author and click the "Add Author to ' 'Song" button to add the new author.')) + def __addAuthorToList(self, author): + """ + Add an author to the author list. + """ + author_item = QtGui.QListWidgetItem(unicode(author.display_name)) + author_item.setData(QtCore.Qt.UserRole, QtCore.QVariant(author.id)) + self.authorsListView.addItem(author_item) + def onAuthorsListViewPressed(self): if self.authorsListView.count() > 1: self.authorRemoveButton.setEnabled(True) @@ -653,7 +653,7 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog): self.books = [] self.topics = [] - def closePressed(self): + def reject(self): """ Exit Dialog and do not save """ diff --git a/openlp/plugins/songs/forms/editversedialog.py b/openlp/plugins/songs/forms/editversedialog.py index 1710d8b93..5680dd8f6 100644 --- a/openlp/plugins/songs/forms/editversedialog.py +++ b/openlp/plugins/songs/forms/editversedialog.py @@ -26,7 +26,8 @@ from PyQt4 import QtCore, QtGui -from openlp.core.lib import build_icon, translate, SpellTextEdit +from openlp.core.lib import build_icon, dialogButtonsSaveCancel, translate, \ + SpellTextEdit from openlp.plugins.songs.lib import VerseType class Ui_EditVerseDialog(object): @@ -59,17 +60,8 @@ class Ui_EditVerseDialog(object): self.verseTypeLayout.addWidget(self.insertButton) self.verseTypeLayout.addStretch() self.dialogLayout.addLayout(self.verseTypeLayout) - self.buttonBox = QtGui.QDialogButtonBox(editVerseDialog) - self.buttonBox.setOrientation(QtCore.Qt.Horizontal) - self.buttonBox.setStandardButtons(QtGui.QDialogButtonBox.Cancel | - QtGui.QDialogButtonBox.Save) - self.buttonBox.setObjectName(u'buttonBox') - self.dialogLayout.addWidget(self.buttonBox) + self.dialogLayout.addWidget(dialogButtonsSaveCancel(editVerseDialog)) self.retranslateUi(editVerseDialog) - QtCore.QObject.connect(self.buttonBox, QtCore.SIGNAL(u'accepted()'), - editVerseDialog.accept) - QtCore.QObject.connect(self.buttonBox, QtCore.SIGNAL(u'rejected()'), - editVerseDialog.reject) QtCore.QMetaObject.connectSlotsByName(editVerseDialog) def retranslateUi(self, editVerseDialog): diff --git a/openlp/plugins/songs/forms/songbookdialog.py b/openlp/plugins/songs/forms/songbookdialog.py index 9b9da43bf..eb1220d66 100644 --- a/openlp/plugins/songs/forms/songbookdialog.py +++ b/openlp/plugins/songs/forms/songbookdialog.py @@ -26,7 +26,7 @@ from PyQt4 import QtCore, QtGui -from openlp.core.lib import translate +from openlp.core.lib import translate, dialogButtonsSaveCancel class Ui_SongBookDialog(object): def setupUi(self, songBookDialog): @@ -49,17 +49,9 @@ class Ui_SongBookDialog(object): self.publisherLabel.setBuddy(self.publisherEdit) self.bookLayout.addRow(self.publisherLabel, self.publisherEdit) self.dialogLayout.addLayout(self.bookLayout) - self.buttonBox = QtGui.QDialogButtonBox(songBookDialog) - self.buttonBox.setStandardButtons( - QtGui.QDialogButtonBox.Save | QtGui.QDialogButtonBox.Cancel) - self.buttonBox.setObjectName(u'buttonBox') - self.dialogLayout.addWidget(self.buttonBox) + self.dialogLayout.addWidget(dialogButtonsSaveCancel(songBookDialog)) self.retranslateUi(songBookDialog) songBookDialog.setMaximumHeight(songBookDialog.sizeHint().height()) - QtCore.QObject.connect(self.buttonBox, - QtCore.SIGNAL(u'accepted()'), songBookDialog.accept) - QtCore.QObject.connect(self.buttonBox, - QtCore.SIGNAL(u'rejected()'), songBookDialog.reject) QtCore.QMetaObject.connectSlotsByName(songBookDialog) def retranslateUi(self, songBookDialog): diff --git a/openlp/plugins/songs/forms/songmaintenanceform.py b/openlp/plugins/songs/forms/songmaintenanceform.py index 6613a050b..2bc609ee2 100644 --- a/openlp/plugins/songs/forms/songmaintenanceform.py +++ b/openlp/plugins/songs/forms/songmaintenanceform.py @@ -310,12 +310,8 @@ class SongMaintenanceForm(QtGui.QDialog, Ui_SongMaintenanceDialog): 'the existing author %s?')) % (author.display_name, temp_display_name, author.display_name), parent=self, question=True) == QtGui.QMessageBox.Yes: - Receiver.send_message(u'cursor_busy') - Receiver.send_message(u'openlp_process_events') - self.mergeAuthors(author) - self.resetAuthors() - Receiver.send_message(u'songs_load_list') - Receiver.send_message(u'cursor_normal') + self.__mergeObjects(author, self.mergeAuthors, + self.resetAuthors) else: # We restore the author's old first and last name as well as # his display name. @@ -350,11 +346,7 @@ class SongMaintenanceForm(QtGui.QDialog, Ui_SongMaintenanceDialog): 'with topic %s use the existing topic %s?')) % (topic.name, temp_name, topic.name), parent=self, question=True) == QtGui.QMessageBox.Yes: - Receiver.send_message(u'cursor_busy') - Receiver.send_message(u'openlp_process_events') - self.mergeTopics(topic) - self.resetTopics() - Receiver.send_message(u'cursor_normal') + self.__mergeObjects(topic, self.mergeTopics, self.resetTopics) else: # We restore the topics's old name. topic.name = temp_name @@ -392,16 +384,23 @@ class SongMaintenanceForm(QtGui.QDialog, Ui_SongMaintenanceDialog): 'with book %s use the existing book %s?')) % (book.name, temp_name, book.name), parent=self, question=True) == QtGui.QMessageBox.Yes: - Receiver.send_message(u'cursor_busy') - Receiver.send_message(u'openlp_process_events') - self.mergeBooks(book) - self.resetBooks() - Receiver.send_message(u'cursor_normal') + self.__mergeObjects(book, self.mergeBooks, self.resetBooks) else: # We restore the book's old name and publisher. book.name = temp_name book.publisher = temp_publisher + def __mergeObjects(self, object, merge, reset): + """ + Utility method to merge two objects to leave one in the database. + """ + Receiver.send_message(u'cursor_busy') + Receiver.send_message(u'openlp_process_events') + merge(object) + reset() + Receiver.send_message(u'songs_load_list') + Receiver.send_message(u'cursor_normal') + def mergeAuthors(self, old_author): """ Merges two authors into one author. @@ -508,42 +507,32 @@ class SongMaintenanceForm(QtGui.QDialog, Ui_SongMaintenanceDialog): def onAuthorsListRowChanged(self, row): """ - Called when the *authorsListWidget* current's row has changed. - - ``row`` - The current row. If there is no current row, the value is -1 + Called when the *authorsListWidget*s current row has changed. """ - if row == -1: - self.authorsDeleteButton.setEnabled(False) - self.authorsEditButton.setEnabled(False) - else: - self.authorsDeleteButton.setEnabled(True) - self.authorsEditButton.setEnabled(True) + self.__rowChange(row, self.authorsEditButton, self.authorsDeleteButton) def onTopicsListRowChanged(self, row): """ - Called when the *booksListWidget* current's row has changed. - - ``row`` - The current row. If there is no current row, the value is -1. + Called when the *topicsListWidget*s current row has changed. """ - if row == -1: - self.topicsDeleteButton.setEnabled(False) - self.topicsEditButton.setEnabled(False) - else: - self.topicsDeleteButton.setEnabled(True) - self.topicsEditButton.setEnabled(True) + self.__rowChange(row, self.topicsEditButton, self.topicsDeleteButton) def onBooksListRowChanged(self, row): """ - Called when the *booksListWidget* current's row has changed. + Called when the *booksListWidget*s current row has changed. + """ + self.__rowChange(row, self.booksEditButton, self.booksDeleteButton) + + def __rowChange(self, row, editButton, deleteButton): + """ + Utility method to toggle if buttons are enabled. ``row`` The current row. If there is no current row, the value is -1. """ if row == -1: - self.booksDeleteButton.setEnabled(False) - self.booksEditButton.setEnabled(False) + deleteButton.setEnabled(False) + editButton.setEnabled(False) else: - self.booksDeleteButton.setEnabled(True) - self.booksEditButton.setEnabled(True) + deleteButton.setEnabled(True) + editButton.setEnabled(True) diff --git a/openlp/plugins/songs/forms/topicsdialog.py b/openlp/plugins/songs/forms/topicsdialog.py index ca0bbed97..8b4ea60bb 100644 --- a/openlp/plugins/songs/forms/topicsdialog.py +++ b/openlp/plugins/songs/forms/topicsdialog.py @@ -26,7 +26,7 @@ from PyQt4 import QtCore, QtGui -from openlp.core.lib import translate +from openlp.core.lib import translate, dialogButtonsSaveCancel class Ui_TopicsDialog(object): def setupUi(self, topicsDialog): @@ -43,17 +43,9 @@ class Ui_TopicsDialog(object): self.nameLabel.setBuddy(self.nameEdit) self.nameLayout.addRow(self.nameLabel, self.nameEdit) self.dialogLayout.addLayout(self.nameLayout) - self.buttonBox = QtGui.QDialogButtonBox(topicsDialog) - self.buttonBox.setStandardButtons( - QtGui.QDialogButtonBox.Save | QtGui.QDialogButtonBox.Cancel) - self.buttonBox.setObjectName(u'buttonBox') - self.dialogLayout.addWidget(self.buttonBox) + self.dialogLayout.addWidget(dialogButtonsSaveCancel(topicsDialog)) self.retranslateUi(topicsDialog) topicsDialog.setMaximumHeight(topicsDialog.sizeHint().height()) - QtCore.QObject.connect(self.buttonBox, - QtCore.SIGNAL(u'accepted()'), topicsDialog.accept) - QtCore.QObject.connect(self.buttonBox, - QtCore.SIGNAL(u'rejected()'), topicsDialog.reject) QtCore.QMetaObject.connectSlotsByName(topicsDialog) def retranslateUi(self, topicsDialog): diff --git a/openlp/plugins/songs/lib/easislidesimport.py b/openlp/plugins/songs/lib/easislidesimport.py index 84e7a3841..fe44c763a 100644 --- a/openlp/plugins/songs/lib/easislidesimport.py +++ b/openlp/plugins/songs/lib/easislidesimport.py @@ -133,30 +133,38 @@ class EasiSlidesImport(SongImport): pass def _add_copyright(self, song): + """ + Assign the copyright information from the import to the song being + created. + + ``song`` + The current song being imported. + """ copyright = [] - try: - copyright.append(unicode(song.Copyright).strip()) - except UnicodeDecodeError: - log.exception(u'Unicode decode error while decoding Copyright') - self._success = False - except AttributeError: - pass - try: - copyright.append(unicode(song.LicenceAdmin1).strip()) - except UnicodeDecodeError: - log.exception(u'Unicode decode error while decoding LicenceAdmin1') - self._success = False - except AttributeError: - pass - try: - copyright.append(unicode(song.LicenceAdmin2).strip()) - except UnicodeDecodeError: - log.exception(u'Unicode decode error while decoding LicenceAdmin2') - self._success = False - except AttributeError: - pass + self.__add_copyright_element(copyright, song.Copyright) + self.__add_copyright_element(copyright, song.LicenceAdmin1) + self.__add_copyright_element(copyright, song.LicenceAdmin2) self.add_copyright(u' '.join(copyright)) + def __add_copyright_element(self, copyright, element): + """ + Add a piece of copyright to the total copyright information for the + song. + + ``copyright`` + The array to add the information to. + + ``element`` + The imported variable to get the data from. + """ + try: + copyright.append(unicode(element).strip()) + except UnicodeDecodeError: + log.exception(u'Unicode error decoding %s' % element) + self._success = False + except AttributeError: + pass + def _parse_and_add_lyrics(self, song): try: lyrics = unicode(song.Contents).strip() diff --git a/openlp/plugins/songs/lib/mediaitem.py b/openlp/plugins/songs/lib/mediaitem.py index dc51f97f5..a62471c2d 100644 --- a/openlp/plugins/songs/lib/mediaitem.py +++ b/openlp/plugins/songs/lib/mediaitem.py @@ -337,16 +337,7 @@ class SongMediaItem(MediaManagerItem): author_list = u'' author_audit = [] ccli = u'' - if item is None: - if self.remoteTriggered is None: - item = self.listView.currentItem() - if item is None: - return False - item_id = (item.data(QtCore.Qt.UserRole)).toInt()[0] - else: - item_id = self.remoteSong - else: - item_id = (item.data(QtCore.Qt.UserRole)).toInt()[0] + item_id = self._getIdOfItemToGenerate(item, self.remoteSong) service_item.add_capability(ItemCapabilities.AllowsEdit) service_item.add_capability(ItemCapabilities.AllowsPreview) service_item.add_capability(ItemCapabilities.AllowsLoop) From f63b046d9bc62378e32f74896dfbfa5df9d6030d Mon Sep 17 00:00:00 2001 From: Jon Tibble Date: Tue, 1 Feb 2011 01:02:44 +0000 Subject: [PATCH 28/43] Fix silly incorrectly formatted name --- openlp/core/lib/__init__.py | 2 +- openlp/core/ui/serviceitemeditdialog.py | 4 ++-- openlp/core/ui/servicenoteform.py | 4 ++-- openlp/plugins/custom/forms/editcustomdialog.py | 4 ++-- openlp/plugins/custom/forms/editcustomslidedialog.py | 4 ++-- openlp/plugins/songs/forms/authorsdialog.py | 4 ++-- openlp/plugins/songs/forms/editsongdialog.py | 4 ++-- openlp/plugins/songs/forms/editversedialog.py | 4 ++-- openlp/plugins/songs/forms/songbookdialog.py | 4 ++-- openlp/plugins/songs/forms/topicsdialog.py | 4 ++-- 10 files changed, 19 insertions(+), 19 deletions(-) diff --git a/openlp/core/lib/__init__.py b/openlp/core/lib/__init__.py index ee2b68c91..f07d7c78d 100644 --- a/openlp/core/lib/__init__.py +++ b/openlp/core/lib/__init__.py @@ -319,7 +319,7 @@ def check_directory_exists(dir): if not os.path.exists(dir): os.makedirs(dir) -def dialogButtonsSaveCancel(parent): +def save_cancel_button_box(parent): """ Return a standard dialog button box with save and cancel buttons. """ diff --git a/openlp/core/ui/serviceitemeditdialog.py b/openlp/core/ui/serviceitemeditdialog.py index 025a7d40c..0993c48b2 100644 --- a/openlp/core/ui/serviceitemeditdialog.py +++ b/openlp/core/ui/serviceitemeditdialog.py @@ -26,7 +26,7 @@ from PyQt4 import QtCore, QtGui -from openlp.core.lib import translate, build_icon, dialogButtonsSaveCancel +from openlp.core.lib import translate, build_icon, save_cancel_button_box class Ui_ServiceItemEditDialog(object): def setupUi(self, serviceItemEditDialog): @@ -53,7 +53,7 @@ class Ui_ServiceItemEditDialog(object): self.buttonLayout.addWidget(self.downButton) self.dialogLayout.addLayout(self.buttonLayout, 0, 1) self.dialogLayout.addWidget( - dialogButtonsSaveCancel(serviceItemEditDialog), 1, 0, 1, 2) + save_cancel_button_box(serviceItemEditDialog), 1, 0, 1, 2) self.retranslateUi(serviceItemEditDialog) QtCore.QMetaObject.connectSlotsByName(serviceItemEditDialog) diff --git a/openlp/core/ui/servicenoteform.py b/openlp/core/ui/servicenoteform.py index 32e7dfe40..215ff2b9d 100644 --- a/openlp/core/ui/servicenoteform.py +++ b/openlp/core/ui/servicenoteform.py @@ -26,7 +26,7 @@ from PyQt4 import QtCore, QtGui -from openlp.core.lib import dialogButtonsSaveCancel, translate +from openlp.core.lib import save_cancel_button_box, translate from servicenotedialog import Ui_ServiceNoteEdit class ServiceNoteForm(QtGui.QDialog, Ui_ServiceNoteEdit): @@ -48,7 +48,7 @@ class ServiceNoteForm(QtGui.QDialog, Ui_ServiceNoteEdit): self.textEdit = QtGui.QTextEdit(self) self.textEdit.setObjectName(u'textEdit') self.dialogLayout.addWidget(self.textEdit) - self.dialogLayout.addWidget(dialogButtonsSaveCancel(self)) + self.dialogLayout.addWidget(save_cancel_button_box(self)) QtCore.QMetaObject.connectSlotsByName(self) def retranslateUi(self): diff --git a/openlp/plugins/custom/forms/editcustomdialog.py b/openlp/plugins/custom/forms/editcustomdialog.py index 1703d3363..3d5e3a3f7 100644 --- a/openlp/plugins/custom/forms/editcustomdialog.py +++ b/openlp/plugins/custom/forms/editcustomdialog.py @@ -26,7 +26,7 @@ from PyQt4 import QtCore, QtGui -from openlp.core.lib import build_icon, translate, dialogButtonsSaveCancel +from openlp.core.lib import build_icon, translate, save_cancel_button_box class Ui_CustomEditDialog(object): def setupUi(self, customEditDialog): @@ -93,7 +93,7 @@ class Ui_CustomEditDialog(object): self.creditLabel.setBuddy(self.creditEdit) self.bottomFormLayout.addRow(self.creditLabel, self.creditEdit) self.dialogLayout.addLayout(self.bottomFormLayout) - self.buttonBox = dialogButtonsSaveCancel(customEditDialog) + self.buttonBox = save_cancel_button_box(customEditDialog) self.dialogLayout.addWidget(self.buttonBox) self.retranslateUi(customEditDialog) QtCore.QMetaObject.connectSlotsByName(customEditDialog) diff --git a/openlp/plugins/custom/forms/editcustomslidedialog.py b/openlp/plugins/custom/forms/editcustomslidedialog.py index 2f95e4755..1325590d9 100644 --- a/openlp/plugins/custom/forms/editcustomslidedialog.py +++ b/openlp/plugins/custom/forms/editcustomslidedialog.py @@ -26,7 +26,7 @@ from PyQt4 import QtCore, QtGui -from openlp.core.lib import translate, SpellTextEdit, dialogButtonsSaveCancel +from openlp.core.lib import translate, SpellTextEdit, save_cancel_button_box class Ui_CustomSlideEditDialog(object): def setupUi(self, customSlideEditDialog): @@ -36,7 +36,7 @@ class Ui_CustomSlideEditDialog(object): self.slideTextEdit = SpellTextEdit(self) self.slideTextEdit.setObjectName(u'slideTextEdit') self.dialogLayout.addWidget(self.slideTextEdit) - self.buttonBox = dialogButtonsSaveCancel(customSlideEditDialog) + self.buttonBox = save_cancel_button_box(customSlideEditDialog) self.splitButton = QtGui.QPushButton(customSlideEditDialog) self.splitButton.setObjectName(u'splitButton') self.buttonBox.addButton(self.splitButton, diff --git a/openlp/plugins/songs/forms/authorsdialog.py b/openlp/plugins/songs/forms/authorsdialog.py index 860e8b5ea..daae83525 100644 --- a/openlp/plugins/songs/forms/authorsdialog.py +++ b/openlp/plugins/songs/forms/authorsdialog.py @@ -26,7 +26,7 @@ from PyQt4 import QtCore, QtGui -from openlp.core.lib import dialogButtonsSaveCancel, translate +from openlp.core.lib import translate, save_cancel_button_box class Ui_AuthorsDialog(object): def setupUi(self, authorsDialog): @@ -55,7 +55,7 @@ class Ui_AuthorsDialog(object): self.displayLabel.setBuddy(self.displayEdit) self.authorLayout.addRow(self.displayLabel, self.displayEdit) self.dialogLayout.addLayout(self.authorLayout) - self.dialogLayout.addWidget(dialogButtonsSaveCancel(authorsDialog)) + self.dialogLayout.addWidget(save_cancel_button_box(authorsDialog)) self.retranslateUi(authorsDialog) authorsDialog.setMaximumHeight(authorsDialog.sizeHint().height()) QtCore.QMetaObject.connectSlotsByName(authorsDialog) diff --git a/openlp/plugins/songs/forms/editsongdialog.py b/openlp/plugins/songs/forms/editsongdialog.py index 732f8e815..4714ab093 100644 --- a/openlp/plugins/songs/forms/editsongdialog.py +++ b/openlp/plugins/songs/forms/editsongdialog.py @@ -26,7 +26,7 @@ from PyQt4 import QtCore, QtGui -from openlp.core.lib import build_icon, translate, dialogButtonsSaveCancel +from openlp.core.lib import build_icon, translate, save_cancel_button_box class Ui_EditSongDialog(object): def setupUi(self, editSongDialog): @@ -264,7 +264,7 @@ class Ui_EditSongDialog(object): self.themeTabLayout.addWidget(self.commentsGroupBox) self.songTabWidget.addTab(self.themeTab, u'') self.dialogLayout.addWidget(self.songTabWidget) - self.buttonBox = dialogButtonsSaveCancel(editSongDialog) + self.buttonBox = save_cancel_button_box(editSongDialog) self.dialogLayout.addWidget(self.buttonBox) self.retranslateUi(editSongDialog) QtCore.QMetaObject.connectSlotsByName(editSongDialog) diff --git a/openlp/plugins/songs/forms/editversedialog.py b/openlp/plugins/songs/forms/editversedialog.py index 5680dd8f6..d74da50d1 100644 --- a/openlp/plugins/songs/forms/editversedialog.py +++ b/openlp/plugins/songs/forms/editversedialog.py @@ -26,7 +26,7 @@ from PyQt4 import QtCore, QtGui -from openlp.core.lib import build_icon, dialogButtonsSaveCancel, translate, \ +from openlp.core.lib import build_icon, save_cancel_button_box, translate, \ SpellTextEdit from openlp.plugins.songs.lib import VerseType @@ -60,7 +60,7 @@ class Ui_EditVerseDialog(object): self.verseTypeLayout.addWidget(self.insertButton) self.verseTypeLayout.addStretch() self.dialogLayout.addLayout(self.verseTypeLayout) - self.dialogLayout.addWidget(dialogButtonsSaveCancel(editVerseDialog)) + self.dialogLayout.addWidget(save_cancel_button_box(editVerseDialog)) self.retranslateUi(editVerseDialog) QtCore.QMetaObject.connectSlotsByName(editVerseDialog) diff --git a/openlp/plugins/songs/forms/songbookdialog.py b/openlp/plugins/songs/forms/songbookdialog.py index eb1220d66..757a629ab 100644 --- a/openlp/plugins/songs/forms/songbookdialog.py +++ b/openlp/plugins/songs/forms/songbookdialog.py @@ -26,7 +26,7 @@ from PyQt4 import QtCore, QtGui -from openlp.core.lib import translate, dialogButtonsSaveCancel +from openlp.core.lib import translate, save_cancel_button_box class Ui_SongBookDialog(object): def setupUi(self, songBookDialog): @@ -49,7 +49,7 @@ class Ui_SongBookDialog(object): self.publisherLabel.setBuddy(self.publisherEdit) self.bookLayout.addRow(self.publisherLabel, self.publisherEdit) self.dialogLayout.addLayout(self.bookLayout) - self.dialogLayout.addWidget(dialogButtonsSaveCancel(songBookDialog)) + self.dialogLayout.addWidget(save_cancel_button_box(songBookDialog)) self.retranslateUi(songBookDialog) songBookDialog.setMaximumHeight(songBookDialog.sizeHint().height()) QtCore.QMetaObject.connectSlotsByName(songBookDialog) diff --git a/openlp/plugins/songs/forms/topicsdialog.py b/openlp/plugins/songs/forms/topicsdialog.py index 8b4ea60bb..38c45407f 100644 --- a/openlp/plugins/songs/forms/topicsdialog.py +++ b/openlp/plugins/songs/forms/topicsdialog.py @@ -26,7 +26,7 @@ from PyQt4 import QtCore, QtGui -from openlp.core.lib import translate, dialogButtonsSaveCancel +from openlp.core.lib import translate, save_cancel_button_box class Ui_TopicsDialog(object): def setupUi(self, topicsDialog): @@ -43,7 +43,7 @@ class Ui_TopicsDialog(object): self.nameLabel.setBuddy(self.nameEdit) self.nameLayout.addRow(self.nameLabel, self.nameEdit) self.dialogLayout.addLayout(self.nameLayout) - self.dialogLayout.addWidget(dialogButtonsSaveCancel(topicsDialog)) + self.dialogLayout.addWidget(save_cancel_button_box(topicsDialog)) self.retranslateUi(topicsDialog) topicsDialog.setMaximumHeight(topicsDialog.sizeHint().height()) QtCore.QMetaObject.connectSlotsByName(topicsDialog) From 807298df6025fe463c60b018d794619f8c59e4e3 Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Tue, 1 Feb 2011 06:04:49 +0000 Subject: [PATCH 29/43] Fix Theme to XML conversion for BOLD Fixes: https://launchpad.net/bugs/710265 --- openlp/core/lib/theme.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openlp/core/lib/theme.py b/openlp/core/lib/theme.py index 70517b34d..8d2c8f356 100644 --- a/openlp/core/lib/theme.py +++ b/openlp/core/lib/theme.py @@ -156,7 +156,7 @@ class VerticalType(object): Middle = 1 Bottom = 2 -boolean_list = [u'italics', u'override', u'outline', u'shadow', +boolean_list = [u'bold', u'italics', u'override', u'outline', u'shadow', u'slide_transition'] integer_list = [u'size', u'line_adjustment', u'x', u'height', u'y', From cfb263cd821338eff00d336c391aea2d858d0897 Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Tue, 1 Feb 2011 07:27:19 +0100 Subject: [PATCH 30/43] --- openlp/core/ui/servicemanager.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/openlp/core/ui/servicemanager.py b/openlp/core/ui/servicemanager.py index 6b0b84472..d43e06fe7 100644 --- a/openlp/core/ui/servicemanager.py +++ b/openlp/core/ui/servicemanager.py @@ -1192,12 +1192,14 @@ class ServiceManager(QtGui.QWidget): printDialog = QtGui.QPrintDialog() if not printDialog.exec_(): return - text = u'

%s

' % translate('OpenLP.ServiceManager', + text = u'

%s

' % translate('OpenLP.ServiceManager', + 'Service Order Sheet') + text += u'%s' % translate('OpenLP.ServiceManager', 'Service Order Sheet') for item in self.serviceItems: item = item[u'service_item'] # add the title - text += u'

%s

' % (item.icon, + text += u'

%s

' % (item.icon, item.get_display_title()) if not QtCore.QSettings().value(u'advanced' + u'/detailed service print', QtCore.QVariant(True)).toBool(): From 40e9bb566b6b337fb9a38511a7296136ee6a5abc Mon Sep 17 00:00:00 2001 From: Jon Tibble Date: Tue, 1 Feb 2011 13:39:17 +0000 Subject: [PATCH 31/43] Fix variable passing --- openlp/plugins/bibles/lib/mediaitem.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/openlp/plugins/bibles/lib/mediaitem.py b/openlp/plugins/bibles/lib/mediaitem.py index 009a19b60..de2649b31 100644 --- a/openlp/plugins/bibles/lib/mediaitem.py +++ b/openlp/plugins/bibles/lib/mediaitem.py @@ -525,7 +525,7 @@ class BibleMediaItem(MediaManagerItem): if self.advancedClearComboBox.currentIndex() == 0: self.listView.clear() if self.listView.count() != 0: - self.__checkSecondBible() + self.__checkSecondBible(bible, second_bible) else: self.displayResults(bible, second_bible) Receiver.send_message(u'cursor_normal') @@ -565,14 +565,14 @@ class BibleMediaItem(MediaManagerItem): if self.quickClearComboBox.currentIndex() == 0: self.listView.clear() if self.listView.count() != 0 and self.search_results: - self.__checkSecondBible() + self.__checkSecondBible(bible, second_bible) elif self.search_results: self.displayResults(bible, second_bible) self.quickSearchButton.setEnabled(True) Receiver.send_message(u'cursor_normal') Receiver.send_message(u'openlp_process_events') - def __checkSecondBible(self): + def __checkSecondBible(self, bible, second_bible): """ Check if the first item is a second bible item or not. """ From 91540c221a753398641d267ad350f44df90b2eb9 Mon Sep 17 00:00:00 2001 From: Jon Tibble Date: Tue, 1 Feb 2011 18:05:59 +0000 Subject: [PATCH 32/43] Cleanups and fix song edit form --- openlp/core/ui/mainwindow.py | 8 ++--- openlp/core/ui/servicenoteform.py | 3 +- openlp/core/ui/slidecontroller.py | 24 ++++++------- openlp/core/ui/themewizard.py | 34 +++++++++---------- openlp/plugins/songs/forms/editsongform.py | 8 +++-- .../songs/forms/songmaintenanceform.py | 8 ++--- openlp/plugins/songs/lib/easislidesimport.py | 16 ++++----- 7 files changed, 50 insertions(+), 51 deletions(-) diff --git a/openlp/core/ui/mainwindow.py b/openlp/core/ui/mainwindow.py index d8bedade3..b84801aff 100644 --- a/openlp/core/ui/mainwindow.py +++ b/openlp/core/ui/mainwindow.py @@ -87,10 +87,10 @@ class Ui_MainWindow(object): self.screens, True) previewVisible = QtCore.QSettings().value( u'user interface/preview panel', QtCore.QVariant(True)).toBool() - self.previewController.Panel.setVisible(previewVisible) + self.previewController.panel.setVisible(previewVisible) liveVisible = QtCore.QSettings().value(u'user interface/live panel', QtCore.QVariant(True)).toBool() - self.liveController.Panel.setVisible(liveVisible) + self.liveController.panel.setVisible(liveVisible) # Create menu self.MenuBar = QtGui.QMenuBar(mainWindow) self.MenuBar.setObjectName(u'MenuBar') @@ -926,7 +926,7 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow): True - Visible False - Hidden """ - self.previewController.Panel.setVisible(visible) + self.previewController.panel.setVisible(visible) QtCore.QSettings().setValue(u'user interface/preview panel', QtCore.QVariant(visible)) self.ViewPreviewPanel.setChecked(visible) @@ -941,7 +941,7 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow): True - Visible False - Hidden """ - self.liveController.Panel.setVisible(visible) + self.liveController.panel.setVisible(visible) QtCore.QSettings().setValue(u'user interface/live panel', QtCore.QVariant(visible)) self.ViewLivePanel.setChecked(visible) diff --git a/openlp/core/ui/servicenoteform.py b/openlp/core/ui/servicenoteform.py index 215ff2b9d..5cb68d03f 100644 --- a/openlp/core/ui/servicenoteform.py +++ b/openlp/core/ui/servicenoteform.py @@ -27,9 +27,8 @@ from PyQt4 import QtCore, QtGui from openlp.core.lib import save_cancel_button_box, translate -from servicenotedialog import Ui_ServiceNoteEdit -class ServiceNoteForm(QtGui.QDialog, Ui_ServiceNoteEdit): +class ServiceNoteForm(QtGui.QDialog): """ This is the form that is used to edit the verses of the song. """ diff --git a/openlp/core/ui/slidecontroller.py b/openlp/core/ui/slidecontroller.py index 223624c4f..ab8a656ff 100644 --- a/openlp/core/ui/slidecontroller.py +++ b/openlp/core/ui/slidecontroller.py @@ -77,14 +77,14 @@ class SlideController(QtGui.QWidget): self.selectedRow = 0 self.serviceItem = None self.alertTab = None - self.Panel = QtGui.QWidget(parent.ControlSplitter) + self.panel = QtGui.QWidget(parent.ControlSplitter) self.slideList = {} # Layout for holding panel - self.panelLayout = QtGui.QVBoxLayout(self.Panel) + self.panelLayout = QtGui.QVBoxLayout(self.panel) self.panelLayout.setSpacing(0) self.panelLayout.setMargin(0) # Type label for the top of the slide controller - self.typeLabel = QtGui.QLabel(self.Panel) + self.typeLabel = QtGui.QLabel(self.panel) if self.isLive: self.typeLabel.setText(translate('OpenLP.SlideController', 'Live')) self.split = 1 @@ -98,7 +98,7 @@ class SlideController(QtGui.QWidget): self.typeLabel.setAlignment(QtCore.Qt.AlignCenter) self.panelLayout.addWidget(self.typeLabel) # Splitter - self.splitter = QtGui.QSplitter(self.Panel) + self.splitter = QtGui.QSplitter(self.panel) self.splitter.setOrientation(QtCore.Qt.Vertical) self.panelLayout.addWidget(self.splitter) # Actual controller section @@ -185,13 +185,13 @@ class SlideController(QtGui.QWidget): u'Stop Loop', u':/media/media_stop.png', translate('OpenLP.SlideController', 'Stop continuous loop'), self.onStopLoop) - self.DelaySpinBox = QtGui.QSpinBox() - self.DelaySpinBox.setMinimum(1) - self.DelaySpinBox.setMaximum(180) - self.toolbar.addToolbarWidget(u'Image SpinBox', self.DelaySpinBox) - self.DelaySpinBox.setSuffix(translate('OpenLP.SlideController', + self.delaySpinBox = QtGui.QSpinBox() + self.delaySpinBox.setMinimum(1) + self.delaySpinBox.setMaximum(180) + self.toolbar.addToolbarWidget(u'Image SpinBox', self.delaySpinBox) + self.delaySpinBox.setSuffix(translate('OpenLP.SlideController', 's')) - self.DelaySpinBox.setToolTip(translate('OpenLP.SlideController', + self.delaySpinBox.setToolTip(translate('OpenLP.SlideController', 'Delay between slides in seconds')) else: self.toolbar.addToolbarSeparator(u'Close Separator') @@ -486,7 +486,7 @@ class SlideController(QtGui.QWidget): self.onSlideSelected() def receiveSpinDelay(self, value): - self.DelaySpinBox.setValue(int(value)) + self.delaySpinBox.setValue(int(value)) def enableToolBar(self, item): """ @@ -998,7 +998,7 @@ class SlideController(QtGui.QWidget): """ if self.previewListWidget.rowCount() > 1: self.timer_id = self.startTimer( - int(self.DelaySpinBox.value()) * 1000) + int(self.delaySpinBox.value()) * 1000) self.toolbar.actions[u'Stop Loop'].setVisible(True) self.toolbar.actions[u'Start Loop'].setVisible(False) diff --git a/openlp/core/ui/themewizard.py b/openlp/core/ui/themewizard.py index 50e8109c5..aba486960 100644 --- a/openlp/core/ui/themewizard.py +++ b/openlp/core/ui/themewizard.py @@ -29,12 +29,11 @@ from PyQt4 import QtCore, QtGui from openlp.core.lib import translate, build_icon class Ui_ThemeWizard(object): - def setupUi(self, ThemeWizard): - ThemeWizard.setObjectName(u'OpenLP.ThemeWizard') - ThemeWizard.setModal(True) - ThemeWizard.setWizardStyle(QtGui.QWizard.ModernStyle) - ThemeWizard.setOptions( - QtGui.QWizard.IndependentPages | + def setupUi(self, themeWizard): + themeWizard.setObjectName(u'OpenLP.ThemeWizard') + themeWizard.setModal(True) + themeWizard.setWizardStyle(QtGui.QWizard.ModernStyle) + themeWizard.setOptions(QtGui.QWizard.IndependentPages | QtGui.QWizard.NoBackButtonOnStartPage) # Welcome Page self.welcomePage = QtGui.QWizardPage() @@ -52,7 +51,7 @@ class Ui_ThemeWizard(object): self.informationLabel.setObjectName(u'InformationLabel') self.welcomeLayout.addWidget(self.informationLabel) self.welcomeLayout.addStretch() - ThemeWizard.addPage(self.welcomePage) + themeWizard.addPage(self.welcomePage) # Background Page self.backgroundPage = QtGui.QWizardPage() self.backgroundPage.setObjectName(u'BackgroundPage') @@ -142,7 +141,7 @@ class Ui_ThemeWizard(object): self.imageSpacer) self.backgroundStack.addWidget(self.imageWidget) self.backgroundLayout.addLayout(self.backgroundStack) - ThemeWizard.addPage(self.backgroundPage) + themeWizard.addPage(self.backgroundPage) # Main Area Page self.mainAreaPage = QtGui.QWizardPage() self.mainAreaPage.setObjectName(u'MainAreaPage') @@ -225,7 +224,7 @@ class Ui_ThemeWizard(object): self.shadowSizeSpinBox.setObjectName(u'ShadowSizeSpinBox') self.shadowLayout.addWidget(self.shadowSizeSpinBox) self.mainAreaLayout.addRow(self.shadowCheckBox, self.shadowLayout) - ThemeWizard.addPage(self.mainAreaPage) + themeWizard.addPage(self.mainAreaPage) # Footer Area Page self.footerAreaPage = QtGui.QWizardPage() self.footerAreaPage.setObjectName(u'FooterAreaPage') @@ -251,7 +250,7 @@ class Ui_ThemeWizard(object): self.footerSizeSpinBox.setObjectName(u'FooterSizeSpinBox') self.footerAreaLayout.addRow(self.footerSizeLabel, self.footerSizeSpinBox) - ThemeWizard.addPage(self.footerAreaPage) + themeWizard.addPage(self.footerAreaPage) # Alignment Page self.alignmentPage = QtGui.QWizardPage() self.alignmentPage.setObjectName(u'AlignmentPage') @@ -276,7 +275,7 @@ class Ui_ThemeWizard(object): self.transitionsCheckBox.setObjectName(u'TransitionsCheckBox') self.alignmentLayout.addRow(self.transitionsLabel, self.transitionsCheckBox) - ThemeWizard.addPage(self.alignmentPage) + themeWizard.addPage(self.alignmentPage) # Area Position Page self.areaPositionPage = QtGui.QWizardPage() self.areaPositionPage.setObjectName(u'AreaPositionPage') @@ -352,7 +351,7 @@ class Ui_ThemeWizard(object): self.footerPositionLayout.addRow(self.footerHeightLabel, self.footerHeightSpinBox) self.areaPositionLayout.addWidget(self.footerPositionGroupBox) - ThemeWizard.addPage(self.areaPositionPage) + themeWizard.addPage(self.areaPositionPage) # Preview Page self.previewPage = QtGui.QWizardPage() self.previewPage.setObjectName(u'PreviewPage') @@ -381,9 +380,8 @@ class Ui_ThemeWizard(object): self.previewBoxLabel.setObjectName(u'PreviewBoxLabel') self.previewAreaLayout.addWidget(self.previewBoxLabel) self.previewLayout.addWidget(self.previewArea) - ThemeWizard.addPage(self.previewPage) - - self.retranslateUi(ThemeWizard) + themeWizard.addPage(self.previewPage) + self.retranslateUi(themeWizard) QtCore.QObject.connect(self.backgroundComboBox, QtCore.SIGNAL(u'currentIndexChanged(int)'), self.backgroundStack, QtCore.SLOT(u'setCurrentIndex(int)')) @@ -423,10 +421,10 @@ class Ui_ThemeWizard(object): QtCore.QObject.connect(self.footerPositionCheckBox, QtCore.SIGNAL(u'toggled(bool)'), self.footerHeightSpinBox, QtCore.SLOT(u'setDisabled(bool)')) - QtCore.QMetaObject.connectSlotsByName(ThemeWizard) + QtCore.QMetaObject.connectSlotsByName(themeWizard) - def retranslateUi(self, ThemeWizard): - ThemeWizard.setWindowTitle( + def retranslateUi(self, themeWizard): + themeWizard.setWindowTitle( translate('OpenLP.ThemeWizard', 'Theme Wizard')) self.titleLabel.setText( u'%s' % \ diff --git a/openlp/plugins/songs/forms/editsongform.py b/openlp/plugins/songs/forms/editsongform.py index 5e9fc1711..c3279e1a9 100644 --- a/openlp/plugins/songs/forms/editsongform.py +++ b/openlp/plugins/songs/forms/editsongform.py @@ -648,6 +648,7 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog): """ Free up autocompletion memory on dialog exit """ + log.debug (u'SongEditForm.clearCaches') self.authors = [] self.themes = [] self.books = [] @@ -657,20 +658,21 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog): """ Exit Dialog and do not save """ + log.debug (u'SongEditForm.reject') Receiver.send_message(u'songs_edit_clear') self.clearCaches() - self.close() + QtGui.QDialog.reject(self) def accept(self): """ Exit Dialog and save song if valid """ - log.debug(u'accept') + log.debug(u'SongEditForm.accept') self.clearCaches() if self._validate_song(): self.saveSong() Receiver.send_message(u'songs_load_list') - self.close() + QtGui.QDialog.accept(self) def saveSong(self, preview=False): """ diff --git a/openlp/plugins/songs/forms/songmaintenanceform.py b/openlp/plugins/songs/forms/songmaintenanceform.py index 2bc609ee2..441182424 100644 --- a/openlp/plugins/songs/forms/songmaintenanceform.py +++ b/openlp/plugins/songs/forms/songmaintenanceform.py @@ -94,8 +94,8 @@ class SongMaintenanceForm(QtGui.QDialog, Ui_SongMaintenanceDialog): self.typeListWidget.setFocus() return QtGui.QDialog.exec_(self) - def _getCurrentItemId(self, ListWidget): - item = ListWidget.currentItem() + def _getCurrentItemId(self, listWidget): + item = listWidget.currentItem() if item: item_id = (item.data(QtCore.Qt.UserRole)).toInt()[0] return item_id @@ -390,13 +390,13 @@ class SongMaintenanceForm(QtGui.QDialog, Ui_SongMaintenanceDialog): book.name = temp_name book.publisher = temp_publisher - def __mergeObjects(self, object, merge, reset): + def __mergeObjects(self, dbObject, merge, reset): """ Utility method to merge two objects to leave one in the database. """ Receiver.send_message(u'cursor_busy') Receiver.send_message(u'openlp_process_events') - merge(object) + merge(dbObject) reset() Receiver.send_message(u'songs_load_list') Receiver.send_message(u'cursor_normal') diff --git a/openlp/plugins/songs/lib/easislidesimport.py b/openlp/plugins/songs/lib/easislidesimport.py index fe44c763a..0b10ce428 100644 --- a/openlp/plugins/songs/lib/easislidesimport.py +++ b/openlp/plugins/songs/lib/easislidesimport.py @@ -140,25 +140,25 @@ class EasiSlidesImport(SongImport): ``song`` The current song being imported. """ - copyright = [] - self.__add_copyright_element(copyright, song.Copyright) - self.__add_copyright_element(copyright, song.LicenceAdmin1) - self.__add_copyright_element(copyright, song.LicenceAdmin2) - self.add_copyright(u' '.join(copyright)) + copyright_list = [] + self.__add_copyright_element(copyright_list, song.Copyright) + self.__add_copyright_element(copyright_list, song.LicenceAdmin1) + self.__add_copyright_element(copyright_list, song.LicenceAdmin2) + self.add_copyright(u' '.join(copyright_list)) - def __add_copyright_element(self, copyright, element): + def __add_copyright_element(self, copyright_list, element): """ Add a piece of copyright to the total copyright information for the song. - ``copyright`` + ``copyright_list`` The array to add the information to. ``element`` The imported variable to get the data from. """ try: - copyright.append(unicode(element).strip()) + copyright_list.append(unicode(element).strip()) except UnicodeDecodeError: log.exception(u'Unicode error decoding %s' % element) self._success = False From a31fda9463d270b433a900eba4a88b5fe29a58c4 Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Tue, 1 Feb 2011 19:22:48 +0100 Subject: [PATCH 33/43] fixed camelCase --- openlp/core/ui/mainwindow.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/openlp/core/ui/mainwindow.py b/openlp/core/ui/mainwindow.py index ea11c7d99..8477ccc24 100644 --- a/openlp/core/ui/mainwindow.py +++ b/openlp/core/ui/mainwindow.py @@ -175,10 +175,10 @@ class Ui_MainWindow(object): self.FileSaveAsItem = QtGui.QAction(mainWindow) self.FileSaveAsItem.setObjectName(u'FileSaveAsItem') mainWindow.actionList.add_action(self.FileSaveAsItem, u'File') - self.PrintServiceOrderItem = QtGui.QAction(mainWindow) - self.PrintServiceOrderItem.setObjectName(u'PrintServiceItem') + self.printServiceOrderItem = QtGui.QAction(mainWindow) + self.printServiceOrderItem.setObjectName(u'printServiceItem') mainWindow.actionList.add_action( - self.PrintServiceOrderItem, u'Print Service Order') + self.printServiceOrderItem, u'Print Service Order') self.FileExitItem = QtGui.QAction(mainWindow) self.FileExitItem.setIcon(build_icon(u':/system/system_exit.png')) self.FileExitItem.setObjectName(u'FileExitItem') @@ -306,7 +306,7 @@ class Ui_MainWindow(object): (self.ExportThemeItem, self.ExportLanguageItem)) self.FileMenuActions = (self.FileNewItem, self.FileOpenItem, self.FileSaveItem, self.FileSaveAsItem, None, - self.PrintServiceOrderItem, None, self.FileImportMenu.menuAction(), + self.printServiceOrderItem, None, self.FileImportMenu.menuAction(), self.FileExportMenu.menuAction(), self.FileExitItem) add_actions(self.ViewModeMenu, (self.ModeDefaultItem, self.ModeSetupItem, self.ModeLiveItem)) @@ -385,11 +385,11 @@ class Ui_MainWindow(object): 'Save the current service under a new name.')) self.FileSaveAsItem.setShortcut( translate('OpenLP.MainWindow', 'Ctrl+Shift+S')) - self.PrintServiceOrderItem.setText( + self.printServiceOrderItem.setText( translate('OpenLP.MainWindow', 'Print Service Order')) - self.PrintServiceOrderItem.setStatusTip(translate('OpenLP.MainWindow', + self.printServiceOrderItem.setStatusTip(translate('OpenLP.MainWindow', 'Print the current Service Order.')) - self.PrintServiceOrderItem.setShortcut( + self.printServiceOrderItem.setShortcut( translate('OpenLP.MainWindow', 'Ctrl+P')) self.FileExitItem.setText( translate('OpenLP.MainWindow', 'E&xit')) @@ -577,7 +577,7 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow): QtCore.QObject.connect(self.FileSaveAsItem, QtCore.SIGNAL(u'triggered()'), self.ServiceManagerContents.saveFileAs) - QtCore.QObject.connect(self.PrintServiceOrderItem, + QtCore.QObject.connect(self.printServiceOrderItem, QtCore.SIGNAL(u'triggered()'), self.ServiceManagerContents.printServiceOrder) # i18n set signals for languages From dd1f418f466492313d3614aea557dbce30427c3a Mon Sep 17 00:00:00 2001 From: Jon Tibble Date: Tue, 1 Feb 2011 19:16:51 +0000 Subject: [PATCH 34/43] Long line --- openlp/core/ui/advancedtab.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/openlp/core/ui/advancedtab.py b/openlp/core/ui/advancedtab.py index db6efcf4c..f68131894 100644 --- a/openlp/core/ui/advancedtab.py +++ b/openlp/core/ui/advancedtab.py @@ -141,7 +141,8 @@ class AdvancedTab(SettingsTab): 'Hide the mouse cursor when moved over the display window')) self.serviceOrderGroupBox.setTitle(translate('OpenLP.AdvancedTab', 'Service Order Print')) - self.detailedServicePrintCheckBox.setText(translate('OpenLP.AdvancedTab', + self.detailedServicePrintCheckBox.setText( + translate('OpenLP.AdvancedTab', 'Print slide texts and service item notes as well')) # self.sharedDirGroupBox.setTitle( # translate('AdvancedTab', 'Central Data Store')) From b28e073d5f3da9c0651cc5c4faffa67026d9ad66 Mon Sep 17 00:00:00 2001 From: Jon Tibble Date: Wed, 2 Feb 2011 00:33:13 +0000 Subject: [PATCH 35/43] Debugging aid for bad file errors --- openlp/core/ui/servicemanager.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openlp/core/ui/servicemanager.py b/openlp/core/ui/servicemanager.py index 81599085b..084e95b5f 100644 --- a/openlp/core/ui/servicemanager.py +++ b/openlp/core/ui/servicemanager.py @@ -526,7 +526,7 @@ class ServiceManager(QtGui.QWidget): 'File is not a valid service.')) log.exception(u'File contains no service data') except (IOError, NameError): - log.exception(u'Problem loading a service file') + log.exception(u'Problem loading service file %s' % filename) finally: if fileTo: fileTo.close() From 6568bd50393b293e83b8101db510e2b6cdaa8b20 Mon Sep 17 00:00:00 2001 From: Jon Tibble Date: Wed, 2 Feb 2011 01:40:36 +0000 Subject: [PATCH 36/43] Deduplicate wizards --- openlp/core/ui/themewizard.py | 18 ++----------- openlp/core/ui/wizard.py | 50 +++++++++++++++++------------------ 2 files changed, 27 insertions(+), 41 deletions(-) diff --git a/openlp/core/ui/themewizard.py b/openlp/core/ui/themewizard.py index aba486960..fe5305454 100644 --- a/openlp/core/ui/themewizard.py +++ b/openlp/core/ui/themewizard.py @@ -27,6 +27,7 @@ from PyQt4 import QtCore, QtGui from openlp.core.lib import translate, build_icon +from openlp.core.ui.wizard import addWelcomePage class Ui_ThemeWizard(object): def setupUi(self, themeWizard): @@ -36,22 +37,7 @@ class Ui_ThemeWizard(object): themeWizard.setOptions(QtGui.QWizard.IndependentPages | QtGui.QWizard.NoBackButtonOnStartPage) # Welcome Page - self.welcomePage = QtGui.QWizardPage() - self.welcomePage.setPixmap(QtGui.QWizard.WatermarkPixmap, - QtGui.QPixmap(u':/wizards/wizard_createtheme.bmp')) - self.welcomePage.setObjectName(u'WelcomePage') - self.welcomeLayout = QtGui.QVBoxLayout(self.welcomePage) - self.welcomeLayout.setObjectName(u'WelcomeLayout') - self.titleLabel = QtGui.QLabel(self.welcomePage) - self.titleLabel.setObjectName(u'TitleLabel') - self.welcomeLayout.addWidget(self.titleLabel) - self.welcomeLayout.addSpacing(40) - self.informationLabel = QtGui.QLabel(self.welcomePage) - self.informationLabel.setWordWrap(True) - self.informationLabel.setObjectName(u'InformationLabel') - self.welcomeLayout.addWidget(self.informationLabel) - self.welcomeLayout.addStretch() - themeWizard.addPage(self.welcomePage) + addWelcomePage(themeWizard, u':/wizards/wizard_createtheme.bmp') # Background Page self.backgroundPage = QtGui.QWizardPage() self.backgroundPage.setObjectName(u'BackgroundPage') diff --git a/openlp/core/ui/wizard.py b/openlp/core/ui/wizard.py index d3a0255b4..f57253d0e 100644 --- a/openlp/core/ui/wizard.py +++ b/openlp/core/ui/wizard.py @@ -63,36 +63,12 @@ class OpenLPWizard(QtGui.QWizard): self.setOptions(QtGui.QWizard.IndependentPages | QtGui.QWizard.NoBackButtonOnStartPage | QtGui.QWizard.NoBackButtonOnLastPage) - self.addWelcomePage(image) + addWelcomePage(self, image) self.addCustomPages() self.addProgressPage() self.retranslateUi() QtCore.QMetaObject.connectSlotsByName(self) - def addWelcomePage(self, image): - """ - Add the opening welcome page to the wizard. - - ``image`` - A splash image for the wizard - """ - self.welcomePage = QtGui.QWizardPage() - self.welcomePage.setPixmap(QtGui.QWizard.WatermarkPixmap, - QtGui.QPixmap(image)) - self.welcomePage.setObjectName(u'WelcomePage') - self.welcomeLayout = QtGui.QVBoxLayout(self.welcomePage) - self.welcomeLayout.setObjectName(u'WelcomeLayout') - self.titleLabel = QtGui.QLabel(self.welcomePage) - self.titleLabel.setObjectName(u'TitleLabel') - self.welcomeLayout.addWidget(self.titleLabel) - self.welcomeLayout.addSpacing(40) - self.informationLabel = QtGui.QLabel(self.welcomePage) - self.informationLabel.setWordWrap(True) - self.informationLabel.setObjectName(u'InformationLabel') - self.welcomeLayout.addWidget(self.informationLabel) - self.welcomeLayout.addStretch() - self.addPage(self.welcomePage) - def addProgressPage(self): """ Add the progress page for the wizard. This page informs the user how @@ -169,3 +145,27 @@ class OpenLPWizard(QtGui.QWizard): self.finishButton.setVisible(True) self.cancelButton.setVisible(False) Receiver.send_message(u'openlp_process_events') + +def addWelcomePage(parent, image): + """ + Generate an opening welcome page for a wizard using a provided image. + + ``image`` + A splash image for the wizard. + """ + parent.welcomePage = QtGui.QWizardPage() + parent.welcomePage.setPixmap(QtGui.QWizard.WatermarkPixmap, + QtGui.QPixmap(image)) + parent.welcomePage.setObjectName(u'WelcomePage') + parent.welcomeLayout = QtGui.QVBoxLayout(parent.welcomePage) + parent.welcomeLayout.setObjectName(u'WelcomeLayout') + parent.titleLabel = QtGui.QLabel(parent.welcomePage) + parent.titleLabel.setObjectName(u'TitleLabel') + parent.welcomeLayout.addWidget(parent.titleLabel) + parent.welcomeLayout.addSpacing(40) + parent.informationLabel = QtGui.QLabel(parent.welcomePage) + parent.informationLabel.setWordWrap(True) + parent.informationLabel.setObjectName(u'InformationLabel') + parent.welcomeLayout.addWidget(parent.informationLabel) + parent.welcomeLayout.addStretch() + parent.addPage(parent.welcomePage) From 0b36143ac291970ef222a5a841769dbcf992378d Mon Sep 17 00:00:00 2001 From: Jon Tibble Date: Wed, 2 Feb 2011 03:32:25 +0000 Subject: [PATCH 37/43] Slim down song importer UI --- openlp/plugins/songs/forms/songimportform.py | 154 +++++++------------ 1 file changed, 59 insertions(+), 95 deletions(-) diff --git a/openlp/plugins/songs/forms/songimportform.py b/openlp/plugins/songs/forms/songimportform.py index 3de251462..a5b0e713a 100644 --- a/openlp/plugins/songs/forms/songimportform.py +++ b/openlp/plugins/songs/forms/songimportform.py @@ -165,29 +165,29 @@ class SongImportForm(OpenLPWizard): self.formatStack = QtGui.QStackedLayout() self.formatStack.setObjectName(u'FormatStack') # OpenLP 2.0 - self.addSingleFileSelectItem(u'openLP2') + self.addFileSelectItem(u'openLP2', single_select=True) # openlp.org 1.x - self.addSingleFileSelectItem(u'openLP1', None, True) + self.addFileSelectItem(u'openLP1', None, True, True) # OpenLyrics - self.addMultiFileSelectItem(u'openLyrics', u'OpenLyrics', True) + self.addFileSelectItem(u'openLyrics', u'OpenLyrics', True) # Open Song - self.addMultiFileSelectItem(u'openSong', u'OpenSong') + self.addFileSelectItem(u'openSong', u'OpenSong') # Words of Worship - self.addMultiFileSelectItem(u'wordsOfWorship') + self.addFileSelectItem(u'wordsOfWorship') # CCLI File import - self.addMultiFileSelectItem(u'ccli') + self.addFileSelectItem(u'ccli') # Songs of Fellowship - self.addMultiFileSelectItem(u'songsOfFellowship', None, True) + self.addFileSelectItem(u'songsOfFellowship', None, True) # Generic Document/Presentation import - self.addMultiFileSelectItem(u'generic', None, True) + self.addFileSelectItem(u'generic', None, True) # EasySlides - self.addSingleFileSelectItem(u'easiSlides') + self.addFileSelectItem(u'easiSlides', single_select=True) # EasyWorship - self.addSingleFileSelectItem(u'ew') + self.addFileSelectItem(u'ew', single_select=True) # Words of Worship - self.addMultiFileSelectItem(u'songBeamer') + self.addFileSelectItem(u'songBeamer') # Commented out for future use. -# self.addSingleFileSelectItem(u'csv', u'CSV') +# self.addFileSelectItem(u'csv', u'CSV', single_select=True) self.sourceLayout.addLayout(self.formatStack) self.addPage(self.sourcePage) @@ -318,16 +318,6 @@ class SongImportForm(OpenLPWizard): self.openLP2FilenameLabel.minimumSizeHint().width()) self.formatSpacer.changeSize(width, 0, QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Fixed) - self.openLP2FormLabelSpacer.changeSize(width, 0, - QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Fixed) - self.openLP1FormLabelSpacer.changeSize(width, 0, - QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Fixed) - self.easiSlidesFormLabelSpacer.changeSize(width, 0, - QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Fixed) - self.ewFormLabelSpacer.changeSize(width, 0, QtGui.QSizePolicy.Fixed, - QtGui.QSizePolicy.Fixed) -# self.csvFormLabelSpacer.changeSize(width, 0, QtGui.QSizePolicy.Fixed, -# QtGui.QSizePolicy.Fixed) def validateCurrentPage(self): """ @@ -791,52 +781,8 @@ class SongImportForm(OpenLPWizard): translate('SongsPlugin.SongImportForm', 'Your song import failed.')) - def addSingleFileSelectItem(self, prefix, obj_prefix=None, - can_disable=False): - if not obj_prefix: - obj_prefix = prefix - page = QtGui.QWidget() - page.setObjectName(obj_prefix + u'Page') - if can_disable: - importWidget = self.disablableWidget(page, prefix, obj_prefix) - else: - importWidget = page - importLayout = QtGui.QFormLayout(importWidget) - importLayout.setMargin(0) - if can_disable: - importLayout.setObjectName(obj_prefix + u'ImportLayout') - else: - importLayout.setObjectName(obj_prefix + u'Layout') - filenameLabel = QtGui.QLabel(importWidget) - filenameLabel.setObjectName(obj_prefix + u'FilenameLabel') - fileLayout = QtGui.QHBoxLayout() - fileLayout.setObjectName(obj_prefix + u'FileLayout') - filenameEdit = QtGui.QLineEdit(importWidget) - filenameEdit.setObjectName(obj_prefix + u'FilenameEdit') - fileLayout.addWidget(filenameEdit) - browseButton = QtGui.QToolButton(importWidget) - browseButton.setIcon(self.openIcon) - browseButton.setObjectName(obj_prefix + u'BrowseButton') - fileLayout.addWidget(browseButton) - importLayout.addRow(filenameLabel, fileLayout) - formSpacer = QtGui.QSpacerItem(10, 0, QtGui.QSizePolicy.Fixed, - QtGui.QSizePolicy.Minimum) - importLayout.setItem(1, QtGui.QFormLayout.LabelRole, formSpacer) - self.formatStack.addWidget(page) - setattr(self, prefix + u'Page', page) - setattr(self, prefix + u'FilenameLabel', filenameLabel) - setattr(self, prefix + u'FormLabelSpacer', formSpacer) - setattr(self, prefix + u'FileLayout', fileLayout) - setattr(self, prefix + u'FilenameEdit', filenameEdit) - setattr(self, prefix + u'BrowseButton', browseButton) - if can_disable: - setattr(self, prefix + u'ImportLayout', importLayout) - else: - setattr(self, prefix + u'Layout', importLayout) - self.formatComboBox.addItem(u'') - - def addMultiFileSelectItem(self, prefix, obj_prefix=None, - can_disable=False): + def addFileSelectItem(self, prefix, obj_prefix=None, can_disable=False, + single_select=False): if not obj_prefix: obj_prefix = prefix page = QtGui.QWidget() @@ -847,37 +793,55 @@ class SongImportForm(OpenLPWizard): importWidget = page importLayout = QtGui.QVBoxLayout(importWidget) importLayout.setMargin(0) - if can_disable: - importLayout.setObjectName(obj_prefix + u'ImportLayout') + importLayout.setObjectName(obj_prefix + u'ImportLayout') + if single_select: + fileLayout = QtGui.QHBoxLayout() + fileLayout.setObjectName(obj_prefix + u'FileLayout') + filenameLabel = QtGui.QLabel(importWidget) + filenameLabel.setObjectName(obj_prefix + u'FilenameLabel') + fileLayout.addWidget(filenameLabel) + filenameEdit = QtGui.QLineEdit(importWidget) + filenameEdit.setObjectName(obj_prefix + u'FilenameEdit') + fileLayout.addWidget(filenameEdit) + browseButton = QtGui.QToolButton(importWidget) + browseButton.setIcon(self.openIcon) + browseButton.setObjectName(obj_prefix + u'BrowseButton') + fileLayout.addWidget(browseButton) + formSpacer = QtGui.QSpacerItem(10, 0, QtGui.QSizePolicy.Fixed, + QtGui.QSizePolicy.Expanding) + importLayout.addLayout(fileLayout) + importLayout.addSpacerItem(formSpacer) else: - importLayout.setObjectName(obj_prefix + u'Layout') - fileListWidget = QtGui.QListWidget(importWidget) - fileListWidget.setSelectionMode( - QtGui.QAbstractItemView.ExtendedSelection) - fileListWidget.setObjectName(obj_prefix + u'FileListWidget') - importLayout.addWidget(fileListWidget) - buttonLayout = QtGui.QHBoxLayout() - buttonLayout.setObjectName(obj_prefix + u'ButtonLayout') - addButton = QtGui.QPushButton(importWidget) - addButton.setIcon(self.openIcon) - addButton.setObjectName(obj_prefix + u'AddButton') - buttonLayout.addWidget(addButton) - buttonLayout.addStretch() - removeButton = QtGui.QPushButton(importWidget) - removeButton.setIcon(self.deleteIcon) - removeButton.setObjectName(obj_prefix + u'RemoveButton') - buttonLayout.addWidget(removeButton) - importLayout.addLayout(buttonLayout) + fileListWidget = QtGui.QListWidget(importWidget) + fileListWidget.setSelectionMode( + QtGui.QAbstractItemView.ExtendedSelection) + fileListWidget.setObjectName(obj_prefix + u'FileListWidget') + importLayout.addWidget(fileListWidget) + buttonLayout = QtGui.QHBoxLayout() + buttonLayout.setObjectName(obj_prefix + u'ButtonLayout') + addButton = QtGui.QPushButton(importWidget) + addButton.setIcon(self.openIcon) + addButton.setObjectName(obj_prefix + u'AddButton') + buttonLayout.addWidget(addButton) + buttonLayout.addStretch() + removeButton = QtGui.QPushButton(importWidget) + removeButton.setIcon(self.deleteIcon) + removeButton.setObjectName(obj_prefix + u'RemoveButton') + buttonLayout.addWidget(removeButton) + importLayout.addLayout(buttonLayout) self.formatStack.addWidget(page) setattr(self, prefix + u'Page', page) - setattr(self, prefix + u'FileListWidget', fileListWidget) - setattr(self, prefix + u'ButtonLayout', buttonLayout) - setattr(self, prefix + u'AddButton', addButton) - setattr(self, prefix + u'RemoveButton', removeButton) - if can_disable: - setattr(self, prefix + u'ImportLayout', importLayout) + if single_select: + setattr(self, prefix + u'FilenameLabel', filenameLabel) + setattr(self, prefix + u'FileLayout', fileLayout) + setattr(self, prefix + u'FilenameEdit', filenameEdit) + setattr(self, prefix + u'BrowseButton', browseButton) else: - setattr(self, prefix + u'Layout', importLayout) + setattr(self, prefix + u'FileListWidget', fileListWidget) + setattr(self, prefix + u'ButtonLayout', buttonLayout) + setattr(self, prefix + u'AddButton', addButton) + setattr(self, prefix + u'RemoveButton', removeButton) + setattr(self, prefix + u'ImportLayout', importLayout) self.formatComboBox.addItem(u'') def disablableWidget(self, page, prefix, obj_prefix): From 078adca9367f7e2a3612483653daacb5f204ecd2 Mon Sep 17 00:00:00 2001 From: Jon Tibble Date: Wed, 2 Feb 2011 04:35:26 +0000 Subject: [PATCH 38/43] Slim down song editer UI --- openlp/plugins/songs/forms/editsongdialog.py | 52 ++++++++------------ 1 file changed, 20 insertions(+), 32 deletions(-) diff --git a/openlp/plugins/songs/forms/editsongdialog.py b/openlp/plugins/songs/forms/editsongdialog.py index 4714ab093..b9b6e5baf 100644 --- a/openlp/plugins/songs/forms/editsongdialog.py +++ b/openlp/plugins/songs/forms/editsongdialog.py @@ -111,14 +111,8 @@ class Ui_EditSongDialog(object): self.authorsLayout.setObjectName(u'authorsLayout') self.authorAddLayout = QtGui.QHBoxLayout() self.authorAddLayout.setObjectName(u'authorAddLayout') - self.authorsComboBox = QtGui.QComboBox(self.authorsGroupBox) - self.authorsComboBox.setSizeAdjustPolicy( - QtGui.QComboBox.AdjustToMinimumContentsLength) - self.authorsComboBox.setSizePolicy( - QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Fixed) - self.authorsComboBox.setEditable(True) - self.authorsComboBox.setInsertPolicy(QtGui.QComboBox.NoInsert) - self.authorsComboBox.setObjectName(u'authorsComboBox') + self.authorsComboBox = editSongDialogComboBox( + self.authorsGroupBox, u'authorsComboBox') self.authorAddLayout.addWidget(self.authorsComboBox) self.authorAddButton = QtGui.QPushButton(self.authorsGroupBox) self.authorAddButton.setObjectName(u'authorAddButton') @@ -152,14 +146,8 @@ class Ui_EditSongDialog(object): self.topicsLayout.setObjectName(u'topicsLayout') self.topicAddLayout = QtGui.QHBoxLayout() self.topicAddLayout.setObjectName(u'topicAddLayout') - self.topicsComboBox = QtGui.QComboBox(self.topicsGroupBox) - self.topicsComboBox.setSizeAdjustPolicy( - QtGui.QComboBox.AdjustToMinimumContentsLength) - self.topicsComboBox.setSizePolicy( - QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Fixed) - self.topicsComboBox.setEditable(True) - self.topicsComboBox.setInsertPolicy(QtGui.QComboBox.NoInsert) - self.topicsComboBox.setObjectName(u'topicsComboBox') + self.topicsComboBox = editSongDialogComboBox( + self.topicsGroupBox, u'topicsComboBox') self.topicAddLayout.addWidget(self.topicsComboBox) self.topicAddButton = QtGui.QPushButton(self.topicsGroupBox) self.topicAddButton.setObjectName(u'topicAddButton') @@ -183,14 +171,8 @@ class Ui_EditSongDialog(object): self.songBookLayout.setObjectName(u'songBookLayout') self.songBookNameLabel = QtGui.QLabel(self.songBookGroupBox) self.songBookNameLabel.setObjectName(u'songBookNameLabel') - self.songBookComboBox = QtGui.QComboBox(self.songBookGroupBox) - self.songBookComboBox.setSizeAdjustPolicy( - QtGui.QComboBox.AdjustToMinimumContentsLength) - self.songBookComboBox.setSizePolicy( - QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Fixed) - self.songBookComboBox.setEditable(True) - self.songBookComboBox.setInsertPolicy(QtGui.QComboBox.NoInsert) - self.songBookComboBox.setObjectName(u'songBookComboBox') + self.songBookComboBox = editSongDialogComboBox( + self.songBookGroupBox, u'songBookComboBox') self.songBookNameLabel.setBuddy(self.songBookComboBox) self.songBookLayout.addRow(self.songBookNameLabel, self.songBookComboBox) @@ -215,14 +197,8 @@ class Ui_EditSongDialog(object): self.themeGroupBox.setObjectName(u'themeGroupBox') self.themeLayout = QtGui.QHBoxLayout(self.themeGroupBox) self.themeLayout.setObjectName(u'themeLayout') - self.themeComboBox = QtGui.QComboBox(self.themeGroupBox) - self.themeComboBox.setSizeAdjustPolicy( - QtGui.QComboBox.AdjustToMinimumContentsLength) - self.themeComboBox.setSizePolicy( - QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Fixed) - self.themeComboBox.setEditable(True) - self.themeComboBox.setInsertPolicy(QtGui.QComboBox.NoInsert) - self.themeComboBox.setObjectName(u'themeComboBox') + self.themeComboBox = editSongDialogComboBox( + self.themeGroupBox, u'themeComboBox') self.themeLayout.addWidget(self.themeComboBox) self.themeAddButton = QtGui.QPushButton(self.themeGroupBox) self.themeAddButton.setObjectName(u'themeAddButton') @@ -331,3 +307,15 @@ class Ui_EditSongDialog(object): self.songTabWidget.indexOf(self.themeTab), translate('SongsPlugin.EditSongForm', 'Theme, Copyright Info && Comments')) + +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.setEditable(True) + comboBox.setInsertPolicy(QtGui.QComboBox.NoInsert) + comboBox.setObjectName(name) + return comboBox From ceb64dd4770bb08d287313d4955eb8236b6916fc Mon Sep 17 00:00:00 2001 From: Jon Tibble Date: Wed, 2 Feb 2011 05:31:11 +0000 Subject: [PATCH 39/43] Slim mode setting --- openlp/core/ui/mainwindow.py | 21 ++++++++------------- 1 file changed, 8 insertions(+), 13 deletions(-) diff --git a/openlp/core/ui/mainwindow.py b/openlp/core/ui/mainwindow.py index b41bbf438..6f57861c4 100644 --- a/openlp/core/ui/mainwindow.py +++ b/openlp/core/ui/mainwindow.py @@ -771,34 +771,29 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow): """ Put OpenLP into "Default" view mode. """ - settings = QtCore.QSettings() - settings.setValue(u'%s/view mode' % self.generalSettingsSection, - u'default') - self.setViewMode(True, True, True, True, True) + self.setViewMode(True, True, True, True, True, u'default') def onModeSetupItemClicked(self): """ Put OpenLP into "Setup" view mode. """ - settings = QtCore.QSettings() - settings.setValue(u'%s/view mode' % self.generalSettingsSection, - u'setup') - self.setViewMode(True, True, False, True, False) + self.setViewMode(True, True, False, True, False, u'setup') def onModeLiveItemClicked(self): """ Put OpenLP into "Live" view mode. """ - settings = QtCore.QSettings() - settings.setValue(u'%s/view mode' % self.generalSettingsSection, - u'live') - self.setViewMode(False, True, False, False, True) + self.setViewMode(False, True, False, False, True, u'live') def setViewMode(self, media=True, service=True, theme=True, preview=True, - live=True): + live=True, mode=u''): """ Set OpenLP to a different view mode. """ + if mode: + settings = QtCore.QSettings() + settings.setValue(u'%s/view mode' % self.generalSettingsSection, + mode) self.MediaManagerDock.setVisible(media) self.ServiceManagerDock.setVisible(service) self.ThemeManagerDock.setVisible(theme) From 9fe4e6fc6daad22b6d31efcd8acac23e1fcb7233 Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Wed, 2 Feb 2011 13:02:18 +0100 Subject: [PATCH 40/43] --- openlp/core/lib/mediamanageritem.py | 1 + openlp/core/lib/serviceitem.py | 4 ++++ openlp/plugins/images/lib/mediaitem.py | 1 + 3 files changed, 6 insertions(+) diff --git a/openlp/core/lib/mediamanageritem.py b/openlp/core/lib/mediamanageritem.py index 7bbdb4f06..d2d70225c 100644 --- a/openlp/core/lib/mediamanageritem.py +++ b/openlp/core/lib/mediamanageritem.py @@ -507,6 +507,7 @@ class MediaManagerItem(QtGui.QWidget): 'No Service Item Selected'), translate('OpenLP.MediaManagerItem', 'You must select an existing service item to add to.')) + # Needs fixing. elif self.title.lower() == serviceItem.name.lower(): self.generateSlideData(serviceItem) self.parent.serviceManager.addServiceItem(serviceItem, diff --git a/openlp/core/lib/serviceitem.py b/openlp/core/lib/serviceitem.py index c74b89144..299761689 100644 --- a/openlp/core/lib/serviceitem.py +++ b/openlp/core/lib/serviceitem.py @@ -314,6 +314,8 @@ class ServiceItem(object): self.add_from_command( path, text_image[u'title'], text_image[u'image'] ) self._new_item() + print self.shortname + print self.from_plugin def get_display_title(self): """ @@ -328,6 +330,8 @@ class ServiceItem(object): return self.title else: return self._raw_frames[0][u'title'] + print self.shortname + print self.from_plugin def merge(self, other): """ diff --git a/openlp/plugins/images/lib/mediaitem.py b/openlp/plugins/images/lib/mediaitem.py index 25d9811f1..bc8a9b7e6 100644 --- a/openlp/plugins/images/lib/mediaitem.py +++ b/openlp/plugins/images/lib/mediaitem.py @@ -182,6 +182,7 @@ class ImageMediaItem(MediaManagerItem): filename = unicode(bitem.data(QtCore.Qt.UserRole).toString()) (path, name) = os.path.split(filename) service_item.add_from_image(filename, name) + print self.shortname return True else: return False From 31a451274b46fa611fb327bdfc62dca2283107f0 Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Wed, 2 Feb 2011 14:22:43 +0100 Subject: [PATCH 41/43] fixed double white space --- openlp/core/lib/mediamanageritem.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openlp/core/lib/mediamanageritem.py b/openlp/core/lib/mediamanageritem.py index ce8178f8e..39c37e2a9 100644 --- a/openlp/core/lib/mediamanageritem.py +++ b/openlp/core/lib/mediamanageritem.py @@ -245,7 +245,7 @@ class MediaManagerItem(QtGui.QWidget): preview_string[u'title'], preview_string[u'tooltip'], u':/general/general_preview.png', self.onPreviewClick) - ## Live Button ## + ## Live Button ## live_string = self.plugin.getString(StringContent.Live) self.addToolbarButton( live_string[u'title'], From 06897d40e1b14f2c88d0fdd2ca3e3708e927059e Mon Sep 17 00:00:00 2001 From: Jon Tibble Date: Wed, 2 Feb 2011 15:52:17 +0000 Subject: [PATCH 42/43] Naming cleanups and docstrings --- openlp/core/lib/searchedit.py | 10 +++--- openlp/core/lib/theme.py | 52 +++++++++++++++++++++++--------- openlp/core/ui/servicemanager.py | 2 +- 3 files changed, 44 insertions(+), 20 deletions(-) diff --git a/openlp/core/lib/searchedit.py b/openlp/core/lib/searchedit.py index c69e1f15b..5e12dcefd 100644 --- a/openlp/core/lib/searchedit.py +++ b/openlp/core/lib/searchedit.py @@ -93,15 +93,15 @@ class SearchEdit(QtGui.QLineEdit): ``event`` The event that happened. """ - sz = self.clearButton.size() + size = self.clearButton.size() frameWidth = self.style().pixelMetric( QtGui.QStyle.PM_DefaultFrameWidth) - self.clearButton.move(self.rect().right() - frameWidth - sz.width(), - (self.rect().bottom() + 1 - sz.height()) / 2) + self.clearButton.move(self.rect().right() - frameWidth - size.width(), + (self.rect().bottom() + 1 - size.height()) / 2) if hasattr(self, u'menuButton'): - sz = self.menuButton.size() + size = self.menuButton.size() self.menuButton.move(self.rect().left() + frameWidth + 2, - (self.rect().bottom() + 1 - sz.height()) / 2) + (self.rect().bottom() + 1 - size.height()) / 2) def currentSearchType(self): """ diff --git a/openlp/core/lib/theme.py b/openlp/core/lib/theme.py index 8d2c8f356..d119f19ff 100644 --- a/openlp/core/lib/theme.py +++ b/openlp/core/lib/theme.py @@ -91,21 +91,30 @@ class ThemeLevel(object): Song = 3 class BackgroundType(object): + """ + Type enumeration for backgrounds. + """ Solid = 0 Gradient = 1 Image = 2 @staticmethod - def to_string(type): - if type == BackgroundType.Solid: + def to_string(background_type): + """ + Return a string representation of a background type. + """ + if background_type == BackgroundType.Solid: return u'solid' - elif type == BackgroundType.Gradient: + elif background_type == BackgroundType.Gradient: return u'gradient' - elif type == BackgroundType.Image: + elif background_type == BackgroundType.Image: return u'image' @staticmethod def from_string(type_string): + """ + Return a background type for the given string. + """ if type_string == u'solid': return BackgroundType.Solid elif type_string == u'gradient': @@ -114,6 +123,9 @@ class BackgroundType(object): return BackgroundType.Image class BackgroundGradientType(object): + """ + Type enumeration for background gradients. + """ Horizontal = 0 Vertical = 1 Circular = 2 @@ -121,20 +133,26 @@ class BackgroundGradientType(object): LeftBottom = 4 @staticmethod - def to_string(type): - if type == BackgroundGradientType.Horizontal: + def to_string(gradient_type): + """ + Return a string representation of a background gradient type. + """ + if gradient_type == BackgroundGradientType.Horizontal: return u'horizontal' - elif type == BackgroundGradientType.Vertical: + elif gradient_type == BackgroundGradientType.Vertical: return u'vertical' - elif type == BackgroundGradientType.Circular: + elif gradient_type == BackgroundGradientType.Circular: return u'circular' - elif type == BackgroundGradientType.LeftTop: + elif gradient_type == BackgroundGradientType.LeftTop: return u'leftTop' - elif type == BackgroundGradientType.LeftBottom: + elif gradient_type == BackgroundGradientType.LeftBottom: return u'leftBottom' @staticmethod def from_string(type_string): + """ + Return a background gradient type for the given string. + """ if type_string == u'horizontal': return BackgroundGradientType.Horizontal elif type_string == u'vertical': @@ -147,19 +165,25 @@ class BackgroundGradientType(object): return BackgroundGradientType.LeftBottom class HorizontalType(object): + """ + Type enumeration for horizontal alignment. + """ Left = 0 Center = 1 Right = 2 class VerticalType(object): + """ + Type enumeration for vertical alignment. + """ Top = 0 Middle = 1 Bottom = 2 -boolean_list = [u'bold', u'italics', u'override', u'outline', u'shadow', +BOOLEAN_LIST = [u'bold', u'italics', u'override', u'outline', u'shadow', u'slide_transition'] -integer_list = [u'size', u'line_adjustment', u'x', u'height', u'y', +INTEGER_LIST = [u'size', u'line_adjustment', u'x', u'height', u'y', u'width', u'shadow_size', u'outline_size', u'horizontal_align', u'vertical_align', u'wrap_style'] @@ -514,9 +538,9 @@ class ThemeXML(object): return field = self._de_hump(element) tag = master + u'_' + field - if field in boolean_list: + if field in BOOLEAN_LIST: setattr(self, tag, str_to_bool(value)) - elif field in integer_list: + elif field in INTEGER_LIST: setattr(self, tag, int(value)) else: # make string value unicode diff --git a/openlp/core/ui/servicemanager.py b/openlp/core/ui/servicemanager.py index 084e95b5f..9082c7a80 100644 --- a/openlp/core/ui/servicemanager.py +++ b/openlp/core/ui/servicemanager.py @@ -526,7 +526,7 @@ class ServiceManager(QtGui.QWidget): 'File is not a valid service.')) log.exception(u'File contains no service data') except (IOError, NameError): - log.exception(u'Problem loading service file %s' % filename) + log.exception(u'Problem loading service file %s' % fileName) finally: if fileTo: fileTo.close() From b1057a913433c3c79fa3af09ce213e51781318c8 Mon Sep 17 00:00:00 2001 From: Jon Tibble Date: Wed, 2 Feb 2011 16:13:43 +0000 Subject: [PATCH 43/43] Fix custom edit (Bug #711934) --- openlp/plugins/custom/forms/editcustomform.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/openlp/plugins/custom/forms/editcustomform.py b/openlp/plugins/custom/forms/editcustomform.py index e274c2395..60b313284 100644 --- a/openlp/plugins/custom/forms/editcustomform.py +++ b/openlp/plugins/custom/forms/editcustomform.py @@ -138,13 +138,13 @@ class EditCustomForm(QtGui.QDialog, Ui_CustomEditDialog): def reject(self): Receiver.send_message(u'custom_edit_clear') - self.close() + QtGui.QDialog.reject(self) def accept(self): log.debug(u'accept') if self.saveCustom(): Receiver.send_message(u'custom_load_list') - self.close() + QtGui.QDialog.accept(self) def saveCustom(self): """