From 82728e148e19dfaaed52e3660c3888f2c5fee6e0 Mon Sep 17 00:00:00 2001 From: Martin Zibricky Date: Thu, 22 Dec 2011 15:46:47 +0100 Subject: [PATCH 1/9] #906926 fix stay on top for OS X --- openlp/core/ui/maindisplay.py | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/openlp/core/ui/maindisplay.py b/openlp/core/ui/maindisplay.py index 328970d45..e99e98f1d 100644 --- a/openlp/core/ui/maindisplay.py +++ b/openlp/core/ui/maindisplay.py @@ -29,6 +29,7 @@ The :mod:`maindisplay` module provides the functionality to display screens and play multimedia within OpenLP. """ import logging +import platform from PyQt4 import QtCore, QtGui, QtWebKit, QtOpenGL from PyQt4.phonon import Phonon @@ -60,7 +61,12 @@ class Display(QtGui.QGraphicsView): self.controller = controller self.screen = {} self.plugins = PluginManager.get_instance().plugins - self.setViewport(QtOpenGL.QGLWidget()) + # FIXME: On Mac OS X (tested on 10.7) the display screen is corrupt with + # OpenGL. Only white blank screen is shown on the 2nd monitor all the + # time. We need to investigate more how to use OpenGL properly on Mac OS + # X. + if platform.system() != 'Darwin': + self.setViewport(QtOpenGL.QGLWidget()) def setup(self): """ @@ -120,9 +126,15 @@ class MainDisplay(Display): self.audioPlayer = None self.firstTime = True self.setStyleSheet(u'border: 0px; margin: 0px; padding: 0px;') - self.setWindowFlags(QtCore.Qt.FramelessWindowHint | QtCore.Qt.Tool | - QtCore.Qt.WindowStaysOnTopHint | - QtCore.Qt.X11BypassWindowManagerHint) + windowFlags = QtCore.Qt.FramelessWindowHint | QtCore.Qt.Tool | \ + QtCore.Qt.WindowStaysOnTopHint | \ + QtCore.Qt.X11BypassWindowManagerHint + # FIXME: QtCore.Qt.SplashScreen is workaround to make display screen + # stay always on top on Mac OS X. For details see bug 906926. + # It needs more investigation to fix it properly. + if platform.system() == 'Darwin': + windowFlags = windowFlags | QtCore.Qt.SplashScreen + self.setWindowFlags(windowFlags) self.setAttribute(QtCore.Qt.WA_DeleteOnClose) if self.isLive: QtCore.QObject.connect(Receiver.get_receiver(), From 6828fc9ef5af073615e3ecc68355ad36d24c70da Mon Sep 17 00:00:00 2001 From: Martin Zibricky Date: Thu, 22 Dec 2011 19:17:35 +0100 Subject: [PATCH 2/9] fixed bug 907857: opengl rendering disabled for mac --- openlp/core/ui/maindisplay.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/openlp/core/ui/maindisplay.py b/openlp/core/ui/maindisplay.py index 03b5da7e6..c8d061e17 100644 --- a/openlp/core/ui/maindisplay.py +++ b/openlp/core/ui/maindisplay.py @@ -30,6 +30,7 @@ and play multimedia within OpenLP. """ import logging import os +import sys from PyQt4 import QtCore, QtGui, QtWebKit, QtOpenGL from PyQt4.phonon import Phonon @@ -61,7 +62,12 @@ class Display(QtGui.QGraphicsView): self.controller = controller self.screen = {} self.plugins = PluginManager.get_instance().plugins - self.setViewport(QtOpenGL.QGLWidget()) + # FIXME: On Mac OS X (tested on 10.7) the display screen is corrupt with + # OpenGL. Only white blank screen is shown on the 2nd monitor all the + # time. We need to investigate more how to use OpenGL properly on Mac OS + # X. + if sys.platform != 'darwin': + self.setViewport(QtOpenGL.QGLWidget()) def setup(self): """ From 4071bc8deb18fe7fe233cca9138d5b30e37c7727 Mon Sep 17 00:00:00 2001 From: Martin Zibricky Date: Thu, 22 Dec 2011 19:21:22 +0100 Subject: [PATCH 3/9] remove disabling opengl - done in new branch --- openlp/core/ui/maindisplay.py | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/openlp/core/ui/maindisplay.py b/openlp/core/ui/maindisplay.py index e99e98f1d..4e314d747 100644 --- a/openlp/core/ui/maindisplay.py +++ b/openlp/core/ui/maindisplay.py @@ -61,12 +61,7 @@ class Display(QtGui.QGraphicsView): self.controller = controller self.screen = {} self.plugins = PluginManager.get_instance().plugins - # FIXME: On Mac OS X (tested on 10.7) the display screen is corrupt with - # OpenGL. Only white blank screen is shown on the 2nd monitor all the - # time. We need to investigate more how to use OpenGL properly on Mac OS - # X. - if platform.system() != 'Darwin': - self.setViewport(QtOpenGL.QGLWidget()) + self.setViewport(QtOpenGL.QGLWidget()) def setup(self): """ From 2508e71a4485c482b9866c0e68956f111a9517b1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mattias=20P=C3=B5ldaru?= Date: Fri, 23 Dec 2011 15:15:19 +0200 Subject: [PATCH 4/9] Supposedly fix for #354 in support.openlp.org, a traceback when JSON response from remote cannot be decoded. --- openlp/plugins/remotes/lib/httpserver.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/openlp/plugins/remotes/lib/httpserver.py b/openlp/plugins/remotes/lib/httpserver.py index 0da445ede..345550f30 100644 --- a/openlp/plugins/remotes/lib/httpserver.py +++ b/openlp/plugins/remotes/lib/httpserver.py @@ -332,7 +332,12 @@ class HttpConnection(object): args = [] for param in match.groups(): args.append(param) - response = func(*args) + try: + response = func(*args) + except ValueError as error: + log.exception(u'Error while decoding JSON message ' + 'from remote browser.') + return False break if response: self.send_response(response) From 706fa7ff497ea674797b566b00d617109b7e91cb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mattias=20P=C3=B5ldaru?= Date: Fri, 23 Dec 2011 16:54:08 +0200 Subject: [PATCH 5/9] Revert previous change. --- openlp/plugins/remotes/lib/httpserver.py | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/openlp/plugins/remotes/lib/httpserver.py b/openlp/plugins/remotes/lib/httpserver.py index 345550f30..0da445ede 100644 --- a/openlp/plugins/remotes/lib/httpserver.py +++ b/openlp/plugins/remotes/lib/httpserver.py @@ -332,12 +332,7 @@ class HttpConnection(object): args = [] for param in match.groups(): args.append(param) - try: - response = func(*args) - except ValueError as error: - log.exception(u'Error while decoding JSON message ' - 'from remote browser.') - return False + response = func(*args) break if response: self.send_response(response) From 7f6edda46321c8160bd051f128735fa5d6aacdf6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mattias=20P=C3=B5ldaru?= Date: Fri, 23 Dec 2011 16:54:53 +0200 Subject: [PATCH 6/9] Add a missing pair of quotes to fix #354. --- openlp/plugins/remotes/html/openlp.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openlp/plugins/remotes/html/openlp.js b/openlp/plugins/remotes/html/openlp.js index 0972a6637..684c77467 100644 --- a/openlp/plugins/remotes/html/openlp.js +++ b/openlp/plugins/remotes/html/openlp.js @@ -208,7 +208,7 @@ window.OpenLP = { }, showAlert: function (event) { event.preventDefault(); - var text = "{\"request\": {\"text\": " + $("#alert-text").val() + "}}"; + var text = "{\"request\": {\"text\": \"" + $("#alert-text").val() + "\"}}"; $.getJSON( "/api/alert", {"data": text}, From e94ab832eb58b07ab9e99a75ef5e24b25bba5344 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mattias=20P=C3=B5ldaru?= Date: Fri, 23 Dec 2011 17:23:32 +0200 Subject: [PATCH 7/9] Escape \ and " characters first, to prevent traceback when sending such an alert from remote. --- openlp/plugins/remotes/html/openlp.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/openlp/plugins/remotes/html/openlp.js b/openlp/plugins/remotes/html/openlp.js index 684c77467..8e4f1cbfc 100644 --- a/openlp/plugins/remotes/html/openlp.js +++ b/openlp/plugins/remotes/html/openlp.js @@ -208,7 +208,9 @@ window.OpenLP = { }, showAlert: function (event) { event.preventDefault(); - var text = "{\"request\": {\"text\": \"" + $("#alert-text").val() + "\"}}"; + var text = "{\"request\": {\"text\": \"" + + $("#alert-text").val().replace("\\", "\\\\").replace("\"", "\\\"") + + "\"}}"; $.getJSON( "/api/alert", {"data": text}, @@ -219,7 +221,9 @@ window.OpenLP = { }, search: function (event) { event.preventDefault(); - var text = "{\"request\": {\"text\": \"" + $("#search-text").val() + "\"}}"; + var text = "{\"request\": {\"text\": \"" + + $("#search-text").val().replace("\\", "\\\\").replace("\"", "\\\"") + + "\"}}"; $.getJSON( "/api/" + $("#search-plugin").val() + "/search", {"data": text}, From 514773abe85bbc7dfcb7fc71906344ee1fdff072 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mattias=20P=C3=B5ldaru?= Date: Fri, 23 Dec 2011 17:47:36 +0200 Subject: [PATCH 8/9] Make replace work for two or more occurrences. --- openlp/plugins/remotes/html/openlp.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openlp/plugins/remotes/html/openlp.js b/openlp/plugins/remotes/html/openlp.js index 8e4f1cbfc..5c991a018 100644 --- a/openlp/plugins/remotes/html/openlp.js +++ b/openlp/plugins/remotes/html/openlp.js @@ -209,7 +209,7 @@ window.OpenLP = { showAlert: function (event) { event.preventDefault(); var text = "{\"request\": {\"text\": \"" + - $("#alert-text").val().replace("\\", "\\\\").replace("\"", "\\\"") + + $("#alert-text").val().replace(/\\/g, "\\\\").replace(/"/g, "\\\"") + "\"}}"; $.getJSON( "/api/alert", From 173915f956fcb488310df866832ecb0a424ac5fb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mattias=20P=C3=B5ldaru?= Date: Fri, 23 Dec 2011 18:03:37 +0200 Subject: [PATCH 9/9] Made search function's replace greedy as well. Thanks to gushie the world is better place now :). --- openlp/plugins/remotes/html/openlp.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openlp/plugins/remotes/html/openlp.js b/openlp/plugins/remotes/html/openlp.js index 5c991a018..56c0c5859 100644 --- a/openlp/plugins/remotes/html/openlp.js +++ b/openlp/plugins/remotes/html/openlp.js @@ -222,7 +222,7 @@ window.OpenLP = { search: function (event) { event.preventDefault(); var text = "{\"request\": {\"text\": \"" + - $("#search-text").val().replace("\\", "\\\\").replace("\"", "\\\"") + + $("#search-text").val().replace(/\\/g, "\\\\").replace(/"/g, "\\\"") + "\"}}"; $.getJSON( "/api/" + $("#search-plugin").val() + "/search",