From 9da5a3223f4f3d5d8d24fbec85ad637bd8476b68 Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Tue, 21 Jul 2009 19:10:14 +0100 Subject: [PATCH 1/9] Fix song conversions Fix focus for Song dialog Preserve state when moving serviceitems --- cnvdb.py | 3 +- openlp/core/ui/maindisplay.py | 12 ++++- openlp/core/ui/servicemanager.py | 53 ++++++++++++++++++---- openlp/plugins/songs/forms/authorsform.py | 3 +- openlp/plugins/songs/forms/songbookform.py | 3 +- openlp/plugins/songs/forms/topicsform.py | 3 +- openlp/plugins/songs/lib/mediaitem.py | 2 +- 7 files changed, 63 insertions(+), 16 deletions(-) diff --git a/cnvdb.py b/cnvdb.py index 4463ec887..a76c942a9 100755 --- a/cnvdb.py +++ b/cnvdb.py @@ -20,6 +20,7 @@ Place, Suite 330, Boston, MA 02111-1307 USA """ import codecs import sys +import chardet def convert_file(inname, outname): """ @@ -31,7 +32,7 @@ def convert_file(inname, outname): ``outname`` The output file name. """ - infile = codecs.open(inname, 'r', encoding='iso-8859-1') + infile = codecs.open(inname, 'r', encoding='CP1252') writefile = codecs.open(outname, 'w', encoding='utf-8') for line in infile: #replace the quotes with quotes diff --git a/openlp/core/ui/maindisplay.py b/openlp/core/ui/maindisplay.py index 183917549..a38891633 100644 --- a/openlp/core/ui/maindisplay.py +++ b/openlp/core/ui/maindisplay.py @@ -62,12 +62,22 @@ class MainDisplay(QtGui.QWidget): self.showFullScreen() else: self.showMinimized() + #Build a custom splash screen + self.InitialFrame = QtGui.QImage(screen[u'size'].width(), + screen[u'size'].height(), QtGui.QImage.Format_ARGB32_Premultiplied) + splash_image = QtGui.QImage(u':/graphics/openlp-splash-screen.png') + painter_image = QtGui.QPainter() + painter_image.begin(self.InitialFrame) + painter_image.fillRect(self.InitialFrame.rect(), QtCore.Qt.white) + painter_image.drawImage((screen[u'size'].width() - splash_image.width()) / 2, + (screen[u'size'].height() - splash_image.height()) / 2 , splash_image) + self.frameView(self.InitialFrame) + #Build a Black screen painter = QtGui.QPainter() self.blankFrame = QtGui.QImage(screen[u'size'].width(), screen[u'size'].height(), QtGui.QImage.Format_ARGB32_Premultiplied) painter.begin(self.blankFrame) painter.fillRect(self.blankFrame.rect(), QtCore.Qt.black) - self.frameView(self.blankFrame) def frameView(self, frame): """ diff --git a/openlp/core/ui/servicemanager.py b/openlp/core/ui/servicemanager.py index 5229715c0..732768505 100644 --- a/openlp/core/ui/servicemanager.py +++ b/openlp/core/ui/servicemanager.py @@ -41,10 +41,39 @@ class ServiceManagerList(QtGui.QTreeWidget): if event.key() == QtCore.Qt.Key_Enter: self.parent.makeLive() event.accept() + elif event.key() == QtCore.Qt.Key_Home: + self.parent.onServiceTop() + event.accept() + elif event.key() == QtCore.Qt.Key_End: + self.parent.onServiceEnd() + event.accept() + elif event.key() == QtCore.Qt.Key_PageUp: + self.parent.onServiceUp() + event.accept() + elif event.key() == QtCore.Qt.Key_PageDown: + self.parent.onServiceDown() + event.accept() + elif event.key() == QtCore.Qt.Key_Up: + self.parent.onServiceUp() + event.accept() + elif event.key() == QtCore.Qt.Key_Down: + self.parent.onServiceDown() + event.accept() event.ignore() else: event.ignore() +class Iter(QtGui.QTreeWidgetItemIterator): + def __init__(self, *args): + QTreeWidgetItemIterator.__init__(self, *args) + def next(self): + self.__iadd__(1) + value = self.value() + if value: + return self.value() + else: + raise StopIteration + class ServiceManager(QtGui.QWidget): """ Manages the orders of service. Currently this involves taking @@ -159,7 +188,7 @@ class ServiceManager(QtGui.QWidget): temp = self.serviceItems[item] self.serviceItems.remove(self.serviceItems[item]) self.serviceItems.insert(0, temp) - self.repaintServiceList() + self.repaintServiceList(0, count) self.parent.OosChanged(False, self.serviceName) def onServiceUp(self): @@ -172,7 +201,7 @@ class ServiceManager(QtGui.QWidget): temp = self.serviceItems[item] self.serviceItems.remove(self.serviceItems[item]) self.serviceItems.insert(item - 1, temp) - self.repaintServiceList() + self.repaintServiceList(item - 1 , count) self.parent.OosChanged(False, self.serviceName) def onServiceDown(self): @@ -185,7 +214,7 @@ class ServiceManager(QtGui.QWidget): temp = self.serviceItems[item] self.serviceItems.remove(self.serviceItems[item]) self.serviceItems.insert(item + 1, temp) - self.repaintServiceList() + self.repaintServiceList(item + 1 , count) self.parent.OosChanged(False, self.serviceName) def onServiceEnd(self): @@ -197,7 +226,7 @@ class ServiceManager(QtGui.QWidget): temp = self.serviceItems[item] self.serviceItems.remove(self.serviceItems[item]) self.serviceItems.insert(len(self.serviceItems), temp) - self.repaintServiceList() + self.repaintServiceList(len(self.serviceItems) - 1, count) self.parent.OosChanged(False, self.serviceName) def onNewService(self): @@ -216,15 +245,19 @@ class ServiceManager(QtGui.QWidget): item, count = self.findServiceItem() if item is not -1: self.serviceItems.remove(self.serviceItems[item]) - self.repaintServiceList() + self.repaintServiceList(0, 0) self.parent.OosChanged(False, self.serviceName) - def repaintServiceList(self): + def repaintServiceList(self, serviceItem, serviceItemCount): """ Clear the existing service list and prepaint all the items Used when moving items as the move takes place in supporting array, and when regenerating all the items due to theme changes """ + aa = Iter(self.ServiceManagerList) + print aa + for a in aa: + print a #Correct order of idems in array count = 1 for item in self.serviceItems: @@ -232,20 +265,20 @@ class ServiceManager(QtGui.QWidget): count += 1 #Repaint the screen self.ServiceManagerList.clear() - for item in self.serviceItems: + for itemcount, item in enumerate(self.serviceItems): serviceitem = item[u'data'] treewidgetitem = QtGui.QTreeWidgetItem(self.ServiceManagerList) treewidgetitem.setText(0,serviceitem.title) treewidgetitem.setIcon(0,serviceitem.iconic_representation) treewidgetitem.setData(0, QtCore.Qt.UserRole, QtCore.QVariant(item[u'order'])) treewidgetitem.setExpanded(item[u'expanded']) - count = 0 - for frame in serviceitem.frames: + for count , frame in enumerate(serviceitem.frames): treewidgetitem1 = QtGui.QTreeWidgetItem(treewidgetitem) text = frame[u'title'] treewidgetitem1.setText(0,text[:40]) treewidgetitem1.setData(0, QtCore.Qt.UserRole,QtCore.QVariant(count)) - count = count + 1 + if serviceItem == itemcount and serviceItemCount == count: + self.ServiceManagerList.setCurrentItem(treewidgetitem1) def onSaveService(self): """ diff --git a/openlp/plugins/songs/forms/authorsform.py b/openlp/plugins/songs/forms/authorsform.py index 256ac2002..f5191f094 100644 --- a/openlp/plugins/songs/forms/authorsform.py +++ b/openlp/plugins/songs/forms/authorsform.py @@ -63,6 +63,7 @@ class AuthorsForm(QtGui.QDialog, Ui_AuthorsDialog): else: self.AuthorListWidget.setCurrentRow(self.currentRow) self._validate_form() + self.onAuthorListWidgetItemClicked() def onDeleteButtonClick(self): """ @@ -100,7 +101,7 @@ class AuthorsForm(QtGui.QDialog, Ui_AuthorsDialog): self._validate_form() self.DisplayEdit.setFocus() - def onAuthorListWidgetItemClicked(self, index): + def onAuthorListWidgetItemClicked(self): """ An Author has been selected display it If the author is attached to a Song prevent delete diff --git a/openlp/plugins/songs/forms/songbookform.py b/openlp/plugins/songs/forms/songbookform.py index cc203cdb4..147c588fb 100644 --- a/openlp/plugins/songs/forms/songbookform.py +++ b/openlp/plugins/songs/forms/songbookform.py @@ -62,6 +62,7 @@ class SongBookForm(QtGui.QDialog, Ui_SongBookDialog): self.BookSongListWidget.setCurrentRow(self.BookSongListWidget.count() - 1) else: self.BookSongListWidget.setCurrentRow(self.currentRow) + self.onBooksListViewItemClicked() def onDeleteButtonClick(self): """ @@ -98,7 +99,7 @@ class SongBookForm(QtGui.QDialog, Ui_SongBookDialog): self._validate_form() self.NameEdit.setFocus() - def onBooksListViewItemClicked(self, index): + def onBooksListViewItemClicked(self): """ An Book has been selected display it If the Book is attached to a Song prevent delete diff --git a/openlp/plugins/songs/forms/topicsform.py b/openlp/plugins/songs/forms/topicsform.py index 825d1a66b..759e72ae3 100644 --- a/openlp/plugins/songs/forms/topicsform.py +++ b/openlp/plugins/songs/forms/topicsform.py @@ -63,6 +63,7 @@ class TopicsForm(QtGui.QDialog, Ui_TopicsDialog): else: self.TopicsListWidget.setCurrentRow(self.currentRow) self._validate_form() + self.onTopicsListWidgetItemClicked() def onDeleteButtonClick(self): """ @@ -97,7 +98,7 @@ class TopicsForm(QtGui.QDialog, Ui_TopicsDialog): self._validate_form() self.TopicNameEdit.setFocus() - def onTopicsListWidgetItemClicked(self, index): + def onTopicsListWidgetItemClicked(self): """ An Topic has been selected display it If the Topic is attached to a Song prevent delete diff --git a/openlp/plugins/songs/lib/mediaitem.py b/openlp/plugins/songs/lib/mediaitem.py index b49bcac95..0a3b01c5e 100644 --- a/openlp/plugins/songs/lib/mediaitem.py +++ b/openlp/plugins/songs/lib/mediaitem.py @@ -289,7 +289,7 @@ class SongMediaItem(MediaManagerItem): else: verses = song.lyrics.split(u'\n\n') for slide in verses: - service_item.add_from_text(slide[:30], slide) + service_item.add_from_text(slide[:30], unicode(slide)) service_item.title = song.title for author in song.authors: if len(author_list) > 1: From e788db767ae6d70eeed547b24bc6cf44075be2c9 Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Tue, 21 Jul 2009 21:04:27 +0100 Subject: [PATCH 2/9] fix renderer to make shadows small for footers Add Keyboard events to servicemanager --- openlp/core/lib/renderer.py | 9 +++-- openlp/core/ui/servicemanager.py | 68 ++++++++++++++++++++++++++------ 2 files changed, 61 insertions(+), 16 deletions(-) diff --git a/openlp/core/lib/renderer.py b/openlp/core/lib/renderer.py index a7e494302..957818132 100644 --- a/openlp/core/lib/renderer.py +++ b/openlp/core/lib/renderer.py @@ -40,6 +40,7 @@ class Renderer(object): self._debug = 0 self._right_margin = 64 # the amount of right indent self._shadow_offset = 5 + self._shadow_offset_footer = 3 self._outline_offset = 2 self.theme_name = None self._theme = None @@ -482,15 +483,17 @@ class Renderer(object): # dont allow alignment messing with footers if footer: align = 0 + shadow_offset = self._shadow_offset_footer else: align = int(self._theme .display_horizontalAlign) + shadow_offset = self._shadow_offset for linenum in range(len(lines)): line = lines[linenum] #find out how wide line is w , h = self._get_extent_and_render(line, footer, tlcorner=(x, y), draw=False) if self._theme.display_shadow: - w += self._shadow_offset - h += self._shadow_offset + w += shadow_offset + h += shadow_offset if self._theme.display_outline: # pixels either side w += 2 * self._outline_offset @@ -515,7 +518,7 @@ class Renderer(object): if live: # now draw the text, and any outlines/shadows if self._theme.display_shadow: - self._get_extent_and_render(line, footer, tlcorner=(x+self._shadow_offset,y+self._shadow_offset), + self._get_extent_and_render(line, footer, tlcorner=(x + shadow_offset, y + shadow_offset), draw=True, color = self._theme.display_shadow_color) if self._theme.display_outline: self._get_extent_and_render(line, footer, (x+self._outline_offset,y), draw=True, diff --git a/openlp/core/ui/servicemanager.py b/openlp/core/ui/servicemanager.py index 732768505..f0f322e4c 100644 --- a/openlp/core/ui/servicemanager.py +++ b/openlp/core/ui/servicemanager.py @@ -54,10 +54,10 @@ class ServiceManagerList(QtGui.QTreeWidget): self.parent.onServiceDown() event.accept() elif event.key() == QtCore.Qt.Key_Up: - self.parent.onServiceUp() + self.parent.onMoveSelectionUp() event.accept() elif event.key() == QtCore.Qt.Key_Down: - self.parent.onServiceDown() + self.parent.onMoveSelectionDown() event.accept() event.ignore() else: @@ -65,14 +65,14 @@ class ServiceManagerList(QtGui.QTreeWidget): class Iter(QtGui.QTreeWidgetItemIterator): def __init__(self, *args): - QTreeWidgetItemIterator.__init__(self, *args) + QtGui.QTreeWidgetItemIterator.__init__(self, *args) def next(self): - self.__iadd__(1) - value = self.value() - if value: - return self.value() - else: - raise StopIteration + self.__iadd__(1) + value = self.value() + if value: + return self.value() + else: + return None class ServiceManager(QtGui.QWidget): """ @@ -163,6 +163,52 @@ class ServiceManager(QtGui.QWidget): self.servicePath = self.config.get_data_path() self.service_theme = self.config.get_config(u'theme service theme', u'') + def onMoveSelectionUp(self): + """ + Moves the selection up the window + Called by the up arrow + """ + it = Iter(self.ServiceManagerList) + item = it.value() + tempItem = None + setLastItem = False + while item is not None: + if item.isSelected() and tempItem is None: + setLastItem = True + item.setSelected(False) + if item.isSelected(): + #We are on the first record + if tempItem is not None: + tempItem.setSelected(True) + item.setSelected(False) + else: + tempItem = item + lastItem = item + item = it.next() + #Top Item was selected so set the last one + if setLastItem: + lastItem.setSelected(True) + + def onMoveSelectionDown(self): + """ + Moves the selection down the window + Called by the down arrow + """ + it = Iter(self.ServiceManagerList) + item = it.value() + firstItem = item + setSelected = False + while item is not None: + if setSelected: + setSelected = False + item.setSelected(True) + elif item.isSelected(): + item.setSelected(False) + setSelected = True + item = it.next() + if setSelected: + firstItem.setSelected(True) + def collapsed(self, item): """ Record if an item is collapsed @@ -254,10 +300,6 @@ class ServiceManager(QtGui.QWidget): Used when moving items as the move takes place in supporting array, and when regenerating all the items due to theme changes """ - aa = Iter(self.ServiceManagerList) - print aa - for a in aa: - print a #Correct order of idems in array count = 1 for item in self.serviceItems: From 8e0901ef67f956f854f114e095637c03040aa57b Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Wed, 22 Jul 2009 07:14:34 +0100 Subject: [PATCH 3/9] Fix bug where empty lists fail to display dialogs --- openlp/plugins/songs/forms/authorsform.py | 37 +++++++++++----------- openlp/plugins/songs/forms/songbookform.py | 23 +++++++------- openlp/plugins/songs/forms/topicsform.py | 21 ++++++------ 3 files changed, 42 insertions(+), 39 deletions(-) diff --git a/openlp/plugins/songs/forms/authorsform.py b/openlp/plugins/songs/forms/authorsform.py index f5191f094..3a8478c93 100644 --- a/openlp/plugins/songs/forms/authorsform.py +++ b/openlp/plugins/songs/forms/authorsform.py @@ -108,24 +108,25 @@ class AuthorsForm(QtGui.QDialog, Ui_AuthorsDialog): """ self.currentRow = self.AuthorListWidget.currentRow() item = self.AuthorListWidget.currentItem() - item_id = (item.data(QtCore.Qt.UserRole)).toInt()[0] - self.author = self.songmanager.get_author(item_id) - self.DisplayEdit.setText(self.author.display_name) - if self.author.first_name is None: - self.FirstNameEdit.setText(u'') - else: - self.FirstNameEdit.setText(self.author.first_name) - if self.author.last_name is None: - self.LastNameEdit.setText(u'') - else: - self.LastNameEdit.setText(self.author.last_name) - if len(self.author.songs) > 0: - self.MessageLabel.setText(translate(u'AuthorForm', u'Author in use "Delete" is disabled')) - self.DeleteButton.setEnabled(False) - else: - self.MessageLabel.setText(translate(u'AuthorForm', u'Author in not used')) - self.DeleteButton.setEnabled(True) - self._validate_form() + if item is not None: + item_id = (item.data(QtCore.Qt.UserRole)).toInt()[0] + self.author = self.songmanager.get_author(item_id) + self.DisplayEdit.setText(self.author.display_name) + if self.author.first_name is None: + self.FirstNameEdit.setText(u'') + else: + self.FirstNameEdit.setText(self.author.first_name) + if self.author.last_name is None: + self.LastNameEdit.setText(u'') + else: + self.LastNameEdit.setText(self.author.last_name) + if len(self.author.songs) > 0: + self.MessageLabel.setText(translate(u'AuthorForm', u'Author in use "Delete" is disabled')) + self.DeleteButton.setEnabled(False) + else: + self.MessageLabel.setText(translate(u'AuthorForm', u'Author in not used')) + self.DeleteButton.setEnabled(True) + self._validate_form() self.DisplayEdit.setFocus() def _validate_form(self): diff --git a/openlp/plugins/songs/forms/songbookform.py b/openlp/plugins/songs/forms/songbookform.py index 147c588fb..e4771d4a3 100644 --- a/openlp/plugins/songs/forms/songbookform.py +++ b/openlp/plugins/songs/forms/songbookform.py @@ -106,17 +106,18 @@ class SongBookForm(QtGui.QDialog, Ui_SongBookDialog): """ self.currentRow = self.BookSongListWidget.currentRow() item = self.BookSongListWidget.currentItem() - item_id = (item.data(QtCore.Qt.UserRole)).toInt()[0] - self.Book = self.songmanager.get_book(item_id) - self.NameEdit.setText(self.Book.name) - self.PublisherEdit.setText(self.Book.publisher) - if len(self.Book.songs) > 0: - self.MessageLabel.setText(translate(u'BookForm', u'Book in use "Delete" is disabled')) - self.DeleteButton.setEnabled(False) - else: - self.MessageLabel.setText(translate(u'BookForm', u'Book in not used')) - self.DeleteButton.setEnabled(True) - self._validate_form() + if item is not None: + item_id = (item.data(QtCore.Qt.UserRole)).toInt()[0] + self.Book = self.songmanager.get_book(item_id) + self.NameEdit.setText(self.Book.name) + self.PublisherEdit.setText(self.Book.publisher) + if len(self.Book.songs) > 0: + self.MessageLabel.setText(translate(u'BookForm', u'Book in use "Delete" is disabled')) + self.DeleteButton.setEnabled(False) + else: + self.MessageLabel.setText(translate(u'BookForm', u'Book in not used')) + self.DeleteButton.setEnabled(True) + self._validate_form() self.NameEdit.setFocus() def _validate_form(self): diff --git a/openlp/plugins/songs/forms/topicsform.py b/openlp/plugins/songs/forms/topicsform.py index 759e72ae3..f3fa87185 100644 --- a/openlp/plugins/songs/forms/topicsform.py +++ b/openlp/plugins/songs/forms/topicsform.py @@ -105,16 +105,17 @@ class TopicsForm(QtGui.QDialog, Ui_TopicsDialog): """ self.currentRow = self.TopicsListWidget.currentRow() item = self.TopicsListWidget.currentItem() - item_id = (item.data(QtCore.Qt.UserRole)).toInt()[0] - self.topic = self.songmanager.get_topic(item_id) - self.TopicNameEdit.setText(self.topic.name) - if len(self.topic.songs) > 0: - self.MessageLabel.setText(translate(u'TopicForm', u'Topic in use "Delete" is disabled')) - self.DeleteButton.setEnabled(False) - else: - self.MessageLabel.setText(translate(u'TopicForm', u'Topic in not used')) - self.DeleteButton.setEnabled(True) - self._validate_form() + if item is not None: + item_id = (item.data(QtCore.Qt.UserRole)).toInt()[0] + self.topic = self.songmanager.get_topic(item_id) + self.TopicNameEdit.setText(self.topic.name) + if len(self.topic.songs) > 0: + self.MessageLabel.setText(translate(u'TopicForm', u'Topic in use "Delete" is disabled')) + self.DeleteButton.setEnabled(False) + else: + self.MessageLabel.setText(translate(u'TopicForm', u'Topic in not used')) + self.DeleteButton.setEnabled(True) + self._validate_form() self.TopicNameEdit.setFocus() def _validate_form(self): From 66eed386711681a2cd218ef3fa9e099a20a27d18 Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Thu, 23 Jul 2009 06:17:26 +0100 Subject: [PATCH 4/9] Change Bible layout options to add verse per slide --- openlp/plugins/bibles/lib/biblestab.py | 64 +++++++++++++------------- openlp/plugins/bibles/lib/mediaitem.py | 15 +++--- 2 files changed, 40 insertions(+), 39 deletions(-) diff --git a/openlp/plugins/bibles/lib/biblestab.py b/openlp/plugins/bibles/lib/biblestab.py index 7d4daa49f..a4bf46363 100644 --- a/openlp/plugins/bibles/lib/biblestab.py +++ b/openlp/plugins/bibles/lib/biblestab.py @@ -56,22 +56,9 @@ class BiblesTab(SettingsTab): self.VerseDisplayLayout = QtGui.QGridLayout(self.VerseDisplayGroupBox) self.VerseDisplayLayout.setMargin(8) self.VerseDisplayLayout.setObjectName(u'VerseDisplayLayout') - self.VerseTypeWidget = QtGui.QWidget(self.VerseDisplayGroupBox) - self.VerseTypeWidget.setObjectName(u'VerseTypeWidget') - self.VerseTypeLayout = QtGui.QHBoxLayout(self.VerseTypeWidget) - self.VerseTypeLayout.setSpacing(8) - self.VerseTypeLayout.setMargin(0) - self.VerseTypeLayout.setObjectName(u'VerseTypeLayout') - self.VerseRadioButton = QtGui.QRadioButton(self.VerseTypeWidget) - self.VerseRadioButton.setObjectName(u'VerseRadioButton') - self.VerseTypeLayout.addWidget(self.VerseRadioButton) - self.ParagraphRadioButton = QtGui.QRadioButton(self.VerseTypeWidget) - self.ParagraphRadioButton.setObjectName(u'ParagraphRadioButton') - self.VerseTypeLayout.addWidget(self.ParagraphRadioButton) - self.VerseDisplayLayout.addWidget(self.VerseTypeWidget, 0, 0, 1, 1) self.NewChaptersCheckBox = QtGui.QCheckBox(self.VerseDisplayGroupBox) self.NewChaptersCheckBox.setObjectName(u'NewChaptersCheckBox') - self.VerseDisplayLayout.addWidget(self.NewChaptersCheckBox, 1, 0, 1, 1) + self.VerseDisplayLayout.addWidget(self.NewChaptersCheckBox, 0, 0, 1, 1) self.DisplayStyleWidget = QtGui.QWidget(self.VerseDisplayGroupBox) self.DisplayStyleWidget.setObjectName(u'DisplayStyleWidget') self.DisplayStyleLayout = QtGui.QHBoxLayout(self.DisplayStyleWidget) @@ -88,7 +75,24 @@ class BiblesTab(SettingsTab): self.DisplayStyleComboBox.addItem(QtCore.QString()) self.DisplayStyleComboBox.addItem(QtCore.QString()) self.DisplayStyleLayout.addWidget(self.DisplayStyleComboBox) - self.VerseDisplayLayout.addWidget(self.DisplayStyleWidget, 2, 0, 1, 1) + self.VerseDisplayLayout.addWidget(self.DisplayStyleWidget, 1, 0, 1, 1) + self.LayoutStyleWidget = QtGui.QWidget(self.VerseDisplayGroupBox) + self.LayoutStyleWidget.setObjectName(u'LayoutStyleWidget') + self.LayoutStyleLayout = QtGui.QHBoxLayout(self.LayoutStyleWidget) + self.LayoutStyleLayout.setSpacing(8) + self.LayoutStyleLayout.setMargin(0) + self.LayoutStyleLayout.setObjectName(u'LayoutStyleLayout') + self.LayoutStyleLabel = QtGui.QLabel(self.LayoutStyleWidget) + self.LayoutStyleLabel.setObjectName(u'LayoutStyleLabel') + self.LayoutStyleLayout.addWidget(self.LayoutStyleLabel) + self.LayoutStyleComboBox = QtGui.QComboBox(self.LayoutStyleWidget) + self.LayoutStyleComboBox.setObjectName(u'LayoutStyleComboBox') + self.LayoutStyleComboBox.addItem(QtCore.QString()) + self.LayoutStyleComboBox.addItem(QtCore.QString()) + self.LayoutStyleComboBox.addItem(QtCore.QString()) + self.LayoutStyleLayout.addWidget(self.LayoutStyleComboBox) + self.VerseDisplayLayout.addWidget(self.LayoutStyleWidget, 2, 0, 1, 1) + self.BibleThemeWidget = QtGui.QWidget(self.VerseDisplayGroupBox) self.BibleThemeWidget.setObjectName(u'BibleThemeWidget') self.BibleThemeLayout = QtGui.QHBoxLayout(self.BibleThemeWidget) @@ -136,22 +140,22 @@ class BiblesTab(SettingsTab): QtCore.SIGNAL(u'stateChanged(int)'), self.onNewChaptersCheckBoxChanged) QtCore.QObject.connect(self.BibleSearchCheckBox, QtCore.SIGNAL(u'stateChanged(int)'), self.onBibleSearchCheckBoxChanged) - QtCore.QObject.connect(self.VerseRadioButton, - QtCore.SIGNAL(u'pressed()'), self.onVerseRadioButtonPressed) - QtCore.QObject.connect(self.ParagraphRadioButton, - QtCore.SIGNAL(u'pressed()'), self.onParagraphRadioButtonPressed) QtCore.QObject.connect(self.DisplayStyleComboBox, QtCore.SIGNAL(u'activated(int)'), self.onDisplayStyleComboBoxChanged) QtCore.QObject.connect(self.BibleThemeComboBox, QtCore.SIGNAL(u'activated(int)'), self.onBibleThemeComboBoxChanged) + QtCore.QObject.connect(self.LayoutStyleComboBox, + QtCore.SIGNAL(u'activated(int)'), self.onLayoutStyleComboBoxChanged) def retranslateUi(self): self.VerseDisplayGroupBox.setTitle(translate(u'SettingsForm', u'Verse Display')) - self.VerseRadioButton.setText(translate(u'SettingsForm', u'Verse style')) - self.ParagraphRadioButton.setText(translate(u'SettingsForm', u'Paragraph style')) self.NewChaptersCheckBox.setText(translate(u'SettingsForm', u'Only show new chapter numbers')) + self.LayoutStyleLabel.setText(translate(u'SettingsForm', u'Layout Style:')) self.DisplayStyleLabel.setText(translate(u'SettingsForm', u'Display Style:')) self.BibleThemeLabel.setText(translate(u'SettingsForm', u'Bible Theme:')) + self.LayoutStyleComboBox.setItemText(0, translate(u'SettingsForm', u'verse per slide')) + self.LayoutStyleComboBox.setItemText(1, translate(u'SettingsForm', u'verse per line')) + self.LayoutStyleComboBox.setItemText(2, translate(u'SettingsForm', u'continuous')) self.DisplayStyleComboBox.setItemText(0, translate(u'SettingsForm', u'No brackets')) self.DisplayStyleComboBox.setItemText(1, translate(u'SettingsForm', u'( and )')) self.DisplayStyleComboBox.setItemText(2, translate(u'SettingsForm', u'{ and }')) @@ -166,11 +170,8 @@ class BiblesTab(SettingsTab): def onDisplayStyleComboBoxChanged(self): self.display_style = self.DisplayStyleComboBox.currentIndex() - def onVerseRadioButtonPressed(self): - self.paragraph_style = False - - def onParagraphRadioButtonPressed(self): - self.paragraph_style = True + def onLayoutStyleComboBoxChanged(self): + self.layout_style = self.LayoutStyleComboBox.currentIndex() def onNewChaptersCheckBoxChanged(self): check_state = self.NewChaptersCheckBox.checkState() @@ -187,23 +188,20 @@ class BiblesTab(SettingsTab): self.bible_search = True def load(self): - self.paragraph_style = str_to_bool(self.config.get_config(u'paragraph style', u'True')) self.show_new_chapters = str_to_bool(self.config.get_config(u'display new chapter', u'False')) self.display_style = int(self.config.get_config(u'display brackets', u'0')) + self.layout_style = int(self.config.get_config(u'verse layout style', u'0')) self.bible_theme = self.config.get_config(u'bible theme', u'0') self.bible_search = str_to_bool(self.config.get_config(u'search as type', u'True')) - if self.paragraph_style: - self.ParagraphRadioButton.setChecked(True) - else: - self.VerseRadioButton.setChecked(True) self.NewChaptersCheckBox.setChecked(self.show_new_chapters) self.DisplayStyleComboBox.setCurrentIndex(self.display_style) + self.LayoutStyleComboBox.setCurrentIndex(self.layout_style) self.BibleSearchCheckBox.setChecked(self.bible_search) def save(self): - self.config.set_config(u'paragraph style', unicode(self.paragraph_style)) self.config.set_config(u'display new chapter', unicode(self.show_new_chapters)) self.config.set_config(u'display brackets', unicode(self.display_style)) + self.config.set_config(u'verse layout style', unicode(self.layout_style)) self.config.set_config(u'search as type', unicode(self.bible_search)) self.config.set_config(u'bible theme', unicode(self.bible_theme)) @@ -220,4 +218,4 @@ class BiblesTab(SettingsTab): # Not Found id = 0 self.bible_theme = u'' - self.BibleThemeComboBox.setCurrentIndex(id) \ No newline at end of file + self.BibleThemeComboBox.setCurrentIndex(id) diff --git a/openlp/plugins/bibles/lib/mediaitem.py b/openlp/plugins/bibles/lib/mediaitem.py index dfa2f73a0..f27d832b1 100644 --- a/openlp/plugins/bibles/lib/mediaitem.py +++ b/openlp/plugins/bibles/lib/mediaitem.py @@ -355,7 +355,7 @@ class BibleMediaItem(MediaManagerItem): verse = unicode(self.search_results[0].verse) text = self.search_results[0].text #Paragraph style force new line per verse - if self.parent.bibles_tab.paragraph_style: + if self.parent.bibles_tab.layout_style == 1: text = text + u'\n\n' if self.parent.bibles_tab.display_style == 1: loc = self.formatVerse(old_chapter, chapter, verse, u'(u', u')') @@ -367,8 +367,13 @@ class BibleMediaItem(MediaManagerItem): loc = self.formatVerse(old_chapter, chapter, verse, u'', u'') old_chapter = chapter bible_text = bible_text + u' '+ loc + u' '+ text + #if we are verse per slide then create slide + if self.parent.bibles_tab.layout_style == 0: + raw_slides.append(bible_text) + bible_text = u'' service_item.title = book + u' ' + loc footer = book + u' (' + self.version + u' ' + self.copyright +u')' + #If not found throws and error so add.s try: raw_footer.index(footer) except: @@ -377,7 +382,9 @@ class BibleMediaItem(MediaManagerItem): service_item.theme = None else: service_item.theme = self.parent.bibles_tab.bible_theme - raw_slides.append(bible_text) + #if we are verse per slide we have already been added + if self.parent.bibles_tab.layout_style != 0: + raw_slides.append(bible_text) for slide in raw_slides: service_item.add_from_text(slide[:30], slide) service_item.raw_footer = raw_footer @@ -425,10 +432,6 @@ class BibleMediaItem(MediaManagerItem): def displayResults(self, bible): for verse in self.search_results: - #bible_text = unicode(u' %s %d:%d (%s)'%(book , chap,vse, bible)) - #bible_verse = QtGui.QListWidgetItem(bible_text) - #bible_verse.setData(QtCore.Qt.UserRole, QtCore.QVariant(bible_text)) - #self.ListView.addItem(bible_verse) bible_text = u' %s %d:%d (%s)' % (verse.book.name, verse.chapter, verse.verse, bible) bible_verse = QtGui.QListWidgetItem(bible_text) From 279c34a67e60338ad4c4c7a3e02693866d2929ee Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Sat, 1 Aug 2009 19:03:07 +0100 Subject: [PATCH 5/9] Add theme bold/Italics to renderer --- openlp/core/lib/renderer.py | 8 +++++--- openlp/core/lib/themexmlhandler.py | 4 ++++ openlp/core/ui/amendthemedialog.py | 30 ++++++++++++++++++++++++++++++ 3 files changed, 39 insertions(+), 3 deletions(-) diff --git a/openlp/core/lib/renderer.py b/openlp/core/lib/renderer.py index 957818132..d6ef78434 100644 --- a/openlp/core/lib/renderer.py +++ b/openlp/core/lib/renderer.py @@ -558,13 +558,15 @@ class Renderer(object): """ self.footerFont = QtGui.QFont(self._theme.font_footer_name, int(self._theme.font_footer_proportion), # size - QtGui.QFont.Normal, # weight - 0)# italic + int(self._theme.font_footer_weight), # weight + 0)# italic + self.footerFont.setItalic(int(self._theme.font_footer_italics)) self.footerFont.setPixelSize(int(self._theme.font_footer_proportion)) self.mainFont = QtGui.QFont(self._theme.font_main_name, int(self._theme.font_main_proportion), # size - QtGui.QFont.Normal, # weight + int(self._theme.font_main_weight), # weight 0)# italic + self.mainFont.setItalic(int(self._theme.font_main_italics)) self.mainFont.setPixelSize(int(self._theme.font_main_proportion)) def _get_extent_and_render(self, line, footer, tlcorner=(0, 0), draw=False, color=None): diff --git a/openlp/core/lib/themexmlhandler.py b/openlp/core/lib/themexmlhandler.py index acb451653..bbb4a0c2a 100644 --- a/openlp/core/lib/themexmlhandler.py +++ b/openlp/core/lib/themexmlhandler.py @@ -46,12 +46,16 @@ blankthemexml=\ Arial #000000 30 + 50 + 0 Arial #000000 12 + 50 + 0 diff --git a/openlp/core/ui/amendthemedialog.py b/openlp/core/ui/amendthemedialog.py index cd0f83cf8..045d78470 100644 --- a/openlp/core/ui/amendthemedialog.py +++ b/openlp/core/ui/amendthemedialog.py @@ -165,6 +165,16 @@ class Ui_AmendThemeDialog(object): self.FontMainSizeSpinBox.setMaximum(999) self.FontMainSizeSpinBox.setObjectName(u'FontMainSizeSpinBox') self.MainFontLayout.setWidget(2, QtGui.QFormLayout.FieldRole, self.FontMainSizeSpinBox) + self.FontMainWeightComboBox = QtGui.QComboBox(self.FontMainGroupBox) + self.FontMainWeightComboBox.setObjectName("FontMainWeightComboBox") + self.FontMainWeightComboBox.addItem(QtCore.QString()) + self.FontMainWeightComboBox.addItem(QtCore.QString()) + self.FontMainWeightComboBox.addItem(QtCore.QString()) + self.FontMainWeightComboBox.addItem(QtCore.QString()) + self.MainFontLayout.setWidget(3, QtGui.QFormLayout.FieldRole, self.FontMainWeightComboBox) + self.FontMainWeightLabel = QtGui.QLabel(self.FontMainGroupBox) + self.FontMainWeightLabel.setObjectName("FontMainWeightLabel") + self.MainFontLayout.setWidget(3, QtGui.QFormLayout.LabelRole, self.FontMainWeightLabel) self.MainLeftLayout.addWidget(self.FontMainGroupBox) spacerItem1 = QtGui.QSpacerItem(20, 40, QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Expanding) self.MainLeftLayout.addItem(spacerItem1) @@ -292,6 +302,16 @@ class Ui_AmendThemeDialog(object): self.FontFooterSizeSpinBox.setMaximum(999) self.FontFooterSizeSpinBox.setObjectName(u'FontFooterSizeSpinBox') self.FooterFontLayout.setWidget(2, QtGui.QFormLayout.FieldRole, self.FontFooterSizeSpinBox) + self.FontFooterWeightComboBox = QtGui.QComboBox(self.FooterFontGroupBox) + self.FontFooterWeightComboBox.setObjectName("FontFooterWeightComboBox") + self.FontFooterWeightComboBox.addItem(QtCore.QString()) + self.FontFooterWeightComboBox.addItem(QtCore.QString()) + self.FontFooterWeightComboBox.addItem(QtCore.QString()) + self.FontFooterWeightComboBox.addItem(QtCore.QString()) + self.FooterFontLayout.setWidget(3, QtGui.QFormLayout.FieldRole, self.FontFooterWeightComboBox) + self.FontFooterWeightLabel = QtGui.QLabel(self.FooterFontGroupBox) + self.FontFooterWeightLabel.setObjectName("FontFooterWeightLabel") + self.FooterFontLayout.setWidget(3, QtGui.QFormLayout.LabelRole, self.FontFooterWeightLabel) self.FooterLeftLayout.addWidget(self.FooterFontGroupBox) spacerItem3 = QtGui.QSpacerItem(20, 40, QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Expanding) self.FooterLeftLayout.addItem(spacerItem3) @@ -550,6 +570,11 @@ class Ui_AmendThemeDialog(object): self.FontMainColorLabel.setText(translate(u'AmendThemeDialog', u'Font Color:')) self.FontMainSize.setText(translate(u'AmendThemeDialog', u'Size:')) self.FontMainSizeSpinBox.setSuffix(translate(u'AmendThemeDialog', u'pt')) + self.FontMainWeightComboBox.setItemText(0, translate("AmendThemeDialog", u'Normal')) + self.FontMainWeightComboBox.setItemText(1, translate("AmendThemeDialog", u'Bold')) + self.FontMainWeightComboBox.setItemText(2, translate("AmendThemeDialog", u'Italics')) + self.FontMainWeightComboBox.setItemText(3, translate("AmendThemeDialog", u'Bold/Italics')) + self.FontMainWeightLabel.setText(translate("AmendThemeDialog", u'Font Weight:')) self.MainLocationGroupBox.setTitle(translate(u'AmendThemeDialog', u'Display Location')) self.DefaultLocationLabel.setText(translate(u'AmendThemeDialog', u'Use Default Location:')) self.FontMainXLabel.setText(translate(u'AmendThemeDialog', u'X Position:')) @@ -566,6 +591,11 @@ class Ui_AmendThemeDialog(object): self.FontFooterColorLabel.setText(translate(u'AmendThemeDialog', u'Font Color:')) self.FontFooterSizeLabel.setText(translate(u'AmendThemeDialog', u'Size:')) self.FontFooterSizeSpinBox.setSuffix(translate(u'AmendThemeDialog', u'pt')) + self.FontFooterWeightComboBox.setItemText(0, translate("AmendThemeDialog", u'Normal')) + self.FontFooterWeightComboBox.setItemText(1, translate("AmendThemeDialog", u'Bold')) + self.FontFooterWeightComboBox.setItemText(2, translate("AmendThemeDialog", u'Italics')) + self.FontFooterWeightComboBox.setItemText(3, translate("AmendThemeDialog", u'Bold/Italics')) + self.FontFooterWeightLabel.setText(translate("AmendThemeDialog", u'Font Weight:')) self.LocationFooterGroupBox.setTitle(translate(u'AmendThemeDialog', u'Display Location')) self.FontFooterDefaultLabel.setText(translate(u'AmendThemeDialog', u'Use Default Location:')) self.FontFooterXLabel.setText(translate(u'AmendThemeDialog', u'X Position:')) From 470f1d19dfb6ae74ba938fe1f0f33e14bdb2f324 Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Sat, 1 Aug 2009 20:25:53 +0100 Subject: [PATCH 6/9] Add attributes to themes Save data Update data --- openlp/core/lib/themexmlhandler.py | 14 ++++++-- openlp/core/ui/amendthemeform.py | 57 ++++++++++++++++++++++++++++-- 2 files changed, 65 insertions(+), 6 deletions(-) diff --git a/openlp/core/lib/themexmlhandler.py b/openlp/core/lib/themexmlhandler.py index bbb4a0c2a..787ca16de 100644 --- a/openlp/core/lib/themexmlhandler.py +++ b/openlp/core/lib/themexmlhandler.py @@ -161,7 +161,7 @@ class ThemeXML(object): #Create Filename element self.child_element(background, u'filename', filename) - def add_font(self, name, color, proportion, override, fonttype=u'main', + def add_font(self, name, color, proportion, override, fonttype=u'main', weight=50, italics=0, xpos=0, ypos=0, width=0, height=0): """ Add a Font. @@ -181,6 +181,12 @@ class ThemeXML(object): ``fonttype`` The type of font, ``main`` or ``footer``. Defaults to ``main``. + ``weight`` + The weight of then font Defaults to 50 Normal + + ``italics`` + Does the font render to italics Defaults to 0 Normal + ``xpos`` The X position of the text block. @@ -202,8 +208,10 @@ class ThemeXML(object): self.child_element(background, u'color', color) #Create Proportion name element self.child_element(background, u'proportion', proportion) - #Create Proportion name element - self.child_element(background, u'proportion', proportion) + #Create weight name element + self.child_element(background, u'weight', weight) + #Create italics name element + self.child_element(background, u'italics', italics) #Create Location element element = self.theme_xml.createElement(u'location') element.setAttribute(u'override',override) diff --git a/openlp/core/ui/amendthemeform.py b/openlp/core/ui/amendthemeform.py index 3b52ba215..fd966f54e 100644 --- a/openlp/core/ui/amendthemeform.py +++ b/openlp/core/ui/amendthemeform.py @@ -53,7 +53,6 @@ class AmendThemeForm(QtGui.QDialog, Ui_AmendThemeDialog): QtCore.SIGNAL(u'pressed()'), self.onShadowColorPushButtonClicked) QtCore.QObject.connect(self.ImageToolButton, QtCore.SIGNAL(u'pressed()'), self.onImageToolButtonClicked) - #Combo boxes QtCore.QObject.connect(self.BackgroundComboBox, QtCore.SIGNAL(u'activated(int)'), self.onBackgroundComboBoxSelected) @@ -63,13 +62,17 @@ class AmendThemeForm(QtGui.QDialog, Ui_AmendThemeDialog): QtCore.SIGNAL(u'activated(int)'), self.onGradientComboBoxSelected) QtCore.QObject.connect(self.FontMainComboBox, QtCore.SIGNAL(u'activated(int)'), self.onFontMainComboBoxSelected) + QtCore.QObject.connect(self.FontMainWeightComboBox, + QtCore.SIGNAL(u'activated(int)'), self.onFontMainWeightComboBoxSelected) QtCore.QObject.connect(self.FontFooterComboBox, QtCore.SIGNAL(u'activated(int)'), self.onFontFooterComboBoxSelected) + QtCore.QObject.connect(self.FontFooterWeightComboBox, + QtCore.SIGNAL(u'activated(int)'), self.onFontFooterWeightComboBoxSelected) QtCore.QObject.connect(self.HorizontalComboBox, QtCore.SIGNAL(u'activated(int)'), self.onHorizontalComboBoxSelected) QtCore.QObject.connect(self.VerticalComboBox, QtCore.SIGNAL(u'activated(int)'), self.onVerticalComboBoxSelected) - + #Spin boxes QtCore.QObject.connect(self.FontMainSizeSpinBox, QtCore.SIGNAL(u'editingFinished()'), self.onFontMainSizeSpinBoxChanged) QtCore.QObject.connect(self.FontFooterSizeSpinBox, @@ -118,10 +121,12 @@ class AmendThemeForm(QtGui.QDialog, Ui_AmendThemeDialog): new_theme.add_font(unicode(self.theme.font_main_name), unicode(self.theme.font_main_color), unicode(self.theme.font_main_proportion), unicode(self.theme.font_main_override), u'main', + unicode(self.theme.font_main_weight), unicode(self.theme.font_main_italics), unicode(self.theme.font_main_x), unicode(self.theme.font_main_y), unicode(self.theme.font_main_width), unicode(self.theme.font_main_height)) new_theme.add_font(unicode(self.theme.font_footer_name), unicode(self.theme.font_footer_color), unicode(self.theme.font_footer_proportion), unicode(self.theme.font_footer_override), u'footer', + unicode(self.theme.font_footer_weight), unicode(self.theme.font_footer_italics), unicode(self.theme.font_footer_x), unicode(self.theme.font_footer_y), unicode(self.theme.font_footer_width), unicode(self.theme.font_footer_height) ) new_theme.add_display(unicode(self.theme.display_shadow), unicode(self.theme.display_shadow_color), @@ -159,6 +164,21 @@ class AmendThemeForm(QtGui.QDialog, Ui_AmendThemeDialog): self.theme.font_main_name = self.FontMainComboBox.currentFont().family() self.previewTheme(self.theme) + def onFontMainWeightComboBoxSelected(self, value): + if value ==0: + self.theme.font_main_weight = 50 + self.theme.font_main_italics = 0 + elif value == 1: + self.theme.font_main_weight = 75 + self.theme.font_main_italics = 0 + elif value == 2: + self.theme.font_main_weight = 50 + self.theme.font_main_italics = 1 + else: + self.theme.font_main_weight = 75 + self.theme.font_main_italics = 1 + self.previewTheme(self.theme) + def onFontMainColorPushButtonClicked(self): self.theme.font_main_color = QtGui.QColorDialog.getColor( QtGui.QColor(self.theme.font_main_color), self).name() @@ -217,6 +237,21 @@ class AmendThemeForm(QtGui.QDialog, Ui_AmendThemeDialog): self.theme.font_footer_name = self.FontFooterComboBox.currentFont().family() self.previewTheme(self.theme) + def onFontFooterWeightComboBoxSelected(self, value): + if value == 0: + self.theme.font_footer_weight = 50 + self.theme.font_footer_italics = 0 + elif value == 1: + self.theme.font_footer_weight = 75 + self.theme.font_footer_italics = 0 + elif value == 2: + self.theme.font_footer_weight = 50 + self.theme.font_footer_italics = 1 + else: + self.theme.font_footer_weight = 75 + self.theme.font_footer_italics = 1 + self.previewTheme(self.theme) + def onFontFooterColorPushButtonClicked(self): self.theme.font_footer_color = QtGui.QColorDialog.getColor( QtGui.QColor(self.theme.font_footer_color), self).name() @@ -410,11 +445,28 @@ class AmendThemeForm(QtGui.QDialog, Ui_AmendThemeDialog): self.GradientComboBox.setCurrentIndex(2) self.FontMainSizeSpinBox.setValue(int(self.theme.font_main_proportion)) + if int(self.theme.font_main_italics) == 0 and int(self.theme.font_main_weight) == 50: + self.FontMainWeightComboBox.setCurrentIndex(0) + elif int(self.theme.font_main_italics) == 0 and int(self.theme.font_main_weight) == 75: + self.FontMainWeightComboBox.setCurrentIndex(1) + elif int(self.theme.font_main_italics) == 1 and int(self.theme.font_main_weight) == 50: + self.FontMainWeightComboBox.setCurrentIndex(2) + else: + self.FontMainWeightComboBox.setCurrentIndex(3) + self.FontMainXSpinBox.setValue(int(self.theme.font_main_x)) self.FontMainYSpinBox.setValue(int(self.theme.font_main_y)) self.FontMainWidthSpinBox.setValue(int(self.theme.font_main_width)) self.FontMainHeightSpinBox.setValue(int(self.theme.font_main_height)) self.FontFooterSizeSpinBox.setValue(int(self.theme.font_footer_proportion)) + if int(self.theme.font_footer_italics) == 0 and int(self.theme.font_footer_weight) == 50: + self.FontFooterWeightComboBox.setCurrentIndex(0) + elif int(self.theme.font_footer_italics) == 0 and int(self.theme.font_footer_weight) == 75: + self.FontFooterWeightComboBox.setCurrentIndex(1) + elif int(self.theme.font_footer_italics) == 1 and int(self.theme.font_footer_weight) == 50: + self.FontFooterWeightComboBox.setCurrentIndex(2) + else: + self.FontFooterWeightComboBox.setCurrentIndex(3) self.FontFooterXSpinBox.setValue(int(self.theme.font_footer_x)) self.FontFooterYSpinBox.setValue(int(self.theme.font_footer_y)) self.FontFooterWidthSpinBox.setValue(int(self.theme.font_footer_width)) @@ -529,7 +581,6 @@ class AmendThemeForm(QtGui.QDialog, Ui_AmendThemeDialog): else: self.ShadowColorPushButton.setEnabled(False) - def previewTheme(self, theme): if self.allowPreview: frame = self.thememanager.generateImage(theme) From fa606e19a93d96dcf6bd86b87d33f6957c81c947 Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Sun, 2 Aug 2009 14:44:41 +0100 Subject: [PATCH 7/9] Add download notifications for HTTP bibles Fix bug running off the end of bible chapter --- openlp/plugins/bibles/lib/bibleHTTPimpl.py | 4 +- openlp/plugins/bibles/lib/manager.py | 49 +++++++++++++++------- openlp/plugins/bibles/lib/mediaitem.py | 14 +++++++ 3 files changed, 49 insertions(+), 18 deletions(-) diff --git a/openlp/plugins/bibles/lib/bibleHTTPimpl.py b/openlp/plugins/bibles/lib/bibleHTTPimpl.py index d41ba1524..706fdd8f9 100644 --- a/openlp/plugins/bibles/lib/bibleHTTPimpl.py +++ b/openlp/plugins/bibles/lib/bibleHTTPimpl.py @@ -96,7 +96,7 @@ class CWExtract(BibleCommon): chapter - chapter number """ log.debug(u'get_bible_chapter %s,%s,%s,%s', version, bookid, bookname, chapter) - bookname = bookname.replace(u' ', '') + bookname = bookname.replace(u' ', u'') urlstring = u'http://bible.crosswalk.com/OnlineStudyBible/bible.cgi?word=%s+%d&version=%s' % (bookname, chapter, version) xml_string = self._get_web_text(urlstring, self.proxyurl) #log.debug(u'Return data %s', xml_string) @@ -151,8 +151,8 @@ class CWExtract(BibleCommon): verseText = xml_string[versePos: i] versePos = i #print verseText + #print self._clean_text(verseText) bible[verse] = self._clean_text(verseText) - #bible[verse] = verseText #log.debug( bible) return SearchResults(book_title, book_chapter, bible) diff --git a/openlp/plugins/bibles/lib/manager.py b/openlp/plugins/bibles/lib/manager.py index e076811d7..63667bc6b 100644 --- a/openlp/plugins/bibles/lib/manager.py +++ b/openlp/plugins/bibles/lib/manager.py @@ -28,9 +28,7 @@ from bibleOSISimpl import BibleOSISImpl from bibleCSVimpl import BibleCSVImpl from bibleDBimpl import BibleDBImpl from bibleHTTPimpl import BibleHTTPImpl - -#from openlp.plugins.bibles.lib.tables import * -#from openlp.plugins.bibles.lib.classes import * +from openlp.core.lib import Receiver class BibleMode(object): Full = 1 @@ -68,6 +66,15 @@ class BibleManager(object): self.dialogobject = None self.reload_bibles() + def set_media_manager(self, media): + """ + Sets the reference to the media manager. + + ``media`` + The reference to the media manager. + """ + self.media = media + def reload_bibles(self): log.debug(u'Reload bibles') files = self.config.get_files(self.bibleSuffix) @@ -228,8 +235,7 @@ class BibleManager(object): Advanced Search, and when the mode is ``BibleMode.Partial`` this method returns all the bibles for the Quick Search. - ``mode`` - Defaults to ``BibleMode.Full``. The Bible mode. +c """ log.debug(u'get_bibles') bible_list = [] @@ -293,17 +299,24 @@ class BibleManager(object): Returns a list of verses for a given Book, Chapter and ranges of verses. If the end verse(everse) is less then the start verse(sverse) then only one verse is returned - bible - Which bible to use. + + ``bible`` + The name of the bible to be used + Rest can be guessed at ! """ text = [] + self.media.setQuickMsg1(u'') + self.media.setQuickMsg2(u'') log.debug(u'get_verse_text %s,%s,%s,%s,%s,%s', bible, bookname, schapter, echapter, sverse, everse) - if not self.bible_http_cache[bible] == None: - # check to see if book/chapter exists + # check to see if book/chapter exists fow HTTP bibles and load cache if necessary + if self.bible_http_cache[bible] is not None: book= self.bible_db_cache[bible].get_bible_book(bookname) if book == None: + self.media.setQuickMsg1(u'Downloading') log.debug(u'get_verse_text : new book') - for chapter in range(schapter, echapter+1): + for chapter in range(schapter, echapter + 1): + self.media.setQuickMsg2(u'%s: %s'% (bookname, chapter)) search_results = self.bible_http_cache [bible].get_bible_chapter(bible, 0, bookname, chapter) if search_results.has_verselist() : ## We have found a book of the bible lets check to see if it was there. @@ -325,35 +338,39 @@ class BibleManager(object): ## Book exists check chapter and texts only. v = self.bible_db_cache[bible].get_bible_chapter(book.id, chapter) if v == None: + self.media.setQuickMsg2(u'%s: %s'%(bookname, chapter)) self.bible_db_cache[bible].create_chapter(book.id, \ chapter, \ search_results.get_verselist()) else: log.debug(u'get_verse_text : old book') - for chapter in range(schapter, echapter+1): + for chapter in range(schapter, echapter + 1): v = self.bible_db_cache[bible].get_bible_chapter(book.id, chapter) if v == None: try: + self.media.setQuickMsg1(u'Downloading') + self.media.setQuickMsg2(u'%s: %s'% (bookname, chapter)) search_results = self.bible_http_cache [bible].get_bible_chapter(bible, book.id, bookname, chapter) - self.bible_db_cache[bible].create_chapter(book.id, \ - search_results.get_chapter(),\ - search_results.get_verselist()) + if search_results.has_verselist(): + self.bible_db_cache[bible].create_chapter(book.id, \ + search_results.get_chapter(),\ + search_results.get_verselist()) except : log.error(u'Errow thrown %s', sys.exc_info()[1]) - + #Now get verses from database if schapter == echapter: text = self.bible_db_cache[bible].get_bible_text(bookname, schapter, sverse, everse) else: for i in range (schapter, echapter + 1): if i == schapter: start = sverse - end = self.get_book_verse_count(bible, bookname,i )[0] + end = self.get_book_verse_count(bible, bookname, i) elif i == echapter: start = 1 end = everse else: start = 1 - end = self.get_book_verse_count(bible, bookname,i )[0] + end = self.get_book_verse_count(bible, bookname, i) txt = self.bible_db_cache[bible].get_bible_text(bookname, i, start, end) text.extend(txt) diff --git a/openlp/plugins/bibles/lib/mediaitem.py b/openlp/plugins/bibles/lib/mediaitem.py index f27d832b1..34c166854 100644 --- a/openlp/plugins/bibles/lib/mediaitem.py +++ b/openlp/plugins/bibles/lib/mediaitem.py @@ -135,6 +135,12 @@ class BibleMediaItem(MediaManagerItem): self.ClearQuickSearchComboBox = QtGui.QComboBox(self.QuickTab) self.ClearQuickSearchComboBox.setObjectName(u'ClearQuickSearchComboBox') self.QuickLayout.addWidget(self.ClearQuickSearchComboBox, 3, 1, 1, 1) + self.QuickMsg1 = QtGui.QLabel(self.QuickTab) + self.QuickMsg1.setObjectName(u'QuickSearchLabel') + self.QuickLayout.addWidget(self.QuickMsg1, 4, 0, 1, 1) + self.QuickMsg2 = QtGui.QLabel(self.QuickTab) + self.QuickMsg2.setObjectName(u'QuickSearchLabel') + self.QuickLayout.addWidget(self.QuickMsg2, 4, 1, 1, 1) self.SearchTabWidget.addTab(self.QuickTab, 'Quick') QuickSpacerItem = QtGui.QSpacerItem(20, 40, QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Expanding) @@ -254,6 +260,14 @@ class BibleMediaItem(MediaManagerItem): def initialise(self): log.debug(u'initialise') self.loadBibles() + self.parent.biblemanager.set_media_manager(self) + + def setQuickMsg1(self, text): + self.QuickMsg1.setText(translate(u'BibleMediaItem', unicode(text))) + + def setQuickMsg2(self, text): + self.QuickMsg2.setText(translate(u'BibleMediaItem', unicode(text))) + Receiver().send_message(u'openlpprocessevents') def loadBibles(self): log.debug(u'Loading Bibles') From 13f016cf5f894035f9618d83c2eb6e513c770a2e Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Sun, 2 Aug 2009 17:13:59 +0100 Subject: [PATCH 8/9] Minor bug fixes --- openlp/core/lib/themexmlhandler.py | 2 +- openlp/core/ui/servicemanager.py | 4 +-- openlp/core/ui/thememanager.py | 4 +++ openlp/migration/migratesongs.py | 2 ++ openlp/plugins/songs/forms/editsongform.py | 31 ---------------------- 5 files changed, 9 insertions(+), 34 deletions(-) diff --git a/openlp/core/lib/themexmlhandler.py b/openlp/core/lib/themexmlhandler.py index 787ca16de..e8a33aade 100644 --- a/openlp/core/lib/themexmlhandler.py +++ b/openlp/core/lib/themexmlhandler.py @@ -161,7 +161,7 @@ class ThemeXML(object): #Create Filename element self.child_element(background, u'filename', filename) - def add_font(self, name, color, proportion, override, fonttype=u'main', weight=50, italics=0, + def add_font(self, name, color, proportion, override, fonttype=u'main', weight=u'50', italics=u'0', xpos=0, ypos=0, width=0, height=0): """ Add a Font. diff --git a/openlp/core/ui/servicemanager.py b/openlp/core/ui/servicemanager.py index f0f322e4c..e19d364f4 100644 --- a/openlp/core/ui/servicemanager.py +++ b/openlp/core/ui/servicemanager.py @@ -300,7 +300,7 @@ class ServiceManager(QtGui.QWidget): Used when moving items as the move takes place in supporting array, and when regenerating all the items due to theme changes """ - #Correct order of idems in array + #Correct order of items in array count = 1 for item in self.serviceItems: item[u'order'] = count @@ -398,7 +398,7 @@ class ServiceManager(QtGui.QWidget): """ Set the theme for the current service """ - self.service_theme = self.ThemeComboBox.currentText() + self.service_theme = unicode(self.ThemeComboBox.currentText()) self.parent.RenderManager.set_service_theme(self.service_theme) self.config.set_config(u'theme service theme', self.service_theme) self.regenerateServiceItems() diff --git a/openlp/core/ui/thememanager.py b/openlp/core/ui/thememanager.py index 56d4224f5..f14a2fabc 100644 --- a/openlp/core/ui/thememanager.py +++ b/openlp/core/ui/thememanager.py @@ -100,6 +100,10 @@ class ThemeManager(QtGui.QWidget): except: #if not present do not worry pass + #As we do not reload the themes push out the change + self.parent.EventManager.post_event(Event(EventType.ThemeListChanged)) + self.parent.ServiceManagerContents.updateThemeList(self.getThemes()) + self.parent.settingsForm.ThemesTab.updateThemeList(self.getThemes()) def onExportTheme(self): pass diff --git a/openlp/migration/migratesongs.py b/openlp/migration/migratesongs.py index 14634758b..17779bd88 100644 --- a/openlp/migration/migratesongs.py +++ b/openlp/migration/migratesongs.py @@ -155,6 +155,8 @@ class MigrateSongs(): if bb is None: author = Author() author.display_name = authors_temp.authorname + author.first_name = u'' + author.last_name = u'' else: id = int(bb[0]) author = self.session.query(Author).get(bb[0]) diff --git a/openlp/plugins/songs/forms/editsongform.py b/openlp/plugins/songs/forms/editsongform.py index caa2a480e..295f1e9fe 100644 --- a/openlp/plugins/songs/forms/editsongform.py +++ b/openlp/plugins/songs/forms/editsongform.py @@ -48,16 +48,12 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog): QtCore.SIGNAL(u'clicked()'), self.onAuthorRemovefromSongItemClicked) QtCore.QObject.connect(self.AuthorsListView, QtCore.SIGNAL(u'itemClicked(QListWidgetItem*)'), self.onAuthorsListViewPressed) -# QtCore.QObject.connect(self.AddTopicButton, -# QtCore.SIGNAL(u'clicked()'), self.onAddTopicButtonClicked) QtCore.QObject.connect(self.AddTopicsToSongButton, QtCore.SIGNAL(u'clicked()'), self.onTopicAddtoSongItemClicked) QtCore.QObject.connect(self.TopicRemoveItem, QtCore.SIGNAL(u'clicked()'), self.onTopicRemovefromSongItemClicked) QtCore.QObject.connect(self.TopicsListView, QtCore.SIGNAL(u'itemClicked(QListWidgetItem*)'), self.onTopicListViewPressed) -# QtCore.QObject.connect(self.AddSongBookButton, -# QtCore.SIGNAL(u'clicked()'), self.onAddSongBookButtonClicked) QtCore.QObject.connect(self.CopyrightInsertItem, QtCore.SIGNAL(u'clicked()'), self.onCopyrightInsertItemTriggered) QtCore.QObject.connect(self.AddButton, @@ -75,9 +71,6 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog): # Create other objects and forms self.songmanager = songmanager self.eventmanager = eventmanager -# self.authors_form = AuthorsForm(self.songmanager) -# self.topics_form = TopicsForm(self.songmanager) -# self.song_book_form = SongBookForm(self.songmanager) self.verse_form = EditVerseForm() self.initialise() self.AuthorsListView.setSortingEnabled(False) @@ -253,30 +246,6 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog): row = self.TopicsListView.row(item) self.TopicsListView.takeItem(row) -# def onAddAuthorsButtonClicked(self): -# """ -# Slot documentation goes here. -# """ -# self.authors_form.load_form() -# self.authors_form.exec_() -# self.loadAuthors() -# -# def onAddTopicButtonClicked(self): -# """ -# Slot documentation goes here. -# """ -# self.topics_form.load_form() -# self.topics_form.exec_() -# self.loadTopics() -# -# def onAddSongBookButtonClicked(self): -# """ -# Slot documentation goes here. -# """ -# self.song_book_form.load_form() -# self.song_book_form.exec_() -# self.loadBooks() - def onSongBookComboChanged(self, item): if item == 0: self.song.song_book_id = 0 From 5ccf0581deae690ed6cf4671e60c87d80c669bd4 Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Mon, 3 Aug 2009 20:49:21 +0100 Subject: [PATCH 9/9] Change xml handling to work with Normal/Bold and True --- openlp/core/lib/renderer.py | 16 +++++++---- openlp/core/lib/themexmlhandler.py | 21 ++++++++------ openlp/core/ui/amendthemeform.py | 44 +++++++++++++++--------------- 3 files changed, 44 insertions(+), 37 deletions(-) diff --git a/openlp/core/lib/renderer.py b/openlp/core/lib/renderer.py index d6ef78434..61558de8b 100644 --- a/openlp/core/lib/renderer.py +++ b/openlp/core/lib/renderer.py @@ -556,17 +556,21 @@ class Renderer(object): """ Set the fonts from the current theme settings. """ + footer_weight = 50 + if self._theme.font_footer_weight == u'Bold': + footer_weight = 75 self.footerFont = QtGui.QFont(self._theme.font_footer_name, int(self._theme.font_footer_proportion), # size - int(self._theme.font_footer_weight), # weight - 0)# italic - self.footerFont.setItalic(int(self._theme.font_footer_italics)) + int(footer_weight), # weight + self._theme.font_footer_italics)# italic self.footerFont.setPixelSize(int(self._theme.font_footer_proportion)) + main_weight = 50 + if self._theme.font_main_weight == u'Bold': + main_weight = 75 self.mainFont = QtGui.QFont(self._theme.font_main_name, int(self._theme.font_main_proportion), # size - int(self._theme.font_main_weight), # weight - 0)# italic - self.mainFont.setItalic(int(self._theme.font_main_italics)) + int(main_weight), # weight + self._theme.font_main_italics)# italic self.mainFont.setPixelSize(int(self._theme.font_main_proportion)) def _get_extent_and_render(self, line, footer, tlcorner=(0, 0), draw=False, color=None): diff --git a/openlp/core/lib/themexmlhandler.py b/openlp/core/lib/themexmlhandler.py index e8a33aade..c5ba6ff99 100644 --- a/openlp/core/lib/themexmlhandler.py +++ b/openlp/core/lib/themexmlhandler.py @@ -46,16 +46,16 @@ blankthemexml=\ Arial #000000 30 - 50 - 0 + Normal + False Arial #000000 12 - 50 - 0 + Normal + False @@ -161,7 +161,7 @@ class ThemeXML(object): #Create Filename element self.child_element(background, u'filename', filename) - def add_font(self, name, color, proportion, override, fonttype=u'main', weight=u'50', italics=u'0', + def add_font(self, name, color, proportion, override, fonttype=u'main', weight=u'Bold', italics=False, xpos=0, ypos=0, width=0, height=0): """ Add a Font. @@ -341,14 +341,17 @@ class ThemeXML(object): setattr(self, master + element.tag + u'_'+ e[0], e[1]) else: field = master + e[0] - e1 = e[1] if e[1] == u'True' or e[1] == u'False': - e1 = str_to_bool(e[1]) - setattr(self, field, e1) + setattr(self, field, str_to_bool(e[1])) + else: + setattr(self, field, e[1]) else: if element.tag is not None: field = master + element.tag - setattr(self, field, element.text) + if element.text == u'True' or element.text == u'False': + setattr(self, field, str_to_bool(element.text)) + else: + setattr(self, field, element.text) def __str__(self): """ diff --git a/openlp/core/ui/amendthemeform.py b/openlp/core/ui/amendthemeform.py index fd966f54e..f22c9212a 100644 --- a/openlp/core/ui/amendthemeform.py +++ b/openlp/core/ui/amendthemeform.py @@ -166,17 +166,17 @@ class AmendThemeForm(QtGui.QDialog, Ui_AmendThemeDialog): def onFontMainWeightComboBoxSelected(self, value): if value ==0: - self.theme.font_main_weight = 50 - self.theme.font_main_italics = 0 + self.theme.font_main_weight = u'Normal' + self.theme.font_main_italics = False elif value == 1: - self.theme.font_main_weight = 75 - self.theme.font_main_italics = 0 + self.theme.font_main_weight = u'Bold' + self.theme.font_main_italics = False elif value == 2: - self.theme.font_main_weight = 50 - self.theme.font_main_italics = 1 + self.theme.font_main_weight = u'Normal' + self.theme.font_main_italics = True else: - self.theme.font_main_weight = 75 - self.theme.font_main_italics = 1 + self.theme.font_main_weight = u'Bold' + self.theme.font_main_italics = True self.previewTheme(self.theme) def onFontMainColorPushButtonClicked(self): @@ -239,17 +239,17 @@ class AmendThemeForm(QtGui.QDialog, Ui_AmendThemeDialog): def onFontFooterWeightComboBoxSelected(self, value): if value == 0: - self.theme.font_footer_weight = 50 - self.theme.font_footer_italics = 0 + self.theme.font_footer_weight = u'Normal' + self.theme.font_footer_italics = False elif value == 1: - self.theme.font_footer_weight = 75 - self.theme.font_footer_italics = 0 + self.theme.font_footer_weight = u'Bold' + self.theme.font_footer_italics = False elif value == 2: - self.theme.font_footer_weight = 50 - self.theme.font_footer_italics = 1 + self.theme.font_footer_weight = u'Normal' + self.theme.font_footer_italics = True else: - self.theme.font_footer_weight = 75 - self.theme.font_footer_italics = 1 + self.theme.font_footer_weight = u'Bold' + self.theme.font_footer_italics = True self.previewTheme(self.theme) def onFontFooterColorPushButtonClicked(self): @@ -445,11 +445,11 @@ class AmendThemeForm(QtGui.QDialog, Ui_AmendThemeDialog): self.GradientComboBox.setCurrentIndex(2) self.FontMainSizeSpinBox.setValue(int(self.theme.font_main_proportion)) - if int(self.theme.font_main_italics) == 0 and int(self.theme.font_main_weight) == 50: + if not self.theme.font_main_italics and self.theme.font_main_weight == u'Normal': self.FontMainWeightComboBox.setCurrentIndex(0) - elif int(self.theme.font_main_italics) == 0 and int(self.theme.font_main_weight) == 75: + elif not self.theme.font_main_italics and self.theme.font_main_weight == u'Bold': self.FontMainWeightComboBox.setCurrentIndex(1) - elif int(self.theme.font_main_italics) == 1 and int(self.theme.font_main_weight) == 50: + elif self.theme.font_main_italics and self.theme.font_main_weight == u'Normal': self.FontMainWeightComboBox.setCurrentIndex(2) else: self.FontMainWeightComboBox.setCurrentIndex(3) @@ -459,11 +459,11 @@ class AmendThemeForm(QtGui.QDialog, Ui_AmendThemeDialog): self.FontMainWidthSpinBox.setValue(int(self.theme.font_main_width)) self.FontMainHeightSpinBox.setValue(int(self.theme.font_main_height)) self.FontFooterSizeSpinBox.setValue(int(self.theme.font_footer_proportion)) - if int(self.theme.font_footer_italics) == 0 and int(self.theme.font_footer_weight) == 50: + if not self.theme.font_footer_italics and self.theme.font_footer_weight == u'Normal': self.FontFooterWeightComboBox.setCurrentIndex(0) - elif int(self.theme.font_footer_italics) == 0 and int(self.theme.font_footer_weight) == 75: + elif not self.theme.font_footer_italics and self.theme.font_footer_weight == u'Bold': self.FontFooterWeightComboBox.setCurrentIndex(1) - elif int(self.theme.font_footer_italics) == 1 and int(self.theme.font_footer_weight) == 50: + elif self.theme.font_footer_italics and self.theme.font_footer_weight == u'Normal': self.FontFooterWeightComboBox.setCurrentIndex(2) else: self.FontFooterWeightComboBox.setCurrentIndex(3)