Plugin standardisation and clanups

This commit is contained in:
Tim Bentley 2009-09-26 10:11:39 +01:00
parent 4615f25963
commit 2c64f1186a
7 changed files with 57 additions and 69 deletions

View File

@ -115,10 +115,23 @@ class MediaManagerItem(QtGui.QWidget):
self.PageLayout = QtGui.QVBoxLayout(self)
self.PageLayout.setSpacing(0)
self.PageLayout.setMargin(0)
self.requiredIcons()
self.setupUi()
self.retranslateUi()
self.initialise()
def requiredIcons(self):
"""
This method is called to define the icons for the plugin.
It provides a default set and the plugin is able to override
the if required.
"""
self.hasNewIcon = True
self.hasEditIcon = True
self.hasFileIcon = False
self.hasDeleteIcon = True
def retranslateUi(self):
"""
This method is called automatically to provide OpenLP with the
@ -221,12 +234,13 @@ class MediaManagerItem(QtGui.QWidget):
u':' + self.IconPath + u'_edit.png', self.onEditClick,
self.PluginTextShort + u'EditItem')
## Delete Button ##
self.addToolbarButton(
translate(
self.TranslationContext, u'Delete ' + self.PluginTextShort),
translate(self.TranslationContext, u'Delete the selected item'),
u':' + self.IconPath + u'_delete.png', self.onDeleteClick,
self.PluginTextShort + u'DeleteItem')
if self.hasDeleteIcon:
self.addToolbarButton(
translate(
self.TranslationContext, u'Delete ' + self.PluginTextShort),
translate(self.TranslationContext, u'Delete the selected item'),
u':' + self.IconPath + u'_delete.png', self.onDeleteClick,
self.PluginTextShort + u'DeleteItem')
## Separator Line ##
self.addToolbarSeparator()
## Preview ##

View File

@ -49,38 +49,21 @@ class BibleMediaItem(MediaManagerItem):
self.TranslationContext = u'BiblePlugin'
self.PluginTextShort = u'Bible'
self.ConfigSection = u'bibles'
self.IconPath = u'songs/song'
self.ListViewWithDnD_class = BibleListView
self.ServiceItemIconName = u':/media/bible_image.png'
self.servicePath = None
MediaManagerItem.__init__(self, parent, icon, title)
self.search_results = {} # place to store the search results
QtCore.QObject.connect(Receiver().get_receiver(),
QtCore.SIGNAL(u'openlpreloadbibles'), self.reloadBibles)
def setupUi(self):
# Add a toolbar
self.addToolbar()
# Create buttons for the toolbar
## New Bible Button ##
self.addToolbarButton(translate(u'BibleMediaItem', u'New Bible'),
translate(u'BibleMediaItem', u'Register a new Bible'),
u':/themes/theme_import.png', self.onBibleNewClick, u'BibleNewItem')
## Separator Line ##
self.addToolbarSeparator()
## Preview Bible Button ##
self.addToolbarButton(translate(u'BibleMediaItem', u'Preview Bible'),
translate(u'BibleMediaItem', u'Preview the selected Bible Verse'),
u':/system/system_preview.png', self.onPreviewClick,
u'BiblePreviewItem')
## Live Bible Button ##
self.addToolbarButton(translate(u'BibleMediaItem',u'Go Live'),
translate(u'BibleMediaItem',
u'Send the selected Bible Verse(s) live'),
u':/system/system_live.png', self.onLiveClick, u'BibleLiveItem')
## Add Bible Button ##
self.addToolbarButton(
translate(u'BibleMediaItem', u'Add Bible Verse(s) To Service'),
translate(u'BibleMediaItem',
u'Add the selected Bible(s) to the service'),
u':/system/system_add.png', self.onAddClick, u'BibleAddItem')
# Create the tab widget
def requiredIcons(self):
MediaManagerItem.requiredIcons(self)
self.hasEditIcon = False
self.hasDeleteIcon = False
def addEndHeaderBar(self):
self.SearchTabWidget = QtGui.QTabWidget(self)
sizePolicy = QtGui.QSizePolicy(
QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum)
@ -191,12 +174,6 @@ 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 = BibleListView()
self.ListView.setAlternatingRowColors(True)
self.ListView.setSelectionMode(
QtGui.QAbstractItemView.ExtendedSelection)
self.ListView.setDragEnabled(True)
self.PageLayout.addWidget(self.ListView)
# Combo Boxes
QtCore.QObject.connect(self.AdvancedVersionComboBox,
QtCore.SIGNAL(u'activated(int)'), self.onAdvancedVersionComboBox)
@ -213,20 +190,6 @@ class BibleMediaItem(MediaManagerItem):
QtCore.SIGNAL(u'pressed()'), self.onAdvancedSearchButton)
QtCore.QObject.connect(self.QuickSearchButton,
QtCore.SIGNAL(u'pressed()'), self.onQuickSearchButton)
QtCore.QObject.connect(self.ListView,
QtCore.SIGNAL(u'doubleClicked(QModelIndex)'), self.onPreviewClick)
# Context Menus
self.ListView.setContextMenuPolicy(QtCore.Qt.ActionsContextMenu)
self.ListView.addAction(contextMenuAction(
self.ListView, u':/system/system_preview.png',
translate(u'BibleMediaItem',u'&Preview Verse'),
self.onPreviewClick))
self.ListView.addAction(contextMenuAction(
self.ListView, u':/system/system_live.png',
translate(u'BibleMediaItem',u'&Show Live'), self.onLiveClick))
self.ListView.addAction(contextMenuAction(
self.ListView, u':/system/system_add.png',
translate(u'BibleMediaItem',u'&Add to Service'), self.onAddClick))
def retranslateUi(self):
log.debug(u'retranslateUi')
@ -304,7 +267,7 @@ class BibleMediaItem(MediaManagerItem):
unicode(self.AdvancedVersionComboBox.currentText()),
unicode(self.AdvancedBookComboBox.currentText()))
def onBibleNewClick(self):
def onNewClick(self):
self.bibleimportform = BibleImportForm(
self.parent.config, self.parent.biblemanager, self)
self.bibleimportform.exec_()

View File

@ -46,9 +46,6 @@ class CustomMediaItem(MediaManagerItem):
self.PluginTextShort = u'Custom'
self.ConfigSection = u'custom'
self.IconPath = u'custom/custom'
self.hasFileIcon = False
self.hasNewIcon = True
self.hasEditIcon = True
# this next is a class, not an instance of a class - it will
# be instanced by the base MediaManagerItem
self.ListViewWithDnD_class = CustomListView
@ -57,6 +54,10 @@ class CustomMediaItem(MediaManagerItem):
MediaManagerItem.__init__(self, parent, icon, title)
self.parent = parent
def requiredIcons(self):
MediaManagerItem.requiredIcons(self)
self.hasFileIcon = False
def initialise(self):
self.loadCustomListView(self.parent.custommanager.get_all_slides())

View File

@ -48,9 +48,6 @@ class ImageMediaItem(MediaManagerItem):
self.PluginTextShort = u'Image'
self.ConfigSection = u'images'
self.IconPath = u'images/image'
self.hasFileIcon = True
self.hasNewIcon = False
self.hasEditIcon = False
self.OnNewPrompt = u'Select Image(s)'
self.OnNewFileMasks = u'Images (*.jpg *jpeg *.gif *.png *.bmp)'
# this next is a class, not an instance of a class - it will
@ -61,6 +58,12 @@ class ImageMediaItem(MediaManagerItem):
MediaManagerItem.__init__(self, parent, icon, title)
self.overrideActive = False
def requiredIcons(self):
MediaManagerItem.requiredIcons(self)
self.hasFileIcon = True
self.hasNewIcon = False
self.hasEditIcon = False
def initialise(self):
self.ListView.setSelectionMode(
QtGui.QAbstractItemView.ExtendedSelection)

View File

@ -44,9 +44,6 @@ class MediaMediaItem(MediaManagerItem):
def __init__(self, parent, icon, title):
self.TranslationContext = u'MediaPlugin'
self.hasFileIcon = True
self.hasNewIcon = False
self.hasEditIcon = False
self.IconPath = u'images/image'
self.PluginTextShort = u'Media'
self.ConfigSection = u'images'
@ -59,6 +56,12 @@ class MediaMediaItem(MediaManagerItem):
self.PreviewFunction = self.video_get_preview
MediaManagerItem.__init__(self, parent, icon, title)
def requiredIcons(self):
MediaManagerItem.requiredIcons(self)
self.hasFileIcon = True
self.hasNewIcon = False
self.hasEditIcon = False
def video_get_preview(self, filename):
#
# For now cross platform is an icon. Phonon does not support

View File

@ -51,9 +51,6 @@ class PresentationMediaItem(MediaManagerItem):
self.TranslationContext = u'PresentationPlugin'
self.PluginTextShort = u'Presentation'
self.ConfigSection = u'presentations'
self.hasFileIcon = True
self.hasNewIcon = False
self.hasEditIcon = False
self.IconPath = u'presentations/presentation'
self.OnNewPrompt = u'Select Presentation(s)'
self.OnNewFileMasks = u'Presentations (*.ppt *.pps *.odp)'
@ -63,6 +60,12 @@ class PresentationMediaItem(MediaManagerItem):
MediaManagerItem.__init__(self, parent, icon, title)
self.message_listener = MessageListener(controllers)
def requiredIcons(self):
MediaManagerItem.requiredIcons(self)
self.hasFileIcon = True
self.hasNewIcon = False
self.hasEditIcon = False
def addEndHeaderBar(self):
self.PresentationWidget = QtGui.QWidget(self)
sizePolicy = QtGui.QSizePolicy(

View File

@ -48,9 +48,6 @@ class SongMediaItem(MediaManagerItem):
self.PluginTextShort = u'Song'
self.ConfigSection = u'song'
self.IconPath = u'songs/song'
self.hasFileIcon = False
self.hasNewIcon = True
self.hasEditIcon = True
self.ListViewWithDnD_class = SongListView
self.ServiceItemIconName = u':/media/song_image.png'
self.servicePath = None
@ -59,6 +56,10 @@ class SongMediaItem(MediaManagerItem):
self.song_maintenance_form = SongMaintenanceForm(
self.parent.songmanager, self)
def requiredIcons(self):
MediaManagerItem.requiredIcons(self)
self.hasFileIcon = False
def addEndHeaderBar(self):
self.addToolbarSeparator()
## Song Maintenance Button ##