- clean ups

bzr-revno: 1984
This commit is contained in:
Andreas Preikschat 2012-06-09 20:28:07 +02:00
commit 6c981afedc
11 changed files with 95 additions and 106 deletions

View File

@ -268,7 +268,7 @@ class Receiver(object):
<<ACTION>>
)``
"""
eventreceiver = EventReceiver()
__eventreceiver__ = EventReceiver()
@staticmethod
def send_message(event, msg=None):
@ -281,11 +281,11 @@ class Receiver(object):
``msg``
Defaults to *None*. The message to send with the event.
"""
Receiver.eventreceiver.send_message(event, msg)
Receiver.__eventreceiver__.send_message(event, msg)
@staticmethod
def get_receiver():
"""
Get the global ``eventreceiver`` instance.
Get the global ``__eventreceiver__`` instance.
"""
return Receiver.eventreceiver
return Receiver.__eventreceiver__

View File

@ -41,13 +41,13 @@ class PluginManager(object):
and executes all the hooks, as and when necessary.
"""
log.info(u'Plugin manager loaded')
__instance__ = None
@staticmethod
def get_instance():
"""
Obtain a single instance of class.
"""
return PluginManager.instance
return PluginManager.__instance__
def __init__(self, plugin_dir):
"""
@ -58,7 +58,7 @@ class PluginManager(object):
The directory to search for plugins.
"""
log.info(u'Plugin manager Initialising')
PluginManager.instance = self
PluginManager.__instance__ = self
if not plugin_dir in sys.path:
log.debug(u'Inserting %s into sys.path', plugin_dir)
sys.path.insert(0, plugin_dir)

View File

@ -303,7 +303,7 @@ class Renderer(object):
try:
text_to_render, text = \
text.split(u'\n[---]\n', 1)
except:
except ValueError:
text_to_render = text.split(u'\n[---]\n')[0]
text = u''
text_to_render, raw_tags, html_tags = \

View File

@ -100,9 +100,8 @@ class Display(QtGui.QGraphicsView):
self.frame.setScrollBarPolicy(QtCore.Qt.Horizontal,
QtCore.Qt.ScrollBarAlwaysOff)
def resizeEvent(self, ev):
self.webView.setGeometry(0, 0,
self.width(), self.height())
def resizeEvent(self, event):
self.webView.setGeometry(0, 0, self.width(), self.height())
def isWebLoaded(self):
"""
@ -120,7 +119,6 @@ class MainDisplay(Display):
Display.__init__(self, parent, live, controller)
self.imageManager = imageManager
self.screens = ScreenList()
self.plugins = PluginManager.get_instance().plugins
self.rebuildCSS = False
self.hideMode = None
self.override = {}

View File

