From 473bb289b6357f3710f9c446e053e53a064c141e Mon Sep 17 00:00:00 2001 From: Raoul Snyman Date: Fri, 5 Jun 2009 20:53:50 +0200 Subject: [PATCH] Fixed displaying of "display" label on the display form. Display form is displayed on the correct screen at startup. Display form switches to active non-primary screen or hidden on primary screen after set in the settings dialog. A few syntax tidy-ups. Made the loading and saving of things to the "registry" better. --- openlp/core/lib/pluginconfig.py | 8 +- openlp/core/lib/renderer.py | 62 +++++---------- openlp/core/lib/rendermanager.py | 18 +++-- openlp/core/lib/settingstab.py | 8 +- openlp/core/ui/alertstab.py | 42 +++++----- openlp/core/ui/generaltab.py | 51 +++++++------ openlp/core/ui/maindisplay.py | 21 ++--- openlp/core/ui/mainwindow.py | 76 ++++++++++--------- openlp/core/ui/themestab.py | 8 +- openlp/core/utils/registry.py | 22 ++++-- openlp/plugins/bibles/lib/biblestab.py | 45 +++++------ openlp/plugins/custom/lib/customtab.py | 2 +- openlp/plugins/media/lib/mediatab.py | 30 ++++---- .../presentations/lib/presentationtab.py | 74 +++++++++--------- openlp/plugins/songs/lib/songstab.py | 4 +- 15 files changed, 236 insertions(+), 235 deletions(-) diff --git a/openlp/core/lib/pluginconfig.py b/openlp/core/lib/pluginconfig.py index d8c6ca2d5..e1c2ff753 100644 --- a/openlp/core/lib/pluginconfig.py +++ b/openlp/core/lib/pluginconfig.py @@ -56,10 +56,8 @@ class PluginConfig(object): 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): @@ -74,8 +72,8 @@ class PluginConfig(object): if suffix != None: return_files = [] for f in files: - if f.find('.') != -1: - nme = f.split('.') + if f.find(u'.') != -1: + nme = f.split(u'.') bname = nme[0] sfx = nme[1].lower() sfx = sfx.lower() @@ -127,7 +125,7 @@ class PluginConfig(object): name = u'last directory' last_dir = self.get_config(name) if last_dir is None: - last_dir = '' + last_dir = u'' return last_dir def set_last_dir(self, directory, num=None): diff --git a/openlp/core/lib/renderer.py b/openlp/core/lib/renderer.py index a661552c3..3825db7a0 100644 --- a/openlp/core/lib/renderer.py +++ b/openlp/core/lib/renderer.py @@ -27,11 +27,8 @@ from PyQt4 import QtGui, QtCore, Qt from copy import copy class Renderer: - - global log - log = logging.getLogger(u'Renderer') - log.info(u'Renderer Loaded') - """All the functions for rendering a set of words onto a Device Context + """ + All the functions for rendering a set of words onto a Device Context How to use: set the words to be displayed with a call to format_slide() - this returns an array of screenfuls of data @@ -39,8 +36,11 @@ class Renderer: tell it which DC to render to with set_DC() set the borders of where you want the text (if not the whole DC) with set_text_rectangle() tell it to render a particular screenfull with render_screen(n) - """ + global log + log = logging.getLogger(u'Renderer') + log.info(u'Renderer Loaded') + def __init__(self): self._rect = None self._debug = 0 @@ -119,19 +119,11 @@ class Renderer: lines = verse.split(u'\n') for line in lines: text.append(line) - split_text = self._split_set_of_lines(text, False) print "split text ", split_text print "text ", text return split_text -# def render_screen(self, screennum): -# log.debug(u'render screen\n %s %s ', screennum, self.words[screennum]) -# t = 0.0 -# words = self.words[screennum] -# retval = self._render_lines(words) -# return retval - def set_text_rectangle(self, rect_main, rect_footer): """ Sets the rectangle within which text should be rendered @@ -145,23 +137,17 @@ class Renderer: """ #print "########## Generate frame from lines ##################" log.debug(u'generate_frame_from_lines - Start') - #print "Render Lines ", lines - bbox = self._render_lines_unaligned(lines, False) if footer_lines is not None: bbox1 = self._render_lines_unaligned(footer_lines, True) - # reset the frame. first time do not worrk about what you paint on. self._frame = QtGui.QPixmap(self._bg_frame) - x, y = self._correctAlignment(self._rect, bbox) bbox = self._render_lines_unaligned(lines, False, (x, y)) - if footer_lines is not None: bbox = self._render_lines_unaligned(footer_lines, True, (self._rect_footer.left(), self._rect_footer.top()) ) log.debug(u'generate_frame_from_lines - Finish') - return self._frame def _generate_background_frame(self): @@ -189,23 +175,18 @@ class Renderer: w = int(self._frame.width()) / 2 h = int(self._frame.height()) / 2 gradient = QtGui.QRadialGradient(w, h, w) # Circular - gradient.setColorAt(0, QtGui.QColor(self._theme.background_startColor)) gradient.setColorAt(1, QtGui.QColor(self._theme.background_endColor)) - painter.setBrush(QtGui.QBrush(gradient)) rectPath = QtGui.QPainterPath() - 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) rectPath.lineTo(max_x, 0) - rectPath.closeSubpath() painter.drawPath(rectPath) - elif self._theme.background_type== u'image': # image if self.bg_image is not None: painter.drawPixmap(0 ,0 , self.bg_image) @@ -219,24 +200,19 @@ class Renderer: def _split_set_of_lines(self, lines, footer): """ Given a list of lines, decide how to split them best if they don't all fit on the screen - - this is done by splitting at 1/2, 1/3 or 1/4 of the set - If it doesn't fit, even at this size, just split at each opportunity - - We'll do this by getting the bounding box of each line, and then summing them appropriately - Returns a list of [lists of lines], one set for each screenful - """ + - this is done by splitting at 1/2, 1/3 or 1/4 of the set + If it doesn't fit, even at this size, just split at each opportunity. + We'll do this by getting the bounding box of each line, and then summing them appropriately + Returns a list of [lists of lines], one set for each screenful + """ bboxes = [] #print "lines ", lines - for line in lines: bboxes.append(self._render_and_wrap_single_line(line, footer)) #print "bboxes ", bboxes - numlines = len(lines) bottom = self._rect.bottom() - count = 0 - for ratio in (numlines, numlines/2, numlines/3, numlines/4): good = 1 startline = 0 @@ -258,7 +234,6 @@ class Renderer: endline = startline + ratio if good == 1: break - retval = [] numlines_per_page = ratio #print "good ", good, ratio @@ -276,7 +251,7 @@ class Renderer: retval.append(thislines) #print "extra ", thislines else: -# print "Just split where you can" + # print "Just split where you can" retval = [] startline = 0 endline = startline + 1 @@ -312,7 +287,6 @@ class Renderer: (using the _render_single_line fn - which may result in going off the bottom) They are expected to be pre-arranged to less than a screenful (eg. by using split_set_of_lines) - Returns the bounding box of the text as QRect """ log.debug(u'render lines unaligned Start') @@ -339,10 +313,8 @@ class Renderer: """ Render a single line of words onto the DC, top left corner specified. - If the line is too wide for the context, it wraps, but right-aligns the surplus words in the manner of song lyrics - Returns the bottom-right corner (of what was rendered) as a tuple(x, y). """ log.debug(u'Render single line %s @ %s '%( line, tlcorner)) @@ -374,7 +346,6 @@ class Renderer: align = 0 else: align = int(self._theme .display_horizontalAlign) - for linenum in range(len(lines)): line = lines[linenum] #find out how wide line is @@ -420,7 +391,6 @@ class Renderer: color = self._theme.display_outline_color) self._get_extent_and_render(line, footer,(x-self._outline_offset,y-self._outline_offset), draw=True, color = self._theme.display_outline_color) - self._get_extent_and_render(line, footer,tlcorner=(x, y), draw=True) y += h if linenum == 0: @@ -432,7 +402,6 @@ class Renderer: painter.setPen(QtGui.QPen(QtGui.QColor(0,255,0))) painter.drawRect(startx , starty , rightextent-startx , y-starty) painter.end() - brcorner = (rightextent , y) log.debug(u'Render single line Finish') return brcorner @@ -489,3 +458,10 @@ class Renderer: if image2 is not None: im = image2.toImage() im.save("renderer2.png", "png") + +# def render_screen(self, screennum): +# log.debug(u'render screen\n %s %s ', screennum, self.words[screennum]) +# t = 0.0 +# words = self.words[screennum] +# retval = self._render_lines(words) +# return retval diff --git a/openlp/core/lib/rendermanager.py b/openlp/core/lib/rendermanager.py index 608a8deaf..d99ee33d1 100644 --- a/openlp/core/lib/rendermanager.py +++ b/openlp/core/lib/rendermanager.py @@ -54,17 +54,25 @@ class RenderManager: log=logging.getLogger(u'RenderManager') log.info(u'RenderManager Loaded') - def __init__(self, theme_manager, screen_list): + def __init__(self, theme_manager, screen_list, screen_number=0): log.debug(u'Initilisation started') self.screen_list = screen_list self.theme_manager = theme_manager self.displays = len(screen_list) - self.current_display = 0 + self.current_display = screen_number self.renderer = Renderer() self.calculate_default(self.screen_list[self.current_display]['size']) self.theme = u'' self.service_theme = u'' + def update_display(self, screen_number): + """ + Updates the render manager's information about the current screen. + """ + if self.current_display != screen_number: + self.current_display = screen_number + self.calculate_default(self.screen_list[self.current_display]['size']) + def set_global_theme(self, global_theme, global_style = u'Global'): self.global_theme = global_theme self.global_style = global_style @@ -95,7 +103,7 @@ class RenderManager: if self.theme is not self.renderer.theme_name: log.debug(u'theme is now %s', self.theme) self.themedata = self.theme_manager.getThemeData(self.theme) - self.calculate_default(self.screen_list[self.current_display]['size']) + self.calculate_default(self.screen_list[self.current_display][u'size']) self.renderer.set_theme(self.themedata) self.build_text_rectangle(self.themedata) @@ -140,14 +148,14 @@ class RenderManager: def format_slide(self, words): log.debug(u'format slide') - self.calculate_default(self.screen_list[self.current_display]['size']) + self.calculate_default(self.screen_list[self.current_display][u'size']) self.build_text_rectangle(self.themedata) self.renderer.set_frame_dest(self.width, self.height) return self.renderer.format_slide(words, False) def generate_slide(self,main_text, footer_text): log.debug(u'generate slide') - self.calculate_default(self.screen_list[self.current_display]['size']) + self.calculate_default(self.screen_list[self.current_display][u'size']) 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) diff --git a/openlp/core/lib/settingstab.py b/openlp/core/lib/settingstab.py index 494ffbe55..1eddbee0e 100644 --- a/openlp/core/lib/settingstab.py +++ b/openlp/core/lib/settingstab.py @@ -25,7 +25,7 @@ class SettingsTab(QtGui.QWidget): """ SettingsTab is a helper widget for plugins to define Tabs for the settings dialog. """ - def __init__(self, title=None): + def __init__(self, title=None, section=None): """ Constructor to create the Steetings tab item. """ @@ -34,10 +34,10 @@ class SettingsTab(QtGui.QWidget): self.setupUi() self.retranslateUi() self.initialise() - if title == None: - self.config = PluginConfig(u'Main') + if section == None: + self.config = PluginConfig(title) else: - self.config = PluginConfig(str(title)) + self.config = PluginConfig(section) self.load() def setTitle(self, title): diff --git a/openlp/core/ui/alertstab.py b/openlp/core/ui/alertstab.py index 883ebc966..c13af83c4 100644 --- a/openlp/core/ui/alertstab.py +++ b/openlp/core/ui/alertstab.py @@ -29,7 +29,7 @@ class AlertsTab(SettingsTab): def __init__(self): self.font_color = '#ffffff' self.bg_color = '#660000' - SettingsTab.__init__(self, u'Alerts') + SettingsTab.__init__(self, translate(u'AlertsTab', u'Alerts'), u'Alerts') def setupUi(self): self.setObjectName(u'AlertsTab') @@ -130,13 +130,13 @@ class AlertsTab(SettingsTab): self.AlertsLayout.addWidget(self.AlertRightColumn) # Signals and slots QtCore.QObject.connect(self.BackgroundColorButton, - QtCore.SIGNAL("pressed()"), self.onBackgroundColorButtonClicked) + QtCore.SIGNAL(u'pressed()'), self.onBackgroundColorButtonClicked) QtCore.QObject.connect(self.FontColorButton, - QtCore.SIGNAL("pressed()"), self.onFontColorButtonClicked) + QtCore.SIGNAL(u'pressed()'), self.onFontColorButtonClicked) QtCore.QObject.connect(self.FontComboBox, - QtCore.SIGNAL("activated(int)"), self.onFontComboBoxClicked) + QtCore.SIGNAL(u'activated(int)'), self.onFontComboBoxClicked) QtCore.QObject.connect(self.TimeoutSpinBox, - QtCore.SIGNAL("valueChanged(int)"), self.onTimeoutSpinBoxChanged) + QtCore.SIGNAL(u'valueChanged(int)'), self.onTimeoutSpinBoxChanged) def retranslateUi(self): self.FontGroupBox.setTitle(translate(u'AlertsTab', u'Font')) @@ -146,13 +146,13 @@ class AlertsTab(SettingsTab): self.TimeoutLabel.setText(translate(u'AlertsTab', u'Alert timeout:')) self.TimeoutSpinBox.setSuffix(translate(u'AlertsTab', u's')) self.PreviewGroupBox.setTitle(translate(u'AlertsTab', u'Preview')) - self.FontPreview.setText(translate(u'AlertsTab', 'openlp.org 2.0 rocks!')) + self.FontPreview.setText(translate(u'AlertsTab', u'openlp.org 2.0 rocks!')) def onBackgroundColorButtonClicked(self): self.bg_color = QtGui.QColorDialog.getColor( - QColor(self.bg_color), self).name() + QtGui.QColor(self.bg_color), self).name() self.BackgroundColorButton.setStyleSheet( - 'background-color: %s' % self.bg_color) + u'background-color: %s' % self.bg_color) self.updateDisplay() def onFontComboBoxClicked(self): @@ -160,22 +160,22 @@ class AlertsTab(SettingsTab): def onFontColorButtonClicked(self): self.font_color = QtGui.QColorDialog.getColor( - QColor(self.font_color), self).name() + QtGui.QColor(self.font_color), self).name() self.FontColorButton.setStyleSheet( - 'background-color: %s' % self.font_color) + u'background-color: %s' % self.font_color) self.updateDisplay() def onTimeoutSpinBoxChanged(self): self.timeout = self.TimeoutSpinBox.value() def load(self): - self.timeout = int(self.config.get_config('timeout', 5)) - self.font_color = str(self.config.get_config('font color', u'#ffffff')) - self.bg_color = str(self.config.get_config('background color', u'#660000')) - self.font_face = str(self.config.get_config('font face', QtGui.QFont().family())) + self.timeout = int(self.config.get_config(u'timeout', 5)) + self.font_color = str(self.config.get_config(u'font color', u'#ffffff')) + self.bg_color = str(self.config.get_config(u'background color', u'#660000')) + self.font_face = str(self.config.get_config(u'font face', QtGui.QFont().family())) self.TimeoutSpinBox.setValue(self.timeout) - self.FontColorButton.setStyleSheet('background-color: %s' % self.font_color) - self.BackgroundColorButton.setStyleSheet('background-color: %s' % self.bg_color) + self.FontColorButton.setStyleSheet(u'background-color: %s' % self.font_color) + self.BackgroundColorButton.setStyleSheet(u'background-color: %s' % self.bg_color) font = QtGui.QFont() font.setFamily(self.font_face) self.FontComboBox.setCurrentFont(font) @@ -183,10 +183,10 @@ class AlertsTab(SettingsTab): def save(self): self.font_face = self.FontComboBox.currentFont().family() - self.config.set_config('background color', str(self.bg_color)) - self.config.set_config('font color', str(self.font_color)) - self.config.set_config('font face', str(self.font_face)) - self.config.set_config('timeout', str(self.timeout)) + self.config.set_config(u'background color', str(self.bg_color)) + self.config.set_config(u'font color', str(self.font_color)) + self.config.set_config(u'font face', str(self.font_face)) + self.config.set_config(u'timeout', str(self.timeout)) def updateDisplay(self): font = QtGui.QFont() @@ -195,4 +195,4 @@ class AlertsTab(SettingsTab): font.setPointSize(16) self.FontPreview.setFont(font) self.FontPreview.setStyleSheet( - 'background-color: %s; color: %s' % (self.bg_color, self.font_color)) + u'background-color: %s; color: %s' % (self.bg_color, self.font_color)) diff --git a/openlp/core/ui/generaltab.py b/openlp/core/ui/generaltab.py index 2a22f67e5..aebcad180 100644 --- a/openlp/core/ui/generaltab.py +++ b/openlp/core/ui/generaltab.py @@ -28,7 +28,7 @@ class GeneralTab(SettingsTab): """ def __init__(self, screen_list): self.screen_list = screen_list - SettingsTab.__init__(self, translate(u'GeneralTab', u'General')) + SettingsTab.__init__(self, translate(u'GeneralTab', u'General'), u'General') def setupUi(self): self.setObjectName(u'GeneralTab') @@ -114,18 +114,17 @@ class GeneralTab(SettingsTab): self.GeneralRightLayout.addItem(self.GeneralRightSpacer) self.GeneralLayout.addWidget(self.GeneralRightWidget) QtCore.QObject.connect(self.MonitorComboBox, - QtCore.SIGNAL("activated(int)"), self.onMonitorComboBoxChanged) + QtCore.SIGNAL(u'activated(int)'), self.onMonitorComboBoxChanged) QtCore.QObject.connect(self.WarningCheckBox, - QtCore.SIGNAL("stateChanged(int)"), self.onWarningCheckBoxChanged) + QtCore.SIGNAL(u'stateChanged(int)'), self.onWarningCheckBoxChanged) QtCore.QObject.connect(self.AutoOpenCheckBox, - QtCore.SIGNAL("stateChanged(int)"), self.onAutoOpenCheckBoxChanged) + QtCore.SIGNAL(u'stateChanged(int)'), self.onAutoOpenCheckBoxChanged) QtCore.QObject.connect(self.NumberEdit, - QtCore.SIGNAL("lostFocus()"), self.onNumberEditLostFocus) + QtCore.SIGNAL(u'lostFocus()'), self.onNumberEditLostFocus) QtCore.QObject.connect(self.UsernameEdit, - QtCore.SIGNAL("lostFocus()"), self.onUsernameEditLostFocus) + QtCore.SIGNAL(u'lostFocus()'), self.onUsernameEditLostFocus) QtCore.QObject.connect(self.PasswordEdit, - QtCore.SIGNAL("lostFocus()"), self.onPasswordEditLostFocus) - + QtCore.SIGNAL(u'lostFocus()'), self.onPasswordEditLostFocus) def retranslateUi(self): self.MonitorGroupBox.setTitle(translate(u'GeneralTab', u'Monitors')) @@ -144,12 +143,14 @@ class GeneralTab(SettingsTab): def onAutoOpenCheckBoxChanged(self, value): self.AutoOpen = False - if value == 2: # we have a set value convert to True/False + if value == 2: + # we have a set value convert to True/False self.AutoOpen = True def onWarningCheckBoxChanged(self, value): self.Warning = False - if value == 2: # we have a set value convert to True/False + if value == 2: + # we have a set value convert to True/False self.Warning = True def onNumberEditLostFocus(self): @@ -164,19 +165,19 @@ class GeneralTab(SettingsTab): def load(self): for screen in self.screen_list: screen_name = translate(u'GeneralTab', u'Screen') + u' ' + \ - str(screen['number'] + 1) - if screen['primary']: + str(screen[u'number'] + 1) + if screen[u'primary']: screen_name = screen_name + u' (' + \ translate(u'GeneralTab', u'primary') + u')' self.MonitorComboBox.addItem(screen_name) - + # Get the configs self.MonitorNumber = int(self.config.get_config(u'Monitor', u'0')) - self.Warning = str_to_bool(self.config.get_config(u'Warning', u"False")) - self.AutoOpen = str_to_bool(self.config.get_config(u'Auto Open', u"False")) - self.CCLNumber = str(self.config.get_config('CCL Number', u'XXX')) - self.Username = str(self.config.get_config('User Name', u'')) - self.Password = str(self.config.get_config('Password', u'')) - + self.Warning = str_to_bool(self.config.get_config(u'Warning', u'False')) + self.AutoOpen = str_to_bool(self.config.get_config(u'Auto Open', u'False')) + self.CCLNumber = str(self.config.get_config(u'CCL Number', u'XXX')) + self.Username = str(self.config.get_config(u'User Name', u'')) + self.Password = str(self.config.get_config(u'Password', u'')) + # Set a few things up self.MonitorComboBox.setCurrentIndex(self.MonitorNumber) self.WarningCheckBox.setChecked(self.Warning) self.AutoOpenCheckBox.setChecked(self.AutoOpen) @@ -185,9 +186,9 @@ class GeneralTab(SettingsTab): self.PasswordEdit.setText(self.Password) def save(self): - self.config.set_config(u'Monitor',str(self.MonitorNumber)) - self.config.set_config(u'Warning', str(self.Warning)) - self.config.set_config(u'Auto Open', str(self.AutoOpen)) - self.config.set_config('CCL Number', str(self.CCLNumber)) - self.config.set_config('User Name',str(self.Username)) - self.config.set_config('Password', str(self.Password )) + self.config.set_config(u'Monitor', self.MonitorNumber) + self.config.set_config(u'Warning', self.Warning) + self.config.set_config(u'Auto Open', self.AutoOpen) + self.config.set_config(u'CCL Number', self.CCLNumber) + self.config.set_config(u'User Name', self.Username) + self.config.set_config(u'Password', self.Password) diff --git a/openlp/core/ui/maindisplay.py b/openlp/core/ui/maindisplay.py index 30ec78454..5eb3a69cd 100644 --- a/openlp/core/ui/maindisplay.py +++ b/openlp/core/ui/maindisplay.py @@ -29,8 +29,13 @@ class MainDisplay(QtGui.QWidget): QtGui.QWidget.__init__(self, parent) self.setWindowTitle(u'OpenLP Display') self.screens = screens + self.layout = QtGui.QVBoxLayout(self) + self.layout.setSpacing(0) + self.layout.setMargin(0) + self.layout.setObjectName(u'layout') self.display = QtGui.QLabel(self) self.display.setScaledContents(True) + self.layout.addWidget(self.display) self.displayBlank = False self.blankFrame= None self.alertactive = False @@ -43,23 +48,21 @@ class MainDisplay(QtGui.QWidget): @param (integer) screen This is the screen number. """ screen = self.screens[screenNumber] - if screen['number'] != screenNumber: + if screen[u'number'] != screenNumber: # We will most probably never actually hit this bit, but just in # case the index in the list doesn't match the screen number, we # search for it. for scrn in self.screens: - if scrn['number'] == screenNumber: + if scrn[u'number'] == screenNumber: screen = scrn break - self.setGeometry(screen['size']) - self.display.setGeometry(screen['size']) - if not screen['primary']: + self.setGeometry(screen[u'size']) + if not screen[u'primary']: self.showFullScreen() else: - self.showMinimized() - - painter=QtGui.QPainter() - self.blankFrame = QtGui.QPixmap(screen['size'].width(), screen['size'].height()) + self.hide() + painter = QtGui.QPainter() + self.blankFrame = QtGui.QPixmap(screen[u'size'].width(), screen[u'size'].height()) painter.begin(self.blankFrame) painter.fillRect(self.blankFrame.rect(), QtGui.QColor(u'#000000')) self.frameView(self.blankFrame) diff --git a/openlp/core/ui/mainwindow.py b/openlp/core/ui/mainwindow.py index d8190310d..4eeda33d0 100644 --- a/openlp/core/ui/mainwindow.py +++ b/openlp/core/ui/mainwindow.py @@ -25,7 +25,7 @@ from PyQt4 import QtCore, QtGui from openlp.core.ui import AboutForm, SettingsForm, AlertForm, ServiceManager, \ ThemeManager, MainDisplay, SlideController from openlp.core.lib import translate, Plugin, MediaManagerItem, SettingsTab, \ - EventManager, RenderManager + EventManager, RenderManager, PluginConfig from openlp.core import PluginManager class MainWindow(object): @@ -46,6 +46,7 @@ class MainWindow(object): self.mainDisplay = MainDisplay(None, screens) self.screenList = screens self.EventManager = EventManager() + self.generalConfig = PluginConfig(u'General') self.alertForm = AlertForm(self) self.aboutForm = AboutForm() self.settingsForm = SettingsForm(self.screenList, self) @@ -60,7 +61,8 @@ class MainWindow(object): #warning cyclic dependency #RenderManager needs to call ThemeManager and #ThemeManager needs to call RenderManager - self.RenderManager = RenderManager(self.ThemeManagerContents, self.screenList) + self.RenderManager = RenderManager(self.ThemeManagerContents, + self.screenList, int(self.generalConfig.get_config(u'Monitor', 0))) log.info(u'Load Plugins') self.plugin_helpers[u'preview'] = self.PreviewController self.plugin_helpers[u'live'] = self.LiveController @@ -91,6 +93,43 @@ class MainWindow(object): log.info(u'Load Themes') self.ThemeManagerContents.loadThemes() + def show(self): + """ + Show the main form, as well as the display form + """ + self.mainWindow.showMaximized() + self.mainDisplay.setup(self.settingsForm.GeneralTab.MonitorNumber) + self.mainDisplay.show() + #self.mainWindow.setFocus(QtCore.Qt.OtherFocusReason) + + def onHelpAboutItemClicked(self): + """ + Show the About form + """ + self.aboutForm.exec_() + + def onToolsAlertItemClicked(self): + """ + Show the Alert form + """ + self.alertForm.exec_() + + def onOptionsSettingsItemClicked(self): + """ + Show the Settings dialog + """ + self.settingsForm.exec_() + screen_number = int(self.generalConfig.get_config(u'Monitor', 0)) + self.RenderManager.update_display(screen_number) + self.mainDisplay.setup(screen_number) + + def onCloseEvent(self, event): + """ + Hook to close the main window and display windows on exit + """ + self.mainDisplay.close() + event.accept() + def setupUi(self): """ Set up the user interface @@ -459,36 +498,3 @@ class MainWindow(object): self.action_Preview_Panel.setText( translate(u'mainWindow', u'&Preview Pane')) self.ModeLiveItem.setText(translate(u'mainWindow', u'&Live')) - - def show(self): - """ - Show the main form, as well as the display form - """ - self.mainWindow.showMaximized() - self.mainDisplay.setup(self.settingsForm.GeneralTab.MonitorNumber) - self.mainDisplay.show() - - def onHelpAboutItemClicked(self): - """ - Show the About form - """ - self.aboutForm.exec_() - - def onToolsAlertItemClicked(self): - """ - Show the Alert form - """ - self.alertForm.exec_() - - def onOptionsSettingsItemClicked(self): - """ - Show the Settings dialog - """ - self.settingsForm.exec_() - - def onCloseEvent(self, event): - """ - Hook to close the main window and display windows on exit - """ - self.mainDisplay.close() - event.accept() diff --git a/openlp/core/ui/themestab.py b/openlp/core/ui/themestab.py index 4b61e9f19..388c6fa72 100644 --- a/openlp/core/ui/themestab.py +++ b/openlp/core/ui/themestab.py @@ -28,7 +28,7 @@ class ThemesTab(SettingsTab): """ def __init__(self, parent): self.parent = parent - SettingsTab.__init__(self, u'Themes') + SettingsTab.__init__(self, translate(u'ThemesTab', u'Themes'), u'Themes') def setupUi(self): self.setObjectName(u'ThemesTab') @@ -90,11 +90,11 @@ class ThemesTab(SettingsTab): self.ThemesTabLayout.addWidget(self.LevelGroupBox) QtCore.QObject.connect(self.SongLevelRadioButton, - QtCore.SIGNAL("pressed()"), self.onSongLevelButtonPressed) + QtCore.SIGNAL(u'pressed()'), self.onSongLevelButtonPressed) QtCore.QObject.connect(self.ServiceLevelRadioButton, - QtCore.SIGNAL("pressed()"), self.onServiceLevelButtonPressed) + QtCore.SIGNAL(u'pressed()'), self.onServiceLevelButtonPressed) QtCore.QObject.connect(self.GlobalLevelRadioButton, - QtCore.SIGNAL("pressed()"), self.onGlobalLevelButtonPressed) + QtCore.SIGNAL(u'pressed()'), self.onGlobalLevelButtonPressed) QtCore.QObject.connect(self.DefaultComboBox, QtCore.SIGNAL("activated(int)"), self.onDefaultComboBoxChanged) diff --git a/openlp/core/utils/registry.py b/openlp/core/utils/registry.py index 71160dc37..23b2ac4c7 100644 --- a/openlp/core/utils/registry.py +++ b/openlp/core/utils/registry.py @@ -28,8 +28,8 @@ class Registry(object): """ def __init__(self, dir): self.config = SafeConfigParser() - self.file_name = os.path.join(dir, 'openlp.conf') - self.config.read(self.file_name) + self.file_name = os.path.join(dir, u'openlp.conf') + self._load() def has_value(self, section, key): """ @@ -95,14 +95,24 @@ class Registry(object): except: return False + def _load(self): + try: + if not os.path.isfile(self.file_name): + return False + file_handle = open(self.file_name, u'r') + self.config.readfp(file_handle) + file_handle.close() + return True + except: + return False + def _save(self): 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, 'w') + file_handle = open(self.file_name, u'w') self.config.write(file_handle) - close(file_handle) - self.config.read(self.file_name) - return True + file_handle.close() + return self._load() except: return False diff --git a/openlp/plugins/bibles/lib/biblestab.py b/openlp/plugins/bibles/lib/biblestab.py index 1f3d1b8a1..f67e52b83 100644 --- a/openlp/plugins/bibles/lib/biblestab.py +++ b/openlp/plugins/bibles/lib/biblestab.py @@ -32,7 +32,7 @@ class BiblesTab(SettingsTab): self.show_new_chapters = False self.display_style = 0 self.bible_search = True - SettingsTab.__init__(self, u'Bibles') + SettingsTab.__init__(self, translate(u'BiblesTab', u'Bibles'), u'Bibles') def setupUi(self): self.setObjectName(u'BiblesTab') @@ -134,32 +134,32 @@ class BiblesTab(SettingsTab): self.BibleLayout.addWidget(self.BibleRightWidget) # Signals and slots QtCore.QObject.connect(self.NewChaptersCheckBox, - QtCore.SIGNAL("stateChanged(int)"), self.onNewChaptersCheckBoxChanged) + QtCore.SIGNAL(u'stateChanged(int)'), self.onNewChaptersCheckBoxChanged) QtCore.QObject.connect(self.BibleSearchCheckBox, - QtCore.SIGNAL("stateChanged(int)"), self.onBibleSearchCheckBoxChanged) + QtCore.SIGNAL(u'stateChanged(int)'), self.onBibleSearchCheckBoxChanged) QtCore.QObject.connect(self.VerseRadioButton, - QtCore.SIGNAL("pressed()"), self.onVerseRadioButtonPressed) + QtCore.SIGNAL(u'pressed()'), self.onVerseRadioButtonPressed) QtCore.QObject.connect(self.ParagraphRadioButton, - QtCore.SIGNAL("pressed()"), self.onParagraphRadioButtonPressed) + QtCore.SIGNAL(u'pressed()'), self.onParagraphRadioButtonPressed) QtCore.QObject.connect(self.DisplayStyleComboBox, - QtCore.SIGNAL("activated(int)"), self.onDisplayStyleComboBoxChanged) + QtCore.SIGNAL(u'activated(int)'), self.onDisplayStyleComboBoxChanged) QtCore.QObject.connect(self.BibleThemeComboBox, - QtCore.SIGNAL("activated(int)"), self.onBibleThemeComboBoxChanged) + QtCore.SIGNAL(u'activated(int)'), self.onBibleThemeComboBoxChanged) def retranslateUi(self): - self.VerseDisplayGroupBox.setTitle(translate('SettingsForm', 'Verse Display')) - self.VerseRadioButton.setText(translate('SettingsForm', 'Verse style')) - self.ParagraphRadioButton.setText(translate('SettingsForm','Paragraph style')) - self.NewChaptersCheckBox.setText(translate('SettingsForm', 'Only show new chapter numbers')) - self.DisplayStyleLabel.setText(translate('SettingsForm', 'Display Style:')) - self.BibleThemeLabel.setText(translate('SettingsForm', 'Bible Theme:')) - self.DisplayStyleComboBox.setItemText(0, translate('SettingsForm', 'No brackets')) - self.DisplayStyleComboBox.setItemText(1, translate('SettingsForm', '( and )')) - self.DisplayStyleComboBox.setItemText(2, translate('SettingsForm', '{ and }')) - self.DisplayStyleComboBox.setItemText(3, translate('SettingsForm', '[ and ]')) - self.ChangeNoteLabel.setText(translate('SettingsForm', 'Note:\nChanges don\'t affect verses already in the service')) - self.BibleSearchGroupBox.setTitle(translate('SettingsForm', 'Search')) - self.BibleSearchCheckBox.setText(translate('SettingsForm', 'Search-as-you-type')) + self.VerseDisplayGroupBox.setTitle(translate(u'SettingsForm', u'Verse Display')) + self.VerseRadioButton.setText(translate(u'SettingsForm', u'Verse style')) + self.ParagraphRadioButton.setText(translate(u'SettingsForm', u'Paragraph style')) + self.NewChaptersCheckBox.setText(translate(u'SettingsForm', u'Only show new chapter numbers')) + self.DisplayStyleLabel.setText(translate(u'SettingsForm', u'Display Style:')) + self.BibleThemeLabel.setText(translate(u'SettingsForm', u'Bible Theme:')) + self.DisplayStyleComboBox.setItemText(0, translate(u'SettingsForm', u'No brackets')) + self.DisplayStyleComboBox.setItemText(1, translate(u'SettingsForm', u'( and )')) + self.DisplayStyleComboBox.setItemText(2, translate(u'SettingsForm', u'{ and }')) + self.DisplayStyleComboBox.setItemText(3, translate(u'SettingsForm', u'[ and ]')) + self.ChangeNoteLabel.setText(translate(u'SettingsForm', u'Note:\nChanges don\'t affect verses already in the service')) + self.BibleSearchGroupBox.setTitle(translate(u'SettingsForm', u'Search')) + self.BibleSearchCheckBox.setText(translate(u'SettingsForm', u'Search-as-you-type')) def onBibleThemeComboBoxChanged(self): self.bible_theme = self.BibleThemeComboBox.currentText() @@ -187,7 +187,7 @@ class BiblesTab(SettingsTab): def load(self): self.paragraph_style = str_to_bool(self.config.get_config(u'paragraph style', u'True')) - self.show_new_chapters = str_to_bool(self.config.get_config(u'display new chapter', u"False")) + self.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.bible_theme = self.config.get_config(u'bible theme', u'0') self.bible_search = str_to_bool(self.config.get_config(u'search as type', u'True')) @@ -216,6 +216,7 @@ class BiblesTab(SettingsTab): self.BibleThemeComboBox.addItem(theme) id = self.BibleThemeComboBox.findText(str(self.bible_theme), QtCore.Qt.MatchExactly) if id == -1: - id = 0 # Not Found + # Not Found + id = 0 self.bible_theme = u'' self.BibleThemeComboBox.setCurrentIndex(id) diff --git a/openlp/plugins/custom/lib/customtab.py b/openlp/plugins/custom/lib/customtab.py index 77161ae07..2140cd1e2 100644 --- a/openlp/plugins/custom/lib/customtab.py +++ b/openlp/plugins/custom/lib/customtab.py @@ -27,7 +27,7 @@ class CustomTab(SettingsTab): SongsTab is the songs settings tab in the settings dialog. """ def __init__(self): - SettingsTab.__init__(self, u'Custom') + SettingsTab.__init__(self, translate(u'CustomTab', u'Custom'), u'Custom') def setupUi(self): self.setObjectName(u'CustomTab') diff --git a/openlp/plugins/media/lib/mediatab.py b/openlp/plugins/media/lib/mediatab.py index f557fde47..2f93bac96 100644 --- a/openlp/plugins/media/lib/mediatab.py +++ b/openlp/plugins/media/lib/mediatab.py @@ -27,40 +27,38 @@ class MediaTab(SettingsTab): mediaTab is the media settings tab in the settings dialog. """ def __init__(self): - SettingsTab.__init__(self, u'Media') + SettingsTab.__init__(self, translate(u'MediaTab', u'Media'), u'Media') def setupUi(self): self.setObjectName(u'MediaTab') - self.MediaLayout = QtGui.QFormLayout(self) - self.MediaLayout.setObjectName("MediaLayout") - + self.MediaLayout.setObjectName(u'MediaLayout') self.MediaModeGroupBox = QtGui.QGroupBox(self) - self.MediaModeGroupBox.setObjectName("MediaModeGroupBox") + self.MediaModeGroupBox.setObjectName(u'MediaModeGroupBox') self.MediaModeLayout = QtGui.QVBoxLayout(self.MediaModeGroupBox) self.MediaModeLayout.setSpacing(8) self.MediaModeLayout.setMargin(8) - self.MediaModeLayout.setObjectName("MediaModeLayout") + self.MediaModeLayout.setObjectName(u'MediaModeLayout') self.UseVMRCheckBox = QtGui.QCheckBox(self.MediaModeGroupBox) - self.UseVMRCheckBox.setObjectName("UseVMRCheckBox") + self.UseVMRCheckBox.setObjectName(u'UseVMRCheckBox') self.MediaModeLayout.addWidget(self.UseVMRCheckBox) self.UseVMRLabel = QtGui.QLabel(self.MediaModeGroupBox) - self.UseVMRLabel.setObjectName("UseVMRLabel") + self.UseVMRLabel.setObjectName(u'UseVMRLabel') self.MediaModeLayout.addWidget(self.UseVMRLabel) self.MediaLayout.setWidget(0, QtGui.QFormLayout.LabelRole, self.MediaModeGroupBox) # Signals and slots QtCore.QObject.connect(self.UseVMRCheckBox, - QtCore.SIGNAL("stateChanged(int)"), self.onVMRCheckBoxChanged) + QtCore.SIGNAL(u'stateChanged(int)'), self.onVMRCheckBoxChanged) def retranslateUi(self): - self.MediaModeGroupBox.setTitle(translate("SettingsForm", "Media Mode")) - self.UseVMRCheckBox.setText(translate("SettingsForm", "Use Video Mode Rendering")) - self.UseVMRLabel.setText(translate("SettingsForm", "\n" -"\n" -"

