Many fixes and corrections

Adding Presentation code (start)
Add error message to code

bzr-revno: 510
This commit is contained in:
Tim Bentley 2009-08-23 17:52:59 +01:00
commit 97c2a4077d
19 changed files with 89 additions and 116 deletions

View File

@ -45,7 +45,7 @@ class Event(object):
"""
Provides an Event class to encapsulate events within openlp.org.
"""
def __init__(self, event_type, sender, payload=None):
def __init__(self, sender, event_type=EventType.Default, payload=None):
self.event_type = event_type
self.payload = payload
self.sender = sender

View File

@ -122,7 +122,6 @@ class Plugin(object):
self.log = logging.getLogger(self.name)
self.preview_controller = plugin_helpers[u'preview']
self.live_controller = plugin_helpers[u'live']
self.theme_manager = plugin_helpers[u'theme']
self.event_manager = plugin_helpers[u'event']
self.render_manager = plugin_helpers[u'render']
self.service_manager = plugin_helpers[u'service']
@ -132,6 +131,7 @@ class Plugin(object):
def check_pre_conditions(self):
"""
Provides the Plugin with a handle to check if it can be loaded.
Failing Preconditions does not stop a settings Tab being created
Returns True or False.
"""

View File

@ -93,18 +93,20 @@ class PluginManager(object):
for p in plugin_classes:
try:
plugin = p(self.plugin_helpers)
log.debug(u'loaded plugin %s with helpers', unicode(p))
log.debug(u'Plugin: %s', unicode(p))
pList = {u'name': plugin.name, u'version':plugin.version, u'status': u'Inactive'}
if plugin.check_pre_conditions():
log.debug(u'Appending %s ', unicode(p))
plugin_objects.append(plugin)
eventmanager.register(plugin)
pList[u'status'] = u'Active'
self.plugin_list.append(pList)
log.debug(u'Loaded plugin %s with helpers', unicode(p))
plugin_objects.append(plugin)
except TypeError:
log.error(u'loaded plugin %s has no helpers', unicode(p))
self.plugins = sorted(plugin_objects, self.order_by_weight)
plugins_list = sorted(plugin_objects, self.order_by_weight)
for plugin in plugins_list:
pList = {u'plugin': plugin, u'status': u'Inactive'}
if plugin.check_pre_conditions():
log.debug(u'Plugin %s active', unicode(plugin.name))
eventmanager.register(plugin)
pList[u'status'] = u'Active'
self.plugins.append(pList)
def order_by_weight(self, x, y):
"""
@ -127,10 +129,11 @@ class PluginManager(object):
The Media Manager itself.
"""
for plugin in self.plugins:
media_manager_item = plugin.get_media_manager_item()
if media_manager_item is not None:
log.debug(u'Inserting media manager item from %s' % plugin.name)
mediatoolbox.addItem(media_manager_item, plugin.icon, media_manager_item.title)
if plugin[u'status'] == u'Active':
media_manager_item = plugin[u'plugin'].get_media_manager_item()
if media_manager_item is not None:
log.debug(u'Inserting media manager item from %s' % plugin[u'plugin'].name)
mediatoolbox.addItem(media_manager_item, plugin[u'plugin'].icon, media_manager_item.title)
def hook_settings_tabs(self, settingsform=None):
"""
@ -141,12 +144,12 @@ class PluginManager(object):
Defaults to *None*. The settings form to add tabs to.
"""
for plugin in self.plugins:
settings_tab = plugin.get_settings_tab()
settings_tab = plugin[u'plugin'].get_settings_tab()
if settings_tab is not None:
log.debug(u'Inserting settings tab item from %s' % plugin.name)
log.debug(u'Inserting settings tab item from %s' % plugin[u'plugin'].name)
settingsform.addTab(settings_tab)
else:
log.debug(u'No settings in %s' % plugin.name)
log.debug(u'No settings in %s' % plugin[u'plugin'].name)
def hook_import_menu(self, import_menu):
"""
@ -157,7 +160,8 @@ class PluginManager(object):
The Import menu.
"""
for plugin in self.plugins:
plugin.add_import_menu_item(import_menu)
if plugin[u'status'] == u'Active':
plugin[u'plugin'].add_import_menu_item(import_menu)
def hook_export_menu(self, export_menu):
"""
@ -168,7 +172,8 @@ class PluginManager(object):
The Export menu.
"""
for plugin in self.plugins:
plugin.add_export_menu_item(export_menu)
if plugin[u'status'] == u'Active':
plugin[u'plugin'].add_export_menu_item(export_menu)
def initialise_plugins(self):
"""
@ -176,7 +181,8 @@ class PluginManager(object):
initialise themselves.
"""
for plugin in self.plugins:
plugin.initialise()
if plugin[u'status'] == u'Active':
plugin[u'plugin'].initialise()
def finalise_plugins(self):
"""
@ -184,4 +190,5 @@ class PluginManager(object):
clean themselves up
"""
for plugin in self.plugins:
plugin.finalise()
if plugin[u'status'] == u'Active':
plugin[u'plugin'].finalise()

