forked from openlp/openlp
Deduplication
This commit is contained in:
parent
90b1205e5b
commit
9744d246d6
@ -319,6 +319,20 @@ def check_directory_exists(dir):
|
||||
if not os.path.exists(dir):
|
||||
os.makedirs(dir)
|
||||
|
||||
def dialogButtonsSaveCancel(parent):
|
||||
"""
|
||||
Return a standard dialog button box with save and cancel buttons.
|
||||
"""
|
||||
button_box = QtGui.QDialogButtonBox(parent)
|
||||
button_box.setStandardButtons(QtGui.QDialogButtonBox.Save |
|
||||
QtGui.QDialogButtonBox.Cancel)
|
||||
button_box.setObjectName(u'%sButtonBox' % parent)
|
||||
QtCore.QObject.connect(button_box, QtCore.SIGNAL(u'accepted()'),
|
||||
parent.accept)
|
||||
QtCore.QObject.connect(button_box, QtCore.SIGNAL(u'rejected()'),
|
||||
parent.reject)
|
||||
return button_box
|
||||
|
||||
from theme import ThemeLevel, ThemeXML, BackgroundGradientType, \
|
||||
BackgroundType, HorizontalType, VerticalType
|
||||
from displaytags import DisplayTags
|
||||
|
@ -540,3 +540,25 @@ class MediaManagerItem(QtGui.QWidget):
|
||||
individual service items need to be processed by the plugins
|
||||
"""
|
||||
pass
|
||||
|
||||
def _getIdOfItemToGenerate(self, item, remoteItem):
|
||||
"""
|
||||
Utility method to check items being submitted for slide generation.
|
||||
|
||||
``item``
|
||||
The item to check.
|
||||
|
||||
``remoteItem``
|
||||
The id to assign if the slide generation was remotely triggered.
|
||||
"""
|
||||
if item is None:
|
||||
if self.remoteTriggered is None:
|
||||
item = self.listView.currentItem()
|
||||
if item is None:
|
||||
return False
|
||||
item_id = (item.data(QtCore.Qt.UserRole)).toInt()[0]
|
||||
else:
|
||||
item_id = remoteItem
|
||||
else:
|
||||
item_id = (item.data(QtCore.Qt.UserRole)).toInt()[0]
|
||||
return item_id
|
||||
|
@ -26,7 +26,7 @@
|
||||
|
||||
from PyQt4 import QtCore, QtGui
|
||||
|
||||
from openlp.core.lib import translate, build_icon
|
||||
from openlp.core.lib import translate, build_icon, dialogButtonsSaveCancel
|
||||
|
||||
class Ui_ServiceItemEditDialog(object):
|
||||
def setupUi(self, serviceItemEditDialog):
|
||||
@ -52,12 +52,8 @@ class Ui_ServiceItemEditDialog(object):
|
||||
self.downButton.setObjectName(u'downButton')
|
||||
self.buttonLayout.addWidget(self.downButton)
|
||||
self.dialogLayout.addLayout(self.buttonLayout, 0, 1)
|
||||
self.buttonBox = QtGui.QDialogButtonBox(serviceItemEditDialog)
|
||||
self.buttonBox.setStandardButtons(
|
||||
QtGui.QDialogButtonBox.Cancel | QtGui.QDialogButtonBox.Save)
|
||||
self.buttonBox.setObjectName(u'buttonBox')
|
||||
self.dialogLayout.addWidget(self.buttonBox, 1, 0, 1, 2)
|
||||
|
||||
self.dialogLayout.addWidget(
|
||||
dialogButtonsSaveCancel(serviceItemEditDialog), 1, 0, 1, 2)
|
||||
self.retranslateUi(serviceItemEditDialog)
|
||||
QtCore.QMetaObject.connectSlotsByName(serviceItemEditDialog)
|
||||
|
||||
|
@ -46,10 +46,6 @@ class ServiceItemEditForm(QtGui.QDialog, Ui_ServiceItemEditDialog):
|
||||
QtCore.SIGNAL(u'clicked()'), self.onItemDown)
|
||||
QtCore.QObject.connect(self.deleteButton,
|
||||
QtCore.SIGNAL(u'clicked()'), self.onItemDelete)
|
||||
QtCore.QObject.connect(self.buttonBox,
|
||||
QtCore.SIGNAL(u'accepted()'), self.accept)
|
||||
QtCore.QObject.connect(self.buttonBox,
|
||||
QtCore.SIGNAL(u'rejected()'), self.reject)
|
||||
QtCore.QObject.connect(self.listWidget,
|
||||
QtCore.SIGNAL(u'currentRowChanged(int)'), self.onCurrentRowChanged)
|
||||
|
||||
@ -100,27 +96,30 @@ class ServiceItemEditForm(QtGui.QDialog, Ui_ServiceItemEditDialog):
|
||||
"""
|
||||
Move the current row up in the list.
|
||||
"""
|
||||
item = self.listWidget.currentItem()
|
||||
if not item:
|
||||
return
|
||||
row = self.listWidget.row(item)
|
||||
temp = self.itemList[row]
|
||||
self.itemList.remove(self.itemList[row])
|
||||
self.itemList.insert(row - 1, temp)
|
||||
self.loadData()
|
||||
self.listWidget.setCurrentRow(row - 1)
|
||||
self.__moveItem(u'up')
|
||||
|
||||
def onItemDown(self):
|
||||
"""
|
||||
Move the current row down in the list
|
||||
"""
|
||||
self.__moveItem(u'down')
|
||||
|
||||
def __moveItem(self, direction=u''):
|
||||
"""
|
||||
Move the current item.
|
||||
"""
|
||||
if not direction:
|
||||
return
|
||||
item = self.listWidget.currentItem()
|
||||
if not item:
|
||||
return
|
||||
row = self.listWidget.row(item)
|
||||
temp = self.itemList[row]
|
||||
self.itemList.remove(self.itemList[row])
|
||||
self.itemList.insert(row + 1, temp)
|
||||
if direction == u'up':
|
||||
self.itemList.insert(row - 1, temp)
|
||||
else:
|
||||
self.itemList.insert(row + 1, temp)
|
||||
self.loadData()
|
||||
self.listWidget.setCurrentRow(row + 1)
|
||||
|
||||
|
@ -1,48 +0,0 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4
|
||||
|
||||
###############################################################################
|
||||
# OpenLP - Open Source Lyrics Projection #
|
||||
# --------------------------------------------------------------------------- #
|
||||
# Copyright (c) 2008-2011 Raoul Snyman #
|
||||
# Portions copyright (c) 2008-2011 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
|
||||
|
||||
class Ui_ServiceNoteEdit(object):
|
||||
def setupUi(self, serviceNoteEdit):
|
||||
serviceNoteEdit.setObjectName(u'serviceNoteEdit')
|
||||
self.dialogLayout = QtGui.QVBoxLayout(serviceNoteEdit)
|
||||
self.dialogLayout.setObjectName(u'verticalLayout')
|
||||
self.textEdit = QtGui.QTextEdit(serviceNoteEdit)
|
||||
self.textEdit.setObjectName(u'textEdit')
|
||||
self.dialogLayout.addWidget(self.textEdit)
|
||||
self.buttonBox = QtGui.QDialogButtonBox(serviceNoteEdit)
|
||||
self.buttonBox.setStandardButtons(QtGui.QDialogButtonBox.Cancel |
|
||||
QtGui.QDialogButtonBox.Save)
|
||||
self.buttonBox.setObjectName(u'buttonBox')
|
||||
self.dialogLayout.addWidget(self.buttonBox)
|
||||
self.retranslateUi(serviceNoteEdit)
|
||||
QtCore.QMetaObject.connectSlotsByName(serviceNoteEdit)
|
||||
|
||||
def retranslateUi(self, serviceNoteEdit):
|
||||
serviceNoteEdit.setWindowTitle(
|
||||
translate('OpenLP.ServiceNoteForm', 'Service Item Notes'))
|
@ -26,6 +26,7 @@
|
||||
|
||||
from PyQt4 import QtCore, QtGui
|
||||
|
||||
from openlp.core.lib import dialogButtonsSaveCancel, translate
|
||||
from servicenotedialog import Ui_ServiceNoteEdit
|
||||
|
||||
class ServiceNoteForm(QtGui.QDialog, Ui_ServiceNoteEdit):
|
||||
@ -37,8 +38,19 @@ class ServiceNoteForm(QtGui.QDialog, Ui_ServiceNoteEdit):
|
||||
Constructor
|
||||
"""
|
||||
QtGui.QDialog.__init__(self, parent)
|
||||
self.setupUi(self)
|
||||
QtCore.QObject.connect(self.buttonBox, QtCore.SIGNAL(u'accepted()'),
|
||||
self.accept)
|
||||
QtCore.QObject.connect(self.buttonBox, QtCore.SIGNAL(u'rejected()'),
|
||||
self.reject)
|
||||
self.setupUi()
|
||||
self.retranslateUi()
|
||||
|
||||
def setupUi(self):
|
||||
self.setObjectName(u'serviceNoteEdit')
|
||||
self.dialogLayout = QtGui.QVBoxLayout(self)
|
||||
self.dialogLayout.setObjectName(u'verticalLayout')
|
||||
self.textEdit = QtGui.QTextEdit(self)
|
||||
self.textEdit.setObjectName(u'textEdit')
|
||||
self.dialogLayout.addWidget(self.textEdit)
|
||||
self.dialogLayout.addWidget(dialogButtonsSaveCancel(self))
|
||||
QtCore.QMetaObject.connectSlotsByName(self)
|
||||
|
||||
def retranslateUi(self):
|
||||
self.setWindowTitle(
|
||||
translate('OpenLP.ServiceNoteForm', 'Service Item Notes'))
|
||||
|
@ -482,14 +482,7 @@ class SlideController(QtGui.QWidget):
|
||||
def onSongBarHandler(self):
|
||||
request = unicode(self.sender().text())
|
||||
slideno = self.slideList[request]
|
||||
if slideno > self.previewListWidget.rowCount():
|
||||
self.previewListWidget.selectRow(
|
||||
self.previewListWidget.rowCount() - 1)
|
||||
else:
|
||||
if slideno + 1 < self.previewListWidget.rowCount():
|
||||
self.previewListWidget.scrollToItem(
|
||||
self.previewListWidget.item(slideno + 1, 0))
|
||||
self.previewListWidget.selectRow(slideno)
|
||||
self.__updatePreviewSelection(slideno)
|
||||
self.onSlideSelected()
|
||||
|
||||
def receiveSpinDelay(self, value):
|
||||
@ -665,14 +658,7 @@ class SlideController(QtGui.QWidget):
|
||||
self.previewListWidget.resizeRowsToContents()
|
||||
self.previewListWidget.setColumnWidth(0,
|
||||
self.previewListWidget.viewport().size().width())
|
||||
if slideno > self.previewListWidget.rowCount():
|
||||
self.previewListWidget.selectRow(
|
||||
self.previewListWidget.rowCount() - 1)
|
||||
else:
|
||||
if slideno + 1 < self.previewListWidget.rowCount():
|
||||
self.previewListWidget.scrollToItem(
|
||||
self.previewListWidget.item(slideno + 1, 0))
|
||||
self.previewListWidget.selectRow(slideno)
|
||||
self.__updatePreviewSelection(slideno)
|
||||
self.enableToolBar(serviceItem)
|
||||
# Pass to display for viewing
|
||||
self.display.buildHtml(self.serviceItem)
|
||||
@ -683,6 +669,19 @@ class SlideController(QtGui.QWidget):
|
||||
Receiver.send_message(u'slidecontroller_%s_started' % self.typePrefix,
|
||||
[serviceItem])
|
||||
|
||||
def __updatePreviewSelection(self, slideno):
|
||||
"""
|
||||
Utility method to update the selected slide in the list.
|
||||
"""
|
||||
if slideno > self.previewListWidget.rowCount():
|
||||
self.previewListWidget.selectRow(
|
||||
self.previewListWidget.rowCount() - 1)
|
||||
else:
|
||||
if slideno + 1 < self.previewListWidget.rowCount():
|
||||
self.previewListWidget.scrollToItem(
|
||||
self.previewListWidget.item(slideno + 1, 0))
|
||||
self.previewListWidget.selectRow(slideno)
|
||||
|
||||
def onTextRequest(self):
|
||||
"""
|
||||
Return the text for the current item in controller
|
||||
|
@ -165,13 +165,7 @@ class ThemesTab(SettingsTab):
|
||||
self.global_theme = unicode(self.DefaultComboBox.currentText())
|
||||
self.parent.renderManager.set_global_theme(
|
||||
self.global_theme, self.theme_level)
|
||||
image = self.parent.ThemeManagerContents.getPreviewImage(
|
||||
self.global_theme)
|
||||
preview = QtGui.QPixmap(unicode(image))
|
||||
if not preview.isNull():
|
||||
preview = preview.scaled(300, 255, QtCore.Qt.KeepAspectRatio,
|
||||
QtCore.Qt.SmoothTransformation)
|
||||
self.DefaultListView.setPixmap(preview)
|
||||
self.__previewGlobalTheme()
|
||||
|
||||
def updateThemeList(self, theme_list):
|
||||
"""
|
||||
@ -198,10 +192,16 @@ class ThemesTab(SettingsTab):
|
||||
self.parent.renderManager.set_global_theme(
|
||||
self.global_theme, self.theme_level)
|
||||
if self.global_theme is not u'':
|
||||
image = self.parent.ThemeManagerContents.getPreviewImage(
|
||||
self.global_theme)
|
||||
preview = QtGui.QPixmap(unicode(image))
|
||||
if not preview.isNull():
|
||||
preview = preview.scaled(300, 255, QtCore.Qt.KeepAspectRatio,
|
||||
QtCore.Qt.SmoothTransformation)
|
||||
self.DefaultListView.setPixmap(preview)
|
||||
self.__previewGlobalTheme()
|
||||
|
||||
def __previewGlobalTheme(self):
|
||||
"""
|
||||
Utility method to update the global theme preview image.
|
||||
"""
|
||||
image = self.parent.ThemeManagerContents.getPreviewImage(
|
||||
self.global_theme)
|
||||
preview = QtGui.QPixmap(unicode(image))
|
||||
if not preview.isNull():
|
||||
preview = preview.scaled(300, 255, QtCore.Qt.KeepAspectRatio,
|
||||
QtCore.Qt.SmoothTransformation)
|
||||
self.DefaultListView.setPixmap(preview)
|
||||
|
@ -525,19 +525,7 @@ class BibleMediaItem(MediaManagerItem):
|
||||
if self.advancedClearComboBox.currentIndex() == 0:
|
||||
self.listView.clear()
|
||||
if self.listView.count() != 0:
|
||||
# Check if the first item is a second bible item or not.
|
||||
bitem = self.listView.item(0)
|
||||
item_second_bible = self._decodeQtObject(bitem, 'second_bible')
|
||||
if item_second_bible and second_bible or not item_second_bible and \
|
||||
not second_bible:
|
||||
self.displayResults(bible, second_bible)
|
||||
elif criticalErrorMessageBox(
|
||||
message=translate('BiblePlugin.MediaItem',
|
||||
'You cannot combine single and second bible verses. Do you '
|
||||
'want to delete your search results and start a new search?'),
|
||||
parent=self, question=True) == QtGui.QMessageBox.Yes:
|
||||
self.listView.clear()
|
||||
self.displayResults(bible, second_bible)
|
||||
self.__checkSecondBible()
|
||||
else:
|
||||
self.displayResults(bible, second_bible)
|
||||
Receiver.send_message(u'cursor_normal')
|
||||
@ -577,24 +565,29 @@ class BibleMediaItem(MediaManagerItem):
|
||||
if self.quickClearComboBox.currentIndex() == 0:
|
||||
self.listView.clear()
|
||||
if self.listView.count() != 0 and self.search_results:
|
||||
bitem = self.listView.item(0)
|
||||
item_second_bible = self._decodeQtObject(bitem, 'second_bible')
|
||||
if item_second_bible and second_bible or not item_second_bible and \
|
||||
not second_bible:
|
||||
self.displayResults(bible, second_bible)
|
||||
elif criticalErrorMessageBox(
|
||||
message=translate('BiblePlugin.MediaItem',
|
||||
'You cannot combine single and second bible verses. Do you '
|
||||
'want to delete your search results and start a new search?'),
|
||||
parent=self, question=True) == QtGui.QMessageBox.Yes:
|
||||
self.listView.clear()
|
||||
self.displayResults(bible, second_bible)
|
||||
self.__checkSecondBible()
|
||||
elif self.search_results:
|
||||
self.displayResults(bible, second_bible)
|
||||
self.quickSearchButton.setEnabled(True)
|
||||
Receiver.send_message(u'cursor_normal')
|
||||
Receiver.send_message(u'openlp_process_events')
|
||||
|
||||
def __checkSecondBible(self):
|
||||
"""
|
||||
Check if the first item is a second bible item or not.
|
||||
"""
|
||||
bitem = self.listView.item(0)
|
||||
item_second_bible = self._decodeQtObject(bitem, 'second_bible')
|
||||
if item_second_bible and second_bible or not item_second_bible and \
|
||||
not second_bible:
|
||||
self.displayResults(bible, second_bible)
|
||||
elif criticalErrorMessageBox(message=translate('BiblePlugin.MediaItem',
|
||||
'You cannot combine single and second bible verses. Do you '
|
||||
'want to delete your search results and start a new search?'),
|
||||
parent=self, question=True) == QtGui.QMessageBox.Yes:
|
||||
self.listView.clear()
|
||||
self.displayResults(bible, second_bible)
|
||||
|
||||
def displayResults(self, bible, second_bible=u''):
|
||||
"""
|
||||
Displays the search results in the media manager. All data needed for
|
||||
|
@ -26,7 +26,7 @@
|
||||
|
||||
from PyQt4 import QtCore, QtGui
|
||||
|
||||
from openlp.core.lib import build_icon, translate
|
||||
from openlp.core.lib import build_icon, translate, dialogButtonsSaveCancel
|
||||
|
||||
class Ui_CustomEditDialog(object):
|
||||
def setupUi(self, customEditDialog):
|
||||
@ -93,16 +93,9 @@ class Ui_CustomEditDialog(object):
|
||||
self.creditLabel.setBuddy(self.creditEdit)
|
||||
self.bottomFormLayout.addRow(self.creditLabel, self.creditEdit)
|
||||
self.dialogLayout.addLayout(self.bottomFormLayout)
|
||||
self.buttonBox = QtGui.QDialogButtonBox(customEditDialog)
|
||||
self.buttonBox.setStandardButtons(QtGui.QDialogButtonBox.Cancel |
|
||||
QtGui.QDialogButtonBox.Save)
|
||||
self.buttonBox.setObjectName(u'buttonBox')
|
||||
self.buttonBox = dialogButtonsSaveCancel(customEditDialog)
|
||||
self.dialogLayout.addWidget(self.buttonBox)
|
||||
self.retranslateUi(customEditDialog)
|
||||
QtCore.QObject.connect(self.buttonBox, QtCore.SIGNAL(u'accepted()'),
|
||||
customEditDialog.accept)
|
||||
QtCore.QObject.connect(self.buttonBox, QtCore.SIGNAL(u'rejected()'),
|
||||
customEditDialog.closePressed)
|
||||
QtCore.QMetaObject.connectSlotsByName(customEditDialog)
|
||||
|
||||
def retranslateUi(self, customEditDialog):
|
||||
|
@ -136,7 +136,7 @@ class EditCustomForm(QtGui.QDialog, Ui_CustomEditDialog):
|
||||
if preview:
|
||||
self.previewButton.setVisible(True)
|
||||
|
||||
def closePressed(self):
|
||||
def reject(self):
|
||||
Receiver.send_message(u'custom_edit_clear')
|
||||
self.close()
|
||||
|
||||
|
@ -26,7 +26,7 @@
|
||||
|
||||
from PyQt4 import QtCore, QtGui
|
||||
|
||||
from openlp.core.lib import translate, SpellTextEdit
|
||||
from openlp.core.lib import translate, SpellTextEdit, dialogButtonsSaveCancel
|
||||
|
||||
class Ui_CustomSlideEditDialog(object):
|
||||
def setupUi(self, customSlideEditDialog):
|
||||
@ -36,20 +36,13 @@ class Ui_CustomSlideEditDialog(object):
|
||||
self.slideTextEdit = SpellTextEdit(self)
|
||||
self.slideTextEdit.setObjectName(u'slideTextEdit')
|
||||
self.dialogLayout.addWidget(self.slideTextEdit)
|
||||
self.buttonBox = QtGui.QDialogButtonBox(customSlideEditDialog)
|
||||
self.buttonBox.setStandardButtons(QtGui.QDialogButtonBox.Cancel |
|
||||
QtGui.QDialogButtonBox.Save)
|
||||
self.buttonBox.setObjectName(u'buttonBox')
|
||||
self.buttonBox = dialogButtonsSaveCancel(customSlideEditDialog)
|
||||
self.splitButton = QtGui.QPushButton(customSlideEditDialog)
|
||||
self.splitButton.setObjectName(u'splitButton')
|
||||
self.buttonBox.addButton(self.splitButton,
|
||||
QtGui.QDialogButtonBox.ActionRole)
|
||||
self.dialogLayout.addWidget(self.buttonBox)
|
||||
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):
|
||||
|
@ -146,16 +146,7 @@ class CustomMediaItem(MediaManagerItem):
|
||||
raw_footer = []
|
||||
slide = None
|
||||
theme = None
|
||||
if item is None:
|
||||
if self.remoteTriggered is None:
|
||||
item = self.listView.currentItem()
|
||||
if item is None:
|
||||
return False
|
||||
item_id = (item.data(QtCore.Qt.UserRole)).toInt()[0]
|
||||
else:
|
||||
item_id = self.remoteCustom
|
||||
else:
|
||||
item_id = (item.data(QtCore.Qt.UserRole)).toInt()[0]
|
||||
item_id = self._getIdOfItemToGenerate(item, self.remoteCustom)
|
||||
service_item.add_capability(ItemCapabilities.AllowsEdit)
|
||||
service_item.add_capability(ItemCapabilities.AllowsPreview)
|
||||
service_item.add_capability(ItemCapabilities.AllowsLoop)
|
||||
|
@ -116,7 +116,7 @@ class Controller(object):
|
||||
|
||||
def last(self):
|
||||
"""
|
||||
Based on the handler passed at startup triggers the first slide
|
||||
Based on the handler passed at startup triggers the last slide
|
||||
"""
|
||||
log.debug(u'Live = %s, last' % self.is_live)
|
||||
if not self.is_live:
|
||||
|
@ -26,7 +26,7 @@
|
||||
|
||||
from PyQt4 import QtCore, QtGui
|
||||
|
||||
from openlp.core.lib import translate
|
||||
from openlp.core.lib import dialogButtonsSaveCancel, translate
|
||||
|
||||
class Ui_AuthorsDialog(object):
|
||||
def setupUi(self, authorsDialog):
|
||||
@ -55,17 +55,9 @@ class Ui_AuthorsDialog(object):
|
||||
self.displayLabel.setBuddy(self.displayEdit)
|
||||
self.authorLayout.addRow(self.displayLabel, self.displayEdit)
|
||||
self.dialogLayout.addLayout(self.authorLayout)
|
||||
self.buttonBox = QtGui.QDialogButtonBox(authorsDialog)
|
||||
self.buttonBox.setStandardButtons(
|
||||
QtGui.QDialogButtonBox.Save | QtGui.QDialogButtonBox.Cancel)
|
||||
self.buttonBox.setObjectName(u'buttonBox')
|
||||
self.dialogLayout.addWidget(self.buttonBox)
|
||||
self.dialogLayout.addWidget(dialogButtonsSaveCancel(authorsDialog))
|
||||
self.retranslateUi(authorsDialog)
|
||||
authorsDialog.setMaximumHeight(authorsDialog.sizeHint().height())
|
||||
QtCore.QObject.connect(self.buttonBox,
|
||||
QtCore.SIGNAL(u'accepted()'), authorsDialog.accept)
|
||||
QtCore.QObject.connect(self.buttonBox,
|
||||
QtCore.SIGNAL(u'rejected()'), authorsDialog.reject)
|
||||
QtCore.QMetaObject.connectSlotsByName(authorsDialog)
|
||||
|
||||
def retranslateUi(self, authorsDialog):
|
||||
|
@ -26,7 +26,7 @@
|
||||
|
||||
from PyQt4 import QtCore, QtGui
|
||||
|
||||
from openlp.core.lib import build_icon, translate
|
||||
from openlp.core.lib import build_icon, translate, dialogButtonsSaveCancel
|
||||
|
||||
class Ui_EditSongDialog(object):
|
||||
def setupUi(self, editSongDialog):
|
||||
@ -264,16 +264,9 @@ class Ui_EditSongDialog(object):
|
||||
self.themeTabLayout.addWidget(self.commentsGroupBox)
|
||||
self.songTabWidget.addTab(self.themeTab, u'')
|
||||
self.dialogLayout.addWidget(self.songTabWidget)
|
||||
self.buttonBox = QtGui.QDialogButtonBox(editSongDialog)
|
||||
self.buttonBox.setStandardButtons(
|
||||
QtGui.QDialogButtonBox.Cancel | QtGui.QDialogButtonBox.Save)
|
||||
self.buttonBox.setObjectName(u'buttonBox')
|
||||
self.buttonBox = dialogButtonsSaveCancel(editSongDialog)
|
||||
self.dialogLayout.addWidget(self.buttonBox)
|
||||
self.retranslateUi(editSongDialog)
|
||||
QtCore.QObject.connect(self.buttonBox,
|
||||
QtCore.SIGNAL(u'rejected()'), editSongDialog.closePressed)
|
||||
QtCore.QObject.connect(self.buttonBox,
|
||||
QtCore.SIGNAL(u'accepted()'), editSongDialog.accept)
|
||||
QtCore.QMetaObject.connectSlotsByName(editSongDialog)
|
||||
|
||||
def retranslateUi(self, editSongDialog):
|
||||
|
@ -333,11 +333,7 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog):
|
||||
author = Author.populate(first_name=text.rsplit(u' ', 1)[0],
|
||||
last_name=text.rsplit(u' ', 1)[1], display_name=text)
|
||||
self.manager.save_object(author)
|
||||
author_item = QtGui.QListWidgetItem(
|
||||
unicode(author.display_name))
|
||||
author_item.setData(QtCore.Qt.UserRole,
|
||||
QtCore.QVariant(author.id))
|
||||
self.authorsListView.addItem(author_item)
|
||||
self.__addAuthorToList(author)
|
||||
self.loadAuthors()
|
||||
self.authorsComboBox.setCurrentIndex(0)
|
||||
else:
|
||||
@ -351,11 +347,7 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog):
|
||||
message=translate('SongsPlugin.EditSongForm',
|
||||
'This author is already in the list.'))
|
||||
else:
|
||||
author_item = QtGui.QListWidgetItem(unicode(
|
||||
author.display_name))
|
||||
author_item.setData(QtCore.Qt.UserRole,
|
||||
QtCore.QVariant(author.id))
|
||||
self.authorsListView.addItem(author_item)
|
||||
self.__addAuthorToList(author)
|
||||
self.authorsComboBox.setCurrentIndex(0)
|
||||
else:
|
||||
QtGui.QMessageBox.warning(self,
|
||||
@ -365,6 +357,14 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog):
|
||||
'or type in a new author and click the "Add Author to '
|
||||
'Song" button to add the new author.'))
|
||||
|
||||
def __addAuthorToList(self, author):
|
||||
"""
|
||||
Add an author to the author list.
|
||||
"""
|
||||
author_item = QtGui.QListWidgetItem(unicode(author.display_name))
|
||||
author_item.setData(QtCore.Qt.UserRole, QtCore.QVariant(author.id))
|
||||
self.authorsListView.addItem(author_item)
|
||||
|
||||
def onAuthorsListViewPressed(self):
|
||||
if self.authorsListView.count() > 1:
|
||||
self.authorRemoveButton.setEnabled(True)
|
||||
@ -653,7 +653,7 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog):
|
||||
self.books = []
|
||||
self.topics = []
|
||||
|
||||
def closePressed(self):
|
||||
def reject(self):
|
||||
"""
|
||||
Exit Dialog and do not save
|
||||
"""
|
||||
|
@ -26,7 +26,8 @@
|
||||
|
||||
from PyQt4 import QtCore, QtGui
|
||||
|
||||
from openlp.core.lib import build_icon, translate, SpellTextEdit
|
||||
from openlp.core.lib import build_icon, dialogButtonsSaveCancel, translate, \
|
||||
SpellTextEdit
|
||||
from openlp.plugins.songs.lib import VerseType
|
||||
|
||||
class Ui_EditVerseDialog(object):
|
||||
@ -59,17 +60,8 @@ class Ui_EditVerseDialog(object):
|
||||
self.verseTypeLayout.addWidget(self.insertButton)
|
||||
self.verseTypeLayout.addStretch()
|
||||
self.dialogLayout.addLayout(self.verseTypeLayout)
|
||||
self.buttonBox = QtGui.QDialogButtonBox(editVerseDialog)
|
||||
self.buttonBox.setOrientation(QtCore.Qt.Horizontal)
|
||||
self.buttonBox.setStandardButtons(QtGui.QDialogButtonBox.Cancel |
|
||||
QtGui.QDialogButtonBox.Save)
|
||||
self.buttonBox.setObjectName(u'buttonBox')
|
||||
self.dialogLayout.addWidget(self.buttonBox)
|
||||
self.dialogLayout.addWidget(dialogButtonsSaveCancel(editVerseDialog))
|
||||
self.retranslateUi(editVerseDialog)
|
||||
QtCore.QObject.connect(self.buttonBox, QtCore.SIGNAL(u'accepted()'),
|
||||
editVerseDialog.accept)
|
||||
QtCore.QObject.connect(self.buttonBox, QtCore.SIGNAL(u'rejected()'),
|
||||
editVerseDialog.reject)
|
||||
QtCore.QMetaObject.connectSlotsByName(editVerseDialog)
|
||||
|
||||
def retranslateUi(self, editVerseDialog):
|
||||
|
@ -26,7 +26,7 @@
|
||||
|
||||
from PyQt4 import QtCore, QtGui
|
||||
|
||||
from openlp.core.lib import translate
|
||||
from openlp.core.lib import translate, dialogButtonsSaveCancel
|
||||
|
||||
class Ui_SongBookDialog(object):
|
||||
def setupUi(self, songBookDialog):
|
||||
@ -49,17 +49,9 @@ class Ui_SongBookDialog(object):
|
||||
self.publisherLabel.setBuddy(self.publisherEdit)
|
||||
self.bookLayout.addRow(self.publisherLabel, self.publisherEdit)
|
||||
self.dialogLayout.addLayout(self.bookLayout)
|
||||
self.buttonBox = QtGui.QDialogButtonBox(songBookDialog)
|
||||
self.buttonBox.setStandardButtons(
|
||||
QtGui.QDialogButtonBox.Save | QtGui.QDialogButtonBox.Cancel)
|
||||
self.buttonBox.setObjectName(u'buttonBox')
|
||||
self.dialogLayout.addWidget(self.buttonBox)
|
||||
self.dialogLayout.addWidget(dialogButtonsSaveCancel(songBookDialog))
|
||||
self.retranslateUi(songBookDialog)
|
||||
songBookDialog.setMaximumHeight(songBookDialog.sizeHint().height())
|
||||
QtCore.QObject.connect(self.buttonBox,
|
||||
QtCore.SIGNAL(u'accepted()'), songBookDialog.accept)
|
||||
QtCore.QObject.connect(self.buttonBox,
|
||||
QtCore.SIGNAL(u'rejected()'), songBookDialog.reject)
|
||||
QtCore.QMetaObject.connectSlotsByName(songBookDialog)
|
||||
|
||||
def retranslateUi(self, songBookDialog):
|
||||
|
@ -310,12 +310,8 @@ class SongMaintenanceForm(QtGui.QDialog, Ui_SongMaintenanceDialog):
|
||||
'the existing author %s?')) % (author.display_name,
|
||||
temp_display_name, author.display_name),
|
||||
parent=self, question=True) == QtGui.QMessageBox.Yes:
|
||||
Receiver.send_message(u'cursor_busy')
|
||||
Receiver.send_message(u'openlp_process_events')
|
||||
self.mergeAuthors(author)
|
||||
self.resetAuthors()
|
||||
Receiver.send_message(u'songs_load_list')
|
||||
Receiver.send_message(u'cursor_normal')
|
||||
self.__mergeObjects(author, self.mergeAuthors,
|
||||
self.resetAuthors)
|
||||
else:
|
||||
# We restore the author's old first and last name as well as
|
||||
# his display name.
|
||||
@ -350,11 +346,7 @@ class SongMaintenanceForm(QtGui.QDialog, Ui_SongMaintenanceDialog):
|
||||
'with topic %s use the existing topic %s?')) % (topic.name,
|
||||
temp_name, topic.name),
|
||||
parent=self, question=True) == QtGui.QMessageBox.Yes:
|
||||
Receiver.send_message(u'cursor_busy')
|
||||
Receiver.send_message(u'openlp_process_events')
|
||||
self.mergeTopics(topic)
|
||||
self.resetTopics()
|
||||
Receiver.send_message(u'cursor_normal')
|
||||
self.__mergeObjects(topic, self.mergeTopics, self.resetTopics)
|
||||
else:
|
||||
# We restore the topics's old name.
|
||||
topic.name = temp_name
|
||||
@ -392,16 +384,23 @@ class SongMaintenanceForm(QtGui.QDialog, Ui_SongMaintenanceDialog):
|
||||
'with book %s use the existing book %s?')) % (book.name,
|
||||
temp_name, book.name),
|
||||
parent=self, question=True) == QtGui.QMessageBox.Yes:
|
||||
Receiver.send_message(u'cursor_busy')
|
||||
Receiver.send_message(u'openlp_process_events')
|
||||
self.mergeBooks(book)
|
||||
self.resetBooks()
|
||||
Receiver.send_message(u'cursor_normal')
|
||||
self.__mergeObjects(book, self.mergeBooks, self.resetBooks)
|
||||
else:
|
||||
# We restore the book's old name and publisher.
|
||||
book.name = temp_name
|
||||
book.publisher = temp_publisher
|
||||
|
||||
def __mergeObjects(self, object, merge, reset):
|
||||
"""
|
||||
Utility method to merge two objects to leave one in the database.
|
||||
"""
|
||||
Receiver.send_message(u'cursor_busy')
|
||||
Receiver.send_message(u'openlp_process_events')
|
||||
merge(object)
|
||||
reset()
|
||||
Receiver.send_message(u'songs_load_list')
|
||||
Receiver.send_message(u'cursor_normal')
|
||||
|
||||
def mergeAuthors(self, old_author):
|
||||
"""
|
||||
Merges two authors into one author.
|
||||
@ -508,42 +507,32 @@ class SongMaintenanceForm(QtGui.QDialog, Ui_SongMaintenanceDialog):
|
||||
|
||||
def onAuthorsListRowChanged(self, row):
|
||||
"""
|
||||
Called when the *authorsListWidget* current's row has changed.
|
||||
|
||||
``row``
|
||||
The current row. If there is no current row, the value is -1
|
||||
Called when the *authorsListWidget*s current row has changed.
|
||||
"""
|
||||
if row == -1:
|
||||
self.authorsDeleteButton.setEnabled(False)
|
||||
self.authorsEditButton.setEnabled(False)
|
||||
else:
|
||||
self.authorsDeleteButton.setEnabled(True)
|
||||
self.authorsEditButton.setEnabled(True)
|
||||
self.__rowChange(row, self.authorsEditButton, self.authorsDeleteButton)
|
||||
|
||||
def onTopicsListRowChanged(self, row):
|
||||
"""
|
||||
Called when the *booksListWidget* current's row has changed.
|
||||
|
||||
``row``
|
||||
The current row. If there is no current row, the value is -1.
|
||||
Called when the *topicsListWidget*s current row has changed.
|
||||
"""
|
||||
if row == -1:
|
||||
self.topicsDeleteButton.setEnabled(False)
|
||||
self.topicsEditButton.setEnabled(False)
|
||||
else:
|
||||
self.topicsDeleteButton.setEnabled(True)
|
||||
self.topicsEditButton.setEnabled(True)
|
||||
self.__rowChange(row, self.topicsEditButton, self.topicsDeleteButton)
|
||||
|
||||
def onBooksListRowChanged(self, row):
|
||||
"""
|
||||
Called when the *booksListWidget* current's row has changed.
|
||||
Called when the *booksListWidget*s current row has changed.
|
||||
"""
|
||||
self.__rowChange(row, self.booksEditButton, self.booksDeleteButton)
|
||||
|
||||
def __rowChange(self, row, editButton, deleteButton):
|
||||
"""
|
||||
Utility method to toggle if buttons are enabled.
|
||||
|
||||
``row``
|
||||
The current row. If there is no current row, the value is -1.
|
||||
"""
|
||||
if row == -1:
|
||||
self.booksDeleteButton.setEnabled(False)
|
||||
self.booksEditButton.setEnabled(False)
|
||||
deleteButton.setEnabled(False)
|
||||
editButton.setEnabled(False)
|
||||
else:
|
||||
self.booksDeleteButton.setEnabled(True)
|
||||
self.booksEditButton.setEnabled(True)
|
||||
deleteButton.setEnabled(True)
|
||||
editButton.setEnabled(True)
|
||||
|
@ -26,7 +26,7 @@
|
||||
|
||||
from PyQt4 import QtCore, QtGui
|
||||
|
||||
from openlp.core.lib import translate
|
||||
from openlp.core.lib import translate, dialogButtonsSaveCancel
|
||||
|
||||
class Ui_TopicsDialog(object):
|
||||
def setupUi(self, topicsDialog):
|
||||
@ -43,17 +43,9 @@ class Ui_TopicsDialog(object):
|
||||
self.nameLabel.setBuddy(self.nameEdit)
|
||||
self.nameLayout.addRow(self.nameLabel, self.nameEdit)
|
||||
self.dialogLayout.addLayout(self.nameLayout)
|
||||
self.buttonBox = QtGui.QDialogButtonBox(topicsDialog)
|
||||
self.buttonBox.setStandardButtons(
|
||||
QtGui.QDialogButtonBox.Save | QtGui.QDialogButtonBox.Cancel)
|
||||
self.buttonBox.setObjectName(u'buttonBox')
|
||||
self.dialogLayout.addWidget(self.buttonBox)
|
||||
self.dialogLayout.addWidget(dialogButtonsSaveCancel(topicsDialog))
|
||||
self.retranslateUi(topicsDialog)
|
||||
topicsDialog.setMaximumHeight(topicsDialog.sizeHint().height())
|
||||
QtCore.QObject.connect(self.buttonBox,
|
||||
QtCore.SIGNAL(u'accepted()'), topicsDialog.accept)
|
||||
QtCore.QObject.connect(self.buttonBox,
|
||||
QtCore.SIGNAL(u'rejected()'), topicsDialog.reject)
|
||||
QtCore.QMetaObject.connectSlotsByName(topicsDialog)
|
||||
|
||||
def retranslateUi(self, topicsDialog):
|
||||
|
@ -133,30 +133,38 @@ class EasiSlidesImport(SongImport):
|
||||
pass
|
||||
|
||||
def _add_copyright(self, song):
|
||||
"""
|
||||
Assign the copyright information from the import to the song being
|
||||
created.
|
||||
|
||||
``song``
|
||||
The current song being imported.
|
||||
"""
|
||||
copyright = []
|
||||
try:
|
||||
copyright.append(unicode(song.Copyright).strip())
|
||||
except UnicodeDecodeError:
|
||||
log.exception(u'Unicode decode error while decoding Copyright')
|
||||
self._success = False
|
||||
except AttributeError:
|
||||
pass
|
||||
try:
|
||||
copyright.append(unicode(song.LicenceAdmin1).strip())
|
||||
except UnicodeDecodeError:
|
||||
log.exception(u'Unicode decode error while decoding LicenceAdmin1')
|
||||
self._success = False
|
||||
except AttributeError:
|
||||
pass
|
||||
try:
|
||||
copyright.append(unicode(song.LicenceAdmin2).strip())
|
||||
except UnicodeDecodeError:
|
||||
log.exception(u'Unicode decode error while decoding LicenceAdmin2')
|
||||
self._success = False
|
||||
except AttributeError:
|
||||
pass
|
||||
self.__add_copyright_element(copyright, song.Copyright)
|
||||
self.__add_copyright_element(copyright, song.LicenceAdmin1)
|
||||
self.__add_copyright_element(copyright, song.LicenceAdmin2)
|
||||
self.add_copyright(u' '.join(copyright))
|
||||
|
||||
def __add_copyright_element(self, copyright, element):
|
||||
"""
|
||||
Add a piece of copyright to the total copyright information for the
|
||||
song.
|
||||
|
||||
``copyright``
|
||||
The array to add the information to.
|
||||
|
||||
``element``
|
||||
The imported variable to get the data from.
|
||||
"""
|
||||
try:
|
||||
copyright.append(unicode(element).strip())
|
||||
except UnicodeDecodeError:
|
||||
log.exception(u'Unicode error decoding %s' % element)
|
||||
self._success = False
|
||||
except AttributeError:
|
||||
pass
|
||||
|
||||
def _parse_and_add_lyrics(self, song):
|
||||
try:
|
||||
lyrics = unicode(song.Contents).strip()
|
||||
|
@ -337,16 +337,7 @@ class SongMediaItem(MediaManagerItem):
|
||||
author_list = u''
|
||||
author_audit = []
|
||||
ccli = u''
|
||||
if item is None:
|
||||
if self.remoteTriggered is None:
|
||||
item = self.listView.currentItem()
|
||||
if item is None:
|
||||
return False
|
||||
item_id = (item.data(QtCore.Qt.UserRole)).toInt()[0]
|
||||
else:
|
||||
item_id = self.remoteSong
|
||||
else:
|
||||
item_id = (item.data(QtCore.Qt.UserRole)).toInt()[0]
|
||||
item_id = self._getIdOfItemToGenerate(item, self.remoteSong)
|
||||
service_item.add_capability(ItemCapabilities.AllowsEdit)
|
||||
service_item.add_capability(ItemCapabilities.AllowsPreview)
|
||||
service_item.add_capability(ItemCapabilities.AllowsLoop)
|
||||
|
Loading…
Reference in New Issue
Block a user