This commit is contained in:
Tim Bentley 2009-09-11 07:18:31 +01:00
commit b657af7a64
2 changed files with 60 additions and 30 deletions

View File

@ -109,7 +109,8 @@ class Ui_MainWindow(object):
self.MediaManagerDock.setWindowIcon(icon)
self.MediaManagerDock.setFloating(False)
self.MediaManagerDock.setObjectName(u'MediaManagerDock')
self.MediaManagerDock.setMinimumWidth(self.settingsmanager.mainwindow_docbars)
self.MediaManagerDock.setMinimumWidth(
self.settingsmanager.mainwindow_docbars)
self.MediaManagerContents = QtGui.QWidget()
self.MediaManagerContents.setObjectName(u'MediaManagerContents')
self.MediaManagerLayout = QtGui.QHBoxLayout(self.MediaManagerContents)
@ -132,7 +133,8 @@ class Ui_MainWindow(object):
self.ServiceManagerDock.setFeatures(
QtGui.QDockWidget.AllDockWidgetFeatures)
self.ServiceManagerDock.setObjectName(u'ServiceManagerDock')
self.ServiceManagerDock.setMinimumWidth(self.settingsmanager.mainwindow_docbars)
self.ServiceManagerDock.setMinimumWidth(
self.settingsmanager.mainwindow_docbars)
self.ServiceManagerContents = ServiceManager(self)
self.ServiceManagerDock.setWidget(self.ServiceManagerContents)
MainWindow.addDockWidget(
@ -593,8 +595,8 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow):
translate(u'mainWindow', u'Save Changes to Service?'),
translate(u'mainWindow', u'Your service has been changed, do you want to save those changes?'),
QtGui.QMessageBox.StandardButtons(
QtGui.QMessageBox.Cancel | \
QtGui.QMessageBox.Discard | \
QtGui.QMessageBox.Cancel |
QtGui.QMessageBox.Discard |
QtGui.QMessageBox.Save),
QtGui.QMessageBox.Save)
if ret == QtGui.QMessageBox.Save:

View File