View File

@ -468,7 +468,6 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow):
self.plugin_helpers[u'preview'] = self.PreviewController
self.plugin_helpers[u'live'] = self.LiveController
self.plugin_helpers[u'event'] = self.EventManager
self.plugin_helpers[u'theme'] = self.ThemeManagerContents
self.plugin_helpers[u'render'] = self.RenderManager
self.plugin_helpers[u'service'] = self.ServiceManagerContents
self.plugin_helpers[u'settings'] = self.settingsForm
@ -596,8 +595,7 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow):
def handle_event(self, event):
if event.event_type == EventType.ThemeListChanged:
themes = self.ThemeManagerContents.getThemes()
self.ServiceManagerContents.updateThemeList(themes)
self.settingsForm.ThemesTab.updateThemeList(themes)
self.ServiceManagerContents.updateThemeList(event.payload)
self.settingsForm.ThemesTab.updateThemeList(event.payload)
self.DefaultThemeLabel.setText(self.defaultThemeText + \
self.ThemeManagerContents.getDefault())

View File

@ -58,12 +58,14 @@ class PluginForm(QtGui.QDialog):
"""
Load the plugin details into the screen
"""
for plugin in self.parent.plugin_manager.plugin_list:
#self.PluginViewList.clear()
self.PluginViewList.setRowCount(0)
for plugin in self.parent.plugin_manager.plugins:
row = self.PluginViewList.rowCount()
self.PluginViewList.setRowCount(row + 1)
item1 = QtGui.QTableWidgetItem(plugin[u'name'])
item1 = QtGui.QTableWidgetItem(plugin[u'plugin'].name)
item1.setTextAlignment(QtCore.Qt.AlignVCenter)
item2 = QtGui.QTableWidgetItem(plugin[u'version'])
item2 = QtGui.QTableWidgetItem(plugin[u'plugin'].version)
item2.setTextAlignment(QtCore.Qt.AlignVCenter)
item3 = QtGui.QTableWidgetItem(translate(u'PluginForm', plugin[u'status']))
item3.setTextAlignment(QtCore.Qt.AlignVCenter)

View File

