From 38615ca5c9643a8d4634f0650c0a40d096e98411 Mon Sep 17 00:00:00 2001 From: Jon Tibble Date: Wed, 4 Nov 2009 01:32:13 +0000 Subject: [PATCH 01/63] Core refactoring 0 --- openlp/core/lib/renderer.py | 30 ++++++++++++++------- openlp/core/lib/rendermanager.py | 43 +++++++------------------------ openlp/core/ui/slidecontroller.py | 15 +++++++---- openlp/core/ui/thememanager.py | 27 ++++++++++++------- 4 files changed, 58 insertions(+), 57 deletions(-) diff --git a/openlp/core/lib/renderer.py b/openlp/core/lib/renderer.py index bc5c09554..698e165bf 100644 --- a/openlp/core/lib/renderer.py +++ b/openlp/core/lib/renderer.py @@ -40,6 +40,7 @@ class Renderer(object): Initialise the renderer. """ self._rect = None + self._footer_rect = None self._debug = 0 self._right_margin = 64 # the amount of right indent self._shadow_offset = 5 @@ -215,18 +216,29 @@ class Renderer(object): split_pages.append(page) return split_pages - def set_text_rectangle(self, rect_main, rect_footer): + def build_text_rectangle(self, theme): """ - Sets the rectangle within which text should be rendered. + Builds a text block using the settings in ``theme``. + One is needed per slide - ``rect_main`` - The main text block. - - ``rect_footer`` - The footer text block. + ``theme`` + The theme to build a text block for. """ - self._rect = rect_main - self._rect_footer = rect_footer + log.debug(u'build_text_rectangle') + if theme.font_main_override == False: + self._rect = QtCore.QRect(10, 0, self.width - 1, + self.footer_start - 20) + else: + self._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) + if theme.font_footer_override == False: + self._footer_rect = QtCore.QRect(10,self.footer_start, self.width - 1, + self.height-self.footer_start) + else: + self._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) def generate_frame_from_lines(self, lines, footer_lines=None): """ diff --git a/openlp/core/lib/rendermanager.py b/openlp/core/lib/rendermanager.py index 50abcfd07..ae3a5316c 100644 --- a/openlp/core/lib/rendermanager.py +++ b/openlp/core/lib/rendermanager.py @@ -137,49 +137,24 @@ class RenderManager(object): self.calculate_default( self.screen_list[self.current_display][u'size']) self.renderer.set_theme(self.themedata) - self.build_text_rectangle(self.themedata) + self.renderer.build_text_rectangle(self.themedata) #Replace the backgrount image from renderer with one from image if self.override_background is not None: if self.save_bg_frame is None: self.save_bg_frame = self.renderer.bg_frame if self.override_background_changed: - self.renderer.bg_frame = self.resize_image(self.override_background) + self.renderer.bg_frame = self.resize_image( + self.override_background) self.override_background_changed = False else: if self.override_background_changed: - self.renderer.bg_frame = self.resize_image(self.override_background) + self.renderer.bg_frame = self.resize_image( + self.override_background) self.override_background_changed = False if self.save_bg_frame is not None: self.renderer.bg_frame = self.save_bg_frame self.save_bg_frame = None - def build_text_rectangle(self, theme): - """ - Builds a text block using the settings in ``theme``. - One is needed per slide - - ``theme`` - The theme to build a text block for. - """ - log.debug(u'build_text_rectangle') - main_rect = None - footer_rect = None - if theme.font_main_override == False: - 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) - if theme.font_footer_override == False: - 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) - self.renderer.set_text_rectangle(main_rect, footer_rect) - def generate_preview(self, themedata): """ Generate a preview of a theme. @@ -190,7 +165,7 @@ class RenderManager(object): log.debug(u'generate preview') self.calculate_default(QtCore.QSize(1024, 768)) self.renderer.set_theme(themedata) - self.build_text_rectangle(themedata) + self.renderer.build_text_rectangle(themedata) self.renderer.set_frame_dest(self.width, self.height, True) verse = [] verse.append(u'Amazing Grace!') @@ -212,7 +187,7 @@ class RenderManager(object): The words to go on the slides. """ log.debug(u'format slide') - self.build_text_rectangle(self.themedata) + self.renderer.build_text_rectangle(self.themedata) return self.renderer.format_slide(words, False) def generate_slide(self, main_text, footer_text): @@ -226,7 +201,7 @@ class RenderManager(object): The text for the slide footer. """ log.debug(u'generate slide') - self.build_text_rectangle(self.themedata) + self.renderer.build_text_rectangle(self.themedata) self.renderer.set_frame_dest(self.width, self.height) return self.renderer.generate_frame_from_lines(main_text, footer_text) @@ -246,7 +221,7 @@ class RenderManager(object): h = height preview = preview.scaled(w, h, QtCore.Qt.KeepAspectRatio, QtCore.Qt.SmoothTransformation) - realw = preview.width(); + realw = preview.width() realh = preview.height() # and move it to the centre of the preview space newImage = QtGui.QImage(w, h, QtGui.QImage.Format_ARGB32_Premultiplied) diff --git a/openlp/core/ui/slidecontroller.py b/openlp/core/ui/slidecontroller.py index 0aefd5537..3c4c70ee2 100644 --- a/openlp/core/ui/slidecontroller.py +++ b/openlp/core/ui/slidecontroller.py @@ -448,9 +448,11 @@ class SlideController(QtGui.QWidget): if self.commandItem is not None and \ self.commandItem.service_item_type == ServiceItemType.Command: if blanked: - Receiver().send_message(u'%s_blank'% self.commandItem.name.lower()) + Receiver().send_message( + u'%s_blank' % self.commandItem.name.lower()) else: - Receiver().send_message(u'%s_unblank'% self.commandItem.name.lower()) + Receiver().send_message( + u'%s_unblank' % self.commandItem.name.lower()) else: self.parent.mainDisplay.blankDisplay() @@ -463,7 +465,8 @@ class SlideController(QtGui.QWidget): self.row = 0 if row > -1 and row < self.PreviewListWidget.rowCount(): if self.commandItem.service_item_type == ServiceItemType.Command: - Receiver().send_message(u'%s_slide'% self.commandItem.name.lower(), [row]) + Receiver().send_message( + u'%s_slide'% self.commandItem.name.lower(), [row]) if self.isLive: QtCore.QTimer.singleShot(0.5, self.grabMainDisplay) else: @@ -489,10 +492,12 @@ class SlideController(QtGui.QWidget): if not rm.screen_list[rm.current_display][u'primary']: winid = QtGui.QApplication.desktop().winId() rect = rm.screen_list[rm.current_display][u'size'] - winimg = QtGui.QPixmap.grabWindow(winid, rect.x(), rect.y(), rect.width(), rect.height()) + winimg = QtGui.QPixmap.grabWindow( + winid, rect.x(), rect.y(), rect.width(), rect.height()) self.SlidePreview.setPixmap(winimg) else: - label = self.PreviewListWidget.cellWidget(self.PreviewListWidget.currentRow(), 0) + label = self.PreviewListWidget.cellWidget( + self.PreviewListWidget.currentRow(), 0) self.SlidePreview.setPixmap(label.pixmap()) def onSlideSelectedNext(self): diff --git a/openlp/core/ui/thememanager.py b/openlp/core/ui/thememanager.py index 9956023c3..ae3cee598 100644 --- a/openlp/core/ui/thememanager.py +++ b/openlp/core/ui/thememanager.py @@ -78,17 +78,25 @@ class ThemeManager(QtGui.QWidget): self.ThemeListWidget.addAction( contextMenuAction(self.ThemeListWidget, u':/themes/theme_edit.png', self.trUtf8(u'Edit a theme'), self.onEditTheme)) - self.ThemeListWidget.addAction(contextMenuSeparator(self.ThemeListWidget)) self.ThemeListWidget.addAction( - contextMenuAction(self.ThemeListWidget, u':/themes/theme_delete.png', - self.trUtf8(u'Delete theme'), self.onDeleteTheme)) + contextMenuSeparator(self.ThemeListWidget)) self.ThemeListWidget.addAction( - contextMenuAction(self.ThemeListWidget, u':/themes/theme_export.png', - self.trUtf8(u'Make Global'), self.changeGlobalFromScreen)) + contextMenuAction(self.ThemeListWidget, + u':/themes/theme_delete.png', + self.trUtf8(u'Delete theme'), + self.onDeleteTheme)) self.ThemeListWidget.addAction( - contextMenuAction(self.ThemeListWidget, u':/themes/theme_export.png', - self.trUtf8(u'Export theme'), self.onExportTheme)) - self.ThemeListWidget.addAction(contextMenuSeparator(self.ThemeListWidget)) + contextMenuAction(self.ThemeListWidget, + u':/themes/theme_export.png', + self.trUtf8(u'Make Global'), + self.changeGlobalFromScreen)) + self.ThemeListWidget.addAction( + contextMenuAction(self.ThemeListWidget, + u':/themes/theme_export.png', + self.trUtf8(u'Export theme'), + self.onExportTheme)) + self.ThemeListWidget.addAction( + contextMenuSeparator(self.ThemeListWidget)) #Signals QtCore.QObject.connect(self.ThemeListWidget, QtCore.SIGNAL(u'doubleClicked(QModelIndex)'), @@ -151,7 +159,8 @@ class ThemeManager(QtGui.QWidget): if item is not None: self.amendThemeForm.loadTheme( unicode(item.data(QtCore.Qt.UserRole).toString())) - self.saveThemeName = unicode(item.data(QtCore.Qt.UserRole).toString()) + self.saveThemeName = unicode( + item.data(QtCore.Qt.UserRole).toString()) self.amendThemeForm.exec_() def onDeleteTheme(self): From e463e83ed5238f86350266582255b9cfd5a845a5 Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Mon, 19 Apr 2010 17:45:13 +0100 Subject: [PATCH 02/63] Icon fixes --- openlp/core/lib/mediamanageritem.py | 5 ++++- openlp/plugins/images/lib/mediaitem.py | 6 ++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/openlp/core/lib/mediamanageritem.py b/openlp/core/lib/mediamanageritem.py index 7ac2a6f0a..fdc81092f 100644 --- a/openlp/core/lib/mediamanageritem.py +++ b/openlp/core/lib/mediamanageritem.py @@ -362,6 +362,9 @@ class MediaManagerItem(QtGui.QWidget): #if file updated rebuild icon if filedate > thumbdate: self.IconFromFile(file, thumb) + if os.path.exists(file): + return True + return False def IconFromFile(self, file, thumb): icon = build_icon(unicode(file)) @@ -471,4 +474,4 @@ class MediaManagerItem(QtGui.QWidget): if self.generateSlideData(service_item, item): return service_item else: - return None \ No newline at end of file + return None diff --git a/openlp/plugins/images/lib/mediaitem.py b/openlp/plugins/images/lib/mediaitem.py index 6fbf66022..914a6ce20 100644 --- a/openlp/plugins/images/lib/mediaitem.py +++ b/openlp/plugins/images/lib/mediaitem.py @@ -124,8 +124,10 @@ class ImageMediaItem(MediaManagerItem): (path, filename) = os.path.split(unicode(file)) thumb = os.path.join(self.servicePath, filename) if os.path.exists(thumb): - self.validate(file, thumb) - icon = build_icon(thumb) + if self.validate(file, thumb): + icon = build_icon(thumb) + else: + icon = build_icon(u':/general/general_delete.png') else: icon = self.IconFromFile(file, thumb) item_name = QtGui.QListWidgetItem(filename) From 8242bac82f2b2bc575df11cac31fdd5d671dc1c5 Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Mon, 19 Apr 2010 19:20:44 +0100 Subject: [PATCH 03/63] Presentation icons --- openlp/core/lib/mediamanageritem.py | 10 ++++----- openlp/plugins/presentations/lib/mediaitem.py | 21 ++++++++++++++++++- .../presentations/presentationplugin.py | 1 - 3 files changed, 25 insertions(+), 7 deletions(-) diff --git a/openlp/core/lib/mediamanageritem.py b/openlp/core/lib/mediamanageritem.py index fdc81092f..05ce36ad1 100644 --- a/openlp/core/lib/mediamanageritem.py +++ b/openlp/core/lib/mediamanageritem.py @@ -357,12 +357,12 @@ class MediaManagerItem(QtGui.QWidget): Validates to see if the file still exists or thumbnail is up to date """ - filedate = os.stat(file).st_mtime - thumbdate = os.stat(thumb).st_mtime - #if file updated rebuild icon - if filedate > thumbdate: - self.IconFromFile(file, thumb) if os.path.exists(file): + filedate = os.stat(file).st_mtime + thumbdate = os.stat(thumb).st_mtime + #if file updated rebuild icon + if filedate > thumbdate: + self.IconFromFile(file, thumb) return True return False diff --git a/openlp/plugins/presentations/lib/mediaitem.py b/openlp/plugins/presentations/lib/mediaitem.py index 79c8600f0..c58345eda 100644 --- a/openlp/plugins/presentations/lib/mediaitem.py +++ b/openlp/plugins/presentations/lib/mediaitem.py @@ -28,7 +28,7 @@ import os from PyQt4 import QtCore, QtGui -from openlp.core.lib import MediaManagerItem, BaseListWithDnD +from openlp.core.lib import MediaManagerItem, BaseListWithDnD, build_icon from openlp.plugins.presentations.lib import MessageListener log = logging.getLogger(__name__) @@ -103,6 +103,10 @@ class PresentationMediaItem(MediaManagerItem): self.PageLayout.addWidget(self.PresentationWidget) def initialise(self): + self.servicePath = os.path.join( + self.parent.config.get_data_path(), u'.thumbnails') + if not os.path.exists(self.servicePath): + os.mkdir(self.servicePath) list = self.parent.config.load_list(u'presentations') self.loadList(list) for item in self.controllers: @@ -128,8 +132,23 @@ class PresentationMediaItem(MediaManagerItem): 'A presentation with that filename already exists.'), QtGui.QMessageBox.Ok) else: + icon = None + for controller in self.controllers: + thumb = os.path.join(self.parent.config.get_data_path(), controller, filename, u'slide1.png') + preview = os.path.join(self.parent.config.get_data_path(), controller, u'thumbnails', filename, u'slide1.png') + if os.path.exists(preview): + if os.path.exists(thumb): + if self.validate(preview, thumb): + icon = build_icon(thumb) + else: + icon = build_icon(u':/general/general_delete.png') + else: + icon = self.IconFromFile(preview, thumb) + if not icon: + icon = build_icon(u':/general/general_delete.png') item_name = QtGui.QListWidgetItem(filename) item_name.setData(QtCore.Qt.UserRole, QtCore.QVariant(file)) + item_name.setIcon(icon) self.ListView.addItem(item_name) def onDeleteClick(self): diff --git a/openlp/plugins/presentations/presentationplugin.py b/openlp/plugins/presentations/presentationplugin.py index 00a83fe4b..a2d01b1a5 100644 --- a/openlp/plugins/presentations/presentationplugin.py +++ b/openlp/plugins/presentations/presentationplugin.py @@ -58,7 +58,6 @@ class PresentationPlugin(Plugin): if self.controllers[controller].enabled: presentation_types.append({u'%s' % controller : self.controllers[controller].supports}) self.controllers[controller].start_process() - Receiver.send_message( u'presentation types', presentation_types) From 17ec820b791b0e7f37d2710a81be96b5a54b4812 Mon Sep 17 00:00:00 2001 From: Jon Tibble Date: Mon, 19 Apr 2010 19:43:20 +0100 Subject: [PATCH 04/63] Import and typo fixes --- openlp/core/ui/mainwindow.py | 2 +- openlp/plugins/alerts/forms/alertstab.py | 1 - openlp/plugins/songs/lib/sofimport.py | 7 ++----- openlp/plugins/songs/lib/songimport.py | 4 +++- 4 files changed, 6 insertions(+), 8 deletions(-) diff --git a/openlp/core/ui/mainwindow.py b/openlp/core/ui/mainwindow.py index e0e8465f5..469bc6d69 100644 --- a/openlp/core/ui/mainwindow.py +++ b/openlp/core/ui/mainwindow.py @@ -671,7 +671,7 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow): def serviceChanged(self, reset=False, serviceName=None): """ - Hook to change the main window title when the service chmainwindow.pyanges + Hook to change the main window title when the service changes ``reset`` Shows if the service has been cleared or saved diff --git a/openlp/plugins/alerts/forms/alertstab.py b/openlp/plugins/alerts/forms/alertstab.py index d15865a6d..b8efe9bdb 100644 --- a/openlp/plugins/alerts/forms/alertstab.py +++ b/openlp/plugins/alerts/forms/alertstab.py @@ -26,7 +26,6 @@ from PyQt4 import QtCore, QtGui from openlp.core.lib import SettingsTab, str_to_bool -from openlp.plugins.alerts.lib.models import AlertItem class AlertsTab(SettingsTab): """ diff --git a/openlp/plugins/songs/lib/sofimport.py b/openlp/plugins/songs/lib/sofimport.py index 48139931b..9d95cf6b5 100644 --- a/openlp/plugins/songs/lib/sofimport.py +++ b/openlp/plugins/songs/lib/sofimport.py @@ -29,22 +29,19 @@ # http://www.oooforum.org/forum/viewtopic.phtml?t=14409 # http://wiki.services.openoffice.org/wiki/Python -import re import os -import time -from PyQt4 import QtCore +import re + from songimport import SongImport from oooimport import OooImport if os.name == u'nt': - from win32com.client import Dispatch BOLD = 150.0 ITALIC = 2 PAGE_BEFORE = 4 PAGE_AFTER = 5 PAGE_BOTH = 6 else: - import uno from com.sun.star.awt.FontWeight import BOLD from com.sun.star.awt.FontSlant import ITALIC from com.sun.star.style.BreakType import PAGE_BEFORE, PAGE_AFTER, PAGE_BOTH diff --git a/openlp/plugins/songs/lib/songimport.py b/openlp/plugins/songs/lib/songimport.py index cb780f987..5fe362842 100644 --- a/openlp/plugins/songs/lib/songimport.py +++ b/openlp/plugins/songs/lib/songimport.py @@ -24,7 +24,9 @@ ############################################################################### import string -from PyQt4 import QtGui, QtCore + +from PyQt4 import QtGui + from openlp.core.lib import SongXMLBuilder from openlp.plugins.songs.lib.models import Song, Author, Topic, Book From 29e4d4cf1adf434d3fbf9023b43a3e0d923fbd02 Mon Sep 17 00:00:00 2001 From: Jonathan Corwin Date: Tue, 20 Apr 2010 23:00:55 +0100 Subject: [PATCH 05/63] event fixes --- openlp/core/lib/mediamanageritem.py | 6 ++-- openlp/core/ui/maindisplay.py | 34 +++++++++---------- openlp/core/ui/servicemanager.py | 13 ++----- openlp/core/ui/slidecontroller.py | 18 +++++----- openlp/core/ui/thememanager.py | 5 ++- openlp/plugins/alerts/lib/alertsmanager.py | 4 +-- openlp/plugins/custom/forms/editcustomform.py | 2 +- openlp/plugins/custom/lib/mediaitem.py | 2 +- .../presentations/lib/messagelistener.py | 6 ++-- openlp/plugins/remotes/remoteplugin.py | 10 +++--- openlp/plugins/songs/forms/editsongform.py | 2 +- openlp/plugins/songs/lib/mediaitem.py | 2 +- 12 files changed, 48 insertions(+), 56 deletions(-) diff --git a/openlp/core/lib/mediamanageritem.py b/openlp/core/lib/mediamanageritem.py index 7ac2a6f0a..c37336057 100644 --- a/openlp/core/lib/mediamanageritem.py +++ b/openlp/core/lib/mediamanageritem.py @@ -450,10 +450,10 @@ class MediaManagerItem(QtGui.QWidget): self.trUtf8('You must select a existing service item to add to.')) elif self.title.lower() == service_item.name.lower(): self.generateSlideData(service_item) - self.parent.service_manager.addServiceItem(service_item) + self.parent.service_manager.addServiceItem(service_item, + replace=True) else: #Turn off the remote edit update message indicator - self.parent.service_manager.remoteEditTriggered = False QtGui.QMessageBox.information(self, self.trUtf8('Invalid Service Item'), self.trUtf8(unicode('You must select a %s service item.' % self.title))) @@ -471,4 +471,4 @@ class MediaManagerItem(QtGui.QWidget): if self.generateSlideData(service_item, item): return service_item else: - return None \ No newline at end of file + return None diff --git a/openlp/core/ui/maindisplay.py b/openlp/core/ui/maindisplay.py index 92312429f..396989b22 100644 --- a/openlp/core/ui/maindisplay.py +++ b/openlp/core/ui/maindisplay.py @@ -46,25 +46,25 @@ class DisplayWidget(QtGui.QWidget): self.parent = parent self.hotkey_map = { QtCore.Qt.Key_Return: 'servicemanager_next_item', - QtCore.Qt.Key_Space: 'slidecontroller_live_next_noloop', - QtCore.Qt.Key_Enter: 'slidecontroller_live_next_noloop', + QtCore.Qt.Key_Space: 'slidecontroller_live_go_next_noloop', + QtCore.Qt.Key_Enter: 'slidecontroller_live_go_next_noloop', QtCore.Qt.Key_0: 'servicemanager_next_item', - QtCore.Qt.Key_Backspace: 'slidecontroller_live_previous_noloop'} + QtCore.Qt.Key_Backspace: 'slidecontroller_live_go_previous_noloop'} def keyPressEvent(self, event): if type(event) == QtGui.QKeyEvent: #here accept the event and do something if event.key() == QtCore.Qt.Key_Up: - Receiver.send_message(u'slidecontroller_live_previous') + Receiver.send_message(u'slidecontroller_go_live_previous') event.accept() elif event.key() == QtCore.Qt.Key_Down: - Receiver.send_message(u'slidecontroller_live_next') + Receiver.send_message(u'slidecontroller_go_live_next') event.accept() elif event.key() == QtCore.Qt.Key_PageUp: - Receiver.send_message(u'slidecontroller_live_first') + Receiver.send_message(u'slidecontroller_go_live_first') event.accept() elif event.key() == QtCore.Qt.Key_PageDown: - Receiver.send_message(u'slidecontroller_live_last') + Receiver.send_message(u'slidecontroller_go_live_last') event.accept() elif event.key() in self.hotkey_map: Receiver.send_message(self.hotkey_map[event.key()]) @@ -113,9 +113,9 @@ class MainDisplay(DisplayWidget): self.hasTransition = False self.mediaBackground = False QtCore.QObject.connect(Receiver.get_receiver(), - QtCore.SIGNAL(u'slide_live_hide'), self.hideDisplay) + QtCore.SIGNAL(u'maindisplay_hide'), self.hideDisplay) QtCore.QObject.connect(Receiver.get_receiver(), - QtCore.SIGNAL(u'slide_live_show'), self.showDisplay) + QtCore.SIGNAL(u'maindisplay_show'), self.showDisplay) QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'slidecontroller_live_mediastart'), self.onMediaQueue) @@ -191,7 +191,7 @@ class MainDisplay(DisplayWidget): if not self.primary: self.setVisible(True) self.showFullScreen() - Receiver.send_message(u'slide_live_active') + Receiver.send_message(u'maindisplay_active') def addImageWithText(self, frame): log.debug(u'addImageWithText') @@ -284,25 +284,25 @@ class VideoWidget(QtGui.QWidget): self.parent = parent self.hotkey_map = { QtCore.Qt.Key_Return: 'servicemanager_next_item', - QtCore.Qt.Key_Space: 'slidecontroller_live_next_noloop', - QtCore.Qt.Key_Enter: 'slidecontroller_live_next_noloop', + QtCore.Qt.Key_Space: 'slidecontroller_live_go_next_noloop', + QtCore.Qt.Key_Enter: 'slidecontroller_live_go_next_noloop', QtCore.Qt.Key_0: 'servicemanager_next_item', - QtCore.Qt.Key_Backspace: 'slidecontroller_live_previous_noloop'} + QtCore.Qt.Key_Backspace: 'slidecontroller_live_go_previous_noloop'} def keyPressEvent(self, event): if type(event) == QtGui.QKeyEvent: #here accept the event and do something if event.key() == QtCore.Qt.Key_Up: - Receiver.send_message(u'slidecontroller_live_previous') + Receiver.send_message(u'slidecontroller_live_go_previous') event.accept() elif event.key() == QtCore.Qt.Key_Down: - Receiver.send_message(u'slidecontroller_live_next') + Receiver.send_message(u'slidecontroller_live_go_next') event.accept() elif event.key() == QtCore.Qt.Key_PageUp: - Receiver.send_message(u'slidecontroller_live_first') + Receiver.send_message(u'slidecontroller_live_go_first') event.accept() elif event.key() == QtCore.Qt.Key_PageDown: - Receiver.send_message(u'slidecontroller_live_last') + Receiver.send_message(u'slidecontroller_live_go_last') event.accept() elif event.key() in self.hotkey_map: Receiver.send_message(self.hotkey_map[event.key()]) diff --git a/openlp/core/ui/servicemanager.py b/openlp/core/ui/servicemanager.py index 11ba067b0..9f0370e95 100644 --- a/openlp/core/ui/servicemanager.py +++ b/openlp/core/ui/servicemanager.py @@ -105,7 +105,6 @@ class ServiceManager(QtGui.QWidget): self.isNew = True #Indicates if remoteTriggering is active. If it is the next addServiceItem call #will replace the currently selected one. - self.remoteEditTriggered = False self.serviceNoteForm = ServiceNoteForm() self.serviceItemEditForm = ServiceItemEditForm() #start with the layout @@ -187,8 +186,6 @@ class ServiceManager(QtGui.QWidget): QtCore.SIGNAL(u'itemExpanded(QTreeWidgetItem*)'), self.expanded) QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'theme_update_list'), self.updateThemeList) - QtCore.QObject.connect(Receiver.get_receiver(), - QtCore.SIGNAL(u'servicemanager_edit_clear'), self.onRemoteEditClear) QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'servicemanager_next_item'), self.nextItem) QtCore.QObject.connect(Receiver.get_receiver(), @@ -638,7 +635,7 @@ class ServiceManager(QtGui.QWidget): #does not impact the saved song so True may also be valid self.parent.serviceChanged(False, self.serviceName) - def addServiceItem(self, item, rebuild=False, expand=True): + def addServiceItem(self, item, rebuild=False, expand=True, replace=False): """ Add a Service item to the list @@ -648,10 +645,9 @@ class ServiceManager(QtGui.QWidget): """ sitem, count = self.findServiceItem() item.render() - if self.remoteEditTriggered: + if replace: item.merge(self.serviceItems[sitem][u'service_item']) self.serviceItems[sitem][u'service_item'] = item - self.remoteEditTriggered = False self.repaintServiceList(sitem + 1, 0) self.parent.LiveController.replaceServiceManagerItem(item) else: @@ -694,8 +690,6 @@ class ServiceManager(QtGui.QWidget): if item == -1: return False else: - #Switch on remote edit update functionality. - self.remoteEditTriggered = True return self.serviceItems[item][u'service_item'] def makeLive(self): @@ -725,9 +719,6 @@ class ServiceManager(QtGui.QWidget): self.serviceItems[item][u'service_item'].name, u'L:%s' % self.serviceItems[item][u'service_item'].editId ) - def onRemoteEditClear(self): - self.remoteEditTriggered = False - def findServiceItem(self): """ Finds a ServiceItem in the list diff --git a/openlp/core/ui/slidecontroller.py b/openlp/core/ui/slidecontroller.py index 1d36bbdb7..2f31642c9 100644 --- a/openlp/core/ui/slidecontroller.py +++ b/openlp/core/ui/slidecontroller.py @@ -197,7 +197,7 @@ class SlideController(QtGui.QWidget): u'Hide screen', u':/slides/slide_desktop.png', self.trUtf8('Hide Screen'), self.onHideDisplay, True) QtCore.QObject.connect(Receiver.get_receiver(), - QtCore.SIGNAL(u'slide_live_blank'), self.blankScreen) + QtCore.SIGNAL(u'maindisplay_blank'), self.blankScreen) if not self.isLive: self.Toolbar.addToolbarSeparator(u'Close Separator') self.Toolbar.addToolbarButton( @@ -318,7 +318,7 @@ class SlideController(QtGui.QWidget): QtCore.SIGNAL(u'slidecontroller_%s_go_first' % self.type_prefix), self.onSlideSelectedFirst) QtCore.QObject.connect(Receiver.get_receiver(), - QtCore.SIGNAL(u'%slidecontroller_s_go_next' % self.type_prefix), + QtCore.SIGNAL(u'slidecontroller_%s_go_next' % self.type_prefix), self.onSlideSelectedNext) QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'slidecontroller_%s_go_previous' % self.type_prefix), @@ -562,10 +562,9 @@ class SlideController(QtGui.QWidget): """ if not self.serviceItem: return + Receiver.send_message(u'slidecontroller_first', + [self.serviceItem, self.isLive]) if self.serviceItem.is_command(): - Receiver.send_message(u'slidecontroller_%s_first' % - self.type_prefix, - self.serviceItem.name.lower(), self.isLive) self.updatePreview() else: self.PreviewListWidget.selectRow(0) @@ -704,8 +703,8 @@ class SlideController(QtGui.QWidget): """ if not self.serviceItem: return - Receiver.send_message(u'slidecontroller_%s_previous' % - self.type_prefix, [self.serviceItem]) + Receiver.send_message(u'slidecontroller_previous', + [self.serviceItem, self.isLive]) if self.serviceItem.is_command(): self.updatePreview() else: @@ -756,8 +755,9 @@ class SlideController(QtGui.QWidget): def onEditSong(self): self.songEdit = True - Receiver.send_message(u'slidecontroller_edit', - [self.serviceItem]) + Receiver.send_message(u'%s_edit' % + self.serviceItem.name.lower(), u'L:%s' % + self.serviceItem.editId) def onGoLive(self): """ diff --git a/openlp/core/ui/thememanager.py b/openlp/core/ui/thememanager.py index 2867ed84b..a651c6211 100644 --- a/openlp/core/ui/thememanager.py +++ b/openlp/core/ui/thememanager.py @@ -147,8 +147,7 @@ class ThemeManager(QtGui.QWidget): name = u'%s (%s)' % (self.global_theme, self.trUtf8('default')) self.ThemeListWidget.item(count).setText(name) self.config.set_config(u'global theme', self.global_theme) - Receiver.send_message( - u'theme_update_global', self.global_theme) + Receiver.send_message(u'theme_update_global', self.global_theme) self.pushThemes() def onAddTheme(self): @@ -564,4 +563,4 @@ class ThemeManager(QtGui.QWidget): theme.font_main_y = int(theme.font_main_y.strip()) #theme.theme_mode theme.theme_name = theme.theme_name.strip() - #theme.theme_version \ No newline at end of file + #theme.theme_version diff --git a/openlp/plugins/alerts/lib/alertsmanager.py b/openlp/plugins/alerts/lib/alertsmanager.py index 7f3d7a654..7ca7fe084 100644 --- a/openlp/plugins/alerts/lib/alertsmanager.py +++ b/openlp/plugins/alerts/lib/alertsmanager.py @@ -44,9 +44,9 @@ class AlertsManager(QtCore.QObject): self.timer_id = 0 self.alertList = [] QtCore.QObject.connect(Receiver.get_receiver(), - QtCore.SIGNAL(u'slide_live_active'), self.generateAlert) + QtCore.SIGNAL(u'maindisplay_active'), self.generateAlert) QtCore.QObject.connect(Receiver.get_receiver(), - QtCore.SIGNAL(u'alert_text'), self.displayAlert) + QtCore.SIGNAL(u'alerts_text'), self.displayAlert) QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'config_screen_changed'), self.screenChanged) diff --git a/openlp/plugins/custom/forms/editcustomform.py b/openlp/plugins/custom/forms/editcustomform.py index ff757d638..eff6bc835 100644 --- a/openlp/plugins/custom/forms/editcustomform.py +++ b/openlp/plugins/custom/forms/editcustomform.py @@ -135,7 +135,7 @@ class EditCustomForm(QtGui.QDialog, Ui_customEditDialog): self.previewButton.setVisible(True) def closePressed(self): - Receiver.send_message(u'servicemanager_edit_clear') + Receiver.send_message(u'custom_edit_clear') self.close() def accept(self): diff --git a/openlp/plugins/custom/lib/mediaitem.py b/openlp/plugins/custom/lib/mediaitem.py index a22c211e6..c79452c20 100644 --- a/openlp/plugins/custom/lib/mediaitem.py +++ b/openlp/plugins/custom/lib/mediaitem.py @@ -60,7 +60,7 @@ class CustomMediaItem(MediaManagerItem): QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'custom_edit'), self.onRemoteEdit) QtCore.QObject.connect(Receiver.get_receiver(), - QtCore.SIGNAL(u'servicemanager_edit_clear' ), self.onRemoteEditClear) + QtCore.SIGNAL(u'custom_edit_clear' ), self.onRemoteEditClear) QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'custom_load_list'), self.initialise) QtCore.QObject.connect(Receiver.get_receiver(), diff --git a/openlp/plugins/presentations/lib/messagelistener.py b/openlp/plugins/presentations/lib/messagelistener.py index beede4019..37bfa564d 100644 --- a/openlp/plugins/presentations/lib/messagelistener.py +++ b/openlp/plugins/presentations/lib/messagelistener.py @@ -55,7 +55,7 @@ class Controller(object): self.doc.start_presentation() if isBlank: self.blank() - Receiver.send_message(u'live_slide_hide') + Receiver.send_message(u'maindisplay_hide') self.doc.slidenumber = 0 def activate(self): @@ -144,7 +144,7 @@ class Controller(object): """ log.debug(u'Live = %s, shutdown' % self.isLive) if self.isLive: - Receiver.send_message(u'live_slide_show') + Receiver.send_message(u'maindisplay_show') self.doc.close_presentation() self.doc = None #self.doc.slidenumber = 0 @@ -283,7 +283,7 @@ class MessageListener(object): if name != u'presentation': return if isLive: - Receiver.send_message(u'slide_live_show') + Receiver.send_message(u'maindisplay_show') self.liveHandler.shutdown() else: self.previewHandler.shutdown() diff --git a/openlp/plugins/remotes/remoteplugin.py b/openlp/plugins/remotes/remoteplugin.py index 4e01e43ee..ede72c954 100644 --- a/openlp/plugins/remotes/remoteplugin.py +++ b/openlp/plugins/remotes/remoteplugin.py @@ -73,10 +73,12 @@ class RemotesPlugin(Plugin): pos = datagram.find(u':') event = unicode(datagram[:pos].lower()) if event == u'alert': - Receiver.send_message(u'alert_text', unicode(datagram[pos + 1:])) - if event == u'next_slide': - Receiver.send_message(u'live_slide_next') - + Receiver.send_message(u'alerts_text', unicode(datagram[pos + 1:])) + elif event == u'next_slide': + Receiver.send_message(u'slidecontroller_live_go_next') + else: + Receiver.send_message(event, unicode(datagram[pos + 1:])) + def about(self): about_text = self.trUtf8('Remote Plugin
This plugin ' 'provides the ability to send messages to a running version of ' diff --git a/openlp/plugins/songs/forms/editsongform.py b/openlp/plugins/songs/forms/editsongform.py index 176e3c2f6..45940623e 100644 --- a/openlp/plugins/songs/forms/editsongform.py +++ b/openlp/plugins/songs/forms/editsongform.py @@ -467,7 +467,7 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog): Receiver.send_message(u'songs_preview') def closePressed(self): - Receiver.send_message(u'servicemanager_edit_clear') + Receiver.send_message(u'songs_edit_clear') self.close() def accept(self): diff --git a/openlp/plugins/songs/lib/mediaitem.py b/openlp/plugins/songs/lib/mediaitem.py index fabf1cc64..fb3f9c3e0 100644 --- a/openlp/plugins/songs/lib/mediaitem.py +++ b/openlp/plugins/songs/lib/mediaitem.py @@ -130,7 +130,7 @@ class SongMediaItem(MediaManagerItem): QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'songs_edit'), self.onRemoteEdit) QtCore.QObject.connect(Receiver.get_receiver(), - QtCore.SIGNAL(u'servicemanager_edit_clear'), self.onRemoteEditClear) + QtCore.SIGNAL(u'songs_edit_clear'), self.onRemoteEditClear) def configUpdated(self): self.searchAsYouType = str_to_bool( From 66339eedd6696a122d9f646ad0ad19268939ad75 Mon Sep 17 00:00:00 2001 From: Jon Tibble Date: Wed, 21 Apr 2010 17:51:52 +0100 Subject: [PATCH 06/63] Back out refactor --- openlp/core/lib/renderer.py | 30 +++++++-------------- openlp/core/lib/rendermanager.py | 43 ++++++++++++++++++++++++------- openlp/core/ui/slidecontroller.py | 15 ++++------- openlp/core/ui/thememanager.py | 27 +++++++------------ 4 files changed, 57 insertions(+), 58 deletions(-) diff --git a/openlp/core/lib/renderer.py b/openlp/core/lib/renderer.py index 698e165bf..bc5c09554 100644 --- a/openlp/core/lib/renderer.py +++ b/openlp/core/lib/renderer.py @@ -40,7 +40,6 @@ class Renderer(object): Initialise the renderer. """ self._rect = None - self._footer_rect = None self._debug = 0 self._right_margin = 64 # the amount of right indent self._shadow_offset = 5 @@ -216,29 +215,18 @@ class Renderer(object): split_pages.append(page) return split_pages - def build_text_rectangle(self, theme): + def set_text_rectangle(self, rect_main, rect_footer): """ - Builds a text block using the settings in ``theme``. - One is needed per slide + Sets the rectangle within which text should be rendered. - ``theme`` - The theme to build a text block for. + ``rect_main`` + The main text block. + + ``rect_footer`` + The footer text block. """ - log.debug(u'build_text_rectangle') - if theme.font_main_override == False: - self._rect = QtCore.QRect(10, 0, self.width - 1, - self.footer_start - 20) - else: - self._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) - if theme.font_footer_override == False: - self._footer_rect = QtCore.QRect(10,self.footer_start, self.width - 1, - self.height-self.footer_start) - else: - self._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) + self._rect = rect_main + self._rect_footer = rect_footer def generate_frame_from_lines(self, lines, footer_lines=None): """ diff --git a/openlp/core/lib/rendermanager.py b/openlp/core/lib/rendermanager.py index ae3a5316c..50abcfd07 100644 --- a/openlp/core/lib/rendermanager.py +++ b/openlp/core/lib/rendermanager.py @@ -137,24 +137,49 @@ class RenderManager(object): self.calculate_default( self.screen_list[self.current_display][u'size']) self.renderer.set_theme(self.themedata) - self.renderer.build_text_rectangle(self.themedata) + self.build_text_rectangle(self.themedata) #Replace the backgrount image from renderer with one from image if self.override_background is not None: if self.save_bg_frame is None: self.save_bg_frame = self.renderer.bg_frame if self.override_background_changed: - self.renderer.bg_frame = self.resize_image( - self.override_background) + self.renderer.bg_frame = self.resize_image(self.override_background) self.override_background_changed = False else: if self.override_background_changed: - self.renderer.bg_frame = self.resize_image( - self.override_background) + self.renderer.bg_frame = self.resize_image(self.override_background) self.override_background_changed = False if self.save_bg_frame is not None: self.renderer.bg_frame = self.save_bg_frame self.save_bg_frame = None + def build_text_rectangle(self, theme): + """ + Builds a text block using the settings in ``theme``. + One is needed per slide + + ``theme`` + The theme to build a text block for. + """ + log.debug(u'build_text_rectangle') + main_rect = None + footer_rect = None + if theme.font_main_override == False: + 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) + if theme.font_footer_override == False: + 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) + self.renderer.set_text_rectangle(main_rect, footer_rect) + def generate_preview(self, themedata): """ Generate a preview of a theme. @@ -165,7 +190,7 @@ class RenderManager(object): log.debug(u'generate preview') self.calculate_default(QtCore.QSize(1024, 768)) self.renderer.set_theme(themedata) - self.renderer.build_text_rectangle(themedata) + self.build_text_rectangle(themedata) self.renderer.set_frame_dest(self.width, self.height, True) verse = [] verse.append(u'Amazing Grace!') @@ -187,7 +212,7 @@ class RenderManager(object): The words to go on the slides. """ log.debug(u'format slide') - self.renderer.build_text_rectangle(self.themedata) + self.build_text_rectangle(self.themedata) return self.renderer.format_slide(words, False) def generate_slide(self, main_text, footer_text): @@ -201,7 +226,7 @@ class RenderManager(object): The text for the slide footer. """ log.debug(u'generate slide') - self.renderer.build_text_rectangle(self.themedata) + self.build_text_rectangle(self.themedata) self.renderer.set_frame_dest(self.width, self.height) return self.renderer.generate_frame_from_lines(main_text, footer_text) @@ -221,7 +246,7 @@ class RenderManager(object): h = height preview = preview.scaled(w, h, QtCore.Qt.KeepAspectRatio, QtCore.Qt.SmoothTransformation) - realw = preview.width() + realw = preview.width(); realh = preview.height() # and move it to the centre of the preview space newImage = QtGui.QImage(w, h, QtGui.QImage.Format_ARGB32_Premultiplied) diff --git a/openlp/core/ui/slidecontroller.py b/openlp/core/ui/slidecontroller.py index 3c4c70ee2..0aefd5537 100644 --- a/openlp/core/ui/slidecontroller.py +++ b/openlp/core/ui/slidecontroller.py @@ -448,11 +448,9 @@ class SlideController(QtGui.QWidget): if self.commandItem is not None and \ self.commandItem.service_item_type == ServiceItemType.Command: if blanked: - Receiver().send_message( - u'%s_blank' % self.commandItem.name.lower()) + Receiver().send_message(u'%s_blank'% self.commandItem.name.lower()) else: - Receiver().send_message( - u'%s_unblank' % self.commandItem.name.lower()) + Receiver().send_message(u'%s_unblank'% self.commandItem.name.lower()) else: self.parent.mainDisplay.blankDisplay() @@ -465,8 +463,7 @@ class SlideController(QtGui.QWidget): self.row = 0 if row > -1 and row < self.PreviewListWidget.rowCount(): if self.commandItem.service_item_type == ServiceItemType.Command: - Receiver().send_message( - u'%s_slide'% self.commandItem.name.lower(), [row]) + Receiver().send_message(u'%s_slide'% self.commandItem.name.lower(), [row]) if self.isLive: QtCore.QTimer.singleShot(0.5, self.grabMainDisplay) else: @@ -492,12 +489,10 @@ class SlideController(QtGui.QWidget): if not rm.screen_list[rm.current_display][u'primary']: winid = QtGui.QApplication.desktop().winId() rect = rm.screen_list[rm.current_display][u'size'] - winimg = QtGui.QPixmap.grabWindow( - winid, rect.x(), rect.y(), rect.width(), rect.height()) + winimg = QtGui.QPixmap.grabWindow(winid, rect.x(), rect.y(), rect.width(), rect.height()) self.SlidePreview.setPixmap(winimg) else: - label = self.PreviewListWidget.cellWidget( - self.PreviewListWidget.currentRow(), 0) + label = self.PreviewListWidget.cellWidget(self.PreviewListWidget.currentRow(), 0) self.SlidePreview.setPixmap(label.pixmap()) def onSlideSelectedNext(self): diff --git a/openlp/core/ui/thememanager.py b/openlp/core/ui/thememanager.py index ae3cee598..9956023c3 100644 --- a/openlp/core/ui/thememanager.py +++ b/openlp/core/ui/thememanager.py @@ -78,25 +78,17 @@ class ThemeManager(QtGui.QWidget): self.ThemeListWidget.addAction( contextMenuAction(self.ThemeListWidget, u':/themes/theme_edit.png', self.trUtf8(u'Edit a theme'), self.onEditTheme)) + self.ThemeListWidget.addAction(contextMenuSeparator(self.ThemeListWidget)) self.ThemeListWidget.addAction( - contextMenuSeparator(self.ThemeListWidget)) + contextMenuAction(self.ThemeListWidget, u':/themes/theme_delete.png', + self.trUtf8(u'Delete theme'), self.onDeleteTheme)) self.ThemeListWidget.addAction( - contextMenuAction(self.ThemeListWidget, - u':/themes/theme_delete.png', - self.trUtf8(u'Delete theme'), - self.onDeleteTheme)) + contextMenuAction(self.ThemeListWidget, u':/themes/theme_export.png', + self.trUtf8(u'Make Global'), self.changeGlobalFromScreen)) self.ThemeListWidget.addAction( - contextMenuAction(self.ThemeListWidget, - u':/themes/theme_export.png', - self.trUtf8(u'Make Global'), - self.changeGlobalFromScreen)) - self.ThemeListWidget.addAction( - contextMenuAction(self.ThemeListWidget, - u':/themes/theme_export.png', - self.trUtf8(u'Export theme'), - self.onExportTheme)) - self.ThemeListWidget.addAction( - contextMenuSeparator(self.ThemeListWidget)) + contextMenuAction(self.ThemeListWidget, u':/themes/theme_export.png', + self.trUtf8(u'Export theme'), self.onExportTheme)) + self.ThemeListWidget.addAction(contextMenuSeparator(self.ThemeListWidget)) #Signals QtCore.QObject.connect(self.ThemeListWidget, QtCore.SIGNAL(u'doubleClicked(QModelIndex)'), @@ -159,8 +151,7 @@ class ThemeManager(QtGui.QWidget): if item is not None: self.amendThemeForm.loadTheme( unicode(item.data(QtCore.Qt.UserRole).toString())) - self.saveThemeName = unicode( - item.data(QtCore.Qt.UserRole).toString()) + self.saveThemeName = unicode(item.data(QtCore.Qt.UserRole).toString()) self.amendThemeForm.exec_() def onDeleteTheme(self): From 9d0c1c01f353aa66395fd00173f7dfa8d5110f50 Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Wed, 21 Apr 2010 18:21:56 +0100 Subject: [PATCH 07/63] Alerts cleanup and fixes --- openlp/plugins/alerts/forms/alertdialog.py | 123 ++++++++++-------- openlp/plugins/alerts/forms/alertform.py | 47 +++---- openlp/plugins/alerts/forms/alertstab.py | 31 ----- openlp/plugins/presentations/lib/mediaitem.py | 6 +- resources/forms/alertdialog.ui | 28 +--- 5 files changed, 96 insertions(+), 139 deletions(-) diff --git a/openlp/plugins/alerts/forms/alertdialog.py b/openlp/plugins/alerts/forms/alertdialog.py index 804975ff1..00203f1f2 100644 --- a/openlp/plugins/alerts/forms/alertdialog.py +++ b/openlp/plugins/alerts/forms/alertdialog.py @@ -1,82 +1,92 @@ # -*- coding: utf-8 -*- +# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4 -# Form implementation generated from reading ui file 'alertdialog.ui' -# -# Created: Sat Apr 17 08:07:40 2010 -# by: PyQt4 UI code generator 4.7 -# -# WARNING! All changes made in this file will be lost! +############################################################################### +# OpenLP - Open Source Lyrics Projection # +# --------------------------------------------------------------------------- # +# Copyright (c) 2008-2010 Raoul Snyman # +# Portions copyright (c) 2008-2010 Tim Bentley, Jonathan Corwin, Michael # +# Gorven, Scott Guerrieri, Christian Richter, Maikel Stuivenberg, Martin # +# Thompson, Jon Tibble, Carsten Tinggaard # +# --------------------------------------------------------------------------- # +# 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 class Ui_AlertDialog(object): def setupUi(self, AlertDialog): - AlertDialog.setObjectName("AlertDialog") + AlertDialog.setObjectName(u'AlertDialog') AlertDialog.resize(567, 440) icon = QtGui.QIcon() - icon.addPixmap(QtGui.QPixmap(":/icon/openlp.org-icon-32.bmp"), QtGui.QIcon.Normal, QtGui.QIcon.Off) + icon.addPixmap(QtGui.QPixmap(u':/icon/openlp.org-icon-32.bmp'), QtGui.QIcon.Normal, QtGui.QIcon.Off) AlertDialog.setWindowIcon(icon) self.AlertFormLayout = QtGui.QVBoxLayout(AlertDialog) self.AlertFormLayout.setSpacing(8) self.AlertFormLayout.setMargin(8) - self.AlertFormLayout.setObjectName("AlertFormLayout") + self.AlertFormLayout.setObjectName(u'AlertFormLayout') self.AlertTextLayout = QtGui.QFormLayout() self.AlertTextLayout.setContentsMargins(0, 0, -1, -1) self.AlertTextLayout.setSpacing(8) - self.AlertTextLayout.setObjectName("AlertTextLayout") + self.AlertTextLayout.setObjectName(u'AlertTextLayout') self.AlertEntryLabel = QtGui.QLabel(AlertDialog) sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Preferred, QtGui.QSizePolicy.Fixed) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth(self.AlertEntryLabel.sizePolicy().hasHeightForWidth()) self.AlertEntryLabel.setSizePolicy(sizePolicy) - self.AlertEntryLabel.setObjectName("AlertEntryLabel") + self.AlertEntryLabel.setObjectName(u'AlertEntryLabel') self.AlertTextLayout.setWidget(0, QtGui.QFormLayout.LabelRole, self.AlertEntryLabel) self.AlertParameter = QtGui.QLabel(AlertDialog) - self.AlertParameter.setObjectName("AlertParameter") + self.AlertParameter.setObjectName(u'AlertParameter') self.AlertTextLayout.setWidget(1, QtGui.QFormLayout.LabelRole, self.AlertParameter) self.ParameterEdit = QtGui.QLineEdit(AlertDialog) - self.ParameterEdit.setObjectName("ParameterEdit") + self.ParameterEdit.setObjectName(u'ParameterEdit') self.AlertTextLayout.setWidget(1, QtGui.QFormLayout.FieldRole, self.ParameterEdit) self.AlertTextEdit = QtGui.QLineEdit(AlertDialog) - self.AlertTextEdit.setObjectName("AlertTextEdit") + self.AlertTextEdit.setObjectName(u'AlertTextEdit') self.AlertTextLayout.setWidget(0, QtGui.QFormLayout.FieldRole, self.AlertTextEdit) self.AlertFormLayout.addLayout(self.AlertTextLayout) self.ManagementLayout = QtGui.QHBoxLayout() self.ManagementLayout.setSpacing(8) self.ManagementLayout.setContentsMargins(-1, -1, -1, 0) - self.ManagementLayout.setObjectName("ManagementLayout") + self.ManagementLayout.setObjectName(u'ManagementLayout') self.AlertListWidget = QtGui.QListWidget(AlertDialog) self.AlertListWidget.setAlternatingRowColors(True) - self.AlertListWidget.setObjectName("AlertListWidget") + self.AlertListWidget.setObjectName(u'AlertListWidget') self.ManagementLayout.addWidget(self.AlertListWidget) self.ManageButtonLayout = QtGui.QVBoxLayout() self.ManageButtonLayout.setSpacing(8) - self.ManageButtonLayout.setObjectName("ManageButtonLayout") + self.ManageButtonLayout.setObjectName(u'ManageButtonLayout') self.NewButton = QtGui.QPushButton(AlertDialog) icon1 = QtGui.QIcon() - icon1.addPixmap(QtGui.QPixmap(":/general/general_new.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off) + icon1.addPixmap(QtGui.QPixmap(u':/general/general_new.png'), QtGui.QIcon.Normal, QtGui.QIcon.Off) self.NewButton.setIcon(icon1) - self.NewButton.setObjectName("NewButton") + self.NewButton.setObjectName(u'NewButton') self.ManageButtonLayout.addWidget(self.NewButton) self.SaveButton = QtGui.QPushButton(AlertDialog) self.SaveButton.setEnabled(False) icon2 = QtGui.QIcon() - icon2.addPixmap(QtGui.QPixmap(":/general/general_save.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off) + icon2.addPixmap(QtGui.QPixmap(u':/general/general_save.png'), QtGui.QIcon.Normal, QtGui.QIcon.Off) self.SaveButton.setIcon(icon2) - self.SaveButton.setObjectName("SaveButton") + self.SaveButton.setObjectName(u'SaveButton') self.ManageButtonLayout.addWidget(self.SaveButton) - self.EditButton = QtGui.QPushButton(AlertDialog) - icon3 = QtGui.QIcon() - icon3.addPixmap(QtGui.QPixmap(":/general/general_edit.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off) - self.EditButton.setIcon(icon3) - self.EditButton.setObjectName("EditButton") - self.ManageButtonLayout.addWidget(self.EditButton) self.DeleteButton = QtGui.QPushButton(AlertDialog) - icon4 = QtGui.QIcon() - icon4.addPixmap(QtGui.QPixmap(":/general/general_delete.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off) - self.DeleteButton.setIcon(icon4) - self.DeleteButton.setObjectName("DeleteButton") + icon3 = QtGui.QIcon() + icon3.addPixmap(QtGui.QPixmap(u':/general/general_delete.png'), QtGui.QIcon.Normal, QtGui.QIcon.Off) + self.DeleteButton.setIcon(icon3) + self.DeleteButton.setObjectName(u'DeleteButton') self.ManageButtonLayout.addWidget(self.DeleteButton) spacerItem = QtGui.QSpacerItem(20, 40, QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Expanding) self.ManageButtonLayout.addItem(spacerItem) @@ -84,51 +94,52 @@ class Ui_AlertDialog(object): self.AlertFormLayout.addLayout(self.ManagementLayout) self.AlertButtonLayout = QtGui.QHBoxLayout() self.AlertButtonLayout.setSpacing(8) - self.AlertButtonLayout.setObjectName("AlertButtonLayout") - spacerItem1 = QtGui.QSpacerItem(181, 0, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum) + self.AlertButtonLayout.setObjectName(u'AlertButtonLayout') + spacerItem1 = QtGui.QSpacerItem(181, 0, QtGui.QSizePolicy.Expanding, + QtGui.QSizePolicy.Minimum) self.AlertButtonLayout.addItem(spacerItem1) self.DisplayButton = QtGui.QPushButton(AlertDialog) - icon5 = QtGui.QIcon() - icon5.addPixmap(QtGui.QPixmap(":/general/general_live.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off) - self.DisplayButton.setIcon(icon5) - self.DisplayButton.setObjectName("DisplayButton") + icon4 = QtGui.QIcon() + icon4.addPixmap(QtGui.QPixmap(u':/general/general_live.png'), + QtGui.QIcon.Normal, QtGui.QIcon.Off) + self.DisplayButton.setIcon(icon4) + self.DisplayButton.setObjectName(u'DisplayButton') self.AlertButtonLayout.addWidget(self.DisplayButton) self.DisplayCloseButton = QtGui.QPushButton(AlertDialog) - self.DisplayCloseButton.setIcon(icon5) - self.DisplayCloseButton.setObjectName("DisplayCloseButton") + self.DisplayCloseButton.setIcon(icon4) + self.DisplayCloseButton.setObjectName(u'DisplayCloseButton') self.AlertButtonLayout.addWidget(self.DisplayCloseButton) self.CloseButton = QtGui.QPushButton(AlertDialog) - icon6 = QtGui.QIcon() - icon6.addPixmap(QtGui.QPixmap(":/system/system_close.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off) - self.CloseButton.setIcon(icon6) - self.CloseButton.setObjectName("CloseButton") + icon5 = QtGui.QIcon() + icon5.addPixmap(QtGui.QPixmap(u':/system/system_close.png'), + QtGui.QIcon.Normal, QtGui.QIcon.Off) + self.CloseButton.setIcon(icon5) + self.CloseButton.setObjectName(u'CloseButton') self.AlertButtonLayout.addWidget(self.CloseButton) self.AlertFormLayout.addLayout(self.AlertButtonLayout) self.AlertEntryLabel.setBuddy(self.AlertTextEdit) self.AlertParameter.setBuddy(self.ParameterEdit) self.retranslateUi(AlertDialog) - QtCore.QObject.connect(self.CloseButton, QtCore.SIGNAL("clicked()"), AlertDialog.close) + QtCore.QObject.connect(self.CloseButton, QtCore.SIGNAL(u'clicked()'), AlertDialog.close) QtCore.QMetaObject.connectSlotsByName(AlertDialog) AlertDialog.setTabOrder(self.AlertTextEdit, self.ParameterEdit) AlertDialog.setTabOrder(self.ParameterEdit, self.AlertListWidget) AlertDialog.setTabOrder(self.AlertListWidget, self.NewButton) AlertDialog.setTabOrder(self.NewButton, self.SaveButton) - AlertDialog.setTabOrder(self.SaveButton, self.EditButton) - AlertDialog.setTabOrder(self.EditButton, self.DeleteButton) + AlertDialog.setTabOrder(self.SaveButton, self.DeleteButton) AlertDialog.setTabOrder(self.DeleteButton, self.DisplayButton) AlertDialog.setTabOrder(self.DisplayButton, self.DisplayCloseButton) AlertDialog.setTabOrder(self.DisplayCloseButton, self.CloseButton) def retranslateUi(self, AlertDialog): - AlertDialog.setWindowTitle(QtGui.QApplication.translate("AlertDialog", "Alert Message", None, QtGui.QApplication.UnicodeUTF8)) - self.AlertEntryLabel.setText(QtGui.QApplication.translate("AlertDialog", "Alert &text:", None, QtGui.QApplication.UnicodeUTF8)) - self.AlertParameter.setText(QtGui.QApplication.translate("AlertDialog", "&Parameter(s):", None, QtGui.QApplication.UnicodeUTF8)) - self.NewButton.setText(QtGui.QApplication.translate("AlertDialog", "&New", None, QtGui.QApplication.UnicodeUTF8)) - self.SaveButton.setText(QtGui.QApplication.translate("AlertDialog", "&Save", None, QtGui.QApplication.UnicodeUTF8)) - self.EditButton.setText(QtGui.QApplication.translate("AlertDialog", "&Edit", None, QtGui.QApplication.UnicodeUTF8)) - self.DeleteButton.setText(QtGui.QApplication.translate("AlertDialog", "&Delete", None, QtGui.QApplication.UnicodeUTF8)) - self.DisplayButton.setText(QtGui.QApplication.translate("AlertDialog", "Displ&ay", None, QtGui.QApplication.UnicodeUTF8)) - self.DisplayCloseButton.setText(QtGui.QApplication.translate("AlertDialog", "Display && Cl&ose", None, QtGui.QApplication.UnicodeUTF8)) - self.CloseButton.setText(QtGui.QApplication.translate("AlertDialog", "&Close", None, QtGui.QApplication.UnicodeUTF8)) + AlertDialog.setWindowTitle(self.trUtf8('Alert Message')) + self.AlertEntryLabel.setText(self.trUtf8('Alert &text:')) + self.AlertParameter.setText(self.trUtf8('&Parameter(s):')) + self.NewButton.setText(self.trUtf8('&New')) + self.SaveButton.setText(self.trUtf8('&Save')) + self.DeleteButton.setText(self.trUtf8('&Delete')) + self.DisplayButton.setText(self.trUtf8('Displ&ay')) + self.DisplayCloseButton.setText(self.trUtf8('Display && Cl&ose')) + self.CloseButton.setText(self.trUtf8('&Close')) diff --git a/openlp/plugins/alerts/forms/alertform.py b/openlp/plugins/alerts/forms/alertform.py index 08e5f5e02..9656dea42 100644 --- a/openlp/plugins/alerts/forms/alertform.py +++ b/openlp/plugins/alerts/forms/alertform.py @@ -39,7 +39,7 @@ class AlertForm(QtGui.QDialog, Ui_AlertDialog): """ self.manager = manager self.parent = parent - self.history_required = True + self.item_id = None QtGui.QDialog.__init__(self, None) self.setupUi(self) QtCore.QObject.connect(self.DisplayButton, @@ -57,9 +57,6 @@ class AlertForm(QtGui.QDialog, Ui_AlertDialog): QtCore.QObject.connect(self.DeleteButton, QtCore.SIGNAL(u'clicked()'), self.onDeleteClick) - QtCore.QObject.connect(self.EditButton, - QtCore.SIGNAL(u'clicked()'), - self.onEditClick) QtCore.QObject.connect(self.SaveButton, QtCore.SIGNAL(u'clicked()'), self.onSaveClick) @@ -79,12 +76,10 @@ class AlertForm(QtGui.QDialog, Ui_AlertDialog): QtCore.Qt.UserRole, QtCore.QVariant(alert.id)) self.AlertListWidget.addItem(item_name) self.SaveButton.setEnabled(False) - self.EditButton.setEnabled(False) self.DeleteButton.setEnabled(False) def onDisplayClicked(self): if self.triggerAlert(unicode(self.AlertTextEdit.text())): - self.history_required = False self.loadList() def onDisplayCloseClicked(self): @@ -103,15 +98,6 @@ class AlertForm(QtGui.QDialog, Ui_AlertDialog): self.DeleteButton.setEnabled(False) self.EditButton.setEnabled(False) - def onEditClick(self): - item = self.AlertListWidget.currentItem() - if item: - self.item_id = (item.data(QtCore.Qt.UserRole)).toInt()[0] - self.AlertTextEdit.setText(unicode(item.text())) - self.SaveButton.setEnabled(True) - self.DeleteButton.setEnabled(True) - self.EditButton.setEnabled(False) - def onNewClick(self): if len(self.AlertTextEdit.text()) == 0: QtGui.QMessageBox.information(self, @@ -121,19 +107,22 @@ class AlertForm(QtGui.QDialog, Ui_AlertDialog): alert = AlertItem() alert.text = unicode(self.AlertTextEdit.text()) self.manager.save_alert(alert) - self.onClearClick() + self.AlertTextEdit.setText(u'') self.loadList() def onSaveClick(self): - alert = self.manager.get_alert(self.item_id) - alert.text = unicode(self.AlertTextEdit.text()) - self.manager.save_alert(alert) - self.onClearClick() - self.loadList() + if self.item_id: + alert = self.manager.get_alert(self.item_id) + alert.text = unicode(self.AlertTextEdit.text()) + self.manager.save_alert(alert) + self.item_id = None + self.loadList() + else: + self.onNewClick() def onTextChanged(self): #Data has changed by editing it so potential storage required - self.history_required = True + self.SaveButton.setEnabled(True) def onDoubleClick(self): """ @@ -143,7 +132,10 @@ class AlertForm(QtGui.QDialog, Ui_AlertDialog): for item in items: bitem = self.AlertListWidget.item(item.row()) self.triggerAlert(bitem.text()) - self.history_required = False + self.AlertTextEdit.setText(bitem.text()) + self.item_id = (bitem.data(QtCore.Qt.UserRole)).toInt()[0] + self.SaveButton.setEnabled(False) + self.DeleteButton.setEnabled(True) def onSingleClick(self): """ @@ -154,16 +146,13 @@ class AlertForm(QtGui.QDialog, Ui_AlertDialog): for item in items: bitem = self.AlertListWidget.item(item.row()) self.AlertTextEdit.setText(bitem.text()) - self.history_required = False - self.EditButton.setEnabled(True) + self.item_id = (bitem.data(QtCore.Qt.UserRole)).toInt()[0] + self.SaveButton.setEnabled(False) self.DeleteButton.setEnabled(True) def triggerAlert(self, text): if text: + text = text.replace(u'<>', unicode(self.ParameterEdit.text())) self.parent.alertsmanager.displayAlert(text) - if self.parent.alertsTab.save_history and self.history_required: - alert = AlertItem() - alert.text = unicode(self.AlertTextEdit.text()) - self.manager.save_alert(alert) return True return False diff --git a/openlp/plugins/alerts/forms/alertstab.py b/openlp/plugins/alerts/forms/alertstab.py index d15865a6d..6882d63df 100644 --- a/openlp/plugins/alerts/forms/alertstab.py +++ b/openlp/plugins/alerts/forms/alertstab.py @@ -35,7 +35,6 @@ class AlertsTab(SettingsTab): def __init__(self, parent, section=None): self.parent = parent self.manager = parent.manager - self.alertsmanager = parent.alertsmanager SettingsTab.__init__(self, parent.name, section) def setupUi(self): @@ -136,22 +135,6 @@ class AlertsTab(SettingsTab): QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum) self.LocationLayout.addItem(self.LocationSpacer) self.FontLayout.addWidget(self.LocationWidget) - self.HistoryWidget = QtGui.QWidget(self.FontGroupBox) - self.HistoryWidget.setObjectName(u'HistoryWidget') - self.HistoryLayout = QtGui.QHBoxLayout(self.HistoryWidget) - self.HistoryLayout.setSpacing(8) - self.HistoryLayout.setMargin(0) - self.HistoryLayout.setObjectName(u'HistoryLayout') - self.HistoryLabel = QtGui.QLabel(self.HistoryWidget) - self.HistoryLabel.setObjectName(u'HistoryLabel') - self.HistoryLayout.addWidget(self.HistoryLabel) - self.HistoryCheckBox = QtGui.QCheckBox(self.HistoryWidget) - self.HistoryCheckBox.setObjectName(u'HistoryCheckBox') - self.HistoryLayout.addWidget(self.HistoryCheckBox) - self.HistorySpacer = QtGui.QSpacerItem(147, 20, - QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum) - self.HistoryLayout.addItem(self.HistorySpacer) - self.FontLayout.addWidget(self.HistoryWidget) self.SlideLeftLayout.addWidget(self.FontGroupBox) self.SlideLeftSpacer = QtGui.QSpacerItem(20, 94, QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Expanding) @@ -190,9 +173,6 @@ class AlertsTab(SettingsTab): self.SlideRightLayout.addItem(self.SlideRightSpacer) self.AlertsLayout.addWidget(self.AlertRightColumn) # Signals and slots - QtCore.QObject.connect(self.HistoryCheckBox, - QtCore.SIGNAL(u'stateChanged(int)'), - self.onHistoryCheckBoxChanged) QtCore.QObject.connect(self.BackgroundColorButton, QtCore.SIGNAL(u'pressed()'), self.onBackgroundColorButtonClicked) QtCore.QObject.connect(self.FontColorButton, @@ -216,7 +196,6 @@ class AlertsTab(SettingsTab): self.TimeoutLabel.setText(self.trUtf8('Alert timeout:')) self.TimeoutSpinBox.setSuffix(self.trUtf8('s')) self.LocationLabel.setText(self.trUtf8('Location:')) - self.HistoryLabel.setText(self.trUtf8('Keep History:')) self.PreviewGroupBox.setTitle(self.trUtf8('Preview')) self.FontPreview.setText(self.trUtf8('openlp.org')) self.LocationComboBox.setItemText(0, self.trUtf8('Top')) @@ -235,12 +214,6 @@ class AlertsTab(SettingsTab): def onLocationComboBoxClicked(self, location): self.location = location - def onHistoryCheckBoxChanged(self, check_state): - self.save_history = False - # we have a set value convert to True/False - if check_state == QtCore.Qt.Checked: - self.save_history = True - def onFontColorButtonClicked(self): self.font_color = QtGui.QColorDialog.getColor( QtGui.QColor(self.font_color), self).name() @@ -265,8 +238,6 @@ class AlertsTab(SettingsTab): self.font_face = unicode( self.config.get_config(u'font face', QtGui.QFont().family())) self.location = int(self.config.get_config(u'location', 0)) - self.save_history = str_to_bool( - self.config.get_config(u'save history', u'False')) self.FontSizeSpinBox.setValue(self.font_size) self.TimeoutSpinBox.setValue(self.timeout) self.FontColorButton.setStyleSheet( @@ -274,7 +245,6 @@ class AlertsTab(SettingsTab): self.BackgroundColorButton.setStyleSheet( u'background-color: %s' % self.bg_color) self.LocationComboBox.setCurrentIndex(self.location) - self.HistoryCheckBox.setChecked(self.save_history) font = QtGui.QFont() font.setFamily(self.font_face) self.FontComboBox.setCurrentFont(font) @@ -293,7 +263,6 @@ class AlertsTab(SettingsTab): self.config.set_config(u'timeout', unicode(self.timeout)) self.config.set_config(u'location', unicode(self.LocationComboBox.currentIndex())) - self.config.set_config(u'save history', unicode(self.save_history)) def updateDisplay(self): font = QtGui.QFont() diff --git a/openlp/plugins/presentations/lib/mediaitem.py b/openlp/plugins/presentations/lib/mediaitem.py index c58345eda..3aea3f1ec 100644 --- a/openlp/plugins/presentations/lib/mediaitem.py +++ b/openlp/plugins/presentations/lib/mediaitem.py @@ -134,8 +134,10 @@ class PresentationMediaItem(MediaManagerItem): else: icon = None for controller in self.controllers: - thumb = os.path.join(self.parent.config.get_data_path(), controller, filename, u'slide1.png') - preview = os.path.join(self.parent.config.get_data_path(), controller, u'thumbnails', filename, u'slide1.png') + thumb = os.path.join(self.parent.config.get_data_path(), \ + controller, filename, u'slide1.png') + preview = os.path.join(self.parent.config.get_data_path(), \ + controller, u'thumbnails', filename, u'slide1.png') if os.path.exists(preview): if os.path.exists(thumb): if self.validate(preview, thumb): diff --git a/resources/forms/alertdialog.ui b/resources/forms/alertdialog.ui index fd4cee5fc..725fb7c4e 100644 --- a/resources/forms/alertdialog.ui +++ b/resources/forms/alertdialog.ui @@ -98,7 +98,7 @@ &New - + :/general/general_new.png:/general/general_new.png @@ -112,29 +112,18 @@ &Save - + :/general/general_save.png:/general/general_save.png - - - - &Edit - - - - :/general/general_edit.png:/general/general_edit.png - - - &Delete - + :/general/general_delete.png:/general/general_delete.png @@ -180,7 +169,7 @@ Displ&ay - + :/general/general_live.png:/general/general_live.png @@ -191,7 +180,7 @@ Display && Cl&ose - + :/general/general_live.png:/general/general_live.png @@ -202,7 +191,7 @@ &Close - + :/system/system_close.png:/system/system_close.png @@ -217,15 +206,12 @@ AlertListWidget NewButton SaveButton - EditButton DeleteButton DisplayButton DisplayCloseButton CloseButton - - - + CloseButton From e6d6541ca29d97528c42d52b78f9240b3d91e6a9 Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Wed, 21 Apr 2010 18:36:29 +0100 Subject: [PATCH 08/63] Presentation Thumbnails --- openlp/plugins/presentations/lib/mediaitem.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/openlp/plugins/presentations/lib/mediaitem.py b/openlp/plugins/presentations/lib/mediaitem.py index 3aea3f1ec..701efc086 100644 --- a/openlp/plugins/presentations/lib/mediaitem.py +++ b/openlp/plugins/presentations/lib/mediaitem.py @@ -104,7 +104,7 @@ class PresentationMediaItem(MediaManagerItem): def initialise(self): self.servicePath = os.path.join( - self.parent.config.get_data_path(), u'.thumbnails') + self.parent.config.get_data_path(), u'thumbnails') if not os.path.exists(self.servicePath): os.mkdir(self.servicePath) list = self.parent.config.load_list(u'presentations') @@ -134,8 +134,9 @@ class PresentationMediaItem(MediaManagerItem): else: icon = None for controller in self.controllers: - thumb = os.path.join(self.parent.config.get_data_path(), \ - controller, filename, u'slide1.png') + thumbPath = os.path.join(self.parent.config.get_data_path(), \ + u'thumbnails', controller, filename) + thumb = os.path.join(thumbPath, u'slide1.png') preview = os.path.join(self.parent.config.get_data_path(), \ controller, u'thumbnails', filename, u'slide1.png') if os.path.exists(preview): @@ -145,6 +146,7 @@ class PresentationMediaItem(MediaManagerItem): else: icon = build_icon(u':/general/general_delete.png') else: + os.makedirs(thumbPath) icon = self.IconFromFile(preview, thumb) if not icon: icon = build_icon(u':/general/general_delete.png') From 877af7ea2c59056e40522da645f386a21c9d7d1c Mon Sep 17 00:00:00 2001 From: Jonathan Corwin Date: Wed, 21 Apr 2010 22:56:48 +0100 Subject: [PATCH 09/63] More fixes --- openlp/core/ui/maindisplay.py | 22 +++++++++--------- openlp/core/ui/mainwindow.py | 2 +- openlp/core/ui/servicemanager.py | 3 +-- openlp/core/ui/slidecontroller.py | 26 +++++++++++----------- openlp/plugins/alerts/alertsplugin.py | 1 - openlp/plugins/alerts/lib/alertsmanager.py | 4 ++-- openlp/plugins/remotes/remoteplugin.py | 2 +- 7 files changed, 29 insertions(+), 31 deletions(-) diff --git a/openlp/core/ui/maindisplay.py b/openlp/core/ui/maindisplay.py index 556872b35..7c0b7357e 100644 --- a/openlp/core/ui/maindisplay.py +++ b/openlp/core/ui/maindisplay.py @@ -68,25 +68,25 @@ class DisplayWidget(QtGui.QWidget): self.parent = parent self.hotkey_map = { QtCore.Qt.Key_Return: 'servicemanager_next_item', - QtCore.Qt.Key_Space: 'slidecontroller_live_go_next_noloop', - QtCore.Qt.Key_Enter: 'slidecontroller_live_go_next_noloop', + QtCore.Qt.Key_Space: 'slidecontroller_live_next_noloop', + QtCore.Qt.Key_Enter: 'slidecontroller_live_next_noloop', QtCore.Qt.Key_0: 'servicemanager_next_item', - QtCore.Qt.Key_Backspace: 'slidecontroller_live_go_previous_noloop'} + QtCore.Qt.Key_Backspace: 'slidecontroller_live_previous_noloop'} def keyPressEvent(self, event): if type(event) == QtGui.QKeyEvent: #here accept the event and do something if event.key() == QtCore.Qt.Key_Up: - Receiver.send_message(u'slidecontroller_go_live_previous') + Receiver.send_message(u'slidecontroller_live_previous') event.accept() elif event.key() == QtCore.Qt.Key_Down: - Receiver.send_message(u'slidecontroller_go_live_next') + Receiver.send_message(u'slidecontroller_live_next') event.accept() elif event.key() == QtCore.Qt.Key_PageUp: - Receiver.send_message(u'slidecontroller_go_live_first') + Receiver.send_message(u'slidecontroller_live_first') event.accept() elif event.key() == QtCore.Qt.Key_PageDown: - Receiver.send_message(u'slidecontroller_go_live_last') + Receiver.send_message(u'slidecontroller_live_last') event.accept() elif event.key() in self.hotkey_map: Receiver.send_message(self.hotkey_map[event.key()]) @@ -325,13 +325,13 @@ class VideoDisplay(Phonon.VideoWidget): Phonon.createPath(self.mediaObject, self) Phonon.createPath(self.mediaObject, self.audioObject) QtCore.QObject.connect(Receiver.get_receiver(), - QtCore.SIGNAL(u'slidecontroller_media_start'), self.onMediaQueue) + QtCore.SIGNAL(u'mediacontroller_start'), self.onMediaQueue) QtCore.QObject.connect(Receiver.get_receiver(), - QtCore.SIGNAL(u'slidecontroller_media_play'), self.onMediaPlay) + QtCore.SIGNAL(u'mediacontroller_play'), self.onMediaPlay) QtCore.QObject.connect(Receiver.get_receiver(), - QtCore.SIGNAL(u'slidecontroller_media_pause'), self.onMediaPause) + QtCore.SIGNAL(u'mediacontroller_pause'), self.onMediaPause) QtCore.QObject.connect(Receiver.get_receiver(), - QtCore.SIGNAL(u'slidecontroller_media_stop'), self.onMediaStop) + QtCore.SIGNAL(u'mediacontroller_stop'), self.onMediaStop) QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'config_updated'), self.setup) diff --git a/openlp/core/ui/mainwindow.py b/openlp/core/ui/mainwindow.py index 91fa21810..5dbcbf758 100644 --- a/openlp/core/ui/mainwindow.py +++ b/openlp/core/ui/mainwindow.py @@ -498,7 +498,7 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow): QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'config_screen_changed'), self.screenChanged) QtCore.QObject.connect(Receiver.get_receiver(), - QtCore.SIGNAL(u'status_message'), self.showStatusMessage) + QtCore.SIGNAL(u'maindisplay_status_text'), self.showStatusMessage) QtCore.QObject.connect(self.FileNewItem, QtCore.SIGNAL(u'triggered()'), self.ServiceManagerContents.onNewService) diff --git a/openlp/core/ui/servicemanager.py b/openlp/core/ui/servicemanager.py index 9f0370e95..02c4e3442 100644 --- a/openlp/core/ui/servicemanager.py +++ b/openlp/core/ui/servicemanager.py @@ -714,9 +714,8 @@ class ServiceManager(QtGui.QWidget): item, count = self.findServiceItem() if self.serviceItems[item][u'service_item']\ .is_capable(ItemCapabilities.AllowsEdit): - self.remoteEditTriggered = True Receiver.send_message(u'%s_edit' % - self.serviceItems[item][u'service_item'].name, u'L:%s' % + self.serviceItems[item][u'service_item'].name.lower(), u'L:%s' % self.serviceItems[item][u'service_item'].editId ) def findServiceItem(self): diff --git a/openlp/core/ui/slidecontroller.py b/openlp/core/ui/slidecontroller.py index 8d2e41c72..46c9f8e71 100644 --- a/openlp/core/ui/slidecontroller.py +++ b/openlp/core/ui/slidecontroller.py @@ -315,23 +315,23 @@ class SlideController(QtGui.QWidget): QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'maindisplay_stop_loop'), self.onStopLoop) QtCore.QObject.connect(Receiver.get_receiver(), - QtCore.SIGNAL(u'slidecontroller_%s_go_first' % self.type_prefix), + QtCore.SIGNAL(u'slidecontroller_%s_first' % self.type_prefix), self.onSlideSelectedFirst) QtCore.QObject.connect(Receiver.get_receiver(), - QtCore.SIGNAL(u'slidecontroller_%s_go_next' % self.type_prefix), + QtCore.SIGNAL(u'slidecontroller_%s_next' % self.type_prefix), self.onSlideSelectedNext) QtCore.QObject.connect(Receiver.get_receiver(), - QtCore.SIGNAL(u'slidecontroller_%s_go_previous' % self.type_prefix), + QtCore.SIGNAL(u'slidecontroller_%s_previous' % self.type_prefix), self.onSlideSelectedPrevious) QtCore.QObject.connect(Receiver.get_receiver(), - QtCore.SIGNAL(u'slidecontroller_%s_go_next_noloop' % self.type_prefix), + QtCore.SIGNAL(u'slidecontroller_%s_next_noloop' % self.type_prefix), self.onSlideSelectedNextNoloop) QtCore.QObject.connect(Receiver.get_receiver(), - QtCore.SIGNAL(u'slidecontroller_%s_go_previous_noloop' % + QtCore.SIGNAL(u'slidecontroller_%s_previous_noloop' % self.type_prefix), self.onSlideSelectedPreviousNoloop) QtCore.QObject.connect(Receiver.get_receiver(), - QtCore.SIGNAL(u'slidecontroller_%s_go_last' % self.type_prefix), + QtCore.SIGNAL(u'slidecontroller_%s_last' % self.type_prefix), self.onSlideSelectedLast) QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'slidecontroller_%s_change' % self.type_prefix), @@ -608,10 +608,10 @@ class SlideController(QtGui.QWidget): """ if self.serviceItem is not None: if blanked: - Receiver.send_message(u'slidecontroller_blank' % + Receiver.send_message(u'slidecontroller_blank', [self.serviceItem, self.isLive]) else: - Receiver.send_message(u'slidecontroller_unblank' % + Receiver.send_message(u'slidecontroller_unblank', [self.serviceItem, self.isLive]) self.parent.mainDisplay.blankDisplay(blankType, blanked) else: @@ -756,7 +756,7 @@ class SlideController(QtGui.QWidget): def onEditSong(self): self.songEdit = True Receiver.send_message(u'%s_edit' % - self.serviceItem.name.lower(), u'L:%s' % + self.serviceItem.name.lower(), u'P:%s' % self.serviceItem.editId) def onGoLive(self): @@ -773,7 +773,7 @@ class SlideController(QtGui.QWidget): blanked = self.blankButton.isChecked() else: blanked = False - Receiver.send_message(u'slidecontroller_media_start', + Receiver.send_message(u'mediacontroller_start', [item, self.isLive, blanked]) if not self.isLive: self.mediaObject.stop() @@ -785,13 +785,13 @@ class SlideController(QtGui.QWidget): self.onMediaPlay() def onMediaPause(self): - Receiver.send_message(u'slidecontroller_media_pause', + Receiver.send_message(u'mediacontroller_pause', [item, self.isLive]) if not self.isLive: self.mediaObject.pause() def onMediaPlay(self): - Receiver.send_message(u'slidecontroller_media_play', + Receiver.send_message(u'mediacontroller_play', [item, self.isLive]) if not self.isLive: self.SlidePreview.hide() @@ -799,7 +799,7 @@ class SlideController(QtGui.QWidget): self.mediaObject.play() def onMediaStop(self): - Receiver.send_message(u'slidecontroller_media_stop', + Receiver.send_message(u'mediacontroller_stop', [item, self.isLive]) if not self.isLive: self.mediaObject.stop() diff --git a/openlp/plugins/alerts/alertsplugin.py b/openlp/plugins/alerts/alertsplugin.py index aeba0ab41..975192da3 100644 --- a/openlp/plugins/alerts/alertsplugin.py +++ b/openlp/plugins/alerts/alertsplugin.py @@ -88,7 +88,6 @@ class alertsPlugin(Plugin): def onAlertsTrigger(self): self.alertForm.loadList() self.alertForm.exec_() - Receiver.send_message(u'text_onTop') def about(self): about_text = self.trUtf8('Alerts Plugin
This plugin ' diff --git a/openlp/plugins/alerts/lib/alertsmanager.py b/openlp/plugins/alerts/lib/alertsmanager.py index 2f30ca84a..a933d49fd 100644 --- a/openlp/plugins/alerts/lib/alertsmanager.py +++ b/openlp/plugins/alerts/lib/alertsmanager.py @@ -82,10 +82,10 @@ class AlertsManager(QtCore.QObject): self.screenChanged() self.alertList.append(text) if self.timer_id != 0: - Receiver.send_message(u'status_message', + Receiver.send_message(u'maindisplay_status_text', self.trUtf8(u'Alert message created and delayed')) return - Receiver.send_message(u'status_message', u'') + Receiver.send_message(u'maindisplay_status_text', u'') self.generateAlert() def generateAlert(self): diff --git a/openlp/plugins/remotes/remoteplugin.py b/openlp/plugins/remotes/remoteplugin.py index ede72c954..eff9496ba 100644 --- a/openlp/plugins/remotes/remoteplugin.py +++ b/openlp/plugins/remotes/remoteplugin.py @@ -75,7 +75,7 @@ class RemotesPlugin(Plugin): if event == u'alert': Receiver.send_message(u'alerts_text', unicode(datagram[pos + 1:])) elif event == u'next_slide': - Receiver.send_message(u'slidecontroller_live_go_next') + Receiver.send_message(u'slidecontroller_live_next') else: Receiver.send_message(event, unicode(datagram[pos + 1:])) From fa54f94905f5574aebed488651e45f536ed424cc Mon Sep 17 00:00:00 2001 From: Jonathan Corwin Date: Thu, 22 Apr 2010 22:22:09 +0100 Subject: [PATCH 10/63] Finish signal refactor --- openlp/core/lib/eventreceiver.py | 146 ++++++++++++------ openlp/core/lib/mediamanageritem.py | 5 +- openlp/core/ui/maindisplay.py | 23 +-- openlp/core/ui/servicemanager.py | 2 - openlp/core/ui/slidecontroller.py | 54 +++---- .../presentations/lib/messagelistener.py | 56 +++---- openlp/plugins/songusage/songusageplugin.py | 5 +- 7 files changed, 159 insertions(+), 132 deletions(-) diff --git a/openlp/core/lib/eventreceiver.py b/openlp/core/lib/eventreceiver.py index ee69c2db0..6443a4795 100644 --- a/openlp/core/lib/eventreceiver.py +++ b/openlp/core/lib/eventreceiver.py @@ -35,17 +35,80 @@ class EventReceiver(QtCore.QObject): system. This is a private class and should not be used directly but rather via the Receiver class. - ``stop_import`` - Stops the Bible Import - - ``pre_load_bibles`` - Triggers the plugin to relaod the bible lists - - ``process_events`` + ``openlp_process_events`` Requests the Application to flush the events queue - ``{plugin}_add_service_item`` - ask the plugin to push the selected items to the service item + ``openlp_version_check`` + Version has changed so pop up window. + + ``config_updated`` + Informs components the config has changed + + ``config_screen_changed`` + The display monitor has been changed + + ``slidecontroller_{live|preview}_first`` + Moves to the first slide + + ``slidecontroller_{live|preview}_next`` + Moves to the next slide + + ``slidecontroller_{live|preview}_next_noloop`` + Moves to the next slide without auto advance + + ``slidecontroller_{live|preview}_previous`` + Moves to the previous slide + + ``slidecontroller_{live|preview}_previous_noloop`` + Moves to the previous slide, without auto advance + + ``slidecontroller_{live|preview}_last`` + Moves to the last slide + + ``slidecontroller_{live|preview}_started`` + Broadcasts that an item has been made live/previewed + + ``slidecontroller_{live|preview}_change`` + Informs the slidecontroller that a slide change has occurred + + ``slidecontroller_live_spin_delay`` + Pushes out the loop delay + + ``slidecontroller_live_stop_loop`` + Stop the loop on the main display + + ``servicecontroller_next_item`` + Display the next item in the service + + ``maindisplay_blank`` + Blank the maindisplay window + + ``maindisplay_hide`` + Hide the maindisplay window + + ``maindisplay_show`` + Return the maindisplay window + + ``maindisplay_active`` + The maindisplay has been made active + + ``maindisplay_status_text`` + Changes the bottom status bar text on the maindisplay window + + ``maindisplay_blank_check`` + Check to see if the blank display message is required + + ``videodisplay_start`` + Open a media item and prepare for playing + + ``videodisplay_play`` + Start playing a media item + + ``videodisplay_pause`` + Pause a media item + + ``videodisplay_stop`` + Stop playing a media item ``theme_update_list`` send out message with new themes @@ -53,18 +116,6 @@ class EventReceiver(QtCore.QObject): ``theme_update_global`` Tell the components we have a new global theme - ``load_song_list`` - Tells the the song plugin to reload the song list - - ``load_custom_list`` - Tells the the custom plugin to reload the custom list - - ``update_spin_delay`` - Pushes out the Image loop delay - - ``request_spin_delay`` - Requests a spin delay - ``{plugin}_start`` Requests a plugin to start a external program Path and file provided in message @@ -81,42 +132,47 @@ class EventReceiver(QtCore.QObject): ``{plugin}_last`` Requests a plugin to handle a last event + ``{plugin}_slide`` + Requests a plugin to handle a go to specific slide event + ``{plugin}_stop`` Requests a plugin to handle a stop event + ``{plugin}_blank`` + Requests a plugin to handle a blank screen event + + ``{plugin}_unblank`` + Requests a plugin to handle an unblank screen event + ``{plugin}_edit`` Requests a plugin edit a database item with the key as the payload - ``songusage_live`` - Sends live song audit requests to the audit component + ``{plugin}_edit_clear`` + Editing has been completed - ``audit_changed`` - Audit information may have changed + ``{plugin}_load_list`` + Tells the the plugin to reload the media manager list - ``config_updated`` - Informs components the config has changed + ``{plugin}_preview`` + Tells the plugin it's item can be previewed - ``preview_song`` - Tells the song plugin the edit has finished and the song can be previewed - Only available if the edit was triggered by the Preview button. + ``{plugin}_add_service_item`` + Ask the plugin to push the selected items to the service item - ``slidecontroller_change`` - Informs the slidecontroller that a slide change has occurred + ``alerts_text`` + Displays an alert message + + ``bibles_nobook`` + Attempt to find book resulted in no match - ``remote_edit_clear`` - Informs all components that remote edit has been aborted. + ``bibles_showprogress`` + Show progress of bible verse import - ``presentation types`` - Informs all components of the presentation types supported. + ``bibles_hideprogress`` + Hide progress of bible verse import - ``blank_check`` - Check to see if th eblank display message is required - - ``version_check`` - Version has changed so pop up window. - - ``mainDisplay_active`` - Version has changed so pop up window. + ``bibles_stop_import`` + Stops the Bible Import """ def __init__(self): @@ -172,4 +228,4 @@ class Receiver(): """ Get the global ``eventreceiver`` instance. """ - return Receiver.eventreceiver \ No newline at end of file + return Receiver.eventreceiver diff --git a/openlp/core/lib/mediamanageritem.py b/openlp/core/lib/mediamanageritem.py index c37336057..28ee257d3 100644 --- a/openlp/core/lib/mediamanageritem.py +++ b/openlp/core/lib/mediamanageritem.py @@ -422,12 +422,13 @@ class MediaManagerItem(QtGui.QWidget): else: #Is it posssible to process multiple list items to generate multiple #service items? - if self.singleServiceItem: + if self.singleServiceItem or self.remoteTriggered: log.debug(self.PluginNameShort + u' Add requested') service_item = self.buildServiceItem() if service_item: service_item.from_plugin = False - self.parent.service_manager.addServiceItem(service_item) + self.parent.service_manager.addServiceItem(service_item, + replace=self.remoteTriggered) else: items = self.ListView.selectedIndexes() for item in items: diff --git a/openlp/core/ui/maindisplay.py b/openlp/core/ui/maindisplay.py index 7c0b7357e..5e7071449 100644 --- a/openlp/core/ui/maindisplay.py +++ b/openlp/core/ui/maindisplay.py @@ -138,7 +138,7 @@ class MainDisplay(DisplayWidget): QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'maindisplay_show'), self.showDisplay) QtCore.QObject.connect(Receiver.get_receiver(), - QtCore.SIGNAL(u'slidecontroller_live_mediastart'), self.hideDisplay) + QtCore.SIGNAL(u'videodisplay_start'), self.hideDisplay) def setup(self): """ @@ -195,7 +195,7 @@ class MainDisplay(DisplayWidget): def resetDisplay(self): log.debug(u'resetDisplay') - Receiver.send_message(u'maindisplay_stop_loop') + Receiver.send_message(u'slidecontroller_live_stop_loop') if self.primary: self.setVisible(False) else: @@ -325,13 +325,13 @@ class VideoDisplay(Phonon.VideoWidget): Phonon.createPath(self.mediaObject, self) Phonon.createPath(self.mediaObject, self.audioObject) QtCore.QObject.connect(Receiver.get_receiver(), - QtCore.SIGNAL(u'mediacontroller_start'), self.onMediaQueue) + QtCore.SIGNAL(u'videodisplay_start'), self.onMediaQueue) QtCore.QObject.connect(Receiver.get_receiver(), - QtCore.SIGNAL(u'mediacontroller_play'), self.onMediaPlay) + QtCore.SIGNAL(u'videodisplay_play'), self.onMediaPlay) QtCore.QObject.connect(Receiver.get_receiver(), - QtCore.SIGNAL(u'mediacontroller_pause'), self.onMediaPause) + QtCore.SIGNAL(u'videodisplay_pause'), self.onMediaPause) QtCore.QObject.connect(Receiver.get_receiver(), - QtCore.SIGNAL(u'mediacontroller_stop'), self.onMediaStop) + QtCore.SIGNAL(u'videodisplay_stop'), self.onMediaStop) QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'config_updated'), self.setup) @@ -364,40 +364,29 @@ class VideoDisplay(Phonon.VideoWidget): self.primary = True def onMediaQueue(self, message): - if not message[1]: - return log.debug(u'VideoDisplay Queue new media message %s' % message) file = os.path.join(message[0].get_frame_path(), message[0].get_frame_title()) - #file = os.path.join(message[1], message[2]) source = self.mediaObject.setCurrentSource(Phonon.MediaSource(file)) self.onMediaPlay() def onMediaPlay(self): - if not message[1]: - return log.debug(u'VideoDisplay Play the new media, Live ') self.mediaObject.play() self.setVisible(True) self.showFullScreen() def onMediaPause(self): - if not message[1]: - return log.debug(u'VideoDisplay Media paused by user') self.mediaObject.pause() self.show() def onMediaStop(self): - if not message[1]: - return log.debug(u'VideoDisplay Media stopped by user') self.mediaObject.stop() self.onMediaFinish() def onMediaFinish(self): - if not message[1]: - return log.debug(u'VideoDisplay Reached end of media playlist') self.mediaObject.clearQueue() self.setVisible(False) diff --git a/openlp/core/ui/servicemanager.py b/openlp/core/ui/servicemanager.py index 02c4e3442..97430bd87 100644 --- a/openlp/core/ui/servicemanager.py +++ b/openlp/core/ui/servicemanager.py @@ -103,8 +103,6 @@ class ServiceManager(QtGui.QWidget): self.droppos = 0 #is a new service and has not been saved self.isNew = True - #Indicates if remoteTriggering is active. If it is the next addServiceItem call - #will replace the currently selected one. self.serviceNoteForm = ServiceNoteForm() self.serviceItemEditForm = ServiceItemEditForm() #start with the layout diff --git a/openlp/core/ui/slidecontroller.py b/openlp/core/ui/slidecontroller.py index 46c9f8e71..2b34a7c0d 100644 --- a/openlp/core/ui/slidecontroller.py +++ b/openlp/core/ui/slidecontroller.py @@ -313,7 +313,8 @@ class SlideController(QtGui.QWidget): self.Toolbar.makeWidgetsInvisible(self.song_edit_list) self.Mediabar.setVisible(False) QtCore.QObject.connect(Receiver.get_receiver(), - QtCore.SIGNAL(u'maindisplay_stop_loop'), self.onStopLoop) + QtCore.SIGNAL(u'slidecontroller_%s_stop_loop' % self.type_prefix), + self.onStopLoop) QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'slidecontroller_%s_first' % self.type_prefix), self.onSlideSelectedFirst) @@ -480,7 +481,7 @@ class SlideController(QtGui.QWidget): blanked = self.blankButton.isChecked() else: blanked = False - Receiver.send_message(u'slidecontroller_start', + Receiver.send_message(u'%s_start' % serviceItem.name.lower(), [serviceItem, self.isLive, blanked, slideno]) self.slideList = {} width = self.parent.ControlSplitter.sizes()[self.split] @@ -553,6 +554,10 @@ class SlideController(QtGui.QWidget): self.enableToolBar(serviceItem) self.onSlideSelected() self.PreviewListWidget.setFocus() + Receiver.send_message(u'%s_%s_started' % + (self.serviceItem.name.lower(), + 'live' if self.isLive else 'preview'), + [serviceItem]) log.log(15, u'Display Rendering took %4s' % (time.time() - before)) #Screen event methods @@ -562,7 +567,7 @@ class SlideController(QtGui.QWidget): """ if not self.serviceItem: return - Receiver.send_message(u'slidecontroller_first', + Receiver.send_message(u'%s_first' % self.serviceItem.name.lower(), [self.serviceItem, self.isLive]) if self.serviceItem.is_command(): self.updatePreview() @@ -608,10 +613,11 @@ class SlideController(QtGui.QWidget): """ if self.serviceItem is not None: if blanked: - Receiver.send_message(u'slidecontroller_blank', + Receiver.send_message(u'%s_blank' % self.serviceItem.name.lower(), [self.serviceItem, self.isLive]) else: - Receiver.send_message(u'slidecontroller_unblank', + Receiver.send_message(u'%s_unblank' + % self.serviceItem.name.lower(), [self.serviceItem, self.isLive]) self.parent.mainDisplay.blankDisplay(blankType, blanked) else: @@ -625,7 +631,7 @@ class SlideController(QtGui.QWidget): row = self.PreviewListWidget.currentRow() self.selectedRow = 0 if row > -1 and row < self.PreviewListWidget.rowCount(): - Receiver.send_message(u'slidecontroller_slide', + Receiver.send_message(u'%s_slide' % self.serviceItem.name.lower(), [self.serviceItem, self.isLive, row]) if self.serviceItem.is_command() and self.isLive: self.updatePreview() @@ -679,7 +685,7 @@ class SlideController(QtGui.QWidget): """ if not self.serviceItem: return - Receiver.send_message(u'slidecontroller_next', + Receiver.send_message(u'%s_next' % self.serviceItem.name.lower(), [self.serviceItem, self.isLive]) if self.serviceItem.is_command(): self.updatePreview() @@ -703,7 +709,7 @@ class SlideController(QtGui.QWidget): """ if not self.serviceItem: return - Receiver.send_message(u'slidecontroller_previous', + Receiver.send_message(u'%s_previous' % self.serviceItem.name.lower(), [self.serviceItem, self.isLive]) if self.serviceItem.is_command(): self.updatePreview() @@ -723,7 +729,7 @@ class SlideController(QtGui.QWidget): """ if not self.serviceItem: return - Receiver.send_message(u'slidecontroller_last', + Receiver.send_message(u'%s_last' % self.serviceItem.name.lower(), [self.serviceItem, self.isLive]) if self.serviceItem.is_command(): self.updatePreview() @@ -755,9 +761,8 @@ class SlideController(QtGui.QWidget): def onEditSong(self): self.songEdit = True - Receiver.send_message(u'%s_edit' % - self.serviceItem.name.lower(), u'P:%s' % - self.serviceItem.editId) + Receiver.send_message(u'%s_edit' % self.serviceItem.name.lower(), + u'P:%s' % self.serviceItem.editId) def onGoLive(self): """ @@ -770,12 +775,9 @@ class SlideController(QtGui.QWidget): def onMediaStart(self, item): if self.isLive: - blanked = self.blankButton.isChecked() + Receiver.send_message(u'videodisplay_start', + [item, self.blankButton.isChecked()]) else: - blanked = False - Receiver.send_message(u'mediacontroller_start', - [item, self.isLive, blanked]) - if not self.isLive: self.mediaObject.stop() self.mediaObject.clearQueue() file = os.path.join(item.get_frame_path(), item.get_frame_title()) @@ -785,23 +787,23 @@ class SlideController(QtGui.QWidget): self.onMediaPlay() def onMediaPause(self): - Receiver.send_message(u'mediacontroller_pause', - [item, self.isLive]) - if not self.isLive: + if self.isLive: + Receiver.send_message(u'videodisplay_pause') + else: self.mediaObject.pause() def onMediaPlay(self): - Receiver.send_message(u'mediacontroller_play', - [item, self.isLive]) - if not self.isLive: + if self.isLive: + Receiver.send_message(u'videodisplay_play') + else: self.SlidePreview.hide() self.video.show() self.mediaObject.play() def onMediaStop(self): - Receiver.send_message(u'mediacontroller_stop', - [item, self.isLive]) - if not self.isLive: + if self.isLive: + Receiver.send_message(u'videodisplay_stop') + else: self.mediaObject.stop() self.video.hide() self.SlidePreview.clear() diff --git a/openlp/plugins/presentations/lib/messagelistener.py b/openlp/plugins/presentations/lib/messagelistener.py index 37bfa564d..3a97cedaf 100644 --- a/openlp/plugins/presentations/lib/messagelistener.py +++ b/openlp/plugins/presentations/lib/messagelistener.py @@ -186,23 +186,23 @@ class MessageListener(object): self.liveHandler = Controller(True) # messages are sent from core.ui.slidecontroller QtCore.QObject.connect(Receiver.get_receiver(), - QtCore.SIGNAL(u'slidecontroller_start'), self.startup) + QtCore.SIGNAL(u'presentation_start'), self.startup) QtCore.QObject.connect(Receiver.get_receiver(), - QtCore.SIGNAL(u'slidecontroller_stop'), self.shutdown) + QtCore.SIGNAL(u'presentation_stop'), self.shutdown) QtCore.QObject.connect(Receiver.get_receiver(), - QtCore.SIGNAL(u'slidecontroller_first'), self.first) + QtCore.SIGNAL(u'presentation_first'), self.first) QtCore.QObject.connect(Receiver.get_receiver(), - QtCore.SIGNAL(u'slidecontroller_previous'), self.previous) + QtCore.SIGNAL(u'presentation_previous'), self.previous) QtCore.QObject.connect(Receiver.get_receiver(), - QtCore.SIGNAL(u'slidecontroller_next'), self.next) + QtCore.SIGNAL(u'presentation_next'), self.next) QtCore.QObject.connect(Receiver.get_receiver(), - QtCore.SIGNAL(u'slidecontroller_last'), self.last) + QtCore.SIGNAL(u'presentation_last'), self.last) QtCore.QObject.connect(Receiver.get_receiver(), - QtCore.SIGNAL(u'slidecontroller_slide'), self.slide) + QtCore.SIGNAL(u'presentation_slide'), self.slide) QtCore.QObject.connect(Receiver.get_receiver(), - QtCore.SIGNAL(u'slidecontroller_blank'), self.blank) + QtCore.SIGNAL(u'presentation_blank'), self.blank) QtCore.QObject.connect(Receiver.get_receiver(), - QtCore.SIGNAL(u'slidecontroller_unblank'), self.unblank) + QtCore.SIGNAL(u'presentation_unblank'), self.unblank) self.timer = QtCore.QTimer() self.timer.setInterval(500) QtCore.QObject.connect(self.timer, QtCore.SIGNAL("timeout()"), self.timeout) @@ -212,9 +212,7 @@ class MessageListener(object): Start of new presentation Save the handler as any new presentations start here """ - name, isLive, item = self.decode_message(message) - if name != u'presentation': - return + isLive, item = self.decode_message(message) log.debug(u'Startup called with message %s' % message) isBlank = message[2] file = os.path.join(item.get_frame_path(), @@ -231,57 +229,45 @@ class MessageListener(object): controller.addHandler(self.controllers[self.handler], file, isBlank) def decode_message(self, message): - return message[0].name.lower(), message[1], message[0] + return message[1], message[0] def slide(self, message): - name, isLive, item = self.decode_message(message) - if name != u'presentation': - return + isLive, item = self.decode_message(message) if isLive: self.liveHandler.slide(slide, live) else: self.previewHandler.slide(slide, live) def first(self, message): - name, isLive, item = self.decode_message(message) - if name != u'presentation': - return + isLive, item = self.decode_message(message) if isLive: self.liveHandler.first() else: self.previewHandler.first() def last(self, message): - name, isLive, item = self.decode_message(message) - if name != u'presentation': - return + isLive, item = self.decode_message(message) if isLive: self.liveHandler.last() else: self.previewHandler.last() def next(self, message): - name, isLive, item = self.decode_message(message) - if name != u'presentation': - return + isLive, item = self.decode_message(message) if isLive: self.liveHandler.next() else: self.previewHandler.next() def previous(self, message): - name, isLive, item = self.decode_message(message) - if name != u'presentation': - return + isLive, item = self.decode_message(message) if isLive: self.liveHandler.previous() else: self.previewHandler.previous() def shutdown(self, message): - name, isLive, item = self.decode_message(message) - if name != u'presentation': - return + isLive, item = self.decode_message(message) if isLive: Receiver.send_message(u'maindisplay_show') self.liveHandler.shutdown() @@ -289,16 +275,12 @@ class MessageListener(object): self.previewHandler.shutdown() def blank(self, message): - name, isLive, item = self.decode_message(message) - if name != u'presentation': - return + isLive, item = self.decode_message(message) if isLive: self.liveHandler.blank() def unblank(self, message): - name, isLive, item = self.decode_message(message) - if name != u'presentation': - return + isLive, item = self.decode_message(message) if isLive: self.liveHandler.unblank() diff --git a/openlp/plugins/songusage/songusageplugin.py b/openlp/plugins/songusage/songusageplugin.py index c4a255d06..3d7f9ad45 100644 --- a/openlp/plugins/songusage/songusageplugin.py +++ b/openlp/plugins/songusage/songusageplugin.py @@ -107,7 +107,7 @@ class SongUsagePlugin(Plugin): log.info(u'SongUsage Initialising') Plugin.initialise(self) QtCore.QObject.connect(Receiver.get_receiver(), - QtCore.SIGNAL(u'slidecontroller_start'), self.onReceiveSongUsage) + QtCore.SIGNAL(u'slidecontroller_live_started'), self.onReceiveSongUsage) self.SongUsageActive = str_to_bool( self.config.get_config(u'active', False)) self.SongUsageStatus.setChecked(self.SongUsageActive) @@ -132,8 +132,7 @@ class SongUsagePlugin(Plugin): SongUsage a live song from SlideController """ audit = items[0].audit - live = items[1] - if self.SongUsageActive and audit and live: + if self.SongUsageActive and audit: song_usage_item = SongUsageItem() song_usage_item.usagedate = datetime.today() song_usage_item.usagetime = datetime.now().time() From 81a208654ad78d0635d239de6af5ff39225e8fef Mon Sep 17 00:00:00 2001 From: Jon Tibble Date: Fri, 23 Apr 2010 15:09:54 +0100 Subject: [PATCH 11/63] Remove redundant code --- openlp.pyw | 5 ----- 1 file changed, 5 deletions(-) diff --git a/openlp.pyw b/openlp.pyw index 528923862..9601e1582 100755 --- a/openlp.pyw +++ b/openlp.pyw @@ -110,11 +110,6 @@ class OpenLP(QtGui.QApplication): finally: if fversion: fversion.close() - #set the default string encoding - try: - sys.setappdefaultencoding(u'utf-8') - except: - pass #provide a listener for widgets to reqest a screen update. QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'process_events'), self.processEvents) From 37720b9cdbebcdf4c1ed5e20029fb6080e83b282 Mon Sep 17 00:00:00 2001 From: Jon Tibble Date: Fri, 23 Apr 2010 17:00:32 +0100 Subject: [PATCH 12/63] Add add_actions support function --- openlp/core/utils/__init__.py | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/openlp/core/utils/__init__.py b/openlp/core/utils/__init__.py index 12fc4a293..d060c8ca2 100644 --- a/openlp/core/utils/__init__.py +++ b/openlp/core/utils/__init__.py @@ -64,7 +64,8 @@ class AppLocation(object): else: try: from xdg import BaseDirectory - path = os.path.join(BaseDirectory.xdg_config_home, u'openlp') + path = os.path.join( + BaseDirectory.xdg_config_home, u'openlp') except ImportError: path = os.path.join(os.getenv(u'HOME'), u'.openlp') return path @@ -117,7 +118,8 @@ def check_latest_version(config, current_version): if last_test != this_test: version_string = u'' if current_version[u'build']: - req = urllib2.Request(u'http://www.openlp.org/files/dev_version.txt') + req = urllib2.Request( + u'http://www.openlp.org/files/dev_version.txt') else: req = urllib2.Request(u'http://www.openlp.org/files/version.txt') req.add_header(u'User-Agent', u'OpenLP/%s' % current_version[u'full']) @@ -149,7 +151,24 @@ def variant_to_unicode(variant): string = string_to_unicode(string) return string +def add_actions(target, actions): + """ + Adds multiple actions to a menu or toolbar in one command. + + ``target`` + The menu or toolbar to add actions to. + + ``actions`` + The actions to be added. + """ + for action in actions: + if action is None: + target.addSeparator() + else: + target.addAction(action) + from registry import Registry from confighelper import ConfigHelper -__all__ = [u'Registry', u'ConfigHelper', u'AppLocation', u'check_latest_version'] +__all__ = [u'Registry', u'ConfigHelper', u'AppLocation', + u'check_latest_version', u'add_actions'] From 460964c3712558c16e0b4e48a2db5381a60e24b8 Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Fri, 23 Apr 2010 17:03:12 +0100 Subject: [PATCH 13/63] fixes --- openlp.pyw | 8 +++++++- openlp/core/lib/mediamanageritem.py | 2 +- openlp/core/lib/renderer.py | 3 ++- openlp/core/ui/servicemanager.py | 1 + 4 files changed, 11 insertions(+), 3 deletions(-) diff --git a/openlp.pyw b/openlp.pyw index 528923862..1726c806f 100755 --- a/openlp.pyw +++ b/openlp.pyw @@ -193,7 +193,13 @@ def main(): qInitResources() # Now create and actually run the application. app = OpenLP(qt_args) - sys.exit(app.run()) + try: + a = app.run() + print a + except: + log.exception(u'it went bang') + + sys.exit(a) if __name__ == u'__main__': """ diff --git a/openlp/core/lib/mediamanageritem.py b/openlp/core/lib/mediamanageritem.py index 05ce36ad1..c12d6bc6b 100644 --- a/openlp/core/lib/mediamanageritem.py +++ b/openlp/core/lib/mediamanageritem.py @@ -425,7 +425,7 @@ class MediaManagerItem(QtGui.QWidget): else: #Is it posssible to process multiple list items to generate multiple #service items? - if self.singleServiceItem: + if self.singleServiceItem or self.remoteTriggered: log.debug(self.PluginNameShort + u' Add requested') service_item = self.buildServiceItem() if service_item: diff --git a/openlp/core/lib/renderer.py b/openlp/core/lib/renderer.py index f574ed6a8..beec5389c 100644 --- a/openlp/core/lib/renderer.py +++ b/openlp/core/lib/renderer.py @@ -244,7 +244,8 @@ class Renderer(object): bbox1 = self._render_lines_unaligned(footer_lines, True) # reset the frame. first time do not worry about what you paint on. self._frame = QtGui.QImage(self.bg_frame) - self._frameOp = QtGui.QImage(self.bg_frame) + if self._theme.display_slideTransition: + self._frameOp = QtGui.QImage(self.bg_frame) x, y = self._correctAlignment(self._rect, bbox) bbox = self._render_lines_unaligned(lines, False, (x, y), True) if footer_lines: diff --git a/openlp/core/ui/servicemanager.py b/openlp/core/ui/servicemanager.py index 27ca95d0e..21d31644b 100644 --- a/openlp/core/ui/servicemanager.py +++ b/openlp/core/ui/servicemanager.py @@ -653,6 +653,7 @@ class ServiceManager(QtGui.QWidget): """ sitem, count = self.findServiceItem() item.render() + print self.remoteEditTriggered if self.remoteEditTriggered: item.merge(self.serviceItems[sitem][u'service_item']) self.serviceItems[sitem][u'service_item'] = item From fbc36e3e9a28729355f190c5735e262201bf4639 Mon Sep 17 00:00:00 2001 From: Jon Tibble Date: Fri, 23 Apr 2010 19:30:53 +0100 Subject: [PATCH 14/63] Add recent files functionality --- openlp.pyw | 2 + openlp/core/ui/mainwindow.py | 119 +++++++++++++++++++------------ openlp/core/ui/servicemanager.py | 21 ++++-- 3 files changed, 93 insertions(+), 49 deletions(-) diff --git a/openlp.pyw b/openlp.pyw index 9601e1582..85de9fe79 100755 --- a/openlp.pyw +++ b/openlp.pyw @@ -113,6 +113,8 @@ class OpenLP(QtGui.QApplication): #provide a listener for widgets to reqest a screen update. QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'process_events'), self.processEvents) + self.setOrganizationName(u'OpenLP') + self.setOrganizationDomain(u'openlp.org') self.setApplicationName(u'OpenLP') self.setApplicationVersion(app_version[u'version']) if os.name == u'nt': diff --git a/openlp/core/ui/mainwindow.py b/openlp/core/ui/mainwindow.py index 469bc6d69..99a246d69 100644 --- a/openlp/core/ui/mainwindow.py +++ b/openlp/core/ui/mainwindow.py @@ -28,12 +28,11 @@ import time from PyQt4 import QtCore, QtGui -from openlp.core.ui import AboutForm, SettingsForm, \ - ServiceManager, ThemeManager, SlideController, \ - PluginForm, MediaDockManager, DisplayManager +from openlp.core.ui import AboutForm, SettingsForm, ServiceManager, \ + ThemeManager, SlideController, PluginForm, MediaDockManager, DisplayManager from openlp.core.lib import RenderManager, PluginConfig, build_icon, \ OpenLPDockWidget, SettingsManager, PluginManager, Receiver, str_to_bool -from openlp.core.utils import check_latest_version, AppLocation +from openlp.core.utils import check_latest_version, AppLocation, add_actions log = logging.getLogger(__name__) @@ -273,50 +272,36 @@ class Ui_MainWindow(object): self.settingsmanager.showPreviewPanel) self.ModeLiveItem = QtGui.QAction(MainWindow) self.ModeLiveItem.setObjectName(u'ModeLiveItem') - self.FileImportMenu.addAction(self.ImportThemeItem) - self.FileImportMenu.addAction(self.ImportLanguageItem) - self.FileExportMenu.addAction(self.ExportThemeItem) - self.FileExportMenu.addAction(self.ExportLanguageItem) - self.FileMenu.addAction(self.FileNewItem) - self.FileMenu.addAction(self.FileOpenItem) - self.FileMenu.addAction(self.FileSaveItem) - self.FileMenu.addAction(self.FileSaveAsItem) - self.FileMenu.addSeparator() - self.FileMenu.addAction(self.FileImportMenu.menuAction()) - self.FileMenu.addAction(self.FileExportMenu.menuAction()) - self.FileMenu.addSeparator() - self.FileMenu.addAction(self.FileExitItem) - self.ViewModeMenu.addAction(self.ModeLiveItem) - self.OptionsViewMenu.addAction(self.ViewModeMenu.menuAction()) - self.OptionsViewMenu.addSeparator() - self.OptionsViewMenu.addAction(self.ViewMediaManagerItem) - self.OptionsViewMenu.addAction(self.ViewServiceManagerItem) - self.OptionsViewMenu.addAction(self.ViewThemeManagerItem) - self.OptionsViewMenu.addSeparator() - self.OptionsViewMenu.addAction(self.action_Preview_Panel) - self.OptionsLanguageMenu.addAction(self.LanguageEnglishItem) - self.OptionsLanguageMenu.addSeparator() - self.OptionsLanguageMenu.addAction(self.LanguageTranslateItem) - self.OptionsMenu.addAction(self.OptionsLanguageMenu.menuAction()) - self.OptionsMenu.addAction(self.OptionsViewMenu.menuAction()) - self.OptionsMenu.addSeparator() - self.OptionsMenu.addAction(self.OptionsSettingsItem) - self.ToolsMenu.addAction(self.PluginItem) - self.ToolsMenu.addSeparator() - self.ToolsMenu.addAction(self.ToolsAddToolItem) - self.HelpMenu.addAction(self.HelpDocumentationItem) - self.HelpMenu.addAction(self.HelpOnlineHelpItem) - self.HelpMenu.addSeparator() - self.HelpMenu.addAction(self.HelpWebSiteItem) - self.HelpMenu.addAction(self.HelpAboutItem) - self.MenuBar.addAction(self.FileMenu.menuAction()) - self.MenuBar.addAction(self.OptionsMenu.menuAction()) - self.MenuBar.addAction(self.ToolsMenu.menuAction()) - self.MenuBar.addAction(self.HelpMenu.menuAction()) + add_actions(self.FileImportMenu, + (self.ImportThemeItem, self.ImportLanguageItem)) + add_actions(self.FileExportMenu, + (self.ExportThemeItem, self.ExportLanguageItem)) + self.FileMenuActions = (self.FileNewItem, self.FileOpenItem, + self.FileSaveItem, self.FileSaveAsItem, None, + self.FileImportMenu.menuAction(), self.FileExportMenu.menuAction(), + self.FileExitItem) + add_actions(self.ViewModeMenu, [self.ModeLiveItem]) + add_actions(self.OptionsViewMenu, (self.ViewModeMenu.menuAction(), + None, self.ViewMediaManagerItem, self.ViewServiceManagerItem, + self.ViewThemeManagerItem, None, self.action_Preview_Panel)) + add_actions(self.OptionsLanguageMenu, (self.LanguageEnglishItem, None, + self.LanguageTranslateItem)) + add_actions(self.OptionsMenu, (self.OptionsLanguageMenu.menuAction(), + self.OptionsViewMenu.menuAction(), None, self.OptionsSettingsItem)) + add_actions(self.ToolsMenu, + (self.PluginItem, None, self.ToolsAddToolItem)) + add_actions(self.HelpMenu, + (self.HelpDocumentationItem, self.HelpOnlineHelpItem, None, + self.HelpWebSiteItem, self.HelpAboutItem)) + add_actions(self.MenuBar, + (self.FileMenu.menuAction(), self.OptionsMenu.menuAction(), + self.ToolsMenu.menuAction(), self.HelpMenu.menuAction())) # Initialise the translation self.retranslateUi(MainWindow) self.MediaToolBox.setCurrentIndex(0) # Connect up some signals and slots + QtCore.QObject.connect(self.FileMenu, + QtCore.SIGNAL(u'aboutToShow()'), self.updateFileMenu) QtCore.QObject.connect(self.FileExitItem, QtCore.SIGNAL(u'triggered()'), MainWindow.close) QtCore.QObject.connect(self.ControlSplitter, @@ -445,12 +430,17 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow): self.displayManager = DisplayManager(screens) self.aboutForm = AboutForm(self, applicationVersion) self.settingsForm = SettingsForm(self.screens, self, self) + self.recentFiles = [] # Set up the path with plugins pluginpath = AppLocation.get_directory(AppLocation.PluginsDir) self.plugin_manager = PluginManager(pluginpath) self.plugin_helpers = {} # Set up the interface self.setupUi(self) + # Load settings after setupUi so defaults UI sizes are overwritten + self.loadSettings() + # Once settings are loaded update FileMenu with recentFiles + self.updateFileMenu() self.pluginForm = PluginForm(self) # Set up signals and slots QtCore.QObject.connect(self.ImportThemeItem, @@ -666,6 +656,8 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow): # Call the cleanup method to shutdown plugins. log.info(u'cleanup plugins') self.plugin_manager.finalise_plugins() + # Save settings + self.saveSettings() #Close down the displays self.displayManager.close() @@ -720,3 +712,42 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow): previewBool = self.PreviewController.Panel.isVisible() self.PreviewController.Panel.setVisible(not previewBool) self.settingsmanager.togglePreviewPanel(not previewBool) + + def loadSettings(self): + log.debug(u'Loading QSettings') + settings = QtCore.QSettings() + self.recentFiles = settings.value(u'RecentFiles').toStringList() + + def saveSettings(self): + log.debug(u'Saving QSettings') + settings = QtCore.QSettings() + recentFiles = QtCore.QVariant(self.recentFiles) \ + if self.recentFiles else QtCore.QVariant() + settings.setValue(u'RecentFiles', recentFiles) + + def updateFileMenu(self): + self.FileMenu.clear() + add_actions(self.FileMenu, self.FileMenuActions[:-1]) + existingRecentFiles = [] + for file in self.recentFiles: + if QtCore.QFile.exists(file): + existingRecentFiles.append(file) + if existingRecentFiles: + self.FileMenu.addSeparator() + for fileId, filename in enumerate(existingRecentFiles): + action = QtGui.QAction(u'&%d %s' % (fileId +1, + QtCore.QFileInfo(filename).fileName()), self) + action.setData(QtCore.QVariant(filename)) + self.connect(action, QtCore.SIGNAL(u'triggered()'), + self.ServiceManagerContents.loadService) + self.FileMenu.addAction(action) + self.FileMenu.addSeparator() + self.FileMenu.addAction(self.FileMenuActions[-1]) + + def addRecentFile(self, filename): + recentFileCount = int(PluginConfig(u'General'). + get_config(u'max recent files', 4)) + if filename and not self.recentFiles.contains(filename): + self.recentFiles.prepend(QtCore.QString(filename)) + while self.recentFiles.count() > recentFileCount: + self.recentFiles.takeLast() diff --git a/openlp/core/ui/servicemanager.py b/openlp/core/ui/servicemanager.py index 27ca95d0e..e2be00b7d 100644 --- a/openlp/core/ui/servicemanager.py +++ b/openlp/core/ui/servicemanager.py @@ -538,23 +538,33 @@ class ServiceManager(QtGui.QWidget): pass #if not present do not worry name = filename.split(os.path.sep) self.serviceName = name[-1] + self.parent.addRecentFile(filename) self.parent.serviceChanged(True, self.serviceName) def onQuickSaveService(self): self.onSaveService(True) def onLoadService(self, lastService=False): - """ - Load an existing service from disk and rebuild the serviceitems. All - files retrieved from the zip file are placed in a temporary directory - and will only be used for this service. - """ if lastService: filename = self.config.get_last_dir() else: filename = QtGui.QFileDialog.getOpenFileName( self, self.trUtf8('Open Service'), self.config.get_last_dir(), u'Services (*.osz)') + self.loadService(filename) + + def loadService(self, filename=None): + """ + Load an existing service from disk and rebuild the serviceitems. All + files retrieved from the zip file are placed in a temporary directory + and will only be used for this service. + """ + if filename is None: + action = self.sender() + if isinstance(action, QtGui.QAction): + filename = action.data().toString() + else: + return filename = unicode(filename) name = filename.split(os.path.sep) if filename: @@ -598,6 +608,7 @@ class ServiceManager(QtGui.QWidget): zip.close() self.isNew = False self.serviceName = name[len(name) - 1] + self.parent.addRecentFile(filename) self.parent.serviceChanged(True, self.serviceName) def validateItem(self, serviceItem): From e6400413185a5c93238ebd83139e9f9c97b223c3 Mon Sep 17 00:00:00 2001 From: Jon Tibble Date: Fri, 23 Apr 2010 20:42:51 +0100 Subject: [PATCH 15/63] Document separators in add_actions --- openlp/core/utils/__init__.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/openlp/core/utils/__init__.py b/openlp/core/utils/__init__.py index d060c8ca2..1900c554e 100644 --- a/openlp/core/utils/__init__.py +++ b/openlp/core/utils/__init__.py @@ -111,7 +111,7 @@ def check_latest_version(config, current_version): The current version of OpenLP. """ version_string = current_version[u'full'] - #set to prod in the distribution confif file. + #set to prod in the distribution config file. last_test = config.get_config(u'last version test', datetime.now().date()) this_test = unicode(datetime.now().date()) config.set_config(u'last version test', this_test) @@ -159,7 +159,8 @@ def add_actions(target, actions): The menu or toolbar to add actions to. ``actions`` - The actions to be added. + The actions to be added. An action consisting of the keyword 'None' + will result in a separator being inserted into the target. """ for action in actions: if action is None: From fde108d4b48143a690d23a3d04310e6a36f7587a Mon Sep 17 00:00:00 2001 From: Jon Tibble Date: Fri, 23 Apr 2010 20:55:31 +0100 Subject: [PATCH 16/63] Warn before loading over unsaved service --- openlp/core/ui/servicemanager.py | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/openlp/core/ui/servicemanager.py b/openlp/core/ui/servicemanager.py index e2be00b7d..2e1d1c872 100644 --- a/openlp/core/ui/servicemanager.py +++ b/openlp/core/ui/servicemanager.py @@ -416,8 +416,8 @@ class ServiceManager(QtGui.QWidget): get_config(u'save prompt', u'False')): ret = QtGui.QMessageBox.question(self, self.trUtf8('Save Changes to Service?'), - self.trUtf8('Your service is unsaved, do you want to save those ' - 'changes before creating a new one ?'), + self.trUtf8('Your service is unsaved, do you want to save ' + 'those changes before creating a new one?'), QtGui.QMessageBox.StandardButtons( QtGui.QMessageBox.Cancel | QtGui.QMessageBox.Save), @@ -514,7 +514,8 @@ class ServiceManager(QtGui.QWidget): try: zip = zipfile.ZipFile(unicode(filename), 'w') for item in self.serviceItems: - service.append({u'serviceitem':item[u'service_item'].get_service_repr()}) + service.append({u'serviceitem':item[u'service_item'] + .get_service_repr()}) if item[u'service_item'].uses_file(): for frame in item[u'service_item'].get_frames(): path_from = unicode(os.path.join( @@ -559,6 +560,17 @@ class ServiceManager(QtGui.QWidget): files retrieved from the zip file are placed in a temporary directory and will only be used for this service. """ + if self.parent.serviceNotSaved: + ret = QtGui.QMessageBox.question(self, + self.trUtf8('Save Changes to Service?'), + self.trUtf8('Your current service is unsaved, do you want to ' + 'save the changes before opening a new one?'), + QtGui.QMessageBox.StandardButtons( + QtGui.QMessageBox.Discard | + QtGui.QMessageBox.Save), + QtGui.QMessageBox.Save) + if ret == QtGui.QMessageBox.Save: + self.onSaveService() if filename is None: action = self.sender() if isinstance(action, QtGui.QAction): From b8f940565ecb697471b5134909ddff759c278e24 Mon Sep 17 00:00:00 2001 From: Jon Tibble Date: Fri, 23 Apr 2010 21:39:27 +0100 Subject: [PATCH 17/63] Import fixes --- openlp/core/lib/serviceitem.py | 2 +- openlp/plugins/alerts/alertsplugin.py | 2 +- openlp/plugins/alerts/forms/alertstab.py | 2 +- openlp/plugins/presentations/presentationplugin.py | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/openlp/core/lib/serviceitem.py b/openlp/core/lib/serviceitem.py index 3f3eedf5d..4374f98aa 100644 --- a/openlp/core/lib/serviceitem.py +++ b/openlp/core/lib/serviceitem.py @@ -30,7 +30,7 @@ import uuid from PyQt4 import QtGui -from openlp.core.lib import build_icon, Receiver, resize_image +from openlp.core.lib import build_icon, resize_image log = logging.getLogger(__name__) diff --git a/openlp/plugins/alerts/alertsplugin.py b/openlp/plugins/alerts/alertsplugin.py index 975192da3..819e8eed6 100644 --- a/openlp/plugins/alerts/alertsplugin.py +++ b/openlp/plugins/alerts/alertsplugin.py @@ -27,7 +27,7 @@ import logging from PyQt4 import QtCore, QtGui -from openlp.core.lib import Plugin, build_icon, PluginStatus, Receiver +from openlp.core.lib import Plugin, build_icon, PluginStatus from openlp.plugins.alerts.lib import AlertsManager, DBManager from openlp.plugins.alerts.forms import AlertsTab, AlertForm diff --git a/openlp/plugins/alerts/forms/alertstab.py b/openlp/plugins/alerts/forms/alertstab.py index 65c1d7f33..3e4b45865 100644 --- a/openlp/plugins/alerts/forms/alertstab.py +++ b/openlp/plugins/alerts/forms/alertstab.py @@ -25,7 +25,7 @@ from PyQt4 import QtCore, QtGui -from openlp.core.lib import SettingsTab, str_to_bool +from openlp.core.lib import SettingsTab class AlertsTab(SettingsTab): """ diff --git a/openlp/plugins/presentations/presentationplugin.py b/openlp/plugins/presentations/presentationplugin.py index ddf096b07..da25dcdc3 100644 --- a/openlp/plugins/presentations/presentationplugin.py +++ b/openlp/plugins/presentations/presentationplugin.py @@ -26,7 +26,7 @@ import os import logging -from openlp.core.lib import Plugin, build_icon, Receiver, PluginStatus +from openlp.core.lib import Plugin, build_icon, PluginStatus from openlp.core.utils import AppLocation from openlp.plugins.presentations.lib import * From b23a699a5ab84d027f6af818741a7991a79f9ccd Mon Sep 17 00:00:00 2001 From: Jon Tibble Date: Fri, 23 Apr 2010 22:10:25 +0100 Subject: [PATCH 18/63] Save MainWindow state and geometry --- openlp/core/ui/mainwindow.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/openlp/core/ui/mainwindow.py b/openlp/core/ui/mainwindow.py index 442943ce2..ad0b17c87 100644 --- a/openlp/core/ui/mainwindow.py +++ b/openlp/core/ui/mainwindow.py @@ -717,6 +717,10 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow): log.debug(u'Loading QSettings') settings = QtCore.QSettings() self.recentFiles = settings.value(u'RecentFiles').toStringList() + self.restoreGeometry( + settings.value(u'MainWindow/Geometry').toByteArray()) + self.restoreState( + settings.value(u'MainWindow/State').toByteArray()) def saveSettings(self): log.debug(u'Saving QSettings') @@ -724,6 +728,10 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow): recentFiles = QtCore.QVariant(self.recentFiles) \ if self.recentFiles else QtCore.QVariant() settings.setValue(u'RecentFiles', recentFiles) + settings.setValue( + u'MainWindow/State', QtCore.QVariant(self.saveState())) + settings.setValue( + u'MainWindow/Geometry', QtCore.QVariant(self.saveGeometry())) def updateFileMenu(self): self.FileMenu.clear() From 471f032b6ef35abbfebe81cf029a62cb890597c9 Mon Sep 17 00:00:00 2001 From: Jon Tibble Date: Fri, 23 Apr 2010 22:31:54 +0100 Subject: [PATCH 19/63] Save MainWindow position --- openlp/core/ui/mainwindow.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/openlp/core/ui/mainwindow.py b/openlp/core/ui/mainwindow.py index ad0b17c87..8546b9d84 100644 --- a/openlp/core/ui/mainwindow.py +++ b/openlp/core/ui/mainwindow.py @@ -561,7 +561,7 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow): """ Show the main form, as well as the display form """ - self.showMaximized() + QtGui.QWidget.show(self) #screen_number = self.getMonitorNumber() self.displayManager.setup() if self.displayManager.mainDisplay.isVisible(): @@ -717,6 +717,8 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow): log.debug(u'Loading QSettings') settings = QtCore.QSettings() self.recentFiles = settings.value(u'RecentFiles').toStringList() + self.move(settings.value(u'MainWindow/Position', + QtCore.QVariant(QtCore.QPoint(0, 0))).toPoint()) self.restoreGeometry( settings.value(u'MainWindow/Geometry').toByteArray()) self.restoreState( @@ -728,6 +730,7 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow): recentFiles = QtCore.QVariant(self.recentFiles) \ if self.recentFiles else QtCore.QVariant() settings.setValue(u'RecentFiles', recentFiles) + settings.setValue(u'MainWindow/Position', QtCore.QVariant(self.pos())) settings.setValue( u'MainWindow/State', QtCore.QVariant(self.saveState())) settings.setValue( From a29ea3f8616262eea3cb29d6d1245ed01fdf3c22 Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Sat, 24 Apr 2010 08:21:35 +0100 Subject: [PATCH 20/63] Add line spacing adjustment to renderer Remove .thumbnail directories --- openlp.pyw | 10 ++-------- openlp/core/lib/renderer.py | 23 +++++++++++++---------- openlp/core/lib/themexmlhandler.py | 8 ++++++-- openlp/core/ui/amendthemedialog.py | 15 ++++++++++++--- openlp/core/ui/amendthemeform.py | 20 +++++++++++++++++--- openlp/core/ui/thememanager.py | 2 +- openlp/plugins/images/lib/mediaitem.py | 2 +- 7 files changed, 52 insertions(+), 28 deletions(-) diff --git a/openlp.pyw b/openlp.pyw index 0f546261f..5cbfea1df 100755 --- a/openlp.pyw +++ b/openlp.pyw @@ -193,16 +193,10 @@ def main(): qInitResources() # Now create and actually run the application. app = OpenLP(qt_args) - try: - a = app.run() - print a - except: - log.exception(u'it went bang') - - sys.exit(a) + sys.exit(app.run()) if __name__ == u'__main__': """ Instantiate and run the application. """ - main() \ No newline at end of file + main() diff --git a/openlp/core/lib/renderer.py b/openlp/core/lib/renderer.py index beec5389c..43db25d64 100644 --- a/openlp/core/lib/renderer.py +++ b/openlp/core/lib/renderer.py @@ -464,10 +464,11 @@ class Renderer(object): # now draw the text, and any outlines/shadows if self._theme.display_shadow: self._get_extent_and_render(line, footer, - tlcorner=(x + display_shadow_size, y + display_shadow_size), - draw=True, color = self._theme.display_shadow_color) - self._get_extent_and_render(line, footer, tlcorner=(x, y), draw=True, - outline_size=display_outline_size) + tlcorner=(x + display_shadow_size, + y + display_shadow_size), + draw=True, color = self._theme.display_shadow_color) + self._get_extent_and_render(line, footer, tlcorner=(x, y), + draw=True, outline_size=display_outline_size) y += h if linenum == 0: self._first_line_right_extent = rightextent @@ -533,7 +534,7 @@ class Renderer(object): font = self.mainFont metrics = QtGui.QFontMetrics(font) w = metrics.width(line) - h = metrics.height() + h = metrics.height() + int(self._theme.font_main_line_adjustment) if draw: self.painter.setFont(font) if color is None: @@ -544,27 +545,29 @@ class Renderer(object): else: pen = QtGui.QColor(color) x, y = tlcorner + rowpos = y + metrics.ascent() if self._theme.display_outline and outline_size != 0 and not footer: path = QtGui.QPainterPath() - path.addText(QtCore.QPointF(x, y + metrics.ascent()), font, line) + path.addText(QtCore.QPointF(x, rowpos), font, line) self.painter.setBrush(self.painter.pen().brush()) self.painter.setPen(QtGui.QPen( QtGui.QColor(self._theme.display_outline_color), outline_size)) self.painter.drawPath(path) self.painter.setPen(pen) - self.painter.drawText(x, y + metrics.ascent(), line) + self.painter.drawText(x, rowpos, line) if self._theme.display_slideTransition: # Print 2nd image with 70% weight if self._theme.display_outline and outline_size != 0 and not footer: path = QtGui.QPainterPath() - path.addText(QtCore.QPointF(x, y + metrics.ascent()), font, line) + path.addText(QtCore.QPointF(x, rowpos), font, line) self.painter2.setBrush(self.painter2.pen().brush()) self.painter2.setPen(QtGui.QPen( - QtGui.QColor(self._theme.display_outline_color), outline_size)) + QtGui.QColor(self._theme.display_outline_color), + outline_size)) self.painter2.drawPath(path) self.painter2.setFont(font) self.painter2.setPen(pen) - self.painter2.drawText(x, y + metrics.ascent(), line) + self.painter2.drawText(x, rowpos, line) return (w, h) def snoop_Image(self, image, image2=None): diff --git a/openlp/core/lib/themexmlhandler.py b/openlp/core/lib/themexmlhandler.py index c30184328..a96cc7355 100644 --- a/openlp/core/lib/themexmlhandler.py +++ b/openlp/core/lib/themexmlhandler.py @@ -53,6 +53,7 @@ blankthemexml=\ Normal False 0 + 0 @@ -62,6 +63,7 @@ blankthemexml=\ Normal False 0 + 0 @@ -171,8 +173,8 @@ class ThemeXML(object): self.child_element(background, u'filename', filename) def add_font(self, name, color, proportion, override, fonttype=u'main', - weight=u'Normal', italics=u'False', indentation=0, xpos=0, ypos=0, - width=0, height=0): + weight=u'Normal', italics=u'False', indentation=0, line_adjustment=0, + xpos=0, ypos=0, width=0, height=0): """ Add a Font. @@ -227,6 +229,8 @@ class ThemeXML(object): self.child_element(background, u'italics', italics) #Create indentation name element self.child_element(background, u'indentation', unicode(indentation)) + #Create indentation name element + self.child_element(background, u'line_adjustment', unicode(line_adjustment)) #Create Location element element = self.theme_xml.createElement(u'location') diff --git a/openlp/core/ui/amendthemedialog.py b/openlp/core/ui/amendthemedialog.py index 65d675cd1..438542192 100644 --- a/openlp/core/ui/amendthemedialog.py +++ b/openlp/core/ui/amendthemedialog.py @@ -178,16 +178,24 @@ class Ui_AmendThemeDialog(object): self.FontMainWeightLabel.setObjectName("FontMainWeightLabel") self.MainFontLayout.setWidget(3, QtGui.QFormLayout.LabelRole, self.FontMainWeightLabel) self.MainLeftLayout.addWidget(self.FontMainGroupBox) + self.FontMainWrapLineAdjustmentLabel = QtGui.QLabel(self.FontMainGroupBox) + self.FontMainWrapLineAdjustmentLabel.setObjectName("FontMainWrapLineAdjustmentLabel") + self.MainFontLayout.setWidget(4, QtGui.QFormLayout.LabelRole, self.FontMainWrapLineAdjustmentLabel) + self.FontMainLineAdjustmentSpinBox = QtGui.QSpinBox(self.FontMainGroupBox) + self.FontMainLineAdjustmentSpinBox.setObjectName("FontMainLineAdjustmentSpinBox") + self.FontMainLineAdjustmentSpinBox.setMaximum(30) + self.FontMainLineAdjustmentSpinBox.setMinimum(-30) + self.MainFontLayout.setWidget(4, QtGui.QFormLayout.FieldRole, self.FontMainLineAdjustmentSpinBox) self.FontMainWrapIndentationLabel = QtGui.QLabel(self.FontMainGroupBox) self.FontMainWrapIndentationLabel.setObjectName("FontMainWrapIndentationLabel") - self.MainFontLayout.setWidget(4, QtGui.QFormLayout.LabelRole, self.FontMainWrapIndentationLabel) + self.MainFontLayout.setWidget(5, QtGui.QFormLayout.LabelRole, self.FontMainWrapIndentationLabel) self.FontMainLineSpacingSpinBox = QtGui.QSpinBox(self.FontMainGroupBox) self.FontMainLineSpacingSpinBox.setObjectName("FontMainLineSpacingSpinBox") self.FontMainLineSpacingSpinBox.setMaximum(10) - self.MainFontLayout.setWidget(4, QtGui.QFormLayout.FieldRole, self.FontMainLineSpacingSpinBox) + self.MainFontLayout.setWidget(5, QtGui.QFormLayout.FieldRole, self.FontMainLineSpacingSpinBox) self.FontMainLinesPageLabel = QtGui.QLabel(self.FontMainGroupBox) self.FontMainLinesPageLabel.setObjectName("FontMainLinesPageLabel") - self.MainFontLayout.setWidget(5, QtGui.QFormLayout.LabelRole, self.FontMainLinesPageLabel) + self.MainFontLayout.setWidget(6, QtGui.QFormLayout.LabelRole, self.FontMainLinesPageLabel) spacerItem1 = QtGui.QSpacerItem(20, 40, QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Expanding) self.MainLeftLayout.addItem(spacerItem1) self.FontMainLayout.addWidget(self.MainLeftWidget) @@ -620,6 +628,7 @@ class Ui_AmendThemeDialog(object): self.FontMainSize.setText(self.trUtf8('Size:')) self.FontMainSizeSpinBox.setSuffix(self.trUtf8('pt')) self.FontMainWrapIndentationLabel.setText(self.trUtf8('Wrap Indentation')) + self.FontMainWrapLineAdjustmentLabel.setText(self.trUtf8('Adjust Line Spacing')) self.FontMainWeightComboBox.setItemText(0, self.trUtf8('Normal')) self.FontMainWeightComboBox.setItemText(1, self.trUtf8('Bold')) self.FontMainWeightComboBox.setItemText(2, self.trUtf8('Italics')) diff --git a/openlp/core/ui/amendthemeform.py b/openlp/core/ui/amendthemeform.py index 03c2df3f5..c43d27cb5 100644 --- a/openlp/core/ui/amendthemeform.py +++ b/openlp/core/ui/amendthemeform.py @@ -101,6 +101,9 @@ class AmendThemeForm(QtGui.QDialog, Ui_AmendThemeDialog): QtCore.QObject.connect(self.FontMainHeightSpinBox, QtCore.SIGNAL(u'editingFinished()'), self.onFontMainHeightSpinBoxChanged) + QtCore.QObject.connect(self.FontMainLineAdjustmentSpinBox, + QtCore.SIGNAL(u'editingFinished()'), + self.onFontMainLineAdjustmentSpinBoxChanged) QtCore.QObject.connect(self.FontMainLineSpacingSpinBox, QtCore.SIGNAL(u'editingFinished()'), self.onFontMainLineSpacingSpinBoxChanged) @@ -163,6 +166,7 @@ class AmendThemeForm(QtGui.QDialog, Ui_AmendThemeDialog): unicode(self.theme.font_main_weight), unicode(self.theme.font_main_italics), unicode(self.theme.font_main_indentation), + unicode(self.theme.font_main_line_adjustment), unicode(self.theme.font_main_x), unicode(self.theme.font_main_y), unicode(self.theme.font_main_width), @@ -173,7 +177,8 @@ class AmendThemeForm(QtGui.QDialog, Ui_AmendThemeDialog): unicode(self.theme.font_footer_override), u'footer', unicode(self.theme.font_footer_weight), unicode(self.theme.font_footer_italics), - 0, + 0, # indentation + 0, # line adjustment unicode(self.theme.font_footer_x), unicode(self.theme.font_footer_y), unicode(self.theme.font_footer_width), @@ -261,6 +266,8 @@ class AmendThemeForm(QtGui.QDialog, Ui_AmendThemeDialog): 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.FontMainLineAdjustmentSpinBox.setValue( + self.theme.font_main_line_adjustment) self.FontMainLineSpacingSpinBox.setValue( self.theme.font_main_indentation) self.stateChanging(self.theme) @@ -281,6 +288,13 @@ class AmendThemeForm(QtGui.QDialog, Ui_AmendThemeDialog): self.theme.font_main_width = self.FontMainWidthSpinBox.value() self.previewTheme() + def onFontMainLineAdjustmentSpinBoxChanged(self): + if self.theme.font_main_line_adjustment != \ + self.FontMainLineAdjustmentSpinBox.value(): + self.theme.font_main_line_adjustment = \ + self.FontMainLineAdjustmentSpinBox.value() + self.previewTheme() + def onFontMainLineSpacingSpinBoxChanged(self): if self.theme.font_main_indentation != \ self.FontMainLineSpacingSpinBox.value(): @@ -687,7 +701,8 @@ class AmendThemeForm(QtGui.QDialog, Ui_AmendThemeDialog): if self.allowPreview: #calculate main number of rows metrics = self._getThemeMetrics() - line_height = metrics.height() + line_height = metrics.height() \ + + int(self.theme.font_main_line_adjustment) if self.theme.display_shadow: line_height += int(self.theme.display_shadow_size) if self.theme.display_outline: @@ -700,7 +715,6 @@ class AmendThemeForm(QtGui.QDialog, Ui_AmendThemeDialog): page_length)) page_length_text = unicode(self.trUtf8('Slide Height is %s rows')) self.FontMainLinesPageLabel.setText(page_length_text % page_length) - #a=c frame = self.thememanager.generateImage(self.theme) self.ThemePreview.setPixmap(QtGui.QPixmap.fromImage(frame)) diff --git a/openlp/core/ui/thememanager.py b/openlp/core/ui/thememanager.py index a651c6211..247dd8394 100644 --- a/openlp/core/ui/thememanager.py +++ b/openlp/core/ui/thememanager.py @@ -107,7 +107,7 @@ class ThemeManager(QtGui.QWidget): self.themelist = [] self.path = os.path.join(ConfigHelper.get_data_path(), u'themes') self.checkThemesExists(self.path) - self.thumbPath = os.path.join(self.path, u'.thumbnails') + self.thumbPath = os.path.join(self.path, u'thumbnails') self.checkThemesExists(self.thumbPath) self.amendThemeForm.path = self.path # Last little bits of setting up diff --git a/openlp/plugins/images/lib/mediaitem.py b/openlp/plugins/images/lib/mediaitem.py index 914a6ce20..9c19c8122 100644 --- a/openlp/plugins/images/lib/mediaitem.py +++ b/openlp/plugins/images/lib/mediaitem.py @@ -76,7 +76,7 @@ class ImageMediaItem(MediaManagerItem): QtGui.QAbstractItemView.ExtendedSelection) self.ListView.setIconSize(QtCore.QSize(88,50)) self.servicePath = os.path.join( - self.parent.config.get_data_path(), u'.thumbnails') + self.parent.config.get_data_path(), u'thumbnails') if not os.path.exists(self.servicePath): os.mkdir(self.servicePath) self.loadList(self.parent.config.load_list(self.ConfigSection)) From 80e9f94a520c327f12a55d61c83f264a335cb069 Mon Sep 17 00:00:00 2001 From: Jonathan Corwin Date: Sat, 24 Apr 2010 14:19:08 +0100 Subject: [PATCH 21/63] Basic http support --- openlp/plugins/remotes/lib/__init__.py | 1 + openlp/plugins/remotes/remoteplugin.py | 25 ++----------------------- 2 files changed, 3 insertions(+), 23 deletions(-) diff --git a/openlp/plugins/remotes/lib/__init__.py b/openlp/plugins/remotes/lib/__init__.py index bb613fb53..9307a0f51 100644 --- a/openlp/plugins/remotes/lib/__init__.py +++ b/openlp/plugins/remotes/lib/__init__.py @@ -24,3 +24,4 @@ ############################################################################### from remotetab import RemoteTab +from httpserver import HttpServer diff --git a/openlp/plugins/remotes/remoteplugin.py b/openlp/plugins/remotes/remoteplugin.py index eff9496ba..0eec0739d 100644 --- a/openlp/plugins/remotes/remoteplugin.py +++ b/openlp/plugins/remotes/remoteplugin.py @@ -28,7 +28,7 @@ import logging from PyQt4 import QtNetwork, QtCore from openlp.core.lib import Plugin, Receiver -from openlp.plugins.remotes.lib import RemoteTab +from openlp.plugins.remotes.lib import RemoteTab, HttpServer log = logging.getLogger(__name__) @@ -44,10 +44,7 @@ class RemotesPlugin(Plugin): log.debug(u'initialise') Plugin.initialise(self) self.insert_toolbox_item() - self.server = QtNetwork.QUdpSocket() - self.server.bind(int(self.config.get_config(u'remote port', 4316))) - QtCore.QObject.connect(self.server, - QtCore.SIGNAL(u'readyRead()'), self.readData) + self.server = HttpServer(self) def finalise(self): log.debug(u'finalise') @@ -60,24 +57,6 @@ class RemotesPlugin(Plugin): Create the settings Tab """ return RemoteTab(self.name) - - def readData(self): - log.info(u'Remoted data has arrived') - while self.server.hasPendingDatagrams(): - datagram, host, port = self.server.readDatagram( - self.server.pendingDatagramSize()) - self.handle_datagram(datagram) - - def handle_datagram(self, datagram): - log.info(u'Sending event %s ', datagram) - pos = datagram.find(u':') - event = unicode(datagram[:pos].lower()) - if event == u'alert': - Receiver.send_message(u'alerts_text', unicode(datagram[pos + 1:])) - elif event == u'next_slide': - Receiver.send_message(u'slidecontroller_live_next') - else: - Receiver.send_message(event, unicode(datagram[pos + 1:])) def about(self): about_text = self.trUtf8('Remote Plugin
This plugin ' From d7e060c503b0d87fe9d2ecbb06ed75bd88306a95 Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Sat, 24 Apr 2010 19:42:01 +0100 Subject: [PATCH 22/63] Start to add ability to set display screen size for a session --- openlp/core/ui/amendthemedialog.py | 2 - openlp/core/ui/maindisplay.py | 14 +- openlp/core/ui/screen.py | 16 ++ openlp/core/ui/slidecontroller.py | 63 ++++--- openlp/plugins/display/__init__.py | 24 +++ openlp/plugins/display/displaysplugin.py | 117 +++++++++++++ openlp/plugins/display/forms/__init__.py | 26 +++ openlp/plugins/display/forms/displaydialog.py | 82 +++++++++ openlp/plugins/display/forms/displayform.py | 163 ++++++++++++++++++ resources/forms/displaydialog.ui | 151 ++++++++++++++++ 10 files changed, 630 insertions(+), 28 deletions(-) create mode 100644 openlp/plugins/display/__init__.py create mode 100644 openlp/plugins/display/displaysplugin.py create mode 100644 openlp/plugins/display/forms/__init__.py create mode 100644 openlp/plugins/display/forms/displaydialog.py create mode 100644 openlp/plugins/display/forms/displayform.py create mode 100644 resources/forms/displaydialog.ui diff --git a/openlp/core/ui/amendthemedialog.py b/openlp/core/ui/amendthemedialog.py index 438542192..c713eb608 100644 --- a/openlp/core/ui/amendthemedialog.py +++ b/openlp/core/ui/amendthemedialog.py @@ -183,8 +183,6 @@ class Ui_AmendThemeDialog(object): self.MainFontLayout.setWidget(4, QtGui.QFormLayout.LabelRole, self.FontMainWrapLineAdjustmentLabel) self.FontMainLineAdjustmentSpinBox = QtGui.QSpinBox(self.FontMainGroupBox) self.FontMainLineAdjustmentSpinBox.setObjectName("FontMainLineAdjustmentSpinBox") - self.FontMainLineAdjustmentSpinBox.setMaximum(30) - self.FontMainLineAdjustmentSpinBox.setMinimum(-30) self.MainFontLayout.setWidget(4, QtGui.QFormLayout.FieldRole, self.FontMainLineAdjustmentSpinBox) self.FontMainWrapIndentationLabel = QtGui.QLabel(self.FontMainGroupBox) self.FontMainWrapIndentationLabel.setObjectName("FontMainWrapIndentationLabel") diff --git a/openlp/core/ui/maindisplay.py b/openlp/core/ui/maindisplay.py index 5e7071449..6dfa7a83c 100644 --- a/openlp/core/ui/maindisplay.py +++ b/openlp/core/ui/maindisplay.py @@ -137,6 +137,10 @@ class MainDisplay(DisplayWidget): QtCore.SIGNAL(u'maindisplay_hide'), self.hideDisplay) QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'maindisplay_show'), self.showDisplay) + QtCore.QObject.connect(Receiver.get_receiver(), + QtCore.SIGNAL(u'maindisplay_hide_theme'), self.hideThemeDisplay) +# QtCore.QObject.connect(Receiver.get_receiver(), +# QtCore.SIGNAL(u'maindisplay_show_theme'), self.showThemeDisplay) QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'videodisplay_start'), self.hideDisplay) @@ -208,6 +212,14 @@ class MainDisplay(DisplayWidget): self.display_text.setPixmap(self.transparent) self.moveToTop() + def hideThemeDisplay(self): + log.debug(u'hideDisplay') + a=c + self.display_image.setPixmap(self.transparent) + self.display_alert.setPixmap(self.transparent) + self.display_text.setPixmap(self.transparent) + self.moveToTop() + def moveToTop(self): log.debug(u'moveToTop') self.setWindowFlags(QtCore.Qt.WindowStaysOnTopHint \ @@ -365,7 +377,7 @@ class VideoDisplay(Phonon.VideoWidget): def onMediaQueue(self, message): log.debug(u'VideoDisplay Queue new media message %s' % message) - file = os.path.join(message[0].get_frame_path(), + file = os.path.join(message[0].get_frame_path(), message[0].get_frame_title()) source = self.mediaObject.setCurrentSource(Phonon.MediaSource(file)) self.onMediaPlay() diff --git a/openlp/core/ui/screen.py b/openlp/core/ui/screen.py index 32cc5ba50..c498d46cb 100644 --- a/openlp/core/ui/screen.py +++ b/openlp/core/ui/screen.py @@ -64,7 +64,23 @@ class ScreenList(object): self.current_display = 0 else: self.current = self.screen_list[number] + self.override = self.current self.preview = self.current self.current_display = number if self.display_count == 1: self.preview = self.screen_list[0] + + def set_override_display(self): + """ + replace the current size with the override values + user wants to have their own screen attributes + """ + self.current = self.override + self.preview = self.current + + def reset_current(self): + """ + replace the current values with the correct values + user wants to use the correct screen attributes + """ + self.set_current_display(self.current_display) diff --git a/openlp/core/ui/slidecontroller.py b/openlp/core/ui/slidecontroller.py index 2b34a7c0d..a41c56387 100644 --- a/openlp/core/ui/slidecontroller.py +++ b/openlp/core/ui/slidecontroller.py @@ -234,6 +234,16 @@ class SlideController(QtGui.QWidget): self.Mediabar.addToolbarButton( u'Media Stop', u':/slides/media_playback_stop.png', self.trUtf8('Start playing media'), self.onMediaStop) + if self.isLive: + self.blankButton = self.Mediabar.addToolbarButton( + u'Blank Screen', u':/slides/slide_blank.png', + self.trUtf8('Blank Screen'), self.onBlankDisplay, True) + self.themeButton = self.Mediabar.addToolbarButton( + u'Display Theme', u':/slides/slide_theme.png', + self.trUtf8('Theme Screen'), self.onThemeDisplay, True) + self.hideButton = self.Mediabar.addToolbarButton( + u'Hide screen', u':/slides/slide_desktop.png', + self.trUtf8('Hide Screen'), self.onHideDisplay, True) if not self.isLive: self.seekSlider = Phonon.SeekSlider() self.seekSlider.setGeometry(QtCore.QRect(90, 260, 221, 24)) @@ -259,7 +269,7 @@ class SlideController(QtGui.QWidget): self.PreviewFrame = QtGui.QFrame(self.Splitter) self.PreviewFrame.setGeometry(QtCore.QRect(0, 0, 300, 225)) self.PreviewFrame.setSizePolicy(QtGui.QSizePolicy( - QtGui.QSizePolicy.Preferred, QtGui.QSizePolicy.Minimum, + QtGui.QSizePolicy.Preferred, QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Label)) self.PreviewFrame.setFrameShape(QtGui.QFrame.StyledPanel) self.PreviewFrame.setFrameShadow(QtGui.QFrame.Sunken) @@ -316,26 +326,26 @@ class SlideController(QtGui.QWidget): QtCore.SIGNAL(u'slidecontroller_%s_stop_loop' % self.type_prefix), self.onStopLoop) QtCore.QObject.connect(Receiver.get_receiver(), - QtCore.SIGNAL(u'slidecontroller_%s_first' % self.type_prefix), + QtCore.SIGNAL(u'slidecontroller_%s_first' % self.type_prefix), self.onSlideSelectedFirst) QtCore.QObject.connect(Receiver.get_receiver(), - QtCore.SIGNAL(u'slidecontroller_%s_next' % self.type_prefix), + QtCore.SIGNAL(u'slidecontroller_%s_next' % self.type_prefix), self.onSlideSelectedNext) QtCore.QObject.connect(Receiver.get_receiver(), - QtCore.SIGNAL(u'slidecontroller_%s_previous' % self.type_prefix), + QtCore.SIGNAL(u'slidecontroller_%s_previous' % self.type_prefix), self.onSlideSelectedPrevious) QtCore.QObject.connect(Receiver.get_receiver(), - QtCore.SIGNAL(u'slidecontroller_%s_next_noloop' % self.type_prefix), + QtCore.SIGNAL(u'slidecontroller_%s_next_noloop' % self.type_prefix), self.onSlideSelectedNextNoloop) QtCore.QObject.connect(Receiver.get_receiver(), - QtCore.SIGNAL(u'slidecontroller_%s_previous_noloop' % + QtCore.SIGNAL(u'slidecontroller_%s_previous_noloop' % self.type_prefix), self.onSlideSelectedPreviousNoloop) QtCore.QObject.connect(Receiver.get_receiver(), - QtCore.SIGNAL(u'slidecontroller_%s_last' % self.type_prefix), + QtCore.SIGNAL(u'slidecontroller_%s_last' % self.type_prefix), self.onSlideSelectedLast) QtCore.QObject.connect(Receiver.get_receiver(), - QtCore.SIGNAL(u'slidecontroller_%s_change' % self.type_prefix), + QtCore.SIGNAL(u'slidecontroller_%s_change' % self.type_prefix), self.onSlideChange) QtCore.QObject.connect(self.Splitter, QtCore.SIGNAL(u'splitterMoved(int, int)'), self.trackSplitter) @@ -481,7 +491,7 @@ class SlideController(QtGui.QWidget): blanked = self.blankButton.isChecked() else: blanked = False - Receiver.send_message(u'%s_start' % serviceItem.name.lower(), + Receiver.send_message(u'%s_start' % serviceItem.name.lower(), [serviceItem, self.isLive, blanked, slideno]) self.slideList = {} width = self.parent.ControlSplitter.sizes()[self.split] @@ -554,9 +564,9 @@ class SlideController(QtGui.QWidget): self.enableToolBar(serviceItem) self.onSlideSelected() self.PreviewListWidget.setFocus() - Receiver.send_message(u'%s_%s_started' % - (self.serviceItem.name.lower(), - 'live' if self.isLive else 'preview'), + Receiver.send_message(u'%s_%s_started' % + (self.serviceItem.name.lower(), + 'live' if self.isLive else 'preview'), [serviceItem]) log.log(15, u'Display Rendering took %4s' % (time.time() - before)) @@ -567,7 +577,7 @@ class SlideController(QtGui.QWidget): """ if not self.serviceItem: return - Receiver.send_message(u'%s_first' % self.serviceItem.name.lower(), + Receiver.send_message(u'%s_first' % self.serviceItem.name.lower(), [self.serviceItem, self.isLive]) if self.serviceItem.is_command(): self.updatePreview() @@ -593,7 +603,10 @@ class SlideController(QtGui.QWidget): log.debug(u'onThemeDisplay %d' % force) if force: self.themeButton.setChecked(True) - self.blankScreen(HideMode.Theme, self.themeButton.isChecked()) + if self.themeButton.isChecked(): + Receiver.send_message(u'maindisplay_show_theme') + else: + Receiver.send_message(u'maindisplay_hide_theme') def onHideDisplay(self, force=False): """ @@ -603,9 +616,9 @@ class SlideController(QtGui.QWidget): if force: self.hideButton.setChecked(True) if self.hideButton.isChecked(): - self.parent.mainDisplay.hideDisplay() + Receiver.send_message(u'maindisplay_hide') else: - self.parent.mainDisplay.showDisplay() + Receiver.send_message(u'maindisplay_show') def blankScreen(self, blankType, blanked=False): """ @@ -613,15 +626,15 @@ class SlideController(QtGui.QWidget): """ if self.serviceItem is not None: if blanked: - Receiver.send_message(u'%s_blank' % self.serviceItem.name.lower(), + Receiver.send_message(u'%s_blank' % self.serviceItem.name.lower(), [self.serviceItem, self.isLive]) else: - Receiver.send_message(u'%s_unblank' - % self.serviceItem.name.lower(), + Receiver.send_message(u'%s_unblank' + % self.serviceItem.name.lower(), [self.serviceItem, self.isLive]) - self.parent.mainDisplay.blankDisplay(blankType, blanked) + self.parent.displayManager.mainDisplay.blankDisplay(blankType, blanked) else: - self.parent.mainDisplay.blankDisplay(blankType, blanked) + self.parent.displayManager.mainDisplay.blankDisplay(blankType, blanked) def onSlideSelected(self): """ @@ -685,7 +698,7 @@ class SlideController(QtGui.QWidget): """ if not self.serviceItem: return - Receiver.send_message(u'%s_next' % self.serviceItem.name.lower(), + Receiver.send_message(u'%s_next' % self.serviceItem.name.lower(), [self.serviceItem, self.isLive]) if self.serviceItem.is_command(): self.updatePreview() @@ -709,7 +722,7 @@ class SlideController(QtGui.QWidget): """ if not self.serviceItem: return - Receiver.send_message(u'%s_previous' % self.serviceItem.name.lower(), + Receiver.send_message(u'%s_previous' % self.serviceItem.name.lower(), [self.serviceItem, self.isLive]) if self.serviceItem.is_command(): self.updatePreview() @@ -729,7 +742,7 @@ class SlideController(QtGui.QWidget): """ if not self.serviceItem: return - Receiver.send_message(u'%s_last' % self.serviceItem.name.lower(), + Receiver.send_message(u'%s_last' % self.serviceItem.name.lower(), [self.serviceItem, self.isLive]) if self.serviceItem.is_command(): self.updatePreview() @@ -775,7 +788,7 @@ class SlideController(QtGui.QWidget): def onMediaStart(self, item): if self.isLive: - Receiver.send_message(u'videodisplay_start', + Receiver.send_message(u'videodisplay_start', [item, self.blankButton.isChecked()]) else: self.mediaObject.stop() diff --git a/openlp/plugins/display/__init__.py b/openlp/plugins/display/__init__.py new file mode 100644 index 000000000..1a348a0df --- /dev/null +++ b/openlp/plugins/display/__init__.py @@ -0,0 +1,24 @@ +# -*- coding: utf-8 -*- +# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4 + +############################################################################### +# OpenLP - Open Source Lyrics Projection # +# --------------------------------------------------------------------------- # +# Copyright (c) 2008-2010 Raoul Snyman # +# Portions copyright (c) 2008-2010 Tim Bentley, Jonathan Corwin, Michael # +# Gorven, Scott Guerrieri, Christian Richter, Maikel Stuivenberg, Martin # +# Thompson, Jon Tibble, Carsten Tinggaard # +# --------------------------------------------------------------------------- # +# 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 # +############################################################################### diff --git a/openlp/plugins/display/displaysplugin.py b/openlp/plugins/display/displaysplugin.py new file mode 100644 index 000000000..052b28b5e --- /dev/null +++ b/openlp/plugins/display/displaysplugin.py @@ -0,0 +1,117 @@ +from openlp.plugins.alerts.forms import AlertsTab, AlertForm# -*- coding: utf-8 -*- +# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4 + +############################################################################### +# OpenLP - Open Source Lyrics Projection # +# --------------------------------------------------------------------------- # +# Copyright (c) 2008-2010 Raoul Snyman # +# Portions copyright (c) 2008-2010 Tim Bentley, Jonathan Corwin, Michael # +# Gorven, Scott Guerrieri, Christian Richter, Maikel Stuivenberg, Martin # +# Thompson, Jon Tibble, Carsten Tinggaard # +# --------------------------------------------------------------------------- # +# 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 datetime import datetime +import logging + +from PyQt4 import QtCore, QtGui + +from openlp.core.lib import Plugin, Receiver, str_to_bool, build_icon +from openlp.plugins.display.forms import DisplayForm + +log = logging.getLogger(__name__) + +class DisplayPlugin(Plugin): + log.info(u'Display Plugin loaded') + + def __init__(self, plugin_helpers): + Plugin.__init__(self, u'Display', u'1.9.1', plugin_helpers) + self.weight = -2 + self.icon = build_icon(u':/media/media_image.png') + + def add_tools_menu_item(self, tools_menu): + """ + Give the Display plugin the opportunity to add items to the + **Tools** menu. + + ``tools_menu`` + The actual **Tools** menu item, so that your actions can + use it as their parent. + """ + log.info(u'add tools menu') + self.toolsMenu = tools_menu + self.DisplayMenu = QtGui.QMenu(tools_menu) + self.DisplayMenu.setObjectName(u'DisplayMenu') + self.DisplayMenu.setTitle(tools_menu.trUtf8('&Override Display')) + #Display Delete + self.DisplayOverride = QtGui.QAction(tools_menu) + self.DisplayOverride.setText( + tools_menu.trUtf8('&Change Display Attributes')) + self.DisplayOverride.setStatusTip( + tools_menu.trUtf8('Amend the display attributes')) + self.DisplayOverride.setObjectName(u'DisplayOverride') + #Display activation + DisplayIcon = build_icon(u':/tools/tools_alert.png') + self.DisplayStatus = QtGui.QAction(tools_menu) + self.DisplayStatus.setIcon(DisplayIcon) + self.DisplayStatus.setCheckable(True) + self.DisplayStatus.setChecked(False) + self.DisplayStatus.setText(tools_menu.trUtf8('Use Display Override')) + self.DisplayStatus.setStatusTip( + tools_menu.trUtf8('Change start/stop using Display Override')) + self.DisplayStatus.setShortcut(u'FX') + self.DisplayStatus.setObjectName(u'DisplayStatus') + #Add Menus together + self.toolsMenu.addAction(self.DisplayMenu.menuAction()) + self.DisplayMenu.addAction(self.DisplayStatus) + self.DisplayMenu.addSeparator() + self.DisplayMenu.addAction(self.DisplayOverride) + # Signals and slots + QtCore.QObject.connect(self.DisplayStatus, + QtCore.SIGNAL(u'visibilityChanged(bool)'), + self.DisplayStatus.setChecked) + QtCore.QObject.connect(self.DisplayStatus, + QtCore.SIGNAL(u'triggered(bool)'), + self.toggleDisplayState) + QtCore.QObject.connect(self.DisplayOverride, + QtCore.SIGNAL(u'triggered()'), self.onDisplayOverride) + self.DisplayMenu.menuAction().setVisible(False) + + def initialise(self): + log.info(u'Display Initialising') + Plugin.initialise(self) + self.DisplayStatus.setChecked(False) + self.screens = self.maindisplay.screens + self.displayform = DisplayForm(self, self.screens) + self.DisplayMenu.menuAction().setVisible(True) + + def finalise(self): + log.info(u'Plugin Finalise') + self.DisplayMenu.menuAction().setVisible(False) + + def toggleDisplayState(self): + Receiver.send_message(u'config_screen_changed') + + def onDisplayOverride(self): + self.displayform.initialise() + self.displayform.exec_() + if self.DisplayStatus.isChecked(): + Receiver.send_message(u'config_screen_changed') + + def about(self): + about_text = self.trUtf8('Display Plugin
This plugin ' + 'allows the dimensions of the live display to be changed.\n' + 'These changes are not stored.') + return about_text diff --git a/openlp/plugins/display/forms/__init__.py b/openlp/plugins/display/forms/__init__.py new file mode 100644 index 000000000..e6a60c3a2 --- /dev/null +++ b/openlp/plugins/display/forms/__init__.py @@ -0,0 +1,26 @@ +# -*- coding: utf-8 -*- +# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4 + +############################################################################### +# OpenLP - Open Source Lyrics Projection # +# --------------------------------------------------------------------------- # +# Copyright (c) 2008-2010 Raoul Snyman # +# Portions copyright (c) 2008-2010 Tim Bentley, Jonathan Corwin, Michael # +# Gorven, Scott Guerrieri, Christian Richter, Maikel Stuivenberg, Martin # +# Thompson, Jon Tibble, Carsten Tinggaard # +# --------------------------------------------------------------------------- # +# 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 displayform import DisplayForm diff --git a/openlp/plugins/display/forms/displaydialog.py b/openlp/plugins/display/forms/displaydialog.py new file mode 100644 index 000000000..8c145b73f --- /dev/null +++ b/openlp/plugins/display/forms/displaydialog.py @@ -0,0 +1,82 @@ +# -*- coding: utf-8 -*- + +# Form implementation generated from reading ui file 'displaydialog.ui' +# +# Created: Sat Apr 24 17:20:48 2010 +# by: PyQt4 UI code generator 4.7.2 +# +# WARNING! All changes made in this file will be lost! + +from PyQt4 import QtCore, QtGui + +class Ui_DisplaysDialog(object): + def setupUi(self, DisplaysDialog): + DisplaysDialog.setObjectName("DisplaysDialog") + DisplaysDialog.resize(327, 224) + self.OkpushButton = QtGui.QPushButton(DisplaysDialog) + self.OkpushButton.setGeometry(QtCore.QRect(210, 200, 97, 24)) + self.OkpushButton.setObjectName("OkpushButton") + self.widget = QtGui.QWidget(DisplaysDialog) + self.widget.setGeometry(QtCore.QRect(10, 0, 301, 191)) + self.widget.setObjectName("widget") + self.verticalLayout = QtGui.QVBoxLayout(self.widget) + self.verticalLayout.setObjectName("verticalLayout") + self.CurrentGroupBox = QtGui.QGroupBox(self.widget) + self.CurrentGroupBox.setObjectName("CurrentGroupBox") + self.layoutWidget = QtGui.QWidget(self.CurrentGroupBox) + self.layoutWidget.setGeometry(QtCore.QRect(20, 30, 261, 17)) + self.layoutWidget.setObjectName("layoutWidget") + self.horizontalLayout = QtGui.QHBoxLayout(self.layoutWidget) + self.horizontalLayout.setObjectName("horizontalLayout") + self.Xpos = QtGui.QLabel(self.layoutWidget) + self.Xpos.setAlignment(QtCore.Qt.AlignCenter) + self.Xpos.setObjectName("Xpos") + self.horizontalLayout.addWidget(self.Xpos) + self.Ypos = QtGui.QLabel(self.layoutWidget) + self.Ypos.setAlignment(QtCore.Qt.AlignCenter) + self.Ypos.setObjectName("Ypos") + self.horizontalLayout.addWidget(self.Ypos) + self.Height = QtGui.QLabel(self.layoutWidget) + self.Height.setAlignment(QtCore.Qt.AlignCenter) + self.Height.setObjectName("Height") + self.horizontalLayout.addWidget(self.Height) + self.Width = QtGui.QLabel(self.layoutWidget) + self.Width.setAlignment(QtCore.Qt.AlignCenter) + self.Width.setObjectName("Width") + self.horizontalLayout.addWidget(self.Width) + self.verticalLayout.addWidget(self.CurrentGroupBox) + self.CurrentGroupBox_2 = QtGui.QGroupBox(self.widget) + self.CurrentGroupBox_2.setObjectName("CurrentGroupBox_2") + self.layoutWidget1 = QtGui.QWidget(self.CurrentGroupBox_2) + self.layoutWidget1.setGeometry(QtCore.QRect(20, 30, 261, 27)) + self.layoutWidget1.setObjectName("layoutWidget1") + self.horizontalLayout_2 = QtGui.QHBoxLayout(self.layoutWidget1) + self.horizontalLayout_2.setObjectName("horizontalLayout_2") + self.XposEdit = QtGui.QLineEdit(self.layoutWidget1) + self.XposEdit.setObjectName("XposEdit") + self.horizontalLayout_2.addWidget(self.XposEdit) + self.YposEdit = QtGui.QLineEdit(self.layoutWidget1) + self.YposEdit.setObjectName("YposEdit") + self.horizontalLayout_2.addWidget(self.YposEdit) + self.HeightEdit = QtGui.QLineEdit(self.layoutWidget1) + self.HeightEdit.setObjectName("HeightEdit") + self.horizontalLayout_2.addWidget(self.HeightEdit) + self.WidthEdit = QtGui.QLineEdit(self.layoutWidget1) + self.WidthEdit.setObjectName("WidthEdit") + self.horizontalLayout_2.addWidget(self.WidthEdit) + self.verticalLayout.addWidget(self.CurrentGroupBox_2) + + self.retranslateUi(DisplaysDialog) + QtCore.QObject.connect(self.OkpushButton, QtCore.SIGNAL("pressed()"), DisplaysDialog.close) + QtCore.QMetaObject.connectSlotsByName(DisplaysDialog) + + def retranslateUi(self, DisplaysDialog): + DisplaysDialog.setWindowTitle(QtGui.QApplication.translate("DisplaysDialog", "Amend Display Settings", None, QtGui.QApplication.UnicodeUTF8)) + self.OkpushButton.setText(QtGui.QApplication.translate("DisplaysDialog", "Ok", None, QtGui.QApplication.UnicodeUTF8)) + self.CurrentGroupBox.setTitle(QtGui.QApplication.translate("DisplaysDialog", "Default Settings", None, QtGui.QApplication.UnicodeUTF8)) + self.Xpos.setText(QtGui.QApplication.translate("DisplaysDialog", "0", None, QtGui.QApplication.UnicodeUTF8)) + self.Ypos.setText(QtGui.QApplication.translate("DisplaysDialog", "0", None, QtGui.QApplication.UnicodeUTF8)) + self.Height.setText(QtGui.QApplication.translate("DisplaysDialog", "0", None, QtGui.QApplication.UnicodeUTF8)) + self.Width.setText(QtGui.QApplication.translate("DisplaysDialog", "0", None, QtGui.QApplication.UnicodeUTF8)) + self.CurrentGroupBox_2.setTitle(QtGui.QApplication.translate("DisplaysDialog", "Amend Settings", None, QtGui.QApplication.UnicodeUTF8)) + diff --git a/openlp/plugins/display/forms/displayform.py b/openlp/plugins/display/forms/displayform.py new file mode 100644 index 000000000..cb6550a84 --- /dev/null +++ b/openlp/plugins/display/forms/displayform.py @@ -0,0 +1,163 @@ +# -*- coding: utf-8 -*- +# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4 + +############################################################################### +# OpenLP - Open Source Lyrics Projection # +# --------------------------------------------------------------------------- # +# Copyright (c) 2008-2010 Raoul Snyman # +# Portions copyright (c) 2008-2010 Tim Bentley, Jonathan Corwin, Michael # +# Gorven, Scott Guerrieri, Christian Richter, Maikel Stuivenberg, Martin # +# Thompson, Jon Tibble, Carsten Tinggaard # +# --------------------------------------------------------------------------- # +# 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 QtGui, QtCore + +from openlp.plugins.alerts.lib.models import AlertItem + +from displaydialog import Ui_DisplaysDialog + +class DisplayForm(QtGui.QDialog, Ui_DisplaysDialog): + """ + Class documentation goes here. + """ + def __init__(self, parent, screens): + """ + Constructor + """ + self.parent = parent + self.screens = screens + self.item_id = None + QtGui.QDialog.__init__(self, None) + self.setupUi(self) +# QtCore.QObject.connect(self.DisplayButton, +# QtCore.SIGNAL(u'clicked()'), +# self.onDisplayClicked) +# QtCore.QObject.connect(self.DisplayCloseButton, +# QtCore.SIGNAL(u'clicked()'), +# self.onDisplayCloseClicked) +# QtCore.QObject.connect(self.AlertTextEdit, +# QtCore.SIGNAL(u'textChanged(const QString&)'), +# self.onTextChanged) +# QtCore.QObject.connect(self.NewButton, +# QtCore.SIGNAL(u'clicked()'), +# self.onNewClick) +# QtCore.QObject.connect(self.DeleteButton, +# QtCore.SIGNAL(u'clicked()'), +# self.onDeleteClick) +# QtCore.QObject.connect(self.SaveButton, +# QtCore.SIGNAL(u'clicked()'), +# self.onSaveClick) +# QtCore.QObject.connect(self.AlertListWidget, +# QtCore.SIGNAL(u'doubleClicked(QModelIndex)'), +# self.onDoubleClick) +# QtCore.QObject.connect(self.AlertListWidget, +# QtCore.SIGNAL(u'clicked(QModelIndex)'), +# self.onSingleClick) + + def initialise(self): + self.Xpos.setText(unicode(self.screens.current[u'size'].x())) + self.Ypos.setText(unicode(self.screens.current[u'size'].y())) + self.Height.setText(unicode(self.screens.current[u'size'].height())) + self.Width.setText(unicode(self.screens.current[u'size'].width())) + self.XposEdit.setText(unicode(self.screens.override[u'size'].x())) + self.YposEdit.setText(unicode(self.screens.override[u'size'].y())) + self.HeightEdit.setText(unicode(self.screens.override[u'size'].height())) + self.WidthEdit.setText(unicode(self.screens.override[u'size'].width())) + + def close(self): + self.screens.override[u'size'] = QtCore.QRect(int(self.XposEdit.text()),\ + int(self.YposEdit.text()), int(self.WidthEdit.text()),\ + int(self.HeightEdit.text())) + return QtGui.QDialog.close(self) + + def onDisplayClicked(self): + if self.triggerAlert(unicode(self.AlertTextEdit.text())): + self.loadList() + + def onDisplayCloseClicked(self): + if self.triggerAlert(unicode(self.AlertTextEdit.text())): + self.close() + + def onDeleteClick(self): + item = self.AlertListWidget.currentItem() + if item: + item_id = (item.data(QtCore.Qt.UserRole)).toInt()[0] + self.parent.manager.delete_alert(item_id) + row = self.AlertListWidget.row(item) + self.AlertListWidget.takeItem(row) + self.AlertTextEdit.setText(u'') + self.SaveButton.setEnabled(False) + self.DeleteButton.setEnabled(False) + self.EditButton.setEnabled(False) + + def onNewClick(self): + if len(self.AlertTextEdit.text()) == 0: + QtGui.QMessageBox.information(self, + self.trUtf8('Item selected to Add'), + self.trUtf8('Missing data')) + else: + alert = AlertItem() + alert.text = unicode(self.AlertTextEdit.text()) + self.manager.save_alert(alert) + self.AlertTextEdit.setText(u'') + self.loadList() + + def onSaveClick(self): + if self.item_id: + alert = self.manager.get_alert(self.item_id) + alert.text = unicode(self.AlertTextEdit.text()) + self.manager.save_alert(alert) + self.item_id = None + self.loadList() + else: + self.onNewClick() + + def onTextChanged(self): + #Data has changed by editing it so potential storage required + self.SaveButton.setEnabled(True) + + def onDoubleClick(self): + """ + List item has been double clicked to display it + """ + items = self.AlertListWidget.selectedIndexes() + for item in items: + bitem = self.AlertListWidget.item(item.row()) + self.triggerAlert(bitem.text()) + self.AlertTextEdit.setText(bitem.text()) + self.item_id = (bitem.data(QtCore.Qt.UserRole)).toInt()[0] + self.SaveButton.setEnabled(False) + self.DeleteButton.setEnabled(True) + + def onSingleClick(self): + """ + List item has been single clicked to add it to + the edit field so it can be changed. + """ + items = self.AlertListWidget.selectedIndexes() + for item in items: + bitem = self.AlertListWidget.item(item.row()) + self.AlertTextEdit.setText(bitem.text()) + self.item_id = (bitem.data(QtCore.Qt.UserRole)).toInt()[0] + self.SaveButton.setEnabled(False) + self.DeleteButton.setEnabled(True) + + def triggerAlert(self, text): + if text: + text = text.replace(u'<>', unicode(self.ParameterEdit.text())) + self.parent.alertsmanager.displayAlert(text) + return True + return False diff --git a/resources/forms/displaydialog.ui b/resources/forms/displaydialog.ui new file mode 100644 index 000000000..a8feb7842 --- /dev/null +++ b/resources/forms/displaydialog.ui @@ -0,0 +1,151 @@ + + + DisplaysDialog + + + + 0 + 0 + 327 + 224 + + + + Amend Display Settings + + + + + 210 + 200 + 97 + 24 + + + + Ok + + + + + + 10 + 0 + 301 + 191 + + + + + + + Default Settings + + + + + 20 + 30 + 261 + 17 + + + + + + + 0 + + + Qt::AlignCenter + + + + + + + 0 + + + Qt::AlignCenter + + + + + + + 0 + + + Qt::AlignCenter + + + + + + + 0 + + + Qt::AlignCenter + + + + + + + + + + + Amend Settings + + + + + 20 + 30 + 261 + 27 + + + + + + + + + + + + + + + + + + + + + + + + + + OkpushButton + pressed() + DisplaysDialog + close() + + + 258 + 211 + + + 163 + 111 + + + + + From b0763714c810ae12fbabe04e6dc6a5ec3ea0903e Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Sat, 24 Apr 2010 20:57:29 +0100 Subject: [PATCH 23/63] Fix up object copy and get to work. --- openlp/core/ui/screen.py | 15 ++- openlp/plugins/display/displaysplugin.py | 5 + openlp/plugins/display/forms/displayform.py | 103 -------------------- 3 files changed, 15 insertions(+), 108 deletions(-) diff --git a/openlp/core/ui/screen.py b/openlp/core/ui/screen.py index c498d46cb..19c4e01b5 100644 --- a/openlp/core/ui/screen.py +++ b/openlp/core/ui/screen.py @@ -24,6 +24,7 @@ ############################################################################### import logging +import copy log = logging.getLogger(__name__) @@ -36,6 +37,7 @@ class ScreenList(object): def __init__(self): self.preview = None self.current = None + self.override = None self.screen_list = [] self.display_count = 0 #actual display number @@ -59,13 +61,14 @@ class ScreenList(object): """ Set up the current screen dimensions """ + log.debug(u'set_override_display %s', number, ) if number + 1 > self.display_count: self.current = self.screen_list[0] self.current_display = 0 else: self.current = self.screen_list[number] - self.override = self.current - self.preview = self.current + self.override = copy.deepcopy(self.current) + self.preview = copy.deepcopy(self.current) self.current_display = number if self.display_count == 1: self.preview = self.screen_list[0] @@ -75,12 +78,14 @@ class ScreenList(object): replace the current size with the override values user wants to have their own screen attributes """ - self.current = self.override - self.preview = self.current + log.debug(u'set_override_display') + self.current = copy.deepcopy(self.override) + self.preview = copy.deepcopy(self.current) - def reset_current(self): + def reset_current_display(self): """ replace the current values with the correct values user wants to use the correct screen attributes """ + log.debug(u'reset_current_display') self.set_current_display(self.current_display) diff --git a/openlp/plugins/display/displaysplugin.py b/openlp/plugins/display/displaysplugin.py index 052b28b5e..d55e1a27b 100644 --- a/openlp/plugins/display/displaysplugin.py +++ b/openlp/plugins/display/displaysplugin.py @@ -102,6 +102,11 @@ class DisplayPlugin(Plugin): self.DisplayMenu.menuAction().setVisible(False) def toggleDisplayState(self): + log.info(u'toggleDisplayState') + if self.DisplayStatus.isChecked(): + self.screens.set_override_display() + else: + self.screens.reset_current_display() Receiver.send_message(u'config_screen_changed') def onDisplayOverride(self): diff --git a/openlp/plugins/display/forms/displayform.py b/openlp/plugins/display/forms/displayform.py index cb6550a84..b1ae02b0a 100644 --- a/openlp/plugins/display/forms/displayform.py +++ b/openlp/plugins/display/forms/displayform.py @@ -42,30 +42,6 @@ class DisplayForm(QtGui.QDialog, Ui_DisplaysDialog): self.item_id = None QtGui.QDialog.__init__(self, None) self.setupUi(self) -# QtCore.QObject.connect(self.DisplayButton, -# QtCore.SIGNAL(u'clicked()'), -# self.onDisplayClicked) -# QtCore.QObject.connect(self.DisplayCloseButton, -# QtCore.SIGNAL(u'clicked()'), -# self.onDisplayCloseClicked) -# QtCore.QObject.connect(self.AlertTextEdit, -# QtCore.SIGNAL(u'textChanged(const QString&)'), -# self.onTextChanged) -# QtCore.QObject.connect(self.NewButton, -# QtCore.SIGNAL(u'clicked()'), -# self.onNewClick) -# QtCore.QObject.connect(self.DeleteButton, -# QtCore.SIGNAL(u'clicked()'), -# self.onDeleteClick) -# QtCore.QObject.connect(self.SaveButton, -# QtCore.SIGNAL(u'clicked()'), -# self.onSaveClick) -# QtCore.QObject.connect(self.AlertListWidget, -# QtCore.SIGNAL(u'doubleClicked(QModelIndex)'), -# self.onDoubleClick) -# QtCore.QObject.connect(self.AlertListWidget, -# QtCore.SIGNAL(u'clicked(QModelIndex)'), -# self.onSingleClick) def initialise(self): self.Xpos.setText(unicode(self.screens.current[u'size'].x())) @@ -82,82 +58,3 @@ class DisplayForm(QtGui.QDialog, Ui_DisplaysDialog): int(self.YposEdit.text()), int(self.WidthEdit.text()),\ int(self.HeightEdit.text())) return QtGui.QDialog.close(self) - - def onDisplayClicked(self): - if self.triggerAlert(unicode(self.AlertTextEdit.text())): - self.loadList() - - def onDisplayCloseClicked(self): - if self.triggerAlert(unicode(self.AlertTextEdit.text())): - self.close() - - def onDeleteClick(self): - item = self.AlertListWidget.currentItem() - if item: - item_id = (item.data(QtCore.Qt.UserRole)).toInt()[0] - self.parent.manager.delete_alert(item_id) - row = self.AlertListWidget.row(item) - self.AlertListWidget.takeItem(row) - self.AlertTextEdit.setText(u'') - self.SaveButton.setEnabled(False) - self.DeleteButton.setEnabled(False) - self.EditButton.setEnabled(False) - - def onNewClick(self): - if len(self.AlertTextEdit.text()) == 0: - QtGui.QMessageBox.information(self, - self.trUtf8('Item selected to Add'), - self.trUtf8('Missing data')) - else: - alert = AlertItem() - alert.text = unicode(self.AlertTextEdit.text()) - self.manager.save_alert(alert) - self.AlertTextEdit.setText(u'') - self.loadList() - - def onSaveClick(self): - if self.item_id: - alert = self.manager.get_alert(self.item_id) - alert.text = unicode(self.AlertTextEdit.text()) - self.manager.save_alert(alert) - self.item_id = None - self.loadList() - else: - self.onNewClick() - - def onTextChanged(self): - #Data has changed by editing it so potential storage required - self.SaveButton.setEnabled(True) - - def onDoubleClick(self): - """ - List item has been double clicked to display it - """ - items = self.AlertListWidget.selectedIndexes() - for item in items: - bitem = self.AlertListWidget.item(item.row()) - self.triggerAlert(bitem.text()) - self.AlertTextEdit.setText(bitem.text()) - self.item_id = (bitem.data(QtCore.Qt.UserRole)).toInt()[0] - self.SaveButton.setEnabled(False) - self.DeleteButton.setEnabled(True) - - def onSingleClick(self): - """ - List item has been single clicked to add it to - the edit field so it can be changed. - """ - items = self.AlertListWidget.selectedIndexes() - for item in items: - bitem = self.AlertListWidget.item(item.row()) - self.AlertTextEdit.setText(bitem.text()) - self.item_id = (bitem.data(QtCore.Qt.UserRole)).toInt()[0] - self.SaveButton.setEnabled(False) - self.DeleteButton.setEnabled(True) - - def triggerAlert(self, text): - if text: - text = text.replace(u'<>', unicode(self.ParameterEdit.text())) - self.parent.alertsmanager.displayAlert(text) - return True - return False From f895c66eb1791f2142e3cc2d300c26ed7e27dd8c Mon Sep 17 00:00:00 2001 From: Jon Tibble Date: Mon, 26 Apr 2010 17:41:31 +0100 Subject: [PATCH 24/63] Clean up saving UI settings --- openlp/core/lib/dockwidget.py | 5 ---- openlp/core/lib/settingsmanager.py | 29 ++++---------------- openlp/core/ui/mainwindow.py | 44 ++++++++++++------------------ 3 files changed, 24 insertions(+), 54 deletions(-) diff --git a/openlp/core/lib/dockwidget.py b/openlp/core/lib/dockwidget.py index fcee02af8..083c99184 100644 --- a/openlp/core/lib/dockwidget.py +++ b/openlp/core/lib/dockwidget.py @@ -43,8 +43,3 @@ class OpenLPDockWidget(QtGui.QDockWidget): self.setObjectName(name) self.setFloating(False) log.debug(u'Init done') - - def closeEvent(self, event): - self.parent.settingsmanager.setUIItemVisibility( - self.objectName(), False) - event.accept() diff --git a/openlp/core/lib/settingsmanager.py b/openlp/core/lib/settingsmanager.py index fe2858cd0..60671ec64 100644 --- a/openlp/core/lib/settingsmanager.py +++ b/openlp/core/lib/settingsmanager.py @@ -23,8 +23,7 @@ # Temple Place, Suite 330, Boston, MA 02111-1307 USA # ############################################################################### -from openlp.core.lib import str_to_bool -from openlp.core.utils import ConfigHelper +from PyQt4 import QtCore class SettingsManager(object): """ @@ -33,6 +32,7 @@ class SettingsManager(object): individual components. """ def __init__(self, screen): + self.settings = QtCore.QSettings() self.screen = screen.current self.width = self.screen[u'size'].width() self.height = self.screen[u'size'].height() @@ -50,26 +50,9 @@ class SettingsManager(object): self.mainwindow_left + self.mainwindow_right) - 100 ) / 2 self.slidecontroller_image = self.slidecontroller - 50 - self.showMediaManager = str_to_bool(ConfigHelper.get_config( - u'user interface', u'media manager', True)) - self.showServiceManager = str_to_bool(ConfigHelper.get_config( - u'user interface', u'service manager', True)) - self.showThemeManager = str_to_bool(ConfigHelper.get_config( - u'user interface', u'theme manager', True)) - self.showPreviewPanel = str_to_bool(ConfigHelper.get_config( - u'user interface', u'preview panel', True)) - - def setUIItemVisibility(self, item=u'', isVisible=True): - if item: - if item == u'ThemeManagerDock': - ConfigHelper.set_config(u'user interface', - u'theme manager', isVisible) - elif item == u'ServiceManagerDock': - ConfigHelper.set_config(u'user interface', - u'service manager', isVisible) - elif item == u'MediaManagerDock': - ConfigHelper.set_config(u'user interface', - u'media manager', isVisible) + self.showPreviewPanel = self.settings.value( + u'user interface/preview panel', True).toBool() def togglePreviewPanel(self, isVisible): - ConfigHelper.set_config(u'user interface', u'preview panel', isVisible) + self.settings.setValue(u'user interface/preview panel', + QtCore.QVariant(isVisible)) diff --git a/openlp/core/ui/mainwindow.py b/openlp/core/ui/mainwindow.py index 8546b9d84..e519623fd 100644 --- a/openlp/core/ui/mainwindow.py +++ b/openlp/core/ui/mainwindow.py @@ -162,7 +162,6 @@ class Ui_MainWindow(object): self.MediaManagerDock.setWidget(self.MediaManagerContents) MainWindow.addDockWidget( QtCore.Qt.DockWidgetArea(1), self.MediaManagerDock) - self.MediaManagerDock.setVisible(self.settingsmanager.showMediaManager) # Create the service manager self.ServiceManagerDock = OpenLPDockWidget(MainWindow) ServiceManagerIcon = build_icon(u':/system/system_servicemanager.png') @@ -174,18 +173,17 @@ class Ui_MainWindow(object): self.ServiceManagerDock.setWidget(self.ServiceManagerContents) MainWindow.addDockWidget( QtCore.Qt.DockWidgetArea(2), self.ServiceManagerDock) - self.ServiceManagerDock.setVisible( - self.settingsmanager.showServiceManager) # Create the theme manager self.ThemeManagerDock = OpenLPDockWidget(MainWindow) ThemeManagerIcon = build_icon(u':/system/system_thememanager.png') self.ThemeManagerDock.setWindowIcon(ThemeManagerIcon) self.ThemeManagerDock.setObjectName(u'ThemeManagerDock') + self.ThemeManagerDock.setMinimumWidth( + self.settingsmanager.mainwindow_right) self.ThemeManagerContents = ThemeManager(self) self.ThemeManagerDock.setWidget(self.ThemeManagerContents) MainWindow.addDockWidget( QtCore.Qt.DockWidgetArea(2), self.ThemeManagerDock) - self.ThemeManagerDock.setVisible(self.settingsmanager.showThemeManager) # Create the menu items self.FileNewItem = QtGui.QAction(MainWindow) self.FileNewItem.setIcon( @@ -224,20 +222,18 @@ class Ui_MainWindow(object): self.OptionsSettingsItem.setObjectName(u'OptionsSettingsItem') self.ViewMediaManagerItem = QtGui.QAction(MainWindow) self.ViewMediaManagerItem.setCheckable(True) - self.ViewMediaManagerItem.setChecked( - self.settingsmanager.showMediaManager) + self.ViewMediaManagerItem.setChecked(self.MediaManagerDock.isVisible()) self.ViewMediaManagerItem.setIcon(MediaManagerIcon) self.ViewMediaManagerItem.setObjectName(u'ViewMediaManagerItem') self.ViewThemeManagerItem = QtGui.QAction(MainWindow) self.ViewThemeManagerItem.setCheckable(True) - self.ViewThemeManagerItem.setChecked( - self.settingsmanager.showThemeManager) + self.ViewThemeManagerItem.setChecked(self.ThemeManagerDock.isVisible()) self.ViewThemeManagerItem.setIcon(ThemeManagerIcon) self.ViewThemeManagerItem.setObjectName(u'ViewThemeManagerItem') self.ViewServiceManagerItem = QtGui.QAction(MainWindow) self.ViewServiceManagerItem.setCheckable(True) self.ViewServiceManagerItem.setChecked( - self.settingsmanager.showServiceManager) + self.ServiceManagerDock.isVisible()) self.ViewServiceManagerItem.setIcon(ServiceManagerIcon) self.ViewServiceManagerItem.setObjectName(u'ViewServiceManagerItem') self.PluginItem = QtGui.QAction(MainWindow) @@ -693,20 +689,14 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow): def toggleMediaManager(self, visible): if self.MediaManagerDock.isVisible() != visible: self.MediaManagerDock.setVisible(visible) - self.settingsmanager.setUIItemVisibility( - self.MediaManagerDock.objectName(), visible) def toggleServiceManager(self, visible): if self.ServiceManagerDock.isVisible() != visible: self.ServiceManagerDock.setVisible(visible) - self.settingsmanager.setUIItemVisibility( - self.ServiceManagerDock.objectName(), visible) def toggleThemeManager(self, visible): if self.ThemeManagerDock.isVisible() != visible: self.ThemeManagerDock.setVisible(visible) - self.settingsmanager.setUIItemVisibility( - self.ThemeManagerDock.objectName(), visible) def togglePreviewPanel(self): previewBool = self.PreviewController.Panel.isVisible() @@ -716,25 +706,27 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow): def loadSettings(self): log.debug(u'Loading QSettings') settings = QtCore.QSettings() - self.recentFiles = settings.value(u'RecentFiles').toStringList() - self.move(settings.value(u'MainWindow/Position', + self.recentFiles = settings.value( + u'general/recent files').toStringList() + self.move(settings.value(u'user interface/main window position', QtCore.QVariant(QtCore.QPoint(0, 0))).toPoint()) - self.restoreGeometry( - settings.value(u'MainWindow/Geometry').toByteArray()) + self.restoreGeometry(settings.value( + u'user interface/main window geometry').toByteArray()) self.restoreState( - settings.value(u'MainWindow/State').toByteArray()) + settings.value(u'user interface/main window state').toByteArray()) def saveSettings(self): log.debug(u'Saving QSettings') settings = QtCore.QSettings() recentFiles = QtCore.QVariant(self.recentFiles) \ if self.recentFiles else QtCore.QVariant() - settings.setValue(u'RecentFiles', recentFiles) - settings.setValue(u'MainWindow/Position', QtCore.QVariant(self.pos())) - settings.setValue( - u'MainWindow/State', QtCore.QVariant(self.saveState())) - settings.setValue( - u'MainWindow/Geometry', QtCore.QVariant(self.saveGeometry())) + settings.setValue(u'general/recent files', recentFiles) + settings.setValue(u'user interface/main window position', + QtCore.QVariant(self.pos())) + settings.setValue(u'user interface/main window state', + QtCore.QVariant(self.saveState())) + settings.setValue(u'user interface/main window geometry', + QtCore.QVariant(self.saveGeometry())) def updateFileMenu(self): self.FileMenu.clear() From 75829333c0d1f4d1281f44cc8fc3fd4fa7886310 Mon Sep 17 00:00:00 2001 From: Jonathan Corwin Date: Mon, 26 Apr 2010 22:29:40 +0100 Subject: [PATCH 25/63] Control via web --- openlp/core/ui/servicemanager.py | 31 ++++++++++++++++++++++ openlp/plugins/alerts/lib/alertsmanager.py | 9 ++++++- 2 files changed, 39 insertions(+), 1 deletion(-) diff --git a/openlp/core/ui/servicemanager.py b/openlp/core/ui/servicemanager.py index 97430bd87..76745f213 100644 --- a/openlp/core/ui/servicemanager.py +++ b/openlp/core/ui/servicemanager.py @@ -186,6 +186,10 @@ class ServiceManager(QtGui.QWidget): QtCore.SIGNAL(u'theme_update_list'), self.updateThemeList) QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'servicemanager_next_item'), self.nextItem) + QtCore.QObject.connect(Receiver.get_receiver(), + QtCore.SIGNAL(u'servicemanager_previous_item'), self.previousItem) + QtCore.QObject.connect(Receiver.get_receiver(), + QtCore.SIGNAL(u'servicemanager_list_request'), self.listRequest) QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'config_updated'), self.regenerateServiceItems) # Last little bits of setting up @@ -287,6 +291,26 @@ class ServiceManager(QtGui.QWidget): lookFor = 1 serviceIterator += 1 + def previousItem(self): + """ + Called by the SlideController to select the + previous service item + """ + if len(self.ServiceManagerList.selectedItems()) == 0: + return + selected = self.ServiceManagerList.selectedItems()[0] + prevItem = None + serviceIterator = QtGui.QTreeWidgetItemIterator(self.ServiceManagerList) + while serviceIterator.value(): + if serviceIterator.value() == selected: + if prevItem: + self.ServiceManagerList.setCurrentItem(prevItem) + self.makeLive() + return + if serviceIterator.value().parent() is None: + prevItem = serviceIterator.value() + serviceIterator += 1 + def onMoveSelectionUp(self): """ Moves the selection up the window @@ -817,3 +841,10 @@ class ServiceManager(QtGui.QWidget): return item.data(0, QtCore.Qt.UserRole).toInt()[0] else: return parentitem.data(0, QtCore.Qt.UserRole).toInt()[0] + + def listRequest(self, message=None): + data = [] + for item in self.serviceItems: + service_item = item[u'service_item'] + data.append([service_item.title]) + Receiver.send_message(u'servicemanager_list_response', data) diff --git a/openlp/plugins/alerts/lib/alertsmanager.py b/openlp/plugins/alerts/lib/alertsmanager.py index a933d49fd..ee91e190e 100644 --- a/openlp/plugins/alerts/lib/alertsmanager.py +++ b/openlp/plugins/alerts/lib/alertsmanager.py @@ -46,7 +46,7 @@ class AlertsManager(QtCore.QObject): QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'maindisplay_active'), self.generateAlert) QtCore.QObject.connect(Receiver.get_receiver(), - QtCore.SIGNAL(u'alerts_text'), self.displayAlert) + QtCore.SIGNAL(u'alerts_text'), self.onAlertText) QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'config_screen_changed'), self.screenChanged) @@ -70,6 +70,13 @@ class AlertsManager(QtCore.QObject): self.parent.maindisplay.setAlertSize(self.alertScreenPosition,\ self.alertHeight) + def onAlertText(self, message): + """ + Called via a alerts_text event. Message is single element array + containing text + """ + self.displayAlert(message[0]) + def displayAlert(self, text=u''): """ Called from the Alert Tab to display an alert From 96051838127aabe6b1464340af59bc0905083f2f Mon Sep 17 00:00:00 2001 From: Jon Tibble Date: Tue, 27 Apr 2010 17:27:57 +0100 Subject: [PATCH 26/63] Config file to QSettings conversion --- openlp.pyw | 8 +- openlp/core/lib/__init__.py | 1 - openlp/core/lib/mediamanageritem.py | 11 +- openlp/core/lib/plugin.py | 27 ++- openlp/core/lib/pluginconfig.py | 194 ------------------ openlp/core/lib/settingsmanager.py | 132 +++++++++++- openlp/core/lib/settingstab.py | 15 +- openlp/core/ui/generaltab.py | 84 +++++--- openlp/core/ui/mainwindow.py | 24 +-- openlp/core/ui/servicemanager.py | 44 ++-- openlp/core/ui/slidecontroller.py | 32 +-- openlp/core/ui/thememanager.py | 29 ++- openlp/core/ui/themestab.py | 18 +- openlp/core/utils/__init__.py | 32 ++- openlp/core/utils/confighelper.py | 76 ------- openlp/core/utils/registry.py | 134 ------------ openlp/plugins/alerts/alertsplugin.py | 5 +- openlp/plugins/alerts/forms/alertstab.py | 40 ++-- openlp/plugins/alerts/lib/manager.py | 20 +- openlp/plugins/bibles/bibleplugin.py | 2 +- .../plugins/bibles/forms/importwizardform.py | 29 ++- openlp/plugins/bibles/lib/biblestab.py | 48 +++-- openlp/plugins/bibles/lib/db.py | 18 +- openlp/plugins/bibles/lib/manager.py | 27 ++- openlp/plugins/bibles/lib/mediaitem.py | 9 +- openlp/plugins/bibles/lib/osis.py | 3 +- openlp/plugins/custom/customplugin.py | 2 +- openlp/plugins/custom/lib/customtab.py | 13 +- openlp/plugins/custom/lib/manager.py | 25 ++- openlp/plugins/custom/lib/mediaitem.py | 6 +- openlp/plugins/images/lib/imagetab.py | 10 +- openlp/plugins/images/lib/mediaitem.py | 15 +- openlp/plugins/media/lib/mediaitem.py | 12 +- openlp/plugins/presentations/lib/mediaitem.py | 24 ++- .../lib/presentationcontroller.py | 21 +- .../presentations/lib/presentationtab.py | 14 +- openlp/plugins/remotes/lib/remotetab.py | 12 +- openlp/plugins/remotes/remoteplugin.py | 3 +- openlp/plugins/songs/lib/manager.py | 20 +- openlp/plugins/songs/lib/mediaitem.py | 8 +- openlp/plugins/songs/lib/songstab.py | 21 +- openlp/plugins/songs/songsplugin.py | 4 +- .../songusage/forms/songusagedetailform.py | 10 +- openlp/plugins/songusage/lib/manager.py | 25 ++- openlp/plugins/songusage/songusageplugin.py | 17 +- 45 files changed, 560 insertions(+), 764 deletions(-) delete mode 100644 openlp/core/lib/pluginconfig.py delete mode 100644 openlp/core/utils/confighelper.py delete mode 100644 openlp/core/utils/registry.py diff --git a/openlp.pyw b/openlp.pyw index 61dd75d36..69e36618c 100755 --- a/openlp.pyw +++ b/openlp.pyw @@ -34,10 +34,10 @@ from PyQt4 import QtCore, QtGui log = logging.getLogger() -from openlp.core.lib import Receiver, str_to_bool +from openlp.core.lib import Receiver from openlp.core.resources import qInitResources from openlp.core.ui import MainWindow, SplashScreen, ScreenList -from openlp.core.utils import AppLocation, ConfigHelper +from openlp.core.utils import AppLocation application_stylesheet = u""" QMainWindow::separator @@ -119,8 +119,8 @@ class OpenLP(QtGui.QApplication): self.setApplicationVersion(app_version[u'version']) if os.name == u'nt': self.setStyleSheet(application_stylesheet) - show_splash = str_to_bool(ConfigHelper.get_registry().get_value( - u'general', u'show splash', True)) + show_splash = QtCore.QSettings().value( + u'general/show splash', True).toBool() if show_splash: self.splash = SplashScreen(self.applicationVersion()) self.splash.show() diff --git a/openlp/core/lib/__init__.py b/openlp/core/lib/__init__.py index 38bcd127c..c8570a643 100644 --- a/openlp/core/lib/__init__.py +++ b/openlp/core/lib/__init__.py @@ -164,7 +164,6 @@ class ThemeLevel(object): from eventreceiver import Receiver from settingsmanager import SettingsManager -from pluginconfig import PluginConfig from plugin import PluginStatus, Plugin from pluginmanager import PluginManager from settingstab import SettingsTab diff --git a/openlp/core/lib/mediamanageritem.py b/openlp/core/lib/mediamanageritem.py index 86b8e608c..bf27ed38a 100644 --- a/openlp/core/lib/mediamanageritem.py +++ b/openlp/core/lib/mediamanageritem.py @@ -29,7 +29,8 @@ import os from PyQt4 import QtCore, QtGui from openlp.core.lib.toolbar import * -from openlp.core.lib import contextMenuAction, contextMenuSeparator +from openlp.core.lib import contextMenuAction, contextMenuSeparator, \ + SettingsManager from serviceitem import ServiceItem log = logging.getLogger(__name__) @@ -334,13 +335,15 @@ class MediaManagerItem(QtGui.QWidget): def onFileClick(self): files = QtGui.QFileDialog.getOpenFileNames( self, self.OnNewPrompt, - self.parent.config.get_last_dir(), self.OnNewFileMasks) + SettingsManager.get_last_dir(self.ConfigSection), + self.OnNewFileMasks) log.info(u'New files(s) %s', unicode(files)) if files: self.loadList(files) dir, filename = os.path.split(unicode(files[0])) - self.parent.config.set_last_dir(dir) - self.parent.config.set_list(self.ConfigSection, self.getFileList()) + SettingsManager.set_last_dir(self.ConfigSection, dir) + SettingsManager.set_list( + self.ConfigSection, self.ConfigSection, self.getFileList()) def getFileList(self): count = 0 diff --git a/openlp/core/lib/plugin.py b/openlp/core/lib/plugin.py index 57dd984c3..f01fa0807 100644 --- a/openlp/core/lib/plugin.py +++ b/openlp/core/lib/plugin.py @@ -24,9 +24,10 @@ ############################################################################### import logging + from PyQt4 import QtCore -from openlp.core.lib import PluginConfig, Receiver +from openlp.core.lib import Receiver log = logging.getLogger(__name__) @@ -53,10 +54,6 @@ class Plugin(QtCore.QObject): ``icon`` An instance of QIcon, which holds an icon for this plugin. - ``config`` - An instance of PluginConfig, which allows plugins to read and write to - openlp.org's configuration. This is pre-instantiated. - ``log`` A log object used to log debugging messages. This is pre-instantiated. @@ -78,7 +75,8 @@ class Plugin(QtCore.QObject): Add an item to the Export menu. ``get_settings_tab()`` - Returns an instance of SettingsTabItem to be used in the Settings dialog. + Returns an instance of SettingsTabItem to be used in the Settings + dialog. ``add_to_menu(menubar)`` A method to add a menu item to anywhere in the menu, given the menu bar. @@ -116,7 +114,6 @@ class Plugin(QtCore.QObject): if version: self.version = version self.icon = None - self.config = PluginConfig(self.name) self.weight = 0 self.status = PluginStatus.Inactive # Set up logging @@ -125,7 +122,7 @@ class Plugin(QtCore.QObject): self.live_controller = plugin_helpers[u'live'] self.render_manager = plugin_helpers[u'render'] self.service_manager = plugin_helpers[u'service'] - self.settings = plugin_helpers[u'settings'] + self.settings_form = plugin_helpers[u'settings form'] self.mediadock = plugin_helpers[u'toolbox'] self.maindisplay = plugin_helpers[u'maindisplay'] QtCore.QObject.connect(Receiver.get_receiver(), @@ -145,15 +142,16 @@ class Plugin(QtCore.QObject): """ Sets the status of the plugin """ - self.status = int(self.config.get_config(u'status', - PluginStatus.Inactive)) + self.status = QtCore.QSettings().value( + self.name.lower() + u'/status', PluginStatus.Inactive).toInt()[0] def toggle_status(self, new_status): """ Changes the status of the plugin and remembers it """ self.status = new_status - self.config.set_config(u'status', self.status) + QtCore.QSettings().setValue( + self.name.lower() + u'/status', QtCore.QVariant(self.status)) def is_active(self): """ @@ -216,7 +214,8 @@ class Plugin(QtCore.QObject): """ Generic Drag and drop handler triggered from service_manager. """ - log.debug(u'process_add_service_event event called for plugin %s' % self.name) + log.debug(u'process_add_service_event event called for plugin %s' % + self.name) self.media_item.onAddClick() def about(self): @@ -244,7 +243,7 @@ class Plugin(QtCore.QObject): Called by the plugin to remove toolbar """ self.mediadock.remove_dock(self.name) - self.settings.removeTab(self.name) + self.settings_form.removeTab(self.name) def insert_toolbox_item(self): """ @@ -253,7 +252,7 @@ class Plugin(QtCore.QObject): if self.media_item: self.mediadock.insert_dock(self.media_item, self.icon, self.weight) if self.settings_tab: - self.settings.insertTab(self.settings_tab, self.weight) + self.settings_form.insertTab(self.settings_tab, self.weight) def can_delete_theme(self, theme): """ diff --git a/openlp/core/lib/pluginconfig.py b/openlp/core/lib/pluginconfig.py deleted file mode 100644 index e27b86669..000000000 --- a/openlp/core/lib/pluginconfig.py +++ /dev/null @@ -1,194 +0,0 @@ -# -*- coding: utf-8 -*- -# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4 - -############################################################################### -# OpenLP - Open Source Lyrics Projection # -# --------------------------------------------------------------------------- # -# Copyright (c) 2008-2010 Raoul Snyman # -# Portions copyright (c) 2008-2010 Tim Bentley, Jonathan Corwin, Michael # -# Gorven, Scott Guerrieri, Christian Richter, Maikel Stuivenberg, Martin # -# Thompson, Jon Tibble, Carsten Tinggaard # -# --------------------------------------------------------------------------- # -# 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 # -############################################################################### - -import os - -from openlp.core.utils import ConfigHelper - -class PluginConfig(object): - """ - This is a generic config helper for plugins. - """ - def __init__(self, plugin_name): - """ - Initialise the plugin config object, setting the section name to the - plugin name. - - ``plugin_name`` - The name of the plugin to use as a section name. - """ - self.section = plugin_name.lower() - - def get_config(self, key, default=None): - """ - Get a configuration value from the configuration registry. - - ``key`` - The name of configuration to load. - - ``default`` - Defaults to *None*. The default value to return if there is no - other value. - """ - return ConfigHelper.get_config(self.section, key, default) - - def delete_config(self, key): - """ - Delete a configuration value from the configuration registry. - - ``key`` - The name of the configuration to remove. - """ - return ConfigHelper.delete_config(self.section, key) - - def set_config(self, key, value): - """ - Set a configuration value in the configuration registry. - - ``key`` - The name of the configuration to save. - - ``value`` - The value of the configuration to save. - """ - return ConfigHelper.set_config(self.section, key, value) - - def get_data_path(self): - """ - Dynamically build the data file path for a plugin. - """ - #app_data = ConfigHelper.get_data_path() - app_data = ConfigHelper.get_data_path() - safe_name = self.section.replace(u' ',u'-') - plugin_data = self.get_config(u'data path', safe_name) - path = os.path.join(app_data, plugin_data) - if not os.path.exists(path): - os.makedirs(path) - return path - - def set_data_path(self, path): - """ - Set the data file path. - - ``path`` - The path to save. - """ - return self.set_config(u'data path', os.path.basename(path)) - - def get_files(self, suffix=None): - """ - Get a list of files from the data files path. - - ``suffix`` - Defaults to *None*. The extension to search for. - """ - try: - files = os.listdir(self.get_data_path()) - except: - return [] - if suffix: - return_files = [] - for file in files: - if file.find(u'.') != -1: - filename = file.split(u'.') - #bname = nme[0] - filesuffix = filename[1].lower() - filesuffix = filesuffix.lower() - # only load files with the correct suffix - if suffix.find(filesuffix) > -1 : - return_files.append(file) - return return_files - else: - # no filtering required - return files - - def load_list(self, name): - """ - Load a list from the config file. - - ``name`` - The name of the list. - """ - list_count = self.get_config(u'%s count' % name) - if list_count: - list_count = int(list_count) - else: - list_count = 0 - list = [] - if list_count > 0: - for counter in range(0, list_count): - item = self.get_config(u'%s %d' % (name, counter)) - if item: - list.append(item) - return list - - def set_list(self, name, list): - """ - Save a list to the config file. - - ``name`` - The name of the list to save. - - ``list`` - The list of values to save. - """ - old_count = int(self.get_config(u'%s count' % name, int(0))) - new_count = len(list) - self.set_config(u'%s count' % name, new_count) - for counter in range (0, new_count): - self.set_config(u'%s %d' % (name, counter), list[counter-1]) - if old_count > new_count: - # Tidy up any old list itrms if list is smaller now - for counter in range(new_count, old_count): - self.delete_config(u'%s %d' % (name, counter)) - - def get_last_dir(self, num=None): - """ - Read the last directory used for plugin. - - ``num`` - Defaults to *None*. A further qualifier. - """ - if num: - name = u'last directory %d' % num - else: - name = u'last directory' - last_dir = self.get_config(name) - if not last_dir: - last_dir = u'' - return last_dir - - def set_last_dir(self, directory, num=None): - """ - Save the last directory used for plugin. - - ``num`` - Defaults to *None*. A further qualifier. - """ - if num: - name = u'last directory %d' % num - else: - name = u'last directory' - self.set_config(name, directory) diff --git a/openlp/core/lib/settingsmanager.py b/openlp/core/lib/settingsmanager.py index 60671ec64..c86170988 100644 --- a/openlp/core/lib/settingsmanager.py +++ b/openlp/core/lib/settingsmanager.py @@ -25,14 +25,14 @@ from PyQt4 import QtCore +from openlp.core.utils import AppLocation + class SettingsManager(object): """ - Class to control the size of the UI components so they size correctly. - This class is created by the main window and then calculates the size of - individual components. + Class to control the initial settings for the UI and provide helper + functions for the loading and saving of application settings. """ def __init__(self, screen): - self.settings = QtCore.QSettings() self.screen = screen.current self.width = self.screen[u'size'].width() self.height = self.screen[u'size'].height() @@ -50,9 +50,129 @@ class SettingsManager(object): self.mainwindow_left + self.mainwindow_right) - 100 ) / 2 self.slidecontroller_image = self.slidecontroller - 50 - self.showPreviewPanel = self.settings.value( + self.showPreviewPanel = QtCore.QSettings().value( u'user interface/preview panel', True).toBool() def togglePreviewPanel(self, isVisible): - self.settings.setValue(u'user interface/preview panel', + QtCore.QSettings().setValue(u'user interface/preview panel', QtCore.QVariant(isVisible)) + + @staticmethod + def get_last_dir(section, num=None): + """ + Read the last directory used for plugin. + + ``section`` + The section of code calling the method. This is used in the + settings key. + + ``num`` + Defaults to *None*. A further qualifier. + """ + if num: + name = u'last directory %d' % num + else: + name = u'last directory' + last_dir = unicode(QtCore.QSettings().value( + section + u'/' + name, u'').toString()) + return last_dir + + @staticmethod + def set_last_dir(section, directory, num=None): + """ + Save the last directory used for plugin. + + ``section`` + The section of code calling the method. This is used in the + settings key. + + ``directory`` + The directory being stored in the settings. + + ``num`` + Defaults to *None*. A further qualifier. + """ + if num: + name = u'last directory %d' % num + else: + name = u'last directory' + QtCore.QSettings().setValue( + section + u'/' + name, QtCore.QVariant(directory)) + + @staticmethod + def set_list(section, name, list): + """ + Save a list to application settings. + + ``section`` + The section of the settings to store this list. + + ``name`` + The name of the list to save. + + ``list`` + The list of values to save. + """ + settings = QtCore.QSettings() + old_count = settings.value( + u'%s/%s count' % (section, name), 0).toInt()[0] + new_count = len(list) + settings.setValue( + u'%s/%s count' % (section, name), QtCore.QVariant(new_count)) + for counter in range (0, new_count): + settings.setValue( + u'%s/%s %d' % (section, name, counter), list[counter-1]) + if old_count > new_count: + # Tidy up any old list itrms if list is smaller now + for counter in range(new_count, old_count): + settings.remove(u'%s/%s %d' % (section, name, counter)) + + @staticmethod + def load_list(section, name): + """ + Load a list from the config file. + + ``section`` + The section of the settings to load the list from. + + ``name`` + The name of the list. + """ + settings = QtCore.QSettings() + list_count = settings.value( + u'%s/%s count' % (section, name), 0).toInt()[0] + list = [] + if list_count: + for counter in range(0, list_count): + item = unicode(settings.value( + u'%s/%s %d' % (section, name, counter)).toString()) + if item: + list.append(item) + return list + + @staticmethod + def get_files(suffix=None): + """ + Get a list of files from the data files path. + + ``suffix`` + Defaults to *None*. The extension to search for. + """ + try: + files = os.listdir(AppLocation.get_data_path()) + except: + return [] + if suffix: + return_files = [] + for file in files: + if file.find(u'.') != -1: + filename = file.split(u'.') + filesuffix = filename[1].lower() + filesuffix = filesuffix.lower() + # only load files with the correct suffix + if suffix.find(filesuffix) > -1 : + return_files.append(file) + return return_files + else: + # no filtering required + return files diff --git a/openlp/core/lib/settingstab.py b/openlp/core/lib/settingstab.py index 930ce6bc8..6f1aef854 100644 --- a/openlp/core/lib/settingstab.py +++ b/openlp/core/lib/settingstab.py @@ -25,24 +25,17 @@ from PyQt4 import QtGui -from openlp.core.lib import PluginConfig - class SettingsTab(QtGui.QWidget): """ SettingsTab is a helper widget for plugins to define Tabs for the settings dialog. """ - def __init__(self, title, section=None): + def __init__(self, title): """ Constructor to create the Settings tab item. ``title`` - Defaults to *None*. The title of the tab, which is usually - displayed on the tab. - - ``section`` - Defaults to *None*. This is the section in the configuration file - to write to when the ``save`` method is called. + The title of the tab, which is usually displayed on the tab. """ QtGui.QWidget.__init__(self) self.tabTitle = title @@ -50,10 +43,6 @@ class SettingsTab(QtGui.QWidget): self.setupUi() self.retranslateUi() self.initialise() - if section is None: - self.config = PluginConfig(title) - else: - self.config = PluginConfig(section) self.preLoad() self.load() diff --git a/openlp/core/ui/generaltab.py b/openlp/core/ui/generaltab.py index f7e87e879..bb35d8f2a 100644 --- a/openlp/core/ui/generaltab.py +++ b/openlp/core/ui/generaltab.py @@ -25,7 +25,7 @@ from PyQt4 import QtCore, QtGui -from openlp.core.lib import SettingsTab, str_to_bool, Receiver +from openlp.core.lib import SettingsTab, Receiver class GeneralTab(SettingsTab): """ @@ -41,11 +41,13 @@ class GeneralTab(SettingsTab): values. If not set before default to last screen. """ - self.MonitorNumber = int(self.config.get_config(u'monitor', - self.screens.monitor_number)) + settings = QtCore.QSettings() + self.MonitorNumber = settings.value( + u'general/monitor', self.screens.monitor_number).toInt()[0] self.screens.set_current_display(self.MonitorNumber) self.screens.monitor_number = self.MonitorNumber - self.DisplayOnMonitor = str_to_bool(self.config.get_config(u'display on monitor', u'True')) + self.DisplayOnMonitor = settings.value( + u'general/display on monitor', True).toBool() self.screens.display = self.DisplayOnMonitor def setupUi(self): @@ -151,15 +153,18 @@ class GeneralTab(SettingsTab): QtCore.QObject.connect(self.MonitorComboBox, QtCore.SIGNAL(u'activated(int)'), self.onMonitorComboBoxChanged) QtCore.QObject.connect(self.DisplayOnMonitorCheck, - QtCore.SIGNAL(u'stateChanged(int)'), self.onDisplayOnMonitorCheckChanged) + QtCore.SIGNAL(u'stateChanged(int)'), + self.onDisplayOnMonitorCheckChanged) QtCore.QObject.connect(self.WarningCheckBox, QtCore.SIGNAL(u'stateChanged(int)'), self.onWarningCheckBoxChanged) QtCore.QObject.connect(self.AutoOpenCheckBox, QtCore.SIGNAL(u'stateChanged(int)'), self.onAutoOpenCheckBoxChanged) QtCore.QObject.connect(self.ShowSplashCheckBox, - QtCore.SIGNAL(u'stateChanged(int)'), self.onShowSplashCheckBoxChanged) + QtCore.SIGNAL(u'stateChanged(int)'), + self.onShowSplashCheckBoxChanged) QtCore.QObject.connect(self.SaveCheckServiceCheckBox, - QtCore.SIGNAL(u'stateChanged(int)'), self.onSaveCheckServiceCheckBox) + QtCore.SIGNAL(u'stateChanged(int)'), + self.onSaveCheckServiceCheckBox) QtCore.QObject.connect(self.AutoPreviewCheckBox, QtCore.SIGNAL(u'stateChanged(int)'), self.onAutoPreviewCheckBox) QtCore.QObject.connect(self.NumberEdit, @@ -171,15 +176,20 @@ class GeneralTab(SettingsTab): def retranslateUi(self): self.MonitorGroupBox.setTitle(self.trUtf8('Monitors')) - self.MonitorLabel.setText(self.trUtf8('Select monitor for output display:')) - self.DisplayOnMonitorCheck.setText(self.trUtf8('Display if in single screen')) + self.MonitorLabel.setText( + self.trUtf8('Select monitor for output display:')) + self.DisplayOnMonitorCheck.setText( + self.trUtf8('Display if in single screen')) self.StartupGroupBox.setTitle(self.trUtf8('Application Startup')) self.WarningCheckBox.setText(self.trUtf8('Show blank screen warning')) - self.AutoOpenCheckBox.setText(self.trUtf8('Automatically open the last service')) + self.AutoOpenCheckBox.setText( + self.trUtf8('Automatically open the last service')) self.ShowSplashCheckBox.setText(self.trUtf8('Show the splash screen')) self.SettingsGroupBox.setTitle(self.trUtf8('Application Settings')) - self.SaveCheckServiceCheckBox.setText(self.trUtf8('Prompt to save Service before starting New')) - self.AutoPreviewCheckBox.setText(self.trUtf8('Preview Next Song from Service Manager')) + self.SaveCheckServiceCheckBox.setText( + self.trUtf8('Prompt to save Service before starting New')) + self.AutoPreviewCheckBox.setText( + self.trUtf8('Preview Next Song from Service Manager')) self.CCLIGroupBox.setTitle(self.trUtf8('CCLI Details')) self.NumberLabel.setText(self.trUtf8('CCLI Number:')) self.UsernameLabel.setText(self.trUtf8('SongSelect Username:')) @@ -216,20 +226,30 @@ class GeneralTab(SettingsTab): self.Password = self.PasswordEdit.displayText() def load(self): + settings = QtCore.QSettings() for screen in self.screens.screen_list: - screen_name = u'%s %d' % (self.trUtf8('Screen'), screen[u'number'] + 1) + screen_name = u'%s %d' % (self.trUtf8('Screen'), + screen[u'number'] + 1) if screen[u'primary']: screen_name = u'%s (%s)' % (screen_name, self.trUtf8('primary')) self.MonitorComboBox.addItem(screen_name) # Get the configs - self.Warning = str_to_bool(self.config.get_config(u'blank warning', u'False')) - self.AutoOpen = str_to_bool(self.config.get_config(u'auto open', u'False')) - self.ShowSplash = str_to_bool(self.config.get_config(u'show splash', u'True')) - self.PromptSaveService = str_to_bool(self.config.get_config(u'save prompt', u'False')) - self.AutoPreview = str_to_bool(self.config.get_config(u'auto preview', u'False')) - self.CCLINumber = unicode(self.config.get_config(u'ccli number', u'')) - self.Username = unicode(self.config.get_config(u'songselect username', u'')) - self.Password = unicode(self.config.get_config(u'songselect password', u'')) + self.Warning = settings.value( + u'general/blank warning', QtCore.QVariant(False)).toBool() + self.AutoOpen = settings.value( + u'general/auto open', QtCore.QVariant(False)).toBool() + self.ShowSplash = settings.value( + u'general/show splash', QtCore.QVariant(True)).toBool() + self.PromptSaveService = settings.value( + u'general/save prompt', QtCore.QVariant(False)).toBool() + self.AutoPreview = settings.value( + u'general/auto preview', QtCore.QVariant(False)).toBool() + self.CCLINumber = unicode(settings.value( + u'general/ccli number', QtCore.QVariant(u'')).toString()) + self.Username = unicode(settings.value( + u'general/songselect username', QtCore.QVariant(u'')).toString()) + self.Password = unicode(settings.value( + u'general/songselect password', QtCore.QVariant(u'')).toString()) self.SaveCheckServiceCheckBox.setChecked(self.PromptSaveService) # Set a few things up self.MonitorComboBox.setCurrentIndex(self.MonitorNumber) @@ -243,16 +263,18 @@ class GeneralTab(SettingsTab): self.PasswordEdit.setText(self.Password) def save(self): - self.config.set_config(u'monitor', self.MonitorNumber) - self.config.set_config(u'display on monitor', self.DisplayOnMonitor) - self.config.set_config(u'blank warning', self.Warning) - self.config.set_config(u'auto open', self.AutoOpen) - self.config.set_config(u'show splash', self.ShowSplash) - self.config.set_config(u'save prompt', self.PromptSaveService) - self.config.set_config(u'auto preview', self.AutoPreview) - self.config.set_config(u'ccli number', self.CCLINumber) - self.config.set_config(u'songselect username', self.Username) - self.config.set_config(u'songselect password', self.Password) + settings = QtCore.QSettings() + settings.setValue(u'general/monitor', self.MonitorNumber) + settings.setValue( + u'general/display on monitor', self.DisplayOnMonitor) + settings.setValue(u'general/blank warning', self.Warning) + settings.setValue(u'general/auto open', self.AutoOpen) + settings.setValue(u'general/show splash', self.ShowSplash) + settings.setValue(u'general/save prompt', self.PromptSaveService) + settings.setValue(u'general/auto preview', self.AutoPreview) + settings.setValue(u'general/ccli number', self.CCLINumber) + settings.setValue(u'general/songselect username', self.Username) + settings.setValue(u'general/songselect password', self.Password) self.screens.display = self.DisplayOnMonitor #Monitor Number has changed. if self.screens.monitor_number != self.MonitorNumber: diff --git a/openlp/core/ui/mainwindow.py b/openlp/core/ui/mainwindow.py index e519623fd..96357f83d 100644 --- a/openlp/core/ui/mainwindow.py +++ b/openlp/core/ui/mainwindow.py @@ -30,8 +30,8 @@ from PyQt4 import QtCore, QtGui from openlp.core.ui import AboutForm, SettingsForm, ServiceManager, \ ThemeManager, SlideController, PluginForm, MediaDockManager, DisplayManager -from openlp.core.lib import RenderManager, PluginConfig, build_icon, \ - OpenLPDockWidget, SettingsManager, PluginManager, Receiver, str_to_bool +from openlp.core.lib import RenderManager, build_icon, OpenLPDockWidget, \ + SettingsManager, PluginManager, Receiver from openlp.core.utils import check_latest_version, AppLocation, add_actions log = logging.getLogger(__name__) @@ -56,11 +56,10 @@ class VersionThread(QtCore.QThread): A special Qt thread class to fetch the version of OpenLP from the website. This is threaded so that it doesn't affect the loading time of OpenLP. """ - def __init__(self, parent, app_version, generalConfig): + def __init__(self, parent, app_version): QtCore.QThread.__init__(self, parent) self.parent = parent self.app_version = app_version - self.generalConfig = generalConfig def run(self): """ @@ -68,7 +67,7 @@ class VersionThread(QtCore.QThread): """ time.sleep(1) Receiver.send_message(u'maindisplay_blank_check') - version = check_latest_version(self.generalConfig, self.app_version) + version = check_latest_version(self.app_version) #new version has arrived if version != self.app_version[u'full']: Receiver.send_message(u'openlp_version_check', u'%s' % version) @@ -422,7 +421,6 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow): self.applicationVersion = applicationVersion self.serviceNotSaved = False self.settingsmanager = SettingsManager(screens) - self.generalConfig = PluginConfig(u'General') self.displayManager = DisplayManager(screens) self.aboutForm = AboutForm(self, applicationVersion) self.settingsForm = SettingsForm(self.screens, self, self) @@ -510,7 +508,7 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow): self.plugin_helpers[u'live'] = self.LiveController self.plugin_helpers[u'render'] = self.RenderManager self.plugin_helpers[u'service'] = self.ServiceManagerContents - self.plugin_helpers[u'settings'] = self.settingsForm + self.plugin_helpers[u'settings form'] = self.settingsForm self.plugin_helpers[u'toolbox'] = self.mediaDockManager self.plugin_helpers[u'maindisplay'] = self.displayManager.mainDisplay self.plugin_manager.find_plugins(pluginpath, self.plugin_helpers) @@ -563,7 +561,7 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow): if self.displayManager.mainDisplay.isVisible(): self.displayManager.mainDisplay.setFocus() self.activateWindow() - if str_to_bool(self.generalConfig.get_config(u'auto open', False)): + if QtCore.QSettings().value(u'general/auto open', False).toBool(): self.ServiceManagerContents.onLoadService(True) def blankCheck(self): @@ -571,8 +569,8 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow): Check and display message if screen blank on setup. Triggered by delay thread. """ - if str_to_bool(self.generalConfig.get_config(u'screen blank', False)) \ - and str_to_bool(self.generalConfig.get_config(u'blank warning', False)): + if QtCore.QSettings().value(u'general/screen blank', False).toBool() \ + and QtCore.QSettings().value(u'general/blank warning', False).toBool(): self.LiveController.onBlankDisplay(True) QtGui.QMessageBox.question(self, self.trUtf8('OpenLP Main Display Blanked'), @@ -584,7 +582,7 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow): """ Start an initial setup thread to delay notifications """ - vT = VersionThread(self, self.applicationVersion, self.generalConfig) + vT = VersionThread(self, self.applicationVersion) vT.start() def onHelpAboutItemClicked(self): @@ -748,8 +746,8 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow): self.FileMenu.addAction(self.FileMenuActions[-1]) def addRecentFile(self, filename): - recentFileCount = int(PluginConfig(u'General'). - get_config(u'max recent files', 4)) + recentFileCount = QtCore.QSettings().value( + u'general/max recent files', 4).toInt()[0] if filename and not self.recentFiles.contains(filename): self.recentFiles.prepend(QtCore.QString(filename)) while self.recentFiles.count() > recentFileCount: diff --git a/openlp/core/ui/servicemanager.py b/openlp/core/ui/servicemanager.py index e76415db5..14bb35113 100644 --- a/openlp/core/ui/servicemanager.py +++ b/openlp/core/ui/servicemanager.py @@ -32,9 +32,10 @@ log = logging.getLogger(__name__) from PyQt4 import QtCore, QtGui -from openlp.core.lib import PluginConfig, OpenLPToolbar, ServiceItem, \ - contextMenuAction, Receiver, str_to_bool, build_icon, ItemCapabilities +from openlp.core.lib import OpenLPToolbar, ServiceItem, contextMenuAction, \ + Receiver, build_icon, ItemCapabilities, SettingsManager from openlp.core.ui import ServiceNoteForm, ServiceItemEditForm +from openlp.core.utils import AppLocation class ServiceManagerList(QtGui.QTreeWidget): @@ -189,10 +190,9 @@ class ServiceManager(QtGui.QWidget): QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'config_updated'), self.regenerateServiceItems) # Last little bits of setting up - self.config = PluginConfig(u'ServiceManager') - self.servicePath = self.config.get_data_path() - self.service_theme = unicode( - self.config.get_config(u'service theme', u'')) + self.service_theme = unicode(QtCore.QSettings().value( + u'service manager/service theme', u'').toString()) + self.servicePath = AppLocation.get_section_data_path(u'servicemanager') #build the context menu self.menu = QtGui.QMenu() self.editAction = self.menu.addAction(self.trUtf8('&Edit Item')) @@ -201,7 +201,8 @@ class ServiceManager(QtGui.QWidget): self.editAction.setIcon(build_icon(u':/general/general_edit.png')) self.notesAction = self.menu.addAction(self.trUtf8('&Notes')) self.notesAction.setIcon(build_icon(u':/services/service_notes.png')) - self.deleteAction = self.menu.addAction(self.trUtf8('&Delete From Service')) + self.deleteAction = self.menu.addAction( + self.trUtf8('&Delete From Service')) self.deleteAction.setIcon(build_icon(u':/general/general_delete.png')) self.sep1 = self.menu.addAction(u'') self.sep1.setSeparator(True) @@ -402,8 +403,7 @@ class ServiceManager(QtGui.QWidget): Clear the list to create a new service """ if self.parent.serviceNotSaved and \ - str_to_bool(PluginConfig(u'General'). - get_config(u'save prompt', u'False')): + QtCore.QSettings().value(u'general/save prompt', False).toBool(): ret = QtGui.QMessageBox.question(self, self.trUtf8('Save Changes to Service?'), self.trUtf8('Your service is unsaved, do you want to save ' @@ -486,17 +486,18 @@ class ServiceManager(QtGui.QWidget): log.debug(u'onSaveService') if not quick or self.isNew: filename = QtGui.QFileDialog.getSaveFileName(self, - self.trUtf8(u'Save Service'), self.config.get_last_dir(), + self.trUtf8(u'Save Service'), + SettingsManager.get_last_dir(u'servicemanager'), self.trUtf8(u'OpenLP Service Files (*.osz)')) else: - filename = self.config.get_last_dir() + filename = SettingsManager.get_last_dir(u'servicemanager') if filename: splittedFile = filename.split(u'.') if splittedFile[-1] != u'osz': filename = filename + u'.osz' filename = unicode(filename) self.isNew = False - self.config.set_last_dir(filename) + SettingsManager.set_last_dir(u'servicemanager', filename) service = [] servicefile = filename + u'.osd' zip = None @@ -537,11 +538,12 @@ class ServiceManager(QtGui.QWidget): def onLoadService(self, lastService=False): if lastService: - filename = self.config.get_last_dir() + filename = SettingsManager.get_last_dir(u'servicemanager') else: filename = QtGui.QFileDialog.getOpenFileName( self, self.trUtf8('Open Service'), - self.config.get_last_dir(), u'Services (*.osz)') + SettingsManager.get_last_dir(u'servicemanager'), + u'Services (*.osz)') self.loadService(filename) def loadService(self, filename=None): @@ -570,7 +572,7 @@ class ServiceManager(QtGui.QWidget): filename = unicode(filename) name = filename.split(os.path.sep) if filename: - self.config.set_last_dir(filename) + SettingsManager.set_last_dir(u'servicemanager', filename) zip = None f = None try: @@ -639,7 +641,8 @@ class ServiceManager(QtGui.QWidget): """ self.service_theme = unicode(self.ThemeComboBox.currentText()) self.parent.RenderManager.set_service_theme(self.service_theme) - self.config.set_config(u'service theme', self.service_theme) + QtCore.QSettings().setValue(u'service manager/service theme', + QtCore.QVariant(self.service_theme)) self.regenerateServiceItems() def regenerateServiceItems(self): @@ -651,7 +654,8 @@ class ServiceManager(QtGui.QWidget): self.serviceItems = [] self.isNew = True for item in tempServiceItems: - self.addServiceItem(item[u'service_item'], False, item[u'expanded']) + self.addServiceItem( + item[u'service_item'], False, item[u'expanded']) #Set to False as items may have changed rendering #does not impact the saved song so True may also be valid self.parent.serviceChanged(False, self.serviceName) @@ -720,11 +724,11 @@ class ServiceManager(QtGui.QWidget): item, count = self.findServiceItem() self.parent.LiveController.addServiceManagerItem( self.serviceItems[item][u'service_item'], count) - if str_to_bool(PluginConfig(u'General'). - get_config(u'auto preview', u'False')): + if QtCore.QSettings().value(u'general/auto preview', False).toBool(): item += 1 if self.serviceItems and item < len(self.serviceItems) and \ - self.serviceItems[item][u'service_item'].is_capable(ItemCapabilities.AllowsPreview): + self.serviceItems[item][u'service_item'].is_capable( + ItemCapabilities.AllowsPreview): self.parent.PreviewController.addServiceManagerItem( self.serviceItems[item][u'service_item'], 0) diff --git a/openlp/core/ui/slidecontroller.py b/openlp/core/ui/slidecontroller.py index 2b34a7c0d..260066fa5 100644 --- a/openlp/core/ui/slidecontroller.py +++ b/openlp/core/ui/slidecontroller.py @@ -41,8 +41,7 @@ class HideMode(object): Blank = 1 Theme = 2 -from openlp.core.lib import OpenLPToolbar, Receiver, str_to_bool, \ - PluginConfig, resize_image +from openlp.core.lib import OpenLPToolbar, Receiver, resize_image log = logging.getLogger(__name__) @@ -96,7 +95,7 @@ class SlideController(QtGui.QWidget): self.settingsmanager = settingsmanager self.isLive = isLive self.parent = parent - self.songsconfig = PluginConfig(u'Songs') + self.mainDisplay = self.parent.displayManager.mainDisplay self.loop_list = [ u'Start Loop', u'Stop Loop', @@ -394,7 +393,7 @@ class SlideController(QtGui.QWidget): self.Toolbar.makeWidgetsInvisible(self.loop_list) if item.is_text(): self.Toolbar.makeWidgetsInvisible(self.loop_list) - if str_to_bool(self.songsconfig.get_config(u'show songbar', True)) \ + if QtCore.QSettings().value(u'songs/show songbar', True) \ and len(self.slideList) > 0: self.Toolbar.makeWidgetsVisible([u'Song Menu']) if item.is_capable(ItemCapabilities.AllowsLoop) and \ @@ -403,7 +402,7 @@ class SlideController(QtGui.QWidget): if item.is_media(): self.Toolbar.setVisible(False) self.Mediabar.setVisible(True) - #self.volumeSlider.setAudioOutput(self.parent.mainDisplay.videoDisplay.audio) + #self.volumeSlider.setAudioOutput(self.mainDisplay.videoDisplay.audio) def enablePreviewToolBar(self, item): """ @@ -583,8 +582,8 @@ class SlideController(QtGui.QWidget): if force: self.blankButton.setChecked(True) self.blankScreen(HideMode.Blank, self.blankButton.isChecked()) - self.parent.generalConfig.set_config(u'screen blank', - self.blankButton.isChecked()) + QtCore.QSettings().setValue(u'general/screen blank', + QtCore.QVariant(self.blankButton.isChecked())) def onThemeDisplay(self, force=False): """ @@ -603,9 +602,9 @@ class SlideController(QtGui.QWidget): if force: self.hideButton.setChecked(True) if self.hideButton.isChecked(): - self.parent.mainDisplay.hideDisplay() + self.mainDisplay.hideDisplay() else: - self.parent.mainDisplay.showDisplay() + self.mainDisplay.showDisplay() def blankScreen(self, blankType, blanked=False): """ @@ -619,9 +618,9 @@ class SlideController(QtGui.QWidget): Receiver.send_message(u'%s_unblank' % self.serviceItem.name.lower(), [self.serviceItem, self.isLive]) - self.parent.mainDisplay.blankDisplay(blankType, blanked) + self.mainDisplay.blankDisplay(blankType, blanked) else: - self.parent.mainDisplay.blankDisplay(blankType, blanked) + self.mainDisplay.blankDisplay(blankType, blanked) def onSlideSelected(self): """ @@ -642,12 +641,15 @@ class SlideController(QtGui.QWidget): self.SlidePreview.setPixmap(QtGui.QPixmap.fromImage(frame)) else: if isinstance(frame[u'main'], basestring): - self.SlidePreview.setPixmap(QtGui.QPixmap(frame[u'main'])) + self.SlidePreview.setPixmap( + QtGui.QPixmap(frame[u'main'])) else: - self.SlidePreview.setPixmap(QtGui.QPixmap.fromImage(frame[u'main'])) - log.log(15, u'Slide Rendering took %4s' % (time.time() - before)) + self.SlidePreview.setPixmap( + QtGui.QPixmap.fromImage(frame[u'main'])) + log.log( + 15, u'Slide Rendering took %4s' % (time.time() - before)) if self.isLive: - self.parent.displayManager.mainDisplay.frameView(frame, True) + self.mainDisplay.frameView(frame, True) self.selectedRow = row def onSlideChange(self, row): diff --git a/openlp/core/ui/thememanager.py b/openlp/core/ui/thememanager.py index a651c6211..0c19c2510 100644 --- a/openlp/core/ui/thememanager.py +++ b/openlp/core/ui/thememanager.py @@ -33,10 +33,10 @@ from PyQt4 import QtCore, QtGui from openlp.core.ui import AmendThemeForm from openlp.core.theme import Theme -from openlp.core.lib import PluginConfig, OpenLPToolbar, contextMenuAction, \ +from openlp.core.lib import OpenLPToolbar, contextMenuAction, \ ThemeXML, str_to_bool, get_text_file_string, build_icon, Receiver, \ - contextMenuSeparator -from openlp.core.utils import ConfigHelper + contextMenuSeparator, SettingsManager +from openlp.core.utils import AppLocation log = logging.getLogger(__name__) @@ -105,16 +105,14 @@ class ThemeManager(QtGui.QWidget): QtCore.SIGNAL(u'theme_update_global'), self.changeGlobalFromTab) #Variables self.themelist = [] - self.path = os.path.join(ConfigHelper.get_data_path(), u'themes') + self.path = AppLocation.get_section_data_path(u'themes') self.checkThemesExists(self.path) self.thumbPath = os.path.join(self.path, u'.thumbnails') self.checkThemesExists(self.thumbPath) self.amendThemeForm.path = self.path # Last little bits of setting up - self.config = PluginConfig(u'themes') - self.servicePath = self.config.get_data_path() - self.global_theme = unicode( - self.config.get_config(u'global theme', u'')) + self.global_theme = unicode(QtCore.QSettings().value( + u'themes/global theme', u'').toString()) def changeGlobalFromTab(self, themeName): log.debug(u'changeGlobalFromTab %s', themeName) @@ -146,7 +144,8 @@ class ThemeManager(QtGui.QWidget): self.ThemeListWidget.item(count).text()) name = u'%s (%s)' % (self.global_theme, self.trUtf8('default')) self.ThemeListWidget.item(count).setText(name) - self.config.set_config(u'global theme', self.global_theme) + QtCore.QSettings().setValue(u'themes/global theme', + self.global_theme) Receiver.send_message(u'theme_update_global', self.global_theme) self.pushThemes() @@ -167,8 +166,8 @@ class ThemeManager(QtGui.QWidget): self.amendThemeForm.exec_() def onDeleteTheme(self): - self.global_theme = unicode( - self.config.get_config(u'global theme', u'')) + self.global_theme = unicode(QtCore.QSettings().value( + u'themes/global theme', u'').toString()) item = self.ThemeListWidget.currentItem() if item: theme = unicode(item.text()) @@ -221,10 +220,10 @@ class ThemeManager(QtGui.QWidget): theme = unicode(item.data(QtCore.Qt.UserRole).toString()) path = QtGui.QFileDialog.getExistingDirectory(self, unicode(self.trUtf8('Save Theme - (%s)')) % theme, - self.config.get_last_dir(1) ) + SettingsManager.get_last_dir(u'themes', 1)) path = unicode(path) if path: - self.config.set_last_dir(path, 1) + SettingsManager.set_last_dir(u'themes', path, 1) themePath = os.path.join(path, theme + u'.theme') zip = None try: @@ -243,11 +242,11 @@ class ThemeManager(QtGui.QWidget): def onImportTheme(self): files = QtGui.QFileDialog.getOpenFileNames( self, self.trUtf8('Select Theme Import File'), - self.config.get_last_dir(), u'Theme (*.*)') + SettingsManager.get_last_dir(u'themes'), u'Theme (*.*)') log.info(u'New Themes %s', unicode(files)) if files: for file in files: - self.config.set_last_dir(unicode(file)) + SettingsManager.set_last_dir(u'themes', unicode(file)) self.unzipTheme(file, self.path) self.loadThemes() diff --git a/openlp/core/ui/themestab.py b/openlp/core/ui/themestab.py index 7bca99bf0..f3b5ec917 100644 --- a/openlp/core/ui/themestab.py +++ b/openlp/core/ui/themestab.py @@ -123,9 +123,11 @@ class ThemesTab(SettingsTab): 'songs.')) def load(self): - self.theme_level = int(self.config.get_config(u'theme level', - ThemeLevel.Global)) - self.global_theme = self.config.get_config(u'global theme', u'') + settings = QtCore.QSettings() + self.theme_level = settings.value( + u'themes/theme level', ThemeLevel.Global).toInt()[0] + self.global_theme = unicode(settings.value( + u'themes/global theme', u'').toString()) if self.theme_level == ThemeLevel.Global: self.GlobalLevelRadioButton.setChecked(True) elif self.theme_level == ThemeLevel.Service: @@ -134,8 +136,11 @@ class ThemesTab(SettingsTab): self.SongLevelRadioButton.setChecked(True) def save(self): - self.config.set_config(u'theme level', self.theme_level) - self.config.set_config(u'global theme',self.global_theme) + settings = QtCore.QSettings() + settings.setValue(u'themes/theme level', + QtCore.QVariant(self.theme_level)) + settings.setValue(u'themes/global theme', + QtCore.QVariant(self.global_theme)) Receiver.send_message(u'theme_update_global', self.global_theme) self.parent.RenderManager.set_global_theme( self.global_theme, self.theme_level) @@ -169,7 +174,8 @@ class ThemesTab(SettingsTab): Called from ThemeManager when the Themes have changed """ #reload as may have been triggered by the ThemeManager - self.global_theme = self.config.get_config(u'global theme', u'') + self.global_theme = unicode(QtCore.QSettings().value( + u'themes/global theme', u'').toString()) self.DefaultComboBox.clear() for theme in theme_list: self.DefaultComboBox.addItem(theme) diff --git a/openlp/core/utils/__init__.py b/openlp/core/utils/__init__.py index 1900c554e..659cb1ceb 100644 --- a/openlp/core/utils/__init__.py +++ b/openlp/core/utils/__init__.py @@ -98,23 +98,37 @@ class AppLocation(object): plugin_path = os.path.split(openlp.__file__)[0] return plugin_path + @staticmethod + def get_data_path(): + path = AppLocation.get_directory(AppLocation.DataDir) + if not os.path.exists(path): + os.makedirs(path) + return path -def check_latest_version(config, current_version): + @staticmethod + def get_section_data_path(section): + data_path = AppLocation.get_data_path() + path = os.path.join(data_path, section) + if not os.path.exists(path): + os.makedirs(path) + return path + + +def check_latest_version(current_version): """ Check the latest version of OpenLP against the version file on the OpenLP site. - ``config`` - The OpenLP config object. - ``current_version`` The current version of OpenLP. """ version_string = current_version[u'full'] #set to prod in the distribution config file. - last_test = config.get_config(u'last version test', datetime.now().date()) + last_test = unicode(QtCore.QSettings().value(u'general/last version test', + datetime.now().date()).toString()) this_test = unicode(datetime.now().date()) - config.set_config(u'last version test', this_test) + QtCore.QSettings().setValue( + u'general/last version test', QtCore.QVariant(this_test)) if last_test != this_test: version_string = u'' if current_version[u'build']: @@ -168,8 +182,4 @@ def add_actions(target, actions): else: target.addAction(action) -from registry import Registry -from confighelper import ConfigHelper - -__all__ = [u'Registry', u'ConfigHelper', u'AppLocation', - u'check_latest_version', u'add_actions'] +__all__ = [u'AppLocation', u'check_latest_version', u'add_actions'] diff --git a/openlp/core/utils/confighelper.py b/openlp/core/utils/confighelper.py deleted file mode 100644 index c2be4bd24..000000000 --- a/openlp/core/utils/confighelper.py +++ /dev/null @@ -1,76 +0,0 @@ -# -*- coding: utf-8 -*- -# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4 - -############################################################################### -# OpenLP - Open Source Lyrics Projection # -# --------------------------------------------------------------------------- # -# Copyright (c) 2008-2010 Raoul Snyman # -# Portions copyright (c) 2008-2010 Tim Bentley, Jonathan Corwin, Michael # -# Gorven, Scott Guerrieri, Christian Richter, Maikel Stuivenberg, Martin # -# Thompson, Jon Tibble, Carsten Tinggaard # -# --------------------------------------------------------------------------- # -# 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 # -############################################################################### - -import os - -from openlp.core.utils import AppLocation -from openlp.core.utils.registry import Registry - -class ConfigHelper(object): - """ - Utility Helper to allow classes to find directories in a standard manner. - """ - __registry__ = None - - @staticmethod - def get_data_path(): - path = AppLocation.get_directory(AppLocation.DataDir) - if not os.path.exists(path): - os.makedirs(path) - return path - - @staticmethod - def get_config(section, key, default=None): - reg = ConfigHelper.get_registry() - if reg.has_value(section, key): - return reg.get_value(section, key, default) - else: - if default: - ConfigHelper.set_config(section, key, default) - return default - - @staticmethod - def set_config(section, key, value): - reg = ConfigHelper.get_registry() - if not reg.has_section(section): - reg.create_section(section) - return reg.set_value(section, key, value) - - @staticmethod - def delete_config(section, key): - reg = ConfigHelper.get_registry() - reg.delete_value(section, key) - - @staticmethod - def get_registry(): - """ - This static method loads the appropriate registry class based on the - current operating system, and returns an instantiation of that class. - """ - if ConfigHelper.__registry__ is None: - config_path = AppLocation.get_directory(AppLocation.ConfigDir) - ConfigHelper.__registry__ = Registry(config_path) - return ConfigHelper.__registry__ - diff --git a/openlp/core/utils/registry.py b/openlp/core/utils/registry.py deleted file mode 100644 index 3d7137dfd..000000000 --- a/openlp/core/utils/registry.py +++ /dev/null @@ -1,134 +0,0 @@ -# -*- coding: utf-8 -*- -# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4 - -############################################################################### -# OpenLP - Open Source Lyrics Projection # -# --------------------------------------------------------------------------- # -# Copyright (c) 2008-2010 Raoul Snyman # -# Portions copyright (c) 2008-2010 Tim Bentley, Jonathan Corwin, Michael # -# Gorven, Scott Guerrieri, Christian Richter, Maikel Stuivenberg, Martin # -# Thompson, Jon Tibble, Carsten Tinggaard # -# --------------------------------------------------------------------------- # -# 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 # -############################################################################### - -import os - -from ConfigParser import SafeConfigParser - -class Registry(object): - """ - The Registry class is a high-level class for working with a configuration - file. - """ - def __init__(self, dir): - self.config = SafeConfigParser() - self.file_name = os.path.join(dir, u'openlp.conf') - self._load() - - def has_value(self, section, key): - """ - Check if a value exists. - """ - return self.config.has_option(section.encode('utf-8'), - key.encode('utf-8')) - - def get_value(self, section, key, default=None): - """ - Get a single value from the registry. - """ - try: - if self.config.get(section.encode('utf-8'), key.encode('utf-8')): - return self.config.get(section.encode('utf-8'), - key.encode('utf-8')).decode('utf-8') - else: - return default - except: - return default - - def set_value(self, section, key, value): - """ - Set a single value in the registry. - """ - try : - self.config.set(section.encode('utf-8'), key.encode('utf-8'), - unicode(value).encode('utf-8')) - return self._save() - except: - return False - - def delete_value(self, section, key): - """ - Delete a single value from the registry. - """ - try: - self.config.remove_option(section.encode('utf-8'), - key.encode('utf-8')) - return self._save() - except: - return False - - def has_section(self, section): - """ - Check if a section exists. - """ - return self.config.has_section(section.encode('utf-8')) - - def create_section(self, section): - """ - Create a new section in the registry. - """ - try: - self.config.add_section(section.encode('utf-8')) - return self._save() - except: - return False - - def delete_section(self, section): - """ - Delete a section (including all values). - """ - try: - self.config.remove_section(section.encode('utf-8')) - return self._save() - except: - return False - - def _load(self): - if not os.path.isfile(self.file_name): - return False - file_handle = None - try: - file_handle = open(self.file_name, u'r') - self.config.readfp(file_handle) - return True - except: - return False - finally: - if file_handle: - file_handle.close() - - def _save(self): - file_handle = None - try: - if not os.path.exists(os.path.dirname(self.file_name)): - os.makedirs(os.path.dirname(self.file_name)) - file_handle = open(self.file_name, u'w') - self.config.write(file_handle) - return self._load() - except: - return False - finally: - if file_handle: - file_handle.close() diff --git a/openlp/plugins/alerts/alertsplugin.py b/openlp/plugins/alerts/alertsplugin.py index 819e8eed6..a55523e4b 100644 --- a/openlp/plugins/alerts/alertsplugin.py +++ b/openlp/plugins/alerts/alertsplugin.py @@ -41,7 +41,7 @@ class alertsPlugin(Plugin): self.weight = -3 self.icon = build_icon(u':/media/media_image.png') self.alertsmanager = AlertsManager(self) - self.manager = DBManager(self.config) + self.manager = DBManager() self.alertForm = AlertForm(self.manager, self) self.status = PluginStatus.Active @@ -83,7 +83,8 @@ class alertsPlugin(Plugin): def togglealertsState(self): self.alertsActive = not self.alertsActive - self.config.set_config(u'active', self.alertsActive) + QtCore.QSettings().setValue( + u'alerts/active', QtCore.QVariant(self.alertsActive)) def onAlertsTrigger(self): self.alertForm.loadList() diff --git a/openlp/plugins/alerts/forms/alertstab.py b/openlp/plugins/alerts/forms/alertstab.py index 3e4b45865..14066f7aa 100644 --- a/openlp/plugins/alerts/forms/alertstab.py +++ b/openlp/plugins/alerts/forms/alertstab.py @@ -31,10 +31,10 @@ class AlertsTab(SettingsTab): """ AlertsTab is the alerts settings tab in the settings dialog. """ - def __init__(self, parent, section=None): + def __init__(self, parent): self.parent = parent self.manager = parent.manager - SettingsTab.__init__(self, parent.name, section) + SettingsTab.__init__(self, parent.name) def setupUi(self): self.setObjectName(u'AlertsTab') @@ -228,15 +228,16 @@ class AlertsTab(SettingsTab): self.updateDisplay() def load(self): - self.timeout = int(self.config.get_config(u'timeout', 5)) - self.font_color = unicode( - self.config.get_config(u'font color', u'#ffffff')) - self.font_size = int(self.config.get_config(u'font size', 40)) - self.bg_color = unicode( - self.config.get_config(u'background color', u'#660000')) - self.font_face = unicode( - self.config.get_config(u'font face', QtGui.QFont().family())) - self.location = int(self.config.get_config(u'location', 0)) + settings = QtCore.QSettings() + self.timeout = settings.value(u'alerts/timeout', 5).toInt()[0] + self.font_color = unicode(settings.value( + u'alerts/font color', u'#ffffff').toString()) + self.font_size = settings.value(u'alerts/font size', 40).toInt()[0] + self.bg_color = unicode(settings.value( + u'alerts/background color', u'#660000').toString()) + self.font_face = unicode(settings.value( + u'alerts/font face', QtGui.QFont().family()).toString()) + self.location = settings.value(u'alerts/location', 0).toInt()[0] self.FontSizeSpinBox.setValue(self.font_size) self.TimeoutSpinBox.setValue(self.timeout) self.FontColorButton.setStyleSheet( @@ -254,14 +255,17 @@ class AlertsTab(SettingsTab): self.DeleteButton.setEnabled(True) def save(self): + settings = QtCore.QSettings() self.font_face = self.FontComboBox.currentFont().family() - self.config.set_config(u'background color', unicode(self.bg_color)) - self.config.set_config(u'font color', unicode(self.font_color)) - self.config.set_config(u'font size', unicode(self.font_size)) - self.config.set_config(u'font face', unicode(self.font_face)) - self.config.set_config(u'timeout', unicode(self.timeout)) - self.config.set_config(u'location', - unicode(self.LocationComboBox.currentIndex())) + settings.setValue( + u'alerts/background color', QtCore.QVariant(self.bg_color)) + settings.setValue( + u'alerts/font color', QtCore.QVariant(self.font_color)) + settings.setValue(u'alerts/font size', QtCore.QVariant(self.font_size)) + settings.setValue(u'alerts/font face', QtCore.QVariant(self.font_face)) + settings.setValue(u'alerts/timeout', QtCore.QVariant(self.timeout)) + settings.setValue(u'alerts/location', + QtCore.QVariant(self.LocationComboBox.currentIndex())) def updateDisplay(self): font = QtGui.QFont() diff --git a/openlp/plugins/alerts/lib/manager.py b/openlp/plugins/alerts/lib/manager.py index ec4654807..98a3d8a43 100644 --- a/openlp/plugins/alerts/lib/manager.py +++ b/openlp/plugins/alerts/lib/manager.py @@ -25,6 +25,9 @@ import logging +from PyQt4 import QtCore + +from openlp.core.utils import AppLocation from openlp.plugins.alerts.lib.models import init_models, metadata, AlertItem log = logging.getLogger(__name__) @@ -36,24 +39,25 @@ class DBManager(): """ log.info(u'Alerts DB loaded') - def __init__(self, config): + def __init__(self): """ Creates the connection to the database, and creates the tables if they don't exist. """ - self.config = config + settings = QtCore.QSettings() log.debug(u'Alerts Initialising') self.db_url = u'' - db_type = self.config.get_config(u'db type', u'sqlite') + db_type = unicode( + settings.value(u'alerts/db type', u'sqlite').toString()) if db_type == u'sqlite': self.db_url = u'sqlite:///%s/alerts.sqlite' % \ - self.config.get_data_path() + AppLocation.get_section_data_path(u'alerts') else: self.db_url = u'%s://%s:%s@%s/%s' % \ - (db_type, self.config.get_config(u'db username'), - self.config.get_config(u'db password'), - self.config.get_config(u'db hostname'), - self.config.get_config(u'db database')) + (db_type, settings.value(u'alerts/db username'), + settings.value(u'alerts/db password'), + settings.value(u'alerts/db hostname'), + settings.value(u'alerts/db database')) self.session = init_models(self.db_url) metadata.create_all(checkfirst=True) diff --git a/openlp/plugins/bibles/bibleplugin.py b/openlp/plugins/bibles/bibleplugin.py index 61724ffb6..5b4070665 100644 --- a/openlp/plugins/bibles/bibleplugin.py +++ b/openlp/plugins/bibles/bibleplugin.py @@ -46,7 +46,7 @@ class BiblePlugin(Plugin): def initialise(self): log.info(u'bibles Initialising') if self.manager is None: - self.manager = BibleManager(self, self.config) + self.manager = BibleManager(self) Plugin.initialise(self) self.insert_toolbox_item() self.ImportBibleItem.setVisible(True) diff --git a/openlp/plugins/bibles/forms/importwizardform.py b/openlp/plugins/bibles/forms/importwizardform.py index 46bff5bb9..41df18cdc 100644 --- a/openlp/plugins/bibles/forms/importwizardform.py +++ b/openlp/plugins/bibles/forms/importwizardform.py @@ -31,7 +31,7 @@ import os.path from PyQt4 import QtCore, QtGui from bibleimportwizard import Ui_BibleImportWizard -from openlp.core.lib import Receiver +from openlp.core.lib import Receiver, SettingsManager from openlp.core.utils import AppLocation, variant_to_unicode from openlp.plugins.bibles.lib.manager import BibleFormat @@ -59,16 +59,13 @@ class ImportWizardForm(QtGui.QWizard, Ui_BibleImportWizard): """ log.info(u'BibleImportForm loaded') - def __init__(self, parent, config, manager, bibleplugin): + def __init__(self, parent, manager, bibleplugin): """ Instantiate the wizard, and run any extra setup we need to. ``parent`` The QWidget-derived parent of the wizard. - ``config`` - The configuration object for storing and retrieving settings. - ``manager`` The Bible manager. @@ -81,7 +78,6 @@ class ImportWizardForm(QtGui.QWizard, Ui_BibleImportWizard): self.finishButton = self.button(QtGui.QWizard.FinishButton) self.cancelButton = self.button(QtGui.QWizard.CancelButton) self.manager = manager - self.config = config self.bibleplugin = bibleplugin self.manager.set_process_dialog(self) self.web_bible_list = {} @@ -277,6 +273,7 @@ class ImportWizardForm(QtGui.QWizard, Ui_BibleImportWizard): u'license_permission', self.PermissionEdit) def setDefaults(self): + settings = QtCore.QSettings() self.setField(u'source_format', QtCore.QVariant(0)) self.setField(u'osis_location', QtCore.QVariant('')) self.setField(u'csv_booksfile', QtCore.QVariant('')) @@ -285,14 +282,15 @@ class ImportWizardForm(QtGui.QWizard, Ui_BibleImportWizard): self.setField(u'web_location', QtCore.QVariant(WebDownload.Crosswalk)) self.setField(u'web_biblename', QtCore.QVariant(self.BibleComboBox)) self.setField(u'proxy_server', - QtCore.QVariant(self.config.get_config(u'proxy address', ''))) + settings.value(u'bibles/proxy address', u'')) self.setField(u'proxy_username', - QtCore.QVariant(self.config.get_config(u'proxy username',''))) + settings.value(u'bibles/proxy username', u'')) self.setField(u'proxy_password', - QtCore.QVariant(self.config.get_config(u'proxy password',''))) + settings.value(u'proxy password', u'')) self.setField(u'license_version', QtCore.QVariant(self.VersionNameEdit)) self.setField(u'license_copyright', QtCore.QVariant(self.CopyrightEdit)) - self.setField(u'license_permission', QtCore.QVariant(self.PermissionEdit)) + self.setField(u'license_permission', + QtCore.QVariant(self.PermissionEdit)) self.onLocationComboBoxChanged(WebDownload.Crosswalk) def loadWebBibles(self): @@ -302,10 +300,10 @@ class ImportWizardForm(QtGui.QWizard, Ui_BibleImportWizard): #Load and store Crosswalk Bibles filepath = AppLocation.get_directory(AppLocation.PluginsDir) filepath = os.path.join(filepath, u'bibles', u'resources') - fbibles = None try: self.web_bible_list[WebDownload.Crosswalk] = {} - books_file = open(os.path.join(filepath, u'crosswalkbooks.csv'), 'r') + books_file = open( + os.path.join(filepath, u'crosswalkbooks.csv'), 'r') dialect = csv.Sniffer().sniff(books_file.read(1024)) books_file.seek(0) books_reader = csv.reader(books_file, dialect) @@ -345,10 +343,10 @@ class ImportWizardForm(QtGui.QWizard, Ui_BibleImportWizard): def getFileName(self, title, editbox): filename = QtGui.QFileDialog.getOpenFileName(self, title, - self.config.get_last_dir(1)) + SettingsManager.get_last_dir(bibles, 1)) if filename: editbox.setText(filename) - self.config.set_last_dir(filename, 1) + SettingsManager.set_last_dir(bibles, filename, 1) def incrementProgressBar(self, status_text): log.debug(u'IncrementBar %s', status_text) @@ -368,7 +366,8 @@ class ImportWizardForm(QtGui.QWizard, Ui_BibleImportWizard): bible_type = self.field(u'source_format').toInt()[0] license_version = variant_to_unicode(self.field(u'license_version')) license_copyright = variant_to_unicode(self.field(u'license_copyright')) - license_permission = variant_to_unicode(self.field(u'license_permission')) + license_permission = variant_to_unicode( + self.field(u'license_permission')) importer = None if bible_type == BibleFormat.OSIS: # Import an OSIS bible diff --git a/openlp/plugins/bibles/lib/biblestab.py b/openlp/plugins/bibles/lib/biblestab.py index 103187615..3965a0933 100644 --- a/openlp/plugins/bibles/lib/biblestab.py +++ b/openlp/plugins/bibles/lib/biblestab.py @@ -27,7 +27,7 @@ import logging from PyQt4 import QtCore, QtGui -from openlp.core.lib import str_to_bool, Receiver, SettingsTab +from openlp.core.lib import Receiver, SettingsTab log = logging.getLogger(__name__) @@ -37,11 +37,11 @@ class BiblesTab(SettingsTab): """ log.info(u'Bible Tab loaded') - def __init__(self, title, section=None): + def __init__(self, title): self.paragraph_style = True self.show_new_chapters = False self.display_style = 0 - SettingsTab.__init__(self, title, section) + SettingsTab.__init__(self, title) def setupUi(self): self.setObjectName(u'BiblesTab') @@ -161,8 +161,8 @@ class BiblesTab(SettingsTab): self.DisplayStyleComboBox.setItemText(1, self.trUtf8('( and )')) self.DisplayStyleComboBox.setItemText(2, self.trUtf8('{ and }')) self.DisplayStyleComboBox.setItemText(3, self.trUtf8('[ and ]')) - self.ChangeNoteLabel.setText( - self.trUtf8('Note:\nChanges don\'t affect verses already in the service')) + self.ChangeNoteLabel.setText(self.trUtf8( + 'Note:\nChanges don\'t affect verses already in the service')) self.BibleDualCheckBox.setText(self.trUtf8('Display Dual Bible Verses')) def onBibleThemeComboBoxChanged(self): @@ -187,29 +187,33 @@ class BiblesTab(SettingsTab): self.duel_bibles = True def load(self): - 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.duel_bibles = str_to_bool( - self.config.get_config(u'dual bibles', u'True')) + settings = QtCore.QSettings() + self.show_new_chapters = settings.value( + u'bibles/display new chapter', False).toBool() + self.display_style = settings.value( + u'bibles/display brackets', 0).toInt()[0] + self.layout_style = settings.value( + u'bibles/verse layout style', 0).toInt()[0] + self.bible_theme = unicode( + settings.value(u'bibles/bible theme', u'').toString()) + self.duel_bibles = settings.value(u'bibles/dual bibles', True).toBool() self.NewChaptersCheckBox.setChecked(self.show_new_chapters) self.DisplayStyleComboBox.setCurrentIndex(self.display_style) self.LayoutStyleComboBox.setCurrentIndex(self.layout_style) self.BibleDualCheckBox.setChecked(self.duel_bibles) def save(self): - 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'dual bibles', unicode(self.duel_bibles)) - self.config.set_config(u'bible theme', unicode(self.bible_theme)) + settings = QtCore.QSettings() + settings.setValue(u'bibles/display new chapter', + QtCore.QVariant(self.show_new_chapters)) + settings.setValue(u'bibles/display brackets', + QtCore.QVariant(self.display_style)) + settings.setValue(u'bibles/verse layout style', + QtCore.QVariant(self.layout_style)) + settings.setValue(u'bibles/dual bibles', + QtCore.QVariant(self.duel_bibles)) + settings.setValue(u'bibles/bible theme', + QtCore.QVariant(self.bible_theme)) def updateThemeList(self, theme_list): """ diff --git a/openlp/plugins/bibles/lib/db.py b/openlp/plugins/bibles/lib/db.py index 66b956109..207fe4091 100644 --- a/openlp/plugins/bibles/lib/db.py +++ b/openlp/plugins/bibles/lib/db.py @@ -56,20 +56,14 @@ class BibleDB(QtCore.QObject): ``name`` The name of the database. This is also used as the file name for SQLite databases. - - ``config`` - The configuration object, passed in from the plugin. """ log.info(u'BibleDB loaded') QtCore.QObject.__init__(self) if u'path' not in kwargs: raise KeyError(u'Missing keyword argument "path".') - if u'config' not in kwargs: - raise KeyError(u'Missing keyword argument "config".') if u'name' not in kwargs and u'file' not in kwargs: raise KeyError(u'Missing keyword argument "name" or "file".') self.stop_import_flag = False - self.config = kwargs[u'config'] if u'name' in kwargs: self.name = kwargs[u'name'] if not isinstance(self.name, unicode): @@ -79,16 +73,18 @@ class BibleDB(QtCore.QObject): self.file = kwargs[u'file'] self.db_file = os.path.join(kwargs[u'path'], self.file) log.debug(u'Load bible %s on path %s', self.file, self.db_file) - db_type = self.config.get_config(u'db type', u'sqlite') + settings = QtCore.QSettings() + db_type = unicode( + settings.value(u'bibles/db type', u'sqlite').toString()) db_url = u'' if db_type == u'sqlite': db_url = u'sqlite:///' + self.db_file else: db_url = u'%s://%s:%s@%s/%s' % \ - (db_type, self.config.get_config(u'db username'), - self.config.get_config(u'db password'), - self.config.get_config(u'db hostname'), - self.config.get_config(u'db database')) + (db_type, unicode(settings.value(u'bibles/db username')), + unicode(settings.value(u'bibles/db password')), + unicode(settings.value(u'bibles/db hostname')), + unicode(settings.value(u'bibles/db database'))) self.metadata, self.session = init_models(db_url) self.metadata.create_all(checkfirst=True) if u'file' in kwargs: diff --git a/openlp/plugins/bibles/lib/manager.py b/openlp/plugins/bibles/lib/manager.py index 8e622963d..bc96a81e5 100644 --- a/openlp/plugins/bibles/lib/manager.py +++ b/openlp/plugins/bibles/lib/manager.py @@ -25,6 +25,11 @@ import logging +from PyQt4 import QtCore + +from openlp.core.lib import SettingsManager +from openlp.core.utils import AppLocation + from common import parse_reference from opensong import OpenSongBible from osis import OSISBible @@ -94,24 +99,21 @@ class BibleManager(object): """ log.info(u'Bible manager loaded') - def __init__(self, parent, config): + def __init__(self, parent): """ Finds all the bibles defined for the system and creates an interface object for each bible containing connection information. Throws Exception if no Bibles are found. Init confirms the bible exists and stores the database path. - - ``config`` - The plugin's configuration object. """ log.debug(u'Bible Initialising') - self.config = config self.parent = parent self.web = u'Web' self.db_cache = None - self.path = self.config.get_data_path() - self.proxy_name = self.config.get_config(u'proxy name') + self.path = AppLocation.get_section_data_path(u'bibles') + self.proxy_name = unicode( + QtCore.QSettings().value(u'bibles/proxy name', u'').toString()) self.suffix = u'sqlite' self.import_wizard = None self.reload_bibles() @@ -124,12 +126,11 @@ class BibleManager(object): BibleDB class. """ log.debug(u'Reload bibles') - files = self.config.get_files(self.suffix) + files = SettingsManager.get_files(self.suffix) log.debug(u'Bible Files %s', files) self.db_cache = {} for filename in files: - bible = BibleDB(self.parent, path=self.path, file=filename, - config=self.config) + bible = BibleDB(self.parent, path=self.path, file=filename) name = bible.get_name() log.debug(u'Bible Name: "%s"', name) self.db_cache[name] = bible @@ -139,8 +140,8 @@ class BibleManager(object): download_name = self.db_cache[name].get_meta(u'download name').value meta_proxy = self.db_cache[name].get_meta(u'proxy url') web_bible = HTTPBible(self.parent, path=self.path, - file=filename, config=self.config, - download_source=source.value, download_name=download_name) + file=filename, download_source=source.value, + download_name=download_name) if meta_proxy: web_bible.set_proxy_server(meta_proxy.value) self.db_cache[name] = web_bible @@ -167,7 +168,6 @@ class BibleManager(object): """ class_ = BibleFormat.get_class(type) kwargs['path'] = self.path - kwargs['config'] = self.config importer = class_(self.parent, **kwargs) name = importer.register(self.import_wizard) self.db_cache[name] = importer @@ -260,4 +260,3 @@ class BibleManager(object): if bible == name: return True return False - diff --git a/openlp/plugins/bibles/lib/mediaitem.py b/openlp/plugins/bibles/lib/mediaitem.py index 66d27e4d3..afdd89e3e 100644 --- a/openlp/plugins/bibles/lib/mediaitem.py +++ b/openlp/plugins/bibles/lib/mediaitem.py @@ -28,8 +28,8 @@ import time from PyQt4 import QtCore, QtGui -from openlp.core.lib import MediaManagerItem, Receiver, str_to_bool, \ - BaseListWithDnD, ItemCapabilities +from openlp.core.lib import MediaManagerItem, Receiver, BaseListWithDnD, \ + ItemCapabilities from openlp.plugins.bibles.forms import ImportWizardForm log = logging.getLogger(__name__) @@ -276,8 +276,7 @@ class BibleMediaItem(MediaManagerItem): self.SearchProgress.setObjectName(u'SearchProgress') def configUpdated(self): - if str_to_bool( - self.parent.config.get_config(u'dual bibles', u'False')): + if QtCore.QSettings().value(u'bibles/dual bibles', False).toBool(): self.AdvancedSecondBibleLabel.setVisible(True) self.AdvancedSecondBibleComboBox.setVisible(True) self.QuickSecondVersionLabel.setVisible(True) @@ -381,7 +380,7 @@ class BibleMediaItem(MediaManagerItem): self.AdvancedBookComboBox.itemData(item).toInt()[0]) def onImportClick(self): - self.bibleimportform = ImportWizardForm(self, self.parent.config, + self.bibleimportform = ImportWizardForm(self, self.parent.manager, self.parent) self.bibleimportform.exec_() self.reloadBibles() diff --git a/openlp/plugins/bibles/lib/osis.py b/openlp/plugins/bibles/lib/osis.py index 7c532e313..bddf04a5a 100644 --- a/openlp/plugins/bibles/lib/osis.py +++ b/openlp/plugins/bibles/lib/osis.py @@ -98,7 +98,8 @@ class OSISBible(BibleDB): Loads a Bible from file. """ log.debug(u'Starting OSIS import from "%s"' % self.filename) - self.wizard.incrementProgressBar(u'Detecting encoding (this may take a few minutes)...') + self.wizard.incrementProgressBar( + u'Detecting encoding (this may take a few minutes)...') detect_file = None try: detect_file = open(self.filename, u'r') diff --git a/openlp/plugins/custom/customplugin.py b/openlp/plugins/custom/customplugin.py index 979df411c..a59596f22 100644 --- a/openlp/plugins/custom/customplugin.py +++ b/openlp/plugins/custom/customplugin.py @@ -45,7 +45,7 @@ class CustomPlugin(Plugin): def __init__(self, plugin_helpers): Plugin.__init__(self, u'Custom', u'1.9.1', plugin_helpers) self.weight = -5 - self.custommanager = CustomManager(self.config) + self.custommanager = CustomManager() self.edit_custom_form = EditCustomForm(self.custommanager) self.icon = build_icon(u':/media/media_custom.png') self.status = PluginStatus.Active diff --git a/openlp/plugins/custom/lib/customtab.py b/openlp/plugins/custom/lib/customtab.py index cceca1148..d99c6d9e3 100644 --- a/openlp/plugins/custom/lib/customtab.py +++ b/openlp/plugins/custom/lib/customtab.py @@ -25,14 +25,14 @@ from PyQt4 import QtCore, QtGui -from openlp.core.lib import SettingsTab, str_to_bool +from openlp.core.lib import SettingsTab class CustomTab(SettingsTab): """ CustomTab is the Custom settings tab in the settings dialog. """ - def __init__(self, title, section=None): - SettingsTab.__init__(self, title, section) + def __init__(self, title): + SettingsTab.__init__(self, title) def setupUi(self): self.setObjectName(u'CustomTab') @@ -66,9 +66,10 @@ class CustomTab(SettingsTab): self.displayFooter = True def load(self): - self.displayFooter = str_to_bool( - self.config.get_config(u'display footer', True)) + self.displayFooter = QtCore.QSettings().value( + u'custom/display footer', True).toBool() self.DisplayFooterCheckBox.setChecked(self.displayFooter) def save(self): - self.config.set_config(u'display footer', unicode(self.displayFooter)) + QtCore.QSettings().setValue( + u'custom/display footer', QtCore.QVariant(self.displayFooter)) diff --git a/openlp/plugins/custom/lib/manager.py b/openlp/plugins/custom/lib/manager.py index 2deee9ba2..54962d9b0 100644 --- a/openlp/plugins/custom/lib/manager.py +++ b/openlp/plugins/custom/lib/manager.py @@ -25,6 +25,9 @@ import logging +from PyQt4 import QtCore + +from openlp.core.utils import AppLocation from openlp.plugins.custom.lib.models import init_models, metadata, CustomSlide log = logging.getLogger(__name__) @@ -36,24 +39,25 @@ class CustomManager(): """ log.info(u'Custom manager loaded') - def __init__(self, config): + def __init__(self): """ Creates the connection to the database, and creates the tables if they don't exist. """ - self.config = config log.debug(u'Custom Initialising') + settings = QtCore.QSettings() self.db_url = u'' - db_type = self.config.get_config(u'db type', u'sqlite') + db_type = unicode( + settings.value(u'custom/db type', u'sqlite').toString()) if db_type == u'sqlite': self.db_url = u'sqlite:///%s/custom.sqlite' % \ - self.config.get_data_path() + AppLocation.get_section_data_path(u'custom') else: - self.db_url = u'%s://%s:%s@%s/%s' % \ - (db_type, self.config.get_config(u'db username'), - self.config.get_config(u'db password'), - self.config.get_config(u'db hostname'), - self.config.get_config(u'db database')) + self.db_url = u'%s://%s:%s@%s/%s' % (db_type, + unicode(settings.value(u'custom/db username')), + unicode(settings.value(u'custom/db password')), + unicode(settings.value(u'custom/db hostname')), + unicode(settings.value(u'custom/db database'))) self.session = init_models(self.db_url) metadata.create_all(checkfirst=True) @@ -107,4 +111,5 @@ class CustomManager(): return True def get_customs_for_theme(self, theme): - return self.session.query(CustomSlide).filter(CustomSlide.theme_name == theme).all() + return self.session.query( + CustomSlide).filter(CustomSlide.theme_name == theme).all() diff --git a/openlp/plugins/custom/lib/mediaitem.py b/openlp/plugins/custom/lib/mediaitem.py index c79452c20..aa82eb452 100644 --- a/openlp/plugins/custom/lib/mediaitem.py +++ b/openlp/plugins/custom/lib/mediaitem.py @@ -27,8 +27,8 @@ import logging from PyQt4 import QtCore, QtGui -from openlp.core.lib import MediaManagerItem, SongXMLParser, BaseListWithDnD,\ -Receiver, str_to_bool, ItemCapabilities +from openlp.core.lib import MediaManagerItem, SongXMLParser, BaseListWithDnD, \ + Receiver, ItemCapabilities log = logging.getLogger(__name__) @@ -164,7 +164,7 @@ class CustomMediaItem(MediaManagerItem): service_item.title = title for slide in raw_slides: service_item.add_from_text(slide[:30], slide) - if str_to_bool(self.parent.config.get_config(u'display footer', True)) \ + if QtCore.QSettings().value(u'custom/display footer', True).toBool() \ or credit: raw_footer.append(title + u' ' + credit) else: diff --git a/openlp/plugins/images/lib/imagetab.py b/openlp/plugins/images/lib/imagetab.py index 9283dbdf3..f7bdb3106 100644 --- a/openlp/plugins/images/lib/imagetab.py +++ b/openlp/plugins/images/lib/imagetab.py @@ -31,8 +31,8 @@ class ImageTab(SettingsTab): """ ImageTab is the Image settings tab in the settings dialog. """ - def __init__(self, title, section=None): - SettingsTab.__init__(self, title, section) + def __init__(self, title): + SettingsTab.__init__(self, title) def setupUi(self): self.setObjectName(u'ImageTab') @@ -71,11 +71,13 @@ class ImageTab(SettingsTab): self.loop_delay = self.TimeoutSpinBox.value() def load(self): - self.loop_delay = int(self.config.get_config(u'loop delay', 5)) + self.loop_delay = QtCore.QSettings().value( + u'images/loop delay', 5).toInt()[0] self.TimeoutSpinBox.setValue(self.loop_delay) def save(self): - self.config.set_config(u'loop delay', self.loop_delay) + QtCore.QSettings().setValue( + u'images/loop delay', QtCore.QVariant(self.loop_delay)) Receiver.send_message(u'slidecontroller_live_spin_delay', self.loop_delay) diff --git a/openlp/plugins/images/lib/mediaitem.py b/openlp/plugins/images/lib/mediaitem.py index 914a6ce20..7b104136c 100644 --- a/openlp/plugins/images/lib/mediaitem.py +++ b/openlp/plugins/images/lib/mediaitem.py @@ -27,8 +27,10 @@ import logging import os from PyQt4 import QtCore, QtGui + from openlp.core.lib import MediaManagerItem, BaseListWithDnD, build_icon, \ - contextMenuAction, ItemCapabilities + contextMenuAction, ItemCapabilities, SettingsManager +from openlp.core.utils import AppLocation log = logging.getLogger(__name__) @@ -76,10 +78,12 @@ class ImageMediaItem(MediaManagerItem): QtGui.QAbstractItemView.ExtendedSelection) self.ListView.setIconSize(QtCore.QSize(88,50)) self.servicePath = os.path.join( - self.parent.config.get_data_path(), u'.thumbnails') + AppLocation.get_section_data_path(self.ConfigSection), + u'.thumbnails') if not os.path.exists(self.servicePath): os.mkdir(self.servicePath) - self.loadList(self.parent.config.load_list(self.ConfigSection)) + self.loadList(SettingsManager.load_list( + self.ConfigSection, self.ConfigSection)) def addListViewToToolBar(self): MediaManagerItem.addListViewToToolBar(self) @@ -112,12 +116,13 @@ class ImageMediaItem(MediaManagerItem): for item in items: text = self.ListView.item(item.row()) try: - os.remove(os.path.join(self.servicePath, unicode(text.text()))) + os.remove( + os.path.join(self.servicePath, unicode(text.text()))) except: #if not present do not worry pass self.ListView.takeItem(item.row()) - self.parent.config.set_list(self.ConfigSection, self.getFileList()) + SettingsManager.set_list(self.ConfigSection, self.getFileList()) def loadList(self, list): for file in list: diff --git a/openlp/plugins/media/lib/mediaitem.py b/openlp/plugins/media/lib/mediaitem.py index aa1a8f38a..9342708f4 100644 --- a/openlp/plugins/media/lib/mediaitem.py +++ b/openlp/plugins/media/lib/mediaitem.py @@ -29,7 +29,7 @@ import os from PyQt4 import QtCore, QtGui from openlp.core.lib import MediaManagerItem, BaseListWithDnD, build_icon, \ -ItemCapabilities + ItemCapabilities, SettingsManager log = logging.getLogger(__name__) @@ -47,12 +47,12 @@ class MediaMediaItem(MediaManagerItem): def __init__(self, parent, icon, title): self.PluginNameShort = u'Media' self.IconPath = u'images/image' - self.ConfigSection = u'media' self.ConfigSection = title # this next is a class, not an instance of a class - it will # be instanced by the base MediaManagerItem self.ListViewWithDnD_class = MediaListView - self.PreviewFunction = QtGui.QPixmap(u':/media/media_video.png').toImage() + self.PreviewFunction = QtGui.QPixmap( + u':/media/media_video.png').toImage() MediaManagerItem.__init__(self, parent, icon, title) self.singleServiceItem = False self.ServiceItemIconName = u':/media/media_video.png' @@ -89,15 +89,15 @@ class MediaMediaItem(MediaManagerItem): self.ListView.setSelectionMode( QtGui.QAbstractItemView.ExtendedSelection) self.ListView.setIconSize(QtCore.QSize(88,50)) - self.loadList(self.parent.config.load_list(self.ConfigSection)) + self.loadList(SettingsManager.load_list( + self.ConfigSection, self.ConfigSection)) def onDeleteClick(self): item = self.ListView.currentItem() if item: row = self.ListView.row(item) self.ListView.takeItem(row) - self.parent.config.set_list( - self.ConfigSection, self.getFileList()) + SettingsManager.set_list(self.ConfigSection, self.getFileList()) def loadList(self, list): for file in list: diff --git a/openlp/plugins/presentations/lib/mediaitem.py b/openlp/plugins/presentations/lib/mediaitem.py index 701efc086..900af71b6 100644 --- a/openlp/plugins/presentations/lib/mediaitem.py +++ b/openlp/plugins/presentations/lib/mediaitem.py @@ -28,7 +28,9 @@ import os from PyQt4 import QtCore, QtGui -from openlp.core.lib import MediaManagerItem, BaseListWithDnD, build_icon +from openlp.core.lib import MediaManagerItem, BaseListWithDnD, build_icon, \ + SettingsManager +from openlp.core.utils import AppLocation from openlp.plugins.presentations.lib import MessageListener log = logging.getLogger(__name__) @@ -68,7 +70,8 @@ class PresentationMediaItem(MediaManagerItem): fileType = u'' for controller in self.controllers: if self.controllers[controller].enabled: - types = self.controllers[controller].supports + self.controllers[controller].alsosupports + types = self.controllers[controller].supports + \ + self.controllers[controller].alsosupports for type in types: if fileType.find(type) == -1: fileType += u'*%s ' % type @@ -104,10 +107,11 @@ class PresentationMediaItem(MediaManagerItem): def initialise(self): self.servicePath = os.path.join( - self.parent.config.get_data_path(), u'thumbnails') + AppLocation.get_section_data_path(self.ConfigSection), + u'thumbnails') if not os.path.exists(self.servicePath): os.mkdir(self.servicePath) - list = self.parent.config.load_list(u'presentations') + list = SettingsManager.load_list(self.ConfigSection, u'presentations') self.loadList(list) for item in self.controllers: #load the drop down selection @@ -134,17 +138,20 @@ class PresentationMediaItem(MediaManagerItem): else: icon = None for controller in self.controllers: - thumbPath = os.path.join(self.parent.config.get_data_path(), \ + thumbPath = os.path.join( + AppLocation.get_section_data_path(self.ConfigSection), u'thumbnails', controller, filename) thumb = os.path.join(thumbPath, u'slide1.png') - preview = os.path.join(self.parent.config.get_data_path(), \ + preview = os.path.join( + AppLocation.get_section_data_path(self.ConfigSection), controller, u'thumbnails', filename, u'slide1.png') if os.path.exists(preview): if os.path.exists(thumb): if self.validate(preview, thumb): icon = build_icon(thumb) else: - icon = build_icon(u':/general/general_delete.png') + icon = build_icon( + u':/general/general_delete.png') else: os.makedirs(thumbPath) icon = self.IconFromFile(preview, thumb) @@ -160,8 +167,7 @@ class PresentationMediaItem(MediaManagerItem): if item: row = self.ListView.row(item) self.ListView.takeItem(row) - self.parent.config.set_list( - self.ConfigSection, self.getFileList()) + SettingsManager.set_list(self.ConfigSection, self.getFileList()) filepath = unicode((item.data(QtCore.Qt.UserRole)).toString()) #not sure of this has errors #John please can you look at . diff --git a/openlp/plugins/presentations/lib/presentationcontroller.py b/openlp/plugins/presentations/lib/presentationcontroller.py index 760e861f8..cbb5c9c00 100644 --- a/openlp/plugins/presentations/lib/presentationcontroller.py +++ b/openlp/plugins/presentations/lib/presentationcontroller.py @@ -30,6 +30,7 @@ import shutil from PyQt4 import QtCore from openlp.core.lib import Receiver +from openlp.core.utils import AppLocation log = logging.getLogger(__name__) @@ -68,7 +69,8 @@ class PresentationController(object): Called at system exit to clean up any running presentations ``check_available()`` - Returns True if presentation application is installed/can run on this machine + Returns True if presentation application is installed/can run on this + machine ``presentation_deleted()`` Deletes presentation specific files, e.g. thumbnails @@ -78,13 +80,14 @@ class PresentationController(object): def __init__(self, plugin=None, name=u'PresentationController'): """ - This is the constructor for the presentationcontroller object. - This provides an easy way for descendent plugins to populate common data. + This is the constructor for the presentationcontroller object. This + provides an easy way for descendent plugins to populate common data. This method *must* be overridden, like so:: class MyPresentationController(PresentationController): def __init__(self, plugin): - PresentationController.__init(self, plugin, u'My Presenter App') + PresentationController.__init( + self, plugin, u'My Presenter App') ``plugin`` Defaults to *None*. The presentationplugin object @@ -99,11 +102,12 @@ class PresentationController(object): self.name = name self.available = self.check_available() if self.available: - self.enabled = int(plugin.config.get_config( - name, QtCore.Qt.Unchecked)) == QtCore.Qt.Checked + self.enabled = QtCore.QSettings().value( + name, QtCore.Qt.Unchecked).toInt()[0] == QtCore.Qt.Checked else: self.enabled = False - self.thumbnailroot = os.path.join(plugin.config.get_data_path(), + self.thumbnailroot = os.path.join( + AppLocation.get_section_data_path(u'presentations'), name, u'thumbnails') self.thumbnailprefix = u'slide' if not os.path.isdir(self.thumbnailroot): @@ -241,7 +245,8 @@ class PresentationDocument(object): return os.path.split(presentation)[1] def get_thumbnail_path(self, presentation): - return os.path.join(self.controller.thumbnailroot, self.get_file_name(presentation)) + return os.path.join( + self.controller.thumbnailroot, self.get_file_name(presentation)) def check_thumbnails(self): """ diff --git a/openlp/plugins/presentations/lib/presentationtab.py b/openlp/plugins/presentations/lib/presentationtab.py index cf18359b1..af492d2c8 100644 --- a/openlp/plugins/presentations/lib/presentationtab.py +++ b/openlp/plugins/presentations/lib/presentationtab.py @@ -23,7 +23,7 @@ # Temple Place, Suite 330, Boston, MA 02111-1307 USA # ############################################################################### -from PyQt4 import QtGui +from PyQt4 import QtCore, QtGui from openlp.core.lib import SettingsTab @@ -31,9 +31,9 @@ class PresentationTab(SettingsTab): """ PresentationsTab is the Presentations settings tab in the settings dialog. """ - def __init__(self, title, controllers, section=None): + def __init__(self, title, controllers): self.controllers = controllers - SettingsTab.__init__(self, title, section) + SettingsTab.__init__(self, title) def setupUi(self): self.setObjectName(u'PresentationTab') @@ -100,12 +100,12 @@ class PresentationTab(SettingsTab): controller = self.controllers[key] if controller.available: checkbox = self.PresenterCheckboxes[controller.name] - checkbox.setChecked( - int(self.config.get_config(controller.name, 0))) + checkbox.setChecked(QtCore.QSettings().value( + u'presentations/' + controller.name, 0).toInt()[0]) def save(self): for key in self.controllers: controller = self.controllers[key] checkbox = self.PresenterCheckboxes[controller.name] - self.config.set_config( - controller.name, unicode(checkbox.checkState())) + QtCore.QSettings().setValue(u'presentations/' + controller.name, + QtCore.QVariant(checkbox.checkState())) diff --git a/openlp/plugins/remotes/lib/remotetab.py b/openlp/plugins/remotes/lib/remotetab.py index 31af42ff2..7096ee302 100644 --- a/openlp/plugins/remotes/lib/remotetab.py +++ b/openlp/plugins/remotes/lib/remotetab.py @@ -23,7 +23,7 @@ # Temple Place, Suite 330, Boston, MA 02111-1307 USA # ############################################################################### -from PyQt4 import QtGui +from PyQt4 import QtCore, QtGui from openlp.core.lib import SettingsTab @@ -31,8 +31,8 @@ class RemoteTab(SettingsTab): """ RemoteTab is the Remotes settings tab in the settings dialog. """ - def __init__(self, title, section=None): - SettingsTab.__init__(self, title, section) + def __init__(self, title): + SettingsTab.__init__(self, title) def setupUi(self): self.setObjectName(u'RemoteTab') @@ -57,8 +57,8 @@ class RemoteTab(SettingsTab): def load(self): self.RemotePortSpinBox.setValue( - int(self.config.get_config(u'remote port', 4316))) + QtCore.QSettings().value(u'remotes/remote port', 4316).toInt()[0]) def save(self): - self.config.set_config( - u'remote port', unicode(self.RemotePortSpinBox.value())) + QtCore.QSettings().setValue(u'remotes/remote port', + QtCore.QVariant(self.RemotePortSpinBox.value())) diff --git a/openlp/plugins/remotes/remoteplugin.py b/openlp/plugins/remotes/remoteplugin.py index eff9496ba..3ceb6d1f8 100644 --- a/openlp/plugins/remotes/remoteplugin.py +++ b/openlp/plugins/remotes/remoteplugin.py @@ -45,7 +45,8 @@ class RemotesPlugin(Plugin): Plugin.initialise(self) self.insert_toolbox_item() self.server = QtNetwork.QUdpSocket() - self.server.bind(int(self.config.get_config(u'remote port', 4316))) + self.server.bind( + QtCore.QSettings().value(u'remotes/remote port', 4316).toInt()[0]) QtCore.QObject.connect(self.server, QtCore.SIGNAL(u'readyRead()'), self.readData) diff --git a/openlp/plugins/songs/lib/manager.py b/openlp/plugins/songs/lib/manager.py index dcb49bfcd..f97b0875d 100644 --- a/openlp/plugins/songs/lib/manager.py +++ b/openlp/plugins/songs/lib/manager.py @@ -25,6 +25,9 @@ import logging +from PyQt4 import QtCore + +from openlp.core.utils import AppLocation from openlp.plugins.songs.lib.models import init_models, metadata, Song, \ Author, Topic, Book @@ -37,24 +40,25 @@ class SongManager(): """ log.info(u'Song manager loaded') - def __init__(self, config): + def __init__(self): """ Creates the connection to the database, and creates the tables if they don't exist. """ - self.config = config log.debug(u'Song Initialising') + settings = QtCore.QSettings() self.db_url = u'' - db_type = self.config.get_config(u'db type', u'sqlite') + db_type = unicode( + settings.value(u'songs/db type', u'sqlite').toString()) if db_type == u'sqlite': self.db_url = u'sqlite:///%s/songs.sqlite' % \ - self.config.get_data_path() + AppLocation.get_section_data_path(u'songs') else: self.db_url = db_type + 'u://' + \ - self.config.get_config(u'db username') + u':' + \ - self.config.get_config(u'db password') + u'@' + \ - self.config.get_config(u'db hostname') + u'/' + \ - self.config.get_config(u'db database') + unicode(settings.value(u'songs/db username', u'').toString()) + u':' + \ + unicode(settings.value(u'songs/db password', u'').toString()) + u'@' + \ + unicode(settings.value(u'songs/db hostname', u'').toString()) + u'/' + \ + unicode(settings.value(u'songs/db database', u'').toString()) self.session = init_models(self.db_url) metadata.create_all(checkfirst=True) log.debug(u'Song Initialised') diff --git a/openlp/plugins/songs/lib/mediaitem.py b/openlp/plugins/songs/lib/mediaitem.py index fb3f9c3e0..24ef71e81 100644 --- a/openlp/plugins/songs/lib/mediaitem.py +++ b/openlp/plugins/songs/lib/mediaitem.py @@ -28,7 +28,7 @@ import logging from PyQt4 import QtCore, QtGui from openlp.core.lib import MediaManagerItem, SongXMLParser, \ - BaseListWithDnD, Receiver, str_to_bool, ItemCapabilities + BaseListWithDnD, Receiver, ItemCapabilities from openlp.plugins.songs.forms import EditSongForm, SongMaintenanceForm log = logging.getLogger(__name__) @@ -133,8 +133,8 @@ class SongMediaItem(MediaManagerItem): QtCore.SIGNAL(u'songs_edit_clear'), self.onRemoteEditClear) def configUpdated(self): - self.searchAsYouType = str_to_bool( - self.parent.config.get_config(u'search as type', u'False')) + self.searchAsYouType = QtCore.QSettings().value( + u'songs/search as type', u'False').toBool() def retranslateUi(self): self.SearchTextLabel.setText(self.trUtf8('Search:')) @@ -350,7 +350,7 @@ class SongMediaItem(MediaManagerItem): author_list = author_list + unicode(author.display_name) author_audit.append(unicode(author.display_name)) if song.ccli_number is None or len(song.ccli_number) == 0: - ccli = self.parent.settings.GeneralTab.CCLINumber + ccli = self.parent.settings_form.GeneralTab.CCLINumber else: ccli = unicode(song.ccli_number) raw_footer.append(song.title) diff --git a/openlp/plugins/songs/lib/songstab.py b/openlp/plugins/songs/lib/songstab.py index 392b15691..3fb41aabf 100644 --- a/openlp/plugins/songs/lib/songstab.py +++ b/openlp/plugins/songs/lib/songstab.py @@ -25,14 +25,14 @@ from PyQt4 import QtCore, QtGui -from openlp.core.lib import SettingsTab, str_to_bool +from openlp.core.lib import SettingsTab class SongsTab(SettingsTab): """ SongsTab is the Songs settings tab in the settings dialog. """ - def __init__(self, title, section=None): - SettingsTab.__init__(self, title, section) + def __init__(self, title): + SettingsTab.__init__(self, title) def setupUi(self): self.setObjectName(u'SongsTab') @@ -80,13 +80,16 @@ class SongsTab(SettingsTab): self.song_bar = True def load(self): - self.song_search = str_to_bool( - self.config.get_config(u'search as type', False)) - self.song_bar = str_to_bool( - self.config.get_config(u'display songbar', True)) + settings = QtCore.QSettings() + self.song_search = settings.value( + u'songs/search as type', False).toBool() + self.song_bar = settings.value(u'songs/display songbar', True).toBool() self.SearchAsTypeCheckBox.setChecked(self.song_search) self.SongBarActiveCheckBox.setChecked(self.song_bar) def save(self): - self.config.set_config(u'search as type', unicode(self.song_search)) - self.config.set_config(u'display songbar', unicode(self.song_bar)) + settings = QtCore.QSettings() + settings.setValue( + u'songs/search as type', QtCore.QVariant(self.song_search)) + settings.setValue( + u'songs/display songbar', QtCore.QVariant(self.song_bar)) diff --git a/openlp/plugins/songs/songsplugin.py b/openlp/plugins/songs/songsplugin.py index 54ea6a352..af05b4605 100644 --- a/openlp/plugins/songs/songsplugin.py +++ b/openlp/plugins/songs/songsplugin.py @@ -51,7 +51,7 @@ class SongsPlugin(Plugin): """ Plugin.__init__(self, u'Songs', u'1.9.1', plugin_helpers) self.weight = -10 - self.songmanager = SongManager(self.config) + self.songmanager = SongManager() self.openlp_import_form = OpenLPImportForm() self.opensong_import_form = OpenSongImportForm() self.openlp_export_form = OpenLPExportForm() @@ -65,7 +65,7 @@ class SongsPlugin(Plugin): def initialise(self): log.info(u'Songs Initialising') #if self.songmanager is None: - # self.songmanager = SongManager(self.config) + # self.songmanager = SongManager() Plugin.initialise(self) self.insert_toolbox_item() self.ImportSongMenu.menuAction().setVisible(True) diff --git a/openlp/plugins/songusage/forms/songusagedetailform.py b/openlp/plugins/songusage/forms/songusagedetailform.py index 4e4f9bb55..e4ec80d58 100644 --- a/openlp/plugins/songusage/forms/songusagedetailform.py +++ b/openlp/plugins/songusage/forms/songusagedetailform.py @@ -23,10 +23,12 @@ # Temple Place, Suite 330, Boston, MA 02111-1307 USA # ############################################################################### +import logging import os from PyQt4 import QtCore, QtGui -import logging + +from openlp.core.lib import SettingsManager from songusagedetaildialog import Ui_SongUsageDetailDialog @@ -53,15 +55,15 @@ class SongUsageDetailForm(QtGui.QDialog, Ui_SongUsageDetailDialog): fromDate = QtCore.QDate(year - 1, 9, 1) self.FromDate.setSelectedDate(fromDate) self.ToDate.setSelectedDate(toDate) - self.FileLineEdit.setText(self.parent.config.get_last_dir(1)) + self.FileLineEdit.setText(SettingsManager.get_last_dir(u'songusage', 1)) def defineOutputLocation(self): path = QtGui.QFileDialog.getExistingDirectory(self, self.trUtf8('Output File Location'), - self.parent.config.get_last_dir(1) ) + SettingsManager.get_last_dir(u'songusage', 1)) path = unicode(path) if path != u'': - self.parent.config.set_last_dir(path, 1) + SettingsManager.set_last_dir(u'songusage', path, 1) self.FileLineEdit.setText(path) def accept(self): diff --git a/openlp/plugins/songusage/lib/manager.py b/openlp/plugins/songusage/lib/manager.py index 2802570ab..dddea5350 100644 --- a/openlp/plugins/songusage/lib/manager.py +++ b/openlp/plugins/songusage/lib/manager.py @@ -25,7 +25,11 @@ import logging -from openlp.plugins.songusage.lib.models import init_models, metadata, SongUsageItem +from PyQt4 import QtCore + +from openlp.core.utils import AppLocation +from openlp.plugins.songusage.lib.models import init_models, metadata, \ + SongUsageItem log = logging.getLogger(__name__) @@ -36,24 +40,25 @@ class SongUsageManager(): """ log.info(u'SongUsage manager loaded') - def __init__(self, config): + def __init__(self): """ Creates the connection to the database, and creates the tables if they don't exist. """ - self.config = config + settings = QtCore.QSettings() log.debug(u'SongUsage Initialising') self.db_url = u'' - db_type = self.config.get_config(u'db type', u'sqlite') + db_type = unicode( + settings.value(u'songusage/db type', u'sqlite').toString()) if db_type == u'sqlite': self.db_url = u'sqlite:///%s/songusage.sqlite' % \ - self.config.get_data_path() + AppLocation.get_section_data_path(u'songusage') else: - self.db_url = u'%s://%s:%s@%s/%s' % \ - (db_type, self.config.get_config(u'db username'), - self.config.get_config(u'db password'), - self.config.get_config(u'db hostname'), - self.config.get_config(u'db database')) + self.db_url = u'%s://%s:%s@%s/%s' % (db_type, + unicode(settings.value(u'songusage/db username', u'')), + unicode(settings.value(u'songusage/db password', u'')), + unicode(settings.value(u'songusage/db hostname', u'')), + unicode(settings.value(u'songusage/db database', u''))) self.session = init_models(self.db_url) metadata.create_all(checkfirst=True) diff --git a/openlp/plugins/songusage/songusageplugin.py b/openlp/plugins/songusage/songusageplugin.py index 3d7f9ad45..c654477e0 100644 --- a/openlp/plugins/songusage/songusageplugin.py +++ b/openlp/plugins/songusage/songusageplugin.py @@ -28,9 +28,10 @@ import logging from PyQt4 import QtCore, QtGui -from openlp.core.lib import Plugin, Receiver, str_to_bool, build_icon +from openlp.core.lib import Plugin, Receiver, build_icon from openlp.plugins.songusage.lib import SongUsageManager -from openlp.plugins.songusage.forms import SongUsageDetailForm, SongUsageDeleteForm +from openlp.plugins.songusage.forms import SongUsageDetailForm, \ + SongUsageDeleteForm from openlp.plugins.songusage.lib.models import SongUsageItem log = logging.getLogger(__name__) @@ -107,12 +108,13 @@ class SongUsagePlugin(Plugin): log.info(u'SongUsage Initialising') Plugin.initialise(self) QtCore.QObject.connect(Receiver.get_receiver(), - QtCore.SIGNAL(u'slidecontroller_live_started'), self.onReceiveSongUsage) - self.SongUsageActive = str_to_bool( - self.config.get_config(u'active', False)) + QtCore.SIGNAL(u'slidecontroller_live_started'), + self.onReceiveSongUsage) + self.SongUsageActive = QtCore.QSettings().value( + u'songusage/active', False).toBool() self.SongUsageStatus.setChecked(self.SongUsageActive) if self.songusagemanager is None: - self.songusagemanager = SongUsageManager(self.config) + self.songusagemanager = SongUsageManager() self.SongUsagedeleteform = SongUsageDeleteForm(self.songusagemanager) self.SongUsagedetailform = SongUsageDetailForm(self) self.SongUsageMenu.menuAction().setVisible(True) @@ -125,7 +127,8 @@ class SongUsagePlugin(Plugin): def toggleSongUsageState(self): self.SongUsageActive = not self.SongUsageActive - self.config.set_config(u'active', self.SongUsageActive) + QtCore.QSettings().setValue( + u'songusage/active', QtCore.QVariant(self.SongUsageActive)) def onReceiveSongUsage(self, items): """ From d5df10576e88a34c097c7eea2125204163dd8f71 Mon Sep 17 00:00:00 2001 From: Jonathan Corwin Date: Tue, 27 Apr 2010 19:39:51 +0100 Subject: [PATCH 27/63] Adding the httpserver.py which contains the functionality might help --- openlp/plugins/remotes/lib/httpserver.py | 235 +++++++++++++++++++++++ 1 file changed, 235 insertions(+) create mode 100644 openlp/plugins/remotes/lib/httpserver.py diff --git a/openlp/plugins/remotes/lib/httpserver.py b/openlp/plugins/remotes/lib/httpserver.py new file mode 100644 index 000000000..7346afba0 --- /dev/null +++ b/openlp/plugins/remotes/lib/httpserver.py @@ -0,0 +1,235 @@ +# -*- coding: utf-8 -*- +# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4 + +############################################################################### +# OpenLP - Open Source Lyrics Projection # +# --------------------------------------------------------------------------- # +# Copyright (c) 2008-2010 Raoul Snyman # +# Portions copyright (c) 2008-2010 Tim Bentley, Jonathan Corwin, Michael # +# Gorven, Scott Guerrieri, Christian Richter, Maikel Stuivenberg, Martin # +# Thompson, Jon Tibble, Carsten Tinggaard # +# --------------------------------------------------------------------------- # +# 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 # +############################################################################### + +import logging +import json +import urlparse + +from PyQt4 import QtCore, QtNetwork + +from openlp.core.lib import Receiver + +log = logging.getLogger(__name__) + +class HttpServer(object): + """ + Ability to control OpenLP via a webbrowser + e.g. http://localhost:4316/send/slidecontroller_live_next + http://localhost:4316/send/alerts_text?q=your%20alert%20text + """ + def __init__(self, parent): + log.debug(u'Initialise httpserver') + self.parent = parent + self.connections = [] + self.start_tcp() + + def start_tcp(self): + log.debug(u'Start TCP server') + port = self.parent.config.get_config(u'remote port', 4316) + self.server = QtNetwork.QTcpServer() + self.server.listen(QtNetwork.QHostAddress(QtNetwork.QHostAddress.Any), + int(port)) + QtCore.QObject.connect(self.server, + QtCore.SIGNAL(u'newConnection()'), self.new_connection) + log.debug(u'TCP listening on port %s' % port) + + def new_connection(self): + log.debug(u'new http connection') + socket = self.server.nextPendingConnection() + if socket: + self.connections.append(HttpConnection(self, socket)) + + def close_connection(self, connection): + log.debug(u'close http connection') + self.connections.remove(connection) + + def close(self): + log.debug(u'close http server') + self.server.close() + +class HttpConnection(object): + + def __init__(self, parent, socket): + log.debug(u'Initialise HttpConnection: %s' % + socket.peerAddress().toString()) + self.socket = socket + self.parent = parent + QtCore.QObject.connect(self.socket, QtCore.SIGNAL(u'readyRead()'), + self.ready_read) + QtCore.QObject.connect(self.socket, QtCore.SIGNAL(u'disconnected()'), + self.disconnected) + + def ready_read(self): + log.debug(u'ready to read socket') + if self.socket.canReadLine(): + data = unicode(self.socket.readLine()) + log.debug(u'received: ' + data) + words = data.split(u' ') + html = None + if words[0] == u'GET': + url = urlparse.urlparse(words[1]) + params = self.load_params(url.query) + folders = url.path.split(u'/') + if folders[1] == u'': + html = self.process_index() + elif folders[1] == u'send': + html = self.process_event(folders[2], params) + elif folders[1] == u'request': + if self.process_request(folders[2], params): + return + if html: + html = self.get_200_ok() + html + u'\n' + else: + html = self.get_404_not_found() + self.socket.write(html) + self.close() + + def process_index(self): + return u""" + + +OpenLP Controller + + + +

OpenLP Controller

+ + +
+ + +
+ + +
+ +
+
+ + +""" + + def load_params(self, query): + params = urlparse.parse_qs(query) + if not params: + return None + else: + return params['q'] + + def process_event(self, event, params): + if params: + Receiver.send_message(event, params) + else: + Receiver.send_message(event) + return u'OK' + + def process_request(self, event, params): + if not event.endswith(u'_request'): + return False + self.event = event + response = event.replace(u'_request', u'_response') + QtCore.QObject.connect(Receiver.get_receiver(), + QtCore.SIGNAL(response), self.process_response) + self.timer = QtCore.QTimer() + self.timer.setSingleShot(True) + QtCore.QObject.connect(self.timer, + QtCore.SIGNAL(u'timeout()'), self.timeout) + self.timer.start(10000) + if params: + Receiver.send_message(event, params) + else: + Receiver.send_message(event) + return True + + def process_response(self, data): + if not self.socket: + return + self.timer.stop() + html = json.dumps(data) + html = self.get_200_ok() + html + u'\n' + self.socket.write(html) + self.close() + + def get_200_ok(self): + return u'HTTP/1.1 200 OK\r\n' + \ + u'Content-Type: text/html; charset="utf-8"\r\n' + \ + u'\r\n' + + def get_404_not_found(self): + return u'HTTP/1.1 404 Not Found\r\n'+ \ + u'Content-Type: text/html; charset="utf-8"\r\n' + \ + u'\r\n' + + def get_408_timeout(self): + return u'HTTP/1.1 408 Request Timeout\r\n' + + def timeout(self): + if not self.socket: + return + html = self.get_408_timeout() + self.socket.write(html) + self.close() + + def disconnected(self): + log.debug(u'socket disconnected') + self.close() + + def close(self): + if not self.socket: + return + log.debug(u'close socket') + self.socket.close() + self.socket = None + self.parent.close_connection(self) + From d0c6cf96394021bb3370b9478d76cb430996068b Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Tue, 27 Apr 2010 20:59:44 +0100 Subject: [PATCH 28/63] move display to core --- openlp/core/ui/__init__.py | 1 + openlp/core/ui/generaltab.py | 2 +- openlp/core/ui/maindisplay.py | 3 +- openlp/core/ui/screen.py | 4 + openlp/core/ui/settingsform.py | 5 +- openlp/plugins/display/forms/displayform.py | 3 +- resources/forms/displaydialog.ui | 151 ---------- resources/forms/displaytab.ui | 295 ++++++++++++++++++++ 8 files changed, 309 insertions(+), 155 deletions(-) delete mode 100644 resources/forms/displaydialog.ui create mode 100644 resources/forms/displaytab.ui diff --git a/openlp/core/ui/__init__.py b/openlp/core/ui/__init__.py index 675c57476..0c1ec731a 100644 --- a/openlp/core/ui/__init__.py +++ b/openlp/core/ui/__init__.py @@ -33,6 +33,7 @@ from maindisplay import DisplayManager from amendthemeform import AmendThemeForm from slidecontroller import SlideController from splashscreen import SplashScreen +from displaytab import DisplayTab from generaltab import GeneralTab from themestab import ThemesTab from aboutform import AboutForm diff --git a/openlp/core/ui/generaltab.py b/openlp/core/ui/generaltab.py index f7e87e879..75e06d691 100644 --- a/openlp/core/ui/generaltab.py +++ b/openlp/core/ui/generaltab.py @@ -172,7 +172,7 @@ class GeneralTab(SettingsTab): def retranslateUi(self): self.MonitorGroupBox.setTitle(self.trUtf8('Monitors')) self.MonitorLabel.setText(self.trUtf8('Select monitor for output display:')) - self.DisplayOnMonitorCheck.setText(self.trUtf8('Display if in single screen')) + self.DisplayOnMonitorCheck.setText(self.trUtf8('Display if a single screen')) self.StartupGroupBox.setTitle(self.trUtf8('Application Startup')) self.WarningCheckBox.setText(self.trUtf8('Show blank screen warning')) self.AutoOpenCheckBox.setText(self.trUtf8('Automatically open the last service')) diff --git a/openlp/core/ui/maindisplay.py b/openlp/core/ui/maindisplay.py index 6dfa7a83c..85db0ed12 100644 --- a/openlp/core/ui/maindisplay.py +++ b/openlp/core/ui/maindisplay.py @@ -214,7 +214,6 @@ class MainDisplay(DisplayWidget): def hideThemeDisplay(self): log.debug(u'hideDisplay') - a=c self.display_image.setPixmap(self.transparent) self.display_alert.setPixmap(self.transparent) self.display_text.setPixmap(self.transparent) @@ -336,6 +335,8 @@ class VideoDisplay(Phonon.VideoWidget): self.audioObject = Phonon.AudioOutput(Phonon.VideoCategory) Phonon.createPath(self.mediaObject, self) Phonon.createPath(self.mediaObject, self.audioObject) + self.setWindowFlags(QtCore.Qt.WindowStaysOnTopHint \ + | QtCore.Qt.FramelessWindowHint | QtCore.Qt.Dialog) QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'videodisplay_start'), self.onMediaQueue) QtCore.QObject.connect(Receiver.get_receiver(), diff --git a/openlp/core/ui/screen.py b/openlp/core/ui/screen.py index 19c4e01b5..0c8679205 100644 --- a/openlp/core/ui/screen.py +++ b/openlp/core/ui/screen.py @@ -80,6 +80,10 @@ class ScreenList(object): """ log.debug(u'set_override_display') self.current = copy.deepcopy(self.override) + print self.screen_list + print self.current + self.current[u'primary'] = True + print self.current self.preview = copy.deepcopy(self.current) def reset_current_display(self): diff --git a/openlp/core/ui/settingsform.py b/openlp/core/ui/settingsform.py index c86525a54..f923c9d7d 100644 --- a/openlp/core/ui/settingsform.py +++ b/openlp/core/ui/settingsform.py @@ -27,7 +27,7 @@ import logging from PyQt4 import QtGui -from openlp.core.ui import GeneralTab, ThemesTab +from openlp.core.ui import GeneralTab, ThemesTab, DisplayTab from settingsdialog import Ui_SettingsDialog log = logging.getLogger(__name__) @@ -43,6 +43,9 @@ class SettingsForm(QtGui.QDialog, Ui_SettingsDialog): # Themes tab self.ThemesTab = ThemesTab(mainWindow) self.addTab(u'Themes', self.ThemesTab) + # Display tab + self.DisplayTab = DisplayTab(screens) + self.addTab(u'Display', self.DisplayTab) def addTab(self, name, tab): log.info(u'Adding %s tab' % tab.tabTitle) diff --git a/openlp/plugins/display/forms/displayform.py b/openlp/plugins/display/forms/displayform.py index b1ae02b0a..a7fa60b6e 100644 --- a/openlp/plugins/display/forms/displayform.py +++ b/openlp/plugins/display/forms/displayform.py @@ -44,7 +44,8 @@ class DisplayForm(QtGui.QDialog, Ui_DisplaysDialog): self.setupUi(self) def initialise(self): - self.Xpos.setText(unicode(self.screens.current[u'size'].x())) + xpos = int(self.config.get_config(u'x position', unicode(self.screens.current[u'size'].x()))) + self.Xpos.setText(xpos) self.Ypos.setText(unicode(self.screens.current[u'size'].y())) self.Height.setText(unicode(self.screens.current[u'size'].height())) self.Width.setText(unicode(self.screens.current[u'size'].width())) diff --git a/resources/forms/displaydialog.ui b/resources/forms/displaydialog.ui deleted file mode 100644 index a8feb7842..000000000 --- a/resources/forms/displaydialog.ui +++ /dev/null @@ -1,151 +0,0 @@ - - - DisplaysDialog - - - - 0 - 0 - 327 - 224 - - - - Amend Display Settings - - - - - 210 - 200 - 97 - 24 - - - - Ok - - - - - - 10 - 0 - 301 - 191 - - - - - - - Default Settings - - - - - 20 - 30 - 261 - 17 - - - - - - - 0 - - - Qt::AlignCenter - - - - - - - 0 - - - Qt::AlignCenter - - - - - - - 0 - - - Qt::AlignCenter - - - - - - - 0 - - - Qt::AlignCenter - - - - - - - - - - - Amend Settings - - - - - 20 - 30 - 261 - 27 - - - - - - - - - - - - - - - - - - - - - - - - - - OkpushButton - pressed() - DisplaysDialog - close() - - - 258 - 211 - - - 163 - 111 - - - - - diff --git a/resources/forms/displaytab.ui b/resources/forms/displaytab.ui new file mode 100644 index 000000000..7d2d78798 --- /dev/null +++ b/resources/forms/displaytab.ui @@ -0,0 +1,295 @@ + + + DisplaysDialog + + + + 0 + 0 + 620 + 716 + + + + Amend Display Settings + + + + + 0 + 40 + 241 + 79 + + + + + + + Default Settings + + + + + + + + X + + + Qt::AlignCenter + + + + + + + 0 + + + Qt::AlignCenter + + + + + + + + + + + Y + + + Qt::AlignCenter + + + + + + + 0 + + + Qt::AlignCenter + + + + + + + + + + + + 100 + 16777215 + + + + Height + + + Qt::AlignCenter + + + + + + + 0 + + + Qt::AlignCenter + + + + + + + + + + + Width + + + Qt::AlignCenter + + + + + + + 0 + + + Qt::AlignCenter + + + + + + + + + + + + + + 0 + 130 + 248 + 87 + + + + + 500 + 16777215 + + + + Amend Settings + + + + + + + + X + + + Qt::AlignCenter + + + + + + + + 50 + 16777215 + + + + 4 + + + + + + + + + + + Y + + + Qt::AlignCenter + + + + + + + + 50 + 16777215 + + + + 4 + + + + + + + + + + + Height + + + Qt::AlignCenter + + + + + + + + 50 + 16777215 + + + + 4 + + + + + + + + + QLayout::SetMinimumSize + + + + + + 100 + 16777215 + + + + Width + + + Qt::AlignCenter + + + + + + + + 60 + 16777215 + + + + + + + + layoutWidget + YAmendLabel + HeightAmendLabel + WidthAmendLabel + YAmendLabel + + + + + 0 + 10 + 191 + 23 + + + + Override Output Display + + + + + + From 55dd795a453d45ba8ee0d49e8be0dd370847f397 Mon Sep 17 00:00:00 2001 From: Jon Tibble Date: Tue, 27 Apr 2010 22:30:04 +0100 Subject: [PATCH 29/63] Unbreak presentations slightly --- .bzrignore | 1 + openlp/plugins/presentations/lib/presentationcontroller.py | 4 ++-- openlp/plugins/presentations/presentationplugin.py | 4 +++- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/.bzrignore b/.bzrignore index 00884055d..2314d48c5 100644 --- a/.bzrignore +++ b/.bzrignore @@ -14,3 +14,4 @@ dist OpenLP.egg-info build resources/innosetup/Output +_eric4project diff --git a/openlp/plugins/presentations/lib/presentationcontroller.py b/openlp/plugins/presentations/lib/presentationcontroller.py index cbb5c9c00..4b304a516 100644 --- a/openlp/plugins/presentations/lib/presentationcontroller.py +++ b/openlp/plugins/presentations/lib/presentationcontroller.py @@ -102,8 +102,8 @@ class PresentationController(object): self.name = name self.available = self.check_available() if self.available: - self.enabled = QtCore.QSettings().value( - name, QtCore.Qt.Unchecked).toInt()[0] == QtCore.Qt.Checked + self.enabled = QtCore.QSettings().value(u'presentations/' + name, + QtCore.Qt.Unchecked).toInt()[0] == QtCore.Qt.Checked else: self.enabled = False self.thumbnailroot = os.path.join( diff --git a/openlp/plugins/presentations/presentationplugin.py b/openlp/plugins/presentations/presentationplugin.py index da25dcdc3..dd1a5259b 100644 --- a/openlp/plugins/presentations/presentationplugin.py +++ b/openlp/plugins/presentations/presentationplugin.py @@ -96,7 +96,9 @@ class PresentationPlugin(Plugin): try: __import__(modulename, globals(), locals(), []) except ImportError, e: - log.error(u'Failed to import %s on path %s for reason %s', modulename, path, e.args[0]) + log.error( + u'Failed to import %s on path %s for reason %s', + modulename, path, e.args[0]) controller_classes = PresentationController.__subclasses__() for controller_class in controller_classes: controller = controller_class(self) From 484a76289c199a2b4f1d88c2fd35cb2a9432bb49 Mon Sep 17 00:00:00 2001 From: Jon Tibble Date: Tue, 27 Apr 2010 23:36:50 +0100 Subject: [PATCH 30/63] Fix presentations a bit more --- openlp/core/ui/maindisplay.py | 12 ++++++--- openlp/core/ui/slidecontroller.py | 12 ++++++--- .../presentations/lib/messagelistener.py | 27 ++++++++++--------- .../lib/presentationcontroller.py | 10 +++---- 4 files changed, 35 insertions(+), 26 deletions(-) diff --git a/openlp/core/ui/maindisplay.py b/openlp/core/ui/maindisplay.py index 5e7071449..04f60fb7d 100644 --- a/openlp/core/ui/maindisplay.py +++ b/openlp/core/ui/maindisplay.py @@ -254,14 +254,17 @@ class MainDisplay(DisplayWidget): if not self.displayBlank: if transition: if self.frame is not None: - self.display_text.setPixmap(QtGui.QPixmap.fromImage(self.frame)) + self.display_text.setPixmap( + QtGui.QPixmap.fromImage(self.frame)) self.repaint() self.frame = None if frame[u'trans'] is not None: - self.display_text.setPixmap(QtGui.QPixmap.fromImage(frame[u'trans'])) + self.display_text.setPixmap( + QtGui.QPixmap.fromImage(frame[u'trans'])) self.repaint() self.frame = frame[u'trans'] - self.display_text.setPixmap(QtGui.QPixmap.fromImage(frame[u'main'])) + self.display_text.setPixmap( + QtGui.QPixmap.fromImage(frame[u'main'])) self.display_frame = frame[u'main'] self.repaint() else: @@ -282,7 +285,8 @@ class MainDisplay(DisplayWidget): if blanked: self.displayBlank = True if blankType == HideMode.Blank: - self.display_text.setPixmap(QtGui.QPixmap.fromImage(self.blankFrame)) + self.display_text.setPixmap( + QtGui.QPixmap.fromImage(self.blankFrame)) elif blankType == HideMode.Theme: theme = self.parent.RenderManager.renderer.bg_frame if not theme: diff --git a/openlp/core/ui/slidecontroller.py b/openlp/core/ui/slidecontroller.py index 260066fa5..c1f38cf38 100644 --- a/openlp/core/ui/slidecontroller.py +++ b/openlp/core/ui/slidecontroller.py @@ -152,13 +152,15 @@ class SlideController(QtGui.QWidget): self.PreviewListWidget.horizontalHeader().setVisible(False) self.PreviewListWidget.verticalHeader().setVisible(False) self.PreviewListWidget.setColumnWidth(1, self.labelWidth) - self.PreviewListWidget.setColumnWidth(1, self.Controller.width() - self.labelWidth) + self.PreviewListWidget.setColumnWidth( + 1, self.Controller.width() - self.labelWidth) self.PreviewListWidget.isLive = self.isLive self.PreviewListWidget.setObjectName(u'PreviewListWidget') self.PreviewListWidget.setSelectionBehavior(1) self.PreviewListWidget.setEditTriggers( QtGui.QAbstractItemView.NoEditTriggers) - self.PreviewListWidget.setHorizontalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOff) + self.PreviewListWidget.setHorizontalScrollBarPolicy( + QtCore.Qt.ScrollBarAlwaysOff) self.PreviewListWidget.setAlternatingRowColors(True) self.ControllerLayout.addWidget(self.PreviewListWidget) # Build the full toolbar @@ -220,7 +222,8 @@ class SlideController(QtGui.QWidget): self.Toolbar.addToolbarWidget( u'Image SpinBox', self.DelaySpinBox) self.DelaySpinBox.setSuffix(self.trUtf8('s')) - self.DelaySpinBox.setToolTip(self.trUtf8('Delay between slides in seconds')) + self.DelaySpinBox.setToolTip( + self.trUtf8('Delay between slides in seconds')) self.ControllerLayout.addWidget(self.Toolbar) #Build a Media ToolBar self.Mediabar = OpenLPToolbar(self) @@ -612,7 +615,8 @@ class SlideController(QtGui.QWidget): """ if self.serviceItem is not None: if blanked: - Receiver.send_message(u'%s_blank' % self.serviceItem.name.lower(), + Receiver.send_message( + u'%s_blank' % self.serviceItem.name.lower(), [self.serviceItem, self.isLive]) else: Receiver.send_message(u'%s_unblank' diff --git a/openlp/plugins/presentations/lib/messagelistener.py b/openlp/plugins/presentations/lib/messagelistener.py index 3a97cedaf..8a1ddc8c7 100644 --- a/openlp/plugins/presentations/lib/messagelistener.py +++ b/openlp/plugins/presentations/lib/messagelistener.py @@ -165,7 +165,8 @@ class Controller(object): if not self.isLive: return self.activate() - if self.doc.slidenumber and self.doc.slidenumber != self.doc.get_slide_number(): + if self.doc.slidenumber and \ + self.doc.slidenumber != self.doc.get_slide_number(): self.doc.goto_slide(self.doc.slidenumber) self.doc.unblank_screen() @@ -186,26 +187,27 @@ class MessageListener(object): self.liveHandler = Controller(True) # messages are sent from core.ui.slidecontroller QtCore.QObject.connect(Receiver.get_receiver(), - QtCore.SIGNAL(u'presentation_start'), self.startup) + QtCore.SIGNAL(u'presentations_start'), self.startup) QtCore.QObject.connect(Receiver.get_receiver(), - QtCore.SIGNAL(u'presentation_stop'), self.shutdown) + QtCore.SIGNAL(u'presentations_stop'), self.shutdown) QtCore.QObject.connect(Receiver.get_receiver(), - QtCore.SIGNAL(u'presentation_first'), self.first) + QtCore.SIGNAL(u'presentations_first'), self.first) QtCore.QObject.connect(Receiver.get_receiver(), - QtCore.SIGNAL(u'presentation_previous'), self.previous) + QtCore.SIGNAL(u'presentations_previous'), self.previous) QtCore.QObject.connect(Receiver.get_receiver(), - QtCore.SIGNAL(u'presentation_next'), self.next) + QtCore.SIGNAL(u'presentations_next'), self.next) QtCore.QObject.connect(Receiver.get_receiver(), - QtCore.SIGNAL(u'presentation_last'), self.last) + QtCore.SIGNAL(u'presentations_last'), self.last) QtCore.QObject.connect(Receiver.get_receiver(), - QtCore.SIGNAL(u'presentation_slide'), self.slide) + QtCore.SIGNAL(u'presentations_slide'), self.slide) QtCore.QObject.connect(Receiver.get_receiver(), - QtCore.SIGNAL(u'presentation_blank'), self.blank) + QtCore.SIGNAL(u'presentations_blank'), self.blank) QtCore.QObject.connect(Receiver.get_receiver(), - QtCore.SIGNAL(u'presentation_unblank'), self.unblank) + QtCore.SIGNAL(u'presentations_unblank'), self.unblank) self.timer = QtCore.QTimer() self.timer.setInterval(500) - QtCore.QObject.connect(self.timer, QtCore.SIGNAL("timeout()"), self.timeout) + QtCore.QObject.connect( + self.timer, QtCore.SIGNAL("timeout()"), self.timeout) def startup(self, message): """ @@ -279,11 +281,10 @@ class MessageListener(object): if isLive: self.liveHandler.blank() - def unblank(self, message): + def unblank(self, message): isLive, item = self.decode_message(message) if isLive: self.liveHandler.unblank() def timeout(self): self.liveHandler.poll() - diff --git a/openlp/plugins/presentations/lib/presentationcontroller.py b/openlp/plugins/presentations/lib/presentationcontroller.py index 4b304a516..8e5d797da 100644 --- a/openlp/plugins/presentations/lib/presentationcontroller.py +++ b/openlp/plugins/presentations/lib/presentationcontroller.py @@ -331,11 +331,11 @@ class PresentationDocument(object): pass def next_step(self): - """ - Triggers the next effect of slide on the running presentation - This might be the next animation on the current slide, or the next slide - """ - pass + """ + Triggers the next effect of slide on the running presentation + This might be the next animation on the current slide, or the next slide + """ + pass def previous_step(self): """ From c626653092463be5c0c08224f06c928359a0fbb9 Mon Sep 17 00:00:00 2001 From: Jon Tibble Date: Tue, 27 Apr 2010 23:51:16 +0100 Subject: [PATCH 31/63] Fix bible reloading --- openlp/core/lib/settingsmanager.py | 13 +++++++++++-- openlp/plugins/bibles/lib/manager.py | 2 +- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/openlp/core/lib/settingsmanager.py b/openlp/core/lib/settingsmanager.py index c86170988..8d4b18ecd 100644 --- a/openlp/core/lib/settingsmanager.py +++ b/openlp/core/lib/settingsmanager.py @@ -23,6 +23,8 @@ # Temple Place, Suite 330, Boston, MA 02111-1307 USA # ############################################################################### +import os + from PyQt4 import QtCore from openlp.core.utils import AppLocation @@ -151,15 +153,22 @@ class SettingsManager(object): return list @staticmethod - def get_files(suffix=None): + def get_files(section=None, suffix=None): """ Get a list of files from the data files path. + ``section`` + Defaults to *None*. The section of code getting the files - used + to load from section directory. + ``suffix`` Defaults to *None*. The extension to search for. """ + path = AppLocation.get_data_path() + if section: + path = os.path.join(path, section) try: - files = os.listdir(AppLocation.get_data_path()) + files = os.listdir(path) except: return [] if suffix: diff --git a/openlp/plugins/bibles/lib/manager.py b/openlp/plugins/bibles/lib/manager.py index bc96a81e5..ad9d4fcc6 100644 --- a/openlp/plugins/bibles/lib/manager.py +++ b/openlp/plugins/bibles/lib/manager.py @@ -126,7 +126,7 @@ class BibleManager(object): BibleDB class. """ log.debug(u'Reload bibles') - files = SettingsManager.get_files(self.suffix) + files = SettingsManager.get_files(u'bibles', self.suffix) log.debug(u'Bible Files %s', files) self.db_cache = {} for filename in files: From 5a8cd52acf35a2bb3cfea38be2b5c1d4c5678d40 Mon Sep 17 00:00:00 2001 From: Jon Tibble Date: Wed, 28 Apr 2010 00:49:21 +0100 Subject: [PATCH 32/63] File list refactor --- openlp/core/lib/settingsmanager.py | 23 ++++++++--------------- openlp/plugins/bibles/lib/manager.py | 2 +- 2 files changed, 9 insertions(+), 16 deletions(-) diff --git a/openlp/core/lib/settingsmanager.py b/openlp/core/lib/settingsmanager.py index 8d4b18ecd..d859ddea8 100644 --- a/openlp/core/lib/settingsmanager.py +++ b/openlp/core/lib/settingsmanager.py @@ -1,3 +1,4 @@ +import os.path # -*- coding: utf-8 -*- # vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4 @@ -153,16 +154,16 @@ class SettingsManager(object): return list @staticmethod - def get_files(section=None, suffix=None): + def get_files(section=None, extension=None): """ Get a list of files from the data files path. ``section`` Defaults to *None*. The section of code getting the files - used - to load from section directory. + to load from a section's data subdirectory. - ``suffix`` - Defaults to *None*. The extension to search for. + ``extension`` + Defaults to *None*. The extension to search for. """ path = AppLocation.get_data_path() if section: @@ -171,17 +172,9 @@ class SettingsManager(object): files = os.listdir(path) except: return [] - if suffix: - return_files = [] - for file in files: - if file.find(u'.') != -1: - filename = file.split(u'.') - filesuffix = filename[1].lower() - filesuffix = filesuffix.lower() - # only load files with the correct suffix - if suffix.find(filesuffix) > -1 : - return_files.append(file) - return return_files + if extension: + return [file for file in files + if extension == os.path.splitext(file)[1]] else: # no filtering required return files diff --git a/openlp/plugins/bibles/lib/manager.py b/openlp/plugins/bibles/lib/manager.py index ad9d4fcc6..1f962be90 100644 --- a/openlp/plugins/bibles/lib/manager.py +++ b/openlp/plugins/bibles/lib/manager.py @@ -114,7 +114,7 @@ class BibleManager(object): self.path = AppLocation.get_section_data_path(u'bibles') self.proxy_name = unicode( QtCore.QSettings().value(u'bibles/proxy name', u'').toString()) - self.suffix = u'sqlite' + self.suffix = u'.sqlite' self.import_wizard = None self.reload_bibles() self.media = None From 2470f776cd16f9ebe1f2854400b278242af74e93 Mon Sep 17 00:00:00 2001 From: Jon Tibble Date: Wed, 28 Apr 2010 01:05:56 +0100 Subject: [PATCH 33/63] Remove PluginConfig doc reference --- documentation/source/core/lib.rst | 6 ------ 1 file changed, 6 deletions(-) diff --git a/documentation/source/core/lib.rst b/documentation/source/core/lib.rst index 146d0d934..81e858c15 100644 --- a/documentation/source/core/lib.rst +++ b/documentation/source/core/lib.rst @@ -36,12 +36,6 @@ .. autoclass:: openlp.core.lib.plugin.Plugin :members: -:mod:`PluginConfig` -------------------- - -.. autoclass:: openlp.core.lib.pluginconfig.PluginConfig - :members: - :mod:`PluginManager` -------------------- From 507cd19739083ec7aaeef549b4850e7ec34c71a9 Mon Sep 17 00:00:00 2001 From: Jon Tibble Date: Wed, 28 Apr 2010 02:28:37 +0100 Subject: [PATCH 34/63] Cleanups and diff reading fixes --- openlp/core/lib/settingsmanager.py | 3 +- openlp/core/ui/generaltab.py | 31 ++++++++++++------- openlp/core/ui/mainwindow.py | 2 +- openlp/core/ui/servicemanager.py | 2 +- openlp/core/ui/slidecontroller.py | 2 +- openlp/core/ui/thememanager.py | 2 +- openlp/plugins/bibles/lib/db.py | 10 +++--- openlp/plugins/custom/lib/customtab.py | 2 +- openlp/plugins/custom/lib/manager.py | 8 ++--- .../presentations/lib/presentationtab.py | 2 +- openlp/plugins/songs/lib/manager.py | 12 ++++--- openlp/plugins/songs/lib/songstab.py | 4 +-- openlp/plugins/songusage/lib/manager.py | 12 ++++--- 13 files changed, 54 insertions(+), 38 deletions(-) diff --git a/openlp/core/lib/settingsmanager.py b/openlp/core/lib/settingsmanager.py index d859ddea8..36caa38f5 100644 --- a/openlp/core/lib/settingsmanager.py +++ b/openlp/core/lib/settingsmanager.py @@ -1,4 +1,3 @@ -import os.path # -*- coding: utf-8 -*- # vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4 @@ -126,7 +125,7 @@ class SettingsManager(object): settings.setValue( u'%s/%s %d' % (section, name, counter), list[counter-1]) if old_count > new_count: - # Tidy up any old list itrms if list is smaller now + # Tidy up any old list items for counter in range(new_count, old_count): settings.remove(u'%s/%s %d' % (section, name, counter)) diff --git a/openlp/core/ui/generaltab.py b/openlp/core/ui/generaltab.py index bb35d8f2a..357756a08 100644 --- a/openlp/core/ui/generaltab.py +++ b/openlp/core/ui/generaltab.py @@ -264,17 +264,26 @@ class GeneralTab(SettingsTab): def save(self): settings = QtCore.QSettings() - settings.setValue(u'general/monitor', self.MonitorNumber) - settings.setValue( - u'general/display on monitor', self.DisplayOnMonitor) - settings.setValue(u'general/blank warning', self.Warning) - settings.setValue(u'general/auto open', self.AutoOpen) - settings.setValue(u'general/show splash', self.ShowSplash) - settings.setValue(u'general/save prompt', self.PromptSaveService) - settings.setValue(u'general/auto preview', self.AutoPreview) - settings.setValue(u'general/ccli number', self.CCLINumber) - settings.setValue(u'general/songselect username', self.Username) - settings.setValue(u'general/songselect password', self.Password) + settings.setValue(u'general/monitor', + QtCore.QVariant(self.MonitorNumber)) + settings.setValue(u'general/display on monitor', + QtCore.QVariant(self.DisplayOnMonitor)) + settings.setValue(u'general/blank warning', + QtCore.QVariant(self.Warning)) + settings.setValue(u'general/auto open', + QtCore.QVariant(self.AutoOpen)) + settings.setValue(u'general/show splash', + QtCore.QVariant(self.ShowSplash)) + settings.setValue(u'general/save prompt', + QtCore.QVariant(self.PromptSaveService)) + settings.setValue(u'general/auto preview', + QtCore.QVariant(self.AutoPreview)) + settings.setValue(u'general/ccli number', + QtCore.QVariant(self.CCLINumber)) + settings.setValue(u'general/songselect username', + QtCore.QVariant(self.Username)) + settings.setValue(u'general/songselect password', + QtCore.QVariant(self.Password)) self.screens.display = self.DisplayOnMonitor #Monitor Number has changed. if self.screens.monitor_number != self.MonitorNumber: diff --git a/openlp/core/ui/mainwindow.py b/openlp/core/ui/mainwindow.py index 96357f83d..d1efc79c5 100644 --- a/openlp/core/ui/mainwindow.py +++ b/openlp/core/ui/mainwindow.py @@ -431,7 +431,7 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow): self.plugin_helpers = {} # Set up the interface self.setupUi(self) - # Load settings after setupUi so defaults UI sizes are overwritten + # Load settings after setupUi so default UI sizes are overwritten self.loadSettings() # Once settings are loaded update FileMenu with recentFiles self.updateFileMenu() diff --git a/openlp/core/ui/servicemanager.py b/openlp/core/ui/servicemanager.py index 14bb35113..28793de71 100644 --- a/openlp/core/ui/servicemanager.py +++ b/openlp/core/ui/servicemanager.py @@ -641,7 +641,7 @@ class ServiceManager(QtGui.QWidget): """ self.service_theme = unicode(self.ThemeComboBox.currentText()) self.parent.RenderManager.set_service_theme(self.service_theme) - QtCore.QSettings().setValue(u'service manager/service theme', + QtCore.QSettings().setValue(u'servicemanager/service theme', QtCore.QVariant(self.service_theme)) self.regenerateServiceItems() diff --git a/openlp/core/ui/slidecontroller.py b/openlp/core/ui/slidecontroller.py index c1f38cf38..6ff739fc3 100644 --- a/openlp/core/ui/slidecontroller.py +++ b/openlp/core/ui/slidecontroller.py @@ -396,7 +396,7 @@ class SlideController(QtGui.QWidget): self.Toolbar.makeWidgetsInvisible(self.loop_list) if item.is_text(): self.Toolbar.makeWidgetsInvisible(self.loop_list) - if QtCore.QSettings().value(u'songs/show songbar', True) \ + if QtCore.QSettings().value(u'songs/show songbar', True).toBool() \ and len(self.slideList) > 0: self.Toolbar.makeWidgetsVisible([u'Song Menu']) if item.is_capable(ItemCapabilities.AllowsLoop) and \ diff --git a/openlp/core/ui/thememanager.py b/openlp/core/ui/thememanager.py index 0c19c2510..a71e65210 100644 --- a/openlp/core/ui/thememanager.py +++ b/openlp/core/ui/thememanager.py @@ -145,7 +145,7 @@ class ThemeManager(QtGui.QWidget): name = u'%s (%s)' % (self.global_theme, self.trUtf8('default')) self.ThemeListWidget.item(count).setText(name) QtCore.QSettings().setValue(u'themes/global theme', - self.global_theme) + QtCore.QVariant(self.global_theme)) Receiver.send_message(u'theme_update_global', self.global_theme) self.pushThemes() diff --git a/openlp/plugins/bibles/lib/db.py b/openlp/plugins/bibles/lib/db.py index 207fe4091..0d2422a8d 100644 --- a/openlp/plugins/bibles/lib/db.py +++ b/openlp/plugins/bibles/lib/db.py @@ -80,11 +80,11 @@ class BibleDB(QtCore.QObject): if db_type == u'sqlite': db_url = u'sqlite:///' + self.db_file else: - db_url = u'%s://%s:%s@%s/%s' % \ - (db_type, unicode(settings.value(u'bibles/db username')), - unicode(settings.value(u'bibles/db password')), - unicode(settings.value(u'bibles/db hostname')), - unicode(settings.value(u'bibles/db database'))) + db_url = u'%s://%s:%s@%s/%s' % (db_type, + unicode(settings.value(u'bibles/db username').toString()), + unicode(settings.value(u'bibles/db password').toString()), + unicode(settings.value(u'bibles/db hostname').toString()), + unicode(settings.value(u'bibles/db database').toString())) self.metadata, self.session = init_models(db_url) self.metadata.create_all(checkfirst=True) if u'file' in kwargs: diff --git a/openlp/plugins/custom/lib/customtab.py b/openlp/plugins/custom/lib/customtab.py index d99c6d9e3..5470c64d0 100644 --- a/openlp/plugins/custom/lib/customtab.py +++ b/openlp/plugins/custom/lib/customtab.py @@ -57,7 +57,7 @@ class CustomTab(SettingsTab): def retranslateUi(self): self.CustomModeGroupBox.setTitle(self.trUtf8('Custom Display')) self.DisplayFooterCheckBox.setText( - self.trUtf8('Display Footer:')) + self.trUtf8('Display Footer')) def onDisplayFooterCheckBoxChanged(self, check_state): self.displayFooter = False diff --git a/openlp/plugins/custom/lib/manager.py b/openlp/plugins/custom/lib/manager.py index 54962d9b0..c9555e63a 100644 --- a/openlp/plugins/custom/lib/manager.py +++ b/openlp/plugins/custom/lib/manager.py @@ -54,10 +54,10 @@ class CustomManager(): AppLocation.get_section_data_path(u'custom') else: self.db_url = u'%s://%s:%s@%s/%s' % (db_type, - unicode(settings.value(u'custom/db username')), - unicode(settings.value(u'custom/db password')), - unicode(settings.value(u'custom/db hostname')), - unicode(settings.value(u'custom/db database'))) + unicode(settings.value(u'custom/db username').toString()), + unicode(settings.value(u'custom/db password').toString()), + unicode(settings.value(u'custom/db hostname').toString()), + unicode(settings.value(u'custom/db database').toString())) self.session = init_models(self.db_url) metadata.create_all(checkfirst=True) diff --git a/openlp/plugins/presentations/lib/presentationtab.py b/openlp/plugins/presentations/lib/presentationtab.py index af492d2c8..4c1b41813 100644 --- a/openlp/plugins/presentations/lib/presentationtab.py +++ b/openlp/plugins/presentations/lib/presentationtab.py @@ -93,7 +93,7 @@ class PresentationTab(SettingsTab): controller = self.controllers[key] checkbox = self.PresenterCheckboxes[controller.name] checkbox.setText( - u'%s %s:' % (controller.name, self.trUtf8('available'))) + u'%s %s' % (controller.name, self.trUtf8('available'))) def load(self): for key in self.controllers: diff --git a/openlp/plugins/songs/lib/manager.py b/openlp/plugins/songs/lib/manager.py index f97b0875d..5264a58ed 100644 --- a/openlp/plugins/songs/lib/manager.py +++ b/openlp/plugins/songs/lib/manager.py @@ -55,10 +55,14 @@ class SongManager(): AppLocation.get_section_data_path(u'songs') else: self.db_url = db_type + 'u://' + \ - unicode(settings.value(u'songs/db username', u'').toString()) + u':' + \ - unicode(settings.value(u'songs/db password', u'').toString()) + u'@' + \ - unicode(settings.value(u'songs/db hostname', u'').toString()) + u'/' + \ - unicode(settings.value(u'songs/db database', u'').toString()) + unicode(settings.value( + u'songs/db username', u'').toString()) + u':' + \ + unicode(settings.value( + u'songs/db password', u'').toString()) + u'@' + \ + unicode(settings.value( + u'songs/db hostname', u'').toString()) + u'/' + \ + unicode(settings.value( + u'songs/db database', u'').toString()) self.session = init_models(self.db_url) metadata.create_all(checkfirst=True) log.debug(u'Song Initialised') diff --git a/openlp/plugins/songs/lib/songstab.py b/openlp/plugins/songs/lib/songstab.py index 3fb41aabf..8b9f6804d 100644 --- a/openlp/plugins/songs/lib/songstab.py +++ b/openlp/plugins/songs/lib/songstab.py @@ -63,9 +63,9 @@ class SongsTab(SettingsTab): def retranslateUi(self): self.SongsModeGroupBox.setTitle(self.trUtf8('Songs Mode')) self.SearchAsTypeCheckBox.setText( - self.trUtf8('Enable search as you type:')) + self.trUtf8('Enable search as you type')) self.SongBarActiveCheckBox.setText( - self.trUtf8('Display Verses on Live Tool bar:')) + self.trUtf8('Display Verses on Live Tool bar')) def onSearchAsTypeCheckBoxChanged(self, check_state): self.song_search = False diff --git a/openlp/plugins/songusage/lib/manager.py b/openlp/plugins/songusage/lib/manager.py index dddea5350..d307f9dd5 100644 --- a/openlp/plugins/songusage/lib/manager.py +++ b/openlp/plugins/songusage/lib/manager.py @@ -55,10 +55,14 @@ class SongUsageManager(): AppLocation.get_section_data_path(u'songusage') else: self.db_url = u'%s://%s:%s@%s/%s' % (db_type, - unicode(settings.value(u'songusage/db username', u'')), - unicode(settings.value(u'songusage/db password', u'')), - unicode(settings.value(u'songusage/db hostname', u'')), - unicode(settings.value(u'songusage/db database', u''))) + unicode( + settings.value(u'songusage/db username', u'').toString()), + unicode( + settings.value(u'songusage/db password', u'').toString()), + unicode( + settings.value(u'songusage/db hostname', u'').toString()), + unicode( + settings.value(u'songusage/db database', u'').toString())) self.session = init_models(self.db_url) metadata.create_all(checkfirst=True) From 97d9ab93f6283d83fe6bb90b8dc49b15b1fcdfbe Mon Sep 17 00:00:00 2001 From: Jon Tibble Date: Wed, 28 Apr 2010 04:16:49 +0100 Subject: [PATCH 35/63] Migration tools settings conversion --- openlp/migration/migratebibles.py | 8 ++++---- openlp/migration/migratefiles.py | 19 ++++++++++++------- openlp/migration/migratesongs.py | 8 ++++---- openlpcnv.pyw | 13 +++++++------ 4 files changed, 27 insertions(+), 21 deletions(-) diff --git a/openlp/migration/migratebibles.py b/openlp/migration/migratebibles.py index c0d47fdb8..cad6afc3f 100644 --- a/openlp/migration/migratebibles.py +++ b/openlp/migration/migratebibles.py @@ -31,7 +31,8 @@ from sqlalchemy import * from sqlalchemy import create_engine from sqlalchemy.orm import scoped_session, sessionmaker, mapper -from openlp.core.lib import PluginConfig +from openlp.core.lib import SettingsManager +from openlp.core.utils import AppLocation from openlp.plugins.bibles.lib.models import * class BaseModel(object): @@ -111,9 +112,8 @@ def init_models(url): class MigrateBibles(): def __init__(self, display): self.display = display - self.config = PluginConfig(u'Bibles') - self.data_path = self.config.get_data_path() - self.database_files = self.config.get_files(u'sqlite') + self.data_path = AppLocation.get_section_data_path(u'bibles') + self.database_files = SettingsManager.get_files(u'bibles', u'.sqlite') print self.database_files def progress(self, text): diff --git a/openlp/migration/migratefiles.py b/openlp/migration/migratefiles.py index 4fa6b5a29..ceca99718 100644 --- a/openlp/migration/migratefiles.py +++ b/openlp/migration/migratefiles.py @@ -23,7 +23,7 @@ # Temple Place, Suite 330, Boston, MA 02111-1307 USA # ############################################################################### -from openlp.core.utils import ConfigHelper +from openlp.core.utils import AppLocation class MigrateFiles(): def __init__(self, display): @@ -36,14 +36,19 @@ class MigrateFiles(): def _initial_setup(self): self.display.output(u'Initial Setup started') - ConfigHelper.get_data_path() + data_path = AppLocation.get_data_path() + print data_path self.display.sub_output(u'Config created') - ConfigHelper.get_config(u'bible', u'data path') + bibles_path = AppLocation.get_section_data_path(u'bibles') + print bibles_path self.display.sub_output(u'Config created') - ConfigHelper.get_config(u'videos', u'data path') - self.display.sub_output(u'videos created') - ConfigHelper.get_config(u'images', u'data path') + # Media doesn't use a directory like the other plugins. + #media_path = AppLocation.get_section_data_path(u'media') + #self.display.sub_output(u'videos created') + images_path = AppLocation.get_section_data_path(u'images') + print images_path self.display.sub_output(u'images created') - ConfigHelper.get_config(u'presentations', u'data path') + presentations_path = AppLocation.get_section_data_path(u'presentations') + print presentations_path self.display.sub_output(u'presentations created') self.display.output(u'Initial Setup finished') diff --git a/openlp/migration/migratesongs.py b/openlp/migration/migratesongs.py index 89b55bdee..a46f50a54 100644 --- a/openlp/migration/migratesongs.py +++ b/openlp/migration/migratesongs.py @@ -31,7 +31,8 @@ from sqlalchemy import * from sqlalchemy import create_engine from sqlalchemy.orm import scoped_session, sessionmaker, mapper, relation -from openlp.core.lib import PluginConfig +from openlp.core.lib import SettingsManager +from openlp.core.utils import AppLocation from openlp.plugins.songs.lib.models import metadata, songs_table, Song, \ Author, Topic, Book from openlp.plugins.songs.lib.tables import * @@ -111,9 +112,8 @@ class TSongAuthor(BaseModel): class MigrateSongs(): def __init__(self, display): self.display = display - self.config = PluginConfig(u'Songs') - self.data_path = self.config.get_data_path() - self.database_files = self.config.get_files(u'sqlite') + self.data_path = AppLocation.get_section_data_path(u'songs') + self.database_files = SettingsManager.get_files(u'songs', u'.sqlite') print self.database_files def process(self): diff --git a/openlpcnv.pyw b/openlpcnv.pyw index 5d0ff62d0..f0c2748f0 100755 --- a/openlpcnv.pyw +++ b/openlpcnv.pyw @@ -35,6 +35,7 @@ if os.name == u'nt': import win32con from win32com.client import Dispatch +from openlp.core.utils import AppLocation from openlp.migration.display import * from openlp.migration.migratefiles import * from openlp.migration.migratebibles import * @@ -103,8 +104,10 @@ class Migration(object): def convert_sqlite2_to_3(self, olddb, newdb): print u'Converting sqlite2 ' + olddb + ' to sqlite3 ' + newdb if os.name == u'nt': - # we can't make this a raw unicode string as the \U within it causes much confusion - hKey = win32api.RegOpenKey(win32con.HKEY_LOCAL_MACHINE, u'SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\SQLite ODBC Driver') + # we can't make this a raw unicode string as the \U within it + # causes much confusion + hKey = win32api.RegOpenKey(win32con.HKEY_LOCAL_MACHINE, + u'SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\SQLite ODBC Driver') value, type = win32api.RegQueryValueEx (hKey, u'UninstallString') sqlitepath, temp = os.path.split(value) sqliteexe = os.path.join(sqlitepath, u'sqlite.exe') @@ -133,10 +136,8 @@ class Migration(object): if __name__ == u'__main__': mig = Migration() - songconfig = PluginConfig(u'Songs') - newsongpath = songconfig.get_data_path() - bibleconfig = PluginConfig(u'Bibles') - newbiblepath = bibleconfig.get_data_path() + newsongpath = AppLocation.get_section_data_path(u'songs') + newbiblepath = AppLocation.get_section_data_path(u'bibles') if os.name == u'nt': if not os.path.isdir(newsongpath): os.makedirs(newsongpath) From bc74bc03351eb77cbc269e2d2ecec793762fe608 Mon Sep 17 00:00:00 2001 From: Jon Tibble Date: Wed, 28 Apr 2010 15:17:42 +0100 Subject: [PATCH 36/63] Cleanup settings saving --- openlp.pyw | 8 +-- openlp/core/lib/mediamanageritem.py | 14 +++-- openlp/core/lib/plugin.py | 9 ++- openlp/core/lib/settingsmanager.py | 21 ++++--- openlp/core/lib/settingstab.py | 1 + openlp/core/ui/generaltab.py | 54 +++++++++--------- openlp/core/ui/mainwindow.py | 55 ++++++++++++------- openlp/core/ui/mediadockmanager.py | 5 +- openlp/core/ui/servicemanager.py | 30 ++++++---- openlp/core/ui/slidecontroller.py | 10 +++- openlp/core/ui/thememanager.py | 24 +++++--- openlp/core/ui/themestab.py | 17 ++++-- openlp/core/utils/__init__.py | 10 ++-- openlp/plugins/alerts/alertsplugin.py | 3 +- openlp/plugins/alerts/forms/alertstab.py | 32 ++++++----- openlp/plugins/alerts/lib/manager.py | 17 +++--- .../plugins/bibles/forms/importwizardform.py | 13 +++-- openlp/plugins/bibles/lib/biblestab.py | 32 ++++++----- openlp/plugins/bibles/lib/db.py | 12 ++-- openlp/plugins/bibles/lib/manager.py | 14 +++-- openlp/plugins/bibles/lib/mediaitem.py | 5 +- openlp/plugins/custom/lib/customtab.py | 7 ++- openlp/plugins/custom/lib/manager.py | 13 +++-- openlp/plugins/custom/lib/mediaitem.py | 8 +-- openlp/plugins/images/lib/imagetab.py | 7 ++- openlp/plugins/images/lib/mediaitem.py | 13 +++-- openlp/plugins/media/lib/mediaitem.py | 8 +-- openlp/plugins/presentations/lib/mediaitem.py | 12 ++-- .../lib/presentationcontroller.py | 6 +- .../presentations/lib/presentationtab.py | 6 +- openlp/plugins/remotes/lib/remotetab.py | 5 +- openlp/plugins/remotes/remoteplugin.py | 3 +- openlp/plugins/songs/lib/manager.py | 12 ++-- openlp/plugins/songs/lib/mediaitem.py | 5 +- openlp/plugins/songs/lib/songstab.py | 15 +++-- .../songusage/forms/songusagedetailform.py | 9 +-- openlp/plugins/songusage/lib/manager.py | 23 ++++---- openlp/plugins/songusage/songusageplugin.py | 7 ++- 38 files changed, 317 insertions(+), 228 deletions(-) diff --git a/openlp.pyw b/openlp.pyw index 69e36618c..0c1227b6a 100755 --- a/openlp.pyw +++ b/openlp.pyw @@ -120,7 +120,7 @@ class OpenLP(QtGui.QApplication): if os.name == u'nt': self.setStyleSheet(application_stylesheet) show_splash = QtCore.QSettings().value( - u'general/show splash', True).toBool() + u'general/show splash', QtCore.QVariant(True)).toBool() if show_splash: self.splash = SplashScreen(self.applicationVersion()) self.splash.show() @@ -130,8 +130,8 @@ class OpenLP(QtGui.QApplication): # Decide how many screens we have and their size for screen in xrange(0, self.desktop().numScreens()): screens.add_screen({u'number': screen, - u'size': self.desktop().availableGeometry(screen), - u'primary': (self.desktop().primaryScreen() == screen)}) + u'size': self.desktop().availableGeometry(screen), + u'primary': (self.desktop().primaryScreen() == screen)}) log.info(u'Screen %d found with resolution %s', screen, self.desktop().availableGeometry(screen)) # start the main app window @@ -196,4 +196,4 @@ if __name__ == u'__main__': """ Instantiate and run the application. """ - main() \ No newline at end of file + main() diff --git a/openlp/core/lib/mediamanageritem.py b/openlp/core/lib/mediamanageritem.py index bf27ed38a..2d16687f4 100644 --- a/openlp/core/lib/mediamanageritem.py +++ b/openlp/core/lib/mediamanageritem.py @@ -70,7 +70,7 @@ class MediaManagerItem(QtGui.QWidget): The user visible name for a plugin which should use a suitable translation function. - ``self.ConfigSection`` + ``self.SettingsSection`` The section in the configuration where the items in the media manager are stored. This could potentially be ``self.PluginNameShort.lower()``. @@ -335,15 +335,15 @@ class MediaManagerItem(QtGui.QWidget): def onFileClick(self): files = QtGui.QFileDialog.getOpenFileNames( self, self.OnNewPrompt, - SettingsManager.get_last_dir(self.ConfigSection), + SettingsManager.get_last_dir(self.SettingsSection), self.OnNewFileMasks) log.info(u'New files(s) %s', unicode(files)) if files: self.loadList(files) dir, filename = os.path.split(unicode(files[0])) - SettingsManager.set_last_dir(self.ConfigSection, dir) + SettingsManager.set_last_dir(self.SettingsSection, dir) SettingsManager.set_list( - self.ConfigSection, self.ConfigSection, self.getFileList()) + self.SettingsSection, self.SettingsSection, self.getFileList()) def getFileList(self): count = 0 @@ -454,7 +454,8 @@ class MediaManagerItem(QtGui.QWidget): if not service_item: QtGui.QMessageBox.information(self, self.trUtf8('No Service Item Selected'), - self.trUtf8('You must select a existing service item to add to.')) + self.trUtf8( + 'You must select an existing service item to add to.')) elif self.title.lower() == service_item.name.lower(): self.generateSlideData(service_item) self.parent.service_manager.addServiceItem(service_item, @@ -463,7 +464,8 @@ class MediaManagerItem(QtGui.QWidget): #Turn off the remote edit update message indicator QtGui.QMessageBox.information(self, self.trUtf8('Invalid Service Item'), - self.trUtf8(unicode('You must select a %s service item.' % self.title))) + self.trUtf8(unicode( + 'You must select a %s service item.' % self.title))) def buildServiceItem(self, item=None): """ diff --git a/openlp/core/lib/plugin.py b/openlp/core/lib/plugin.py index f01fa0807..c7a257700 100644 --- a/openlp/core/lib/plugin.py +++ b/openlp/core/lib/plugin.py @@ -51,6 +51,9 @@ class Plugin(QtCore.QObject): ``version`` The version number of this iteration of the plugin. + ``settings_section`` + The namespace to store settings for the plugin. + ``icon`` An instance of QIcon, which holds an icon for this plugin. @@ -113,6 +116,7 @@ class Plugin(QtCore.QObject): self.name = name if version: self.version = version + self.settings_section = self.name.lower() self.icon = None self.weight = 0 self.status = PluginStatus.Inactive @@ -143,7 +147,8 @@ class Plugin(QtCore.QObject): Sets the status of the plugin """ self.status = QtCore.QSettings().value( - self.name.lower() + u'/status', PluginStatus.Inactive).toInt()[0] + self.settings_section + u'/status', + QtCore.QVariant(PluginStatus.Inactive)).toInt()[0] def toggle_status(self, new_status): """ @@ -151,7 +156,7 @@ class Plugin(QtCore.QObject): """ self.status = new_status QtCore.QSettings().setValue( - self.name.lower() + u'/status', QtCore.QVariant(self.status)) + self.settings_section + u'/status', QtCore.QVariant(self.status)) def is_active(self): """ diff --git a/openlp/core/lib/settingsmanager.py b/openlp/core/lib/settingsmanager.py index 36caa38f5..de1401d56 100644 --- a/openlp/core/lib/settingsmanager.py +++ b/openlp/core/lib/settingsmanager.py @@ -76,7 +76,7 @@ class SettingsManager(object): else: name = u'last directory' last_dir = unicode(QtCore.QSettings().value( - section + u'/' + name, u'').toString()) + section + u'/' + name, QtCore.QVariant(u'')).toString()) return last_dir @staticmethod @@ -116,18 +116,19 @@ class SettingsManager(object): The list of values to save. """ settings = QtCore.QSettings() + settings.beginGroup(section) old_count = settings.value( - u'%s/%s count' % (section, name), 0).toInt()[0] + u'%s count' % name, QtCore.QVariant(0)).toInt()[0] new_count = len(list) - settings.setValue( - u'%s/%s count' % (section, name), QtCore.QVariant(new_count)) + settings.setValue(u'%s count' % name, QtCore.QVariant(new_count)) for counter in range (0, new_count): settings.setValue( - u'%s/%s %d' % (section, name, counter), list[counter-1]) + u'%s %d' % (name, counter), QtCore.QVariant(list[counter-1])) if old_count > new_count: # Tidy up any old list items for counter in range(new_count, old_count): - settings.remove(u'%s/%s %d' % (section, name, counter)) + settings.remove(u'%s %d' % (name, counter)) + settings.endGroup() @staticmethod def load_list(section, name): @@ -141,15 +142,17 @@ class SettingsManager(object): The name of the list. """ settings = QtCore.QSettings() + settings.beginGroup(section) list_count = settings.value( - u'%s/%s count' % (section, name), 0).toInt()[0] + u'%s count' % name, QtCore.QVariant(0)).toInt()[0] list = [] if list_count: for counter in range(0, list_count): - item = unicode(settings.value( - u'%s/%s %d' % (section, name, counter)).toString()) + item = unicode( + settings.value(u'%s %d' % (name, counter)).toString()) if item: list.append(item) + settings.endGroup() return list @staticmethod diff --git a/openlp/core/lib/settingstab.py b/openlp/core/lib/settingstab.py index 6f1aef854..0b862d9f8 100644 --- a/openlp/core/lib/settingstab.py +++ b/openlp/core/lib/settingstab.py @@ -40,6 +40,7 @@ class SettingsTab(QtGui.QWidget): QtGui.QWidget.__init__(self) self.tabTitle = title self.tabTitleVisible = None + self.settingsSection = self.tabTitle.lower() self.setupUi() self.retranslateUi() self.initialise() diff --git a/openlp/core/ui/generaltab.py b/openlp/core/ui/generaltab.py index 357756a08..005e588ac 100644 --- a/openlp/core/ui/generaltab.py +++ b/openlp/core/ui/generaltab.py @@ -42,13 +42,15 @@ class GeneralTab(SettingsTab): If not set before default to last screen. """ settings = QtCore.QSettings() - self.MonitorNumber = settings.value( - u'general/monitor', self.screens.monitor_number).toInt()[0] + settings.beginGroup(self.settingsSection) + self.MonitorNumber = settings.value(u'monitor', + QtCore.QVariant(self.screens.monitor_number)).toInt()[0] self.screens.set_current_display(self.MonitorNumber) self.screens.monitor_number = self.MonitorNumber self.DisplayOnMonitor = settings.value( - u'general/display on monitor', True).toBool() + u'display on monitor', QtCore.QVariant(True)).toBool() self.screens.display = self.DisplayOnMonitor + settings.endGroup() def setupUi(self): self.setObjectName(u'GeneralTab') @@ -227,6 +229,7 @@ class GeneralTab(SettingsTab): def load(self): settings = QtCore.QSettings() + settings.beginGroup(self.settingsSection) for screen in self.screens.screen_list: screen_name = u'%s %d' % (self.trUtf8('Screen'), screen[u'number'] + 1) @@ -235,21 +238,22 @@ class GeneralTab(SettingsTab): self.MonitorComboBox.addItem(screen_name) # Get the configs self.Warning = settings.value( - u'general/blank warning', QtCore.QVariant(False)).toBool() + u'blank warning', QtCore.QVariant(False)).toBool() self.AutoOpen = settings.value( - u'general/auto open', QtCore.QVariant(False)).toBool() + u'auto open', QtCore.QVariant(False)).toBool() self.ShowSplash = settings.value( - u'general/show splash', QtCore.QVariant(True)).toBool() + u'show splash', QtCore.QVariant(True)).toBool() self.PromptSaveService = settings.value( - u'general/save prompt', QtCore.QVariant(False)).toBool() + u'save prompt', QtCore.QVariant(False)).toBool() self.AutoPreview = settings.value( - u'general/auto preview', QtCore.QVariant(False)).toBool() + u'auto preview', QtCore.QVariant(False)).toBool() self.CCLINumber = unicode(settings.value( - u'general/ccli number', QtCore.QVariant(u'')).toString()) + u'ccli number', QtCore.QVariant(u'')).toString()) self.Username = unicode(settings.value( - u'general/songselect username', QtCore.QVariant(u'')).toString()) + u'songselect username', QtCore.QVariant(u'')).toString()) self.Password = unicode(settings.value( - u'general/songselect password', QtCore.QVariant(u'')).toString()) + u'songselect password', QtCore.QVariant(u'')).toString()) + settings.endGroup() self.SaveCheckServiceCheckBox.setChecked(self.PromptSaveService) # Set a few things up self.MonitorComboBox.setCurrentIndex(self.MonitorNumber) @@ -264,26 +268,22 @@ class GeneralTab(SettingsTab): def save(self): settings = QtCore.QSettings() - settings.setValue(u'general/monitor', - QtCore.QVariant(self.MonitorNumber)) - settings.setValue(u'general/display on monitor', + settings.beginGroup(self.settingsSection) + settings.setValue(u'monitor', QtCore.QVariant(self.MonitorNumber)) + settings.setValue(u'display on monitor', QtCore.QVariant(self.DisplayOnMonitor)) - settings.setValue(u'general/blank warning', - QtCore.QVariant(self.Warning)) - settings.setValue(u'general/auto open', - QtCore.QVariant(self.AutoOpen)) - settings.setValue(u'general/show splash', - QtCore.QVariant(self.ShowSplash)) - settings.setValue(u'general/save prompt', + settings.setValue(u'blank warning', QtCore.QVariant(self.Warning)) + settings.setValue(u'auto open', QtCore.QVariant(self.AutoOpen)) + settings.setValue(u'show splash', QtCore.QVariant(self.ShowSplash)) + settings.setValue(u'save prompt', QtCore.QVariant(self.PromptSaveService)) - settings.setValue(u'general/auto preview', - QtCore.QVariant(self.AutoPreview)) - settings.setValue(u'general/ccli number', - QtCore.QVariant(self.CCLINumber)) - settings.setValue(u'general/songselect username', + settings.setValue(u'auto preview', QtCore.QVariant(self.AutoPreview)) + settings.setValue(u'ccli number', QtCore.QVariant(self.CCLINumber)) + settings.setValue(u'songselect username', QtCore.QVariant(self.Username)) - settings.setValue(u'general/songselect password', + settings.setValue(u'songselect password', QtCore.QVariant(self.Password)) + settings.endGroup() self.screens.display = self.DisplayOnMonitor #Monitor Number has changed. if self.screens.monitor_number != self.MonitorNumber: diff --git a/openlp/core/ui/mainwindow.py b/openlp/core/ui/mainwindow.py index d1efc79c5..44341244d 100644 --- a/openlp/core/ui/mainwindow.py +++ b/openlp/core/ui/mainwindow.py @@ -362,12 +362,14 @@ class Ui_MainWindow(object): self.actionLook_Feel.setText(self.trUtf8('Look && &Feel')) self.OptionsSettingsItem.setText(self.trUtf8('&Settings')) self.ViewMediaManagerItem.setText(self.trUtf8('&Media Manager')) - self.ViewMediaManagerItem.setToolTip(self.trUtf8('Toggle Media Manager')) + self.ViewMediaManagerItem.setToolTip( + self.trUtf8('Toggle Media Manager')) self.ViewMediaManagerItem.setStatusTip( self.trUtf8('Toggle the visibility of the Media Manager')) self.ViewMediaManagerItem.setShortcut(self.trUtf8('F8')) self.ViewThemeManagerItem.setText(self.trUtf8('&Theme Manager')) - self.ViewThemeManagerItem.setToolTip(self.trUtf8('Toggle Theme Manager')) + self.ViewThemeManagerItem.setToolTip( + self.trUtf8('Toggle Theme Manager')) self.ViewThemeManagerItem.setStatusTip( self.trUtf8('Toggle the visibility of the Theme Manager')) self.ViewThemeManagerItem.setShortcut(self.trUtf8('F10')) @@ -378,7 +380,8 @@ class Ui_MainWindow(object): self.trUtf8('Toggle the visibility of the Service Manager')) self.ViewServiceManagerItem.setShortcut(self.trUtf8('F9')) self.action_Preview_Panel.setText(self.trUtf8('&Preview Panel')) - self.action_Preview_Panel.setToolTip(self.trUtf8('Toggle Preview Panel')) + self.action_Preview_Panel.setToolTip( + self.trUtf8('Toggle Preview Panel')) self.action_Preview_Panel.setStatusTip( self.trUtf8('Toggle the visibility of the Preview Panel')) self.action_Preview_Panel.setShortcut(self.trUtf8('F11')) @@ -419,6 +422,8 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow): QtGui.QMainWindow.__init__(self) self.screens = screens self.applicationVersion = applicationVersion + self.generalSettingsSection = u'general' + self.uiSettingsSection = u'user interface' self.serviceNotSaved = False self.settingsmanager = SettingsManager(screens) self.displayManager = DisplayManager(screens) @@ -498,8 +503,8 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow): #warning cyclic dependency #RenderManager needs to call ThemeManager and #ThemeManager needs to call RenderManager - self.RenderManager = RenderManager(self.ThemeManagerContents, - self.screens) + self.RenderManager = RenderManager( + self.ThemeManagerContents, self.screens) #Define the media Dock Manager self.mediaDockManager = MediaDockManager(self.MediaToolBox) log.info(u'Load Plugins') @@ -561,7 +566,8 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow): if self.displayManager.mainDisplay.isVisible(): self.displayManager.mainDisplay.setFocus() self.activateWindow() - if QtCore.QSettings().value(u'general/auto open', False).toBool(): + if QtCore.QSettings().value(self.generalSettingsSection + u'/auto open', + QtCore.QVariant(False)).toBool(): self.ServiceManagerContents.onLoadService(True) def blankCheck(self): @@ -569,14 +575,17 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow): Check and display message if screen blank on setup. Triggered by delay thread. """ - if QtCore.QSettings().value(u'general/screen blank', False).toBool() \ - and QtCore.QSettings().value(u'general/blank warning', False).toBool(): + settings = QtCore.QSettings() + settings.beginGroup(self.generalSettingsSection) + if settings.value(u'screen blank', QtCore.QVariant(False)).toBool() \ + and settings.value(u'blank warning', QtCore.QVariant(False)).toBool(): self.LiveController.onBlankDisplay(True) QtGui.QMessageBox.question(self, self.trUtf8('OpenLP Main Display Blanked'), self.trUtf8('The Main Display has been blanked out'), QtGui.QMessageBox.StandardButtons(QtGui.QMessageBox.Ok), QtGui.QMessageBox.Ok) + settings.endGroup() def versionThread(self): """ @@ -622,7 +631,8 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow): if self.serviceNotSaved: ret = QtGui.QMessageBox.question(self, self.trUtf8('Save Changes to Service?'), - self.trUtf8('Your service has changed, do you want to save those changes?'), + self.trUtf8('Your service has changed. ' + 'Do you want to save those changes?'), QtGui.QMessageBox.StandardButtons( QtGui.QMessageBox.Cancel | QtGui.QMessageBox.Discard | @@ -705,26 +715,30 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow): log.debug(u'Loading QSettings') settings = QtCore.QSettings() self.recentFiles = settings.value( - u'general/recent files').toStringList() - self.move(settings.value(u'user interface/main window position', + self.generalSettingsSection + u'/recent files').toStringList() + settings.beginGroup(self.uiSettingsSection) + self.move(settings.value(u'main window position', QtCore.QVariant(QtCore.QPoint(0, 0))).toPoint()) - self.restoreGeometry(settings.value( - u'user interface/main window geometry').toByteArray()) - self.restoreState( - settings.value(u'user interface/main window state').toByteArray()) + self.restoreGeometry( + settings.value(u'main window geometry').toByteArray()) + self.restoreState(settings.value(u'main window state').toByteArray()) + settings.endGroup() def saveSettings(self): log.debug(u'Saving QSettings') settings = QtCore.QSettings() recentFiles = QtCore.QVariant(self.recentFiles) \ if self.recentFiles else QtCore.QVariant() - settings.setValue(u'general/recent files', recentFiles) - settings.setValue(u'user interface/main window position', + settings.setValue( + self.generalSettingsSection + u'/recent files', recentFiles) + settings.beginGroup(self.uiSettingsSection) + settings.setValue(u'main window position', QtCore.QVariant(self.pos())) - settings.setValue(u'user interface/main window state', + settings.setValue(u'main window state', QtCore.QVariant(self.saveState())) - settings.setValue(u'user interface/main window geometry', + settings.setValue(u'main window geometry', QtCore.QVariant(self.saveGeometry())) + settings.endGroup() def updateFileMenu(self): self.FileMenu.clear() @@ -747,7 +761,8 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow): def addRecentFile(self, filename): recentFileCount = QtCore.QSettings().value( - u'general/max recent files', 4).toInt()[0] + self.generalSettingsSection + u'/max recent files', + QtCore.QVariant(4)).toInt()[0] if filename and not self.recentFiles.contains(filename): self.recentFiles.prepend(QtCore.QString(filename)) while self.recentFiles.count() > recentFileCount: diff --git a/openlp/core/ui/mediadockmanager.py b/openlp/core/ui/mediadockmanager.py index 574b181da..ae77cc43a 100644 --- a/openlp/core/ui/mediadockmanager.py +++ b/openlp/core/ui/mediadockmanager.py @@ -45,7 +45,8 @@ class MediaDockManager(object): log.debug(u'Inserting %s dock' % media_item.title) match = False for dock_index in range(0, self.media_dock.count()): - if self.media_dock.widget(dock_index).ConfigSection == media_item.title.lower(): + if self.media_dock.widget(dock_index).SettingsSection == \ + media_item.title.lower(): match = True break if not match: @@ -56,6 +57,6 @@ class MediaDockManager(object): log.debug(u'remove %s dock' % name) for dock_index in range(0, self.media_dock.count()): if self.media_dock.widget(dock_index): - if self.media_dock.widget(dock_index).ConfigSection == name: + if self.media_dock.widget(dock_index).SettingsSection == name: self.media_dock.widget(dock_index).hide() self.media_dock.removeItem(dock_index) diff --git a/openlp/core/ui/servicemanager.py b/openlp/core/ui/servicemanager.py index 28793de71..45d007c17 100644 --- a/openlp/core/ui/servicemanager.py +++ b/openlp/core/ui/servicemanager.py @@ -40,7 +40,7 @@ from openlp.core.utils import AppLocation class ServiceManagerList(QtGui.QTreeWidget): def __init__(self, parent=None, name=None): - QtGui.QTreeWidget.__init__(self,parent) + QtGui.QTreeWidget.__init__(self, parent) self.parent = parent def keyPressEvent(self, event): @@ -99,6 +99,8 @@ class ServiceManager(QtGui.QWidget): """ QtGui.QWidget.__init__(self) self.parent = parent + self.settingsSection = u'servicemanager' + self.generalSettingsSection = self.parent.generalSettingsSection self.serviceItems = [] self.serviceName = u'' self.droppos = 0 @@ -191,7 +193,8 @@ class ServiceManager(QtGui.QWidget): QtCore.SIGNAL(u'config_updated'), self.regenerateServiceItems) # Last little bits of setting up self.service_theme = unicode(QtCore.QSettings().value( - u'service manager/service theme', u'').toString()) + self.settingsSection + u'/service theme', + QtCore.QVariant(u'')).toString()) self.servicePath = AppLocation.get_section_data_path(u'servicemanager') #build the context menu self.menu = QtGui.QMenu() @@ -402,8 +405,9 @@ class ServiceManager(QtGui.QWidget): """ Clear the list to create a new service """ - if self.parent.serviceNotSaved and \ - QtCore.QSettings().value(u'general/save prompt', False).toBool(): + if self.parent.serviceNotSaved and QtCore.QSettings().value( + self.generalSettingsSection + u'/save prompt', + QtCore.QVariant(False)).toBool(): ret = QtGui.QMessageBox.question(self, self.trUtf8('Save Changes to Service?'), self.trUtf8('Your service is unsaved, do you want to save ' @@ -487,17 +491,17 @@ class ServiceManager(QtGui.QWidget): if not quick or self.isNew: filename = QtGui.QFileDialog.getSaveFileName(self, self.trUtf8(u'Save Service'), - SettingsManager.get_last_dir(u'servicemanager'), + SettingsManager.get_last_dir(self.settingsSection), self.trUtf8(u'OpenLP Service Files (*.osz)')) else: - filename = SettingsManager.get_last_dir(u'servicemanager') + filename = SettingsManager.get_last_dir(self.settingsSection) if filename: splittedFile = filename.split(u'.') if splittedFile[-1] != u'osz': filename = filename + u'.osz' filename = unicode(filename) self.isNew = False - SettingsManager.set_last_dir(u'servicemanager', filename) + SettingsManager.set_last_dir(self.settingsSection, filename) service = [] servicefile = filename + u'.osd' zip = None @@ -538,11 +542,11 @@ class ServiceManager(QtGui.QWidget): def onLoadService(self, lastService=False): if lastService: - filename = SettingsManager.get_last_dir(u'servicemanager') + filename = SettingsManager.get_last_dir(self.settingsSection) else: filename = QtGui.QFileDialog.getOpenFileName( self, self.trUtf8('Open Service'), - SettingsManager.get_last_dir(u'servicemanager'), + SettingsManager.get_last_dir(self.settingsSection), u'Services (*.osz)') self.loadService(filename) @@ -572,7 +576,7 @@ class ServiceManager(QtGui.QWidget): filename = unicode(filename) name = filename.split(os.path.sep) if filename: - SettingsManager.set_last_dir(u'servicemanager', filename) + SettingsManager.set_last_dir(self.settingsSection, filename) zip = None f = None try: @@ -641,7 +645,7 @@ class ServiceManager(QtGui.QWidget): """ self.service_theme = unicode(self.ThemeComboBox.currentText()) self.parent.RenderManager.set_service_theme(self.service_theme) - QtCore.QSettings().setValue(u'servicemanager/service theme', + QtCore.QSettings().setValue(self.settingsSection + u'/service theme', QtCore.QVariant(self.service_theme)) self.regenerateServiceItems() @@ -724,7 +728,9 @@ class ServiceManager(QtGui.QWidget): item, count = self.findServiceItem() self.parent.LiveController.addServiceManagerItem( self.serviceItems[item][u'service_item'], count) - if QtCore.QSettings().value(u'general/auto preview', False).toBool(): + if QtCore.QSettings().value( + self.generalSettingsSection + u'/auto preview', + QtCore.QVariant(False)).toBool(): item += 1 if self.serviceItems and item < len(self.serviceItems) and \ self.serviceItems[item][u'service_item'].is_capable( diff --git a/openlp/core/ui/slidecontroller.py b/openlp/core/ui/slidecontroller.py index 6ff739fc3..811fd51e3 100644 --- a/openlp/core/ui/slidecontroller.py +++ b/openlp/core/ui/slidecontroller.py @@ -93,6 +93,8 @@ class SlideController(QtGui.QWidget): """ QtGui.QWidget.__init__(self, parent) self.settingsmanager = settingsmanager + self.generalSettingsSection = u'general' + self.songsSettingsSection = u'songs' self.isLive = isLive self.parent = parent self.mainDisplay = self.parent.displayManager.mainDisplay @@ -396,8 +398,9 @@ class SlideController(QtGui.QWidget): self.Toolbar.makeWidgetsInvisible(self.loop_list) if item.is_text(): self.Toolbar.makeWidgetsInvisible(self.loop_list) - if QtCore.QSettings().value(u'songs/show songbar', True).toBool() \ - and len(self.slideList) > 0: + if QtCore.QSettings().value( + self.songsSettingsSection + u'/show songbar', + QtCore.QVariant(True)).toBool() and len(self.slideList) > 0: self.Toolbar.makeWidgetsVisible([u'Song Menu']) if item.is_capable(ItemCapabilities.AllowsLoop) and \ len(item.get_frames()) > 1: @@ -585,7 +588,8 @@ class SlideController(QtGui.QWidget): if force: self.blankButton.setChecked(True) self.blankScreen(HideMode.Blank, self.blankButton.isChecked()) - QtCore.QSettings().setValue(u'general/screen blank', + QtCore.QSettings().setValue( + self.generalSettingsSection + u'/screen blank', QtCore.QVariant(self.blankButton.isChecked())) def onThemeDisplay(self, force=False): diff --git a/openlp/core/ui/thememanager.py b/openlp/core/ui/thememanager.py index a71e65210..797a6a27a 100644 --- a/openlp/core/ui/thememanager.py +++ b/openlp/core/ui/thememanager.py @@ -47,6 +47,7 @@ class ThemeManager(QtGui.QWidget): def __init__(self, parent): QtGui.QWidget.__init__(self, parent) self.parent = parent + self.settingsSection = u'themes' self.Layout = QtGui.QVBoxLayout(self) self.Layout.setSpacing(0) self.Layout.setMargin(0) @@ -105,14 +106,15 @@ class ThemeManager(QtGui.QWidget): QtCore.SIGNAL(u'theme_update_global'), self.changeGlobalFromTab) #Variables self.themelist = [] - self.path = AppLocation.get_section_data_path(u'themes') + self.path = AppLocation.get_section_data_path(self.settingsSection) self.checkThemesExists(self.path) self.thumbPath = os.path.join(self.path, u'.thumbnails') self.checkThemesExists(self.thumbPath) self.amendThemeForm.path = self.path # Last little bits of setting up self.global_theme = unicode(QtCore.QSettings().value( - u'themes/global theme', u'').toString()) + self.settingsSection + u'/global theme', + QtCore.QVariant(u'')).toString()) def changeGlobalFromTab(self, themeName): log.debug(u'changeGlobalFromTab %s', themeName) @@ -144,7 +146,8 @@ class ThemeManager(QtGui.QWidget): self.ThemeListWidget.item(count).text()) name = u'%s (%s)' % (self.global_theme, self.trUtf8('default')) self.ThemeListWidget.item(count).setText(name) - QtCore.QSettings().setValue(u'themes/global theme', + QtCore.QSettings().setValue( + self.settingsSection + u'/global theme', QtCore.QVariant(self.global_theme)) Receiver.send_message(u'theme_update_global', self.global_theme) self.pushThemes() @@ -167,7 +170,8 @@ class ThemeManager(QtGui.QWidget): def onDeleteTheme(self): self.global_theme = unicode(QtCore.QSettings().value( - u'themes/global theme', u'').toString()) + self.settingsSection + u'/global theme', + QtCore.QVariant(u'')).toString()) item = self.ThemeListWidget.currentItem() if item: theme = unicode(item.text()) @@ -220,10 +224,10 @@ class ThemeManager(QtGui.QWidget): theme = unicode(item.data(QtCore.Qt.UserRole).toString()) path = QtGui.QFileDialog.getExistingDirectory(self, unicode(self.trUtf8('Save Theme - (%s)')) % theme, - SettingsManager.get_last_dir(u'themes', 1)) + SettingsManager.get_last_dir(self.settingsSection, 1)) path = unicode(path) if path: - SettingsManager.set_last_dir(u'themes', path, 1) + SettingsManager.set_last_dir(self.settingsSection, path, 1) themePath = os.path.join(path, theme + u'.theme') zip = None try: @@ -232,7 +236,8 @@ class ThemeManager(QtGui.QWidget): for root, dirs, files in os.walk(source): for name in files: zip.write( - os.path.join(source, name), os.path.join(theme, name)) + os.path.join(source, name), + os.path.join(theme, name)) except: log.exception(u'Export Theme Failed') finally: @@ -242,11 +247,12 @@ class ThemeManager(QtGui.QWidget): def onImportTheme(self): files = QtGui.QFileDialog.getOpenFileNames( self, self.trUtf8('Select Theme Import File'), - SettingsManager.get_last_dir(u'themes'), u'Theme (*.*)') + SettingsManager.get_last_dir(self.settingsSection), u'Theme (*.*)') log.info(u'New Themes %s', unicode(files)) if files: for file in files: - SettingsManager.set_last_dir(u'themes', unicode(file)) + SettingsManager.set_last_dir( + self.settingsSection, unicode(file)) self.unzipTheme(file, self.path) self.loadThemes() diff --git a/openlp/core/ui/themestab.py b/openlp/core/ui/themestab.py index f3b5ec917..dba07eb6d 100644 --- a/openlp/core/ui/themestab.py +++ b/openlp/core/ui/themestab.py @@ -124,10 +124,12 @@ class ThemesTab(SettingsTab): def load(self): settings = QtCore.QSettings() + settings.beginGroup(self.settingsSection) self.theme_level = settings.value( - u'themes/theme level', ThemeLevel.Global).toInt()[0] + u'theme level', QtCore.QVariant(ThemeLevel.Global)).toInt()[0] self.global_theme = unicode(settings.value( - u'themes/global theme', u'').toString()) + u'global theme', QtCore.QVariant(u'')).toString()) + settings.endGroup() if self.theme_level == ThemeLevel.Global: self.GlobalLevelRadioButton.setChecked(True) elif self.theme_level == ThemeLevel.Service: @@ -137,10 +139,12 @@ class ThemesTab(SettingsTab): def save(self): settings = QtCore.QSettings() - settings.setValue(u'themes/theme level', + settings.beginGroup(self.settingsSection) + settings.setValue(u'theme level', QtCore.QVariant(self.theme_level)) - settings.setValue(u'themes/global theme', + settings.setValue(u'global theme', QtCore.QVariant(self.global_theme)) + settings.endGroup() Receiver.send_message(u'theme_update_global', self.global_theme) self.parent.RenderManager.set_global_theme( self.global_theme, self.theme_level) @@ -175,7 +179,8 @@ class ThemesTab(SettingsTab): """ #reload as may have been triggered by the ThemeManager self.global_theme = unicode(QtCore.QSettings().value( - u'themes/global theme', u'').toString()) + self.settingsSection + u'/global theme', + QtCore.QVariant(u'')).toString()) self.DefaultComboBox.clear() for theme in theme_list: self.DefaultComboBox.addItem(theme) @@ -194,4 +199,4 @@ class ThemesTab(SettingsTab): if not preview.isNull(): preview = preview.scaled(300, 255, QtCore.Qt.KeepAspectRatio, QtCore.Qt.SmoothTransformation) - self.DefaultListView.setPixmap(preview) \ No newline at end of file + self.DefaultListView.setPixmap(preview) diff --git a/openlp/core/utils/__init__.py b/openlp/core/utils/__init__.py index 659cb1ceb..0aaa31de3 100644 --- a/openlp/core/utils/__init__.py +++ b/openlp/core/utils/__init__.py @@ -124,11 +124,13 @@ def check_latest_version(current_version): """ version_string = current_version[u'full'] #set to prod in the distribution config file. - last_test = unicode(QtCore.QSettings().value(u'general/last version test', - datetime.now().date()).toString()) + settings = QtCore.QSettings() + settings.beginGroup(u'general') + last_test = unicode(settings.value(u'last version test', + QtCore.QVariant(datetime.now().date())).toString()) this_test = unicode(datetime.now().date()) - QtCore.QSettings().setValue( - u'general/last version test', QtCore.QVariant(this_test)) + settings.setValue(u'last version test', QtCore.QVariant(this_test)) + settings.endGroup() if last_test != this_test: version_string = u'' if current_version[u'build']: diff --git a/openlp/plugins/alerts/alertsplugin.py b/openlp/plugins/alerts/alertsplugin.py index a55523e4b..2ec2db506 100644 --- a/openlp/plugins/alerts/alertsplugin.py +++ b/openlp/plugins/alerts/alertsplugin.py @@ -84,7 +84,8 @@ class alertsPlugin(Plugin): def togglealertsState(self): self.alertsActive = not self.alertsActive QtCore.QSettings().setValue( - u'alerts/active', QtCore.QVariant(self.alertsActive)) + self.settings_section + u'/active', + QtCore.QVariant(self.alertsActive)) def onAlertsTrigger(self): self.alertForm.loadList() diff --git a/openlp/plugins/alerts/forms/alertstab.py b/openlp/plugins/alerts/forms/alertstab.py index 14066f7aa..7cda09488 100644 --- a/openlp/plugins/alerts/forms/alertstab.py +++ b/openlp/plugins/alerts/forms/alertstab.py @@ -229,15 +229,19 @@ class AlertsTab(SettingsTab): def load(self): settings = QtCore.QSettings() - self.timeout = settings.value(u'alerts/timeout', 5).toInt()[0] + settings.beginGroup(self.settingsSection) + self.timeout = settings.value(u'timeout', QtCore.QVariant(5)).toInt()[0] self.font_color = unicode(settings.value( - u'alerts/font color', u'#ffffff').toString()) - self.font_size = settings.value(u'alerts/font size', 40).toInt()[0] + u'font color', QtCore.QVariant(u'#ffffff')).toString()) + self.font_size = settings.value( + u'font size', QtCore.QVariant(40)).toInt()[0] self.bg_color = unicode(settings.value( - u'alerts/background color', u'#660000').toString()) + u'background color', QtCore.QVariant(u'#660000')).toString()) self.font_face = unicode(settings.value( - u'alerts/font face', QtGui.QFont().family()).toString()) - self.location = settings.value(u'alerts/location', 0).toInt()[0] + u'font face', QtCore.QVariant(QtGui.QFont().family())).toString()) + self.location = settings.value( + u'location', QtCore.QVariant(0)).toInt()[0] + settings.endGroup() self.FontSizeSpinBox.setValue(self.font_size) self.TimeoutSpinBox.setValue(self.timeout) self.FontColorButton.setStyleSheet( @@ -256,16 +260,16 @@ class AlertsTab(SettingsTab): def save(self): settings = QtCore.QSettings() + settings.beginGroup(self.settingsSection) self.font_face = self.FontComboBox.currentFont().family() - settings.setValue( - u'alerts/background color', QtCore.QVariant(self.bg_color)) - settings.setValue( - u'alerts/font color', QtCore.QVariant(self.font_color)) - settings.setValue(u'alerts/font size', QtCore.QVariant(self.font_size)) - settings.setValue(u'alerts/font face', QtCore.QVariant(self.font_face)) - settings.setValue(u'alerts/timeout', QtCore.QVariant(self.timeout)) - settings.setValue(u'alerts/location', + settings.setValue(u'background color', QtCore.QVariant(self.bg_color)) + settings.setValue(u'font color', QtCore.QVariant(self.font_color)) + settings.setValue(u'font size', QtCore.QVariant(self.font_size)) + settings.setValue(u'font face', QtCore.QVariant(self.font_face)) + settings.setValue(u'timeout', QtCore.QVariant(self.timeout)) + settings.setValue(u'location', QtCore.QVariant(self.LocationComboBox.currentIndex())) + settings.endGroup() def updateDisplay(self): font = QtGui.QFont() diff --git a/openlp/plugins/alerts/lib/manager.py b/openlp/plugins/alerts/lib/manager.py index 98a3d8a43..f82266f49 100644 --- a/openlp/plugins/alerts/lib/manager.py +++ b/openlp/plugins/alerts/lib/manager.py @@ -44,23 +44,24 @@ class DBManager(): Creates the connection to the database, and creates the tables if they don't exist. """ - settings = QtCore.QSettings() log.debug(u'Alerts Initialising') + settings = QtCore.QSettings() + settings.beginGroup(u'alerts') self.db_url = u'' db_type = unicode( - settings.value(u'alerts/db type', u'sqlite').toString()) + settings.value(u'db type', QtCore.QVariant(u'sqlite')).toString()) if db_type == u'sqlite': self.db_url = u'sqlite:///%s/alerts.sqlite' % \ AppLocation.get_section_data_path(u'alerts') else: - self.db_url = u'%s://%s:%s@%s/%s' % \ - (db_type, settings.value(u'alerts/db username'), - settings.value(u'alerts/db password'), - settings.value(u'alerts/db hostname'), - settings.value(u'alerts/db database')) + self.db_url = u'%s://%s:%s@%s/%s' % (db_type, + unicode(settings.value(u'db username').toString()), + unicode(settings.value(u'db password').toString()), + unicode(settings.value(u'db hostname').toString()), + unicode(settings.value(u'db database').toString())) + settings.endGroup() self.session = init_models(self.db_url) metadata.create_all(checkfirst=True) - log.debug(u'Alerts Initialised') def get_all_alerts(self): diff --git a/openlp/plugins/bibles/forms/importwizardform.py b/openlp/plugins/bibles/forms/importwizardform.py index 41df18cdc..d3e8acd73 100644 --- a/openlp/plugins/bibles/forms/importwizardform.py +++ b/openlp/plugins/bibles/forms/importwizardform.py @@ -274,6 +274,7 @@ class ImportWizardForm(QtGui.QWizard, Ui_BibleImportWizard): def setDefaults(self): settings = QtCore.QSettings() + settings.beginGroup(self.bibleplugin.settings_section) self.setField(u'source_format', QtCore.QVariant(0)) self.setField(u'osis_location', QtCore.QVariant('')) self.setField(u'csv_booksfile', QtCore.QVariant('')) @@ -282,16 +283,17 @@ class ImportWizardForm(QtGui.QWizard, Ui_BibleImportWizard): self.setField(u'web_location', QtCore.QVariant(WebDownload.Crosswalk)) self.setField(u'web_biblename', QtCore.QVariant(self.BibleComboBox)) self.setField(u'proxy_server', - settings.value(u'bibles/proxy address', u'')) + settings.value(u'proxy address', QtCore.QVariant(u''))) self.setField(u'proxy_username', - settings.value(u'bibles/proxy username', u'')) + settings.value(u'proxy username', QtCore.QVariant(u''))) self.setField(u'proxy_password', - settings.value(u'proxy password', u'')) + settings.value(u'proxy password', QtCore.QVariant(u''))) self.setField(u'license_version', QtCore.QVariant(self.VersionNameEdit)) self.setField(u'license_copyright', QtCore.QVariant(self.CopyrightEdit)) self.setField(u'license_permission', QtCore.QVariant(self.PermissionEdit)) self.onLocationComboBoxChanged(WebDownload.Crosswalk) + settings.endGroup() def loadWebBibles(self): """ @@ -343,10 +345,11 @@ class ImportWizardForm(QtGui.QWizard, Ui_BibleImportWizard): def getFileName(self, title, editbox): filename = QtGui.QFileDialog.getOpenFileName(self, title, - SettingsManager.get_last_dir(bibles, 1)) + SettingsManager.get_last_dir(self.bibleplugin.settings_section, 1)) if filename: editbox.setText(filename) - SettingsManager.set_last_dir(bibles, filename, 1) + SettingsManager.set_last_dir( + self.bibleplugin.settings_section, filename, 1) def incrementProgressBar(self, status_text): log.debug(u'IncrementBar %s', status_text) diff --git a/openlp/plugins/bibles/lib/biblestab.py b/openlp/plugins/bibles/lib/biblestab.py index 3965a0933..80e0cef5e 100644 --- a/openlp/plugins/bibles/lib/biblestab.py +++ b/openlp/plugins/bibles/lib/biblestab.py @@ -150,7 +150,8 @@ class BiblesTab(SettingsTab): def retranslateUi(self): self.VerseDisplayGroupBox.setTitle(self.trUtf8('Verse Display')) - self.NewChaptersCheckBox.setText(self.trUtf8('Only show new chapter numbers')) + self.NewChaptersCheckBox.setText( + self.trUtf8('Only show new chapter numbers')) self.LayoutStyleLabel.setText(self.trUtf8('Layout Style:')) self.DisplayStyleLabel.setText(self.trUtf8('Display Style:')) self.BibleThemeLabel.setText(self.trUtf8('Bible Theme:')) @@ -188,32 +189,35 @@ class BiblesTab(SettingsTab): def load(self): settings = QtCore.QSettings() + settings.beginGroup(self.settingsSection) self.show_new_chapters = settings.value( - u'bibles/display new chapter', False).toBool() + u'display new chapter', QtCore.QVariant(False)).toBool() self.display_style = settings.value( - u'bibles/display brackets', 0).toInt()[0] + u'display brackets', QtCore.QVariant(0)).toInt()[0] self.layout_style = settings.value( - u'bibles/verse layout style', 0).toInt()[0] + u'verse layout style', QtCore.QVariant(0)).toInt()[0] self.bible_theme = unicode( - settings.value(u'bibles/bible theme', u'').toString()) - self.duel_bibles = settings.value(u'bibles/dual bibles', True).toBool() + settings.value(u'bible theme', QtCore.QVariant(u'')).toString()) + self.duel_bibles = settings.value( + u'dual bibles', QtCore.QVariant(True)).toBool() self.NewChaptersCheckBox.setChecked(self.show_new_chapters) self.DisplayStyleComboBox.setCurrentIndex(self.display_style) self.LayoutStyleComboBox.setCurrentIndex(self.layout_style) self.BibleDualCheckBox.setChecked(self.duel_bibles) + settings.endGroup() def save(self): settings = QtCore.QSettings() - settings.setValue(u'bibles/display new chapter', + settings.beginGroup(self.settingsSection) + settings.setValue(u'display new chapter', QtCore.QVariant(self.show_new_chapters)) - settings.setValue(u'bibles/display brackets', + settings.setValue(u'display brackets', QtCore.QVariant(self.display_style)) - settings.setValue(u'bibles/verse layout style', + settings.setValue(u'verse layout style', QtCore.QVariant(self.layout_style)) - settings.setValue(u'bibles/dual bibles', - QtCore.QVariant(self.duel_bibles)) - settings.setValue(u'bibles/bible theme', - QtCore.QVariant(self.bible_theme)) + settings.setValue(u'dual bibles', QtCore.QVariant(self.duel_bibles)) + settings.setValue(u'bible theme', QtCore.QVariant(self.bible_theme)) + settings.endGroup() def updateThemeList(self, theme_list): """ @@ -229,4 +233,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/db.py b/openlp/plugins/bibles/lib/db.py index 0d2422a8d..c95884693 100644 --- a/openlp/plugins/bibles/lib/db.py +++ b/openlp/plugins/bibles/lib/db.py @@ -74,17 +74,19 @@ class BibleDB(QtCore.QObject): self.db_file = os.path.join(kwargs[u'path'], self.file) log.debug(u'Load bible %s on path %s', self.file, self.db_file) settings = QtCore.QSettings() + settings.beginGroup(u'bibles') db_type = unicode( - settings.value(u'bibles/db type', u'sqlite').toString()) + settings.value(u'db type', QtCore.QVariant(u'sqlite')).toString()) db_url = u'' if db_type == u'sqlite': db_url = u'sqlite:///' + self.db_file else: db_url = u'%s://%s:%s@%s/%s' % (db_type, - unicode(settings.value(u'bibles/db username').toString()), - unicode(settings.value(u'bibles/db password').toString()), - unicode(settings.value(u'bibles/db hostname').toString()), - unicode(settings.value(u'bibles/db database').toString())) + unicode(settings.value(u'db username').toString()), + unicode(settings.value(u'db password').toString()), + unicode(settings.value(u'db hostname').toString()), + unicode(settings.value(u'db database').toString())) + settings.endGroup() self.metadata, self.session = init_models(db_url) self.metadata.create_all(checkfirst=True) if u'file' in kwargs: diff --git a/openlp/plugins/bibles/lib/manager.py b/openlp/plugins/bibles/lib/manager.py index 1f962be90..d8fe3e156 100644 --- a/openlp/plugins/bibles/lib/manager.py +++ b/openlp/plugins/bibles/lib/manager.py @@ -109,11 +109,13 @@ class BibleManager(object): """ log.debug(u'Bible Initialising') self.parent = parent + self.settings_section = u'bibles' self.web = u'Web' self.db_cache = None - self.path = AppLocation.get_section_data_path(u'bibles') + self.path = AppLocation.get_section_data_path(self.settings_section) self.proxy_name = unicode( - QtCore.QSettings().value(u'bibles/proxy name', u'').toString()) + QtCore.QSettings().value(self.settings_section + u'/proxy name', + QtCore.QVariant(u'')).toString()) self.suffix = u'.sqlite' self.import_wizard = None self.reload_bibles() @@ -126,7 +128,7 @@ class BibleManager(object): BibleDB class. """ log.debug(u'Reload bibles') - files = SettingsManager.get_files(u'bibles', self.suffix) + files = SettingsManager.get_files(self.settings_section, self.suffix) log.debug(u'Bible Files %s', files) self.db_cache = {} for filename in files: @@ -137,7 +139,8 @@ class BibleManager(object): # look to see if lazy load bible exists and get create getter. source = self.db_cache[name].get_meta(u'download source') if source: - download_name = self.db_cache[name].get_meta(u'download name').value + download_name = \ + self.db_cache[name].get_meta(u'download name').value meta_proxy = self.db_cache[name].get_meta(u'proxy url') web_bible = HTTPBible(self.parent, path=self.path, file=filename, download_source=source.value, @@ -208,7 +211,8 @@ class BibleManager(object): Returns all the number of verses for a given book and chapterMaxBibleBookVerses """ - log.debug(u'BibleManager.get_verse_count("%s", "%s", %s)', bible, book, chapter) + log.debug(u'BibleManager.get_verse_count("%s", "%s", %s)', + bible, book, chapter) return self.db_cache[bible].get_verse_count(book, chapter) def get_verses(self, bible, versetext): diff --git a/openlp/plugins/bibles/lib/mediaitem.py b/openlp/plugins/bibles/lib/mediaitem.py index afdd89e3e..c448e5066 100644 --- a/openlp/plugins/bibles/lib/mediaitem.py +++ b/openlp/plugins/bibles/lib/mediaitem.py @@ -54,7 +54,7 @@ class BibleMediaItem(MediaManagerItem): def __init__(self, parent, icon, title): self.PluginNameShort = u'Bible' - self.ConfigSection = title + self.SettingsSection = title.lower() self.IconPath = u'songs/song' self.ListViewWithDnD_class = BibleListView self.lastReference = [] @@ -276,7 +276,8 @@ class BibleMediaItem(MediaManagerItem): self.SearchProgress.setObjectName(u'SearchProgress') def configUpdated(self): - if QtCore.QSettings().value(u'bibles/dual bibles', False).toBool(): + if QtCore.QSettings().value(self.SettingsSection + u'/dual bibles', + QtCore.QVariant(False)).toBool(): self.AdvancedSecondBibleLabel.setVisible(True) self.AdvancedSecondBibleComboBox.setVisible(True) self.QuickSecondVersionLabel.setVisible(True) diff --git a/openlp/plugins/custom/lib/customtab.py b/openlp/plugins/custom/lib/customtab.py index 5470c64d0..2b6cedfbf 100644 --- a/openlp/plugins/custom/lib/customtab.py +++ b/openlp/plugins/custom/lib/customtab.py @@ -67,9 +67,10 @@ class CustomTab(SettingsTab): def load(self): self.displayFooter = QtCore.QSettings().value( - u'custom/display footer', True).toBool() + self.settingsSection + u'/display footer', + QtCore.QVariant(True)).toBool() self.DisplayFooterCheckBox.setChecked(self.displayFooter) def save(self): - QtCore.QSettings().setValue( - u'custom/display footer', QtCore.QVariant(self.displayFooter)) + QtCore.QSettings().setValue(self.settingsSection + u'/display footer', + QtCore.QVariant(self.displayFooter)) diff --git a/openlp/plugins/custom/lib/manager.py b/openlp/plugins/custom/lib/manager.py index c9555e63a..9e781f560 100644 --- a/openlp/plugins/custom/lib/manager.py +++ b/openlp/plugins/custom/lib/manager.py @@ -46,21 +46,22 @@ class CustomManager(): """ log.debug(u'Custom Initialising') settings = QtCore.QSettings() + settings.beginGroup(u'custom') self.db_url = u'' db_type = unicode( - settings.value(u'custom/db type', u'sqlite').toString()) + settings.value(u'db type', QtCore.QVariant(u'sqlite')).toString()) if db_type == u'sqlite': self.db_url = u'sqlite:///%s/custom.sqlite' % \ AppLocation.get_section_data_path(u'custom') else: self.db_url = u'%s://%s:%s@%s/%s' % (db_type, - unicode(settings.value(u'custom/db username').toString()), - unicode(settings.value(u'custom/db password').toString()), - unicode(settings.value(u'custom/db hostname').toString()), - unicode(settings.value(u'custom/db database').toString())) + unicode(settings.value(u'db username').toString()), + unicode(settings.value(u'db password').toString()), + unicode(settings.value(u'db hostname').toString()), + unicode(settings.value(u'db database').toString())) self.session = init_models(self.db_url) metadata.create_all(checkfirst=True) - + settings.endGroup() log.debug(u'Custom Initialised') def get_all_slides(self): diff --git a/openlp/plugins/custom/lib/mediaitem.py b/openlp/plugins/custom/lib/mediaitem.py index aa82eb452..c1f4ff1e6 100644 --- a/openlp/plugins/custom/lib/mediaitem.py +++ b/openlp/plugins/custom/lib/mediaitem.py @@ -45,7 +45,7 @@ class CustomMediaItem(MediaManagerItem): def __init__(self, parent, icon, title): self.PluginNameShort = u'Custom' - self.ConfigSection = title + self.SettingsSection = title.lower() self.IconPath = u'custom/custom' # this next is a class, not an instance of a class - it will # be instanced by the base MediaManagerItem @@ -133,7 +133,7 @@ class CustomMediaItem(MediaManagerItem): self.ListView.takeItem(row) def generateSlideData(self, service_item, item=None): - raw_slides =[] + raw_slides = [] raw_footer = [] slide = None theme = None @@ -164,8 +164,8 @@ class CustomMediaItem(MediaManagerItem): service_item.title = title for slide in raw_slides: service_item.add_from_text(slide[:30], slide) - if QtCore.QSettings().value(u'custom/display footer', True).toBool() \ - or credit: + if QtCore.QSettings().value(self.SettingsSection + u'/display footer', + QtCore.QVariant(True)).toBool() or credit: raw_footer.append(title + u' ' + credit) else: raw_footer.append(u'') diff --git a/openlp/plugins/images/lib/imagetab.py b/openlp/plugins/images/lib/imagetab.py index f7bdb3106..346d28b16 100644 --- a/openlp/plugins/images/lib/imagetab.py +++ b/openlp/plugins/images/lib/imagetab.py @@ -72,12 +72,13 @@ class ImageTab(SettingsTab): def load(self): self.loop_delay = QtCore.QSettings().value( - u'images/loop delay', 5).toInt()[0] + self.settingsSection + u'/loop delay', + QtCore.QVariant(5)).toInt()[0] self.TimeoutSpinBox.setValue(self.loop_delay) def save(self): - QtCore.QSettings().setValue( - u'images/loop delay', QtCore.QVariant(self.loop_delay)) + QtCore.QSettings().setValue(self.settingsSection + u'/loop delay', + QtCore.QVariant(self.loop_delay)) Receiver.send_message(u'slidecontroller_live_spin_delay', self.loop_delay) diff --git a/openlp/plugins/images/lib/mediaitem.py b/openlp/plugins/images/lib/mediaitem.py index 7b104136c..32ed5edb6 100644 --- a/openlp/plugins/images/lib/mediaitem.py +++ b/openlp/plugins/images/lib/mediaitem.py @@ -49,7 +49,7 @@ class ImageMediaItem(MediaManagerItem): def __init__(self, parent, icon, title): self.PluginNameShort = u'Image' - self.ConfigSection = title + self.SettingsSection = title.lower() self.IconPath = u'images/image' # this next is a class, not an instance of a class - it will # be instanced by the base MediaManagerItem @@ -61,8 +61,8 @@ class ImageMediaItem(MediaManagerItem): def retranslateUi(self): self.OnNewPrompt = self.trUtf8('Select Image(s)') - self.OnNewFileMasks = \ - self.trUtf8('Images (*.jpg *.jpeg *.gif *.png *.bmp);; All files (*)') + self.OnNewFileMasks = self.trUtf8( + 'Images (*.jpg *.jpeg *.gif *.png *.bmp);; All files (*)') def requiredIcons(self): MediaManagerItem.requiredIcons(self) @@ -78,12 +78,12 @@ class ImageMediaItem(MediaManagerItem): QtGui.QAbstractItemView.ExtendedSelection) self.ListView.setIconSize(QtCore.QSize(88,50)) self.servicePath = os.path.join( - AppLocation.get_section_data_path(self.ConfigSection), + AppLocation.get_section_data_path(self.SettingsSection), u'.thumbnails') if not os.path.exists(self.servicePath): os.mkdir(self.servicePath) self.loadList(SettingsManager.load_list( - self.ConfigSection, self.ConfigSection)) + self.SettingsSection, self.SettingsSection)) def addListViewToToolBar(self): MediaManagerItem.addListViewToToolBar(self) @@ -122,7 +122,8 @@ class ImageMediaItem(MediaManagerItem): #if not present do not worry pass self.ListView.takeItem(item.row()) - SettingsManager.set_list(self.ConfigSection, self.getFileList()) + SettingsManager.set_list( + self.SettingsSection, self.getFileList()) def loadList(self, list): for file in list: diff --git a/openlp/plugins/media/lib/mediaitem.py b/openlp/plugins/media/lib/mediaitem.py index 9342708f4..f594fe54c 100644 --- a/openlp/plugins/media/lib/mediaitem.py +++ b/openlp/plugins/media/lib/mediaitem.py @@ -47,7 +47,7 @@ class MediaMediaItem(MediaManagerItem): def __init__(self, parent, icon, title): self.PluginNameShort = u'Media' self.IconPath = u'images/image' - self.ConfigSection = title + self.SettingsSection = title.lower() # this next is a class, not an instance of a class - it will # be instanced by the base MediaManagerItem self.ListViewWithDnD_class = MediaListView @@ -90,14 +90,14 @@ class MediaMediaItem(MediaManagerItem): QtGui.QAbstractItemView.ExtendedSelection) self.ListView.setIconSize(QtCore.QSize(88,50)) self.loadList(SettingsManager.load_list( - self.ConfigSection, self.ConfigSection)) + self.SettingsSection, self.SettingsSection)) def onDeleteClick(self): item = self.ListView.currentItem() if item: row = self.ListView.row(item) self.ListView.takeItem(row) - SettingsManager.set_list(self.ConfigSection, self.getFileList()) + SettingsManager.set_list(self.SettingsSection, self.getFileList()) def loadList(self, list): for file in list: @@ -106,4 +106,4 @@ class MediaMediaItem(MediaManagerItem): img = QtGui.QPixmap(u':/media/media_video.png').toImage() item_name.setIcon(build_icon(img)) item_name.setData(QtCore.Qt.UserRole, QtCore.QVariant(file)) - self.ListView.addItem(item_name) \ No newline at end of file + self.ListView.addItem(item_name) diff --git a/openlp/plugins/presentations/lib/mediaitem.py b/openlp/plugins/presentations/lib/mediaitem.py index 900af71b6..f547f0633 100644 --- a/openlp/plugins/presentations/lib/mediaitem.py +++ b/openlp/plugins/presentations/lib/mediaitem.py @@ -52,7 +52,7 @@ class PresentationMediaItem(MediaManagerItem): def __init__(self, parent, icon, title, controllers): self.controllers = controllers self.PluginNameShort = u'Presentation' - self.ConfigSection = title + self.SettingsSection = title.lower() self.IconPath = u'presentations/presentation' self.Automatic = u'' # this next is a class, not an instance of a class - it will @@ -107,11 +107,11 @@ class PresentationMediaItem(MediaManagerItem): def initialise(self): self.servicePath = os.path.join( - AppLocation.get_section_data_path(self.ConfigSection), + AppLocation.get_section_data_path(self.SettingsSection), u'thumbnails') if not os.path.exists(self.servicePath): os.mkdir(self.servicePath) - list = SettingsManager.load_list(self.ConfigSection, u'presentations') + list = SettingsManager.load_list(self.SettingsSection, u'presentations') self.loadList(list) for item in self.controllers: #load the drop down selection @@ -139,11 +139,11 @@ class PresentationMediaItem(MediaManagerItem): icon = None for controller in self.controllers: thumbPath = os.path.join( - AppLocation.get_section_data_path(self.ConfigSection), + AppLocation.get_section_data_path(self.SettingsSection), u'thumbnails', controller, filename) thumb = os.path.join(thumbPath, u'slide1.png') preview = os.path.join( - AppLocation.get_section_data_path(self.ConfigSection), + AppLocation.get_section_data_path(self.SettingsSection), controller, u'thumbnails', filename, u'slide1.png') if os.path.exists(preview): if os.path.exists(thumb): @@ -167,7 +167,7 @@ class PresentationMediaItem(MediaManagerItem): if item: row = self.ListView.row(item) self.ListView.takeItem(row) - SettingsManager.set_list(self.ConfigSection, self.getFileList()) + SettingsManager.set_list(self.SettingsSection, self.getFileList()) filepath = unicode((item.data(QtCore.Qt.UserRole)).toString()) #not sure of this has errors #John please can you look at . diff --git a/openlp/plugins/presentations/lib/presentationcontroller.py b/openlp/plugins/presentations/lib/presentationcontroller.py index 8e5d797da..fa6e9474d 100644 --- a/openlp/plugins/presentations/lib/presentationcontroller.py +++ b/openlp/plugins/presentations/lib/presentationcontroller.py @@ -100,14 +100,16 @@ class PresentationController(object): self.docs = [] self.plugin = plugin self.name = name + self.settings_section = self.plugin.settings_section self.available = self.check_available() if self.available: - self.enabled = QtCore.QSettings().value(u'presentations/' + name, + self.enabled = QtCore.QSettings().value( + self.settings_section + u'/' + name, QtCore.Qt.Unchecked).toInt()[0] == QtCore.Qt.Checked else: self.enabled = False self.thumbnailroot = os.path.join( - AppLocation.get_section_data_path(u'presentations'), + AppLocation.get_section_data_path(self.settings_section), name, u'thumbnails') self.thumbnailprefix = u'slide' if not os.path.isdir(self.thumbnailroot): diff --git a/openlp/plugins/presentations/lib/presentationtab.py b/openlp/plugins/presentations/lib/presentationtab.py index 4c1b41813..ebcbb3d7b 100644 --- a/openlp/plugins/presentations/lib/presentationtab.py +++ b/openlp/plugins/presentations/lib/presentationtab.py @@ -101,11 +101,13 @@ class PresentationTab(SettingsTab): if controller.available: checkbox = self.PresenterCheckboxes[controller.name] checkbox.setChecked(QtCore.QSettings().value( - u'presentations/' + controller.name, 0).toInt()[0]) + self.settingsSection + u'/' + controller.name, + QtCore.QVariant(0)).toInt()[0]) def save(self): for key in self.controllers: controller = self.controllers[key] checkbox = self.PresenterCheckboxes[controller.name] - QtCore.QSettings().setValue(u'presentations/' + controller.name, + QtCore.QSettings().setValue( + self.settingsSection + u'/' + controller.name, QtCore.QVariant(checkbox.checkState())) diff --git a/openlp/plugins/remotes/lib/remotetab.py b/openlp/plugins/remotes/lib/remotetab.py index 7096ee302..abdda065f 100644 --- a/openlp/plugins/remotes/lib/remotetab.py +++ b/openlp/plugins/remotes/lib/remotetab.py @@ -57,8 +57,9 @@ class RemoteTab(SettingsTab): def load(self): self.RemotePortSpinBox.setValue( - QtCore.QSettings().value(u'remotes/remote port', 4316).toInt()[0]) + QtCore.QSettings().value(self.settingsSection + u'/remote port', + QtCore.QVariant(4316)).toInt()[0]) def save(self): - QtCore.QSettings().setValue(u'remotes/remote port', + QtCore.QSettings().setValue(self.settingsSection + u'/remote port', QtCore.QVariant(self.RemotePortSpinBox.value())) diff --git a/openlp/plugins/remotes/remoteplugin.py b/openlp/plugins/remotes/remoteplugin.py index 3ceb6d1f8..8bc91c824 100644 --- a/openlp/plugins/remotes/remoteplugin.py +++ b/openlp/plugins/remotes/remoteplugin.py @@ -46,7 +46,8 @@ class RemotesPlugin(Plugin): self.insert_toolbox_item() self.server = QtNetwork.QUdpSocket() self.server.bind( - QtCore.QSettings().value(u'remotes/remote port', 4316).toInt()[0]) + QtCore.QSettings().value(self.settings_section + u'/remote port', + QtCore.QVariant(4316)).toInt()[0]) QtCore.QObject.connect(self.server, QtCore.SIGNAL(u'readyRead()'), self.readData) diff --git a/openlp/plugins/songs/lib/manager.py b/openlp/plugins/songs/lib/manager.py index 5264a58ed..ff9231fe2 100644 --- a/openlp/plugins/songs/lib/manager.py +++ b/openlp/plugins/songs/lib/manager.py @@ -47,6 +47,7 @@ class SongManager(): """ log.debug(u'Song Initialising') settings = QtCore.QSettings() + settings.beginGroup(u'songs') self.db_url = u'' db_type = unicode( settings.value(u'songs/db type', u'sqlite').toString()) @@ -54,17 +55,18 @@ class SongManager(): self.db_url = u'sqlite:///%s/songs.sqlite' % \ AppLocation.get_section_data_path(u'songs') else: - self.db_url = db_type + 'u://' + \ + self.db_url = u'%s://%s:%s@%s/%s' % (db_type, unicode(settings.value( - u'songs/db username', u'').toString()) + u':' + \ + u'db username', QtCore.QVariant(u'')).toString()), unicode(settings.value( - u'songs/db password', u'').toString()) + u'@' + \ + u'db password', QtCore.QVariant(u'')).toString()), unicode(settings.value( - u'songs/db hostname', u'').toString()) + u'/' + \ + u'db hostname', QtCore.QVariant(u'')).toString()), unicode(settings.value( - u'songs/db database', u'').toString()) + u'db database', QtCore.QVariant(u'')).toString())) self.session = init_models(self.db_url) metadata.create_all(checkfirst=True) + settings.endGroup() log.debug(u'Song Initialised') def get_songs(self): diff --git a/openlp/plugins/songs/lib/mediaitem.py b/openlp/plugins/songs/lib/mediaitem.py index 24ef71e81..84af7e6d0 100644 --- a/openlp/plugins/songs/lib/mediaitem.py +++ b/openlp/plugins/songs/lib/mediaitem.py @@ -46,7 +46,7 @@ class SongMediaItem(MediaManagerItem): def __init__(self, parent, icon, title): self.PluginNameShort = u'Song' - self.ConfigSection = title + self.SettingsSection = title.lower() self.IconPath = u'songs/song' self.ListViewWithDnD_class = SongListView MediaManagerItem.__init__(self, parent, icon, title) @@ -134,7 +134,8 @@ class SongMediaItem(MediaManagerItem): def configUpdated(self): self.searchAsYouType = QtCore.QSettings().value( - u'songs/search as type', u'False').toBool() + self.SettingsSection + u'/search as type', + QtCore.QVariant(u'False')).toBool() def retranslateUi(self): self.SearchTextLabel.setText(self.trUtf8('Search:')) diff --git a/openlp/plugins/songs/lib/songstab.py b/openlp/plugins/songs/lib/songstab.py index 8b9f6804d..38bdd791d 100644 --- a/openlp/plugins/songs/lib/songstab.py +++ b/openlp/plugins/songs/lib/songstab.py @@ -81,15 +81,18 @@ class SongsTab(SettingsTab): def load(self): settings = QtCore.QSettings() + settings.beginGroup(self.settingsSection) self.song_search = settings.value( - u'songs/search as type', False).toBool() - self.song_bar = settings.value(u'songs/display songbar', True).toBool() + u'search as type', QtCore.QVariant(False)).toBool() + self.song_bar = settings.value( + u'display songbar', QtCore.QVariant(True)).toBool() self.SearchAsTypeCheckBox.setChecked(self.song_search) self.SongBarActiveCheckBox.setChecked(self.song_bar) + settings.endGroup() def save(self): settings = QtCore.QSettings() - settings.setValue( - u'songs/search as type', QtCore.QVariant(self.song_search)) - settings.setValue( - u'songs/display songbar', QtCore.QVariant(self.song_bar)) + settings.beginGroup(self.settingsSection) + settings.setValue(u'search as type', QtCore.QVariant(self.song_search)) + settings.setValue(u'display songbar', QtCore.QVariant(self.song_bar)) + settings.endGroup() diff --git a/openlp/plugins/songusage/forms/songusagedetailform.py b/openlp/plugins/songusage/forms/songusagedetailform.py index e4ec80d58..97359807f 100644 --- a/openlp/plugins/songusage/forms/songusagedetailform.py +++ b/openlp/plugins/songusage/forms/songusagedetailform.py @@ -45,6 +45,7 @@ class SongUsageDetailForm(QtGui.QDialog, Ui_SongUsageDetailDialog): """ QtGui.QDialog.__init__(self, None) self.parent = parent + self.settingsSection = u'songusage' self.setupUi(self) def initialise(self): @@ -55,15 +56,16 @@ class SongUsageDetailForm(QtGui.QDialog, Ui_SongUsageDetailDialog): fromDate = QtCore.QDate(year - 1, 9, 1) self.FromDate.setSelectedDate(fromDate) self.ToDate.setSelectedDate(toDate) - self.FileLineEdit.setText(SettingsManager.get_last_dir(u'songusage', 1)) + self.FileLineEdit.setText( + SettingsManager.get_last_dir(self.settingsSection, 1)) def defineOutputLocation(self): path = QtGui.QFileDialog.getExistingDirectory(self, self.trUtf8('Output File Location'), - SettingsManager.get_last_dir(u'songusage', 1)) + SettingsManager.get_last_dir(self.settingsSection, 1)) path = unicode(path) if path != u'': - SettingsManager.set_last_dir(u'songusage', path, 1) + SettingsManager.set_last_dir(self.settingsSection, path, 1) self.FileLineEdit.setText(path) def accept(self): @@ -88,4 +90,3 @@ class SongUsageDetailForm(QtGui.QDialog, Ui_SongUsageDetailDialog): finally: if file: file.close() - diff --git a/openlp/plugins/songusage/lib/manager.py b/openlp/plugins/songusage/lib/manager.py index d307f9dd5..e8816b552 100644 --- a/openlp/plugins/songusage/lib/manager.py +++ b/openlp/plugins/songusage/lib/manager.py @@ -45,27 +45,28 @@ class SongUsageManager(): Creates the connection to the database, and creates the tables if they don't exist. """ - settings = QtCore.QSettings() log.debug(u'SongUsage Initialising') + settings = QtCore.QSettings() + settings.beginGroup(u'songusage') self.db_url = u'' db_type = unicode( - settings.value(u'songusage/db type', u'sqlite').toString()) + settings.value(u'db type', QtCore.QVariant(u'sqlite')).toString()) if db_type == u'sqlite': self.db_url = u'sqlite:///%s/songusage.sqlite' % \ AppLocation.get_section_data_path(u'songusage') else: self.db_url = u'%s://%s:%s@%s/%s' % (db_type, - unicode( - settings.value(u'songusage/db username', u'').toString()), - unicode( - settings.value(u'songusage/db password', u'').toString()), - unicode( - settings.value(u'songusage/db hostname', u'').toString()), - unicode( - settings.value(u'songusage/db database', u'').toString())) + unicode(settings.value(u'db username', + QtCore.QVariant(u'')).toString()), + unicode(settings.value(u'db password', + QtCore.QVariant(u'')).toString()), + unicode(settings.value(u'db hostname', + QtCore.QVariant(u'')).toString()), + unicode(settings.value(u'db database', + QtCore.QVariant(u'')).toString())) self.session = init_models(self.db_url) metadata.create_all(checkfirst=True) - + settings.endGroup() log.debug(u'SongUsage Initialised') def get_all_songusage(self, start_date, end_date): diff --git a/openlp/plugins/songusage/songusageplugin.py b/openlp/plugins/songusage/songusageplugin.py index c654477e0..da557e81e 100644 --- a/openlp/plugins/songusage/songusageplugin.py +++ b/openlp/plugins/songusage/songusageplugin.py @@ -111,7 +111,8 @@ class SongUsagePlugin(Plugin): QtCore.SIGNAL(u'slidecontroller_live_started'), self.onReceiveSongUsage) self.SongUsageActive = QtCore.QSettings().value( - u'songusage/active', False).toBool() + self.settings_section + u'/active', + QtCore.QVariant(False)).toBool() self.SongUsageStatus.setChecked(self.SongUsageActive) if self.songusagemanager is None: self.songusagemanager = SongUsageManager() @@ -127,8 +128,8 @@ class SongUsagePlugin(Plugin): def toggleSongUsageState(self): self.SongUsageActive = not self.SongUsageActive - QtCore.QSettings().setValue( - u'songusage/active', QtCore.QVariant(self.SongUsageActive)) + QtCore.QSettings().setValue(self.settings_section + u'/active', + QtCore.QVariant(self.SongUsageActive)) def onReceiveSongUsage(self, items): """ From 17ee4f00facaec1fa6d057a7fae0680ecdb59723 Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Wed, 28 Apr 2010 17:41:04 +0100 Subject: [PATCH 37/63] remove plugin --- openlp/core/ui/screen.py | 4 - openlp/plugins/display/__init__.py | 24 ---- openlp/plugins/display/displaysplugin.py | 122 ------------------ openlp/plugins/display/forms/__init__.py | 26 ---- openlp/plugins/display/forms/displaydialog.py | 82 ------------ openlp/plugins/display/forms/displayform.py | 61 --------- 6 files changed, 319 deletions(-) delete mode 100644 openlp/plugins/display/__init__.py delete mode 100644 openlp/plugins/display/displaysplugin.py delete mode 100644 openlp/plugins/display/forms/__init__.py delete mode 100644 openlp/plugins/display/forms/displaydialog.py delete mode 100644 openlp/plugins/display/forms/displayform.py diff --git a/openlp/core/ui/screen.py b/openlp/core/ui/screen.py index 0c8679205..19c4e01b5 100644 --- a/openlp/core/ui/screen.py +++ b/openlp/core/ui/screen.py @@ -80,10 +80,6 @@ class ScreenList(object): """ log.debug(u'set_override_display') self.current = copy.deepcopy(self.override) - print self.screen_list - print self.current - self.current[u'primary'] = True - print self.current self.preview = copy.deepcopy(self.current) def reset_current_display(self): diff --git a/openlp/plugins/display/__init__.py b/openlp/plugins/display/__init__.py deleted file mode 100644 index 1a348a0df..000000000 --- a/openlp/plugins/display/__init__.py +++ /dev/null @@ -1,24 +0,0 @@ -# -*- coding: utf-8 -*- -# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4 - -############################################################################### -# OpenLP - Open Source Lyrics Projection # -# --------------------------------------------------------------------------- # -# Copyright (c) 2008-2010 Raoul Snyman # -# Portions copyright (c) 2008-2010 Tim Bentley, Jonathan Corwin, Michael # -# Gorven, Scott Guerrieri, Christian Richter, Maikel Stuivenberg, Martin # -# Thompson, Jon Tibble, Carsten Tinggaard # -# --------------------------------------------------------------------------- # -# 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 # -############################################################################### diff --git a/openlp/plugins/display/displaysplugin.py b/openlp/plugins/display/displaysplugin.py deleted file mode 100644 index d55e1a27b..000000000 --- a/openlp/plugins/display/displaysplugin.py +++ /dev/null @@ -1,122 +0,0 @@ -from openlp.plugins.alerts.forms import AlertsTab, AlertForm# -*- coding: utf-8 -*- -# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4 - -############################################################################### -# OpenLP - Open Source Lyrics Projection # -# --------------------------------------------------------------------------- # -# Copyright (c) 2008-2010 Raoul Snyman # -# Portions copyright (c) 2008-2010 Tim Bentley, Jonathan Corwin, Michael # -# Gorven, Scott Guerrieri, Christian Richter, Maikel Stuivenberg, Martin # -# Thompson, Jon Tibble, Carsten Tinggaard # -# --------------------------------------------------------------------------- # -# 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 datetime import datetime -import logging - -from PyQt4 import QtCore, QtGui - -from openlp.core.lib import Plugin, Receiver, str_to_bool, build_icon -from openlp.plugins.display.forms import DisplayForm - -log = logging.getLogger(__name__) - -class DisplayPlugin(Plugin): - log.info(u'Display Plugin loaded') - - def __init__(self, plugin_helpers): - Plugin.__init__(self, u'Display', u'1.9.1', plugin_helpers) - self.weight = -2 - self.icon = build_icon(u':/media/media_image.png') - - def add_tools_menu_item(self, tools_menu): - """ - Give the Display plugin the opportunity to add items to the - **Tools** menu. - - ``tools_menu`` - The actual **Tools** menu item, so that your actions can - use it as their parent. - """ - log.info(u'add tools menu') - self.toolsMenu = tools_menu - self.DisplayMenu = QtGui.QMenu(tools_menu) - self.DisplayMenu.setObjectName(u'DisplayMenu') - self.DisplayMenu.setTitle(tools_menu.trUtf8('&Override Display')) - #Display Delete - self.DisplayOverride = QtGui.QAction(tools_menu) - self.DisplayOverride.setText( - tools_menu.trUtf8('&Change Display Attributes')) - self.DisplayOverride.setStatusTip( - tools_menu.trUtf8('Amend the display attributes')) - self.DisplayOverride.setObjectName(u'DisplayOverride') - #Display activation - DisplayIcon = build_icon(u':/tools/tools_alert.png') - self.DisplayStatus = QtGui.QAction(tools_menu) - self.DisplayStatus.setIcon(DisplayIcon) - self.DisplayStatus.setCheckable(True) - self.DisplayStatus.setChecked(False) - self.DisplayStatus.setText(tools_menu.trUtf8('Use Display Override')) - self.DisplayStatus.setStatusTip( - tools_menu.trUtf8('Change start/stop using Display Override')) - self.DisplayStatus.setShortcut(u'FX') - self.DisplayStatus.setObjectName(u'DisplayStatus') - #Add Menus together - self.toolsMenu.addAction(self.DisplayMenu.menuAction()) - self.DisplayMenu.addAction(self.DisplayStatus) - self.DisplayMenu.addSeparator() - self.DisplayMenu.addAction(self.DisplayOverride) - # Signals and slots - QtCore.QObject.connect(self.DisplayStatus, - QtCore.SIGNAL(u'visibilityChanged(bool)'), - self.DisplayStatus.setChecked) - QtCore.QObject.connect(self.DisplayStatus, - QtCore.SIGNAL(u'triggered(bool)'), - self.toggleDisplayState) - QtCore.QObject.connect(self.DisplayOverride, - QtCore.SIGNAL(u'triggered()'), self.onDisplayOverride) - self.DisplayMenu.menuAction().setVisible(False) - - def initialise(self): - log.info(u'Display Initialising') - Plugin.initialise(self) - self.DisplayStatus.setChecked(False) - self.screens = self.maindisplay.screens - self.displayform = DisplayForm(self, self.screens) - self.DisplayMenu.menuAction().setVisible(True) - - def finalise(self): - log.info(u'Plugin Finalise') - self.DisplayMenu.menuAction().setVisible(False) - - def toggleDisplayState(self): - log.info(u'toggleDisplayState') - if self.DisplayStatus.isChecked(): - self.screens.set_override_display() - else: - self.screens.reset_current_display() - Receiver.send_message(u'config_screen_changed') - - def onDisplayOverride(self): - self.displayform.initialise() - self.displayform.exec_() - if self.DisplayStatus.isChecked(): - Receiver.send_message(u'config_screen_changed') - - def about(self): - about_text = self.trUtf8('Display Plugin
This plugin ' - 'allows the dimensions of the live display to be changed.\n' - 'These changes are not stored.') - return about_text diff --git a/openlp/plugins/display/forms/__init__.py b/openlp/plugins/display/forms/__init__.py deleted file mode 100644 index e6a60c3a2..000000000 --- a/openlp/plugins/display/forms/__init__.py +++ /dev/null @@ -1,26 +0,0 @@ -# -*- coding: utf-8 -*- -# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4 - -############################################################################### -# OpenLP - Open Source Lyrics Projection # -# --------------------------------------------------------------------------- # -# Copyright (c) 2008-2010 Raoul Snyman # -# Portions copyright (c) 2008-2010 Tim Bentley, Jonathan Corwin, Michael # -# Gorven, Scott Guerrieri, Christian Richter, Maikel Stuivenberg, Martin # -# Thompson, Jon Tibble, Carsten Tinggaard # -# --------------------------------------------------------------------------- # -# 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 displayform import DisplayForm diff --git a/openlp/plugins/display/forms/displaydialog.py b/openlp/plugins/display/forms/displaydialog.py deleted file mode 100644 index 8c145b73f..000000000 --- a/openlp/plugins/display/forms/displaydialog.py +++ /dev/null @@ -1,82 +0,0 @@ -# -*- coding: utf-8 -*- - -# Form implementation generated from reading ui file 'displaydialog.ui' -# -# Created: Sat Apr 24 17:20:48 2010 -# by: PyQt4 UI code generator 4.7.2 -# -# WARNING! All changes made in this file will be lost! - -from PyQt4 import QtCore, QtGui - -class Ui_DisplaysDialog(object): - def setupUi(self, DisplaysDialog): - DisplaysDialog.setObjectName("DisplaysDialog") - DisplaysDialog.resize(327, 224) - self.OkpushButton = QtGui.QPushButton(DisplaysDialog) - self.OkpushButton.setGeometry(QtCore.QRect(210, 200, 97, 24)) - self.OkpushButton.setObjectName("OkpushButton") - self.widget = QtGui.QWidget(DisplaysDialog) - self.widget.setGeometry(QtCore.QRect(10, 0, 301, 191)) - self.widget.setObjectName("widget") - self.verticalLayout = QtGui.QVBoxLayout(self.widget) - self.verticalLayout.setObjectName("verticalLayout") - self.CurrentGroupBox = QtGui.QGroupBox(self.widget) - self.CurrentGroupBox.setObjectName("CurrentGroupBox") - self.layoutWidget = QtGui.QWidget(self.CurrentGroupBox) - self.layoutWidget.setGeometry(QtCore.QRect(20, 30, 261, 17)) - self.layoutWidget.setObjectName("layoutWidget") - self.horizontalLayout = QtGui.QHBoxLayout(self.layoutWidget) - self.horizontalLayout.setObjectName("horizontalLayout") - self.Xpos = QtGui.QLabel(self.layoutWidget) - self.Xpos.setAlignment(QtCore.Qt.AlignCenter) - self.Xpos.setObjectName("Xpos") - self.horizontalLayout.addWidget(self.Xpos) - self.Ypos = QtGui.QLabel(self.layoutWidget) - self.Ypos.setAlignment(QtCore.Qt.AlignCenter) - self.Ypos.setObjectName("Ypos") - self.horizontalLayout.addWidget(self.Ypos) - self.Height = QtGui.QLabel(self.layoutWidget) - self.Height.setAlignment(QtCore.Qt.AlignCenter) - self.Height.setObjectName("Height") - self.horizontalLayout.addWidget(self.Height) - self.Width = QtGui.QLabel(self.layoutWidget) - self.Width.setAlignment(QtCore.Qt.AlignCenter) - self.Width.setObjectName("Width") - self.horizontalLayout.addWidget(self.Width) - self.verticalLayout.addWidget(self.CurrentGroupBox) - self.CurrentGroupBox_2 = QtGui.QGroupBox(self.widget) - self.CurrentGroupBox_2.setObjectName("CurrentGroupBox_2") - self.layoutWidget1 = QtGui.QWidget(self.CurrentGroupBox_2) - self.layoutWidget1.setGeometry(QtCore.QRect(20, 30, 261, 27)) - self.layoutWidget1.setObjectName("layoutWidget1") - self.horizontalLayout_2 = QtGui.QHBoxLayout(self.layoutWidget1) - self.horizontalLayout_2.setObjectName("horizontalLayout_2") - self.XposEdit = QtGui.QLineEdit(self.layoutWidget1) - self.XposEdit.setObjectName("XposEdit") - self.horizontalLayout_2.addWidget(self.XposEdit) - self.YposEdit = QtGui.QLineEdit(self.layoutWidget1) - self.YposEdit.setObjectName("YposEdit") - self.horizontalLayout_2.addWidget(self.YposEdit) - self.HeightEdit = QtGui.QLineEdit(self.layoutWidget1) - self.HeightEdit.setObjectName("HeightEdit") - self.horizontalLayout_2.addWidget(self.HeightEdit) - self.WidthEdit = QtGui.QLineEdit(self.layoutWidget1) - self.WidthEdit.setObjectName("WidthEdit") - self.horizontalLayout_2.addWidget(self.WidthEdit) - self.verticalLayout.addWidget(self.CurrentGroupBox_2) - - self.retranslateUi(DisplaysDialog) - QtCore.QObject.connect(self.OkpushButton, QtCore.SIGNAL("pressed()"), DisplaysDialog.close) - QtCore.QMetaObject.connectSlotsByName(DisplaysDialog) - - def retranslateUi(self, DisplaysDialog): - DisplaysDialog.setWindowTitle(QtGui.QApplication.translate("DisplaysDialog", "Amend Display Settings", None, QtGui.QApplication.UnicodeUTF8)) - self.OkpushButton.setText(QtGui.QApplication.translate("DisplaysDialog", "Ok", None, QtGui.QApplication.UnicodeUTF8)) - self.CurrentGroupBox.setTitle(QtGui.QApplication.translate("DisplaysDialog", "Default Settings", None, QtGui.QApplication.UnicodeUTF8)) - self.Xpos.setText(QtGui.QApplication.translate("DisplaysDialog", "0", None, QtGui.QApplication.UnicodeUTF8)) - self.Ypos.setText(QtGui.QApplication.translate("DisplaysDialog", "0", None, QtGui.QApplication.UnicodeUTF8)) - self.Height.setText(QtGui.QApplication.translate("DisplaysDialog", "0", None, QtGui.QApplication.UnicodeUTF8)) - self.Width.setText(QtGui.QApplication.translate("DisplaysDialog", "0", None, QtGui.QApplication.UnicodeUTF8)) - self.CurrentGroupBox_2.setTitle(QtGui.QApplication.translate("DisplaysDialog", "Amend Settings", None, QtGui.QApplication.UnicodeUTF8)) - diff --git a/openlp/plugins/display/forms/displayform.py b/openlp/plugins/display/forms/displayform.py deleted file mode 100644 index a7fa60b6e..000000000 --- a/openlp/plugins/display/forms/displayform.py +++ /dev/null @@ -1,61 +0,0 @@ -# -*- coding: utf-8 -*- -# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4 - -############################################################################### -# OpenLP - Open Source Lyrics Projection # -# --------------------------------------------------------------------------- # -# Copyright (c) 2008-2010 Raoul Snyman # -# Portions copyright (c) 2008-2010 Tim Bentley, Jonathan Corwin, Michael # -# Gorven, Scott Guerrieri, Christian Richter, Maikel Stuivenberg, Martin # -# Thompson, Jon Tibble, Carsten Tinggaard # -# --------------------------------------------------------------------------- # -# 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 QtGui, QtCore - -from openlp.plugins.alerts.lib.models import AlertItem - -from displaydialog import Ui_DisplaysDialog - -class DisplayForm(QtGui.QDialog, Ui_DisplaysDialog): - """ - Class documentation goes here. - """ - def __init__(self, parent, screens): - """ - Constructor - """ - self.parent = parent - self.screens = screens - self.item_id = None - QtGui.QDialog.__init__(self, None) - self.setupUi(self) - - def initialise(self): - xpos = int(self.config.get_config(u'x position', unicode(self.screens.current[u'size'].x()))) - self.Xpos.setText(xpos) - self.Ypos.setText(unicode(self.screens.current[u'size'].y())) - self.Height.setText(unicode(self.screens.current[u'size'].height())) - self.Width.setText(unicode(self.screens.current[u'size'].width())) - self.XposEdit.setText(unicode(self.screens.override[u'size'].x())) - self.YposEdit.setText(unicode(self.screens.override[u'size'].y())) - self.HeightEdit.setText(unicode(self.screens.override[u'size'].height())) - self.WidthEdit.setText(unicode(self.screens.override[u'size'].width())) - - def close(self): - self.screens.override[u'size'] = QtCore.QRect(int(self.XposEdit.text()),\ - int(self.YposEdit.text()), int(self.WidthEdit.text()),\ - int(self.HeightEdit.text())) - return QtGui.QDialog.close(self) From d19d3eb213e60a417fec21b0b7adb30b60f450df Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Wed, 28 Apr 2010 18:00:05 +0100 Subject: [PATCH 38/63] Fix video display --- openlp/core/ui/maindisplay.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/openlp/core/ui/maindisplay.py b/openlp/core/ui/maindisplay.py index 85db0ed12..319a7da92 100644 --- a/openlp/core/ui/maindisplay.py +++ b/openlp/core/ui/maindisplay.py @@ -335,7 +335,7 @@ class VideoDisplay(Phonon.VideoWidget): self.audioObject = Phonon.AudioOutput(Phonon.VideoCategory) Phonon.createPath(self.mediaObject, self) Phonon.createPath(self.mediaObject, self.audioObject) - self.setWindowFlags(QtCore.Qt.WindowStaysOnTopHint \ + self.setWindowFlags(QtCore.Qt.WindowStaysOnBottomHint \ | QtCore.Qt.FramelessWindowHint | QtCore.Qt.Dialog) QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'videodisplay_start'), self.onMediaQueue) @@ -347,6 +347,7 @@ class VideoDisplay(Phonon.VideoWidget): QtCore.SIGNAL(u'videodisplay_stop'), self.onMediaStop) QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'config_updated'), self.setup) + self.setVisible(False) def keyPressEvent(self, event): if type(event) == QtGui.QKeyEvent: @@ -364,12 +365,11 @@ class VideoDisplay(Phonon.VideoWidget): """ log.debug(u'VideoDisplay Setup %s for %s ' %(self.screens, self.screens.monitor_number)) - self.setVisible(False) self.screen = self.screens.current #Sort out screen locations and sizes self.setGeometry(self.screen[u'size']) # To display or not to display? - if not self.screen[u'primary']: + if not self.screen[u'primary'] and self.isVisible(): self.showFullScreen() self.primary = False else: @@ -403,3 +403,4 @@ class VideoDisplay(Phonon.VideoWidget): log.debug(u'VideoDisplay Reached end of media playlist') self.mediaObject.clearQueue() self.setVisible(False) + From 92ef8471b03a69a0204bc1cc9029af1d604ffc96 Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Wed, 28 Apr 2010 19:17:51 +0100 Subject: [PATCH 39/63] Add new tab for display sizing --- openlp/core/ui/displaytab.py | 235 ++++++++++++++++++++++++++++++++++ resources/forms/displaytab.py | 150 ++++++++++++++++++++++ 2 files changed, 385 insertions(+) create mode 100644 openlp/core/ui/displaytab.py create mode 100644 resources/forms/displaytab.py diff --git a/openlp/core/ui/displaytab.py b/openlp/core/ui/displaytab.py new file mode 100644 index 000000000..38a0baa91 --- /dev/null +++ b/openlp/core/ui/displaytab.py @@ -0,0 +1,235 @@ +# -*- coding: utf-8 -*- +# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4 + +############################################################################### +# OpenLP - Open Source Lyrics Projection # +# --------------------------------------------------------------------------- # +# Copyright (c) 2008-2010 Raoul Snyman # +# Portions copyright (c) 2008-2010 Tim Bentley, Jonathan Corwin, Michael # +# Gorven, Scott Guerrieri, Christian Richter, Maikel Stuivenberg, Martin # +# Thompson, Jon Tibble, Carsten Tinggaard # +# --------------------------------------------------------------------------- # +# 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 QtGui, QtCore + +from openlp.core.lib import SettingsTab, Receiver + +class DisplayTab(SettingsTab): + """ + Class documentation goes here. + """ + def __init__(self, screens): + """ + Constructor + """ + self.screens = screens + SettingsTab.__init__(self, u'Display') + + def setupUi(self): + self.tabTitleVisible = self.trUtf8('Displays') + self.layoutWidget = QtGui.QWidget(self) + self.layoutWidget.setGeometry(QtCore.QRect(0, 40, 241, 79)) + self.layoutWidget.setObjectName("layoutWidget") + self.verticalLayout = QtGui.QVBoxLayout(self.layoutWidget) + self.verticalLayout.setObjectName("verticalLayout") + self.CurrentGroupBox = QtGui.QGroupBox(self.layoutWidget) + self.CurrentGroupBox.setObjectName("CurrentGroupBox") + self.horizontalLayout = QtGui.QHBoxLayout(self.CurrentGroupBox) + self.horizontalLayout.setObjectName("horizontalLayout") + self.verticalLayout_6 = QtGui.QVBoxLayout() + self.verticalLayout_6.setObjectName("verticalLayout_6") + self.XLabel = QtGui.QLabel(self.CurrentGroupBox) + self.XLabel.setAlignment(QtCore.Qt.AlignCenter) + self.XLabel.setObjectName("XLabel") + self.verticalLayout_6.addWidget(self.XLabel) + self.Xpos = QtGui.QLabel(self.CurrentGroupBox) + self.Xpos.setAlignment(QtCore.Qt.AlignCenter) + self.Xpos.setObjectName("Xpos") + self.verticalLayout_6.addWidget(self.Xpos) + self.horizontalLayout.addLayout(self.verticalLayout_6) + self.verticalLayout_7 = QtGui.QVBoxLayout() + self.verticalLayout_7.setObjectName("verticalLayout_7") + self.YLabel = QtGui.QLabel(self.CurrentGroupBox) + self.YLabel.setAlignment(QtCore.Qt.AlignCenter) + self.YLabel.setObjectName("YLabel") + self.verticalLayout_7.addWidget(self.YLabel) + self.Ypos = QtGui.QLabel(self.CurrentGroupBox) + self.Ypos.setAlignment(QtCore.Qt.AlignCenter) + self.Ypos.setObjectName("Ypos") + self.verticalLayout_7.addWidget(self.Ypos) + self.horizontalLayout.addLayout(self.verticalLayout_7) + self.verticalLayout_9 = QtGui.QVBoxLayout() + self.verticalLayout_9.setObjectName("verticalLayout_9") + self.HeightLabel = QtGui.QLabel(self.CurrentGroupBox) + self.HeightLabel.setMaximumSize(QtCore.QSize(100, 16777215)) + self.HeightLabel.setAlignment(QtCore.Qt.AlignCenter) + self.HeightLabel.setObjectName("HeightLabel") + self.verticalLayout_9.addWidget(self.HeightLabel) + self.Height = QtGui.QLabel(self.CurrentGroupBox) + self.Height.setAlignment(QtCore.Qt.AlignCenter) + self.Height.setObjectName("Height") + self.verticalLayout_9.addWidget(self.Height) + self.horizontalLayout.addLayout(self.verticalLayout_9) + self.verticalLayout_8 = QtGui.QVBoxLayout() + self.verticalLayout_8.setObjectName("verticalLayout_8") + self.WidthLabel = QtGui.QLabel(self.CurrentGroupBox) + self.WidthLabel.setAlignment(QtCore.Qt.AlignCenter) + self.WidthLabel.setObjectName("WidthLabel") + self.verticalLayout_8.addWidget(self.WidthLabel) + self.Width = QtGui.QLabel(self.CurrentGroupBox) + self.Width.setAlignment(QtCore.Qt.AlignCenter) + self.Width.setObjectName("Width") + self.verticalLayout_8.addWidget(self.Width) + self.horizontalLayout.addLayout(self.verticalLayout_8) + self.verticalLayout.addWidget(self.CurrentGroupBox) + self.CurrentGroupBox_2 = QtGui.QGroupBox(self) + self.CurrentGroupBox_2.setGeometry(QtCore.QRect(0, 130, 248, 87)) + self.CurrentGroupBox_2.setMaximumSize(QtCore.QSize(500, 16777215)) + self.CurrentGroupBox_2.setObjectName("CurrentGroupBox_2") + self.horizontalLayout_2 = QtGui.QHBoxLayout(self.CurrentGroupBox_2) + self.horizontalLayout_2.setObjectName("horizontalLayout_2") + self.verticalLayout_2 = QtGui.QVBoxLayout() + self.verticalLayout_2.setObjectName("verticalLayout_2") + self.XAmendLabel = QtGui.QLabel(self.CurrentGroupBox_2) + self.XAmendLabel.setAlignment(QtCore.Qt.AlignCenter) + self.XAmendLabel.setObjectName("XAmendLabel") + self.verticalLayout_2.addWidget(self.XAmendLabel) + self.XposEdit = QtGui.QLineEdit(self.CurrentGroupBox_2) + self.XposEdit.setMaximumSize(QtCore.QSize(50, 16777215)) + self.XposEdit.setMaxLength(4) + self.XposEdit.setObjectName("XposEdit") + self.verticalLayout_2.addWidget(self.XposEdit) + self.horizontalLayout_2.addLayout(self.verticalLayout_2) + self.verticalLayout_3 = QtGui.QVBoxLayout() + self.verticalLayout_3.setObjectName("verticalLayout_3") + self.YAmendLabel = QtGui.QLabel(self.CurrentGroupBox_2) + self.YAmendLabel.setAlignment(QtCore.Qt.AlignCenter) + self.YAmendLabel.setObjectName("YAmendLabel") + self.verticalLayout_3.addWidget(self.YAmendLabel) + self.YposEdit = QtGui.QLineEdit(self.CurrentGroupBox_2) + self.YposEdit.setMaximumSize(QtCore.QSize(50, 16777215)) + self.YposEdit.setMaxLength(4) + self.YposEdit.setObjectName("YposEdit") + self.verticalLayout_3.addWidget(self.YposEdit) + self.horizontalLayout_2.addLayout(self.verticalLayout_3) + self.verticalLayout_4 = QtGui.QVBoxLayout() + self.verticalLayout_4.setObjectName("verticalLayout_4") + self.HeightAmendLabel = QtGui.QLabel(self.CurrentGroupBox_2) + self.HeightAmendLabel.setAlignment(QtCore.Qt.AlignCenter) + self.HeightAmendLabel.setObjectName("HeightAmendLabel") + self.verticalLayout_4.addWidget(self.HeightAmendLabel) + self.HeightEdit = QtGui.QLineEdit(self.CurrentGroupBox_2) + self.HeightEdit.setMaximumSize(QtCore.QSize(50, 16777215)) + self.HeightEdit.setMaxLength(4) + self.HeightEdit.setObjectName("HeightEdit") + self.verticalLayout_4.addWidget(self.HeightEdit) + self.horizontalLayout_2.addLayout(self.verticalLayout_4) + self.verticalLayout_5 = QtGui.QVBoxLayout() + self.verticalLayout_5.setSizeConstraint(QtGui.QLayout.SetMinimumSize) + self.verticalLayout_5.setObjectName("verticalLayout_5") + self.WidthAmendLabel = QtGui.QLabel(self.CurrentGroupBox_2) + self.WidthAmendLabel.setMaximumSize(QtCore.QSize(100, 16777215)) + self.WidthAmendLabel.setAlignment(QtCore.Qt.AlignCenter) + self.WidthAmendLabel.setObjectName("WidthAmendLabel") + self.verticalLayout_5.addWidget(self.WidthAmendLabel) + self.WidthEdit = QtGui.QLineEdit(self.CurrentGroupBox_2) + self.WidthEdit.setMaximumSize(QtCore.QSize(60, 16777215)) + self.WidthEdit.setObjectName("WidthEdit") + self.verticalLayout_5.addWidget(self.WidthEdit) + self.horizontalLayout_2.addLayout(self.verticalLayout_5) + self.OverrideCheckBox = QtGui.QCheckBox(self) + self.OverrideCheckBox.setGeometry(QtCore.QRect(0, 10, 191, 23)) + self.OverrideCheckBox.setObjectName("OverrideCheckBox") + QtCore.QMetaObject.connectSlotsByName(self) + QtCore.QObject.connect(self.OverrideCheckBox, + QtCore.SIGNAL(u'stateChanged(int)'), + self.onOverrideCheckBoxChanged) + + def retranslateUi(self): + self.setWindowTitle(QtGui.QApplication.translate("self", "Amend Display Settings", None, QtGui.QApplication.UnicodeUTF8)) + self.CurrentGroupBox.setTitle(QtGui.QApplication.translate("self", "Default Settings", None, QtGui.QApplication.UnicodeUTF8)) + self.XLabel.setText(QtGui.QApplication.translate("self", "X", None, QtGui.QApplication.UnicodeUTF8)) + self.Xpos.setText(QtGui.QApplication.translate("self", "0", None, QtGui.QApplication.UnicodeUTF8)) + self.YLabel.setText(QtGui.QApplication.translate("self", "Y", None, QtGui.QApplication.UnicodeUTF8)) + self.Ypos.setText(QtGui.QApplication.translate("self", "0", None, QtGui.QApplication.UnicodeUTF8)) + self.HeightLabel.setText(QtGui.QApplication.translate("self", "Height", None, QtGui.QApplication.UnicodeUTF8)) + self.Height.setText(QtGui.QApplication.translate("self", "0", None, QtGui.QApplication.UnicodeUTF8)) + self.WidthLabel.setText(QtGui.QApplication.translate("self", "Width", None, QtGui.QApplication.UnicodeUTF8)) + self.Width.setText(QtGui.QApplication.translate("self", "0", None, QtGui.QApplication.UnicodeUTF8)) + self.CurrentGroupBox_2.setTitle(QtGui.QApplication.translate("self", "Amend Settings", None, QtGui.QApplication.UnicodeUTF8)) + self.XAmendLabel.setText(QtGui.QApplication.translate("self", "X", None, QtGui.QApplication.UnicodeUTF8)) + self.YAmendLabel.setText(QtGui.QApplication.translate("self", "Y", None, QtGui.QApplication.UnicodeUTF8)) + self.HeightAmendLabel.setText(QtGui.QApplication.translate("self", "Height", None, QtGui.QApplication.UnicodeUTF8)) + self.WidthAmendLabel.setText(QtGui.QApplication.translate("self", "Width", None, QtGui.QApplication.UnicodeUTF8)) + self.OverrideCheckBox.setText(QtGui.QApplication.translate("self", "Override Output Display", None, QtGui.QApplication.UnicodeUTF8)) + + def load(self): + settings = QtCore.QSettings() + settings.beginGroup(self.settingsSection) + self.Xpos.setText(unicode(self.screens.current[u'size'].x())) + self.Ypos.setText(unicode(self.screens.current[u'size'].y())) + self.Height.setText(unicode(self.screens.current[u'size'].height())) + self.Width.setText(unicode(self.screens.current[u'size'].width())) + xpos = settings.value(u'x position', + QtCore.QVariant(self.screens.current[u'size'].x())).toString() + self.XposEdit.setText(xpos) + ypos = settings.value(u'y position', + QtCore.QVariant(self.screens.current[u'size'].y())).toString() + self.YposEdit.setText(ypos) + height = settings.value(u'height', + QtCore.QVariant(self.screens.current[u'size'].height())).toString() + self.HeightEdit.setText(height) + width = settings.value(u'width', + QtCore.QVariant(self.screens.current[u'size'].width())).toString() + self.WidthEdit.setText(width) + self.amend_display = settings.value(u'amend display', + QtCore.QVariant(False)).toBool() + self.OverrideCheckBox.setChecked(self.amend_display) + self.amend_display_start = self.amend_display + + def onOverrideCheckBoxChanged(self, check_state): + self.amend_display = False + # we have a set value convert to True/False + if check_state == QtCore.Qt.Checked: + self.amend_display = True + + def save(self): + settings = QtCore.QSettings() + settings.beginGroup(self.settingsSection) + settings.setValue('x position', + QtCore.QVariant(self.XposEdit.text())) + settings.setValue('y position', + QtCore.QVariant(self.YposEdit.text())) + settings.setValue('height', + QtCore.QVariant(self.HeightEdit.text())) + settings.setValue('width', + QtCore.QVariant(self.WidthEdit.text())) + settings.setValue('amend display', + QtCore.QVariant(self.amend_display)) + self.postSetUp() + + def postSetUp(self): + self.screens.override[u'size'] = QtCore.QRect(int(self.XposEdit.text()),\ + int(self.YposEdit.text()), int(self.WidthEdit.text()),\ + int(self.HeightEdit.text())) + if self.amend_display: + self.screens.set_override_display() + else: + self.screens.reset_current_display() + #only trigger event if data has changed in this edit session + if self.amend_display_start != self.amend_display: + self.amend_display_start = self.amend_display + Receiver.send_message(u'config_screen_changed') diff --git a/resources/forms/displaytab.py b/resources/forms/displaytab.py new file mode 100644 index 000000000..80ff2fdd5 --- /dev/null +++ b/resources/forms/displaytab.py @@ -0,0 +1,150 @@ +# -*- coding: utf-8 -*- + +# Form implementation generated from reading ui file 'displaytab.ui' +# +# Created: Tue Apr 27 06:10:08 2010 +# by: PyQt4 UI code generator 4.7.3 +# +# WARNING! All changes made in this file will be lost! + +from PyQt4 import QtCore, QtGui + +class Ui_DisplaysDialog(object): + def setupUi(self, DisplaysDialog): + DisplaysDialog.setObjectName("DisplaysDialog") + DisplaysDialog.resize(620, 716) + self.layoutWidget = QtGui.QWidget(DisplaysDialog) + self.layoutWidget.setGeometry(QtCore.QRect(0, 40, 241, 79)) + self.layoutWidget.setObjectName("layoutWidget") + self.verticalLayout = QtGui.QVBoxLayout(self.layoutWidget) + self.verticalLayout.setObjectName("verticalLayout") + self.CurrentGroupBox = QtGui.QGroupBox(self.layoutWidget) + self.CurrentGroupBox.setObjectName("CurrentGroupBox") + self.horizontalLayout = QtGui.QHBoxLayout(self.CurrentGroupBox) + self.horizontalLayout.setObjectName("horizontalLayout") + self.verticalLayout_6 = QtGui.QVBoxLayout() + self.verticalLayout_6.setObjectName("verticalLayout_6") + self.XLabel = QtGui.QLabel(self.CurrentGroupBox) + self.XLabel.setAlignment(QtCore.Qt.AlignCenter) + self.XLabel.setObjectName("XLabel") + self.verticalLayout_6.addWidget(self.XLabel) + self.Xpos = QtGui.QLabel(self.CurrentGroupBox) + self.Xpos.setAlignment(QtCore.Qt.AlignCenter) + self.Xpos.setObjectName("Xpos") + self.verticalLayout_6.addWidget(self.Xpos) + self.horizontalLayout.addLayout(self.verticalLayout_6) + self.verticalLayout_7 = QtGui.QVBoxLayout() + self.verticalLayout_7.setObjectName("verticalLayout_7") + self.YLabel = QtGui.QLabel(self.CurrentGroupBox) + self.YLabel.setAlignment(QtCore.Qt.AlignCenter) + self.YLabel.setObjectName("YLabel") + self.verticalLayout_7.addWidget(self.YLabel) + self.Ypos = QtGui.QLabel(self.CurrentGroupBox) + self.Ypos.setAlignment(QtCore.Qt.AlignCenter) + self.Ypos.setObjectName("Ypos") + self.verticalLayout_7.addWidget(self.Ypos) + self.horizontalLayout.addLayout(self.verticalLayout_7) + self.verticalLayout_9 = QtGui.QVBoxLayout() + self.verticalLayout_9.setObjectName("verticalLayout_9") + self.HeightLabel = QtGui.QLabel(self.CurrentGroupBox) + self.HeightLabel.setMaximumSize(QtCore.QSize(100, 16777215)) + self.HeightLabel.setAlignment(QtCore.Qt.AlignCenter) + self.HeightLabel.setObjectName("HeightLabel") + self.verticalLayout_9.addWidget(self.HeightLabel) + self.Height = QtGui.QLabel(self.CurrentGroupBox) + self.Height.setAlignment(QtCore.Qt.AlignCenter) + self.Height.setObjectName("Height") + self.verticalLayout_9.addWidget(self.Height) + self.horizontalLayout.addLayout(self.verticalLayout_9) + self.verticalLayout_8 = QtGui.QVBoxLayout() + self.verticalLayout_8.setObjectName("verticalLayout_8") + self.WidthLabel = QtGui.QLabel(self.CurrentGroupBox) + self.WidthLabel.setAlignment(QtCore.Qt.AlignCenter) + self.WidthLabel.setObjectName("WidthLabel") + self.verticalLayout_8.addWidget(self.WidthLabel) + self.Width = QtGui.QLabel(self.CurrentGroupBox) + self.Width.setAlignment(QtCore.Qt.AlignCenter) + self.Width.setObjectName("Width") + self.verticalLayout_8.addWidget(self.Width) + self.horizontalLayout.addLayout(self.verticalLayout_8) + self.verticalLayout.addWidget(self.CurrentGroupBox) + self.CurrentGroupBox_2 = QtGui.QGroupBox(DisplaysDialog) + self.CurrentGroupBox_2.setGeometry(QtCore.QRect(0, 130, 248, 87)) + self.CurrentGroupBox_2.setMaximumSize(QtCore.QSize(500, 16777215)) + self.CurrentGroupBox_2.setObjectName("CurrentGroupBox_2") + self.horizontalLayout_2 = QtGui.QHBoxLayout(self.CurrentGroupBox_2) + self.horizontalLayout_2.setObjectName("horizontalLayout_2") + self.verticalLayout_2 = QtGui.QVBoxLayout() + self.verticalLayout_2.setObjectName("verticalLayout_2") + self.XAmendLabel = QtGui.QLabel(self.CurrentGroupBox_2) + self.XAmendLabel.setAlignment(QtCore.Qt.AlignCenter) + self.XAmendLabel.setObjectName("XAmendLabel") + self.verticalLayout_2.addWidget(self.XAmendLabel) + self.XposEdit = QtGui.QLineEdit(self.CurrentGroupBox_2) + self.XposEdit.setMaximumSize(QtCore.QSize(50, 16777215)) + self.XposEdit.setMaxLength(4) + self.XposEdit.setObjectName("XposEdit") + self.verticalLayout_2.addWidget(self.XposEdit) + self.horizontalLayout_2.addLayout(self.verticalLayout_2) + self.verticalLayout_3 = QtGui.QVBoxLayout() + self.verticalLayout_3.setObjectName("verticalLayout_3") + self.YAmendLabel = QtGui.QLabel(self.CurrentGroupBox_2) + self.YAmendLabel.setAlignment(QtCore.Qt.AlignCenter) + self.YAmendLabel.setObjectName("YAmendLabel") + self.verticalLayout_3.addWidget(self.YAmendLabel) + self.YposEdit = QtGui.QLineEdit(self.CurrentGroupBox_2) + self.YposEdit.setMaximumSize(QtCore.QSize(50, 16777215)) + self.YposEdit.setMaxLength(4) + self.YposEdit.setObjectName("YposEdit") + self.verticalLayout_3.addWidget(self.YposEdit) + self.horizontalLayout_2.addLayout(self.verticalLayout_3) + self.verticalLayout_4 = QtGui.QVBoxLayout() + self.verticalLayout_4.setObjectName("verticalLayout_4") + self.HeightAmendLabel = QtGui.QLabel(self.CurrentGroupBox_2) + self.HeightAmendLabel.setAlignment(QtCore.Qt.AlignCenter) + self.HeightAmendLabel.setObjectName("HeightAmendLabel") + self.verticalLayout_4.addWidget(self.HeightAmendLabel) + self.HeightEdit = QtGui.QLineEdit(self.CurrentGroupBox_2) + self.HeightEdit.setMaximumSize(QtCore.QSize(50, 16777215)) + self.HeightEdit.setMaxLength(4) + self.HeightEdit.setObjectName("HeightEdit") + self.verticalLayout_4.addWidget(self.HeightEdit) + self.horizontalLayout_2.addLayout(self.verticalLayout_4) + self.verticalLayout_5 = QtGui.QVBoxLayout() + self.verticalLayout_5.setSizeConstraint(QtGui.QLayout.SetMinimumSize) + self.verticalLayout_5.setObjectName("verticalLayout_5") + self.WidthAmendLabel = QtGui.QLabel(self.CurrentGroupBox_2) + self.WidthAmendLabel.setMaximumSize(QtCore.QSize(100, 16777215)) + self.WidthAmendLabel.setAlignment(QtCore.Qt.AlignCenter) + self.WidthAmendLabel.setObjectName("WidthAmendLabel") + self.verticalLayout_5.addWidget(self.WidthAmendLabel) + self.WidthEdit = QtGui.QLineEdit(self.CurrentGroupBox_2) + self.WidthEdit.setMaximumSize(QtCore.QSize(60, 16777215)) + self.WidthEdit.setObjectName("WidthEdit") + self.verticalLayout_5.addWidget(self.WidthEdit) + self.horizontalLayout_2.addLayout(self.verticalLayout_5) + self.OverrideCheckBox = QtGui.QCheckBox(DisplaysDialog) + self.OverrideCheckBox.setGeometry(QtCore.QRect(0, 10, 191, 23)) + self.OverrideCheckBox.setObjectName("OverrideCheckBox") + + self.retranslateUi(DisplaysDialog) + QtCore.QMetaObject.connectSlotsByName(DisplaysDialog) + + def retranslateUi(self, DisplaysDialog): + DisplaysDialog.setWindowTitle(QtGui.QApplication.translate("DisplaysDialog", "Amend Display Settings", None, QtGui.QApplication.UnicodeUTF8)) + self.CurrentGroupBox.setTitle(QtGui.QApplication.translate("DisplaysDialog", "Default Settings", None, QtGui.QApplication.UnicodeUTF8)) + self.XLabel.setText(QtGui.QApplication.translate("DisplaysDialog", "X", None, QtGui.QApplication.UnicodeUTF8)) + self.Xpos.setText(QtGui.QApplication.translate("DisplaysDialog", "0", None, QtGui.QApplication.UnicodeUTF8)) + self.YLabel.setText(QtGui.QApplication.translate("DisplaysDialog", "Y", None, QtGui.QApplication.UnicodeUTF8)) + self.Ypos.setText(QtGui.QApplication.translate("DisplaysDialog", "0", None, QtGui.QApplication.UnicodeUTF8)) + self.HeightLabel.setText(QtGui.QApplication.translate("DisplaysDialog", "Height", None, QtGui.QApplication.UnicodeUTF8)) + self.Height.setText(QtGui.QApplication.translate("DisplaysDialog", "0", None, QtGui.QApplication.UnicodeUTF8)) + self.WidthLabel.setText(QtGui.QApplication.translate("DisplaysDialog", "Width", None, QtGui.QApplication.UnicodeUTF8)) + self.Width.setText(QtGui.QApplication.translate("DisplaysDialog", "0", None, QtGui.QApplication.UnicodeUTF8)) + self.CurrentGroupBox_2.setTitle(QtGui.QApplication.translate("DisplaysDialog", "Amend Settings", None, QtGui.QApplication.UnicodeUTF8)) + self.XAmendLabel.setText(QtGui.QApplication.translate("DisplaysDialog", "X", None, QtGui.QApplication.UnicodeUTF8)) + self.YAmendLabel.setText(QtGui.QApplication.translate("DisplaysDialog", "Y", None, QtGui.QApplication.UnicodeUTF8)) + self.HeightAmendLabel.setText(QtGui.QApplication.translate("DisplaysDialog", "Height", None, QtGui.QApplication.UnicodeUTF8)) + self.WidthAmendLabel.setText(QtGui.QApplication.translate("DisplaysDialog", "Width", None, QtGui.QApplication.UnicodeUTF8)) + self.OverrideCheckBox.setText(QtGui.QApplication.translate("DisplaysDialog", "Override Output Display", None, QtGui.QApplication.UnicodeUTF8)) + From f4cc91f529358b11654ec99f405a2d12ddc5d0f4 Mon Sep 17 00:00:00 2001 From: Jonathan Corwin Date: Wed, 28 Apr 2010 23:08:37 +0100 Subject: [PATCH 40/63] Show service and song text. Click on service item/song verse to go live --- openlp/core/ui/servicemanager.py | 29 ++++- openlp/core/ui/slidecontroller.py | 40 +++++++ .../presentations/lib/messagelistener.py | 1 + openlp/plugins/remotes/lib/httpserver.py | 110 +++++++++++++----- 4 files changed, 151 insertions(+), 29 deletions(-) diff --git a/openlp/core/ui/servicemanager.py b/openlp/core/ui/servicemanager.py index 5c0a2468a..0cb8a7d10 100644 --- a/openlp/core/ui/servicemanager.py +++ b/openlp/core/ui/servicemanager.py @@ -191,6 +191,8 @@ class ServiceManager(QtGui.QWidget): QtCore.SIGNAL(u'servicemanager_next_item'), self.nextItem) QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'servicemanager_previous_item'), self.previousItem) + QtCore.QObject.connect(Receiver.get_receiver(), + QtCore.SIGNAL(u'servicemanager_set_item'), self.onSetItem) QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'servicemanager_list_request'), self.listRequest) QtCore.QObject.connect(Receiver.get_receiver(), @@ -315,6 +317,21 @@ class ServiceManager(QtGui.QWidget): prevItem = serviceIterator.value() serviceIterator += 1 + def onSetItem(self, message): + """ + Called by a signal to select a specific item + """ + self.setItem(int(message[0])) + + def setItem(self, index): + """ + Makes a specific item in the service live + """ + if index >= 0 and index < self.ServiceManagerList.topLevelItemCount: + item = self.ServiceManagerList.topLevelItem(index) + self.ServiceManagerList.setCurrentItem(item) + self.makeLive() + def onMoveSelectionUp(self): """ Moves the selection up the window @@ -877,7 +894,17 @@ class ServiceManager(QtGui.QWidget): def listRequest(self, message=None): data = [] + curindex, count = self.findServiceItem() + if curindex >= 0 and curindex < len(self.serviceItems): + curitem = self.serviceItems[curindex] + else: + curitem = None for item in self.serviceItems: service_item = item[u'service_item'] - data.append([service_item.title]) + data_item = {} + data_item[u'title'] = unicode(service_item.title) + data_item[u'plugin'] = unicode(service_item.name) + data_item[u'notes'] = unicode(service_item.notes) + data_item[u'selected'] = (item == curitem) + data.append(data_item) Receiver.send_message(u'servicemanager_list_response', data) diff --git a/openlp/core/ui/slidecontroller.py b/openlp/core/ui/slidecontroller.py index 811fd51e3..9381a9f2b 100644 --- a/openlp/core/ui/slidecontroller.py +++ b/openlp/core/ui/slidecontroller.py @@ -341,6 +341,12 @@ class SlideController(QtGui.QWidget): QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'slidecontroller_%s_change' % self.type_prefix), self.onSlideChange) + QtCore.QObject.connect(Receiver.get_receiver(), + QtCore.SIGNAL(u'slidecontroller_%s_set' % self.type_prefix), + self.onSlideSelectedIndex) + QtCore.QObject.connect(Receiver.get_receiver(), + QtCore.SIGNAL(u'slidecontroller_%s_text_request' % self.type_prefix), + self.onTextRequest) QtCore.QObject.connect(self.Splitter, QtCore.SIGNAL(u'splitterMoved(int, int)'), self.trackSplitter) QtCore.QObject.connect(Receiver.get_receiver(), @@ -565,6 +571,25 @@ class SlideController(QtGui.QWidget): [serviceItem]) log.log(15, u'Display Rendering took %4s' % (time.time() - before)) + def onTextRequest(self): + """ + Return the text for the current item in controller + """ + data = [] + for framenumber, frame in enumerate(self.serviceItem.get_frames()): + data_item = {} + if self.serviceItem.is_text(): + data_item[u'tag'] = unicode(frame[u'verseTag']) + data_item[u'text'] = unicode(frame[u'text']) + else: + data_item[u'tag'] = unicode(framenumber) + data_item[u'text'] = u'' + data_item[u'selected'] = \ + (self.PreviewListWidget.currentRow() == framenumber) + data.append(data_item) + Receiver.send_message(u'slidecontroller_%s_text_response' % self.type_prefix, + data) + #Screen event methods def onSlideSelectedFirst(self): """ @@ -580,6 +605,21 @@ class SlideController(QtGui.QWidget): self.PreviewListWidget.selectRow(0) self.onSlideSelected() + def onSlideSelectedIndex(self, message): + """ + Go to the requested slide + """ + index = int(message[0]) + if not self.serviceItem: + return + Receiver.send_message(u'%s_slide' % self.serviceItem.name.lower(), + [self.serviceItem, self.isLive, index]) + if self.serviceItem.is_command(): + self.updatePreview() + else: + self.PreviewListWidget.selectRow(index) + self.onSlideSelected() + def onBlankDisplay(self, force=False): """ Handle the blank screen button diff --git a/openlp/plugins/presentations/lib/messagelistener.py b/openlp/plugins/presentations/lib/messagelistener.py index 8a1ddc8c7..65ffbe726 100644 --- a/openlp/plugins/presentations/lib/messagelistener.py +++ b/openlp/plugins/presentations/lib/messagelistener.py @@ -235,6 +235,7 @@ class MessageListener(object): def slide(self, message): isLive, item = self.decode_message(message) + slide = message[2] if isLive: self.liveHandler.slide(slide, live) else: diff --git a/openlp/plugins/remotes/lib/httpserver.py b/openlp/plugins/remotes/lib/httpserver.py index 7346afba0..c9acbaccc 100644 --- a/openlp/plugins/remotes/lib/httpserver.py +++ b/openlp/plugins/remotes/lib/httpserver.py @@ -47,13 +47,15 @@ class HttpServer(object): def start_tcp(self): log.debug(u'Start TCP server') - port = self.parent.config.get_config(u'remote port', 4316) + port = QtCore.QSettings().value( + self.parent.settings_section + u'/remote port', + QtCore.QVariant(4316)).toInt()[0] self.server = QtNetwork.QTcpServer() self.server.listen(QtNetwork.QHostAddress(QtNetwork.QHostAddress.Any), - int(port)) + port) QtCore.QObject.connect(self.server, QtCore.SIGNAL(u'newConnection()'), self.new_connection) - log.debug(u'TCP listening on port %s' % port) + log.debug(u'TCP listening on port %d' % port) def new_connection(self): log.debug(u'new http connection') @@ -70,7 +72,10 @@ class HttpServer(object): self.server.close() class HttpConnection(object): - + """ + A single connection, this handles communication between the server + and the client + """ def __init__(self, parent, socket): log.debug(u'Initialise HttpConnection: %s' % socket.peerAddress().toString()) @@ -115,47 +120,96 @@ class HttpConnection(object): function send_event(eventname, data){ var req = new XMLHttpRequest(); - url = 'send/' + eventname; + req.onreadystatechange = function() { + if(req.readyState==4 && req.status==200) + response(eventname, req.responseText); + } + var url = ''; + if(eventname.substr(-8) == '_request') + url = 'request'; + else + url = 'send'; + url += '/' + eventname; if(data!=null) url += '?q=' + escape(data); req.open('GET', url, true); req.send(); } -function get_service(){ - var req = new XMLHttpRequest(); - req.onreadystatechange = function() { - if(req.readyState==4 && req.status==200){ - data = eval('(' + req.responseText + ')'); - html = ''; +function response(eventname, text){ + switch(eventname){ + case 'servicemanager_list_request': + var data = eval('(' + text + ')'); + var html = '
'; for(row in data){ - html += ''; + html += '' + html += '' + html += '' + html += '' + html += ''; } html += '
' + data[row][0] + '
' + data[row]['title'] + '' + data[row]['plugin'] + '' + data[row]['notes'] + '
'; - service = document.getElementById('service'); - service.innerHTML = html; - } + document.getElementById('service').innerHTML = html; + break; + case 'servicemanager_previous_item': + case 'servicemanager_next_item': + case 'servicemanager_set_item': + send_event("servicemanager_list_request"); + break; + case 'slidecontroller_live_text_request': + var data = eval('(' + text + ')'); + var html = ''; + for(row in data){ + html += '' + html += '' + html += ''; + } + html += '
' + data[row]['text'] + '
'; + document.getElementById('currentitem').innerHTML = html; + break; + case 'slidecontroller_live_next': + case 'slidecontroller_live_previous': + case 'slidecontroller_live_set': + send_event("slidecontroller_live_text_request"); + break; + } - req.open('GET', 'request/servicemanager_list_request', true); - req.send(); } +send_event("servicemanager_list_request");

OpenLP Controller

- - + +
- - -
- + + +
+ -
- -
-
+ document.getElementById("alert").value);' /> +
+ +
+ +
""" From 32b7bca71ebf6729c04ace6448aa134b1cc79d17 Mon Sep 17 00:00:00 2001 From: Jon Tibble Date: Thu, 29 Apr 2010 13:35:40 +0100 Subject: [PATCH 41/63] Help -> Website and disable unimplemented options --- openlp/core/ui/mainwindow.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/openlp/core/ui/mainwindow.py b/openlp/core/ui/mainwindow.py index 44341244d..f3ceb18be 100644 --- a/openlp/core/ui/mainwindow.py +++ b/openlp/core/ui/mainwindow.py @@ -242,12 +242,14 @@ class Ui_MainWindow(object): ContentsIcon = build_icon(u':/system/system_help_contents.png') self.HelpDocumentationItem.setIcon(ContentsIcon) self.HelpDocumentationItem.setObjectName(u'HelpDocumentationItem') + self.HelpDocumentationItem.setEnabled(False) self.HelpAboutItem = QtGui.QAction(MainWindow) AboutIcon = build_icon(u':/system/system_about.png') self.HelpAboutItem.setIcon(AboutIcon) self.HelpAboutItem.setObjectName(u'HelpAboutItem') self.HelpOnlineHelpItem = QtGui.QAction(MainWindow) self.HelpOnlineHelpItem.setObjectName(u'HelpOnlineHelpItem') + self.HelpOnlineHelpItem.setEnabled(False) self.HelpWebSiteItem = QtGui.QAction(MainWindow) self.HelpWebSiteItem.setObjectName(u'HelpWebSiteItem') self.LanguageTranslateItem = QtGui.QAction(MainWindow) @@ -472,6 +474,8 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow): QtCore.QObject.connect(self.PreviewController.Panel, QtCore.SIGNAL(u'visibilityChanged(bool)'), self.action_Preview_Panel.setChecked) + QtCore.QObject.connect(self.HelpWebSiteItem, + QtCore.SIGNAL(u'triggered()'), self.onHelpWebSiteClicked) QtCore.QObject.connect(self.HelpAboutItem, QtCore.SIGNAL(u'triggered()'), self.onHelpAboutItemClicked) QtCore.QObject.connect(self.PluginItem, @@ -594,6 +598,13 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow): vT = VersionThread(self, self.applicationVersion) vT.start() + def onHelpWebSiteClicked(self): + """ + Load the OpenLP website + """ + import webbrowser + webbrowser.open_new(u'http://openlp.org/') + def onHelpAboutItemClicked(self): """ Show the About form From 39a4593bd3323f40515816e106bd55b630ceff71 Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Thu, 29 Apr 2010 20:33:45 +0100 Subject: [PATCH 42/63] Fix up display buttons --- openlp/core/ui/maindisplay.py | 98 +++++++++++++++++++++---------- openlp/core/ui/mainwindow.py | 1 + openlp/core/ui/slidecontroller.py | 68 +++++++++++---------- 3 files changed, 104 insertions(+), 63 deletions(-) diff --git a/openlp/core/ui/maindisplay.py b/openlp/core/ui/maindisplay.py index a459fb72f..f3bad6bb1 100644 --- a/openlp/core/ui/maindisplay.py +++ b/openlp/core/ui/maindisplay.py @@ -40,6 +40,7 @@ class DisplayManager(QtGui.QWidget): Wrapper class to hold the display widgets. I will provide API's in future to access the screens allow for extra displays to be added. + RenderManager is poked in by MainWindow """ def __init__(self, screens): QtGui.QWidget.__init__(self) @@ -130,17 +131,14 @@ class MainDisplay(DisplayWidget): self.displayBlank = False self.blankFrame = None self.frame = None - self.firstTime = True - self.hasTransition = False - self.mediaBackground = False + QtCore.QObject.connect(Receiver.get_receiver(), + QtCore.SIGNAL(u'maindisplay_blank'), self.blankDisplay) QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'maindisplay_hide'), self.hideDisplay) QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'maindisplay_show'), self.showDisplay) QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'maindisplay_hide_theme'), self.hideThemeDisplay) -# QtCore.QObject.connect(Receiver.get_receiver(), -# QtCore.SIGNAL(u'maindisplay_show_theme'), self.showThemeDisplay) QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'videodisplay_start'), self.hideDisplay) @@ -153,12 +151,12 @@ class MainDisplay(DisplayWidget): self.setVisible(False) self.screen = self.screens.current #Sort out screen locations and sizes - self.setGeometry(self.screen[u'size']) self.display_alert.setGeometry(self.screen[u'size']) self.display_image.resize(self.screen[u'size'].width(), self.screen[u'size'].height()) self.display_text.resize(self.screen[u'size'].width(), self.screen[u'size'].height()) + self.setGeometry(self.screen[u'size']) #Build a custom splash screen self.InitialFrame = QtGui.QImage( self.screen[u'size'].width(), @@ -205,16 +203,65 @@ class MainDisplay(DisplayWidget): else: self.showFullScreen() + def blankDisplay(self):#, blankType=HideMode.Blank, blanked=True): + log.debug(u'Blank main Display ') + """ + Hide the display by making all layers transparent + Store the images so they can be replaced when required + """ + self.storeImage = QtGui.QPixmap(self.display_image.pixmap()) + self.storeText = QtGui.QPixmap(self.display_text.pixmap()) + self.display_image.setPixmap(QtGui.QPixmap.fromImage(self.blankFrame)) + self.display_alert.setPixmap(self.transparent) + self.display_text.setPixmap(self.transparent) + self.moveToTop() +# if blanked: +# self.displayBlank = True +# if blankType == HideMode.Blank: +# self.display_text.setPixmap( +# QtGui.QPixmap.fromImage(self.blankFrame)) +# elif blankType == HideMode.Theme: +# theme = self.parent.RenderManager.renderer.bg_frame +# if not theme: +# theme = self.blankFrame +# self.display_text.setPixmap(QtGui.QPixmap.fromImage(theme)) +# self.waitingFrame = None +# self.waitingFrameTrans = False +# else: +# self.displayBlank = False +# if self.waitingFrame: +# self.frameView(self.waitingFrame, self.waitingFrameTrans) +# elif self.display_frame: +# self.frameView(self.display_frame) + def hideDisplay(self): + """ + Hide the display by making all layers transparent + Store the images so they can be replaced when required + """ log.debug(u'hideDisplay') + self.storeImage = QtGui.QPixmap(self.display_image.pixmap()) + self.storeText = QtGui.QPixmap(self.display_text.pixmap()) self.display_image.setPixmap(self.transparent) self.display_alert.setPixmap(self.transparent) self.display_text.setPixmap(self.transparent) self.moveToTop() def hideThemeDisplay(self): + """ + Hide the display by making all layers transparent + Add the theme background to the image layer unless it has + not been generated in which case make it black. + Store the images so they can be replaced when required + """ log.debug(u'hideDisplay') - self.display_image.setPixmap(self.transparent) + self.storeImage = QtGui.QPixmap(self.display_image.pixmap()) + self.storeText = QtGui.QPixmap(self.display_text.pixmap()) + if self.parent.renderManager.renderer.bg_frame: + self.display_image.setPixmap(QtGui.QPixmap.fromImage(\ + self.parent.renderManager.renderer.bg_frame)) + else: + self.display_image.setPixmap(QtGui.QPixmap.fromImage(self.blankFrame)) self.display_alert.setPixmap(self.transparent) self.display_text.setPixmap(self.transparent) self.moveToTop() @@ -226,10 +273,20 @@ class MainDisplay(DisplayWidget): self.show() def showDisplay(self): + """ + Show the stored layers so the screen reappears as it was + originally. + Make the stored images None to release memory. + """ log.debug(u'showDisplay') - if not self.primary: - self.setVisible(True) - self.showFullScreen() + if self.storeImage: + self.display_image.setPixmap(self.storeImage) + self.display_alert.setPixmap(self.transparent) + if self.storeText: + self.display_text.setPixmap(self.storeText) + self.storeImage = None + self.store = None + self.moveToTop() Receiver.send_message(u'maindisplay_active') def addImageWithText(self, frame): @@ -291,27 +348,6 @@ class MainDisplay(DisplayWidget): self.waitingFrame = frame self.waitingFrameTrans = transition - def blankDisplay(self, blankType=HideMode.Blank, blanked=True): - log.debug(u'Blank main Display %d' % blanked) - if blanked: - self.displayBlank = True - if blankType == HideMode.Blank: - self.display_text.setPixmap( - QtGui.QPixmap.fromImage(self.blankFrame)) - elif blankType == HideMode.Theme: - theme = self.parent.RenderManager.renderer.bg_frame - if not theme: - theme = self.blankFrame - self.display_text.setPixmap(QtGui.QPixmap.fromImage(theme)) - self.waitingFrame = None - self.waitingFrameTrans = False - else: - self.displayBlank = False - if self.waitingFrame: - self.frameView(self.waitingFrame, self.waitingFrameTrans) - elif self.display_frame: - self.frameView(self.display_frame) - class VideoDisplay(Phonon.VideoWidget): """ This is the form that is used to display videos on the projector. diff --git a/openlp/core/ui/mainwindow.py b/openlp/core/ui/mainwindow.py index 44341244d..d1294d7cd 100644 --- a/openlp/core/ui/mainwindow.py +++ b/openlp/core/ui/mainwindow.py @@ -505,6 +505,7 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow): #ThemeManager needs to call RenderManager self.RenderManager = RenderManager( self.ThemeManagerContents, self.screens) + self.displayManager.renderManager = self.RenderManager #Define the media Dock Manager self.mediaDockManager = MediaDockManager(self.MediaToolBox) log.info(u'Load Plugins') diff --git a/openlp/core/ui/slidecontroller.py b/openlp/core/ui/slidecontroller.py index 529aad36f..c5326aaa8 100644 --- a/openlp/core/ui/slidecontroller.py +++ b/openlp/core/ui/slidecontroller.py @@ -199,8 +199,6 @@ class SlideController(QtGui.QWidget): self.hideButton = self.Toolbar.addToolbarButton( u'Hide screen', u':/slides/slide_desktop.png', self.trUtf8('Hide Screen'), self.onHideDisplay, True) - QtCore.QObject.connect(Receiver.get_receiver(), - QtCore.SIGNAL(u'maindisplay_blank'), self.blankScreen) if not self.isLive: self.Toolbar.addToolbarSeparator(u'Close Separator') self.Toolbar.addToolbarButton( @@ -590,58 +588,64 @@ class SlideController(QtGui.QWidget): self.PreviewListWidget.selectRow(0) self.onSlideSelected() - def onBlankDisplay(self, force=False): + def onBlankDisplay(self, checked): """ Handle the blank screen button """ - log.debug(u'onBlankDisplay %d' % force) - if force: - self.blankButton.setChecked(True) - self.blankScreen(HideMode.Blank, self.blankButton.isChecked()) + log.debug(u'onBlankDisplay %d' % checked) + self.hideButton.setChecked(False) + self.themeButton.setChecked(False) QtCore.QSettings().setValue( self.generalSettingsSection + u'/screen blank', - QtCore.QVariant(self.blankButton.isChecked())) + QtCore.QVariant(checked)) + if checked: + Receiver.send_message(u'maindisplay_blank') + else: + Receiver.send_message(u'maindisplay_show') - def onThemeDisplay(self, force=False): + def onThemeDisplay(self, checked): """ Handle the Theme screen button """ - log.debug(u'onThemeDisplay %d' % force) - if force: - self.themeButton.setChecked(True) - if self.themeButton.isChecked(): - Receiver.send_message(u'maindisplay_show_theme') - else: + log.debug(u'onThemeDisplay %d' % checked) + self.blankButton.setChecked(False) + self.hideButton.setChecked(False) + if checked: Receiver.send_message(u'maindisplay_hide_theme') + else: + Receiver.send_message(u'maindisplay_show') - def onHideDisplay(self, force=False): + def onHideDisplay(self, checked): """ Handle the Hide screen button """ - log.debug(u'onHideDisplay %d' % force) - if force: - self.hideButton.setChecked(True) - if self.hideButton.isChecked(): + log.debug(u'onHideDisplay %d' % checked) + self.blankButton.setChecked(False) + self.themeButton.setChecked(False) + if checked: Receiver.send_message(u'maindisplay_hide') else: Receiver.send_message(u'maindisplay_show') - def blankScreen(self, blankType, blanked=False): + def blankScreen(self, checked): """ Blank the display screen. """ - if self.serviceItem is not None: - if blanked: - Receiver.send_message( - u'%s_blank' % self.serviceItem.name.lower(), - [self.serviceItem, self.isLive]) - else: - Receiver.send_message(u'%s_unblank' - % self.serviceItem.name.lower(), - [self.serviceItem, self.isLive]) - self.parent.displayManager.mainDisplay.blankDisplay(blankType, blanked) + self.hideButton.setChecked(False) + self.themeButton.setChecked(False) +# if self.serviceItem is not None: +# if checked: +# Receiver.send_message( +# u'%s_blank' % self.serviceItem.name.lower(), +# [self.serviceItem, self.isLive]) +# else: +# Receiver.send_message(u'%s_unblank' +# % self.serviceItem.name.lower(), +# [self.serviceItem, self.isLive]) + if checked: + Receiver.send_message(u'maindisplay_blank') else: - self.parent.displayManager.mainDisplay.blankDisplay(blankType, blanked) + Receiver.send_message(u'maindisplay_show4') def onSlideSelected(self): """ From 4e6c56c43019f2e49bb1d26a2259daedb3aa6e05 Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Thu, 29 Apr 2010 21:56:27 +0100 Subject: [PATCH 43/63] Video clean ups and bug fixes from 800 --- openlp/core/lib/serviceitem.py | 1 - openlp/core/ui/__init__.py | 10 ++ openlp/core/ui/maindisplay.py | 93 +++++++------------ openlp/core/ui/slidecontroller.py | 61 ++++++------ openlp/plugins/images/lib/mediaitem.py | 2 +- openlp/plugins/media/lib/mediaitem.py | 3 +- openlp/plugins/presentations/lib/mediaitem.py | 3 +- 7 files changed, 74 insertions(+), 99 deletions(-) diff --git a/openlp/core/lib/serviceitem.py b/openlp/core/lib/serviceitem.py index 4374f98aa..25f08717f 100644 --- a/openlp/core/lib/serviceitem.py +++ b/openlp/core/lib/serviceitem.py @@ -49,7 +49,6 @@ class ItemCapabilities(object): RequiresMedia = 4 AllowsLoop = 5 - class ServiceItem(object): """ The service item is a base class for the plugins to use to interact with diff --git a/openlp/core/ui/__init__.py b/openlp/core/ui/__init__.py index 0c1ec731a..76b84503e 100644 --- a/openlp/core/ui/__init__.py +++ b/openlp/core/ui/__init__.py @@ -23,6 +23,16 @@ # Temple Place, Suite 330, Boston, MA 02111-1307 USA # ############################################################################### +class HideMode(object): + """ + This is basically an enumeration class which specifies the mode of a Bible. + Mode refers to whether or not a Bible in OpenLP is a full Bible or needs to + be downloaded from the Internet on an as-needed basis. + """ + Blank = 1 + Theme = 2 + Screen = 3 + from slidecontroller import HideMode from servicenoteform import ServiceNoteForm from serviceitemeditform import ServiceItemEditForm diff --git a/openlp/core/ui/maindisplay.py b/openlp/core/ui/maindisplay.py index f3bad6bb1..321e28e1b 100644 --- a/openlp/core/ui/maindisplay.py +++ b/openlp/core/ui/maindisplay.py @@ -131,16 +131,10 @@ class MainDisplay(DisplayWidget): self.displayBlank = False self.blankFrame = None self.frame = None - QtCore.QObject.connect(Receiver.get_receiver(), - QtCore.SIGNAL(u'maindisplay_blank'), self.blankDisplay) QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'maindisplay_hide'), self.hideDisplay) QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'maindisplay_show'), self.showDisplay) - QtCore.QObject.connect(Receiver.get_receiver(), - QtCore.SIGNAL(u'maindisplay_hide_theme'), self.hideThemeDisplay) - QtCore.QObject.connect(Receiver.get_receiver(), - QtCore.SIGNAL(u'videodisplay_start'), self.hideDisplay) def setup(self): """ @@ -203,67 +197,26 @@ class MainDisplay(DisplayWidget): else: self.showFullScreen() - def blankDisplay(self):#, blankType=HideMode.Blank, blanked=True): - log.debug(u'Blank main Display ') + def hideDisplay(self, mode=HideMode.Screen): """ Hide the display by making all layers transparent Store the images so they can be replaced when required """ + log.debug(u'hideDisplay mode = %d', mode) self.storeImage = QtGui.QPixmap(self.display_image.pixmap()) self.storeText = QtGui.QPixmap(self.display_text.pixmap()) - self.display_image.setPixmap(QtGui.QPixmap.fromImage(self.blankFrame)) self.display_alert.setPixmap(self.transparent) self.display_text.setPixmap(self.transparent) - self.moveToTop() -# if blanked: -# self.displayBlank = True -# if blankType == HideMode.Blank: -# self.display_text.setPixmap( -# QtGui.QPixmap.fromImage(self.blankFrame)) -# elif blankType == HideMode.Theme: -# theme = self.parent.RenderManager.renderer.bg_frame -# if not theme: -# theme = self.blankFrame -# self.display_text.setPixmap(QtGui.QPixmap.fromImage(theme)) -# self.waitingFrame = None -# self.waitingFrameTrans = False -# else: -# self.displayBlank = False -# if self.waitingFrame: -# self.frameView(self.waitingFrame, self.waitingFrameTrans) -# elif self.display_frame: -# self.frameView(self.display_frame) - - def hideDisplay(self): - """ - Hide the display by making all layers transparent - Store the images so they can be replaced when required - """ - log.debug(u'hideDisplay') - self.storeImage = QtGui.QPixmap(self.display_image.pixmap()) - self.storeText = QtGui.QPixmap(self.display_text.pixmap()) - self.display_image.setPixmap(self.transparent) - self.display_alert.setPixmap(self.transparent) - self.display_text.setPixmap(self.transparent) - self.moveToTop() - - def hideThemeDisplay(self): - """ - Hide the display by making all layers transparent - Add the theme background to the image layer unless it has - not been generated in which case make it black. - Store the images so they can be replaced when required - """ - log.debug(u'hideDisplay') - self.storeImage = QtGui.QPixmap(self.display_image.pixmap()) - self.storeText = QtGui.QPixmap(self.display_text.pixmap()) - if self.parent.renderManager.renderer.bg_frame: - self.display_image.setPixmap(QtGui.QPixmap.fromImage(\ - self.parent.renderManager.renderer.bg_frame)) - else: + if mode == HideMode.Screen: + self.display_image.setPixmap(self.transparent) + elif mode == HideMode.Blank: self.display_image.setPixmap(QtGui.QPixmap.fromImage(self.blankFrame)) - self.display_alert.setPixmap(self.transparent) - self.display_text.setPixmap(self.transparent) + else: + if self.parent.renderManager.renderer.bg_frame: + self.display_image.setPixmap(QtGui.QPixmap.fromImage(\ + self.parent.renderManager.renderer.bg_frame)) + else: + self.display_image.setPixmap(QtGui.QPixmap.fromImage(self.blankFrame)) self.moveToTop() def moveToTop(self): @@ -370,6 +323,7 @@ class VideoDisplay(Phonon.VideoWidget): self.setWindowTitle(u'OpenLP Video Display') self.parent = parent self.screens = screens + self.hidden = False self.mediaObject = Phonon.MediaObject() self.setAspectRatio(aspect) self.audioObject = Phonon.AudioOutput(Phonon.VideoCategory) @@ -377,6 +331,10 @@ class VideoDisplay(Phonon.VideoWidget): Phonon.createPath(self.mediaObject, self.audioObject) self.setWindowFlags(QtCore.Qt.WindowStaysOnBottomHint \ | QtCore.Qt.FramelessWindowHint | QtCore.Qt.Dialog) + QtCore.QObject.connect(Receiver.get_receiver(), + QtCore.SIGNAL(u'maindisplay_hide'), self.mediaHide) + QtCore.QObject.connect(Receiver.get_receiver(), + QtCore.SIGNAL(u'maindisplay_show'), self.mediaShow) QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'videodisplay_start'), self.onMediaQueue) QtCore.QObject.connect(Receiver.get_receiver(), @@ -421,10 +379,15 @@ class VideoDisplay(Phonon.VideoWidget): file = os.path.join(message[0].get_frame_path(), message[0].get_frame_title()) source = self.mediaObject.setCurrentSource(Phonon.MediaSource(file)) - self.onMediaPlay() + self._play() def onMediaPlay(self): - log.debug(u'VideoDisplay Play the new media, Live ') + if not self.hidden: + log.debug(u'VideoDisplay Play the new media, Live ') + self._play() + + def _play(self): + log.debug(u'VideoDisplay _play called') self.mediaObject.play() self.setVisible(True) self.showFullScreen() @@ -444,3 +407,13 @@ class VideoDisplay(Phonon.VideoWidget): self.mediaObject.clearQueue() self.setVisible(False) + def mediaHide(self): + self.mediaObject.pause() + self.hidden = True + self.setVisible(False) + + def mediaShow(self): + if self.hidden: + self.hidden = False + self._play() + diff --git a/openlp/core/ui/slidecontroller.py b/openlp/core/ui/slidecontroller.py index c5326aaa8..32b301111 100644 --- a/openlp/core/ui/slidecontroller.py +++ b/openlp/core/ui/slidecontroller.py @@ -30,18 +30,9 @@ import os from PyQt4 import QtCore, QtGui from PyQt4.phonon import Phonon -from openlp.core.lib import ItemCapabilities - -class HideMode(object): - """ - This is basically an enumeration class which specifies the mode of a Bible. - Mode refers to whether or not a Bible in OpenLP is a full Bible or needs to - be downloaded from the Internet on an as-needed basis. - """ - Blank = 1 - Theme = 2 - -from openlp.core.lib import OpenLPToolbar, Receiver, resize_image +from openlp.core.ui import HideMode +from openlp.core.lib import OpenLPToolbar, Receiver, resize_image, \ +ItemCapabilities log = logging.getLogger(__name__) @@ -599,7 +590,7 @@ class SlideController(QtGui.QWidget): self.generalSettingsSection + u'/screen blank', QtCore.QVariant(checked)) if checked: - Receiver.send_message(u'maindisplay_blank') + Receiver.send_message(u'maindisplay_hide', HideMode.Blank) else: Receiver.send_message(u'maindisplay_show') @@ -611,7 +602,7 @@ class SlideController(QtGui.QWidget): self.blankButton.setChecked(False) self.hideButton.setChecked(False) if checked: - Receiver.send_message(u'maindisplay_hide_theme') + Receiver.send_message(u'maindisplay_hide', HideMode.Theme) else: Receiver.send_message(u'maindisplay_show') @@ -623,30 +614,10 @@ class SlideController(QtGui.QWidget): self.blankButton.setChecked(False) self.themeButton.setChecked(False) if checked: - Receiver.send_message(u'maindisplay_hide') + Receiver.send_message(u'maindisplay_hide', HideMode.Screen) else: Receiver.send_message(u'maindisplay_show') - def blankScreen(self, checked): - """ - Blank the display screen. - """ - self.hideButton.setChecked(False) - self.themeButton.setChecked(False) -# if self.serviceItem is not None: -# if checked: -# Receiver.send_message( -# u'%s_blank' % self.serviceItem.name.lower(), -# [self.serviceItem, self.isLive]) -# else: -# Receiver.send_message(u'%s_unblank' -# % self.serviceItem.name.lower(), -# [self.serviceItem, self.isLive]) - if checked: - Receiver.send_message(u'maindisplay_blank') - else: - Receiver.send_message(u'maindisplay_show4') - def onSlideSelected(self): """ Generate the preview when you click on a slide. @@ -787,6 +758,9 @@ class SlideController(QtGui.QWidget): self.onSlideSelectedNext() def onEditSong(self): + """ + From the preview display requires the service Item to be editied + """ self.songEdit = True Receiver.send_message(u'%s_edit' % self.serviceItem.name.lower(), u'P:%s' % self.serviceItem.editId) @@ -801,9 +775,14 @@ class SlideController(QtGui.QWidget): self.serviceItem, row) def onMediaStart(self, item): + """ + Respond to the arrival of a media service item + """ + log.debug(u'SlideController onMediaStart') if self.isLive: Receiver.send_message(u'videodisplay_start', [item, self.blankButton.isChecked()]) + Receiver.send_message(u'maindisplay_hide', HideMode.Screen) else: self.mediaObject.stop() self.mediaObject.clearQueue() @@ -814,12 +793,20 @@ class SlideController(QtGui.QWidget): self.onMediaPlay() def onMediaPause(self): + """ + Respond to the Pause from the media Toolbar + """ + log.debug(u'SlideController onMediaPause') if self.isLive: Receiver.send_message(u'videodisplay_pause') else: self.mediaObject.pause() def onMediaPlay(self): + """ + Respond to the Play from the media Toolbar + """ + log.debug(u'SlideController onMediaPlay') if self.isLive: Receiver.send_message(u'videodisplay_play') else: @@ -828,6 +815,10 @@ class SlideController(QtGui.QWidget): self.mediaObject.play() def onMediaStop(self): + """ + Respond to the Stop from the media Toolbar + """ + log.debug(u'SlideController onMediaStop') if self.isLive: Receiver.send_message(u'videodisplay_stop') else: diff --git a/openlp/plugins/images/lib/mediaitem.py b/openlp/plugins/images/lib/mediaitem.py index e3a3084c4..0907a8222 100644 --- a/openlp/plugins/images/lib/mediaitem.py +++ b/openlp/plugins/images/lib/mediaitem.py @@ -122,7 +122,7 @@ class ImageMediaItem(MediaManagerItem): #if not present do not worry pass self.ListView.takeItem(item.row()) - SettingsManager.set_list( + SettingsManager.set_list(self.SettingsSection,\ self.SettingsSection, self.getFileList()) def loadList(self, list): diff --git a/openlp/plugins/media/lib/mediaitem.py b/openlp/plugins/media/lib/mediaitem.py index f594fe54c..fc7895fb1 100644 --- a/openlp/plugins/media/lib/mediaitem.py +++ b/openlp/plugins/media/lib/mediaitem.py @@ -97,7 +97,8 @@ class MediaMediaItem(MediaManagerItem): if item: row = self.ListView.row(item) self.ListView.takeItem(row) - SettingsManager.set_list(self.SettingsSection, self.getFileList()) + SettingsManager.set_list(self.SettingsSection, \ + self.SettingsSection, self.getFileList()) def loadList(self, list): for file in list: diff --git a/openlp/plugins/presentations/lib/mediaitem.py b/openlp/plugins/presentations/lib/mediaitem.py index f547f0633..3b91b3b94 100644 --- a/openlp/plugins/presentations/lib/mediaitem.py +++ b/openlp/plugins/presentations/lib/mediaitem.py @@ -167,7 +167,8 @@ class PresentationMediaItem(MediaManagerItem): if item: row = self.ListView.row(item) self.ListView.takeItem(row) - SettingsManager.set_list(self.SettingsSection, self.getFileList()) + SettingsManager.set_list(self.SettingsSection,\ + self.SettingsSection, self.getFileList()) filepath = unicode((item.data(QtCore.Qt.UserRole)).toString()) #not sure of this has errors #John please can you look at . From 72fa923937e54c4491bdbc773db6b49a0611d09c Mon Sep 17 00:00:00 2001 From: Jonathan Corwin Date: Thu, 29 Apr 2010 23:52:23 +0100 Subject: [PATCH 44/63] update browser if slide changes --- openlp/core/lib/eventreceiver.py | 26 +++++++- openlp/core/ui/slidecontroller.py | 35 ++++++----- openlp/plugins/remotes/lib/httpserver.py | 69 +++++++++++++++------ openlp/plugins/songusage/songusageplugin.py | 2 +- 4 files changed, 95 insertions(+), 37 deletions(-) diff --git a/openlp/core/lib/eventreceiver.py b/openlp/core/lib/eventreceiver.py index 6443a4795..73bfbbe61 100644 --- a/openlp/core/lib/eventreceiver.py +++ b/openlp/core/lib/eventreceiver.py @@ -65,11 +65,23 @@ class EventReceiver(QtCore.QObject): ``slidecontroller_{live|preview}_last`` Moves to the last slide + ``slidecontroller_{live|preview}_set`` + Moves to a specific slide, by index + ``slidecontroller_{live|preview}_started`` Broadcasts that an item has been made live/previewed ``slidecontroller_{live|preview}_change`` - Informs the slidecontroller that a slide change has occurred + Informs the slidecontroller that a slide change has occurred and to + update itself + + ``slidecontroller_{live|preview}_changed`` + Broadcasts that the slidecontroller has changed the current slide + + ``slidecontroller_{live|preview}_text_request`` + Request the text for the current item in the controller + Returns a slidecontroller_{live|preview}_text_response with an + array of dictionaries with the tag and verse text ``slidecontroller_live_spin_delay`` Pushes out the loop delay @@ -77,9 +89,19 @@ class EventReceiver(QtCore.QObject): ``slidecontroller_live_stop_loop`` Stop the loop on the main display - ``servicecontroller_next_item`` + ``servicemanager_previous_item`` + Display the previous item in the service + + ``servicemanager_next_item`` Display the next item in the service + ``servicemanager_set_item`` + Go live on a specific item, by index + + ``servicemanager_list_request`` + Request the service list. Responds with servicemanager_list_response + containing a array of dictionaries + ``maindisplay_blank`` Blank the maindisplay window diff --git a/openlp/core/ui/slidecontroller.py b/openlp/core/ui/slidecontroller.py index 9381a9f2b..02bde1e0c 100644 --- a/openlp/core/ui/slidecontroller.py +++ b/openlp/core/ui/slidecontroller.py @@ -565,9 +565,7 @@ class SlideController(QtGui.QWidget): self.enableToolBar(serviceItem) self.onSlideSelected() self.PreviewListWidget.setFocus() - Receiver.send_message(u'%s_%s_started' % - (self.serviceItem.name.lower(), - 'live' if self.isLive else 'preview'), + Receiver.send_message(u'slidecontroller_%s_started' % self.type_prefix, [serviceItem]) log.log(15, u'Display Rendering took %4s' % (time.time() - before)) @@ -576,19 +574,20 @@ class SlideController(QtGui.QWidget): Return the text for the current item in controller """ data = [] - for framenumber, frame in enumerate(self.serviceItem.get_frames()): - data_item = {} - if self.serviceItem.is_text(): - data_item[u'tag'] = unicode(frame[u'verseTag']) - data_item[u'text'] = unicode(frame[u'text']) - else: - data_item[u'tag'] = unicode(framenumber) - data_item[u'text'] = u'' - data_item[u'selected'] = \ - (self.PreviewListWidget.currentRow() == framenumber) - data.append(data_item) - Receiver.send_message(u'slidecontroller_%s_text_response' % self.type_prefix, - data) + if self.serviceItem: + for framenumber, frame in enumerate(self.serviceItem.get_frames()): + data_item = {} + if self.serviceItem.is_text(): + data_item[u'tag'] = unicode(frame[u'verseTag']) + data_item[u'text'] = unicode(frame[u'text']) + else: + data_item[u'tag'] = unicode(framenumber) + data_item[u'text'] = u'' + data_item[u'selected'] = \ + (self.PreviewListWidget.currentRow() == framenumber) + data.append(data_item) + Receiver.send_message(u'slidecontroller_%s_text_response' + % self.type_prefix, data) #Screen event methods def onSlideSelectedFirst(self): @@ -699,6 +698,8 @@ class SlideController(QtGui.QWidget): if self.isLive: self.mainDisplay.frameView(frame, True) self.selectedRow = row + Receiver.send_message(u'slidecontroller_%s_changed' % self.type_prefix, + row) def onSlideChange(self, row): """ @@ -706,6 +707,8 @@ class SlideController(QtGui.QWidget): """ self.PreviewListWidget.selectRow(row) self.updatePreview() + Receiver.send_message(u'slidecontroller_%s_changed' % self.type_prefix, + row) def updatePreview(self): rm = self.parent.RenderManager diff --git a/openlp/plugins/remotes/lib/httpserver.py b/openlp/plugins/remotes/lib/httpserver.py index c9acbaccc..d8c0a56f2 100644 --- a/openlp/plugins/remotes/lib/httpserver.py +++ b/openlp/plugins/remotes/lib/httpserver.py @@ -43,6 +43,8 @@ class HttpServer(object): log.debug(u'Initialise httpserver') self.parent = parent self.connections = [] + self.current_item = None + self.current_slide = None self.start_tcp() def start_tcp(self): @@ -53,10 +55,29 @@ class HttpServer(object): self.server = QtNetwork.QTcpServer() self.server.listen(QtNetwork.QHostAddress(QtNetwork.QHostAddress.Any), port) + QtCore.QObject.connect(Receiver.get_receiver(), + QtCore.SIGNAL(u'slidecontroller_live_changed'), + self.slide_change) + QtCore.QObject.connect(Receiver.get_receiver(), + QtCore.SIGNAL(u'slidecontroller_live_started'), + self.item_change) QtCore.QObject.connect(self.server, QtCore.SIGNAL(u'newConnection()'), self.new_connection) log.debug(u'TCP listening on port %d' % port) - + + def slide_change(self, row): + self.current_slide = row + self.send_poll() + + def item_change(self, items): + self.current_item = items[0].title + self.send_poll() + + def send_poll(self): + Receiver.send_message(u'remote_poll_response', + {'slide': self.current_slide, + 'item': self.current_item}) + def new_connection(self): log.debug(u'new http connection') socket = self.server.nextPendingConnection() @@ -121,8 +142,8 @@ class HttpConnection(object): function send_event(eventname, data){ var req = new XMLHttpRequest(); req.onreadystatechange = function() { - if(req.readyState==4 && req.status==200) - response(eventname, req.responseText); + if(req.readyState==4) + response(eventname, req); } var url = ''; if(eventname.substr(-8) == '_request') @@ -135,7 +156,20 @@ function send_event(eventname, data){ req.open('GET', url, true); req.send(); } -function response(eventname, text){ +function failed_response(eventname, req){ + switch(eventname){ + case 'remote_poll_request': + if(req.status==408) + send_event("remote_poll_request"); + break; + } +} +function response(eventname, req){ + if(req.status!=200){ + failed_response(eventname, req); + return; + } + text = req.responseText; switch(eventname){ case 'servicemanager_list_request': var data = eval('(' + text + ')'); @@ -155,11 +189,6 @@ function response(eventname, text){ html += ''; document.getElementById('service').innerHTML = html; break; - case 'servicemanager_previous_item': - case 'servicemanager_next_item': - case 'servicemanager_set_item': - send_event("servicemanager_list_request"); - break; case 'slidecontroller_live_text_request': var data = eval('(' + text + ')'); var html = ''; @@ -168,23 +197,24 @@ function response(eventname, text){ html += "'slidecontroller_live_set', " + row + ')"'; if(data[row]['selected']) html += ' style="font-weight: bold"'; - html += '>' - html += '' - html += '' - html += ''; + html += '>'; + html += ''; + html += ''; } html += '
' + data[row]['tag'] + '' + data[row]['text'] + '
' + data[row]['tag'] + '' + data[row]['text'].replace(/\\n/g, '
'); + html += '
'; document.getElementById('currentitem').innerHTML = html; break; - case 'slidecontroller_live_next': - case 'slidecontroller_live_previous': - case 'slidecontroller_live_set': + case 'remote_poll_request': + send_event("remote_poll_request"); + send_event("servicemanager_list_request"); send_event("slidecontroller_live_text_request"); break; - } } send_event("servicemanager_list_request"); +send_event("slidecontroller_live_text_request"); +send_event("remote_poll_request"); @@ -239,7 +269,10 @@ send_event("servicemanager_list_request"); self.timer.setSingleShot(True) QtCore.QObject.connect(self.timer, QtCore.SIGNAL(u'timeout()'), self.timeout) - self.timer.start(10000) + if event == 'remote_poll_request': + self.timer.start(60000) + else: + self.timer.start(10000) if params: Receiver.send_message(event, params) else: diff --git a/openlp/plugins/songusage/songusageplugin.py b/openlp/plugins/songusage/songusageplugin.py index da557e81e..9e45e6f0c 100644 --- a/openlp/plugins/songusage/songusageplugin.py +++ b/openlp/plugins/songusage/songusageplugin.py @@ -108,7 +108,7 @@ class SongUsagePlugin(Plugin): log.info(u'SongUsage Initialising') Plugin.initialise(self) QtCore.QObject.connect(Receiver.get_receiver(), - QtCore.SIGNAL(u'slidecontroller_live_started'), + QtCore.SIGNAL(u'songs_live_started'), self.onReceiveSongUsage) self.SongUsageActive = QtCore.QSettings().value( self.settings_section + u'/active', From 22b00a130f4ed0b5f8954b874c1cc19f58ff09ed Mon Sep 17 00:00:00 2001 From: Jon Tibble Date: Fri, 30 Apr 2010 02:31:41 +0100 Subject: [PATCH 45/63] Make settings_sections consistent --- openlp/core/lib/mediamanageritem.py | 18 +++++------- openlp/core/lib/settingstab.py | 2 +- openlp/core/ui/generaltab.py | 6 ++-- openlp/core/ui/mainwindow.py | 29 ++++++++++++------- openlp/core/ui/mediadockmanager.py | 5 ++-- openlp/core/ui/servicemanager.py | 29 ++++++++++--------- openlp/core/ui/slidecontroller.py | 6 ++-- openlp/core/ui/thememanager.py | 18 ++++++------ openlp/core/ui/themestab.py | 6 ++-- openlp/plugins/alerts/forms/alertstab.py | 4 +-- openlp/plugins/bibles/lib/biblestab.py | 4 +-- openlp/plugins/bibles/lib/mediaitem.py | 3 +- openlp/plugins/custom/lib/customtab.py | 4 +-- openlp/plugins/custom/lib/mediaitem.py | 3 +- openlp/plugins/images/lib/imagetab.py | 4 +-- openlp/plugins/images/lib/mediaitem.py | 9 +++--- openlp/plugins/media/lib/mediaitem.py | 6 ++-- openlp/plugins/presentations/lib/mediaitem.py | 15 ++++++---- .../presentations/lib/presentationtab.py | 4 +-- openlp/plugins/remotes/lib/remotetab.py | 4 +-- openlp/plugins/songs/lib/mediaitem.py | 3 +- openlp/plugins/songs/lib/songstab.py | 4 +-- .../songusage/forms/songusagedetailform.py | 7 ++--- 23 files changed, 97 insertions(+), 96 deletions(-) diff --git a/openlp/core/lib/mediamanageritem.py b/openlp/core/lib/mediamanageritem.py index 2d16687f4..83937160e 100644 --- a/openlp/core/lib/mediamanageritem.py +++ b/openlp/core/lib/mediamanageritem.py @@ -70,11 +70,6 @@ class MediaManagerItem(QtGui.QWidget): The user visible name for a plugin which should use a suitable translation function. - ``self.SettingsSection`` - The section in the configuration where the items in the media - manager are stored. This could potentially be - ``self.PluginNameShort.lower()``. - ``self.OnNewPrompt`` Defaults to *'Select Image(s)'*. @@ -103,6 +98,7 @@ class MediaManagerItem(QtGui.QWidget): """ QtGui.QWidget.__init__(self) self.parent = parent + self.settings_section = title.lower() if type(icon) is QtGui.QIcon: self.icon = icon elif type(icon) is types.StringType: @@ -335,20 +331,20 @@ class MediaManagerItem(QtGui.QWidget): def onFileClick(self): files = QtGui.QFileDialog.getOpenFileNames( self, self.OnNewPrompt, - SettingsManager.get_last_dir(self.SettingsSection), + SettingsManager.get_last_dir(self.settings_section), self.OnNewFileMasks) log.info(u'New files(s) %s', unicode(files)) if files: self.loadList(files) - dir, filename = os.path.split(unicode(files[0])) - SettingsManager.set_last_dir(self.SettingsSection, dir) - SettingsManager.set_list( - self.SettingsSection, self.SettingsSection, self.getFileList()) + dir = os.path.split(unicode(files[0]))[0] + SettingsManager.set_last_dir(self.settings_section, dir) + SettingsManager.set_list(self.settings_section, + self.settings_section, self.getFileList()) def getFileList(self): count = 0 filelist = [] - while count < self.ListView.count(): + while count < self.ListView.count(): bitem = self.ListView.item(count) filename = unicode((bitem.data(QtCore.Qt.UserRole)).toString()) filelist.append(filename) diff --git a/openlp/core/lib/settingstab.py b/openlp/core/lib/settingstab.py index 0b862d9f8..8b9cc4261 100644 --- a/openlp/core/lib/settingstab.py +++ b/openlp/core/lib/settingstab.py @@ -40,7 +40,7 @@ class SettingsTab(QtGui.QWidget): QtGui.QWidget.__init__(self) self.tabTitle = title self.tabTitleVisible = None - self.settingsSection = self.tabTitle.lower() + self.settings_section = self.tabTitle.lower() self.setupUi() self.retranslateUi() self.initialise() diff --git a/openlp/core/ui/generaltab.py b/openlp/core/ui/generaltab.py index 005e588ac..e622dad78 100644 --- a/openlp/core/ui/generaltab.py +++ b/openlp/core/ui/generaltab.py @@ -42,7 +42,7 @@ class GeneralTab(SettingsTab): If not set before default to last screen. """ settings = QtCore.QSettings() - settings.beginGroup(self.settingsSection) + settings.beginGroup(self.settings_section) self.MonitorNumber = settings.value(u'monitor', QtCore.QVariant(self.screens.monitor_number)).toInt()[0] self.screens.set_current_display(self.MonitorNumber) @@ -229,7 +229,7 @@ class GeneralTab(SettingsTab): def load(self): settings = QtCore.QSettings() - settings.beginGroup(self.settingsSection) + settings.beginGroup(self.settings_section) for screen in self.screens.screen_list: screen_name = u'%s %d' % (self.trUtf8('Screen'), screen[u'number'] + 1) @@ -268,7 +268,7 @@ class GeneralTab(SettingsTab): def save(self): settings = QtCore.QSettings() - settings.beginGroup(self.settingsSection) + settings.beginGroup(self.settings_section) settings.setValue(u'monitor', QtCore.QVariant(self.MonitorNumber)) settings.setValue(u'display on monitor', QtCore.QVariant(self.DisplayOnMonitor)) diff --git a/openlp/core/ui/mainwindow.py b/openlp/core/ui/mainwindow.py index f3ceb18be..13567a7d9 100644 --- a/openlp/core/ui/mainwindow.py +++ b/openlp/core/ui/mainwindow.py @@ -424,8 +424,12 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow): QtGui.QMainWindow.__init__(self) self.screens = screens self.applicationVersion = applicationVersion - self.generalSettingsSection = u'general' - self.uiSettingsSection = u'user interface' + # Set up settings sections for the main application + # (not for use by plugins) + self.ui_settings_section = u'user interface' + self.general_settings_section = u'general' + self.service_settings_section = u'servicemanager' + self.songs_settings_section = u'songs' self.serviceNotSaved = False self.settingsmanager = SettingsManager(screens) self.displayManager = DisplayManager(screens) @@ -570,7 +574,8 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow): if self.displayManager.mainDisplay.isVisible(): self.displayManager.mainDisplay.setFocus() self.activateWindow() - if QtCore.QSettings().value(self.generalSettingsSection + u'/auto open', + if QtCore.QSettings().value( + self.general_settings_section + u'/auto open', QtCore.QVariant(False)).toBool(): self.ServiceManagerContents.onLoadService(True) @@ -580,7 +585,7 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow): Triggered by delay thread. """ settings = QtCore.QSettings() - settings.beginGroup(self.generalSettingsSection) + settings.beginGroup(self.general_settings_section) if settings.value(u'screen blank', QtCore.QVariant(False)).toBool() \ and settings.value(u'blank warning', QtCore.QVariant(False)).toBool(): self.LiveController.onBlankDisplay(True) @@ -725,9 +730,10 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow): def loadSettings(self): log.debug(u'Loading QSettings') settings = QtCore.QSettings() - self.recentFiles = settings.value( - self.generalSettingsSection + u'/recent files').toStringList() - settings.beginGroup(self.uiSettingsSection) + settings.beginGroup(self.general_settings_section) + self.recentFiles = settings.value(u'recent files').toStringList() + settings.endGroup() + settings.beginGroup(self.ui_settings_section) self.move(settings.value(u'main window position', QtCore.QVariant(QtCore.QPoint(0, 0))).toPoint()) self.restoreGeometry( @@ -738,11 +744,12 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow): def saveSettings(self): log.debug(u'Saving QSettings') settings = QtCore.QSettings() + settings.beginGroup(self.general_settings_section) recentFiles = QtCore.QVariant(self.recentFiles) \ if self.recentFiles else QtCore.QVariant() - settings.setValue( - self.generalSettingsSection + u'/recent files', recentFiles) - settings.beginGroup(self.uiSettingsSection) + settings.setValue(u'recent files', recentFiles) + settings.endGroup() + settings.beginGroup(self.ui_settings_section) settings.setValue(u'main window position', QtCore.QVariant(self.pos())) settings.setValue(u'main window state', @@ -772,7 +779,7 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow): def addRecentFile(self, filename): recentFileCount = QtCore.QSettings().value( - self.generalSettingsSection + u'/max recent files', + self.general_settings_section + u'/max recent files', QtCore.QVariant(4)).toInt()[0] if filename and not self.recentFiles.contains(filename): self.recentFiles.prepend(QtCore.QString(filename)) diff --git a/openlp/core/ui/mediadockmanager.py b/openlp/core/ui/mediadockmanager.py index ae77cc43a..aece0729e 100644 --- a/openlp/core/ui/mediadockmanager.py +++ b/openlp/core/ui/mediadockmanager.py @@ -45,18 +45,17 @@ class MediaDockManager(object): log.debug(u'Inserting %s dock' % media_item.title) match = False for dock_index in range(0, self.media_dock.count()): - if self.media_dock.widget(dock_index).SettingsSection == \ + if self.media_dock.widget(dock_index).settings_section == \ media_item.title.lower(): match = True break if not match: self.media_dock.addItem(media_item, icon, media_item.title) - def remove_dock(self, name): log.debug(u'remove %s dock' % name) for dock_index in range(0, self.media_dock.count()): if self.media_dock.widget(dock_index): - if self.media_dock.widget(dock_index).SettingsSection == name: + if self.media_dock.widget(dock_index).settings_section == name: self.media_dock.widget(dock_index).hide() self.media_dock.removeItem(dock_index) diff --git a/openlp/core/ui/servicemanager.py b/openlp/core/ui/servicemanager.py index 45d007c17..2a4da68a4 100644 --- a/openlp/core/ui/servicemanager.py +++ b/openlp/core/ui/servicemanager.py @@ -99,8 +99,6 @@ class ServiceManager(QtGui.QWidget): """ QtGui.QWidget.__init__(self) self.parent = parent - self.settingsSection = u'servicemanager' - self.generalSettingsSection = self.parent.generalSettingsSection self.serviceItems = [] self.serviceName = u'' self.droppos = 0 @@ -193,7 +191,7 @@ class ServiceManager(QtGui.QWidget): QtCore.SIGNAL(u'config_updated'), self.regenerateServiceItems) # Last little bits of setting up self.service_theme = unicode(QtCore.QSettings().value( - self.settingsSection + u'/service theme', + self.parent.service_settings_section + u'/service theme', QtCore.QVariant(u'')).toString()) self.servicePath = AppLocation.get_section_data_path(u'servicemanager') #build the context menu @@ -406,7 +404,7 @@ class ServiceManager(QtGui.QWidget): Clear the list to create a new service """ if self.parent.serviceNotSaved and QtCore.QSettings().value( - self.generalSettingsSection + u'/save prompt', + self.parent.general_settings_section + u'/save prompt', QtCore.QVariant(False)).toBool(): ret = QtGui.QMessageBox.question(self, self.trUtf8('Save Changes to Service?'), @@ -491,17 +489,19 @@ class ServiceManager(QtGui.QWidget): if not quick or self.isNew: filename = QtGui.QFileDialog.getSaveFileName(self, self.trUtf8(u'Save Service'), - SettingsManager.get_last_dir(self.settingsSection), + SettingsManager.get_last_dir(self.parent.service_settings_section), self.trUtf8(u'OpenLP Service Files (*.osz)')) else: - filename = SettingsManager.get_last_dir(self.settingsSection) + filename = SettingsManager.get_last_dir( + self.parent.service_settings_section) if filename: splittedFile = filename.split(u'.') if splittedFile[-1] != u'osz': filename = filename + u'.osz' filename = unicode(filename) self.isNew = False - SettingsManager.set_last_dir(self.settingsSection, filename) + SettingsManager.set_last_dir( + self.parent.service_settings_section, filename) service = [] servicefile = filename + u'.osd' zip = None @@ -542,12 +542,13 @@ class ServiceManager(QtGui.QWidget): def onLoadService(self, lastService=False): if lastService: - filename = SettingsManager.get_last_dir(self.settingsSection) + filename = SettingsManager.get_last_dir( + self.parent.service_settings_section) else: filename = QtGui.QFileDialog.getOpenFileName( self, self.trUtf8('Open Service'), - SettingsManager.get_last_dir(self.settingsSection), - u'Services (*.osz)') + SettingsManager.get_last_dir( + self.parent.service_settings_section), u'Services (*.osz)') self.loadService(filename) def loadService(self, filename=None): @@ -576,7 +577,8 @@ class ServiceManager(QtGui.QWidget): filename = unicode(filename) name = filename.split(os.path.sep) if filename: - SettingsManager.set_last_dir(self.settingsSection, filename) + SettingsManager.set_last_dir( + self.parent.service_settings_section, filename) zip = None f = None try: @@ -645,7 +647,8 @@ class ServiceManager(QtGui.QWidget): """ self.service_theme = unicode(self.ThemeComboBox.currentText()) self.parent.RenderManager.set_service_theme(self.service_theme) - QtCore.QSettings().setValue(self.settingsSection + u'/service theme', + QtCore.QSettings().setValue( + self.parent.service_settings_section + u'/service theme', QtCore.QVariant(self.service_theme)) self.regenerateServiceItems() @@ -729,7 +732,7 @@ class ServiceManager(QtGui.QWidget): self.parent.LiveController.addServiceManagerItem( self.serviceItems[item][u'service_item'], count) if QtCore.QSettings().value( - self.generalSettingsSection + u'/auto preview', + self.parent.general_settings_section + u'/auto preview', QtCore.QVariant(False)).toBool(): item += 1 if self.serviceItems and item < len(self.serviceItems) and \ diff --git a/openlp/core/ui/slidecontroller.py b/openlp/core/ui/slidecontroller.py index 811fd51e3..d84a64c2a 100644 --- a/openlp/core/ui/slidecontroller.py +++ b/openlp/core/ui/slidecontroller.py @@ -93,8 +93,6 @@ class SlideController(QtGui.QWidget): """ QtGui.QWidget.__init__(self, parent) self.settingsmanager = settingsmanager - self.generalSettingsSection = u'general' - self.songsSettingsSection = u'songs' self.isLive = isLive self.parent = parent self.mainDisplay = self.parent.displayManager.mainDisplay @@ -399,7 +397,7 @@ class SlideController(QtGui.QWidget): if item.is_text(): self.Toolbar.makeWidgetsInvisible(self.loop_list) if QtCore.QSettings().value( - self.songsSettingsSection + u'/show songbar', + self.parent.songs_settings_section + u'/show songbar', QtCore.QVariant(True)).toBool() and len(self.slideList) > 0: self.Toolbar.makeWidgetsVisible([u'Song Menu']) if item.is_capable(ItemCapabilities.AllowsLoop) and \ @@ -589,7 +587,7 @@ class SlideController(QtGui.QWidget): self.blankButton.setChecked(True) self.blankScreen(HideMode.Blank, self.blankButton.isChecked()) QtCore.QSettings().setValue( - self.generalSettingsSection + u'/screen blank', + self.parent.general_settings_section + u'/screen blank', QtCore.QVariant(self.blankButton.isChecked())) def onThemeDisplay(self, force=False): diff --git a/openlp/core/ui/thememanager.py b/openlp/core/ui/thememanager.py index 797a6a27a..1d45415b6 100644 --- a/openlp/core/ui/thememanager.py +++ b/openlp/core/ui/thememanager.py @@ -47,7 +47,7 @@ class ThemeManager(QtGui.QWidget): def __init__(self, parent): QtGui.QWidget.__init__(self, parent) self.parent = parent - self.settingsSection = u'themes' + self.settings_section = u'themes' self.Layout = QtGui.QVBoxLayout(self) self.Layout.setSpacing(0) self.Layout.setMargin(0) @@ -106,14 +106,14 @@ class ThemeManager(QtGui.QWidget): QtCore.SIGNAL(u'theme_update_global'), self.changeGlobalFromTab) #Variables self.themelist = [] - self.path = AppLocation.get_section_data_path(self.settingsSection) + self.path = AppLocation.get_section_data_path(self.settings_section) self.checkThemesExists(self.path) self.thumbPath = os.path.join(self.path, u'.thumbnails') self.checkThemesExists(self.thumbPath) self.amendThemeForm.path = self.path # Last little bits of setting up self.global_theme = unicode(QtCore.QSettings().value( - self.settingsSection + u'/global theme', + self.settings_section + u'/global theme', QtCore.QVariant(u'')).toString()) def changeGlobalFromTab(self, themeName): @@ -147,7 +147,7 @@ class ThemeManager(QtGui.QWidget): name = u'%s (%s)' % (self.global_theme, self.trUtf8('default')) self.ThemeListWidget.item(count).setText(name) QtCore.QSettings().setValue( - self.settingsSection + u'/global theme', + self.settings_section + u'/global theme', QtCore.QVariant(self.global_theme)) Receiver.send_message(u'theme_update_global', self.global_theme) self.pushThemes() @@ -170,7 +170,7 @@ class ThemeManager(QtGui.QWidget): def onDeleteTheme(self): self.global_theme = unicode(QtCore.QSettings().value( - self.settingsSection + u'/global theme', + self.settings_section + u'/global theme', QtCore.QVariant(u'')).toString()) item = self.ThemeListWidget.currentItem() if item: @@ -224,10 +224,10 @@ class ThemeManager(QtGui.QWidget): theme = unicode(item.data(QtCore.Qt.UserRole).toString()) path = QtGui.QFileDialog.getExistingDirectory(self, unicode(self.trUtf8('Save Theme - (%s)')) % theme, - SettingsManager.get_last_dir(self.settingsSection, 1)) + SettingsManager.get_last_dir(self.settings_section, 1)) path = unicode(path) if path: - SettingsManager.set_last_dir(self.settingsSection, path, 1) + SettingsManager.set_last_dir(self.settings_section, path, 1) themePath = os.path.join(path, theme + u'.theme') zip = None try: @@ -247,12 +247,12 @@ class ThemeManager(QtGui.QWidget): def onImportTheme(self): files = QtGui.QFileDialog.getOpenFileNames( self, self.trUtf8('Select Theme Import File'), - SettingsManager.get_last_dir(self.settingsSection), u'Theme (*.*)') + SettingsManager.get_last_dir(self.settings_section), u'Theme (*.*)') log.info(u'New Themes %s', unicode(files)) if files: for file in files: SettingsManager.set_last_dir( - self.settingsSection, unicode(file)) + self.settings_section, unicode(file)) self.unzipTheme(file, self.path) self.loadThemes() diff --git a/openlp/core/ui/themestab.py b/openlp/core/ui/themestab.py index dba07eb6d..09e6cadaa 100644 --- a/openlp/core/ui/themestab.py +++ b/openlp/core/ui/themestab.py @@ -124,7 +124,7 @@ class ThemesTab(SettingsTab): def load(self): settings = QtCore.QSettings() - settings.beginGroup(self.settingsSection) + settings.beginGroup(self.settings_section) self.theme_level = settings.value( u'theme level', QtCore.QVariant(ThemeLevel.Global)).toInt()[0] self.global_theme = unicode(settings.value( @@ -139,7 +139,7 @@ class ThemesTab(SettingsTab): def save(self): settings = QtCore.QSettings() - settings.beginGroup(self.settingsSection) + settings.beginGroup(self.settings_section) settings.setValue(u'theme level', QtCore.QVariant(self.theme_level)) settings.setValue(u'global theme', @@ -179,7 +179,7 @@ class ThemesTab(SettingsTab): """ #reload as may have been triggered by the ThemeManager self.global_theme = unicode(QtCore.QSettings().value( - self.settingsSection + u'/global theme', + self.settings_section + u'/global theme', QtCore.QVariant(u'')).toString()) self.DefaultComboBox.clear() for theme in theme_list: diff --git a/openlp/plugins/alerts/forms/alertstab.py b/openlp/plugins/alerts/forms/alertstab.py index 7cda09488..53b8d2a7a 100644 --- a/openlp/plugins/alerts/forms/alertstab.py +++ b/openlp/plugins/alerts/forms/alertstab.py @@ -229,7 +229,7 @@ class AlertsTab(SettingsTab): def load(self): settings = QtCore.QSettings() - settings.beginGroup(self.settingsSection) + settings.beginGroup(self.settings_section) self.timeout = settings.value(u'timeout', QtCore.QVariant(5)).toInt()[0] self.font_color = unicode(settings.value( u'font color', QtCore.QVariant(u'#ffffff')).toString()) @@ -260,7 +260,7 @@ class AlertsTab(SettingsTab): def save(self): settings = QtCore.QSettings() - settings.beginGroup(self.settingsSection) + settings.beginGroup(self.settings_section) self.font_face = self.FontComboBox.currentFont().family() settings.setValue(u'background color', QtCore.QVariant(self.bg_color)) settings.setValue(u'font color', QtCore.QVariant(self.font_color)) diff --git a/openlp/plugins/bibles/lib/biblestab.py b/openlp/plugins/bibles/lib/biblestab.py index 80e0cef5e..7d3b7eb8c 100644 --- a/openlp/plugins/bibles/lib/biblestab.py +++ b/openlp/plugins/bibles/lib/biblestab.py @@ -189,7 +189,7 @@ class BiblesTab(SettingsTab): def load(self): settings = QtCore.QSettings() - settings.beginGroup(self.settingsSection) + settings.beginGroup(self.settings_section) self.show_new_chapters = settings.value( u'display new chapter', QtCore.QVariant(False)).toBool() self.display_style = settings.value( @@ -208,7 +208,7 @@ class BiblesTab(SettingsTab): def save(self): settings = QtCore.QSettings() - settings.beginGroup(self.settingsSection) + settings.beginGroup(self.settings_section) settings.setValue(u'display new chapter', QtCore.QVariant(self.show_new_chapters)) settings.setValue(u'display brackets', diff --git a/openlp/plugins/bibles/lib/mediaitem.py b/openlp/plugins/bibles/lib/mediaitem.py index c448e5066..228e39d5a 100644 --- a/openlp/plugins/bibles/lib/mediaitem.py +++ b/openlp/plugins/bibles/lib/mediaitem.py @@ -54,7 +54,6 @@ class BibleMediaItem(MediaManagerItem): def __init__(self, parent, icon, title): self.PluginNameShort = u'Bible' - self.SettingsSection = title.lower() self.IconPath = u'songs/song' self.ListViewWithDnD_class = BibleListView self.lastReference = [] @@ -276,7 +275,7 @@ class BibleMediaItem(MediaManagerItem): self.SearchProgress.setObjectName(u'SearchProgress') def configUpdated(self): - if QtCore.QSettings().value(self.SettingsSection + u'/dual bibles', + if QtCore.QSettings().value(self.settings_section + u'/dual bibles', QtCore.QVariant(False)).toBool(): self.AdvancedSecondBibleLabel.setVisible(True) self.AdvancedSecondBibleComboBox.setVisible(True) diff --git a/openlp/plugins/custom/lib/customtab.py b/openlp/plugins/custom/lib/customtab.py index 2b6cedfbf..2917487ff 100644 --- a/openlp/plugins/custom/lib/customtab.py +++ b/openlp/plugins/custom/lib/customtab.py @@ -67,10 +67,10 @@ class CustomTab(SettingsTab): def load(self): self.displayFooter = QtCore.QSettings().value( - self.settingsSection + u'/display footer', + self.settings_section + u'/display footer', QtCore.QVariant(True)).toBool() self.DisplayFooterCheckBox.setChecked(self.displayFooter) def save(self): - QtCore.QSettings().setValue(self.settingsSection + u'/display footer', + QtCore.QSettings().setValue(self.settings_section + u'/display footer', QtCore.QVariant(self.displayFooter)) diff --git a/openlp/plugins/custom/lib/mediaitem.py b/openlp/plugins/custom/lib/mediaitem.py index c1f4ff1e6..171317e1b 100644 --- a/openlp/plugins/custom/lib/mediaitem.py +++ b/openlp/plugins/custom/lib/mediaitem.py @@ -45,7 +45,6 @@ class CustomMediaItem(MediaManagerItem): def __init__(self, parent, icon, title): self.PluginNameShort = u'Custom' - self.SettingsSection = title.lower() self.IconPath = u'custom/custom' # this next is a class, not an instance of a class - it will # be instanced by the base MediaManagerItem @@ -164,7 +163,7 @@ class CustomMediaItem(MediaManagerItem): service_item.title = title for slide in raw_slides: service_item.add_from_text(slide[:30], slide) - if QtCore.QSettings().value(self.SettingsSection + u'/display footer', + if QtCore.QSettings().value(self.settings_section + u'/display footer', QtCore.QVariant(True)).toBool() or credit: raw_footer.append(title + u' ' + credit) else: diff --git a/openlp/plugins/images/lib/imagetab.py b/openlp/plugins/images/lib/imagetab.py index 346d28b16..0cc531c0c 100644 --- a/openlp/plugins/images/lib/imagetab.py +++ b/openlp/plugins/images/lib/imagetab.py @@ -72,12 +72,12 @@ class ImageTab(SettingsTab): def load(self): self.loop_delay = QtCore.QSettings().value( - self.settingsSection + u'/loop delay', + self.settings_section + u'/loop delay', QtCore.QVariant(5)).toInt()[0] self.TimeoutSpinBox.setValue(self.loop_delay) def save(self): - QtCore.QSettings().setValue(self.settingsSection + u'/loop delay', + QtCore.QSettings().setValue(self.settings_section + u'/loop delay', QtCore.QVariant(self.loop_delay)) Receiver.send_message(u'slidecontroller_live_spin_delay', self.loop_delay) diff --git a/openlp/plugins/images/lib/mediaitem.py b/openlp/plugins/images/lib/mediaitem.py index 32ed5edb6..e417d6960 100644 --- a/openlp/plugins/images/lib/mediaitem.py +++ b/openlp/plugins/images/lib/mediaitem.py @@ -49,7 +49,6 @@ class ImageMediaItem(MediaManagerItem): def __init__(self, parent, icon, title): self.PluginNameShort = u'Image' - self.SettingsSection = title.lower() self.IconPath = u'images/image' # this next is a class, not an instance of a class - it will # be instanced by the base MediaManagerItem @@ -78,12 +77,12 @@ class ImageMediaItem(MediaManagerItem): QtGui.QAbstractItemView.ExtendedSelection) self.ListView.setIconSize(QtCore.QSize(88,50)) self.servicePath = os.path.join( - AppLocation.get_section_data_path(self.SettingsSection), + AppLocation.get_section_data_path(self.settings_section), u'.thumbnails') if not os.path.exists(self.servicePath): os.mkdir(self.servicePath) self.loadList(SettingsManager.load_list( - self.SettingsSection, self.SettingsSection)) + self.settings_section, self.settings_section)) def addListViewToToolBar(self): MediaManagerItem.addListViewToToolBar(self) @@ -122,8 +121,8 @@ class ImageMediaItem(MediaManagerItem): #if not present do not worry pass self.ListView.takeItem(item.row()) - SettingsManager.set_list( - self.SettingsSection, self.getFileList()) + SettingsManager.set_list(self.settings_section, + self.settings_section, self.getFileList()) def loadList(self, list): for file in list: diff --git a/openlp/plugins/media/lib/mediaitem.py b/openlp/plugins/media/lib/mediaitem.py index f594fe54c..dee49f429 100644 --- a/openlp/plugins/media/lib/mediaitem.py +++ b/openlp/plugins/media/lib/mediaitem.py @@ -47,7 +47,6 @@ class MediaMediaItem(MediaManagerItem): def __init__(self, parent, icon, title): self.PluginNameShort = u'Media' self.IconPath = u'images/image' - self.SettingsSection = title.lower() # this next is a class, not an instance of a class - it will # be instanced by the base MediaManagerItem self.ListViewWithDnD_class = MediaListView @@ -90,14 +89,15 @@ class MediaMediaItem(MediaManagerItem): QtGui.QAbstractItemView.ExtendedSelection) self.ListView.setIconSize(QtCore.QSize(88,50)) self.loadList(SettingsManager.load_list( - self.SettingsSection, self.SettingsSection)) + self.settings_section, self.settings_section)) def onDeleteClick(self): item = self.ListView.currentItem() if item: row = self.ListView.row(item) self.ListView.takeItem(row) - SettingsManager.set_list(self.SettingsSection, self.getFileList()) + SettingsManager.set_list(self.settings_section, + self.settings_section, self.getFileList()) def loadList(self, list): for file in list: diff --git a/openlp/plugins/presentations/lib/mediaitem.py b/openlp/plugins/presentations/lib/mediaitem.py index f547f0633..e8ac32a44 100644 --- a/openlp/plugins/presentations/lib/mediaitem.py +++ b/openlp/plugins/presentations/lib/mediaitem.py @@ -52,7 +52,6 @@ class PresentationMediaItem(MediaManagerItem): def __init__(self, parent, icon, title, controllers): self.controllers = controllers self.PluginNameShort = u'Presentation' - self.SettingsSection = title.lower() self.IconPath = u'presentations/presentation' self.Automatic = u'' # this next is a class, not an instance of a class - it will @@ -107,11 +106,12 @@ class PresentationMediaItem(MediaManagerItem): def initialise(self): self.servicePath = os.path.join( - AppLocation.get_section_data_path(self.SettingsSection), + AppLocation.get_section_data_path(self.settings_section), u'thumbnails') if not os.path.exists(self.servicePath): os.mkdir(self.servicePath) - list = SettingsManager.load_list(self.SettingsSection, u'presentations') + list = SettingsManager.load_list( + self.settings_section, u'presentations') self.loadList(list) for item in self.controllers: #load the drop down selection @@ -139,11 +139,13 @@ class PresentationMediaItem(MediaManagerItem): icon = None for controller in self.controllers: thumbPath = os.path.join( - AppLocation.get_section_data_path(self.SettingsSection), + AppLocation.get_section_data_path( + self.settings_section), u'thumbnails', controller, filename) thumb = os.path.join(thumbPath, u'slide1.png') preview = os.path.join( - AppLocation.get_section_data_path(self.SettingsSection), + AppLocation.get_section_data_path( + self.settings_section), controller, u'thumbnails', filename, u'slide1.png') if os.path.exists(preview): if os.path.exists(thumb): @@ -167,7 +169,8 @@ class PresentationMediaItem(MediaManagerItem): if item: row = self.ListView.row(item) self.ListView.takeItem(row) - SettingsManager.set_list(self.SettingsSection, self.getFileList()) + SettingsManager.set_list(self.settings_section, + self.settings_section, self.getFileList()) filepath = unicode((item.data(QtCore.Qt.UserRole)).toString()) #not sure of this has errors #John please can you look at . diff --git a/openlp/plugins/presentations/lib/presentationtab.py b/openlp/plugins/presentations/lib/presentationtab.py index ebcbb3d7b..998753a59 100644 --- a/openlp/plugins/presentations/lib/presentationtab.py +++ b/openlp/plugins/presentations/lib/presentationtab.py @@ -101,7 +101,7 @@ class PresentationTab(SettingsTab): if controller.available: checkbox = self.PresenterCheckboxes[controller.name] checkbox.setChecked(QtCore.QSettings().value( - self.settingsSection + u'/' + controller.name, + self.settings_section + u'/' + controller.name, QtCore.QVariant(0)).toInt()[0]) def save(self): @@ -109,5 +109,5 @@ class PresentationTab(SettingsTab): controller = self.controllers[key] checkbox = self.PresenterCheckboxes[controller.name] QtCore.QSettings().setValue( - self.settingsSection + u'/' + controller.name, + self.settings_section + u'/' + controller.name, QtCore.QVariant(checkbox.checkState())) diff --git a/openlp/plugins/remotes/lib/remotetab.py b/openlp/plugins/remotes/lib/remotetab.py index abdda065f..2e38c1e2b 100644 --- a/openlp/plugins/remotes/lib/remotetab.py +++ b/openlp/plugins/remotes/lib/remotetab.py @@ -57,9 +57,9 @@ class RemoteTab(SettingsTab): def load(self): self.RemotePortSpinBox.setValue( - QtCore.QSettings().value(self.settingsSection + u'/remote port', + QtCore.QSettings().value(self.settings_section + u'/remote port', QtCore.QVariant(4316)).toInt()[0]) def save(self): - QtCore.QSettings().setValue(self.settingsSection + u'/remote port', + QtCore.QSettings().setValue(self.settings_section + u'/remote port', QtCore.QVariant(self.RemotePortSpinBox.value())) diff --git a/openlp/plugins/songs/lib/mediaitem.py b/openlp/plugins/songs/lib/mediaitem.py index 84af7e6d0..6a99c4ef7 100644 --- a/openlp/plugins/songs/lib/mediaitem.py +++ b/openlp/plugins/songs/lib/mediaitem.py @@ -46,7 +46,6 @@ class SongMediaItem(MediaManagerItem): def __init__(self, parent, icon, title): self.PluginNameShort = u'Song' - self.SettingsSection = title.lower() self.IconPath = u'songs/song' self.ListViewWithDnD_class = SongListView MediaManagerItem.__init__(self, parent, icon, title) @@ -134,7 +133,7 @@ class SongMediaItem(MediaManagerItem): def configUpdated(self): self.searchAsYouType = QtCore.QSettings().value( - self.SettingsSection + u'/search as type', + self.settings_section + u'/search as type', QtCore.QVariant(u'False')).toBool() def retranslateUi(self): diff --git a/openlp/plugins/songs/lib/songstab.py b/openlp/plugins/songs/lib/songstab.py index 38bdd791d..36438f6fc 100644 --- a/openlp/plugins/songs/lib/songstab.py +++ b/openlp/plugins/songs/lib/songstab.py @@ -81,7 +81,7 @@ class SongsTab(SettingsTab): def load(self): settings = QtCore.QSettings() - settings.beginGroup(self.settingsSection) + settings.beginGroup(self.settings_section) self.song_search = settings.value( u'search as type', QtCore.QVariant(False)).toBool() self.song_bar = settings.value( @@ -92,7 +92,7 @@ class SongsTab(SettingsTab): def save(self): settings = QtCore.QSettings() - settings.beginGroup(self.settingsSection) + settings.beginGroup(self.settings_section) settings.setValue(u'search as type', QtCore.QVariant(self.song_search)) settings.setValue(u'display songbar', QtCore.QVariant(self.song_bar)) settings.endGroup() diff --git a/openlp/plugins/songusage/forms/songusagedetailform.py b/openlp/plugins/songusage/forms/songusagedetailform.py index 97359807f..c6156e55c 100644 --- a/openlp/plugins/songusage/forms/songusagedetailform.py +++ b/openlp/plugins/songusage/forms/songusagedetailform.py @@ -45,7 +45,6 @@ class SongUsageDetailForm(QtGui.QDialog, Ui_SongUsageDetailDialog): """ QtGui.QDialog.__init__(self, None) self.parent = parent - self.settingsSection = u'songusage' self.setupUi(self) def initialise(self): @@ -57,15 +56,15 @@ class SongUsageDetailForm(QtGui.QDialog, Ui_SongUsageDetailDialog): self.FromDate.setSelectedDate(fromDate) self.ToDate.setSelectedDate(toDate) self.FileLineEdit.setText( - SettingsManager.get_last_dir(self.settingsSection, 1)) + SettingsManager.get_last_dir(self.parent.settings_section, 1)) def defineOutputLocation(self): path = QtGui.QFileDialog.getExistingDirectory(self, self.trUtf8('Output File Location'), - SettingsManager.get_last_dir(self.settingsSection, 1)) + SettingsManager.get_last_dir(self.parent.settings_section, 1)) path = unicode(path) if path != u'': - SettingsManager.set_last_dir(self.settingsSection, path, 1) + SettingsManager.set_last_dir(self.parent.settings_section, path, 1) self.FileLineEdit.setText(path) def accept(self): From a582d097520553079b2f95b8c4c3a6cdca13907e Mon Sep 17 00:00:00 2001 From: Jon Tibble Date: Fri, 30 Apr 2010 02:35:41 +0100 Subject: [PATCH 46/63] Make plugin tab file locations consistent --- openlp/plugins/alerts/forms/__init__.py | 1 - openlp/plugins/alerts/lib/__init__.py | 1 + openlp/plugins/alerts/{forms => lib}/alertstab.py | 0 3 files changed, 1 insertion(+), 1 deletion(-) rename openlp/plugins/alerts/{forms => lib}/alertstab.py (100%) diff --git a/openlp/plugins/alerts/forms/__init__.py b/openlp/plugins/alerts/forms/__init__.py index 2ef91059f..9cccd8a01 100644 --- a/openlp/plugins/alerts/forms/__init__.py +++ b/openlp/plugins/alerts/forms/__init__.py @@ -23,5 +23,4 @@ # Temple Place, Suite 330, Boston, MA 02111-1307 USA # ############################################################################### -from alertstab import AlertsTab from alertform import AlertForm diff --git a/openlp/plugins/alerts/lib/__init__.py b/openlp/plugins/alerts/lib/__init__.py index 59a27b28e..81a2641f6 100644 --- a/openlp/plugins/alerts/lib/__init__.py +++ b/openlp/plugins/alerts/lib/__init__.py @@ -24,4 +24,5 @@ ############################################################################### from alertsmanager import AlertsManager +from alertstab import AlertsTab from manager import DBManager diff --git a/openlp/plugins/alerts/forms/alertstab.py b/openlp/plugins/alerts/lib/alertstab.py similarity index 100% rename from openlp/plugins/alerts/forms/alertstab.py rename to openlp/plugins/alerts/lib/alertstab.py From 8d6a624c6cd6d1bf79359cbe0ed7c41c3cf805a2 Mon Sep 17 00:00:00 2001 From: Jon Tibble Date: Fri, 30 Apr 2010 02:43:05 +0100 Subject: [PATCH 47/63] Fix break --- openlp/plugins/alerts/alertsplugin.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/openlp/plugins/alerts/alertsplugin.py b/openlp/plugins/alerts/alertsplugin.py index 2ec2db506..b3c72cc3f 100644 --- a/openlp/plugins/alerts/alertsplugin.py +++ b/openlp/plugins/alerts/alertsplugin.py @@ -28,8 +28,8 @@ import logging from PyQt4 import QtCore, QtGui from openlp.core.lib import Plugin, build_icon, PluginStatus -from openlp.plugins.alerts.lib import AlertsManager, DBManager -from openlp.plugins.alerts.forms import AlertsTab, AlertForm +from openlp.plugins.alerts.lib import AlertsManager, AlertsTab, DBManager +from openlp.plugins.alerts.forms import AlertForm log = logging.getLogger(__name__) From c6a7549d12a158be45af078007dfe4ee6b003d25 Mon Sep 17 00:00:00 2001 From: Jon Tibble Date: Fri, 30 Apr 2010 02:59:15 +0100 Subject: [PATCH 48/63] Make settings_section/last directory entries consistent --- openlp/core/ui/servicemanager.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/openlp/core/ui/servicemanager.py b/openlp/core/ui/servicemanager.py index 2a4da68a4..56ac3e8b4 100644 --- a/openlp/core/ui/servicemanager.py +++ b/openlp/core/ui/servicemanager.py @@ -1,3 +1,4 @@ +import os.path # -*- coding: utf-8 -*- # vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4 @@ -501,7 +502,8 @@ class ServiceManager(QtGui.QWidget): filename = unicode(filename) self.isNew = False SettingsManager.set_last_dir( - self.parent.service_settings_section, filename) + self.parent.service_settings_section, + os.path.split(filename)[0]) service = [] servicefile = filename + u'.osd' zip = None @@ -578,7 +580,8 @@ class ServiceManager(QtGui.QWidget): name = filename.split(os.path.sep) if filename: SettingsManager.set_last_dir( - self.parent.service_settings_section, filename) + self.parent.service_settings_section, + os.path.split(filename)[0]) zip = None f = None try: From d28498611d0a0a5109374f93f76b24c5c164e5fa Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Fri, 30 Apr 2010 06:16:06 +0100 Subject: [PATCH 49/63] Fix up video playing so main screen is hidden on start --- openlp/core/ui/maindisplay.py | 8 ++++++++ openlp/core/ui/slidecontroller.py | 1 - 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/openlp/core/ui/maindisplay.py b/openlp/core/ui/maindisplay.py index 321e28e1b..652a70de0 100644 --- a/openlp/core/ui/maindisplay.py +++ b/openlp/core/ui/maindisplay.py @@ -131,6 +131,8 @@ class MainDisplay(DisplayWidget): self.displayBlank = False self.blankFrame = None self.frame = None + QtCore.QObject.connect(Receiver.get_receiver(), + QtCore.SIGNAL(u'videodisplay_start'), self.hideDisplayForVideo) QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'maindisplay_hide'), self.hideDisplay) QtCore.QObject.connect(Receiver.get_receiver(), @@ -197,6 +199,12 @@ class MainDisplay(DisplayWidget): else: self.showFullScreen() + def hideDisplayForVideo(self): + """ + Hides the main display if for the video to be played + """ + self.hideDisplay(HideMode.Screen) + def hideDisplay(self, mode=HideMode.Screen): """ Hide the display by making all layers transparent diff --git a/openlp/core/ui/slidecontroller.py b/openlp/core/ui/slidecontroller.py index 32b301111..ca4d34826 100644 --- a/openlp/core/ui/slidecontroller.py +++ b/openlp/core/ui/slidecontroller.py @@ -782,7 +782,6 @@ class SlideController(QtGui.QWidget): if self.isLive: Receiver.send_message(u'videodisplay_start', [item, self.blankButton.isChecked()]) - Receiver.send_message(u'maindisplay_hide', HideMode.Screen) else: self.mediaObject.stop() self.mediaObject.clearQueue() From 591dc0735494059049abd212959071cce3c236ac Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Fri, 30 Apr 2010 06:50:52 +0100 Subject: [PATCH 50/63] Fix up presentations so they work again --- .../presentations/lib/messagelistener.py | 21 +++++++++++-------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/openlp/plugins/presentations/lib/messagelistener.py b/openlp/plugins/presentations/lib/messagelistener.py index 8a1ddc8c7..eb31660f0 100644 --- a/openlp/plugins/presentations/lib/messagelistener.py +++ b/openlp/plugins/presentations/lib/messagelistener.py @@ -217,7 +217,7 @@ class MessageListener(object): isLive, item = self.decode_message(message) log.debug(u'Startup called with message %s' % message) isBlank = message[2] - file = os.path.join(item.get_frame_path(), + file = os.path.join(item.get_frame_path(), item.get_frame_title()) self.handler = item.title if self.handler == self.mediaitem.Automatic: @@ -231,14 +231,17 @@ class MessageListener(object): controller.addHandler(self.controllers[self.handler], file, isBlank) def decode_message(self, message): - return message[1], message[0] - - def slide(self, message): - isLive, item = self.decode_message(message) - if isLive: - self.liveHandler.slide(slide, live) + if len(message) == 3: + return message[1], message[0], message[2] else: - self.previewHandler.slide(slide, live) + return message[1], message[0] + + def slide(self, message): + isLive, item, slide = self.decode_message(message) + if isLive: + self.liveHandler.slide(slide, isLive) + else: + self.previewHandler.slide(slide, isLive) def first(self, message): isLive, item = self.decode_message(message) @@ -285,6 +288,6 @@ class MessageListener(object): isLive, item = self.decode_message(message) if isLive: self.liveHandler.unblank() - + def timeout(self): self.liveHandler.poll() From 8e630c5adf3409406eda9eceeb64673c1358ea79 Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Fri, 30 Apr 2010 10:38:17 +0100 Subject: [PATCH 51/63] Fixes --- openlp/core/ui/slidecontroller.py | 2 ++ openlp/plugins/presentations/lib/messagelistener.py | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/openlp/core/ui/slidecontroller.py b/openlp/core/ui/slidecontroller.py index ca4d34826..f4f355483 100644 --- a/openlp/core/ui/slidecontroller.py +++ b/openlp/core/ui/slidecontroller.py @@ -591,8 +591,10 @@ class SlideController(QtGui.QWidget): QtCore.QVariant(checked)) if checked: Receiver.send_message(u'maindisplay_hide', HideMode.Blank) + Receiver.send_message(u'presentation_blank') else: Receiver.send_message(u'maindisplay_show') + Receiver.send_message(u'presentation_unblank') def onThemeDisplay(self, checked): """ diff --git a/openlp/plugins/presentations/lib/messagelistener.py b/openlp/plugins/presentations/lib/messagelistener.py index eb31660f0..8bfd53bb7 100644 --- a/openlp/plugins/presentations/lib/messagelistener.py +++ b/openlp/plugins/presentations/lib/messagelistener.py @@ -215,7 +215,7 @@ class MessageListener(object): Save the handler as any new presentations start here """ isLive, item = self.decode_message(message) - log.debug(u'Startup called with message %s' % message) + log.debug(u'Startup called with message ' % message) isBlank = message[2] file = os.path.join(item.get_frame_path(), item.get_frame_title()) From c42054ec870f9f315bc6f427b206626db7b5f523 Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Fri, 30 Apr 2010 15:30:07 +0100 Subject: [PATCH 52/63] Fix up final 802 fallout --- openlp/core/ui/displaytab.py | 4 ++-- openlp/core/ui/slidecontroller.py | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/openlp/core/ui/displaytab.py b/openlp/core/ui/displaytab.py index 38a0baa91..b38ff0842 100644 --- a/openlp/core/ui/displaytab.py +++ b/openlp/core/ui/displaytab.py @@ -178,7 +178,7 @@ class DisplayTab(SettingsTab): def load(self): settings = QtCore.QSettings() - settings.beginGroup(self.settingsSection) + settings.beginGroup(self.settings_section) self.Xpos.setText(unicode(self.screens.current[u'size'].x())) self.Ypos.setText(unicode(self.screens.current[u'size'].y())) self.Height.setText(unicode(self.screens.current[u'size'].height())) @@ -208,7 +208,7 @@ class DisplayTab(SettingsTab): def save(self): settings = QtCore.QSettings() - settings.beginGroup(self.settingsSection) + settings.beginGroup(self.settings_section) settings.setValue('x position', QtCore.QVariant(self.XposEdit.text())) settings.setValue('y position', diff --git a/openlp/core/ui/slidecontroller.py b/openlp/core/ui/slidecontroller.py index cbb854b85..a3bc31bf2 100644 --- a/openlp/core/ui/slidecontroller.py +++ b/openlp/core/ui/slidecontroller.py @@ -585,7 +585,7 @@ class SlideController(QtGui.QWidget): self.hideButton.setChecked(False) self.themeButton.setChecked(False) QtCore.QSettings().setValue( - self.parent.generalSettingsSection + u'/screen blank', + self.parent.general_settings_section + u'/screen blank', QtCore.QVariant(checked)) if checked: Receiver.send_message(u'maindisplay_hide', HideMode.Blank) From 932560e81db9ed6ceaa8e64b27d12286efd0f330 Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Fri, 30 Apr 2010 15:49:27 +0100 Subject: [PATCH 53/63] Fix missing %s --- openlp/plugins/presentations/lib/messagelistener.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openlp/plugins/presentations/lib/messagelistener.py b/openlp/plugins/presentations/lib/messagelistener.py index 8bfd53bb7..eb31660f0 100644 --- a/openlp/plugins/presentations/lib/messagelistener.py +++ b/openlp/plugins/presentations/lib/messagelistener.py @@ -215,7 +215,7 @@ class MessageListener(object): Save the handler as any new presentations start here """ isLive, item = self.decode_message(message) - log.debug(u'Startup called with message ' % message) + log.debug(u'Startup called with message %s' % message) isBlank = message[2] file = os.path.join(item.get_frame_path(), item.get_frame_title()) From 387e281da0e49ee418b301db6e05d1d8c9fc9716 Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Fri, 30 Apr 2010 16:41:48 +0100 Subject: [PATCH 54/63] Fix up bugs from last merge --- openlp/core/ui/slidecontroller.py | 23 ++++- resources/forms/displaytab.py | 150 ------------------------------ 2 files changed, 21 insertions(+), 152 deletions(-) delete mode 100644 resources/forms/displaytab.py diff --git a/openlp/core/ui/slidecontroller.py b/openlp/core/ui/slidecontroller.py index a3bc31bf2..a35257f75 100644 --- a/openlp/core/ui/slidecontroller.py +++ b/openlp/core/ui/slidecontroller.py @@ -589,10 +589,10 @@ class SlideController(QtGui.QWidget): QtCore.QVariant(checked)) if checked: Receiver.send_message(u'maindisplay_hide', HideMode.Blank) - Receiver.send_message(u'presentation_blank') + self.blankPlugin(True) else: Receiver.send_message(u'maindisplay_show') - Receiver.send_message(u'presentation_unblank') + self.blankPlugin(False) def onThemeDisplay(self, checked): """ @@ -603,8 +603,10 @@ class SlideController(QtGui.QWidget): self.hideButton.setChecked(False) if checked: Receiver.send_message(u'maindisplay_hide', HideMode.Theme) + self.blankPlugin(True) else: Receiver.send_message(u'maindisplay_show') + self.blankPlugin(False) def onHideDisplay(self, checked): """ @@ -615,8 +617,25 @@ class SlideController(QtGui.QWidget): self.themeButton.setChecked(False) if checked: Receiver.send_message(u'maindisplay_hide', HideMode.Screen) + self.blankPlugin(True) else: Receiver.send_message(u'maindisplay_show') + self.blankPlugin(False) + + def blankPlugin(self, blank): + """ + Blank the display screen. + """ + if self.serviceItem is not None: + if blank: + Receiver.send_message(u'%s_blank' + % self.serviceItem.name.lower(), + [self.serviceItem, self.isLive]) + else: + Receiver.send_message(u'%s_unblank' + % self.serviceItem.name.lower(), + [self.serviceItem, self.isLive]) + def onSlideSelected(self): """ diff --git a/resources/forms/displaytab.py b/resources/forms/displaytab.py deleted file mode 100644 index 80ff2fdd5..000000000 --- a/resources/forms/displaytab.py +++ /dev/null @@ -1,150 +0,0 @@ -# -*- coding: utf-8 -*- - -# Form implementation generated from reading ui file 'displaytab.ui' -# -# Created: Tue Apr 27 06:10:08 2010 -# by: PyQt4 UI code generator 4.7.3 -# -# WARNING! All changes made in this file will be lost! - -from PyQt4 import QtCore, QtGui - -class Ui_DisplaysDialog(object): - def setupUi(self, DisplaysDialog): - DisplaysDialog.setObjectName("DisplaysDialog") - DisplaysDialog.resize(620, 716) - self.layoutWidget = QtGui.QWidget(DisplaysDialog) - self.layoutWidget.setGeometry(QtCore.QRect(0, 40, 241, 79)) - self.layoutWidget.setObjectName("layoutWidget") - self.verticalLayout = QtGui.QVBoxLayout(self.layoutWidget) - self.verticalLayout.setObjectName("verticalLayout") - self.CurrentGroupBox = QtGui.QGroupBox(self.layoutWidget) - self.CurrentGroupBox.setObjectName("CurrentGroupBox") - self.horizontalLayout = QtGui.QHBoxLayout(self.CurrentGroupBox) - self.horizontalLayout.setObjectName("horizontalLayout") - self.verticalLayout_6 = QtGui.QVBoxLayout() - self.verticalLayout_6.setObjectName("verticalLayout_6") - self.XLabel = QtGui.QLabel(self.CurrentGroupBox) - self.XLabel.setAlignment(QtCore.Qt.AlignCenter) - self.XLabel.setObjectName("XLabel") - self.verticalLayout_6.addWidget(self.XLabel) - self.Xpos = QtGui.QLabel(self.CurrentGroupBox) - self.Xpos.setAlignment(QtCore.Qt.AlignCenter) - self.Xpos.setObjectName("Xpos") - self.verticalLayout_6.addWidget(self.Xpos) - self.horizontalLayout.addLayout(self.verticalLayout_6) - self.verticalLayout_7 = QtGui.QVBoxLayout() - self.verticalLayout_7.setObjectName("verticalLayout_7") - self.YLabel = QtGui.QLabel(self.CurrentGroupBox) - self.YLabel.setAlignment(QtCore.Qt.AlignCenter) - self.YLabel.setObjectName("YLabel") - self.verticalLayout_7.addWidget(self.YLabel) - self.Ypos = QtGui.QLabel(self.CurrentGroupBox) - self.Ypos.setAlignment(QtCore.Qt.AlignCenter) - self.Ypos.setObjectName("Ypos") - self.verticalLayout_7.addWidget(self.Ypos) - self.horizontalLayout.addLayout(self.verticalLayout_7) - self.verticalLayout_9 = QtGui.QVBoxLayout() - self.verticalLayout_9.setObjectName("verticalLayout_9") - self.HeightLabel = QtGui.QLabel(self.CurrentGroupBox) - self.HeightLabel.setMaximumSize(QtCore.QSize(100, 16777215)) - self.HeightLabel.setAlignment(QtCore.Qt.AlignCenter) - self.HeightLabel.setObjectName("HeightLabel") - self.verticalLayout_9.addWidget(self.HeightLabel) - self.Height = QtGui.QLabel(self.CurrentGroupBox) - self.Height.setAlignment(QtCore.Qt.AlignCenter) - self.Height.setObjectName("Height") - self.verticalLayout_9.addWidget(self.Height) - self.horizontalLayout.addLayout(self.verticalLayout_9) - self.verticalLayout_8 = QtGui.QVBoxLayout() - self.verticalLayout_8.setObjectName("verticalLayout_8") - self.WidthLabel = QtGui.QLabel(self.CurrentGroupBox) - self.WidthLabel.setAlignment(QtCore.Qt.AlignCenter) - self.WidthLabel.setObjectName("WidthLabel") - self.verticalLayout_8.addWidget(self.WidthLabel) - self.Width = QtGui.QLabel(self.CurrentGroupBox) - self.Width.setAlignment(QtCore.Qt.AlignCenter) - self.Width.setObjectName("Width") - self.verticalLayout_8.addWidget(self.Width) - self.horizontalLayout.addLayout(self.verticalLayout_8) - self.verticalLayout.addWidget(self.CurrentGroupBox) - self.CurrentGroupBox_2 = QtGui.QGroupBox(DisplaysDialog) - self.CurrentGroupBox_2.setGeometry(QtCore.QRect(0, 130, 248, 87)) - self.CurrentGroupBox_2.setMaximumSize(QtCore.QSize(500, 16777215)) - self.CurrentGroupBox_2.setObjectName("CurrentGroupBox_2") - self.horizontalLayout_2 = QtGui.QHBoxLayout(self.CurrentGroupBox_2) - self.horizontalLayout_2.setObjectName("horizontalLayout_2") - self.verticalLayout_2 = QtGui.QVBoxLayout() - self.verticalLayout_2.setObjectName("verticalLayout_2") - self.XAmendLabel = QtGui.QLabel(self.CurrentGroupBox_2) - self.XAmendLabel.setAlignment(QtCore.Qt.AlignCenter) - self.XAmendLabel.setObjectName("XAmendLabel") - self.verticalLayout_2.addWidget(self.XAmendLabel) - self.XposEdit = QtGui.QLineEdit(self.CurrentGroupBox_2) - self.XposEdit.setMaximumSize(QtCore.QSize(50, 16777215)) - self.XposEdit.setMaxLength(4) - self.XposEdit.setObjectName("XposEdit") - self.verticalLayout_2.addWidget(self.XposEdit) - self.horizontalLayout_2.addLayout(self.verticalLayout_2) - self.verticalLayout_3 = QtGui.QVBoxLayout() - self.verticalLayout_3.setObjectName("verticalLayout_3") - self.YAmendLabel = QtGui.QLabel(self.CurrentGroupBox_2) - self.YAmendLabel.setAlignment(QtCore.Qt.AlignCenter) - self.YAmendLabel.setObjectName("YAmendLabel") - self.verticalLayout_3.addWidget(self.YAmendLabel) - self.YposEdit = QtGui.QLineEdit(self.CurrentGroupBox_2) - self.YposEdit.setMaximumSize(QtCore.QSize(50, 16777215)) - self.YposEdit.setMaxLength(4) - self.YposEdit.setObjectName("YposEdit") - self.verticalLayout_3.addWidget(self.YposEdit) - self.horizontalLayout_2.addLayout(self.verticalLayout_3) - self.verticalLayout_4 = QtGui.QVBoxLayout() - self.verticalLayout_4.setObjectName("verticalLayout_4") - self.HeightAmendLabel = QtGui.QLabel(self.CurrentGroupBox_2) - self.HeightAmendLabel.setAlignment(QtCore.Qt.AlignCenter) - self.HeightAmendLabel.setObjectName("HeightAmendLabel") - self.verticalLayout_4.addWidget(self.HeightAmendLabel) - self.HeightEdit = QtGui.QLineEdit(self.CurrentGroupBox_2) - self.HeightEdit.setMaximumSize(QtCore.QSize(50, 16777215)) - self.HeightEdit.setMaxLength(4) - self.HeightEdit.setObjectName("HeightEdit") - self.verticalLayout_4.addWidget(self.HeightEdit) - self.horizontalLayout_2.addLayout(self.verticalLayout_4) - self.verticalLayout_5 = QtGui.QVBoxLayout() - self.verticalLayout_5.setSizeConstraint(QtGui.QLayout.SetMinimumSize) - self.verticalLayout_5.setObjectName("verticalLayout_5") - self.WidthAmendLabel = QtGui.QLabel(self.CurrentGroupBox_2) - self.WidthAmendLabel.setMaximumSize(QtCore.QSize(100, 16777215)) - self.WidthAmendLabel.setAlignment(QtCore.Qt.AlignCenter) - self.WidthAmendLabel.setObjectName("WidthAmendLabel") - self.verticalLayout_5.addWidget(self.WidthAmendLabel) - self.WidthEdit = QtGui.QLineEdit(self.CurrentGroupBox_2) - self.WidthEdit.setMaximumSize(QtCore.QSize(60, 16777215)) - self.WidthEdit.setObjectName("WidthEdit") - self.verticalLayout_5.addWidget(self.WidthEdit) - self.horizontalLayout_2.addLayout(self.verticalLayout_5) - self.OverrideCheckBox = QtGui.QCheckBox(DisplaysDialog) - self.OverrideCheckBox.setGeometry(QtCore.QRect(0, 10, 191, 23)) - self.OverrideCheckBox.setObjectName("OverrideCheckBox") - - self.retranslateUi(DisplaysDialog) - QtCore.QMetaObject.connectSlotsByName(DisplaysDialog) - - def retranslateUi(self, DisplaysDialog): - DisplaysDialog.setWindowTitle(QtGui.QApplication.translate("DisplaysDialog", "Amend Display Settings", None, QtGui.QApplication.UnicodeUTF8)) - self.CurrentGroupBox.setTitle(QtGui.QApplication.translate("DisplaysDialog", "Default Settings", None, QtGui.QApplication.UnicodeUTF8)) - self.XLabel.setText(QtGui.QApplication.translate("DisplaysDialog", "X", None, QtGui.QApplication.UnicodeUTF8)) - self.Xpos.setText(QtGui.QApplication.translate("DisplaysDialog", "0", None, QtGui.QApplication.UnicodeUTF8)) - self.YLabel.setText(QtGui.QApplication.translate("DisplaysDialog", "Y", None, QtGui.QApplication.UnicodeUTF8)) - self.Ypos.setText(QtGui.QApplication.translate("DisplaysDialog", "0", None, QtGui.QApplication.UnicodeUTF8)) - self.HeightLabel.setText(QtGui.QApplication.translate("DisplaysDialog", "Height", None, QtGui.QApplication.UnicodeUTF8)) - self.Height.setText(QtGui.QApplication.translate("DisplaysDialog", "0", None, QtGui.QApplication.UnicodeUTF8)) - self.WidthLabel.setText(QtGui.QApplication.translate("DisplaysDialog", "Width", None, QtGui.QApplication.UnicodeUTF8)) - self.Width.setText(QtGui.QApplication.translate("DisplaysDialog", "0", None, QtGui.QApplication.UnicodeUTF8)) - self.CurrentGroupBox_2.setTitle(QtGui.QApplication.translate("DisplaysDialog", "Amend Settings", None, QtGui.QApplication.UnicodeUTF8)) - self.XAmendLabel.setText(QtGui.QApplication.translate("DisplaysDialog", "X", None, QtGui.QApplication.UnicodeUTF8)) - self.YAmendLabel.setText(QtGui.QApplication.translate("DisplaysDialog", "Y", None, QtGui.QApplication.UnicodeUTF8)) - self.HeightAmendLabel.setText(QtGui.QApplication.translate("DisplaysDialog", "Height", None, QtGui.QApplication.UnicodeUTF8)) - self.WidthAmendLabel.setText(QtGui.QApplication.translate("DisplaysDialog", "Width", None, QtGui.QApplication.UnicodeUTF8)) - self.OverrideCheckBox.setText(QtGui.QApplication.translate("DisplaysDialog", "Override Output Display", None, QtGui.QApplication.UnicodeUTF8)) - From 09da62f9cc633da67e8dd9ed55450030be2b0657 Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Fri, 30 Apr 2010 17:30:25 +0100 Subject: [PATCH 55/63] Text over video --- openlp/core/ui/maindisplay.py | 9 ++++ openlp/plugins/media/lib/mediaitem.py | 45 ++++++++++++++++++- openlp/plugins/presentations/lib/mediaitem.py | 1 + 3 files changed, 54 insertions(+), 1 deletion(-) diff --git a/openlp/core/ui/maindisplay.py b/openlp/core/ui/maindisplay.py index 652a70de0..c4fe167d8 100644 --- a/openlp/core/ui/maindisplay.py +++ b/openlp/core/ui/maindisplay.py @@ -137,6 +137,8 @@ class MainDisplay(DisplayWidget): QtCore.SIGNAL(u'maindisplay_hide'), self.hideDisplay) QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'maindisplay_show'), self.showDisplay) + QtCore.QObject.connect(Receiver.get_receiver(), + QtCore.SIGNAL(u'videodisplay_background'), self.hideDisplayForVideo) def setup(self): """ @@ -351,6 +353,8 @@ class VideoDisplay(Phonon.VideoWidget): QtCore.SIGNAL(u'videodisplay_pause'), self.onMediaPause) QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'videodisplay_stop'), self.onMediaStop) + QtCore.QObject.connect(Receiver.get_receiver(), + QtCore.SIGNAL(u'videodisplay_background'), self.onMediaBackground) QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'config_updated'), self.setup) self.setVisible(False) @@ -382,6 +386,11 @@ class VideoDisplay(Phonon.VideoWidget): self.setVisible(False) self.primary = True + def onMediaBackground(self, message): + log.debug(u'VideoDisplay Queue new media message %s' % message) + source = self.mediaObject.setCurrentSource(Phonon.MediaSource(message)) + self._play() + def onMediaQueue(self, message): log.debug(u'VideoDisplay Queue new media message %s' % message) file = os.path.join(message[0].get_frame_path(), diff --git a/openlp/plugins/media/lib/mediaitem.py b/openlp/plugins/media/lib/mediaitem.py index dee49f429..7afe52cae 100644 --- a/openlp/plugins/media/lib/mediaitem.py +++ b/openlp/plugins/media/lib/mediaitem.py @@ -29,7 +29,7 @@ import os from PyQt4 import QtCore, QtGui from openlp.core.lib import MediaManagerItem, BaseListWithDnD, build_icon, \ - ItemCapabilities, SettingsManager + ItemCapabilities, SettingsManager, contextMenuAction, Receiver log = logging.getLogger(__name__) @@ -47,6 +47,7 @@ class MediaMediaItem(MediaManagerItem): def __init__(self, parent, icon, title): self.PluginNameShort = u'Media' self.IconPath = u'images/image' + self.background = False # this next is a class, not an instance of a class - it will # be instanced by the base MediaManagerItem self.ListViewWithDnD_class = MediaListView @@ -71,6 +72,48 @@ class MediaMediaItem(MediaManagerItem): self.hasNewIcon = False self.hasEditIcon = False + def addListViewToToolBar(self): + MediaManagerItem.addListViewToToolBar(self) + self.ListView.setContextMenuPolicy(QtCore.Qt.ActionsContextMenu) + self.ListView.addAction( + contextMenuAction( + self.ListView, u':/slides/slide_blank.png', + self.trUtf8('Replace Live Background'), + self.onReplaceClick)) + + def addEndHeaderBar(self): + self.ImageWidget = QtGui.QWidget(self) + sizePolicy = QtGui.QSizePolicy( + QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum) + sizePolicy.setHorizontalStretch(0) + sizePolicy.setVerticalStretch(0) + sizePolicy.setHeightForWidth( + self.ImageWidget.sizePolicy().hasHeightForWidth()) + self.ImageWidget.setSizePolicy(sizePolicy) + self.ImageWidget.setObjectName(u'ImageWidget') + self.blankButton = self.Toolbar.addToolbarButton( + u'Replace Background', u':/slides/slide_blank.png', + self.trUtf8('Replace Live Background'), self.onReplaceClick, False) + # Add the song widget to the page layout + self.PageLayout.addWidget(self.ImageWidget) + + def onReplaceClick(self): + if self.background: + self.background = False + Receiver.send_message(u'videodisplay_stop') + else: + self.background = True + if not self.ListView.selectedIndexes(): + QtGui.QMessageBox.information(self, + self.trUtf8('No item selected'), + self.trUtf8('You must select one item')) + items = self.ListView.selectedIndexes() + for item in items: + bitem = self.ListView.item(item.row()) + filename = unicode((bitem.data(QtCore.Qt.UserRole)).toString()) + Receiver.send_message(u'videodisplay_background', filename) + + def generateSlideData(self, service_item, item=None): if item is None: item = self.ListView.currentItem() diff --git a/openlp/plugins/presentations/lib/mediaitem.py b/openlp/plugins/presentations/lib/mediaitem.py index e8ac32a44..62f81e5d5 100644 --- a/openlp/plugins/presentations/lib/mediaitem.py +++ b/openlp/plugins/presentations/lib/mediaitem.py @@ -108,6 +108,7 @@ class PresentationMediaItem(MediaManagerItem): self.servicePath = os.path.join( AppLocation.get_section_data_path(self.settings_section), u'thumbnails') + self.ListView.setIconSize(QtCore.QSize(88,50)) if not os.path.exists(self.servicePath): os.mkdir(self.servicePath) list = SettingsManager.load_list( From 79180c7f1c0df831651e5f2b80acf89a3ceda148 Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Fri, 30 Apr 2010 17:57:53 +0100 Subject: [PATCH 56/63] Text over video with loop --- openlp/core/ui/maindisplay.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/openlp/core/ui/maindisplay.py b/openlp/core/ui/maindisplay.py index c4fe167d8..1907a55b0 100644 --- a/openlp/core/ui/maindisplay.py +++ b/openlp/core/ui/maindisplay.py @@ -334,6 +334,7 @@ class VideoDisplay(Phonon.VideoWidget): self.parent = parent self.screens = screens self.hidden = False + self.background = False self.mediaObject = Phonon.MediaObject() self.setAspectRatio(aspect) self.audioObject = Phonon.AudioOutput(Phonon.VideoCategory) @@ -357,6 +358,8 @@ class VideoDisplay(Phonon.VideoWidget): QtCore.SIGNAL(u'videodisplay_background'), self.onMediaBackground) QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'config_updated'), self.setup) + QtCore.QObject.connect(self.mediaObject, + QtCore.SIGNAL(u'finished()'), self.onMediaBackground) self.setVisible(False) def keyPressEvent(self, event): @@ -387,8 +390,12 @@ class VideoDisplay(Phonon.VideoWidget): self.primary = True def onMediaBackground(self, message): + if not message: + message = self.message log.debug(u'VideoDisplay Queue new media message %s' % message) source = self.mediaObject.setCurrentSource(Phonon.MediaSource(message)) + self.message = message + self.background = True self._play() def onMediaQueue(self, message): @@ -416,6 +423,8 @@ class VideoDisplay(Phonon.VideoWidget): def onMediaStop(self): log.debug(u'VideoDisplay Media stopped by user') + self.background = False + self.message = None self.mediaObject.stop() self.onMediaFinish() From 22c2e4c38eba5b4b8fbf3466552e18836af9a65a Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Fri, 30 Apr 2010 20:37:47 +0100 Subject: [PATCH 57/63] Minor cleanups and add comments to code --- openlp/core/ui/maindisplay.py | 49 +++++++++++++++++++++++++++++------ 1 file changed, 41 insertions(+), 8 deletions(-) diff --git a/openlp/core/ui/maindisplay.py b/openlp/core/ui/maindisplay.py index 1907a55b0..2fc96e34d 100644 --- a/openlp/core/ui/maindisplay.py +++ b/openlp/core/ui/maindisplay.py @@ -334,7 +334,7 @@ class VideoDisplay(Phonon.VideoWidget): self.parent = parent self.screens = screens self.hidden = False - self.background = False + self.message = None self.mediaObject = Phonon.MediaObject() self.setAspectRatio(aspect) self.audioObject = Phonon.AudioOutput(Phonon.VideoCategory) @@ -389,16 +389,28 @@ class VideoDisplay(Phonon.VideoWidget): self.setVisible(False) self.primary = True - def onMediaBackground(self, message): + def onMediaBackground(self, message=None): + """ + Play a video triggered from the video plugin with the + file name passed in on the event. + Also triggered from the Finish event so the video will loop + if it is triggered from the plugin + """ + log.debug(u'VideoDisplay Queue new media message %s' % message) + #If not file take the stored one if not message: message = self.message - log.debug(u'VideoDisplay Queue new media message %s' % message) - source = self.mediaObject.setCurrentSource(Phonon.MediaSource(message)) - self.message = message - self.background = True - self._play() + # still no file name then stop as it was a normal video stopping + if not message: + log.debug(u'VideoDisplay Queue new media message %s' % message) + source = self.mediaObject.setCurrentSource(Phonon.MediaSource(message)) + self.message = message + self._play() def onMediaQueue(self, message): + """ + Set up a video to play from the serviceitem. + """ log.debug(u'VideoDisplay Queue new media message %s' % message) file = os.path.join(message[0].get_frame_path(), message[0].get_frame_title()) @@ -406,39 +418,60 @@ class VideoDisplay(Phonon.VideoWidget): self._play() def onMediaPlay(self): + """ + Respond to the Play button on the slide controller unless the display + has been hidden by the slidecontroller + """ if not self.hidden: log.debug(u'VideoDisplay Play the new media, Live ') self._play() def _play(self): + """ + We want to play the video so start it and display the screen + """ log.debug(u'VideoDisplay _play called') self.mediaObject.play() self.setVisible(True) self.showFullScreen() def onMediaPause(self): + """ + Pause the video and refresh the screen + """ log.debug(u'VideoDisplay Media paused by user') self.mediaObject.pause() self.show() def onMediaStop(self): + """ + Stop the video and clean up + """ log.debug(u'VideoDisplay Media stopped by user') - self.background = False self.message = None self.mediaObject.stop() self.onMediaFinish() def onMediaFinish(self): + """ + Clean up the Object queue + """ log.debug(u'VideoDisplay Reached end of media playlist') self.mediaObject.clearQueue() self.setVisible(False) def mediaHide(self): + """ + Hide the video display + """ self.mediaObject.pause() self.hidden = True self.setVisible(False) def mediaShow(self): + """ + Show the video disaply if it was already hidden + """ if self.hidden: self.hidden = False self._play() From 5614e1032418bd4f224185e477afcbd927b3fd55 Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Fri, 30 Apr 2010 20:56:26 +0100 Subject: [PATCH 58/63] Fix again --- openlp/core/ui/maindisplay.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/openlp/core/ui/maindisplay.py b/openlp/core/ui/maindisplay.py index 2fc96e34d..e035de9ca 100644 --- a/openlp/core/ui/maindisplay.py +++ b/openlp/core/ui/maindisplay.py @@ -401,8 +401,7 @@ class VideoDisplay(Phonon.VideoWidget): if not message: message = self.message # still no file name then stop as it was a normal video stopping - if not message: - log.debug(u'VideoDisplay Queue new media message %s' % message) + if message: source = self.mediaObject.setCurrentSource(Phonon.MediaSource(message)) self.message = message self._play() From b81160768bca31c65fddfd4c88f91a60646c21a8 Mon Sep 17 00:00:00 2001 From: Jon Tibble Date: Fri, 30 Apr 2010 22:00:17 +0100 Subject: [PATCH 59/63] Coding style fixes --- openlp/core/lib/baselistwithdnd.py | 3 +- openlp/core/lib/renderer.py | 13 +++--- openlp/core/ui/amendthemeform.py | 10 ++--- openlp/core/ui/maindisplay.py | 45 +++++++++---------- openlp/core/ui/servicemanager.py | 5 +-- openlp/core/ui/slidecontroller.py | 11 +++-- openlp/core/ui/thememanager.py | 2 +- openlp/migration/migratesongs.py | 6 +-- openlp/plugins/bibles/lib/db.py | 2 +- openlp/plugins/bibles/lib/osis.py | 2 +- openlp/plugins/custom/forms/editcustomform.py | 2 +- openlp/plugins/media/lib/mediaitem.py | 1 - .../presentations/lib/impresscontroller.py | 6 +-- .../presentations/lib/messagelistener.py | 2 +- .../presentations/lib/powerpointcontroller.py | 9 ++-- .../presentations/lib/pptviewcontroller.py | 8 ++-- .../lib/presentationcontroller.py | 6 +-- openlp/plugins/songs/forms/editsongform.py | 11 +++-- openlp/plugins/songs/lib/songxml.py | 2 +- 19 files changed, 70 insertions(+), 76 deletions(-) diff --git a/openlp/core/lib/baselistwithdnd.py b/openlp/core/lib/baselistwithdnd.py index bc043082c..d34eada98 100644 --- a/openlp/core/lib/baselistwithdnd.py +++ b/openlp/core/lib/baselistwithdnd.py @@ -48,5 +48,4 @@ class BaseListWithDnD(QtGui.QListWidget): mimeData = QtCore.QMimeData() drag.setMimeData(mimeData) mimeData.setText(self.PluginName) - dropAction = drag.start(QtCore.Qt.CopyAction) - + drag.start(QtCore.Qt.CopyAction) diff --git a/openlp/core/lib/renderer.py b/openlp/core/lib/renderer.py index 43db25d64..75229f780 100644 --- a/openlp/core/lib/renderer.py +++ b/openlp/core/lib/renderer.py @@ -117,8 +117,7 @@ class Renderer(object): QtGui.QImage.Format_ARGB32_Premultiplied) if self._bg_image_filename and not self.bg_image: self.bg_image = resize_image(self._bg_image_filename, - self._frame.width(), - self._frame.height()) + self._frame.width(), self._frame.height()) if self.bg_frame is None: self._generate_background_frame() @@ -223,7 +222,7 @@ class Renderer(object): ``rect_footer`` The footer text block. """ - log.debug(u'set_text_rectangle %s , %s' %(rect_main, rect_footer) ) + log.debug(u'set_text_rectangle %s , %s' % (rect_main, rect_footer)) self._rect = rect_main self._rect_footer = rect_footer @@ -268,8 +267,8 @@ class Renderer(object): QtGui.QPixmap(self._frame.width(), self._frame.height()) self.bg_frame.fill(QtCore.Qt.transparent) else: - self.bg_frame = QtGui.QImage(self._frame.width(), self._frame.height(), - QtGui.QImage.Format_ARGB32_Premultiplied) + self.bg_frame = QtGui.QImage(self._frame.width(), + self._frame.height(), QtGui.QImage.Format_ARGB32_Premultiplied) log.debug(u'render background %s start', self._theme.background_type) painter = QtGui.QPainter() painter.begin(self.bg_frame) @@ -550,8 +549,8 @@ class Renderer(object): path = QtGui.QPainterPath() path.addText(QtCore.QPointF(x, rowpos), font, line) self.painter.setBrush(self.painter.pen().brush()) - self.painter.setPen(QtGui.QPen( - QtGui.QColor(self._theme.display_outline_color), outline_size)) + self.painter.setPen(QtGui.QPen(QtGui.QColor( + self._theme.display_outline_color), outline_size)) self.painter.drawPath(path) self.painter.setPen(pen) self.painter.drawText(x, rowpos, line) diff --git a/openlp/core/ui/amendthemeform.py b/openlp/core/ui/amendthemeform.py index c43d27cb5..fab72c312 100644 --- a/openlp/core/ui/amendthemeform.py +++ b/openlp/core/ui/amendthemeform.py @@ -133,7 +133,8 @@ class AmendThemeForm(QtGui.QDialog, Ui_AmendThemeDialog): QtCore.SIGNAL(u'editingFinished()'), self.onOutlineSpinBoxChanged) QtCore.QObject.connect(self.SlideTransitionCheckedBox, - QtCore.SIGNAL(u'stateChanged(int)'), self.onSlideTransitionCheckedBoxChanged) + QtCore.SIGNAL(u'stateChanged(int)'), + self.onSlideTransitionCheckedBoxChanged) def accept(self): new_theme = ThemeXML() @@ -145,10 +146,10 @@ class AmendThemeForm(QtGui.QDialog, Ui_AmendThemeDialog): new_theme.add_background_transparent() else: if self.theme.background_type == u'solid': - new_theme.add_background_solid( \ + new_theme.add_background_solid( unicode(self.theme.background_color)) elif self.theme.background_type == u'gradient': - new_theme.add_background_gradient( \ + new_theme.add_background_gradient( unicode(self.theme.background_startColor), unicode(self.theme.background_endColor), self.theme.background_direction) @@ -158,7 +159,6 @@ class AmendThemeForm(QtGui.QDialog, Ui_AmendThemeDialog): new_theme.add_background_image(filename) save_to = os.path.join(self.path, theme_name, filename) save_from = self.theme.background_filename - new_theme.add_font(unicode(self.theme.font_main_name), unicode(self.theme.font_main_color), unicode(self.theme.font_main_proportion), @@ -182,7 +182,7 @@ class AmendThemeForm(QtGui.QDialog, Ui_AmendThemeDialog): unicode(self.theme.font_footer_x), unicode(self.theme.font_footer_y), unicode(self.theme.font_footer_width), - unicode(self.theme.font_footer_height) ) + unicode(self.theme.font_footer_height)) new_theme.add_display(unicode(self.theme.display_shadow), unicode(self.theme.display_shadow_color), unicode(self.theme.display_outline), diff --git a/openlp/core/ui/maindisplay.py b/openlp/core/ui/maindisplay.py index 1907a55b0..31c75e186 100644 --- a/openlp/core/ui/maindisplay.py +++ b/openlp/core/ui/maindisplay.py @@ -34,7 +34,6 @@ from openlp.core.ui import HideMode log = logging.getLogger(__name__) - class DisplayManager(QtGui.QWidget): """ Wrapper class to hold the display widgets. @@ -144,16 +143,16 @@ class MainDisplay(DisplayWidget): """ Sets up the screen on a particular screen. """ - log.debug(u'Setup %s for %s ' %(self.screens, - self.screens.monitor_number)) + log.debug(u'Setup %s for %s ' % ( + self.screens, self.screens.monitor_number)) self.setVisible(False) self.screen = self.screens.current #Sort out screen locations and sizes self.display_alert.setGeometry(self.screen[u'size']) - self.display_image.resize(self.screen[u'size'].width(), - self.screen[u'size'].height()) - self.display_text.resize(self.screen[u'size'].width(), - self.screen[u'size'].height()) + self.display_image.resize( + self.screen[u'size'].width(), self.screen[u'size'].height()) + self.display_text.resize( + self.screen[u'size'].width(), self.screen[u'size'].height()) self.setGeometry(self.screen[u'size']) #Build a custom splash screen self.InitialFrame = QtGui.QImage( @@ -179,8 +178,8 @@ class MainDisplay(DisplayWidget): painter.begin(self.blankFrame) painter.fillRect(self.blankFrame.rect(), QtCore.Qt.black) #build a blank transparent image - self.transparent = QtGui.QPixmap(self.screen[u'size'].width(), - self.screen[u'size'].height()) + self.transparent = QtGui.QPixmap( + self.screen[u'size'].width(), self.screen[u'size'].height()) self.transparent.fill(QtCore.Qt.transparent) self.display_alert.setPixmap(self.transparent) self.display_text.setPixmap(self.transparent) @@ -220,19 +219,21 @@ class MainDisplay(DisplayWidget): if mode == HideMode.Screen: self.display_image.setPixmap(self.transparent) elif mode == HideMode.Blank: - self.display_image.setPixmap(QtGui.QPixmap.fromImage(self.blankFrame)) + self.display_image.setPixmap( + QtGui.QPixmap.fromImage(self.blankFrame)) else: if self.parent.renderManager.renderer.bg_frame: - self.display_image.setPixmap(QtGui.QPixmap.fromImage(\ + self.display_image.setPixmap(QtGui.QPixmap.fromImage( self.parent.renderManager.renderer.bg_frame)) else: - self.display_image.setPixmap(QtGui.QPixmap.fromImage(self.blankFrame)) + self.display_image.setPixmap( + QtGui.QPixmap.fromImage(self.blankFrame)) self.moveToTop() def moveToTop(self): log.debug(u'moveToTop') - self.setWindowFlags(QtCore.Qt.WindowStaysOnTopHint \ - | QtCore.Qt.FramelessWindowHint | QtCore.Qt.Dialog) + self.setWindowFlags(QtCore.Qt.WindowStaysOnTopHint | + QtCore.Qt.FramelessWindowHint | QtCore.Qt.Dialog) self.show() def showDisplay(self): @@ -254,9 +255,8 @@ class MainDisplay(DisplayWidget): def addImageWithText(self, frame): log.debug(u'addImageWithText') - frame = resize_image(frame, - self.screen[u'size'].width(), - self.screen[u'size'].height() ) + frame = resize_image( + frame, self.screen[u'size'].width(), self.screen[u'size'].height()) self.display_image.setPixmap(QtGui.QPixmap.fromImage(frame)) self.moveToTop() @@ -340,8 +340,8 @@ class VideoDisplay(Phonon.VideoWidget): self.audioObject = Phonon.AudioOutput(Phonon.VideoCategory) Phonon.createPath(self.mediaObject, self) Phonon.createPath(self.mediaObject, self.audioObject) - self.setWindowFlags(QtCore.Qt.WindowStaysOnBottomHint \ - | QtCore.Qt.FramelessWindowHint | QtCore.Qt.Dialog) + self.setWindowFlags(QtCore.Qt.WindowStaysOnBottomHint | + QtCore.Qt.FramelessWindowHint | QtCore.Qt.Dialog) QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'maindisplay_hide'), self.mediaHide) QtCore.QObject.connect(Receiver.get_receiver(), @@ -376,7 +376,7 @@ class VideoDisplay(Phonon.VideoWidget): """ Sets up the screen on a particular screen. """ - log.debug(u'VideoDisplay Setup %s for %s ' %(self.screens, + log.debug(u'VideoDisplay Setup %s for %s ' % (self.screens, self.screens.monitor_number)) self.screen = self.screens.current #Sort out screen locations and sizes @@ -393,7 +393,7 @@ class VideoDisplay(Phonon.VideoWidget): if not message: message = self.message log.debug(u'VideoDisplay Queue new media message %s' % message) - source = self.mediaObject.setCurrentSource(Phonon.MediaSource(message)) + self.mediaObject.setCurrentSource(Phonon.MediaSource(message)) self.message = message self.background = True self._play() @@ -402,7 +402,7 @@ class VideoDisplay(Phonon.VideoWidget): log.debug(u'VideoDisplay Queue new media message %s' % message) file = os.path.join(message[0].get_frame_path(), message[0].get_frame_title()) - source = self.mediaObject.setCurrentSource(Phonon.MediaSource(file)) + self.mediaObject.setCurrentSource(Phonon.MediaSource(file)) self._play() def onMediaPlay(self): @@ -442,4 +442,3 @@ class VideoDisplay(Phonon.VideoWidget): if self.hidden: self.hidden = False self._play() - diff --git a/openlp/core/ui/servicemanager.py b/openlp/core/ui/servicemanager.py index 56ac3e8b4..b85301f8f 100644 --- a/openlp/core/ui/servicemanager.py +++ b/openlp/core/ui/servicemanager.py @@ -1,4 +1,3 @@ -import os.path # -*- coding: utf-8 -*- # vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4 @@ -85,7 +84,7 @@ class ServiceManagerList(QtGui.QTreeWidget): mimeData = QtCore.QMimeData() drag.setMimeData(mimeData) mimeData.setText(u'ServiceManager') - dropAction = drag.start(QtCore.Qt.CopyAction) + drag.start(QtCore.Qt.CopyAction) class ServiceManager(QtGui.QWidget): """ @@ -797,7 +796,7 @@ class ServiceManager(QtGui.QWidget): plugin = event.mimeData().text() item = self.ServiceManagerList.itemAt(event.pos()) if plugin == u'ServiceManager': - startpos, startCount = self.findServiceItem() + startpos, startCount = self.findServiceItem() if item is None: endpos = len(self.serviceItems) else: diff --git a/openlp/core/ui/slidecontroller.py b/openlp/core/ui/slidecontroller.py index a35257f75..6648bed00 100644 --- a/openlp/core/ui/slidecontroller.py +++ b/openlp/core/ui/slidecontroller.py @@ -200,7 +200,7 @@ class SlideController(QtGui.QWidget): if isLive: self.Toolbar.addToolbarSeparator(u'Loop Separator') self.Toolbar.addToolbarButton( - u'Start Loop', u':/media/media_time.png', + u'Start Loop', u':/media/media_time.png', self.trUtf8('Start continuous loop'), self.onStartLoop) self.Toolbar.addToolbarButton( u'Stop Loop', u':/media/media_stop.png', @@ -217,13 +217,13 @@ class SlideController(QtGui.QWidget): #Build a Media ToolBar self.Mediabar = OpenLPToolbar(self) self.Mediabar.addToolbarButton( - u'Media Start', u':/slides/media_playback_start.png', + u'Media Start', u':/slides/media_playback_start.png', self.trUtf8('Start playing media'), self.onMediaPlay) self.Mediabar.addToolbarButton( - u'Media Pause', u':/slides/media_playback_pause.png', + u'Media Pause', u':/slides/media_playback_pause.png', self.trUtf8('Start playing media'), self.onMediaPause) self.Mediabar.addToolbarButton( - u'Media Stop', u':/slides/media_playback_stop.png', + u'Media Stop', u':/slides/media_playback_stop.png', self.trUtf8('Start playing media'), self.onMediaStop) if self.isLive: self.blankButton = self.Mediabar.addToolbarButton( @@ -636,7 +636,6 @@ class SlideController(QtGui.QWidget): % self.serviceItem.name.lower(), [self.serviceItem, self.isLive]) - def onSlideSelected(self): """ Generate the preview when you click on a slide. @@ -727,7 +726,7 @@ class SlideController(QtGui.QWidget): if not self.serviceItem: return Receiver.send_message(u'%s_previous' % self.serviceItem.name.lower(), - [self.serviceItem, self.isLive]) + [self.serviceItem, self.isLive]) if self.serviceItem.is_command(): self.updatePreview() else: diff --git a/openlp/core/ui/thememanager.py b/openlp/core/ui/thememanager.py index b6ed2366d..8c3897fd1 100644 --- a/openlp/core/ui/thememanager.py +++ b/openlp/core/ui/thememanager.py @@ -295,7 +295,7 @@ class ThemeManager(QtGui.QWidget): self.pushThemes() def pushThemes(self): - Receiver.send_message(u'theme_update_list', self.getThemes() ) + Receiver.send_message(u'theme_update_list', self.getThemes()) def getThemes(self): return self.themelist diff --git a/openlp/migration/migratesongs.py b/openlp/migration/migratesongs.py index a46f50a54..b43b1e68a 100644 --- a/openlp/migration/migratesongs.py +++ b/openlp/migration/migratesongs.py @@ -47,7 +47,7 @@ def init_models(url): mapper(TAuthor, temp_authors_table) mapper(Book, song_books_table) mapper(Song, songs_table, - properties={'authors': relation(Author, backref='songs', + properties={'authors': relation(Author, backref='songs', secondary=authors_songs_table), 'book': relation(Book, backref='songs'), 'topics': relation(Topic, backref='songs', @@ -156,13 +156,13 @@ class MigrateSongs(): print songs_temp.songtitle aa = self.session.execute( u'select * from songauthors_temp where songid =' + \ - unicode(songs_temp.songid) ) + unicode(songs_temp.songid)) for row in aa: a = row['authorid'] authors_temp = self.session.query(TAuthor).get(a) bb = self.session.execute( u'select * from authors where display_name = \"%s\"' % \ - unicode(authors_temp.authorname) ).fetchone() + unicode(authors_temp.authorname)).fetchone() if bb is None: author = Author() author.display_name = authors_temp.authorname diff --git a/openlp/plugins/bibles/lib/db.py b/openlp/plugins/bibles/lib/db.py index c95884693..79a650541 100644 --- a/openlp/plugins/bibles/lib/db.py +++ b/openlp/plugins/bibles/lib/db.py @@ -111,7 +111,7 @@ class BibleDB(QtCore.QObject): ``old_filename`` The "dirty" file name or version name. """ - if not isinstance(old_filename, unicode): + if not isinstance(old_filename, unicode): old_filename = unicode(old_filename, u'utf-8') old_filename = re.sub(r'[^\w]+', u'_', old_filename).strip(u'_') return old_filename + u'.sqlite' diff --git a/openlp/plugins/bibles/lib/osis.py b/openlp/plugins/bibles/lib/osis.py index bddf04a5a..104e2adb8 100644 --- a/openlp/plugins/bibles/lib/osis.py +++ b/openlp/plugins/bibles/lib/osis.py @@ -165,7 +165,7 @@ class OSISBible(BibleDB): verse_text = verse_text.replace(u'', u'')\ .replace(u'', u'').replace(u'', u'')\ .replace(u'', u'').replace(u'', u'')\ - .replace(u'', u'').replace(u'', u'') + .replace(u'', u'').replace(u'', u'') verse_text = self.spaces_regex.sub(u' ', verse_text) self.create_verse(db_book.id, chapter, verse, verse_text) Receiver.send_message(u'openlp_process_events') diff --git a/openlp/plugins/custom/forms/editcustomform.py b/openlp/plugins/custom/forms/editcustomform.py index eff6bc835..373c29794 100644 --- a/openlp/plugins/custom/forms/editcustomform.py +++ b/openlp/plugins/custom/forms/editcustomform.py @@ -271,4 +271,4 @@ class EditCustomForm(QtGui.QDialog, Ui_customEditDialog): if self.VerseTextEdit.toPlainText(): self.VerseTextEdit.setFocus() return False, self.trUtf8('You have unsaved data, please save or clear') - return True, u'' + return True, u'' diff --git a/openlp/plugins/media/lib/mediaitem.py b/openlp/plugins/media/lib/mediaitem.py index 7afe52cae..4f9c5e486 100644 --- a/openlp/plugins/media/lib/mediaitem.py +++ b/openlp/plugins/media/lib/mediaitem.py @@ -113,7 +113,6 @@ class MediaMediaItem(MediaManagerItem): filename = unicode((bitem.data(QtCore.Qt.UserRole)).toString()) Receiver.send_message(u'videodisplay_background', filename) - def generateSlideData(self, service_item, item=None): if item is None: item = self.ListView.currentItem() diff --git a/openlp/plugins/presentations/lib/impresscontroller.py b/openlp/plugins/presentations/lib/impresscontroller.py index 92717b6d7..a1a025c02 100644 --- a/openlp/plugins/presentations/lib/impresscontroller.py +++ b/openlp/plugins/presentations/lib/impresscontroller.py @@ -47,7 +47,7 @@ else: from PyQt4 import QtCore -from presentationcontroller import PresentationController, PresentationDocument +from presentationcontroller import PresentationController, PresentationDocument log = logging.getLogger(__name__) @@ -171,13 +171,13 @@ class ImpressController(PresentationController): def add_doc(self, name): log.debug(u'Add Doc OpenOffice') - doc = ImpressDocument(self, name) + doc = ImpressDocument(self, name) self.docs.append(doc) return doc class ImpressDocument(PresentationDocument): - def __init__(self, controller, presentation): + def __init__(self, controller, presentation): log.debug(u'Init Presentation OpenOffice') self.controller = controller self.document = None diff --git a/openlp/plugins/presentations/lib/messagelistener.py b/openlp/plugins/presentations/lib/messagelistener.py index eb31660f0..b15f25642 100644 --- a/openlp/plugins/presentations/lib/messagelistener.py +++ b/openlp/plugins/presentations/lib/messagelistener.py @@ -44,7 +44,7 @@ class Controller(object): self.doc = None log.info(u'%s controller loaded' % live) - def addHandler(self, controller, file, isBlank): + def addHandler(self, controller, file, isBlank): log.debug(u'Live = %s, addHandler %s' % (self.isLive, file)) self.controller = controller if self.doc is not None: diff --git a/openlp/plugins/presentations/lib/powerpointcontroller.py b/openlp/plugins/presentations/lib/powerpointcontroller.py index 67870574d..3ea95f509 100644 --- a/openlp/plugins/presentations/lib/powerpointcontroller.py +++ b/openlp/plugins/presentations/lib/powerpointcontroller.py @@ -31,7 +31,7 @@ if os.name == u'nt': import _winreg import win32ui -from presentationcontroller import PresentationController, PresentationDocument +from presentationcontroller import PresentationController, PresentationDocument log = logging.getLogger(__name__) @@ -62,7 +62,8 @@ class PowerpointController(PresentationController): log.debug(u'check_available') if os.name == u'nt': try: - _winreg.OpenKey(_winreg.HKEY_CLASSES_ROOT, u'PowerPoint.Application').Close() + _winreg.OpenKey(_winreg.HKEY_CLASSES_ROOT, + u'PowerPoint.Application').Close() return True except: pass @@ -96,13 +97,13 @@ class PowerpointController(PresentationController): def add_doc(self, name): log.debug(u'Add Doc PowerPoint') - doc = PowerpointDocument(self, name) + doc = PowerpointDocument(self, name) self.docs.append(doc) return doc class PowerpointDocument(PresentationDocument): - def __init__(self, controller, presentation): + def __init__(self, controller, presentation): log.debug(u'Init Presentation Powerpoint') self.presentation = None self.controller = controller diff --git a/openlp/plugins/presentations/lib/pptviewcontroller.py b/openlp/plugins/presentations/lib/pptviewcontroller.py index 455e1c601..e45fac45f 100644 --- a/openlp/plugins/presentations/lib/pptviewcontroller.py +++ b/openlp/plugins/presentations/lib/pptviewcontroller.py @@ -82,7 +82,8 @@ class PptviewController(PresentationController): if self.process: return log.debug(u'start PPTView') - self.process = cdll.LoadLibrary(r'openlp\plugins\presentations\lib\pptviewlib\pptviewlib.dll') + self.process = cdll.LoadLibrary( + r'openlp\plugins\presentations\lib\pptviewlib\pptviewlib.dll') def kill(self): """ @@ -94,13 +95,12 @@ class PptviewController(PresentationController): def add_doc(self, name): log.debug(u'Add Doc PPTView') - doc = PptviewDocument(self, name) + doc = PptviewDocument(self, name) self.docs.append(doc) return doc class PptviewDocument(PresentationDocument): - - def __init__(self, controller, presentation): + def __init__(self, controller, presentation): log.debug(u'Init Presentation PowerPoint') self.presentation = None self.pptid = None diff --git a/openlp/plugins/presentations/lib/presentationcontroller.py b/openlp/plugins/presentations/lib/presentationcontroller.py index fa6e9474d..1407820bc 100644 --- a/openlp/plugins/presentations/lib/presentationcontroller.py +++ b/openlp/plugins/presentations/lib/presentationcontroller.py @@ -210,7 +210,7 @@ class PresentationDocument(object): Returns a path to an image containing a preview for the requested slide """ - def __init__(self, controller, name): + def __init__(self, controller, name): self.slidenumber = 0 self.controller = controller self.store_filename(name) @@ -243,10 +243,10 @@ class PresentationDocument(object): if not os.path.isdir(self.thumbnailpath): os.mkdir(self.thumbnailpath) - def get_file_name(self, presentation): + def get_file_name(self, presentation): return os.path.split(presentation)[1] - def get_thumbnail_path(self, presentation): + def get_thumbnail_path(self, presentation): return os.path.join( self.controller.thumbnailroot, self.get_file_name(presentation)) diff --git a/openlp/plugins/songs/forms/editsongform.py b/openlp/plugins/songs/forms/editsongform.py index 8e8e873a6..4c3f78e2f 100644 --- a/openlp/plugins/songs/forms/editsongform.py +++ b/openlp/plugins/songs/forms/editsongform.py @@ -150,8 +150,7 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog): def loadBooks(self): books = self.songmanager.get_books() booksCompleter = QtGui.QCompleter( - [book.name for book in books], - self.SongbookCombo) + [book.name for book in books], self.SongbookCombo) booksCompleter.setCaseSensitivity(QtCore.Qt.CaseInsensitive); self.SongbookCombo.setCompleter(booksCompleter); self.SongbookCombo.clear() @@ -340,7 +339,7 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog): self.verse_form.setVerse(u'', self.VerseListWidget.count() + 1, True) if self.verse_form.exec_(): afterText, verse, subVerse = self.verse_form.getVerse() - data = u'%s:%s' %(verse, subVerse) + data = u'%s:%s' % (verse, subVerse) item = QtGui.QListWidgetItem(afterText) item.setData(QtCore.Qt.UserRole, QtCore.QVariant(data)) item.setText(afterText) @@ -351,11 +350,11 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog): if item: tempText = item.text() verseId = unicode((item.data(QtCore.Qt.UserRole)).toString()) - self.verse_form.setVerse(tempText, \ - self.VerseListWidget.count(), True, verseId) + self.verse_form.setVerse( + tempText, self.VerseListWidget.count(), True, verseId) if self.verse_form.exec_(): afterText, verse, subVerse = self.verse_form.getVerse() - data = u'%s:%s' %(verse, subVerse) + data = u'%s:%s' % (verse, subVerse) item.setData(QtCore.Qt.UserRole, QtCore.QVariant(data)) item.setText(afterText) #number of lines has change so repaint the list moving the data diff --git a/openlp/plugins/songs/lib/songxml.py b/openlp/plugins/songs/lib/songxml.py index 71506ff2d..2dc55ff7d 100644 --- a/openlp/plugins/songs/lib/songxml.py +++ b/openlp/plugins/songs/lib/songxml.py @@ -137,7 +137,7 @@ class _OpenSong(XmlRootClass): newtag = "Pre-chorus" else: newtag = t - s = (u'# %s %s'%(newtag, c)).rstrip() + s = (u'# %s %s' % (newtag, c)).rstrip() res.append(s) res.append(l[1:]) if (len(l) == 0) and (not tagPending): From 5a7e36b5bcd00f74da4597e0f63a791997756e67 Mon Sep 17 00:00:00 2001 From: Jon Tibble Date: Fri, 30 Apr 2010 23:38:15 +0100 Subject: [PATCH 60/63] Correct settingsSection naming convention --- openlp/core/lib/mediamanageritem.py | 10 ++++----- openlp/core/lib/plugin.py | 8 +++---- openlp/core/lib/settingstab.py | 2 +- openlp/core/ui/displaytab.py | 4 ++-- openlp/core/ui/generaltab.py | 6 ++--- openlp/core/ui/mainwindow.py | 22 +++++++++---------- openlp/core/ui/mediadockmanager.py | 4 ++-- openlp/core/ui/servicemanager.py | 20 ++++++++--------- openlp/core/ui/slidecontroller.py | 4 ++-- openlp/core/ui/thememanager.py | 18 +++++++-------- openlp/core/ui/themestab.py | 6 ++--- openlp/plugins/alerts/alertsplugin.py | 2 +- openlp/plugins/alerts/lib/alertstab.py | 4 ++-- .../plugins/bibles/forms/importwizardform.py | 6 ++--- openlp/plugins/bibles/lib/biblestab.py | 4 ++-- openlp/plugins/bibles/lib/manager.py | 8 +++---- openlp/plugins/bibles/lib/mediaitem.py | 2 +- openlp/plugins/custom/lib/customtab.py | 4 ++-- openlp/plugins/custom/lib/mediaitem.py | 2 +- openlp/plugins/images/lib/imagetab.py | 4 ++-- openlp/plugins/images/lib/mediaitem.py | 8 +++---- openlp/plugins/media/lib/mediaitem.py | 6 ++--- openlp/plugins/presentations/lib/mediaitem.py | 12 +++++----- .../lib/presentationcontroller.py | 6 ++--- .../presentations/lib/presentationtab.py | 4 ++-- openlp/plugins/remotes/lib/remotetab.py | 4 ++-- openlp/plugins/remotes/remoteplugin.py | 2 +- openlp/plugins/songs/lib/mediaitem.py | 2 +- openlp/plugins/songs/lib/songstab.py | 4 ++-- .../songusage/forms/songusagedetailform.py | 6 ++--- openlp/plugins/songusage/songusageplugin.py | 4 ++-- resources/pyinstaller/hook-lxml.objectify.py | 2 +- 32 files changed, 100 insertions(+), 100 deletions(-) diff --git a/openlp/core/lib/mediamanageritem.py b/openlp/core/lib/mediamanageritem.py index 83937160e..33901fb80 100644 --- a/openlp/core/lib/mediamanageritem.py +++ b/openlp/core/lib/mediamanageritem.py @@ -98,7 +98,7 @@ class MediaManagerItem(QtGui.QWidget): """ QtGui.QWidget.__init__(self) self.parent = parent - self.settings_section = title.lower() + self.settingsSection = title.lower() if type(icon) is QtGui.QIcon: self.icon = icon elif type(icon) is types.StringType: @@ -331,15 +331,15 @@ class MediaManagerItem(QtGui.QWidget): def onFileClick(self): files = QtGui.QFileDialog.getOpenFileNames( self, self.OnNewPrompt, - SettingsManager.get_last_dir(self.settings_section), + SettingsManager.get_last_dir(self.settingsSection), self.OnNewFileMasks) log.info(u'New files(s) %s', unicode(files)) if files: self.loadList(files) dir = os.path.split(unicode(files[0]))[0] - SettingsManager.set_last_dir(self.settings_section, dir) - SettingsManager.set_list(self.settings_section, - self.settings_section, self.getFileList()) + SettingsManager.set_last_dir(self.settingsSection, dir) + SettingsManager.set_list(self.settingsSection, + self.settingsSection, self.getFileList()) def getFileList(self): count = 0 diff --git a/openlp/core/lib/plugin.py b/openlp/core/lib/plugin.py index c7a257700..c1e06f780 100644 --- a/openlp/core/lib/plugin.py +++ b/openlp/core/lib/plugin.py @@ -51,7 +51,7 @@ class Plugin(QtCore.QObject): ``version`` The version number of this iteration of the plugin. - ``settings_section`` + ``settingsSection`` The namespace to store settings for the plugin. ``icon`` @@ -116,7 +116,7 @@ class Plugin(QtCore.QObject): self.name = name if version: self.version = version - self.settings_section = self.name.lower() + self.settingsSection = self.name.lower() self.icon = None self.weight = 0 self.status = PluginStatus.Inactive @@ -147,7 +147,7 @@ class Plugin(QtCore.QObject): Sets the status of the plugin """ self.status = QtCore.QSettings().value( - self.settings_section + u'/status', + self.settingsSection + u'/status', QtCore.QVariant(PluginStatus.Inactive)).toInt()[0] def toggle_status(self, new_status): @@ -156,7 +156,7 @@ class Plugin(QtCore.QObject): """ self.status = new_status QtCore.QSettings().setValue( - self.settings_section + u'/status', QtCore.QVariant(self.status)) + self.settingsSection + u'/status', QtCore.QVariant(self.status)) def is_active(self): """ diff --git a/openlp/core/lib/settingstab.py b/openlp/core/lib/settingstab.py index 8b9cc4261..0b862d9f8 100644 --- a/openlp/core/lib/settingstab.py +++ b/openlp/core/lib/settingstab.py @@ -40,7 +40,7 @@ class SettingsTab(QtGui.QWidget): QtGui.QWidget.__init__(self) self.tabTitle = title self.tabTitleVisible = None - self.settings_section = self.tabTitle.lower() + self.settingsSection = self.tabTitle.lower() self.setupUi() self.retranslateUi() self.initialise() diff --git a/openlp/core/ui/displaytab.py b/openlp/core/ui/displaytab.py index b38ff0842..38a0baa91 100644 --- a/openlp/core/ui/displaytab.py +++ b/openlp/core/ui/displaytab.py @@ -178,7 +178,7 @@ class DisplayTab(SettingsTab): def load(self): settings = QtCore.QSettings() - settings.beginGroup(self.settings_section) + settings.beginGroup(self.settingsSection) self.Xpos.setText(unicode(self.screens.current[u'size'].x())) self.Ypos.setText(unicode(self.screens.current[u'size'].y())) self.Height.setText(unicode(self.screens.current[u'size'].height())) @@ -208,7 +208,7 @@ class DisplayTab(SettingsTab): def save(self): settings = QtCore.QSettings() - settings.beginGroup(self.settings_section) + settings.beginGroup(self.settingsSection) settings.setValue('x position', QtCore.QVariant(self.XposEdit.text())) settings.setValue('y position', diff --git a/openlp/core/ui/generaltab.py b/openlp/core/ui/generaltab.py index 4616a62ba..ac4f92336 100644 --- a/openlp/core/ui/generaltab.py +++ b/openlp/core/ui/generaltab.py @@ -42,7 +42,7 @@ class GeneralTab(SettingsTab): If not set before default to last screen. """ settings = QtCore.QSettings() - settings.beginGroup(self.settings_section) + settings.beginGroup(self.settingsSection) self.MonitorNumber = settings.value(u'monitor', QtCore.QVariant(self.screens.monitor_number)).toInt()[0] self.screens.set_current_display(self.MonitorNumber) @@ -229,7 +229,7 @@ class GeneralTab(SettingsTab): def load(self): settings = QtCore.QSettings() - settings.beginGroup(self.settings_section) + settings.beginGroup(self.settingsSection) for screen in self.screens.screen_list: screen_name = u'%s %d' % (self.trUtf8('Screen'), screen[u'number'] + 1) @@ -268,7 +268,7 @@ class GeneralTab(SettingsTab): def save(self): settings = QtCore.QSettings() - settings.beginGroup(self.settings_section) + settings.beginGroup(self.settingsSection) settings.setValue(u'monitor', QtCore.QVariant(self.MonitorNumber)) settings.setValue(u'display on monitor', QtCore.QVariant(self.DisplayOnMonitor)) diff --git a/openlp/core/ui/mainwindow.py b/openlp/core/ui/mainwindow.py index 7c5f3ce24..df275dd20 100644 --- a/openlp/core/ui/mainwindow.py +++ b/openlp/core/ui/mainwindow.py @@ -426,10 +426,10 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow): self.applicationVersion = applicationVersion # Set up settings sections for the main application # (not for use by plugins) - self.ui_settings_section = u'user interface' - self.general_settings_section = u'general' - self.service_settings_section = u'servicemanager' - self.songs_settings_section = u'songs' + self.uiSettingsSection = u'user interface' + self.generalSettingsSection = u'general' + self.serviceSettingsSection = u'servicemanager' + self.songsSettingsSection = u'songs' self.serviceNotSaved = False self.settingsmanager = SettingsManager(screens) self.displayManager = DisplayManager(screens) @@ -576,7 +576,7 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow): self.displayManager.mainDisplay.setFocus() self.activateWindow() if QtCore.QSettings().value( - self.general_settings_section + u'/auto open', + self.generalSettingsSection + u'/auto open', QtCore.QVariant(False)).toBool(): self.ServiceManagerContents.onLoadService(True) @@ -586,7 +586,7 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow): Triggered by delay thread. """ settings = QtCore.QSettings() - settings.beginGroup(self.general_settings_section) + settings.beginGroup(self.generalSettingsSection) if settings.value(u'screen blank', QtCore.QVariant(False)).toBool() \ and settings.value(u'blank warning', QtCore.QVariant(False)).toBool(): self.LiveController.onBlankDisplay(True) @@ -731,10 +731,10 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow): def loadSettings(self): log.debug(u'Loading QSettings') settings = QtCore.QSettings() - settings.beginGroup(self.general_settings_section) + settings.beginGroup(self.generalSettingsSection) self.recentFiles = settings.value(u'recent files').toStringList() settings.endGroup() - settings.beginGroup(self.ui_settings_section) + settings.beginGroup(self.uiSettingsSection) self.move(settings.value(u'main window position', QtCore.QVariant(QtCore.QPoint(0, 0))).toPoint()) self.restoreGeometry( @@ -745,12 +745,12 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow): def saveSettings(self): log.debug(u'Saving QSettings') settings = QtCore.QSettings() - settings.beginGroup(self.general_settings_section) + settings.beginGroup(self.generalSettingsSection) recentFiles = QtCore.QVariant(self.recentFiles) \ if self.recentFiles else QtCore.QVariant() settings.setValue(u'recent files', recentFiles) settings.endGroup() - settings.beginGroup(self.ui_settings_section) + settings.beginGroup(self.uiSettingsSection) settings.setValue(u'main window position', QtCore.QVariant(self.pos())) settings.setValue(u'main window state', @@ -780,7 +780,7 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow): def addRecentFile(self, filename): recentFileCount = QtCore.QSettings().value( - self.general_settings_section + u'/max recent files', + self.generalSettingsSection + u'/max recent files', QtCore.QVariant(4)).toInt()[0] if filename and not self.recentFiles.contains(filename): self.recentFiles.prepend(QtCore.QString(filename)) diff --git a/openlp/core/ui/mediadockmanager.py b/openlp/core/ui/mediadockmanager.py index aece0729e..782383cd4 100644 --- a/openlp/core/ui/mediadockmanager.py +++ b/openlp/core/ui/mediadockmanager.py @@ -45,7 +45,7 @@ class MediaDockManager(object): log.debug(u'Inserting %s dock' % media_item.title) match = False for dock_index in range(0, self.media_dock.count()): - if self.media_dock.widget(dock_index).settings_section == \ + if self.media_dock.widget(dock_index).settingsSection == \ media_item.title.lower(): match = True break @@ -56,6 +56,6 @@ class MediaDockManager(object): log.debug(u'remove %s dock' % name) for dock_index in range(0, self.media_dock.count()): if self.media_dock.widget(dock_index): - if self.media_dock.widget(dock_index).settings_section == name: + if self.media_dock.widget(dock_index).settingsSection == name: self.media_dock.widget(dock_index).hide() self.media_dock.removeItem(dock_index) diff --git a/openlp/core/ui/servicemanager.py b/openlp/core/ui/servicemanager.py index b85301f8f..a92e923d5 100644 --- a/openlp/core/ui/servicemanager.py +++ b/openlp/core/ui/servicemanager.py @@ -191,7 +191,7 @@ class ServiceManager(QtGui.QWidget): QtCore.SIGNAL(u'config_updated'), self.regenerateServiceItems) # Last little bits of setting up self.service_theme = unicode(QtCore.QSettings().value( - self.parent.service_settings_section + u'/service theme', + self.parent.serviceSettingsSection + u'/service theme', QtCore.QVariant(u'')).toString()) self.servicePath = AppLocation.get_section_data_path(u'servicemanager') #build the context menu @@ -404,7 +404,7 @@ class ServiceManager(QtGui.QWidget): Clear the list to create a new service """ if self.parent.serviceNotSaved and QtCore.QSettings().value( - self.parent.general_settings_section + u'/save prompt', + self.parent.generalSettingsSection + u'/save prompt', QtCore.QVariant(False)).toBool(): ret = QtGui.QMessageBox.question(self, self.trUtf8('Save Changes to Service?'), @@ -489,11 +489,11 @@ class ServiceManager(QtGui.QWidget): if not quick or self.isNew: filename = QtGui.QFileDialog.getSaveFileName(self, self.trUtf8(u'Save Service'), - SettingsManager.get_last_dir(self.parent.service_settings_section), + SettingsManager.get_last_dir(self.parent.serviceSettingsSection), self.trUtf8(u'OpenLP Service Files (*.osz)')) else: filename = SettingsManager.get_last_dir( - self.parent.service_settings_section) + self.parent.serviceSettingsSection) if filename: splittedFile = filename.split(u'.') if splittedFile[-1] != u'osz': @@ -501,7 +501,7 @@ class ServiceManager(QtGui.QWidget): filename = unicode(filename) self.isNew = False SettingsManager.set_last_dir( - self.parent.service_settings_section, + self.parent.serviceSettingsSection, os.path.split(filename)[0]) service = [] servicefile = filename + u'.osd' @@ -544,12 +544,12 @@ class ServiceManager(QtGui.QWidget): def onLoadService(self, lastService=False): if lastService: filename = SettingsManager.get_last_dir( - self.parent.service_settings_section) + self.parent.serviceSettingsSection) else: filename = QtGui.QFileDialog.getOpenFileName( self, self.trUtf8('Open Service'), SettingsManager.get_last_dir( - self.parent.service_settings_section), u'Services (*.osz)') + self.parent.serviceSettingsSection), u'Services (*.osz)') self.loadService(filename) def loadService(self, filename=None): @@ -579,7 +579,7 @@ class ServiceManager(QtGui.QWidget): name = filename.split(os.path.sep) if filename: SettingsManager.set_last_dir( - self.parent.service_settings_section, + self.parent.serviceSettingsSection, os.path.split(filename)[0]) zip = None f = None @@ -650,7 +650,7 @@ class ServiceManager(QtGui.QWidget): self.service_theme = unicode(self.ThemeComboBox.currentText()) self.parent.RenderManager.set_service_theme(self.service_theme) QtCore.QSettings().setValue( - self.parent.service_settings_section + u'/service theme', + self.parent.serviceSettingsSection + u'/service theme', QtCore.QVariant(self.service_theme)) self.regenerateServiceItems() @@ -734,7 +734,7 @@ class ServiceManager(QtGui.QWidget): self.parent.LiveController.addServiceManagerItem( self.serviceItems[item][u'service_item'], count) if QtCore.QSettings().value( - self.parent.general_settings_section + u'/auto preview', + self.parent.generalSettingsSection + u'/auto preview', QtCore.QVariant(False)).toBool(): item += 1 if self.serviceItems and item < len(self.serviceItems) and \ diff --git a/openlp/core/ui/slidecontroller.py b/openlp/core/ui/slidecontroller.py index 6648bed00..8a0fa5641 100644 --- a/openlp/core/ui/slidecontroller.py +++ b/openlp/core/ui/slidecontroller.py @@ -396,7 +396,7 @@ class SlideController(QtGui.QWidget): if item.is_text(): self.Toolbar.makeWidgetsInvisible(self.loop_list) if QtCore.QSettings().value( - self.parent.songs_settings_section + u'/show songbar', + self.parent.songsSettingsSection + u'/show songbar', QtCore.QVariant(True)).toBool() and len(self.slideList) > 0: self.Toolbar.makeWidgetsVisible([u'Song Menu']) if item.is_capable(ItemCapabilities.AllowsLoop) and \ @@ -585,7 +585,7 @@ class SlideController(QtGui.QWidget): self.hideButton.setChecked(False) self.themeButton.setChecked(False) QtCore.QSettings().setValue( - self.parent.general_settings_section + u'/screen blank', + self.parent.generalSettingsSection + u'/screen blank', QtCore.QVariant(checked)) if checked: Receiver.send_message(u'maindisplay_hide', HideMode.Blank) diff --git a/openlp/core/ui/thememanager.py b/openlp/core/ui/thememanager.py index 8c3897fd1..4b356f758 100644 --- a/openlp/core/ui/thememanager.py +++ b/openlp/core/ui/thememanager.py @@ -47,7 +47,7 @@ class ThemeManager(QtGui.QWidget): def __init__(self, parent): QtGui.QWidget.__init__(self, parent) self.parent = parent - self.settings_section = u'themes' + self.settingsSection = u'themes' self.Layout = QtGui.QVBoxLayout(self) self.Layout.setSpacing(0) self.Layout.setMargin(0) @@ -106,14 +106,14 @@ class ThemeManager(QtGui.QWidget): QtCore.SIGNAL(u'theme_update_global'), self.changeGlobalFromTab) #Variables self.themelist = [] - self.path = AppLocation.get_section_data_path(self.settings_section) + self.path = AppLocation.get_section_data_path(self.settingsSection) self.checkThemesExists(self.path) self.thumbPath = os.path.join(self.path, u'thumbnails') self.checkThemesExists(self.thumbPath) self.amendThemeForm.path = self.path # Last little bits of setting up self.global_theme = unicode(QtCore.QSettings().value( - self.settings_section + u'/global theme', + self.settingsSection + u'/global theme', QtCore.QVariant(u'')).toString()) def changeGlobalFromTab(self, themeName): @@ -147,7 +147,7 @@ class ThemeManager(QtGui.QWidget): name = u'%s (%s)' % (self.global_theme, self.trUtf8('default')) self.ThemeListWidget.item(count).setText(name) QtCore.QSettings().setValue( - self.settings_section + u'/global theme', + self.settingsSection + u'/global theme', QtCore.QVariant(self.global_theme)) Receiver.send_message(u'theme_update_global', self.global_theme) self.pushThemes() @@ -170,7 +170,7 @@ class ThemeManager(QtGui.QWidget): def onDeleteTheme(self): self.global_theme = unicode(QtCore.QSettings().value( - self.settings_section + u'/global theme', + self.settingsSection + u'/global theme', QtCore.QVariant(u'')).toString()) item = self.ThemeListWidget.currentItem() if item: @@ -224,10 +224,10 @@ class ThemeManager(QtGui.QWidget): theme = unicode(item.data(QtCore.Qt.UserRole).toString()) path = QtGui.QFileDialog.getExistingDirectory(self, unicode(self.trUtf8('Save Theme - (%s)')) % theme, - SettingsManager.get_last_dir(self.settings_section, 1)) + SettingsManager.get_last_dir(self.settingsSection, 1)) path = unicode(path) if path: - SettingsManager.set_last_dir(self.settings_section, path, 1) + SettingsManager.set_last_dir(self.settingsSection, path, 1) themePath = os.path.join(path, theme + u'.theme') zip = None try: @@ -247,12 +247,12 @@ class ThemeManager(QtGui.QWidget): def onImportTheme(self): files = QtGui.QFileDialog.getOpenFileNames( self, self.trUtf8('Select Theme Import File'), - SettingsManager.get_last_dir(self.settings_section), u'Theme (*.*)') + SettingsManager.get_last_dir(self.settingsSection), u'Theme (*.*)') log.info(u'New Themes %s', unicode(files)) if files: for file in files: SettingsManager.set_last_dir( - self.settings_section, unicode(file)) + self.settingsSection, unicode(file)) self.unzipTheme(file, self.path) self.loadThemes() diff --git a/openlp/core/ui/themestab.py b/openlp/core/ui/themestab.py index 09e6cadaa..dba07eb6d 100644 --- a/openlp/core/ui/themestab.py +++ b/openlp/core/ui/themestab.py @@ -124,7 +124,7 @@ class ThemesTab(SettingsTab): def load(self): settings = QtCore.QSettings() - settings.beginGroup(self.settings_section) + settings.beginGroup(self.settingsSection) self.theme_level = settings.value( u'theme level', QtCore.QVariant(ThemeLevel.Global)).toInt()[0] self.global_theme = unicode(settings.value( @@ -139,7 +139,7 @@ class ThemesTab(SettingsTab): def save(self): settings = QtCore.QSettings() - settings.beginGroup(self.settings_section) + settings.beginGroup(self.settingsSection) settings.setValue(u'theme level', QtCore.QVariant(self.theme_level)) settings.setValue(u'global theme', @@ -179,7 +179,7 @@ class ThemesTab(SettingsTab): """ #reload as may have been triggered by the ThemeManager self.global_theme = unicode(QtCore.QSettings().value( - self.settings_section + u'/global theme', + self.settingsSection + u'/global theme', QtCore.QVariant(u'')).toString()) self.DefaultComboBox.clear() for theme in theme_list: diff --git a/openlp/plugins/alerts/alertsplugin.py b/openlp/plugins/alerts/alertsplugin.py index b3c72cc3f..f97540029 100644 --- a/openlp/plugins/alerts/alertsplugin.py +++ b/openlp/plugins/alerts/alertsplugin.py @@ -84,7 +84,7 @@ class alertsPlugin(Plugin): def togglealertsState(self): self.alertsActive = not self.alertsActive QtCore.QSettings().setValue( - self.settings_section + u'/active', + self.settingsSection + u'/active', QtCore.QVariant(self.alertsActive)) def onAlertsTrigger(self): diff --git a/openlp/plugins/alerts/lib/alertstab.py b/openlp/plugins/alerts/lib/alertstab.py index 53b8d2a7a..7cda09488 100644 --- a/openlp/plugins/alerts/lib/alertstab.py +++ b/openlp/plugins/alerts/lib/alertstab.py @@ -229,7 +229,7 @@ class AlertsTab(SettingsTab): def load(self): settings = QtCore.QSettings() - settings.beginGroup(self.settings_section) + settings.beginGroup(self.settingsSection) self.timeout = settings.value(u'timeout', QtCore.QVariant(5)).toInt()[0] self.font_color = unicode(settings.value( u'font color', QtCore.QVariant(u'#ffffff')).toString()) @@ -260,7 +260,7 @@ class AlertsTab(SettingsTab): def save(self): settings = QtCore.QSettings() - settings.beginGroup(self.settings_section) + settings.beginGroup(self.settingsSection) self.font_face = self.FontComboBox.currentFont().family() settings.setValue(u'background color', QtCore.QVariant(self.bg_color)) settings.setValue(u'font color', QtCore.QVariant(self.font_color)) diff --git a/openlp/plugins/bibles/forms/importwizardform.py b/openlp/plugins/bibles/forms/importwizardform.py index d3e8acd73..f5dbc8ee0 100644 --- a/openlp/plugins/bibles/forms/importwizardform.py +++ b/openlp/plugins/bibles/forms/importwizardform.py @@ -274,7 +274,7 @@ class ImportWizardForm(QtGui.QWizard, Ui_BibleImportWizard): def setDefaults(self): settings = QtCore.QSettings() - settings.beginGroup(self.bibleplugin.settings_section) + settings.beginGroup(self.bibleplugin.settingsSection) self.setField(u'source_format', QtCore.QVariant(0)) self.setField(u'osis_location', QtCore.QVariant('')) self.setField(u'csv_booksfile', QtCore.QVariant('')) @@ -345,11 +345,11 @@ class ImportWizardForm(QtGui.QWizard, Ui_BibleImportWizard): def getFileName(self, title, editbox): filename = QtGui.QFileDialog.getOpenFileName(self, title, - SettingsManager.get_last_dir(self.bibleplugin.settings_section, 1)) + SettingsManager.get_last_dir(self.bibleplugin.settingsSection, 1)) if filename: editbox.setText(filename) SettingsManager.set_last_dir( - self.bibleplugin.settings_section, filename, 1) + self.bibleplugin.settingsSection, filename, 1) def incrementProgressBar(self, status_text): log.debug(u'IncrementBar %s', status_text) diff --git a/openlp/plugins/bibles/lib/biblestab.py b/openlp/plugins/bibles/lib/biblestab.py index 7d3b7eb8c..80e0cef5e 100644 --- a/openlp/plugins/bibles/lib/biblestab.py +++ b/openlp/plugins/bibles/lib/biblestab.py @@ -189,7 +189,7 @@ class BiblesTab(SettingsTab): def load(self): settings = QtCore.QSettings() - settings.beginGroup(self.settings_section) + settings.beginGroup(self.settingsSection) self.show_new_chapters = settings.value( u'display new chapter', QtCore.QVariant(False)).toBool() self.display_style = settings.value( @@ -208,7 +208,7 @@ class BiblesTab(SettingsTab): def save(self): settings = QtCore.QSettings() - settings.beginGroup(self.settings_section) + settings.beginGroup(self.settingsSection) settings.setValue(u'display new chapter', QtCore.QVariant(self.show_new_chapters)) settings.setValue(u'display brackets', diff --git a/openlp/plugins/bibles/lib/manager.py b/openlp/plugins/bibles/lib/manager.py index d8fe3e156..8a87288f3 100644 --- a/openlp/plugins/bibles/lib/manager.py +++ b/openlp/plugins/bibles/lib/manager.py @@ -109,12 +109,12 @@ class BibleManager(object): """ log.debug(u'Bible Initialising') self.parent = parent - self.settings_section = u'bibles' + self.settingsSection = u'bibles' self.web = u'Web' self.db_cache = None - self.path = AppLocation.get_section_data_path(self.settings_section) + self.path = AppLocation.get_section_data_path(self.settingsSection) self.proxy_name = unicode( - QtCore.QSettings().value(self.settings_section + u'/proxy name', + QtCore.QSettings().value(self.settingsSection + u'/proxy name', QtCore.QVariant(u'')).toString()) self.suffix = u'.sqlite' self.import_wizard = None @@ -128,7 +128,7 @@ class BibleManager(object): BibleDB class. """ log.debug(u'Reload bibles') - files = SettingsManager.get_files(self.settings_section, self.suffix) + files = SettingsManager.get_files(self.settingsSection, self.suffix) log.debug(u'Bible Files %s', files) self.db_cache = {} for filename in files: diff --git a/openlp/plugins/bibles/lib/mediaitem.py b/openlp/plugins/bibles/lib/mediaitem.py index 228e39d5a..4ed28032c 100644 --- a/openlp/plugins/bibles/lib/mediaitem.py +++ b/openlp/plugins/bibles/lib/mediaitem.py @@ -275,7 +275,7 @@ class BibleMediaItem(MediaManagerItem): self.SearchProgress.setObjectName(u'SearchProgress') def configUpdated(self): - if QtCore.QSettings().value(self.settings_section + u'/dual bibles', + if QtCore.QSettings().value(self.settingsSection + u'/dual bibles', QtCore.QVariant(False)).toBool(): self.AdvancedSecondBibleLabel.setVisible(True) self.AdvancedSecondBibleComboBox.setVisible(True) diff --git a/openlp/plugins/custom/lib/customtab.py b/openlp/plugins/custom/lib/customtab.py index 2917487ff..2b6cedfbf 100644 --- a/openlp/plugins/custom/lib/customtab.py +++ b/openlp/plugins/custom/lib/customtab.py @@ -67,10 +67,10 @@ class CustomTab(SettingsTab): def load(self): self.displayFooter = QtCore.QSettings().value( - self.settings_section + u'/display footer', + self.settingsSection + u'/display footer', QtCore.QVariant(True)).toBool() self.DisplayFooterCheckBox.setChecked(self.displayFooter) def save(self): - QtCore.QSettings().setValue(self.settings_section + u'/display footer', + QtCore.QSettings().setValue(self.settingsSection + u'/display footer', QtCore.QVariant(self.displayFooter)) diff --git a/openlp/plugins/custom/lib/mediaitem.py b/openlp/plugins/custom/lib/mediaitem.py index 171317e1b..599d73625 100644 --- a/openlp/plugins/custom/lib/mediaitem.py +++ b/openlp/plugins/custom/lib/mediaitem.py @@ -163,7 +163,7 @@ class CustomMediaItem(MediaManagerItem): service_item.title = title for slide in raw_slides: service_item.add_from_text(slide[:30], slide) - if QtCore.QSettings().value(self.settings_section + u'/display footer', + if QtCore.QSettings().value(self.settingsSection + u'/display footer', QtCore.QVariant(True)).toBool() or credit: raw_footer.append(title + u' ' + credit) else: diff --git a/openlp/plugins/images/lib/imagetab.py b/openlp/plugins/images/lib/imagetab.py index 0cc531c0c..346d28b16 100644 --- a/openlp/plugins/images/lib/imagetab.py +++ b/openlp/plugins/images/lib/imagetab.py @@ -72,12 +72,12 @@ class ImageTab(SettingsTab): def load(self): self.loop_delay = QtCore.QSettings().value( - self.settings_section + u'/loop delay', + self.settingsSection + u'/loop delay', QtCore.QVariant(5)).toInt()[0] self.TimeoutSpinBox.setValue(self.loop_delay) def save(self): - QtCore.QSettings().setValue(self.settings_section + u'/loop delay', + QtCore.QSettings().setValue(self.settingsSection + u'/loop delay', QtCore.QVariant(self.loop_delay)) Receiver.send_message(u'slidecontroller_live_spin_delay', self.loop_delay) diff --git a/openlp/plugins/images/lib/mediaitem.py b/openlp/plugins/images/lib/mediaitem.py index c230b15f7..bcf2bd015 100644 --- a/openlp/plugins/images/lib/mediaitem.py +++ b/openlp/plugins/images/lib/mediaitem.py @@ -77,12 +77,12 @@ class ImageMediaItem(MediaManagerItem): QtGui.QAbstractItemView.ExtendedSelection) self.ListView.setIconSize(QtCore.QSize(88,50)) self.servicePath = os.path.join( - AppLocation.get_section_data_path(self.settings_section), + AppLocation.get_section_data_path(self.settingsSection), u'thumbnails') if not os.path.exists(self.servicePath): os.mkdir(self.servicePath) self.loadList(SettingsManager.load_list( - self.settings_section, self.settings_section)) + self.settingsSection, self.settingsSection)) def addListViewToToolBar(self): MediaManagerItem.addListViewToToolBar(self) @@ -121,8 +121,8 @@ class ImageMediaItem(MediaManagerItem): #if not present do not worry pass self.ListView.takeItem(item.row()) - SettingsManager.set_list(self.settings_section, - self.settings_section, self.getFileList()) + SettingsManager.set_list(self.settingsSection, + self.settingsSection, self.getFileList()) def loadList(self, list): for file in list: diff --git a/openlp/plugins/media/lib/mediaitem.py b/openlp/plugins/media/lib/mediaitem.py index 4f9c5e486..3ba632239 100644 --- a/openlp/plugins/media/lib/mediaitem.py +++ b/openlp/plugins/media/lib/mediaitem.py @@ -131,15 +131,15 @@ class MediaMediaItem(MediaManagerItem): QtGui.QAbstractItemView.ExtendedSelection) self.ListView.setIconSize(QtCore.QSize(88,50)) self.loadList(SettingsManager.load_list( - self.settings_section, self.settings_section)) + self.settingsSection, self.settingsSection)) def onDeleteClick(self): item = self.ListView.currentItem() if item: row = self.ListView.row(item) self.ListView.takeItem(row) - SettingsManager.set_list(self.settings_section, - self.settings_section, self.getFileList()) + SettingsManager.set_list(self.settingsSection, + self.settingsSection, self.getFileList()) def loadList(self, list): for file in list: diff --git a/openlp/plugins/presentations/lib/mediaitem.py b/openlp/plugins/presentations/lib/mediaitem.py index 62f81e5d5..408b33670 100644 --- a/openlp/plugins/presentations/lib/mediaitem.py +++ b/openlp/plugins/presentations/lib/mediaitem.py @@ -106,13 +106,13 @@ class PresentationMediaItem(MediaManagerItem): def initialise(self): self.servicePath = os.path.join( - AppLocation.get_section_data_path(self.settings_section), + AppLocation.get_section_data_path(self.settingsSection), u'thumbnails') self.ListView.setIconSize(QtCore.QSize(88,50)) if not os.path.exists(self.servicePath): os.mkdir(self.servicePath) list = SettingsManager.load_list( - self.settings_section, u'presentations') + self.settingsSection, u'presentations') self.loadList(list) for item in self.controllers: #load the drop down selection @@ -141,12 +141,12 @@ class PresentationMediaItem(MediaManagerItem): for controller in self.controllers: thumbPath = os.path.join( AppLocation.get_section_data_path( - self.settings_section), + self.settingsSection), u'thumbnails', controller, filename) thumb = os.path.join(thumbPath, u'slide1.png') preview = os.path.join( AppLocation.get_section_data_path( - self.settings_section), + self.settingsSection), controller, u'thumbnails', filename, u'slide1.png') if os.path.exists(preview): if os.path.exists(thumb): @@ -170,8 +170,8 @@ class PresentationMediaItem(MediaManagerItem): if item: row = self.ListView.row(item) self.ListView.takeItem(row) - SettingsManager.set_list(self.settings_section, - self.settings_section, self.getFileList()) + SettingsManager.set_list(self.settingsSection, + self.settingsSection, self.getFileList()) filepath = unicode((item.data(QtCore.Qt.UserRole)).toString()) #not sure of this has errors #John please can you look at . diff --git a/openlp/plugins/presentations/lib/presentationcontroller.py b/openlp/plugins/presentations/lib/presentationcontroller.py index 1407820bc..84a3d83a2 100644 --- a/openlp/plugins/presentations/lib/presentationcontroller.py +++ b/openlp/plugins/presentations/lib/presentationcontroller.py @@ -100,16 +100,16 @@ class PresentationController(object): self.docs = [] self.plugin = plugin self.name = name - self.settings_section = self.plugin.settings_section + self.settingsSection = self.plugin.settingsSection self.available = self.check_available() if self.available: self.enabled = QtCore.QSettings().value( - self.settings_section + u'/' + name, + self.settingsSection + u'/' + name, QtCore.Qt.Unchecked).toInt()[0] == QtCore.Qt.Checked else: self.enabled = False self.thumbnailroot = os.path.join( - AppLocation.get_section_data_path(self.settings_section), + AppLocation.get_section_data_path(self.settingsSection), name, u'thumbnails') self.thumbnailprefix = u'slide' if not os.path.isdir(self.thumbnailroot): diff --git a/openlp/plugins/presentations/lib/presentationtab.py b/openlp/plugins/presentations/lib/presentationtab.py index 998753a59..ebcbb3d7b 100644 --- a/openlp/plugins/presentations/lib/presentationtab.py +++ b/openlp/plugins/presentations/lib/presentationtab.py @@ -101,7 +101,7 @@ class PresentationTab(SettingsTab): if controller.available: checkbox = self.PresenterCheckboxes[controller.name] checkbox.setChecked(QtCore.QSettings().value( - self.settings_section + u'/' + controller.name, + self.settingsSection + u'/' + controller.name, QtCore.QVariant(0)).toInt()[0]) def save(self): @@ -109,5 +109,5 @@ class PresentationTab(SettingsTab): controller = self.controllers[key] checkbox = self.PresenterCheckboxes[controller.name] QtCore.QSettings().setValue( - self.settings_section + u'/' + controller.name, + self.settingsSection + u'/' + controller.name, QtCore.QVariant(checkbox.checkState())) diff --git a/openlp/plugins/remotes/lib/remotetab.py b/openlp/plugins/remotes/lib/remotetab.py index 2e38c1e2b..abdda065f 100644 --- a/openlp/plugins/remotes/lib/remotetab.py +++ b/openlp/plugins/remotes/lib/remotetab.py @@ -57,9 +57,9 @@ class RemoteTab(SettingsTab): def load(self): self.RemotePortSpinBox.setValue( - QtCore.QSettings().value(self.settings_section + u'/remote port', + QtCore.QSettings().value(self.settingsSection + u'/remote port', QtCore.QVariant(4316)).toInt()[0]) def save(self): - QtCore.QSettings().setValue(self.settings_section + u'/remote port', + QtCore.QSettings().setValue(self.settingsSection + u'/remote port', QtCore.QVariant(self.RemotePortSpinBox.value())) diff --git a/openlp/plugins/remotes/remoteplugin.py b/openlp/plugins/remotes/remoteplugin.py index 8bc91c824..7e95ff3bb 100644 --- a/openlp/plugins/remotes/remoteplugin.py +++ b/openlp/plugins/remotes/remoteplugin.py @@ -46,7 +46,7 @@ class RemotesPlugin(Plugin): self.insert_toolbox_item() self.server = QtNetwork.QUdpSocket() self.server.bind( - QtCore.QSettings().value(self.settings_section + u'/remote port', + QtCore.QSettings().value(self.settingsSection + u'/remote port', QtCore.QVariant(4316)).toInt()[0]) QtCore.QObject.connect(self.server, QtCore.SIGNAL(u'readyRead()'), self.readData) diff --git a/openlp/plugins/songs/lib/mediaitem.py b/openlp/plugins/songs/lib/mediaitem.py index 6a99c4ef7..040a6b26f 100644 --- a/openlp/plugins/songs/lib/mediaitem.py +++ b/openlp/plugins/songs/lib/mediaitem.py @@ -133,7 +133,7 @@ class SongMediaItem(MediaManagerItem): def configUpdated(self): self.searchAsYouType = QtCore.QSettings().value( - self.settings_section + u'/search as type', + self.settingsSection + u'/search as type', QtCore.QVariant(u'False')).toBool() def retranslateUi(self): diff --git a/openlp/plugins/songs/lib/songstab.py b/openlp/plugins/songs/lib/songstab.py index 36438f6fc..38bdd791d 100644 --- a/openlp/plugins/songs/lib/songstab.py +++ b/openlp/plugins/songs/lib/songstab.py @@ -81,7 +81,7 @@ class SongsTab(SettingsTab): def load(self): settings = QtCore.QSettings() - settings.beginGroup(self.settings_section) + settings.beginGroup(self.settingsSection) self.song_search = settings.value( u'search as type', QtCore.QVariant(False)).toBool() self.song_bar = settings.value( @@ -92,7 +92,7 @@ class SongsTab(SettingsTab): def save(self): settings = QtCore.QSettings() - settings.beginGroup(self.settings_section) + settings.beginGroup(self.settingsSection) settings.setValue(u'search as type', QtCore.QVariant(self.song_search)) settings.setValue(u'display songbar', QtCore.QVariant(self.song_bar)) settings.endGroup() diff --git a/openlp/plugins/songusage/forms/songusagedetailform.py b/openlp/plugins/songusage/forms/songusagedetailform.py index c6156e55c..31971f465 100644 --- a/openlp/plugins/songusage/forms/songusagedetailform.py +++ b/openlp/plugins/songusage/forms/songusagedetailform.py @@ -56,15 +56,15 @@ class SongUsageDetailForm(QtGui.QDialog, Ui_SongUsageDetailDialog): self.FromDate.setSelectedDate(fromDate) self.ToDate.setSelectedDate(toDate) self.FileLineEdit.setText( - SettingsManager.get_last_dir(self.parent.settings_section, 1)) + SettingsManager.get_last_dir(self.parent.settingsSection, 1)) def defineOutputLocation(self): path = QtGui.QFileDialog.getExistingDirectory(self, self.trUtf8('Output File Location'), - SettingsManager.get_last_dir(self.parent.settings_section, 1)) + SettingsManager.get_last_dir(self.parent.settingsSection, 1)) path = unicode(path) if path != u'': - SettingsManager.set_last_dir(self.parent.settings_section, path, 1) + SettingsManager.set_last_dir(self.parent.settingsSection, path, 1) self.FileLineEdit.setText(path) def accept(self): diff --git a/openlp/plugins/songusage/songusageplugin.py b/openlp/plugins/songusage/songusageplugin.py index da557e81e..aa753e163 100644 --- a/openlp/plugins/songusage/songusageplugin.py +++ b/openlp/plugins/songusage/songusageplugin.py @@ -111,7 +111,7 @@ class SongUsagePlugin(Plugin): QtCore.SIGNAL(u'slidecontroller_live_started'), self.onReceiveSongUsage) self.SongUsageActive = QtCore.QSettings().value( - self.settings_section + u'/active', + self.settingsSection + u'/active', QtCore.QVariant(False)).toBool() self.SongUsageStatus.setChecked(self.SongUsageActive) if self.songusagemanager is None: @@ -128,7 +128,7 @@ class SongUsagePlugin(Plugin): def toggleSongUsageState(self): self.SongUsageActive = not self.SongUsageActive - QtCore.QSettings().setValue(self.settings_section + u'/active', + QtCore.QSettings().setValue(self.settingsSection + u'/active', QtCore.QVariant(self.SongUsageActive)) def onReceiveSongUsage(self, items): diff --git a/resources/pyinstaller/hook-lxml.objectify.py b/resources/pyinstaller/hook-lxml.objectify.py index 071a0dca4..9d83432df 100644 --- a/resources/pyinstaller/hook-lxml.objectify.py +++ b/resources/pyinstaller/hook-lxml.objectify.py @@ -1 +1 @@ -hiddenimports = ['lxml.etree'] +hiddenimports = ['lxml.etree'] From 13922b05993f5433f725d6e92fc9784ecef8c143 Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Sat, 1 May 2010 07:58:41 +0100 Subject: [PATCH 61/63] Renames for consistancy --- openlp/core/lib/renderer.py | 60 ++++++++++++++++++------------------- 1 file changed, 30 insertions(+), 30 deletions(-) diff --git a/openlp/core/lib/renderer.py b/openlp/core/lib/renderer.py index 75229f780..cfb0e2bc2 100644 --- a/openlp/core/lib/renderer.py +++ b/openlp/core/lib/renderer.py @@ -48,8 +48,8 @@ class Renderer(object): self.theme_name = None self._theme = None self._bg_image_filename = None - self._frame = None - self._frameOp = None + self.frame = None + self.frame_opaque = None self.bg_frame = None self.bg_image = None @@ -89,10 +89,10 @@ class Renderer(object): """ log.debug(u'set bg image %s', filename) self._bg_image_filename = unicode(filename) - if self._frame: + if self.frame: self.bg_image = resize_image(self._bg_image_filename, - self._frame.width(), - self._frame.height()) + self.frame.width(), + self.frame.height()) def set_frame_dest(self, frame_width, frame_height, preview=False): """ @@ -111,13 +111,13 @@ class Renderer(object): self.bg_frame = None log.debug(u'set frame dest (frame) w %d h %d', frame_width, frame_height) - self._frame = QtGui.QImage(frame_width, frame_height, + self.frame = QtGui.QImage(frame_width, frame_height, QtGui.QImage.Format_ARGB32_Premultiplied) - self._frameOp = QtGui.QImage(frame_width, frame_height, + self.frame_opaque = QtGui.QImage(frame_width, frame_height, QtGui.QImage.Format_ARGB32_Premultiplied) if self._bg_image_filename and not self.bg_image: self.bg_image = resize_image(self._bg_image_filename, - self._frame.width(), self._frame.height()) + self.frame.width(), self.frame.height()) if self.bg_frame is None: self._generate_background_frame() @@ -242,9 +242,9 @@ class Renderer(object): if footer_lines: bbox1 = self._render_lines_unaligned(footer_lines, True) # reset the frame. first time do not worry about what you paint on. - self._frame = QtGui.QImage(self.bg_frame) + self.frame = QtGui.QImage(self.bg_frame) if self._theme.display_slideTransition: - self._frameOp = QtGui.QImage(self.bg_frame) + self.frame_opaque = QtGui.QImage(self.bg_frame) x, y = self._correctAlignment(self._rect, bbox) bbox = self._render_lines_unaligned(lines, False, (x, y), True) if footer_lines: @@ -252,9 +252,9 @@ class Renderer(object): (self._rect_footer.left(), self._rect_footer.top()), True) log.debug(u'generate_frame_from_lines - Finish') if self._theme.display_slideTransition: - return {u'main':self._frame, u'trans':self._frameOp} + return {u'main':self.frame, u'trans':self.frame_opaque} else: - return {u'main':self._frame, u'trans':None} + return {u'main':self.frame, u'trans':None} def _generate_background_frame(self): """ @@ -264,36 +264,36 @@ class Renderer(object): assert(self._theme) if self._theme.background_mode == u'transparent': self.bg_frame = \ - QtGui.QPixmap(self._frame.width(), self._frame.height()) + QtGui.QPixmap(self.frame.width(), self.frame.height()) self.bg_frame.fill(QtCore.Qt.transparent) else: - self.bg_frame = QtGui.QImage(self._frame.width(), - self._frame.height(), QtGui.QImage.Format_ARGB32_Premultiplied) + self.bg_frame = QtGui.QImage(self.frame.width(), + self.frame.height(), QtGui.QImage.Format_ARGB32_Premultiplied) log.debug(u'render background %s start', self._theme.background_type) painter = QtGui.QPainter() painter.begin(self.bg_frame) if self._theme.background_mode == u'transparent': - painter.fillRect(self._frame.rect(), QtCore.Qt.transparent) + painter.fillRect(self.frame.rect(), QtCore.Qt.transparent) else: if self._theme.background_type == u'solid': - painter.fillRect(self._frame.rect(), + painter.fillRect(self.frame.rect(), QtGui.QColor(self._theme.background_color)) elif self._theme.background_type == u'gradient': # gradient gradient = None if self._theme.background_direction == u'horizontal': - w = int(self._frame.width()) / 2 + w = int(self.frame.width()) / 2 # vertical gradient = QtGui.QLinearGradient(w, 0, w, - self._frame.height()) + self.frame.height()) elif self._theme.background_direction == u'vertical': - h = int(self._frame.height()) / 2 + h = int(self.frame.height()) / 2 # Horizontal - gradient = QtGui.QLinearGradient(0, h, self._frame.width(), + gradient = QtGui.QLinearGradient(0, h, self.frame.width(), h) else: - w = int(self._frame.width()) / 2 - h = int(self._frame.height()) / 2 + w = int(self.frame.width()) / 2 + h = int(self.frame.height()) / 2 # Circular gradient = QtGui.QRadialGradient(w, h, w) gradient.setColorAt(0, @@ -302,8 +302,8 @@ class Renderer(object): QtGui.QColor(self._theme.background_endColor)) painter.setBrush(QtGui.QBrush(gradient)) rectPath = QtGui.QPainterPath() - max_x = self._frame.width() - max_y = self._frame.height() + max_x = self.frame.width() + max_y = self.frame.height() rectPath.moveTo(0, 0) rectPath.lineTo(0, max_y) rectPath.lineTo(max_x, max_y) @@ -312,7 +312,7 @@ class Renderer(object): painter.drawPath(rectPath) elif self._theme.background_type == u'image': # image - painter.fillRect(self._frame.rect(), QtCore.Qt.black) + painter.fillRect(self.frame.rect(), QtCore.Qt.black) if self.bg_image: painter.drawImage(0, 0, self.bg_image) painter.end() @@ -378,7 +378,7 @@ class Renderer(object): retval = QtCore.QRect(x, y, brx - x, bry - y) if self._debug: painter = QtGui.QPainter() - painter.begin(self._frame) + painter.begin(self.frame) painter.setPen(QtGui.QPen(QtGui.QColor(0, 0, 255))) painter.drawRect(retval) painter.end() @@ -414,11 +414,11 @@ class Renderer(object): starty = y rightextent = None self.painter = QtGui.QPainter() - self.painter.begin(self._frame) + self.painter.begin(self.frame) self.painter.setRenderHint(QtGui.QPainter.Antialiasing) if self._theme.display_slideTransition: self.painter2 = QtGui.QPainter() - self.painter2.begin(self._frameOp) + self.painter2.begin(self.frame_opaque) self.painter2.setRenderHint(QtGui.QPainter.Antialiasing) self.painter2.setOpacity(0.7) # dont allow alignment messing with footers @@ -581,4 +581,4 @@ class Renderer(object): """ image.save(u'renderer.png', u'png') if image2: - image2.save(u'renderer2.png', u'png') + image2.save(u'renderer2.png', u'png') \ No newline at end of file From 9ef2b13ad6bb063d29e6d28428fdf00f70146ea0 Mon Sep 17 00:00:00 2001 From: Jonathan Corwin Date: Sat, 1 May 2010 13:10:48 +0100 Subject: [PATCH 62/63] comments, update client, load html from disk, blanking --- openlp/core/lib/eventreceiver.py | 13 ++ openlp/core/ui/slidecontroller.py | 18 ++ openlp/plugins/alerts/lib/alertsmanager.py | 7 +- openlp/plugins/remotes/html/index.html | 117 +++++++++++ openlp/plugins/remotes/lib/httpserver.py | 227 ++++++++++----------- openlp/plugins/remotes/remoteplugin.py | 16 +- scripts/openlp-remoteclient.py | 37 ++-- 7 files changed, 295 insertions(+), 140 deletions(-) create mode 100644 openlp/plugins/remotes/html/index.html diff --git a/openlp/core/lib/eventreceiver.py b/openlp/core/lib/eventreceiver.py index 73bfbbe61..d21e3f167 100644 --- a/openlp/core/lib/eventreceiver.py +++ b/openlp/core/lib/eventreceiver.py @@ -83,6 +83,12 @@ class EventReceiver(QtCore.QObject): Returns a slidecontroller_{live|preview}_text_response with an array of dictionaries with the tag and verse text + ``slidecontroller_{live|preview}_blank`` + Request that the output screen is blanked + + ``slidecontroller_{live|preview}_unblank`` + Request that the output screen is unblanked + ``slidecontroller_live_spin_delay`` Pushes out the loop delay @@ -132,6 +138,9 @@ class EventReceiver(QtCore.QObject): ``videodisplay_stop`` Stop playing a media item + ``videodisplay_background`` + Replace the background video + ``theme_update_list`` send out message with new themes @@ -196,6 +205,10 @@ class EventReceiver(QtCore.QObject): ``bibles_stop_import`` Stops the Bible Import + ``remotes_poll_request`` + Waits for openlp to do something "interesting" and sends a + remotes_poll_response signal when it does + """ def __init__(self): """ diff --git a/openlp/core/ui/slidecontroller.py b/openlp/core/ui/slidecontroller.py index 462f276bb..c0d0d915f 100644 --- a/openlp/core/ui/slidecontroller.py +++ b/openlp/core/ui/slidecontroller.py @@ -341,6 +341,12 @@ class SlideController(QtGui.QWidget): QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'slidecontroller_%s_set' % self.type_prefix), self.onSlideSelectedIndex) + QtCore.QObject.connect(Receiver.get_receiver(), + QtCore.SIGNAL(u'slidecontroller_%s_blank' % self.type_prefix), + self.onSlideBlank) + QtCore.QObject.connect(Receiver.get_receiver(), + QtCore.SIGNAL(u'slidecontroller_%s_unblank' % self.type_prefix), + self.onSlideUnblank) QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'slidecontroller_%s_text_request' % self.type_prefix), self.onTextRequest) @@ -616,6 +622,18 @@ class SlideController(QtGui.QWidget): self.PreviewListWidget.selectRow(index) self.onSlideSelected() + def onSlideBlank(self): + """ + Handle the slidecontroller blank event + """ + self.onBlankDisplay(True) + + def onSlideUnblank(self): + """ + Handle the slidecontroller unblank event + """ + self.onBlankDisplay(False) + def onBlankDisplay(self, checked): """ Handle the blank screen button diff --git a/openlp/plugins/alerts/lib/alertsmanager.py b/openlp/plugins/alerts/lib/alertsmanager.py index ee91e190e..35be3b7c2 100644 --- a/openlp/plugins/alerts/lib/alertsmanager.py +++ b/openlp/plugins/alerts/lib/alertsmanager.py @@ -75,8 +75,11 @@ class AlertsManager(QtCore.QObject): Called via a alerts_text event. Message is single element array containing text """ - self.displayAlert(message[0]) - + if message: + self.displayAlert(message[0]) + else: + self.displayAlert(u'') + def displayAlert(self, text=u''): """ Called from the Alert Tab to display an alert diff --git a/openlp/plugins/remotes/html/index.html b/openlp/plugins/remotes/html/index.html new file mode 100644 index 000000000..25b08fd43 --- /dev/null +++ b/openlp/plugins/remotes/html/index.html @@ -0,0 +1,117 @@ + + +OpenLP Controller + + + +

OpenLP Controller

+ + +
+ + +
+ + +
+ + +
+ +
+
+ +
+
+ OpenLP website + + + diff --git a/openlp/plugins/remotes/lib/httpserver.py b/openlp/plugins/remotes/lib/httpserver.py index 6f0ee3217..2c4105dab 100644 --- a/openlp/plugins/remotes/lib/httpserver.py +++ b/openlp/plugins/remotes/lib/httpserver.py @@ -24,12 +24,14 @@ ############################################################################### import logging +import os import json import urlparse from PyQt4 import QtCore, QtNetwork from openlp.core.lib import Receiver +from openlp.core.utils import AppLocation log = logging.getLogger(__name__) @@ -40,14 +42,25 @@ class HttpServer(object): http://localhost:4316/send/alerts_text?q=your%20alert%20text """ def __init__(self, parent): + """ + Initialise the httpserver, and start the server + """ log.debug(u'Initialise httpserver') self.parent = parent + self.html_dir = os.path.join( + AppLocation.get_directory(AppLocation.PluginsDir), + u'remotes', u'html') self.connections = [] self.current_item = None self.current_slide = None self.start_tcp() def start_tcp(self): + """ + Start the http server, use the port in the settings default to 4316 + Listen out for slide and song changes so they can be broadcast to + clients. Listen out for socket connections + """ log.debug(u'Start TCP server') port = QtCore.QSettings().value( self.parent.settingsSection + u'/remote port', @@ -66,29 +79,48 @@ class HttpServer(object): log.debug(u'TCP listening on port %d' % port) def slide_change(self, row): + """ + Slide change listener. Store the item and tell the clients + """ self.current_slide = row self.send_poll() def item_change(self, items): + """ + Item (song) change listener. Store the slide and tell the clients + """ self.current_item = items[0].title self.send_poll() def send_poll(self): - Receiver.send_message(u'remote_poll_response', + """ + Tell the clients something has changed + """ + Receiver.send_message(u'remotes_poll_response', {'slide': self.current_slide, 'item': self.current_item}) def new_connection(self): + """ + A new http connection has been made. Create a client object to handle + communication + """ log.debug(u'new http connection') socket = self.server.nextPendingConnection() if socket: self.connections.append(HttpConnection(self, socket)) def close_connection(self, connection): + """ + The connection has been closed. Clean up + """ log.debug(u'close http connection') self.connections.remove(connection) def close(self): + """ + Close down the http server + """ log.debug(u'close http server') self.server.close() @@ -98,6 +130,9 @@ class HttpConnection(object): and the client """ def __init__(self, parent, socket): + """ + Initialise the http connection. Listen out for socket signals + """ log.debug(u'Initialise HttpConnection: %s' % socket.peerAddress().toString()) self.socket = socket @@ -108,6 +143,9 @@ class HttpConnection(object): self.disconnected) def ready_read(self): + """ + Data has been sent from the client. Respond to it + """ log.debug(u'ready to read socket') if self.socket.canReadLine(): data = unicode(self.socket.readLine()) @@ -119,7 +157,9 @@ class HttpConnection(object): params = self.load_params(url.query) folders = url.path.split(u'/') if folders[1] == u'': - html = self.process_index() + html = self.serve_file(u'') + elif folders[1] == u'files': + html = self.serve_file(folders[2]) elif folders[1] == u'send': html = self.process_event(folders[2], params) elif folders[1] == u'request': @@ -131,120 +171,39 @@ class HttpConnection(object): html = self.get_404_not_found() self.socket.write(html) self.close() - - def process_index(self): - return u""" - - -OpenLP Controller - - - -

OpenLP Controller

- - -
- - -
- - -
- -
- -
- - -""" - + def serve_file(self, filename): + """ + Send a file to the socket. For now, just .html files + and must be top level inside the html folder. + If subfolders requested return 404, easier for security for the present. + + Ultimately for i18n, this could first look for xx/file.html before + falling back to file.html... where xx is the language, e.g. 'en' + """ + log.debug(u'serve file request %s' % filename) + if not filename: + filename = u'index.html' + if os.path.basename(filename) != filename: + return None + (fileroot, ext) = os.path.splitext(filename) + if ext != u'.html': + return None + path = os.path.join(self.parent.html_dir, filename) + try: + f = open(path, u'rb') + except: + log.exception(u'Failed to open %s' % path) + return None + log.debug(u'Opened %s' % path) + html = f.read() + f.close() + return html + def load_params(self, query): + """ + Decode the query string parameters sent from the browser + """ params = urlparse.parse_qs(query) if not params: return None @@ -252,6 +211,11 @@ send_event("remote_poll_request"); return params['q'] def process_event(self, event, params): + """ + Send a signal to openlp to perform an action. + Currently lets anything through. Later we should restrict and perform + basic parameter checking, otherwise rogue clients could crash openlp + """ if params: Receiver.send_message(event, params) else: @@ -259,6 +223,16 @@ send_event("remote_poll_request"); return u'OK' def process_request(self, event, params): + """ + Client has requested data. Send the signal and parameters for openlp + to handle, then listen out for a corresponding _request signal + which will have the data to return. + For most event timeout after 10 seconds (i.e. incase the signal + recipient isn't listening) + remotes_poll_request is a special case, this is a ajax long poll which + is just waiting for slide change/song change activity. This can wait + longer (one minute) + """ if not event.endswith(u'_request'): return False self.event = event @@ -269,7 +243,7 @@ send_event("remote_poll_request"); self.timer.setSingleShot(True) QtCore.QObject.connect(self.timer, QtCore.SIGNAL(u'timeout()'), self.timeout) - if event == 'remote_poll_request': + if event == 'remotes_poll_request': self.timer.start(60000) else: self.timer.start(10000) @@ -280,6 +254,10 @@ send_event("remote_poll_request"); return True def process_response(self, data): + """ + The recipient of a _request signal has sent data. Convert this to + json and return it to client + """ if not self.socket: return self.timer.stop() @@ -289,19 +267,32 @@ send_event("remote_poll_request"); self.close() def get_200_ok(self): + """ + Successful request. Send OK headers. Assume html for now. + """ return u'HTTP/1.1 200 OK\r\n' + \ u'Content-Type: text/html; charset="utf-8"\r\n' + \ u'\r\n' def get_404_not_found(self): + """ + Invalid url. Say so + """ return u'HTTP/1.1 404 Not Found\r\n'+ \ u'Content-Type: text/html; charset="utf-8"\r\n' + \ u'\r\n' def get_408_timeout(self): + """ + A _request hasn't returned anything in the timeout period. + Return timeout + """ return u'HTTP/1.1 408 Request Timeout\r\n' def timeout(self): + """ + Listener for timeout signal + """ if not self.socket: return html = self.get_408_timeout() @@ -309,10 +300,16 @@ send_event("remote_poll_request"); self.close() def disconnected(self): + """ + The client has disconnected. Tidy up + """ log.debug(u'socket disconnected') self.close() def close(self): + """ + The server has closed the connection. Tidy up + """ if not self.socket: return log.debug(u'close socket') diff --git a/openlp/plugins/remotes/remoteplugin.py b/openlp/plugins/remotes/remoteplugin.py index 0eec0739d..2c632d90d 100644 --- a/openlp/plugins/remotes/remoteplugin.py +++ b/openlp/plugins/remotes/remoteplugin.py @@ -36,17 +36,26 @@ class RemotesPlugin(Plugin): log.info(u'Remote Plugin loaded') def __init__(self, plugin_helpers): + """ + remotes constructor + """ Plugin.__init__(self, u'Remotes', u'1.9.1', plugin_helpers) self.weight = -1 self.server = None def initialise(self): + """ + Initialise the remotes plugin, and start the http server + """ log.debug(u'initialise') Plugin.initialise(self) self.insert_toolbox_item() self.server = HttpServer(self) def finalise(self): + """ + Tidy up and close down the http server + """ log.debug(u'finalise') self.remove_toolbox_item() if self.server: @@ -59,8 +68,11 @@ class RemotesPlugin(Plugin): return RemoteTab(self.name) def about(self): + """ + Information about this plugin + """ about_text = self.trUtf8('Remote Plugin
This plugin ' 'provides the ability to send messages to a running version of ' - 'openlp on a different computer.
The Primary use for this ' - 'would be to send alerts from a creche') + 'openlp on a different computer via a web browser or other app
' + 'The Primary use for this would be to send alerts from a creche') return about_text diff --git a/scripts/openlp-remoteclient.py b/scripts/openlp-remoteclient.py index de3099920..3ff7ccc05 100755 --- a/scripts/openlp-remoteclient.py +++ b/scripts/openlp-remoteclient.py @@ -24,34 +24,33 @@ # Temple Place, Suite 330, Boston, MA 02111-1307 USA # ############################################################################### -import socket +import urllib import sys from optparse import OptionParser -def sendData(options, message): - addr = (options.address, options.port) +def sendData(options): + addr = 'http://%s:%s/send/%s?q=%s' % (options.address, options.port, + options.event, options.message) try: - UDPSock = socket.socket(socket.AF_INET,socket.SOCK_DGRAM) - UDPSock.sendto(message, addr) - print u'message sent ', message, addr + urllib.urlopen(addr) + print u'Message sent ', addr except: - print u'Errow thrown ', sys.exc_info()[1] - -def format_message(options): - return u'%s:%s' % (u'alert', options.message) + print u'Error thrown ', sys.exc_info()[1] def main(): - usage = "usage: %prog [options] arg1 arg2" + usage = "usage: %prog [-a address] [-p port] [-e event] [-m message]" parser = OptionParser(usage=usage) - parser.add_option("-v", "--verbose", - action="store_true", dest="verbose", default=True, - help="make lots of noise [%default]") parser.add_option("-p", "--port", default=4316, help="IP Port number %default ") parser.add_option("-a", "--address", - help="Recipient address ") + help="Recipient address ", + default="localhost") + parser.add_option("-e", "--event", + help="Action to be performed", + default="alerts_text") parser.add_option("-m", "--message", - help="Message to be passed for the action") + help="Message to be passed for the action", + default="") (options, args) = parser.parse_args() if args: @@ -60,12 +59,8 @@ def main(): elif options.address is None: parser.print_help() parser.error("IP address missing") - elif options.message is None: - parser.print_help() - parser.error("No message passed") else: - text = format_message(options) - sendData(options, text) + sendData(options) if __name__ == u'__main__': main() From 4ffb7d8a185559c0ad60df41360443d4115975e2 Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Sat, 1 May 2010 14:05:17 +0100 Subject: [PATCH 63/63] Fix up drag and Drop for service items --- openlp/core/lib/mediamanageritem.py | 4 +- openlp/core/lib/plugin.py | 7 +++- openlp/core/lib/serviceitem.py | 1 + openlp/core/ui/servicemanager.py | 30 ++++++++++++-- openlp/plugins/bibles/lib/mediaitem.py | 1 + openlp/plugins/images/lib/mediaitem.py | 1 + openlp/plugins/presentations/lib/mediaitem.py | 41 ++++++++++--------- 7 files changed, 59 insertions(+), 26 deletions(-) diff --git a/openlp/core/lib/mediamanageritem.py b/openlp/core/lib/mediamanageritem.py index 33901fb80..36cc738b8 100644 --- a/openlp/core/lib/mediamanageritem.py +++ b/openlp/core/lib/mediamanageritem.py @@ -429,7 +429,7 @@ class MediaManagerItem(QtGui.QWidget): service_item = self.buildServiceItem() if service_item: service_item.from_plugin = False - self.parent.service_manager.addServiceItem(service_item, + self.parent.service_manager.addServiceItem(service_item, replace=self.remoteTriggered) else: items = self.ListView.selectedIndexes() @@ -454,7 +454,7 @@ class MediaManagerItem(QtGui.QWidget): 'You must select an existing service item to add to.')) elif self.title.lower() == service_item.name.lower(): self.generateSlideData(service_item) - self.parent.service_manager.addServiceItem(service_item, + self.parent.service_manager.addServiceItem(service_item, replace=True) else: #Turn off the remote edit update message indicator diff --git a/openlp/core/lib/plugin.py b/openlp/core/lib/plugin.py index c1e06f780..ebb38615d 100644 --- a/openlp/core/lib/plugin.py +++ b/openlp/core/lib/plugin.py @@ -215,13 +215,16 @@ class Plugin(QtCore.QObject): """ pass - def process_add_service_event(self): + def process_add_service_event(self, replace=False): """ Generic Drag and drop handler triggered from service_manager. """ log.debug(u'process_add_service_event event called for plugin %s' % self.name) - self.media_item.onAddClick() + if replace: + self.media_item.onAddEditClick() + else: + self.media_item.onAddClick() def about(self): """ diff --git a/openlp/core/lib/serviceitem.py b/openlp/core/lib/serviceitem.py index 25f08717f..2f6d973e2 100644 --- a/openlp/core/lib/serviceitem.py +++ b/openlp/core/lib/serviceitem.py @@ -48,6 +48,7 @@ class ItemCapabilities(object): AllowsMaintain = 3 RequiresMedia = 4 AllowsLoop = 5 + AllowsAdditions = 6 class ServiceItem(object): """ diff --git a/openlp/core/ui/servicemanager.py b/openlp/core/ui/servicemanager.py index a92e923d5..d8642f4d9 100644 --- a/openlp/core/ui/servicemanager.py +++ b/openlp/core/ui/servicemanager.py @@ -194,12 +194,18 @@ class ServiceManager(QtGui.QWidget): self.parent.serviceSettingsSection + u'/service theme', QtCore.QVariant(u'')).toString()) self.servicePath = AppLocation.get_section_data_path(u'servicemanager') + #build the drag and drop context menu + self.dndMenu = QtGui.QMenu() + self.newAction = self.dndMenu.addAction(self.trUtf8('&Add New Item')) + self.newAction.setIcon(build_icon(u':/general/general_edit.png')) + self.addToAction = self.dndMenu.addAction(self.trUtf8('&Add to Selected Item')) + self.addToAction.setIcon(build_icon(u':/general/general_edit.png')) #build the context menu self.menu = QtGui.QMenu() self.editAction = self.menu.addAction(self.trUtf8('&Edit Item')) self.editAction.setIcon(build_icon(u':/general/general_edit.png')) self.maintainAction = self.menu.addAction(self.trUtf8('&Maintain Item')) - self.editAction.setIcon(build_icon(u':/general/general_edit.png')) + self.maintainAction.setIcon(build_icon(u':/general/general_edit.png')) self.notesAction = self.menu.addAction(self.trUtf8('&Notes')) self.notesAction.setIcon(build_icon(u':/services/service_notes.png')) self.deleteAction = self.menu.addAction( @@ -795,6 +801,7 @@ class ServiceManager(QtGui.QWidget): if link.hasText(): plugin = event.mimeData().text() item = self.ServiceManagerList.itemAt(event.pos()) + #ServiceManager started the drag and drop if plugin == u'ServiceManager': startpos, startCount = self.findServiceItem() if item is None: @@ -810,11 +817,28 @@ class ServiceManager(QtGui.QWidget): self.serviceItems.insert(newpos, serviceItem) self.repaintServiceList(endpos, startCount) else: + #we are not over anything so drop + replace = False if item == None: self.droppos = len(self.serviceItems) else: - self.droppos = self._getParentItemData(item) - Receiver.send_message(u'%s_add_service_item' % plugin) + #we are over somthing so lets investigate + pos = self._getParentItemData(item) - 1 + serviceItem = self.serviceItems[pos] + if plugin == serviceItem[u'service_item'].name \ + and serviceItem[u'service_item'].is_capable(ItemCapabilities.AllowsAdditions): + action = self.dndMenu.exec_(QtGui.QCursor.pos()) + #New action required + if action == self.newAction: + self.droppos = self._getParentItemData(item) + #Append to existing action + if action == self.addToAction: + self.droppos = self._getParentItemData(item) + item.setSelected(True) + replace = True + else: + self.droppos = self._getParentItemData(item) + Receiver.send_message(u'%s_add_service_item' % plugin, replace) def updateThemeList(self, theme_list): """ diff --git a/openlp/plugins/bibles/lib/mediaitem.py b/openlp/plugins/bibles/lib/mediaitem.py index 4ed28032c..d6aadd09f 100644 --- a/openlp/plugins/bibles/lib/mediaitem.py +++ b/openlp/plugins/bibles/lib/mediaitem.py @@ -449,6 +449,7 @@ class BibleMediaItem(MediaManagerItem): bible_text = u'' service_item.add_capability(ItemCapabilities.AllowsPreview) service_item.add_capability(ItemCapabilities.AllowsLoop) + service_item.add_capability(ItemCapabilities.AllowsAdditions) #If we want to use a 2nd translation / version bible2 = u'' if self.SearchTabWidget.currentIndex() == 0: diff --git a/openlp/plugins/images/lib/mediaitem.py b/openlp/plugins/images/lib/mediaitem.py index bcf2bd015..306664fe3 100644 --- a/openlp/plugins/images/lib/mediaitem.py +++ b/openlp/plugins/images/lib/mediaitem.py @@ -147,6 +147,7 @@ class ImageMediaItem(MediaManagerItem): service_item.add_capability(ItemCapabilities.AllowsMaintain) service_item.add_capability(ItemCapabilities.AllowsPreview) service_item.add_capability(ItemCapabilities.AllowsLoop) + service_item.add_capability(ItemCapabilities.AllowsAdditions) for item in items: bitem = self.ListView.item(item.row()) filename = unicode((bitem.data(QtCore.Qt.UserRole)).toString()) diff --git a/openlp/plugins/presentations/lib/mediaitem.py b/openlp/plugins/presentations/lib/mediaitem.py index 408b33670..9c654b198 100644 --- a/openlp/plugins/presentations/lib/mediaitem.py +++ b/openlp/plugins/presentations/lib/mediaitem.py @@ -187,26 +187,29 @@ class PresentationMediaItem(MediaManagerItem): service_item.title = unicode(self.DisplayTypeComboBox.currentText()) service_item.shortname = unicode(self.DisplayTypeComboBox.currentText()) shortname = service_item.shortname - for item in items: - bitem = self.ListView.item(item.row()) - filename = unicode((bitem.data(QtCore.Qt.UserRole)).toString()) - if shortname == self.Automatic: - service_item.shortname = self.findControllerByType(filename) - if not service_item.shortname: - return False - controller = self.controllers[service_item.shortname] - (path, name) = os.path.split(filename) - doc = controller.add_doc(filename) - if doc.get_slide_preview_file(1) is None: - doc.load_presentation() - i = 1 - img = doc.get_slide_preview_file(i) - while img: - service_item.add_from_command(path, name, img) - i = i + 1 + if shortname: + for item in items: + bitem = self.ListView.item(item.row()) + filename = unicode((bitem.data(QtCore.Qt.UserRole)).toString()) + if shortname == self.Automatic: + service_item.shortname = self.findControllerByType(filename) + if not service_item.shortname: + return False + controller = self.controllers[service_item.shortname] + (path, name) = os.path.split(filename) + doc = controller.add_doc(filename) + if doc.get_slide_preview_file(1) is None: + doc.load_presentation() + i = 1 img = doc.get_slide_preview_file(i) - doc.close_presentation() - return True + while img: + service_item.add_from_command(path, name, img) + i = i + 1 + img = doc.get_slide_preview_file(i) + doc.close_presentation() + return True + else: + return False def findControllerByType(self, filename): filetype = os.path.splitext(filename)[1]