@ -335,8 +335,7 @@ class MediaController(object):
if controller.isLive and \
(QtCore.QSettings().value(u'general/auto unblank',
QtCore.QVariant(False)).toBool() or \
controller.media_info.is_background == True) or \
controller.isLive == False:
controller.media_info.is_background) or not controller.isLive:
if not self.video_play([controller]):
critical_error_message_box(
translate('MediaPlugin.MediaItem', 'Unsupported File'),
@ -495,7 +494,7 @@ class MediaController(object):
return
controller = self.parent.liveController
for display in self.curDisplayMediaPlayer.keys():
if display.controller != controller or \
if display.controller != controller or \
self.curDisplayMediaPlayer[display].state != MediaState.Playing:
continue
self.curDisplayMediaPlayer[display].pause(display)

View File

@ -38,21 +38,21 @@ from openlp.core.ui.media import MediaState
log = logging.getLogger(__name__)
ADDITIONAL_EXT = {
u'audio/ac3': [u'.ac3'],
u'audio/flac': [u'.flac'],
u'audio/x-m4a': [u'.m4a'],
u'audio/midi': [u'.mid', u'.midi'],
u'audio/x-mp3': [u'.mp3'],
u'audio/mpeg': [u'.mp3', u'.mp2', u'.mpga', u'.mpega', u'.m4a'],
u'audio/qcelp': [u'.qcp'],
u'audio/x-wma': [u'.wma'],
u'audio/x-ms-wma': [u'.wma'],
u'video/x-flv': [u'.flv'],
u'video/x-matroska': [u'.mpv', u'.mkv'],
u'video/x-wmv': [u'.wmv'],
u'video/x-mpg': [u'.mpg'],
u'video/mpeg' : [u'.mp4', u'.mts'],
u'video/x-ms-wmv': [u'.wmv']}
u'audio/ac3': [u'.ac3'],
u'audio/flac': [u'.flac'],
u'audio/x-m4a': [u'.m4a'],
u'audio/midi': [u'.mid', u'.midi'],
u'audio/x-mp3': [u'.mp3'],
u'audio/mpeg': [u'.mp3', u'.mp2', u'.mpga', u'.mpega', u'.m4a'],
u'audio/qcelp': [u'.qcp'],
u'audio/x-wma': [u'.wma'],
u'audio/x-ms-wma': [u'.wma'],
u'video/x-flv': [u'.flv'],
u'video/x-matroska': [u'.mpv', u'.mkv'],
u'video/x-wmv': [u'.wmv'],
u'video/x-mpg': [u'.mpg'],
u'video/mpeg' : [u'.mp4', u'.mts'],
u'video/x-ms-wmv': [u'.wmv']}
class PhononPlayer(MediaPlayer):
@ -101,7 +101,7 @@ class PhononPlayer(MediaPlayer):
display.mediaObject = Phonon.MediaObject(display)
Phonon.createPath(display.mediaObject, display.phononWidget)
if display.hasAudio:
display.audio = Phonon.AudioOutput( \
display.audio = Phonon.AudioOutput(
Phonon.VideoCategory, display.mediaObject)
Phonon.createPath(display.mediaObject, display.audio)
display.phononWidget.raise_()
@ -148,18 +148,17 @@ class PhononPlayer(MediaPlayer):
controller.media_info.start_time > 0:
start_time = controller.media_info.start_time
display.mediaObject.play()
if self.media_state_wait(display, Phonon.PlayingState):
if start_time > 0:
self.seek(display, controller.media_info.start_time*1000)
self.volume(display, controller.media_info.volume)
controller.media_info.length = \
int(display.mediaObject.totalTime()/1000)
controller.seekSlider.setMaximum(controller.media_info.length*1000)
self.state = MediaState.Playing
display.phononWidget.raise_()
return True
else:
if not self.media_state_wait(display, Phonon.PlayingState):
return False
if start_time > 0:
self.seek(display, controller.media_info.start_time * 1000)
self.volume(display, controller.media_info.volume)
controller.media_info.length = \
int(display.mediaObject.totalTime() / 1000)
controller.seekSlider.setMaximum(controller.media_info.length * 1000)
self.state = MediaState.Playing
display.phononWidget.raise_()
return True
def pause(self, display):
display.mediaObject.pause()
@ -198,9 +197,9 @@ class PhononPlayer(MediaPlayer):
controller = display.controller
if controller.media_info.end_time > 0:
if display.mediaObject.currentTime() > \
controller.media_info.end_time*1000:
controller.media_info.end_time * 1000:
self.stop(display)
self.set_visible(display, False)
if not controller.seekSlider.isSliderDown():
controller.seekSlider.setSliderPosition( \
controller.seekSlider.setSliderPosition(
display.mediaObject.currentTime())

View File

@ -62,7 +62,7 @@ if VLC_AVAILABLE:
log.debug(u'VLC could not be loaded: %s' % version)
AUDIO_EXT = [
u'*.mp3'
u'*.mp3'
, u'*.wav'
, u'*.ogg'
]
@ -130,9 +130,9 @@ class VlcPlayer(MediaPlayer):
# this is platform specific!
# you have to give the id of the QFrame (or similar object) to
# vlc, different platforms have different functions for this
if sys.platform == "win32": # for Windows
if sys.platform == "win32":
display.vlcMediaPlayer.set_hwnd(int(display.vlcWidget.winId()))
elif sys.platform == "darwin": # for MacOS
elif sys.platform == "darwin":
display.vlcMediaPlayer.set_agl(int(display.vlcWidget.winId()))
else:
# for Linux using the X Server
@ -181,17 +181,16 @@ class VlcPlayer(MediaPlayer):
if controller.media_info.start_time > 0:
start_time = controller.media_info.start_time
display.vlcMediaPlayer.play()
if self.media_state_wait(display, vlc.State.Playing):
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)
controller.seekSlider.setMaximum(controller.media_info.length * 1000)
self.state = MediaState.Playing
display.vlcWidget.raise_()
return True
else:
if not self.media_state_wait(display, vlc.State.Playing):
return False
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)
controller.seekSlider.setMaximum(controller.media_info.length * 1000)
self.state = MediaState.Playing
display.vlcWidget.raise_()
return True
def pause(self, display):
if display.vlcMedia.get_state() != vlc.State.Playing:

View File

