fix up player tab after setup changes and start to fix light save

This commit is contained in:
Tim Bentley 2012-10-14 16:58:04 +01:00
parent 7ce17e99f8
commit aea75e6c73
6 changed files with 90 additions and 65 deletions

View File

@ -292,7 +292,8 @@ class ServiceItem(object):
elif self.service_item_type == ServiceItemType.Command:
for slide in self._raw_frames:
service_data.append(
{u'title': slide[u'title'], u'image': slide[u'image']})
{u'title': slide[u'title'], u'image': slide[u'image'],
u'path': slide[u'path']})
return {u'header': service_header, u'data': service_data}
def set_from_service(self, serviceitem, path=None):
@ -342,9 +343,14 @@ class ServiceItem(object):
self.add_from_image(filename, text_image)
elif self.service_item_type == ServiceItemType.Command:
for text_image in serviceitem[u'serviceitem'][u'data']:
filename = os.path.join(path, text_image[u'title'])
self.add_from_command(
path, text_image[u'title'], text_image[u'image'])
if path:
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'])
self._new_item()
def get_display_title(self):

View File

@ -1167,7 +1167,7 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow):
if self.serviceManagerContents.isModified():
ret = self.serviceManagerContents.saveModifiedService()
if ret == QtGui.QMessageBox.Save:
if self.serviceManagerContents.saveFile():
if self.serviceManagerContents.decideSaveMethod():
self.cleanUp()
event.accept()
else:

View File