@ -101,25 +101,39 @@ class ServiceManager(QtGui.QWidget):
# Create the top toolbar
self.Toolbar = OpenLPToolbar(self)
self.Toolbar.addToolbarButton(u'New Service',
u':/services/service_new.png', translate(u'ServiceManager',
u'Create a new Service'), self.onNewService)
u':/services/service_new.png',
translate(u'ServiceManager', u'Create a new service'),
self.onNewService)
self.Toolbar.addToolbarButton(u'Open Service',
u':/services/service_open.png', translate(u'ServiceManager',
u'Load Existing'), self.onLoadService)
u':/services/service_open.png',
translate(u'ServiceManager', u'Load an existing service'),
self.onLoadService)
self.Toolbar.addToolbarButton(u'Save Service',
u':/services/service_save.png', translate(u'ServiceManager',
u'Save Service'), self.onSaveService)
u':/services/service_save.png',
translate(u'ServiceManager', u'Save this service'),
self.onSaveService)
self.Toolbar.addSeparator()
self.ThemeLabel = QtGui.QLabel(translate(u'ServiceManager', u'Theme:'),
self)
self.ThemeLabel.setMargin(3)
self.Toolbar.addWidget(self.ThemeLabel)
self.ThemeComboBox = QtGui.QComboBox(self.Toolbar)
self.ThemeComboBox.setSizeAdjustPolicy(QtGui.QComboBox.AdjustToContents)
self.ThemeComboBox.setToolTip(translate(u'ServiceManager',
u'Select a theme for the service'))
self.ThemeComboBox.setSizeAdjustPolicy(
QtGui.QComboBox.AdjustToContents)
self.ThemeWidget = QtGui.QWidgetAction(self.Toolbar)
self.ThemeWidget.setDefaultWidget(self.ThemeComboBox)
self.Toolbar.addAction(self.ThemeWidget)
self.Layout.addWidget(self.Toolbar)
# Create the service manager list
self.ServiceManagerList = ServiceManagerList(self)
self.ServiceManagerList.setEditTriggers(QtGui.QAbstractItemView.CurrentChanged|QtGui.QAbstractItemView.DoubleClicked|QtGui.QAbstractItemView.EditKeyPressed)
self.ServiceManagerList.setDragDropMode(QtGui.QAbstractItemView.DragDrop)
self.ServiceManagerList.setEditTriggers(
QtGui.QAbstractItemView.CurrentChanged |
QtGui.QAbstractItemView.DoubleClicked |
QtGui.QAbstractItemView.EditKeyPressed)
self.ServiceManagerList.setDragDropMode(
QtGui.QAbstractItemView.DragDrop)
self.ServiceManagerList.setAlternatingRowColors(True)
self.ServiceManagerList.setHeaderHidden(True)
self.ServiceManagerList.setObjectName(u'ServiceManagerList')
@ -128,14 +142,16 @@ class ServiceManager(QtGui.QWidget):
self.ServiceManagerList.__class__.dragMoveEvent = self.dragEnterEvent
self.ServiceManagerList.__class__.dropEvent = self.dropEvent
# Add a context menu to the service manager list
self.ServiceManagerList.setContextMenuPolicy(QtCore.Qt.ActionsContextMenu)
self.ServiceManagerList.setContextMenuPolicy(
QtCore.Qt.ActionsContextMenu)
self.ServiceManagerList.addAction(contextMenuAction(
self.ServiceManagerList, ':/system/system_preview.png',
translate(u'ServiceManager',u'&Preview Verse'), self.makePreview))
self.ServiceManagerList.addAction(contextMenuAction(
self.ServiceManagerList, ':/system/system_live.png',
translate(u'ServiceManager',u'&Show Live'), self.makeLive))
self.ServiceManagerList.addAction(contextMenuSeparator(self.ServiceManagerList))
self.ServiceManagerList.addAction(contextMenuSeparator(
self.ServiceManagerList))
self.ServiceManagerList.addAction(contextMenuAction(
self.ServiceManagerList, ':/services/service_delete',
translate(u'ServiceManager',u'&Remove from Service'),
@ -151,7 +167,8 @@ class ServiceManager(QtGui.QWidget):
translate(u'ServiceManager', u'Move up order'), self.onServiceUp)
self.OrderToolbar.addToolbarButton(u'Move down',
u':/services/service_down.png',
translate(u'ServiceManager', u'Move down order'), self.onServiceDown)
translate(u'ServiceManager', u'Move down order'),
self.onServiceDown)
self.OrderToolbar.addToolbarButton(u'Move to bottom',
u':/services/service_bottom.png',
translate(u'ServiceManager', u'Move to end'), self.onServiceEnd)
@ -175,7 +192,8 @@ class ServiceManager(QtGui.QWidget):
# Last little bits of setting up
self.config = PluginConfig(u'ServiceManager')
self.servicePath = self.config.get_data_path()
self.service_theme = unicode(self.config.get_config(u'theme service theme', u''))
self.service_theme = unicode(
self.config.get_config(u'theme service theme', u''))
def onMoveSelectionUp(self):
"""
@ -345,7 +363,8 @@ class ServiceManager(QtGui.QWidget):
* An ood which is a pickle of the service items
* All image, presentation and video files needed to run the service.
"""
filename = QtGui.QFileDialog.getSaveFileName(self, u'Save Order of Service',self.config.get_last_dir() )
filename = QtGui.QFileDialog.getSaveFileName(self,
u'Save Order of Service',self.config.get_last_dir() )
filename = unicode(filename)
if filename != u'':
self.config.set_last_dir(filename)
@ -357,7 +376,8 @@ class ServiceManager(QtGui.QWidget):
if item[u'data'].service_item_type == ServiceType.Image or \
item[u'data'].service_item_type == ServiceType.Command:
for frame in item[u'data'].frames:
path_from = unicode(item[u'data'].service_item_path + u'/' + frame[u'title'])
path_from = unicode(os.path.join(
item[u'data'].service_item_path, frame[u'title']))
zip.write(path_from)
file = open(servicefile, u'wb')
cPickle.dump(service, file)
@ -373,10 +393,11 @@ class ServiceManager(QtGui.QWidget):
def onLoadService(self):
"""
Load an existing service from disk and rebuilds the serviceitems
All files retrieved from the zip file are placed in a temporary directory and
will only be used for this service.
All files retrieved from the zip file are placed in a temporary
directory and will only be used for this service.
"""
filename = QtGui.QFileDialog.getOpenFileName(self, u'Open Order of Service',self.config.get_last_dir(),
filename = QtGui.QFileDialog.getOpenFileName(self,
u'Open Order of Service',self.config.get_last_dir(),
u'Services (*.oos)')
filename = unicode(filename)
name = filename.split(os.path.sep)
@ -388,7 +409,8 @@ class ServiceManager(QtGui.QWidget):
themename = None
for file in zip.namelist():
names = file.split(os.path.sep)
file_to = os.path.join(self.servicePath, names[len(names) - 1])
file_to = os.path.join(self.servicePath,
names[len(names) - 1])
file_data = zip.read(file)
f = open(file_to, u'w')
f.write(file_data)
@ -439,11 +461,13 @@ class ServiceManager(QtGui.QWidget):
Service Item to be added
"""
self.serviceItems.append({u'data': item, u'order': len(self.serviceItems)+1, u'expanded':True})
self.serviceItems.append({u'data': item,
u'order': len(self.serviceItems)+1, u'expanded':True})
treewidgetitem = QtGui.QTreeWidgetItem(self.ServiceManagerList)
treewidgetitem.setText(0,item.title)
treewidgetitem.setIcon(0,item.iconic_representation)
treewidgetitem.setData(0, QtCore.Qt.UserRole, QtCore.QVariant(len(self.serviceItems)))
treewidgetitem.setData(0, QtCore.Qt.UserRole,
QtCore.QVariant(len(self.serviceItems)))
treewidgetitem.setExpanded(True)
item.render()
count = 0
@ -451,7 +475,8 @@ class ServiceManager(QtGui.QWidget):
treewidgetitem1 = QtGui.QTreeWidgetItem(treewidgetitem)
text = frame[u'title']
treewidgetitem1.setText(0,text[:40])
treewidgetitem1.setData(0, QtCore.Qt.UserRole,QtCore.QVariant(count))
treewidgetitem1.setData(0, QtCore.Qt.UserRole,
QtCore.QVariant(count))
count = count + 1
self.parent.OosChanged(False, self.serviceName)
@ -460,14 +485,16 @@ class ServiceManager(QtGui.QWidget):
Send the current item to the Preview slide controller
"""
item, count = self.findServiceItem()
self.parent.PreviewController.addServiceManagerItem(self.serviceItems[item][u'data'], count)
self.parent.PreviewController.addServiceManagerItem(
self.serviceItems[item][u'data'], count)
def makeLive(self):
"""
Send the current item to the Live slide controller
"""
item, count = self.findServiceItem()
self.parent.LiveController.addServiceManagerItem(self.serviceItems[item][u'data'], count)
self.parent.LiveController.addServiceManagerItem(
self.serviceItems[item][u'data'], count)
def findServiceItem(self):
"""
@ -523,7 +550,8 @@ class ServiceManager(QtGui.QWidget):
self.ThemeComboBox.addItem(u'')
for theme in theme_list:
self.ThemeComboBox.addItem(theme)
id = self.ThemeComboBox.findText(self.service_theme, QtCore.Qt.MatchExactly)
id = self.ThemeComboBox.findText(self.service_theme,
QtCore.Qt.MatchExactly)
# Not Found
if id == -1:
id = 0