mirror of https://gitlab.com/openlp/openlp.git
r2151 + conflicts
This commit is contained in:
commit
e762e3b672
|
@ -173,6 +173,7 @@ class OpenLP(QtGui.QApplication):
|
|||
return False
|
||||
|
||||
def hookException(self, exctype, value, traceback):
|
||||
print ''.join(format_exception(exctype, value, traceback))
|
||||
if not hasattr(self, u'mainWindow'):
|
||||
log.exception(''.join(format_exception(exctype, value, traceback)))
|
||||
return
|
||||
|
|
|
@ -34,7 +34,6 @@ import logging
|
|||
import os
|
||||
from urllib import quote_plus as urlquote
|
||||
|
||||
from PyQt4 import QtCore
|
||||
from sqlalchemy import Table, MetaData, Column, types, create_engine
|
||||
from sqlalchemy.exc import SQLAlchemyError, InvalidRequestError, DBAPIError, OperationalError
|
||||
from sqlalchemy.orm import scoped_session, sessionmaker, mapper
|
||||
|
|
|
@ -31,8 +31,6 @@ Provide HTML Tag management and Formatting Tag access class
|
|||
"""
|
||||
import cPickle
|
||||
|
||||
from PyQt4 import QtCore
|
||||
|
||||
from openlp.core.lib import translate, Settings
|
||||
|
||||
class FormattingTags(object):
|
||||
|
|
|
@ -37,7 +37,7 @@ import logging
|
|||
import os
|
||||
import uuid
|
||||
|
||||
from PyQt4 import QtCore, QtGui
|
||||
from PyQt4 import QtGui
|
||||
|
||||
from openlp.core.lib import build_icon, clean_tags, expand_tags, translate, ImageSource, Settings
|
||||
|
||||
|
@ -184,6 +184,7 @@ class ServiceItem(object):
|
|||
self.theme_overwritten = False
|
||||
self.temporary_edit = False
|
||||
self.will_auto_start = False
|
||||
self.has_original_files = True
|
||||
self._new_item()
|
||||
|
||||
def _new_item(self):
|
||||
|
@ -192,6 +193,7 @@ class ServiceItem(object):
|
|||
service items to see if they are the same.
|
||||
"""
|
||||
self._uuid = unicode(uuid.uuid1())
|
||||
self.validate_item()
|
||||
|
||||
def add_capability(self, capability):
|
||||
"""
|
||||
|
@ -397,6 +399,7 @@ class ServiceItem(object):
|
|||
self.end_time = header.get(u'end_time', 0)
|
||||
self.media_length = header.get(u'media_length', 0)
|
||||
self.will_auto_start = header.get(u'will_auto_start', False)
|
||||
self.has_original_files = True
|
||||
if u'background_audio' in header:
|
||||
self.background_audio = []
|
||||
for filename in header[u'background_audio']:
|
||||
|
@ -410,6 +413,7 @@ class ServiceItem(object):
|
|||
settingsSection = serviceitem[u'serviceitem'][u'header'][u'name']
|
||||
background = QtGui.QColor(Settings().value(settingsSection + u'/background color', u'#000000'))
|
||||
if path:
|
||||
self.has_original_files = False
|
||||
for text_image in serviceitem[u'serviceitem'][u'data']:
|
||||
filename = os.path.join(path, text_image)
|
||||
self.add_from_image(filename, text_image, background)
|
||||
|
@ -419,6 +423,7 @@ class ServiceItem(object):
|
|||
elif self.service_item_type == ServiceItemType.Command:
|
||||
for text_image in serviceitem[u'serviceitem'][u'data']:
|
||||
if path:
|
||||
self.has_original_files = False
|
||||
self.add_from_command(path, text_image[u'title'], text_image[u'image'])
|
||||
else:
|
||||
self.add_from_command(text_image[u'path'], text_image[u'title'], text_image[u'image'])
|
||||
|
@ -609,8 +614,25 @@ class ServiceItem(object):
|
|||
if self.get_frame_path(frame=frame) in invalid_paths:
|
||||
self.remove_frame(frame)
|
||||
|
||||
def validate(self):
|
||||
def missing_frames(self):
|
||||
"""
|
||||
Validates this service item
|
||||
Returns if there are any frames in the service item
|
||||
"""
|
||||
return bool(self._raw_frames)
|
||||
return not bool(self._raw_frames)
|
||||
|
||||
def validate_item(self, suffix_list=None):
|
||||
"""
|
||||
Validates a service item to make sure it is valid
|
||||
"""
|
||||
self.is_valid = True
|
||||
for frame in self._raw_frames:
|
||||
if self.is_image() and not os.path.exists((frame[u'path'])):
|
||||
self.is_valid = False
|
||||
elif self.is_command():
|
||||
file = os.path.join(frame[u'path'],frame[u'title'])
|
||||
if not os.path.exists(file):
|
||||
self.is_valid = False
|
||||
if suffix_list and not self.is_text():
|
||||
type = frame[u'title'].split(u'.')[-1]
|
||||
if type.lower() not in suffix_list:
|
||||
self.is_valid = False
|
||||
|
|
|
@ -29,9 +29,7 @@
|
|||
"""
|
||||
The :mod:`ui` module provides the core user interface for OpenLP
|
||||
"""
|
||||
from PyQt4 import QtGui
|
||||
|
||||
from openlp.core.lib import translate
|
||||
|
||||
|
||||
class HideMode(object):
|
||||
|
|
|
@ -29,7 +29,7 @@
|
|||
|
||||
from PyQt4 import QtCore, QtGui
|
||||
|
||||
from openlp.core.lib import translate, build_icon
|
||||
from openlp.core.lib import translate
|
||||
from openlp.core.lib.ui import create_button, create_button_box
|
||||
|
||||
class Ui_ExceptionDialog(object):
|
||||
|
|
|
@ -29,19 +29,49 @@
|
|||
|
||||
import logging
|
||||
import os
|
||||
import sys
|
||||
import datetime
|
||||
from PyQt4 import QtCore, QtGui
|
||||
|
||||
from openlp.core.lib import OpenLPToolbar, Receiver, translate, Settings, UiStrings
|
||||
from openlp.core.lib.ui import critical_error_message_box
|
||||
from openlp.core.ui.media import MediaState, MediaInfo, MediaType, \
|
||||
get_media_players, set_media_players
|
||||
from openlp.core.ui.media import MediaState, MediaInfo, MediaType, get_media_players, set_media_players
|
||||
from openlp.core.ui.media.mediaplayer import MediaPlayer
|
||||
from openlp.core.utils import AppLocation
|
||||
from openlp.core.ui import DisplayControllerType
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
class MediaSlider(QtGui.QSlider):
|
||||
"""
|
||||
Allows the mouse events of a slider to be overridden and extra functionality added
|
||||
"""
|
||||
def __init__(self, direction, manager, controller, parent=None):
|
||||
QtGui.QSlider.__init__(self, direction)
|
||||
self.manager = manager
|
||||
self.controller = controller
|
||||
|
||||
def mouseMoveEvent(self, event):
|
||||
"""
|
||||
Override event to allow hover time to be displayed.
|
||||
"""
|
||||
timevalue = QtGui.QStyle.sliderValueFromPosition(self.minimum(), self.maximum(), event.x(), self.width())
|
||||
self.setToolTip(u'%s' % datetime.timedelta(seconds=int(timevalue/1000)))
|
||||
QtGui.QSlider.mouseMoveEvent(self, event)
|
||||
|
||||
def mousePressEvent(self, event):
|
||||
"""
|
||||
Mouse Press event no new functionality
|
||||
"""
|
||||
QtGui.QSlider.mousePressEvent(self, event)
|
||||
|
||||
def mouseReleaseEvent(self, event):
|
||||
"""
|
||||
Set the slider position when the mouse is clicked and released on the slider.
|
||||
"""
|
||||
self.setValue(QtGui.QStyle.sliderValueFromPosition(self.minimum(), self.maximum(), event.x(), self.width()))
|
||||
QtGui.QSlider.mouseReleaseEvent(self, event)
|
||||
|
||||
|
||||
class MediaController(object):
|
||||
"""
|
||||
The implementation of the Media Controller. The Media Controller adds an own
|
||||
|
@ -69,8 +99,8 @@ class MediaController(object):
|
|||
QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'playbackPlay'), self.media_play_msg)
|
||||
QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'playbackPause'), self.media_pause_msg)
|
||||
QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'playbackStop'), self.media_stop_msg)
|
||||
QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'seekSlider'), self.media_seek)
|
||||
QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'volumeSlider'), self.media_volume)
|
||||
QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'seekSlider'), self.media_seek_msg)
|
||||
QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'volumeSlider'), self.media_volume_msg)
|
||||
QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'media_hide'), self.media_hide)
|
||||
QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'media_blank'), self.media_blank)
|
||||
QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'media_unblank'), self.media_unblank)
|
||||
|
@ -241,9 +271,10 @@ class MediaController(object):
|
|||
icon=u':/slides/media_playback_stop.png',
|
||||
tooltip=translate('OpenLP.SlideController', 'Stop playing media.'), triggers=controller.sendToPlugins)
|
||||
# Build the seekSlider.
|
||||
controller.seekSlider = QtGui.QSlider(QtCore.Qt.Horizontal)
|
||||
controller.seekSlider = MediaSlider(QtCore.Qt.Horizontal, self, controller)
|
||||
controller.seekSlider.setMaximum(1000)
|
||||
controller.seekSlider.setTracking(False)
|
||||
controller.seekSlider.setTracking(True)
|
||||
controller.seekSlider.setMouseTracking(True)
|
||||
controller.seekSlider.setToolTip(translate('OpenLP.SlideController', 'Video position.'))
|
||||
controller.seekSlider.setGeometry(QtCore.QRect(90, 260, 221, 24))
|
||||
controller.seekSlider.setObjectName(u'seekSlider')
|
||||
|
@ -344,12 +375,8 @@ class MediaController(object):
|
|||
# stop running videos
|
||||
self.media_reset(controller)
|
||||
controller.media_info = MediaInfo()
|
||||
if videoBehindText:
|
||||
controller.media_info.volume = 0
|
||||
controller.media_info.is_background = True
|
||||
else:
|
||||
controller.media_info.volume = controller.volumeSlider.value()
|
||||
controller.media_info.is_background = False
|
||||
controller.media_info.volume = controller.volumeSlider.value()
|
||||
controller.media_info.is_background = videoBehindText
|
||||
controller.media_info.file_info = QtCore.QFileInfo(serviceItem.get_frame_path())
|
||||
display = self._define_display(controller)
|
||||
if controller.isLive:
|
||||
|
@ -361,7 +388,7 @@ class MediaController(object):
|
|||
controller.media_info.start_time = 0
|
||||
controller.media_info.end_time = 0
|
||||
else:
|
||||
controller.media_info.start_time = display.serviceItem.start_time
|
||||
controller.media_info.start_time = serviceItem.start_time
|
||||
controller.media_info.end_time = serviceItem.end_time
|
||||
elif controller.previewDisplay:
|
||||
isValid = self._check_file_type(controller, display, serviceItem)
|
||||
|
@ -483,9 +510,17 @@ class MediaController(object):
|
|||
The controller to be played
|
||||
"""
|
||||
log.debug(u'media_play')
|
||||
controller.seekSlider.blockSignals(True)
|
||||
controller.volumeSlider.blockSignals(True)
|
||||
display = self._define_display(controller)
|
||||
if not self.currentMediaPlayer[controller.controllerType].play(display):
|
||||
controller.seekSlider.blockSignals(False)
|
||||
controller.volumeSlider.blockSignals(False)
|
||||
return False
|
||||
if controller.media_info.is_background:
|
||||
self.media_volume(controller, 0)
|
||||
else:
|
||||
self.media_volume(controller, controller.media_info.volume)
|
||||
if status:
|
||||
display.frame.evaluateJavaScript(u'show_blank("desktop");')
|
||||
self.currentMediaPlayer[controller.controllerType].set_visible(display, True)
|
||||
|
@ -503,6 +538,8 @@ class MediaController(object):
|
|||
# Start Timer for ui updates
|
||||
if not self.timer.isActive():
|
||||
self.timer.start()
|
||||
controller.seekSlider.blockSignals(False)
|
||||
controller.volumeSlider.blockSignals(False)
|
||||
return True
|
||||
|
||||
def media_pause_msg(self, msg):
|
||||
|
@ -557,7 +594,7 @@ class MediaController(object):
|
|||
controller.mediabar.actions[u'playbackStop'].setVisible(False)
|
||||
controller.mediabar.actions[u'playbackPause'].setVisible(False)
|
||||
|
||||
def media_volume(self, msg):
|
||||
def media_volume_msg(self, msg):
|
||||
"""
|
||||
Changes the volume of a running video
|
||||
|
||||
|
@ -566,11 +603,21 @@ class MediaController(object):
|
|||
"""
|
||||
controller = msg[0]
|
||||
vol = msg[1][0]
|
||||
log.debug(u'media_volume %d' % vol)
|
||||
display = self._define_display(controller)
|
||||
self.currentMediaPlayer[controller.controllerType].volume(display, vol)
|
||||
self.media_volume(controller, vol)
|
||||
|
||||
def media_seek(self, msg):
|
||||
def media_volume(self, controller, volume):
|
||||
"""
|
||||
Changes the volume of a running video
|
||||
|
||||
``msg``
|
||||
First element is the controller which should be used
|
||||
"""
|
||||
log.debug(u'media_volume %d' % volume)
|
||||
display = self._define_display(controller)
|
||||
self.currentMediaPlayer[controller.controllerType].volume(display, volume)
|
||||
controller.volumeSlider.setValue(volume)
|
||||
|
||||
def media_seek_msg(self, msg):
|
||||
"""
|
||||
Responds to the request to change the seek Slider of a loaded video
|
||||
|
||||
|
@ -581,6 +628,17 @@ class MediaController(object):
|
|||
log.debug(u'media_seek')
|
||||
controller = msg[0]
|
||||
seekVal = msg[1][0]
|
||||
self.media_seek(controller, seekVal)
|
||||
|
||||
def media_seek(self, controller, seekVal):
|
||||
"""
|
||||
Responds to the request to change the seek Slider of a loaded video
|
||||
|
||||
``msg``
|
||||
First element is the controller which should be used
|
||||
Second element is a list with the seek Value as first element
|
||||
"""
|
||||
log.debug(u'media_seek')
|
||||
display = self._define_display(controller)
|
||||
self.currentMediaPlayer[controller.controllerType].seek(display, seekVal)
|
||||
|
||||
|
@ -610,7 +668,8 @@ class MediaController(object):
|
|||
return
|
||||
controller = self.mainWindow.liveController
|
||||
display = self._define_display(controller)
|
||||
if self.currentMediaPlayer[controller.controllerType].state == MediaState.Playing:
|
||||
if controller.controllerType in self.currentMediaPlayer and \
|
||||
self.currentMediaPlayer[controller.controllerType].state == MediaState.Playing:
|
||||
self.currentMediaPlayer[controller.controllerType].pause(display)
|
||||
self.currentMediaPlayer[controller.controllerType].set_visible(display, False)
|
||||
|
||||
|
|
|
@ -31,7 +31,7 @@ import logging
|
|||
import mimetypes
|
||||
from datetime import datetime
|
||||
|
||||
from PyQt4 import QtCore, QtGui
|
||||
from PyQt4 import QtGui
|
||||
from PyQt4.phonon import Phonon
|
||||
|
||||
from openlp.core.lib import Receiver, translate, Settings
|
||||
|
@ -215,8 +215,9 @@ class PhononPlayer(MediaPlayer):
|
|||
self.stop(display)
|
||||
self.set_visible(display, False)
|
||||
if not controller.seekSlider.isSliderDown():
|
||||
controller.seekSlider.setSliderPosition(
|
||||
display.mediaObject.currentTime())
|
||||
controller.seekSlider.blockSignals(True)
|
||||
controller.seekSlider.setSliderPosition(display.mediaObject.currentTime())
|
||||
controller.seekSlider.blockSignals(False)
|
||||
|
||||
def get_media_display_css(self):
|
||||
"""
|
||||
|
|
|
@ -33,7 +33,7 @@ import logging
|
|||
import os
|
||||
import sys
|
||||
|
||||
from PyQt4 import QtCore, QtGui
|
||||
from PyQt4 import QtGui
|
||||
|
||||
from openlp.core.lib import Receiver, translate, Settings
|
||||
from openlp.core.ui.media import MediaState
|
||||
|
@ -109,6 +109,7 @@ class VlcPlayer(MediaPlayer):
|
|||
|
||||
def setup(self, display):
|
||||
display.vlcWidget = QtGui.QFrame(display)
|
||||
display.vlcWidget.setFrameStyle(QtGui.QFrame.NoFrame)
|
||||
# creating a basic vlc instance
|
||||
command_line_options = u'--no-video-title-show'
|
||||
if not display.hasAudio:
|
||||
|
@ -188,6 +189,7 @@ class VlcPlayer(MediaPlayer):
|
|||
display.vlcMediaPlayer.play()
|
||||
if not self.media_state_wait(display, vlc.State.Playing):
|
||||
return False
|
||||
self.volume(display, controller.media_info.volume)
|
||||
if start_time > 0:
|
||||
self.seek(display, controller.media_info.start_time * 1000)
|
||||
controller.media_info.length = int(display.vlcMediaPlayer.get_media().get_duration() / 1000)
|
||||
|
@ -234,7 +236,9 @@ class VlcPlayer(MediaPlayer):
|
|||
self.stop(display)
|
||||
self.set_visible(display, False)
|
||||
if not controller.seekSlider.isSliderDown():
|
||||
controller.seekSlider.blockSignals(True)
|
||||
controller.seekSlider.setSliderPosition(display.vlcMediaPlayer.get_time())
|
||||
controller.seekSlider.blockSignals(False)
|
||||
|
||||
def get_info(self):
|
||||
return(translate('Media.player', 'VLC is an external player which '
|
||||
|
|
|
@ -423,7 +423,9 @@ class WebkitPlayer(MediaPlayer):
|
|||
controller.media_info.length = length
|
||||
controller.seekSlider.setMaximum(length)
|
||||
if not controller.seekSlider.isSliderDown():
|
||||
controller.seekSlider.blockSignals(True)
|
||||
controller.seekSlider.setSliderPosition(currentTime)
|
||||
controller.seekSlider.blockSignals(False)
|
||||
|
||||
def get_info(self):
|
||||
return(translate('Media.player', 'Webkit is a media player which runs '
|
||||
|
|
|
@ -114,6 +114,7 @@ class ServiceManager(QtGui.QWidget):
|
|||
# is a new service and has not been saved
|
||||
self._modified = False
|
||||
self._fileName = u''
|
||||
self.service_has_all_original_files = True
|
||||
self.serviceNoteForm = ServiceNoteForm(self.mainwindow)
|
||||
self.serviceItemEditForm = ServiceItemEditForm(self.mainwindow)
|
||||
self.startTimeForm = StartTimeForm(self.mainwindow)
|
||||
|
@ -458,7 +459,7 @@ class ServiceManager(QtGui.QWidget):
|
|||
for item in list(self.serviceItems):
|
||||
self.mainwindow.incrementProgressBar()
|
||||
item[u'service_item'].remove_invalid_frames(missing_list)
|
||||
if not item[u'service_item'].validate():
|
||||
if item[u'service_item'].missing_frames():
|
||||
self.serviceItems.remove(item)
|
||||
else:
|
||||
service_item = item[u'service_item'].get_service_repr(self._saveLite)
|
||||
|
@ -616,7 +617,7 @@ class ServiceManager(QtGui.QWidget):
|
|||
path = os.path.join(directory, default_filename)
|
||||
# SaveAs from osz to oszl is not valid as the files will be deleted
|
||||
# on exit which is not sensible or usable in the long term.
|
||||
if self._fileName.endswith(u'oszl') or not self._fileName:
|
||||
if self._fileName.endswith(u'oszl') or self.service_has_all_original_files:
|
||||
fileName = QtGui.QFileDialog.getSaveFileName(self.mainwindow, UiStrings().SaveService, path,
|
||||
translate('OpenLP.ServiceManager',
|
||||
'OpenLP Service Files (*.osz);; OpenLP Service Files - lite (*.oszl)'))
|
||||
|
@ -689,7 +690,7 @@ class ServiceManager(QtGui.QWidget):
|
|||
serviceItem.set_from_service(item)
|
||||
else:
|
||||
serviceItem.set_from_service(item, self.servicePath)
|
||||
self.validateItem(serviceItem)
|
||||
serviceItem.validate_item(self.suffixes)
|
||||
self.load_item_uuid = 0
|
||||
if serviceItem.is_capable(ItemCapabilities.OnLoadUpdate):
|
||||
Receiver.send_message(u'%s_service_load' % serviceItem.name.lower(), serviceItem)
|
||||
|
@ -1028,9 +1029,12 @@ class ServiceManager(QtGui.QWidget):
|
|||
"""
|
||||
# Correct order of items in array
|
||||
count = 1
|
||||
self.service_has_all_original_files = True
|
||||
for item in self.serviceItems:
|
||||
item[u'order'] = count
|
||||
count += 1
|
||||
if not item[u'service_item'].has_original_files:
|
||||
self.service_has_all_original_files = False
|
||||
# Repaint the screen
|
||||
self.serviceManagerList.clear()
|
||||
for itemcount, item in enumerate(self.serviceItems):
|
||||
|
@ -1089,18 +1093,6 @@ class ServiceManager(QtGui.QWidget):
|
|||
self.serviceManagerList.setCurrentItem(treewidgetitem)
|
||||
treewidgetitem.setExpanded(item[u'expanded'])
|
||||
|
||||
def validateItem(self, serviceItem):
|
||||
"""
|
||||
Validates the service item and if the suffix matches an accepted
|
||||
one it allows the item to be displayed.
|
||||
"""
|
||||
#@todo check file items exist
|
||||
if serviceItem.is_command():
|
||||
type = serviceItem._raw_frames[0][u'title'].split(u'.')[-1]
|
||||
if type.lower() not in self.suffixes:
|
||||
serviceItem.is_valid = False
|
||||
#@todo check file items exist
|
||||
|
||||
def cleanUp(self):
|
||||
"""
|
||||
Empties the servicePath of temporary files on system exit.
|
||||
|
@ -1140,7 +1132,7 @@ class ServiceManager(QtGui.QWidget):
|
|||
Receiver.send_message(u'cursor_busy')
|
||||
log.debug(u'regenerateServiceItems')
|
||||
# force reset of renderer as theme data has changed
|
||||
self.mainwindow.renderer.themedata = None
|
||||
self.service_has_all_original_files = True
|
||||
if self.serviceItems:
|
||||
for item in self.serviceItems:
|
||||
item[u'selected'] = False
|
||||
|
|
|
@ -31,7 +31,7 @@ The :mod:`settingsform` provides a user interface for the OpenLP settings
|
|||
"""
|
||||
import logging
|
||||
|
||||
from PyQt4 import QtCore, QtGui
|
||||
from PyQt4 import QtGui
|
||||
|
||||
from openlp.core.lib import Receiver, build_icon, PluginStatus
|
||||
from openlp.core.ui import AdvancedTab, GeneralTab, ThemesTab
|
||||
|
@ -141,4 +141,4 @@ class SettingsForm(QtGui.QDialog, Ui_SettingsDialog):
|
|||
"""
|
||||
if self.resetSuffixes:
|
||||
self.mainWindow.serviceManagerContents.resetSupportedSuffixes()
|
||||
self.resetSuffixes = False
|
||||
self.resetSuffixes = False
|
||||
|
|
|
@ -929,8 +929,7 @@ class SlideController(DisplayController):
|
|||
else:
|
||||
if not self.serviceItem.is_command():
|
||||
Receiver.send_message(u'live_display_show')
|
||||
Receiver.send_message(u'%s_unblank' % self.serviceItem.name.lower(),
|
||||
[self.serviceItem, self.isLive])
|
||||
Receiver.send_message(u'%s_unblank' % self.serviceItem.name.lower(), [self.serviceItem, self.isLive])
|
||||
else:
|
||||
if hide_mode:
|
||||
Receiver.send_message(u'live_display_hide', hide_mode)
|
||||
|
@ -945,13 +944,11 @@ class SlideController(DisplayController):
|
|||
if self.serviceItem is not None:
|
||||
if hide:
|
||||
Receiver.send_message(u'live_display_hide', HideMode.Screen)
|
||||
Receiver.send_message(u'%s_hide' % self.serviceItem.name.lower(),
|
||||
[self.serviceItem, self.isLive])
|
||||
Receiver.send_message(u'%s_hide' % self.serviceItem.name.lower(), [self.serviceItem, self.isLive])
|
||||
else:
|
||||
if not self.serviceItem.is_command():
|
||||
Receiver.send_message(u'live_display_show')
|
||||
Receiver.send_message(u'%s_unblank' % self.serviceItem.name.lower(),
|
||||
[self.serviceItem, self.isLive])
|
||||
Receiver.send_message(u'%s_unblank' % self.serviceItem.name.lower(), [self.serviceItem, self.isLive])
|
||||
else:
|
||||
if hide:
|
||||
Receiver.send_message(u'live_display_hide', HideMode.Screen)
|
||||
|
|
|
@ -29,7 +29,7 @@
|
|||
|
||||
import logging
|
||||
|
||||
from PyQt4 import QtCore, QtGui
|
||||
from PyQt4 import QtGui
|
||||
|
||||
from openlp.core.lib import Plugin, StringContent, build_icon, translate, Settings
|
||||
from openlp.core.lib.ui import create_action, UiStrings
|
||||
|
|
|
@ -34,7 +34,7 @@ import logging
|
|||
import re
|
||||
|
||||
from openlp.core.lib import translate, Settings
|
||||
from openlp.plugins.bibles.lib.db import BiblesResourcesDB
|
||||
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
|
|
|
@ -30,8 +30,6 @@
|
|||
import logging
|
||||
import os
|
||||
|
||||
from PyQt4 import QtCore
|
||||
|
||||
from openlp.core.lib import Receiver, SettingsManager, translate, Settings
|
||||
from openlp.core.utils import AppLocation, delete_file
|
||||
from openlp.plugins.bibles.lib import parse_reference, get_reference_separator, LanguageSelection
|
||||
|
|
|
@ -33,11 +33,12 @@ import os
|
|||
from PyQt4 import QtCore, QtGui
|
||||
|
||||
from openlp.core.lib import MediaManagerItem, build_icon, ItemCapabilities, SettingsManager, translate, \
|
||||
check_item_selected, Receiver, MediaType, ServiceItem, build_html, ServiceItemContext, Settings, UiStrings
|
||||
check_item_selected, Receiver, MediaType, ServiceItem, ServiceItemContext, Settings, UiStrings, \
|
||||
check_directory_exists
|
||||
from openlp.core.lib.ui import critical_error_message_box, create_horizontal_adjusting_combo_box
|
||||
from openlp.core.ui import DisplayController, Display, DisplayControllerType
|
||||
from openlp.core.ui.media import get_media_players, set_media_players
|
||||
from openlp.core.utils import locale_compare
|
||||
from openlp.core.utils import AppLocation, locale_compare
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
|
@ -130,8 +131,7 @@ class MediaMediaItem(MediaManagerItem):
|
|||
"""
|
||||
Called to reset the Live background with the media selected,
|
||||
"""
|
||||
self.plugin.liveController.mediaController.media_reset(
|
||||
self.plugin.liveController)
|
||||
self.plugin.liveController.mediaController.media_reset(self.plugin.liveController)
|
||||
self.resetAction.setVisible(False)
|
||||
|
||||
def videobackgroundReplaced(self):
|
||||
|
@ -145,8 +145,7 @@ class MediaMediaItem(MediaManagerItem):
|
|||
Called to replace Live background with the media selected.
|
||||
"""
|
||||
if check_item_selected(self.listView,
|
||||
translate('MediaPlugin.MediaItem',
|
||||
'You must select a media file to replace the background with.')):
|
||||
translate('MediaPlugin.MediaItem', 'You must select a media file to replace the background with.')):
|
||||
item = self.listView.currentItem()
|
||||
filename = item.data(QtCore.Qt.UserRole)
|
||||
if os.path.exists(filename):
|
||||
|
@ -166,8 +165,8 @@ class MediaMediaItem(MediaManagerItem):
|
|||
translate('MediaPlugin.MediaItem',
|
||||
'There was a problem replacing your background, the media file "%s" no longer exists.') % filename)
|
||||
|
||||
def generateSlideData(self, service_item, item=None, xmlVersion=False,
|
||||
remote=False, context=ServiceItemContext.Live):
|
||||
def generateSlideData(self, service_item, item=None, xmlVersion=False, remote=False,
|
||||
context=ServiceItemContext.Live):
|
||||
if item is None:
|
||||
item = self.listView.currentItem()
|
||||
if item is None:
|
||||
|
@ -201,6 +200,8 @@ class MediaMediaItem(MediaManagerItem):
|
|||
def initialise(self):
|
||||
self.listView.clear()
|
||||
self.listView.setIconSize(QtCore.QSize(88, 50))
|
||||
self.servicePath = os.path.join(AppLocation.get_section_data_path(self.settingsSection), u'thumbnails')
|
||||
check_directory_exists(self.servicePath)
|
||||
self.loadList(Settings().value(self.settingsSection + u'/media files'))
|
||||
self.populateDisplayTypes()
|
||||
|
||||
|
@ -247,8 +248,8 @@ class MediaMediaItem(MediaManagerItem):
|
|||
"""
|
||||
Remove a media item from the list.
|
||||
"""
|
||||
if check_item_selected(self.listView, translate('MediaPlugin.MediaItem',
|
||||
'You must select a media file to delete.')):
|
||||
if check_item_selected(self.listView,
|
||||
translate('MediaPlugin.MediaItem', 'You must select a media file to delete.')):
|
||||
row_list = [item.row() for item in self.listView.selectedIndexes()]
|
||||
row_list.sort(reverse=True)
|
||||
for row in row_list:
|
||||
|
|
|
@ -28,7 +28,6 @@
|
|||
###############################################################################
|
||||
|
||||
import logging
|
||||
import os
|
||||
|
||||
from PyQt4 import QtCore
|
||||
|
||||
|
|
|
@ -28,7 +28,7 @@
|
|||
###############################################################################
|
||||
import re
|
||||
|
||||
from PyQt4 import QtGui, QtCore
|
||||
from PyQt4 import QtGui
|
||||
|
||||
from openlp.core.lib import translate
|
||||
from openlp.core.utils import CONTROL_CHARS, locale_direct_compare
|
||||
|
|
|
@ -36,7 +36,6 @@ import re
|
|||
from sqlalchemy import Column, ForeignKey, Table, types
|
||||
from sqlalchemy.orm import mapper, relation, reconstructor
|
||||
from sqlalchemy.sql.expression import func
|
||||
from PyQt4 import QtCore
|
||||
|
||||
from openlp.core.lib.db import BaseModel, init_db
|
||||
|
||||
|
|
|
@ -30,8 +30,6 @@
|
|||
The :mod:`dreambeamimport` module provides the functionality for importing
|
||||
DreamBeam songs into the OpenLP database.
|
||||
"""
|
||||
import os
|
||||
import sys
|
||||
import logging
|
||||
|
||||
from lxml import etree, objectify
|
||||
|
@ -46,11 +44,11 @@ class DreamBeamImport(SongImport):
|
|||
"""
|
||||
The :class:`DreamBeamImport` class provides the ability to import song files from
|
||||
DreamBeam.
|
||||
|
||||
|
||||
An example of DreamBeam xml mark-up::
|
||||
|
||||
|
||||
<?xml version="1.0"?>
|
||||
<DreamSong xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
<DreamSong xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns:xsd="http://www.w3.org/2001/XMLSchema">
|
||||
<WordWrap>false</WordWrap>
|
||||
<Version>0.80</Version>
|
||||
|
@ -84,7 +82,7 @@ class DreamBeamImport(SongImport):
|
|||
|
||||
* \*.xml
|
||||
"""
|
||||
|
||||
|
||||
def doImport(self):
|
||||
"""
|
||||
Receive a single file or a list of files to import.
|
||||
|
|
|
@ -30,8 +30,6 @@
|
|||
The :mod:`mediashoutimport` module provides the functionality for importing
|
||||
a MediaShout database into the OpenLP database.
|
||||
"""
|
||||
import re
|
||||
import os
|
||||
import pyodbc
|
||||
|
||||
from openlp.core.lib import translate
|
||||
|
|
|
@ -31,9 +31,7 @@ The :mod:`songproimport` module provides the functionality for importing SongPro
|
|||
songs into the OpenLP database.
|
||||
"""
|
||||
import re
|
||||
import os
|
||||
|
||||
from openlp.core.lib import translate
|
||||
from openlp.plugins.songs.lib import strip_rtf
|
||||
from openlp.plugins.songs.lib.songimport import SongImport
|
||||
|
||||
|
|
Binary file not shown.
After Width: | Height: | Size: 213 KiB |
|
@ -0,0 +1,163 @@
|
|||
"""
|
||||
Package to test the openlp.core.lib package.
|
||||
"""
|
||||
import os
|
||||
|
||||
from unittest import TestCase
|
||||
from mock import MagicMock
|
||||
from openlp.core.lib import ServiceItem
|
||||
|
||||
VERSE = u'The Lord said to {r}Noah{/r}: \n'\
|
||||
'There\'s gonna be a {su}floody{/su}, {sb}floody{/sb}\n'\
|
||||
'The Lord said to {g}Noah{/g}:\n'\
|
||||
'There\'s gonna be a {st}floody{/st}, {it}floody{/it}\n'\
|
||||
'Get those children out of the muddy, muddy \n'\
|
||||
'{r}C{/r}{b}h{/b}{bl}i{/bl}{y}l{/y}{g}d{/g}{pk}'\
|
||||
'r{/pk}{o}e{/o}{pp}n{/pp} of the Lord\n'
|
||||
FOOTER = [u'Arky Arky (Unknown)', u'Public Domain', u'CCLI 123456']
|
||||
|
||||
TESTPATH = os.path.abspath(os.path.join(os.path.dirname(__file__), u'resources'))
|
||||
|
||||
class TestServiceItem(TestCase):
|
||||
|
||||
def serviceitem_basic_test(self):
|
||||
"""
|
||||
Test the Service Item basic test
|
||||
"""
|
||||
# GIVEN: A new service item
|
||||
|
||||
# WHEN:A service item is created (without a plugin)
|
||||
service_item = ServiceItem(None)
|
||||
|
||||
# THEN: We should get back a valid service item
|
||||
assert service_item.is_valid is True, u'The new service item should be valid'
|
||||
assert service_item.missing_frames() is True, u'There should not be any frames in the service item'
|
||||
|
||||
def serviceitem_add_text_test(self):
|
||||
"""
|
||||
Test the Service Item add text test
|
||||
"""
|
||||
# GIVEN: A new service item
|
||||
service_item = ServiceItem(None)
|
||||
|
||||
# WHEN: adding text to a service item
|
||||
service_item.add_from_text(VERSE)
|
||||
service_item.raw_footer = FOOTER
|
||||
|
||||
# THEN: We should get back a valid service item
|
||||
assert service_item.is_valid is True, u'The new service item should be valid'
|
||||
assert service_item.missing_frames() is False, u'check frames loaded '
|
||||
|
||||
# GIVEN: A service item with text
|
||||
mocked_renderer = MagicMock()
|
||||
mocked_renderer.format_slide.return_value = [VERSE]
|
||||
service_item.renderer = mocked_renderer
|
||||
|
||||
# WHEN: Render called
|
||||
assert len(service_item._display_frames) == 0, u'A blank Service Item with no display frames'
|
||||
service_item.render(True)
|
||||
|
||||
# THEN: We should have a page of output.
|
||||
assert len(service_item._display_frames) == 1, u'A valid rendered Service Item has 1 display frame'
|
||||
assert service_item.get_rendered_frame(0) == VERSE.split(u'\n')[0], u'A output has rendered correctly.'
|
||||
|
||||
def serviceitem_add_image_test(self):
|
||||
"""
|
||||
Test the Service Item add image test
|
||||
"""
|
||||
# GIVEN: A new service item and a mocked renderer
|
||||
service_item = ServiceItem(None)
|
||||
service_item.name = u'test'
|
||||
mocked_renderer = MagicMock()
|
||||
service_item.renderer = mocked_renderer
|
||||
|
||||
# WHEN: adding image to a service item
|
||||
test_image = os.path.join(TESTPATH, u'church.jpg')
|
||||
service_item.add_from_image(test_image, u'Image Title')
|
||||
|
||||
# THEN: We should get back a valid service item
|
||||
assert service_item.is_valid is True, u'The new service item should be valid'
|
||||
assert len(service_item._display_frames) == 0, u'The service item has no display frames'
|
||||
|
||||
# THEN: We should have a page of output.
|
||||
assert len(service_item._raw_frames) == 1, u'A valid rendered Service Item has display frames'
|
||||
assert service_item.get_rendered_frame(0) == test_image
|
||||
|
||||
# WHEN: adding a second image to a service item
|
||||
service_item.add_from_image(test_image, u'Image1 Title')
|
||||
|
||||
# THEN: We should have an increased page of output.
|
||||
assert len(service_item._raw_frames) == 2, u'A valid rendered Service Item has display frames'
|
||||
assert service_item.get_rendered_frame(0) == test_image
|
||||
assert service_item.get_rendered_frame(0) == service_item.get_rendered_frame(1)
|
||||
|
||||
# WHEN requesting a saved service item
|
||||
service = service_item.get_service_repr(True)
|
||||
|
||||
# THEN: We should have two parts of the service.
|
||||
assert len(service) == 2, u'A saved service has two parts'
|
||||
assert service[u'header'][u'name'] == u'test' , u'A test plugin was returned'
|
||||
assert service[u'data'][0][u'title'] == u'Image Title' , u'The first title name matches the request'
|
||||
assert service[u'data'][0][u'path'] == test_image , u'The first image name matches'
|
||||
assert service[u'data'][0][u'title'] != service[u'data'][1][u'title'], \
|
||||
u'The individual titles should not match'
|
||||
assert service[u'data'][0][u'path'] == service[u'data'][1][u'path'], u'The file paths should match'
|
||||
|
||||
# WHEN validating a service item
|
||||
service_item.validate_item([u'jpg'])
|
||||
|
||||
# THEN the service item should be valid
|
||||
assert service_item.is_valid is True, u'The new service item should be valid'
|
||||
|
||||
# WHEN: adding a second image to a service item
|
||||
service_item.add_from_image(u'resources/church1.jpg', u'Image1 Title')
|
||||
|
||||
# WHEN validating a service item
|
||||
service_item.validate_item([u'jpg'])
|
||||
|
||||
# THEN the service item should be valid
|
||||
assert service_item.is_valid is False, u'The service item is not valid due to validation changes'
|
||||
|
||||
def serviceitem_add_command_test(self):
|
||||
"""
|
||||
Test the Service Item add command test
|
||||
"""
|
||||
# GIVEN: A new service item and a mocked renderer
|
||||
service_item = ServiceItem(None)
|
||||
service_item.name = u'test'
|
||||
mocked_renderer = MagicMock()
|
||||
service_item.renderer = mocked_renderer
|
||||
|
||||
# WHEN: adding image to a service item
|
||||
test_file = os.path.join(TESTPATH, u'church.jpg')
|
||||
service_item.add_from_command(TESTPATH, u'church.jpg', test_file)
|
||||
|
||||
# THEN: We should get back a valid service item
|
||||
assert service_item.is_valid is True, u'The new service item should be valid'
|
||||
assert len(service_item._display_frames) == 0, u'The service item has no display frames '
|
||||
|
||||
# THEN: We should have a page of output.
|
||||
assert len(service_item._raw_frames) == 1, u'A valid rendered Service Item has one raw frame'
|
||||
assert service_item.get_rendered_frame(0) == test_file, u'The image matches the input'
|
||||
|
||||
# WHEN requesting a saved service item
|
||||
service = service_item.get_service_repr(True)
|
||||
|
||||
# THEN: We should have two parts of the service.
|
||||
assert len(service) == 2, u'A saved service has two parts'
|
||||
assert service[u'header'][u'name'] == u'test' , u'A test plugin'
|
||||
assert service[u'data'][0][u'title'] == u'church.jpg' , u'The first title name '
|
||||
assert service[u'data'][0][u'path'] == TESTPATH , u'The first image name'
|
||||
assert service[u'data'][0][u'image'] == test_file , u'The first image name'
|
||||
|
||||
# WHEN validating a service item
|
||||
service_item.validate_item([u'jpg'])
|
||||
|
||||
# THEN the service item should be valid
|
||||
assert service_item.is_valid is True, u'The service item is valid'
|
||||
|
||||
# WHEN validating a service item with a different suffix
|
||||
service_item.validate_item([u'png'])
|
||||
|
||||
# THEN the service item should not be valid
|
||||
assert service_item.is_valid is False, u'The service item is not valid'
|
|
@ -0,0 +1,48 @@
|
|||
"""
|
||||
Package to test the openlp.core.ui package.
|
||||
"""
|
||||
import sys
|
||||
|
||||
from unittest import TestCase
|
||||
from mock import MagicMock
|
||||
from openlp.core.ui import starttimeform
|
||||
from PyQt4 import QtCore, QtGui, QtTest
|
||||
|
||||
class TestStartTimeDialog(TestCase):
|
||||
|
||||
def setUp(self):
|
||||
"""
|
||||
Create the UI
|
||||
"""
|
||||
self.app = QtGui.QApplication(sys.argv)
|
||||
self.window = QtGui.QMainWindow()
|
||||
self.form = starttimeform.StartTimeForm(self.window)
|
||||
|
||||
def ui_defaults_test(self):
|
||||
"""
|
||||
Test StartTimeDialog defaults
|
||||
"""
|
||||
self.assertEqual(self.form.hourSpinBox.minimum(), 0)
|
||||
self.assertEqual(self.form.hourSpinBox.maximum(), 4)
|
||||
self.assertEqual(self.form.minuteSpinBox.minimum(), 0)
|
||||
self.assertEqual(self.form.minuteSpinBox.maximum(), 59)
|
||||
self.assertEqual(self.form.secondSpinBox.minimum(), 0)
|
||||
self.assertEqual(self.form.secondSpinBox.maximum(), 59)
|
||||
self.assertEqual(self.form.hourFinishSpinBox.minimum(), 0)
|
||||
self.assertEqual(self.form.hourFinishSpinBox.maximum(), 4)
|
||||
self.assertEqual(self.form.minuteFinishSpinBox.minimum(), 0)
|
||||
self.assertEqual(self.form.minuteFinishSpinBox.maximum(), 59)
|
||||
self.assertEqual(self.form.secondFinishSpinBox.minimum(), 0)
|
||||
self.assertEqual(self.form.secondFinishSpinBox.maximum(), 59)
|
||||
|
||||
def time_display_test(self):
|
||||
"""
|
||||
Test StartTimeDialog display initialisation
|
||||
"""
|
||||
#GIVEN: A service item with with time
|
||||
mocked_serviceitem = MagicMock()
|
||||
mocked_serviceitem.start_time = 61
|
||||
mocked_serviceitem.end_time = 3701
|
||||
|
||||
self.form.item = mocked_serviceitem
|
||||
#self.form.exec_()
|
Binary file not shown.
After Width: | Height: | Size: 213 KiB |
|
@ -34,4 +34,4 @@ from openlp.core.ui.mainwindow import MainWindow
|
|||
def test_start_app(openlpapp):
|
||||
assert type(openlpapp) == OpenLP
|
||||
assert type(openlpapp.mainWindow) == MainWindow
|
||||
assert unicode(openlpapp.mainWindow.windowTitle()) == u'OpenLP 2.0'
|
||||
assert unicode(openlpapp.mainWindow.windowTitle()) == u'OpenLP 2.1'
|
||||
|
|
Loading…
Reference in New Issue