@ -488,7 +488,7 @@ class ServiceManager(QtGui.QWidget):
link = event.mimeData()
if link.hasText():
plugin = event.mimeData().text()
self.parent.EventManager.post_event(Event(EventType.LoadServiceItem, u'ServiceManager', plugin))
self.parent.EventManager.post_event(Event(u'ServiceManager', EventType.LoadServiceItem, plugin))
def updateThemeList(self, theme_list):
"""

View File

@ -184,7 +184,7 @@ class ThemeManager(QtGui.QWidget):
self.pushThemes()
def pushThemes(self):
self.parent.EventManager.post_event(Event(EventType.ThemeListChanged,u'ThemeManager'))
self.parent.EventManager.post_event(Event(u'ThemeManager', EventType.ThemeListChanged, self.getThemes()))
def getThemes(self):
return self.themelist

View File

@ -81,5 +81,5 @@ class BiblePlugin(Plugin):
log.debug(u'Handle event called with event %s with payload %s'%(event.event_type, event.payload))
if event.event_type == EventType.ThemeListChanged:
log.debug(u'New Theme request received')
self.bibles_tab.updateThemeList(self.theme_manager.getThemes())
self.bibles_tab.updateThemeList(event.payload)
return Plugin.handle_event(self, event)

View File

@ -47,6 +47,7 @@ class BibleImportForm(QtGui.QDialog, Ui_BibleImportDialog):
self.bibleplugin = bibleplugin
self.bible_type = None
self.barmax = 0
self.tabWidget.setCurrentIndex(0)
self.AddressEdit.setText(self.config.get_config(u'proxy_address', u''))
self.UsernameEdit.setText(self.config.get_config(u'proxy_username',u''))
self.PasswordEdit.setText(self.config.get_config(u'proxy_password',u''))

View File

@ -25,30 +25,14 @@ import time
from PyQt4 import QtCore, QtGui
from openlp.core.lib import translate, ServiceItem, MediaManagerItem, \
Receiver, contextMenuAction, contextMenuSeparator
Receiver, contextMenuAction, contextMenuSeparator, BaseListWithDnD
from openlp.plugins.bibles.forms import BibleImportForm
from openlp.plugins.bibles.lib.manager import BibleMode
class BibleList(QtGui.QListWidget):
def __init__(self,parent=None,name=None):
QtGui.QListView.__init__(self,parent)
def mouseMoveEvent(self, event):
"""
Drag and drop event does not care what data is selected
as the recepient will use events to request the data move
just tell it what plugin to call
"""
if event.buttons() != QtCore.Qt.LeftButton:
return
drag = QtGui.QDrag(self)
mimeData = QtCore.QMimeData()
drag.setMimeData(mimeData)
mimeData.setText(u'Bibles')
dropAction = drag.start(QtCore.Qt.CopyAction)
if dropAction == QtCore.Qt.CopyAction:
self.close()
class BibleListView(BaseListWithDnD):
def __init__(self, parent=None):
self.PluginName = u'Bibles'
BaseListWithDnD.__init__(self, parent)
class BibleMediaItem(MediaManagerItem):
"""
@ -201,7 +185,7 @@ class BibleMediaItem(MediaManagerItem):
self.SearchTabWidget.addTab(self.AdvancedTab, u'Advanced')
# Add the search tab widget to the page layout
self.PageLayout.addWidget(self.SearchTabWidget)
self.ListView = BibleList()
self.ListView = BibleListView()
self.ListView.setAlternatingRowColors(True)
self.ListView.setSelectionMode(QtGui.QAbstractItemView.ExtendedSelection)
self.ListView.setDragEnabled(True)

View File

@ -57,5 +57,5 @@ class CustomPlugin(Plugin):
log.debug(u'Handle event called with event %s with payload %s'%(event.event_type, event.payload))
if event.event_type == EventType.ThemeListChanged:
log.debug(u'New Theme request received')
self.edit_custom_form.loadThemes(self.theme_manager.getThemes())
self.edit_custom_form.loadThemes(event.payload)
return Plugin.handle_event(self, event)

View File