No video preview available with VMR enabled

")) + self.MediaModeGroupBox.setTitle(translate(u'MediaTab', u'Media Mode')) + self.UseVMRCheckBox.setText(translate(u'MediaTab', u'Use Video Mode Rendering')) + self.UseVMRLabel.setText(translate(u'MediaTab', u'\n' + u'\n' + u'

No video preview available with VMR enabled

')) def onVMRCheckBoxChanged(self): use_vmr_mode = self.UseVMRCheckBox.checkState() diff --git a/openlp/plugins/presentations/lib/presentationtab.py b/openlp/plugins/presentations/lib/presentationtab.py index 192f4a4a7..1a8871ca1 100644 --- a/openlp/plugins/presentations/lib/presentationtab.py +++ b/openlp/plugins/presentations/lib/presentationtab.py @@ -24,23 +24,23 @@ from openlp.core.lib import SettingsTab, translate class PresentationTab(SettingsTab): """ - BiblesTab is the Bibles settings tab in the settings dialog. + PresentationsTab is the Presentations settings tab in the settings dialog. """ def __init__(self): - SettingsTab.__init__(self, u'Presentation') + SettingsTab.__init__(self, translate(u'PresentationTab', u'Presentation'), u'Presentation') def setupUi(self): - self.setObjectName(u'BiblesTab') - self.BibleLayout = QtGui.QHBoxLayout(self) - self.BibleLayout.setSpacing(8) - self.BibleLayout.setMargin(8) - self.BibleLayout.setObjectName(u'BibleLayout') - self.BibleLeftWidget = QtGui.QWidget(self) - self.BibleLeftWidget.setObjectName(u'BibleLeftWidget') - self.BibleLeftLayout = QtGui.QVBoxLayout(self.BibleLeftWidget) - self.BibleLeftLayout.setObjectName(u'BibleLeftLayout') - self.BibleLeftLayout.setSpacing(8) - self.BibleLeftLayout.setMargin(0) + self.setObjectName(u'PresentationTab') + self.PresentationLayout = QtGui.QHBoxLayout(self) + self.PresentationLayout.setSpacing(8) + self.PresentationLayout.setMargin(8) + self.PresentationLayout.setObjectName(u'PresentationLayout') + self.PresentationLeftWidget = QtGui.QWidget(self) + self.PresentationLeftWidget.setObjectName(u'PresentationLeftWidget') + self.PresentationLeftLayout = QtGui.QVBoxLayout(self.PresentationLeftWidget) + self.PresentationLeftLayout.setObjectName(u'PresentationLeftLayout') + self.PresentationLeftLayout.setSpacing(8) + self.PresentationLeftLayout.setMargin(0) self.VerseDisplayGroupBox = QtGui.QGroupBox(self) self.VerseDisplayGroupBox.setObjectName(u'VerseDisplayGroupBox') @@ -70,29 +70,29 @@ class PresentationTab(SettingsTab): self.ImpressPath.setObjectName("ImpressPath") self.VerseDisplayLayout.addWidget(self.ImpressPath, 3, 0, 1, 1) - self.BibleThemeWidget = QtGui.QWidget(self.VerseDisplayGroupBox) - self.BibleThemeWidget.setObjectName(u'BibleThemeWidget') - self.BibleThemeLayout = QtGui.QHBoxLayout(self.BibleThemeWidget) - self.BibleThemeLayout.setSpacing(8) - self.BibleThemeLayout.setMargin(0) - self.BibleThemeLayout.setObjectName(u'BibleThemeLayout') + self.PresentationThemeWidget = QtGui.QWidget(self.VerseDisplayGroupBox) + self.PresentationThemeWidget.setObjectName(u'PresentationThemeWidget') + self.PresentationThemeLayout = QtGui.QHBoxLayout(self.PresentationThemeWidget) + self.PresentationThemeLayout.setSpacing(8) + self.PresentationThemeLayout.setMargin(0) + self.PresentationThemeLayout.setObjectName(u'PresentationThemeLayout') - self.BibleLeftLayout.addWidget(self.VerseDisplayGroupBox) - self.BibleLeftSpacer = QtGui.QSpacerItem(40, 20, + self.PresentationLeftLayout.addWidget(self.VerseDisplayGroupBox) + self.PresentationLeftSpacer = QtGui.QSpacerItem(40, 20, QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Expanding) - self.BibleLeftLayout.addItem(self.BibleLeftSpacer) - self.BibleLayout.addWidget(self.BibleLeftWidget) + self.PresentationLeftLayout.addItem(self.PresentationLeftSpacer) + self.PresentationLayout.addWidget(self.PresentationLeftWidget) - self.BibleRightWidget = QtGui.QWidget(self) - self.BibleRightWidget.setObjectName(u'BibleRightWidget') - self.BibleRightLayout = QtGui.QVBoxLayout(self.BibleRightWidget) - self.BibleRightLayout.setObjectName(u'BibleRightLayout') - self.BibleRightLayout.setSpacing(8) - self.BibleRightLayout.setMargin(0) - self.BibleRightSpacer = QtGui.QSpacerItem(50, 20, + self.PresentationRightWidget = QtGui.QWidget(self) + self.PresentationRightWidget.setObjectName(u'PresentationRightWidget') + self.PresentationRightLayout = QtGui.QVBoxLayout(self.PresentationRightWidget) + self.PresentationRightLayout.setObjectName(u'PresentationRightLayout') + self.PresentationRightLayout.setSpacing(8) + self.PresentationRightLayout.setMargin(0) + self.PresentationRightSpacer = QtGui.QSpacerItem(50, 20, QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Expanding) - self.BibleRightLayout.addItem(self.BibleRightSpacer) - self.BibleLayout.addWidget(self.BibleRightWidget) + self.PresentationRightLayout.addItem(self.PresentationRightSpacer) + self.PresentationLayout.addWidget(self.PresentationRightWidget) # Signals and slots #QtCore.QObject.connect(self.NewChaptersCheckBox, @@ -116,20 +116,20 @@ class PresentationTab(SettingsTab): # self.paragraph_style = (self.config.get_config(u'paragraph style', u'True')) # self.show_new_chapters = (self.config.get_config(u'display new chapter', u"False")) # self.display_style = int(self.config.get_config(u'display brackets', u'0')) -# self.bible_theme = int(self.config.get_config(u'bible theme', u'0')) -# self.bible_search = (self.config.get_config(u'search as type', u'True')) +# self.Presentation_theme = int(self.config.get_config(u'Presentation theme', u'0')) +# self.Presentation_search = (self.config.get_config(u'search as type', u'True')) # if self.paragraph_style: # self.ParagraphRadioButton.setChecked(True) # else: # self.VerseRadioButton.setChecked(True) # self.NewChaptersCheckBox.setChecked(self.show_new_chapters) # self.DisplayStyleComboBox.setCurrentIndex(self.display_style) -# self.BibleSearchCheckBox.setChecked(self.bible_search) +# self.PresentationSearchCheckBox.setChecked(self.Presentation_search) def save(self): pass # self.config.set_config(u'paragraph style', str(self.paragraph_style)) # self.config.set_config(u'display new chapter', str(self.show_new_chapters)) # self.config.set_config(u'display brackets', str(self.display_style)) -# self.config.set_config(u'search as type', str(self.bible_search)) -# self.config.set_config(u'bible theme', str(self.bible_theme)) +# self.config.set_config(u'search as type', str(self.Presentation_search)) +# self.config.set_config(u'Presentation theme', str(self.Presentation_theme)) diff --git a/openlp/plugins/songs/lib/songstab.py b/openlp/plugins/songs/lib/songstab.py index e270b97bc..52518b7ac 100644 --- a/openlp/plugins/songs/lib/songstab.py +++ b/openlp/plugins/songs/lib/songstab.py @@ -20,14 +20,14 @@ Place, Suite 330, Boston, MA 02111-1307 USA from PyQt4 import QtCore, QtGui -from openlp.core.lib import SettingsTab, translate +from openlp.core.lib import SettingsTab, translate class SongsTab(SettingsTab): """ SongsTab is the songs settings tab in the settings dialog. """ def __init__(self): - SettingsTab.__init__(self, u'Songs') + SettingsTab.__init__(self, translate(u'SongsTab', u'Songs'), u'Songs') def setupUi(self): self.setObjectName(u'SongsTab')