mirror of
https://gitlab.com/openlp/openlp.git
synced 2024-09-28 19:07:35 +00:00
songimporters
This commit is contained in:
parent
33ebf40630
commit
a27b251060
@ -47,45 +47,37 @@ class MediaManagerItem(QtGui.QWidget):
|
||||
"""
|
||||
MediaManagerItem is a helper widget for plugins.
|
||||
|
||||
None of the following *need* to be used, feel free to override
|
||||
them completely in your plugin's implementation. Alternatively,
|
||||
call them from your plugin before or after you've done extra
|
||||
things that you need to.
|
||||
None of the following *need* to be used, feel free to override them completely in your plugin's implementation.
|
||||
Alternatively, call them from your plugin before or after you've done extra things that you need to.
|
||||
|
||||
**Constructor Parameters**
|
||||
|
||||
``parent``
|
||||
The parent widget. Usually this will be the *Media Manager*
|
||||
itself. This needs to be a class descended from ``QWidget``.
|
||||
The parent widget. Usually this will be the *Media Manager* itself. This needs to be a class descended from
|
||||
``QWidget``.
|
||||
|
||||
``plugin``
|
||||
The plugin widget. Usually this will be the *Plugin*
|
||||
itself. This needs to be a class descended from ``Plugin``.
|
||||
The plugin widget. Usually this will be the *Plugin* itself. This needs to be a class descended from ``Plugin``.
|
||||
|
||||
``icon``
|
||||
Either a ``QIcon``, a resource path, or a file name. This is
|
||||
the icon which is displayed in the *Media Manager*.
|
||||
Either a ``QIcon``, a resource path, or a file name. This is the icon which is displayed in the *Media Manager*.
|
||||
|
||||
**Member Variables**
|
||||
|
||||
When creating a descendant class from this class for your plugin,
|
||||
the following member variables should be set.
|
||||
When creating a descendant class from this class for your plugin, the following member variables should be set.
|
||||
|
||||
``self.onNewPrompt``
|
||||
|
||||
Defaults to *'Select Image(s)'*.
|
||||
|
||||
``self.onNewFileMasks``
|
||||
Defaults to *'Images (*.jpg *jpeg *.gif *.png *.bmp)'*. This
|
||||
assumes that the new action is to load a file. If not, you
|
||||
need to override the ``OnNew`` method.
|
||||
Defaults to *'Images (*.jpg *jpeg *.gif *.png *.bmp)'*. This assumes that the new action is to load a file. If
|
||||
not, you need to override the ``OnNew`` method.
|
||||
|
||||
``self.PreviewFunction``
|
||||
This must be a method which returns a QImage to represent the
|
||||
item (usually a preview). No scaling is required, that is
|
||||
performed automatically by OpenLP when necessary. If this
|
||||
method is not defined, a default will be used (treat the
|
||||
filename as an image).
|
||||
This must be a method which returns a QImage to represent the item (usually a preview). No scaling is required,
|
||||
that is performed automatically by OpenLP when necessary. If this method is not defined, a default will be used
|
||||
(treat the filename as an image).
|
||||
"""
|
||||
log.info(u'Media Item loaded')
|
||||
|
||||
@ -120,9 +112,8 @@ class MediaManagerItem(QtGui.QWidget):
|
||||
|
||||
def requiredIcons(self):
|
||||
"""
|
||||
This method is called to define the icons for the plugin.
|
||||
It provides a default set and the plugin is able to override
|
||||
the if required.
|
||||
This method is called to define the icons for the plugin. It provides a default set and the plugin is able to
|
||||
override the if required.
|
||||
"""
|
||||
self.hasImportIcon = False
|
||||
self.hasNewIcon = True
|
||||
@ -133,16 +124,14 @@ class MediaManagerItem(QtGui.QWidget):
|
||||
|
||||
def retranslateUi(self):
|
||||
"""
|
||||
This method is called automatically to provide OpenLP with the
|
||||
opportunity to translate the ``MediaManagerItem`` to another
|
||||
language.
|
||||
This method is called automatically to provide OpenLP with the opportunity to translate the ``MediaManagerItem``
|
||||
to another language.
|
||||
"""
|
||||
pass
|
||||
|
||||
def addToolbar(self):
|
||||
"""
|
||||
A method to help developers easily add a toolbar to the media
|
||||
manager item.
|
||||
A method to help developers easily add a toolbar to the media manager item.
|
||||
"""
|
||||
if self.toolbar is None:
|
||||
self.toolbar = OpenLPToolbar(self)
|
||||
@ -150,9 +139,8 @@ class MediaManagerItem(QtGui.QWidget):
|
||||
|
||||
def setupUi(self):
|
||||
"""
|
||||
This method sets up the interface on the button. Plugin
|
||||
developers use this to add and create toolbars, and the rest
|
||||
of the interface of the media manager item.
|
||||
This method sets up the interface on the button. Plugin developers use this to add and create toolbars, and the
|
||||
rest of the interface of the media manager item.
|
||||
"""
|
||||
# Add a toolbar
|
||||
self.addToolbar()
|
||||
@ -447,7 +435,7 @@ class MediaManagerItem(QtGui.QWidget):
|
||||
"""
|
||||
pass
|
||||
|
||||
def generateSlideData(self, service_item, item=None, xmlVersion=False, remote=False,
|
||||
def generateSlideData(self, service_item, item=None, xml_version=False, remote=False,
|
||||
context=ServiceItemContext.Live):
|
||||
"""
|
||||
Generate the slide data. Needs to be implemented by the plugin.
|
||||
@ -473,8 +461,7 @@ class MediaManagerItem(QtGui.QWidget):
|
||||
|
||||
def onPreviewClick(self, keepFocus=False):
|
||||
"""
|
||||
Preview an item by building a service item then adding that service
|
||||
item to the preview slide controller.
|
||||
Preview an item by building a service item then adding that service item to the preview slide controller.
|
||||
"""
|
||||
if not self.listView.selectedIndexes() and not self.remoteTriggered:
|
||||
QtGui.QMessageBox.information(self, UiStrings().NISp,
|
||||
@ -490,8 +477,7 @@ class MediaManagerItem(QtGui.QWidget):
|
||||
|
||||
def onLiveClick(self):
|
||||
"""
|
||||
Send an item live by building a service item then adding that service
|
||||
item to the live slide controller.
|
||||
Send an item live by building a service item then adding that service item to the live slide controller.
|
||||
"""
|
||||
if not self.listView.selectedIndexes():
|
||||
QtGui.QMessageBox.information(self, UiStrings().NISp,
|
||||
@ -584,8 +570,8 @@ class MediaManagerItem(QtGui.QWidget):
|
||||
|
||||
def serviceLoad(self, message):
|
||||
"""
|
||||
Method to add processing when a service has been loaded and
|
||||
individual service items need to be processed by the plugins
|
||||
Method to add processing when a service has been loaded and individual service items need to be processed by the
|
||||
plugins.
|
||||
"""
|
||||
pass
|
||||
|
||||
|
@ -40,8 +40,8 @@ log = logging.getLogger(__name__)
|
||||
|
||||
class OpenLPToolbar(QtGui.QToolBar):
|
||||
"""
|
||||
Lots of toolbars around the place, so it makes sense to have a common way
|
||||
to manage them. This is the base toolbar class.
|
||||
Lots of toolbars around the place, so it makes sense to have a common way to manage them. This is the base toolbar
|
||||
class.
|
||||
"""
|
||||
def __init__(self, parent):
|
||||
"""
|
||||
@ -55,10 +55,9 @@ class OpenLPToolbar(QtGui.QToolBar):
|
||||
|
||||
def add_toolbar_action(self, name, **kwargs):
|
||||
"""
|
||||
A method to help developers easily add a button to the toolbar.
|
||||
A new QAction is created by calling ``create_action()``. The action is
|
||||
added to the toolbar and the toolbar is set as parent.
|
||||
For more details please look at openlp.core.lib.ui.create_action()
|
||||
A method to help developers easily add a button to the toolbar. A new QAction is created by calling
|
||||
``create_action()``. The action is added to the toolbar and the toolbar is set as parent. For more details
|
||||
please look at openlp.core.lib.ui.create_action()
|
||||
"""
|
||||
action = create_widget_action(self, name, **kwargs)
|
||||
self.actions[name] = action
|
||||
|
@ -50,21 +50,21 @@ def add_welcome_page(parent, image):
|
||||
``image``
|
||||
A splash image for the wizard.
|
||||
"""
|
||||
parent.welcomePage = QtGui.QWizardPage()
|
||||
parent.welcomePage.setPixmap(QtGui.QWizard.WatermarkPixmap, QtGui.QPixmap(image))
|
||||
parent.welcomePage.setObjectName(u'WelcomePage')
|
||||
parent.welcomeLayout = QtGui.QVBoxLayout(parent.welcomePage)
|
||||
parent.welcomeLayout.setObjectName(u'WelcomeLayout')
|
||||
parent.titleLabel = QtGui.QLabel(parent.welcomePage)
|
||||
parent.titleLabel.setObjectName(u'TitleLabel')
|
||||
parent.welcomeLayout.addWidget(parent.titleLabel)
|
||||
parent.welcomeLayout.addSpacing(40)
|
||||
parent.informationLabel = QtGui.QLabel(parent.welcomePage)
|
||||
parent.informationLabel.setWordWrap(True)
|
||||
parent.informationLabel.setObjectName(u'InformationLabel')
|
||||
parent.welcomeLayout.addWidget(parent.informationLabel)
|
||||
parent.welcomeLayout.addStretch()
|
||||
parent.addPage(parent.welcomePage)
|
||||
parent.welcome_page = QtGui.QWizardPage()
|
||||
parent.welcome_page.setPixmap(QtGui.QWizard.WatermarkPixmap, QtGui.QPixmap(image))
|
||||
parent.welcome_page.setObjectName(u'welcome_page')
|
||||
parent.welcome_layout = QtGui.QVBoxLayout(parent.welcome_page)
|
||||
parent.welcome_layout.setObjectName(u'WelcomeLayout')
|
||||
parent.title_label = QtGui.QLabel(parent.welcome_page)
|
||||
parent.title_label.setObjectName(u'title_label')
|
||||
parent.welcome_layout.addWidget(parent.title_label)
|
||||
parent.welcome_layout.addSpacing(40)
|
||||
parent.information_label = QtGui.QLabel(parent.welcome_page)
|
||||
parent.information_label.setWordWrap(True)
|
||||
parent.information_label.setObjectName(u'information_label')
|
||||
parent.welcome_layout.addWidget(parent.information_label)
|
||||
parent.welcome_layout.addStretch()
|
||||
parent.addPage(parent.welcome_page)
|
||||
|
||||
|
||||
def create_button_box(dialog, name, standard_buttons, custom_buttons=None):
|
||||
|
@ -191,15 +191,15 @@ class Ui_FirstTimeWizard(object):
|
||||
FirstTimeWizard.setPage(FirstTimePage.Defaults, self.defaultsPage)
|
||||
# Progress page
|
||||
self.progressPage = QtGui.QWizardPage()
|
||||
self.progressPage.setObjectName(u'progressPage')
|
||||
self.progressPage.setObjectName(u'progress_page')
|
||||
self.progressLayout = QtGui.QVBoxLayout(self.progressPage)
|
||||
self.progressLayout.setMargin(48)
|
||||
self.progressLayout.setObjectName(u'progressLayout')
|
||||
self.progressLayout.setObjectName(u'progress_layout')
|
||||
self.progressLabel = QtGui.QLabel(self.progressPage)
|
||||
self.progressLabel.setObjectName(u'progressLabel')
|
||||
self.progressLabel.setObjectName(u'progress_label')
|
||||
self.progressLayout.addWidget(self.progressLabel)
|
||||
self.progressBar = QtGui.QProgressBar(self.progressPage)
|
||||
self.progressBar.setObjectName(u'progressBar')
|
||||
self.progressBar.setObjectName(u'progress_bar')
|
||||
self.progressLayout.addWidget(self.progressBar)
|
||||
FirstTimeWizard.setPage(FirstTimePage.Progress, self.progressPage)
|
||||
self.retranslateUi(FirstTimeWizard)
|
||||
@ -209,9 +209,9 @@ class Ui_FirstTimeWizard(object):
|
||||
Translate the UI on the fly
|
||||
"""
|
||||
FirstTimeWizard.setWindowTitle(translate('OpenLP.FirstTimeWizard', 'First Time Wizard'))
|
||||
self.titleLabel.setText(u'<span style="font-size:14pt; font-weight:600;">%s</span>' %
|
||||
self.title_label.setText(u'<span style="font-size:14pt; font-weight:600;">%s</span>' %
|
||||
translate('OpenLP.FirstTimeWizard', 'Welcome to the First Time Wizard'))
|
||||
self.informationLabel.setText(translate('OpenLP.FirstTimeWizard',
|
||||
self.information_label.setText(translate('OpenLP.FirstTimeWizard',
|
||||
'This wizard will help you to configure OpenLP for initial use. Click the next button below to start.'))
|
||||
self.pluginPage.setTitle(translate('OpenLP.FirstTimeWizard', 'Activate required Plugins'))
|
||||
self.pluginPage.setSubTitle(translate('OpenLP.FirstTimeWizard', 'Select the Plugins you wish to use. '))
|
||||
|
@ -79,10 +79,10 @@ class PlayerTab(SettingsTab):
|
||||
self.backgroundColorButton.setObjectName(u'BackgroundColorButton')
|
||||
self.colorLayout.addWidget(self.backgroundColorButton)
|
||||
self.formLayout.addRow(self.colorLayout)
|
||||
self.informationLabel = QtGui.QLabel(self.bgColorGroupBox)
|
||||
self.informationLabel.setObjectName(u'InformationLabel')
|
||||
self.informationLabel.setWordWrap(True)
|
||||
self.formLayout.addRow(self.informationLabel)
|
||||
self.information_label = QtGui.QLabel(self.bgColorGroupBox)
|
||||
self.information_label.setObjectName(u'information_label')
|
||||
self.information_label.setWordWrap(True)
|
||||
self.formLayout.addRow(self.information_label)
|
||||
self.leftLayout.addWidget(self.bgColorGroupBox)
|
||||
self.leftLayout.addStretch()
|
||||
self.rightColumn.setSizePolicy(QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Preferred)
|
||||
@ -133,7 +133,7 @@ class PlayerTab(SettingsTab):
|
||||
self.playerOrderGroupBox.setTitle(translate('OpenLP.PlayerTab', 'Player Search Order'))
|
||||
self.bgColorGroupBox.setTitle(UiStrings().BackgroundColor)
|
||||
self.backgroundColorLabel.setText(UiStrings().DefaultColor)
|
||||
self.informationLabel.setText(translate('OpenLP.PlayerTab',
|
||||
self.information_label.setText(translate('OpenLP.PlayerTab',
|
||||
'Visible background for videos with aspect ratio different to screen.'))
|
||||
self.retranslatePlayers()
|
||||
|
||||
|
@ -103,9 +103,9 @@ class Ui_PrintServiceDialog(object):
|
||||
self.optionsWidget.setAutoFillBackground(True)
|
||||
self.optionsLayout = QtGui.QVBoxLayout(self.optionsWidget)
|
||||
self.optionsLayout.setContentsMargins(8, 8, 8, 8)
|
||||
self.titleLabel = QtGui.QLabel(self.optionsWidget)
|
||||
self.titleLabel.setObjectName(u'titleLabel')
|
||||
self.optionsLayout.addWidget(self.titleLabel)
|
||||
self.title_label = QtGui.QLabel(self.optionsWidget)
|
||||
self.title_label.setObjectName(u'title_label')
|
||||
self.optionsLayout.addWidget(self.title_label)
|
||||
self.titleLineEdit = QtGui.QLineEdit(self.optionsWidget)
|
||||
self.titleLineEdit.setObjectName(u'titleLineEdit')
|
||||
self.optionsLayout.addWidget(self.titleLineEdit)
|
||||
@ -141,7 +141,7 @@ class Ui_PrintServiceDialog(object):
|
||||
self.zoomOriginalButton.setToolTip(translate('OpenLP.PrintServiceForm', 'Zoom Original'))
|
||||
self.zoomInButton.setToolTip(translate('OpenLP.PrintServiceForm', 'Zoom In'))
|
||||
self.optionsButton.setText(translate('OpenLP.PrintServiceForm', 'Options'))
|
||||
self.titleLabel.setText(translate('OpenLP.PrintServiceForm', 'Title:'))
|
||||
self.title_label.setText(translate('OpenLP.PrintServiceForm', 'Title:'))
|
||||
self.footerLabel.setText(translate('OpenLP.PrintServiceForm', 'Custom Footer Text:'))
|
||||
self.optionsGroupBox.setTitle(translate('OpenLP.PrintServiceForm', 'Other Options'))
|
||||
self.slideTextCheckBox.setText(translate('OpenLP.PrintServiceForm', 'Include slide text if available'))
|
||||
|
@ -500,7 +500,7 @@ class ServiceManager(QtGui.QWidget, ServiceManagerDialog):
|
||||
return False
|
||||
# Check if item contains a missing file.
|
||||
for item in list(self.service_items):
|
||||
self.main_window.incrementProgressBar()
|
||||
self.main_window.increment_progress_bar()
|
||||
item[u'service_item'].remove_invalid_frames(missing_list)
|
||||
if item[u'service_item'].missing_frames():
|
||||
self.service_items.remove(item)
|
||||
@ -525,7 +525,7 @@ class ServiceManager(QtGui.QWidget, ServiceManagerDialog):
|
||||
log.debug(u'ServiceManager.save_file - allowZip64 is %s' % allow_zip_64)
|
||||
zip_file = None
|
||||
success = True
|
||||
self.main_window.incrementProgressBar()
|
||||
self.main_window.increment_progress_bar()
|
||||
try:
|
||||
zip_file = zipfile.ZipFile(temp_file_name, 'w', zipfile.ZIP_STORED, allow_zip_64)
|
||||
# First we add service contents.
|
||||
@ -590,15 +590,15 @@ class ServiceManager(QtGui.QWidget, ServiceManagerDialog):
|
||||
# Number of items + 1 to zip it
|
||||
self.main_window.displayProgressBar(len(self.service_items) + 1)
|
||||
for item in self.service_items:
|
||||
self.main_window.incrementProgressBar()
|
||||
self.main_window.increment_progress_bar()
|
||||
service_item = item[u'service_item'].get_service_repr(self._save_lite)
|
||||
#@todo check for file item on save.
|
||||
service.append({u'serviceitem': service_item})
|
||||
self.main_window.incrementProgressBar()
|
||||
self.main_window.increment_progress_bar()
|
||||
service_content = cPickle.dumps(service)
|
||||
zip_file = None
|
||||
success = True
|
||||
self.main_window.incrementProgressBar()
|
||||
self.main_window.increment_progress_bar()
|
||||
try:
|
||||
zip_file = zipfile.ZipFile(temp_file_name, 'w', zipfile.ZIP_STORED,
|
||||
True)
|
||||
@ -719,7 +719,7 @@ class ServiceManager(QtGui.QWidget, ServiceManagerDialog):
|
||||
self.set_file_name(file_name)
|
||||
self.main_window.displayProgressBar(len(items))
|
||||
for item in items:
|
||||
self.main_window.incrementProgressBar()
|
||||
self.main_window.increment_progress_bar()
|
||||
service_item = ServiceItem()
|
||||
if self._save_lite:
|
||||
service_item.set_from_service(item)
|
||||
|
@ -68,10 +68,10 @@ class Ui_ShortcutListDialog(object):
|
||||
shortcutListDialog.resize(500, 438)
|
||||
self.shortcutListLayout = QtGui.QVBoxLayout(shortcutListDialog)
|
||||
self.shortcutListLayout.setObjectName(u'shortcutListLayout')
|
||||
self.descriptionLabel = QtGui.QLabel(shortcutListDialog)
|
||||
self.descriptionLabel.setObjectName(u'description_label')
|
||||
self.descriptionLabel.setWordWrap(True)
|
||||
self.shortcutListLayout.addWidget(self.descriptionLabel)
|
||||
self.description_label = QtGui.QLabel(shortcutListDialog)
|
||||
self.description_label.setObjectName(u'description_label')
|
||||
self.description_label.setWordWrap(True)
|
||||
self.shortcutListLayout.addWidget(self.description_label)
|
||||
self.treeWidget = QtGui.QTreeWidget(shortcutListDialog)
|
||||
self.treeWidget.setObjectName(u'treeWidget')
|
||||
self.treeWidget.setAlternatingRowColors(True)
|
||||
@ -129,7 +129,7 @@ class Ui_ShortcutListDialog(object):
|
||||
Translate the UI on the fly
|
||||
"""
|
||||
shortcutListDialog.setWindowTitle(translate('OpenLP.ShortcutListDialog', 'Configure Shortcuts'))
|
||||
self.descriptionLabel.setText(
|
||||
self.description_label.setText(
|
||||
translate('OpenLP.ShortcutListDialog', 'Select an action and click one of the buttons below to start '
|
||||
'capturing a new primary or alternate shortcut, respectively.'))
|
||||
self.treeWidget.setHeaderLabels([translate('OpenLP.ShortcutListDialog', 'Action'),
|
||||
|
@ -149,7 +149,7 @@ class ThemeForm(QtGui.QWizard, Ui_ThemeWizard):
|
||||
Calculate the number of lines on a page by rendering text
|
||||
"""
|
||||
# Do not trigger on start up
|
||||
if self.currentPage != self.welcomePage:
|
||||
if self.currentPage != self.welcome_page:
|
||||
self.updateTheme()
|
||||
self.theme_manager.generate_image(self.theme, True)
|
||||
|
||||
|
@ -681,7 +681,7 @@ class ThemeManager(QtGui.QWidget):
|
||||
log.debug('update_preview_images')
|
||||
self.main_window.displayProgressBar(len(self.theme_list))
|
||||
for theme in self.theme_list:
|
||||
self.main_window.incrementProgressBar()
|
||||
self.main_window.increment_progress_bar()
|
||||
self.generate_and_save_image(self.path, theme, self.get_theme_data(theme))
|
||||
self.main_window.finishedProgressBar()
|
||||
self.load_themes()
|
||||
|
@ -394,9 +394,9 @@ class Ui_ThemeWizard(object):
|
||||
Translate the UI on the fly
|
||||
"""
|
||||
themeWizard.setWindowTitle(translate('OpenLP.ThemeWizard', 'Theme Wizard'))
|
||||
self.titleLabel.setText(u'<span style="font-size:14pt; font-weight:600;">%s</span>' %
|
||||
self.title_label.setText(u'<span style="font-size:14pt; font-weight:600;">%s</span>' %
|
||||
translate('OpenLP.ThemeWizard', 'Welcome to the Theme Wizard'))
|
||||
self.informationLabel.setText(
|
||||
self.information_label.setText(
|
||||
translate('OpenLP.ThemeWizard', 'This wizard will help you to create and edit your themes. Click the next '
|
||||
'button below to start the process by setting up your background.'))
|
||||
self.backgroundPage.setTitle(translate('OpenLP.ThemeWizard', 'Set Up Background'))
|
||||
|
@ -85,17 +85,17 @@ class OpenLPWizard(QtGui.QWizard):
|
||||
QtGui.QWizard.__init__(self, parent)
|
||||
self.plugin = plugin
|
||||
self.setObjectName(name)
|
||||
self.openIcon = build_icon(u':/general/general_open.png')
|
||||
self.deleteIcon = build_icon(u':/general/general_delete.png')
|
||||
self.finishButton = self.button(QtGui.QWizard.FinishButton)
|
||||
self.cancelButton = self.button(QtGui.QWizard.CancelButton)
|
||||
self.open_icon = build_icon(u':/general/general_open.png')
|
||||
self.delete_icon = build_icon(u':/general/general_delete.png')
|
||||
self.finish_button = self.button(QtGui.QWizard.FinishButton)
|
||||
self.cancel_button = self.button(QtGui.QWizard.CancelButton)
|
||||
self.setupUi(image)
|
||||
self.registerFields()
|
||||
self.register_fields()
|
||||
self.customInit()
|
||||
self.customSignals()
|
||||
QtCore.QObject.connect(self, QtCore.SIGNAL(u'currentIdChanged(int)'), self.onCurrentIdChanged)
|
||||
QtCore.QObject.connect(self.errorCopyToButton, QtCore.SIGNAL(u'clicked()'), self.onErrorCopyToButtonClicked)
|
||||
QtCore.QObject.connect(self.errorSaveToButton, QtCore.SIGNAL(u'clicked()'), self.onErrorSaveToButtonClicked)
|
||||
QtCore.QObject.connect(self, QtCore.SIGNAL(u'currentIdChanged(int)'), self.on_current_id_changed)
|
||||
QtCore.QObject.connect(self.error_copy_to_button, QtCore.SIGNAL(u'clicked()'), self.on_error_copy_to_button_clicked)
|
||||
QtCore.QObject.connect(self.error_save_to_button, QtCore.SIGNAL(u'clicked()'), self.on_error_save_to_button_clicked)
|
||||
|
||||
def setupUi(self, image):
|
||||
"""
|
||||
@ -110,7 +110,7 @@ class OpenLPWizard(QtGui.QWizard):
|
||||
self.addProgressPage()
|
||||
self.retranslateUi()
|
||||
|
||||
def registerFields(self):
|
||||
def register_fields(self):
|
||||
"""
|
||||
Hook method for wizards to register any fields they need.
|
||||
"""
|
||||
@ -121,41 +121,41 @@ class OpenLPWizard(QtGui.QWizard):
|
||||
Add the progress page for the wizard. This page informs the user how
|
||||
the wizard is progressing with its task.
|
||||
"""
|
||||
self.progressPage = QtGui.QWizardPage()
|
||||
self.progressPage.setObjectName(u'progressPage')
|
||||
self.progressLayout = QtGui.QVBoxLayout(self.progressPage)
|
||||
self.progressLayout.setMargin(48)
|
||||
self.progressLayout.setObjectName(u'progressLayout')
|
||||
self.progressLabel = QtGui.QLabel(self.progressPage)
|
||||
self.progressLabel.setObjectName(u'progressLabel')
|
||||
self.progressLabel.setWordWrap(True)
|
||||
self.progressLayout.addWidget(self.progressLabel)
|
||||
self.progressBar = QtGui.QProgressBar(self.progressPage)
|
||||
self.progressBar.setObjectName(u'progressBar')
|
||||
self.progressLayout.addWidget(self.progressBar)
|
||||
self.progress_page = QtGui.QWizardPage()
|
||||
self.progress_page.setObjectName(u'progress_page')
|
||||
self.progress_layout = QtGui.QVBoxLayout(self.progress_page)
|
||||
self.progress_layout.setMargin(48)
|
||||
self.progress_layout.setObjectName(u'progress_layout')
|
||||
self.progress_label = QtGui.QLabel(self.progress_page)
|
||||
self.progress_label.setObjectName(u'progress_label')
|
||||
self.progress_label.setWordWrap(True)
|
||||
self.progress_layout.addWidget(self.progress_label)
|
||||
self.progress_bar = QtGui.QProgressBar(self.progress_page)
|
||||
self.progress_bar.setObjectName(u'progress_bar')
|
||||
self.progress_layout.addWidget(self.progress_bar)
|
||||
# Add a QTextEdit and a copy to file and copy to clipboard button to be
|
||||
# able to provide feedback to the user. Hidden by default.
|
||||
self.errorReportTextEdit = QtGui.QTextEdit(self.progressPage)
|
||||
self.errorReportTextEdit.setObjectName(u'progresserrorReportTextEdit')
|
||||
self.errorReportTextEdit.setHidden(True)
|
||||
self.errorReportTextEdit.setReadOnly(True)
|
||||
self.progressLayout.addWidget(self.errorReportTextEdit)
|
||||
self.errorButtonLayout = QtGui.QHBoxLayout()
|
||||
self.errorButtonLayout.setObjectName(u'errorButtonLayout')
|
||||
self.error_report_text_edit = QtGui.QTextEdit(self.progress_page)
|
||||
self.error_report_text_edit.setObjectName(u'progresserrorReportTextEdit')
|
||||
self.error_report_text_edit.setHidden(True)
|
||||
self.error_report_text_edit.setReadOnly(True)
|
||||
self.progress_layout.addWidget(self.error_report_text_edit)
|
||||
self.error_button_layout = QtGui.QHBoxLayout()
|
||||
self.error_button_layout.setObjectName(u'error_button_layout')
|
||||
spacer = QtGui.QSpacerItem(40, 20, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum)
|
||||
self.errorButtonLayout.addItem(spacer)
|
||||
self.errorCopyToButton = QtGui.QPushButton(self.progressPage)
|
||||
self.errorCopyToButton.setObjectName(u'errorCopyToButton')
|
||||
self.errorCopyToButton.setHidden(True)
|
||||
self.errorCopyToButton.setIcon(build_icon(u':/system/system_edit_copy.png'))
|
||||
self.errorButtonLayout.addWidget(self.errorCopyToButton)
|
||||
self.errorSaveToButton = QtGui.QPushButton(self.progressPage)
|
||||
self.errorSaveToButton.setObjectName(u'errorSaveToButton')
|
||||
self.errorSaveToButton.setHidden(True)
|
||||
self.errorSaveToButton.setIcon(build_icon(u':/general/general_save.png'))
|
||||
self.errorButtonLayout.addWidget(self.errorSaveToButton)
|
||||
self.progressLayout.addLayout(self.errorButtonLayout)
|
||||
self.addPage(self.progressPage)
|
||||
self.error_button_layout.addItem(spacer)
|
||||
self.error_copy_to_button = QtGui.QPushButton(self.progress_page)
|
||||
self.error_copy_to_button.setObjectName(u'error_copy_to_button')
|
||||
self.error_copy_to_button.setHidden(True)
|
||||
self.error_copy_to_button.setIcon(build_icon(u':/system/system_edit_copy.png'))
|
||||
self.error_button_layout.addWidget(self.error_copy_to_button)
|
||||
self.error_save_to_button = QtGui.QPushButton(self.progress_page)
|
||||
self.error_save_to_button.setObjectName(u'error_save_to_button')
|
||||
self.error_save_to_button.setHidden(True)
|
||||
self.error_save_to_button.setIcon(build_icon(u':/general/general_save.png'))
|
||||
self.error_button_layout.addWidget(self.error_save_to_button)
|
||||
self.progress_layout.addLayout(self.error_button_layout)
|
||||
self.addPage(self.progress_page)
|
||||
|
||||
def exec_(self):
|
||||
"""
|
||||
@ -169,40 +169,40 @@ class OpenLPWizard(QtGui.QWizard):
|
||||
Stop the wizard on cancel button, close button or ESC key.
|
||||
"""
|
||||
log.debug(u'Wizard cancelled by user.')
|
||||
if self.currentPage() == self.progressPage:
|
||||
if self.currentPage() == self.progress_page:
|
||||
Registry().execute(u'openlp_stop_wizard')
|
||||
self.done(QtGui.QDialog.Rejected)
|
||||
|
||||
def onCurrentIdChanged(self, pageId):
|
||||
def on_current_id_changed(self, pageId):
|
||||
"""
|
||||
Perform necessary functions depending on which wizard page is active.
|
||||
"""
|
||||
if self.page(pageId) == self.progressPage:
|
||||
self.preWizard()
|
||||
if self.page(pageId) == self.progress_page:
|
||||
self.pre_wizard()
|
||||
self.performWizard()
|
||||
self.postWizard()
|
||||
else:
|
||||
self.customPageChanged(pageId)
|
||||
self.custom_cage_changed(pageId)
|
||||
|
||||
def customPageChanged(self, pageId):
|
||||
def custom_cage_changed(self, pageId):
|
||||
"""
|
||||
Called when changing to a page other than the progress page
|
||||
"""
|
||||
pass
|
||||
|
||||
def onErrorCopyToButtonClicked(self):
|
||||
def on_error_copy_to_button_clicked(self):
|
||||
"""
|
||||
Called when the ``onErrorCopyToButtonClicked`` has been clicked.
|
||||
Called when the ``on_error_copy_to_button_clicked`` has been clicked.
|
||||
"""
|
||||
pass
|
||||
|
||||
def onErrorSaveToButtonClicked(self):
|
||||
def on_error_save_to_button_clicked(self):
|
||||
"""
|
||||
Called when the ``onErrorSaveToButtonClicked`` has been clicked.
|
||||
Called when the ``on_error_save_to_button_clicked`` has been clicked.
|
||||
"""
|
||||
pass
|
||||
|
||||
def incrementProgressBar(self, status_text, increment=1):
|
||||
def increment_progress_bar(self, status_text, increment=1):
|
||||
"""
|
||||
Update the wizard progress page.
|
||||
|
||||
@ -213,30 +213,30 @@ class OpenLPWizard(QtGui.QWizard):
|
||||
The value to increment the progress bar by.
|
||||
"""
|
||||
log.debug(u'IncrementBar %s', status_text)
|
||||
self.progressLabel.setText(status_text)
|
||||
self.progress_label.setText(status_text)
|
||||
if increment > 0:
|
||||
self.progressBar.setValue(self.progressBar.value() + increment)
|
||||
self.progress_bar.setValue(self.progress_bar.value() + increment)
|
||||
self.application.process_events()
|
||||
|
||||
def preWizard(self):
|
||||
def pre_wizard(self):
|
||||
"""
|
||||
Prepare the UI for the import.
|
||||
"""
|
||||
self.finishButton.setVisible(False)
|
||||
self.progressBar.setMinimum(0)
|
||||
self.progressBar.setMaximum(1188)
|
||||
self.progressBar.setValue(0)
|
||||
self.finish_button.setVisible(False)
|
||||
self.progress_bar.setMinimum(0)
|
||||
self.progress_bar.setMaximum(1188)
|
||||
self.progress_bar.setValue(0)
|
||||
|
||||
def postWizard(self):
|
||||
"""
|
||||
Clean up the UI after the import has finished.
|
||||
"""
|
||||
self.progressBar.setValue(self.progressBar.maximum())
|
||||
self.finishButton.setVisible(True)
|
||||
self.cancelButton.setVisible(False)
|
||||
self.progress_bar.setValue(self.progress_bar.maximum())
|
||||
self.finish_button.setVisible(True)
|
||||
self.cancel_button.setVisible(False)
|
||||
self.application.process_events()
|
||||
|
||||
def getFileName(self, title, editbox, setting_name, filters=u''):
|
||||
def get_file_name(self, title, editbox, setting_name, filters=u''):
|
||||
"""
|
||||
Opens a QFileDialog and saves the filename to the given editbox.
|
||||
|
||||
@ -264,7 +264,7 @@ class OpenLPWizard(QtGui.QWizard):
|
||||
editbox.setText(filename)
|
||||
Settings().setValue(self.plugin.settingsSection + u'/' + setting_name, filename)
|
||||
|
||||
def getFolder(self, title, editbox, setting_name):
|
||||
def get_folder(self, title, editbox, setting_name):
|
||||
"""
|
||||
Opens a QFileDialog and saves the selected folder to the given editbox.
|
||||
|
||||
|
@ -165,7 +165,7 @@ class BibleImportForm(OpenLPWizard):
|
||||
self.osisFileEdit.setObjectName(u'OsisFileEdit')
|
||||
self.osisFileLayout.addWidget(self.osisFileEdit)
|
||||
self.osisBrowseButton = QtGui.QToolButton(self.osisWidget)
|
||||
self.osisBrowseButton.setIcon(self.openIcon)
|
||||
self.osisBrowseButton.setIcon(self.open_icon)
|
||||
self.osisBrowseButton.setObjectName(u'OsisBrowseButton')
|
||||
self.osisFileLayout.addWidget(self.osisBrowseButton)
|
||||
self.osisLayout.addRow(self.osisFileLabel, self.osisFileLayout)
|
||||
@ -184,7 +184,7 @@ class BibleImportForm(OpenLPWizard):
|
||||
self.csvBooksEdit.setObjectName(u'CsvBooksEdit')
|
||||
self.csvBooksLayout.addWidget(self.csvBooksEdit)
|
||||
self.csvBooksButton = QtGui.QToolButton(self.csvWidget)
|
||||
self.csvBooksButton.setIcon(self.openIcon)
|
||||
self.csvBooksButton.setIcon(self.open_icon)
|
||||
self.csvBooksButton.setObjectName(u'CsvBooksButton')
|
||||
self.csvBooksLayout.addWidget(self.csvBooksButton)
|
||||
self.csvLayout.addRow(self.csvBooksLabel, self.csvBooksLayout)
|
||||
@ -196,7 +196,7 @@ class BibleImportForm(OpenLPWizard):
|
||||
self.csvVersesEdit.setObjectName(u'CsvVersesEdit')
|
||||
self.csvVersesLayout.addWidget(self.csvVersesEdit)
|
||||
self.csvVersesButton = QtGui.QToolButton(self.csvWidget)
|
||||
self.csvVersesButton.setIcon(self.openIcon)
|
||||
self.csvVersesButton.setIcon(self.open_icon)
|
||||
self.csvVersesButton.setObjectName(u'CsvVersesButton')
|
||||
self.csvVersesLayout.addWidget(self.csvVersesButton)
|
||||
self.csvLayout.addRow(self.csvVersesLabel, self.csvVersesLayout)
|
||||
@ -215,7 +215,7 @@ class BibleImportForm(OpenLPWizard):
|
||||
self.openSongFileEdit.setObjectName(u'OpenSongFileEdit')
|
||||
self.openSongFileLayout.addWidget(self.openSongFileEdit)
|
||||
self.openSongBrowseButton = QtGui.QToolButton(self.openSongWidget)
|
||||
self.openSongBrowseButton.setIcon(self.openIcon)
|
||||
self.openSongBrowseButton.setIcon(self.open_icon)
|
||||
self.openSongBrowseButton.setObjectName(u'OpenSongBrowseButton')
|
||||
self.openSongFileLayout.addWidget(self.openSongBrowseButton)
|
||||
self.openSongLayout.addRow(self.openSongFileLabel, self.openSongFileLayout)
|
||||
@ -279,7 +279,7 @@ class BibleImportForm(OpenLPWizard):
|
||||
self.openlp1FileEdit.setObjectName(u'Openlp1FileEdit')
|
||||
self.openlp1FileLayout.addWidget(self.openlp1FileEdit)
|
||||
self.openlp1BrowseButton = QtGui.QToolButton(self.openlp1Widget)
|
||||
self.openlp1BrowseButton.setIcon(self.openIcon)
|
||||
self.openlp1BrowseButton.setIcon(self.open_icon)
|
||||
self.openlp1BrowseButton.setObjectName(u'Openlp1BrowseButton')
|
||||
self.openlp1FileLayout.addWidget(self.openlp1BrowseButton)
|
||||
self.openlp1Layout.addRow(self.openlp1FileLabel, self.openlp1FileLayout)
|
||||
@ -322,9 +322,9 @@ class BibleImportForm(OpenLPWizard):
|
||||
Allow for localisation of the bible import wizard.
|
||||
"""
|
||||
self.setWindowTitle(translate('BiblesPlugin.ImportWizardForm', 'Bible Import Wizard'))
|
||||
self.titleLabel.setText(WizardStrings.HeaderStyle %
|
||||
self.title_label.setText(WizardStrings.HeaderStyle %
|
||||
translate('OpenLP.Ui', 'Welcome to the Bible Import Wizard'))
|
||||
self.informationLabel.setText(
|
||||
self.information_label.setText(
|
||||
translate('BiblesPlugin.ImportWizardForm',
|
||||
'This wizard will help you to import Bibles from a variety of '
|
||||
'formats. Click the next button below to start the process by '
|
||||
@ -366,11 +366,11 @@ class BibleImportForm(OpenLPWizard):
|
||||
self.versionNameLabel.setText(translate('BiblesPlugin.ImportWizardForm', 'Version name:'))
|
||||
self.copyrightLabel.setText(translate('BiblesPlugin.ImportWizardForm', 'Copyright:'))
|
||||
self.permissionsLabel.setText(translate('BiblesPlugin.ImportWizardForm', 'Permissions:'))
|
||||
self.progressPage.setTitle(WizardStrings.Importing)
|
||||
self.progressPage.setSubTitle(translate('BiblesPlugin.ImportWizardForm',
|
||||
self.progress_page.setTitle(WizardStrings.Importing)
|
||||
self.progress_page.setSubTitle(translate('BiblesPlugin.ImportWizardForm',
|
||||
'Please wait while your Bible is imported.'))
|
||||
self.progressLabel.setText(WizardStrings.Ready)
|
||||
self.progressBar.setFormat(u'%p%')
|
||||
self.progress_label.setText(WizardStrings.Ready)
|
||||
self.progress_bar.setFormat(u'%p%')
|
||||
self.openlp1DisabledLabel.setText(WizardStrings.NoSqlite)
|
||||
# Align all QFormLayouts towards each other.
|
||||
labelWidth = max(self.formatLabel.minimumSizeHint().width(),
|
||||
@ -385,7 +385,7 @@ class BibleImportForm(OpenLPWizard):
|
||||
"""
|
||||
Validate the current page before moving on to the next page.
|
||||
"""
|
||||
if self.currentPage() == self.welcomePage:
|
||||
if self.currentPage() == self.welcome_page:
|
||||
return True
|
||||
elif self.currentPage() == self.selectPage:
|
||||
if self.field(u'source_format') == BibleFormat.OSIS:
|
||||
@ -449,7 +449,7 @@ class BibleImportForm(OpenLPWizard):
|
||||
self.versionNameEdit.setFocus()
|
||||
return False
|
||||
return True
|
||||
if self.currentPage() == self.progressPage:
|
||||
if self.currentPage() == self.progress_page:
|
||||
return True
|
||||
|
||||
def onWebSourceComboBoxIndexChanged(self, index):
|
||||
@ -469,33 +469,33 @@ class BibleImportForm(OpenLPWizard):
|
||||
"""
|
||||
Show the file open dialog for the OSIS file.
|
||||
"""
|
||||
self.getFileName(WizardStrings.OpenTypeFile % WizardStrings.OSIS, self.osisFileEdit, u'last directory import')
|
||||
self.get_file_name(WizardStrings.OpenTypeFile % WizardStrings.OSIS, self.osisFileEdit, u'last directory import')
|
||||
|
||||
def onCsvBooksBrowseButtonClicked(self):
|
||||
"""
|
||||
Show the file open dialog for the books CSV file.
|
||||
"""
|
||||
self.getFileName(WizardStrings.OpenTypeFile % WizardStrings.CSV, self.csvBooksEdit, u'last directory import',
|
||||
self.get_file_name(WizardStrings.OpenTypeFile % WizardStrings.CSV, self.csvBooksEdit, u'last directory import',
|
||||
u'%s (*.csv)' % translate('BiblesPlugin.ImportWizardForm', 'CSV File'))
|
||||
|
||||
def onCsvVersesBrowseButtonClicked(self):
|
||||
"""
|
||||
Show the file open dialog for the verses CSV file.
|
||||
"""
|
||||
self.getFileName(WizardStrings.OpenTypeFile % WizardStrings.CSV, self.csvVersesEdit, u'last directory import',
|
||||
self.get_file_name(WizardStrings.OpenTypeFile % WizardStrings.CSV, self.csvVersesEdit, u'last directory import',
|
||||
u'%s (*.csv)' % translate('BiblesPlugin.ImportWizardForm', 'CSV File'))
|
||||
|
||||
def onOpenSongBrowseButtonClicked(self):
|
||||
"""
|
||||
Show the file open dialog for the OpenSong file.
|
||||
"""
|
||||
self.getFileName(WizardStrings.OpenTypeFile % WizardStrings.OS, self.openSongFileEdit, u'last directory import')
|
||||
self.get_file_name(WizardStrings.OpenTypeFile % WizardStrings.OS, self.openSongFileEdit, u'last directory import')
|
||||
|
||||
def onOpenlp1BrowseButtonClicked(self):
|
||||
"""
|
||||
Show the file open dialog for the openlp.org 1.x file.
|
||||
"""
|
||||
self.getFileName(WizardStrings.OpenTypeFile % UiStrings().OLPV1, self.openlp1FileEdit, u'last directory import',
|
||||
self.get_file_name(WizardStrings.OpenTypeFile % UiStrings().OLPV1, self.openlp1FileEdit, u'last directory import',
|
||||
u'%s (*.bible)' % translate('BiblesPlugin.ImportWizardForm', 'openlp.org 1.x Bible Files'))
|
||||
|
||||
def registerFields(self):
|
||||
@ -524,8 +524,8 @@ class BibleImportForm(OpenLPWizard):
|
||||
settings = Settings()
|
||||
settings.beginGroup(self.plugin.settingsSection)
|
||||
self.restart()
|
||||
self.finishButton.setVisible(False)
|
||||
self.cancelButton.setVisible(True)
|
||||
self.finish_button.setVisible(False)
|
||||
self.cancel_button.setVisible(True)
|
||||
self.setField(u'source_format', 0)
|
||||
self.setField(u'osis_location', '')
|
||||
self.setField(u'csv_booksfile', '')
|
||||
@ -572,12 +572,12 @@ class BibleImportForm(OpenLPWizard):
|
||||
"""
|
||||
Prepare the UI for the import.
|
||||
"""
|
||||
OpenLPWizard.preWizard(self)
|
||||
OpenLPWizard.pre_wizard(self)
|
||||
bible_type = self.field(u'source_format')
|
||||
if bible_type == BibleFormat.WebDownload:
|
||||
self.progressLabel.setText(translate('BiblesPlugin.ImportWizardForm', 'Registering Bible...'))
|
||||
self.progress_label.setText(translate('BiblesPlugin.ImportWizardForm', 'Registering Bible...'))
|
||||
else:
|
||||
self.progressLabel.setText(WizardStrings.StartingImport)
|
||||
self.progress_label.setText(WizardStrings.StartingImport)
|
||||
self.application.process_events()
|
||||
|
||||
def performWizard(self):
|
||||
@ -610,7 +610,7 @@ class BibleImportForm(OpenLPWizard):
|
||||
)
|
||||
elif bible_type == BibleFormat.WebDownload:
|
||||
# Import a bible from the web.
|
||||
self.progressBar.setMaximum(1)
|
||||
self.progress_bar.setMaximum(1)
|
||||
download_location = self.field(u'web_location')
|
||||
bible_version = self.webTranslationComboBox.currentText()
|
||||
bible = self.web_bible_list[download_location][bible_version]
|
||||
@ -633,12 +633,12 @@ class BibleImportForm(OpenLPWizard):
|
||||
license_copyright, license_permissions)
|
||||
self.manager.reload_bibles()
|
||||
if bible_type == BibleFormat.WebDownload:
|
||||
self.progressLabel.setText(
|
||||
self.progress_label.setText(
|
||||
translate('BiblesPlugin.ImportWizardForm', 'Registered Bible. Please note, that verses will be '
|
||||
'downloaded on\ndemand and thus an internet connection is required.'))
|
||||
else:
|
||||
self.progressLabel.setText(WizardStrings.FinishedImport)
|
||||
self.progress_label.setText(WizardStrings.FinishedImport)
|
||||
else:
|
||||
self.progressLabel.setText(translate('BiblesPlugin.ImportWizardForm', 'Your Bible import failed.'))
|
||||
self.progress_label.setText(translate('BiblesPlugin.ImportWizardForm', 'Your Bible import failed.'))
|
||||
del self.manager.db_cache[importer.name]
|
||||
delete_database(self.plugin.settingsSection, importer.file)
|
||||
|
@ -97,14 +97,14 @@ class BibleUpgradeForm(OpenLPWizard):
|
||||
"""
|
||||
log.debug(u'Wizard cancelled by user')
|
||||
self.stop_import_flag = True
|
||||
if not self.currentPage() == self.progressPage:
|
||||
if not self.currentPage() == self.progress_page:
|
||||
self.done(QtGui.QDialog.Rejected)
|
||||
|
||||
def onCurrentIdChanged(self, pageId):
|
||||
"""
|
||||
Perform necessary functions depending on which wizard page is active.
|
||||
"""
|
||||
if self.page(pageId) == self.progressPage:
|
||||
if self.page(pageId) == self.progress_page:
|
||||
self.preWizard()
|
||||
self.performWizard()
|
||||
self.postWizard()
|
||||
@ -183,7 +183,7 @@ class BibleUpgradeForm(OpenLPWizard):
|
||||
self.backupDirectoryEdit.setObjectName(u'BackupFolderEdit')
|
||||
self.backupDirectoryLayout.addWidget(self.backupDirectoryEdit)
|
||||
self.backupBrowseButton = QtGui.QToolButton(self.backupPage)
|
||||
self.backupBrowseButton.setIcon(self.openIcon)
|
||||
self.backupBrowseButton.setIcon(self.open_icon)
|
||||
self.backupBrowseButton.setObjectName(u'BackupBrowseButton')
|
||||
self.backupDirectoryLayout.addWidget(self.backupBrowseButton)
|
||||
self.formLayout.addRow(self.backupDirectoryLabel, self.backupDirectoryLayout)
|
||||
@ -242,9 +242,9 @@ class BibleUpgradeForm(OpenLPWizard):
|
||||
Allow for localisation of the bible import wizard.
|
||||
"""
|
||||
self.setWindowTitle(translate('BiblesPlugin.UpgradeWizardForm', 'Bible Upgrade Wizard'))
|
||||
self.titleLabel.setText(WizardStrings.HeaderStyle %
|
||||
self.title_label.setText(WizardStrings.HeaderStyle %
|
||||
translate('OpenLP.Ui', 'Welcome to the Bible Upgrade Wizard'))
|
||||
self.informationLabel.setText(translate('BiblesPlugin.UpgradeWizardForm',
|
||||
self.information_label.setText(translate('BiblesPlugin.UpgradeWizardForm',
|
||||
'This wizard will help you to upgrade your existing Bibles from a prior version of OpenLP 2. '
|
||||
'Click the next button below to start the upgrade process.'))
|
||||
self.backupPage.setTitle(translate('BiblesPlugin.UpgradeWizardForm', 'Select Backup Directory'))
|
||||
@ -265,17 +265,17 @@ class BibleUpgradeForm(OpenLPWizard):
|
||||
self.selectPage.setTitle(translate('BiblesPlugin.UpgradeWizardForm', 'Select Bibles'))
|
||||
self.selectPage.setSubTitle(translate('BiblesPlugin.UpgradeWizardForm',
|
||||
'Please select the Bibles to upgrade'))
|
||||
self.progressPage.setTitle(translate('BiblesPlugin.UpgradeWizardForm', 'Upgrading'))
|
||||
self.progressPage.setSubTitle(translate('BiblesPlugin.UpgradeWizardForm',
|
||||
self.progress_page.setTitle(translate('BiblesPlugin.UpgradeWizardForm', 'Upgrading'))
|
||||
self.progress_page.setSubTitle(translate('BiblesPlugin.UpgradeWizardForm',
|
||||
'Please wait while your Bibles are upgraded.'))
|
||||
self.progressLabel.setText(WizardStrings.Ready)
|
||||
self.progressBar.setFormat(u'%p%')
|
||||
self.progress_label.setText(WizardStrings.Ready)
|
||||
self.progress_bar.setFormat(u'%p%')
|
||||
|
||||
def validateCurrentPage(self):
|
||||
"""
|
||||
Validate the current page before moving on to the next page.
|
||||
"""
|
||||
if self.currentPage() == self.welcomePage:
|
||||
if self.currentPage() == self.welcome_page:
|
||||
return True
|
||||
elif self.currentPage() == self.backupPage:
|
||||
if not self.noBackupCheckBox.checkState() == QtCore.Qt.Checked:
|
||||
@ -304,7 +304,7 @@ class BibleUpgradeForm(OpenLPWizard):
|
||||
else:
|
||||
delete_file(os.path.join(self.path, filename[0]))
|
||||
return True
|
||||
if self.currentPage() == self.progressPage:
|
||||
if self.currentPage() == self.progress_page:
|
||||
return True
|
||||
|
||||
def setDefaults(self):
|
||||
@ -323,18 +323,18 @@ class BibleUpgradeForm(OpenLPWizard):
|
||||
self.retranslateUi()
|
||||
for number, filename in enumerate(self.files):
|
||||
self.checkBox[number].setCheckState(QtCore.Qt.Checked)
|
||||
self.progressBar.show()
|
||||
self.progress_bar.show()
|
||||
self.restart()
|
||||
self.finishButton.setVisible(False)
|
||||
self.cancelButton.setVisible(True)
|
||||
self.finish_button.setVisible(False)
|
||||
self.cancel_button.setVisible(True)
|
||||
settings.endGroup()
|
||||
|
||||
def preWizard(self):
|
||||
"""
|
||||
Prepare the UI for the upgrade.
|
||||
"""
|
||||
OpenLPWizard.preWizard(self)
|
||||
self.progressLabel.setText(translate('BiblesPlugin.UpgradeWizardForm', 'Starting upgrade...'))
|
||||
OpenLPWizard.pre_wizard(self)
|
||||
self.progress_label.setText(translate('BiblesPlugin.UpgradeWizardForm', 'Starting upgrade...'))
|
||||
self.application.process_events()
|
||||
|
||||
def performWizard(self):
|
||||
@ -344,9 +344,9 @@ class BibleUpgradeForm(OpenLPWizard):
|
||||
self.includeWebBible = False
|
||||
proxy_server = None
|
||||
if not self.files:
|
||||
self.progressLabel.setText(translate('BiblesPlugin.UpgradeWizardForm',
|
||||
self.progress_label.setText(translate('BiblesPlugin.UpgradeWizardForm',
|
||||
'There are no Bibles that need to be upgraded.'))
|
||||
self.progressBar.hide()
|
||||
self.progress_bar.hide()
|
||||
return
|
||||
max_bibles = 0
|
||||
for number, file in enumerate(self.files):
|
||||
@ -366,11 +366,11 @@ class BibleUpgradeForm(OpenLPWizard):
|
||||
if not self.checkBox[number].checkState() == QtCore.Qt.Checked:
|
||||
self.success[number] = False
|
||||
continue
|
||||
self.progressBar.reset()
|
||||
self.progress_bar.reset()
|
||||
old_bible = OldBibleDB(self.mediaItem, path=self.temp_dir,
|
||||
file=filename[0])
|
||||
name = filename[1]
|
||||
self.progressLabel.setText(translate('BiblesPlugin.UpgradeWizardForm',
|
||||
self.progress_label.setText(translate('BiblesPlugin.UpgradeWizardForm',
|
||||
'Upgrading Bible %s of %s: "%s"\nUpgrading ...') % (number + 1, max_bibles, name))
|
||||
self.newbibles[number] = BibleDB(self.mediaItem, path=self.path, name=name, file=filename[0])
|
||||
self.newbibles[number].register(self.plugin.upgrade_wizard)
|
||||
@ -409,9 +409,9 @@ class BibleUpgradeForm(OpenLPWizard):
|
||||
translate('BiblesPlugin.UpgradeWizardForm', 'Download Error'),
|
||||
translate('BiblesPlugin.UpgradeWizardForm',
|
||||
'To upgrade your Web Bibles an Internet connection is required.'))
|
||||
self.incrementProgressBar(translate(
|
||||
self.increment_progress_bar(translate(
|
||||
'BiblesPlugin.UpgradeWizardForm', 'Upgrading Bible %s of %s: "%s"\nFailed') %
|
||||
(number + 1, max_bibles, name), self.progressBar.maximum() - self.progressBar.value())
|
||||
(number + 1, max_bibles, name), self.progress_bar.maximum() - self.progress_bar.value())
|
||||
self.success[number] = False
|
||||
continue
|
||||
bible = BiblesResourcesDB.get_webbible(
|
||||
@ -427,17 +427,17 @@ class BibleUpgradeForm(OpenLPWizard):
|
||||
log.warn(u'Upgrading from "%s" failed' % filename[0])
|
||||
self.newbibles[number].session.close()
|
||||
del self.newbibles[number]
|
||||
self.incrementProgressBar(translate('BiblesPlugin.UpgradeWizardForm',
|
||||
self.increment_progress_bar(translate('BiblesPlugin.UpgradeWizardForm',
|
||||
'Upgrading Bible %s of %s: "%s"\nFailed') % (number + 1, max_bibles, name),
|
||||
self.progressBar.maximum() - self.progressBar.value())
|
||||
self.progress_bar.maximum() - self.progress_bar.value())
|
||||
self.success[number] = False
|
||||
continue
|
||||
self.progressBar.setMaximum(len(books))
|
||||
self.progress_bar.setMaximum(len(books))
|
||||
for book in books:
|
||||
if self.stop_import_flag:
|
||||
self.success[number] = False
|
||||
break
|
||||
self.incrementProgressBar(translate('BiblesPlugin.UpgradeWizardForm',
|
||||
self.increment_progress_bar(translate('BiblesPlugin.UpgradeWizardForm',
|
||||
'Upgrading Bible %s of %s: "%s"\nUpgrading %s ...') % (number + 1, max_bibles, name, book))
|
||||
book_ref_id = self.newbibles[number].\
|
||||
get_book_ref_id_by_name(book, len(books), language_id)
|
||||
@ -475,18 +475,18 @@ class BibleUpgradeForm(OpenLPWizard):
|
||||
log.warn(u'Upgrading books from "%s" failed' % name)
|
||||
self.newbibles[number].session.close()
|
||||
del self.newbibles[number]
|
||||
self.incrementProgressBar(translate('BiblesPlugin.UpgradeWizardForm',
|
||||
self.increment_progress_bar(translate('BiblesPlugin.UpgradeWizardForm',
|
||||
'Upgrading Bible %s of %s: "%s"\nFailed') % (number + 1, max_bibles, name),
|
||||
self.progressBar.maximum() - self.progressBar.value())
|
||||
self.progress_bar.maximum() - self.progress_bar.value())
|
||||
self.success[number] = False
|
||||
continue
|
||||
books = old_bible.get_books()
|
||||
self.progressBar.setMaximum(len(books))
|
||||
self.progress_bar.setMaximum(len(books))
|
||||
for book in books:
|
||||
if self.stop_import_flag:
|
||||
self.success[number] = False
|
||||
break
|
||||
self.incrementProgressBar(translate('BiblesPlugin.UpgradeWizardForm',
|
||||
self.increment_progress_bar(translate('BiblesPlugin.UpgradeWizardForm',
|
||||
'Upgrading Bible %s of %s: "%s"\nUpgrading %s ...') %
|
||||
(number + 1, max_bibles, name, book[u'name']))
|
||||
book_ref_id = self.newbibles[number].get_book_ref_id_by_name(book[u'name'], len(books), language_id)
|
||||
@ -514,13 +514,13 @@ class BibleUpgradeForm(OpenLPWizard):
|
||||
self.application.process_events()
|
||||
self.newbibles[number].session.commit()
|
||||
if not self.success.get(number, True):
|
||||
self.incrementProgressBar(translate('BiblesPlugin.UpgradeWizardForm',
|
||||
self.increment_progress_bar(translate('BiblesPlugin.UpgradeWizardForm',
|
||||
'Upgrading Bible %s of %s: "%s"\nFailed') % (number + 1, max_bibles, name),
|
||||
self.progressBar.maximum() - self.progressBar.value())
|
||||
self.progress_bar.maximum() - self.progress_bar.value())
|
||||
else:
|
||||
self.success[number] = True
|
||||
self.newbibles[number].save_meta(u'name', name)
|
||||
self.incrementProgressBar(translate('BiblesPlugin.UpgradeWizardForm',
|
||||
self.increment_progress_bar(translate('BiblesPlugin.UpgradeWizardForm',
|
||||
'Upgrading Bible %s of %s: "%s"\nComplete') % (number + 1, max_bibles, name))
|
||||
if number in self.newbibles:
|
||||
self.newbibles[number].session.close()
|
||||
@ -549,14 +549,14 @@ class BibleUpgradeForm(OpenLPWizard):
|
||||
failed_import_text = u''
|
||||
if successful_import > 0:
|
||||
if self.includeWebBible:
|
||||
self.progressLabel.setText(translate('BiblesPlugin.UpgradeWizardForm',
|
||||
self.progress_label.setText(translate('BiblesPlugin.UpgradeWizardForm',
|
||||
'Upgrading Bible(s): %s successful%s\nPlease note that verses from Web Bibles will be downloaded '
|
||||
'on demand and so an Internet connection is required.') % (successful_import, failed_import_text))
|
||||
else:
|
||||
self.progressLabel.setText(translate('BiblesPlugin.UpgradeWizardForm',
|
||||
self.progress_label.setText(translate('BiblesPlugin.UpgradeWizardForm',
|
||||
'Upgrading Bible(s): %s successful%s') % (successful_import, failed_import_text))
|
||||
else:
|
||||
self.progressLabel.setText(translate('BiblesPlugin.UpgradeWizardForm', 'Upgrade failed.'))
|
||||
self.progress_label.setText(translate('BiblesPlugin.UpgradeWizardForm', 'Upgrade failed.'))
|
||||
# Remove temp directory.
|
||||
shutil.rmtree(self.temp_dir, True)
|
||||
OpenLPWizard.postWizard(self)
|
||||
|
@ -88,9 +88,9 @@ class CSVBible(BibleDB):
|
||||
"""
|
||||
Import the bible books and verses.
|
||||
"""
|
||||
self.wizard.progressBar.setValue(0)
|
||||
self.wizard.progressBar.setMinimum(0)
|
||||
self.wizard.progressBar.setMaximum(66)
|
||||
self.wizard.progress_bar.setValue(0)
|
||||
self.wizard.progress_bar.setMinimum(0)
|
||||
self.wizard.progress_bar.setMaximum(66)
|
||||
success = True
|
||||
language_id = self.get_language(bible_name)
|
||||
if not language_id:
|
||||
@ -109,7 +109,7 @@ class CSVBible(BibleDB):
|
||||
for line in books_reader:
|
||||
if self.stop_import_flag:
|
||||
break
|
||||
self.wizard.incrementProgressBar(translate('BiblesPlugin.CSVBible', 'Importing books... %s') %
|
||||
self.wizard.increment_progress_bar(translate('BiblesPlugin.CSVBible', 'Importing books... %s') %
|
||||
unicode(line[2], details['encoding']))
|
||||
book_ref_id = self.get_book_ref_id_by_name(unicode(line[2], details['encoding']), 67, language_id)
|
||||
if not book_ref_id:
|
||||
@ -127,8 +127,8 @@ class CSVBible(BibleDB):
|
||||
books_file.close()
|
||||
if self.stop_import_flag or not success:
|
||||
return False
|
||||
self.wizard.progressBar.setValue(0)
|
||||
self.wizard.progressBar.setMaximum(67)
|
||||
self.wizard.progress_bar.setValue(0)
|
||||
self.wizard.progress_bar.setMaximum(67)
|
||||
verse_file = None
|
||||
try:
|
||||
book_ptr = None
|
||||
@ -148,7 +148,7 @@ class CSVBible(BibleDB):
|
||||
if book_ptr != line_book:
|
||||
book = self.get_book(line_book)
|
||||
book_ptr = book.name
|
||||
self.wizard.incrementProgressBar(translate('BiblesPlugin.CSVBible',
|
||||
self.wizard.increment_progress_bar(translate('BiblesPlugin.CSVBible',
|
||||
'Importing verses from %s... Importing verses from <book name>...') % book.name)
|
||||
self.session.commit()
|
||||
try:
|
||||
@ -156,7 +156,7 @@ class CSVBible(BibleDB):
|
||||
except UnicodeError:
|
||||
verse_text = unicode(line[3], u'cp1252')
|
||||
self.create_verse(book.id, line[1], line[2], verse_text)
|
||||
self.wizard.incrementProgressBar(translate('BiblesPlugin.CSVBible', 'Importing verses... done.'))
|
||||
self.wizard.increment_progress_bar(translate('BiblesPlugin.CSVBible', 'Importing verses... done.'))
|
||||
self.application.process_events()
|
||||
self.session.commit()
|
||||
except IOError:
|
||||
|
@ -511,8 +511,8 @@ class HTTPBible(BibleDB):
|
||||
Run the import. This method overrides the parent class method. Returns
|
||||
``True`` on success, ``False`` on failure.
|
||||
"""
|
||||
self.wizard.progressBar.setMaximum(68)
|
||||
self.wizard.incrementProgressBar(translate('BiblesPlugin.HTTPBible', 'Registering Bible and loading books...'))
|
||||
self.wizard.progress_bar.setMaximum(68)
|
||||
self.wizard.increment_progress_bar(translate('BiblesPlugin.HTTPBible', 'Registering Bible and loading books...'))
|
||||
self.save_meta(u'download_source', self.download_source)
|
||||
self.save_meta(u'download_name', self.download_name)
|
||||
if self.proxy_server:
|
||||
@ -534,8 +534,8 @@ class HTTPBible(BibleDB):
|
||||
log.exception(u'Importing books from %s - download name: "%s" '\
|
||||
'failed' % (self.download_source, self.download_name))
|
||||
return False
|
||||
self.wizard.progressBar.setMaximum(len(books) + 2)
|
||||
self.wizard.incrementProgressBar(translate( 'BiblesPlugin.HTTPBible', 'Registering Language...'))
|
||||
self.wizard.progress_bar.setMaximum(len(books) + 2)
|
||||
self.wizard.increment_progress_bar(translate( 'BiblesPlugin.HTTPBible', 'Registering Language...'))
|
||||
bible = BiblesResourcesDB.get_webbible(self.download_name, self.download_source.lower())
|
||||
if bible[u'language_id']:
|
||||
language_id = bible[u'language_id']
|
||||
@ -548,7 +548,7 @@ class HTTPBible(BibleDB):
|
||||
for book in books:
|
||||
if self.stop_import_flag:
|
||||
break
|
||||
self.wizard.incrementProgressBar(translate(
|
||||
self.wizard.increment_progress_bar(translate(
|
||||
'BiblesPlugin.HTTPBible', 'Importing %s...',
|
||||
'Importing <book name>...') % book)
|
||||
book_ref_id = self.get_book_ref_id_by_name(book, len(books), language_id)
|
||||
|
@ -77,7 +77,7 @@ class OpenLP1Bible(BibleDB):
|
||||
# This file is not an openlp.org 1.x bible database.
|
||||
return False
|
||||
books = cursor.fetchall()
|
||||
self.wizard.progressBar.setMaximum(len(books) + 1)
|
||||
self.wizard.progress_bar.setMaximum(len(books) + 1)
|
||||
for book in books:
|
||||
if self.stop_import_flag:
|
||||
connection.close()
|
||||
@ -94,7 +94,7 @@ class OpenLP1Bible(BibleDB):
|
||||
book_details = BiblesResourcesDB.get_book_by_id(book_ref_id)
|
||||
db_book = self.create_book(name, book_ref_id, book_details[u'testament_id'])
|
||||
# Update the progess bar.
|
||||
self.wizard.incrementProgressBar(WizardStrings.ImportingType % name)
|
||||
self.wizard.increment_progress_bar(WizardStrings.ImportingType % name)
|
||||
# Import the verses for this book.
|
||||
cursor.execute(u'SELECT chapter, verse, text || \'\' AS text FROM '
|
||||
'verse WHERE book_id=%s' % book_id)
|
||||
|
@ -126,7 +126,7 @@ class OpenSongBible(BibleDB):
|
||||
chapter_number,
|
||||
verse_number,
|
||||
self.get_text(verse))
|
||||
self.wizard.incrementProgressBar(translate('BiblesPlugin.Opensong', 'Importing %s %s...',
|
||||
self.wizard.increment_progress_bar(translate('BiblesPlugin.Opensong', 'Importing %s %s...',
|
||||
'Importing <book name> <chapter>...')) % (db_book.name, chapter_number)
|
||||
self.session.commit()
|
||||
self.application.process_events()
|
||||
|
@ -85,7 +85,7 @@ class OSISBible(BibleDB):
|
||||
success = True
|
||||
last_chapter = 0
|
||||
match_count = 0
|
||||
self.wizard.incrementProgressBar(translate('BiblesPlugin.OsisImport',
|
||||
self.wizard.increment_progress_bar(translate('BiblesPlugin.OsisImport',
|
||||
'Detecting encoding (this may take a few minutes)...'))
|
||||
try:
|
||||
detect_file = open(self.filename, u'r')
|
||||
@ -151,11 +151,11 @@ class OSISBible(BibleDB):
|
||||
book_ref_id,
|
||||
book_details[u'testament_id'])
|
||||
if last_chapter == 0:
|
||||
self.wizard.progressBar.setMaximum(chapter_count)
|
||||
self.wizard.progress_bar.setMaximum(chapter_count)
|
||||
if last_chapter != chapter:
|
||||
if last_chapter != 0:
|
||||
self.session.commit()
|
||||
self.wizard.incrementProgressBar(translate('BiblesPlugin.OsisImport', 'Importing %s %s...',
|
||||
self.wizard.increment_progress_bar(translate('BiblesPlugin.OsisImport', 'Importing %s %s...',
|
||||
'Importing <book name> <chapter>...') % (book_details[u'name'], chapter))
|
||||
last_chapter = chapter
|
||||
# All of this rigmarol below is because the mod2osis
|
||||
|
@ -53,10 +53,10 @@ class ImageTab(SettingsTab):
|
||||
self.backgroundColorButton.setObjectName(u'BackgroundColorButton')
|
||||
self.colorLayout.addWidget(self.backgroundColorButton)
|
||||
self.formLayout.addRow(self.colorLayout)
|
||||
self.informationLabel = QtGui.QLabel(self.bgColorGroupBox)
|
||||
self.informationLabel.setObjectName(u'InformationLabel')
|
||||
self.informationLabel.setWordWrap(True)
|
||||
self.formLayout.addRow(self.informationLabel)
|
||||
self.information_label = QtGui.QLabel(self.bgColorGroupBox)
|
||||
self.information_label.setObjectName(u'information_label')
|
||||
self.information_label.setWordWrap(True)
|
||||
self.formLayout.addRow(self.information_label)
|
||||
self.leftLayout.addWidget(self.bgColorGroupBox)
|
||||
self.leftLayout.addStretch()
|
||||
self.rightColumn.setSizePolicy(QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Preferred)
|
||||
@ -68,7 +68,7 @@ class ImageTab(SettingsTab):
|
||||
def retranslateUi(self):
|
||||
self.bgColorGroupBox.setTitle(UiStrings().BackgroundColor)
|
||||
self.backgroundColorLabel.setText(UiStrings().DefaultColor)
|
||||
self.informationLabel.setText(
|
||||
self.information_label.setText(
|
||||
translate('ImagesPlugin.ImageTab', 'Visible background for images with aspect ratio different to screen.'))
|
||||
|
||||
def onbackgroundColorButtonClicked(self):
|
||||
|
@ -105,7 +105,7 @@ class ImageMediaItem(MediaManagerItem):
|
||||
if text:
|
||||
delete_file(os.path.join(self.servicePath, text.text()))
|
||||
self.listView.takeItem(row)
|
||||
self.main_window.incrementProgressBar()
|
||||
self.main_window.increment_progress_bar()
|
||||
Settings.setValue(self.settingsSection + u'/images files', self.getFileList())
|
||||
self.main_window.finishedProgressBar()
|
||||
self.application.set_normal_cursor()
|
||||
@ -134,7 +134,7 @@ class ImageMediaItem(MediaManagerItem):
|
||||
item_name.setData(QtCore.Qt.UserRole, imageFile)
|
||||
self.listView.addItem(item_name)
|
||||
if not initialLoad:
|
||||
self.main_window.incrementProgressBar()
|
||||
self.main_window.increment_progress_bar()
|
||||
if not initialLoad:
|
||||
self.main_window.finishedProgressBar()
|
||||
self.application.set_normal_cursor()
|
||||
|
@ -157,7 +157,7 @@ class PresentationMediaItem(MediaManagerItem):
|
||||
key=lambda filename: os.path.split(unicode(filename))[1])
|
||||
for file in files:
|
||||
if not initialLoad:
|
||||
self.main_window.incrementProgressBar()
|
||||
self.main_window.increment_progress_bar()
|
||||
if currlist.count(file) > 0:
|
||||
continue
|
||||
filename = os.path.split(unicode(file))[1]
|
||||
@ -224,7 +224,7 @@ class PresentationMediaItem(MediaManagerItem):
|
||||
doc = self.controllers[cidx].add_document(filepath)
|
||||
doc.presentation_deleted()
|
||||
doc.close_presentation()
|
||||
self.main_window.incrementProgressBar()
|
||||
self.main_window.increment_progress_bar()
|
||||
self.main_window.finishedProgressBar()
|
||||
self.application.set_busy_cursor()
|
||||
for row in row_list:
|
||||
|
@ -50,19 +50,19 @@ class Ui_EditSongDialog(object):
|
||||
self.lyricsTab.setObjectName(u'lyricsTab')
|
||||
self.lyricsTabLayout = QtGui.QGridLayout(self.lyricsTab)
|
||||
self.lyricsTabLayout.setObjectName(u'lyricsTabLayout')
|
||||
self.titleLabel = QtGui.QLabel(self.lyricsTab)
|
||||
self.titleLabel.setObjectName(u'titleLabel')
|
||||
self.lyricsTabLayout.addWidget(self.titleLabel, 0, 0)
|
||||
self.title_label = QtGui.QLabel(self.lyricsTab)
|
||||
self.title_label.setObjectName(u'title_label')
|
||||
self.lyricsTabLayout.addWidget(self.title_label, 0, 0)
|
||||
self.titleEdit = QtGui.QLineEdit(self.lyricsTab)
|
||||
self.titleEdit.setObjectName(u'titleEdit')
|
||||
self.titleLabel.setBuddy(self.titleEdit)
|
||||
self.title_label.setBuddy(self.titleEdit)
|
||||
self.lyricsTabLayout.addWidget(self.titleEdit, 0, 1, 1, 2)
|
||||
self.alternativeTitleLabel = QtGui.QLabel(self.lyricsTab)
|
||||
self.alternativeTitleLabel.setObjectName(u'alternativeTitleLabel')
|
||||
self.lyricsTabLayout.addWidget(self.alternativeTitleLabel, 1, 0)
|
||||
self.alternativetitle_label = QtGui.QLabel(self.lyricsTab)
|
||||
self.alternativetitle_label.setObjectName(u'alternativetitle_label')
|
||||
self.lyricsTabLayout.addWidget(self.alternativetitle_label, 1, 0)
|
||||
self.alternativeEdit = QtGui.QLineEdit(self.lyricsTab)
|
||||
self.alternativeEdit.setObjectName(u'alternativeEdit')
|
||||
self.alternativeTitleLabel.setBuddy(self.alternativeEdit)
|
||||
self.alternativetitle_label.setBuddy(self.alternativeEdit)
|
||||
self.lyricsTabLayout.addWidget(self.alternativeEdit, 1, 1, 1, 2)
|
||||
self.lyricsLabel = QtGui.QLabel(self.lyricsTab)
|
||||
self.lyricsLabel.setFixedHeight(self.titleEdit.sizeHint().height())
|
||||
@ -279,8 +279,8 @@ class Ui_EditSongDialog(object):
|
||||
|
||||
def retranslateUi(self, editSongDialog):
|
||||
editSongDialog.setWindowTitle(translate('SongsPlugin.EditSongForm', 'Song Editor'))
|
||||
self.titleLabel.setText(translate('SongsPlugin.EditSongForm', '&Title:'))
|
||||
self.alternativeTitleLabel.setText(translate('SongsPlugin.EditSongForm', 'Alt&ernate title:'))
|
||||
self.title_label.setText(translate('SongsPlugin.EditSongForm', '&Title:'))
|
||||
self.alternativetitle_label.setText(translate('SongsPlugin.EditSongForm', 'Alt&ernate title:'))
|
||||
self.lyricsLabel.setText(translate('SongsPlugin.EditSongForm', '&Lyrics:'))
|
||||
self.verseOrderLabel.setText(translate('SongsPlugin.EditSongForm', '&Verse order:'))
|
||||
self.verseAddButton.setText(UiStrings().Add)
|
||||
|
@ -159,9 +159,9 @@ class SongExportForm(OpenLPWizard):
|
||||
Song wizard localisation.
|
||||
"""
|
||||
self.setWindowTitle(translate('SongsPlugin.ExportWizardForm', 'Song Export Wizard'))
|
||||
self.titleLabel.setText(WizardStrings.HeaderStyle %
|
||||
self.title_label.setText(WizardStrings.HeaderStyle %
|
||||
translate('OpenLP.Ui', 'Welcome to the Song Export Wizard'))
|
||||
self.informationLabel.setText(translate('SongsPlugin.ExportWizardForm', 'This wizard will help to'
|
||||
self.information_label.setText(translate('SongsPlugin.ExportWizardForm', 'This wizard will help to'
|
||||
' export your songs to the open and free <strong>OpenLyrics </strong> worship song format.'))
|
||||
self.availableSongsPage.setTitle(translate('SongsPlugin.ExportWizardForm', 'Select Songs'))
|
||||
self.availableSongsPage.setSubTitle(translate('SongsPlugin.ExportWizardForm',
|
||||
@ -173,17 +173,17 @@ class SongExportForm(OpenLPWizard):
|
||||
self.exportSongPage.setSubTitle(translate('SongsPlugin.ExportWizardForm',
|
||||
'Select the directory where you want the songs to be saved.'))
|
||||
self.directoryLabel.setText(translate('SongsPlugin.ExportWizardForm', 'Directory:'))
|
||||
self.progressPage.setTitle(translate('SongsPlugin.ExportWizardForm', 'Exporting'))
|
||||
self.progressPage.setSubTitle(translate('SongsPlugin.ExportWizardForm',
|
||||
self.progress_page.setTitle(translate('SongsPlugin.ExportWizardForm', 'Exporting'))
|
||||
self.progress_page.setSubTitle(translate('SongsPlugin.ExportWizardForm',
|
||||
'Please wait while your songs are exported.'))
|
||||
self.progressLabel.setText(WizardStrings.Ready)
|
||||
self.progressBar.setFormat(WizardStrings.PercentSymbolFormat)
|
||||
self.progress_label.setText(WizardStrings.Ready)
|
||||
self.progress_bar.setFormat(WizardStrings.PercentSymbolFormat)
|
||||
|
||||
def validateCurrentPage(self):
|
||||
"""
|
||||
Validate the current page before moving on to the next page.
|
||||
"""
|
||||
if self.currentPage() == self.welcomePage:
|
||||
if self.currentPage() == self.welcome_page:
|
||||
return True
|
||||
elif self.currentPage() == self.availableSongsPage:
|
||||
items = [
|
||||
@ -209,7 +209,7 @@ class SongExportForm(OpenLPWizard):
|
||||
translate('SongsPlugin.ExportWizardForm', 'You need to specify a directory.'))
|
||||
return False
|
||||
return True
|
||||
elif self.currentPage() == self.progressPage:
|
||||
elif self.currentPage() == self.progress_page:
|
||||
self.availableListWidget.clear()
|
||||
self.selectedListWidget.clear()
|
||||
return True
|
||||
@ -219,8 +219,8 @@ class SongExportForm(OpenLPWizard):
|
||||
Set default form values for the song export wizard.
|
||||
"""
|
||||
self.restart()
|
||||
self.finishButton.setVisible(False)
|
||||
self.cancelButton.setVisible(True)
|
||||
self.finish_button.setVisible(False)
|
||||
self.cancel_button.setVisible(True)
|
||||
self.availableListWidget.clear()
|
||||
self.selectedListWidget.clear()
|
||||
self.directoryLineEdit.clear()
|
||||
@ -246,8 +246,8 @@ class SongExportForm(OpenLPWizard):
|
||||
"""
|
||||
Perform pre export tasks.
|
||||
"""
|
||||
OpenLPWizard.preWizard(self)
|
||||
self.progressLabel.setText(translate('SongsPlugin.ExportWizardForm', 'Starting export...'))
|
||||
OpenLPWizard.pre_wizard(self)
|
||||
self.progress_label.setText(translate('SongsPlugin.ExportWizardForm', 'Starting export...'))
|
||||
self.application.process_events()
|
||||
|
||||
def performWizard(self):
|
||||
@ -261,10 +261,10 @@ class SongExportForm(OpenLPWizard):
|
||||
]
|
||||
exporter = OpenLyricsExport(self, songs, self.directoryLineEdit.text())
|
||||
if exporter.do_export():
|
||||
self.progressLabel.setText(translate('SongsPlugin.SongExportForm',
|
||||
self.progress_label.setText(translate('SongsPlugin.SongExportForm',
|
||||
'Finished export. To import these files use the <strong>OpenLyrics</strong> importer.'))
|
||||
else:
|
||||
self.progressLabel.setText(translate('SongsPlugin.SongExportForm', 'Your song export failed.'))
|
||||
self.progress_label.setText(translate('SongsPlugin.SongExportForm', 'Your song export failed.'))
|
||||
|
||||
def _findListWidgetItems(self, listWidget, text=u''):
|
||||
"""
|
||||
@ -331,5 +331,5 @@ class SongExportForm(OpenLPWizard):
|
||||
Called when the *directoryButton* was clicked. Opens a dialog and writes
|
||||
the path to *directoryLineEdit*.
|
||||
"""
|
||||
self.getFolder(translate('SongsPlugin.ExportWizardForm', 'Select Destination Folder'),
|
||||
self.get_folder(translate('SongsPlugin.ExportWizardForm', 'Select Destination Folder'),
|
||||
self.directoryLineEdit, u'last directory export')
|
||||
|
@ -67,20 +67,19 @@ class SongImportForm(OpenLPWizard):
|
||||
"""
|
||||
Set up the song wizard UI.
|
||||
"""
|
||||
self.formatWidgets = dict([(format, {}) for format in SongFormat.get_format_list()])
|
||||
self.format_widgets = dict([(format, {}) for format in SongFormat.get_format_list()])
|
||||
OpenLPWizard.setupUi(self, image)
|
||||
self.currentFormat = SongFormat.OpenLyrics
|
||||
self.formatStack.setCurrentIndex(self.currentFormat)
|
||||
QtCore.QObject.connect(self.formatComboBox, QtCore.SIGNAL(u'currentIndexChanged(int)'),
|
||||
self.onCurrentIndexChanged)
|
||||
self.current_format = SongFormat.OpenLyrics
|
||||
self.format_stack.setCurrentIndex(self.current_format)
|
||||
self.format_combo_box.currentIndexChanged.connect(self.onCurrentIndexChanged)
|
||||
|
||||
def onCurrentIndexChanged(self, index):
|
||||
"""
|
||||
Called when the format combo box's index changed.
|
||||
"""
|
||||
self.currentFormat = index
|
||||
self.formatStack.setCurrentIndex(index)
|
||||
self.sourcePage.emit(QtCore.SIGNAL(u'completeChanged()'))
|
||||
self.current_format = index
|
||||
self.format_stack.setCurrentIndex(index)
|
||||
self.source_page.emit(QtCore.SIGNAL(u'completeChanged()'))
|
||||
|
||||
def customInit(self):
|
||||
"""
|
||||
@ -88,8 +87,8 @@ class SongImportForm(OpenLPWizard):
|
||||
"""
|
||||
for format in SongFormat.get_format_list():
|
||||
if not SongFormat.get(format, u'availability'):
|
||||
self.formatWidgets[format][u'disabledWidget'].setVisible(True)
|
||||
self.formatWidgets[format][u'importWidget'].setVisible(False)
|
||||
self.format_widgets[format][u'disabled_widget'].setVisible(True)
|
||||
self.format_widgets[format][u'import_widget'].setVisible(False)
|
||||
|
||||
def customSignals(self):
|
||||
"""
|
||||
@ -98,94 +97,90 @@ class SongImportForm(OpenLPWizard):
|
||||
for format in SongFormat.get_format_list():
|
||||
select_mode = SongFormat.get(format, u'selectMode')
|
||||
if select_mode == SongFormatSelect.MultipleFiles:
|
||||
QtCore.QObject.connect(self.formatWidgets[format][u'addButton'],
|
||||
QtCore.SIGNAL(u'clicked()'), self.onAddButtonClicked)
|
||||
QtCore.QObject.connect(self.formatWidgets[format][u'removeButton'],
|
||||
QtCore.SIGNAL(u'clicked()'), self.onRemoveButtonClicked)
|
||||
self.format_widgets[format][u'addButton'].clicked.connect(self.on_add_button_clicked)
|
||||
self.format_widgets[format][u'removeButton'].clicked.connect(self.onRemoveButtonClicked)
|
||||
else:
|
||||
QtCore.QObject.connect(self.formatWidgets[format][u'browseButton'],
|
||||
QtCore.SIGNAL(u'clicked()'), self.onBrowseButtonClicked)
|
||||
QtCore.QObject.connect(self.formatWidgets[format][u'filepathEdit'],
|
||||
QtCore.SIGNAL(u'textChanged (const QString&)'), self.onFilepathEditTextChanged)
|
||||
self.format_widgets[format][u'browseButton'].clicked.connect(self.on_browse_button_clicked)
|
||||
self.format_widgets[format][u'file_path_edit'].textChanged.connect(self.onFilepathEditTextChanged)
|
||||
|
||||
def addCustomPages(self):
|
||||
"""
|
||||
Add song wizard specific pages.
|
||||
"""
|
||||
# Source Page
|
||||
self.sourcePage = SongImportSourcePage()
|
||||
self.sourcePage.setObjectName(u'SourcePage')
|
||||
self.sourceLayout = QtGui.QVBoxLayout(self.sourcePage)
|
||||
self.sourceLayout.setObjectName(u'SourceLayout')
|
||||
self.formatLayout = QtGui.QFormLayout()
|
||||
self.formatLayout.setObjectName(u'FormatLayout')
|
||||
self.formatLabel = QtGui.QLabel(self.sourcePage)
|
||||
self.formatLabel.setObjectName(u'FormatLabel')
|
||||
self.formatComboBox = QtGui.QComboBox(self.sourcePage)
|
||||
self.formatComboBox.setObjectName(u'FormatComboBox')
|
||||
self.formatLayout.addRow(self.formatLabel, self.formatComboBox)
|
||||
self.formatSpacer = QtGui.QSpacerItem(10, 0, QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Minimum)
|
||||
self.formatLayout.setItem(1, QtGui.QFormLayout.LabelRole, self.formatSpacer)
|
||||
self.sourceLayout.addLayout(self.formatLayout)
|
||||
self.formatHSpacing = self.formatLayout.horizontalSpacing()
|
||||
self.formatVSpacing = self.formatLayout.verticalSpacing()
|
||||
self.formatLayout.setVerticalSpacing(0)
|
||||
self.stackSpacer = QtGui.QSpacerItem(10, 0, QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Expanding)
|
||||
self.formatStack = QtGui.QStackedLayout()
|
||||
self.formatStack.setObjectName(u'FormatStack')
|
||||
self.disablableFormats = []
|
||||
for self.currentFormat in SongFormat.get_format_list():
|
||||
self.source_page = SongImportSourcePage()
|
||||
self.source_page.setObjectName(u'SourcePage')
|
||||
self.source_layout = QtGui.QVBoxLayout(self.source_page)
|
||||
self.source_layout.setObjectName(u'SourceLayout')
|
||||
self.format_layout = QtGui.QFormLayout()
|
||||
self.format_layout.setObjectName(u'FormatLayout')
|
||||
self.format_label = QtGui.QLabel(self.source_page)
|
||||
self.format_label.setObjectName(u'FormatLabel')
|
||||
self.format_combo_box = QtGui.QComboBox(self.source_page)
|
||||
self.format_combo_box.setObjectName(u'FormatComboBox')
|
||||
self.format_layout.addRow(self.format_label, self.format_combo_box)
|
||||
self.format_spacer = QtGui.QSpacerItem(10, 0, QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Minimum)
|
||||
self.format_layout.setItem(1, QtGui.QFormLayout.LabelRole, self.format_spacer)
|
||||
self.source_layout.addLayout(self.format_layout)
|
||||
self.format_h_spacing = self.format_layout.horizontalSpacing()
|
||||
self.format_v_spacing = self.format_layout.verticalSpacing()
|
||||
self.format_layout.setVerticalSpacing(0)
|
||||
self.stack_spacer = QtGui.QSpacerItem(10, 0, QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Expanding)
|
||||
self.format_stack = QtGui.QStackedLayout()
|
||||
self.format_stack.setObjectName(u'FormatStack')
|
||||
self.disablable_formats = []
|
||||
for self.current_format in SongFormat.get_format_list():
|
||||
self.addFileSelectItem()
|
||||
self.sourceLayout.addLayout(self.formatStack)
|
||||
self.addPage(self.sourcePage)
|
||||
self.source_layout.addLayout(self.format_stack)
|
||||
self.addPage(self.source_page)
|
||||
|
||||
def retranslateUi(self):
|
||||
"""
|
||||
Song wizard localisation.
|
||||
"""
|
||||
self.setWindowTitle(translate('SongsPlugin.ImportWizardForm', 'Song Import Wizard'))
|
||||
self.titleLabel.setText(WizardStrings.HeaderStyle % translate('OpenLP.Ui', 'Welcome to the Song Import Wizard'))
|
||||
self.informationLabel.setText(translate('SongsPlugin.ImportWizardForm',
|
||||
self.title_label.setText(WizardStrings.HeaderStyle % translate('OpenLP.Ui', 'Welcome to the Song Import Wizard'))
|
||||
self.information_label.setText(translate('SongsPlugin.ImportWizardForm',
|
||||
'This wizard will help you to import songs from a variety of '
|
||||
'formats. Click the next button below to start the process by selecting a format to import from.'))
|
||||
self.sourcePage.setTitle(WizardStrings.ImportSelect)
|
||||
self.sourcePage.setSubTitle(WizardStrings.ImportSelectLong)
|
||||
self.formatLabel.setText(WizardStrings.FormatLabel)
|
||||
self.source_page.setTitle(WizardStrings.ImportSelect)
|
||||
self.source_page.setSubTitle(WizardStrings.ImportSelectLong)
|
||||
self.format_label.setText(WizardStrings.FormatLabel)
|
||||
for format in SongFormat.get_format_list():
|
||||
format_name, custom_combo_text, description_text, select_mode = \
|
||||
SongFormat.get(format, u'name', u'comboBoxText', u'descriptionText', u'selectMode')
|
||||
combo_box_text = (custom_combo_text if custom_combo_text else format_name)
|
||||
self.formatComboBox.setItemText(format, combo_box_text)
|
||||
self.format_combo_box.setItemText(format, combo_box_text)
|
||||
if description_text is not None:
|
||||
self.formatWidgets[format][u'description_label'].setText(description_text)
|
||||
self.format_widgets[format][u'description_label'].setText(description_text)
|
||||
if select_mode == SongFormatSelect.MultipleFiles:
|
||||
self.formatWidgets[format][u'addButton'].setText(
|
||||
self.format_widgets[format][u'addButton'].setText(
|
||||
translate('SongsPlugin.ImportWizardForm', 'Add Files...'))
|
||||
self.formatWidgets[format][u'removeButton'].setText(
|
||||
self.format_widgets[format][u'removeButton'].setText(
|
||||
translate('SongsPlugin.ImportWizardForm', 'Remove File(s)'))
|
||||
else:
|
||||
self.formatWidgets[format][u'browseButton'].setText(UiStrings().Browse)
|
||||
self.format_widgets[format][u'browseButton'].setText(UiStrings().Browse)
|
||||
f_label = 'Filename:'
|
||||
if select_mode == SongFormatSelect.SingleFolder:
|
||||
f_label = 'Folder:'
|
||||
self.formatWidgets[format][u'filepathLabel'].setText(translate('SongsPlugin.ImportWizardForm', f_label))
|
||||
for format in self.disablableFormats:
|
||||
self.formatWidgets[format][u'disabledLabel'].setText(SongFormat.get(format, u'disabledLabelText'))
|
||||
self.progressPage.setTitle(WizardStrings.Importing)
|
||||
self.progressPage.setSubTitle(
|
||||
self.format_widgets[format][u'filepathLabel'].setText(translate('SongsPlugin.ImportWizardForm', f_label))
|
||||
for format in self.disablable_formats:
|
||||
self.format_widgets[format][u'disabled_label'].setText(SongFormat.get(format, u'disabledLabelText'))
|
||||
self.progress_page.setTitle(WizardStrings.Importing)
|
||||
self.progress_page.setSubTitle(
|
||||
translate('SongsPlugin.ImportWizardForm', 'Please wait while your songs are imported.'))
|
||||
self.progressLabel.setText(WizardStrings.Ready)
|
||||
self.progressBar.setFormat(WizardStrings.PercentSymbolFormat)
|
||||
self.errorCopyToButton.setText(translate('SongsPlugin.ImportWizardForm', 'Copy'))
|
||||
self.errorSaveToButton.setText(translate('SongsPlugin.ImportWizardForm', 'Save to File'))
|
||||
self.progress_label.setText(WizardStrings.Ready)
|
||||
self.progress_bar.setFormat(WizardStrings.PercentSymbolFormat)
|
||||
self.error_copy_to_button.setText(translate('SongsPlugin.ImportWizardForm', 'Copy'))
|
||||
self.error_save_to_button.setText(translate('SongsPlugin.ImportWizardForm', 'Save to File'))
|
||||
# Align all QFormLayouts towards each other.
|
||||
formats = filter(lambda f: u'filepathLabel' in self.formatWidgets[f], SongFormat.get_format_list())
|
||||
labels = [self.formatWidgets[f][u'filepathLabel'] for f in formats]
|
||||
formats = filter(lambda f: u'filepathLabel' in self.format_widgets[f], SongFormat.get_format_list())
|
||||
labels = [self.format_widgets[f][u'filepathLabel'] for f in formats]
|
||||
# Get max width of all labels
|
||||
max_label_width = max(self.formatLabel.minimumSizeHint().width(),
|
||||
max_label_width = max(self.format_label.minimumSizeHint().width(),
|
||||
max([label.minimumSizeHint().width() for label in labels]))
|
||||
self.formatSpacer.changeSize(max_label_width, 0, QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Fixed)
|
||||
spacers = [self.formatWidgets[f][u'filepathSpacer'] for f in formats]
|
||||
self.format_spacer.changeSize(max_label_width, 0, QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Fixed)
|
||||
spacers = [self.format_widgets[f][u'filepathSpacer'] for f in formats]
|
||||
for index, spacer in enumerate(spacers):
|
||||
spacer.changeSize(
|
||||
max_label_width - labels[index].minimumSizeHint().width(), 0,
|
||||
@ -193,45 +188,44 @@ class SongImportForm(OpenLPWizard):
|
||||
# Align descriptionLabels with rest of layout
|
||||
for format in SongFormat.get_format_list():
|
||||
if SongFormat.get(format, u'descriptionText') is not None:
|
||||
self.formatWidgets[format][u'descriptionSpacer'].changeSize(
|
||||
max_label_width + self.formatHSpacing, 0, QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Fixed)
|
||||
self.format_widgets[format][u'descriptionSpacer'].changeSize(
|
||||
max_label_width + self.format_h_spacing, 0, QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Fixed)
|
||||
|
||||
def customPageChanged(self, pageId):
|
||||
def custom_page_changed(self, page_id):
|
||||
"""
|
||||
Called when changing to a page other than the progress page.
|
||||
"""
|
||||
if self.page(pageId) == self.sourcePage:
|
||||
self.onCurrentIndexChanged(self.formatStack.currentIndex())
|
||||
if self.page(page_id) == self.source_page:
|
||||
self.onCurrentIndexChanged(self.format_stack.currentIndex())
|
||||
|
||||
def validateCurrentPage(self):
|
||||
"""
|
||||
Validate the current page before moving on to the next page.
|
||||
Provide each song format class with a chance to validate its input by
|
||||
overriding isValidSource().
|
||||
Re-implement te validateCurrentPage() method. Validate the current page before moving on to the next page.
|
||||
Provide each song format class with a chance to validate its input by overriding isValidSource().
|
||||
"""
|
||||
if self.currentPage() == self.welcomePage:
|
||||
if self.currentPage() == self.welcome_page:
|
||||
return True
|
||||
elif self.currentPage() == self.sourcePage:
|
||||
this_format = self.currentFormat
|
||||
elif self.currentPage() == self.source_page:
|
||||
this_format = self.current_format
|
||||
Settings().setValue(u'songs/last import type', this_format)
|
||||
select_mode, class_, error_msg = SongFormat.get(this_format, u'selectMode', u'class', u'invalidSourceMsg')
|
||||
if select_mode == SongFormatSelect.MultipleFiles:
|
||||
import_source = self.getListOfFiles(self.formatWidgets[this_format][u'fileListWidget'])
|
||||
import_source = self.get_list_of_files(self.format_widgets[this_format][u'fileListWidget'])
|
||||
error_title = UiStrings().IFSp
|
||||
focus_button = self.formatWidgets[this_format][u'addButton']
|
||||
focus_button = self.format_widgets[this_format][u'addButton']
|
||||
else:
|
||||
import_source = self.formatWidgets[this_format][u'filepathEdit'].text()
|
||||
import_source = self.format_widgets[this_format][u'file_path_edit'].text()
|
||||
error_title = (UiStrings().IFSs if select_mode == SongFormatSelect.SingleFile else UiStrings().IFdSs)
|
||||
focus_button = self.formatWidgets[this_format][u'browseButton']
|
||||
focus_button = self.format_widgets[this_format][u'browseButton']
|
||||
if not class_.isValidSource(import_source):
|
||||
critical_error_message_box(error_title, error_msg)
|
||||
focus_button.setFocus()
|
||||
return False
|
||||
return True
|
||||
elif self.currentPage() == self.progressPage:
|
||||
elif self.currentPage() == self.progress_page:
|
||||
return True
|
||||
|
||||
def getFiles(self, title, listbox, filters=u''):
|
||||
def get_files(self, title, listbox, filters=u''):
|
||||
"""
|
||||
Opens a QFileDialog and writes the filenames to the given listbox.
|
||||
|
||||
@ -257,88 +251,86 @@ class SongImportForm(OpenLPWizard):
|
||||
Settings().setValue(self.plugin.settingsSection + u'/last directory import',
|
||||
os.path.split(unicode(filenames[0]))[0])
|
||||
|
||||
def getListOfFiles(self, listbox):
|
||||
def get_list_of_files(self, listbox):
|
||||
"""
|
||||
Return a list of file from the listbox
|
||||
"""
|
||||
return [listbox.item(i).text() for i in range(listbox.count())]
|
||||
|
||||
def removeSelectedItems(self, listbox):
|
||||
def remove_selected_items(self, list_box):
|
||||
"""
|
||||
Remove selected listbox items
|
||||
Remove selected list_box items
|
||||
"""
|
||||
for item in listbox.selectedItems():
|
||||
item = listbox.takeItem(listbox.row(item))
|
||||
for item in list_box.selectedItems():
|
||||
item = list_box.takeItem(list_box.row(item))
|
||||
del item
|
||||
|
||||
def onBrowseButtonClicked(self):
|
||||
def on_browse_button_clicked(self):
|
||||
"""
|
||||
Browse for files or a directory.
|
||||
"""
|
||||
this_format = self.currentFormat
|
||||
select_mode, format_name, ext_filter = SongFormat.get(this_format, u'selectMode',
|
||||
u'name', u'filter')
|
||||
filepathEdit = self.formatWidgets[this_format][u'filepathEdit']
|
||||
this_format = self.current_format
|
||||
select_mode, format_name, ext_filter = SongFormat.get(this_format, u'selectMode', u'name', u'filter')
|
||||
file_path_edit = self.format_widgets[this_format][u'file_path_edit']
|
||||
if select_mode == SongFormatSelect.SingleFile:
|
||||
self.getFileName(WizardStrings.OpenTypeFile % format_name, filepathEdit,
|
||||
u'last directory import', ext_filter)
|
||||
self.get_file_name(
|
||||
WizardStrings.OpenTypeFile % format_name, file_path_edit, u'last directory import', ext_filter)
|
||||
elif select_mode == SongFormatSelect.SingleFolder:
|
||||
self.getFolder(WizardStrings.OpenTypeFolder % format_name, filepathEdit, u'last directory import')
|
||||
self.get_folder(WizardStrings.OpenTypeFolder % format_name, file_path_edit, u'last directory import')
|
||||
|
||||
def onAddButtonClicked(self):
|
||||
def on_add_button_clicked(self):
|
||||
"""
|
||||
Add a file or directory.
|
||||
"""
|
||||
this_format = self.currentFormat
|
||||
this_format = self.current_format
|
||||
select_mode, format_name, ext_filter, custom_title = \
|
||||
SongFormat.get(this_format, u'selectMode', u'name', u'filter', u'getFilesTitle')
|
||||
title = custom_title if custom_title else WizardStrings.OpenTypeFile % format_name
|
||||
if select_mode == SongFormatSelect.MultipleFiles:
|
||||
self.getFiles(title, self.formatWidgets[this_format][u'fileListWidget'], ext_filter)
|
||||
self.sourcePage.emit(QtCore.SIGNAL(u'completeChanged()'))
|
||||
self.get_files(title, self.format_widgets[this_format][u'fileListWidget'], ext_filter)
|
||||
self.source_page.emit(QtCore.SIGNAL(u'completeChanged()'))
|
||||
|
||||
def onRemoveButtonClicked(self):
|
||||
"""
|
||||
Remove a file from the list.
|
||||
"""
|
||||
self.removeSelectedItems(
|
||||
self.formatWidgets[self.currentFormat][u'fileListWidget'])
|
||||
self.sourcePage.emit(QtCore.SIGNAL(u'completeChanged()'))
|
||||
self.remove_selected_items(self.format_widgets[self.current_format][u'fileListWidget'])
|
||||
self.source_page.emit(QtCore.SIGNAL(u'completeChanged()'))
|
||||
|
||||
def onFilepathEditTextChanged(self):
|
||||
"""
|
||||
Called when the content of the Filename/Folder edit box changes.
|
||||
"""
|
||||
self.sourcePage.emit(QtCore.SIGNAL(u'completeChanged()'))
|
||||
self.source_page.emit(QtCore.SIGNAL(u'completeChanged()'))
|
||||
|
||||
def setDefaults(self):
|
||||
"""
|
||||
Set default form values for the song import wizard.
|
||||
"""
|
||||
self.restart()
|
||||
self.finishButton.setVisible(False)
|
||||
self.cancelButton.setVisible(True)
|
||||
self.finish_button.setVisible(False)
|
||||
self.cancel_button.setVisible(True)
|
||||
last_import_type = Settings().value(u'songs/last import type')
|
||||
if last_import_type < 0 or last_import_type >= self.formatComboBox.count():
|
||||
if last_import_type < 0 or last_import_type >= self.format_combo_box.count():
|
||||
last_import_type = 0
|
||||
self.formatComboBox.setCurrentIndex(last_import_type)
|
||||
self.format_combo_box.setCurrentIndex(last_import_type)
|
||||
for format in SongFormat.get_format_list():
|
||||
select_mode = SongFormat.get(format, u'selectMode')
|
||||
if select_mode == SongFormatSelect.MultipleFiles:
|
||||
self.formatWidgets[format][u'fileListWidget'].clear()
|
||||
self.format_widgets[format][u'fileListWidget'].clear()
|
||||
else:
|
||||
self.formatWidgets[format][u'filepathEdit'].setText(u'')
|
||||
self.errorReportTextEdit.clear()
|
||||
self.errorReportTextEdit.setHidden(True)
|
||||
self.errorCopyToButton.setHidden(True)
|
||||
self.errorSaveToButton.setHidden(True)
|
||||
self.format_widgets[format][u'file_path_edit'].setText(u'')
|
||||
self.error_report_text_edit.clear()
|
||||
self.error_report_text_edit.setHidden(True)
|
||||
self.error_copy_to_button.setHidden(True)
|
||||
self.error_save_to_button.setHidden(True)
|
||||
|
||||
def preWizard(self):
|
||||
"""
|
||||
Perform pre import tasks
|
||||
"""
|
||||
OpenLPWizard.preWizard(self)
|
||||
self.progressLabel.setText(WizardStrings.StartingImport)
|
||||
OpenLPWizard.pre_wizard(self)
|
||||
self.progress_label.setText(WizardStrings.StartingImport)
|
||||
self.application.process_events()
|
||||
|
||||
def performWizard(self):
|
||||
@ -347,25 +339,25 @@ class SongImportForm(OpenLPWizard):
|
||||
class, and then runs the ``doImport`` method of the importer to do
|
||||
the actual importing.
|
||||
"""
|
||||
source_format = self.currentFormat
|
||||
source_format = self.current_format
|
||||
select_mode = SongFormat.get(source_format, u'selectMode')
|
||||
if select_mode == SongFormatSelect.SingleFile:
|
||||
importer = self.plugin.importSongs(source_format,
|
||||
filename=self.formatWidgets[source_format][u'filepathEdit'].text())
|
||||
filename=self.format_widgets[source_format][u'file_path_edit'].text())
|
||||
elif select_mode == SongFormatSelect.SingleFolder:
|
||||
importer = self.plugin.importSongs(source_format,
|
||||
folder=self.formatWidgets[source_format][u'filepathEdit'].text())
|
||||
folder=self.format_widgets[source_format][u'file_path_edit'].text())
|
||||
else:
|
||||
importer = self.plugin.importSongs(source_format,
|
||||
filenames=self.getListOfFiles(self.formatWidgets[source_format][u'fileListWidget']))
|
||||
filenames=self.get_list_of_files(self.format_widgets[source_format][u'fileListWidget']))
|
||||
importer.doImport()
|
||||
self.progressLabel.setText(WizardStrings.FinishedImport)
|
||||
self.progress_label.setText(WizardStrings.FinishedImport)
|
||||
|
||||
def onErrorCopyToButtonClicked(self):
|
||||
"""
|
||||
Copy the error report to the clipboard.
|
||||
"""
|
||||
self.clipboard.setText(self.errorReportTextEdit.toPlainText())
|
||||
self.clipboard.setText(self.error_report_text_edit.toPlainText())
|
||||
|
||||
def onErrorSaveToButtonClicked(self):
|
||||
"""
|
||||
@ -376,14 +368,14 @@ class SongImportForm(OpenLPWizard):
|
||||
if not filename:
|
||||
return
|
||||
report_file = codecs.open(filename, u'w', u'utf-8')
|
||||
report_file.write(self.errorReportTextEdit.toPlainText())
|
||||
report_file.write(self.error_report_text_edit.toPlainText())
|
||||
report_file.close()
|
||||
|
||||
def addFileSelectItem(self):
|
||||
"""
|
||||
Add a file selection page.
|
||||
"""
|
||||
this_format = self.currentFormat
|
||||
this_format = self.current_format
|
||||
prefix, can_disable, description_text, select_mode = \
|
||||
SongFormat.get(this_format, u'prefix', u'canDisable', u'descriptionText', u'selectMode')
|
||||
page = QtGui.QWidget()
|
||||
@ -400,94 +392,94 @@ class SongImportForm(OpenLPWizard):
|
||||
descriptionLayout.setObjectName(prefix + u'DescriptionLayout')
|
||||
descriptionSpacer = QtGui.QSpacerItem(0, 0, QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Fixed)
|
||||
descriptionLayout.addSpacerItem(descriptionSpacer)
|
||||
descriptionLabel = QtGui.QLabel(importWidget)
|
||||
descriptionLabel.setWordWrap(True)
|
||||
descriptionLabel.setOpenExternalLinks(True)
|
||||
descriptionLabel.setObjectName(prefix + u'DescriptionLabel')
|
||||
descriptionLayout.addWidget(descriptionLabel)
|
||||
description_label = QtGui.QLabel(importWidget)
|
||||
description_label.setWordWrap(True)
|
||||
description_label.setOpenExternalLinks(True)
|
||||
description_label.setObjectName(prefix + u'DescriptionLabel')
|
||||
descriptionLayout.addWidget(description_label)
|
||||
importLayout.addLayout(descriptionLayout)
|
||||
self.formatWidgets[this_format][u'descriptionLabel'] = descriptionLabel
|
||||
self.formatWidgets[this_format][u'descriptionSpacer'] = descriptionSpacer
|
||||
self.format_widgets[this_format][u'description_label'] = description_label
|
||||
self.format_widgets[this_format][u'descriptionSpacer'] = descriptionSpacer
|
||||
if select_mode == SongFormatSelect.SingleFile or select_mode == SongFormatSelect.SingleFolder:
|
||||
filepathLayout = QtGui.QHBoxLayout()
|
||||
filepathLayout.setObjectName(prefix + u'FilepathLayout')
|
||||
filepathLayout.setContentsMargins(0, self.formatVSpacing, 0, 0)
|
||||
file_path_layout = QtGui.QHBoxLayout()
|
||||
file_path_layout.setObjectName(prefix + u'FilepathLayout')
|
||||
file_path_layout.setContentsMargins(0, self.format_v_spacing, 0, 0)
|
||||
filepathLabel = QtGui.QLabel(importWidget)
|
||||
filepathLabel.setObjectName(prefix + u'FilepathLabel')
|
||||
filepathLayout.addWidget(filepathLabel)
|
||||
file_path_layout.addWidget(filepathLabel)
|
||||
filepathSpacer = QtGui.QSpacerItem(0, 0, QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Fixed)
|
||||
filepathLayout.addSpacerItem(filepathSpacer)
|
||||
filepathEdit = QtGui.QLineEdit(importWidget)
|
||||
filepathEdit.setObjectName(prefix + u'FilepathEdit')
|
||||
filepathLayout.addWidget(filepathEdit)
|
||||
file_path_layout.addSpacerItem(filepathSpacer)
|
||||
file_path_edit = QtGui.QLineEdit(importWidget)
|
||||
file_path_edit.setObjectName(prefix + u'FilepathEdit')
|
||||
file_path_layout.addWidget(file_path_edit)
|
||||
browseButton = QtGui.QToolButton(importWidget)
|
||||
browseButton.setIcon(self.openIcon)
|
||||
browseButton.setIcon(self.open_icon)
|
||||
browseButton.setObjectName(prefix + u'BrowseButton')
|
||||
filepathLayout.addWidget(browseButton)
|
||||
importLayout.addLayout(filepathLayout)
|
||||
importLayout.addSpacerItem(self.stackSpacer)
|
||||
self.formatWidgets[this_format][u'filepathLabel'] = filepathLabel
|
||||
self.formatWidgets[this_format][u'filepathSpacer'] = filepathSpacer
|
||||
self.formatWidgets[this_format][u'filepathLayout'] = filepathLayout
|
||||
self.formatWidgets[this_format][u'filepathEdit'] = filepathEdit
|
||||
self.formatWidgets[this_format][u'browseButton'] = browseButton
|
||||
file_path_layout.addWidget(browseButton)
|
||||
importLayout.addLayout(file_path_layout)
|
||||
importLayout.addSpacerItem(self.stack_spacer)
|
||||
self.format_widgets[this_format][u'filepathLabel'] = filepathLabel
|
||||
self.format_widgets[this_format][u'filepathSpacer'] = filepathSpacer
|
||||
self.format_widgets[this_format][u'file_path_layout'] = file_path_layout
|
||||
self.format_widgets[this_format][u'file_path_edit'] = file_path_edit
|
||||
self.format_widgets[this_format][u'browseButton'] = browseButton
|
||||
elif select_mode == SongFormatSelect.MultipleFiles:
|
||||
fileListWidget = QtGui.QListWidget(importWidget)
|
||||
fileListWidget.setSelectionMode(QtGui.QAbstractItemView.ExtendedSelection)
|
||||
fileListWidget.setObjectName(prefix + u'FileListWidget')
|
||||
importLayout.addWidget(fileListWidget)
|
||||
buttonLayout = QtGui.QHBoxLayout()
|
||||
buttonLayout.setObjectName(prefix + u'ButtonLayout')
|
||||
button_layout = QtGui.QHBoxLayout()
|
||||
button_layout.setObjectName(prefix + u'ButtonLayout')
|
||||
addButton = QtGui.QPushButton(importWidget)
|
||||
addButton.setIcon(self.openIcon)
|
||||
addButton.setIcon(self.open_icon)
|
||||
addButton.setObjectName(prefix + u'AddButton')
|
||||
buttonLayout.addWidget(addButton)
|
||||
buttonLayout.addStretch()
|
||||
button_layout.addWidget(addButton)
|
||||
button_layout.addStretch()
|
||||
removeButton = QtGui.QPushButton(importWidget)
|
||||
removeButton.setIcon(self.deleteIcon)
|
||||
removeButton.setIcon(self.delete_icon)
|
||||
removeButton.setObjectName(prefix + u'RemoveButton')
|
||||
buttonLayout.addWidget(removeButton)
|
||||
importLayout.addLayout(buttonLayout)
|
||||
self.formatWidgets[this_format][u'fileListWidget'] = fileListWidget
|
||||
self.formatWidgets[this_format][u'buttonLayout'] = buttonLayout
|
||||
self.formatWidgets[this_format][u'addButton'] = addButton
|
||||
self.formatWidgets[this_format][u'removeButton'] = removeButton
|
||||
self.formatStack.addWidget(page)
|
||||
self.formatWidgets[this_format][u'page'] = page
|
||||
self.formatWidgets[this_format][u'importLayout'] = importLayout
|
||||
self.formatComboBox.addItem(u'')
|
||||
button_layout.addWidget(removeButton)
|
||||
importLayout.addLayout(button_layout)
|
||||
self.format_widgets[this_format][u'fileListWidget'] = fileListWidget
|
||||
self.format_widgets[this_format][u'button_layout'] = button_layout
|
||||
self.format_widgets[this_format][u'addButton'] = addButton
|
||||
self.format_widgets[this_format][u'removeButton'] = removeButton
|
||||
self.format_stack.addWidget(page)
|
||||
self.format_widgets[this_format][u'page'] = page
|
||||
self.format_widgets[this_format][u'importLayout'] = importLayout
|
||||
self.format_combo_box.addItem(u'')
|
||||
|
||||
def disablableWidget(self, page, prefix):
|
||||
"""
|
||||
Disable a widget.
|
||||
"""
|
||||
this_format = self.currentFormat
|
||||
self.disablableFormats.append(this_format)
|
||||
this_format = self.current_format
|
||||
self.disablable_formats.append(this_format)
|
||||
layout = QtGui.QVBoxLayout(page)
|
||||
layout.setMargin(0)
|
||||
layout.setSpacing(0)
|
||||
layout.setObjectName(prefix + u'Layout')
|
||||
disabledWidget = QtGui.QWidget(page)
|
||||
disabledWidget.setVisible(False)
|
||||
disabledWidget.setObjectName(prefix + u'DisabledWidget')
|
||||
disabledLayout = QtGui.QVBoxLayout(disabledWidget)
|
||||
disabledLayout.setMargin(0)
|
||||
disabledLayout.setObjectName(prefix + u'DisabledLayout')
|
||||
disabledLabel = QtGui.QLabel(disabledWidget)
|
||||
disabledLabel.setWordWrap(True)
|
||||
disabledLabel.setObjectName(prefix + u'DisabledLabel')
|
||||
disabledLayout.addWidget(disabledLabel)
|
||||
disabledLayout.addSpacerItem(self.stackSpacer)
|
||||
layout.addWidget(disabledWidget)
|
||||
importWidget = QtGui.QWidget(page)
|
||||
importWidget.setObjectName(prefix + u'ImportWidget')
|
||||
layout.addWidget(importWidget)
|
||||
self.formatWidgets[this_format][u'layout'] = layout
|
||||
self.formatWidgets[this_format][u'disabledWidget'] = disabledWidget
|
||||
self.formatWidgets[this_format][u'disabledLayout'] = disabledLayout
|
||||
self.formatWidgets[this_format][u'disabledLabel'] = disabledLabel
|
||||
self.formatWidgets[this_format][u'importWidget'] = importWidget
|
||||
return importWidget
|
||||
disabled_widget = QtGui.QWidget(page)
|
||||
disabled_widget.setVisible(False)
|
||||
disabled_widget.setObjectName(prefix + u'DisabledWidget')
|
||||
disabled_layout = QtGui.QVBoxLayout(disabled_widget)
|
||||
disabled_layout.setMargin(0)
|
||||
disabled_layout.setObjectName(prefix + u'DisabledLayout')
|
||||
disabled_label = QtGui.QLabel(disabled_widget)
|
||||
disabled_label.setWordWrap(True)
|
||||
disabled_label.setObjectName(prefix + u'DisabledLabel')
|
||||
disabled_layout.addWidget(disabled_label)
|
||||
disabled_layout.addSpacerItem(self.stack_spacer)
|
||||
layout.addWidget(disabled_widget)
|
||||
import_widget = QtGui.QWidget(page)
|
||||
import_widget.setObjectName(prefix + u'ImportWidget')
|
||||
layout.addWidget(import_widget)
|
||||
self.format_widgets[this_format][u'layout'] = layout
|
||||
self.format_widgets[this_format][u'disabled_widget'] = disabled_widget
|
||||
self.format_widgets[this_format][u'disabled_layout'] = disabled_layout
|
||||
self.format_widgets[this_format][u'disabled_label'] = disabled_label
|
||||
self.format_widgets[this_format][u'import_widget'] = import_widget
|
||||
return import_widget
|
||||
|
||||
def _get_main_window(self):
|
||||
"""
|
||||
@ -516,14 +508,14 @@ class SongImportSourcePage(QtGui.QWizardPage):
|
||||
When this method returns True, the wizard's Next button is enabled.
|
||||
"""
|
||||
wizard = self.wizard()
|
||||
this_format = wizard.currentFormat
|
||||
this_format = wizard.current_format
|
||||
select_mode, format_available = SongFormat.get(this_format, u'selectMode', u'availability')
|
||||
if format_available:
|
||||
if select_mode == SongFormatSelect.MultipleFiles:
|
||||
if wizard.formatWidgets[this_format][u'fileListWidget'].count() > 0:
|
||||
if wizard.format_widgets[this_format][u'fileListWidget'].count() > 0:
|
||||
return True
|
||||
else:
|
||||
filepath = unicode(wizard.formatWidgets[this_format][u'filepathEdit'].text())
|
||||
filepath = unicode(wizard.format_widgets[this_format][u'file_path_edit'].text())
|
||||
if filepath:
|
||||
if select_mode == SongFormatSelect.SingleFile and os.path.isfile(filepath):
|
||||
return True
|
||||
|
@ -62,8 +62,8 @@ class CCLIFileImport(SongImport):
|
||||
Import either a ``.usr`` or a ``.txt`` SongSelect file.
|
||||
"""
|
||||
log.debug(u'Starting CCLI File Import')
|
||||
self.importWizard.progressBar.setMaximum(len(self.importSource))
|
||||
for filename in self.importSource:
|
||||
self.import_wizard.progress_bar.setMaximum(len(self.import_source))
|
||||
for filename in self.import_source:
|
||||
filename = unicode(filename)
|
||||
log.debug(u'Importing CCLI File: %s', filename)
|
||||
lines = []
|
||||
|
@ -87,9 +87,9 @@ class DreamBeamImport(SongImport):
|
||||
"""
|
||||
Receive a single file or a list of files to import.
|
||||
"""
|
||||
if isinstance(self.importSource, list):
|
||||
self.importWizard.progressBar.setMaximum(len(self.importSource))
|
||||
for file in self.importSource:
|
||||
if isinstance(self.import_source, list):
|
||||
self.import_wizard.progress_bar.setMaximum(len(self.import_source))
|
||||
for file in self.import_source:
|
||||
if self.stop_import_flag:
|
||||
return
|
||||
self.setDefaults()
|
||||
@ -148,6 +148,6 @@ class DreamBeamImport(SongImport):
|
||||
unicode(SongStrings.CopyrightSymbol)) >= 0:
|
||||
self.addCopyright(author_copyright)
|
||||
else:
|
||||
self.parseAuthor(author_copyright)
|
||||
self.parse_author(author_copyright)
|
||||
if not self.finish():
|
||||
self.logError(file)
|
||||
|
@ -51,12 +51,12 @@ class EasySlidesImport(SongImport):
|
||||
SongImport.__init__(self, manager, **kwargs)
|
||||
|
||||
def doImport(self):
|
||||
log.info(u'Importing EasySlides XML file %s', self.importSource)
|
||||
log.info(u'Importing EasySlides XML file %s', self.import_source)
|
||||
parser = etree.XMLParser(remove_blank_text=True)
|
||||
parsed_file = etree.parse(self.importSource, parser)
|
||||
parsed_file = etree.parse(self.import_source, parser)
|
||||
xml = unicode(etree.tostring(parsed_file))
|
||||
song_xml = objectify.fromstring(xml)
|
||||
self.importWizard.progressBar.setMaximum(len(song_xml.Item))
|
||||
self.import_wizard.progress_bar.setMaximum(len(song_xml.Item))
|
||||
for song in song_xml.Item:
|
||||
if self.stop_import_flag:
|
||||
return
|
||||
@ -64,22 +64,22 @@ class EasySlidesImport(SongImport):
|
||||
|
||||
def _parseSong(self, song):
|
||||
self._success = True
|
||||
self._addUnicodeAttribute(u'title', song.Title1, True)
|
||||
self._add_unicode_attribute(u'title', song.Title1, True)
|
||||
if hasattr(song, u'Title2'):
|
||||
self._addUnicodeAttribute(u'alternateTitle', song.Title2)
|
||||
self._add_unicode_attribute(u'alternateTitle', song.Title2)
|
||||
if hasattr(song, u'SongNumber'):
|
||||
self._addUnicodeAttribute(u'songNumber', song.SongNumber)
|
||||
self._add_unicode_attribute(u'songNumber', song.SongNumber)
|
||||
if self.songNumber == u'0':
|
||||
self.songNumber = u''
|
||||
self._addAuthors(song)
|
||||
if hasattr(song, u'Copyright'):
|
||||
self._addCopyright(song.Copyright)
|
||||
self._add_copyright(song.Copyright)
|
||||
if hasattr(song, u'LicenceAdmin1'):
|
||||
self._addCopyright(song.LicenceAdmin1)
|
||||
self._add_copyright(song.LicenceAdmin1)
|
||||
if hasattr(song, u'LicenceAdmin2'):
|
||||
self._addCopyright(song.LicenceAdmin2)
|
||||
self._add_copyright(song.LicenceAdmin2)
|
||||
if hasattr(song, u'BookReference'):
|
||||
self._addUnicodeAttribute(u'songBookName', song.BookReference)
|
||||
self._add_unicode_attribute(u'songBookName', song.BookReference)
|
||||
self._parseAndAddLyrics(song)
|
||||
if self._success:
|
||||
if not self.finish():
|
||||
@ -87,7 +87,7 @@ class EasySlidesImport(SongImport):
|
||||
else:
|
||||
self.setDefaults()
|
||||
|
||||
def _addUnicodeAttribute(self, self_attribute, import_attribute, mandatory=False):
|
||||
def _add_unicode_attribute(self, self_attribute, import_attribute, mandatory=False):
|
||||
"""
|
||||
Add imported values to the song model converting them to unicode at the
|
||||
same time. If the unicode decode fails or a mandatory attribute is not
|
||||
@ -123,7 +123,7 @@ class EasySlidesImport(SongImport):
|
||||
except AttributeError:
|
||||
pass
|
||||
|
||||
def _addCopyright(self, element):
|
||||
def _add_copyright(self, element):
|
||||
"""
|
||||
Add a piece of copyright to the total copyright information for the
|
||||
song.
|
||||
|
@ -64,15 +64,15 @@ class EasyWorshipSongImport(SongImport):
|
||||
|
||||
def doImport(self):
|
||||
# Open the DB and MB files if they exist
|
||||
import_source_mb = self.importSource.replace('.DB', '.MB')
|
||||
if not os.path.isfile(self.importSource):
|
||||
import_source_mb = self.import_source.replace('.DB', '.MB')
|
||||
if not os.path.isfile(self.import_source):
|
||||
return
|
||||
if not os.path.isfile(import_source_mb):
|
||||
return
|
||||
db_size = os.path.getsize(self.importSource)
|
||||
db_size = os.path.getsize(self.import_source)
|
||||
if db_size < 0x800:
|
||||
return
|
||||
db_file = open(self.importSource, 'rb')
|
||||
db_file = open(self.import_source, 'rb')
|
||||
self.memoFile = open(import_source_mb, 'rb')
|
||||
# Don't accept files that are clearly not paradox files
|
||||
record_size, header_size, block_size, first_block, num_fields = struct.unpack('<hhxb8xh17xh', db_file.read(35))
|
||||
@ -110,7 +110,7 @@ class EasyWorshipSongImport(SongImport):
|
||||
# There does not appear to be a _reliable_ way of getting the number
|
||||
# of songs/records, so let's use file blocks for measuring progress.
|
||||
total_blocks = (db_size - header_size) / (block_size * 1024)
|
||||
self.importWizard.progressBar.setMaximum(total_blocks)
|
||||
self.import_wizard.progress_bar.setMaximum(total_blocks)
|
||||
# Read the field description information
|
||||
db_file.seek(120)
|
||||
field_info = db_file.read(num_fields * 2)
|
||||
@ -216,7 +216,7 @@ class EasyWorshipSongImport(SongImport):
|
||||
if self.stop_import_flag:
|
||||
break
|
||||
if not self.finish():
|
||||
self.logError(self.importSource)
|
||||
self.logError(self.import_source)
|
||||
db_file.close()
|
||||
self.memoFile.close()
|
||||
|
||||
|
@ -121,12 +121,12 @@ class FoilPresenterImport(SongImport):
|
||||
"""
|
||||
Imports the songs.
|
||||
"""
|
||||
self.importWizard.progressBar.setMaximum(len(self.importSource))
|
||||
self.import_wizard.progress_bar.setMaximum(len(self.import_source))
|
||||
parser = etree.XMLParser(remove_blank_text=True)
|
||||
for file_path in self.importSource:
|
||||
for file_path in self.import_source:
|
||||
if self.stop_import_flag:
|
||||
return
|
||||
self.importWizard.incrementProgressBar(
|
||||
self.import_wizard.increment_progress_bar(
|
||||
WizardStrings.ImportingType % os.path.basename(file_path))
|
||||
try:
|
||||
parsed_file = etree.parse(file_path, parser)
|
||||
|
@ -140,7 +140,7 @@ class SongFormat(object):
|
||||
"""
|
||||
# Song formats (ordered alphabetically after Generic)
|
||||
# * Numerical order of song formats is significant as it determines the
|
||||
# order used by formatComboBox.
|
||||
# order used by format_combo_box.
|
||||
Unknown = -1
|
||||
OpenLyrics = 0
|
||||
OpenLP2 = 1
|
||||
|
@ -289,9 +289,9 @@ class SongMediaItem(MediaManagerItem):
|
||||
self.onClearTextButtonClick()
|
||||
|
||||
def onImportClick(self):
|
||||
if not hasattr(self, u'importWizard'):
|
||||
self.importWizard = SongImportForm(self, self.plugin)
|
||||
self.importWizard.exec_()
|
||||
if not hasattr(self, u'import_wizard'):
|
||||
self.import_wizard = SongImportForm(self, self.plugin)
|
||||
self.import_wizard.exec_()
|
||||
# Run song load as list may have been cancelled but some songs loaded
|
||||
Registry().execute(u'songs_load_list')
|
||||
|
||||
@ -378,7 +378,7 @@ class SongMediaItem(MediaManagerItem):
|
||||
except OSError:
|
||||
log.exception(u'Could not remove directory: %s', save_path)
|
||||
self.plugin.manager.delete_object(Song, item_id)
|
||||
self.main_window.incrementProgressBar()
|
||||
self.main_window.increment_progress_bar()
|
||||
self.main_window.finishedProgressBar()
|
||||
self.application.set_normal_cursor()
|
||||
self.onSearchTextButtonClicked()
|
||||
|
@ -54,17 +54,17 @@ class MediaShoutImport(SongImport):
|
||||
"""
|
||||
try:
|
||||
conn = pyodbc.connect(u'DRIVER={Microsoft Access Driver (*.mdb)};'
|
||||
u'DBQ=%s;PWD=6NOZ4eHK7k' % self.importSource)
|
||||
u'DBQ=%s;PWD=6NOZ4eHK7k' % self.import_source)
|
||||
except:
|
||||
# Unfortunately no specific exception type
|
||||
self.logError(self.importSource,
|
||||
self.logError(self.import_source,
|
||||
translate('SongsPlugin.MediaShoutImport', 'Unable to open the MediaShout database.'))
|
||||
return
|
||||
cursor = conn.cursor()
|
||||
cursor.execute(u'SELECT Record, Title, Author, Copyright, '
|
||||
u'SongID, CCLI, Notes FROM Songs ORDER BY Title')
|
||||
songs = cursor.fetchall()
|
||||
self.importWizard.progressBar.setMaximum(len(songs))
|
||||
self.import_wizard.progress_bar.setMaximum(len(songs))
|
||||
for song in songs:
|
||||
if self.stop_import_flag:
|
||||
break
|
||||
@ -90,7 +90,7 @@ class MediaShoutImport(SongImport):
|
||||
"""
|
||||
self.setDefaults()
|
||||
self.title = song.Title
|
||||
self.parseAuthor(song.Author)
|
||||
self.parse_author(song.Author)
|
||||
self.addCopyright(song.Copyright)
|
||||
self.comments = song.Notes
|
||||
for topic in topics:
|
||||
|
@ -37,7 +37,7 @@ import sqlite
|
||||
import sys
|
||||
import os
|
||||
|
||||
from openlp.core.lib import translate
|
||||
from openlp.core.lib import Registry, translate
|
||||
from openlp.plugins.songs.lib import retrieve_windows_encoding
|
||||
from songimport import SongImport
|
||||
|
||||
@ -61,21 +61,20 @@ class OpenLP1SongImport(SongImport):
|
||||
The database providing the data to import.
|
||||
"""
|
||||
SongImport.__init__(self, manager, **kwargs)
|
||||
self.availableThemes = kwargs[u'plugin'].theme_manager.get_themes()
|
||||
|
||||
def doImport(self):
|
||||
"""
|
||||
Run the import for an openlp.org 1.x song database.
|
||||
"""
|
||||
if not self.importSource.endswith(u'.olp'):
|
||||
self.logError(self.importSource,
|
||||
if not self.import_source.endswith(u'.olp'):
|
||||
self.logError(self.import_source,
|
||||
translate('SongsPlugin.OpenLP1SongImport', 'Not a valid openlp.org 1.x song database.'))
|
||||
return
|
||||
encoding = self.getEncoding()
|
||||
if not encoding:
|
||||
return
|
||||
# Connect to the database.
|
||||
connection = sqlite.connect(self.importSource, mode=0444, encoding=(encoding, 'replace'))
|
||||
connection = sqlite.connect(self.import_source, mode=0444, encoding=(encoding, 'replace'))
|
||||
cursor = connection.cursor()
|
||||
# Determine if the db supports linking audio to songs.
|
||||
cursor.execute(u'SELECT name FROM sqlite_master '
|
||||
@ -100,14 +99,14 @@ class OpenLP1SongImport(SongImport):
|
||||
cursor.execute(u'-- types int, unicode')
|
||||
cursor.execute(u'SELECT settingsid, settingsname FROM settings')
|
||||
for theme_id, theme_name in cursor.fetchall():
|
||||
if theme_name in self.availableThemes:
|
||||
if theme_name in self.theme_manager.get_themes():
|
||||
themes[theme_id] = theme_name
|
||||
# Import the songs.
|
||||
cursor.execute(u'-- types int, unicode, unicode, unicode')
|
||||
cursor.execute(u'SELECT songid, songtitle, lyrics || \'\' AS ' \
|
||||
u'lyrics, copyrightinfo FROM songs')
|
||||
songs = cursor.fetchall()
|
||||
self.importWizard.progressBar.setMaximum(len(songs))
|
||||
self.import_wizard.progress_bar.setMaximum(len(songs))
|
||||
for song in songs:
|
||||
self.setDefaults()
|
||||
if self.stop_import_flag:
|
||||
@ -135,7 +134,7 @@ class OpenLP1SongImport(SongImport):
|
||||
break
|
||||
for author in authors:
|
||||
if author[0] == author_id[0]:
|
||||
self.parseAuthor(author[1])
|
||||
self.parse_author(author[1])
|
||||
break
|
||||
if self.stop_import_flag:
|
||||
break
|
||||
@ -156,14 +155,14 @@ class OpenLP1SongImport(SongImport):
|
||||
if self.stop_import_flag:
|
||||
break
|
||||
if not self.finish():
|
||||
self.logError(self.importSource)
|
||||
self.logError(self.import_source)
|
||||
|
||||
def getEncoding(self):
|
||||
"""
|
||||
Detect character encoding of an openlp.org 1.x song database.
|
||||
"""
|
||||
# Connect to the database.
|
||||
connection = sqlite.connect(self.importSource.encode(
|
||||
connection = sqlite.connect(self.import_source.encode(
|
||||
sys.getfilesystemencoding()), mode=0444)
|
||||
cursor = connection.cursor()
|
||||
|
||||
@ -216,3 +215,13 @@ class OpenLP1SongImport(SongImport):
|
||||
if not common_app_data:
|
||||
return filename
|
||||
return os.path.join(common_app_data, u'openlp.org', 'Audio', filename)
|
||||
|
||||
def _get_theme_manager(self):
|
||||
"""
|
||||
Adds the theme manager to the class dynamically
|
||||
"""
|
||||
if not hasattr(self, u'_theme_manager'):
|
||||
self._theme_manager = Registry().get(u'theme_manager')
|
||||
return self._theme_manager
|
||||
|
||||
theme_manager = property(_get_theme_manager)
|
||||
|
@ -106,13 +106,13 @@ class OpenLPSongImport(SongImport):
|
||||
pass
|
||||
|
||||
# Check the file type
|
||||
if not self.importSource.endswith(u'.sqlite'):
|
||||
self.logError(self.importSource,
|
||||
if not self.import_source.endswith(u'.sqlite'):
|
||||
self.logError(self.import_source,
|
||||
translate('SongsPlugin.OpenLPSongImport', 'Not a valid OpenLP 2.0 song database.'))
|
||||
return
|
||||
self.importSource = u'sqlite:///%s' % self.importSource
|
||||
self.import_source = u'sqlite:///%s' % self.import_source
|
||||
# Load the db file
|
||||
engine = create_engine(self.importSource)
|
||||
engine = create_engine(self.import_source)
|
||||
source_meta = MetaData()
|
||||
source_meta.reflect(engine)
|
||||
self.sourceSession = scoped_session(sessionmaker(bind=engine))
|
||||
@ -169,8 +169,8 @@ class OpenLPSongImport(SongImport):
|
||||
mapper(OldTopic, source_topics_table)
|
||||
|
||||
source_songs = self.sourceSession.query(OldSong).all()
|
||||
if self.importWizard:
|
||||
self.importWizard.progressBar.setMaximum(len(source_songs))
|
||||
if self.import_wizard:
|
||||
self.import_wizard.progress_bar.setMaximum(len(source_songs))
|
||||
for song in source_songs:
|
||||
new_song = Song()
|
||||
new_song.title = song.title
|
||||
@ -224,7 +224,7 @@ class OpenLPSongImport(SongImport):
|
||||
progressDialog.setValue(progressDialog.value() + 1)
|
||||
progressDialog.setLabelText(WizardStrings.ImportingType % new_song.title)
|
||||
else:
|
||||
self.importWizard.incrementProgressBar(WizardStrings.ImportingType % new_song.title)
|
||||
self.import_wizard.increment_progress_bar(WizardStrings.ImportingType % new_song.title)
|
||||
if self.stop_import_flag:
|
||||
break
|
||||
engine.dispose()
|
||||
|
@ -65,18 +65,18 @@ class OooImport(SongImport):
|
||||
self.processStarted = False
|
||||
|
||||
def doImport(self):
|
||||
if not isinstance(self.importSource, list):
|
||||
if not isinstance(self.import_source, list):
|
||||
return
|
||||
try:
|
||||
self.startOoo()
|
||||
except NoConnectException as exc:
|
||||
self.logError(
|
||||
self.importSource[0],
|
||||
self.import_source[0],
|
||||
translate('SongsPlugin.SongImport', 'Cannot access OpenOffice or LibreOffice'))
|
||||
log.error(exc)
|
||||
return
|
||||
self.importWizard.progressBar.setMaximum(len(self.importSource))
|
||||
for filename in self.importSource:
|
||||
self.import_wizard.progress_bar.setMaximum(len(self.import_source))
|
||||
for filename in self.import_source:
|
||||
if self.stop_import_flag:
|
||||
break
|
||||
filename = unicode(filename)
|
||||
@ -162,7 +162,7 @@ class OooImport(SongImport):
|
||||
self.document.supportsService("com.sun.star.text.TextDocument"):
|
||||
self.closeOooFile()
|
||||
else:
|
||||
self.importWizard.incrementProgressBar(u'Processing file ' + filepath, 0)
|
||||
self.import_wizard.increment_progress_bar(u'Processing file ' + filepath, 0)
|
||||
except AttributeError:
|
||||
log.exception("openOooFile failed: %s", url)
|
||||
return
|
||||
@ -190,7 +190,7 @@ class OooImport(SongImport):
|
||||
text = u''
|
||||
for slide_no in range(slides.getCount()):
|
||||
if self.stop_import_flag:
|
||||
self.importWizard.incrementProgressBar(u'Import cancelled', 0)
|
||||
self.import_wizard.increment_progress_bar(u'Import cancelled', 0)
|
||||
return
|
||||
slide = slides.getByIndex(slide_no)
|
||||
slidetext = u''
|
||||
|
@ -62,12 +62,12 @@ class OpenLyricsExport(object):
|
||||
"""
|
||||
log.debug(u'started OpenLyricsExport')
|
||||
openLyrics = OpenLyrics(self.manager)
|
||||
self.parent.progressBar.setMaximum(len(self.songs))
|
||||
self.parent.progress_bar.setMaximum(len(self.songs))
|
||||
for song in self.songs:
|
||||
self.application.process_events()
|
||||
if self.parent.stop_export_flag:
|
||||
return False
|
||||
self.parent.incrementProgressBar(translate('SongsPlugin.OpenLyricsExport', 'Exporting "%s"...') %
|
||||
self.parent.increment_progress_bar(translate('SongsPlugin.OpenLyricsExport', 'Exporting "%s"...') %
|
||||
song.title)
|
||||
xml = openLyrics.song_to_xml(song)
|
||||
tree = etree.ElementTree(etree.fromstring(xml))
|
||||
|
@ -60,12 +60,12 @@ class OpenLyricsImport(SongImport):
|
||||
"""
|
||||
Imports the songs.
|
||||
"""
|
||||
self.importWizard.progressBar.setMaximum(len(self.importSource))
|
||||
self.import_wizard.progress_bar.setMaximum(len(self.import_source))
|
||||
parser = etree.XMLParser(remove_blank_text=True)
|
||||
for file_path in self.importSource:
|
||||
for file_path in self.import_source:
|
||||
if self.stop_import_flag:
|
||||
return
|
||||
self.importWizard.incrementProgressBar(WizardStrings.ImportingType % os.path.basename(file_path))
|
||||
self.import_wizard.increment_progress_bar(WizardStrings.ImportingType % os.path.basename(file_path))
|
||||
try:
|
||||
# Pass a file object, because lxml does not cope with some
|
||||
# special characters in the path (see lp:757673 and lp:744337).
|
||||
|
@ -111,8 +111,8 @@ class OpenSongImport(SongImport):
|
||||
SongImport.__init__(self, manager, **kwargs)
|
||||
|
||||
def doImport(self):
|
||||
self.importWizard.progressBar.setMaximum(len(self.importSource))
|
||||
for filename in self.importSource:
|
||||
self.import_wizard.progress_bar.setMaximum(len(self.import_source))
|
||||
for filename in self.import_source:
|
||||
if self.stop_import_flag:
|
||||
return
|
||||
song_file = open(filename)
|
||||
@ -139,7 +139,7 @@ class OpenSongImport(SongImport):
|
||||
decode = {
|
||||
u'copyright': self.addCopyright,
|
||||
u'ccli': u'ccli_number',
|
||||
u'author': self.parseAuthor,
|
||||
u'author': self.parse_author,
|
||||
u'title': u'title',
|
||||
u'aka': u'alternate_title',
|
||||
u'hymn_number': u'song_number'
|
||||
|
@ -91,21 +91,21 @@ class PowerSongImport(SongImport):
|
||||
"""
|
||||
from importer import SongFormat
|
||||
PS_string = SongFormat.get(SongFormat.PowerSong, u'name')
|
||||
if isinstance(self.importSource, unicode):
|
||||
if os.path.isdir(self.importSource):
|
||||
dir = self.importSource
|
||||
self.importSource = []
|
||||
if isinstance(self.import_source, unicode):
|
||||
if os.path.isdir(self.import_source):
|
||||
dir = self.import_source
|
||||
self.import_source = []
|
||||
for file in os.listdir(dir):
|
||||
if fnmatch.fnmatch(file, u'*.song'):
|
||||
self.importSource.append(os.path.join(dir, file))
|
||||
self.import_source.append(os.path.join(dir, file))
|
||||
else:
|
||||
self.importSource = u''
|
||||
if not self.importSource or not isinstance(self.importSource, list):
|
||||
self.import_source = u''
|
||||
if not self.import_source or not isinstance(self.import_source, list):
|
||||
self.logError(translate('SongsPlugin.PowerSongImport', 'No songs to import.'),
|
||||
translate('SongsPlugin.PowerSongImport', 'No %s files found.') % PS_string)
|
||||
return
|
||||
self.importWizard.progressBar.setMaximum(len(self.importSource))
|
||||
for file in self.importSource:
|
||||
self.import_wizard.progress_bar.setMaximum(len(self.import_source))
|
||||
for file in self.import_source:
|
||||
if self.stop_import_flag:
|
||||
return
|
||||
self.setDefaults()
|
||||
@ -127,7 +127,7 @@ class PowerSongImport(SongImport):
|
||||
if label == u'TITLE':
|
||||
self.title = field.replace(u'\n', u' ')
|
||||
elif label == u'AUTHOR':
|
||||
self.parseAuthor(field)
|
||||
self.parse_author(field)
|
||||
elif label == u'COPYRIGHTLINE':
|
||||
found_copyright = True
|
||||
self._parseCopyrightCCLI(field)
|
||||
|
@ -261,7 +261,7 @@ class SofImport(OooImport):
|
||||
if title.endswith(u','):
|
||||
title = title[:-1]
|
||||
self.title = title
|
||||
self.importWizard.incrementProgressBar(u'Processing song ' + title, 0)
|
||||
self.import_wizard.increment_progress_bar(u'Processing song ' + title, 0)
|
||||
|
||||
def addSofAuthor(self, text):
|
||||
"""
|
||||
@ -271,7 +271,7 @@ class SofImport(OooImport):
|
||||
"Mr Smith" and "Mrs Smith".
|
||||
"""
|
||||
text = text.replace(u' and ', u' & ')
|
||||
self.parseAuthor(text)
|
||||
self.parse_author(text)
|
||||
|
||||
def addVerseLine(self, text):
|
||||
"""
|
||||
|
@ -102,10 +102,10 @@ class SongBeamerImport(SongImport):
|
||||
"""
|
||||
Receive a single file or a list of files to import.
|
||||
"""
|
||||
self.importWizard.progressBar.setMaximum(len(self.importSource))
|
||||
if not isinstance(self.importSource, list):
|
||||
self.import_wizard.progress_bar.setMaximum(len(self.import_source))
|
||||
if not isinstance(self.import_source, list):
|
||||
return
|
||||
for file in self.importSource:
|
||||
for file in self.import_source:
|
||||
# TODO: check that it is a valid SongBeamer file
|
||||
if self.stop_import_flag:
|
||||
return
|
||||
@ -177,7 +177,7 @@ class SongBeamerImport(SongImport):
|
||||
elif tag_val[0] == u'#AddCopyrightInfo':
|
||||
pass
|
||||
elif tag_val[0] == u'#Author':
|
||||
self.parseAuthor(tag_val[1])
|
||||
self.parse_author(tag_val[1])
|
||||
elif tag_val[0] == u'#BackgroundImage':
|
||||
pass
|
||||
elif tag_val[0] == u'#Bible':
|
||||
@ -217,7 +217,7 @@ class SongBeamerImport(SongImport):
|
||||
elif tag_val[0] == u'#LangCount':
|
||||
pass
|
||||
elif tag_val[0] == u'#Melody':
|
||||
self.parseAuthor(tag_val[1])
|
||||
self.parse_author(tag_val[1])
|
||||
elif tag_val[0] == u'#NatCopyright':
|
||||
pass
|
||||
elif tag_val[0] == u'#OTitle':
|
||||
|
@ -71,15 +71,15 @@ class SongImport(QtCore.QObject):
|
||||
self.manager = manager
|
||||
QtCore.QObject.__init__(self)
|
||||
if u'filename' in kwargs:
|
||||
self.importSource = kwargs[u'filename']
|
||||
self.import_source = kwargs[u'filename']
|
||||
elif u'filenames' in kwargs:
|
||||
self.importSource = kwargs[u'filenames']
|
||||
self.import_source = kwargs[u'filenames']
|
||||
elif u'folder' in kwargs:
|
||||
self.importSource = kwargs[u'folder']
|
||||
self.import_source = kwargs[u'folder']
|
||||
else:
|
||||
raise KeyError(u'Keyword arguments "filename[s]" or "folder" not supplied.')
|
||||
log.debug(self.importSource)
|
||||
self.importWizard = None
|
||||
log.debug(self.import_source)
|
||||
self.import_wizard = None
|
||||
self.song = None
|
||||
self.stop_import_flag = False
|
||||
self.setDefaults()
|
||||
@ -92,7 +92,7 @@ class SongImport(QtCore.QObject):
|
||||
"""
|
||||
self.title = u''
|
||||
self.songNumber = u''
|
||||
self.alternateTitle = u''
|
||||
self.alternate_title = u''
|
||||
self.copyright = u''
|
||||
self.comments = u''
|
||||
self.themeName = u''
|
||||
@ -114,7 +114,7 @@ class SongImport(QtCore.QObject):
|
||||
This should be called, when a song could not be imported.
|
||||
|
||||
``filepath``
|
||||
This should be the file path if ``self.importSource`` is a list
|
||||
This should be the file path if ``self.import_source`` is a list
|
||||
with different files. If it is not a list, but a single file (for
|
||||
instance a database), then this should be the song's title.
|
||||
|
||||
@ -123,15 +123,15 @@ class SongImport(QtCore.QObject):
|
||||
informative as possible.
|
||||
"""
|
||||
self.setDefaults()
|
||||
if self.importWizard is None:
|
||||
if self.import_wizard is None:
|
||||
return
|
||||
if self.importWizard.errorReportTextEdit.isHidden():
|
||||
self.importWizard.errorReportTextEdit.setText(translate('SongsPlugin.SongImport',
|
||||
if self.import_wizard.error_report_text_edit.isHidden():
|
||||
self.import_wizard.error_report_text_edit.setText(translate('SongsPlugin.SongImport',
|
||||
'The following songs could not be imported:'))
|
||||
self.importWizard.errorReportTextEdit.setVisible(True)
|
||||
self.importWizard.errorCopyToButton.setVisible(True)
|
||||
self.importWizard.errorSaveToButton.setVisible(True)
|
||||
self.importWizard.errorReportTextEdit.append(u'- %s (%s)' % (filepath, reason))
|
||||
self.import_wizard.error_report_text_edit.setVisible(True)
|
||||
self.import_wizard.error_copy_to_button.setVisible(True)
|
||||
self.import_wizard.error_save_to_button.setVisible(True)
|
||||
self.import_wizard.error_report_text_edit.append(u'- %s (%s)' % (filepath, reason))
|
||||
|
||||
def stop_import(self):
|
||||
"""
|
||||
@ -141,7 +141,7 @@ class SongImport(QtCore.QObject):
|
||||
self.stop_import_flag = True
|
||||
|
||||
def register(self, import_wizard):
|
||||
self.importWizard = import_wizard
|
||||
self.import_wizard = import_wizard
|
||||
|
||||
def tidyText(self, text):
|
||||
"""
|
||||
@ -177,10 +177,10 @@ class SongImport(QtCore.QObject):
|
||||
copyright_found = True
|
||||
self.addCopyright(line)
|
||||
else:
|
||||
self.parseAuthor(line)
|
||||
self.parse_author(line)
|
||||
return
|
||||
if len(lines) == 1:
|
||||
self.parseAuthor(lines[0])
|
||||
self.parse_author(lines[0])
|
||||
return
|
||||
if not self.title:
|
||||
self.title = lines[0]
|
||||
@ -196,7 +196,7 @@ class SongImport(QtCore.QObject):
|
||||
self.copyright += ' '
|
||||
self.copyright += copyright
|
||||
|
||||
def parseAuthor(self, text):
|
||||
def parse_author(self, text):
|
||||
"""
|
||||
Add the author. OpenLP stores them individually so split by 'and', '&'
|
||||
and comma. However need to check for 'Mr and Mrs Smith' and turn it to
|
||||
@ -291,9 +291,9 @@ class SongImport(QtCore.QObject):
|
||||
log.info(u'committing song %s to database', self.title)
|
||||
song = Song()
|
||||
song.title = self.title
|
||||
if self.importWizard is not None:
|
||||
self.importWizard.incrementProgressBar(WizardStrings.ImportingType % song.title)
|
||||
song.alternate_title = self.alternateTitle
|
||||
if self.import_wizard is not None:
|
||||
self.import_wizard.increment_progress_bar(WizardStrings.ImportingType % song.title)
|
||||
song.alternate_title = self.alternate_title
|
||||
# Values will be set when cleaning the song.
|
||||
song.search_title = u''
|
||||
song.search_lyrics = u''
|
||||
@ -366,7 +366,7 @@ class SongImport(QtCore.QObject):
|
||||
The file to copy.
|
||||
"""
|
||||
if not hasattr(self, u'save_path'):
|
||||
self.save_path = os.path.join(AppLocation.get_section_data_path(self.importWizard.plugin.name),
|
||||
self.save_path = os.path.join(AppLocation.get_section_data_path(self.import_wizard.plugin.name),
|
||||
'audio', str(song_id))
|
||||
check_directory_exists(self.save_path)
|
||||
if not filename.startswith(self.save_path):
|
||||
|
@ -78,8 +78,8 @@ class SongProImport(SongImport):
|
||||
Receive a single file or a list of files to import.
|
||||
"""
|
||||
self.encoding = None
|
||||
with open(self.importSource, 'r') as songs_file:
|
||||
self.importWizard.progressBar.setMaximum(0)
|
||||
with open(self.import_source, 'r') as songs_file:
|
||||
self.import_wizard.progress_bar.setMaximum(0)
|
||||
tag = u''
|
||||
text = u''
|
||||
for file_line in songs_file:
|
||||
@ -115,7 +115,7 @@ class SongProImport(SongImport):
|
||||
if not text:
|
||||
return
|
||||
if tag == u'A':
|
||||
self.parseAuthor(text)
|
||||
self.parse_author(text)
|
||||
elif tag in [u'B', u'C']:
|
||||
self.addVerse(text, tag)
|
||||
elif tag == u'D':
|
||||
|
@ -101,17 +101,17 @@ class SongShowPlusImport(SongImport):
|
||||
"""
|
||||
Receive a single file or a list of files to import.
|
||||
"""
|
||||
if not isinstance(self.importSource, list):
|
||||
if not isinstance(self.import_source, list):
|
||||
return
|
||||
self.importWizard.progressBar.setMaximum(len(self.importSource))
|
||||
for file in self.importSource:
|
||||
self.import_wizard.progress_bar.setMaximum(len(self.import_source))
|
||||
for file in self.import_source:
|
||||
if self.stop_import_flag:
|
||||
return
|
||||
self.sspVerseOrderList = []
|
||||
other_count = 0
|
||||
other_list = {}
|
||||
file_name = os.path.split(file)[1]
|
||||
self.importWizard.incrementProgressBar(WizardStrings.ImportingType % file_name, 0)
|
||||
self.import_wizard.increment_progress_bar(WizardStrings.ImportingType % file_name, 0)
|
||||
song_data = open(file, 'rb')
|
||||
while True:
|
||||
block_key, = struct.unpack("I", song_data.read(4))
|
||||
@ -146,7 +146,7 @@ class SongShowPlusImport(SongImport):
|
||||
if author.find(",") !=-1:
|
||||
authorParts = author.split(", ")
|
||||
author = authorParts[1] + " " + authorParts[0]
|
||||
self.parseAuthor(unicode(author, u'cp1252'))
|
||||
self.parse_author(unicode(author, u'cp1252'))
|
||||
elif block_key == COPYRIGHT:
|
||||
self.addCopyright(unicode(data, u'cp1252'))
|
||||
elif block_key == CCLI_NO:
|
||||
|
@ -63,8 +63,8 @@ class SundayPlusImport(SongImport):
|
||||
self.encoding = u'us-ascii'
|
||||
|
||||
def doImport(self):
|
||||
self.importWizard.progressBar.setMaximum(len(self.importSource))
|
||||
for filename in self.importSource:
|
||||
self.import_wizard.progress_bar.setMaximum(len(self.import_source))
|
||||
for filename in self.import_source:
|
||||
if self.stop_import_flag:
|
||||
return
|
||||
song_file = open(filename)
|
||||
|
@ -105,9 +105,9 @@ class WowImport(SongImport):
|
||||
"""
|
||||
Receive a single file or a list of files to import.
|
||||
"""
|
||||
if isinstance(self.importSource, list):
|
||||
self.importWizard.progressBar.setMaximum(len(self.importSource))
|
||||
for source in self.importSource:
|
||||
if isinstance(self.import_source, list):
|
||||
self.import_wizard.progress_bar.setMaximum(len(self.import_source))
|
||||
for source in self.import_source:
|
||||
if self.stop_import_flag:
|
||||
return
|
||||
self.setDefaults()
|
||||
@ -145,7 +145,7 @@ class WowImport(SongImport):
|
||||
# Now to extract the author
|
||||
author_length = ord(song_data.read(1))
|
||||
if author_length:
|
||||
self.parseAuthor(unicode(song_data.read(author_length), u'cp1252'))
|
||||
self.parse_author(unicode(song_data.read(author_length), u'cp1252'))
|
||||
# Finally the copyright
|
||||
copyright_length = ord(song_data.read(1))
|
||||
if copyright_length:
|
||||
|
@ -82,7 +82,7 @@ class ZionWorxImport(SongImport):
|
||||
"""
|
||||
Receive a CSV file (from a ZionWorx database dump) to import.
|
||||
"""
|
||||
with open(self.importSource, 'rb') as songs_file:
|
||||
with open(self.import_source, 'rb') as songs_file:
|
||||
field_names = [u'SongNum', u'Title1', u'Title2', u'Lyrics', u'Writer', u'Copyright', u'Keywords',
|
||||
u'DefaultStyle']
|
||||
songs_reader = csv.DictReader(songs_file, field_names)
|
||||
@ -94,7 +94,7 @@ class ZionWorxImport(SongImport):
|
||||
return
|
||||
num_records = len(records)
|
||||
log.info(u'%s records found in CSV file' % num_records)
|
||||
self.importWizard.progressBar.setMaximum(num_records)
|
||||
self.import_wizard.progress_bar.setMaximum(num_records)
|
||||
for index, record in enumerate(records, 1):
|
||||
if self.stop_import_flag:
|
||||
return
|
||||
@ -102,8 +102,8 @@ class ZionWorxImport(SongImport):
|
||||
try:
|
||||
self.title = self._decode(record[u'Title1'])
|
||||
if record[u'Title2']:
|
||||
self.alternateTitle = self._decode(record[u'Title2'])
|
||||
self.parseAuthor(self._decode(record[u'Writer']))
|
||||
self.alternate_title = self._decode(record[u'Title2'])
|
||||
self.parse_author(self._decode(record[u'Writer']))
|
||||
self.addCopyright(self._decode(record[u'Copyright']))
|
||||
lyrics = self._decode(record[u'Lyrics'])
|
||||
except UnicodeDecodeError, e:
|
||||
|
@ -204,9 +204,8 @@ class SongsPlugin(Plugin):
|
||||
|
||||
def importSongs(self, format, **kwargs):
|
||||
class_ = SongFormat.get(format, u'class')
|
||||
kwargs[u'plugin'] = self
|
||||
importer = class_(self.manager, **kwargs)
|
||||
importer.register(self.mediaItem.importWizard)
|
||||
importer.register(self.mediaItem.import_wizard)
|
||||
return importer
|
||||
|
||||
def set_plugin_text_strings(self):
|
||||
|
Loading…
Reference in New Issue
Block a user