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 #
|
# with this program; if not, write to the Free Software Foundation, Inc., 59 #
|
||||||
# Temple Place, Suite 330, Boston, MA 02111-1307 USA #
|
# 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:
|
# Import uuid now, to avoid the rare bug described in the support system:
|
||||||
# http://support.openlp.org/issues/102
|
# http://support.openlp.org/issues/102
|
||||||
# If https://bugs.gentoo.org/show_bug.cgi?id=317557 is fixed, the import can be
|
# If https://bugs.gentoo.org/show_bug.cgi?id=317557 is fixed, the import can be
|
||||||
# removed.
|
# removed.
|
||||||
import uuid
|
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__':
|
if __name__ == u'__main__':
|
||||||
"""
|
"""
|
||||||
|
@ -24,9 +24,265 @@
|
|||||||
# with this program; if not, write to the Free Software Foundation, Inc., 59 #
|
# with this program; if not, write to the Free Software Foundation, Inc., 59 #
|
||||||
# Temple Place, Suite 330, Boston, MA 02111-1307 USA #
|
# 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
|
The :mod:`core` module provides all core application functions
|
||||||
|
|
||||||
All the core functions of the OpenLP application including the GUI, settings,
|
All the core functions of the OpenLP application including the GUI, settings,
|
||||||
logging and a plugin framework are contained within the openlp.core module.
|
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;
|
position: absolute;
|
||||||
left: 0px;
|
left: 0px;
|
||||||
top: 0px;
|
top: 0px;
|
||||||
width: 100%%;//%spx;
|
width: 100%%;
|
||||||
height: 100%%;//%spx;
|
height: 100%%;
|
||||||
}
|
}
|
||||||
#black {
|
#black {
|
||||||
z-index: 8;
|
z-index: 8;
|
||||||
@ -285,9 +285,8 @@ def build_html(item, screen, alert, islive, background, plugins=None, \
|
|||||||
js_additions += plugin.getDisplayJavaScript()
|
js_additions += plugin.getDisplayJavaScript()
|
||||||
html_additions += plugin.getDisplayHtml()
|
html_additions += plugin.getDisplayHtml()
|
||||||
html = HTMLSRC % (build_background_css(item, width, height),
|
html = HTMLSRC % (build_background_css(item, width, height),
|
||||||
width, height,
|
|
||||||
css_additions,
|
css_additions,
|
||||||
build_alert_css(alert, width),
|
build_alert_css(alert),
|
||||||
build_footer_css(item, height),
|
build_footer_css(item, height),
|
||||||
build_lyrics_css(item, webkitvers),
|
build_lyrics_css(item, webkitvers),
|
||||||
u'true' if theme and theme.display_slide_transition and islive \
|
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)
|
theme.font_footer_size, theme.font_footer_color)
|
||||||
return lyrics_html
|
return lyrics_html
|
||||||
|
|
||||||
def build_alert_css(alertTab, width):
|
def build_alert_css(alertTab):
|
||||||
"""
|
"""
|
||||||
Build the display of the footer
|
Build the display of the footer
|
||||||
|
|
||||||
@ -563,7 +562,7 @@ def build_alert_css(alertTab, width):
|
|||||||
Details from the Alert tab for fonts etc
|
Details from the Alert tab for fonts etc
|
||||||
"""
|
"""
|
||||||
style = u"""
|
style = u"""
|
||||||
width: %spx;
|
width: 100%%;
|
||||||
vertical-align: %s;
|
vertical-align: %s;
|
||||||
font-family: %s;
|
font-family: %s;
|
||||||
font-size: %spt;
|
font-size: %spt;
|
||||||
@ -573,6 +572,6 @@ def build_alert_css(alertTab, width):
|
|||||||
if not alertTab:
|
if not alertTab:
|
||||||
return u''
|
return u''
|
||||||
align = VerticalType.Names[alertTab.location]
|
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)
|
alertTab.font_color, alertTab.bg_color)
|
||||||
return alert
|
return alert
|
||||||
|
@ -168,7 +168,7 @@ class Plugin(QtCore.QObject):
|
|||||||
self.mediadock = plugin_helpers[u'toolbox']
|
self.mediadock = plugin_helpers[u'toolbox']
|
||||||
self.pluginManager = plugin_helpers[u'pluginmanager']
|
self.pluginManager = plugin_helpers[u'pluginmanager']
|
||||||
self.formparent = plugin_helpers[u'formparent']
|
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.QObject.connect(Receiver.get_receiver(),
|
||||||
QtCore.SIGNAL(u'%s_add_service_item' % self.name),
|
QtCore.SIGNAL(u'%s_add_service_item' % self.name),
|
||||||
self.processAddServiceEvent)
|
self.processAddServiceEvent)
|
||||||
|
@ -258,12 +258,11 @@ class Renderer(object):
|
|||||||
# we have to render the first virtual slide.
|
# we have to render the first virtual slide.
|
||||||
text_contains_break = u'[---]' in text
|
text_contains_break = u'[---]' in text
|
||||||
if text_contains_break:
|
if text_contains_break:
|
||||||
html_text, text = text.split(u'\n[---]\n', 1)
|
text_to_render, text = text.split(u'\n[---]\n', 1)
|
||||||
else:
|
else:
|
||||||
html_text = text
|
text_to_render = text
|
||||||
text = u''
|
text = u''
|
||||||
lines = expand_tags(html_text)
|
lines = text_to_render.strip(u'\n').split(u'\n')
|
||||||
lines = lines.strip(u'\n').split(u'\n')
|
|
||||||
slides = self._paginate_slide(lines, line_end)
|
slides = self._paginate_slide(lines, line_end)
|
||||||
if len(slides) > 1 and text:
|
if len(slides) > 1 and text:
|
||||||
# Add all slides apart from the last one the
|
# Add all slides apart from the last one the
|
||||||
@ -277,8 +276,7 @@ class Renderer(object):
|
|||||||
else:
|
else:
|
||||||
pages.extend(slides)
|
pages.extend(slides)
|
||||||
if u'[---]' not in text:
|
if u'[---]' not in text:
|
||||||
lines = expand_tags(text)
|
lines = text.strip(u'\n').split(u'\n')
|
||||||
lines = lines.strip(u'\n').split(u'\n')
|
|
||||||
pages.extend(self._paginate_slide(lines, line_end))
|
pages.extend(self._paginate_slide(lines, line_end))
|
||||||
break
|
break
|
||||||
new_pages = []
|
new_pages = []
|
||||||
|
@ -253,7 +253,7 @@ class MainDisplay(Display):
|
|||||||
"""
|
"""
|
||||||
log.debug(u'image to display')
|
log.debug(u'image to display')
|
||||||
image = self.imageManager.get_image_bytes(name)
|
image = self.imageManager.get_image_bytes(name)
|
||||||
self.controller.mediaManager.video_reset(self.controller)
|
self.controller.mediaController.video_reset(self.controller)
|
||||||
self.displayImage(image)
|
self.displayImage(image)
|
||||||
return self.preview()
|
return self.preview()
|
||||||
|
|
||||||
|
@ -148,7 +148,7 @@ class Ui_MainWindow(object):
|
|||||||
self.defaultThemeLabel = QtGui.QLabel(self.statusBar)
|
self.defaultThemeLabel = QtGui.QLabel(self.statusBar)
|
||||||
self.defaultThemeLabel.setObjectName(u'defaultThemeLabel')
|
self.defaultThemeLabel.setObjectName(u'defaultThemeLabel')
|
||||||
self.statusBar.addPermanentWidget(self.defaultThemeLabel)
|
self.statusBar.addPermanentWidget(self.defaultThemeLabel)
|
||||||
# Create the MediaController
|
# Create the MediaManager
|
||||||
self.mediaManagerDock = OpenLPDockWidget(mainWindow,
|
self.mediaManagerDock = OpenLPDockWidget(mainWindow,
|
||||||
u'mediaManagerDock', u':/system/system_mediamanager.png')
|
u'mediaManagerDock', u':/system/system_mediamanager.png')
|
||||||
self.mediaManagerDock.setStyleSheet(MEDIA_MANAGER_STYLE)
|
self.mediaManagerDock.setStyleSheet(MEDIA_MANAGER_STYLE)
|
||||||
@ -557,7 +557,7 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow):
|
|||||||
self.pluginManager = PluginManager(pluginpath)
|
self.pluginManager = PluginManager(pluginpath)
|
||||||
self.pluginHelpers = {}
|
self.pluginHelpers = {}
|
||||||
self.imageManager = ImageManager()
|
self.imageManager = ImageManager()
|
||||||
self.mediaManager = MediaController(self)
|
self.mediaController = MediaController(self)
|
||||||
# Set up the interface
|
# Set up the interface
|
||||||
self.setupUi(self)
|
self.setupUi(self)
|
||||||
# Load settings after setupUi so default UI sizes are overwritten
|
# 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'toolbox'] = self.mediaDockManager
|
||||||
self.pluginHelpers[u'pluginmanager'] = self.pluginManager
|
self.pluginHelpers[u'pluginmanager'] = self.pluginManager
|
||||||
self.pluginHelpers[u'formparent'] = self
|
self.pluginHelpers[u'formparent'] = self
|
||||||
self.pluginHelpers[u'mediacontroller'] = self.mediaManager
|
self.pluginHelpers[u'mediacontroller'] = self.mediaController
|
||||||
self.pluginManager.find_plugins(pluginpath, self.pluginHelpers)
|
self.pluginManager.find_plugins(pluginpath, self.pluginHelpers)
|
||||||
# hook methods have to happen after find_plugins. Find plugins needs
|
# hook methods have to happen after find_plugins. Find plugins needs
|
||||||
# the controllers hence the hooks have moved from setupUI() to here
|
# the controllers hence the hooks have moved from setupUI() to here
|
||||||
|
@ -34,9 +34,189 @@ from openlp.core.ui.media import MediaAPI, MediaState
|
|||||||
|
|
||||||
log = logging.getLogger(__name__)
|
log = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
video_css = u"""
|
||||||
|
#video1 {
|
||||||
|
z-index:3;
|
||||||
|
}
|
||||||
|
#video2 {
|
||||||
|
z-index:3;
|
||||||
|
}
|
||||||
|
"""
|
||||||
|
|
||||||
|
video_js = u"""
|
||||||
|
var video_timer = null;
|
||||||
|
var current_video = '1';
|
||||||
|
|
||||||
|
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 <video>'s, and hiding/
|
||||||
|
// preloading one, and toggle between the two when looping.
|
||||||
|
|
||||||
|
if(current_video=='1'){
|
||||||
|
var vid = document.getElementById('video1');
|
||||||
|
var vid2 = document.getElementById('video2');
|
||||||
|
} else {
|
||||||
|
var vid = document.getElementById('video2');
|
||||||
|
var vid2 = document.getElementById('video1');
|
||||||
|
}
|
||||||
|
if(volume != null){
|
||||||
|
vid.volume = volume;
|
||||||
|
vid2.volume = volume;
|
||||||
|
}
|
||||||
|
switch(state){
|
||||||
|
case 'init':
|
||||||
|
vid.src = path;
|
||||||
|
vid2.src = path;
|
||||||
|
if(loop == null) loop = false;
|
||||||
|
vid.looping = loop;
|
||||||
|
vid2.looping = loop;
|
||||||
|
vid.load();
|
||||||
|
break;
|
||||||
|
case 'load':
|
||||||
|
vid2.style.visibility = 'hidden';
|
||||||
|
vid2.load();
|
||||||
|
break;
|
||||||
|
case 'play':
|
||||||
|
vid.play();
|
||||||
|
//vid.style.visibility = 'visible';
|
||||||
|
if(vid.looping){
|
||||||
|
video_timer = setInterval(
|
||||||
|
function() {
|
||||||
|
show_video('poll');
|
||||||
|
}, 200);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 'pause':
|
||||||
|
if(video_timer!=null){
|
||||||
|
clearInterval(video_timer);
|
||||||
|
video_timer = null;
|
||||||
|
}
|
||||||
|
vid.pause();
|
||||||
|
break;
|
||||||
|
case 'stop':
|
||||||
|
show_video('pause');
|
||||||
|
break;
|
||||||
|
case 'poll':
|
||||||
|
if(vid.ended||vid.currentTime+0.2>vid.duration)
|
||||||
|
show_video('swap');
|
||||||
|
break;
|
||||||
|
case 'swap':
|
||||||
|
show_video('pause');
|
||||||
|
if(current_video=='1')
|
||||||
|
current_video = '2';
|
||||||
|
else
|
||||||
|
current_video = '1';
|
||||||
|
show_video('play');
|
||||||
|
show_video('load');
|
||||||
|
break;
|
||||||
|
case 'close':
|
||||||
|
show_video('stop');
|
||||||
|
vid.src = '';
|
||||||
|
vid2.src = '';
|
||||||
|
break;
|
||||||
|
case 'length':
|
||||||
|
return vid.duration;
|
||||||
|
case 'currentTime':
|
||||||
|
return vid.currentTime;
|
||||||
|
case 'seek':
|
||||||
|
// doesnt work currently
|
||||||
|
//vid.currentTime = varVal;
|
||||||
|
break;
|
||||||
|
case 'setVisible':
|
||||||
|
vid.style.visibility = varVal;
|
||||||
|
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])
|
||||||
|
{
|
||||||
|
return window.document[movieName];
|
||||||
|
}
|
||||||
|
if (document.embeds && document.embeds[movieName])
|
||||||
|
return document.embeds[movieName];
|
||||||
|
}
|
||||||
|
|
||||||
|
function show_flash(state, path, volume, varVal){
|
||||||
|
var text = document.getElementById('flash');
|
||||||
|
var flashMovie = getFlashMovieObject("OpenLPFlashMovie");
|
||||||
|
var src = "src = 'file:///" + path + "'";
|
||||||
|
var view_parm = " wmode='opaque'" +
|
||||||
|
" width='100%%'" +
|
||||||
|
" height='100%%'";
|
||||||
|
var swf_parm = " name='OpenLPFlashMovie'" +
|
||||||
|
" autostart='true' loop='false' play='true'" +
|
||||||
|
" hidden='false' swliveconnect='true' allowscriptaccess='always'" +
|
||||||
|
" volume='" + volume + "'";
|
||||||
|
|
||||||
|
switch(state){
|
||||||
|
case 'load':
|
||||||
|
text.innerHTML = "<embed " + src + view_parm + swf_parm + "/>";
|
||||||
|
flashMovie = getFlashMovieObject("OpenLPFlashMovie");
|
||||||
|
flashMovie.Play();
|
||||||
|
break;
|
||||||
|
case 'play':
|
||||||
|
flashMovie.Play();
|
||||||
|
break;
|
||||||
|
case 'pause':
|
||||||
|
flashMovie.StopPlay();
|
||||||
|
break;
|
||||||
|
case 'stop':
|
||||||
|
flashMovie.StopPlay();
|
||||||
|
tempHtml = text.innerHTML;
|
||||||
|
text.innerHTML = '';
|
||||||
|
text.innerHTML = tempHtml;
|
||||||
|
break;
|
||||||
|
case 'close':
|
||||||
|
flashMovie.StopPlay();
|
||||||
|
text.innerHTML = '';
|
||||||
|
break;
|
||||||
|
case 'length':
|
||||||
|
return flashMovie.TotalFrames();
|
||||||
|
case 'currentTime':
|
||||||
|
return flashMovie.CurrentFrame();
|
||||||
|
case 'seek':
|
||||||
|
// flashMovie.GotoFrame(varVal);
|
||||||
|
break;
|
||||||
|
case 'setVisible':
|
||||||
|
text.style.visibility = varVal;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
"""
|
||||||
|
|
||||||
|
flash_html = u"""
|
||||||
|
<div id="flash" class="size" style="visibility:hidden"></div>
|
||||||
|
"""
|
||||||
|
|
||||||
class WebkitAPI(MediaAPI):
|
class WebkitAPI(MediaAPI):
|
||||||
"""
|
"""
|
||||||
A specialised version of the MediaAPI class,
|
A specialised version of the MediaAPI class,
|
||||||
which provides a QtWebKit display.
|
which provides a QtWebKit display.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
@ -68,7 +248,8 @@ class WebkitAPI(MediaAPI):
|
|||||||
, u'*.mp4'
|
, u'*.mp4'
|
||||||
, u'*.ogv'
|
, u'*.ogv'
|
||||||
, u'*.webm'
|
, u'*.webm'
|
||||||
, u'*.swf', u'*.mpg', u'*.wmv', u'*.mpeg', u'*.avi'
|
, u'*.mpg', u'*.wmv', u'*.mpeg', u'*.avi'
|
||||||
|
, u'*.swf'
|
||||||
]
|
]
|
||||||
|
|
||||||
def setup_controls(self, controller, control_panel):
|
def setup_controls(self, controller, control_panel):
|
||||||
@ -79,190 +260,21 @@ class WebkitAPI(MediaAPI):
|
|||||||
"""
|
"""
|
||||||
Add css style sheets to htmlbuilder
|
Add css style sheets to htmlbuilder
|
||||||
"""
|
"""
|
||||||
css = u'''
|
return video_css + flash_css
|
||||||
#video1 {
|
|
||||||
z-index:3;
|
|
||||||
}
|
|
||||||
#video2 {
|
|
||||||
z-index:3;
|
|
||||||
}
|
|
||||||
#flash {
|
|
||||||
z-index:4;
|
|
||||||
}
|
|
||||||
'''
|
|
||||||
return css
|
|
||||||
|
|
||||||
|
|
||||||
def get_media_display_javascript(self):
|
def get_media_display_javascript(self):
|
||||||
"""
|
"""
|
||||||
Add javascript functions to htmlbuilder
|
Add javascript functions to htmlbuilder
|
||||||
"""
|
"""
|
||||||
js = u'''
|
return video_js + flash_js
|
||||||
var video_timer = null;
|
|
||||||
var current_video = '1';
|
|
||||||
|
|
||||||
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 <video>'s, and hiding/
|
|
||||||
// preloading one, and toggle between the two when looping.
|
|
||||||
|
|
||||||
if(current_video=='1'){
|
|
||||||
var vid = document.getElementById('video1');
|
|
||||||
var vid2 = document.getElementById('video2');
|
|
||||||
} else {
|
|
||||||
var vid = document.getElementById('video2');
|
|
||||||
var vid2 = document.getElementById('video1');
|
|
||||||
}
|
|
||||||
if(volume != null){
|
|
||||||
vid.volume = volume;
|
|
||||||
vid2.volume = volume;
|
|
||||||
}
|
|
||||||
switch(state){
|
|
||||||
case 'init':
|
|
||||||
vid.src = path;
|
|
||||||
vid2.src = path;
|
|
||||||
if(loop == null) loop = false;
|
|
||||||
vid.looping = loop;
|
|
||||||
vid2.looping = loop;
|
|
||||||
vid.load();
|
|
||||||
break;
|
|
||||||
case 'load':
|
|
||||||
vid2.style.visibility = 'hidden';
|
|
||||||
vid2.load();
|
|
||||||
break;
|
|
||||||
case 'play':
|
|
||||||
vid.play();
|
|
||||||
//vid.style.visibility = 'visible';
|
|
||||||
if(vid.looping){
|
|
||||||
video_timer = setInterval(
|
|
||||||
function() {
|
|
||||||
show_video('poll');
|
|
||||||
}, 200);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case 'pause':
|
|
||||||
if(video_timer!=null){
|
|
||||||
clearInterval(video_timer);
|
|
||||||
video_timer = null;
|
|
||||||
}
|
|
||||||
vid.pause();
|
|
||||||
break;
|
|
||||||
case 'stop':
|
|
||||||
show_video('pause');
|
|
||||||
break;
|
|
||||||
case 'poll':
|
|
||||||
if(vid.ended||vid.currentTime+0.2>vid.duration)
|
|
||||||
show_video('swap');
|
|
||||||
break;
|
|
||||||
case 'swap':
|
|
||||||
show_video('pause');
|
|
||||||
if(current_video=='1')
|
|
||||||
current_video = '2';
|
|
||||||
else
|
|
||||||
current_video = '1';
|
|
||||||
show_video('play');
|
|
||||||
show_video('load');
|
|
||||||
break;
|
|
||||||
case 'close':
|
|
||||||
show_video('stop');
|
|
||||||
vid.src = '';
|
|
||||||
vid2.src = '';
|
|
||||||
break;
|
|
||||||
case 'length':
|
|
||||||
return vid.duration;
|
|
||||||
case 'currentTime':
|
|
||||||
return vid.currentTime;
|
|
||||||
case 'seek':
|
|
||||||
// doesnt work currently
|
|
||||||
//vid.currentTime = varVal;
|
|
||||||
break;
|
|
||||||
case 'setVisible':
|
|
||||||
vid.style.visibility = varVal;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function getFlashMovieObject(movieName)
|
|
||||||
{
|
|
||||||
if (window.document[movieName])
|
|
||||||
{
|
|
||||||
return window.document[movieName];
|
|
||||||
}
|
|
||||||
if (document.embeds && document.embeds[movieName])
|
|
||||||
return document.embeds[movieName];
|
|
||||||
}
|
|
||||||
|
|
||||||
function show_flash(state, path, volume, varVal){
|
|
||||||
var text = document.getElementById('flash');
|
|
||||||
var flashMovie = getFlashMovieObject("OpenLPFlashMovie");
|
|
||||||
var src = "src = 'file:///" + path + "'";
|
|
||||||
var view_parm = " wmode='opaque'" +
|
|
||||||
" width='100%%'" +
|
|
||||||
" height='100%%'";
|
|
||||||
var swf_parm = " name='OpenLPFlashMovie'" +
|
|
||||||
" autostart='true' loop='false' play='true'" +
|
|
||||||
" hidden='false' swliveconnect='true' allowscriptaccess='always'" +
|
|
||||||
" volume='" + volume + "'";
|
|
||||||
|
|
||||||
switch(state){
|
|
||||||
case 'load':
|
|
||||||
text.innerHTML = "<embed " + src + view_parm + swf_parm + "/>";
|
|
||||||
flashMovie = getFlashMovieObject("OpenLPFlashMovie");
|
|
||||||
flashMovie.Play();
|
|
||||||
break;
|
|
||||||
case 'play':
|
|
||||||
flashMovie.Play();
|
|
||||||
break;
|
|
||||||
case 'pause':
|
|
||||||
flashMovie.StopPlay();
|
|
||||||
break;
|
|
||||||
case 'stop':
|
|
||||||
flashMovie.StopPlay();
|
|
||||||
tempHtml = text.innerHTML;
|
|
||||||
text.innerHTML = '';
|
|
||||||
text.innerHTML = tempHtml;
|
|
||||||
break;
|
|
||||||
case 'close':
|
|
||||||
flashMovie.StopPlay();
|
|
||||||
text.innerHTML = '';
|
|
||||||
break;
|
|
||||||
case 'length':
|
|
||||||
return flashMovie.TotalFrames();
|
|
||||||
case 'currentTime':
|
|
||||||
return flashMovie.CurrentFrame();
|
|
||||||
case 'seek':
|
|
||||||
// flashMovie.GotoFrame(varVal);
|
|
||||||
break;
|
|
||||||
case 'setVisible':
|
|
||||||
text.style.visibility = varVal;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
'''
|
|
||||||
return js
|
|
||||||
|
|
||||||
|
|
||||||
def get_media_display_html(self):
|
def get_media_display_html(self):
|
||||||
"""
|
"""
|
||||||
Add html code to htmlbuilder
|
Add html code to htmlbuilder
|
||||||
"""
|
"""
|
||||||
html = u'''
|
return video_html + flash_html
|
||||||
<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
|
|
||||||
|
|
||||||
def setup(self, display):
|
def setup(self, display):
|
||||||
display.webView.resize(display.size())
|
display.webView.resize(display.size())
|
||||||
|
@ -85,7 +85,7 @@ class SlideController(Controller):
|
|||||||
self.ratio = float(self.screens.current[u'size'].width()) / \
|
self.ratio = float(self.screens.current[u'size'].width()) / \
|
||||||
float(self.screens.current[u'size'].height())
|
float(self.screens.current[u'size'].height())
|
||||||
self.imageManager = self.parent().imageManager
|
self.imageManager = self.parent().imageManager
|
||||||
self.mediaManager = self.parent().mediaManager
|
self.mediaController = self.parent().mediaController
|
||||||
self.loopList = [
|
self.loopList = [
|
||||||
u'Play Slides Menu',
|
u'Play Slides Menu',
|
||||||
u'Loop Separator',
|
u'Loop Separator',
|
||||||
@ -253,7 +253,7 @@ class SlideController(Controller):
|
|||||||
self.onEditSong)
|
self.onEditSong)
|
||||||
self.controllerLayout.addWidget(self.toolbar)
|
self.controllerLayout.addWidget(self.toolbar)
|
||||||
# Build the Media Toolbar
|
# Build the Media Toolbar
|
||||||
self.mediaManager.add_controller_items(self, self.controllerLayout)
|
self.mediaController.add_controller_items(self, self.controllerLayout)
|
||||||
if self.isLive:
|
if self.isLive:
|
||||||
# Build the Song Toolbar
|
# Build the Song Toolbar
|
||||||
self.songMenu = QtGui.QToolButton(self.toolbar)
|
self.songMenu = QtGui.QToolButton(self.toolbar)
|
||||||
@ -390,7 +390,7 @@ class SlideController(Controller):
|
|||||||
|
|
||||||
def liveEscape(self):
|
def liveEscape(self):
|
||||||
self.display.setVisible(False)
|
self.display.setVisible(False)
|
||||||
Receiver.send_message('Media Stop', [self])
|
self.mediaController.video_stop([self])
|
||||||
|
|
||||||
def servicePrevious(self):
|
def servicePrevious(self):
|
||||||
time.sleep(0.1)
|
time.sleep(0.1)
|
||||||
@ -417,10 +417,10 @@ class SlideController(Controller):
|
|||||||
# The SlidePreview's ratio.
|
# The SlidePreview's ratio.
|
||||||
self.ratio = float(self.screens.current[u'size'].width()) / \
|
self.ratio = float(self.screens.current[u'size'].width()) / \
|
||||||
float(self.screens.current[u'size'].height())
|
float(self.screens.current[u'size'].height())
|
||||||
self.mediaManager.setup_display(self.display)
|
self.mediaController.setup_display(self.display)
|
||||||
self.previewSizeChanged()
|
self.previewSizeChanged()
|
||||||
self.previewDisplay.setup()
|
self.previewDisplay.setup()
|
||||||
self.mediaManager.setup_display(self.previewDisplay)
|
self.mediaController.setup_display(self.previewDisplay)
|
||||||
if self.serviceItem:
|
if self.serviceItem:
|
||||||
self.refreshServiceItem()
|
self.refreshServiceItem()
|
||||||
|
|
||||||
@ -519,7 +519,6 @@ class SlideController(Controller):
|
|||||||
# See bug #791050
|
# See bug #791050
|
||||||
self.previousItem.setVisible(True)
|
self.previousItem.setVisible(True)
|
||||||
self.nextItem.setVisible(True)
|
self.nextItem.setVisible(True)
|
||||||
self.toolbar.show()
|
|
||||||
self.toolbar.show()
|
self.toolbar.show()
|
||||||
|
|
||||||
def enablePreviewToolBar(self, item):
|
def enablePreviewToolBar(self, item):
|
||||||
@ -1148,8 +1147,8 @@ class SlideController(Controller):
|
|||||||
"""
|
"""
|
||||||
log.debug(u'SlideController onMediaStart')
|
log.debug(u'SlideController onMediaStart')
|
||||||
file = os.path.join(item.get_frame_path(), item.get_frame_title())
|
file = os.path.join(item.get_frame_path(), item.get_frame_title())
|
||||||
self.mediaManager.video(self, file, False, False)
|
self.mediaController.video(self, file, False, False)
|
||||||
if not self.isLive or self.mediaManager.withLivePreview:
|
if not self.isLive or self.mediaController.withLivePreview:
|
||||||
self.previewDisplay.show()
|
self.previewDisplay.show()
|
||||||
self.slidePreview.hide()
|
self.slidePreview.hide()
|
||||||
|
|
||||||
@ -1158,7 +1157,7 @@ class SlideController(Controller):
|
|||||||
Respond to a request to close the Video
|
Respond to a request to close the Video
|
||||||
"""
|
"""
|
||||||
log.debug(u'SlideController onMediaClose')
|
log.debug(u'SlideController onMediaClose')
|
||||||
self.mediaManager.video_reset(self)
|
self.mediaController.video_reset(self)
|
||||||
self.previewDisplay.hide()
|
self.previewDisplay.hide()
|
||||||
self.slidePreview.show()
|
self.slidePreview.show()
|
||||||
|
|
||||||
|
@ -56,14 +56,14 @@ class MediaMediaItem(MediaManagerItem):
|
|||||||
self.mediaObject = None
|
self.mediaObject = None
|
||||||
self.mediaController = Controller(parent)
|
self.mediaController = Controller(parent)
|
||||||
self.mediaController.controllerLayout = QtGui.QVBoxLayout()
|
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.mediaController.controllerLayout)
|
||||||
self.plugin.mediaManager.set_controls_visible(self.mediaController, \
|
self.plugin.mediaController.set_controls_visible(self.mediaController, \
|
||||||
False)
|
False)
|
||||||
self.mediaController.previewDisplay = Display(self.mediaController, \
|
self.mediaController.previewDisplay = Display(self.mediaController, \
|
||||||
False, self.mediaController, self.plugin.pluginManager.plugins)
|
False, self.mediaController, self.plugin.pluginManager.plugins)
|
||||||
self.mediaController.previewDisplay.setup()
|
self.mediaController.previewDisplay.setup()
|
||||||
self.plugin.mediaManager.setup_display( \
|
self.plugin.mediaController.setup_display( \
|
||||||
self.mediaController.previewDisplay)
|
self.mediaController.previewDisplay)
|
||||||
self.mediaController.previewDisplay.hide()
|
self.mediaController.previewDisplay.hide()
|
||||||
|
|
||||||
@ -106,7 +106,7 @@ class MediaMediaItem(MediaManagerItem):
|
|||||||
"""
|
"""
|
||||||
Called to reset the Live background with the media selected,
|
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.plugin.liveController)
|
||||||
self.resetAction.setVisible(False)
|
self.resetAction.setVisible(False)
|
||||||
|
|
||||||
@ -126,7 +126,7 @@ class MediaMediaItem(MediaManagerItem):
|
|||||||
item = self.listView.currentItem()
|
item = self.listView.currentItem()
|
||||||
filename = unicode(item.data(QtCore.Qt.UserRole).toString())
|
filename = unicode(item.data(QtCore.Qt.UserRole).toString())
|
||||||
if os.path.exists(filename):
|
if os.path.exists(filename):
|
||||||
if self.plugin.liveController.mediaManager.video( \
|
if self.plugin.liveController.mediaController.video( \
|
||||||
self.plugin.liveController, filename, True, True):
|
self.plugin.liveController, filename, True, True):
|
||||||
self.resetAction.setVisible(True)
|
self.resetAction.setVisible(True)
|
||||||
else:
|
else:
|
||||||
@ -153,11 +153,11 @@ class MediaMediaItem(MediaManagerItem):
|
|||||||
'The file %s no longer exists.')) % filename)
|
'The file %s no longer exists.')) % filename)
|
||||||
return False
|
return False
|
||||||
self.mediaLength = 0
|
self.mediaLength = 0
|
||||||
if self.plugin.mediaManager.video( \
|
if self.plugin.mediaController.video( \
|
||||||
self.mediaController, filename, False, False):
|
self.mediaController, filename, False, False):
|
||||||
self.mediaLength = self.mediaController.media_info.length
|
self.mediaLength = self.mediaController.media_info.length
|
||||||
service_item.media_length = self.mediaLength
|
service_item.media_length = self.mediaLength
|
||||||
self.plugin.mediaManager.video_reset(self.mediaController)
|
self.plugin.mediaController.video_reset(self.mediaController)
|
||||||
if self.mediaLength > 0:
|
if self.mediaLength > 0:
|
||||||
service_item.add_capability(
|
service_item.add_capability(
|
||||||
ItemCapabilities.AllowsVariableStartTime)
|
ItemCapabilities.AllowsVariableStartTime)
|
||||||
|
@ -45,11 +45,11 @@ class MediaPlugin(Plugin):
|
|||||||
# passed with drag and drop messages
|
# passed with drag and drop messages
|
||||||
self.dnd_id = u'Media'
|
self.dnd_id = u'Media'
|
||||||
self.audio_extensions_list = \
|
self.audio_extensions_list = \
|
||||||
self.mediaManager.get_audio_extensions_list()
|
self.mediaController.get_audio_extensions_list()
|
||||||
for ext in self.audio_extensions_list:
|
for ext in self.audio_extensions_list:
|
||||||
self.serviceManager.supportedSuffixes(ext[2:])
|
self.serviceManager.supportedSuffixes(ext[2:])
|
||||||
self.video_extensions_list = \
|
self.video_extensions_list = \
|
||||||
self.mediaManager.get_video_extensions_list()
|
self.mediaController.get_video_extensions_list()
|
||||||
for ext in self.video_extensions_list:
|
for ext in self.video_extensions_list:
|
||||||
self.serviceManager.supportedSuffixes(ext[2:])
|
self.serviceManager.supportedSuffixes(ext[2:])
|
||||||
|
|
||||||
@ -59,7 +59,7 @@ class MediaPlugin(Plugin):
|
|||||||
"""
|
"""
|
||||||
visible_name = self.getString(StringContent.VisibleName)
|
visible_name = self.getString(StringContent.VisibleName)
|
||||||
return MediaTab(parent, self.name, visible_name[u'title'],
|
return MediaTab(parent, self.name, visible_name[u'title'],
|
||||||
self.mediaManager.APIs, self.icon_path)
|
self.mediaController.APIs, self.icon_path)
|
||||||
|
|
||||||
def about(self):
|
def about(self):
|
||||||
about_text = translate('MediaPlugin', '<strong>Media Plugin</strong>'
|
about_text = translate('MediaPlugin', '<strong>Media Plugin</strong>'
|
||||||
@ -98,23 +98,23 @@ class MediaPlugin(Plugin):
|
|||||||
Time to tidy up on exit
|
Time to tidy up on exit
|
||||||
"""
|
"""
|
||||||
log.info(u'Media Finalising')
|
log.info(u'Media Finalising')
|
||||||
self.mediaManager.finalise()
|
self.mediaController.finalise()
|
||||||
Plugin.finalise(self)
|
Plugin.finalise(self)
|
||||||
|
|
||||||
def getDisplayCss(self):
|
def getDisplayCss(self):
|
||||||
"""
|
"""
|
||||||
Add css style sheets to htmlbuilder
|
Add css style sheets to htmlbuilder
|
||||||
"""
|
"""
|
||||||
return self.mediaManager.get_media_display_css()
|
return self.mediaController.get_media_display_css()
|
||||||
|
|
||||||
def getDisplayJavaScript(self):
|
def getDisplayJavaScript(self):
|
||||||
"""
|
"""
|
||||||
Add javascript functions to htmlbuilder
|
Add javascript functions to htmlbuilder
|
||||||
"""
|
"""
|
||||||
return self.mediaManager.get_media_display_javascript()
|
return self.mediaController.get_media_display_javascript()
|
||||||
|
|
||||||
def getDisplayHtml(self):
|
def getDisplayHtml(self):
|
||||||
"""
|
"""
|
||||||
Add html code to htmlbuilder
|
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