Custom Plugin cleaup

This commit is contained in:
Tim Bentley 2009-09-11 05:54:22 +01:00
parent e0a2e5e1f3
commit 3c3c1f19ce
10 changed files with 324 additions and 217 deletions

View File

@ -173,6 +173,8 @@ class MediaManagerItem(QtGui.QWidget):
""" """
# Add a toolbar # Add a toolbar
self.addToolbar() self.addToolbar()
#Allow the plugin to define it's own header
self.addHeaderBar1()
# Create buttons for the toolbar # Create buttons for the toolbar
## File Button ## ## File Button ##
if self.hasFileIcon: if self.hasFileIcon:
@ -185,13 +187,13 @@ class MediaManagerItem(QtGui.QWidget):
self.addToolbarButton( self.addToolbarButton(
translate(self.TranslationContext, u'New '+self.PluginTextShort), translate(self.TranslationContext, u'New '+self.PluginTextShort),
translate(self.TranslationContext, u'Add a new '+self.PluginTextShort), translate(self.TranslationContext, u'Add a new '+self.PluginTextShort),
u':'+self.IconPath+ u'_load.png', self.onNewClick, self.PluginTextShort+u'NewItem') u':'+self.IconPath+ u'_new.png', self.onNewClick, self.PluginTextShort+u'NewItem')
## Edit Button ## ## Edit Button ##
if self.hasEditIcon: if self.hasEditIcon:
self.addToolbarButton( self.addToolbarButton(
translate(self.TranslationContext, u'Edit '+self.PluginTextShort), translate(self.TranslationContext, u'Edit '+self.PluginTextShort),
translate(self.TranslationContext, u'Edit the selected '+self.PluginTextShort), translate(self.TranslationContext, u'Edit the selected '+self.PluginTextShort),
u':'+self.IconPath+ u'_load.png', self.onEditClick, self.PluginTextShort+u'EditItem') u':'+self.IconPath+ u'_edit.png', self.onEditClick, self.PluginTextShort+u'EditItem')
## Delete Button ## ## Delete Button ##
self.addToolbarButton( self.addToolbarButton(
translate(self.TranslationContext, u'Delete '+self.PluginTextShort), translate(self.TranslationContext, u'Delete '+self.PluginTextShort),
@ -215,7 +217,7 @@ class MediaManagerItem(QtGui.QWidget):
translate(self.TranslationContext, u'Add the selected item(s) to the service'), translate(self.TranslationContext, u'Add the selected item(s) to the service'),
u':/system/system_add.png', self.onAddClick, self.PluginTextShort+u'AddItem') u':/system/system_add.png', self.onAddClick, self.PluginTextShort+u'AddItem')
#Allow the plugin to define it's own header #Allow the plugin to define it's own header
self.addHeaderBar() self.addHeaderBar2()
#Add the List widget #Add the List widget
self.ListView = self.ListViewWithDnD_class() self.ListView = self.ListViewWithDnD_class()
self.ListView.uniformItemSizes = True self.ListView.uniformItemSizes = True
@ -234,7 +236,7 @@ class MediaManagerItem(QtGui.QWidget):
':' +self.IconPath+u'_new.png', ':' +self.IconPath+u'_new.png',
translate(self.TranslationContext, u'&Edit '+self.PluginTextShort), translate(self.TranslationContext, u'&Edit '+self.PluginTextShort),
self.onEditClick)) self.onEditClick))
self.ListView.addAction(self.contextMenuSeparator(self.SongListWidget)) self.ListView.addAction(contextMenuSeparator(self.ListView))
self.ListView.addAction(contextMenuAction( self.ListView.addAction(contextMenuAction(
self.ListView, ':/system/system_preview.png', self.ListView, ':/system/system_preview.png',
translate(self.TranslationContext, u'&Preview '+self.PluginTextShort), translate(self.TranslationContext, u'&Preview '+self.PluginTextShort),
@ -258,7 +260,16 @@ class MediaManagerItem(QtGui.QWidget):
""" """
pass pass
def addHeaderBar(self): def addHeaderBar1(self):
"""
Slot at start of toolbar for pluin to addwidgets
"""
pass
def addHeaderBar2(self):
"""
Slot at end of toolbar for pluin to add widgets
"""
pass pass
def onFileClick(self): def onFileClick(self):

View File

@ -23,10 +23,18 @@ from PyQt4 import QtCore, QtGui
from forms import EditCustomForm from forms import EditCustomForm
from openlp.core.lib import Plugin from openlp.core.lib import Plugin
from openlp.plugins.custom.lib import CustomManager, CustomTab, CustomMediaItem from openlp.plugins.custom.lib import CustomManager, CustomMediaItem
class CustomPlugin(Plugin): class CustomPlugin(Plugin):
"""
This plugin enables the user to create, edit and display
custom slide shows. Custom shows are divided into slides.
Each show is able to have it's own theme.
Custom shows are designed to replace the use of songs where
the songs plugin has become restrictive. Examples could be
Welcome slides, Bible Reading information, Orders of service.
"""
global log global log
log=logging.getLogger(u'CustomPlugin') log=logging.getLogger(u'CustomPlugin')

View File

@ -1,11 +1,22 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4
"""
OpenLP - Open Source Lyrics Projection
Copyright (c) 2008 Raoul Snyman
Portions copyright (c) 2008-2009 Martin Thompson, Tim Bentley,
# Form implementation generated from reading ui file 'editcustomdialog.ui' This program is free software; you can redistribute it and/or modify it under
# the terms of the GNU General Public License as published by the Free Software
# Created: Sat Mar 7 09:01:43 2009 Foundation; version 2 of the License.
# by: PyQt4 UI code generator 4.4.4
# This program is distributed in the hope that it will be useful, but WITHOUT ANY
# WARNING! All changes made in this file will be lost! WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with
this program; if not, write to the Free Software Foundation, Inc., 59 Temple
Place, Suite 330, Boston, MA 02111-1307 USA
"""
from PyQt4 import QtCore, QtGui from PyQt4 import QtCore, QtGui
from openlp.core.lib import translate from openlp.core.lib import translate
@ -15,7 +26,7 @@ class Ui_customEditDialog(object):
customEditDialog.setObjectName(u'customEditDialog') customEditDialog.setObjectName(u'customEditDialog')
customEditDialog.resize(590, 541) customEditDialog.resize(590, 541)
icon = QtGui.QIcon() icon = QtGui.QIcon()
icon.addPixmap(QtGui.QPixmap(u':/icon/openlp-logo-16x16.png'), QtGui.QIcon.Normal, QtGui.QIcon.Off) icon.addPixmap(QtGui.QPixmap(u':/icon/openlp.org-icon-32.bmp'), QtGui.QIcon.Normal, QtGui.QIcon.Off)
customEditDialog.setWindowIcon(icon) customEditDialog.setWindowIcon(icon)
self.gridLayout = QtGui.QGridLayout(customEditDialog) self.gridLayout = QtGui.QGridLayout(customEditDialog)
self.gridLayout.setObjectName(u'gridLayout') self.gridLayout.setObjectName(u'gridLayout')
@ -31,8 +42,8 @@ class Ui_customEditDialog(object):
self.horizontalLayout_4 = QtGui.QHBoxLayout() self.horizontalLayout_4 = QtGui.QHBoxLayout()
self.horizontalLayout_4.setObjectName(u'horizontalLayout_4') self.horizontalLayout_4.setObjectName(u'horizontalLayout_4')
self.VerseListView = QtGui.QListWidget(customEditDialog) self.VerseListView = QtGui.QListWidget(customEditDialog)
self.VerseListView.setObjectName(u'VerseListView')
self.VerseListView.setAlternatingRowColors(True) self.VerseListView.setAlternatingRowColors(True)
self.VerseListView.setObjectName(u'VerseListView')
self.horizontalLayout_4.addWidget(self.VerseListView) self.horizontalLayout_4.addWidget(self.VerseListView)
self.verticalLayout = QtGui.QVBoxLayout() self.verticalLayout = QtGui.QVBoxLayout()
self.verticalLayout.setObjectName(u'verticalLayout') self.verticalLayout.setObjectName(u'verticalLayout')
@ -54,47 +65,49 @@ class Ui_customEditDialog(object):
self.gridLayout.addLayout(self.horizontalLayout_4, 1, 0, 1, 1) self.gridLayout.addLayout(self.horizontalLayout_4, 1, 0, 1, 1)
self.EditWidget = QtGui.QWidget(customEditDialog) self.EditWidget = QtGui.QWidget(customEditDialog)
self.EditWidget.setObjectName(u'EditWidget') self.EditWidget.setObjectName(u'EditWidget')
self.EditLayout = QtGui.QHBoxLayout(self.EditWidget) self.EditLayout_3 = QtGui.QHBoxLayout(self.EditWidget)
self.EditLayout.setSpacing(8) self.EditLayout_3.setSpacing(8)
self.EditLayout.setMargin(0) self.EditLayout_3.setMargin(0)
self.EditLayout.setObjectName(u'EditLayout') self.EditLayout_3.setObjectName(u'EditLayout_3')
self.VerseTextEdit = QtGui.QTextEdit(self.EditWidget) self.VerseTextEdit = QtGui.QTextEdit(self.EditWidget)
self.VerseTextEdit.setObjectName(u'VerseTextEdit') self.VerseTextEdit.setObjectName(u'VerseTextEdit')
self.EditLayout.addWidget(self.VerseTextEdit) self.EditLayout_3.addWidget(self.VerseTextEdit)
self.ButtonWidget = QtGui.QWidget(self.EditWidget) self.ButtonWidge = QtGui.QWidget(self.EditWidget)
self.ButtonWidget.setObjectName(u'ButtonWidget') self.ButtonWidge.setObjectName(u'ButtonWidge')
self.ButtonLayout = QtGui.QVBoxLayout(self.ButtonWidget) self.verticalLayout_2 = QtGui.QVBoxLayout(self.ButtonWidge)
self.ButtonLayout.setSpacing(8) self.verticalLayout_2.setObjectName(u'verticalLayout_2')
self.ButtonLayout.setMargin(0) self.AddButton = QtGui.QPushButton(self.ButtonWidge)
self.ButtonLayout.setObjectName(u'ButtonLayout')
self.AddButton = QtGui.QPushButton(self.ButtonWidget)
self.AddButton.setObjectName(u'AddButton') self.AddButton.setObjectName(u'AddButton')
self.ButtonLayout.addWidget(self.AddButton) self.AddButton.setToolTip(translate(u'customEditDialog', u'Add new slide at bottom'))
self.EditButton = QtGui.QPushButton(self.ButtonWidget) self.verticalLayout_2.addWidget(self.AddButton)
self.EditButton = QtGui.QPushButton(self.ButtonWidge)
self.EditButton.setObjectName(u'EditButton') self.EditButton.setObjectName(u'EditButton')
self.ButtonLayout.addWidget(self.EditButton) self.verticalLayout_2.addWidget(self.EditButton)
self.SaveButton = QtGui.QPushButton(self.ButtonWidget) self.EditAllButton = QtGui.QPushButton(self.ButtonWidge)
self.EditAllButton.setObjectName(u'EditAllButton')
self.verticalLayout_2.addWidget(self.EditAllButton)
self.SaveButton = QtGui.QPushButton(self.ButtonWidge)
self.SaveButton.setObjectName(u'SaveButton') self.SaveButton.setObjectName(u'SaveButton')
self.ButtonLayout.addWidget(self.SaveButton) self.verticalLayout_2.addWidget(self.SaveButton)
self.DeleteButton = QtGui.QPushButton(self.ButtonWidget) self.DeleteButton = QtGui.QPushButton(self.ButtonWidge)
self.DeleteButton.setObjectName(u'DeleteButton') self.DeleteButton.setObjectName(u'DeleteButton')
self.ButtonLayout.addWidget(self.DeleteButton) self.verticalLayout_2.addWidget(self.DeleteButton)
self.ClearButton = QtGui.QPushButton(self.ButtonWidget) self.ClearButton = QtGui.QPushButton(self.ButtonWidge)
self.ClearButton.setObjectName(u'ClearButton') self.ClearButton.setObjectName(u'ClearButton')
self.ButtonLayout.addWidget(self.ClearButton) self.verticalLayout_2.addWidget(self.ClearButton)
spacerItem1 = QtGui.QSpacerItem(20, 40, QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Expanding) spacerItem1 = QtGui.QSpacerItem(20, 40, QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Expanding)
self.ButtonLayout.addItem(spacerItem1) self.verticalLayout_2.addItem(spacerItem1)
self.EditLayout.addWidget(self.ButtonWidget) self.EditLayout_3.addWidget(self.ButtonWidge)
self.gridLayout.addWidget(self.EditWidget, 2, 0, 1, 1) self.gridLayout.addWidget(self.EditWidget, 2, 0, 1, 1)
self.horizontalLayout = QtGui.QHBoxLayout() self.horizontalLayout_3 = QtGui.QHBoxLayout()
self.horizontalLayout.setObjectName(u'horizontalLayout') self.horizontalLayout_3.setObjectName(u'horizontalLayout_3')
self.ThemeLabel = QtGui.QLabel(customEditDialog) self.ThemeLabel = QtGui.QLabel(customEditDialog)
self.ThemeLabel.setObjectName(u'ThemeLabel') self.ThemeLabel.setObjectName(u'ThemeLabel')
self.horizontalLayout.addWidget(self.ThemeLabel) self.horizontalLayout_3.addWidget(self.ThemeLabel)
self.ThemecomboBox = QtGui.QComboBox(customEditDialog) self.ThemeComboBox = QtGui.QComboBox(customEditDialog)
self.ThemecomboBox.setObjectName(u'ThemecomboBox') self.ThemeComboBox.setObjectName(u'ThemeComboBox')
self.horizontalLayout.addWidget(self.ThemecomboBox) self.horizontalLayout_3.addWidget(self.ThemeComboBox)
self.gridLayout.addLayout(self.horizontalLayout, 3, 0, 1, 1) self.gridLayout.addLayout(self.horizontalLayout_3, 3, 0, 1, 1)
self.horizontalLayout_2 = QtGui.QHBoxLayout() self.horizontalLayout_2 = QtGui.QHBoxLayout()
self.horizontalLayout_2.setObjectName(u'horizontalLayout_2') self.horizontalLayout_2.setObjectName(u'horizontalLayout_2')
self.CreditLabel = QtGui.QLabel(customEditDialog) self.CreditLabel = QtGui.QLabel(customEditDialog)
@ -108,24 +121,39 @@ class Ui_customEditDialog(object):
self.buttonBox.setStandardButtons(QtGui.QDialogButtonBox.Cancel|QtGui.QDialogButtonBox.Ok) self.buttonBox.setStandardButtons(QtGui.QDialogButtonBox.Cancel|QtGui.QDialogButtonBox.Ok)
self.buttonBox.setObjectName(u'buttonBox') self.buttonBox.setObjectName(u'buttonBox')
self.gridLayout.addWidget(self.buttonBox, 5, 0, 1, 1) self.gridLayout.addWidget(self.buttonBox, 5, 0, 1, 1)
self.retranslateUi(customEditDialog) self.retranslateUi(customEditDialog)
QtCore.QMetaObject.connectSlotsByName(customEditDialog) QtCore.QMetaObject.connectSlotsByName(customEditDialog)
customEditDialog.setTabOrder(self.TitleEdit, self.VerseTextEdit) customEditDialog.setTabOrder(self.TitleEdit, self.VerseTextEdit)
customEditDialog.setTabOrder(self.VerseTextEdit, self.EditButton) customEditDialog.setTabOrder(self.VerseTextEdit, self.AddButton)
customEditDialog.setTabOrder(self.EditButton, self.SaveButton) customEditDialog.setTabOrder(self.AddButton, self.VerseListView)
customEditDialog.setTabOrder(self.SaveButton, self.CreditEdit) customEditDialog.setTabOrder(self.VerseListView, self.EditButton)
customEditDialog.setTabOrder(self.CreditEdit, self.VerseListView) customEditDialog.setTabOrder(self.EditButton, self.EditAllButton)
customEditDialog.setTabOrder(self.VerseListView, self.AddButton) customEditDialog.setTabOrder(self.EditAllButton, self.SaveButton)
customEditDialog.setTabOrder(self.AddButton, self.DeleteButton) customEditDialog.setTabOrder(self.SaveButton, self.DeleteButton)
customEditDialog.setTabOrder(self.DeleteButton, self.buttonBox) customEditDialog.setTabOrder(self.DeleteButton, self.CreditEdit)
customEditDialog.setTabOrder(self.CreditEdit, self.UpButton)
customEditDialog.setTabOrder(self.UpButton, self.DownButton)
customEditDialog.setTabOrder(self.DownButton, self.ThemeComboBox)
customEditDialog.setTabOrder(self.ThemeComboBox, self.buttonBox)
def retranslateUi(self, customEditDialog): def retranslateUi(self, customEditDialog):
customEditDialog.setWindowTitle(translate(u'customEditDialog', u'Edit Custom Slides')) self.UpButton.setToolTip(translate(u'customEditDialog', u'Move slide Up 1'))
self.TitleLabel.setText(translate(u'customEditDialog', u'Title:')) self.DownButton.setToolTip(translate(u'customEditDialog', u'Move slide down 1'))
self.AddButton.setText(translate(u'customEditDialog', u'Add')) customEditDialog.setWindowTitle(translate(u'customEditDialog', 'Edit Custom Slides'))
self.EditButton.setText(translate(u'customEditDialog', u'Edit')) self.TitleLabel.setText(translate(u'customEditDialog', 'Title:'))
self.SaveButton.setText(translate(u'customEditDialog', u'Save')) self.AddButton.setText(translate(u'customEditDialog', 'Add New'))
self.DeleteButton.setText(translate(u'customEditDialog', u'Delete')) self.AddButton.setToolTip(translate(u'customEditDialog', u'Add new slide at bottom'))
self.ClearButton.setText(translate(u'customEditDialog', u'Clear')) self.EditButton.setText(translate(u'customEditDialog', 'Edit'))
self.ThemeLabel.setText(translate(u'customEditDialog', u'Theme:')) self.EditButton.setToolTip(translate(u'customEditDialog', u'Edit selected slide'))
self.CreditLabel.setText(translate(u'customEditDialog', u'Credits:')) self.EditAllButton.setText(translate(u'customEditDialog', 'Edit All'))
self.EditAllButton.setToolTip(translate(u'customEditDialog', u'Edit all slides'))
self.SaveButton.setText(translate(u'customEditDialog', 'Save'))
self.SaveButton.setToolTip(translate(u'customEditDialog', u'Replace edited slide'))
self.DeleteButton.setText(translate(u'customEditDialog', 'Delete'))
self.DeleteButton.setToolTip(translate(u'customEditDialog', u'Delete selected slide'))
self.ClearButton.setText(translate(u'customEditDialog', 'Clear'))
self.ClearButton.setToolTip(translate(u'customEditDialog', u'Clear edit area'))
self.ThemeLabel.setText(translate(u'customEditDialog', 'Theme:'))
self.ThemeComboBox.setToolTip(translate(u'customEditDialog', u'Set Theme for Slides'))
self.CreditLabel.setText(translate(u'customEditDialog', 'Credits:'))

View File

@ -35,20 +35,33 @@ class EditCustomForm(QtGui.QDialog, Ui_customEditDialog):
#self.parent = parent #self.parent = parent
self.setupUi(self) self.setupUi(self)
# Connecting signals and slots # Connecting signals and slots
QtCore.QObject.connect(self.buttonBox, QtCore.SIGNAL(u'rejected()'), self.rejected) QtCore.QObject.connect(self.buttonBox,
QtCore.QObject.connect(self.buttonBox, QtCore.SIGNAL(u'accepted()'), self.accept) QtCore.SIGNAL(u'rejected()'), self.rejected)
QtCore.QObject.connect(self.AddButton, QtCore.SIGNAL(u'pressed()'), self.onAddButtonPressed) QtCore.QObject.connect(self.buttonBox,
QtCore.QObject.connect(self.EditButton, QtCore.SIGNAL(u'pressed()'), self.onEditButtonPressed) QtCore.SIGNAL(u'accepted()'), self.accept)
QtCore.QObject.connect(self.SaveButton, QtCore.SIGNAL(u'pressed()'), self.onSaveButtonPressed) QtCore.QObject.connect(self.AddButton,
QtCore.QObject.connect(self.DeleteButton, QtCore.SIGNAL(u'pressed()'), self.onDeleteButtonPressed) QtCore.SIGNAL(u'pressed()'), self.onAddButtonPressed)
QtCore.QObject.connect(self.ClearButton, QtCore.SIGNAL(u'pressed()'), self.onClearButtonPressed) QtCore.QObject.connect(self.EditButton,
QtCore.QObject.connect(self.UpButton, QtCore.SIGNAL(u'pressed()'), self.onUpButtonPressed) QtCore.SIGNAL(u'pressed()'), self.onEditButtonPressed)
QtCore.QObject.connect(self.DownButton, QtCore.SIGNAL(u'pressed()'), self.onDownButtonPressed) QtCore.QObject.connect(self.EditAllButton,
QtCore.SIGNAL(u'pressed()'), self.onEditAllButtonPressed)
QtCore.QObject.connect(self.SaveButton,
QtCore.SIGNAL(u'pressed()'), self.onSaveButtonPressed)
QtCore.QObject.connect(self.DeleteButton,
QtCore.SIGNAL(u'pressed()'), self.onDeleteButtonPressed)
QtCore.QObject.connect(self.ClearButton,
QtCore.SIGNAL(u'pressed()'), self.onClearButtonPressed)
QtCore.QObject.connect(self.UpButton,
QtCore.SIGNAL(u'pressed()'), self.onUpButtonPressed)
QtCore.QObject.connect(self.DownButton,
QtCore.SIGNAL(u'pressed()'), self.onDownButtonPressed)
QtCore.QObject.connect(self.VerseListView, QtCore.QObject.connect(self.VerseListView,
QtCore.SIGNAL(u'itemDoubleClicked(QListWidgetItem*)'), self.onVerseListViewSelected) QtCore.SIGNAL(u'itemDoubleClicked(QListWidgetItem*)'),
self.onVerseListViewSelected)
QtCore.QObject.connect(self.VerseListView, QtCore.QObject.connect(self.VerseListView,
QtCore.SIGNAL(u'itemClicked(QListWidgetItem*)'), self.onVerseListViewPressed) QtCore.SIGNAL(u'itemClicked(QListWidgetItem*)'),
self.onVerseListViewPressed)
QtCore.QObject.connect(Receiver.get_receiver(), QtCore.QObject.connect(Receiver.get_receiver(),
QtCore.SIGNAL(u'update_themes'), self.loadThemes) QtCore.SIGNAL(u'update_themes'), self.loadThemes)
# Create other objects and forms # Create other objects and forms
@ -56,23 +69,25 @@ class EditCustomForm(QtGui.QDialog, Ui_customEditDialog):
self.initialise() self.initialise()
def initialise(self): def initialise(self):
self.valid = True self.editAll = False
self.DeleteButton.setEnabled(False) self.DeleteButton.setEnabled(False)
self.EditButton.setEnabled(False) self.EditButton.setEnabled(False)
self.EditAllButton.setEnabled(True)
self.SaveButton.setEnabled(False) self.SaveButton.setEnabled(False)
self.ClearButton.setEnabled(False)
self.TitleEdit.setText(u'') self.TitleEdit.setText(u'')
self.CreditEdit.setText(u'') self.CreditEdit.setText(u'')
self.VerseTextEdit.clear() self.VerseTextEdit.clear()
self.VerseListView.clear() self.VerseListView.clear()
#make sure we have a new item #make sure we have a new item
self.customSlide = CustomSlide() self.customSlide = CustomSlide()
self.ThemecomboBox.addItem(u'') self.ThemeComboBox.addItem(u'')
def loadThemes(self, themelist): def loadThemes(self, themelist):
self.ThemecomboBox.clear() self.ThemeComboBox.clear()
self.ThemecomboBox.addItem(u'') self.ThemeComboBox.addItem(u'')
for themename in themelist: for themename in themelist:
self.ThemecomboBox.addItem(themename) self.ThemeComboBox.addItem(themename)
def loadCustom(self, id): def loadCustom(self, id):
self.customSlide = CustomSlide() self.customSlide = CustomSlide()
@ -87,12 +102,12 @@ class EditCustomForm(QtGui.QDialog, Ui_customEditDialog):
for verse in verseList: for verse in verseList:
self.VerseListView.addItem(verse[1]) self.VerseListView.addItem(verse[1])
theme = unicode(self.customSlide.theme_name) theme = unicode(self.customSlide.theme_name)
id = self.ThemecomboBox.findText(theme, QtCore.Qt.MatchExactly) id = self.ThemeComboBox.findText(theme, QtCore.Qt.MatchExactly)
if id == -1: if id == -1:
id = 0 # Not Found id = 0 # Not Found
self.ThemecomboBox.setCurrentIndex(id) self.ThemeComboBox.setCurrentIndex(id)
else: else:
self.ThemecomboBox.setCurrentIndex(0) self.ThemeComboBox.setCurrentIndex(0)
def accept(self): def accept(self):
valid , message = self._validate() valid , message = self._validate()
@ -111,7 +126,7 @@ class EditCustomForm(QtGui.QDialog, Ui_customEditDialog):
self.customSlide.title = unicode(self.TitleEdit.displayText()) self.customSlide.title = unicode(self.TitleEdit.displayText())
self.customSlide.text = unicode(sxml.extract_xml()) self.customSlide.text = unicode(sxml.extract_xml())
self.customSlide.credits = unicode(self.CreditEdit.displayText()) self.customSlide.credits = unicode(self.CreditEdit.displayText())
self.customSlide.theme_name = unicode(self.ThemecomboBox.currentText()) self.customSlide.theme_name = unicode(self.ThemeComboBox.currentText())
self.custommanager.save_slide(self.customSlide) self.custommanager.save_slide(self.customSlide)
self.close() self.close()
@ -135,6 +150,10 @@ class EditCustomForm(QtGui.QDialog, Ui_customEditDialog):
def onClearButtonPressed(self): def onClearButtonPressed(self):
self.VerseTextEdit.clear() self.VerseTextEdit.clear()
self.editAll = False
self.AddButton.setEnabled(True)
self.EditAllButton.setEnabled(True)
self.SaveButton.setEnabled(False)
def onVerseListViewPressed(self, item): def onVerseListViewPressed(self, item):
self.DeleteButton.setEnabled(True) self.DeleteButton.setEnabled(True)
@ -151,30 +170,52 @@ class EditCustomForm(QtGui.QDialog, Ui_customEditDialog):
def onEditButtonPressed(self): def onEditButtonPressed(self):
self.editText(self.VerseListView.currentItem().text()) self.editText(self.VerseListView.currentItem().text())
def onEditAllButtonPressed(self):
self.editAll = True
self.AddButton.setEnabled(False)
if self.VerseListView.count() > 0:
verse_list = u''
for row in range(0, self.VerseListView.count()):
item = self.VerseListView.item(row)
verse_list += item.text()
verse_list += u'\n---\n'
self.editText(verse_list)
def editText(self, text): def editText(self, text):
self.beforeText = text self.beforeText = text
self.VerseTextEdit.setPlainText(text) self.VerseTextEdit.setPlainText(text)
self.DeleteButton.setEnabled(False) self.DeleteButton.setEnabled(False)
self.EditButton.setEnabled(False) self.EditButton.setEnabled(False)
self.EditAllButton.setEnabled(False)
self.SaveButton.setEnabled(True) self.SaveButton.setEnabled(True)
self.ClearButton.setEnabled(True)
def onSaveButtonPressed(self): def onSaveButtonPressed(self):
self.VerseListView.currentItem().setText(self.VerseTextEdit.toPlainText()) if self.editAll:
#number of lines has change
if len(self.beforeText.split(u'\n')) != len(self.VerseTextEdit.toPlainText().split(u'\n')):
tempList = {}
for row in range(0, self.VerseListView.count()):
tempList[row] = self.VerseListView.item(row).text()
self.VerseListView.clear() self.VerseListView.clear()
for row in range (0, len(tempList)): for row in unicode(self.VerseTextEdit.toPlainText()).split(u'---'):
self.VerseListView.addItem(tempList[row]) self.VerseListView.addItem(row)
self.VerseListView.repaint() else:
self.VerseListView.currentItem().setText(self.VerseTextEdit.toPlainText())
#number of lines has change
if len(self.beforeText.split(u'\n')) != len(self.VerseTextEdit.toPlainText().split(u'\n')):
tempList = {}
for row in range(0, self.VerseListView.count()):
tempList[row] = self.VerseListView.item(row).text()
self.VerseListView.clear()
for row in range (0, len(tempList)):
self.VerseListView.addItem(tempList[row])
self.VerseListView.repaint()
self.AddButton.setEnabled(True)
self.SaveButton.setEnabled(False) self.SaveButton.setEnabled(False)
self.EditButton.setEnabled(False) self.EditButton.setEnabled(False)
self.EditAllButton.setEnabled(True)
self.VerseTextEdit.clear()
def onDeleteButtonPressed(self): def onDeleteButtonPressed(self):
self.VerseListView.takeItem(self.VerseListView.currentRow()) self.VerseListView.takeItem(self.VerseListView.currentRow())
self.EditButton.setEnabled(False) self.EditButton.setEnabled(False)
self.EditAllButton.setEnabled(True)
def _validate(self): def _validate(self):
valid = True valid = True

View File

@ -18,5 +18,4 @@ this program; if not, write to the Free Software Foundation, Inc., 59 Temple
Place, Suite 330, Boston, MA 02111-1307 USA Place, Suite 330, Boston, MA 02111-1307 USA
""" """
from manager import CustomManager from manager import CustomManager
from customtab import CustomTab
from mediaitem import CustomMediaItem from mediaitem import CustomMediaItem

View File

@ -1,33 +0,0 @@
# -*- coding: utf-8 -*-
# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4
"""
OpenLP - Open Source Lyrics Projection
Copyright (c) 2008 Raoul Snyman
Portions copyright (c) 2008 - 2009 Martin Thompson, Tim Bentley,
This program is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software
Foundation; version 2 of the License.
This program is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with
this program; if not, write to the Free Software Foundation, Inc., 59 Temple
Place, Suite 330, Boston, MA 02111-1307 USA
"""
from PyQt4 import QtCore, QtGui
from openlp.core.lib import SettingsTab, translate
class CustomTab(SettingsTab):
"""
SongsTab is the songs settings tab in the settings dialog.
"""
def __init__(self):
SettingsTab.__init__(self, translate(u'CustomTab', u'Custom'), u'Custom')
def setupUi(self):
self.setObjectName(u'CustomTab')

View File

@ -21,7 +21,8 @@ import logging
from PyQt4 import QtCore, QtGui from PyQt4 import QtCore, QtGui
from openlp.core.lib import MediaManagerItem, SongXMLParser, ServiceItem, translate, contextMenuAction, contextMenuSeparator, BaseListWithDnD from openlp.core.lib import MediaManagerItem, SongXMLParser, ServiceItem, \
translate, contextMenuAction, contextMenuSeparator, BaseListWithDnD
class CustomListView(BaseListWithDnD): class CustomListView(BaseListWithDnD):
def __init__(self, parent=None): def __init__(self, parent=None):
@ -40,77 +41,86 @@ class CustomMediaItem(MediaManagerItem):
self.TranslationContext = u'CustomPlugin' self.TranslationContext = u'CustomPlugin'
self.PluginTextShort = u'Custom' self.PluginTextShort = u'Custom'
self.ConfigSection = 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
self.ServiceItemIconName = u':/custom/custom_image.png'
self.servicePath = None
MediaManagerItem.__init__(self, parent, icon, title) MediaManagerItem.__init__(self, parent, icon, title)
self.parent = parent self.parent = parent
def setupUi(self): # def addHeaderBar(self):
# Add a toolbar # # Add a toolbar
self.addToolbar() # self.addToolbar()
# Create buttons for the toolbar # # Create buttons for the toolbar
## New Custom Button ## # ## New Custom Button ##
self.addToolbarButton( # self.addToolbarButton(
translate(u'CustomMediaItem',u'New Custom Item'), # translate(u'CustomMediaItem',u'New Custom Item'),
translate(u'CustomMediaItem',u'Add a new Custom Item'), # translate(u'CustomMediaItem',u'Add a new Custom Item'),
u':/custom/custom_new.png', self.onCustomNewClick, u'CustomNewItem') # u':/custom/custom_new.png', self.onCustomNewClick, u'CustomNewItem')
## Edit Custom Button ## # ## Edit Custom Button ##
self.addToolbarButton( # self.addToolbarButton(
translate(u'CustomMediaItem',u'Edit Custom Item'), # translate(u'CustomMediaItem',u'Edit Custom Item'),
translate(u'CustomMediaItem',u'Edit the selected Custom Item'), # translate(u'CustomMediaItem',u'Edit the selected Custom Item'),
u':/custom/custom_edit.png', self.onCustomEditClick, u'CustomEditItem') # u':/custom/custom_edit.png', self.onCustomEditClick, u'CustomEditItem')
## Delete Custom Button ## # ## Delete Custom Button ##
self.addToolbarButton( # self.addToolbarButton(
translate(u'CustomMediaItem',u'Delete Custom Item'), # translate(u'CustomMediaItem',u'Delete Custom Item'),
translate(u'CustomMediaItem',u'Delete the selected Custom Item'), # translate(u'CustomMediaItem',u'Delete the selected Custom Item'),
u':/custom/custom_delete.png', self.onCustomDeleteClick, u'CustomDeleteItem') # u':/custom/custom_delete.png', self.onCustomDeleteClick, u'CustomDeleteItem')
## Separator Line ## # ## Separator Line ##
self.addToolbarSeparator() # self.addToolbarSeparator()
## Preview Custom Button ## # ## Preview Custom Button ##
self.addToolbarButton( # self.addToolbarButton(
translate(u'CustomMediaItem',u'Preview Custom Item'), # translate(u'CustomMediaItem',u'Preview Custom Item'),
translate(u'CustomMediaItem',u'Preview the selected Custom Item'), # translate(u'CustomMediaItem',u'Preview the selected Custom Item'),
u':/system/system_preview.png', self.onPreviewClick, u'CustomPreviewItem') # u':/system/system_preview.png', self.onPreviewClick, u'CustomPreviewItem')
## Live Custom Button ## # ## Live Custom Button ##
self.addToolbarButton( # self.addToolbarButton(
translate(u'CustomMediaItem',u'Go Live'), # translate(u'CustomMediaItem',u'Go Live'),
translate(u'CustomMediaItem', u'Send the selected Custom live'), # translate(u'CustomMediaItem', u'Send the selected Custom live'),
u':/system/system_live.png', self.onLiveClick, u'CustomLiveItem') # u':/system/system_live.png', self.onLiveClick, u'CustomLiveItem')
## Add Custom Button ## # ## Add Custom Button ##
self.addToolbarButton( # self.addToolbarButton(
translate(u'CustomMediaItem',u'Add Custom To Service'), # translate(u'CustomMediaItem',u'Add Custom To Service'),
translate(u'CustomMediaItem',u'Add the selected Custom(s) to the service'), # translate(u'CustomMediaItem',u'Add the selected Custom(s) to the service'),
u':/system/system_add.png', self.onAddClick, u'CustomAddItem') # u':/system/system_add.png', self.onAddClick, u'CustomAddItem')
# Add the CustomListView widget # # Add the CustomListView widget
self.CustomWidget = QtGui.QWidget(self) # self.CustomWidget = QtGui.QWidget(self)
sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum) # sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum)
sizePolicy.setHorizontalStretch(0) # sizePolicy.setHorizontalStretch(0)
sizePolicy.setVerticalStretch(0) # sizePolicy.setVerticalStretch(0)
sizePolicy.setHeightForWidth(self.CustomWidget.sizePolicy().hasHeightForWidth()) # sizePolicy.setHeightForWidth(self.CustomWidget.sizePolicy().hasHeightForWidth())
self.CustomWidget.setSizePolicy(sizePolicy) # self.CustomWidget.setSizePolicy(sizePolicy)
self.CustomWidget.setObjectName(u'CustomWidget') # self.CustomWidget.setObjectName(u'CustomWidget')
# Add the Custom widget to the page layout # # Add the Custom widget to the page layout
self.PageLayout.addWidget(self.CustomWidget) # self.PageLayout.addWidget(self.CustomWidget)
self.ListView = CustomListView() # self.ListView = CustomListView()
self.ListView.setAlternatingRowColors(True) # self.ListView.setAlternatingRowColors(True)
self.ListView.setDragEnabled(True) # self.ListView.setDragEnabled(True)
self.PageLayout.addWidget(self.ListView) # self.PageLayout.addWidget(self.ListView)
# Signals # # Signals
QtCore.QObject.connect(self.ListView, # QtCore.QObject.connect(self.ListView,
QtCore.SIGNAL(u'doubleClicked(QModelIndex)'), self.onPreviewClick) # QtCore.SIGNAL(u'doubleClicked(QModelIndex)'), self.onPreviewClick)
#define and add the context menu # #define and add the context menu
self.ListView.setContextMenuPolicy(QtCore.Qt.ActionsContextMenu) # self.ListView.setContextMenuPolicy(QtCore.Qt.ActionsContextMenu)
self.ListView.addAction(contextMenuAction(self.ListView, # self.ListView.addAction(contextMenuAction(self.ListView,
':/custom/custom_edit.png', translate(u'CustomMediaItem', u'&Edit Custom'), # ':/custom/custom_edit.png', translate(u'CustomMediaItem', u'&Edit Custom'),
self.onCustomEditClick)) # self.onCustomEditClick))
self.ListView.addAction(contextMenuSeparator(self.ListView)) # self.ListView.addAction(contextMenuSeparator(self.ListView))
self.ListView.addAction(contextMenuAction( # self.ListView.addAction(contextMenuAction(
self.ListView, ':/system/system_preview.png', # self.ListView, ':/system/system_preview.png',
translate(u'CustomMediaItem',u'&Preview Custom'), self.onPreviewClick)) # translate(u'CustomMediaItem',u'&Preview Custom'), self.onPreviewClick))
self.ListView.addAction(contextMenuAction( # self.ListView.addAction(contextMenuAction(
self.ListView, ':/system/system_live.png', # self.ListView, ':/system/system_live.png',
translate(u'CustomMediaItem',u'&Show Live'), self.onLiveClick)) # translate(u'CustomMediaItem',u'&Show Live'), self.onLiveClick))
self.ListView.addAction(contextMenuAction( # self.ListView.addAction(contextMenuAction(
self.ListView, ':/system/system_add.png', # self.ListView, ':/system/system_add.png',
translate(u'CustomMediaItem',u'&Add to Service'), self.onAddClick)) # translate(u'CustomMediaItem',u'&Add to Service'), self.onAddClick))
def initialise(self): def initialise(self):
self.loadCustomListView(self.parent.custommanager.get_all_slides()) self.loadCustomListView(self.parent.custommanager.get_all_slides())
@ -122,12 +132,12 @@ class CustomMediaItem(MediaManagerItem):
custom_name.setData(QtCore.Qt.UserRole, QtCore.QVariant(CustomSlide.id)) custom_name.setData(QtCore.Qt.UserRole, QtCore.QVariant(CustomSlide.id))
self.ListView.addItem(custom_name) self.ListView.addItem(custom_name)
def onCustomNewClick(self): def onNewClick(self):
self.parent.edit_custom_form.loadCustom(0) self.parent.edit_custom_form.loadCustom(0)
self.parent.edit_custom_form.exec_() self.parent.edit_custom_form.exec_()
self.initialise() self.initialise()
def onCustomEditClick(self): def onEditClick(self):
item = self.ListView.currentItem() item = self.ListView.currentItem()
if item is not None: if item is not None:
item_id = (item.data(QtCore.Qt.UserRole)).toInt()[0] item_id = (item.data(QtCore.Qt.UserRole)).toInt()[0]
@ -135,7 +145,7 @@ class CustomMediaItem(MediaManagerItem):
self.parent.edit_custom_form.exec_() self.parent.edit_custom_form.exec_()
self.initialise() self.initialise()
def onCustomDeleteClick(self): def onDeleteClick(self):
item = self.ListView.currentItem() item = self.ListView.currentItem()
if item is not None: if item is not None:
item_id = (item.data(QtCore.Qt.UserRole)).toInt()[0] item_id = (item.data(QtCore.Qt.UserRole)).toInt()[0]

View File

@ -48,7 +48,6 @@ class ImageMediaItem(MediaManagerItem):
self.hasEditIcon = False self.hasEditIcon = False
self.OnNewPrompt = u'Select Image(s)' self.OnNewPrompt = u'Select Image(s)'
self.OnNewFileMasks = u'Images (*.jpg *jpeg *.gif *.png *.bmp)' self.OnNewFileMasks = u'Images (*.jpg *jpeg *.gif *.png *.bmp)'
self.slidecontroller = u'image'
# this next is a class, not an instance of a class - it will # this next is a class, not an instance of a class - it will
# be instanced by the base MediaManagerItem # be instanced by the base MediaManagerItem
self.ListViewWithDnD_class = ImageListView self.ListViewWithDnD_class = ImageListView

View File

@ -57,7 +57,7 @@ class PresentationMediaItem(MediaManagerItem):
MediaManagerItem.__init__(self, parent, icon, title) MediaManagerItem.__init__(self, parent, icon, title)
self.message_listener = MessageListener(controllers) self.message_listener = MessageListener(controllers)
def addHeaderBar(self): def addHeaderBar2(self):
self.PresentationWidget = QtGui.QWidget(self) self.PresentationWidget = QtGui.QWidget(self)
sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum) sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum)
sizePolicy.setHorizontalStretch(0) sizePolicy.setHorizontalStretch(0)

View File

@ -14,7 +14,7 @@
<string>Edit Custom Slides</string> <string>Edit Custom Slides</string>
</property> </property>
<property name="windowIcon"> <property name="windowIcon">
<iconset resource="../images/openlp-2.qrc"> <iconset>
<normaloff>:/icon/openlp.org-icon-32.bmp</normaloff>:/icon/openlp.org-icon-32.bmp</iconset> <normaloff>:/icon/openlp.org-icon-32.bmp</normaloff>:/icon/openlp.org-icon-32.bmp</iconset>
</property> </property>
<layout class="QGridLayout" name="gridLayout"> <layout class="QGridLayout" name="gridLayout">
@ -35,12 +35,19 @@
<item row="1" column="0"> <item row="1" column="0">
<layout class="QHBoxLayout" name="horizontalLayout_4"> <layout class="QHBoxLayout" name="horizontalLayout_4">
<item> <item>
<widget class="QListWidget" name="VerseListView"/> <widget class="QListWidget" name="VerseListView">
<property name="alternatingRowColors">
<bool>true</bool>
</property>
</widget>
</item> </item>
<item> <item>
<layout class="QVBoxLayout" name="verticalLayout"> <layout class="QVBoxLayout" name="verticalLayout">
<item> <item>
<widget class="QPushButton" name="UpButton"> <widget class="QPushButton" name="UpButton">
<property name="toolTip">
<string extracomment="Move selected slide up one"/>
</property>
<property name="text"> <property name="text">
<string/> <string/>
</property> </property>
@ -65,6 +72,9 @@
</item> </item>
<item> <item>
<widget class="QPushButton" name="DownButton"> <widget class="QPushButton" name="DownButton">
<property name="toolTip">
<string extracomment="Move selected slide down one"/>
</property>
<property name="text"> <property name="text">
<string/> <string/>
</property> </property>
@ -88,33 +98,46 @@
<number>0</number> <number>0</number>
</property> </property>
<item> <item>
<widget class="QTextEdit" name="VerseTextEdit_3"/> <widget class="QTextEdit" name="VerseTextEdit"/>
</item> </item>
<item> <item>
<widget class="QWidget" name="ButtonWidge" native="true"> <widget class="QWidget" name="ButtonWidge" native="true">
<layout class="QVBoxLayout" name="ButtonLayout_3"> <layout class="QVBoxLayout" name="verticalLayout_2">
<property name="spacing">
<number>8</number>
</property>
<property name="margin">
<number>0</number>
</property>
<item> <item>
<widget class="QPushButton" name="AddButton_3"> <widget class="QPushButton" name="AddButton">
<property name="toolTip">
<string extracomment="Adds a new slide at bottom of list"/>
</property>
<property name="text"> <property name="text">
<string>Add</string> <string>Add New</string>
</property> </property>
</widget> </widget>
</item> </item>
<item> <item>
<widget class="QPushButton" name="EditButton_3"> <widget class="QPushButton" name="EditButton">
<property name="toolTip">
<string extracomment="Edit selected slide"/>
</property>
<property name="text"> <property name="text">
<string>Edit</string> <string>Edit</string>
</property> </property>
</widget> </widget>
</item> </item>
<item> <item>
<widget class="QPushButton" name="SaveButton_3"> <widget class="QPushButton" name="EditAllButton">
<property name="toolTip">
<string extracomment="Edit all slides"/>
</property>
<property name="text">
<string>Edit All</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="SaveButton">
<property name="toolTip">
<string extracomment="Save changed slide"/>
</property>
<property name="text"> <property name="text">
<string>Save</string> <string>Save</string>
</property> </property>
@ -122,11 +145,24 @@
</item> </item>
<item> <item>
<widget class="QPushButton" name="DeleteButton"> <widget class="QPushButton" name="DeleteButton">
<property name="toolTip">
<string extracomment="Delete selected slide"/>
</property>
<property name="text"> <property name="text">
<string>Delete</string> <string>Delete</string>
</property> </property>
</widget> </widget>
</item> </item>
<item>
<widget class="QPushButton" name="ClearButton">
<property name="toolTip">
<string extracomment="Clear selection"/>
</property>
<property name="text">
<string>Clear</string>
</property>
</widget>
</item>
<item> <item>
<spacer name="ButtonSpacer"> <spacer name="ButtonSpacer">
<property name="orientation"> <property name="orientation">
@ -156,7 +192,11 @@
</widget> </widget>
</item> </item>
<item> <item>
<widget class="QComboBox" name="ThemecomboBox"/> <widget class="QComboBox" name="ThemeComboBox">
<property name="toolTip">
<string extracomment="Select custom theme for slide"/>
</property>
</widget>
</item> </item>
</layout> </layout>
</item> </item>
@ -185,13 +225,17 @@
</widget> </widget>
<tabstops> <tabstops>
<tabstop>TitleEdit</tabstop> <tabstop>TitleEdit</tabstop>
<tabstop>VerseTextEdit_3</tabstop> <tabstop>VerseTextEdit</tabstop>
<tabstop>EditButton_3</tabstop> <tabstop>AddButton</tabstop>
<tabstop>SaveButton_3</tabstop>
<tabstop>CreditEdit</tabstop>
<tabstop>VerseListView</tabstop> <tabstop>VerseListView</tabstop>
<tabstop>AddButton_3</tabstop> <tabstop>EditButton</tabstop>
<tabstop>EditAllButton</tabstop>
<tabstop>SaveButton</tabstop>
<tabstop>DeleteButton</tabstop> <tabstop>DeleteButton</tabstop>
<tabstop>CreditEdit</tabstop>
<tabstop>UpButton</tabstop>
<tabstop>DownButton</tabstop>
<tabstop>ThemeComboBox</tabstop>
<tabstop>buttonBox</tabstop> <tabstop>buttonBox</tabstop>
</tabstops> </tabstops>
<resources> <resources>