@ -227,33 +227,33 @@ FLASH_HTML = u"""
"""
VIDEO_EXT = [
u'*.3gp'
, u'*.3gpp'
, u'*.3g2'
, u'*.3gpp2'
, u'*.aac'
, u'*.flv'
, u'*.f4a'
, u'*.f4b'
, u'*.f4p'
, u'*.f4v'
, u'*.mov'
, u'*.m4a'
, u'*.m4b'
, u'*.m4p'
, u'*.m4v'
, u'*.mkv'
, u'*.mp4'
, u'*.ogv'
, u'*.webm'
, u'*.mpg', u'*.wmv', u'*.mpeg', u'*.avi'
, u'*.swf'
]
u'*.3gp'
, u'*.3gpp'
, u'*.3g2'
, u'*.3gpp2'
, u'*.aac'
, u'*.flv'
, u'*.f4a'
, u'*.f4b'
, u'*.f4p'
, u'*.f4v'
, u'*.mov'
, u'*.m4a'
, u'*.m4b'
, u'*.m4p'
, u'*.m4v'
, u'*.mkv'
, u'*.mp4'
, u'*.ogv'
, u'*.webm'
, u'*.mpg', u'*.wmv', u'*.mpeg', u'*.avi'
, u'*.swf'
]
AUDIO_EXT = [
u'*.mp3'
, u'*.ogg'
]
u'*.mp3'
, u'*.ogg'
]
class WebkitPlayer(MediaPlayer):
@ -339,7 +339,7 @@ class WebkitPlayer(MediaPlayer):
else:
display.frame.evaluateJavaScript(u'show_video("play");')
if start_time > 0:
self.seek(display, controller.media_info.start_time*1000)
self.seek(display, controller.media_info.start_time * 1000)
# TODO add playing check and get the correct media length
controller.media_info.length = length
self.state = MediaState.Playing
@ -375,11 +375,11 @@ class WebkitPlayer(MediaPlayer):
controller = display.controller
if controller.media_info.is_flash:
seek = seekVal
display.frame.evaluateJavaScript( \
display.frame.evaluateJavaScript(
u'show_flash("seek", null, null, "%s");' % (seek))
else:
seek = float(seekVal)/1000
display.frame.evaluateJavaScript( \
seek = float(seekVal) / 1000
display.frame.evaluateJavaScript(
u'show_video("seek", null, null, null, "%f");' % (seek))
def reset(self, display):
@ -406,24 +406,24 @@ class WebkitPlayer(MediaPlayer):
def update_ui(self, display):
controller = display.controller
if controller.media_info.is_flash:
currentTime = display.frame.evaluateJavaScript( \
currentTime = display.frame.evaluateJavaScript(
u'show_flash("currentTime");').toInt()[0]
length = display.frame.evaluateJavaScript( \
length = display.frame.evaluateJavaScript(
u'show_flash("length");').toInt()[0]
else:
if display.frame.evaluateJavaScript( \
if display.frame.evaluateJavaScript(
u'show_video("isEnded");').toString() == 'true':
self.stop(display)
(currentTime, ok) = display.frame.evaluateJavaScript( \
(currentTime, ok) = display.frame.evaluateJavaScript(
u'show_video("currentTime");').toFloat()
# check if conversion was ok and value is not 'NaN'
if ok and currentTime != float('inf'):
currentTime = int(currentTime*1000)
(length, ok) = display.frame.evaluateJavaScript( \
currentTime = int(currentTime * 1000)
(length, ok) = display.frame.evaluateJavaScript(
u'show_video("length");').toFloat()
# check if conversion was ok and value is not 'NaN'
if ok and length != float('inf'):
length = int(length*1000)
length = int(length * 1000)
if currentTime > 0:
controller.media_info.length = length
controller.seekSlider.setMaximum(length)

View File

@ -102,9 +102,9 @@ class PluginForm(QtGui.QDialog, Ui_PluginViewDialog):
self.versionNumberLabel.setText(self.activePlugin.version)
self.aboutTextBrowser.setHtml(self.activePlugin.about())
self.programaticChange = True
status = 1
status = PluginStatus.Active
if self.activePlugin.status == PluginStatus.Active:
status = 0
status = PluginStatus.Inactive
self.statusComboBox.setCurrentIndex(status)
self.statusComboBox.setEnabled(True)
self.programaticChange = False
@ -129,7 +129,7 @@ class PluginForm(QtGui.QDialog, Ui_PluginViewDialog):
def onStatusComboBoxChanged(self, status):
if self.programaticChange or status == PluginStatus.Disabled:
return
if status == 0:
if status == PluginStatus.Inactive:
Receiver.send_message(u'cursor_busy')
self.activePlugin.toggleStatus(PluginStatus.Active)
Receiver.send_message(u'cursor_normal')

View File

@ -580,10 +580,7 @@ class ServiceManager(QtGui.QWidget):
return self.saveFileAs()
self.mainwindow.addRecentFile(path_file_name)
self.setModified(False)
try:
delete_file(temp_file_name)
except:
pass
delete_file(temp_file_name)
return success
def saveFileAs(self):

View File

@ -172,17 +172,14 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog):
def loadThemes(self, theme_list):
self.themeComboBox.clear()
self.themeComboBox.addItem(u'')
self.themes = []
for theme in theme_list:
self.themeComboBox.addItem(theme)
self.themes.append(theme)
self.themes = theme_list
self.themeComboBox.addItems(theme_list)
set_case_insensitive_completer(self.themes, self.themeComboBox)
def loadMediaFiles(self):
self.audioAddFromMediaButton.setVisible(False)
for plugin in self.parent().pluginManager.plugins:
if plugin.name == u'media' and \
plugin.status == PluginStatus.Active:
if plugin.name == u'media' and plugin.status == PluginStatus.Active:
self.audioAddFromMediaButton.setVisible(True)
self.mediaForm.populateFiles(
plugin.mediaItem.getList(MediaType.Audio))