More Code cleanups

This commit is contained in:
Tim Bentley 2012-10-06 09:10:28 +01:00
parent e141ff1c24
commit 2dadfbd17a
4 changed files with 18 additions and 16 deletions

View File

@ -81,7 +81,7 @@ from screen import ScreenList
from maindisplay import MainDisplay, Display from maindisplay import MainDisplay, Display
from servicenoteform import ServiceNoteForm from servicenoteform import ServiceNoteForm
from serviceitemeditform import ServiceItemEditForm from serviceitemeditform import ServiceItemEditForm
from slidecontroller import SlideController, Controller from slidecontroller import SlideController, DisplayController
from splashscreen import SplashScreen from splashscreen import SplashScreen
from generaltab import GeneralTab from generaltab import GeneralTab
from themestab import ThemesTab from themestab import ThemesTab

View File

@ -51,7 +51,6 @@ class MediaController(object):
self.mediaPlayers = {} self.mediaPlayers = {}
self.controller = [] self.controller = []
self.curDisplayMediaPlayer = {} self.curDisplayMediaPlayer = {}
self.currentPlayer = None
# Timer for video state # Timer for video state
self.timer = QtCore.QTimer() self.timer = QtCore.QTimer()
self.timer.setInterval(200) self.timer.setInterval(200)
@ -284,9 +283,6 @@ class MediaController(object):
if self.curDisplayMediaPlayer[controller.display] != \ if self.curDisplayMediaPlayer[controller.display] != \
self.mediaPlayers[u'webkit']: self.mediaPlayers[u'webkit']:
controller.display.setTransparency(False) controller.display.setTransparency(False)
# Special controls: Here media type specific Controls will be enabled
# (e.g. for DVD control, ...)
# TODO
def resize(self, controller, display, player): def resize(self, controller, display, player):
""" """
@ -316,9 +312,9 @@ class MediaController(object):
if controller.isLive: if controller.isLive:
if controller.previewDisplay: if controller.previewDisplay:
display = controller.previewDisplay display = controller.previewDisplay
isValid = self.check_file_type(controller, display) isValid = self._check_file_type(controller, display)
display = controller.display display = controller.display
isValid = self.check_file_type(controller, display) isValid = self._check_file_type(controller, display)
display.override[u'theme'] = u'' display.override[u'theme'] = u''
display.override[u'video'] = True display.override[u'video'] = True
if controller.media_info.is_background: if controller.media_info.is_background:
@ -331,7 +327,7 @@ class MediaController(object):
controller.media_info.end_time = serviceItem.end_time controller.media_info.end_time = serviceItem.end_time
elif controller.previewDisplay: elif controller.previewDisplay:
display = controller.previewDisplay display = controller.previewDisplay
isValid = self.check_file_type(controller, display) isValid = self._check_file_type(controller, display)
if not isValid: if not isValid:
# Media could not be loaded correctly # Media could not be loaded correctly
critical_error_message_box( critical_error_message_box(
@ -371,7 +367,7 @@ class MediaController(object):
""" """
Loads and starts a media item to obtain the media length Loads and starts a media item to obtain the media length
``msg`` ``controller``
First element is the controller which should be used First element is the controller which should be used
``serviceItem`` ``serviceItem``
@ -385,7 +381,7 @@ class MediaController(object):
controller.media_info.file_info = QtCore.QFileInfo(serviceItem controller.media_info.file_info = QtCore.QFileInfo(serviceItem
.get_filename()) .get_filename())
display = controller.previewDisplay display = controller.previewDisplay
if not self.check_file_type(controller, display): if not self._check_file_type(controller, display):
# Media could not be loaded correctly # Media could not be loaded correctly
critical_error_message_box( critical_error_message_box(
translate('MediaPlugin.MediaItem', 'Unsupported File'), translate('MediaPlugin.MediaItem', 'Unsupported File'),
@ -403,9 +399,15 @@ class MediaController(object):
log.debug(u'use %s controller' % self.curDisplayMediaPlayer[display]) log.debug(u'use %s controller' % self.curDisplayMediaPlayer[display])
return True return True
def check_file_type(self, controller, display): def _check_file_type(self, controller, display):
""" """
Select the correct media Player type from the prioritized Player list Select the correct media Player type from the prioritized Player list
``controller``
First element is the controller which should be used
``serviceItem``
The ServiceItem containing the details to be played.
""" """
usedPlayers, overriddenPlayer = get_media_players() usedPlayers, overriddenPlayer = get_media_players()
if overriddenPlayer and overriddenPlayer != u'auto': if overriddenPlayer and overriddenPlayer != u'auto':

View File

@ -52,7 +52,7 @@ class SlideList(QtGui.QTableWidget):
QtGui.QTableWidget.__init__(self, parent.controller) QtGui.QTableWidget.__init__(self, parent.controller)
class Controller(QtGui.QWidget): class DisplayController(QtGui.QWidget):
""" """
Controller is a general display controller widget. Controller is a general display controller widget.
""" """
@ -76,7 +76,7 @@ class Controller(QtGui.QWidget):
Receiver.send_message('%s' % sender, [controller, args]) Receiver.send_message('%s' % sender, [controller, args])
class SlideController(Controller): class SlideController(DisplayController):
""" """
SlideController is the slide controller widget. This widget is what the SlideController is the slide controller widget. This widget is what the
user uses to control the displaying of verses/slides/etc on the screen. user uses to control the displaying of verses/slides/etc on the screen.
@ -85,7 +85,7 @@ class SlideController(Controller):
""" """
Set up the Slide Controller. Set up the Slide Controller.
""" """
Controller.__init__(self, parent, isLive) DisplayController.__init__(self, parent, isLive)
self.screens = ScreenList() self.screens = ScreenList()
try: try:
self.ratio = float(self.screens.current[u'size'].width()) / \ self.ratio = float(self.screens.current[u'size'].width()) / \

View File

@ -38,7 +38,7 @@ from openlp.core.lib import MediaManagerItem, build_icon, ItemCapabilities, \
from openlp.core.lib.settings import Settings from openlp.core.lib.settings import Settings
from openlp.core.lib.ui import UiStrings, critical_error_message_box, \ from openlp.core.lib.ui import UiStrings, critical_error_message_box, \
create_horizontal_adjusting_combo_box create_horizontal_adjusting_combo_box
from openlp.core.ui import Controller, Display from openlp.core.ui import DisplayController, Display
from openlp.core.ui.media import get_media_players, set_media_players from openlp.core.ui.media import get_media_players, set_media_players
log = logging.getLogger(__name__) log = logging.getLogger(__name__)
@ -62,7 +62,7 @@ class MediaMediaItem(MediaManagerItem):
self.singleServiceItem = False self.singleServiceItem = False
self.hasSearch = True self.hasSearch = True
self.mediaObject = None self.mediaObject = None
self.mediaController = Controller(parent) self.mediaController = DisplayController(parent)
self.mediaController.controllerLayout = QtGui.QVBoxLayout() self.mediaController.controllerLayout = QtGui.QVBoxLayout()
self.plugin.mediaController.register_controller(self self.plugin.mediaController.register_controller(self
.mediaController, self.mediaController.controllerLayout) .mediaController, self.mediaController.controllerLayout)