@ -94,12 +94,25 @@ class MediaController(object):
self.mediaPlayers[player].isActive = player in savedPlayers
def _generate_extensions_lists(self):
self.audio_extensions_list = self.get_audio_extensions_list()
for ext in self.audio_extensions_list:
self.mainWindow.serviceManagerContents.supportedSuffixes(ext[2:])
self.video_extensions_list = self.get_video_extensions_list()
for ext in self.video_extensions_list:
self.mainWindow.serviceManagerContents.supportedSuffixes(ext[2:])
"""
Set the active players and available media files
"""
self.audio_extensions_list = []
for player in self.mediaPlayers.values():
if player.isActive:
for item in player.audio_extensions_list:
if not item in self.audio_extensions_list:
self.audio_extensions_list.append(item)
self.mainWindow.serviceManagerContents. \
supportedSuffixes(item[2:])
self.video_extensions_list = []
for player in self.mediaPlayers.values():
if player.isActive:
for item in player.video_extensions_list:
if item not in self.video_extensions_list:
self.video_extensions_list.extend(item)
self.mainWindow.serviceManagerContents. \
supportedSuffixes(item[2:])
def register_players(self, player):
"""
@ -657,23 +670,6 @@ class MediaController(object):
if not self.timer.isActive():
self.timer.start()
def get_audio_extensions_list(self):
audio_list = []
for player in self.mediaPlayers.values():
if player.isActive:
for item in player.audio_extensions_list:
if not item in audio_list:
audio_list.append(item)
return audio_list
def get_video_extensions_list(self):
video_list = []
for player in self.mediaPlayers.values():
if player.isActive:
video_list.extend([item for item in player.video_extensions_list
if item not in video_list])
return video_list
def finalise(self):
self.timer.stop()
for controller in self.controller:

View File

@ -83,13 +83,6 @@ class PlayerTab(SettingsTab):
self.mediaPlayerLayout = QtGui.QVBoxLayout(self.mediaPlayerGroupBox)
self.mediaPlayerLayout.setObjectName(u'mediaPlayerLayout')
self.playerCheckBoxes = {}
for key, player in self.mediaPlayers.iteritems():
player = self.mediaPlayers[key]
checkbox = MediaQCheckBox(self.mediaPlayerGroupBox)
checkbox.setEnabled(player.available)
checkbox.setObjectName(player.name + u'CheckBox')
self.playerCheckBoxes[player.name] = checkbox
self.mediaPlayerLayout.addWidget(checkbox)
self.leftLayout.addWidget(self.mediaPlayerGroupBox)
self.playerOrderGroupBox = QtGui.QGroupBox(self.leftColumn)
self.playerOrderGroupBox.setObjectName(u'playerOrderGroupBox')
@ -126,12 +119,6 @@ class PlayerTab(SettingsTab):
self.leftLayout.addWidget(self.playerOrderGroupBox)
self.leftLayout.addStretch()
self.rightLayout.addStretch()
for key in self.mediaPlayers:
player = self.mediaPlayers[key]
checkbox = self.playerCheckBoxes[player.name]
QtCore.QObject.connect(checkbox,
QtCore.SIGNAL(u'stateChanged(int)'),
self.onPlayerCheckBoxChanged)
# Signals and slots
QtCore.QObject.connect(self.backgroundColorButton,
QtCore.SIGNAL(u'clicked()'), self.onbackgroundColorButtonClicked)
@ -139,16 +126,6 @@ class PlayerTab(SettingsTab):
def retranslateUi(self):
self.mediaPlayerGroupBox.setTitle(
translate('OpenLP.PlayerTab', 'Available Media Players'))
for key in self.mediaPlayers:
player = self.mediaPlayers[key]
checkbox = self.playerCheckBoxes[player.name]
checkbox.setPlayerName(player.name)
if player.available:
checkbox.setText(player.display_name)
else:
checkbox.setText(
unicode(translate('OpenLP.PlayerTab',
'%s (unavailable)')) % player.display_name)
self.playerOrderGroupBox.setTitle(
translate('OpenLP.PlayerTab', 'Player Search Order'))
self.bgColorGroupBox.setTitle(
@ -157,8 +134,8 @@ class PlayerTab(SettingsTab):
translate('ImagesPlugin.ImageTab', 'Default Color:'))
self.informationLabel.setText(
translate('ImagesPlugin.ImageTab', 'Visible background for images '
'with aspect ratio different to screen.'))
'with aspect ratio different to screen.'))
self.retranslatePlayers()
def onbackgroundColorButtonClicked(self):
new_color = QtGui.QColorDialog.getColor(
@ -213,13 +190,7 @@ class PlayerTab(SettingsTab):
self.usedPlayers = self.savedUsedPlayers
self.usedPlayers = get_media_players()[0]
self.savedUsedPlayers = self.usedPlayers
for key in self.mediaPlayers:
player = self.mediaPlayers[key]
checkbox = self.playerCheckBoxes[player.name]
if player.available and player.name in self.usedPlayers:
checkbox.setChecked(True)
else:
checkbox.setChecked(False)
settings = Settings()
settings.beginGroup(self.settingsSection)
self.updatePlayerList()
@ -248,3 +219,37 @@ class PlayerTab(SettingsTab):
Receiver.send_message(u'mediaitem_media_rebuild')
Receiver.send_message(u'config_screen_changed')
def postSetUp(self, postUpdate=False):
"""
Late stup for players as the MediaController has to be initialised
firest.
"""
for key, player in self.mediaPlayers.iteritems():
player = self.mediaPlayers[key]
checkbox = MediaQCheckBox(self.mediaPlayerGroupBox)
checkbox.setEnabled(player.available)
checkbox.setObjectName(player.name + u'CheckBox')
self.playerCheckBoxes[player.name] = checkbox
QtCore.QObject.connect(checkbox,QtCore.SIGNAL(u'stateChanged(int)'),
self.onPlayerCheckBoxChanged)
self.mediaPlayerLayout.addWidget(checkbox)
if player.available and player.name in self.usedPlayers:
checkbox.setChecked(True)
else:
checkbox.setChecked(False)
self.retranslatePlayers()
def retranslatePlayers(self):
"""
Translations for players is dependent on their setup as well
"""
for key in self.mediaPlayers:
player = self.mediaPlayers[key]
checkbox = self.playerCheckBoxes[player.name]
checkbox.setPlayerName(player.name)
if player.available:
checkbox.setText(player.display_name)
else:
checkbox.setText(
unicode(translate('OpenLP.PlayerTab',
'%s (unavailable)')) % player.display_name)

View File

@ -135,7 +135,7 @@ class ServiceManager(QtGui.QWidget):
self.toolbar.addToolbarAction(u'saveService',
text=UiStrings().SaveService, icon=u':/general/general_save.png',
tooltip=translate('OpenLP.ServiceManager', 'Save this service.'),
triggers=self.saveFile)
triggers=self.decideSaveMethod)
self.toolbar.addSeparator()
self.themeLabel = QtGui.QLabel(u'%s:' % UiStrings().Theme, self)
self.themeLabel.setMargin(3)
@ -361,6 +361,7 @@ class ServiceManager(QtGui.QWidget):
self.shortFileName())
Settings(). \
setValue(u'servicemanager/last file',QtCore.QVariant(fileName))
self._saveLight = True if self._fileName.endswith(u'.oszl') else False
def fileName(self):
"""
@ -408,7 +409,7 @@ class ServiceManager(QtGui.QWidget):
if result == QtGui.QMessageBox.Cancel:
return False
elif result == QtGui.QMessageBox.Save:
if not self.saveFile():
if not self.decideSaveMethod():
return False
self.newFile()
@ -426,7 +427,7 @@ class ServiceManager(QtGui.QWidget):
if result == QtGui.QMessageBox.Cancel:
return False
elif result == QtGui.QMessageBox.Save:
self.saveFile()
self.decideSaveMethod()
if not loadFile:
fileName = unicode(QtGui.QFileDialog.getOpenFileName(
self.mainwindow,
@ -721,12 +722,24 @@ class ServiceManager(QtGui.QWidget):
ext = os.path.splitext(fileName)[1]
fileName.replace(ext, u'.osz')
self.setFileName(fileName)
if fileName.endswith(u'.oszl'):
self.decideSaveMethod()
def decideSaveMethod(self):
"""
Determine which type of save method to use.
"""
if not self.fileName():
return self.saveFileAs()
print "decideSaveMethod",self._saveLight
if self._saveLight:
return self.saveLocalFile()
else:
return self.saveFile()
def loadFile(self, fileName):
"""
Load an existing service file
"""
if not fileName:
return False
fileName = unicode(fileName)
@ -766,7 +779,11 @@ class ServiceManager(QtGui.QWidget):
self.mainwindow.incrementProgressBar()
serviceItem = ServiceItem()
serviceItem.renderer = self.mainwindow.renderer
serviceItem.set_from_service(item, self.servicePath)
print self._saveLight
if self._saveLight:
serviceItem.set_from_service(item)
else:
serviceItem.set_from_service(item, self.servicePath)
self.validateItem(serviceItem)
self.load_item_uuid = 0
if serviceItem.is_capable(ItemCapabilities.OnLoadUpdate):

View File

@ -120,6 +120,7 @@ class SettingsForm(QtGui.QDialog, Ui_SettingsDialog):
self.generalTab.postSetUp()
self.themesTab.postSetUp()
self.advancedTab.postSetUp()
self.playerTab.postSetUp()
for plugin in self.plugins:
if plugin.settingsTab:
plugin.settingsTab.postSetUp()