forked from openlp/openlp
better wizard form, clean ups, docs
This commit is contained in:
commit
c030104b3a
@ -24,7 +24,8 @@
|
|||||||
# Temple Place, Suite 330, Boston, MA 02111-1307 USA #
|
# Temple Place, Suite 330, Boston, MA 02111-1307 USA #
|
||||||
###############################################################################
|
###############################################################################
|
||||||
"""
|
"""
|
||||||
The song export function for OpenLP.
|
The :mod:`songexportform` module provides the wizard for exporting songs to the
|
||||||
|
OpenLyrics format.
|
||||||
"""
|
"""
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
@ -40,8 +41,8 @@ log = logging.getLogger(__name__)
|
|||||||
|
|
||||||
class SongExportForm(OpenLPWizard):
|
class SongExportForm(OpenLPWizard):
|
||||||
"""
|
"""
|
||||||
This is the Song Export Wizard, which allows easy exporting of Songs to
|
This is the Song Export Wizard, which allows easy exporting of Songs to the
|
||||||
OpenLyrics.
|
OpenLyrics format.
|
||||||
"""
|
"""
|
||||||
log.info(u'SongExportForm loaded')
|
log.info(u'SongExportForm loaded')
|
||||||
|
|
||||||
@ -57,7 +58,7 @@ class SongExportForm(OpenLPWizard):
|
|||||||
"""
|
"""
|
||||||
self.plugin = plugin
|
self.plugin = plugin
|
||||||
OpenLPWizard.__init__(self, parent, plugin, u'songExportWizard',
|
OpenLPWizard.__init__(self, parent, plugin, u'songExportWizard',
|
||||||
u':/wizards/wizard_importsong.bmp')
|
u':/wizards/wizard_exportsong.bmp')
|
||||||
self.stop_export_flag = False
|
self.stop_export_flag = False
|
||||||
QtCore.QObject.connect(Receiver.get_receiver(),
|
QtCore.QObject.connect(Receiver.get_receiver(),
|
||||||
QtCore.SIGNAL(u'openlp_stop_wizard'), self.stop_export)
|
QtCore.SIGNAL(u'openlp_stop_wizard'), self.stop_export)
|
||||||
@ -85,9 +86,9 @@ class SongExportForm(OpenLPWizard):
|
|||||||
"""
|
"""
|
||||||
Song wizard specific signals.
|
Song wizard specific signals.
|
||||||
"""
|
"""
|
||||||
QtCore.QObject.connect(self.addSelected,
|
QtCore.QObject.connect(self.addButton,
|
||||||
QtCore.SIGNAL(u'clicked()'), self.onAddSelectedClicked)
|
QtCore.SIGNAL(u'clicked()'), self.onAddSelectedClicked)
|
||||||
QtCore.QObject.connect(self.removeSelected,
|
QtCore.QObject.connect(self.removeButton,
|
||||||
QtCore.SIGNAL(u'clicked()'), self.onRemoveSelectedClicked)
|
QtCore.SIGNAL(u'clicked()'), self.onRemoveSelectedClicked)
|
||||||
QtCore.QObject.connect(self.availableListWidget,
|
QtCore.QObject.connect(self.availableListWidget,
|
||||||
QtCore.SIGNAL(u'itemDoubleClicked(QListWidgetItem *)'),
|
QtCore.SIGNAL(u'itemDoubleClicked(QListWidgetItem *)'),
|
||||||
@ -95,6 +96,12 @@ class SongExportForm(OpenLPWizard):
|
|||||||
QtCore.QObject.connect(self.selectedListWidget,
|
QtCore.QObject.connect(self.selectedListWidget,
|
||||||
QtCore.SIGNAL(u'itemDoubleClicked(QListWidgetItem *)'),
|
QtCore.SIGNAL(u'itemDoubleClicked(QListWidgetItem *)'),
|
||||||
self.onSelectedListItemDoubleClicked)
|
self.onSelectedListItemDoubleClicked)
|
||||||
|
QtCore.QObject.connect(self.directoryButton,
|
||||||
|
QtCore.SIGNAL(u'clicked()'), self.onDirectoryButtonClicked)
|
||||||
|
QtCore.QObject.connect(self.allAvailableButton,
|
||||||
|
QtCore.SIGNAL(u'clicked()'), self.onAllAvailableButtonClicked)
|
||||||
|
QtCore.QObject.connect(self.allSelectedButton,
|
||||||
|
QtCore.SIGNAL(u'clicked()'), self.onAllSelectedButtonClicked)
|
||||||
|
|
||||||
def addCustomPages(self):
|
def addCustomPages(self):
|
||||||
"""
|
"""
|
||||||
@ -103,82 +110,83 @@ class SongExportForm(OpenLPWizard):
|
|||||||
# Source Page
|
# Source Page
|
||||||
self.sourcePage = QtGui.QWizardPage()
|
self.sourcePage = QtGui.QWizardPage()
|
||||||
self.sourcePage.setObjectName(u'sourcePage')
|
self.sourcePage.setObjectName(u'sourcePage')
|
||||||
self.sourceLayout = QtGui.QHBoxLayout(self.sourcePage)
|
self.horizontalLayout = QtGui.QHBoxLayout(self.sourcePage)
|
||||||
self.sourceLayout.setObjectName(u'sourceLayout')
|
self.horizontalLayout.setObjectName(u'horizontalLayout')
|
||||||
self.availableGroupBox = QtGui.QGroupBox(self.sourcePage)
|
self.verticalLayout = QtGui.QVBoxLayout()
|
||||||
self.availableGroupBox.setObjectName(u'availableGroupBox')
|
|
||||||
self.verticalLayout = QtGui.QVBoxLayout(self.availableGroupBox)
|
|
||||||
self.verticalLayout.setObjectName(u'verticalLayout')
|
self.verticalLayout.setObjectName(u'verticalLayout')
|
||||||
self.verticalLayout.setContentsMargins(0, -1, 0, 0)
|
self.gridLayout = QtGui.QGridLayout()
|
||||||
self.availableListWidget = QtGui.QListWidget(self.availableGroupBox)
|
self.gridLayout.setObjectName(u'gridLayout')
|
||||||
self.availableListWidget.setObjectName(u'availableListWidget')
|
self.selectedListWidget = QtGui.QListWidget(self.sourcePage)
|
||||||
self.availableListWidget.setSelectionMode(
|
|
||||||
QtGui.QAbstractItemView.ExtendedSelection)
|
|
||||||
self.availableListWidget.setSizePolicy(
|
|
||||||
QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Expanding)
|
|
||||||
self.availableListWidget.setSortingEnabled(True)
|
|
||||||
self.verticalLayout.addWidget(self.availableListWidget)
|
|
||||||
self.sourceLayout.addWidget(self.availableGroupBox)
|
|
||||||
self.selectionWidget = QtGui.QWidget(self.sourcePage)
|
|
||||||
self.selectionWidget.setObjectName(u'selectionWidget')
|
|
||||||
self.selectionLayout = QtGui.QVBoxLayout(self.selectionWidget)
|
|
||||||
self.selectionLayout.setSpacing(0)
|
|
||||||
self.selectionLayout.setMargin(0)
|
|
||||||
self.selectionLayout.setObjectName(u'selectionLayout')
|
|
||||||
spacerItem = QtGui.QSpacerItem(20, 0,
|
|
||||||
QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.MinimumExpanding)
|
|
||||||
self.selectionLayout.addItem(spacerItem)
|
|
||||||
self.addSelected = QtGui.QToolButton(self.selectionWidget)
|
|
||||||
icon = QtGui.QIcon()
|
|
||||||
icon.addPixmap(QtGui.QPixmap(
|
|
||||||
u':/exports/export_move_to_list.png'),
|
|
||||||
QtGui.QIcon.Normal, QtGui.QIcon.Off)
|
|
||||||
self.addSelected.setIcon(icon)
|
|
||||||
self.addSelected.setIconSize(QtCore.QSize(20, 20))
|
|
||||||
self.addSelected.setObjectName(u'addSelected')
|
|
||||||
self.selectionLayout.addWidget(self.addSelected)
|
|
||||||
self.removeSelected = QtGui.QToolButton(self.selectionWidget)
|
|
||||||
icon = QtGui.QIcon()
|
|
||||||
icon.addPixmap(QtGui.QPixmap(
|
|
||||||
u':/exports/export_remove.png'),
|
|
||||||
QtGui.QIcon.Normal, QtGui.QIcon.Off)
|
|
||||||
self.removeSelected.setIcon(icon)
|
|
||||||
self.removeSelected.setIconSize(QtCore.QSize(20, 20))
|
|
||||||
self.removeSelected.setObjectName(u'removeSelected')
|
|
||||||
self.selectionLayout.addWidget(self.removeSelected)
|
|
||||||
spacerItem = QtGui.QSpacerItem(20, 0,
|
|
||||||
QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.MinimumExpanding)
|
|
||||||
self.selectionLayout.addItem(spacerItem)
|
|
||||||
self.sourceLayout.addWidget(self.selectionWidget)
|
|
||||||
self.selectedGroupBox = QtGui.QGroupBox(self.sourcePage)
|
|
||||||
self.selectedGroupBox.setObjectName(u'selectedGroupBox')
|
|
||||||
self.verticalLayout = QtGui.QVBoxLayout(self.selectedGroupBox)
|
|
||||||
self.verticalLayout.setObjectName(u'verticalLayout')
|
|
||||||
self.verticalLayout.setContentsMargins(0, -1, 0, 0)
|
|
||||||
self.selectedListWidget = QtGui.QListWidget(self.selectedGroupBox)
|
|
||||||
self.selectedListWidget.setObjectName(u'selectedListWidget')
|
self.selectedListWidget.setObjectName(u'selectedListWidget')
|
||||||
self.selectedListWidget.setSelectionMode(
|
self.selectedListWidget.setSelectionMode(
|
||||||
QtGui.QAbstractItemView.ExtendedSelection)
|
QtGui.QAbstractItemView.ExtendedSelection)
|
||||||
self.selectedListWidget.setSizePolicy(
|
|
||||||
QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Expanding)
|
|
||||||
self.selectedListWidget.setSortingEnabled(True)
|
self.selectedListWidget.setSortingEnabled(True)
|
||||||
self.verticalLayout.addWidget(self.selectedListWidget)
|
self.gridLayout.addWidget(self.selectedListWidget, 1, 2, 1, 1)
|
||||||
self.sourceLayout.addWidget(self.selectedGroupBox)
|
self.gridLayout2 = QtGui.QGridLayout()
|
||||||
#
|
self.gridLayout2.setObjectName(u'gridLayout2')
|
||||||
self.horizontalLayout = QtGui.QHBoxLayout()
|
self.addButton = QtGui.QToolButton(self.sourcePage)
|
||||||
self.horizontalLayout.setObjectName(u'horizontalLayout')
|
icon = QtGui.QIcon()
|
||||||
self.pathLabel = QtGui.QLabel()
|
icon.addPixmap(QtGui.QPixmap(u':/exports/export_move_to_list.png'),
|
||||||
self.pathLabel.setObjectName(u'pathLabel')
|
QtGui.QIcon.Normal, QtGui.QIcon.Off)
|
||||||
self.horizontalLayout.addWidget(self.pathLabel)
|
self.addButton.setIcon(icon)
|
||||||
self.pathEdit = QtGui.QLineEdit()
|
self.addButton.setObjectName(u'addButton')
|
||||||
self.pathEdit.setObjectName(u'pathEdit')
|
self.gridLayout2.addWidget(self.addButton, 1, 0, 1, 1)
|
||||||
self.horizontalLayout.addWidget(self.pathEdit)
|
self.removeButton = QtGui.QToolButton(self.sourcePage)
|
||||||
self.browseButton = QtGui.QToolButton()
|
icon = QtGui.QIcon()
|
||||||
self.browseButton.setObjectName(u'browseButton')
|
icon.addPixmap(QtGui.QPixmap(u':/exports/export_remove.png'),
|
||||||
self.horizontalLayout.addWidget(self.browseButton)
|
QtGui.QIcon.Normal, QtGui.QIcon.Off)
|
||||||
#
|
self.removeButton.setIcon(icon)
|
||||||
|
self.removeButton.setObjectName(u'removeButton')
|
||||||
|
self.gridLayout2.addWidget(self.removeButton, 2, 0, 1, 1)
|
||||||
|
spacerItem = QtGui.QSpacerItem(20, 40,
|
||||||
|
QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Expanding)
|
||||||
|
self.gridLayout2.addItem(spacerItem, 0, 0, 1, 1)
|
||||||
|
self.gridLayout2.addItem(spacerItem, 3, 0, 1, 1)
|
||||||
|
self.gridLayout.addLayout(self.gridLayout2, 1, 1, 1, 1)
|
||||||
|
self.availableLabel = QtGui.QLabel(self.sourcePage)
|
||||||
|
self.availableLabel.setObjectName(u'availableLabel')
|
||||||
|
self.gridLayout.addWidget(self.availableLabel, 0, 0, 1, 1)
|
||||||
|
self.selectedLabel = QtGui.QLabel(self.sourcePage)
|
||||||
|
self.selectedLabel.setObjectName(u'selectedLabel')
|
||||||
|
self.gridLayout.addWidget(self.selectedLabel, 0, 2, 1, 1)
|
||||||
|
self.availableListWidget = QtGui.QListWidget(self.sourcePage)
|
||||||
|
self.availableListWidget.setObjectName(u'availableListWidget')
|
||||||
|
self.availableListWidget.setSelectionMode(
|
||||||
|
QtGui.QAbstractItemView.ExtendedSelection)
|
||||||
|
self.availableListWidget.setSortingEnabled(True)
|
||||||
|
self.gridLayout.addWidget(self.availableListWidget, 1, 0, 1, 1)
|
||||||
|
# Button to select all songs in the "selectedListWidget".
|
||||||
|
self.allSelectedButton = QtGui.QToolButton(self.sourcePage)
|
||||||
|
# sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Fixed)
|
||||||
|
# sizePolicy.setHorizontalStretch(0)
|
||||||
|
# sizePolicy.setVerticalStretch(0)
|
||||||
|
# sizePolicy.setHeightForWidth(self.allSelectedButton.sizePolicy().hasHeightForWidth())
|
||||||
|
# self.allSelectedButton.setSizePolicy(sizePolicy)
|
||||||
|
self.allSelectedButton.setObjectName(u'allSelectedButton')
|
||||||
|
self.gridLayout.addWidget(self.allSelectedButton, 3, 2, 1, 1)
|
||||||
|
# Button to select all songs in the "availableListWidget".
|
||||||
|
self.allAvailableButton = QtGui.QToolButton(self.sourcePage)
|
||||||
|
self.allAvailableButton.setObjectName(u'allAvailableButton')
|
||||||
|
self.gridLayout.addWidget(self.allAvailableButton, 3, 0, 1, 1)
|
||||||
|
self.verticalLayout.addLayout(self.gridLayout)
|
||||||
|
self.gridLayout3 = QtGui.QGridLayout()
|
||||||
|
self.gridLayout3.setObjectName(u'gridLayout3')
|
||||||
|
self.directoryButton = QtGui.QToolButton(self.sourcePage)
|
||||||
|
icon = QtGui.QIcon()
|
||||||
|
icon.addPixmap(QtGui.QPixmap(u':/exports/export_load.png'),
|
||||||
|
QtGui.QIcon.Normal, QtGui.QIcon.Off)
|
||||||
|
self.directoryButton.setIcon(icon)
|
||||||
|
self.directoryButton.setObjectName(u'directoryButton')
|
||||||
|
self.gridLayout3.addWidget(self.directoryButton, 0, 2, 1, 1)
|
||||||
|
self.directoryLineEdit = QtGui.QLineEdit(self.sourcePage)
|
||||||
|
self.directoryLineEdit.setObjectName(u'directoryLineEdit')
|
||||||
|
self.gridLayout3.addWidget(self.directoryLineEdit, 0, 1, 1, 1)
|
||||||
|
self.directoryLabel = QtGui.QLabel(self.sourcePage)
|
||||||
|
self.directoryLabel.setObjectName(u'directoryLabel')
|
||||||
|
self.gridLayout3.addWidget(self.directoryLabel, 0, 0, 1, 1)
|
||||||
|
self.verticalLayout.addLayout(self.gridLayout3)
|
||||||
|
self.horizontalLayout.addLayout(self.verticalLayout)
|
||||||
self.addPage(self.sourcePage)
|
self.addPage(self.sourcePage)
|
||||||
#TODO: Add save dialog and maybe a search box.
|
|
||||||
|
|
||||||
def retranslateUi(self):
|
def retranslateUi(self):
|
||||||
"""
|
"""
|
||||||
@ -193,13 +201,13 @@ class SongExportForm(OpenLPWizard):
|
|||||||
self.informationLabel.setText(
|
self.informationLabel.setText(
|
||||||
translate('SongsPlugin.ExportWizardForm', 'This wizard will help to '
|
translate('SongsPlugin.ExportWizardForm', 'This wizard will help to '
|
||||||
'export your songs to the open and free OpenLyrics worship song '
|
'export your songs to the open and free OpenLyrics worship song '
|
||||||
'format. You can import these songs in all lyrics projection '
|
'format.'))
|
||||||
'software, which supports OpenLyrics.'))
|
|
||||||
self.sourcePage.setTitle(
|
self.sourcePage.setTitle(
|
||||||
translate('SongsPlugin.ExportWizardForm', 'Select Songs'))
|
translate('SongsPlugin.ExportWizardForm', 'Select Songs'))
|
||||||
self.sourcePage.setSubTitle(
|
self.sourcePage.setSubTitle(
|
||||||
translate('SongsPlugin.ExportWizardForm',
|
translate('SongsPlugin.ExportWizardForm',
|
||||||
'Select the songs, you want to export.'))
|
'Add the songs, you want to export to the list on the right hand '
|
||||||
|
'side. You can use the buttons below or double click them.'))
|
||||||
|
|
||||||
self.progressPage.setTitle(
|
self.progressPage.setTitle(
|
||||||
translate('SongsPlugin.ExportWizardForm', 'Exporting'))
|
translate('SongsPlugin.ExportWizardForm', 'Exporting'))
|
||||||
@ -211,37 +219,38 @@ class SongExportForm(OpenLPWizard):
|
|||||||
self.progressBar.setFormat(
|
self.progressBar.setFormat(
|
||||||
translate('SongsPlugin.ExportWizardForm', '%p%'))
|
translate('SongsPlugin.ExportWizardForm', '%p%'))
|
||||||
|
|
||||||
self.availableGroupBox.setTitle(
|
self.directoryLabel.setText(translate('SongsPlugin.ExportWizardForm',
|
||||||
translate('SongsPlugin.ExportWizardForm', 'Available Songs'))
|
'Directory:'))
|
||||||
self.selectedGroupBox.setTitle(
|
self.availableLabel.setText(
|
||||||
translate('SongsPlugin.ExportWizardForm', 'Selected Songs'))
|
translate('SongsPlugin.ExportWizardForm', '<b>Available Songs</b>'))
|
||||||
|
self.selectedLabel.setText(
|
||||||
|
translate('SongsPlugin.ExportWizardForm', '<b>Selected Songs</b>'))
|
||||||
|
self.allSelectedButton.setText(
|
||||||
|
translate('SongsPlugin.ExportWizardForm', 'Select all'))
|
||||||
|
self.allAvailableButton.setText(
|
||||||
|
translate('SongsPlugin.ExportWizardForm', 'Select all'))
|
||||||
|
|
||||||
def validateCurrentPage(self):
|
def validateCurrentPage(self):
|
||||||
"""
|
"""
|
||||||
Validate the current page before moving on to the next page.
|
Validate the current page before moving on to the next page.
|
||||||
"""
|
"""
|
||||||
if self.currentPage() == self.welcomePage:
|
if self.currentPage() == self.welcomePage:
|
||||||
Receiver.send_message(u'cursor_busy')
|
|
||||||
songs = self.plugin.manager.get_all_objects(Song)
|
|
||||||
for song in songs:
|
|
||||||
authors = u', '.join([author.display_name
|
|
||||||
for author in song.authors])
|
|
||||||
song_detail = u'%s (%s)' % (unicode(song.title), authors)
|
|
||||||
song_name = QtGui.QListWidgetItem(song_detail)
|
|
||||||
song_name.setData(QtCore.Qt.UserRole, QtCore.QVariant(song))
|
|
||||||
self.availableListWidget.addItem(song_name)
|
|
||||||
self.availableListWidget.selectAll()
|
|
||||||
Receiver.send_message(u'cursor_normal')
|
|
||||||
return True
|
return True
|
||||||
elif self.currentPage() == self.sourcePage:
|
elif self.currentPage() == self.sourcePage:
|
||||||
self.selectedListWidget.selectAll()
|
if not self.selectedListWidget.count():
|
||||||
if not self.selectedListWidget.selectedItems():
|
|
||||||
criticalErrorMessageBox(
|
criticalErrorMessageBox(
|
||||||
translate('SongsPlugin.ExportWizardForm',
|
translate('SongsPlugin.ExportWizardForm',
|
||||||
'No Song Selected'),
|
'No Song Selected'),
|
||||||
translate('SongsPlugin.ImportWizardForm',
|
translate('SongsPlugin.ExportWizardForm',
|
||||||
'You need to add at least one Song to export.'))
|
'You need to add at least one Song to export.'))
|
||||||
return False
|
return False
|
||||||
|
elif not self.directoryLineEdit.text():
|
||||||
|
criticalErrorMessageBox(
|
||||||
|
translate('SongsPlugin.ExportWizardForm',
|
||||||
|
'No Save Location specified'),
|
||||||
|
translate('SongsPlugin.ExportWizardForm',
|
||||||
|
'You need to specified a directory to save the songs in.'))
|
||||||
|
return False
|
||||||
return True
|
return True
|
||||||
elif self.currentPage() == self.progressPage:
|
elif self.currentPage() == self.progressPage:
|
||||||
self.availableListWidget.clear()
|
self.availableListWidget.clear()
|
||||||
@ -261,10 +270,25 @@ class SongExportForm(OpenLPWizard):
|
|||||||
self.restart()
|
self.restart()
|
||||||
self.finishButton.setVisible(False)
|
self.finishButton.setVisible(False)
|
||||||
self.cancelButton.setVisible(True)
|
self.cancelButton.setVisible(True)
|
||||||
|
self.availableListWidget.clear()
|
||||||
|
self.selectedListWidget.clear()
|
||||||
|
self.directoryLineEdit.clear()
|
||||||
|
# Load the list of songs.
|
||||||
|
Receiver.send_message(u'cursor_busy')
|
||||||
|
songs = self.plugin.manager.get_all_objects(Song)
|
||||||
|
for song in songs:
|
||||||
|
authors = u', '.join([author.display_name
|
||||||
|
for author in song.authors])
|
||||||
|
song_detail = u'%s (%s)' % (unicode(song.title), authors)
|
||||||
|
song_name = QtGui.QListWidgetItem(song_detail)
|
||||||
|
song_name.setData(QtCore.Qt.UserRole, QtCore.QVariant(song))
|
||||||
|
self.availableListWidget.addItem(song_name)
|
||||||
|
self.availableListWidget.selectAll()
|
||||||
|
Receiver.send_message(u'cursor_normal')
|
||||||
|
|
||||||
def preWizard(self):
|
def preWizard(self):
|
||||||
"""
|
"""
|
||||||
Perform pre export tasks
|
Perform pre export tasks.
|
||||||
"""
|
"""
|
||||||
OpenLPWizard.preWizard(self)
|
OpenLPWizard.preWizard(self)
|
||||||
self.progressLabel.setText(
|
self.progressLabel.setText(
|
||||||
@ -273,18 +297,14 @@ class SongExportForm(OpenLPWizard):
|
|||||||
|
|
||||||
def performWizard(self):
|
def performWizard(self):
|
||||||
"""
|
"""
|
||||||
Perform the actual export. This method pulls in the correct exporter
|
Perform the actual export. This creates an *openlyricsexport* instance
|
||||||
class, and then runs the ``do_export`` method of the exporter to do
|
and calls the *do_export* method.
|
||||||
the actual exporting.
|
|
||||||
"""
|
"""
|
||||||
path = unicode(QtGui.QFileDialog.getExistingDirectory(self, translate(
|
self.selectedListWidget.selectAll()
|
||||||
'SongsPlugin.ExportWizardForm', 'Selecte to Folder'),
|
|
||||||
SettingsManager.get_last_dir(self.plugin.settingsSection, 1),
|
|
||||||
options=QtGui.QFileDialog.ShowDirsOnly))
|
|
||||||
SettingsManager.set_last_dir(self.plugin.settingsSection, path, 1)
|
|
||||||
songs = [item.data(QtCore.Qt.UserRole).toPyObject()
|
songs = [item.data(QtCore.Qt.UserRole).toPyObject()
|
||||||
for item in self.selectedListWidget.selectedItems()]
|
for item in self.selectedListWidget.selectedItems()]
|
||||||
exporter = OpenLyricsExport(self, songs, path)
|
exporter = OpenLyricsExport(
|
||||||
|
self, songs, unicode(self.directoryLineEdit.text()))
|
||||||
if exporter.do_export():
|
if exporter.do_export():
|
||||||
self.progressLabel.setText(
|
self.progressLabel.setText(
|
||||||
translate('SongsPlugin.SongExportForm', 'Finished export.'))
|
translate('SongsPlugin.SongExportForm', 'Finished export.'))
|
||||||
@ -340,3 +360,27 @@ class SongExportForm(OpenLPWizard):
|
|||||||
"""
|
"""
|
||||||
self.selectedListWidget.takeItem(self.selectedListWidget.row(item))
|
self.selectedListWidget.takeItem(self.selectedListWidget.row(item))
|
||||||
self.availableListWidget.addItem(item)
|
self.availableListWidget.addItem(item)
|
||||||
|
|
||||||
|
def onAllAvailableButtonClicked(self):
|
||||||
|
"""
|
||||||
|
Selects all songs in the *availableListWidget*.
|
||||||
|
"""
|
||||||
|
self.availableListWidget.selectAll()
|
||||||
|
|
||||||
|
def onDirectoryButtonClicked(self):
|
||||||
|
"""
|
||||||
|
Called when click on the *directoryButton*. Opens a dialog and writes
|
||||||
|
the path to *directoryLineEdit*.
|
||||||
|
"""
|
||||||
|
path = unicode(QtGui.QFileDialog.getExistingDirectory(self,
|
||||||
|
translate('SongsPlugin.ExportWizardForm', 'Selecte to Folder'),
|
||||||
|
SettingsManager.get_last_dir(self.plugin.settingsSection, 1),
|
||||||
|
options=QtGui.QFileDialog.ShowDirsOnly))
|
||||||
|
SettingsManager.set_last_dir(self.plugin.settingsSection, path, 1)
|
||||||
|
self.directoryLineEdit.setText(path)
|
||||||
|
|
||||||
|
def onAllSelectedButtonClicked(self):
|
||||||
|
"""
|
||||||
|
Selects all songs in the *selectedListWidget*.
|
||||||
|
"""
|
||||||
|
self.selectedListWidget.selectAll()
|
||||||
|
@ -25,7 +25,7 @@
|
|||||||
###############################################################################
|
###############################################################################
|
||||||
"""
|
"""
|
||||||
The :mod:`openlyricsexport` module provides the functionality for exporting
|
The :mod:`openlyricsexport` module provides the functionality for exporting
|
||||||
songs from the database.
|
songs from the database to the OpenLyrics format.
|
||||||
"""
|
"""
|
||||||
import logging
|
import logging
|
||||||
import os
|
import os
|
||||||
@ -50,6 +50,8 @@ class OpenLyricsExport(object):
|
|||||||
self.manager = parent.plugin.manager
|
self.manager = parent.plugin.manager
|
||||||
self.songs = songs
|
self.songs = songs
|
||||||
self.save_path = save_path
|
self.save_path = save_path
|
||||||
|
if not os.path.exists(self.save_path):
|
||||||
|
os.mkdir(self.save_path)
|
||||||
|
|
||||||
def do_export(self):
|
def do_export(self):
|
||||||
"""
|
"""
|
||||||
@ -63,14 +65,10 @@ class OpenLyricsExport(object):
|
|||||||
if self.parent.stop_export_flag:
|
if self.parent.stop_export_flag:
|
||||||
return False
|
return False
|
||||||
self.parent.incrementProgressBar(unicode(translate(
|
self.parent.incrementProgressBar(unicode(translate(
|
||||||
'SongsPlugin.OpenLyricsExport', 'Exporting %s...')) %
|
'SongsPlugin.OpenLyricsExport', 'Exporting "%s"...')) %
|
||||||
song.title)
|
song.title)
|
||||||
# Check if path exists. If not, create the directories!
|
|
||||||
# What do we do with songs with the same title? I do not want to
|
|
||||||
# overwrite them!
|
|
||||||
path = os.path.join(self.save_path, song.title + u'.xml')
|
|
||||||
xml = openLyrics.song_to_xml(song)
|
xml = openLyrics.song_to_xml(song)
|
||||||
tree = etree.ElementTree(etree.fromstring(xml))
|
tree = etree.ElementTree(etree.fromstring(xml))
|
||||||
tree.write(path, encoding=u'utf-8', xml_declaration=True,
|
tree.write(os.path.join(self.save_path, song.title + u'.xml'),
|
||||||
pretty_print=True)
|
encoding=u'utf-8', xml_declaration=True, pretty_print=True)
|
||||||
return True
|
return True
|
||||||
|
@ -1,241 +0,0 @@
|
|||||||
<ui version="4.0" >
|
|
||||||
<class>SongExportDialog</class>
|
|
||||||
<widget class="QDialog" name="SongExportDialog" >
|
|
||||||
<property name="geometry" >
|
|
||||||
<rect>
|
|
||||||
<x>0</x>
|
|
||||||
<y>0</y>
|
|
||||||
<width>641</width>
|
|
||||||
<height>607</height>
|
|
||||||
</rect>
|
|
||||||
</property>
|
|
||||||
<property name="windowTitle" >
|
|
||||||
<string>Dialog</string>
|
|
||||||
</property>
|
|
||||||
<layout class="QVBoxLayout" name="SongExportLayout" >
|
|
||||||
<property name="spacing" >
|
|
||||||
<number>8</number>
|
|
||||||
</property>
|
|
||||||
<property name="margin" >
|
|
||||||
<number>8</number>
|
|
||||||
</property>
|
|
||||||
<item>
|
|
||||||
<widget class="QWidget" native="1" name="SongListsWidget" >
|
|
||||||
<layout class="QHBoxLayout" name="SongListsLayout" >
|
|
||||||
<property name="spacing" >
|
|
||||||
<number>8</number>
|
|
||||||
</property>
|
|
||||||
<property name="margin" >
|
|
||||||
<number>0</number>
|
|
||||||
</property>
|
|
||||||
<item>
|
|
||||||
<widget class="QGroupBox" name="AvailableGroupBox" >
|
|
||||||
<property name="title" >
|
|
||||||
<string>Available Songs</string>
|
|
||||||
</property>
|
|
||||||
<layout class="QVBoxLayout" name="verticalLayout" >
|
|
||||||
<item>
|
|
||||||
<widget class="QListWidget" name="AvailableListWidget" />
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QToolButton" name="AvailableAllToolButton" >
|
|
||||||
<property name="text" >
|
|
||||||
<string>Select All</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QWidget" native="1" name="SelectionWidget" >
|
|
||||||
<property name="sizePolicy" >
|
|
||||||
<sizepolicy vsizetype="Minimum" hsizetype="Minimum" >
|
|
||||||
<horstretch>0</horstretch>
|
|
||||||
<verstretch>0</verstretch>
|
|
||||||
</sizepolicy>
|
|
||||||
</property>
|
|
||||||
<property name="maximumSize" >
|
|
||||||
<size>
|
|
||||||
<width>30</width>
|
|
||||||
<height>16777215</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
<layout class="QVBoxLayout" name="SelectionLayout" >
|
|
||||||
<property name="spacing" >
|
|
||||||
<number>8</number>
|
|
||||||
</property>
|
|
||||||
<property name="sizeConstraint" >
|
|
||||||
<enum>QLayout::SetMinimumSize</enum>
|
|
||||||
</property>
|
|
||||||
<property name="margin" >
|
|
||||||
<number>0</number>
|
|
||||||
</property>
|
|
||||||
<item>
|
|
||||||
<spacer name="TopVerticalSpacer" >
|
|
||||||
<property name="orientation" >
|
|
||||||
<enum>Qt::Vertical</enum>
|
|
||||||
</property>
|
|
||||||
<property name="sizeType" >
|
|
||||||
<enum>QSizePolicy::MinimumExpanding</enum>
|
|
||||||
</property>
|
|
||||||
<property name="sizeHint" stdset="0" >
|
|
||||||
<size>
|
|
||||||
<width>20</width>
|
|
||||||
<height>132</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
</spacer>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QToolButton" name="SelectToolButton" >
|
|
||||||
<property name="text" >
|
|
||||||
<string>Select Songs</string>
|
|
||||||
</property>
|
|
||||||
<property name="icon" >
|
|
||||||
<iconset resource="../images/openlp-2.qrc" >
|
|
||||||
<normaloff>:/exports/export_move_to_list.png</normaloff>:/exports/export_move_to_list.png</iconset>
|
|
||||||
</property>
|
|
||||||
<property name="iconSize" >
|
|
||||||
<size>
|
|
||||||
<width>20</width>
|
|
||||||
<height>20</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QToolButton" name="DeselectToolButton" >
|
|
||||||
<property name="text" >
|
|
||||||
<string>Deselect Songs</string>
|
|
||||||
</property>
|
|
||||||
<property name="icon" >
|
|
||||||
<iconset resource="../images/openlp-2.qrc" >
|
|
||||||
<normaloff>:/exports/export_remove.png</normaloff>:/exports/export_remove.png</iconset>
|
|
||||||
</property>
|
|
||||||
<property name="iconSize" >
|
|
||||||
<size>
|
|
||||||
<width>20</width>
|
|
||||||
<height>20</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<spacer name="BottomVerticalSpacer" >
|
|
||||||
<property name="orientation" >
|
|
||||||
<enum>Qt::Vertical</enum>
|
|
||||||
</property>
|
|
||||||
<property name="sizeType" >
|
|
||||||
<enum>QSizePolicy::MinimumExpanding</enum>
|
|
||||||
</property>
|
|
||||||
<property name="sizeHint" stdset="0" >
|
|
||||||
<size>
|
|
||||||
<width>20</width>
|
|
||||||
<height>131</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
</spacer>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QGroupBox" name="SelectedGroupBox" >
|
|
||||||
<property name="title" >
|
|
||||||
<string>Selected Songs</string>
|
|
||||||
</property>
|
|
||||||
<layout class="QVBoxLayout" name="verticalLayout_2" >
|
|
||||||
<item>
|
|
||||||
<widget class="QListWidget" name="SelectedListWidget" />
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QToolButton" name="SelectedAllToolButton" >
|
|
||||||
<property name="text" >
|
|
||||||
<string>Select All</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QTabWidget" name="ExportTabWidget" >
|
|
||||||
<property name="currentIndex" >
|
|
||||||
<number>0</number>
|
|
||||||
</property>
|
|
||||||
<widget class="QWidget" name="OpenLyricTab" >
|
|
||||||
<attribute name="title" >
|
|
||||||
<string>OpenLyric Format</string>
|
|
||||||
</attribute>
|
|
||||||
</widget>
|
|
||||||
<widget class="QWidget" name="TextFileTab" >
|
|
||||||
<attribute name="title" >
|
|
||||||
<string>Text File</string>
|
|
||||||
</attribute>
|
|
||||||
</widget>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QDialogButtonBox" name="SongExportButtonBox" >
|
|
||||||
<property name="orientation" >
|
|
||||||
<enum>Qt::Horizontal</enum>
|
|
||||||
</property>
|
|
||||||
<property name="standardButtons" >
|
|
||||||
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</widget>
|
|
||||||
<tabstops>
|
|
||||||
<tabstop>SongExportButtonBox</tabstop>
|
|
||||||
<tabstop>AvailableListWidget</tabstop>
|
|
||||||
<tabstop>AvailableAllToolButton</tabstop>
|
|
||||||
<tabstop>SelectToolButton</tabstop>
|
|
||||||
<tabstop>DeselectToolButton</tabstop>
|
|
||||||
<tabstop>SelectedListWidget</tabstop>
|
|
||||||
<tabstop>SelectedAllToolButton</tabstop>
|
|
||||||
<tabstop>ExportTabWidget</tabstop>
|
|
||||||
</tabstops>
|
|
||||||
<resources>
|
|
||||||
<include location="../images/openlp-2.qrc" />
|
|
||||||
</resources>
|
|
||||||
<connections>
|
|
||||||
<connection>
|
|
||||||
<sender>SongExportButtonBox</sender>
|
|
||||||
<signal>accepted()</signal>
|
|
||||||
<receiver>SongExportDialog</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>SongExportButtonBox</sender>
|
|
||||||
<signal>rejected()</signal>
|
|
||||||
<receiver>SongExportDialog</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>
|
|
148
resources/forms/songexportform.ui
Normal file
148
resources/forms/songexportform.ui
Normal file
@ -0,0 +1,148 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<ui version="4.0">
|
||||||
|
<class>WizardPage</class>
|
||||||
|
<widget class="QWizardPage" name="WizardPage">
|
||||||
|
<property name="geometry">
|
||||||
|
<rect>
|
||||||
|
<x>0</x>
|
||||||
|
<y>0</y>
|
||||||
|
<width>576</width>
|
||||||
|
<height>334</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
|
<property name="windowTitle">
|
||||||
|
<string>WizardPage</string>
|
||||||
|
</property>
|
||||||
|
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||||
|
<item>
|
||||||
|
<layout class="QVBoxLayout" name="verticalLayout">
|
||||||
|
<item>
|
||||||
|
<layout class="QGridLayout" name="gridLayout">
|
||||||
|
<item row="1" column="2">
|
||||||
|
<widget class="QListWidget" name="selectedListWidget"/>
|
||||||
|
</item>
|
||||||
|
<item row="1" column="1">
|
||||||
|
<layout class="QGridLayout" name="gridLayout2">
|
||||||
|
<item row="1" column="0">
|
||||||
|
<widget class="QToolButton" name="addButton">
|
||||||
|
<property name="text">
|
||||||
|
<string>...</string>
|
||||||
|
</property>
|
||||||
|
<property name="icon">
|
||||||
|
<iconset resource="../images/openlp-2.qrc">
|
||||||
|
<normaloff>:/exports/export_move_to_list.png</normaloff>:/exports/export_move_to_list.png</iconset>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="2" column="0">
|
||||||
|
<widget class="QToolButton" name="removeButton">
|
||||||
|
<property name="text">
|
||||||
|
<string>...</string>
|
||||||
|
</property>
|
||||||
|
<property name="icon">
|
||||||
|
<iconset resource="../images/openlp-2.qrc">
|
||||||
|
<normaloff>:/exports/export_remove.png</normaloff>:/exports/export_remove.png</iconset>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="0" column="0">
|
||||||
|
<spacer name="spacerItem2">
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Vertical</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeHint" stdset="0">
|
||||||
|
<size>
|
||||||
|
<width>20</width>
|
||||||
|
<height>40</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</spacer>
|
||||||
|
</item>
|
||||||
|
<item row="3" column="0">
|
||||||
|
<spacer name="spacerItem">
|
||||||
|
<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>
|
||||||
|
</item>
|
||||||
|
<item row="0" column="0">
|
||||||
|
<widget class="QLabel" name="availableLabel">
|
||||||
|
<property name="text">
|
||||||
|
<string>Available Songs</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="0" column="2">
|
||||||
|
<widget class="QLabel" name="selectedLabel">
|
||||||
|
<property name="text">
|
||||||
|
<string>Selected Songs</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="1" column="0">
|
||||||
|
<widget class="QListWidget" name="availableListWidget"/>
|
||||||
|
</item>
|
||||||
|
<item row="3" column="2">
|
||||||
|
<widget class="QToolButton" name="allSelectedButton">
|
||||||
|
<property name="sizePolicy">
|
||||||
|
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
|
||||||
|
<horstretch>0</horstretch>
|
||||||
|
<verstretch>0</verstretch>
|
||||||
|
</sizepolicy>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Select all</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="3" column="0">
|
||||||
|
<widget class="QToolButton" name="allAvailableButton">
|
||||||
|
<property name="text">
|
||||||
|
<string>Select all</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<layout class="QGridLayout" name="gridLayout3">
|
||||||
|
<item row="0" column="2">
|
||||||
|
<widget class="QToolButton" name="directoryButton">
|
||||||
|
<property name="text">
|
||||||
|
<string>...</string>
|
||||||
|
</property>
|
||||||
|
<property name="icon">
|
||||||
|
<iconset resource="../images/openlp-2.qrc">
|
||||||
|
<normaloff>:/exports/export_load.png</normaloff>:/exports/export_load.png</iconset>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="0" column="1">
|
||||||
|
<widget class="QLineEdit" name="directoryLineEdit"/>
|
||||||
|
</item>
|
||||||
|
<item row="0" column="0">
|
||||||
|
<widget class="QLabel" name="directoryLabel">
|
||||||
|
<property name="text">
|
||||||
|
<string>Directory:</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
<resources>
|
||||||
|
<include location="../images/openlp-2.qrc"/>
|
||||||
|
</resources>
|
||||||
|
<connections/>
|
||||||
|
</ui>
|
Binary file not shown.
Before Width: | Height: | Size: 784 B |
@ -78,12 +78,12 @@
|
|||||||
<file>import_load.png</file>
|
<file>import_load.png</file>
|
||||||
</qresource>
|
</qresource>
|
||||||
<qresource prefix="exports">
|
<qresource prefix="exports">
|
||||||
<file>export_selectall.png</file>
|
|
||||||
<file>export_remove.png</file>
|
<file>export_remove.png</file>
|
||||||
<file>export_load.png</file>
|
<file>export_load.png</file>
|
||||||
<file>export_move_to_list.png</file>
|
<file>export_move_to_list.png</file>
|
||||||
</qresource>
|
</qresource>
|
||||||
<qresource prefix="wizards">
|
<qresource prefix="wizards">
|
||||||
|
<file>wizard_exportsong.bmp</file>
|
||||||
<file>wizard_importsong.bmp</file>
|
<file>wizard_importsong.bmp</file>
|
||||||
<file>wizard_importbible.bmp</file>
|
<file>wizard_importbible.bmp</file>
|
||||||
<file>wizard_createtheme.bmp</file>
|
<file>wizard_createtheme.bmp</file>
|
||||||
|
BIN
resources/images/wizard_exportsong.bmp
Normal file
BIN
resources/images/wizard_exportsong.bmp
Normal file
Binary file not shown.
After Width: | Height: | Size: 168 KiB |
Loading…
Reference in New Issue
Block a user