diff --git a/openlp/core/lib/formattingtags.py b/openlp/core/lib/formattingtags.py index b2d8f6ea7..1984b08ba 100644 --- a/openlp/core/lib/formattingtags.py +++ b/openlp/core/lib/formattingtags.py @@ -29,7 +29,7 @@ """ Provide HTML Tag management and Formatting Tag access class """ -import cPickle +import json from openlp.core.lib import Settings, translate @@ -66,7 +66,7 @@ class FormattingTags(object): if isinstance(tag[element], unicode): tag[element] = tag[element].encode('utf8') # Formatting Tags were also known as display tags. - Settings().setValue(u'displayTags/html_tags', cPickle.dumps(tags) if tags else u'') + Settings().setValue(u'formattingTags/html_tags', json.dumps(tags) if tags else u'') @staticmethod def load_tags(): @@ -156,13 +156,10 @@ class FormattingTags(object): u'end html': u'', u'protected': True, u'temporary': False}) FormattingTags.add_html_tags(base_tags) FormattingTags.add_html_tags(temporary_tags) - # Formatting Tags were also known as display tags. - user_expands = Settings().value(u'displayTags/html_tags') - # cPickle only accepts str not unicode strings - user_expands_string = str(user_expands) + user_expands_string = str(Settings().value(u'formattingTags/html_tags')) if user_expands_string: - user_tags = cPickle.loads(user_expands_string) + user_tags = json.loads(user_expands_string) for tag in user_tags: for element in tag: if isinstance(tag[element], str): diff --git a/openlp/core/lib/imagemanager.py b/openlp/core/lib/imagemanager.py index 412eddd1e..dc535a665 100644 --- a/openlp/core/lib/imagemanager.py +++ b/openlp/core/lib/imagemanager.py @@ -1,3 +1,4 @@ + # -*- coding: utf-8 -*- # vim: autoindent shiftwidth=4 expandtab textwidth=120 tabstop=4 softtabstop=4 diff --git a/openlp/core/lib/mediamanageritem.py b/openlp/core/lib/mediamanageritem.py index c3e1fa366..973d457bb 100644 --- a/openlp/core/lib/mediamanageritem.py +++ b/openlp/core/lib/mediamanageritem.py @@ -728,10 +728,14 @@ class MediaManagerItem(QtGui.QWidget): def _get_application(self): """ - Adds the openlp to the class dynamically + Adds the openlp to the class dynamically. + Windows needs to access the application in a dynamic manner. """ - if not hasattr(self, u'_application'): - self._application = Registry().get(u'application') - return self._application + if os.name == u'nt': + return Registry().get(u'application') + else: + if not hasattr(self, u'_application'): + self._application = Registry().get(u'application') + return self._application application = property(_get_application) diff --git a/openlp/core/lib/plugin.py b/openlp/core/lib/plugin.py index b4f851b24..a79ba850a 100644 --- a/openlp/core/lib/plugin.py +++ b/openlp/core/lib/plugin.py @@ -30,6 +30,7 @@ Provide the generic plugin functionality for OpenLP plugins. """ import logging +import os from PyQt4 import QtCore @@ -424,8 +425,11 @@ class Plugin(QtCore.QObject): """ Adds the openlp to the class dynamically """ - if not hasattr(self, u'_application'): - self._application = Registry().get(u'application') - return self._application + if os.name == u'nt': + return Registry().get(u'application') + else: + if not hasattr(self, u'_application'): + self._application = Registry().get(u'application') + return self._application application = property(_get_application) diff --git a/openlp/core/lib/registry.py b/openlp/core/lib/registry.py index 7e880f1f9..cee9e0329 100644 --- a/openlp/core/lib/registry.py +++ b/openlp/core/lib/registry.py @@ -103,9 +103,6 @@ class Registry(object): ``key`` The service to be deleted. """ - if self.running_under_test is False: - log.error(u'Invalid Method call for key %s' % key) - raise KeyError(u'Invalid Method call for key %s' % key) if key in self.service_list: del self.service_list[key] diff --git a/openlp/core/lib/serviceitem.py b/openlp/core/lib/serviceitem.py index b32e1aaf0..ee1a5c588 100644 --- a/openlp/core/lib/serviceitem.py +++ b/openlp/core/lib/serviceitem.py @@ -485,6 +485,12 @@ class ServiceItem(object): """ return self.unique_identifier != other.unique_identifier + def __hash__(self): + """ + Return the hash for the service item. + """ + return self.unique_identifier + def is_media(self): """ Confirms if the ServiceItem is media diff --git a/openlp/core/lib/settings.py b/openlp/core/lib/settings.py index 5f32b8cef..a887d2ce6 100644 --- a/openlp/core/lib/settings.py +++ b/openlp/core/lib/settings.py @@ -115,7 +115,7 @@ class Settings(QtCore.QSettings): u'advanced/single click preview': False, u'advanced/x11 bypass wm': X11_BYPASS_DEFAULT, u'crashreport/last directory': u'', - u'displayTags/html_tags': u'', + u'formattingTags/html_tags': u'', u'core/audio repeat list': False, u'core/auto open': False, u'core/auto preview': False, diff --git a/openlp/core/ui/exceptionform.py b/openlp/core/ui/exceptionform.py index af1744424..49d6b0bef 100644 --- a/openlp/core/ui/exceptionform.py +++ b/openlp/core/ui/exceptionform.py @@ -34,8 +34,8 @@ import re import os import platform +import bs4 import sqlalchemy -from bs4 import BeautifulSoup from lxml import etree from PyQt4 import Qt, QtCore, QtGui, QtWebKit @@ -145,7 +145,7 @@ class ExceptionForm(QtGui.QDialog, Ui_ExceptionDialog): u'QtWebkit: %s\n' % WEBKIT_VERSION + \ u'SQLAlchemy: %s\n' % sqlalchemy.__version__ + \ u'SQLAlchemy Migrate: %s\n' % MIGRATE_VERSION + \ - u'BeautifulSoup: %s\n' % BeautifulSoup.__version__ + \ + u'BeautifulSoup: %s\n' % bs4.__version__ + \ u'lxml: %s\n' % etree.__version__ + \ u'Chardet: %s\n' % CHARDET_VERSION + \ u'PyEnchant: %s\n' % ENCHANT_VERSION + \ diff --git a/openlp/core/ui/firsttimeform.py b/openlp/core/ui/firsttimeform.py index b66a38445..f163b3573 100644 --- a/openlp/core/ui/firsttimeform.py +++ b/openlp/core/ui/firsttimeform.py @@ -485,10 +485,14 @@ class FirstTimeForm(QtGui.QWizard, Ui_FirstTimeWizard): def _get_application(self): """ - Adds the openlp to the class dynamically + Adds the openlp to the class dynamically. + Windows needs to access the application in a dynamic manner. """ - if not hasattr(self, u'_application'): - self._application = Registry().get(u'application') - return self._application + if os.name == u'nt': + return Registry().get(u'application') + else: + if not hasattr(self, u'_application'): + self._application = Registry().get(u'application') + return self._application application = property(_get_application) diff --git a/openlp/core/ui/listpreviewwidget.py b/openlp/core/ui/listpreviewwidget.py index ca04c9688..ae6d0bed8 100644 --- a/openlp/core/ui/listpreviewwidget.py +++ b/openlp/core/ui/listpreviewwidget.py @@ -30,7 +30,7 @@ The :mod:`listpreviewwidget` is a widget that lists the slides in the slide controller. It is based on a QTableWidget but represents its contents in list form. """ - +from __future__ import division from PyQt4 import QtCore, QtGui from openlp.core.lib import ImageSource, Registry, ServiceItem @@ -76,7 +76,7 @@ class ListPreviewWidget(QtGui.QTableWidget): else: # Sort out image heights. for framenumber in range(len(self.service_item.get_frames())): - height = self.viewport().width() / self.screen_ratio + height = self.viewport().width() // self.screen_ratio self.setRowHeight(framenumber, height) def screen_size_changed(self, screen_ratio): @@ -101,7 +101,7 @@ class ListPreviewWidget(QtGui.QTableWidget): for framenumber, frame in enumerate(self.service_item.get_frames()): self.setRowCount(self.slide_count() + 1) item = QtGui.QTableWidgetItem() - slideHeight = 0 + slide_height = 0 if self.service_item.is_text(): if frame[u'verseTag']: # These tags are already translated. @@ -125,12 +125,12 @@ class ListPreviewWidget(QtGui.QTableWidget): image = self.image_manager.get_image(frame[u'path'], ImageSource.ImagePlugin) label.setPixmap(QtGui.QPixmap.fromImage(image)) self.setCellWidget(framenumber, 0, label) - slideHeight = width / self.screen_ratio + slide_height = width // self.screen_ratio row += 1 text.append(unicode(row)) self.setItem(framenumber, 0, item) - if slideHeight: - self.setRowHeight(framenumber, slideHeight) + if slide_height: + self.setRowHeight(framenumber, slide_height) self.setVerticalHeaderLabels(text) if self.service_item.is_text(): self.resizeRowsToContents() diff --git a/openlp/core/ui/maindisplay.py b/openlp/core/ui/maindisplay.py index 02ae469d6..eab89cb7d 100644 --- a/openlp/core/ui/maindisplay.py +++ b/openlp/core/ui/maindisplay.py @@ -38,6 +38,7 @@ Some of the code for this form is based on the examples at: from __future__ import division import cgi import logging +import os import sys from PyQt4 import QtCore, QtGui, QtWebKit, QtOpenGL @@ -288,7 +289,7 @@ class MainDisplay(Display): self.image(path) # Update the preview frame. if self.is_live: - self.live_controller.updatePreview() + self.live_controller.update_preview() return True def image(self, path): @@ -494,11 +495,15 @@ class MainDisplay(Display): def _get_application(self): """ - Adds the openlp to the class dynamically + Adds the openlp to the class dynamically. + Windows needs to access the application in a dynamic manner. """ - if not hasattr(self, u'_application'): - self._application = Registry().get(u'application') - return self._application + if os.name == u'nt': + return Registry().get(u'application') + else: + if not hasattr(self, u'_application'): + self._application = Registry().get(u'application') + return self._application application = property(_get_application) diff --git a/openlp/core/ui/mainwindow.py b/openlp/core/ui/mainwindow.py index 92151d6a3..307239032 100644 --- a/openlp/core/ui/mainwindow.py +++ b/openlp/core/ui/mainwindow.py @@ -683,7 +683,7 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow): Check and display message if screen blank on setup. """ settings = Settings() - self.live_controller.mainDisplaySetBackground() + self.live_controller.main_display_set_background() if settings.value(u'%s/screen blank' % self.general_settings_section): if settings.value(u'%s/blank warning' % self.general_settings_section): QtGui.QMessageBox.question(self, translate('OpenLP.MainWindow', 'OpenLP Main Display Blanked'), @@ -1076,6 +1076,9 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow): if self.live_controller.display: self.live_controller.display.close() self.live_controller.display = None + if os.name == u'nt': + # Needed for Windows to stop crashes on exit + Registry().remove(u'application') def set_service_modified(self, modified, file_name): """ @@ -1360,10 +1363,14 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow): def _get_application(self): """ - Adds the openlp to the class dynamically + Adds the openlp to the class dynamically. + Windows needs to access the application in a dynamic manner. """ - if not hasattr(self, u'_application'): - self._application = Registry().get(u'application') - return self._application + if os.name == u'nt': + return Registry().get(u'application') + else: + if not hasattr(self, u'_application'): + self._application = Registry().get(u'application') + return self._application application = property(_get_application) diff --git a/openlp/core/ui/media/mediaplayer.py b/openlp/core/ui/media/mediaplayer.py index c1f060f60..5d9e3663f 100644 --- a/openlp/core/ui/media/mediaplayer.py +++ b/openlp/core/ui/media/mediaplayer.py @@ -29,6 +29,8 @@ """ The :mod:`~openlp.core.ui.media.mediaplayer` module contains the MediaPlayer class. """ +import os + from openlp.core.lib import Registry from openlp.core.ui.media import MediaState @@ -153,10 +155,14 @@ class MediaPlayer(object): def _get_application(self): """ - Adds the openlp to the class dynamically + Adds the openlp to the class dynamically. + Windows needs to access the application in a dynamic manner. """ - if not hasattr(self, u'_application'): - self._application = Registry().get(u'application') - return self._application + if os.name == u'nt': + return Registry().get(u'application') + else: + if not hasattr(self, u'_application'): + self._application = Registry().get(u'application') + return self._application application = property(_get_application) \ No newline at end of file diff --git a/openlp/core/ui/media/webkitplayer.py b/openlp/core/ui/media/webkitplayer.py index f2dbfe5dc..e534a974b 100644 --- a/openlp/core/ui/media/webkitplayer.py +++ b/openlp/core/ui/media/webkitplayer.py @@ -44,113 +44,57 @@ VIDEO_CSS = u""" z-index:3; background-color: %(bgcolor)s; } -#video1 { - background-color: %(bgcolor)s; - z-index:4; -} -#video2 { +#video { background-color: %(bgcolor)s; z-index:4; } """ VIDEO_JS = u""" - var video_timer = null; - var current_video = '1'; + function show_video(state, path, volume, loop, variable_value){ + // Sometimes video.currentTime stops slightly short of video.duration and video.ended is intermittent! - function show_video(state, path, volume, loop, varVal){ - // Note, the preferred method for looping would be to use the - // video tag loop attribute. - // But QtWebKit doesn't support this. Neither does it support the - // onended event, hence the setInterval() - // In addition, setting the currentTime attribute to zero to restart - // the video raises an INDEX_SIZE_ERROR: DOM Exception 1 - // To complicate it further, sometimes vid.currentTime stops - // slightly short of vid.duration and vid.ended is intermittent! - // - // Note, currently the background may go black between loops. Not - // desirable. Need to investigate using two