From e0bfaf07bc57a949ee4bfaae71d527b48b27f937 Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Tue, 4 May 2010 21:01:45 +0100 Subject: [PATCH] Cleanup and finish bits --- openlp/core/lib/serviceitem.py | 1 + openlp/core/ui/generaltab.py | 3 +- openlp/core/ui/servicemanager.py | 81 +++++++++++-------- .../presentations/presentationplugin.py | 1 + 4 files changed, 52 insertions(+), 34 deletions(-) diff --git a/openlp/core/lib/serviceitem.py b/openlp/core/lib/serviceitem.py index 2f6d973e2..764875f4f 100644 --- a/openlp/core/lib/serviceitem.py +++ b/openlp/core/lib/serviceitem.py @@ -81,6 +81,7 @@ class ServiceItem(object): self.notes = u'' self.from_plugin = False self.capabilities = [] + self.isValid = True def add_capability(self, capability): self.capabilities.append(capability) diff --git a/openlp/core/ui/generaltab.py b/openlp/core/ui/generaltab.py index ac4f92336..cef241aea 100644 --- a/openlp/core/ui/generaltab.py +++ b/openlp/core/ui/generaltab.py @@ -44,7 +44,8 @@ class GeneralTab(SettingsTab): settings = QtCore.QSettings() settings.beginGroup(self.settingsSection) self.MonitorNumber = settings.value(u'monitor', - QtCore.QVariant(self.screens.monitor_number)).toInt()[0] + QtCore.QVariant(self.screens.display_count - 1)).toInt()[0] + print self.MonitorNumber, self.screens.monitor_number, self.screens.display_count, self.screens.screen_list self.screens.set_current_display(self.MonitorNumber) self.screens.monitor_number = self.MonitorNumber self.DisplayOnMonitor = settings.value( diff --git a/openlp/core/ui/servicemanager.py b/openlp/core/ui/servicemanager.py index 03cdbcecc..e13e72794 100644 --- a/openlp/core/ui/servicemanager.py +++ b/openlp/core/ui/servicemanager.py @@ -326,7 +326,7 @@ class ServiceManager(QtGui.QWidget): Called by a signal to select a specific item """ self.setItem(int(message[0])) - + def setItem(self, index): """ Makes a specific item in the service live @@ -495,19 +495,22 @@ class ServiceManager(QtGui.QWidget): for itemcount, item in enumerate(self.serviceItems): serviceitem = item[u'service_item'] treewidgetitem = QtGui.QTreeWidgetItem(self.ServiceManagerList) - if serviceitem.notes: - icon = QtGui.QImage(serviceitem.icon) - icon = icon.scaled(80, 80, QtCore.Qt.KeepAspectRatio, - QtCore.Qt.SmoothTransformation) - overlay = QtGui.QImage(':/services/service_item_notes.png') - overlay = overlay.scaled(80, 80, QtCore.Qt.KeepAspectRatio, - QtCore.Qt.SmoothTransformation) - painter = QtGui.QPainter(icon) - painter.drawImage(0, 0, overlay) - painter.end() - treewidgetitem.setIcon(0, build_icon(icon)) + if serviceitem.isValid: + if serviceitem.notes: + icon = QtGui.QImage(serviceitem.icon) + icon = icon.scaled(80, 80, QtCore.Qt.KeepAspectRatio, + QtCore.Qt.SmoothTransformation) + overlay = QtGui.QImage(':/services/service_item_notes.png') + overlay = overlay.scaled(80, 80, QtCore.Qt.KeepAspectRatio, + QtCore.Qt.SmoothTransformation) + painter = QtGui.QPainter(icon) + painter.drawImage(0, 0, overlay) + painter.end() + treewidgetitem.setIcon(0, build_icon(icon)) + else: + treewidgetitem.setIcon(0, serviceitem.iconic_representation) else: - treewidgetitem.setIcon(0, serviceitem.iconic_representation) + treewidgetitem.setIcon(0, build_icon(u':/general/general_delete.png')) treewidgetitem.setText(0, serviceitem.title) treewidgetitem.setToolTip(0, serviceitem.notes) treewidgetitem.setData(0, QtCore.Qt.UserRole, @@ -651,8 +654,8 @@ class ServiceManager(QtGui.QWidget): serviceitem = ServiceItem() serviceitem.RenderManager = self.parent.RenderManager serviceitem.set_from_service(item, self.servicePath) - if self.validateItem(serviceitem): - self.addServiceItem(serviceitem) + self.validateItem(serviceitem) + self.addServiceItem(serviceitem) try: if os.path.isfile(p_file): os.remove(p_file) @@ -671,12 +674,15 @@ class ServiceManager(QtGui.QWidget): self.parent.serviceChanged(True, self.serviceName) def validateItem(self, serviceItem): -# print "---" -# print serviceItem.name -# print serviceItem.title -# print serviceItem.service_item_path -# print serviceItem.service_item_type - return True + """ + Validates the service item and if the suffix matches an accepted + one it allows the item to be displayed + """ + print serviceItem.title + if serviceItem.is_command(): + type = serviceItem._raw_frames[0][u'title'].split(u'.')[1] + if type not in ['odp']: + serviceItem.isValid = False def cleanUp(self): """ @@ -778,17 +784,26 @@ class ServiceManager(QtGui.QWidget): Send the current item to the Live slide controller """ item, count = self.findServiceItem() - self.parent.LiveController.addServiceManagerItem( - self.serviceItems[item][u'service_item'], count) - if QtCore.QSettings().value( - self.parent.generalSettingsSection + u'/auto preview', - QtCore.QVariant(False)).toBool(): - item += 1 - if self.serviceItems and item < len(self.serviceItems) and \ - self.serviceItems[item][u'service_item'].is_capable( - ItemCapabilities.AllowsPreview): - self.parent.PreviewController.addServiceManagerItem( - self.serviceItems[item][u'service_item'], 0) + if self.serviceItems[item][u'service_item'].isValid: + self.parent.LiveController.addServiceManagerItem( + self.serviceItems[item][u'service_item'], count) + if QtCore.QSettings().value( + self.parent.generalSettingsSection + u'/auto preview', + QtCore.QVariant(False)).toBool(): + item += 1 + if self.serviceItems and item < len(self.serviceItems) and \ + self.serviceItems[item][u'service_item'].is_capable( + ItemCapabilities.AllowsPreview): + self.parent.PreviewController.addServiceManagerItem( + self.serviceItems[item][u'service_item'], 0) + else: + QtGui.QMessageBox.critical(self, + self.trUtf8('Missing Display Handler?'), + self.trUtf8('Your item cannot be display as ' + 'there is no handler to display it?'), + QtGui.QMessageBox.StandardButtons( + QtGui.QMessageBox.Ok), + QtGui.QMessageBox.Ok) def remoteEdit(self): """ @@ -920,7 +935,7 @@ class ServiceManager(QtGui.QWidget): return item.data(0, QtCore.Qt.UserRole).toInt()[0] else: return parentitem.data(0, QtCore.Qt.UserRole).toInt()[0] - + def listRequest(self, message=None): data = [] curindex, count = self.findServiceItem() diff --git a/openlp/plugins/presentations/presentationplugin.py b/openlp/plugins/presentations/presentationplugin.py index dd1a5259b..9a8a5a182 100644 --- a/openlp/plugins/presentations/presentationplugin.py +++ b/openlp/plugins/presentations/presentationplugin.py @@ -53,6 +53,7 @@ class PresentationPlugin(Plugin): log.info(u'Presentations Initialising') Plugin.initialise(self) self.insert_toolbox_item() + presentation_types = [] for controller in self.controllers: if self.controllers[controller].enabled: self.controllers[controller].start_process()