From 2136155f48beed8df3fe268c6bd3559691e55df7 Mon Sep 17 00:00:00 2001 From: Jon Tibble Date: Wed, 4 Nov 2009 01:16:15 +0000 Subject: [PATCH] Fix theme loading and song editing --- openlp/core/lib/mediamanageritem.py | 1 - openlp/core/lib/renderer.py | 14 +-- openlp/core/lib/rendermanager.py | 13 ++- openlp/core/ui/amendthemeform.py | 113 ++++++++++----------- openlp/core/ui/slidecontroller.py | 9 +- openlp/core/ui/thememanager.py | 23 +++-- openlp/plugins/songs/forms/editsongform.py | 6 +- openlp/plugins/songs/lib/mediaitem.py | 34 ++++++- 8 files changed, 124 insertions(+), 89 deletions(-) diff --git a/openlp/core/lib/mediamanageritem.py b/openlp/core/lib/mediamanageritem.py index f5930944b..d18bb5843 100644 --- a/openlp/core/lib/mediamanageritem.py +++ b/openlp/core/lib/mediamanageritem.py @@ -403,7 +403,6 @@ class MediaManagerItem(QtGui.QWidget): service_item.addIcon( u':/media/media_' + self.PluginNameShort.lower() + u'.png') if self.generateSlideData(service_item): - self.ListView.clearSelection() return service_item else: return None diff --git a/openlp/core/lib/renderer.py b/openlp/core/lib/renderer.py index f7e59c099..4ca653303 100644 --- a/openlp/core/lib/renderer.py +++ b/openlp/core/lib/renderer.py @@ -410,7 +410,7 @@ class Renderer(object): align = 0 shadow_offset = self._shadow_offset_footer else: - align = int(self._theme .display_horizontalAlign) + align = self._theme.display_horizontalAlign shadow_offset = self._shadow_offset for linenum in range(len(lines)): line = lines[linenum] @@ -501,18 +501,18 @@ class Renderer(object): 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(footer_weight), # weight + self._theme.font_footer_proportion, # size + footer_weight, # weight self._theme.font_footer_italics) # italic - self.footerFont.setPixelSize(int(self._theme.font_footer_proportion)) + self.footerFont.setPixelSize(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(main_weight), # weight + self._theme.font_main_proportion, # size + main_weight, # weight self._theme.font_main_italics)# italic - self.mainFont.setPixelSize(int(self._theme.font_main_proportion)) + self.mainFont.setPixelSize(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/rendermanager.py b/openlp/core/lib/rendermanager.py index eb36aa473..d4463ea21 100644 --- a/openlp/core/lib/rendermanager.py +++ b/openlp/core/lib/rendermanager.py @@ -170,16 +170,15 @@ class RenderManager(object): main_rect = QtCore.QRect(10, 0, self.width - 1, self.footer_start - 20) else: - main_rect = QtCore.QRect(int(theme.font_main_x), - int(theme.font_main_y), int(theme.font_main_width)-1, - int(theme.font_main_height) - 1) + main_rect = QtCore.QRect(theme.font_main_x, theme.font_main_y, + theme.font_main_width - 1, theme.font_main_height - 1) if not theme.font_footer_override: - footer_rect = QtCore.QRect(10,self.footer_start, self.width - 1, + footer_rect = QtCore.QRect(10, self.footer_start, self.width - 1, self.height-self.footer_start) else: - footer_rect = QtCore.QRect(int(theme.font_footer_x), - int(theme.font_footer_y), int(theme.font_footer_width)-1, - int(theme.font_footer_height) - 1) + footer_rect = QtCore.QRect(theme.font_footer_x, + theme.font_footer_y, theme.font_footer_width - 1, + theme.font_footer_height - 1) self.renderer.set_text_rectangle(main_rect, footer_rect) def generate_preview(self, themedata): diff --git a/openlp/core/ui/amendthemeform.py b/openlp/core/ui/amendthemeform.py index cf1e6f9e6..2723c17d8 100644 --- a/openlp/core/ui/amendthemeform.py +++ b/openlp/core/ui/amendthemeform.py @@ -246,21 +246,18 @@ class AmendThemeForm(QtGui.QDialog, Ui_AmendThemeDialog): else: self.theme.font_main_override = True - if int(self.theme.font_main_x) == 0 and \ - int(self.theme.font_main_y) == 0 and \ - int(self.theme.font_main_width) == 0 and \ - int(self.theme.font_main_height) == 0: + if not self.theme.font_main_x and not self.theme.font_main_y and \ + not self.theme.font_main_width and not self.theme.font_main_height: self.theme.font_main_x = u'10' self.theme.font_main_y = u'10' self.theme.font_main_width = u'1024' self.theme.font_main_height = u'730' - 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.FontMainLineSpacingSpinBox.setValue(int( \ - self.theme.font_main_indentation)) + self.FontMainXSpinBox.setValue(self.theme.font_main_x) + self.FontMainYSpinBox.setValue(self.theme.font_main_y) + self.FontMainWidthSpinBox.setValue(self.theme.font_main_width) + self.FontMainHeightSpinBox.setValue(self.theme.font_main_height) + self.FontMainLineSpacingSpinBox.setValue( + self.theme.font_main_indentation) self.stateChanging(self.theme) self.previewTheme(self.theme) @@ -280,8 +277,10 @@ class AmendThemeForm(QtGui.QDialog, Ui_AmendThemeDialog): self.previewTheme(self.theme) def onFontMainLineSpacingSpinBoxChanged(self): - if self.theme.font_main_indentation != self.FontMainLineSpacingSpinBox.value(): - self.theme.font_main_indentation = self.FontMainLineSpacingSpinBox.value() + if self.theme.font_main_indentation != \ + self.FontMainLineSpacingSpinBox.value(): + self.theme.font_main_indentation = \ + self.FontMainLineSpacingSpinBox.value() self.previewTheme(self.theme) def onFontMainHeightSpinBoxChanged(self): @@ -331,23 +330,18 @@ class AmendThemeForm(QtGui.QDialog, Ui_AmendThemeDialog): self.theme.font_footer_override = False else: self.theme.font_footer_override = True - - if int(self.theme.font_footer_x) == 0 and \ - int(self.theme.font_footer_y) == 0 and \ - int(self.theme.font_footer_width) == 0 and \ - int(self.theme.font_footer_height) == 0: + if not self.theme.font_footer_x and not self.theme.font_footer_y and \ + not self.theme.font_footer_width and \ + not self.theme.font_footer_height: self.theme.font_footer_x = u'10' self.theme.font_footer_y = u'730' self.theme.font_footer_width = u'1024' self.theme.font_footer_height = u'38' - - 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)) - self.FontFooterHeightSpinBox.setValue(int( \ - self.theme.font_footer_height)) - + self.FontFooterXSpinBox.setValue(self.theme.font_footer_x) + self.FontFooterYSpinBox.setValue(self.theme.font_footer_y) + self.FontFooterWidthSpinBox.setValue(self.theme.font_footer_width) + self.FontFooterHeightSpinBox.setValue( + self.theme.font_footer_height) self.stateChanging(self.theme) self.previewTheme(self.theme) @@ -369,7 +363,8 @@ class AmendThemeForm(QtGui.QDialog, Ui_AmendThemeDialog): def onFontFooterHeightSpinBoxChanged(self): if self.theme.font_footer_height != \ self.FontFooterHeightSpinBox.value(): - self.theme.font_footer_height = self.FontFooterHeightSpinBox.value() + self.theme.font_footer_height = \ + self.FontFooterHeightSpinBox.value() self.previewTheme(self.theme) # #Background Tab @@ -502,7 +497,7 @@ class AmendThemeForm(QtGui.QDialog, Ui_AmendThemeDialog): # Font Main Tab self.FontMainComboBox.setCurrentFont( QtGui.QFont(self.theme.font_main_name)) - self.FontMainSizeSpinBox.setValue(int(self.theme.font_main_proportion)) + self.FontMainSizeSpinBox.setValue(self.theme.font_main_proportion) if not self.theme.font_main_italics and \ self.theme.font_main_weight == u'Normal': self.FontMainWeightComboBox.setCurrentIndex(0) @@ -514,16 +509,17 @@ class AmendThemeForm(QtGui.QDialog, Ui_AmendThemeDialog): self.FontMainWeightComboBox.setCurrentIndex(2) else: self.FontMainWeightComboBox.setCurrentIndex(3) - self.FontMainLineSpacingSpinBox.setValue(int(self.theme.font_main_indentation)) - 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.FontMainLineSpacingSpinBox.setValue( + self.theme.font_main_indentation) + self.FontMainXSpinBox.setValue(self.theme.font_main_x) + self.FontMainYSpinBox.setValue(self.theme.font_main_y) + self.FontMainWidthSpinBox.setValue(self.theme.font_main_width) + self.FontMainHeightSpinBox.setValue(self.theme.font_main_height) # Font Footer Tab self.FontFooterComboBox.setCurrentFont( QtGui.QFont(self.theme.font_footer_name)) self.FontFooterSizeSpinBox.setValue( - int(self.theme.font_footer_proportion)) + self.theme.font_footer_proportion) if not self.theme.font_footer_italics and \ self.theme.font_footer_weight == u'Normal': self.FontFooterWeightComboBox.setCurrentIndex(0) @@ -535,11 +531,10 @@ class AmendThemeForm(QtGui.QDialog, Ui_AmendThemeDialog): 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)) - self.FontFooterHeightSpinBox.setValue( - int(self.theme.font_footer_height)) + self.FontFooterXSpinBox.setValue(self.theme.font_footer_x) + self.FontFooterYSpinBox.setValue(self.theme.font_footer_y) + self.FontFooterWidthSpinBox.setValue(self.theme.font_footer_width) + self.FontFooterHeightSpinBox.setValue(self.theme.font_footer_height) self.FontMainColorPushButton.setStyleSheet( u'background-color: %s' % unicode(theme.font_main_color)) self.FontFooterColorPushButton.setStyleSheet( @@ -575,23 +570,22 @@ class AmendThemeForm(QtGui.QDialog, Ui_AmendThemeDialog): self.ShadowColorPushButton.setEnabled(False) self.HorizontalComboBox.setCurrentIndex( - int(self.theme.display_horizontalAlign)) - self.VerticalComboBox.setCurrentIndex( - int(self.theme.display_verticalAlign)) + self.theme.display_horizontalAlign) + self.VerticalComboBox.setCurrentIndex(self.theme.display_verticalAlign) def stateChanging(self, theme): if theme.background_mode == u'transparent': - self.Color1Label.setVisible(False) - self.Color1PushButton.setVisible(False) - self.Color2Label.setVisible(False) - self.Color2PushButton.setVisible(False) - self.ImageLabel.setVisible(False) - self.ImageLineEdit.setVisible(False) - self.ImageFilenameWidget.setVisible(False) - self.GradientLabel.setVisible(False) - self.GradientComboBox.setVisible(False) - self.BackgroundTypeComboBox.setVisible(False) - self.BackgroundTypeLabel.setVisible(False) + self.Color1Label.setVisible(False) + self.Color1PushButton.setVisible(False) + self.Color2Label.setVisible(False) + self.Color2PushButton.setVisible(False) + self.ImageLabel.setVisible(False) + self.ImageLineEdit.setVisible(False) + self.ImageFilenameWidget.setVisible(False) + self.GradientLabel.setVisible(False) + self.GradientComboBox.setVisible(False) + self.BackgroundTypeComboBox.setVisible(False) + self.BackgroundTypeLabel.setVisible(False) else: self.BackgroundTypeComboBox.setVisible(True) self.BackgroundTypeLabel.setVisible(True) @@ -674,15 +668,18 @@ class AmendThemeForm(QtGui.QDialog, Ui_AmendThemeDialog): if self.theme.font_main_weight == u'Bold': main_weight = 75 mainFont = QtGui.QFont(self.theme.font_main_name, - int(self.theme.font_main_proportion), # size - int(main_weight), # weight + self.theme.font_main_proportion, # size + main_weight, # weight self.theme.font_main_italics)# italic - mainFont.setPixelSize(int(self.theme.font_main_proportion)) + mainFont.setPixelSize(self.theme.font_main_proportion) metrics = QtGui.QFontMetrics(mainFont) - page_length = (int(self.FontMainHeightSpinBox.value()) / metrics.height() - 2) - 1 + page_length = \ + (self.FontMainHeightSpinBox.value() / metrics.height() - 2) - 1 log.debug(u'Page Length area height %s, metrics %s, lines %s' % - (int(self.FontMainHeightSpinBox.value()), metrics.height(), page_length)) + (self.FontMainHeightSpinBox.value(), metrics.height(), + page_length)) page_length_text = unicode(self.trUtf8(u'Slide Height is %s rows')) self.FontMainLinesPageLabel.setText(page_length_text % page_length) frame = self.thememanager.generateImage(theme) self.ThemePreview.setPixmap(QtGui.QPixmap.fromImage(frame)) + diff --git a/openlp/core/ui/slidecontroller.py b/openlp/core/ui/slidecontroller.py index 1697ac3f4..efd523c82 100644 --- a/openlp/core/ui/slidecontroller.py +++ b/openlp/core/ui/slidecontroller.py @@ -100,9 +100,11 @@ class SlideController(QtGui.QWidget): # Type label for the top of the slide controller self.TypeLabel = QtGui.QLabel(self.Panel) if self.isLive: - self.TypeLabel.setText(u'%s' % self.trUtf8(u'Live')) + self.TypeLabel.setText(u'%s' % + self.trUtf8(u'Live')) else: - self.TypeLabel.setText(u'%s' % self.trUtf8(u'Preview')) + self.TypeLabel.setText(u'%s' % + self.trUtf8(u'Preview')) self.TypeLabel.setAlignment(QtCore.Qt.AlignCenter) self.PanelLayout.addWidget(self.TypeLabel) # Splitter @@ -126,7 +128,8 @@ class SlideController(QtGui.QWidget): self.PreviewListWidget.setColumnWidth(1, self.Controller.width()) self.PreviewListWidget.isLive = self.isLive self.PreviewListWidget.setObjectName(u'PreviewListWidget') - self.PreviewListWidget.setEditTriggers(QtGui.QAbstractItemView.NoEditTriggers) + self.PreviewListWidget.setEditTriggers( + QtGui.QAbstractItemView.NoEditTriggers) self.ControllerLayout.addWidget(self.PreviewListWidget) # Build the full toolbar self.Toolbar = OpenLPToolbar(self) diff --git a/openlp/core/ui/thememanager.py b/openlp/core/ui/thememanager.py index e6f5e11e6..a55f39fd3 100644 --- a/openlp/core/ui/thememanager.py +++ b/openlp/core/ui/thememanager.py @@ -475,7 +475,8 @@ class ThemeManager(QtGui.QWidget): #theme.background_type if theme.display_display: theme.display_display = theme.display_display.strip() - theme.display_horizontalAlign = theme.display_horizontalAlign.strip() + theme.display_horizontalAlign = \ + int(theme.display_horizontalAlign.strip()) theme.display_outline = str_to_bool(theme.display_outline) #theme.display_outline_color theme.display_shadow = str_to_bool(theme.display_shadow) @@ -483,25 +484,27 @@ class ThemeManager(QtGui.QWidget): theme.display_verticalAlign = int(theme.display_verticalAlign.strip()) theme.display_wrapStyle = theme.display_wrapStyle.strip() theme.font_footer_color = theme.font_footer_color.strip() - theme.font_footer_height = theme.font_footer_height.strip() + theme.font_footer_height = int(theme.font_footer_height.strip()) theme.font_footer_italics = str_to_bool(theme.font_footer_italics) theme.font_footer_name = theme.font_footer_name.strip() #theme.font_footer_override - theme.font_footer_proportion = theme.font_footer_proportion.strip() + theme.font_footer_proportion = \ + int(theme.font_footer_proportion.strip()) theme.font_footer_weight = theme.font_footer_weight.strip() - theme.font_footer_width = theme.font_footer_width.strip() - theme.font_footer_x = theme.font_footer_x.strip() - theme.font_footer_y = theme.font_footer_y.strip() + theme.font_footer_width = int(theme.font_footer_width.strip()) + theme.font_footer_x = int(theme.font_footer_x.strip()) + theme.font_footer_y = int(theme.font_footer_y.strip()) theme.font_main_color = theme.font_main_color.strip() - theme.font_main_height = theme.font_main_height.strip() + theme.font_main_height = int(theme.font_main_height.strip()) theme.font_main_italics = str_to_bool(theme.font_main_italics) theme.font_main_indentation = int(theme.font_main_indentation) theme.font_main_name = theme.font_main_name.strip() #theme.font_main_override - theme.font_main_proportion = theme.font_main_proportion.strip() + theme.font_main_proportion = int(theme.font_main_proportion.strip()) theme.font_main_weight = theme.font_main_weight.strip() - theme.font_main_x = theme.font_main_x.strip() - theme.font_main_y = theme.font_main_y.strip() + theme.font_main_width = int(theme.font_main_width.strip()) + theme.font_main_x = int(theme.font_main_x.strip()) + theme.font_main_y = int(theme.font_main_y.strip()) #theme.theme_mode theme.theme_name = theme.theme_name.strip() #theme.theme_version diff --git a/openlp/plugins/songs/forms/editsongform.py b/openlp/plugins/songs/forms/editsongform.py index b6b54a381..96a5021be 100644 --- a/openlp/plugins/songs/forms/editsongform.py +++ b/openlp/plugins/songs/forms/editsongform.py @@ -66,7 +66,8 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog): QtCore.QObject.connect(self.VerseAddButton, QtCore.SIGNAL(u'clicked()'), self.onVerseAddButtonClicked) QtCore.QObject.connect(self.VerseListWidget, - QtCore.SIGNAL(u'doubleClicked(QModelIndex)'), self.onVerseEditButtonClicked) + QtCore.SIGNAL(u'doubleClicked(QModelIndex)'), + self.onVerseEditButtonClicked) QtCore.QObject.connect(self.VerseEditButton, QtCore.SIGNAL(u'clicked()'), self.onVerseEditButtonClicked) QtCore.QObject.connect(self.VerseEditAllButton, @@ -463,7 +464,8 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog): self.song.search_lyrics = unicode(text) self.song.lyrics = unicode(sxml.extract_xml()) except: - log.exception(u'Problem processing song Lyrics \n%s', sxml.dump_xml()) + log.exception(u'Problem processing song Lyrics \n%s', + sxml.dump_xml()) def processTitle(self): log.debug(u'processTitle') diff --git a/openlp/plugins/songs/lib/mediaitem.py b/openlp/plugins/songs/lib/mediaitem.py index b9efe7845..a859bfabc 100644 --- a/openlp/plugins/songs/lib/mediaitem.py +++ b/openlp/plugins/songs/lib/mediaitem.py @@ -131,7 +131,7 @@ class SongMediaItem(MediaManagerItem): QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'%s_edit' % self.parent.name), self.onRemoteEdit) QtCore.QObject.connect(Receiver.get_receiver(), - QtCore.SIGNAL(u'remote_edit_clear' ), self.onRemoteEditClear) + QtCore.SIGNAL(u'remote_edit_clear'), self.onRemoteEditClear) def configUpdated(self): self.searchAsYouType = str_to_bool( @@ -322,3 +322,35 @@ class SongMediaItem(MediaManagerItem): song.title, author_audit, song.copyright, song.ccli_number ] return True + + def onPreviewClick(self): + if not self.remoteTriggered: + MediaManagerItem.onPreviewClick(self) + else: + log.debug(self.PluginNameShort + u' Preview Requested') + service_item = self.buildServiceItem() + if service_item: + service_item.fromPlugin = True + self.parent.preview_controller.addServiceItem(service_item) + + def onLiveClick(self): + if not self.remoteTriggered: + MediaManagerItem.onLiveClick(self) + else: + log.debug(self.PluginNameShort + u' Live Requested') + service_item = self.buildServiceItem() + if service_item: + service_item.fromPlugin = True + service_item.uuid = unicode(uuid.uuid1()) + self.parent.live_controller.addServiceItem(service_item) + + def onAddClick(self): + if not self.remoteTriggered: + MediaManagerItem.onAddClick(self) + else: + log.debug(self.PluginNameShort + u' Add Requested') + service_item = self.buildServiceItem() + if service_item: + service_item.fromPlugin = False + service_item.uuid = unicode(uuid.uuid1()) + self.parent.service_manager.addServiceItem(service_item)