forked from openlp/openlp
This commit is contained in:
parent
58b768fc66
commit
ead4f95835
@ -59,20 +59,24 @@ class Ui_CustomEditDialog(object):
|
|||||||
self.addButton.setObjectName(u'addButton')
|
self.addButton.setObjectName(u'addButton')
|
||||||
self.buttonLayout.addWidget(self.addButton)
|
self.buttonLayout.addWidget(self.addButton)
|
||||||
self.editButton = QtGui.QPushButton(customEditDialog)
|
self.editButton = QtGui.QPushButton(customEditDialog)
|
||||||
|
self.editButton.setEnabled(False)
|
||||||
self.editButton.setObjectName(u'editButton')
|
self.editButton.setObjectName(u'editButton')
|
||||||
self.buttonLayout.addWidget(self.editButton)
|
self.buttonLayout.addWidget(self.editButton)
|
||||||
self.editAllButton = QtGui.QPushButton(customEditDialog)
|
self.editAllButton = QtGui.QPushButton(customEditDialog)
|
||||||
self.editAllButton.setObjectName(u'editAllButton')
|
self.editAllButton.setObjectName(u'editAllButton')
|
||||||
self.buttonLayout.addWidget(self.editAllButton)
|
self.buttonLayout.addWidget(self.editAllButton)
|
||||||
self.deleteButton = QtGui.QPushButton(customEditDialog)
|
self.deleteButton = QtGui.QPushButton(customEditDialog)
|
||||||
|
self.deleteButton.setEnabled(False)
|
||||||
self.deleteButton.setObjectName(u'deleteButton')
|
self.deleteButton.setObjectName(u'deleteButton')
|
||||||
self.buttonLayout.addWidget(self.deleteButton)
|
self.buttonLayout.addWidget(self.deleteButton)
|
||||||
self.buttonLayout.addStretch()
|
self.buttonLayout.addStretch()
|
||||||
self.upButton = QtGui.QPushButton(customEditDialog)
|
self.upButton = QtGui.QPushButton(customEditDialog)
|
||||||
|
self.upButton.setEnabled(False)
|
||||||
self.upButton.setIcon(build_icon(u':/services/service_up.png'))
|
self.upButton.setIcon(build_icon(u':/services/service_up.png'))
|
||||||
self.upButton.setObjectName(u'upButton')
|
self.upButton.setObjectName(u'upButton')
|
||||||
self.buttonLayout.addWidget(self.upButton)
|
self.buttonLayout.addWidget(self.upButton)
|
||||||
self.downButton = QtGui.QPushButton(customEditDialog)
|
self.downButton = QtGui.QPushButton(customEditDialog)
|
||||||
|
self.downButton.setEnabled(False)
|
||||||
self.downButton.setIcon(build_icon(u':/services/service_down.png'))
|
self.downButton.setIcon(build_icon(u':/services/service_down.png'))
|
||||||
self.downButton.setObjectName(u'downButton')
|
self.downButton.setObjectName(u'downButton')
|
||||||
self.buttonLayout.addWidget(self.downButton)
|
self.buttonLayout.addWidget(self.downButton)
|
||||||
@ -95,6 +99,9 @@ class Ui_CustomEditDialog(object):
|
|||||||
self.bottomFormLayout.addRow(self.creditLabel, self.creditEdit)
|
self.bottomFormLayout.addRow(self.creditLabel, self.creditEdit)
|
||||||
self.dialogLayout.addLayout(self.bottomFormLayout)
|
self.dialogLayout.addLayout(self.bottomFormLayout)
|
||||||
self.buttonBox = save_cancel_button_box(customEditDialog)
|
self.buttonBox = save_cancel_button_box(customEditDialog)
|
||||||
|
self.previewButton = QtGui.QPushButton()
|
||||||
|
self.buttonBox.addButton(
|
||||||
|
self.previewButton, QtGui.QDialogButtonBox.ActionRole)
|
||||||
self.dialogLayout.addWidget(self.buttonBox)
|
self.dialogLayout.addWidget(self.buttonBox)
|
||||||
self.retranslateUi(customEditDialog)
|
self.retranslateUi(customEditDialog)
|
||||||
QtCore.QMetaObject.connectSlotsByName(customEditDialog)
|
QtCore.QMetaObject.connectSlotsByName(customEditDialog)
|
||||||
@ -134,3 +141,5 @@ class Ui_CustomEditDialog(object):
|
|||||||
translate('CustomPlugin.EditCustomForm', 'The&me:'))
|
translate('CustomPlugin.EditCustomForm', 'The&me:'))
|
||||||
self.creditLabel.setText(
|
self.creditLabel.setText(
|
||||||
translate('CustomPlugin.EditCustomForm', '&Credits:'))
|
translate('CustomPlugin.EditCustomForm', '&Credits:'))
|
||||||
|
self.previewButton.setText(
|
||||||
|
translate('CustomPlugin.EditCustomForm', 'Save && Preview'))
|
||||||
|
@ -48,14 +48,12 @@ class EditCustomForm(QtGui.QDialog, Ui_CustomEditDialog):
|
|||||||
"""
|
"""
|
||||||
QtGui.QDialog.__init__(self, parent)
|
QtGui.QDialog.__init__(self, parent)
|
||||||
self.setupUi(self)
|
self.setupUi(self)
|
||||||
|
# Create other objects and forms.
|
||||||
|
self.manager = manager
|
||||||
|
self.editSlideForm = EditCustomSlideForm(self)
|
||||||
# Connecting signals and slots
|
# Connecting signals and slots
|
||||||
self.previewButton = QtGui.QPushButton()
|
QtCore.QObject.connect(self.previewButton,
|
||||||
self.previewButton.setText(
|
QtCore.SIGNAL(u'pressed()'), self.onPreviewButtonPressed)
|
||||||
translate('CustomPlugin.EditCustomForm', 'Save && Preview'))
|
|
||||||
self.buttonBox.addButton(
|
|
||||||
self.previewButton, QtGui.QDialogButtonBox.ActionRole)
|
|
||||||
QtCore.QObject.connect(self.buttonBox,
|
|
||||||
QtCore.SIGNAL(u'clicked(QAbstractButton*)'), self.onPreview)
|
|
||||||
QtCore.QObject.connect(self.addButton,
|
QtCore.QObject.connect(self.addButton,
|
||||||
QtCore.SIGNAL(u'pressed()'), self.onAddButtonPressed)
|
QtCore.SIGNAL(u'pressed()'), self.onAddButtonPressed)
|
||||||
QtCore.QObject.connect(self.editButton,
|
QtCore.QObject.connect(self.editButton,
|
||||||
@ -68,32 +66,10 @@ class EditCustomForm(QtGui.QDialog, Ui_CustomEditDialog):
|
|||||||
QtCore.SIGNAL(u'pressed()'), self.onUpButtonPressed)
|
QtCore.SIGNAL(u'pressed()'), self.onUpButtonPressed)
|
||||||
QtCore.QObject.connect(self.downButton,
|
QtCore.QObject.connect(self.downButton,
|
||||||
QtCore.SIGNAL(u'pressed()'), self.onDownButtonPressed)
|
QtCore.SIGNAL(u'pressed()'), self.onDownButtonPressed)
|
||||||
QtCore.QObject.connect(self.slideListView,
|
|
||||||
QtCore.SIGNAL(u'itemClicked(QListWidgetItem*)'),
|
|
||||||
self.onSlideListViewPressed)
|
|
||||||
QtCore.QObject.connect(Receiver.get_receiver(),
|
QtCore.QObject.connect(Receiver.get_receiver(),
|
||||||
QtCore.SIGNAL(u'theme_update_list'), self.loadThemes)
|
QtCore.SIGNAL(u'theme_update_list'), self.loadThemes)
|
||||||
# Create other objects and forms.
|
QtCore.QObject.connect(self.slideListView,
|
||||||
self.manager = manager
|
QtCore.SIGNAL(u'currentRowChanged(int)'), self.onCurrentRowChanged)
|
||||||
self.editSlideForm = EditCustomSlideForm(self)
|
|
||||||
self.initialise()
|
|
||||||
|
|
||||||
def onPreview(self, button):
|
|
||||||
log.debug(u'onPreview')
|
|
||||||
if button.text() == unicode(translate('CustomPlugin.EditCustomForm',
|
|
||||||
'Save && Preview')) and self.saveCustom():
|
|
||||||
Receiver.send_message(u'custom_preview')
|
|
||||||
|
|
||||||
def initialise(self):
|
|
||||||
self.addButton.setEnabled(True)
|
|
||||||
self.deleteButton.setEnabled(False)
|
|
||||||
self.editButton.setEnabled(False)
|
|
||||||
self.editAllButton.setEnabled(True)
|
|
||||||
self.titleEdit.setText(u'')
|
|
||||||
self.creditEdit.setText(u'')
|
|
||||||
self.slideListView.clear()
|
|
||||||
# Make sure we have a new item.
|
|
||||||
self.customSlide = CustomSlide()
|
|
||||||
|
|
||||||
def loadThemes(self, themelist):
|
def loadThemes(self, themelist):
|
||||||
self.themeComboBox.clear()
|
self.themeComboBox.clear()
|
||||||
@ -112,9 +88,13 @@ class EditCustomForm(QtGui.QDialog, Ui_CustomEditDialog):
|
|||||||
States whether the custom is edited while being previewed in the
|
States whether the custom is edited while being previewed in the
|
||||||
preview panel.
|
preview panel.
|
||||||
"""
|
"""
|
||||||
self.customSlide = CustomSlide()
|
self.slideListView.clear()
|
||||||
self.initialise()
|
if id == 0:
|
||||||
if id != 0:
|
self.customSlide = CustomSlide()
|
||||||
|
self.titleEdit.setText(u'')
|
||||||
|
self.creditEdit.setText(u'')
|
||||||
|
self.themeComboBox.setCurrentIndex(0)
|
||||||
|
else:
|
||||||
self.customSlide = self.manager.get_object(CustomSlide, id)
|
self.customSlide = self.manager.get_object(CustomSlide, id)
|
||||||
self.titleEdit.setText(self.customSlide.title)
|
self.titleEdit.setText(self.customSlide.title)
|
||||||
self.creditEdit.setText(self.customSlide.credits)
|
self.creditEdit.setText(self.customSlide.credits)
|
||||||
@ -128,9 +108,6 @@ class EditCustomForm(QtGui.QDialog, Ui_CustomEditDialog):
|
|||||||
if id == -1:
|
if id == -1:
|
||||||
id = 0
|
id = 0
|
||||||
self.themeComboBox.setCurrentIndex(id)
|
self.themeComboBox.setCurrentIndex(id)
|
||||||
else:
|
|
||||||
self.themeComboBox.setCurrentIndex(0)
|
|
||||||
self.editAllButton.setEnabled(False)
|
|
||||||
# If not preview hide the preview button.
|
# If not preview hide the preview button.
|
||||||
self.previewButton.setVisible(False)
|
self.previewButton.setVisible(False)
|
||||||
if preview:
|
if preview:
|
||||||
@ -150,9 +127,7 @@ class EditCustomForm(QtGui.QDialog, Ui_CustomEditDialog):
|
|||||||
"""
|
"""
|
||||||
Saves the custom.
|
Saves the custom.
|
||||||
"""
|
"""
|
||||||
valid, message = self._validate()
|
if not self._validate():
|
||||||
if not valid:
|
|
||||||
critical_error_message_box(message=message)
|
|
||||||
return False
|
return False
|
||||||
sxml = CustomXMLBuilder()
|
sxml = CustomXMLBuilder()
|
||||||
sxml.new_document()
|
sxml.new_document()
|
||||||
@ -183,16 +158,11 @@ class EditCustomForm(QtGui.QDialog, Ui_CustomEditDialog):
|
|||||||
self.slideListView.insertItem(selectedRow + 1, qw)
|
self.slideListView.insertItem(selectedRow + 1, qw)
|
||||||
self.slideListView.setCurrentRow(selectedRow + 1)
|
self.slideListView.setCurrentRow(selectedRow + 1)
|
||||||
|
|
||||||
def onSlideListViewPressed(self, item):
|
|
||||||
self.deleteButton.setEnabled(True)
|
|
||||||
self.editButton.setEnabled(True)
|
|
||||||
|
|
||||||
def onAddButtonPressed(self):
|
def onAddButtonPressed(self):
|
||||||
self.editSlideForm.setText(u'')
|
self.editSlideForm.setText(u'')
|
||||||
if self.editSlideForm.exec_():
|
if self.editSlideForm.exec_():
|
||||||
for slide in self.editSlideForm.getText():
|
for slide in self.editSlideForm.getText():
|
||||||
self.slideListView.addItem(slide)
|
self.slideListView.addItem(slide)
|
||||||
self.editAllButton.setEnabled(True)
|
|
||||||
|
|
||||||
def onEditButtonPressed(self):
|
def onEditButtonPressed(self):
|
||||||
self.editSlideForm.setText(self.slideListView.currentItem().text())
|
self.editSlideForm.setText(self.slideListView.currentItem().text())
|
||||||
@ -203,16 +173,23 @@ class EditCustomForm(QtGui.QDialog, Ui_CustomEditDialog):
|
|||||||
"""
|
"""
|
||||||
Edits all slides.
|
Edits all slides.
|
||||||
"""
|
"""
|
||||||
if self.slideListView.count() > 0:
|
slide_list = u''
|
||||||
slide_list = u''
|
for row in range(0, self.slideListView.count()):
|
||||||
for row in range(0, self.slideListView.count()):
|
item = self.slideListView.item(row)
|
||||||
item = self.slideListView.item(row)
|
slide_list += item.text()
|
||||||
slide_list += item.text()
|
if row != self.slideListView.count() - 1:
|
||||||
if row != self.slideListView.count() - 1:
|
slide_list += u'\n[---]\n'
|
||||||
slide_list += u'\n[---]\n'
|
self.editSlideForm.setText(slide_list)
|
||||||
self.editSlideForm.setText(slide_list)
|
if self.editSlideForm.exec_():
|
||||||
if self.editSlideForm.exec_():
|
self.updateSlideList(self.editSlideForm.getText(), True)
|
||||||
self.updateSlideList(self.editSlideForm.getText(), True)
|
|
||||||
|
def onPreviewButtonPressed(self):
|
||||||
|
"""
|
||||||
|
Save the custom item and preview it.
|
||||||
|
"""
|
||||||
|
log.debug(u'onPreview')
|
||||||
|
if self.saveCustom():
|
||||||
|
Receiver.send_message(u'custom_preview')
|
||||||
|
|
||||||
def updateSlideList(self, slides, edit_all=False):
|
def updateSlideList(self, slides, edit_all=False):
|
||||||
"""
|
"""
|
||||||
@ -244,13 +221,40 @@ class EditCustomForm(QtGui.QDialog, Ui_CustomEditDialog):
|
|||||||
self.slideListView.repaint()
|
self.slideListView.repaint()
|
||||||
|
|
||||||
def onDeleteButtonPressed(self):
|
def onDeleteButtonPressed(self):
|
||||||
|
"""
|
||||||
|
Removes the current row from the list.
|
||||||
|
"""
|
||||||
self.slideListView.takeItem(self.slideListView.currentRow())
|
self.slideListView.takeItem(self.slideListView.currentRow())
|
||||||
self.editButton.setEnabled(True)
|
if self.slideListView.currentRow() == 0:
|
||||||
self.editAllButton.setEnabled(True)
|
self.upButton.setEnabled(False)
|
||||||
if self.slideListView.count() == 0:
|
if self.slideListView.currentRow() == self.slideListView.count():
|
||||||
|
self.downButton.setEnabled(False)
|
||||||
|
|
||||||
|
def onCurrentRowChanged(self, row):
|
||||||
|
"""
|
||||||
|
Called when the *slideListView*'s current row has been changed. This
|
||||||
|
enables or disables buttons which require an slide to act on.
|
||||||
|
|
||||||
|
``row``
|
||||||
|
The row (int). If there is no current row, the value is -1.
|
||||||
|
"""
|
||||||
|
if row == -1:
|
||||||
self.deleteButton.setEnabled(False)
|
self.deleteButton.setEnabled(False)
|
||||||
self.editButton.setEnabled(False)
|
self.editButton.setEnabled(False)
|
||||||
self.editAllButton.setEnabled(False)
|
self.upButton.setEnabled(False)
|
||||||
|
self.downButton.setEnabled(False)
|
||||||
|
else:
|
||||||
|
self.deleteButton.setEnabled(True)
|
||||||
|
self.editButton.setEnabled(True)
|
||||||
|
# Decide if the up/down buttons should be enabled or not.
|
||||||
|
if self.slideListView.count() - 1 == row:
|
||||||
|
self.downButton.setEnabled(False)
|
||||||
|
else:
|
||||||
|
self.downButton.setEnabled(True)
|
||||||
|
if row == 0:
|
||||||
|
self.upButton.setEnabled(False)
|
||||||
|
else:
|
||||||
|
self.upButton.setEnabled(True)
|
||||||
|
|
||||||
def _validate(self):
|
def _validate(self):
|
||||||
"""
|
"""
|
||||||
@ -259,10 +263,14 @@ class EditCustomForm(QtGui.QDialog, Ui_CustomEditDialog):
|
|||||||
# We must have a title.
|
# We must have a title.
|
||||||
if len(self.titleEdit.displayText()) == 0:
|
if len(self.titleEdit.displayText()) == 0:
|
||||||
self.titleEdit.setFocus()
|
self.titleEdit.setFocus()
|
||||||
return False, translate('CustomPlugin.EditCustomForm',
|
critical_error_message_box(
|
||||||
'You need to type in a title.')
|
message=translate('CustomPlugin.EditCustomForm',
|
||||||
|
'You need to type in a title.'))
|
||||||
|
return False
|
||||||
# We must have at least one slide.
|
# We must have at least one slide.
|
||||||
if self.slideListView.count() == 0:
|
if self.slideListView.count() == 0:
|
||||||
return False, translate('CustomPlugin.EditCustomForm',
|
critical_error_message_box(
|
||||||
'You need to add at least one slide')
|
message=translate('CustomPlugin.EditCustomForm',
|
||||||
return True, u''
|
'You need to add at least one slide'))
|
||||||
|
return False
|
||||||
|
return True
|
||||||
|
Loading…
Reference in New Issue
Block a user