Finish slide spltting code

This commit is contained in:
Tim Bentley 2011-05-22 14:08:43 +01:00
parent 596ffe9443
commit 37679fc1db
4 changed files with 39 additions and 2 deletions

View File

@ -26,7 +26,7 @@
from PyQt4 import QtCore, QtGui
from openlp.core.lib import translate, SpellTextEdit
from openlp.core.lib import translate, SpellTextEdit, build_icon
from openlp.core.lib.ui import create_accept_reject_button_box
class Ui_CustomSlideEditDialog(object):
@ -39,9 +39,15 @@ class Ui_CustomSlideEditDialog(object):
self.dialogLayout.addWidget(self.slideTextEdit)
self.buttonBox = create_accept_reject_button_box(customSlideEditDialog)
self.splitButton = QtGui.QPushButton(customSlideEditDialog)
self.splitButton.setIcon(build_icon(u':/general/general_add.png'))
self.splitButton.setObjectName(u'splitButton')
self.buttonBox.addButton(self.splitButton,
QtGui.QDialogButtonBox.ActionRole)
self.insertButton = QtGui.QPushButton(customSlideEditDialog)
self.insertButton.setIcon(build_icon(u':/general/general_add.png'))
self.insertButton.setObjectName(u'insertButton')
self.buttonBox.addButton(self.insertButton,
QtGui.QDialogButtonBox.ActionRole)
self.dialogLayout.addWidget(self.buttonBox)
self.retranslateUi(customSlideEditDialog)
QtCore.QMetaObject.connectSlotsByName(customSlideEditDialog)
@ -50,5 +56,10 @@ class Ui_CustomSlideEditDialog(object):
self.splitButton.setText(
translate('CustomPlugin.EditCustomForm', 'Split Slide'))
self.splitButton.setToolTip(
translate('CustomPlugin.EditCustomForm', 'Split a slide into two '
'only if it does not fit on the screen as one slide.'))
self.insertButton.setText(
translate('CustomPlugin.EditCustomForm', 'Insert Slide'))
self.insertButton.setToolTip(
translate('CustomPlugin.EditCustomForm', 'Split a slide into two '
'by inserting a slide splitter.'))

View File

@ -44,6 +44,8 @@ class EditCustomSlideForm(QtGui.QDialog, Ui_CustomSlideEditDialog):
QtGui.QDialog.__init__(self, parent)
self.setupUi(self)
# Connecting signals and slots
QtCore.QObject.connect(self.insertButton,
QtCore.SIGNAL(u'clicked()'), self.onInsertButtonPressed)
QtCore.QObject.connect(self.splitButton,
QtCore.SIGNAL(u'clicked()'), self.onSplitButtonPressed)
@ -65,7 +67,7 @@ class EditCustomSlideForm(QtGui.QDialog, Ui_CustomSlideEditDialog):
"""
return self.slideTextEdit.toPlainText().split(u'\n[===]\n')
def onSplitButtonPressed(self):
def onInsertButtonPressed(self):
"""
Adds a slide split at the cursor.
"""
@ -73,3 +75,12 @@ class EditCustomSlideForm(QtGui.QDialog, Ui_CustomSlideEditDialog):
self.slideTextEdit.insertPlainText(u'\n')
self.slideTextEdit.insertPlainText(u'[===]\n')
self.slideTextEdit.setFocus()
def onSplitButtonPressed(self):
"""
Adds a virtual split at cursor.
"""
if self.slideTextEdit.textCursor().columnNumber() != 0:
self.slideTextEdit.insertPlainText(u'\n')
self.slideTextEdit.insertPlainText(u'[---]')
self.slideTextEdit.setFocus()

View File

@ -42,6 +42,10 @@ class Ui_EditVerseDialog(object):
self.dialogLayout.addWidget(self.verseTextEdit)
self.verseTypeLayout = QtGui.QHBoxLayout()
self.verseTypeLayout.setObjectName(u'verseTypeLayout')
self.splitButton = QtGui.QPushButton(editVerseDialog)
self.splitButton.setIcon(build_icon(u':/general/general_add.png'))
self.splitButton.setObjectName(u'splitButton')
self.verseTypeLayout.addWidget(self.splitButton)
self.verseTypeLabel = QtGui.QLabel(editVerseDialog)
self.verseTypeLabel.setObjectName(u'verseTypeLabel')
self.verseTypeLayout.addWidget(self.verseTypeLabel)
@ -84,5 +88,7 @@ class Ui_EditVerseDialog(object):
VerseType.TranslatedNames[VerseType.Ending])
self.verseTypeComboBox.setItemText(VerseType.Other,
VerseType.TranslatedNames[VerseType.Other])
self.splitButton.setText(
translate('SongsPlugin.EditVerseForm', '&Split'))
self.insertButton.setText(
translate('SongsPlugin.EditVerseForm', '&Insert'))

View File

@ -51,6 +51,8 @@ class EditVerseForm(QtGui.QDialog, Ui_EditVerseDialog):
self.contextMenu)
QtCore.QObject.connect(self.insertButton, QtCore.SIGNAL(u'clicked()'),
self.onInsertButtonClicked)
QtCore.QObject.connect(self.splitButton, QtCore.SIGNAL(u'clicked()'),
self.onSplitButtonClicked)
QtCore.QObject.connect(self.verseTextEdit,
QtCore.SIGNAL(u'cursorPositionChanged()'),
self.onCursorPositionChanged)
@ -70,6 +72,13 @@ class EditVerseForm(QtGui.QDialog, Ui_EditVerseDialog):
(verse_tag, verse_num))
self.verseTextEdit.setFocus()
def onSplitButtonClicked(self):
verse_type_index = self.verseTypeComboBox.currentIndex()
if self.verseTextEdit.textCursor().columnNumber() != 0:
self.verseTextEdit.insertPlainText(u'\n')
self.verseTextEdit.insertPlainText(u'[---]')
self.verseTextEdit.setFocus()
def onInsertButtonClicked(self):
verse_type_index = self.verseTypeComboBox.currentIndex()
self.insertVerse(VerseType.Tags[verse_type_index],