openlp-core team mailing list archive
-
openlp-core team
-
Mailing list archive
-
Message #04151
[Merge] lp:~googol-hush/openlp/custom into lp:openlp
Andreas Preikschat has proposed merging lp:~googol-hush/openlp/custom into lp:openlp.
Requested reviews:
Raoul Snyman (raoul-snyman)
Tim Bentley (trb143)
Hello!
- reworked the custom slide editor
It is the first time I've done something like that....
(And by the way I replaced "verse" by slide where I could, because both terms were used.)
--
https://code.launchpad.net/~googol-hush/openlp/custom/+merge/38096
Your team OpenLP Core is subscribed to branch lp:openlp.
=== modified file 'openlp/plugins/custom/forms/__init__.py'
--- openlp/plugins/custom/forms/__init__.py 2010-09-14 18:18:47 +0000
+++ openlp/plugins/custom/forms/__init__.py 2010-10-11 07:49:43 +0000
@@ -25,3 +25,4 @@
###############################################################################
from editcustomform import EditCustomForm
+from editcustomslideform import EditCustomSlideForm
=== modified file 'openlp/plugins/custom/forms/editcustomdialog.py'
--- openlp/plugins/custom/forms/editcustomdialog.py 2010-09-14 18:18:47 +0000
+++ openlp/plugins/custom/forms/editcustomdialog.py 2010-10-11 07:49:43 +0000
@@ -26,7 +26,7 @@
from PyQt4 import QtCore, QtGui
-from openlp.core.lib import build_icon, translate, SpellTextEdit
+from openlp.core.lib import build_icon, translate
class Ui_CustomEditDialog(object):
def setupUi(self, customEditDialog):
@@ -36,76 +36,6 @@
build_icon(u':/icon/openlp.org-icon-32.bmp'))
self.gridLayout = QtGui.QGridLayout(customEditDialog)
self.gridLayout.setObjectName(u'gridLayout')
- self.horizontalLayout = QtGui.QHBoxLayout()
- self.horizontalLayout.setObjectName(u'horizontalLayout')
- self.titleLabel = QtGui.QLabel(customEditDialog)
- self.titleLabel.setObjectName(u'titleLabel')
- self.horizontalLayout.addWidget(self.titleLabel)
- self.titleEdit = QtGui.QLineEdit(customEditDialog)
- self.titleLabel.setBuddy(self.titleEdit)
- self.titleEdit.setObjectName(u'titleEdit')
- self.horizontalLayout.addWidget(self.titleEdit)
- self.gridLayout.addLayout(self.horizontalLayout, 0, 0, 1, 1)
- self.horizontalLayout4 = QtGui.QHBoxLayout()
- self.horizontalLayout4.setObjectName(u'horizontalLayout4')
- self.verseListView = QtGui.QListWidget(customEditDialog)
- self.verseListView.setAlternatingRowColors(True)
- self.verseListView.setObjectName(u'verseListView')
- self.horizontalLayout4.addWidget(self.verseListView)
- self.verticalLayout = QtGui.QVBoxLayout()
- self.verticalLayout.setObjectName(u'verticalLayout')
- self.upButton = QtGui.QPushButton(customEditDialog)
- self.upButton.setIcon(build_icon(u':/services/service_up.png'))
- self.upButton.setObjectName(u'upButton')
- self.verticalLayout.addWidget(self.upButton)
- spacerItem = QtGui.QSpacerItem(20, 128, QtGui.QSizePolicy.Minimum,
- QtGui.QSizePolicy.Expanding)
- self.verticalLayout.addItem(spacerItem)
- self.downButton = QtGui.QPushButton(customEditDialog)
- self.downButton.setIcon(build_icon(u':/services/service_down.png'))
- self.downButton.setObjectName(u'downButton')
- self.verticalLayout.addWidget(self.downButton)
- self.horizontalLayout4.addLayout(self.verticalLayout)
- self.gridLayout.addLayout(self.horizontalLayout4, 1, 0, 1, 1)
- self.editWidget = QtGui.QWidget(customEditDialog)
- self.editWidget.setObjectName(u'editWidget')
- self.editLayout3 = QtGui.QHBoxLayout(self.editWidget)
- self.editLayout3.setSpacing(8)
- self.editLayout3.setMargin(0)
- self.editLayout3.setObjectName(u'editLayout3')
- self.verseTextEdit = SpellTextEdit(self)
- self.verseTextEdit.setObjectName(u'verseTextEdit')
- self.editLayout3.addWidget(self.verseTextEdit)
- self.buttonWidget = QtGui.QWidget(self.editWidget)
- self.buttonWidget.setObjectName(u'buttonWidget')
- self.verticalLayout2 = QtGui.QVBoxLayout(self.buttonWidget)
- self.verticalLayout2.setObjectName(u'verticalLayout2')
- self.addButton = QtGui.QPushButton(self.buttonWidget)
- self.addButton.setObjectName(u'addButton')
- self.verticalLayout2.addWidget(self.addButton)
- self.editButton = QtGui.QPushButton(self.buttonWidget)
- self.editButton.setObjectName(u'editButton')
- self.verticalLayout2.addWidget(self.editButton)
- self.editAllButton = QtGui.QPushButton(self.buttonWidget)
- self.editAllButton.setObjectName(u'editAllButton')
- self.verticalLayout2.addWidget(self.editAllButton)
- self.saveButton = QtGui.QPushButton(self.buttonWidget)
- self.saveButton.setObjectName(u'saveButton')
- self.verticalLayout2.addWidget(self.saveButton)
- self.deleteButton = QtGui.QPushButton(self.buttonWidget)
- self.deleteButton.setObjectName(u'deleteButton')
- self.verticalLayout2.addWidget(self.deleteButton)
- self.clearButton = QtGui.QPushButton(self.buttonWidget)
- self.clearButton.setObjectName(u'clearButton')
- self.verticalLayout2.addWidget(self.clearButton)
- self.splitButton = QtGui.QPushButton(self.buttonWidget)
- self.splitButton.setObjectName(u'splitButton')
- self.verticalLayout2.addWidget(self.splitButton)
- spacerItem1 = QtGui.QSpacerItem(20, 40, QtGui.QSizePolicy.Minimum,
- QtGui.QSizePolicy.Expanding)
- self.verticalLayout2.addItem(spacerItem1)
- self.editLayout3.addWidget(self.buttonWidget)
- self.gridLayout.addWidget(self.editWidget, 2, 0, 1, 1)
self.horizontalLayout3 = QtGui.QHBoxLayout()
self.horizontalLayout3.setObjectName(u'horizontalLayout3')
self.themeLabel = QtGui.QLabel(customEditDialog)
@@ -115,7 +45,7 @@
self.themeLabel.setBuddy(self.themeComboBox)
self.themeComboBox.setObjectName(u'themeComboBox')
self.horizontalLayout3.addWidget(self.themeComboBox)
- self.gridLayout.addLayout(self.horizontalLayout3, 3, 0, 1, 1)
+ self.gridLayout.addLayout(self.horizontalLayout3, 2, 0, 1, 1)
self.horizontalLayout2 = QtGui.QHBoxLayout()
self.horizontalLayout2.setObjectName(u'horizontalLayout2')
self.creditLabel = QtGui.QLabel(customEditDialog)
@@ -125,12 +55,61 @@
self.creditLabel.setBuddy(self.creditEdit)
self.creditEdit.setObjectName(u'creditEdit')
self.horizontalLayout2.addWidget(self.creditEdit)
- self.gridLayout.addLayout(self.horizontalLayout2, 4, 0, 1, 1)
+ self.gridLayout.addLayout(self.horizontalLayout2, 3, 0, 1, 1)
self.buttonBox = QtGui.QDialogButtonBox(customEditDialog)
self.buttonBox.setStandardButtons(QtGui.QDialogButtonBox.Cancel |
QtGui.QDialogButtonBox.Save)
self.buttonBox.setObjectName(u'buttonBox')
- self.gridLayout.addWidget(self.buttonBox, 5, 0, 1, 1)
+ self.gridLayout.addWidget(self.buttonBox, 4, 0, 1, 1)
+ self.horizontalLayout4 = QtGui.QHBoxLayout()
+ self.horizontalLayout4.setObjectName(u'horizontalLayout4')
+ self.slideListView = QtGui.QListWidget(customEditDialog)
+ self.slideListView.setAlternatingRowColors(True)
+ self.slideListView.setObjectName(u'slideListView')
+ self.horizontalLayout4.addWidget(self.slideListView)
+ self.verticalLayout = QtGui.QVBoxLayout()
+ self.verticalLayout.setObjectName(u'verticalLayout')
+ self.addButton = QtGui.QPushButton(customEditDialog)
+ self.addButton.setObjectName(u'addButton')
+ self.verticalLayout.addWidget(self.addButton)
+ self.editButton = QtGui.QPushButton(customEditDialog)
+ self.editButton.setObjectName(u'editButton')
+ self.verticalLayout.addWidget(self.editButton)
+ self.editAllButton = QtGui.QPushButton(customEditDialog)
+ self.editAllButton.setObjectName(u'editAllButton')
+ self.verticalLayout.addWidget(self.editAllButton)
+ self.deleteButton = QtGui.QPushButton(customEditDialog)
+ self.deleteButton.setObjectName(u'deleteButton')
+ self.verticalLayout.addWidget(self.deleteButton)
+ spacerItem = QtGui.QSpacerItem(20, 128, QtGui.QSizePolicy.Minimum,
+ QtGui.QSizePolicy.Expanding)
+ self.verticalLayout.addItem(spacerItem)
+ self.upButton = QtGui.QPushButton(customEditDialog)
+ icon1 = QtGui.QIcon()
+ icon1.addPixmap(QtGui.QPixmap(u':/services/service_up.png'),
+ QtGui.QIcon.Normal, QtGui.QIcon.Off)
+ self.upButton.setIcon(icon1)
+ self.upButton.setObjectName(u'upButton')
+ self.verticalLayout.addWidget(self.upButton)
+ self.downButton = QtGui.QPushButton(customEditDialog)
+ icon2 = QtGui.QIcon()
+ icon2.addPixmap(QtGui.QPixmap(u':/services/service_down.png'),
+ QtGui.QIcon.Normal, QtGui.QIcon.Off)
+ self.downButton.setIcon(icon2)
+ self.downButton.setObjectName(u'downButton')
+ self.verticalLayout.addWidget(self.downButton)
+ self.horizontalLayout4.addLayout(self.verticalLayout)
+ self.gridLayout.addLayout(self.horizontalLayout4, 1, 0, 1, 1)
+ self.horizontalLayout = QtGui.QHBoxLayout()
+ self.horizontalLayout.setObjectName(u'horizontalLayout')
+ self.titleLabel = QtGui.QLabel(customEditDialog)
+ self.titleLabel.setObjectName(u'titleLabel')
+ self.horizontalLayout.addWidget(self.titleLabel)
+ self.titleEdit = QtGui.QLineEdit(customEditDialog)
+ self.titleLabel.setBuddy(self.titleEdit)
+ self.titleEdit.setObjectName(u'titleEdit')
+ self.horizontalLayout.addWidget(self.titleEdit)
+ self.gridLayout.addLayout(self.horizontalLayout, 0, 0, 1, 1)
self.retranslateUi(customEditDialog)
QtCore.QObject.connect(self.buttonBox, QtCore.SIGNAL(u'accepted()'),
customEditDialog.accept)
@@ -143,46 +122,32 @@
translate('CustomPlugin.EditCustomForm', 'Edit Custom Slides'))
self.upButton.setToolTip(
translate('CustomPlugin.EditCustomForm', 'Move slide up one '
- 'position.'))
+ 'position.'))
self.downButton.setToolTip(
translate('CustomPlugin.EditCustomForm', 'Move slide down one '
- 'position.'))
+ 'position.'))
self.titleLabel.setText(
translate('CustomPlugin.EditCustomForm', '&Title:'))
self.addButton.setText(
- translate('CustomPlugin.EditCustomForm', 'Add New'))
+ translate('CustomPlugin.EditCustomForm', '&Add'))
self.addButton.setToolTip(
translate('CustomPlugin.EditCustomForm', 'Add a new slide at '
- 'bottom.'))
+ 'bottom.'))
self.editButton.setText(
- translate('CustomPlugin.EditCustomForm', 'Edit'))
+ translate('CustomPlugin.EditCustomForm', '&Edit'))
self.editButton.setToolTip(
translate('CustomPlugin.EditCustomForm', 'Edit the selected '
- 'slide.'))
+ 'slide.'))
self.editAllButton.setText(
- translate('CustomPlugin.EditCustomForm', 'Edit All'))
+ translate('CustomPlugin.EditCustomForm', 'Ed&it All'))
self.editAllButton.setToolTip(
translate('CustomPlugin.EditCustomForm', 'Edit all the slides at '
- 'once.'))
- self.saveButton.setText(
- translate('CustomPlugin.EditCustomForm', 'Save'))
- self.saveButton.setToolTip(
- translate('CustomPlugin.EditCustomForm', 'Save the slide currently '
- 'being edited.'))
+ 'once.'))
self.deleteButton.setText(
- translate('CustomPlugin.EditCustomForm', 'Delete'))
+ translate('CustomPlugin.EditCustomForm', '&Delete'))
self.deleteButton.setToolTip(
translate('CustomPlugin.EditCustomForm', 'Delete the selected '
- 'slide.'))
- self.clearButton.setText(
- translate('CustomPlugin.EditCustomForm', 'Clear'))
- self.clearButton.setToolTip(
- translate('CustomPlugin.EditCustomForm', 'Clear edit area'))
- self.splitButton.setText(
- translate('CustomPlugin.EditCustomForm', 'Split Slide'))
- self.splitButton.setToolTip(
- translate('CustomPlugin.EditCustomForm', 'Split a slide into two '
- 'by inserting a slide splitter.'))
+ 'slide.'))
self.themeLabel.setText(
translate('CustomPlugin.EditCustomForm', 'The&me:'))
self.creditLabel.setText(
=== modified file 'openlp/plugins/custom/forms/editcustomform.py'
--- openlp/plugins/custom/forms/editcustomform.py 2010-09-14 18:18:47 +0000
+++ openlp/plugins/custom/forms/editcustomform.py 2010-10-11 07:49:43 +0000
@@ -32,6 +32,7 @@
from openlp.plugins.custom.lib import CustomXMLBuilder, CustomXMLParser
from openlp.plugins.custom.lib.db import CustomSlide
from editcustomdialog import Ui_CustomEditDialog
+from editcustomslideform import EditCustomSlideForm
log = logging.getLogger(__name__)
@@ -40,7 +41,7 @@
Class documentation goes here.
"""
log.info(u'Custom Editor loaded')
- def __init__(self, custommanager, parent = None):
+ def __init__(self, custommanager, parent=None):
"""
Constructor
"""
@@ -61,28 +62,20 @@
QtCore.SIGNAL(u'pressed()'), self.onEditButtonPressed)
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.splitButton,
- QtCore.SIGNAL(u'pressed()'), self.onSplitButtonPressed)
- QtCore.QObject.connect(self.verseListView,
- QtCore.SIGNAL(u'itemDoubleClicked(QListWidgetItem*)'),
- self.onVerseListViewSelected)
- QtCore.QObject.connect(self.verseListView,
+ QtCore.QObject.connect(self.slideListView,
QtCore.SIGNAL(u'itemClicked(QListWidgetItem*)'),
- self.onVerseListViewPressed)
+ self.onSlideListViewPressed)
QtCore.QObject.connect(Receiver.get_receiver(),
QtCore.SIGNAL(u'theme_update_list'), self.loadThemes)
- # Create other objects and forms
+ # Create other objects and forms.
self.custommanager = custommanager
+ self.editSlideForm = EditCustomSlideForm(self)
self.initialise()
def onPreview(self, button):
@@ -92,21 +85,15 @@
Receiver.send_message(u'custom_preview')
def initialise(self):
- self.editAll = False
self.addButton.setEnabled(True)
self.deleteButton.setEnabled(False)
self.editButton.setEnabled(False)
self.editAllButton.setEnabled(True)
- self.saveButton.setEnabled(False)
- self.clearButton.setEnabled(False)
- self.splitButton.setEnabled(False)
self.titleEdit.setText(u'')
self.creditEdit.setText(u'')
- self.verseTextEdit.clear()
- self.verseListView.clear()
- #make sure we have a new item
+ self.slideListView.clear()
+ # Make sure we have a new item.
self.customSlide = CustomSlide()
- self.themeComboBox.addItem(u'')
def loadThemes(self, themelist):
self.themeComboBox.clear()
@@ -115,6 +102,16 @@
self.themeComboBox.addItem(themename)
def loadCustom(self, id, preview=False):
+ """
+ Called when editing or creating a new custom.
+
+ ``id``
+ The cutom's id. If zero, then a new custom is created.
+
+ ``preview``
+ States whether the custom is edited while being previewed in the
+ preview panel.
+ """
self.customSlide = CustomSlide()
self.initialise()
if id != 0:
@@ -122,9 +119,9 @@
self.titleEdit.setText(self.customSlide.title)
self.creditEdit.setText(self.customSlide.credits)
customXML = CustomXMLParser(self.customSlide.text)
- verseList = customXML.get_verses()
- for verse in verseList:
- self.verseListView.addItem(verse[1])
+ slideList = customXML.get_verses()
+ for slide in slideList:
+ self.slideListView.addItem(slide[1])
theme = self.customSlide.theme_name
id = self.themeComboBox.findText(theme, QtCore.Qt.MatchExactly)
if id == -1:
@@ -132,7 +129,8 @@
self.themeComboBox.setCurrentIndex(id)
else:
self.themeComboBox.setCurrentIndex(0)
- #if not preview hide the preview button
+ self.editAllButton.setEnabled(False)
+ # If not preview hide the preview button.
self.previewButton.setVisible(False)
if preview:
self.previewButton.setVisible(True)
@@ -148,6 +146,9 @@
self.close()
def saveCustom(self):
+ """
+ Saves the custom.
+ """
valid, message = self._validate()
if not valid:
QtGui.QMessageBox.critical(self,
@@ -157,9 +158,9 @@
sxml.new_document()
sxml.add_lyrics_to_song()
count = 1
- for i in range(0, self.verseListView.count()):
+ for i in range(0, self.slideListView.count()):
sxml.add_verse_to_lyrics(u'custom', unicode(count),
- unicode(self.verseListView.item(i).text()))
+ unicode(self.slideListView.item(i).text()))
count += 1
self.customSlide.title = unicode(self.titleEdit.displayText(), u'utf-8')
self.customSlide.text = unicode(sxml.extract_xml(), u'utf-8')
@@ -170,114 +171,103 @@
return self.custommanager.save_object(self.customSlide)
def onUpButtonPressed(self):
- selectedRow = self.verseListView.currentRow()
+ selectedRow = self.slideListView.currentRow()
if selectedRow != 0:
- qw = self.verseListView.takeItem(selectedRow)
- self.verseListView.insertItem(selectedRow - 1, qw)
- self.verseListView.setCurrentRow(selectedRow - 1)
+ qw = self.slideListView.takeItem(selectedRow)
+ self.slideListView.insertItem(selectedRow - 1, qw)
+ self.slideListView.setCurrentRow(selectedRow - 1)
def onDownButtonPressed(self):
- selectedRow = self.verseListView.currentRow()
+ selectedRow = self.slideListView.currentRow()
# zero base arrays
- if selectedRow != self.verseListView.count() - 1:
- qw = self.verseListView.takeItem(selectedRow)
- self.verseListView.insertItem(selectedRow + 1, qw)
- self.verseListView.setCurrentRow(selectedRow + 1)
-
- def onClearButtonPressed(self):
- self.verseTextEdit.clear()
- self.editAll = False
- self.addButton.setEnabled(True)
- self.editAllButton.setEnabled(True)
- self.saveButton.setEnabled(False)
-
- def onVerseListViewPressed(self, item):
+ if selectedRow != self.slideListView.count() - 1:
+ qw = self.slideListView.takeItem(selectedRow)
+ self.slideListView.insertItem(selectedRow + 1, qw)
+ self.slideListView.setCurrentRow(selectedRow + 1)
+
+ def onSlideListViewPressed(self, item):
self.deleteButton.setEnabled(True)
self.editButton.setEnabled(True)
- def onVerseListViewSelected(self, item):
- self.editText(item.text())
-
def onAddButtonPressed(self):
- self.verseListView.addItem(self.verseTextEdit.toPlainText())
- self.deleteButton.setEnabled(False)
- self.verseTextEdit.clear()
+ self.editSlideForm.setText(u'')
+ if self.editSlideForm.exec_():
+ for slide in self.editSlideForm.getText():
+ self.slideListView.addItem(slide)
+ self.editAllButton.setEnabled(True)
def onEditButtonPressed(self):
- self.editText(self.verseListView.currentItem().text())
+ self.editSlideForm.setText(self.slideListView.currentItem().text())
+ if self.editSlideForm.exec_():
+ self.updateSlideList(self.editSlideForm.getText())
def onEditAllButtonPressed(self):
- self.editAll = True
- self.addButton.setEnabled(False)
- self.splitButton.setEnabled(True)
- 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()
- if row != self.verseListView.count() - 1:
- verse_list += u'\n[---]\n'
- self.editText(verse_list)
-
- def editText(self, text):
- self.beforeText = text
- self.verseTextEdit.setPlainText(text)
- self.deleteButton.setEnabled(False)
- self.editButton.setEnabled(False)
- self.editAllButton.setEnabled(False)
- self.saveButton.setEnabled(True)
- self.clearButton.setEnabled(True)
-
- def onSaveButtonPressed(self):
- if self.editAll:
- self.verseListView.clear()
- for row in unicode(self.verseTextEdit.toPlainText()).split(
- u'\n[---]\n'):
- self.verseListView.addItem(row)
+ """
+ Edits all slides.
+ """
+ if self.slideListView.count() > 0:
+ slide_list = u''
+ for row in range(0, self.slideListView.count()):
+ item = self.slideListView.item(row)
+ slide_list += item.text()
+ if row != self.slideListView.count() - 1:
+ slide_list += u'\n[---]\n'
+ self.editSlideForm.setText(slide_list)
+ if self.editSlideForm.exec_():
+ self.updateSlideList(self.editSlideForm.getText(), True)
+
+ def updateSlideList(self, slides, edit_all=False):
+ """
+ Updates the slide list after editing slides.
+
+ ``slides``
+ A list of all slides which have been edited.
+
+ ``edit_all``
+ Indicates if all slides or only one slide has been edited.
+ """
+ if len(slides) == 1:
+ self.slideListView.currentItem().setText(slides[0])
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.editButton.setEnabled(False)
- self.editAllButton.setEnabled(True)
- self.splitButton.setEnabled(False)
- self.verseTextEdit.clear()
-
- def onSplitButtonPressed(self):
- if self.verseTextEdit.textCursor().columnNumber() != 0:
- self.verseTextEdit.insertPlainText(u'\n')
- self.verseTextEdit.insertPlainText(u'[---]\n' )
- self.verseTextEdit.setFocus()
+ if edit_all:
+ self.slideListView.clear()
+ for slide in slides:
+ self.slideListView.addItem(slide)
+ else:
+ old_slides = []
+ old_row = self.slideListView.currentRow()
+ # Create a list with all (old/unedited) slides.
+ old_slides = [self.slideListView.item(row).text() for row in \
+ range(0, self.slideListView.count())]
+ self.slideListView.clear()
+ old_slides.pop(old_row)
+ # Insert all slides to make the old_slides list complete.
+ for slide in slides:
+ old_slides.insert(old_row, slide)
+ for slide in old_slides:
+ self.slideListView.addItem(slide)
+ self.slideListView.repaint()
def onDeleteButtonPressed(self):
- self.verseListView.takeItem(self.verseListView.currentRow())
- self.editButton.setEnabled(False)
+ self.slideListView.takeItem(self.slideListView.currentRow())
+ self.editButton.setEnabled(True)
self.editAllButton.setEnabled(True)
+ if self.slideListView.count() == 0:
+ self.deleteButton.setEnabled(False)
+ self.editButton.setEnabled(False)
+ self.editAllButton.setEnabled(False)
def _validate(self):
+ """
+ Checks whether a custom is valid or not.
+ """
+ # We must have a title.
if len(self.titleEdit.displayText()) == 0:
self.titleEdit.setFocus()
return False, translate('CustomPlugin.EditCustomForm',
'You need to type in a title.')
- # must have 1 slide
- if self.verseListView.count() == 0:
- self.verseTextEdit.setFocus()
+ # We must have one slide.
+ if self.slideListView.count() == 0:
return False, translate('CustomPlugin.EditCustomForm',
'You need to add at least one slide')
- if self.verseTextEdit.toPlainText():
- self.verseTextEdit.setFocus()
- return False, translate('CustomPlugin.EditCustomForm',
- 'You have one or more unsaved slides, please either save your '
- 'slide(s) or clear your changes.')
return True, u''
=== added file 'openlp/plugins/custom/forms/editcustomslidedialog.py'
--- openlp/plugins/custom/forms/editcustomslidedialog.py 1970-01-01 00:00:00 +0000
+++ openlp/plugins/custom/forms/editcustomslidedialog.py 2010-10-11 07:49:43 +0000
@@ -0,0 +1,59 @@
+# -*- coding: utf-8 -*-
+# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4
+
+###############################################################################
+# OpenLP - Open Source Lyrics Projection #
+# --------------------------------------------------------------------------- #
+# Copyright (c) 2008-2010 Raoul Snyman #
+# Portions copyright (c) 2008-2010 Tim Bentley, Jonathan Corwin, Michael #
+# Gorven, Scott Guerrieri, Meinert Jordan, Andreas Preikschat, Christian #
+# Richter, Philip Ridout, Maikel Stuivenberg, Martin Thompson, Jon Tibble, #
+# Carsten Tinggaard, Frode Woldsund #
+# --------------------------------------------------------------------------- #
+# 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 translate, SpellTextEdit
+
+class Ui_CustomSlideEditDialog(object):
+ def setupUi(self, customSlideEditDialog):
+ customSlideEditDialog.setObjectName(u'customSlideEditDialog')
+ customSlideEditDialog.resize(474, 442)
+ self.buttonBox = QtGui.QDialogButtonBox(customSlideEditDialog)
+ self.buttonBox.setGeometry(QtCore.QRect(8, 407, 458, 32))
+ self.buttonBox.setOrientation(QtCore.Qt.Horizontal)
+ self.buttonBox.setStandardButtons(QtGui.QDialogButtonBox.Cancel |
+ QtGui.QDialogButtonBox.Save)
+ self.buttonBox.setObjectName(u'buttonBox')
+ self.slideTextEdit = SpellTextEdit(self)
+ self.slideTextEdit.setGeometry(QtCore.QRect(8, 8, 458, 349))
+ self.slideTextEdit.setObjectName(u'slideTextEdit')
+ self.splitButton = QtGui.QPushButton(customSlideEditDialog)
+ self.splitButton.setGeometry(QtCore.QRect(380, 370, 85, 27))
+ self.splitButton.setObjectName(u'splitButton')
+ self.retranslateUi(customSlideEditDialog)
+ QtCore.QObject.connect(self.buttonBox, QtCore.SIGNAL(u'accepted()'),
+ customSlideEditDialog.accept)
+ QtCore.QObject.connect(self.buttonBox, QtCore.SIGNAL(u'rejected()'),
+ customSlideEditDialog.reject)
+ QtCore.QMetaObject.connectSlotsByName(customSlideEditDialog)
+
+ def retranslateUi(self, customSlideEditDialog):
+ self.splitButton.setText(
+ translate('CustomPlugin.EditCustomForm', 'Split Slide'))
+ self.splitButton.setToolTip(
+ translate('CustomPlugin.EditCustomForm', 'Split a slide into two '
+ 'by inserting a slide splitter.'))
=== added file 'openlp/plugins/custom/forms/editcustomslideform.py'
--- openlp/plugins/custom/forms/editcustomslideform.py 1970-01-01 00:00:00 +0000
+++ openlp/plugins/custom/forms/editcustomslideform.py 2010-10-11 07:49:43 +0000
@@ -0,0 +1,76 @@
+# -*- coding: utf-8 -*-
+# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4
+
+###############################################################################
+# OpenLP - Open Source Lyrics Projection #
+# --------------------------------------------------------------------------- #
+# Copyright (c) 2008-2010 Raoul Snyman #
+# Portions copyright (c) 2008-2010 Tim Bentley, Jonathan Corwin, Michael #
+# Gorven, Scott Guerrieri, Meinert Jordan, Andreas Preikschat, Christian #
+# Richter, Philip Ridout, Maikel Stuivenberg, Martin Thompson, Jon Tibble, #
+# Carsten Tinggaard, Frode Woldsund #
+# --------------------------------------------------------------------------- #
+# 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 #
+###############################################################################
+
+import logging
+
+from PyQt4 import QtCore, QtGui
+
+from openlp.core.lib import Receiver, translate
+from editcustomslidedialog import Ui_CustomSlideEditDialog
+
+log = logging.getLogger(__name__)
+
+class EditCustomSlideForm(QtGui.QDialog, Ui_CustomSlideEditDialog):
+ """
+ Class documentation goes here.
+ """
+ log.info(u'Custom Verse Editor loaded')
+ def __init__(self, parent=None):
+ """
+ Constructor
+ """
+ QtGui.QDialog.__init__(self, parent)
+ self.setupUi(self)
+ # Connecting signals and slots
+ QtCore.QObject.connect(self.splitButton,
+ QtCore.SIGNAL(u'pressed()'), self.onSplitButtonPressed)
+
+ def setText(self, text):
+ """
+ Set the text for slideTextEdit.
+
+ ``text``
+ The text (unicode).
+ """
+ self.slideTextEdit.clear()
+ if text:
+ self.slideTextEdit.setPlainText(text)
+ self.slideTextEdit.setFocus()
+
+ def getText(self):
+ """
+ Returns a list with all slides.
+ """
+ return self.slideTextEdit.toPlainText().split(u'\n[---]\n')
+
+ def onSplitButtonPressed(self):
+ """
+ Splits a slide in two slides.
+ """
+ if self.slideTextEdit.textCursor().columnNumber() != 0:
+ self.slideTextEdit.insertPlainText(u'\n')
+ self.slideTextEdit.insertPlainText(u'[---]\n' )
+ self.slideTextEdit.setFocus()
=== modified file 'resources/forms/editcustomdialog.ui'
--- resources/forms/editcustomdialog.ui 2010-09-14 18:18:47 +0000
+++ resources/forms/editcustomdialog.ui 2010-10-11 07:49:43 +0000
@@ -18,19 +18,47 @@
<normaloff>:/icon/openlp.org-icon-32.bmp</normaloff>:/icon/openlp.org-icon-32.bmp</iconset>
</property>
<layout class="QGridLayout" name="gridLayout">
- <item row="0" column="0">
- <layout class="QHBoxLayout" name="horizontalLayout">
- <item>
- <widget class="QLabel" name="TitleLabel">
- <property name="text">
- <string>Title:</string>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QLineEdit" name="TitleEdit"/>
- </item>
- </layout>
+ <item row="2" column="0">
+ <layout class="QHBoxLayout" name="horizontalLayout_3">
+ <item>
+ <widget class="QLabel" name="ThemeLabel">
+ <property name="text">
+ <string>Theme:</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QComboBox" name="ThemeComboBox">
+ <property name="toolTip">
+ <string extracomment="Select custom theme for slide"/>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ <item row="3" column="0">
+ <layout class="QHBoxLayout" name="horizontalLayout_2">
+ <item>
+ <widget class="QLabel" name="CreditLabel">
+ <property name="text">
+ <string>Credits:</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QLineEdit" name="CreditEdit"/>
+ </item>
+ </layout>
+ </item>
+ <item row="4" column="0">
+ <widget class="QDialogButtonBox" name="buttonBox">
+ <property name="toolTip">
+ <string extracomment="Edit dialog"/>
+ </property>
+ <property name="standardButtons">
+ <set>QDialogButtonBox::Cancel|QDialogButtonBox::Save</set>
+ </property>
+ </widget>
</item>
<item row="1" column="0">
<layout class="QHBoxLayout" name="horizontalLayout_4">
@@ -44,16 +72,42 @@
<item>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
- <widget class="QPushButton" name="UpButton">
- <property name="toolTip">
- <string extracomment="Move slide up 1"/>
- </property>
- <property name="text">
- <string/>
- </property>
- <property name="icon">
- <iconset resource="../images/openlp-2.qrc">
- <normaloff>:/services/service_up.png</normaloff>:/services/service_up.png</iconset>
+ <widget class="QPushButton" name="AddButton">
+ <property name="toolTip">
+ <string extracomment="Adds a new slide at bottom"/>
+ </property>
+ <property name="text">
+ <string>Add New</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QPushButton" name="EditButton">
+ <property name="toolTip">
+ <string extracomment="Edit selected slide"/>
+ </property>
+ <property name="text">
+ <string>Edit</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <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="DeleteButton">
+ <property name="toolTip">
+ <string extracomment="Delete selected slide"/>
+ </property>
+ <property name="text">
+ <string>Delete</string>
</property>
</widget>
</item>
@@ -71,6 +125,20 @@
</spacer>
</item>
<item>
+ <widget class="QPushButton" name="UpButton">
+ <property name="toolTip">
+ <string extracomment="Move slide up 1"/>
+ </property>
+ <property name="text">
+ <string/>
+ </property>
+ <property name="icon">
+ <iconset resource="../images/openlp-2.qrc">
+ <normaloff>:/services/service_up.png</normaloff>:/services/service_up.png</iconset>
+ </property>
+ </widget>
+ </item>
+ <item>
<widget class="QPushButton" name="DownButton">
<property name="toolTip">
<string extracomment="Move slide down 1"/>
@@ -88,166 +156,26 @@
</item>
</layout>
</item>
- <item row="2" column="0">
- <widget class="QWidget" name="EditWidget" native="true">
- <layout class="QHBoxLayout" name="EditLayout_3">
- <property name="spacing">
- <number>8</number>
- </property>
- <property name="margin">
- <number>0</number>
- </property>
- <item>
- <widget class="QTextEdit" name="VerseTextEdit"/>
- </item>
- <item>
- <widget class="QWidget" name="ButtonWidge" native="true">
- <layout class="QVBoxLayout" name="verticalLayout_2">
- <item>
- <widget class="QPushButton" name="AddButton">
- <property name="toolTip">
- <string extracomment="Adds a new slide at bottom"/>
- </property>
- <property name="text">
- <string>Add New</string>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QPushButton" name="EditButton">
- <property name="toolTip">
- <string extracomment="Edit selected slide"/>
- </property>
- <property name="text">
- <string>Edit</string>
- </property>
- </widget>
- </item>
- <item>
- <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="Replace edited slide"/>
- </property>
- <property name="text">
- <string>Save</string>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QPushButton" name="DeleteButton">
- <property name="toolTip">
- <string extracomment="Delete selected slide"/>
- </property>
- <property name="text">
- <string>Delete</string>
- </property>
- </widget>
- </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>
- <widget class="QPushButton" name="SplitButton">
- <property name="toolTip">
- <string extracomment="Add new slide split"/>
- </property>
- <property name="text">
- <string>Split Slide</string>
- </property>
- </widget>
- </item>
- <item>
- <spacer name="ButtonSpacer">
- <property name="orientation">
- <enum>Qt::Vertical</enum>
- </property>
- <property name="sizeHint" stdset="0">
- <size>
- <width>20</width>
- <height>40</height>
- </size>
- </property>
- </spacer>
- </item>
- </layout>
- </widget>
- </item>
- </layout>
- </widget>
- </item>
- <item row="3" column="0">
- <layout class="QHBoxLayout" name="horizontalLayout_3">
- <item>
- <widget class="QLabel" name="ThemeLabel">
- <property name="text">
- <string>Theme:</string>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QComboBox" name="ThemeComboBox">
- <property name="toolTip">
- <string extracomment="Select custom theme for slide"/>
- </property>
- </widget>
- </item>
- </layout>
- </item>
- <item row="4" column="0">
- <layout class="QHBoxLayout" name="horizontalLayout_2">
- <item>
- <widget class="QLabel" name="CreditLabel">
- <property name="text">
- <string>Credits:</string>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QLineEdit" name="CreditEdit"/>
- </item>
- </layout>
- </item>
- <item row="5" column="0">
- <widget class="QDialogButtonBox" name="buttonBox">
- <property name="toolTip">
- <string extracomment="Edit dialog"/>
- </property>
- <property name="standardButtons">
- <set>QDialogButtonBox::Cancel|QDialogButtonBox::Save</set>
- </property>
- </widget>
+ <item row="0" column="0">
+ <layout class="QHBoxLayout" name="horizontalLayout">
+ <item>
+ <widget class="QLabel" name="TitleLabel">
+ <property name="text">
+ <string>Title:</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QLineEdit" name="TitleEdit"/>
+ </item>
+ </layout>
</item>
</layout>
</widget>
<tabstops>
<tabstop>TitleEdit</tabstop>
- <tabstop>VerseTextEdit</tabstop>
- <tabstop>AddButton</tabstop>
<tabstop>VerseListView</tabstop>
- <tabstop>EditButton</tabstop>
- <tabstop>EditAllButton</tabstop>
- <tabstop>SaveButton</tabstop>
- <tabstop>DeleteButton</tabstop>
<tabstop>CreditEdit</tabstop>
- <tabstop>UpButton</tabstop>
- <tabstop>DownButton</tabstop>
<tabstop>ThemeComboBox</tabstop>
</tabstops>
<resources>
=== added file 'resources/forms/editcustomslidedialog.ui'
--- resources/forms/editcustomslidedialog.ui 1970-01-01 00:00:00 +0000
+++ resources/forms/editcustomslidedialog.ui 2010-10-11 07:49:43 +0000
@@ -0,0 +1,96 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>customSlideEditDialog</class>
+ <widget class="QDialog" name="customSlideEditDialog">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>474</width>
+ <height>442</height>
+ </rect>
+ </property>
+ <property name="windowTitle">
+ <string>Dialog</string>
+ </property>
+ <widget class="QDialogButtonBox" name="buttonBox">
+ <property name="geometry">
+ <rect>
+ <x>8</x>
+ <y>407</y>
+ <width>458</width>
+ <height>32</height>
+ </rect>
+ </property>
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="standardButtons">
+ <set>QDialogButtonBox::Cancel|QDialogButtonBox::Save</set>
+ </property>
+ </widget>
+ <widget class="QTextEdit" name="VerseTextEdit">
+ <property name="geometry">
+ <rect>
+ <x>8</x>
+ <y>8</y>
+ <width>458</width>
+ <height>349</height>
+ </rect>
+ </property>
+ </widget>
+ <widget class="QPushButton" name="SplitButton">
+ <property name="geometry">
+ <rect>
+ <x>380</x>
+ <y>370</y>
+ <width>85</width>
+ <height>27</height>
+ </rect>
+ </property>
+ <property name="toolTip">
+ <string extracomment="Add new slide split"/>
+ </property>
+ <property name="text">
+ <string>Split Slide</string>
+ </property>
+ </widget>
+ </widget>
+ <resources>
+ <include location="../images/openlp-2.qrc"/>
+ </resources>
+ <connections>
+ <connection>
+ <sender>buttonBox</sender>
+ <signal>accepted()</signal>
+ <receiver>customSlideEditDialog</receiver>
+ <slot>accept()</slot>
+ <hints>
+ <hint type="sourcelabel">
+ <x>248</x>
+ <y>254</y>
+ </hint>
+ <hint type="destinationlabel">
+ <x>157</x>
+ <y>274</y>
+ </hint>
+ </hints>
+ </connection>
+ <connection>
+ <sender>buttonBox</sender>
+ <signal>rejected()</signal>
+ <receiver>customSlideEditDialog</receiver>
+ <slot>reject()</slot>
+ <hints>
+ <hint type="sourcelabel">
+ <x>316</x>
+ <y>260</y>
+ </hint>
+ <hint type="destinationlabel">
+ <x>286</x>
+ <y>274</y>
+ </hint>
+ </hints>
+ </connection>
+ </connections>
+</ui>
Follow ups