forked from openlp/openlp
review changes part 2 and Head
This commit is contained in:
commit
709037ccca
243
openlp.pyw
243
openlp.pyw
@ -25,254 +25,15 @@
|
||||
# with this program; if not, write to the Free Software Foundation, Inc., 59 #
|
||||
# Temple Place, Suite 330, Boston, MA 02111-1307 USA #
|
||||
###############################################################################
|
||||
import os
|
||||
import sys
|
||||
import logging
|
||||
|
||||
# Import uuid now, to avoid the rare bug described in the support system:
|
||||
# http://support.openlp.org/issues/102
|
||||
# If https://bugs.gentoo.org/show_bug.cgi?id=317557 is fixed, the import can be
|
||||
# removed.
|
||||
import uuid
|
||||
from optparse import OptionParser
|
||||
from traceback import format_exception
|
||||
|
||||
from PyQt4 import QtCore, QtGui
|
||||
from openlp.core import main
|
||||
|
||||
from openlp.core.lib import Receiver, check_directory_exists
|
||||
from openlp.core.lib.ui import UiStrings
|
||||
from openlp.core.resources import qInitResources
|
||||
from openlp.core.ui.mainwindow import MainWindow
|
||||
from openlp.core.ui.firsttimelanguageform import FirstTimeLanguageForm
|
||||
from openlp.core.ui.firsttimeform import FirstTimeForm
|
||||
from openlp.core.ui.exceptionform import ExceptionForm
|
||||
from openlp.core.ui import SplashScreen, ScreenList
|
||||
from openlp.core.utils import AppLocation, LanguageManager, VersionThread, \
|
||||
get_application_version, DelayStartThread
|
||||
|
||||
log = logging.getLogger()
|
||||
|
||||
application_stylesheet = u"""
|
||||
QMainWindow::separator
|
||||
{
|
||||
border: none;
|
||||
}
|
||||
|
||||
QDockWidget::title
|
||||
{
|
||||
border: 1px solid palette(dark);
|
||||
padding-left: 5px;
|
||||
padding-top: 2px;
|
||||
margin: 1px 0;
|
||||
}
|
||||
|
||||
QToolBar
|
||||
{
|
||||
border: none;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
}
|
||||
"""
|
||||
|
||||
class OpenLP(QtGui.QApplication):
|
||||
"""
|
||||
The core application class. This class inherits from Qt's QApplication
|
||||
class in order to provide the core of the application.
|
||||
"""
|
||||
|
||||
args = []
|
||||
|
||||
def exec_(self):
|
||||
"""
|
||||
Override exec method to allow the shared memory to be released on exit
|
||||
"""
|
||||
QtGui.QApplication.exec_()
|
||||
self.sharedMemory.detach()
|
||||
|
||||
def run(self, args):
|
||||
"""
|
||||
Run the OpenLP application.
|
||||
"""
|
||||
# On Windows, the args passed into the constructor are
|
||||
# ignored. Not very handy, so set the ones we want to use.
|
||||
self.args.extend(args)
|
||||
# provide a listener for widgets to reqest a screen update.
|
||||
QtCore.QObject.connect(Receiver.get_receiver(),
|
||||
QtCore.SIGNAL(u'openlp_process_events'), self.processEvents)
|
||||
QtCore.QObject.connect(Receiver.get_receiver(),
|
||||
QtCore.SIGNAL(u'cursor_busy'), self.setBusyCursor)
|
||||
QtCore.QObject.connect(Receiver.get_receiver(),
|
||||
QtCore.SIGNAL(u'cursor_normal'), self.setNormalCursor)
|
||||
# Decide how many screens we have and their size
|
||||
screens = ScreenList(self.desktop())
|
||||
# First time checks in settings
|
||||
has_run_wizard = QtCore.QSettings().value(
|
||||
u'general/has run wizard', QtCore.QVariant(False)).toBool()
|
||||
if not has_run_wizard:
|
||||
if FirstTimeForm(screens).exec_() == QtGui.QDialog.Accepted:
|
||||
QtCore.QSettings().setValue(u'general/has run wizard',
|
||||
QtCore.QVariant(True))
|
||||
if os.name == u'nt':
|
||||
self.setStyleSheet(application_stylesheet)
|
||||
show_splash = QtCore.QSettings().value(
|
||||
u'general/show splash', QtCore.QVariant(True)).toBool()
|
||||
if show_splash:
|
||||
self.splash = SplashScreen()
|
||||
self.splash.show()
|
||||
# make sure Qt really display the splash screen
|
||||
self.processEvents()
|
||||
# start the main app window
|
||||
self.mainWindow = MainWindow(self.clipboard(), self.args)
|
||||
self.mainWindow.show()
|
||||
if show_splash:
|
||||
# now kill the splashscreen
|
||||
self.splash.finish(self.mainWindow)
|
||||
log.debug(u'Splashscreen closed')
|
||||
# make sure Qt really display the splash screen
|
||||
self.processEvents()
|
||||
self.mainWindow.repaint()
|
||||
self.processEvents()
|
||||
if not has_run_wizard:
|
||||
self.mainWindow.firstTime()
|
||||
update_check = QtCore.QSettings().value(
|
||||
u'general/update check', QtCore.QVariant(True)).toBool()
|
||||
if update_check:
|
||||
VersionThread(self.mainWindow).start()
|
||||
Receiver.send_message(u'maindisplay_blank_check')
|
||||
self.mainWindow.appStartup()
|
||||
DelayStartThread(self.mainWindow).start()
|
||||
return self.exec_()
|
||||
|
||||
def isAlreadyRunning(self):
|
||||
"""
|
||||
Look to see if OpenLP is already running and ask if a 2nd copy
|
||||
is to be started.
|
||||
"""
|
||||
self.sharedMemory = QtCore.QSharedMemory('OpenLP')
|
||||
if self.sharedMemory.attach():
|
||||
status = QtGui.QMessageBox.critical(None,
|
||||
UiStrings().Error, UiStrings().OpenLPStart,
|
||||
QtGui.QMessageBox.StandardButtons(
|
||||
QtGui.QMessageBox.Yes | QtGui.QMessageBox.No))
|
||||
if status == QtGui.QMessageBox.No:
|
||||
return True
|
||||
return False
|
||||
else:
|
||||
self.sharedMemory.create(1)
|
||||
return False
|
||||
|
||||
def hookException(self, exctype, value, traceback):
|
||||
if not hasattr(self, u'mainWindow'):
|
||||
log.exception(''.join(format_exception(exctype, value, traceback)))
|
||||
return
|
||||
if not hasattr(self, u'exceptionForm'):
|
||||
self.exceptionForm = ExceptionForm(self.mainWindow)
|
||||
self.exceptionForm.exceptionTextEdit.setPlainText(
|
||||
''.join(format_exception(exctype, value, traceback)))
|
||||
self.setNormalCursor()
|
||||
self.exceptionForm.exec_()
|
||||
|
||||
def setBusyCursor(self):
|
||||
"""
|
||||
Sets the Busy Cursor for the Application
|
||||
"""
|
||||
self.setOverrideCursor(QtCore.Qt.BusyCursor)
|
||||
self.processEvents()
|
||||
|
||||
def setNormalCursor(self):
|
||||
"""
|
||||
Sets the Normal Cursor for the Application
|
||||
"""
|
||||
self.restoreOverrideCursor()
|
||||
|
||||
def event(self, event):
|
||||
"""
|
||||
Enables direct file opening on OS X
|
||||
"""
|
||||
if event.type() == QtCore.QEvent.FileOpen:
|
||||
file_name = event.file()
|
||||
log.debug(u'Got open file event for %s!', file_name)
|
||||
self.args.insert(0, unicode(file_name))
|
||||
return True
|
||||
else:
|
||||
return QtGui.QApplication.event(self, event)
|
||||
|
||||
def main():
|
||||
"""
|
||||
The main function which parses command line options and then runs
|
||||
the PyQt4 Application.
|
||||
"""
|
||||
# Set up command line options.
|
||||
usage = 'Usage: %prog [options] [qt-options]'
|
||||
parser = OptionParser(usage=usage)
|
||||
parser.add_option('-e', '--no-error-form', dest='no_error_form',
|
||||
action='store_true', help='Disable the error notification form.')
|
||||
parser.add_option('-l', '--log-level', dest='loglevel',
|
||||
default='warning', metavar='LEVEL', help='Set logging to LEVEL '
|
||||
'level. Valid values are "debug", "info", "warning".')
|
||||
parser.add_option('-p', '--portable', dest='portable',
|
||||
action='store_true', help='Specify if this should be run as a '
|
||||
'portable app, off a USB flash drive (not implemented).')
|
||||
parser.add_option('-d', '--dev-version', dest='dev_version',
|
||||
action='store_true', help='Ignore the version file and pull the '
|
||||
'version directly from Bazaar')
|
||||
parser.add_option('-s', '--style', dest='style',
|
||||
help='Set the Qt4 style (passed directly to Qt4).')
|
||||
# Set up logging
|
||||
log_path = AppLocation.get_directory(AppLocation.CacheDir)
|
||||
check_directory_exists(log_path)
|
||||
filename = os.path.join(log_path, u'openlp.log')
|
||||
logfile = logging.FileHandler(filename, u'w')
|
||||
logfile.setFormatter(logging.Formatter(
|
||||
u'%(asctime)s %(name)-55s %(levelname)-8s %(message)s'))
|
||||
log.addHandler(logfile)
|
||||
logging.addLevelName(15, u'Timer')
|
||||
# Parse command line options and deal with them.
|
||||
(options, args) = parser.parse_args()
|
||||
qt_args = []
|
||||
if options.loglevel.lower() in ['d', 'debug']:
|
||||
log.setLevel(logging.DEBUG)
|
||||
print 'Logging to:', filename
|
||||
elif options.loglevel.lower() in ['w', 'warning']:
|
||||
log.setLevel(logging.WARNING)
|
||||
else:
|
||||
log.setLevel(logging.INFO)
|
||||
if options.style:
|
||||
qt_args.extend(['-style', options.style])
|
||||
# Throw the rest of the arguments at Qt, just in case.
|
||||
qt_args.extend(args)
|
||||
# Initialise the resources
|
||||
qInitResources()
|
||||
# Now create and actually run the application.
|
||||
app = OpenLP(qt_args)
|
||||
# Instance check
|
||||
if app.isAlreadyRunning():
|
||||
sys.exit()
|
||||
app.setOrganizationName(u'OpenLP')
|
||||
app.setOrganizationDomain(u'openlp.org')
|
||||
app.setApplicationName(u'OpenLP')
|
||||
app.setApplicationVersion(get_application_version()[u'version'])
|
||||
# First time checks in settings
|
||||
if not QtCore.QSettings().value(u'general/has run wizard',
|
||||
QtCore.QVariant(False)).toBool():
|
||||
if not FirstTimeLanguageForm().exec_():
|
||||
# if cancel then stop processing
|
||||
sys.exit()
|
||||
if sys.platform == u'darwin':
|
||||
OpenLP.addLibraryPath(QtGui.QApplication.applicationDirPath()
|
||||
+ "/qt4_plugins")
|
||||
# i18n Set Language
|
||||
language = LanguageManager.get_language()
|
||||
app_translator, default_translator = \
|
||||
LanguageManager.get_translator(language)
|
||||
if not app_translator.isEmpty():
|
||||
app.installTranslator(app_translator)
|
||||
if not default_translator.isEmpty():
|
||||
app.installTranslator(default_translator)
|
||||
else:
|
||||
log.debug(u'Could not find default_translator.')
|
||||
if not options.no_error_form:
|
||||
sys.excepthook = app.hookException
|
||||
sys.exit(app.run(qt_args))
|
||||
|
||||
if __name__ == u'__main__':
|
||||
"""
|
||||
|
@ -24,9 +24,265 @@
|
||||
# with this program; if not, write to the Free Software Foundation, Inc., 59 #
|
||||
# Temple Place, Suite 330, Boston, MA 02111-1307 USA #
|
||||
###############################################################################
|
||||
|
||||
__all__ = ('OpenLP', 'main')
|
||||
|
||||
import os
|
||||
import sys
|
||||
import logging
|
||||
from optparse import OptionParser
|
||||
from traceback import format_exception
|
||||
|
||||
from PyQt4 import QtCore, QtGui
|
||||
|
||||
from openlp.core.lib import Receiver, check_directory_exists
|
||||
from openlp.core.lib.ui import UiStrings
|
||||
from openlp.core.resources import qInitResources
|
||||
from openlp.core.ui.mainwindow import MainWindow
|
||||
from openlp.core.ui.firsttimelanguageform import FirstTimeLanguageForm
|
||||
from openlp.core.ui.firsttimeform import FirstTimeForm
|
||||
from openlp.core.ui.exceptionform import ExceptionForm
|
||||
from openlp.core.ui import SplashScreen, ScreenList
|
||||
from openlp.core.utils import AppLocation, LanguageManager, VersionThread, \
|
||||
get_application_version, DelayStartThread
|
||||
|
||||
log = logging.getLogger()
|
||||
|
||||
|
||||
"""
|
||||
The :mod:`core` module provides all core application functions
|
||||
|
||||
All the core functions of the OpenLP application including the GUI, settings,
|
||||
logging and a plugin framework are contained within the openlp.core module.
|
||||
"""
|
||||
|
||||
application_stylesheet = u"""
|
||||
QMainWindow::separator
|
||||
{
|
||||
border: none;
|
||||
}
|
||||
|
||||
QDockWidget::title
|
||||
{
|
||||
border: 1px solid palette(dark);
|
||||
padding-left: 5px;
|
||||
padding-top: 2px;
|
||||
margin: 1px 0;
|
||||
}
|
||||
|
||||
QToolBar
|
||||
{
|
||||
border: none;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
}
|
||||
"""
|
||||
|
||||
|
||||
class OpenLP(QtGui.QApplication):
|
||||
"""
|
||||
The core application class. This class inherits from Qt's QApplication
|
||||
class in order to provide the core of the application.
|
||||
"""
|
||||
|
||||
args = []
|
||||
|
||||
def exec_(self):
|
||||
"""
|
||||
Override exec method to allow the shared memory to be released on exit
|
||||
"""
|
||||
QtGui.QApplication.exec_()
|
||||
self.sharedMemory.detach()
|
||||
|
||||
def run(self, args, testing=False):
|
||||
"""
|
||||
Run the OpenLP application.
|
||||
"""
|
||||
# On Windows, the args passed into the constructor are
|
||||
# ignored. Not very handy, so set the ones we want to use.
|
||||
self.args.extend(args)
|
||||
# provide a listener for widgets to reqest a screen update.
|
||||
QtCore.QObject.connect(Receiver.get_receiver(),
|
||||
QtCore.SIGNAL(u'openlp_process_events'), self.processEvents)
|
||||
QtCore.QObject.connect(Receiver.get_receiver(),
|
||||
QtCore.SIGNAL(u'cursor_busy'), self.setBusyCursor)
|
||||
QtCore.QObject.connect(Receiver.get_receiver(),
|
||||
QtCore.SIGNAL(u'cursor_normal'), self.setNormalCursor)
|
||||
# Decide how many screens we have and their size
|
||||
screens = ScreenList(self.desktop())
|
||||
# First time checks in settings
|
||||
has_run_wizard = QtCore.QSettings().value(
|
||||
u'general/has run wizard', QtCore.QVariant(False)).toBool()
|
||||
if not has_run_wizard:
|
||||
if FirstTimeForm(screens).exec_() == QtGui.QDialog.Accepted:
|
||||
QtCore.QSettings().setValue(u'general/has run wizard',
|
||||
QtCore.QVariant(True))
|
||||
if os.name == u'nt':
|
||||
self.setStyleSheet(application_stylesheet)
|
||||
show_splash = QtCore.QSettings().value(
|
||||
u'general/show splash', QtCore.QVariant(True)).toBool()
|
||||
if show_splash:
|
||||
self.splash = SplashScreen()
|
||||
self.splash.show()
|
||||
# make sure Qt really display the splash screen
|
||||
self.processEvents()
|
||||
# start the main app window
|
||||
self.mainWindow = MainWindow(self.clipboard(), self.args)
|
||||
self.mainWindow.show()
|
||||
if show_splash:
|
||||
# now kill the splashscreen
|
||||
self.splash.finish(self.mainWindow)
|
||||
log.debug(u'Splashscreen closed')
|
||||
# make sure Qt really display the splash screen
|
||||
self.processEvents()
|
||||
self.mainWindow.repaint()
|
||||
self.processEvents()
|
||||
if not has_run_wizard:
|
||||
self.mainWindow.firstTime()
|
||||
update_check = QtCore.QSettings().value(
|
||||
u'general/update check', QtCore.QVariant(True)).toBool()
|
||||
if update_check:
|
||||
VersionThread(self.mainWindow).start()
|
||||
Receiver.send_message(u'maindisplay_blank_check')
|
||||
self.mainWindow.appStartup()
|
||||
DelayStartThread(self.mainWindow).start()
|
||||
# Skip exec_() for gui tests
|
||||
if not testing:
|
||||
return self.exec_()
|
||||
|
||||
def isAlreadyRunning(self):
|
||||
"""
|
||||
Look to see if OpenLP is already running and ask if a 2nd copy
|
||||
is to be started.
|
||||
"""
|
||||
self.sharedMemory = QtCore.QSharedMemory('OpenLP')
|
||||
if self.sharedMemory.attach():
|
||||
status = QtGui.QMessageBox.critical(None,
|
||||
UiStrings().Error, UiStrings().OpenLPStart,
|
||||
QtGui.QMessageBox.StandardButtons(
|
||||
QtGui.QMessageBox.Yes | QtGui.QMessageBox.No))
|
||||
if status == QtGui.QMessageBox.No:
|
||||
return True
|
||||
return False
|
||||
else:
|
||||
self.sharedMemory.create(1)
|
||||
return False
|
||||
|
||||
def hookException(self, exctype, value, traceback):
|
||||
if not hasattr(self, u'mainWindow'):
|
||||
log.exception(''.join(format_exception(exctype, value, traceback)))
|
||||
return
|
||||
if not hasattr(self, u'exceptionForm'):
|
||||
self.exceptionForm = ExceptionForm(self.mainWindow)
|
||||
self.exceptionForm.exceptionTextEdit.setPlainText(
|
||||
''.join(format_exception(exctype, value, traceback)))
|
||||
self.setNormalCursor()
|
||||
self.exceptionForm.exec_()
|
||||
|
||||
def setBusyCursor(self):
|
||||
"""
|
||||
Sets the Busy Cursor for the Application
|
||||
"""
|
||||
self.setOverrideCursor(QtCore.Qt.BusyCursor)
|
||||
self.processEvents()
|
||||
|
||||
def setNormalCursor(self):
|
||||
"""
|
||||
Sets the Normal Cursor for the Application
|
||||
"""
|
||||
self.restoreOverrideCursor()
|
||||
|
||||
def event(self, event):
|
||||
"""
|
||||
Enables direct file opening on OS X
|
||||
"""
|
||||
if event.type() == QtCore.QEvent.FileOpen:
|
||||
file_name = event.file()
|
||||
log.debug(u'Got open file event for %s!', file_name)
|
||||
self.args.insert(0, unicode(file_name))
|
||||
return True
|
||||
else:
|
||||
return QtGui.QApplication.event(self, event)
|
||||
|
||||
|
||||
def main(args=None):
|
||||
"""
|
||||
The main function which parses command line options and then runs
|
||||
the PyQt4 Application.
|
||||
"""
|
||||
# Set up command line options.
|
||||
usage = 'Usage: %prog [options] [qt-options]'
|
||||
parser = OptionParser(usage=usage)
|
||||
parser.add_option('-e', '--no-error-form', dest='no_error_form',
|
||||
action='store_true', help='Disable the error notification form.')
|
||||
parser.add_option('-l', '--log-level', dest='loglevel',
|
||||
default='warning', metavar='LEVEL', help='Set logging to LEVEL '
|
||||
'level. Valid values are "debug", "info", "warning".')
|
||||
parser.add_option('-p', '--portable', dest='portable',
|
||||
action='store_true', help='Specify if this should be run as a '
|
||||
'portable app, off a USB flash drive (not implemented).')
|
||||
parser.add_option('-d', '--dev-version', dest='dev_version',
|
||||
action='store_true', help='Ignore the version file and pull the '
|
||||
'version directly from Bazaar')
|
||||
parser.add_option('-s', '--style', dest='style',
|
||||
help='Set the Qt4 style (passed directly to Qt4).')
|
||||
parser.add_option('--testing', dest='testing',
|
||||
action='store_true', help='Run by testing framework')
|
||||
# Set up logging
|
||||
log_path = AppLocation.get_directory(AppLocation.CacheDir)
|
||||
check_directory_exists(log_path)
|
||||
filename = os.path.join(log_path, u'openlp.log')
|
||||
logfile = logging.FileHandler(filename, u'w')
|
||||
logfile.setFormatter(logging.Formatter(
|
||||
u'%(asctime)s %(name)-55s %(levelname)-8s %(message)s'))
|
||||
log.addHandler(logfile)
|
||||
logging.addLevelName(15, u'Timer')
|
||||
# Parse command line options and deal with them.
|
||||
# Use args supplied programatically if possible.
|
||||
(options, args) = parser.parse_args(args) if args else parser.parse_args()
|
||||
qt_args = []
|
||||
if options.loglevel.lower() in ['d', 'debug']:
|
||||
log.setLevel(logging.DEBUG)
|
||||
print 'Logging to:', filename
|
||||
elif options.loglevel.lower() in ['w', 'warning']:
|
||||
log.setLevel(logging.WARNING)
|
||||
else:
|
||||
log.setLevel(logging.INFO)
|
||||
if options.style:
|
||||
qt_args.extend(['-style', options.style])
|
||||
# Throw the rest of the arguments at Qt, just in case.
|
||||
qt_args.extend(args)
|
||||
# Initialise the resources
|
||||
qInitResources()
|
||||
# Now create and actually run the application.
|
||||
app = OpenLP(qt_args)
|
||||
app.setOrganizationName(u'OpenLP')
|
||||
app.setOrganizationDomain(u'openlp.org')
|
||||
app.setApplicationName(u'OpenLP')
|
||||
app.setApplicationVersion(get_application_version()[u'version'])
|
||||
# Instance check
|
||||
if app.isAlreadyRunning():
|
||||
sys.exit()
|
||||
# First time checks in settings
|
||||
if not QtCore.QSettings().value(u'general/has run wizard',
|
||||
QtCore.QVariant(False)).toBool():
|
||||
if not FirstTimeLanguageForm().exec_():
|
||||
# if cancel then stop processing
|
||||
sys.exit()
|
||||
# i18n Set Language
|
||||
language = LanguageManager.get_language()
|
||||
app_translator, default_translator = \
|
||||
LanguageManager.get_translator(language)
|
||||
if not app_translator.isEmpty():
|
||||
app.installTranslator(app_translator)
|
||||
if not default_translator.isEmpty():
|
||||
app.installTranslator(default_translator)
|
||||
else:
|
||||
log.debug(u'Could not find default_translator.')
|
||||
if not options.no_error_form:
|
||||
sys.excepthook = app.hookException
|
||||
# Do not run method app.exec_() when running gui tests
|
||||
if options.testing:
|
||||
app.run(qt_args, testing=True)
|
||||
else:
|
||||
sys.exit(app.run(qt_args))
|
||||
|
@ -53,8 +53,8 @@ body {
|
||||
position: absolute;
|
||||
left: 0px;
|
||||
top: 0px;
|
||||
width: 100%%;//%spx;
|
||||
height: 100%%;//%spx;
|
||||
width: 100%%;
|
||||
height: 100%%;
|
||||
}
|
||||
#black {
|
||||
z-index: 8;
|
||||
@ -285,9 +285,8 @@ def build_html(item, screen, alert, islive, background, plugins=None, \
|
||||
js_additions += plugin.getDisplayJavaScript()
|
||||
html_additions += plugin.getDisplayHtml()
|
||||
html = HTMLSRC % (build_background_css(item, width, height),
|
||||
width, height,
|
||||
css_additions,
|
||||
build_alert_css(alert, width),
|
||||
build_alert_css(alert),
|
||||
build_footer_css(item, height),
|
||||
build_lyrics_css(item, webkitvers),
|
||||
u'true' if theme and theme.display_slide_transition and islive \
|
||||
@ -555,7 +554,7 @@ def build_footer_css(item, height):
|
||||
theme.font_footer_size, theme.font_footer_color)
|
||||
return lyrics_html
|
||||
|
||||
def build_alert_css(alertTab, width):
|
||||
def build_alert_css(alertTab):
|
||||
"""
|
||||
Build the display of the footer
|
||||
|
||||
@ -563,7 +562,7 @@ def build_alert_css(alertTab, width):
|
||||
Details from the Alert tab for fonts etc
|
||||
"""
|
||||
style = u"""
|
||||
width: %spx;
|
||||
width: 100%%;
|
||||
vertical-align: %s;
|
||||
font-family: %s;
|
||||
font-size: %spt;
|
||||
@ -573,6 +572,6 @@ def build_alert_css(alertTab, width):
|
||||
if not alertTab:
|
||||
return u''
|
||||
align = VerticalType.Names[alertTab.location]
|
||||
alert = style % (width, align, alertTab.font_face, alertTab.font_size,
|
||||
alert = style % (align, alertTab.font_face, alertTab.font_size,
|
||||
alertTab.font_color, alertTab.bg_color)
|
||||
return alert
|
||||
|
@ -168,7 +168,7 @@ class Plugin(QtCore.QObject):
|
||||
self.mediadock = plugin_helpers[u'toolbox']
|
||||
self.pluginManager = plugin_helpers[u'pluginmanager']
|
||||
self.formparent = plugin_helpers[u'formparent']
|
||||
self.mediaManager = plugin_helpers[u'mediacontroller']
|
||||
self.mediaController = plugin_helpers[u'mediacontroller']
|
||||
QtCore.QObject.connect(Receiver.get_receiver(),
|
||||
QtCore.SIGNAL(u'%s_add_service_item' % self.name),
|
||||
self.processAddServiceEvent)
|
||||
|
@ -258,12 +258,11 @@ class Renderer(object):
|
||||
# we have to render the first virtual slide.
|
||||
text_contains_break = u'[---]' in text
|
||||
if text_contains_break:
|
||||
html_text, text = text.split(u'\n[---]\n', 1)
|
||||
text_to_render, text = text.split(u'\n[---]\n', 1)
|
||||
else:
|
||||
html_text = text
|
||||
text_to_render = text
|
||||
text = u''
|
||||
lines = expand_tags(html_text)
|
||||
lines = lines.strip(u'\n').split(u'\n')
|
||||
lines = text_to_render.strip(u'\n').split(u'\n')
|
||||
slides = self._paginate_slide(lines, line_end)
|
||||
if len(slides) > 1 and text:
|
||||
# Add all slides apart from the last one the
|
||||
@ -277,8 +276,7 @@ class Renderer(object):
|
||||
else:
|
||||
pages.extend(slides)
|
||||
if u'[---]' not in text:
|
||||
lines = expand_tags(text)
|
||||
lines = lines.strip(u'\n').split(u'\n')
|
||||
lines = text.strip(u'\n').split(u'\n')
|
||||
pages.extend(self._paginate_slide(lines, line_end))
|
||||
break
|
||||
new_pages = []
|
||||
|
@ -253,7 +253,7 @@ class MainDisplay(Display):
|
||||
"""
|
||||
log.debug(u'image to display')
|
||||
image = self.imageManager.get_image_bytes(name)
|
||||
self.controller.mediaManager.video_reset(self.controller)
|
||||
self.controller.mediaController.video_reset(self.controller)
|
||||
self.displayImage(image)
|
||||
return self.preview()
|
||||
|
||||
|
@ -148,7 +148,7 @@ class Ui_MainWindow(object):
|
||||
self.defaultThemeLabel = QtGui.QLabel(self.statusBar)
|
||||
self.defaultThemeLabel.setObjectName(u'defaultThemeLabel')
|
||||
self.statusBar.addPermanentWidget(self.defaultThemeLabel)
|
||||
# Create the MediaController
|
||||
# Create the MediaManager
|
||||
self.mediaManagerDock = OpenLPDockWidget(mainWindow,
|
||||
u'mediaManagerDock', u':/system/system_mediamanager.png')
|
||||
self.mediaManagerDock.setStyleSheet(MEDIA_MANAGER_STYLE)
|
||||
@ -557,7 +557,7 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow):
|
||||
self.pluginManager = PluginManager(pluginpath)
|
||||
self.pluginHelpers = {}
|
||||
self.imageManager = ImageManager()
|
||||
self.mediaManager = MediaController(self)
|
||||
self.mediaController = MediaController(self)
|
||||
# Set up the interface
|
||||
self.setupUi(self)
|
||||
# Load settings after setupUi so default UI sizes are overwritten
|
||||
@ -646,7 +646,7 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow):
|
||||
self.pluginHelpers[u'toolbox'] = self.mediaDockManager
|
||||
self.pluginHelpers[u'pluginmanager'] = self.pluginManager
|
||||
self.pluginHelpers[u'formparent'] = self
|
||||
self.pluginHelpers[u'mediacontroller'] = self.mediaManager
|
||||
self.pluginHelpers[u'mediacontroller'] = self.mediaController
|
||||
self.pluginManager.find_plugins(pluginpath, self.pluginHelpers)
|
||||
# hook methods have to happen after find_plugins. Find plugins needs
|
||||
# the controllers hence the hooks have moved from setupUI() to here
|
||||
|
@ -34,70 +34,16 @@ from openlp.core.ui.media import MediaAPI, MediaState
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
class WebkitAPI(MediaAPI):
|
||||
"""
|
||||
A specialised version of the MediaAPI class,
|
||||
which provides a QtWebKit display.
|
||||
"""
|
||||
|
||||
def __init__(self, parent):
|
||||
MediaAPI.__init__(self, parent, u'Webkit')
|
||||
self.parent = parent
|
||||
self.canBackground = True
|
||||
self.audio_extensions_list = [
|
||||
u'*.mp3'
|
||||
, u'*.ogg'
|
||||
]
|
||||
self.video_extensions_list = [
|
||||
u'*.3gp'
|
||||
, u'*.3gpp'
|
||||
, u'*.3g2'
|
||||
, u'*.3gpp2'
|
||||
, u'*.aac'
|
||||
, u'*.flv'
|
||||
, u'*.f4a'
|
||||
, u'*.f4b'
|
||||
, u'*.f4p'
|
||||
, u'*.f4v'
|
||||
, u'*.mov'
|
||||
, u'*.m4a'
|
||||
, u'*.m4b'
|
||||
, u'*.m4p'
|
||||
, u'*.m4v'
|
||||
, u'*.mkv'
|
||||
, u'*.mp4'
|
||||
, u'*.ogv'
|
||||
, u'*.webm'
|
||||
, u'*.swf', u'*.mpg', u'*.wmv', u'*.mpeg', u'*.avi'
|
||||
]
|
||||
|
||||
def setup_controls(self, controller, control_panel):
|
||||
# no special controls
|
||||
pass
|
||||
|
||||
def get_media_display_css(self):
|
||||
"""
|
||||
Add css style sheets to htmlbuilder
|
||||
"""
|
||||
css = u'''
|
||||
video_css = u"""
|
||||
#video1 {
|
||||
z-index:3;
|
||||
}
|
||||
#video2 {
|
||||
z-index:3;
|
||||
}
|
||||
#flash {
|
||||
z-index:4;
|
||||
}
|
||||
'''
|
||||
return css
|
||||
|
||||
|
||||
def get_media_display_javascript(self):
|
||||
"""
|
||||
Add javascript functions to htmlbuilder
|
||||
"""
|
||||
js = u'''
|
||||
|
||||
video_js = u"""
|
||||
var video_timer = null;
|
||||
var current_video = '1';
|
||||
|
||||
@ -190,7 +136,22 @@ class WebkitAPI(MediaAPI):
|
||||
break;
|
||||
}
|
||||
}
|
||||
"""
|
||||
|
||||
video_html = u"""
|
||||
<video id="video1" class="size" style="visibility:hidden" autobuffer preload>
|
||||
</video>
|
||||
<video id="video2" class="size" style="visibility:hidden" autobuffer preload>
|
||||
</video>
|
||||
"""
|
||||
|
||||
flash_css = u"""
|
||||
#flash {
|
||||
z-index:4;
|
||||
}
|
||||
"""
|
||||
|
||||
flash_js = u"""
|
||||
function getFlashMovieObject(movieName)
|
||||
{
|
||||
if (window.document[movieName])
|
||||
@ -247,22 +208,73 @@ class WebkitAPI(MediaAPI):
|
||||
break;
|
||||
}
|
||||
}
|
||||
'''
|
||||
return js
|
||||
"""
|
||||
|
||||
flash_html = u"""
|
||||
<div id="flash" class="size" style="visibility:hidden"></div>
|
||||
"""
|
||||
|
||||
class WebkitAPI(MediaAPI):
|
||||
"""
|
||||
A specialised version of the MediaAPI class,
|
||||
which provides a QtWebKit display.
|
||||
"""
|
||||
|
||||
def __init__(self, parent):
|
||||
MediaAPI.__init__(self, parent, u'Webkit')
|
||||
self.parent = parent
|
||||
self.canBackground = True
|
||||
self.audio_extensions_list = [
|
||||
u'*.mp3'
|
||||
, u'*.ogg'
|
||||
]
|
||||
self.video_extensions_list = [
|
||||
u'*.3gp'
|
||||
, u'*.3gpp'
|
||||
, u'*.3g2'
|
||||
, u'*.3gpp2'
|
||||
, u'*.aac'
|
||||
, u'*.flv'
|
||||
, u'*.f4a'
|
||||
, u'*.f4b'
|
||||
, u'*.f4p'
|
||||
, u'*.f4v'
|
||||
, u'*.mov'
|
||||
, u'*.m4a'
|
||||
, u'*.m4b'
|
||||
, u'*.m4p'
|
||||
, u'*.m4v'
|
||||
, u'*.mkv'
|
||||
, u'*.mp4'
|
||||
, u'*.ogv'
|
||||
, u'*.webm'
|
||||
, u'*.mpg', u'*.wmv', u'*.mpeg', u'*.avi'
|
||||
, u'*.swf'
|
||||
]
|
||||
|
||||
def setup_controls(self, controller, control_panel):
|
||||
# no special controls
|
||||
pass
|
||||
|
||||
def get_media_display_css(self):
|
||||
"""
|
||||
Add css style sheets to htmlbuilder
|
||||
"""
|
||||
return video_css + flash_css
|
||||
|
||||
|
||||
def get_media_display_javascript(self):
|
||||
"""
|
||||
Add javascript functions to htmlbuilder
|
||||
"""
|
||||
return video_js + flash_js
|
||||
|
||||
|
||||
def get_media_display_html(self):
|
||||
"""
|
||||
Add html code to htmlbuilder
|
||||
"""
|
||||
html = u'''
|
||||
<video id="video1" class="size" style="visibility:hidden" autobuffer preload>
|
||||
</video>
|
||||
<video id="video2" class="size" style="visibility:hidden" autobuffer preload>
|
||||
</video>
|
||||
<div id="flash" class="size" style="visibility:hidden"></div>
|
||||
'''
|
||||
return html
|
||||
return video_html + flash_html
|
||||
|
||||
def setup(self, display):
|
||||
display.webView.resize(display.size())
|
||||
|
@ -85,7 +85,7 @@ class SlideController(Controller):
|
||||
self.ratio = float(self.screens.current[u'size'].width()) / \
|
||||
float(self.screens.current[u'size'].height())
|
||||
self.imageManager = self.parent().imageManager
|
||||
self.mediaManager = self.parent().mediaManager
|
||||
self.mediaController = self.parent().mediaController
|
||||
self.loopList = [
|
||||
u'Play Slides Menu',
|
||||
u'Loop Separator',
|
||||
@ -253,7 +253,7 @@ class SlideController(Controller):
|
||||
self.onEditSong)
|
||||
self.controllerLayout.addWidget(self.toolbar)
|
||||
# Build the Media Toolbar
|
||||
self.mediaManager.add_controller_items(self, self.controllerLayout)
|
||||
self.mediaController.add_controller_items(self, self.controllerLayout)
|
||||
if self.isLive:
|
||||
# Build the Song Toolbar
|
||||
self.songMenu = QtGui.QToolButton(self.toolbar)
|
||||
@ -390,7 +390,7 @@ class SlideController(Controller):
|
||||
|
||||
def liveEscape(self):
|
||||
self.display.setVisible(False)
|
||||
Receiver.send_message('Media Stop', [self])
|
||||
self.mediaController.video_stop([self])
|
||||
|
||||
def servicePrevious(self):
|
||||
time.sleep(0.1)
|
||||
@ -417,10 +417,10 @@ class SlideController(Controller):
|
||||
# The SlidePreview's ratio.
|
||||
self.ratio = float(self.screens.current[u'size'].width()) / \
|
||||
float(self.screens.current[u'size'].height())
|
||||
self.mediaManager.setup_display(self.display)
|
||||
self.mediaController.setup_display(self.display)
|
||||
self.previewSizeChanged()
|
||||
self.previewDisplay.setup()
|
||||
self.mediaManager.setup_display(self.previewDisplay)
|
||||
self.mediaController.setup_display(self.previewDisplay)
|
||||
if self.serviceItem:
|
||||
self.refreshServiceItem()
|
||||
|
||||
@ -520,7 +520,6 @@ class SlideController(Controller):
|
||||
self.previousItem.setVisible(True)
|
||||
self.nextItem.setVisible(True)
|
||||
self.toolbar.show()
|
||||
self.toolbar.show()
|
||||
|
||||
def enablePreviewToolBar(self, item):
|
||||
"""
|
||||
@ -1148,8 +1147,8 @@ class SlideController(Controller):
|
||||
"""
|
||||
log.debug(u'SlideController onMediaStart')
|
||||
file = os.path.join(item.get_frame_path(), item.get_frame_title())
|
||||
self.mediaManager.video(self, file, False, False)
|
||||
if not self.isLive or self.mediaManager.withLivePreview:
|
||||
self.mediaController.video(self, file, False, False)
|
||||
if not self.isLive or self.mediaController.withLivePreview:
|
||||
self.previewDisplay.show()
|
||||
self.slidePreview.hide()
|
||||
|
||||
@ -1158,7 +1157,7 @@ class SlideController(Controller):
|
||||
Respond to a request to close the Video
|
||||
"""
|
||||
log.debug(u'SlideController onMediaClose')
|
||||
self.mediaManager.video_reset(self)
|
||||
self.mediaController.video_reset(self)
|
||||
self.previewDisplay.hide()
|
||||
self.slidePreview.show()
|
||||
|
||||
|
@ -56,14 +56,14 @@ class MediaMediaItem(MediaManagerItem):
|
||||
self.mediaObject = None
|
||||
self.mediaController = Controller(parent)
|
||||
self.mediaController.controllerLayout = QtGui.QVBoxLayout()
|
||||
self.plugin.mediaManager.add_controller_items(self.mediaController, \
|
||||
self.plugin.mediaController.add_controller_items(self.mediaController, \
|
||||
self.mediaController.controllerLayout)
|
||||
self.plugin.mediaManager.set_controls_visible(self.mediaController, \
|
||||
self.plugin.mediaController.set_controls_visible(self.mediaController, \
|
||||
False)
|
||||
self.mediaController.previewDisplay = Display(self.mediaController, \
|
||||
False, self.mediaController, self.plugin.pluginManager.plugins)
|
||||
self.mediaController.previewDisplay.setup()
|
||||
self.plugin.mediaManager.setup_display( \
|
||||
self.plugin.mediaController.setup_display( \
|
||||
self.mediaController.previewDisplay)
|
||||
self.mediaController.previewDisplay.hide()
|
||||
|
||||
@ -106,7 +106,7 @@ class MediaMediaItem(MediaManagerItem):
|
||||
"""
|
||||
Called to reset the Live background with the media selected,
|
||||
"""
|
||||
self.plugin.liveController.mediaManager.video_reset( \
|
||||
self.plugin.liveController.mediaController.video_reset( \
|
||||
self.plugin.liveController)
|
||||
self.resetAction.setVisible(False)
|
||||
|
||||
@ -126,7 +126,7 @@ class MediaMediaItem(MediaManagerItem):
|
||||
item = self.listView.currentItem()
|
||||
filename = unicode(item.data(QtCore.Qt.UserRole).toString())
|
||||
if os.path.exists(filename):
|
||||
if self.plugin.liveController.mediaManager.video( \
|
||||
if self.plugin.liveController.mediaController.video( \
|
||||
self.plugin.liveController, filename, True, True):
|
||||
self.resetAction.setVisible(True)
|
||||
else:
|
||||
@ -153,11 +153,11 @@ class MediaMediaItem(MediaManagerItem):
|
||||
'The file %s no longer exists.')) % filename)
|
||||
return False
|
||||
self.mediaLength = 0
|
||||
if self.plugin.mediaManager.video( \
|
||||
if self.plugin.mediaController.video( \
|
||||
self.mediaController, filename, False, False):
|
||||
self.mediaLength = self.mediaController.media_info.length
|
||||
service_item.media_length = self.mediaLength
|
||||
self.plugin.mediaManager.video_reset(self.mediaController)
|
||||
self.plugin.mediaController.video_reset(self.mediaController)
|
||||
if self.mediaLength > 0:
|
||||
service_item.add_capability(
|
||||
ItemCapabilities.AllowsVariableStartTime)
|
||||
|
@ -45,11 +45,11 @@ class MediaPlugin(Plugin):
|
||||
# passed with drag and drop messages
|
||||
self.dnd_id = u'Media'
|
||||
self.audio_extensions_list = \
|
||||
self.mediaManager.get_audio_extensions_list()
|
||||
self.mediaController.get_audio_extensions_list()
|
||||
for ext in self.audio_extensions_list:
|
||||
self.serviceManager.supportedSuffixes(ext[2:])
|
||||
self.video_extensions_list = \
|
||||
self.mediaManager.get_video_extensions_list()
|
||||
self.mediaController.get_video_extensions_list()
|
||||
for ext in self.video_extensions_list:
|
||||
self.serviceManager.supportedSuffixes(ext[2:])
|
||||
|
||||
@ -59,7 +59,7 @@ class MediaPlugin(Plugin):
|
||||
"""
|
||||
visible_name = self.getString(StringContent.VisibleName)
|
||||
return MediaTab(parent, self.name, visible_name[u'title'],
|
||||
self.mediaManager.APIs, self.icon_path)
|
||||
self.mediaController.APIs, self.icon_path)
|
||||
|
||||
def about(self):
|
||||
about_text = translate('MediaPlugin', '<strong>Media Plugin</strong>'
|
||||
@ -98,23 +98,23 @@ class MediaPlugin(Plugin):
|
||||
Time to tidy up on exit
|
||||
"""
|
||||
log.info(u'Media Finalising')
|
||||
self.mediaManager.finalise()
|
||||
self.mediaController.finalise()
|
||||
Plugin.finalise(self)
|
||||
|
||||
def getDisplayCss(self):
|
||||
"""
|
||||
Add css style sheets to htmlbuilder
|
||||
"""
|
||||
return self.mediaManager.get_media_display_css()
|
||||
return self.mediaController.get_media_display_css()
|
||||
|
||||
def getDisplayJavaScript(self):
|
||||
"""
|
||||
Add javascript functions to htmlbuilder
|
||||
"""
|
||||
return self.mediaManager.get_media_display_javascript()
|
||||
return self.mediaController.get_media_display_javascript()
|
||||
|
||||
def getDisplayHtml(self):
|
||||
"""
|
||||
Add html code to htmlbuilder
|
||||
"""
|
||||
return self.mediaManager.get_media_display_html()
|
||||
return self.mediaController.get_media_display_html()
|
||||
|
Loading…
Reference in New Issue
Block a user