@ -21,28 +21,12 @@ import logging
from PyQt4 import QtCore, QtGui
from openlp.core.lib import MediaManagerItem, SongXMLParser, ServiceItem, translate, contextMenuAction, contextMenuSeparator
from openlp.core.lib import MediaManagerItem, SongXMLParser, ServiceItem, translate, contextMenuAction, contextMenuSeparator, BaseListWithDnD
class CustomList(QtGui.QListWidget):
def __init__(self,parent=None,name=None):
QtGui.QListView.__init__(self,parent)
def mouseMoveEvent(self, event):
"""
Drag and drop event does not care what data is selected
as the recepient will use events to request the data move
just tell it what plugin to call
"""
if event.buttons() != QtCore.Qt.LeftButton:
return
drag = QtGui.QDrag(self)
mimeData = QtCore.QMimeData()
drag.setMimeData(mimeData)
mimeData.setText(u'Custom')
dropAction = drag.start(QtCore.Qt.CopyAction)
if dropAction == QtCore.Qt.CopyAction:
self.close()
class CustomListView(BaseListWithDnD):
def __init__(self, parent=None):
self.PluginName = u'Custom'
BaseListWithDnD.__init__(self, parent)
class CustomMediaItem(MediaManagerItem):
"""
@ -95,7 +79,7 @@ class CustomMediaItem(MediaManagerItem):
translate(u'CustomMediaItem',u'Add Custom To Service'),
translate(u'CustomMediaItem',u'Add the selected Custom(s) to the service'),
u':/system/system_add.png', self.onCustomAddClick, u'CustomAddItem')
# Add the Customlist widget
# Add the CustomListView widget
self.CustomWidget = QtGui.QWidget(self)
sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum)
sizePolicy.setHorizontalStretch(0)
@ -105,7 +89,7 @@ class CustomMediaItem(MediaManagerItem):
self.CustomWidget.setObjectName(u'CustomWidget')
# Add the Custom widget to the page layout
self.PageLayout.addWidget(self.CustomWidget)
self.ListView = CustomList()
self.ListView = CustomListView()
self.ListView.setAlternatingRowColors(True)
self.ListView.setDragEnabled(True)
self.PageLayout.addWidget(self.ListView)
@ -129,9 +113,9 @@ class CustomMediaItem(MediaManagerItem):
translate(u'CustomMediaItem',u'&Add to Service'), self.onCustomAddClick))
def initialise(self):
self.loadCustomList(self.parent.custommanager.get_all_slides())
self.loadCustomListView(self.parent.custommanager.get_all_slides())
def loadCustomList(self, list):
def loadCustomListView(self, list):
self.ListView.clear()
for CustomSlide in list:
custom_name = QtGui.QListWidgetItem(CustomSlide.title)

View File

@ -32,7 +32,6 @@ from openlp.core.lib import MediaManagerItem, translate
from openlp.plugins.media.lib import MediaTab
from openlp.plugins.media.lib import FileListData
# from listwithpreviews import ListWithPreviews
from openlp.core.lib import MediaManagerItem, ServiceItem, translate, BaseListWithDnD, buildIcon
class MediaListView(BaseListWithDnD):

View File

@ -93,4 +93,3 @@ class PresentationTab(SettingsTab):
def save(self):
self.config.set_config(u'Powerpoint', unicode(self.PowerpointCheckBox.checkState()))
self.config.set_config(u'Impress', unicode(self.ImpressCheckBox.checkState()))
print self.PowerpointCheckBox.checkState(), unicode(self.PowerpointCheckBox.checkState())

View File

@ -67,12 +67,12 @@ class PresentationPlugin(Plugin):
"""
log.debug('check_pre_conditions')
if int(self.config.get_config(u'Powerpoint', 0)) == 2:
if int(self.config.get_config(u'Impress', 0)) == 2:
try:
#Check to see if we have uno installed
import uno
#openoffice = impressController()
self.registerControllers(u'Impress', None)
openoffice = impressController()
self.registerControllers(u'Impress', openoffice)
except:
pass
#If we have no controllers disable plugin
@ -80,3 +80,10 @@ class PresentationPlugin(Plugin):
return True
else:
return False
def finalise(self):
log.debug(u'Finalise')
print self.controllers
for controller in self.controllers:
print controller
self.controllers[controller].kill()

View File

@ -56,9 +56,9 @@ class RemotesPlugin(Plugin):
log.info(u'Sending event %s ', datagram)
pos = datagram.find(u':')
event = unicode(datagram[:pos].lower())
payload = unicode(datagram[pos + 1:])
if event == u'alert':
self.event_manager.post_event(Event(EventType.TriggerAlert, u'RemotePlugin', payload))
self.event_manager.post_event(Event(u'RemotePlugin', EventType.TriggerAlert , unicode(datagram[pos + 1:])))

View File

