From 1f5ac7f48312295c15a9b6a6937bd92c9cdd96f3 Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Wed, 13 Jun 2012 17:44:33 +0200 Subject: [PATCH 1/3] fixed ticket 729 and fixed variables to camelCase --- openlp/core/ui/maindisplay.py | 55 ++++++++++++++++++----------------- 1 file changed, 28 insertions(+), 27 deletions(-) diff --git a/openlp/core/ui/maindisplay.py b/openlp/core/ui/maindisplay.py index eb6b6c925..b27a16727 100644 --- a/openlp/core/ui/maindisplay.py +++ b/openlp/core/ui/maindisplay.py @@ -130,6 +130,7 @@ class MainDisplay(Display): else: self.audioPlayer = None self.firstTime = True + self.webLoaded = True self.setStyleSheet(u'border: 0px; margin: 0px; padding: 0px;') windowFlags = QtCore.Qt.FramelessWindowHint | QtCore.Qt.Tool | \ QtCore.Qt.WindowStaysOnTopHint @@ -194,27 +195,27 @@ class MainDisplay(Display): Display.setup(self) if self.isLive: # Build the initial frame. - image_file = Settings().value(u'advanced/default image', - QtCore.QVariant(u':/graphics/openlp-splash-screen.png'))\ - .toString() - background_color = QtGui.QColor() - background_color.setNamedColor(Settings().value( + backgroundColor = QtGui.QColor() + backgroundColor.setNamedColor(Settings().value( u'advanced/default color', QtCore.QVariant(u'#ffffff')).toString()) - if not background_color.isValid(): - background_color = QtCore.Qt.white - splash_image = QtGui.QImage(image_file) + if not backgroundColor.isValid(): + backgroundColor = QtCore.Qt.white + imageFile = Settings().value(u'advanced/default image', + QtCore.QVariant(u':/graphics/openlp-splash-screen.png'))\ + .toString() + splashImage = QtGui.QImage(imageFile) self.initialFrame = QtGui.QImage( self.screen[u'size'].width(), self.screen[u'size'].height(), QtGui.QImage.Format_ARGB32_Premultiplied) - painter_image = QtGui.QPainter() - painter_image.begin(self.initialFrame) - painter_image.fillRect(self.initialFrame.rect(), background_color) - painter_image.drawImage( - (self.screen[u'size'].width() - splash_image.width()) / 2, - (self.screen[u'size'].height() - splash_image.height()) / 2, - splash_image) + painterImage = QtGui.QPainter() + painterImage.begin(self.initialFrame) + painterImage.fillRect(self.initialFrame.rect(), backgroundColor) + painterImage.drawImage( + (self.screen[u'size'].width() - splashImage.width()) / 2, + (self.screen[u'size'].height() - splashImage.height()) / 2, + splashImage) serviceItem = ServiceItem() serviceItem.bg_image_bytes = image_to_byte(self.initialFrame) self.webView.setHtml(build_html(serviceItem, self.screen, @@ -247,27 +248,27 @@ class MainDisplay(Display): log.debug(u'alert to display') # First we convert <>& marks to html variants, then apply # formattingtags, finally we double all backslashes for JavaScript. - text_prepared = expand_tags( + textPrepared = expand_tags( cgi.escape(text)).replace(u'\\', u'\\\\').replace(u'\"', u'\\\"') if self.height() != self.screen[u'size'].height() or not \ self.isVisible(): shrink = True - js = u'show_alert("%s", "%s")' % (text_prepared, u'top') + js = u'show_alert("%s", "%s")' % (textPrepared, u'top') else: shrink = False - js = u'show_alert("%s", "")' % text_prepared + js = u'show_alert("%s", "")' % textPrepared height = self.frame.evaluateJavaScript(js) if shrink: if text: - alert_height = int(height.toString()) - self.resize(self.width(), alert_height) + alertHeight = int(height.toString()) + self.resize(self.width(), alertHeight) self.setVisible(True) if location == AlertLocation.Middle: self.move(self.screen[u'size'].left(), - (self.screen[u'size'].height() - alert_height) / 2) + (self.screen[u'size'].height() - alertHeight) / 2) elif location == AlertLocation.Bottom: self.move(self.screen[u'size'].left(), - self.screen[u'size'].height() - alert_height) + self.screen[u'size'].height() - alertHeight) else: self.setVisible(False) self.setGeometry(self.screen[u'size']) @@ -360,8 +361,8 @@ class MainDisplay(Display): def buildHtml(self, serviceItem, image=None): """ - Store the serviceItem and build the new HTML from it. Add the - HTML to the display + Store the serviceItem and build the new HTML from it. Add the HTML to + the display. """ log.debug(u'buildHtml') self.webLoaded = False @@ -388,11 +389,11 @@ class MainDisplay(Display): self.serviceItem.bg_image_bytes = self.imageManager. \ getImageBytes(self.serviceItem.themedata.theme_name) if image: - image_bytes = self.imageManager.getImageBytes(image) + imageBytes = self.imageManager.getImageBytes(image) else: - image_bytes = None + imageBytes = None html = build_html(self.serviceItem, self.screen, self.isLive, - background, image_bytes, self.plugins) + background, imageBytes, self.plugins) log.debug(u'buildHtml - pre setHtml') self.webView.setHtml(html) log.debug(u'buildHtml - post setHtml') From 21fc0f9533f87f0f8934e40fa73595b4edab9f6e Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Wed, 13 Jun 2012 17:53:54 +0200 Subject: [PATCH 2/3] fixed docstring --- openlp/core/ui/maindisplay.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openlp/core/ui/maindisplay.py b/openlp/core/ui/maindisplay.py index b27a16727..ef0cdc1a5 100644 --- a/openlp/core/ui/maindisplay.py +++ b/openlp/core/ui/maindisplay.py @@ -293,7 +293,7 @@ class MainDisplay(Display): Add an image as the background. The image has already been added to the cache. - ``Image`` + ``name`` The name of the image to be displayed. """ log.debug(u'image to display') From 6a23b75b8c01dbccde3a0300e6d57087e0dc8179 Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Thu, 14 Jun 2012 17:46:47 +0200 Subject: [PATCH 3/3] reverted changes --- openlp/core/ui/maindisplay.py | 56 +++++++++++++++++------------------ 1 file changed, 28 insertions(+), 28 deletions(-) diff --git a/openlp/core/ui/maindisplay.py b/openlp/core/ui/maindisplay.py index ef0cdc1a5..0a56946c1 100644 --- a/openlp/core/ui/maindisplay.py +++ b/openlp/core/ui/maindisplay.py @@ -133,7 +133,7 @@ class MainDisplay(Display): self.webLoaded = True self.setStyleSheet(u'border: 0px; margin: 0px; padding: 0px;') windowFlags = QtCore.Qt.FramelessWindowHint | QtCore.Qt.Tool | \ - QtCore.Qt.WindowStaysOnTopHint + QtCore.Qt.WindowStaysOnTopHint if Settings().value(u'advanced/x11 bypass wm', QtCore.QVariant(True)).toBool(): windowFlags |= QtCore.Qt.X11BypassWindowManagerHint @@ -195,27 +195,27 @@ class MainDisplay(Display): Display.setup(self) if self.isLive: # Build the initial frame. - backgroundColor = QtGui.QColor() - backgroundColor.setNamedColor(Settings().value( + background_color = QtGui.QColor() + background_color.setNamedColor(Settings().value( u'advanced/default color', QtCore.QVariant(u'#ffffff')).toString()) - if not backgroundColor.isValid(): - backgroundColor = QtCore.Qt.white - imageFile = Settings().value(u'advanced/default image', + if not background_color.isValid(): + background_color = QtCore.Qt.white + image_file = Settings().value(u'advanced/default image', QtCore.QVariant(u':/graphics/openlp-splash-screen.png'))\ .toString() - splashImage = QtGui.QImage(imageFile) + splash_image = QtGui.QImage(image_file) self.initialFrame = QtGui.QImage( self.screen[u'size'].width(), self.screen[u'size'].height(), QtGui.QImage.Format_ARGB32_Premultiplied) - painterImage = QtGui.QPainter() - painterImage.begin(self.initialFrame) - painterImage.fillRect(self.initialFrame.rect(), backgroundColor) - painterImage.drawImage( - (self.screen[u'size'].width() - splashImage.width()) / 2, - (self.screen[u'size'].height() - splashImage.height()) / 2, - splashImage) + painter_image = QtGui.QPainter() + painter_image.begin(self.initialFrame) + painter_image.fillRect(self.initialFrame.rect(), background_color) + painter_image.drawImage( + (self.screen[u'size'].width() - splash_image.width()) / 2, + (self.screen[u'size'].height() - splash_image.height()) / 2, + splash_image) serviceItem = ServiceItem() serviceItem.bg_image_bytes = image_to_byte(self.initialFrame) self.webView.setHtml(build_html(serviceItem, self.screen, @@ -248,27 +248,27 @@ class MainDisplay(Display): log.debug(u'alert to display') # First we convert <>& marks to html variants, then apply # formattingtags, finally we double all backslashes for JavaScript. - textPrepared = expand_tags( + text_prepared = expand_tags( cgi.escape(text)).replace(u'\\', u'\\\\').replace(u'\"', u'\\\"') if self.height() != self.screen[u'size'].height() or not \ self.isVisible(): shrink = True - js = u'show_alert("%s", "%s")' % (textPrepared, u'top') + js = u'show_alert("%s", "%s")' % (text_prepared, u'top') else: shrink = False - js = u'show_alert("%s", "")' % textPrepared + js = u'show_alert("%s", "")' % text_prepared height = self.frame.evaluateJavaScript(js) if shrink: if text: - alertHeight = int(height.toString()) - self.resize(self.width(), alertHeight) + alert_height = int(height.toString()) + self.resize(self.width(), alert_height) self.setVisible(True) if location == AlertLocation.Middle: self.move(self.screen[u'size'].left(), - (self.screen[u'size'].height() - alertHeight) / 2) + (self.screen[u'size'].height() - alert_height) / 2) elif location == AlertLocation.Bottom: self.move(self.screen[u'size'].left(), - self.screen[u'size'].height() - alertHeight) + self.screen[u'size'].height() - alert_height) else: self.setVisible(False) self.setGeometry(self.screen[u'size']) @@ -290,8 +290,8 @@ class MainDisplay(Display): def image(self, name): """ - Add an image as the background. The image has already been added - to the cache. + Add an image as the background. The image has already been added to the + cache. ``name`` The name of the image to be displayed. @@ -361,8 +361,8 @@ class MainDisplay(Display): def buildHtml(self, serviceItem, image=None): """ - Store the serviceItem and build the new HTML from it. Add the HTML to - the display. + Store the serviceItem and build the new HTML from it. Add the + HTML to the display """ log.debug(u'buildHtml') self.webLoaded = False @@ -389,11 +389,11 @@ class MainDisplay(Display): self.serviceItem.bg_image_bytes = self.imageManager. \ getImageBytes(self.serviceItem.themedata.theme_name) if image: - imageBytes = self.imageManager.getImageBytes(image) + image_bytes = self.imageManager.getImageBytes(image) else: - imageBytes = None + image_bytes = None html = build_html(self.serviceItem, self.screen, self.isLive, - background, imageBytes, self.plugins) + background, image_bytes, self.plugins) log.debug(u'buildHtml - pre setHtml') self.webView.setHtml(html) log.debug(u'buildHtml - post setHtml')