diff --git a/openlp/plugins/bibles/forms/__init__.py b/openlp/plugins/bibles/forms/__init__.py index b7215167a..30b9c5b1e 100644 --- a/openlp/plugins/bibles/forms/__init__.py +++ b/openlp/plugins/bibles/forms/__init__.py @@ -24,5 +24,6 @@ ############################################################################### from bibleimportform import BibleImportForm +from importwizardform import ImportWizardForm -__all__ = ['BibleImportForm'] +__all__ = ['BibleImportForm', 'ImportWizardForm'] diff --git a/openlp/plugins/bibles/forms/bibleimportwizard.py b/openlp/plugins/bibles/forms/bibleimportwizard.py new file mode 100644 index 000000000..cf2033af0 --- /dev/null +++ b/openlp/plugins/bibles/forms/bibleimportwizard.py @@ -0,0 +1,319 @@ +# -*- coding: utf-8 -*- +# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4 + +############################################################################### +# OpenLP - Open Source Lyrics Projection # +# --------------------------------------------------------------------------- # +# Copyright (c) 2008-2009 Raoul Snyman # +# Portions copyright (c) 2008-2009 Tim Bentley, Jonathan Corwin, Michael # +# Gorven, Scott Guerrieri, Maikel Stuivenberg, Martin Thompson, Jon Tibble, # +# Carsten Tinggaard # +# --------------------------------------------------------------------------- # +# This program is free software; you can redistribute it and/or modify it # +# under the terms of the GNU General Public License as published by the Free # +# Software Foundation; version 2 of the License. # +# # +# This program is distributed in the hope that it will be useful, but WITHOUT # +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or # +# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for # +# more details. # +# # +# You should have received a copy of the GNU General Public License along # +# with this program; if not, write to the Free Software Foundation, Inc., 59 # +# Temple Place, Suite 330, Boston, MA 02111-1307 USA # +############################################################################### + +from PyQt4 import QtCore, QtGui + +class Ui_BibleImportWizard(object): + def setupUi(self, BibleImportWizard): + BibleImportWizard.setObjectName(u'BibleImportWizard') + BibleImportWizard.resize(550, 386) + BibleImportWizard.setModal(True) + BibleImportWizard.setWizardStyle(QtGui.QWizard.ModernStyle) + BibleImportWizard.setOptions( + QtGui.QWizard.IndependentPages | \ + QtGui.QWizard.NoBackButtonOnStartPage | \ + QtGui.QWizard.NoBackButtonOnLastPage) + self.WelcomePage = QtGui.QWizardPage() + self.WelcomePage.setPixmap(QtGui.QWizard.WatermarkPixmap, + QtGui.QPixmap(u':/wizards/wizard_importbible.bmp')) + self.WelcomePage.setObjectName(u'WelcomePage') + self.WelcomeLayout = QtGui.QVBoxLayout(self.WelcomePage) + self.WelcomeLayout.setSpacing(8) + self.WelcomeLayout.setMargin(0) + self.WelcomeLayout.setObjectName(u'WelcomeLayout') + self.TitleLabel = QtGui.QLabel(self.WelcomePage) + self.TitleLabel.setObjectName(u'TitleLabel') + self.WelcomeLayout.addWidget(self.TitleLabel) + spacerItem = QtGui.QSpacerItem(20, 40, QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Fixed) + self.WelcomeLayout.addItem(spacerItem) + self.InformationLabel = QtGui.QLabel(self.WelcomePage) + self.InformationLabel.setWordWrap(True) + self.InformationLabel.setMargin(10) + self.InformationLabel.setObjectName(u'InformationLabel') + self.WelcomeLayout.addWidget(self.InformationLabel) + spacerItem1 = QtGui.QSpacerItem(20, 40, QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Expanding) + self.WelcomeLayout.addItem(spacerItem1) + BibleImportWizard.addPage(self.WelcomePage) + self.SelectPage = QtGui.QWizardPage() + self.SelectPage.setObjectName(u'SelectPage') + self.SelectPageLayout = QtGui.QVBoxLayout(self.SelectPage) + self.SelectPageLayout.setSpacing(8) + self.SelectPageLayout.setMargin(20) + self.SelectPageLayout.setObjectName(u'SelectPageLayout') + self.FormatSelectLayout = QtGui.QHBoxLayout() + self.FormatSelectLayout.setSpacing(8) + self.FormatSelectLayout.setObjectName(u'FormatSelectLayout') + self.FormatLabel = QtGui.QLabel(self.SelectPage) + self.FormatLabel.setObjectName(u'FormatLabel') + self.FormatSelectLayout.addWidget(self.FormatLabel) + self.FormatComboBox = QtGui.QComboBox(self.SelectPage) + self.FormatComboBox.setObjectName(u'FormatComboBox') + self.FormatComboBox.addItem(u'') + self.FormatComboBox.addItem(u'') + self.FormatComboBox.addItem(u'') + self.FormatComboBox.addItem(u'') + self.FormatSelectLayout.addWidget(self.FormatComboBox) + spacerItem2 = QtGui.QSpacerItem(40, 20, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum) + self.FormatSelectLayout.addItem(spacerItem2) + self.SelectPageLayout.addLayout(self.FormatSelectLayout) + self.FormatWidget = QtGui.QStackedWidget(self.SelectPage) + self.FormatWidget.setObjectName(u'FormatWidget') + self.OsisPage = QtGui.QWidget() + self.OsisPage.setObjectName(u'OsisPage') + self.OsisLayout = QtGui.QFormLayout(self.OsisPage) + self.OsisLayout.setFieldGrowthPolicy(QtGui.QFormLayout.ExpandingFieldsGrow) + self.OsisLayout.setMargin(0) + self.OsisLayout.setSpacing(8) + self.OsisLayout.setObjectName(u'OsisLayout') + self.OsisBibleNameLabel = QtGui.QLabel(self.OsisPage) + self.OsisBibleNameLabel.setIndent(0) + self.OsisBibleNameLabel.setObjectName(u'OsisBibleNameLabel') + self.OsisLayout.setWidget(0, QtGui.QFormLayout.LabelRole, self.OsisBibleNameLabel) + self.OsisBibleNameEdit = QtGui.QLineEdit(self.OsisPage) + self.OsisBibleNameEdit.setObjectName(u'OsisBibleNameEdit') + self.OsisLayout.setWidget(0, QtGui.QFormLayout.FieldRole, self.OsisBibleNameEdit) + self.OsisLocationLabel = QtGui.QLabel(self.OsisPage) + self.OsisLocationLabel.setObjectName(u'OsisLocationLabel') + self.OsisLayout.setWidget(1, QtGui.QFormLayout.LabelRole, self.OsisLocationLabel) + self.OsisLocationLayout = QtGui.QHBoxLayout() + self.OsisLocationLayout.setSpacing(8) + self.OsisLocationLayout.setObjectName(u'OsisLocationLayout') + self.OSISLocationEdit = QtGui.QLineEdit(self.OsisPage) + self.OSISLocationEdit.setObjectName(u'OSISLocationEdit') + self.OsisLocationLayout.addWidget(self.OSISLocationEdit) + self.OsisFileButton = QtGui.QToolButton(self.OsisPage) + self.OsisFileButton.setMaximumSize(QtCore.QSize(32, 16777215)) + icon = QtGui.QIcon() + icon.addPixmap(QtGui.QPixmap(u':/imports/import_load.png'), QtGui.QIcon.Normal, QtGui.QIcon.Off) + self.OsisFileButton.setIcon(icon) + self.OsisFileButton.setObjectName(u'OsisFileButton') + self.OsisLocationLayout.addWidget(self.OsisFileButton) + self.OsisLayout.setLayout(1, QtGui.QFormLayout.FieldRole, self.OsisLocationLayout) + self.FormatWidget.addWidget(self.OsisPage) + self.CsvPage = QtGui.QWidget() + self.CsvPage.setObjectName(u'CsvPage') + self.CsvSourceLayout = QtGui.QFormLayout(self.CsvPage) + self.CsvSourceLayout.setFieldGrowthPolicy(QtGui.QFormLayout.ExpandingFieldsGrow) + self.CsvSourceLayout.setLabelAlignment(QtCore.Qt.AlignBottom|QtCore.Qt.AlignRight|QtCore.Qt.AlignTrailing) + self.CsvSourceLayout.setFormAlignment(QtCore.Qt.AlignLeading|QtCore.Qt.AlignLeft|QtCore.Qt.AlignTop) + self.CsvSourceLayout.setMargin(0) + self.CsvSourceLayout.setSpacing(8) + self.CsvSourceLayout.setObjectName(u'CsvSourceLayout') + self.BooksLocationLabel = QtGui.QLabel(self.CsvPage) + self.BooksLocationLabel.setObjectName(u'BooksLocationLabel') + self.CsvSourceLayout.setWidget(0, QtGui.QFormLayout.LabelRole, self.BooksLocationLabel) + self.CsvBooksLayout = QtGui.QHBoxLayout() + self.CsvBooksLayout.setSpacing(8) + self.CsvBooksLayout.setObjectName(u'CsvBooksLayout') + self.BooksLocationEdit = QtGui.QLineEdit(self.CsvPage) + self.BooksLocationEdit.setObjectName(u'BooksLocationEdit') + self.CsvBooksLayout.addWidget(self.BooksLocationEdit) + self.BooksFileButton = QtGui.QToolButton(self.CsvPage) + self.BooksFileButton.setMaximumSize(QtCore.QSize(32, 16777215)) + self.BooksFileButton.setIcon(icon) + self.BooksFileButton.setObjectName(u'BooksFileButton') + self.CsvBooksLayout.addWidget(self.BooksFileButton) + self.CsvSourceLayout.setLayout(0, QtGui.QFormLayout.FieldRole, self.CsvBooksLayout) + self.VerseLocationLabel = QtGui.QLabel(self.CsvPage) + self.VerseLocationLabel.setObjectName(u'VerseLocationLabel') + self.CsvSourceLayout.setWidget(1, QtGui.QFormLayout.LabelRole, self.VerseLocationLabel) + self.CsvVerseLayout = QtGui.QHBoxLayout() + self.CsvVerseLayout.setSpacing(8) + self.CsvVerseLayout.setObjectName(u'CsvVerseLayout') + self.CsvVerseLocationEdit = QtGui.QLineEdit(self.CsvPage) + self.CsvVerseLocationEdit.setObjectName(u'CsvVerseLocationEdit') + self.CsvVerseLayout.addWidget(self.CsvVerseLocationEdit) + self.CsvVersesFileButton = QtGui.QToolButton(self.CsvPage) + self.CsvVersesFileButton.setMaximumSize(QtCore.QSize(32, 16777215)) + self.CsvVersesFileButton.setIcon(icon) + self.CsvVersesFileButton.setObjectName(u'CsvVersesFileButton') + self.CsvVerseLayout.addWidget(self.CsvVersesFileButton) + self.CsvSourceLayout.setLayout(1, QtGui.QFormLayout.FieldRole, self.CsvVerseLayout) + self.FormatWidget.addWidget(self.CsvPage) + self.OpenSongPage = QtGui.QWidget() + self.OpenSongPage.setObjectName(u'OpenSongPage') + self.OpenSongLayout = QtGui.QFormLayout(self.OpenSongPage) + self.OpenSongLayout.setMargin(0) + self.OpenSongLayout.setSpacing(8) + self.OpenSongLayout.setObjectName(u'OpenSongLayout') + self.OpenSongFileLabel = QtGui.QLabel(self.OpenSongPage) + self.OpenSongFileLabel.setObjectName(u'OpenSongFileLabel') + self.OpenSongLayout.setWidget(0, QtGui.QFormLayout.LabelRole, self.OpenSongFileLabel) + self.OpenSongFileLayout = QtGui.QHBoxLayout() + self.OpenSongFileLayout.setSpacing(8) + self.OpenSongFileLayout.setObjectName(u'OpenSongFileLayout') + self.OpenSongFileEdit = QtGui.QLineEdit(self.OpenSongPage) + self.OpenSongFileEdit.setObjectName(u'OpenSongFileEdit') + self.OpenSongFileLayout.addWidget(self.OpenSongFileEdit) + self.OpenSongBrowseButton = QtGui.QToolButton(self.OpenSongPage) + self.OpenSongBrowseButton.setIcon(icon) + self.OpenSongBrowseButton.setObjectName(u'OpenSongBrowseButton') + self.OpenSongFileLayout.addWidget(self.OpenSongBrowseButton) + self.OpenSongLayout.setLayout(0, QtGui.QFormLayout.FieldRole, self.OpenSongFileLayout) + self.FormatWidget.addWidget(self.OpenSongPage) + self.WebDownloadPage = QtGui.QWidget() + self.WebDownloadPage.setObjectName(u'WebDownloadPage') + self.WebDownloadLayout = QtGui.QVBoxLayout(self.WebDownloadPage) + self.WebDownloadLayout.setSpacing(8) + self.WebDownloadLayout.setMargin(0) + self.WebDownloadLayout.setObjectName(u'WebDownloadLayout') + self.WebDownloadTabWidget = QtGui.QTabWidget(self.WebDownloadPage) + self.WebDownloadTabWidget.setObjectName(u'WebDownloadTabWidget') + self.DownloadOptionsTab = QtGui.QWidget() + self.DownloadOptionsTab.setObjectName(u'DownloadOptionsTab') + self.DownloadOptionsLayout = QtGui.QFormLayout(self.DownloadOptionsTab) + self.DownloadOptionsLayout.setMargin(8) + self.DownloadOptionsLayout.setSpacing(8) + self.DownloadOptionsLayout.setObjectName(u'DownloadOptionsLayout') + self.LocationLabel = QtGui.QLabel(self.DownloadOptionsTab) + self.LocationLabel.setObjectName(u'LocationLabel') + self.DownloadOptionsLayout.setWidget(0, QtGui.QFormLayout.LabelRole, self.LocationLabel) + self.LocationComboBox = QtGui.QComboBox(self.DownloadOptionsTab) + self.LocationComboBox.setObjectName(u'LocationComboBox') + self.LocationComboBox.addItem(u'') + self.DownloadOptionsLayout.setWidget(0, QtGui.QFormLayout.FieldRole, self.LocationComboBox) + self.BibleLabel = QtGui.QLabel(self.DownloadOptionsTab) + self.BibleLabel.setObjectName(u'BibleLabel') + self.DownloadOptionsLayout.setWidget(1, QtGui.QFormLayout.LabelRole, self.BibleLabel) + self.BibleComboBox = QtGui.QComboBox(self.DownloadOptionsTab) + self.BibleComboBox.setSizeAdjustPolicy(QtGui.QComboBox.AdjustToContents) + self.BibleComboBox.setObjectName(u'BibleComboBox') + self.BibleComboBox.addItem(u'') + self.BibleComboBox.addItem(u'') + self.BibleComboBox.addItem(u'') + self.DownloadOptionsLayout.setWidget(1, QtGui.QFormLayout.FieldRole, self.BibleComboBox) + self.WebDownloadTabWidget.addTab(self.DownloadOptionsTab, u'') + self.ProxyServerTab = QtGui.QWidget() + self.ProxyServerTab.setObjectName(u'ProxyServerTab') + self.ProxyServerLayout = QtGui.QFormLayout(self.ProxyServerTab) + self.ProxyServerLayout.setObjectName(u'ProxyServerLayout') + self.AddressLabel = QtGui.QLabel(self.ProxyServerTab) + self.AddressLabel.setObjectName(u'AddressLabel') + self.ProxyServerLayout.setWidget(0, QtGui.QFormLayout.LabelRole, self.AddressLabel) + self.AddressEdit = QtGui.QLineEdit(self.ProxyServerTab) + self.AddressEdit.setObjectName(u'AddressEdit') + self.ProxyServerLayout.setWidget(0, QtGui.QFormLayout.FieldRole, self.AddressEdit) + self.UsernameLabel = QtGui.QLabel(self.ProxyServerTab) + self.UsernameLabel.setObjectName(u'UsernameLabel') + self.ProxyServerLayout.setWidget(1, QtGui.QFormLayout.LabelRole, self.UsernameLabel) + self.UsernameEdit = QtGui.QLineEdit(self.ProxyServerTab) + self.UsernameEdit.setObjectName(u'UsernameEdit') + self.ProxyServerLayout.setWidget(1, QtGui.QFormLayout.FieldRole, self.UsernameEdit) + self.PasswordLabel = QtGui.QLabel(self.ProxyServerTab) + self.PasswordLabel.setObjectName(u'PasswordLabel') + self.ProxyServerLayout.setWidget(2, QtGui.QFormLayout.LabelRole, self.PasswordLabel) + self.PasswordEdit = QtGui.QLineEdit(self.ProxyServerTab) + self.PasswordEdit.setObjectName(u'PasswordEdit') + self.ProxyServerLayout.setWidget(2, QtGui.QFormLayout.FieldRole, self.PasswordEdit) + self.WebDownloadTabWidget.addTab(self.ProxyServerTab, u'') + self.WebDownloadLayout.addWidget(self.WebDownloadTabWidget) + self.FormatWidget.addWidget(self.WebDownloadPage) + self.SelectPageLayout.addWidget(self.FormatWidget) + BibleImportWizard.addPage(self.SelectPage) + self.LicenseDetailsPage = QtGui.QWizardPage() + self.LicenseDetailsPage.setObjectName(u'LicenseDetailsPage') + self.LicenseDetailsLayout = QtGui.QFormLayout(self.LicenseDetailsPage) + self.LicenseDetailsLayout.setMargin(20) + self.LicenseDetailsLayout.setSpacing(8) + self.LicenseDetailsLayout.setObjectName(u'LicenseDetailsLayout') + self.VersionNameLabel = QtGui.QLabel(self.LicenseDetailsPage) + self.VersionNameLabel.setObjectName(u'VersionNameLabel') + self.LicenseDetailsLayout.setWidget(0, QtGui.QFormLayout.LabelRole, self.VersionNameLabel) + self.VersionNameEdit = QtGui.QLineEdit(self.LicenseDetailsPage) + self.VersionNameEdit.setObjectName(u'VersionNameEdit') + self.LicenseDetailsLayout.setWidget(0, QtGui.QFormLayout.FieldRole, self.VersionNameEdit) + self.CopyrightLabel = QtGui.QLabel(self.LicenseDetailsPage) + self.CopyrightLabel.setObjectName(u'CopyrightLabel') + self.LicenseDetailsLayout.setWidget(1, QtGui.QFormLayout.LabelRole, self.CopyrightLabel) + self.CopyrightEdit = QtGui.QLineEdit(self.LicenseDetailsPage) + self.CopyrightEdit.setObjectName(u'CopyrightEdit') + self.LicenseDetailsLayout.setWidget(1, QtGui.QFormLayout.FieldRole, self.CopyrightEdit) + self.PermissionLabel = QtGui.QLabel(self.LicenseDetailsPage) + self.PermissionLabel.setObjectName(u'PermissionLabel') + self.LicenseDetailsLayout.setWidget(2, QtGui.QFormLayout.LabelRole, self.PermissionLabel) + self.PermissionEdit = QtGui.QLineEdit(self.LicenseDetailsPage) + self.PermissionEdit.setObjectName(u'PermissionEdit') + self.LicenseDetailsLayout.setWidget(2, QtGui.QFormLayout.FieldRole, self.PermissionEdit) + BibleImportWizard.addPage(self.LicenseDetailsPage) + self.ImportPage = QtGui.QWizardPage() + self.ImportPage.setObjectName(u'ImportPage') + self.ImportLayout = QtGui.QVBoxLayout(self.ImportPage) + self.ImportLayout.setSpacing(8) + self.ImportLayout.setMargin(50) + self.ImportLayout.setObjectName(u'ImportLayout') + self.ImportProgressLabel = QtGui.QLabel(self.ImportPage) + self.ImportProgressLabel.setObjectName(u'ImportProgressLabel') + self.ImportLayout.addWidget(self.ImportProgressLabel) + self.ImportProgressBar = QtGui.QProgressBar(self.ImportPage) + self.ImportProgressBar.setProperty(u'value', 0) + self.ImportProgressBar.setInvertedAppearance(False) + self.ImportProgressBar.setObjectName(u'ImportProgressBar') + self.ImportLayout.addWidget(self.ImportProgressBar) + BibleImportWizard.addPage(self.ImportPage) + + + self.retranslateUi(BibleImportWizard) + self.FormatWidget.setCurrentIndex(0) + self.WebDownloadTabWidget.setCurrentIndex(0) + QtCore.QObject.connect(self.FormatComboBox, QtCore.SIGNAL(u'currentIndexChanged(int)'), self.FormatWidget.setCurrentIndex) + QtCore.QMetaObject.connectSlotsByName(BibleImportWizard) + + def retranslateUi(self, BibleImportWizard): + BibleImportWizard.setWindowTitle(self.trUtf8('Bible Import Wizard')) + self.TitleLabel.setText(u'' + self.trUtf8('Welcome to the Bible Import Wizard') + u'') + self.InformationLabel.setText(self.trUtf8('This wizard will help you to import Bibles from a variety of formats. Click the next button below to start the process by selecting a format to import from.')) + self.SelectPage.setTitle(self.trUtf8('Select Import Source')) + self.SelectPage.setSubTitle(self.trUtf8('Select the import format, and where to import from.')) + self.FormatLabel.setText(self.trUtf8('Format:')) + self.FormatComboBox.setItemText(0, self.trUtf8('OSIS')) + self.FormatComboBox.setItemText(1, self.trUtf8('CSV')) + self.FormatComboBox.setItemText(2, self.trUtf8('OpenSong')) + self.FormatComboBox.setItemText(3, self.trUtf8('Web Download')) + self.OsisBibleNameLabel.setText(self.trUtf8('Bible Name:')) + self.OsisLocationLabel.setText(self.trUtf8('File Location:')) + self.BooksLocationLabel.setText(self.trUtf8('Books Location:')) + self.VerseLocationLabel.setText(self.trUtf8('Verse Location:')) + self.OpenSongFileLabel.setText(self.trUtf8('Bible Filename:')) + self.LocationLabel.setText(self.trUtf8('Location:')) + self.LocationComboBox.setItemText(0, self.trUtf8('Crosswalk')) + self.BibleLabel.setText(self.trUtf8('Bible:')) + self.BibleComboBox.setItemText(0, self.trUtf8('English Standard Version')) + self.BibleComboBox.setItemText(1, self.trUtf8('King James Version')) + self.BibleComboBox.setItemText(2, self.trUtf8('New International Version')) + self.WebDownloadTabWidget.setTabText(self.WebDownloadTabWidget.indexOf(self.DownloadOptionsTab), self.trUtf8('Download Options')) + self.AddressLabel.setText(self.trUtf8('Server:')) + self.UsernameLabel.setText(self.trUtf8('Username:')) + self.PasswordLabel.setText(self.trUtf8('Password:')) + self.WebDownloadTabWidget.setTabText(self.WebDownloadTabWidget.indexOf(self.ProxyServerTab), self.trUtf8('Proxy Server (Optional)')) + self.LicenseDetailsPage.setTitle(self.trUtf8('License Details')) + self.LicenseDetailsPage.setSubTitle(self.trUtf8('Set up the Bible\'s license details.')) + self.VersionNameLabel.setText(self.trUtf8('Version Name:')) + self.CopyrightLabel.setText(self.trUtf8('Copyright:')) + self.PermissionLabel.setText(self.trUtf8('Permission:')) + self.ImportPage.setTitle(self.trUtf8('Importing')) + self.ImportPage.setSubTitle(self.trUtf8('Please wait while your Bible is imported.')) + self.ImportProgressLabel.setText(self.trUtf8('Ready.')) + self.ImportProgressBar.setFormat(u'%p') + diff --git a/openlp/plugins/bibles/forms/importwizardform.py b/openlp/plugins/bibles/forms/importwizardform.py new file mode 100644 index 000000000..95eaada04 --- /dev/null +++ b/openlp/plugins/bibles/forms/importwizardform.py @@ -0,0 +1,132 @@ +# -*- coding: utf-8 -*- +# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4 + +############################################################################### +# OpenLP - Open Source Lyrics Projection # +# --------------------------------------------------------------------------- # +# Copyright (c) 2008-2009 Raoul Snyman # +# Portions copyright (c) 2008-2009 Tim Bentley, Jonathan Corwin, Michael # +# Gorven, Scott Guerrieri, Maikel Stuivenberg, Martin Thompson, Jon Tibble, # +# Carsten Tinggaard # +# --------------------------------------------------------------------------- # +# This program is free software; you can redistribute it and/or modify it # +# under the terms of the GNU General Public License as published by the Free # +# Software Foundation; version 2 of the License. # +# # +# This program is distributed in the hope that it will be useful, but WITHOUT # +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or # +# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for # +# more details. # +# # +# You should have received a copy of the GNU General Public License along # +# with this program; if not, write to the Free Software Foundation, Inc., 59 # +# Temple Place, Suite 330, Boston, MA 02111-1307 USA # +############################################################################### + +import logging +import os +import os.path + +from PyQt4 import QtCore, QtGui + +from bibleimportwizard import Ui_BibleImportWizard +from openlp.core.lib import Receiver + +class BibleFormat(object): + Unknown = -1 + OSIS = 0 + CSV = 1 + OpenSong = 2 + WebDownload = 3 + + +class ImportWizardForm(QtGui.QWizard, Ui_BibleImportWizard): + """ + This is the Bible Import Wizard, which allows easy importing of Bibles + into OpenLP from other formats like OSIS, CSV and OpenSong. + """ + + global log + log = logging.getLogger(u'BibleImportForm') + log.info(u'BibleImportForm loaded') + + def __init__(self, parent, config, biblemanager, bibleplugin): + ''' + Constructor + ''' + QtGui.QWizard.__init__(self, parent) + self.setupUi(self) + self.registerFields() + self.biblemanager = biblemanager + self.config = config + self.bibleplugin = bibleplugin + self.bible_type = BibleFormat.Unknown + + def registerFields(self): + self.SelectPage.registerField(u'source_format', self.FormatComboBox) + self.SelectPage.registerField(u'osis_biblename', self.OsisBibleNameEdit) + self.SelectPage.registerField(u'osis_location', self.OSISLocationEdit) + self.SelectPage.registerField(u'csv_booksfile', self.BooksLocationEdit) + self.SelectPage.registerField(u'csv_versefile', self.CsvVerseLocationEdit) + self.SelectPage.registerField(u'opensong_file', self.OpenSongFileEdit) + self.SelectPage.registerField(u'web_location', self.LocationComboBox) + self.SelectPage.registerField(u'web_biblename', self.BibleComboBox) + self.SelectPage.registerField(u'web_server', self.AddressEdit) + self.SelectPage.registerField(u'web_username', self.UsernameEdit) + self.SelectPage.registerField(u'web_password', self.PasswordEdit) + self.LicenseDetailsPage.registerField(u'license_version', self.VersionNameEdit) + self.LicenseDetailsPage.registerField(u'license_copyright', self.CopyrightEdit) + self.LicenseDetailsPage.registerField(u'license_permission', self.PermissionEdit) + + def validateCurrentPage(self): + if self.currentId() == 0: + # Welcome page + return True + elif self.currentId() == 1: + # Select page + if self.field(u'source_format').toInt()[0] == BibleFormat.OSIS: + if self.field(u'osis_biblename').toString() == u'': + QtGui.QMessageBox.critical(self, + self.trUtf8('Invalid Bible Name'), + self.trUtf8('You need to specify a name for your Bible!'), + QtGui.QMessageBox.StandardButtons(QtGui.QMessageBox.Ok)) + self.OsisBibleNameEdit.setFocus() + return False + if self.field(u'osis_location').toString() == u'': + QtGui.QMessageBox.critical(self, + self.trUtf8('Invalid Bible Location'), + self.trUtf8('You need to specify a file to import your Bible from!'), + QtGui.QMessageBox.StandardButtons(QtGui.QMessageBox.Ok)) + self.OSISLocationEdit.setFocus() + return False + elif self.field(u'source_format').toInt()[0] == BibleFormat.CSV: + if self.field(u'csv_booksfile').toString() == QtCore.QString(u''): + QtGui.QMessageBox.critical(self, + self.trUtf8('Invalid Books File'), + self.trUtf8('You need to specify a file with books of the Bible to use in the import!'), + QtGui.QMessageBox.StandardButtons(QtGui.QMessageBox.Ok)) + self.BooksLocationEdit.setFocus() + return False + elif self.field(u'csv_versefile').toString() == QtCore.QString(u''): + QtGui.QMessageBox.critical(self, + self.trUtf8('Invalid Verse File'), + self.trUtf8('You need to specify a file of Bible verses to import!'), + QtGui.QMessageBox.StandardButtons(QtGui.QMessageBox.Ok)) + self.CsvVerseLocationEdit.setFocus() + return False + elif self.field(u'source_format').toInt()[0] == BibleFormat.OpenSong: + if self.field(u'opensong_file').toString() == QtCore.QString(u''): + QtGui.QMessageBox.critical(self, + self.trUtf8('Invalid OpenSong Bible'), + self.trUtf8('You need to specify an OpenSong Bible file to import!'), + QtGui.QMessageBox.StandardButtons(QtGui.QMessageBox.Ok)) + self.OpenSongFileEdit.setFocus() + return False + return True + + def show(self): + self.FormatComboBox.setCurrentIndex(0) + self.FormatWidget.setCurrentIndex(0) + self.WebDownloadTabWidget.setCurrentIndex(0) + return QtGui.QWizard.show() + diff --git a/openlp/plugins/bibles/lib/bibleCSVimpl.py b/openlp/plugins/bibles/lib/bibleCSVimpl.py index e356f4c4f..0d419072c 100644 --- a/openlp/plugins/bibles/lib/bibleCSVimpl.py +++ b/openlp/plugins/bibles/lib/bibleCSVimpl.py @@ -100,6 +100,7 @@ class BibleCSVImpl(BibleCommon): if count % 3 == 0: Receiver.send_message(u'process_events') count = 0 + self.bibledb.save_verses() except: log.exception(u'Loading verses from file failed') finally: diff --git a/openlp/plugins/bibles/lib/bibleDBimpl.py b/openlp/plugins/bibles/lib/bibleDBimpl.py index d0810f27c..f6e5d5480 100644 --- a/openlp/plugins/bibles/lib/bibleDBimpl.py +++ b/openlp/plugins/bibles/lib/bibleDBimpl.py @@ -67,6 +67,9 @@ class BibleDBImpl(BibleCommon): verse.verse = vse verse.text = text self.session.add(verse) + return verse + + def save_verses(self): self.session.commit() def create_chapter(self, bookid, chap, textlist): diff --git a/openlp/plugins/bibles/lib/bibleOSISimpl.py b/openlp/plugins/bibles/lib/bibleOSISimpl.py index 089649b89..5c60e4617 100644 --- a/openlp/plugins/bibles/lib/bibleOSISimpl.py +++ b/openlp/plugins/bibles/lib/bibleOSISimpl.py @@ -112,7 +112,7 @@ class BibleOSISImpl(): count = 0 verseText = u' + + Wizard + + + + 0 + 0 + 550 + 386 + + + + Bible Import Wizard + + + true + + + QWizard::ModernStyle + + + QWizard::NoBackButtonOnLastPage|QWizard::NoBackButtonOnStartPage + + + + + + + + + + + 8 + + + 0 + + + + + + 163 + 0 + + + + + 163 + 16777215 + + + + 0 + + + + + + :/wizards/wizard_importbible.bmp + + + 0 + + + + + + + 8 + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body > +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:14pt; font-weight:600;">Welcome to the Bible Import Wizard</span></p></body></html> + + + + + + + Qt::Vertical + + + QSizePolicy::Fixed + + + + 20 + 40 + + + + + + + + This wizard will help you to import Bibles from a variety of formats. Click the next button below to start the process by selecting a format to import from. + + + true + + + 10 + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + + + Select Import Source + + + Select the import format, and where to import from. + + + + 8 + + + 20 + + + + + 8 + + + + + Format: + + + + + + + + OSIS + + + + + CSV + + + + + OpenSong + + + + + Web Download + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + 0 + + + + + QFormLayout::ExpandingFieldsGrow + + + 8 + + + 8 + + + 0 + + + + + Bible Name: + + + 0 + + + + + + + + + + File Location: + + + + + + + 8 + + + + + + + + + 32 + 16777215 + + + + + + + + :/imports/import_load.png:/imports/import_load.png + + + + + + + + + + + QFormLayout::ExpandingFieldsGrow + + + Qt::AlignBottom|Qt::AlignRight|Qt::AlignTrailing + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop + + + 8 + + + 8 + + + 0 + + + + + Books Location: + + + + + + + 8 + + + + + + + + + 32 + 16777215 + + + + + + + + :/imports/import_load.png:/imports/import_load.png + + + + + + + + + Verse Location: + + + + + + + 8 + + + + + + + + + 32 + 16777215 + + + + + + + + :/imports/import_load.png:/imports/import_load.png + + + + + + + + + + + 8 + + + 8 + + + 0 + + + + + Bible Filename: + + + + + + + 8 + + + + + + + + + + + + :/imports/import_load.png:/imports/import_load.png + + + + + + + + + + + 8 + + + 0 + + + + + 0 + + + + Download Options + + + + 8 + + + 8 + + + 8 + + + + + Location: + + + + + + + + Crosswalk + + + + + + + + Bible: + + + + + + + QComboBox::AdjustToContents + + + + English Standard Version + + + + + King James Version + + + + + New International Version + + + + + + + + + Proxy Server (Optional) + + + + + + Server: + + + + + + + + + + Username: + + + + + + + + + + Password: + + + + + + + + + + + + + + + + + + + License Details + + + Set up the Bible's license details. + + + + 8 + + + 8 + + + 20 + + + + + Version Name: + + + + + + + + + + Copyright: + + + + + + + + + + Permission: + + + + + + + + + + + Importing + + + Please wait while your Bible is imported. + + + + 8 + + + 50 + + + + + Ready. + + + + + + + 0 + + + false + + + %p + + + + + + + + + + + + FormatComboBox + currentIndexChanged(int) + FormatWidget + setCurrentIndex(int) + + + 106 + 76 + + + 296 + 147 + + + + +