@ -23,7 +23,7 @@ import logging
from PyQt4 import Qt, QtCore, QtGui
from openlp.core.lib import SongXMLBuilder, SongXMLParser, Event, \
EventType, EventManager
EventType, EventManager, translate
from openlp.plugins.songs.forms import EditVerseForm
from openlp.plugins.songs.lib.models import Song
from editsongdialog import Ui_EditSongDialog
@ -299,22 +299,26 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog):
log.debug(u'Validate Song')
# Lets be nice and assume the data is correct.
valid = True
message = u''
if len(self.TitleEditItem.displayText()) == 0:
valid = False
self.TitleEditItem.setStyleSheet(u'background-color: red; color: white')
message = translate(u'SongFormDialog', u'You need to enter a song title \n')
else:
self.TitleEditItem.setStyleSheet(u'')
if self.VerseListWidget.count() == 0:
valid = False
self.VerseListWidget.setStyleSheet(u'background-color: red; color: white')
message = message + translate(u'SongFormDialog', u'You need to enter some verse text \n')
else:
self.VerseListWidget.setStyleSheet(u'')
if self.AuthorsListView.count() == 0:
valid = False
self.AuthorsListView.setStyleSheet(u'background-color: red; color: white')
message = message + translate(u'SongFormDialog', u'You need to provide an author')
else:
self.AuthorsListView.setStyleSheet(u'')
return valid
return valid, message
def on_TitleEditItem_lostFocus(self):
self.song.title = self.TitleEditItem.text()
@ -345,7 +349,11 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog):
def accept(self):
log.debug(u'accept')
if not self._validate_song():
valid , message = self._validate_song()
if not valid:
QtGui.QMessageBox.critical(self,
translate(u'SongFormDialog', u'Error'), message,
QtGui.QMessageBox.StandardButtons(QtGui.QMessageBox.Ok))
return
self.song.title = unicode(self.TitleEditItem.displayText())
self.song.copyright = unicode(self.CopyrightEditItem.displayText())
@ -356,7 +364,7 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog):
self.processTitle()
self.songmanager.save_song(self.song)
if self.title_change:
self.eventmanager.post_event(Event(EventType.LoadSongList, u'EditSongForm'))
self.eventmanager.post_event(Event(u'EditSongForm', EventType.LoadSongList))
self.close()
def processLyrics(self):

View File

@ -22,29 +22,13 @@ import logging
from PyQt4 import QtCore, QtGui
from openlp.core.lib import MediaManagerItem, translate, ServiceItem, \
SongXMLParser, contextMenuAction, contextMenuSeparator
SongXMLParser, contextMenuAction, contextMenuSeparator, BaseListWithDnD
from openlp.plugins.songs.forms import EditSongForm, SongMaintenanceForm
class SongList(QtGui.QListWidget):
def __init__(self, parent=None, name=None):
QtGui.QListWidget.__init__(self,parent)
def mouseMoveEvent(self, event):
"""
Drag and drop event does not care what data is selected
as the recepient will use events to request the data move
just tell it what plugin to call
"""
if event.buttons() != QtCore.Qt.LeftButton:
return
drag = QtGui.QDrag(self)
mimeData = QtCore.QMimeData()
drag.setMimeData(mimeData)
mimeData.setText(u'Song')
dropAction = drag.start(QtCore.Qt.CopyAction)
if dropAction == QtCore.Qt.CopyAction:
self.close()
class SongListView(BaseListWithDnD):
def __init__(self, parent=None):
self.PluginName = u'Song'
BaseListWithDnD.__init__(self, parent)
class SongMediaItem(MediaManagerItem):
"""
@ -97,7 +81,7 @@ class SongMediaItem(MediaManagerItem):
self.addToolbarButton(translate(u'SongMediaItem', u'Song Maintenance'),
translate(u'SongMediaItem', u'Maintain the lists of authors, topics and books'),
':/songs/song_maintenance.png', self.onSongMaintenanceClick, 'SongMaintenanceItem')
## Add the songlist widget ##
## Add the SongListView widget ##
# Create the tab widget
self.SongWidget = QtGui.QWidget(self)
sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum)
@ -128,7 +112,7 @@ class SongMediaItem(MediaManagerItem):
self.SearchLayout.addWidget(self.SearchTextButton, 3, 2, 1, 1)
# Add the song widget to the page layout
self.PageLayout.addWidget(self.SongWidget)
self.ListView = SongList()
self.ListView = SongListView()
self.ListView.setAlternatingRowColors(True)
self.ListView.setDragEnabled(True)
self.ListView.setObjectName(u'ListView')

View File

@ -136,7 +136,7 @@ class SongsPlugin(Plugin):
log.debug(u'Handle event called with event %s' % event.event_type)
if event.event_type == EventType.ThemeListChanged:
log.debug(u'New Theme request received')
self.media_item.edit_song_form.loadThemes(self.theme_manager.getThemes())
self.media_item.edit_song_form.loadThemes(event.payload)
if event.event_type == EventType.LoadSongList :
log.debug(u'Load Load Song List Item received')
self.media_item.displayResultsSong(self.songmanager.get_songs())