From c0de5cfd8880c3277be6e2f4ad1255676c5d8e15 Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Thu, 3 Feb 2011 17:11:20 +0000 Subject: [PATCH 01/68] Fix up exception form --- openlp.pyw | 1 + openlp/core/ui/exceptiondialog.py | 23 ++++ openlp/core/ui/exceptionform.py | 30 ++++- resources/forms/exceptiondialog.ui | 194 ++++++++++++++++++----------- 4 files changed, 170 insertions(+), 78 deletions(-) diff --git a/openlp.pyw b/openlp.pyw index 8d20080c9..4704a8740 100755 --- a/openlp.pyw +++ b/openlp.pyw @@ -196,6 +196,7 @@ class OpenLP(QtGui.QApplication): self.mainWindow.repaint() update_check = QtCore.QSettings().value( u'general/update check', QtCore.QVariant(True)).toBool() + a=c if update_check: VersionThread(self.mainWindow, app_version).start() return self.exec_() diff --git a/openlp/core/ui/exceptiondialog.py b/openlp/core/ui/exceptiondialog.py index 69035dc4d..9e9b558df 100644 --- a/openlp/core/ui/exceptiondialog.py +++ b/openlp/core/ui/exceptiondialog.py @@ -46,6 +46,15 @@ class Ui_ExceptionDialog(object): self.messageLabel.setObjectName(u'messageLabel') self.messageLayout.addWidget(self.messageLabel) self.exceptionLayout.addLayout(self.messageLayout) + self.descriptionExplanation = QtGui.QLabel(exceptionDialog) + self.descriptionExplanation.setObjectName(u'descriptionExplanation') + self.exceptionLayout.addWidget(self.descriptionExplanation) + self.descriptionTextEdit = QtGui.QPlainTextEdit(exceptionDialog) + self.descriptionTextEdit.setObjectName(u'descriptionTextEdit') + self.exceptionLayout.addWidget(self.descriptionTextEdit) + self.descriptionWordCount = QtGui.QLabel(exceptionDialog) + self.descriptionWordCount.setObjectName(u'descriptionWordCount') + self.exceptionLayout.addWidget(self.descriptionWordCount) self.exceptionTextEdit = QtGui.QPlainTextEdit(exceptionDialog) self.exceptionTextEdit.setReadOnly(True) self.exceptionTextEdit.setObjectName(u'exceptionTextEdit') @@ -65,19 +74,31 @@ class Ui_ExceptionDialog(object): self.saveReportButton.setObjectName(u'saveReportButton') self.exceptionButtonBox.addButton(self.saveReportButton, QtGui.QDialogButtonBox.ActionRole) + self.attachFileButton = QtGui.QPushButton(exceptionDialog) + self.attachFileButton.setIcon(build_icon(u':/general/general_open.png')) + self.attachFileButton.setObjectName(u'attachFileButton') + self.exceptionButtonBox.addButton(self.attachFileButton, + QtGui.QDialogButtonBox.ActionRole) self.retranslateUi(exceptionDialog) + QtCore.QObject.connect(self.descriptionTextEdit, + QtCore.SIGNAL(u'textChanged()'), self.onDescriptionUpdated) QtCore.QObject.connect(self.exceptionButtonBox, QtCore.SIGNAL(u'rejected()'), exceptionDialog.reject) QtCore.QObject.connect(self.sendReportButton, QtCore.SIGNAL(u'pressed()'), self.onSendReportButtonPressed) QtCore.QObject.connect(self.saveReportButton, QtCore.SIGNAL(u'pressed()'), self.onSaveReportButtonPressed) + QtCore.QObject.connect(self.attachFileButton, + QtCore.SIGNAL(u'pressed()'), self.onAttachFileButtonPressed) QtCore.QMetaObject.connectSlotsByName(exceptionDialog) def retranslateUi(self, exceptionDialog): exceptionDialog.setWindowTitle( translate('OpenLP.ExceptionDialog', 'Error Occurred')) + self.descriptionExplanation.setText(translate('OpenLP.ExceptionDialog', + 'Please enter a description of what you were doing to cause this ' + 'error')) self.messageLabel.setText(translate('OpenLP.ExceptionDialog', 'Oops! ' 'OpenLP hit a problem, and couldn\'t recover. The text in the box ' 'below contains information that might be helpful to the OpenLP ' @@ -88,3 +109,5 @@ class Ui_ExceptionDialog(object): 'Send E-Mail')) self.saveReportButton.setText(translate('OpenLP.ExceptionDialog', 'Save to File')) + self.attachFileButton.setText(translate('OpenLP.ExceptionDialog', + 'Attach File')) diff --git a/openlp/core/ui/exceptionform.py b/openlp/core/ui/exceptionform.py index 347bcf8f1..ff37770d2 100644 --- a/openlp/core/ui/exceptionform.py +++ b/openlp/core/ui/exceptionform.py @@ -70,8 +70,13 @@ class ExceptionForm(QtGui.QDialog, Ui_ExceptionDialog): self.setupUi(self) self.settingsSection = u'crashreport' + def exec_(self): + self.onDescriptionUpdated() + return QtGui.QDialog.exec_(self) + def _createReport(self): openlp_version = self.parent().applicationVersion[u'full'] + description = unicode(self.descriptionTextEdit.toPlainText()) traceback = unicode(self.exceptionTextEdit.toPlainText()) system = unicode(translate('OpenLP.ExceptionForm', 'Platform: %s\n')) % platform.platform() @@ -90,7 +95,7 @@ class ExceptionForm(QtGui.QDialog, Ui_ExceptionDialog): system = system + u'Desktop: KDE SC\n' elif os.environ.get(u'GNOME_DESKTOP_SESSION_ID'): system = system + u'Desktop: GNOME\n' - return (openlp_version, traceback, system, libraries) + return (openlp_version, description, traceback, system, libraries) def onSaveReportButtonPressed(self): """ @@ -99,6 +104,7 @@ class ExceptionForm(QtGui.QDialog, Ui_ExceptionDialog): report = unicode(translate('OpenLP.ExceptionForm', '**OpenLP Bug Report**\n' 'Version: %s\n\n' + '--- Details of the Exception. ---\n\n%s\n\n ' '--- Exception Traceback ---\n%s\n' '--- System information ---\n%s\n' '--- Library Versions ---\n%s\n')) @@ -129,10 +135,11 @@ class ExceptionForm(QtGui.QDialog, Ui_ExceptionDialog): Opening systems default email client and inserting exception log and system informations. """ + attach = None body = unicode(translate('OpenLP.ExceptionForm', '*OpenLP Bug Report*\n' 'Version: %s\n\n' - '--- Please enter the report below this line. ---\n\n\n' + '--- Details of the Exception. ---\n\n%s\n\n ' '--- Exception Traceback ---\n%s\n' '--- System information ---\n%s\n' '--- Library Versions ---\n%s\n', @@ -145,5 +152,20 @@ class ExceptionForm(QtGui.QDialog, Ui_ExceptionDialog): if u':' in line: exception = line.split(u'\n')[-1].split(u':')[0] subject = u'Bug report: %s in %s' % (exception, source) - mailto(address=u'bugs@openlp.org', subject=subject, - body=body % content) + if attach: + mailto(address=u'bugs@openlp.org', subject=subject, + body=body % content, attach=attach) + else: + mailto(address=u'bugs@openlp.org', subject=subject, + body=body % content) + + def onDescriptionUpdated(self): + count = int(20 - len(self.descriptionTextEdit.toPlainText())) + if count < 0: + count = 0 + self.descriptionWordCount.setText( + unicode(translate('OpenLP.ExceptionDialog', + 'Characters to Enter : %s')) % count ) + + def onAttachFileButtonPressed(self): + print self.descriptionTextEdit.toPlainText() diff --git a/resources/forms/exceptiondialog.ui b/resources/forms/exceptiondialog.ui index f6f15cdc7..9fd138092 100644 --- a/resources/forms/exceptiondialog.ui +++ b/resources/forms/exceptiondialog.ui @@ -13,82 +13,128 @@ Dialog - - - 8 + + + + 8 + 194 + 564 + 171 + - - 8 + + true - - - - 0 - - - 0 - - - 0 - - - - - - 64 - 64 - - - - - 64 - 64 - - - - - - - :/graphics/exception.png - - - Qt::AlignCenter - - - - - - - Oops! OpenLP hit a problem, and couldn't recover. The text in the box below contains information that might be helpful to the OpenLP developers, so please e-mail it to bugs@openlp.org, along with a detailed description of what you were doing when the problem occurred. - - - true - - - - - - - - - true - - - false - - - - - - - Qt::Horizontal - - - QDialogButtonBox::Close - - - - + + false + + + + + + 8 + 373 + 83 + 26 + + + + Qt::Horizontal + + + QDialogButtonBox::Close + + + + + + 8 + 103 + 561 + 71 + + + + + 0 + 0 + + + + + + + 10 + 170 + 301 + 17 + + + + TextLabel + + + + + + 10 + 80 + 59 + 17 + + + + TextLabel + + + + + + 0 + + + 0 + + + 0 + + + + + + 64 + 64 + + + + + 64 + 64 + + + + + + + :/graphics/exception.png + + + Qt::AlignCenter + + + + + + + Oops! OpenLP hit a problem, and couldn't recover. The text in the box below contains information that might be helpful to the OpenLP developers, so please e-mail it to bugs@openlp.org, along with a detailed description of what you were doing when the problem occurred. + + + true + + + + + From ccfc9abc734e416ce1a538fce7109c179fd80a7e Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Thu, 3 Feb 2011 17:23:24 +0000 Subject: [PATCH 02/68] Fix up exception form - part 2 --- openlp.pyw | 1 + openlp/core/ui/exceptionform.py | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/openlp.pyw b/openlp.pyw index 4704a8740..695d6e09f 100755 --- a/openlp.pyw +++ b/openlp.pyw @@ -217,6 +217,7 @@ class OpenLP(QtGui.QApplication): Sets the Busy Cursor for the Application """ self.setOverrideCursor(QtCore.Qt.BusyCursor) + self.processEvents() def setNormalCursor(self): """ diff --git a/openlp/core/ui/exceptionform.py b/openlp/core/ui/exceptionform.py index ff37770d2..f9a9c59e0 100644 --- a/openlp/core/ui/exceptionform.py +++ b/openlp/core/ui/exceptionform.py @@ -146,7 +146,7 @@ class ExceptionForm(QtGui.QDialog, Ui_ExceptionDialog): 'Please add the information that bug reports are favoured written ' 'in English.')) content = self._createReport() - for line in content[1].split(u'\n'): + for line in content[2].split(u'\n'): if re.search(r'[/\\]openlp[/\\]', line): source = re.sub(r'.*[/\\]openlp[/\\](.*)".*', r'\1', line) if u':' in line: From eb9364b45e17d049c15a4b1fd2abd50c985b8f17 Mon Sep 17 00:00:00 2001 From: Jon Tibble Date: Thu, 3 Feb 2011 17:56:22 +0000 Subject: [PATCH 03/68] UI library - delete_push_button --- openlp/core/lib/ui.py | 17 ++++++++++++++++- openlp/core/ui/serviceitemeditdialog.py | 7 ++----- openlp/core/ui/serviceitemeditform.py | 4 +--- openlp/plugins/alerts/forms/alertdialog.py | 7 ++----- openlp/plugins/alerts/forms/alertform.py | 4 +--- openlp/plugins/custom/forms/editcustomdialog.py | 10 ++-------- openlp/plugins/custom/forms/editcustomform.py | 4 +--- 7 files changed, 25 insertions(+), 28 deletions(-) diff --git a/openlp/core/lib/ui.py b/openlp/core/lib/ui.py index 8cfffef45..2c8853744 100644 --- a/openlp/core/lib/ui.py +++ b/openlp/core/lib/ui.py @@ -30,7 +30,7 @@ import logging from PyQt4 import QtCore, QtGui -from openlp.core.lib import translate +from openlp.core.lib import build_icon, translate log = logging.getLogger(__name__) @@ -108,3 +108,18 @@ def media_item_combo_box(parent, name): combo.setSizeAdjustPolicy(QtGui.QComboBox.AdjustToMinimumContentsLength) combo.setSizePolicy(QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Fixed) return combo + +def delete_push_button(parent, icon=None): + """ + Return a standard push button with delete label. + """ + delete_button = QtGui.QPushButton(parent) + delete_button.setObjectName(u'deleteButton') + delete_icon = icon if icon else u':/general/general_delete.png' + delete_button.setIcon(build_icon(delete_icon)) + delete_button.setText(translate('OpenLP.Ui', '&Delete')) + delete_button.setToolTip( + translate('OpenLP.Ui', 'Delete the selected item.')) + QtCore.QObject.connect(delete_button, + QtCore.SIGNAL(u'clicked()'), parent.onDeleteButtonClicked) + return delete_button diff --git a/openlp/core/ui/serviceitemeditdialog.py b/openlp/core/ui/serviceitemeditdialog.py index d4c86fa61..44304f8e6 100644 --- a/openlp/core/ui/serviceitemeditdialog.py +++ b/openlp/core/ui/serviceitemeditdialog.py @@ -27,7 +27,7 @@ from PyQt4 import QtCore, QtGui from openlp.core.lib import translate, build_icon -from openlp.core.lib.ui import save_cancel_button_box +from openlp.core.lib.ui import save_cancel_button_box, delete_push_button class Ui_ServiceItemEditDialog(object): def setupUi(self, serviceItemEditDialog): @@ -40,8 +40,7 @@ class Ui_ServiceItemEditDialog(object): self.dialogLayout.addWidget(self.listWidget, 0, 0) self.buttonLayout = QtGui.QVBoxLayout() self.buttonLayout.setObjectName(u'buttonLayout') - self.deleteButton = QtGui.QPushButton(serviceItemEditDialog) - self.deleteButton.setObjectName(u'deleteButton') + self.deleteButton = delete_push_button(serviceItemEditDialog) self.buttonLayout.addWidget(self.deleteButton) self.buttonLayout.addStretch() self.upButton = QtGui.QPushButton(serviceItemEditDialog) @@ -61,5 +60,3 @@ class Ui_ServiceItemEditDialog(object): def retranslateUi(self, serviceItemEditDialog): serviceItemEditDialog.setWindowTitle( translate('OpenLP.ServiceItemEditForm', 'Reorder Service Item')) - self.deleteButton.setText(translate('OpenLP.ServiceItemEditForm', - 'Delete')) diff --git a/openlp/core/ui/serviceitemeditform.py b/openlp/core/ui/serviceitemeditform.py index 0621a44bd..808c0c179 100644 --- a/openlp/core/ui/serviceitemeditform.py +++ b/openlp/core/ui/serviceitemeditform.py @@ -44,8 +44,6 @@ class ServiceItemEditForm(QtGui.QDialog, Ui_ServiceItemEditDialog): QtCore.SIGNAL(u'clicked()'), self.onItemUp) QtCore.QObject.connect(self.downButton, QtCore.SIGNAL(u'clicked()'), self.onItemDown) - QtCore.QObject.connect(self.deleteButton, - QtCore.SIGNAL(u'clicked()'), self.onItemDelete) QtCore.QObject.connect(self.listWidget, QtCore.SIGNAL(u'currentRowChanged(int)'), self.onCurrentRowChanged) @@ -77,7 +75,7 @@ class ServiceItemEditForm(QtGui.QDialog, Ui_ServiceItemEditDialog): item_name = QtGui.QListWidgetItem(frame[u'title']) self.listWidget.addItem(item_name) - def onItemDelete(self): + def onDeleteButtonClicked(self): """ Delete the current row. """ diff --git a/openlp/plugins/alerts/forms/alertdialog.py b/openlp/plugins/alerts/forms/alertdialog.py index 272a96f3d..7a824c4d6 100644 --- a/openlp/plugins/alerts/forms/alertdialog.py +++ b/openlp/plugins/alerts/forms/alertdialog.py @@ -27,6 +27,7 @@ from PyQt4 import QtCore, QtGui from openlp.core.lib import build_icon, translate +from openlp.core.lib.ui import delete_push_button class Ui_AlertDialog(object): def setupUi(self, alertDialog): @@ -65,9 +66,7 @@ class Ui_AlertDialog(object): self.saveButton.setIcon(build_icon(u':/general/general_save.png')) self.saveButton.setObjectName(u'saveButton') self.manageButtonLayout.addWidget(self.saveButton) - self.deleteButton = QtGui.QPushButton(alertDialog) - self.deleteButton.setIcon(build_icon(u':/general/general_delete.png')) - self.deleteButton.setObjectName(u'deleteButton') + self.deleteButton = delete_push_button(alertDialog) self.manageButtonLayout.addWidget(self.deleteButton) self.manageButtonLayout.addStretch() self.alertDialogLayout.addLayout(self.manageButtonLayout, 1, 1) @@ -101,8 +100,6 @@ class Ui_AlertDialog(object): translate('AlertsPlugin.AlertForm', '&New')) self.saveButton.setText( translate('AlertsPlugin.AlertForm', '&Save')) - self.deleteButton.setText( - translate('AlertsPlugin.AlertForm', '&Delete')) self.displayButton.setText( translate('AlertsPlugin.AlertForm', 'Displ&ay')) self.displayCloseButton.setText( diff --git a/openlp/plugins/alerts/forms/alertform.py b/openlp/plugins/alerts/forms/alertform.py index f1a0f7fea..6b3b2a9e0 100644 --- a/openlp/plugins/alerts/forms/alertform.py +++ b/openlp/plugins/alerts/forms/alertform.py @@ -52,8 +52,6 @@ class AlertForm(QtGui.QDialog, Ui_AlertDialog): QtCore.SIGNAL(u'textChanged(const QString&)'), self.onTextChanged) QtCore.QObject.connect(self.newButton, QtCore.SIGNAL(u'clicked()'), self.onNewClick) - QtCore.QObject.connect(self.deleteButton, QtCore.SIGNAL(u'clicked()'), - self.onDeleteClick) QtCore.QObject.connect(self.saveButton, QtCore.SIGNAL(u'clicked()'), self.onSaveClick) QtCore.QObject.connect(self.alertListWidget, @@ -83,7 +81,7 @@ class AlertForm(QtGui.QDialog, Ui_AlertDialog): if self.triggerAlert(unicode(self.alertTextEdit.text())): self.close() - def onDeleteClick(self): + def onDeleteButtonClicked(self): """ Deletes the selected item. """ diff --git a/openlp/plugins/custom/forms/editcustomdialog.py b/openlp/plugins/custom/forms/editcustomdialog.py index 75717c082..d7de805dd 100644 --- a/openlp/plugins/custom/forms/editcustomdialog.py +++ b/openlp/plugins/custom/forms/editcustomdialog.py @@ -27,7 +27,7 @@ from PyQt4 import QtCore, QtGui from openlp.core.lib import build_icon, translate -from openlp.core.lib.ui import save_cancel_button_box +from openlp.core.lib.ui import save_cancel_button_box, delete_push_button class Ui_CustomEditDialog(object): def setupUi(self, customEditDialog): @@ -64,8 +64,7 @@ class Ui_CustomEditDialog(object): self.editAllButton = QtGui.QPushButton(customEditDialog) self.editAllButton.setObjectName(u'editAllButton') self.buttonLayout.addWidget(self.editAllButton) - self.deleteButton = QtGui.QPushButton(customEditDialog) - self.deleteButton.setObjectName(u'deleteButton') + self.deleteButton = delete_push_button(customEditDialog) self.buttonLayout.addWidget(self.deleteButton) self.buttonLayout.addStretch() self.upButton = QtGui.QPushButton(customEditDialog) @@ -125,11 +124,6 @@ class Ui_CustomEditDialog(object): self.editAllButton.setToolTip( translate('CustomPlugin.EditCustomForm', 'Edit all the slides at ' 'once.')) - self.deleteButton.setText( - translate('CustomPlugin.EditCustomForm', '&Delete')) - self.deleteButton.setToolTip( - translate('CustomPlugin.EditCustomForm', 'Delete the selected ' - 'slide.')) self.themeLabel.setText( translate('CustomPlugin.EditCustomForm', 'The&me:')) self.creditLabel.setText( diff --git a/openlp/plugins/custom/forms/editcustomform.py b/openlp/plugins/custom/forms/editcustomform.py index e8dfa20aa..896100d67 100644 --- a/openlp/plugins/custom/forms/editcustomform.py +++ b/openlp/plugins/custom/forms/editcustomform.py @@ -62,8 +62,6 @@ class EditCustomForm(QtGui.QDialog, Ui_CustomEditDialog): QtCore.SIGNAL(u'pressed()'), self.onEditButtonPressed) QtCore.QObject.connect(self.editAllButton, QtCore.SIGNAL(u'pressed()'), self.onEditAllButtonPressed) - QtCore.QObject.connect(self.deleteButton, - QtCore.SIGNAL(u'pressed()'), self.onDeleteButtonPressed) QtCore.QObject.connect(self.upButton, QtCore.SIGNAL(u'pressed()'), self.onUpButtonPressed) QtCore.QObject.connect(self.downButton, @@ -243,7 +241,7 @@ class EditCustomForm(QtGui.QDialog, Ui_CustomEditDialog): self.slideListView.addItem(slide) self.slideListView.repaint() - def onDeleteButtonPressed(self): + def onDeleteButtonClicked(self): self.slideListView.takeItem(self.slideListView.currentRow()) self.editButton.setEnabled(True) self.editAllButton.setEnabled(True) From b73a429ab23266677d63a79104c74e05eb600edf Mon Sep 17 00:00:00 2001 From: Jon Tibble Date: Thu, 3 Feb 2011 18:19:56 +0000 Subject: [PATCH 04/68] UI library - up_down_push_button_set --- openlp/core/lib/ui.py | 20 +++++++++++++++++++ openlp/core/ui/serviceitemeditdialog.py | 11 ++++------ openlp/core/ui/serviceitemeditform.py | 9 ++------- .../plugins/custom/forms/editcustomdialog.py | 17 ++++------------ openlp/plugins/custom/forms/editcustomform.py | 8 ++------ 5 files changed, 32 insertions(+), 33 deletions(-) diff --git a/openlp/core/lib/ui.py b/openlp/core/lib/ui.py index 2c8853744..334aaff2b 100644 --- a/openlp/core/lib/ui.py +++ b/openlp/core/lib/ui.py @@ -123,3 +123,23 @@ def delete_push_button(parent, icon=None): QtCore.QObject.connect(delete_button, QtCore.SIGNAL(u'clicked()'), parent.onDeleteButtonClicked) return delete_button + +def up_down_push_button_set(parent): + """ + Return a standard set of two push buttons for up and down use with lists. + """ + up_button = QtGui.QPushButton(parent) + up_button.setIcon(build_icon(u':/services/service_up.png')) + up_button.setObjectName(u'upButton') + up_button.setToolTip( + translate('OpenLP.Ui', 'Move selection up one position.')) + down_button = QtGui.QPushButton(parent) + down_button.setIcon(build_icon(u':/services/service_down.png')) + down_button.setObjectName(u'downButton') + down_button.setToolTip( + translate('OpenLP.Ui', 'Move selection down one position.')) + QtCore.QObject.connect(up_button, + QtCore.SIGNAL(u'clicked()'), parent.onUpButtonClicked) + QtCore.QObject.connect(down_button, + QtCore.SIGNAL(u'clicked()'), parent.onDownButtonClicked) + return up_button, down_button diff --git a/openlp/core/ui/serviceitemeditdialog.py b/openlp/core/ui/serviceitemeditdialog.py index 44304f8e6..be7072026 100644 --- a/openlp/core/ui/serviceitemeditdialog.py +++ b/openlp/core/ui/serviceitemeditdialog.py @@ -27,7 +27,8 @@ from PyQt4 import QtCore, QtGui from openlp.core.lib import translate, build_icon -from openlp.core.lib.ui import save_cancel_button_box, delete_push_button +from openlp.core.lib.ui import save_cancel_button_box, delete_push_button, \ + up_down_push_button_set class Ui_ServiceItemEditDialog(object): def setupUi(self, serviceItemEditDialog): @@ -43,13 +44,9 @@ class Ui_ServiceItemEditDialog(object): self.deleteButton = delete_push_button(serviceItemEditDialog) self.buttonLayout.addWidget(self.deleteButton) self.buttonLayout.addStretch() - self.upButton = QtGui.QPushButton(serviceItemEditDialog) - self.upButton.setIcon(build_icon(u':/services/service_up.png')) - self.upButton.setObjectName(u'upButton') + self.upButton, self.downButton = up_down_push_button_set( + serviceItemEditDialog) self.buttonLayout.addWidget(self.upButton) - self.downButton = QtGui.QPushButton(serviceItemEditDialog) - self.downButton.setIcon(build_icon(u':/services/service_down.png')) - self.downButton.setObjectName(u'downButton') self.buttonLayout.addWidget(self.downButton) self.dialogLayout.addLayout(self.buttonLayout, 0, 1) self.dialogLayout.addWidget( diff --git a/openlp/core/ui/serviceitemeditform.py b/openlp/core/ui/serviceitemeditform.py index 808c0c179..70518f30c 100644 --- a/openlp/core/ui/serviceitemeditform.py +++ b/openlp/core/ui/serviceitemeditform.py @@ -39,11 +39,6 @@ class ServiceItemEditForm(QtGui.QDialog, Ui_ServiceItemEditDialog): QtGui.QDialog.__init__(self, parent) self.setupUi(self) self.itemList = [] - # enable drop - QtCore.QObject.connect(self.upButton, - QtCore.SIGNAL(u'clicked()'), self.onItemUp) - QtCore.QObject.connect(self.downButton, - QtCore.SIGNAL(u'clicked()'), self.onItemDown) QtCore.QObject.connect(self.listWidget, QtCore.SIGNAL(u'currentRowChanged(int)'), self.onCurrentRowChanged) @@ -90,13 +85,13 @@ class ServiceItemEditForm(QtGui.QDialog, Ui_ServiceItemEditDialog): else: self.listWidget.setCurrentRow(row) - def onItemUp(self): + def onUpButtonClicked(self): """ Move the current row up in the list. """ self.__moveItem(u'up') - def onItemDown(self): + def onDownButtonClicked(self): """ Move the current row down in the list """ diff --git a/openlp/plugins/custom/forms/editcustomdialog.py b/openlp/plugins/custom/forms/editcustomdialog.py index d7de805dd..b73899057 100644 --- a/openlp/plugins/custom/forms/editcustomdialog.py +++ b/openlp/plugins/custom/forms/editcustomdialog.py @@ -27,7 +27,8 @@ from PyQt4 import QtCore, QtGui from openlp.core.lib import build_icon, translate -from openlp.core.lib.ui import save_cancel_button_box, delete_push_button +from openlp.core.lib.ui import save_cancel_button_box, delete_push_button, \ + up_down_push_button_set class Ui_CustomEditDialog(object): def setupUi(self, customEditDialog): @@ -67,13 +68,9 @@ class Ui_CustomEditDialog(object): self.deleteButton = delete_push_button(customEditDialog) self.buttonLayout.addWidget(self.deleteButton) self.buttonLayout.addStretch() - self.upButton = QtGui.QPushButton(customEditDialog) - self.upButton.setIcon(build_icon(u':/services/service_up.png')) - self.upButton.setObjectName(u'upButton') + self.upButton, self.downButton = up_down_push_button_set( + customEditDialog) self.buttonLayout.addWidget(self.upButton) - self.downButton = QtGui.QPushButton(customEditDialog) - self.downButton.setIcon(build_icon(u':/services/service_down.png')) - self.downButton.setObjectName(u'downButton') self.buttonLayout.addWidget(self.downButton) self.centralLayout.addLayout(self.buttonLayout) self.dialogLayout.addLayout(self.centralLayout) @@ -101,12 +98,6 @@ class Ui_CustomEditDialog(object): def retranslateUi(self, customEditDialog): customEditDialog.setWindowTitle( translate('CustomPlugin.EditCustomForm', 'Edit Custom Slides')) - self.upButton.setToolTip( - translate('CustomPlugin.EditCustomForm', 'Move slide up one ' - 'position.')) - self.downButton.setToolTip( - translate('CustomPlugin.EditCustomForm', 'Move slide down one ' - 'position.')) self.titleLabel.setText( translate('CustomPlugin.EditCustomForm', '&Title:')) self.addButton.setText( diff --git a/openlp/plugins/custom/forms/editcustomform.py b/openlp/plugins/custom/forms/editcustomform.py index 896100d67..5a32d6cc1 100644 --- a/openlp/plugins/custom/forms/editcustomform.py +++ b/openlp/plugins/custom/forms/editcustomform.py @@ -62,10 +62,6 @@ class EditCustomForm(QtGui.QDialog, Ui_CustomEditDialog): QtCore.SIGNAL(u'pressed()'), self.onEditButtonPressed) QtCore.QObject.connect(self.editAllButton, QtCore.SIGNAL(u'pressed()'), self.onEditAllButtonPressed) - QtCore.QObject.connect(self.upButton, - QtCore.SIGNAL(u'pressed()'), self.onUpButtonPressed) - QtCore.QObject.connect(self.downButton, - QtCore.SIGNAL(u'pressed()'), self.onDownButtonPressed) QtCore.QObject.connect(self.slideListView, QtCore.SIGNAL(u'itemClicked(QListWidgetItem*)'), self.onSlideListViewPressed) @@ -166,14 +162,14 @@ class EditCustomForm(QtGui.QDialog, Ui_CustomEditDialog): self.customSlide.theme_name = unicode(self.themeComboBox.currentText()) return self.manager.save_object(self.customSlide) - def onUpButtonPressed(self): + def onUpButtonClicked(self): selectedRow = self.slideListView.currentRow() if selectedRow != 0: qw = self.slideListView.takeItem(selectedRow) self.slideListView.insertItem(selectedRow - 1, qw) self.slideListView.setCurrentRow(selectedRow - 1) - def onDownButtonPressed(self): + def onDownButtonClicked(self): selectedRow = self.slideListView.currentRow() # zero base arrays if selectedRow != self.slideListView.count() - 1: From 2069737e1f00cd2934abc826ecd38b3180950b64 Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Thu, 3 Feb 2011 18:48:41 +0000 Subject: [PATCH 05/68] remove extra post events --- openlp/core/ui/servicemanager.py | 1 - openlp/plugins/bibles/lib/http.py | 1 - openlp/plugins/songs/forms/songmaintenanceform.py | 1 - 3 files changed, 3 deletions(-) diff --git a/openlp/core/ui/servicemanager.py b/openlp/core/ui/servicemanager.py index 4d36f4aec..bddd150b8 100644 --- a/openlp/core/ui/servicemanager.py +++ b/openlp/core/ui/servicemanager.py @@ -507,7 +507,6 @@ class ServiceManager(QtGui.QWidget): p_file = filePath if 'p_file' in locals(): Receiver.send_message(u'cursor_busy') - Receiver.send_message(u'openlp_process_events') fileTo = open(p_file, u'r') items = cPickle.load(fileTo) fileTo.close() diff --git a/openlp/plugins/bibles/lib/http.py b/openlp/plugins/bibles/lib/http.py index 8db214140..7cba6facb 100644 --- a/openlp/plugins/bibles/lib/http.py +++ b/openlp/plugins/bibles/lib/http.py @@ -443,7 +443,6 @@ class HTTPBible(BibleDB): book = db_book.name if BibleDB.get_verse_count(self, book, reference[1]) == 0: Receiver.send_message(u'cursor_busy') - Receiver.send_message(u'openlp_process_events') search_results = self.get_chapter(book, reference[1]) if search_results and search_results.has_verselist(): ## We have found a book of the bible lets check to see diff --git a/openlp/plugins/songs/forms/songmaintenanceform.py b/openlp/plugins/songs/forms/songmaintenanceform.py index 737d63204..2aeb30228 100644 --- a/openlp/plugins/songs/forms/songmaintenanceform.py +++ b/openlp/plugins/songs/forms/songmaintenanceform.py @@ -372,7 +372,6 @@ class SongMaintenanceForm(QtGui.QDialog, Ui_SongMaintenanceDialog): Utility method to merge two objects to leave one in the database. """ Receiver.send_message(u'cursor_busy') - Receiver.send_message(u'openlp_process_events') merge(dbObject) reset() Receiver.send_message(u'songs_load_list') From 999f40ffc9ab0b5ca204fe6a5d3c759f8612802e Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Thu, 3 Feb 2011 19:07:27 +0000 Subject: [PATCH 06/68] Exception Form has attachments --- openlp/core/ui/exceptionform.py | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/openlp/core/ui/exceptionform.py b/openlp/core/ui/exceptionform.py index f9a9c59e0..a92967b6c 100644 --- a/openlp/core/ui/exceptionform.py +++ b/openlp/core/ui/exceptionform.py @@ -72,6 +72,7 @@ class ExceptionForm(QtGui.QDialog, Ui_ExceptionDialog): def exec_(self): self.onDescriptionUpdated() + self.fileAttachment = None return QtGui.QDialog.exec_(self) def _createReport(self): @@ -152,9 +153,9 @@ class ExceptionForm(QtGui.QDialog, Ui_ExceptionDialog): if u':' in line: exception = line.split(u'\n')[-1].split(u':')[0] subject = u'Bug report: %s in %s' % (exception, source) - if attach: + if self.fileAttachment: mailto(address=u'bugs@openlp.org', subject=subject, - body=body % content, attach=attach) + body=body % content, attach=self.fileAttachment) else: mailto(address=u'bugs@openlp.org', subject=subject, body=body % content) @@ -163,9 +164,24 @@ class ExceptionForm(QtGui.QDialog, Ui_ExceptionDialog): count = int(20 - len(self.descriptionTextEdit.toPlainText())) if count < 0: count = 0 + self.__buttonState(True) + else: + self.__buttonState(False) self.descriptionWordCount.setText( unicode(translate('OpenLP.ExceptionDialog', 'Characters to Enter : %s')) % count ) def onAttachFileButtonPressed(self): - print self.descriptionTextEdit.toPlainText() + files = QtGui.QFileDialog.getOpenFileName( + self,translate('ImagePlugin.ExceptionDialog', + 'Select Attachment'), + SettingsManager.get_last_dir(u'exceptions'), + u'%s (*.*) (*)' % + unicode(translate('ImagePlugin.MediaItem', 'All Files'))) + log.info(u'New files(s) %s', unicode(files)) + if files: + self.fileAttachment = unicode(files) + + def __buttonState(self, state): + self.saveReportButton.setEnabled(state) + self.sendReportButton.setEnabled(state) From 842e4ba5f3f8af7fb3b1f5748f22a50f122e7f45 Mon Sep 17 00:00:00 2001 From: Jon Tibble Date: Thu, 3 Feb 2011 19:44:03 +0000 Subject: [PATCH 07/68] Cleanup bible import form --- .../plugins/bibles/forms/bibleimportform.py | 39 +++++++------------ 1 file changed, 14 insertions(+), 25 deletions(-) diff --git a/openlp/plugins/bibles/forms/bibleimportform.py b/openlp/plugins/bibles/forms/bibleimportform.py index a2509ba97..882e5c586 100644 --- a/openlp/plugins/bibles/forms/bibleimportform.py +++ b/openlp/plugins/bibles/forms/bibleimportform.py @@ -162,6 +162,8 @@ class BibleImportForm(OpenLPWizard): self.formatLayout.setItem(1, QtGui.QFormLayout.LabelRole, self.formatSpacer) self.selectPageLayout.addLayout(self.formatLayout) + self.typeSpacer = QtGui.QSpacerItem(10, 0, QtGui.QSizePolicy.Fixed, + QtGui.QSizePolicy.Minimum) self.selectStack = QtGui.QStackedLayout() self.selectStack.setObjectName(u'SelectStack') self.osisWidget = QtGui.QWidget(self.selectPage) @@ -181,9 +183,7 @@ class BibleImportForm(OpenLPWizard): self.osisBrowseButton.setObjectName(u'OsisBrowseButton') self.osisFileLayout.addWidget(self.osisBrowseButton) self.osisLayout.addRow(self.osisFileLabel, self.osisFileLayout) - self.osisSpacer = QtGui.QSpacerItem(10, 0, QtGui.QSizePolicy.Fixed, - QtGui.QSizePolicy.Minimum) - self.osisLayout.setItem(1, QtGui.QFormLayout.LabelRole, self.osisSpacer) + self.osisLayout.setItem(1, QtGui.QFormLayout.LabelRole, self.typeSpacer) self.selectStack.addWidget(self.osisWidget) self.csvWidget = QtGui.QWidget(self.selectPage) self.csvWidget.setObjectName(u'CsvWidget') @@ -226,9 +226,7 @@ class BibleImportForm(OpenLPWizard): self.csvVersesButton.setObjectName(u'CsvVersesButton') self.csvVersesLayout.addWidget(self.csvVersesButton) self.csvLayout.addRow(self.csvVersesLabel, self.csvVersesLayout) - self.csvSpacer = QtGui.QSpacerItem(10, 0, QtGui.QSizePolicy.Fixed, - QtGui.QSizePolicy.Minimum) - self.csvLayout.setItem(3, QtGui.QFormLayout.LabelRole, self.csvSpacer) + self.csvLayout.setItem(3, QtGui.QFormLayout.LabelRole, self.typeSpacer) self.selectStack.addWidget(self.csvWidget) self.openSongWidget = QtGui.QWidget(self.selectPage) self.openSongWidget.setObjectName(u'OpenSongWidget') @@ -248,10 +246,8 @@ class BibleImportForm(OpenLPWizard): self.openSongFileLayout.addWidget(self.openSongBrowseButton) self.openSongLayout.addRow(self.openSongFileLabel, self.openSongFileLayout) - self.openSongSpacer = QtGui.QSpacerItem(10, 0, QtGui.QSizePolicy.Fixed, - QtGui.QSizePolicy.Minimum) self.openSongLayout.setItem(1, QtGui.QFormLayout.LabelRole, - self.openSongSpacer) + self.typeSpacer) self.selectStack.addWidget(self.openSongWidget) self.webTabWidget = QtGui.QTabWidget(self.selectPage) self.webTabWidget.setObjectName(u'WebTabWidget') @@ -330,10 +326,8 @@ class BibleImportForm(OpenLPWizard): self.openlp1DisabledLabel.setWordWrap(True) self.openlp1DisabledLabel.setObjectName(u'Openlp1DisabledLabel') self.openlp1Layout.addRow(self.openlp1DisabledLabel) - self.openlp1Spacer = QtGui.QSpacerItem(10, 0, QtGui.QSizePolicy.Fixed, - QtGui.QSizePolicy.Minimum) self.openlp1Layout.setItem(1, QtGui.QFormLayout.LabelRole, - self.openlp1Spacer) + self.typeSpacer) self.selectStack.addWidget(self.openlp1Widget) self.selectPageLayout.addLayout(self.selectStack) self.addPage(self.selectPage) @@ -401,17 +395,17 @@ class BibleImportForm(OpenLPWizard): self.formatComboBox.setItemText(4, translate('BiblesPlugin.ImportWizardForm', 'openlp.org 1.x')) self.openlp1FileLabel.setText( - translate('BiblesPlugin.ImportWizardForm', 'File location:')) + translate('BiblesPlugin.ImportWizardForm', 'Bible file:')) self.osisFileLabel.setText( - translate('BiblesPlugin.ImportWizardForm', 'File location:')) + translate('BiblesPlugin.ImportWizardForm', 'Bible file:')) self.csvTestamentsLabel.setText( - translate('BiblesPlugin.ImportWizardForm', 'Testaments location:')) + translate('BiblesPlugin.ImportWizardForm', 'Testaments file:')) self.csvBooksLabel.setText( - translate('BiblesPlugin.ImportWizardForm', 'Books location:')) + translate('BiblesPlugin.ImportWizardForm', 'Books file:')) self.csvVersesLabel.setText( - translate('BiblesPlugin.ImportWizardForm', 'Verse location:')) + translate('BiblesPlugin.ImportWizardForm', 'Verses file:')) self.openSongFileLabel.setText( - translate('BiblesPlugin.ImportWizardForm', 'Bible filename:')) + translate('BiblesPlugin.ImportWizardForm', 'Bible file:')) self.webSourceLabel.setText( translate('BiblesPlugin.ImportWizardForm', 'Location:')) self.webSourceComboBox.setItemText(0, @@ -462,19 +456,14 @@ class BibleImportForm(OpenLPWizard): # Align all QFormLayouts towards each other. labelWidth = max(self.formatLabel.minimumSizeHint().width(), self.osisFileLabel.minimumSizeHint().width(), + self.csvTestamentsLabel.minimumSizeHint().width(), self.csvBooksLabel.minimumSizeHint().width(), self.csvVersesLabel.minimumSizeHint().width(), self.openSongFileLabel.minimumSizeHint().width(), self.openlp1FileLabel.minimumSizeHint().width()) self.formatSpacer.changeSize(labelWidth, 0, QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Fixed) - self.osisSpacer.changeSize(labelWidth, 0, - QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Fixed) - self.csvSpacer.changeSize(labelWidth, 0, - QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Fixed) - self.openSongSpacer.changeSize(labelWidth, 0, - QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Fixed) - self.openlp1Spacer.changeSize(labelWidth, 0, + self.typeSpacer.changeSize(labelWidth, 0, QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Fixed) def validateCurrentPage(self): From 1ecaab4fa9b23251daa1bb27c5056f62a7b5a9d8 Mon Sep 17 00:00:00 2001 From: Jon Tibble Date: Thu, 3 Feb 2011 20:12:06 +0000 Subject: [PATCH 08/68] Cleanup import wizard spacers --- .../plugins/bibles/forms/bibleimportform.py | 21 +++++++------------ openlp/plugins/songs/forms/songimportform.py | 7 ++++--- 2 files changed, 11 insertions(+), 17 deletions(-) diff --git a/openlp/plugins/bibles/forms/bibleimportform.py b/openlp/plugins/bibles/forms/bibleimportform.py index 882e5c586..f21dd0e07 100644 --- a/openlp/plugins/bibles/forms/bibleimportform.py +++ b/openlp/plugins/bibles/forms/bibleimportform.py @@ -157,13 +157,10 @@ class BibleImportForm(OpenLPWizard): self.formatComboBox.addItems([u'', u'', u'', u'', u'']) self.formatComboBox.setObjectName(u'FormatComboBox') self.formatLayout.addRow(self.formatLabel, self.formatComboBox) - self.formatSpacer = QtGui.QSpacerItem(10, 0, QtGui.QSizePolicy.Fixed, + self.spacer = QtGui.QSpacerItem(10, 0, QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Minimum) - self.formatLayout.setItem(1, QtGui.QFormLayout.LabelRole, - self.formatSpacer) + self.formatLayout.setItem(1, QtGui.QFormLayout.LabelRole, self.spacer) self.selectPageLayout.addLayout(self.formatLayout) - self.typeSpacer = QtGui.QSpacerItem(10, 0, QtGui.QSizePolicy.Fixed, - QtGui.QSizePolicy.Minimum) self.selectStack = QtGui.QStackedLayout() self.selectStack.setObjectName(u'SelectStack') self.osisWidget = QtGui.QWidget(self.selectPage) @@ -183,7 +180,7 @@ class BibleImportForm(OpenLPWizard): self.osisBrowseButton.setObjectName(u'OsisBrowseButton') self.osisFileLayout.addWidget(self.osisBrowseButton) self.osisLayout.addRow(self.osisFileLabel, self.osisFileLayout) - self.osisLayout.setItem(1, QtGui.QFormLayout.LabelRole, self.typeSpacer) + self.osisLayout.setItem(1, QtGui.QFormLayout.LabelRole, self.spacer) self.selectStack.addWidget(self.osisWidget) self.csvWidget = QtGui.QWidget(self.selectPage) self.csvWidget.setObjectName(u'CsvWidget') @@ -226,7 +223,7 @@ class BibleImportForm(OpenLPWizard): self.csvVersesButton.setObjectName(u'CsvVersesButton') self.csvVersesLayout.addWidget(self.csvVersesButton) self.csvLayout.addRow(self.csvVersesLabel, self.csvVersesLayout) - self.csvLayout.setItem(3, QtGui.QFormLayout.LabelRole, self.typeSpacer) + self.csvLayout.setItem(3, QtGui.QFormLayout.LabelRole, self.spacer) self.selectStack.addWidget(self.csvWidget) self.openSongWidget = QtGui.QWidget(self.selectPage) self.openSongWidget.setObjectName(u'OpenSongWidget') @@ -246,8 +243,7 @@ class BibleImportForm(OpenLPWizard): self.openSongFileLayout.addWidget(self.openSongBrowseButton) self.openSongLayout.addRow(self.openSongFileLabel, self.openSongFileLayout) - self.openSongLayout.setItem(1, QtGui.QFormLayout.LabelRole, - self.typeSpacer) + self.openSongLayout.setItem(1, QtGui.QFormLayout.LabelRole, self.spacer) self.selectStack.addWidget(self.openSongWidget) self.webTabWidget = QtGui.QTabWidget(self.selectPage) self.webTabWidget.setObjectName(u'WebTabWidget') @@ -326,8 +322,7 @@ class BibleImportForm(OpenLPWizard): self.openlp1DisabledLabel.setWordWrap(True) self.openlp1DisabledLabel.setObjectName(u'Openlp1DisabledLabel') self.openlp1Layout.addRow(self.openlp1DisabledLabel) - self.openlp1Layout.setItem(1, QtGui.QFormLayout.LabelRole, - self.typeSpacer) + self.openlp1Layout.setItem(1, QtGui.QFormLayout.LabelRole, self.spacer) self.selectStack.addWidget(self.openlp1Widget) self.selectPageLayout.addLayout(self.selectStack) self.addPage(self.selectPage) @@ -461,9 +456,7 @@ class BibleImportForm(OpenLPWizard): self.csvVersesLabel.minimumSizeHint().width(), self.openSongFileLabel.minimumSizeHint().width(), self.openlp1FileLabel.minimumSizeHint().width()) - self.formatSpacer.changeSize(labelWidth, 0, - QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Fixed) - self.typeSpacer.changeSize(labelWidth, 0, + self.spacer.changeSize(labelWidth, 0, QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Fixed) def validateCurrentPage(self): diff --git a/openlp/plugins/songs/forms/songimportform.py b/openlp/plugins/songs/forms/songimportform.py index f1e1f82ed..a9af7f6b2 100644 --- a/openlp/plugins/songs/forms/songimportform.py +++ b/openlp/plugins/songs/forms/songimportform.py @@ -162,6 +162,8 @@ class SongImportForm(OpenLPWizard): self.formatLayout.setItem(1, QtGui.QFormLayout.LabelRole, self.formatSpacer) self.sourceLayout.addLayout(self.formatLayout) + self.stackSpacer = QtGui.QSpacerItem(10, 0, QtGui.QSizePolicy.Fixed, + QtGui.QSizePolicy.Expanding) self.formatStack = QtGui.QStackedLayout() self.formatStack.setObjectName(u'FormatStack') # OpenLP 2.0 @@ -807,10 +809,8 @@ class SongImportForm(OpenLPWizard): browseButton.setIcon(self.openIcon) browseButton.setObjectName(obj_prefix + u'BrowseButton') fileLayout.addWidget(browseButton) - formSpacer = QtGui.QSpacerItem(10, 0, QtGui.QSizePolicy.Fixed, - QtGui.QSizePolicy.Expanding) importLayout.addLayout(fileLayout) - importLayout.addSpacerItem(formSpacer) + importLayout.addSpacerItem(self.stackSpacer) else: fileListWidget = QtGui.QListWidget(importWidget) fileListWidget.setSelectionMode( @@ -859,6 +859,7 @@ class SongImportForm(OpenLPWizard): disabledLabel.setWordWrap(True) disabledLabel.setObjectName(obj_prefix + u'DisabledLabel') disabledLayout.addWidget(disabledLabel) + disabledLayout.addSpacerItem(self.stackSpacer) layout.addWidget(disabledWidget) importWidget = QtGui.QWidget(page) importWidget.setObjectName(obj_prefix + u'ImportWidget') From 004a38fd7fb4007f7878905659f4c2b2af2b523a Mon Sep 17 00:00:00 2001 From: Jon Tibble Date: Thu, 3 Feb 2011 21:32:32 +0000 Subject: [PATCH 09/68] Cleanup theme wizard spacers --- openlp/core/ui/themewizard.py | 39 +++++++++++------------------------ 1 file changed, 12 insertions(+), 27 deletions(-) diff --git a/openlp/core/ui/themewizard.py b/openlp/core/ui/themewizard.py index e8765b9e2..49522df70 100644 --- a/openlp/core/ui/themewizard.py +++ b/openlp/core/ui/themewizard.py @@ -36,6 +36,8 @@ class Ui_ThemeWizard(object): themeWizard.setWizardStyle(QtGui.QWizard.ModernStyle) themeWizard.setOptions(QtGui.QWizard.IndependentPages | QtGui.QWizard.NoBackButtonOnStartPage) + self.spacer = QtGui.QSpacerItem(10, 0, + QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Minimum) # Welcome Page add_welcome_page(themeWizard, u':/wizards/wizard_createtheme.bmp') # Background Page @@ -52,10 +54,8 @@ class Ui_ThemeWizard(object): self.backgroundComboBox.setObjectName(u'BackgroundComboBox') self.backgroundTypeLayout.addRow(self.backgroundLabel, self.backgroundComboBox) - self.backgroundTypeSpacer = QtGui.QSpacerItem(10, 0, - QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Minimum) self.backgroundTypeLayout.setItem(1, QtGui.QFormLayout.LabelRole, - self.backgroundTypeSpacer) + self.spacer) self.backgroundLayout.addLayout(self.backgroundTypeLayout) self.backgroundStack = QtGui.QStackedLayout() self.backgroundStack.setObjectName(u'BackgroundStack') @@ -69,10 +69,7 @@ class Ui_ThemeWizard(object): self.colorButton = QtGui.QPushButton(self.colorWidget) self.colorButton.setObjectName(u'ColorButton') self.colorLayout.addRow(self.colorLabel, self.colorButton) - self.colorSpacer = QtGui.QSpacerItem(10, 0, QtGui.QSizePolicy.Fixed, - QtGui.QSizePolicy.Minimum) - self.colorLayout.setItem(1, QtGui.QFormLayout.LabelRole, - self.colorSpacer) + self.colorLayout.setItem(1, QtGui.QFormLayout.LabelRole, self.spacer) self.backgroundStack.addWidget(self.colorWidget) self.gradientWidget = QtGui.QWidget(self.backgroundPage) self.gradientWidget.setObjectName(u'GradientWidget') @@ -98,10 +95,7 @@ class Ui_ThemeWizard(object): self.gradientComboBox.addItems([u'', u'', u'', u'', u'']) self.gradientLayout.addRow(self.gradientTypeLabel, self.gradientComboBox) - self.gradientSpacer = QtGui.QSpacerItem(10, 0, QtGui.QSizePolicy.Fixed, - QtGui.QSizePolicy.Minimum) - self.gradientLayout.setItem(3, QtGui.QFormLayout.LabelRole, - self.gradientSpacer) + self.gradientLayout.setItem(3, QtGui.QFormLayout.LabelRole, self.spacer) self.backgroundStack.addWidget(self.gradientWidget) self.imageWidget = QtGui.QWidget(self.backgroundPage) self.imageWidget.setObjectName(u'ImageWidget') @@ -121,10 +115,7 @@ class Ui_ThemeWizard(object): build_icon(u':/general/general_open.png')) self.imageFileLayout.addWidget(self.imageBrowseButton) self.imageLayout.addRow(self.imageLabel, self.imageFileLayout) - self.imageSpacer = QtGui.QSpacerItem(10, 0, QtGui.QSizePolicy.Fixed, - QtGui.QSizePolicy.Minimum) - self.imageLayout.setItem(1, QtGui.QFormLayout.LabelRole, - self.imageSpacer) + self.imageLayout.setItem(1, QtGui.QFormLayout.LabelRole, self.spacer) self.backgroundStack.addWidget(self.imageWidget) self.backgroundLayout.addLayout(self.backgroundStack) themeWizard.addPage(self.backgroundPage) @@ -236,6 +227,8 @@ class Ui_ThemeWizard(object): self.footerSizeSpinBox.setObjectName(u'FooterSizeSpinBox') self.footerAreaLayout.addRow(self.footerSizeLabel, self.footerSizeSpinBox) + self.footerAreaLayout.setItem(3, QtGui.QFormLayout.LabelRole, + self.spacer) themeWizard.addPage(self.footerAreaPage) # Alignment Page self.alignmentPage = QtGui.QWizardPage() @@ -261,6 +254,8 @@ class Ui_ThemeWizard(object): self.transitionsCheckBox.setObjectName(u'TransitionsCheckBox') self.alignmentLayout.addRow(self.transitionsLabel, self.transitionsCheckBox) + self.alignmentLayout.setItem(3, QtGui.QFormLayout.LabelRole, + self.spacer) themeWizard.addPage(self.alignmentPage) # Area Position Page self.areaPositionPage = QtGui.QWizardPage() @@ -552,16 +547,6 @@ class Ui_ThemeWizard(object): translate('OpenLP.ThemeWizard', 'Theme name:')) # Align all QFormLayouts towards each other. labelWidth = max(self.backgroundLabel.minimumSizeHint().width(), - self.colorLabel.minimumSizeHint().width(), - self.gradientStartLabel.minimumSizeHint().width(), - self.gradientEndLabel.minimumSizeHint().width(), - self.gradientTypeLabel.minimumSizeHint().width(), - self.imageLabel.minimumSizeHint().width()) - self.backgroundTypeSpacer.changeSize(labelWidth, 0, - QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Fixed) - self.colorSpacer.changeSize(labelWidth, 0, - QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Fixed) - self.gradientSpacer.changeSize(labelWidth, 0, - QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Fixed) - self.imageSpacer.changeSize(labelWidth, 0, + self.horizontalLabel.minimumSizeHint().width()) + self.spacer.changeSize(labelWidth, 0, QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Fixed) From 7bd9d8a10b2dd1ed64f3724be75a02b7d3e842c5 Mon Sep 17 00:00:00 2001 From: Jon Tibble Date: Thu, 3 Feb 2011 21:37:00 +0000 Subject: [PATCH 10/68] Importers have replaced scripts --- scripts/bible-1to2-converter.py | 308 ----------------------------- scripts/openlp-1to2-converter.py | 323 ------------------------------- 2 files changed, 631 deletions(-) delete mode 100755 scripts/bible-1to2-converter.py delete mode 100755 scripts/openlp-1to2-converter.py diff --git a/scripts/bible-1to2-converter.py b/scripts/bible-1to2-converter.py deleted file mode 100755 index ebf246608..000000000 --- a/scripts/bible-1to2-converter.py +++ /dev/null @@ -1,308 +0,0 @@ -#!/usr/bin/env python -# -*- coding: utf-8 -*- -# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4 - -############################################################################### -# OpenLP - Open Source Lyrics Projection # -# --------------------------------------------------------------------------- # -# Copyright (c) 2008-2010 Raoul Snyman # -# Portions copyright (c) 2008-2010 Tim Bentley, Jonathan Corwin, Michael # -# Gorven, Scott Guerrieri, Meinert Jordan, Andreas Preikschat, Christian # -# Richter, Philip Ridout, Maikel Stuivenberg, Martin Thompson, Jon Tibble, # -# Carsten Tinggaard, Frode Woldsund # -# --------------------------------------------------------------------------- # -# This program is free software; you can redistribute it and/or modify it # -# under the terms of the GNU General Public License as published by the Free # -# Software Foundation; version 2 of the License. # -# # -# This program is distributed in the hope that it will be useful, but WITHOUT # -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or # -# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for # -# more details. # -# # -# You should have received a copy of the GNU General Public License along # -# with this program; if not, write to the Free Software Foundation, Inc., 59 # -# Temple Place, Suite 330, Boston, MA 02111-1307 USA # -############################################################################### - -import sys -import os -import sqlite -import sqlite3 - -from optparse import OptionParser -from traceback import format_tb as get_traceback - -# Some global options to be used throughout the import process -verbose = False -debug = False -old_cursor = None -new_cursor = None - -# SQL create statments -create_statements = [ - (u'table "book"', u"""CREATE TABLE book ( - id INTEGER NOT NULL, - testament_id INTEGER, - name VARCHAR(30), - abbreviation VARCHAR(5), - PRIMARY KEY (id), - FOREIGN KEY(testament_id) REFERENCES testament (id) -)"""), - (u'table "metadata"', u"""CREATE TABLE metadata ( - "key" VARCHAR(255) NOT NULL, - value VARCHAR(255), - PRIMARY KEY ("key") -)"""), - (u'table "testament"', u"""CREATE TABLE testament ( - id INTEGER NOT NULL, - name VARCHAR(30), - PRIMARY KEY (id) -)"""), - (u'table "verse"', u"""CREATE TABLE verse ( - id INTEGER NOT NULL, - book_id INTEGER, - chapter INTEGER, - verse INTEGER, - text TEXT, - PRIMARY KEY (id), - FOREIGN KEY(book_id) REFERENCES book (id) -)"""), - (u'index "idx_abbrev"', - u"""CREATE INDEX idx_abbrev ON book (abbreviation, id)"""), - (u'index "idx_chapter_verse_book', - u"""CREATE INDEX idx_chapter_verse_book ON verse (chapter, verse, book_id, id)"""), - (u'index "idx_chapter_verse_text"', - u"""CREATE INDEX idx_chapter_verse_text ON verse (text, verse, book_id, id)"""), - (u'index "idx_name"', - u"""CREATE INDEX idx_name ON book (name, id)""") -] - -def display_sql(sql, params): - prepared_params = [] - for param in params: - if isinstance(param, basestring): - prepared_params.append(u'"%s"' % param) - elif isinstance(param, (int, long)): - prepared_params.append(u'%d' % param) - elif isinstance(param, (float, complex)): - prepared_params.append(u'%f' % param) - else: - prepared_params.append(u'"%s"' % str(param)) - for prepared_param in prepared_params: - sql = sql.replace(u'?', prepared_param, 1) - return sql - -def create_database(): - global new_cursor, create_statements - if debug or verbose: - print 'Creating new database:' - else: - print 'Creating new database...', - for statement_type, sql_create in create_statements: - if debug: - print '... ', sql_create.replace('\n', ' ').replace(' ', ' ') - elif verbose: - print '... creating %s...' % statement_type, - new_cursor.execute(sql_create) - if verbose and not debug: - print 'done.' - if not verbose and not debug: - print 'done.' - -def import_bible(): - global old_cursor, new_cursor, debug, verbose - if debug or verbose: - print 'Importing metadata:' - else: - print 'Importing metadata...', - if debug: - print '... SELECT "key", "value" FROM metadata' - elif verbose: - print '... fetching metadata from old database...', - old_cursor.execute(u'SELECT "key", "value" FROM metadata') - rows = old_cursor.fetchall() - if not debug and verbose: - print 'done.' - for row in rows: - key = unicode(row[0], u'cp1252') - value = unicode(row[1], u'cp1252') - if key == u'Permission': - key = u'Permissions' - sql_insert = u'INSERT INTO metadata '\ - '("key", "value") '\ - 'VALUES (?, ?)' - sql_params = (key, value) - if debug: - print '...', display_sql(sql_insert, sql_params) - elif verbose: - print '... importing "%s"' % key - new_cursor.execute(sql_insert, sql_params) - if not verbose and not debug: - print 'done.' - if debug or verbose: - print 'Importing testaments:' - else: - print 'Importing testaments...', - if debug: - print '... SELECT id, name FROM testament' - elif verbose: - print '... fetching testaments from old database...', - old_cursor.execute(u'SELECT id, name FROM testament') - rows = old_cursor.fetchall() - if not debug and verbose: - print 'done.' - for row in rows: - id = int(row[0]) - name = unicode(row[1], u'cp1252') - sql_insert = u'INSERT INTO testament '\ - '(id, name) '\ - 'VALUES (?, ?)' - sql_params = (id, name) - if debug: - print '...', display_sql(sql_insert, sql_params) - elif verbose: - print '... importing "%s"' % name - new_cursor.execute(sql_insert, sql_params) - if not verbose and not debug: - print 'done.' - if debug or verbose: - print 'Importing books:' - else: - print 'Importing books...', - if debug: - print '... SELECT id, testament_id, name, abbreviation FROM book' - elif verbose: - print '... fetching books from old database...', - old_cursor.execute(u'SELECT id, testament_id, name, abbreviation FROM book') - rows = old_cursor.fetchall() - if not debug and verbose: - print 'done.' - book_map = {} - for row in rows: - testament_id = int(row[1]) - name = unicode(row[2], u'cp1252') - abbreviation = unicode(row[3], u'cp1252') - sql_insert = u'INSERT INTO book '\ - '(id, testament_id, name, abbreviation) '\ - 'VALUES (NULL, ?, ?, ?)' - sql_params = (testament_id, name, abbreviation) - if debug: - print '...', display_sql(sql_insert, sql_params) - elif verbose: - print '... importing "%s"' % name - new_cursor.execute(sql_insert, sql_params) - book_map[row[0]] = new_cursor.lastrowid - if debug: - print ' >>> (old) books.id =', row[0], ' (new) books.id =', book_map[row[0]] - if not verbose and not debug: - print 'done.' - if debug or verbose: - print 'Importing verses:' - else: - print 'Importing verses...', - if debug: - print '... SELECT id, book_id, chapter, verse, text || \'\' AS text FROM verse...', - elif verbose: - print '... fetching verses from old database...', - old_cursor.execute(u'SELECT id, book_id, chapter, verse, text || \'\' AS text FROM verse') - rows = old_cursor.fetchall() - if debug or verbose: - print 'done.' - for row in rows: - book_id = int(row[1]) - chapter = int(row[2]) - verse = int(row[3]) - text = unicode(row[4], u'cp1252') - sql_insert = u'INSERT INTO verse '\ - '(id, book_id, chapter, verse, text) '\ - 'VALUES (NULL, ?, ?, ?, ?)' - sql_params = (book_map[book_id], chapter, verse, text) - if debug: - print '...', display_sql(sql_insert, sql_params) - elif verbose: - print '... importing "%s..."' % text[:17] - new_cursor.execute(sql_insert, sql_params) - if not verbose and not debug: - print 'done.' - -def main(old_db, new_db): - global old_cursor, new_cursor, debug - old_connection = None - new_connection = None - try: - old_connection = sqlite.connect(old_db) - except: - if debug: - errormsg = '\n' + ''.join(get_traceback(sys.exc_info()[2]))\ - + str(sys.exc_info()[1]) - else: - errormsg = sys.exc_info()[1] - print 'There was a problem connecting to the old database:', errormsg - return 1 - try: - new_connection = sqlite3.connect(new_db) - except: - if debug: - errormsg = '\n' + ''.join(get_traceback(sys.exc_info()[2]))\ - + str(sys.exc_info()[1]) - else: - errormsg = sys.exc_info()[1] - print 'There was a problem creating the new database:', errormsg - return 1 - old_cursor = old_connection.cursor() - new_cursor = new_connection.cursor() - try: - create_database() - except: - if debug: - errormsg = '\n' + ''.join(get_traceback(sys.exc_info()[2]))\ - + str(sys.exc_info()[1]) - else: - errormsg = sys.exc_info()[1] - print 'There was a problem creating the database:', errormsg - return 1 - try: - import_bible() - new_connection.commit() - except: - new_connection.rollback() - if debug: - errormsg = '\n' + ''.join(get_traceback(sys.exc_info()[2]))\ - + str(sys.exc_info()[1]) - else: - errormsg = sys.exc_info()[1] - print 'There was a problem importing songs:', errormsg - return 1 - print 'Import complete.' - -if __name__ == u'__main__': - option_parser = OptionParser(usage='Usage: %prog [options] OLDDATABASE NEWDATABASE') - option_parser.add_option('-o', '--overwrite', dest='overwrite', default=False, - action=u'store_true', help='Overwrite database file if it already exists.') - option_parser.add_option('-v', '--verbose', dest='verbose', default=False, - action=u'store_true', help='Outputs additional progress data.') - option_parser.add_option('-d', '--debug', dest='debug', default=False, - action=u'store_true', help='Outputs raw SQL statements (overrides verbose).') - options, arguments = option_parser.parse_args() - if len(arguments) < 2: - if len(arguments) == 0: - option_parser.error('Please specify an old database and a new database.') - else: - option_parser.error('Please specify a new database.') - old_db = os.path.abspath(arguments[0]) - new_db = os.path.abspath(arguments[1]) - if not os.path.isfile(old_db): - option_parser.error('Old database file ("%s") is not a file.' % old_db) - if not os.path.exists(old_db): - option_parser.error('Old database file ("%s") does not exist.' % old_db) - if os.path.exists(new_db): - if not options.overwrite: - option_parser.error('New database file ("%s") exists. If you want to overwrite it, specify the --overwrite option.' % new_db) - else: - if not os.path.isfile(new_db): - option_parser.error('New database file ("%s") is not a file.' % new_db) - os.unlink(new_db) - verbose = options.verbose - debug = options.debug - main(old_db, new_db) diff --git a/scripts/openlp-1to2-converter.py b/scripts/openlp-1to2-converter.py deleted file mode 100755 index bd554aa70..000000000 --- a/scripts/openlp-1to2-converter.py +++ /dev/null @@ -1,323 +0,0 @@ -#!/usr/bin/env python -# -*- coding: utf-8 -*- -# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4 - -############################################################################### -# OpenLP - Open Source Lyrics Projection # -# --------------------------------------------------------------------------- # -# Copyright (c) 2008-2010 Raoul Snyman # -# Portions copyright (c) 2008-2010 Tim Bentley, Jonathan Corwin, Michael # -# Gorven, Scott Guerrieri, Meinert Jordan, Andreas Preikschat, Christian # -# Richter, Philip Ridout, Maikel Stuivenberg, Martin Thompson, Jon Tibble, # -# Carsten Tinggaard, Frode Woldsund # -# --------------------------------------------------------------------------- # -# This program is free software; you can redistribute it and/or modify it # -# under the terms of the GNU General Public License as published by the Free # -# Software Foundation; version 2 of the License. # -# # -# This program is distributed in the hope that it will be useful, but WITHOUT # -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or # -# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for # -# more details. # -# # -# You should have received a copy of the GNU General Public License along # -# with this program; if not, write to the Free Software Foundation, Inc., 59 # -# Temple Place, Suite 330, Boston, MA 02111-1307 USA # -############################################################################### - -import sys -import os -import sqlite -import sqlite3 -import re -from optparse import OptionParser -from traceback import format_tb as get_traceback - -# Some global options to be used throughout the import process -dirty_chars = re.compile(r'\W ', re.UNICODE) -verbose = False -debug = False -old_cursor = None -new_cursor = None - -# SQL create statments -create_statements = [ - (u'table "authors"', u"""CREATE TABLE authors ( - id INTEGER NOT NULL, - first_name VARCHAR(128), - last_name VARCHAR(128), - display_name VARCHAR(255) NOT NULL, - PRIMARY KEY (id) -)"""), - (u'table "song_books"', u"""CREATE TABLE song_books ( - id INTEGER NOT NULL, - name VARCHAR(128) NOT NULL, - publisher VARCHAR(128), - PRIMARY KEY (id) -)"""), - (u'table "songs"', u"""CREATE TABLE songs ( - id INTEGER NOT NULL, - song_book_id INTEGER, - title VARCHAR(255) NOT NULL, - alternate_title VARCHAR(255), - lyrics TEXT NOT NULL, - verse_order VARCHAR(128), - copyright VARCHAR(255), - comments TEXT, - ccli_number VARCHAR(64), - song_number VARCHAR(64), - theme_name VARCHAR(128), - search_title VARCHAR(255) NOT NULL, - search_lyrics TEXT NOT NULL, - PRIMARY KEY (id), - FOREIGN KEY(song_book_id) REFERENCES song_books (id) -)"""), - (u'table "topics"', u"""CREATE TABLE topics ( - id INTEGER NOT NULL, - name VARCHAR(128) NOT NULL, - PRIMARY KEY (id) -)"""), - (u'index "ix_songs_search_lyrics"', - u"""CREATE INDEX ix_songs_search_lyrics ON songs (search_lyrics)"""), - (u'index "ix_songs_search_title', - u"""CREATE INDEX ix_songs_search_title ON songs (search_title)"""), - (u'table "authors_songs"', u"""CREATE TABLE authors_songs ( - author_id INTEGER NOT NULL, - song_id INTEGER NOT NULL, - PRIMARY KEY (author_id, song_id), - FOREIGN KEY(author_id) REFERENCES authors (id), - FOREIGN KEY(song_id) REFERENCES songs (id) -)"""), - (u'table "songs_topics"', u"""CREATE TABLE songs_topics ( - song_id INTEGER NOT NULL, - topic_id INTEGER NOT NULL, - PRIMARY KEY (song_id, topic_id), - FOREIGN KEY(song_id) REFERENCES songs (id), - FOREIGN KEY(topic_id) REFERENCES topics (id) -)""") -] - -def prepare_string(dirty): - return dirty_chars.sub(u'', dirty.replace(u'\r\n', u' ').replace(u'\n', u' ')) - -def display_sql(sql, params): - prepared_params = [] - for param in params: - if isinstance(param, basestring): - prepared_params.append(u'"%s"' % param) - elif isinstance(param, (int, long)): - prepared_params.append(u'%d' % param) - elif isinstance(param, (float, complex)): - prepared_params.append(u'%f' % param) - else: - prepared_params.append(u'"%s"' % str(param)) - for prepared_param in prepared_params: - sql = sql.replace(u'?', prepared_param, 1) - return sql - -def create_database(): - global new_cursor, create_statements - if debug or verbose: - print 'Creating new database:' - else: - print 'Creating new database...', - for statement_type, sql_create in create_statements: - if debug: - print '... ', sql_create.replace('\n', ' ').replace(' ', ' ') - elif verbose: - print '... creating %s...' % statement_type, - new_cursor.execute(sql_create) - if verbose and not debug: - print 'done.' - if not verbose and not debug: - print 'done.' - -def import_songs(): - global old_cursor, new_cursor, debug, verbose - if debug or verbose: - print 'Importing authors:' - else: - print 'Importing authors...', - if debug: - print '... SELECT authorid AS id, authorname AS displayname FROM authors' - elif verbose: - print '... fetching authors from old database...', - old_cursor.execute(u'SELECT authorid AS id, authorname AS displayname FROM authors') - rows = old_cursor.fetchall() - if not debug and verbose: - print 'done.' - author_map = {} - for row in rows: - display_name = unicode(row[1], u'cp1252') - names = display_name.split(u' ') - first_name = names[0] - last_name = u' '.join(names[1:]) - if last_name is None: - last_name = u'' - sql_insert = u'INSERT INTO authors '\ - '(id, first_name, last_name, display_name) '\ - 'VALUES (NULL, ?, ?, ?)' - sql_params = (first_name, last_name, display_name) - if debug: - print '...', display_sql(sql_insert, sql_params) - elif verbose: - print '... importing "%s"' % display_name - new_cursor.execute(sql_insert, sql_params) - author_map[row[0]] = new_cursor.lastrowid - if debug: - print ' >>> authors.authorid =', row[0], 'authors.id =', author_map[row[0]] - if not verbose and not debug: - print 'done.' - if debug or verbose: - print 'Importing songs:' - else: - print 'Importing songs...', - if debug: - print '... SELECT songid AS id, songtitle AS title, lyrics || \'\' AS lyrics, copyrightinfo AS copyright FROM songs...', - elif verbose: - print '... fetching songs from old database...', - old_cursor.execute(u'SELECT songid AS id, songtitle AS title, lyrics || \'\' AS lyrics, copyrightinfo AS copyright FROM songs') - rows = old_cursor.fetchall() - if debug or verbose: - print 'done.' - song_map = {} - xml_lyrics_template = u'%s' - xml_verse_template = u'' - for row in rows: - clean_title = unicode(row[1], u'cp1252') - clean_lyrics = unicode(row[2], u'cp1252').replace(u'\r\n', u'\n') - clean_copyright = unicode(row[3], u'cp1252') - verse_order = u'' - text_lyrics = clean_lyrics.split(u'\n\n') - xml_verse = u'' - verses = [] - for line, verse in enumerate(text_lyrics): - if not verse: - continue - xml_verse += (xml_verse_template % (line + 1, verse)) - verses.append(u'V%d' % (line + 1)) - verse_order = u' '.join(verses) - xml_lyrics = xml_lyrics_template % xml_verse - search_title = prepare_string(clean_title) - search_lyrics = prepare_string(clean_lyrics) - sql_insert = u'INSERT INTO songs '\ - '(id, song_book_id, title, lyrics, verse_order, copyright, search_title, search_lyrics) '\ - 'VALUES (NULL, 0, ?, ?, ?, ?, ?, ?)' - sql_params = (clean_title, xml_lyrics, verse_order, clean_copyright, search_title, search_lyrics) - if debug: - print '...', display_sql(sql_insert, (sql_params[0], u'%s...' % clean_lyrics[:7], sql_params[2], sql_params[3], sql_params[4], u'%s...' % search_lyrics[:7])) - elif verbose: - print '... importing "%s"' % clean_title - new_cursor.execute(sql_insert, sql_params) - song_map[row[0]] = new_cursor.lastrowid - if debug: - print ' >>> songs.songid =', row[0], 'songs.id =', song_map[row[0]] - if not verbose and not debug: - print 'done.' - if debug or verbose: - print 'Importing song-to-author mapping:' - else: - print 'Importing song-to-author mapping...', - if debug: - print '... SELECT authorid AS author_id, songid AS song_id FROM songauthors' - elif verbose: - print '... fetching song-to-author mapping from old database...', - old_cursor.execute(u'SELECT authorid AS author_id, songid AS song_id FROM songauthors') - rows = old_cursor.fetchall() - if not debug and verbose: - print 'done.' - for row in rows: - sql_insert = u'INSERT INTO authors_songs '\ - '(author_id, song_id) '\ - 'VALUES (?, ?)' - sql_params = (author_map[row[0]], song_map[row[1]]) - if debug: - print '... ', display_sql(sql_insert, sql_params) - elif verbose: - print '... Author %d (was %d) => Song %d (was %d)'\ - % (int(row[0]), author_map[row[0]], - int(row[1]), song_map[row[1]]) - new_cursor.execute(sql_insert, sql_params) - if not verbose and not debug: - print 'done.' - -def main(old_db, new_db): - global old_cursor, new_cursor, debug - old_connection = None - new_connection = None - try: - old_connection = sqlite.connect(old_db) - except: - if debug: - errormsg = '\n' + ''.join(get_traceback(sys.exc_info()[2]))\ - + str(sys.exc_info()[1]) - else: - errormsg = sys.exc_info()[1] - print 'There was a problem connecting to the old database:', errormsg - return 1 - try: - new_connection = sqlite3.connect(new_db) - except: - if debug: - errormsg = '\n' + ''.join(get_traceback(sys.exc_info()[2]))\ - + str(sys.exc_info()[1]) - else: - errormsg = sys.exc_info()[1] - print 'There was a problem creating the new database:', errormsg - return 1 - old_cursor = old_connection.cursor() - new_cursor = new_connection.cursor() - try: - create_database() - except: - if debug: - errormsg = '\n' + ''.join(get_traceback(sys.exc_info()[2]))\ - + str(sys.exc_info()[1]) - else: - errormsg = sys.exc_info()[1] - print 'There was a problem creating the database:', errormsg - return 1 - try: - import_songs() - new_connection.commit() - except: - new_connection.rollback() - if debug: - errormsg = '\n' + ''.join(get_traceback(sys.exc_info()[2]))\ - + str(sys.exc_info()[1]) - else: - errormsg = sys.exc_info()[1] - print 'There was a problem importing songs:', errormsg - return 1 - print 'Import complete.' - -if __name__ == u'__main__': - option_parser = OptionParser(usage='Usage: %prog [options] OLDDATABASE NEWDATABASE') - option_parser.add_option('-o', '--overwrite', dest='overwrite', default=False, - action=u'store_true', help='Overwrite database file if it already exists.') - option_parser.add_option('-v', '--verbose', dest='verbose', default=False, - action=u'store_true', help='Outputs additional progress data.') - option_parser.add_option('-d', '--debug', dest='debug', default=False, - action=u'store_true', help='Outputs raw SQL statements (overrides verbose).') - options, arguments = option_parser.parse_args() - if len(arguments) < 2: - if len(arguments) == 0: - option_parser.error('Please specify an old database and a new database.') - else: - option_parser.error('Please specify a new database.') - old_db = os.path.abspath(arguments[0]) - new_db = os.path.abspath(arguments[1]) - if not os.path.isfile(old_db): - option_parser.error('Old database file ("%s") is not a file.' % old_db) - if not os.path.exists(old_db): - option_parser.error('Old database file ("%s") does not exist.' % old_db) - if os.path.exists(new_db): - if not options.overwrite: - option_parser.error('New database file ("%s") exists. If you want to overwrite it, specify the --overwrite option.' % new_db) - else: - if not os.path.isfile(new_db): - option_parser.error('New database file ("%s") is not a file.' % new_db) - os.unlink(new_db) - verbose = options.verbose - debug = options.debug - main(old_db, new_db) From ea479bb67a8a2b2b1db2d20b9b9e84be37f30293 Mon Sep 17 00:00:00 2001 From: Jon Tibble Date: Thu, 3 Feb 2011 22:00:14 +0000 Subject: [PATCH 11/68] Fix missing import --- openlp/core/lib/ui.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openlp/core/lib/ui.py b/openlp/core/lib/ui.py index 334aaff2b..399f75a9c 100644 --- a/openlp/core/lib/ui.py +++ b/openlp/core/lib/ui.py @@ -30,7 +30,7 @@ import logging from PyQt4 import QtCore, QtGui -from openlp.core.lib import build_icon, translate +from openlp.core.lib import build_icon, Receiver, translate log = logging.getLogger(__name__) From a2994fb7d7d75aeeb52bfa1db1d5dbfee98c1814 Mon Sep 17 00:00:00 2001 From: Jon Tibble Date: Thu, 3 Feb 2011 22:39:18 +0000 Subject: [PATCH 12/68] Unused import --- openlp/core/ui/serviceitemeditdialog.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openlp/core/ui/serviceitemeditdialog.py b/openlp/core/ui/serviceitemeditdialog.py index be7072026..4046e94ab 100644 --- a/openlp/core/ui/serviceitemeditdialog.py +++ b/openlp/core/ui/serviceitemeditdialog.py @@ -26,7 +26,7 @@ from PyQt4 import QtCore, QtGui -from openlp.core.lib import translate, build_icon +from openlp.core.lib import translate from openlp.core.lib.ui import save_cancel_button_box, delete_push_button, \ up_down_push_button_set From d029fb81a781cb4f386efb98755fbfef938d89f8 Mon Sep 17 00:00:00 2001 From: Jon Tibble Date: Thu, 3 Feb 2011 23:25:52 +0000 Subject: [PATCH 13/68] MediaItem cleanups --- openlp/core/lib/mediamanageritem.py | 41 +++++++++++++++----------- openlp/plugins/images/lib/mediaitem.py | 10 +++---- 2 files changed, 28 insertions(+), 23 deletions(-) diff --git a/openlp/core/lib/mediamanageritem.py b/openlp/core/lib/mediamanageritem.py index 39c37e2a9..683459825 100644 --- a/openlp/core/lib/mediamanageritem.py +++ b/openlp/core/lib/mediamanageritem.py @@ -366,33 +366,34 @@ class MediaManagerItem(QtGui.QWidget): count += 1 return filelist - def validate(self, file, thumb): + def validate(self, image, thumb): """ - Validates to see if the file still exists or thumbnail is up to date + Validates whether an image still exists and, if it does, is the + thumbnail representation of the image up to date. """ - if not os.path.exists(file): + if not os.path.exists(image): return False if os.path.exists(thumb): - filedate = os.stat(file).st_mtime - thumbdate = os.stat(thumb).st_mtime - # if file updated rebuild icon - if filedate > thumbdate: - self.iconFromFile(file, thumb) + imageDate = os.stat(image).st_mtime + thumbDate = os.stat(thumb).st_mtime + # If image has been updated rebuild icon + if imageDate > thumbDate: + self.iconFromFile(image, thumb) else: - self.iconFromFile(file, thumb) + self.iconFromFile(image, thumb) return True - def iconFromFile(self, file, thumb): + def iconFromFile(self, image, thumb): """ - Create a thumbnail icon from a given file + Create a thumbnail icon from a given image. - ``file`` - The file to create the icon from + ``image`` + The image file to create the icon from. ``thumb`` The filename to save the thumbnail to """ - icon = build_icon(unicode(file)) + icon = build_icon(unicode(image)) pixmap = icon.pixmap(QtCore.QSize(88, 50)) ext = os.path.splitext(thumb)[1].lower() pixmap.save(thumb, ext[1:]) @@ -403,12 +404,16 @@ class MediaManagerItem(QtGui.QWidget): u'defined by the plugin') def onNewClick(self): - raise NotImplementedError(u'MediaManagerItem.onNewClick needs to be ' - u'defined by the plugin') + """ + Hook for plugins to define behaviour for adding new items. + """ + pass def onEditClick(self): - raise NotImplementedError(u'MediaManagerItem.onEditClick needs to be ' - u'defined by the plugin') + """ + Hook for plugins to define behaviour for editing items. + """ + pass def onDeleteClick(self): raise NotImplementedError(u'MediaManagerItem.onDeleteClick needs to ' diff --git a/openlp/plugins/images/lib/mediaitem.py b/openlp/plugins/images/lib/mediaitem.py index cbefc7171..71027881c 100644 --- a/openlp/plugins/images/lib/mediaitem.py +++ b/openlp/plugins/images/lib/mediaitem.py @@ -123,19 +123,19 @@ class ImageMediaItem(MediaManagerItem): self.settingsSection, self.getFileList()) def loadList(self, list): - for file in list: - filename = os.path.split(unicode(file))[1] + for imageFile in list: + filename = os.path.split(unicode(imageFile))[1] thumb = os.path.join(self.servicePath, filename) if os.path.exists(thumb): - if self.validate(file, thumb): + if self.validate(imageFile, thumb): icon = build_icon(thumb) else: icon = build_icon(u':/general/general_delete.png') else: - icon = self.iconFromFile(file, thumb) + icon = self.iconFromFile(imageFile, thumb) item_name = QtGui.QListWidgetItem(filename) item_name.setIcon(icon) - item_name.setData(QtCore.Qt.UserRole, QtCore.QVariant(file)) + item_name.setData(QtCore.Qt.UserRole, QtCore.QVariant(imageFile)) self.listView.addItem(item_name) def generateSlideData(self, service_item, item=None, xmlVersion=False): From 8fd9111f99a7789f2ef1d1eebdbb16a03b9512db Mon Sep 17 00:00:00 2001 From: Jon Tibble Date: Fri, 4 Feb 2011 01:56:19 +0000 Subject: [PATCH 14/68] UI library - actions --- openlp/core/lib/dockwidget.py | 4 +- openlp/core/lib/ui.py | 29 ++++++ openlp/core/ui/mainwindow.py | 164 ++++++++++++---------------------- 3 files changed, 91 insertions(+), 106 deletions(-) diff --git a/openlp/core/lib/dockwidget.py b/openlp/core/lib/dockwidget.py index 24841ec33..32d6ce765 100644 --- a/openlp/core/lib/dockwidget.py +++ b/openlp/core/lib/dockwidget.py @@ -31,6 +31,8 @@ import logging from PyQt4 import QtGui +from openlp.core.lib import build_icon + log = logging.getLogger(__name__) class OpenLPDockWidget(QtGui.QDockWidget): @@ -47,4 +49,4 @@ class OpenLPDockWidget(QtGui.QDockWidget): if name: self.setObjectName(name) if icon: - self.setWindowIcon(icon) + self.setWindowIcon(build_icon(icon)) diff --git a/openlp/core/lib/ui.py b/openlp/core/lib/ui.py index 399f75a9c..03590d5d9 100644 --- a/openlp/core/lib/ui.py +++ b/openlp/core/lib/ui.py @@ -143,3 +143,32 @@ def up_down_push_button_set(parent): QtCore.QObject.connect(down_button, QtCore.SIGNAL(u'clicked()'), parent.onDownButtonClicked) return up_button, down_button + +def base_action(parent, name): + """ + Return the most basic action with the object name set. + """ + action = QtGui.QAction(parent) + action.setObjectName(name) + return action + +def checkable_action(parent, name, checked=None): + """ + Return a standard action with the checkable attribute set. + """ + action = base_action(parent, name) + action.setCheckable(True) + if checked is not None: + action.setChecked(checked) + return action + +def icon_action(parent, name, icon, checked=None): + """ + Return a standard action with an icon. + """ + if checked is not None: + action = checkable_action(parent, name, checked) + else: + action = base_action(parent, name) + action.setIcon(build_icon(icon)) + return action diff --git a/openlp/core/ui/mainwindow.py b/openlp/core/ui/mainwindow.py index 6f57861c4..9af4931fb 100644 --- a/openlp/core/ui/mainwindow.py +++ b/openlp/core/ui/mainwindow.py @@ -28,11 +28,12 @@ import logging from PyQt4 import QtCore, QtGui +from openlp.core.lib import RenderManager, build_icon, OpenLPDockWidget, \ + SettingsManager, PluginManager, Receiver, translate +from openlp.core.lib.ui import base_action, checkable_action, icon_action from openlp.core.ui import AboutForm, SettingsForm, ServiceManager, \ ThemeManager, SlideController, PluginForm, MediaDockManager, \ ShortcutListForm -from openlp.core.lib import RenderManager, build_icon, OpenLPDockWidget, \ - SettingsManager, PluginManager, Receiver, translate from openlp.core.utils import AppLocation, add_actions, LanguageManager, \ ActionList @@ -124,9 +125,8 @@ class Ui_MainWindow(object): self.DefaultThemeLabel.setObjectName(u'DefaultThemeLabel') self.StatusBar.addPermanentWidget(self.DefaultThemeLabel) # Create the MediaManager - self.MediaManagerDock = OpenLPDockWidget( - mainWindow, u'MediaManagerDock', - build_icon(u':/system/system_mediamanager.png')) + self.MediaManagerDock = OpenLPDockWidget(mainWindow, + u'MediaManagerDock', u':/system/system_mediamanager.png') self.MediaManagerDock.setStyleSheet(MEDIA_MANAGER_STYLE) self.MediaManagerDock.setMinimumWidth( self.settingsmanager.mainwindow_left) @@ -137,9 +137,8 @@ class Ui_MainWindow(object): mainWindow.addDockWidget(QtCore.Qt.LeftDockWidgetArea, self.MediaManagerDock) # Create the service manager - self.ServiceManagerDock = OpenLPDockWidget( - mainWindow, u'ServiceManagerDock', - build_icon(u':/system/system_servicemanager.png')) + self.ServiceManagerDock = OpenLPDockWidget(mainWindow, + u'ServiceManagerDock', u':/system/system_servicemanager.png') self.ServiceManagerDock.setMinimumWidth( self.settingsmanager.mainwindow_right) self.ServiceManagerContents = ServiceManager(mainWindow, @@ -148,9 +147,8 @@ class Ui_MainWindow(object): mainWindow.addDockWidget(QtCore.Qt.RightDockWidgetArea, self.ServiceManagerDock) # Create the theme manager - self.ThemeManagerDock = OpenLPDockWidget( - mainWindow, u'ThemeManagerDock', - build_icon(u':/system/system_thememanager.png')) + self.ThemeManagerDock = OpenLPDockWidget(mainWindow, + u'ThemeManagerDock', u':/system/system_thememanager.png') self.ThemeManagerDock.setMinimumWidth( self.settingsmanager.mainwindow_right) self.ThemeManagerContents = ThemeManager(mainWindow, @@ -160,103 +158,70 @@ class Ui_MainWindow(object): mainWindow.addDockWidget(QtCore.Qt.RightDockWidgetArea, self.ThemeManagerDock) # Create the menu items - self.FileNewItem = QtGui.QAction(mainWindow) - self.FileNewItem.setIcon(build_icon(u':/general/general_new.png')) - self.FileNewItem.setObjectName(u'FileNewItem') + self.FileNewItem = icon_action(mainWindow, u'FileNewItem', + u':/general/general_new.png') mainWindow.actionList.add_action(self.FileNewItem, u'File') - self.FileOpenItem = QtGui.QAction(mainWindow) - self.FileOpenItem.setIcon(build_icon(u':/general/general_open.png')) - self.FileOpenItem.setObjectName(u'FileOpenItem') + self.FileOpenItem = icon_action(mainWindow, u'FileOpenItem', + u':/general/general_open.png') mainWindow.actionList.add_action(self.FileOpenItem, u'File') - self.FileSaveItem = QtGui.QAction(mainWindow) - self.FileSaveItem.setIcon(build_icon(u':/general/general_save.png')) - self.FileSaveItem.setObjectName(u'FileSaveItem') + self.FileSaveItem = icon_action(mainWindow, u'FileSaveItem', + u':/general/general_save.png') mainWindow.actionList.add_action(self.FileSaveItem, u'File') - self.FileSaveAsItem = QtGui.QAction(mainWindow) - self.FileSaveAsItem.setObjectName(u'FileSaveAsItem') + self.FileSaveAsItem = base_action(mainWindow, u'FileSaveAsItem') mainWindow.actionList.add_action(self.FileSaveAsItem, u'File') - self.printServiceOrderItem = QtGui.QAction(mainWindow) - self.printServiceOrderItem.setObjectName(u'printServiceItem') + self.printServiceOrderItem = base_action( + mainWindow, u'printServiceItem') mainWindow.actionList.add_action( self.printServiceOrderItem, u'Print Service Order') - self.FileExitItem = QtGui.QAction(mainWindow) - self.FileExitItem.setIcon(build_icon(u':/system/system_exit.png')) - self.FileExitItem.setObjectName(u'FileExitItem') + self.FileExitItem = icon_action(mainWindow, u'FileExitItem', + u':/system/system_exit.png') mainWindow.actionList.add_action(self.FileExitItem, u'File') - self.ImportThemeItem = QtGui.QAction(mainWindow) - self.ImportThemeItem.setObjectName(u'ImportThemeItem') + self.ImportThemeItem = base_action(mainWindow, u'ImportThemeItem') mainWindow.actionList.add_action(self.ImportThemeItem, u'Import') - self.ImportLanguageItem = QtGui.QAction(mainWindow) - self.ImportLanguageItem.setObjectName(u'ImportLanguageItem') + self.ImportLanguageItem = base_action(mainWindow, u'ImportLanguageItem') mainWindow.actionList.add_action(self.ImportLanguageItem, u'Import') - self.ExportThemeItem = QtGui.QAction(mainWindow) - self.ExportThemeItem.setObjectName(u'ExportThemeItem') + self.ExportThemeItem = base_action(mainWindow, u'ExportThemeItem') mainWindow.actionList.add_action(self.ExportThemeItem, u'Export') - self.ExportLanguageItem = QtGui.QAction(mainWindow) - self.ExportLanguageItem.setObjectName(u'ExportLanguageItem') + self.ExportLanguageItem = base_action(mainWindow, u'ExportLanguageItem') mainWindow.actionList.add_action(self.ExportLanguageItem, u'Export') - self.ViewMediaManagerItem = QtGui.QAction(mainWindow) - self.ViewMediaManagerItem.setCheckable(True) - self.ViewMediaManagerItem.setChecked(self.MediaManagerDock.isVisible()) - self.ViewMediaManagerItem.setIcon( - build_icon(u':/system/system_mediamanager.png')) - self.ViewMediaManagerItem.setObjectName(u'ViewMediaManagerItem') - self.ViewThemeManagerItem = QtGui.QAction(mainWindow) - self.ViewThemeManagerItem.setCheckable(True) - self.ViewThemeManagerItem.setChecked(self.ThemeManagerDock.isVisible()) - self.ViewThemeManagerItem.setIcon( - build_icon(u':/system/system_thememanager.png')) - self.ViewThemeManagerItem.setObjectName(u'ViewThemeManagerItem') + self.ViewMediaManagerItem = icon_action(mainWindow, + u'ViewMediaManagerItem', u':/system/system_mediamanager.png', + self.MediaManagerDock.isVisible()) + self.ViewThemeManagerItem = icon_action(mainWindow, + u'ViewThemeManagerItem', u':/system/system_thememanager.png', + self.ThemeManagerDock.isVisible()) mainWindow.actionList.add_action(self.ViewMediaManagerItem, u'View') - self.ViewServiceManagerItem = QtGui.QAction(mainWindow) - self.ViewServiceManagerItem.setCheckable(True) - self.ViewServiceManagerItem.setChecked( + self.ViewServiceManagerItem = icon_action(mainWindow, + u'ViewServiceManagerItem', u':/system/system_servicemanager.png', self.ServiceManagerDock.isVisible()) - self.ViewServiceManagerItem.setIcon( - build_icon(u':/system/system_servicemanager.png')) - self.ViewServiceManagerItem.setObjectName(u'ViewServiceManagerItem') mainWindow.actionList.add_action(self.ViewServiceManagerItem, u'View') - self.ViewPreviewPanel = QtGui.QAction(mainWindow) - self.ViewPreviewPanel.setCheckable(True) - self.ViewPreviewPanel.setChecked(previewVisible) - self.ViewPreviewPanel.setObjectName(u'ViewPreviewPanel') + self.ViewPreviewPanel = checkable_action(mainWindow, + u'ViewPreviewPanel', previewVisible) mainWindow.actionList.add_action(self.ViewPreviewPanel, u'View') - self.ViewLivePanel = QtGui.QAction(mainWindow) - self.ViewLivePanel.setCheckable(True) - self.ViewLivePanel.setChecked(liveVisible) - self.ViewLivePanel.setObjectName(u'ViewLivePanel') + self.ViewLivePanel = checkable_action(mainWindow, u'ViewLivePanel', + liveVisible) mainWindow.actionList.add_action(self.ViewLivePanel, u'View') - self.ModeDefaultItem = QtGui.QAction(mainWindow) - self.ModeDefaultItem.setCheckable(True) - self.ModeDefaultItem.setObjectName(u'ModeDefaultItem') + self.ModeDefaultItem = checkable_action(mainWindow, u'ModeDefaultItem') mainWindow.actionList.add_action(self.ModeDefaultItem, u'View Mode') - self.ModeSetupItem = QtGui.QAction(mainWindow) - self.ModeSetupItem.setCheckable(True) - self.ModeSetupItem.setObjectName(u'ModeLiveItem') + self.ModeSetupItem = checkable_action(mainWindow, u'ModeLiveItem') mainWindow.actionList.add_action(self.ModeSetupItem, u'View Mode') - self.ModeLiveItem = QtGui.QAction(mainWindow) - self.ModeLiveItem.setCheckable(True) - self.ModeLiveItem.setObjectName(u'ModeLiveItem') + self.ModeLiveItem = checkable_action(mainWindow, u'ModeLiveItem') mainWindow.actionList.add_action(self.ModeLiveItem, u'View Mode') self.ModeGroup = QtGui.QActionGroup(mainWindow) self.ModeGroup.addAction(self.ModeDefaultItem) self.ModeGroup.addAction(self.ModeSetupItem) self.ModeGroup.addAction(self.ModeLiveItem) self.ModeDefaultItem.setChecked(True) - self.ToolsAddToolItem = QtGui.QAction(mainWindow) - self.ToolsAddToolItem.setIcon(build_icon(u':/tools/tools_add.png')) - self.ToolsAddToolItem.setObjectName(u'ToolsAddToolItem') + self.ToolsAddToolItem = icon_action(mainWindow, u'ToolsAddToolItem', + u':/tools/tools_add.png') mainWindow.actionList.add_action(self.ToolsAddToolItem, u'Tools') - self.SettingsPluginListItem = QtGui.QAction(mainWindow) - self.SettingsPluginListItem.setIcon( - build_icon(u':/system/settings_plugin_list.png')) - self.SettingsPluginListItem.setObjectName(u'SettingsPluginListItem') + self.SettingsPluginListItem = icon_action(mainWindow, + u'SettingsPluginListItem', u':/system/settings_plugin_list.png') mainWindow.actionList.add_action(self.SettingsPluginListItem, u'Settings') # i18n Language Items - self.AutoLanguageItem = QtGui.QAction(mainWindow) - self.AutoLanguageItem.setObjectName(u'AutoLanguageItem') - self.AutoLanguageItem.setCheckable(True) + self.AutoLanguageItem = checkable_action(mainWindow, + u'AutoLanguageItem') mainWindow.actionList.add_action(self.AutoLanguageItem, u'Settings') self.LanguageGroup = QtGui.QActionGroup(mainWindow) self.LanguageGroup.setExclusive(True) @@ -266,39 +231,28 @@ class Ui_MainWindow(object): qmList = LanguageManager.get_qm_list() savedLanguage = LanguageManager.get_language() for key in sorted(qmList.keys()): - languageItem = QtGui.QAction(mainWindow) - languageItem.setObjectName(key) - languageItem.setCheckable(True) + languageItem = checkable_action(mainWindow, key) if qmList[key] == savedLanguage: languageItem.setChecked(True) add_actions(self.LanguageGroup, [languageItem]) - self.SettingsShortcutsItem = QtGui.QAction(mainWindow) - self.SettingsShortcutsItem.setIcon( - build_icon(u':/system/system_configure_shortcuts.png')) - self.SettingsShortcutsItem.setObjectName(u'SettingsShortcutsItem') - self.SettingsConfigureItem = QtGui.QAction(mainWindow) - self.SettingsConfigureItem.setIcon( - build_icon(u':/system/system_settings.png')) - self.SettingsConfigureItem.setObjectName(u'SettingsConfigureItem') + self.SettingsShortcutsItem = icon_action(mainWindow, + u'SettingsShortcutsItem', + u':/system/system_configure_shortcuts.png') + self.SettingsConfigureItem = icon_action(mainWindow, + u'SettingsConfigureItem', u':/system/system_settings.png') mainWindow.actionList.add_action(self.SettingsShortcutsItem, u'Settings') - self.HelpDocumentationItem = QtGui.QAction(mainWindow) - self.HelpDocumentationItem.setIcon( - build_icon(u':/system/system_help_contents.png')) - self.HelpDocumentationItem.setObjectName(u'HelpDocumentationItem') + self.HelpDocumentationItem = icon_action(mainWindow, + u'HelpDocumentationItem', u':/system/system_help_contents.png') self.HelpDocumentationItem.setEnabled(False) mainWindow.actionList.add_action(self.HelpDocumentationItem, u'Help') - self.HelpAboutItem = QtGui.QAction(mainWindow) - self.HelpAboutItem.setIcon( - build_icon(u':/system/system_about.png')) - self.HelpAboutItem.setObjectName(u'HelpAboutItem') + self.HelpAboutItem = icon_action(mainWindow, u'HelpAboutItem', + u':/system/system_about.png') mainWindow.actionList.add_action(self.HelpAboutItem, u'Help') - self.HelpOnlineHelpItem = QtGui.QAction(mainWindow) - self.HelpOnlineHelpItem.setObjectName(u'HelpOnlineHelpItem') + self.HelpOnlineHelpItem = base_action(mainWindow, u'HelpOnlineHelpItem') self.HelpOnlineHelpItem.setEnabled(False) mainWindow.actionList.add_action(self.HelpOnlineHelpItem, u'Help') - self.HelpWebSiteItem = QtGui.QAction(mainWindow) - self.HelpWebSiteItem.setObjectName(u'HelpWebSiteItem') + self.HelpWebSiteItem = base_action(mainWindow, u'HelpWebSiteItem') mainWindow.actionList.add_action(self.HelpWebSiteItem, u'Help') add_actions(self.FileImportMenu, (self.ImportThemeItem, self.ImportLanguageItem)) @@ -999,8 +953,8 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow): u'advanced/recent file count', QtCore.QVariant(4)).toInt()[0] self.FileMenu.clear() add_actions(self.FileMenu, self.FileMenuActions[:-1]) - existingRecentFiles = [file for file in self.recentFiles - if QtCore.QFile.exists(file)] + existingRecentFiles = [recentFile for recentFile in self.recentFiles + if QtCore.QFile.exists(recentFile)] recentFilesToDisplay = existingRecentFiles[0:recentFileCount] if recentFilesToDisplay: self.FileMenu.addSeparator() From 70e7b549d526497c3419fc3715555f7adbedbcc5 Mon Sep 17 00:00:00 2001 From: Jon Tibble Date: Fri, 4 Feb 2011 02:56:59 +0000 Subject: [PATCH 15/68] UI library - shortcut_action --- openlp/core/lib/ui.py | 10 ++++++++++ openlp/core/ui/slidecontroller.py | 32 +++++++++++-------------------- 2 files changed, 21 insertions(+), 21 deletions(-) diff --git a/openlp/core/lib/ui.py b/openlp/core/lib/ui.py index 03590d5d9..f388e03b4 100644 --- a/openlp/core/lib/ui.py +++ b/openlp/core/lib/ui.py @@ -172,3 +172,13 @@ def icon_action(parent, name, icon, checked=None): action = base_action(parent, name) action.setIcon(build_icon(icon)) return action + +def shortcut_action(parent, text, shortcuts, function): + """ + Return a shortcut enabled action. + """ + action = QtGui.QAction(text, parent) + action.setShortcuts(shortcuts) + action.setShortcutContext(QtCore.Qt.WidgetWithChildrenShortcut) + QtCore.QObject.connect(action, QtCore.SIGNAL(u'triggered()'), function) + return action diff --git a/openlp/core/ui/slidecontroller.py b/openlp/core/ui/slidecontroller.py index ab8a656ff..d0a0a6bf8 100644 --- a/openlp/core/ui/slidecontroller.py +++ b/openlp/core/ui/slidecontroller.py @@ -30,9 +30,10 @@ import os from PyQt4 import QtCore, QtGui from PyQt4.phonon import Phonon -from openlp.core.ui import HideMode, MainDisplay from openlp.core.lib import OpenLPToolbar, Receiver, resize_image, \ ItemCapabilities, translate +from openlp.core.lib.ui import shortcut_action +from openlp.core.ui import HideMode, MainDisplay log = logging.getLogger(__name__) @@ -390,28 +391,17 @@ class SlideController(QtGui.QWidget): self.nextItem.setShortcuts([QtCore.Qt.Key_Down, QtCore.Qt.Key_PageDown]) self.nextItem.setShortcutContext(QtCore.Qt.WidgetWithChildrenShortcut) actionList.add_action(self.nextItem, u'Live') - self.previousService = QtGui.QAction(translate( - 'OpenLP.SlideController', 'Previous Service'), parent) - self.previousService.setShortcuts([QtCore.Qt.Key_Left, 0]) - self.previousService.setShortcutContext( - QtCore.Qt.WidgetWithChildrenShortcut) - QtCore.QObject.connect(self.previousService, - QtCore.SIGNAL(u'triggered()'), self.servicePrevious) + self.previousService = shortcut_action(parent, + translate('OpenLP.SlideController', 'Previous Service'), + [QtCore.Qt.Key_Left, 0], self.servicePrevious) actionList.add_action(self.previousService, u'Live') - self.nextService = QtGui.QAction(translate( - 'OpenLP.SlideController', 'Next Service'), parent) - self.nextService.setShortcuts([QtCore.Qt.Key_Right, 0]) - self.nextService.setShortcutContext( - QtCore.Qt.WidgetWithChildrenShortcut) - QtCore.QObject.connect(self.nextService, - QtCore.SIGNAL(u'triggered()'), self.serviceNext) + self.nextService = shortcut_action(parent, + translate('OpenLP.SlideController', 'Next Service'), + [QtCore.Qt.Key_Right, 0], self.serviceNext) actionList.add_action(self.nextService, u'Live') - self.escapeItem = QtGui.QAction(translate( - 'OpenLP.SlideController', 'Escape Item'), parent) - self.escapeItem.setShortcuts([QtCore.Qt.Key_Escape, 0]) - self.escapeItem.setShortcutContext(QtCore.Qt.WidgetWithChildrenShortcut) - QtCore.QObject.connect(self.escapeItem, - QtCore.SIGNAL(u'triggered()'), self.liveEscape) + self.escapeItem = shortcut_action(parent, + translate('OpenLP.SlideController', 'Escape Item'), + [QtCore.Qt.Key_Escape, 0], self.liveEscape) actionList.add_action(self.escapeItem, u'Live') def liveEscape(self): From 3831e5d1c957b1b1ee4dc254f5de5c6c53ec7b03 Mon Sep 17 00:00:00 2001 From: Jon Tibble Date: Fri, 4 Feb 2011 03:31:06 +0000 Subject: [PATCH 16/68] Slim down slidecontroller --- openlp/core/ui/slidecontroller.py | 63 +++++++++++-------------------- 1 file changed, 21 insertions(+), 42 deletions(-) diff --git a/openlp/core/ui/slidecontroller.py b/openlp/core/ui/slidecontroller.py index d0a0a6bf8..bf0453e05 100644 --- a/openlp/core/ui/slidecontroller.py +++ b/openlp/core/ui/slidecontroller.py @@ -318,18 +318,8 @@ class SlideController(QtGui.QWidget): self.mediabar.setVisible(False) if self.isLive: self.setLiveHotkeys(self) - self.previewListWidget.addActions( - [self.previousItem, - self.nextItem, - self.previousService, - self.nextService, - self.escapeItem]) - self.display.addActions( - [self.previousItem, - self.nextItem, - self.previousService, - self.nextService, - self.escapeItem]) + self.__addActionsToWidget(self.previewListWidget) + self.__addActionsToWidget(self.display) else: self.setPreviewHotkeys() self.previewListWidget.addActions( @@ -425,12 +415,7 @@ class SlideController(QtGui.QWidget): self.display.alertTab = self.alertTab self.display.setup() if self.isLive: - self.display.addActions( - [self.previousItem, - self.nextItem, - self.previousService, - self.nextService, - self.escapeItem]) + self.__addActionsToWidget(self.display) # The SlidePreview's ratio. self.ratio = float(self.screens.current[u'size'].width()) / \ float(self.screens.current[u'size'].height()) @@ -438,6 +423,12 @@ class SlideController(QtGui.QWidget): if self.serviceItem: self.refreshServiceItem() + def __addActionsToWidget(self, widget): + widget.addActions([ + self.previousItem, self.nextItem, + self.previousService, self.nextService, + self.escapeItem]) + def previewSizeChanged(self): """ Takes care of the SlidePreview's size. Is called when one of the the @@ -565,10 +556,7 @@ class SlideController(QtGui.QWidget): slideno = 0 # If service item is the same as the current on only change slide if item.__eq__(self.serviceItem): - if slideno + 1 < self.previewListWidget.rowCount(): - self.previewListWidget.scrollToItem( - self.previewListWidget.item(slideno + 1, 0)) - self.previewListWidget.selectRow(slideno) + self.__checkUpdateSelectedSlide(slideno) self.onSlideSelected() return self._processItem(item, slideno) @@ -667,10 +655,7 @@ class SlideController(QtGui.QWidget): self.previewListWidget.selectRow( self.previewListWidget.rowCount() - 1) else: - if slideno + 1 < self.previewListWidget.rowCount(): - self.previewListWidget.scrollToItem( - self.previewListWidget.item(slideno + 1, 0)) - self.previewListWidget.selectRow(slideno) + self.__checkUpdateSelectedSlide(slideno) def onTextRequest(self): """ @@ -719,10 +704,7 @@ class SlideController(QtGui.QWidget): [self.serviceItem, self.isLive, index]) self.updatePreview() else: - if index + 1 < self.previewListWidget.rowCount(): - self.previewListWidget.scrollToItem( - self.previewListWidget.item(index + 1, 0)) - self.previewListWidget.selectRow(index) + self.__checkUpdateSelectedSlide(index) self.onSlideSelected() def mainDisplaySetBackground(self): @@ -881,10 +863,7 @@ class SlideController(QtGui.QWidget): """ The slide has been changed. Update the slidecontroller accordingly """ - if row + 1 < self.previewListWidget.rowCount(): - self.previewListWidget.scrollToItem( - self.previewListWidget.item(row + 1, 0)) - self.previewListWidget.selectRow(row) + self.__checkUpdateSelectedSlide(row) self.updatePreview() Receiver.send_message(u'slidecontroller_%s_changed' % self.typePrefix, row) @@ -935,10 +914,7 @@ class SlideController(QtGui.QWidget): else: Receiver.send_message('servicemanager_next_item') return - if row + 1 < self.previewListWidget.rowCount(): - self.previewListWidget.scrollToItem( - self.previewListWidget.item(row + 1, 0)) - self.previewListWidget.selectRow(row) + self.__checkUpdateSelectedSlide(row) self.onSlideSelected() def onSlideSelectedPreviousNoloop(self): @@ -961,12 +937,15 @@ class SlideController(QtGui.QWidget): row = self.previewListWidget.rowCount() - 1 else: row = 0 - if row + 1 < self.previewListWidget.rowCount(): - self.previewListWidget.scrollToItem( - self.previewListWidget.item(row + 1, 0)) - self.previewListWidget.selectRow(row) + self.__checkUpdateSelectedSlide(row) self.onSlideSelected() + def __checkUpdateSelectedSlide(self, row): + if row + 1 < self.previewListWidget.rowCount(): + self.previewListWidget.scrollToItem( + self.previewListWidget.item(row + 1, 0)) + self.previewListWidget.selectRow(row) + def onSlideSelectedLast(self): """ Go to the last slide. From 0047b8d1c105f969293f2fe8e7cd64ea7da1d4df Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Fri, 4 Feb 2011 13:57:48 +0100 Subject: [PATCH 17/68] --- openlp/core/ui/advancedtab.py | 39 ++++++++++++------ openlp/core/ui/servicemanager.py | 68 +++++++++++++++++++------------- 2 files changed, 67 insertions(+), 40 deletions(-) diff --git a/openlp/core/ui/advancedtab.py b/openlp/core/ui/advancedtab.py index f68131894..630cbc18c 100644 --- a/openlp/core/ui/advancedtab.py +++ b/openlp/core/ui/advancedtab.py @@ -84,11 +84,15 @@ class AdvancedTab(SettingsTab): self.serviceOrderGroupBox.setObjectName(u'serviceOrderGroupBox') self.serviceOrderLayout = QtGui.QVBoxLayout(self.serviceOrderGroupBox) self.serviceOrderLayout.setObjectName(u'serviceOrderLayout') - self.detailedServicePrintCheckBox = QtGui.QCheckBox( - self.serviceOrderGroupBox) - self.detailedServicePrintCheckBox.setObjectName( - u'detailedServicePrintCheckBox') - self.serviceOrderLayout.addWidget(self.detailedServicePrintCheckBox) + self.printSlideTextCheckBox = QtGui.QCheckBox(self.serviceOrderGroupBox) + self.printSlideTextCheckBox.setObjectName(u'printSlideTextCheckBox') + self.serviceOrderLayout.addWidget(self.printSlideTextCheckBox) + self.printMetaDataCheckBox = QtGui.QCheckBox(self.serviceOrderGroupBox) + self.printMetaDataCheckBox.setObjectName(u'printMetaDataCheckBox') + self.serviceOrderLayout.addWidget(self.printMetaDataCheckBox) + self.printNotesCheckBox = QtGui.QCheckBox(self.serviceOrderGroupBox) + self.printNotesCheckBox.setObjectName(u'printNotesCheckBox') + self.serviceOrderLayout.addWidget(self.printNotesCheckBox) self.leftLayout.addWidget(self.serviceOrderGroupBox) # self.sharedDirGroupBox = QtGui.QGroupBox(self.leftColumn) # self.sharedDirGroupBox.setObjectName(u'sharedDirGroupBox') @@ -141,9 +145,12 @@ class AdvancedTab(SettingsTab): 'Hide the mouse cursor when moved over the display window')) self.serviceOrderGroupBox.setTitle(translate('OpenLP.AdvancedTab', 'Service Order Print')) - self.detailedServicePrintCheckBox.setText( - translate('OpenLP.AdvancedTab', - 'Print slide texts and service item notes as well')) + self.printSlideTextCheckBox.setText( + translate('OpenLP.AdvancedTab', 'Include text slides if available')) + self.printMetaDataCheckBox.setText(translate( + 'OpenLP.AdvancedTab', 'Include playing time of media files')) + self.printNotesCheckBox.setText( + translate('OpenLP.AdvancedTab', 'Include service item notes')) # self.sharedDirGroupBox.setTitle( # translate('AdvancedTab', 'Central Data Store')) # self.sharedCheckBox.setText( @@ -179,8 +186,12 @@ class AdvancedTab(SettingsTab): QtCore.QVariant(True)).toBool()) self.hideMouseCheckBox.setChecked( settings.value(u'hide mouse', QtCore.QVariant(False)).toBool()) - self.detailedServicePrintCheckBox.setChecked(settings.value( - u'detailed service print', QtCore.QVariant(False)).toBool()) + self.printSlideTextCheckBox.setChecked(settings.value( + u'print slide text', QtCore.QVariant(False)).toBool()) + self.printMetaDataCheckBox.setChecked(settings.value( + u'print file meta data', QtCore.QVariant(False)).toBool()) + self.printNotesCheckBox.setChecked(settings.value( + u'print notes', QtCore.QVariant(False)).toBool()) settings.endGroup() def save(self): @@ -201,8 +212,12 @@ class AdvancedTab(SettingsTab): QtCore.QVariant(self.enableAutoCloseCheckBox.isChecked())) settings.setValue(u'hide mouse', QtCore.QVariant(self.hideMouseCheckBox.isChecked())) - settings.setValue(u'detailed service print', - QtCore.QVariant(self.detailedServicePrintCheckBox.isChecked())) + settings.setValue(u'print slide text', + QtCore.QVariant(self.printSlideTextCheckBox.isChecked())) + settings.setValue(u'print file meta data', + QtCore.QVariant(self.printMetaDataCheckBox.isChecked())) + settings.setValue(u'print notes', + QtCore.QVariant(self.printNotesCheckBox.isChecked())) settings.endGroup() # def onSharedCheckBoxChanged(self, checked): diff --git a/openlp/core/ui/servicemanager.py b/openlp/core/ui/servicemanager.py index 4d36f4aec..3f38afe58 100644 --- a/openlp/core/ui/servicemanager.py +++ b/openlp/core/ui/servicemanager.py @@ -24,9 +24,11 @@ # Temple Place, Suite 330, Boston, MA 02111-1307 USA # ############################################################################### -import os -import logging import cPickle +import datetime +import logging +import mutagen +import os import zipfile log = logging.getLogger(__name__) @@ -1188,11 +1190,6 @@ class ServiceManager(QtGui.QWidget): """ Print a Service Order Sheet. """ - if not self.serviceItems: - critical_error_message_box( - message=translate('OpenLP.ServiceManager', - 'There is no service item in this service.')) - return printDialog = QtGui.QPrintDialog() if not printDialog.exec_(): return @@ -1200,29 +1197,44 @@ class ServiceManager(QtGui.QWidget): 'Service Order Sheet') for item in self.serviceItems: item = item[u'service_item'] - # add the title + # Add the title of the service item. text += u'

%s

' % (item.icon, item.get_display_title()) - if not QtCore.QSettings().value(u'advanced' + - u'/detailed service print', QtCore.QVariant(True)).toBool(): - continue - if item.is_text(): - # Add the text of the service item. - for slide in item.get_frames(): - text += u'

' + slide[u'text'] + u'

' - elif item.is_image(): - # Add the image names of the service item. - text += u'
    ' - for slide in range(len(item.get_frames())): - text += u'
  1. %s

  2. ' % item.get_frame_title(slide) - text += u'
' - if item.foot_text: - # add footer - text += u'

%s

' % item.foot_text - if item.notes: - # add notes - text += u'

%s %s

' % (translate( - 'OpenLP.ServiceManager', 'Notes:'), item.notes) + # Add slide text of the service item. + if QtCore.QSettings().value(u'advanced' + + u'/print slide text', QtCore.QVariant(False)).toBool(): + if item.is_text(): + # Add the text of the service item. + for slide in item.get_frames(): + text += u'

' + slide[u'text'] + u'

' + elif item.is_image(): + # Add the image names of the service item. + text += u'
    ' + for slide in range(len(item.get_frames())): + text += u'
  1. %s

  2. ' % item.get_frame_title(slide) + text += u'
' + if item.foot_text: + # add footer + text += u'

%s

' % item.foot_text + # Add service items' notes. + if QtCore.QSettings().value(u'advanced' + + u'/print notes', QtCore.QVariant(False)).toBool(): + if item.notes: + text += u'

%s %s

' % (translate( + 'OpenLP.ServiceManager', 'Notes:'), item.notes) + # Add play length of media files. + if item.is_media() and QtCore.QSettings().value(u'advanced' + + u'/print file meta data', QtCore.QVariant(False)).toBool(): + path = os.path.join(item.get_frames()[0][u'path'], + item.get_frames()[0][u'title']) + if not os.path.isfile(path): + continue + file = mutagen.File(path) + if file is not None: + length = int(file.info.length) + text += u'

%s %s

' % (translate( + 'OpenLP.ServiceManager', u'Playing time:'), + unicode(datetime.timedelta(seconds=length))) serviceDocument = QtGui.QTextDocument() serviceDocument.setHtml(text) serviceDocument.print_(printDialog.printer()) From 7c69bad1120fef22071f5c42c86598d374fc949b Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Fri, 4 Feb 2011 14:35:55 +0100 Subject: [PATCH 18/68] fixed long line --- openlp/core/ui/servicemanager.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/openlp/core/ui/servicemanager.py b/openlp/core/ui/servicemanager.py index 3f38afe58..ec1025d45 100644 --- a/openlp/core/ui/servicemanager.py +++ b/openlp/core/ui/servicemanager.py @@ -1211,7 +1211,8 @@ class ServiceManager(QtGui.QWidget): # Add the image names of the service item. text += u'
    ' for slide in range(len(item.get_frames())): - text += u'
  1. %s

  2. ' % item.get_frame_title(slide) + text += u'
  3. %s

  4. ' % \ + item.get_frame_title(slide) text += u'
' if item.foot_text: # add footer From ce2640c80e8324580ea5379fa2f9a2532443801e Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Fri, 4 Feb 2011 16:46:16 +0100 Subject: [PATCH 19/68] --- openlp/core/ui/__init__.py | 1 + openlp/core/ui/servicemanager.py | 59 ++++---------------------------- 2 files changed, 8 insertions(+), 52 deletions(-) diff --git a/openlp/core/ui/__init__.py b/openlp/core/ui/__init__.py index eb0e89775..9de96e9b5 100644 --- a/openlp/core/ui/__init__.py +++ b/openlp/core/ui/__init__.py @@ -70,6 +70,7 @@ from shortcutlistform import ShortcutListForm from mediadockmanager import MediaDockManager from servicemanager import ServiceManager from thememanager import ThemeManager +from printserviceorderform import PrintServiceOrderForm __all__ = ['SplashScreen', 'AboutForm', 'SettingsForm', 'MainDisplay', 'SlideController', 'ServiceManager', 'ThemeManager', 'MediaDockManager', diff --git a/openlp/core/ui/servicemanager.py b/openlp/core/ui/servicemanager.py index ec1025d45..05171daf7 100644 --- a/openlp/core/ui/servicemanager.py +++ b/openlp/core/ui/servicemanager.py @@ -25,15 +25,13 @@ ############################################################################### import cPickle -import datetime import logging -import mutagen import os import zipfile log = logging.getLogger(__name__) -from PyQt4 import QtCore, QtGui +from PyQt4 import QtCore, QtGui, QtWebKit from openlp.core.lib import OpenLPToolbar, ServiceItem, context_menu_action, \ Receiver, build_icon, ItemCapabilities, SettingsManager, translate, \ @@ -1190,52 +1188,9 @@ class ServiceManager(QtGui.QWidget): """ Print a Service Order Sheet. """ - printDialog = QtGui.QPrintDialog() - if not printDialog.exec_(): - return - text = u'

%s

' % translate('OpenLP.ServiceManager', - 'Service Order Sheet') - for item in self.serviceItems: - item = item[u'service_item'] - # Add the title of the service item. - text += u'

%s

' % (item.icon, - item.get_display_title()) - # Add slide text of the service item. - if QtCore.QSettings().value(u'advanced' + - u'/print slide text', QtCore.QVariant(False)).toBool(): - if item.is_text(): - # Add the text of the service item. - for slide in item.get_frames(): - text += u'

' + slide[u'text'] + u'

' - elif item.is_image(): - # Add the image names of the service item. - text += u'
    ' - for slide in range(len(item.get_frames())): - text += u'
  1. %s

  2. ' % \ - item.get_frame_title(slide) - text += u'
' - if item.foot_text: - # add footer - text += u'

%s

' % item.foot_text - # Add service items' notes. - if QtCore.QSettings().value(u'advanced' + - u'/print notes', QtCore.QVariant(False)).toBool(): - if item.notes: - text += u'

%s %s

' % (translate( - 'OpenLP.ServiceManager', 'Notes:'), item.notes) - # Add play length of media files. - if item.is_media() and QtCore.QSettings().value(u'advanced' + - u'/print file meta data', QtCore.QVariant(False)).toBool(): - path = os.path.join(item.get_frames()[0][u'path'], - item.get_frames()[0][u'title']) - if not os.path.isfile(path): - continue - file = mutagen.File(path) - if file is not None: - length = int(file.info.length) - text += u'

%s %s

' % (translate( - 'OpenLP.ServiceManager', u'Playing time:'), - unicode(datetime.timedelta(seconds=length))) - serviceDocument = QtGui.QTextDocument() - serviceDocument.setHtml(text) - serviceDocument.print_(printDialog.printer()) + from openlp.core.ui import PrintServiceOrderForm + dialog = PrintServiceOrderForm(self) + dialog.exec_() +# printer = QtGui.QPrinter() +# serviceDocument = QtGui.QTextDocument() +# serviceDocument.setHtml(text) From 90023bb8537266f21b8314b1bfef4691160ebe22 Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Fri, 4 Feb 2011 16:39:01 +0000 Subject: [PATCH 20/68] For updates --- openlp.pyw | 2 +- openlp/core/ui/exceptiondialog.py | 3 +++ openlp/core/ui/exceptionform.py | 2 +- 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/openlp.pyw b/openlp.pyw index 695d6e09f..15f2c8788 100755 --- a/openlp.pyw +++ b/openlp.pyw @@ -76,7 +76,7 @@ class OpenLP(QtGui.QApplication): """ Load and store current Application Version """ - if u'--dev-version' in sys.argv: + if u'--dev-version' in sys.argv or u'-d' in sys.argv: # If we're running the dev version, let's use bzr to get the version try: # If bzrlib is availble, use it diff --git a/openlp/core/ui/exceptiondialog.py b/openlp/core/ui/exceptiondialog.py index 9e9b558df..2279e5272 100644 --- a/openlp/core/ui/exceptiondialog.py +++ b/openlp/core/ui/exceptiondialog.py @@ -63,17 +63,20 @@ class Ui_ExceptionDialog(object): self.exceptionButtonBox.setStandardButtons(QtGui.QDialogButtonBox.Close) self.exceptionButtonBox.setObjectName(u'exceptionButtonBox') self.exceptionLayout.addWidget(self.exceptionButtonBox) + self.sendReportButton = QtGui.QPushButton(exceptionDialog) self.sendReportButton.setIcon(build_icon( u':/general/general_email.png')) self.sendReportButton.setObjectName(u'sendReportButton') self.exceptionButtonBox.addButton(self.sendReportButton, QtGui.QDialogButtonBox.ActionRole) + self.saveReportButton = QtGui.QPushButton(exceptionDialog) self.saveReportButton.setIcon(build_icon(u':/general/general_save.png')) self.saveReportButton.setObjectName(u'saveReportButton') self.exceptionButtonBox.addButton(self.saveReportButton, QtGui.QDialogButtonBox.ActionRole) + self.attachFileButton = QtGui.QPushButton(exceptionDialog) self.attachFileButton.setIcon(build_icon(u':/general/general_open.png')) self.attachFileButton.setObjectName(u'attachFileButton') diff --git a/openlp/core/ui/exceptionform.py b/openlp/core/ui/exceptionform.py index a92967b6c..0a2d7acee 100644 --- a/openlp/core/ui/exceptionform.py +++ b/openlp/core/ui/exceptionform.py @@ -169,7 +169,7 @@ class ExceptionForm(QtGui.QDialog, Ui_ExceptionDialog): self.__buttonState(False) self.descriptionWordCount.setText( unicode(translate('OpenLP.ExceptionDialog', - 'Characters to Enter : %s')) % count ) + 'Description characters to Enter : %s')) % count ) def onAttachFileButtonPressed(self): files = QtGui.QFileDialog.getOpenFileName( From 7369a0391c5282622945448d026cfa771f27a795 Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Fri, 4 Feb 2011 16:41:02 +0000 Subject: [PATCH 21/68] Fix setup.py --- setup.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/setup.py b/setup.py index a435c5496..205688f1e 100755 --- a/setup.py +++ b/setup.py @@ -69,8 +69,7 @@ OpenLP (previously openlp.org) is free church presentation software, or lyrics p url='http://openlp.org/', license='GNU General Public License', packages=find_packages(exclude=['ez_setup', 'examples', 'tests']), - scripts=['openlp.pyw', 'scripts/openlp-1to2-converter.py', - 'scripts/bible-1to2-converter.py','scripts/openlp-remoteclient.py'], + scripts=['openlp.pyw', 'scripts/openlp-remoteclient.py'], include_package_data=True, zip_safe=False, install_requires=[ From 396037c0a3cbe583b38227f2f1ee13152fcf0343 Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Fri, 4 Feb 2011 16:49:30 +0000 Subject: [PATCH 22/68] Clean up time --- openlp.pyw | 1 - openlp/core/ui/exceptiondialog.py | 5 +---- openlp/core/ui/exceptionform.py | 2 +- 3 files changed, 2 insertions(+), 6 deletions(-) diff --git a/openlp.pyw b/openlp.pyw index 15f2c8788..100c3336f 100755 --- a/openlp.pyw +++ b/openlp.pyw @@ -196,7 +196,6 @@ class OpenLP(QtGui.QApplication): self.mainWindow.repaint() update_check = QtCore.QSettings().value( u'general/update check', QtCore.QVariant(True)).toBool() - a=c if update_check: VersionThread(self.mainWindow, app_version).start() return self.exec_() diff --git a/openlp/core/ui/exceptiondialog.py b/openlp/core/ui/exceptiondialog.py index 2279e5272..ba7bab496 100644 --- a/openlp/core/ui/exceptiondialog.py +++ b/openlp/core/ui/exceptiondialog.py @@ -63,20 +63,17 @@ class Ui_ExceptionDialog(object): self.exceptionButtonBox.setStandardButtons(QtGui.QDialogButtonBox.Close) self.exceptionButtonBox.setObjectName(u'exceptionButtonBox') self.exceptionLayout.addWidget(self.exceptionButtonBox) - self.sendReportButton = QtGui.QPushButton(exceptionDialog) self.sendReportButton.setIcon(build_icon( u':/general/general_email.png')) self.sendReportButton.setObjectName(u'sendReportButton') self.exceptionButtonBox.addButton(self.sendReportButton, QtGui.QDialogButtonBox.ActionRole) - self.saveReportButton = QtGui.QPushButton(exceptionDialog) self.saveReportButton.setIcon(build_icon(u':/general/general_save.png')) self.saveReportButton.setObjectName(u'saveReportButton') self.exceptionButtonBox.addButton(self.saveReportButton, QtGui.QDialogButtonBox.ActionRole) - self.attachFileButton = QtGui.QPushButton(exceptionDialog) self.attachFileButton.setIcon(build_icon(u':/general/general_open.png')) self.attachFileButton.setObjectName(u'attachFileButton') @@ -101,7 +98,7 @@ class Ui_ExceptionDialog(object): translate('OpenLP.ExceptionDialog', 'Error Occurred')) self.descriptionExplanation.setText(translate('OpenLP.ExceptionDialog', 'Please enter a description of what you were doing to cause this ' - 'error')) + 'error \n(Minimum 20 characters)')) self.messageLabel.setText(translate('OpenLP.ExceptionDialog', 'Oops! ' 'OpenLP hit a problem, and couldn\'t recover. The text in the box ' 'below contains information that might be helpful to the OpenLP ' diff --git a/openlp/core/ui/exceptionform.py b/openlp/core/ui/exceptionform.py index 0a2d7acee..ef3c84f18 100644 --- a/openlp/core/ui/exceptionform.py +++ b/openlp/core/ui/exceptionform.py @@ -169,7 +169,7 @@ class ExceptionForm(QtGui.QDialog, Ui_ExceptionDialog): self.__buttonState(False) self.descriptionWordCount.setText( unicode(translate('OpenLP.ExceptionDialog', - 'Description characters to Enter : %s')) % count ) + 'Description characters to enter : %s')) % count ) def onAttachFileButtonPressed(self): files = QtGui.QFileDialog.getOpenFileName( From 6577f6c25e0803e611545d53d957b868e7b24fea Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Fri, 4 Feb 2011 17:15:48 +0000 Subject: [PATCH 23/68] Fixes --- openlp/core/ui/exceptionform.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openlp/core/ui/exceptionform.py b/openlp/core/ui/exceptionform.py index ef3c84f18..7f9e23c61 100644 --- a/openlp/core/ui/exceptionform.py +++ b/openlp/core/ui/exceptionform.py @@ -71,6 +71,7 @@ class ExceptionForm(QtGui.QDialog, Ui_ExceptionDialog): self.settingsSection = u'crashreport' def exec_(self): + self.descriptionTextEdit.setPlainText(u'') self.onDescriptionUpdated() self.fileAttachment = None return QtGui.QDialog.exec_(self) @@ -136,7 +137,6 @@ class ExceptionForm(QtGui.QDialog, Ui_ExceptionDialog): Opening systems default email client and inserting exception log and system informations. """ - attach = None body = unicode(translate('OpenLP.ExceptionForm', '*OpenLP Bug Report*\n' 'Version: %s\n\n' From 642011b379065bb31c08db2cc84bb26bbe892230 Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Fri, 4 Feb 2011 19:00:59 +0100 Subject: [PATCH 24/68] --- openlp/core/ui/__init__.py | 3 +- openlp/core/ui/advancedtab.py | 34 ------ openlp/core/ui/printserviceorderform.py | 133 ++++++++++++++++++++++++ openlp/core/ui/servicemanager.py | 11 +- 4 files changed, 140 insertions(+), 41 deletions(-) create mode 100644 openlp/core/ui/printserviceorderform.py diff --git a/openlp/core/ui/__init__.py b/openlp/core/ui/__init__.py index 9de96e9b5..d6d1aa582 100644 --- a/openlp/core/ui/__init__.py +++ b/openlp/core/ui/__init__.py @@ -70,8 +70,7 @@ from shortcutlistform import ShortcutListForm from mediadockmanager import MediaDockManager from servicemanager import ServiceManager from thememanager import ThemeManager -from printserviceorderform import PrintServiceOrderForm __all__ = ['SplashScreen', 'AboutForm', 'SettingsForm', 'MainDisplay', 'SlideController', 'ServiceManager', 'ThemeManager', 'MediaDockManager', - 'ServiceItemEditForm'] + 'ServiceItemEditForm',] diff --git a/openlp/core/ui/advancedtab.py b/openlp/core/ui/advancedtab.py index 630cbc18c..58b637bc2 100644 --- a/openlp/core/ui/advancedtab.py +++ b/openlp/core/ui/advancedtab.py @@ -80,20 +80,6 @@ class AdvancedTab(SettingsTab): self.hideMouseCheckBox.setObjectName(u'hideMouseCheckBox') self.hideMouseLayout.addWidget(self.hideMouseCheckBox) self.leftLayout.addWidget(self.hideMouseGroupBox) - self.serviceOrderGroupBox = QtGui.QGroupBox(self.leftColumn) - self.serviceOrderGroupBox.setObjectName(u'serviceOrderGroupBox') - self.serviceOrderLayout = QtGui.QVBoxLayout(self.serviceOrderGroupBox) - self.serviceOrderLayout.setObjectName(u'serviceOrderLayout') - self.printSlideTextCheckBox = QtGui.QCheckBox(self.serviceOrderGroupBox) - self.printSlideTextCheckBox.setObjectName(u'printSlideTextCheckBox') - self.serviceOrderLayout.addWidget(self.printSlideTextCheckBox) - self.printMetaDataCheckBox = QtGui.QCheckBox(self.serviceOrderGroupBox) - self.printMetaDataCheckBox.setObjectName(u'printMetaDataCheckBox') - self.serviceOrderLayout.addWidget(self.printMetaDataCheckBox) - self.printNotesCheckBox = QtGui.QCheckBox(self.serviceOrderGroupBox) - self.printNotesCheckBox.setObjectName(u'printNotesCheckBox') - self.serviceOrderLayout.addWidget(self.printNotesCheckBox) - self.leftLayout.addWidget(self.serviceOrderGroupBox) # self.sharedDirGroupBox = QtGui.QGroupBox(self.leftColumn) # self.sharedDirGroupBox.setObjectName(u'sharedDirGroupBox') # self.sharedDirLayout = QtGui.QFormLayout(self.sharedDirGroupBox) @@ -143,14 +129,6 @@ class AdvancedTab(SettingsTab): 'Mouse Cursor')) self.hideMouseCheckBox.setText(translate('OpenLP.AdvancedTab', 'Hide the mouse cursor when moved over the display window')) - self.serviceOrderGroupBox.setTitle(translate('OpenLP.AdvancedTab', - 'Service Order Print')) - self.printSlideTextCheckBox.setText( - translate('OpenLP.AdvancedTab', 'Include text slides if available')) - self.printMetaDataCheckBox.setText(translate( - 'OpenLP.AdvancedTab', 'Include playing time of media files')) - self.printNotesCheckBox.setText( - translate('OpenLP.AdvancedTab', 'Include service item notes')) # self.sharedDirGroupBox.setTitle( # translate('AdvancedTab', 'Central Data Store')) # self.sharedCheckBox.setText( @@ -186,12 +164,6 @@ class AdvancedTab(SettingsTab): QtCore.QVariant(True)).toBool()) self.hideMouseCheckBox.setChecked( settings.value(u'hide mouse', QtCore.QVariant(False)).toBool()) - self.printSlideTextCheckBox.setChecked(settings.value( - u'print slide text', QtCore.QVariant(False)).toBool()) - self.printMetaDataCheckBox.setChecked(settings.value( - u'print file meta data', QtCore.QVariant(False)).toBool()) - self.printNotesCheckBox.setChecked(settings.value( - u'print notes', QtCore.QVariant(False)).toBool()) settings.endGroup() def save(self): @@ -212,12 +184,6 @@ class AdvancedTab(SettingsTab): QtCore.QVariant(self.enableAutoCloseCheckBox.isChecked())) settings.setValue(u'hide mouse', QtCore.QVariant(self.hideMouseCheckBox.isChecked())) - settings.setValue(u'print slide text', - QtCore.QVariant(self.printSlideTextCheckBox.isChecked())) - settings.setValue(u'print file meta data', - QtCore.QVariant(self.printMetaDataCheckBox.isChecked())) - settings.setValue(u'print notes', - QtCore.QVariant(self.printNotesCheckBox.isChecked())) settings.endGroup() # def onSharedCheckBoxChanged(self, checked): diff --git a/openlp/core/ui/printserviceorderform.py b/openlp/core/ui/printserviceorderform.py new file mode 100644 index 000000000..127cb95a8 --- /dev/null +++ b/openlp/core/ui/printserviceorderform.py @@ -0,0 +1,133 @@ +# -*- coding: utf-8 -*- +# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4 + +############################################################################### +# OpenLP - Open Source Lyrics Projection # +# --------------------------------------------------------------------------- # +# Copyright (c) 2008-2011 Raoul Snyman # +# Portions copyright (c) 2008-2011 Tim Bentley, Jonathan Corwin, Michael # +# Gorven, Scott Guerrieri, Meinert Jordan, Andreas Preikschat, Christian # +# Richter, Philip Ridout, Maikel Stuivenberg, Martin Thompson, Jon Tibble, # +# Carsten Tinggaard, Frode Woldsund # +# --------------------------------------------------------------------------- # +# This program is free software; you can redistribute it and/or modify it # +# under the terms of the GNU General Public License as published by the Free # +# Software Foundation; version 2 of the License. # +# # +# This program is distributed in the hope that it will be useful, but WITHOUT # +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or # +# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for # +# more details. # +# # +# You should have received a copy of the GNU General Public License along # +# with this program; if not, write to the Free Software Foundation, Inc., 59 # +# Temple Place, Suite 330, Boston, MA 02111-1307 USA # +############################################################################### +import datetime +import mutagen +import os + +from PyQt4 import QtCore, QtGui + +from openlp.core.lib import translate +from openlp.core.lib.ui import save_cancel_button_box + + +class PrintServiceOrderForm(QtGui.QDialog): + def __init__(self, parent=None): + """ + Constructor + """ + self.serviceManager = parent + QtGui.QDialog.__init__(self, parent) + self.setupUi() + self.retranslateUi() + + def setupUi(self): + self.dialogLayout = QtGui.QHBoxLayout(self) + self.dialogLayout.setObjectName(u'dialogLayout') + self.verticalLayout = QtGui.QVBoxLayout() + self.verticalLayout.setObjectName(u'verticalLayout') + self.serviceTitleLayout = QtGui.QHBoxLayout() + self.serviceTitleLayout.setObjectName(u'serviceTitleLayout') + self.serviceTitleLabel = QtGui.QLabel(self) + self.serviceTitleLabel.setObjectName(u'serviceTitleLabel') + self.serviceTitleLayout.addWidget(self.serviceTitleLabel) + self.serviceTitleLineEdit = QtGui.QLineEdit(self) + self.serviceTitleLineEdit.setObjectName(u'serviceTitleLineEdit') + self.serviceTitleLayout.addWidget(self.serviceTitleLineEdit) + self.verticalLayout.addLayout(self.serviceTitleLayout) + self.printSlideTextCheckBox = QtGui.QCheckBox(self) + self.printSlideTextCheckBox.setObjectName(u'printSlideTextCheckBox') + self.verticalLayout.addWidget(self.printSlideTextCheckBox) + self.printNotesCheckBox = QtGui.QCheckBox(self) + self.printNotesCheckBox.setObjectName(u'printNotesCheckBox') + self.verticalLayout.addWidget(self.printNotesCheckBox) + self.metaDataCheckBox = QtGui.QCheckBox(self) + self.metaDataCheckBox.setObjectName(u'metaDataCheckBox') + self.verticalLayout.addWidget(self.metaDataCheckBox) + self.verticalLayout.addWidget(save_cancel_button_box(self)) + self.dialogLayout.addLayout(self.verticalLayout) + QtCore.QMetaObject.connectSlotsByName(self) + + def retranslateUi(self): + self.setWindowTitle( + translate('OpenLP.PrintServiceOrderForm', 'Print Service Order')) + self.printSlideTextCheckBox.setText(translate( + 'OpenLP.PrintServiceOrderForm', 'Include slide text if avaialbe')) + self.printNotesCheckBox.setText(translate( + 'OpenLP.PrintServiceOrderForm', 'Include service item notes')) + self.metaDataCheckBox.setText(translate('OpenLP.PrintServiceOrderForm', + 'Include play lenght of media items')) + self.serviceTitleLabel.setText(translate( + 'OpenLP.PrintServiceOrderForm', 'Service Order Title')) + + def serviceOrderText(self): + """ + """ + if self.serviceTitleLineEdit.text(): + text = u'

%s

' % unicode(self.serviceTitleLineEdit.text()) + else: + text = u'

%s

' % translate('OpenLP.ServiceManager', + 'Service Order Sheet') + for item in self.serviceManager.serviceItems: + item = item[u'service_item'] + # Add the title of the service item. + text += u'

%s

' % (item.icon, + item.get_display_title()) + # Add slide text of the service item. + if self.printSlideTextCheckBox.isChecked(): + if item.is_text(): + # Add the text of the service item. + for slide in item.get_frames(): + text += u'

' + slide[u'text'] + u'

' + elif item.is_image(): + # Add the image names of the service item. + text += u'
    ' + for slide in range(len(item.get_frames())): + text += u'
  1. %s

  2. ' % \ + item.get_frame_title(slide) + text += u'
' + if item.foot_text: + # add footer + text += u'

%s

' % item.foot_text + # Add service items' notes. + if self.printNotesCheckBox.isChecked(): + if item.notes: + text += u'

%s %s

' % (translate( + 'OpenLP.ServiceManager', 'Notes:'), item.notes) + # Add play length of media files. + if item.is_media() and self.metaDataCheckBox.isChecked(): + path = os.path.join(item.get_frames()[0][u'path'], + item.get_frames()[0][u'title']) + if not os.path.isfile(path): + continue + file = mutagen.File(path) + if file is not None: + length = int(file.info.length) + text += u'

%s %s

' % (translate( + 'OpenLP.ServiceManager', u'Playing time:'), + unicode(datetime.timedelta(seconds=length))) + return text + + diff --git a/openlp/core/ui/servicemanager.py b/openlp/core/ui/servicemanager.py index b97171a5b..3d6c8e861 100644 --- a/openlp/core/ui/servicemanager.py +++ b/openlp/core/ui/servicemanager.py @@ -38,6 +38,7 @@ from openlp.core.lib import OpenLPToolbar, ServiceItem, context_menu_action, \ ThemeLevel from openlp.core.lib.ui import critical_error_message_box from openlp.core.ui import ServiceNoteForm, ServiceItemEditForm +from openlp.core.ui.printserviceorderform import PrintServiceOrderForm from openlp.core.utils import AppLocation, delete_file, file_is_unicode, \ split_filename @@ -1188,11 +1189,11 @@ class ServiceManager(QtGui.QWidget): """ Print a Service Order Sheet. """ - from openlp.core.ui import PrintServiceOrderForm - dialog = PrintServiceOrderForm(self) - if dialog.exec_(): - serviceDocument = QtGui.QTextDocument() - serviceDocument.setHtml(dialog.printServiceOrder()) + settingDialog = PrintServiceOrderForm(self) + if not settingDialog.exec_(): + return + serviceDocument = QtGui.QTextDocument() + serviceDocument.setHtml(settingDialog.serviceOrderText()) printDialog = QtGui.QPrintDialog() if not printDialog.exec_(): return From c3ac82a934ff1c09230f9cbaf4998d4a25b9571c Mon Sep 17 00:00:00 2001 From: Jon Tibble Date: Fri, 4 Feb 2011 18:17:28 +0000 Subject: [PATCH 25/68] UI library - add_widget_completer --- openlp/core/lib/ui.py | 8 ++++ openlp/plugins/bibles/lib/mediaitem.py | 7 ++-- openlp/plugins/songs/forms/editsongform.py | 45 ++++++++-------------- 3 files changed, 27 insertions(+), 33 deletions(-) diff --git a/openlp/core/lib/ui.py b/openlp/core/lib/ui.py index f388e03b4..983d278b0 100644 --- a/openlp/core/lib/ui.py +++ b/openlp/core/lib/ui.py @@ -182,3 +182,11 @@ def shortcut_action(parent, text, shortcuts, function): action.setShortcutContext(QtCore.Qt.WidgetWithChildrenShortcut) QtCore.QObject.connect(action, QtCore.SIGNAL(u'triggered()'), function) return action + +def add_widget_completer(cache, widget): + """ + Add a text autocompleter to a widget. + """ + completer = QtGui.QCompleter(cache) + completer.setCaseSensitivity(QtCore.Qt.CaseInsensitive) + widget.setCompleter(completer) diff --git a/openlp/plugins/bibles/lib/mediaitem.py b/openlp/plugins/bibles/lib/mediaitem.py index 26f45b6b3..c162447b2 100644 --- a/openlp/plugins/bibles/lib/mediaitem.py +++ b/openlp/plugins/bibles/lib/mediaitem.py @@ -30,7 +30,8 @@ from PyQt4 import QtCore, QtGui from openlp.core.lib import MediaManagerItem, Receiver, BaseListWithDnD, \ ItemCapabilities, translate -from openlp.core.lib.ui import critical_error_message_box, media_item_combo_box +from openlp.core.lib.ui import add_widget_completer, media_item_combo_box, \ + critical_error_message_box from openlp.plugins.bibles.forms import BibleImportForm from openlp.plugins.bibles.lib import get_reference_match @@ -379,9 +380,7 @@ class BibleMediaItem(MediaManagerItem): book_data = bibles[bible].get_books() books = [book.name for book in book_data] books.sort() - completer = QtGui.QCompleter(books) - completer.setCaseSensitivity(QtCore.Qt.CaseInsensitive) - self.quickSearchEdit.setCompleter(completer) + add_widget_completer(books, self.quickSearchEdit) def onAdvancedVersionComboBox(self): self.initialiseBible( diff --git a/openlp/plugins/songs/forms/editsongform.py b/openlp/plugins/songs/forms/editsongform.py index bf94503ff..57ad13f38 100644 --- a/openlp/plugins/songs/forms/editsongform.py +++ b/openlp/plugins/songs/forms/editsongform.py @@ -30,7 +30,7 @@ import re from PyQt4 import QtCore, QtGui from openlp.core.lib import Receiver, translate -from openlp.core.lib.ui import critical_error_message_box +from openlp.core.lib.ui import add_widget_completer, critical_error_message_box from openlp.plugins.songs.forms import EditVerseForm from openlp.plugins.songs.lib import SongXML, VerseType from openlp.plugins.songs.lib.db import Book, Song, Author, Topic @@ -129,37 +129,26 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog): self.authorsComboBox.setItemData( row, QtCore.QVariant(author.id)) self.authors.append(author.display_name) - completer = QtGui.QCompleter(self.authors) - completer.setCaseSensitivity(QtCore.Qt.CaseInsensitive) - self.authorsComboBox.setCompleter(completer) + add_widget_completer(self.authors, self.authorsComboBox) def loadTopics(self): - topics = self.manager.get_all_objects(Topic, order_by_ref=Topic.name) - self.topicsComboBox.clear() - self.topicsComboBox.addItem(u'') self.topics = [] - for topic in topics: - row = self.topicsComboBox.count() - self.topicsComboBox.addItem(topic.name) - self.topics.append(topic.name) - self.topicsComboBox.setItemData(row, QtCore.QVariant(topic.id)) - completer = QtGui.QCompleter(self.topics) - completer.setCaseSensitivity(QtCore.Qt.CaseInsensitive) - self.topicsComboBox.setCompleter(completer) + self.__loadObjects(Topic, self.topicsComboBox, self.topics) def loadBooks(self): - books = self.manager.get_all_objects(Book, order_by_ref=Book.name) - self.songBookComboBox.clear() - self.songBookComboBox.addItem(u'') self.books = [] - for book in books: - row = self.songBookComboBox.count() - self.songBookComboBox.addItem(book.name) - self.books.append(book.name) - self.songBookComboBox.setItemData(row, QtCore.QVariant(book.id)) - completer = QtGui.QCompleter(self.books) - completer.setCaseSensitivity(QtCore.Qt.CaseInsensitive) - self.songBookComboBox.setCompleter(completer) + self.__loadObjects(Book, self.songBookComboBox, self.books) + + def __loadObjects(self, class, combo, cache): + objects = self.manager.get_all_objects(class, order_by_ref=class.name) + combo.clear() + combo.addItem(u'') + for object in objects: + row = combo.count() + combo.addItem(object.name) + cache.append(object.name) + combo.setItemData(row, QtCore.QVariant(object.id)) + add_widget_completer(cache, combo) def loadThemes(self, theme_list): self.themeComboBox.clear() @@ -168,9 +157,7 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog): for theme in theme_list: self.themeComboBox.addItem(theme) self.themes.append(theme) - completer = QtGui.QCompleter(self.themes) - completer.setCaseSensitivity(QtCore.Qt.CaseInsensitive) - self.themeComboBox.setCompleter(completer) + add_widget_completer(self.themes, self.themeComboBox) def newSong(self): log.debug(u'New Song') From 9659eb2a1cfe36227b1584aa1428f495e68480b8 Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Fri, 4 Feb 2011 19:34:22 +0100 Subject: [PATCH 26/68] added print dialog --- openlp/core/ui/printserviceorderform.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/openlp/core/ui/printserviceorderform.py b/openlp/core/ui/printserviceorderform.py index 616159da6..b130f9470 100644 --- a/openlp/core/ui/printserviceorderform.py +++ b/openlp/core/ui/printserviceorderform.py @@ -80,17 +80,17 @@ class PrintServiceOrderForm(QtGui.QDialog): self.metaDataCheckBox.setText(translate('OpenLP.PrintServiceOrderForm', 'Include play lenght of media items')) self.serviceTitleLabel.setText(translate( - 'OpenLP.PrintServiceOrderForm', 'Service Order Title')) + 'OpenLP.PrintServiceOrderForm', 'Service Order Title:')) + self.serviceTitleLineEdit.setText(translate('OpenLP.ServiceManager', + 'Service Order Sheet')) def serviceOrderText(self): """ Creates the html text, to print the service items. """ + text = u'' if self.serviceTitleLineEdit.text(): - text = u'

%s

' % unicode(self.serviceTitleLineEdit.text()) - else: - text = u'

%s

' % translate('OpenLP.ServiceManager', - 'Service Order Sheet') + text += u'

%s

' % unicode(self.serviceTitleLineEdit.text()) for item in self.serviceManager.serviceItems: item = item[u'service_item'] # Add the title of the service item. From 20e05efd394caae670f49e5d6f4c4185d043da21 Mon Sep 17 00:00:00 2001 From: Jon Tibble Date: Fri, 4 Feb 2011 18:42:37 +0000 Subject: [PATCH 27/68] Fix inherited method name --- openlp/plugins/custom/lib/mediaitem.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/openlp/plugins/custom/lib/mediaitem.py b/openlp/plugins/custom/lib/mediaitem.py index ec915b0a9..908c4e18d 100644 --- a/openlp/plugins/custom/lib/mediaitem.py +++ b/openlp/plugins/custom/lib/mediaitem.py @@ -69,7 +69,7 @@ class CustomMediaItem(MediaManagerItem): QtCore.SIGNAL(u'custom_preview'), self.onPreviewClick) def initialise(self): - self.loadCustomListView(self.manager.get_all_objects( + self.loadList(self.manager.get_all_objects( CustomSlide, order_by_ref=CustomSlide.title)) # Called to redisplay the custom list screen edith from a search # or from the exit of the Custom edit dialog. If remote editing is @@ -80,7 +80,7 @@ class CustomMediaItem(MediaManagerItem): self.onPreviewClick() self.onRemoteEditClear() - def loadCustomListView(self, list): + def loadList(self, list): self.listView.clear() for customSlide in list: custom_name = QtGui.QListWidgetItem(customSlide.title) From ead4f958356d9b5d3fe080bcc38e483a3074c0c6 Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Fri, 4 Feb 2011 19:51:20 +0100 Subject: [PATCH 28/68] --- .../plugins/custom/forms/editcustomdialog.py | 9 ++ openlp/plugins/custom/forms/editcustomform.py | 136 +++++++++--------- 2 files changed, 81 insertions(+), 64 deletions(-) diff --git a/openlp/plugins/custom/forms/editcustomdialog.py b/openlp/plugins/custom/forms/editcustomdialog.py index 75717c082..542f41410 100644 --- a/openlp/plugins/custom/forms/editcustomdialog.py +++ b/openlp/plugins/custom/forms/editcustomdialog.py @@ -59,20 +59,24 @@ class Ui_CustomEditDialog(object): self.addButton.setObjectName(u'addButton') self.buttonLayout.addWidget(self.addButton) self.editButton = QtGui.QPushButton(customEditDialog) + self.editButton.setEnabled(False) self.editButton.setObjectName(u'editButton') self.buttonLayout.addWidget(self.editButton) self.editAllButton = QtGui.QPushButton(customEditDialog) self.editAllButton.setObjectName(u'editAllButton') self.buttonLayout.addWidget(self.editAllButton) self.deleteButton = QtGui.QPushButton(customEditDialog) + self.deleteButton.setEnabled(False) self.deleteButton.setObjectName(u'deleteButton') self.buttonLayout.addWidget(self.deleteButton) self.buttonLayout.addStretch() self.upButton = QtGui.QPushButton(customEditDialog) + self.upButton.setEnabled(False) self.upButton.setIcon(build_icon(u':/services/service_up.png')) self.upButton.setObjectName(u'upButton') self.buttonLayout.addWidget(self.upButton) self.downButton = QtGui.QPushButton(customEditDialog) + self.downButton.setEnabled(False) self.downButton.setIcon(build_icon(u':/services/service_down.png')) self.downButton.setObjectName(u'downButton') self.buttonLayout.addWidget(self.downButton) @@ -95,6 +99,9 @@ class Ui_CustomEditDialog(object): self.bottomFormLayout.addRow(self.creditLabel, self.creditEdit) self.dialogLayout.addLayout(self.bottomFormLayout) self.buttonBox = save_cancel_button_box(customEditDialog) + self.previewButton = QtGui.QPushButton() + self.buttonBox.addButton( + self.previewButton, QtGui.QDialogButtonBox.ActionRole) self.dialogLayout.addWidget(self.buttonBox) self.retranslateUi(customEditDialog) QtCore.QMetaObject.connectSlotsByName(customEditDialog) @@ -134,3 +141,5 @@ class Ui_CustomEditDialog(object): translate('CustomPlugin.EditCustomForm', 'The&me:')) self.creditLabel.setText( translate('CustomPlugin.EditCustomForm', '&Credits:')) + self.previewButton.setText( + translate('CustomPlugin.EditCustomForm', 'Save && Preview')) diff --git a/openlp/plugins/custom/forms/editcustomform.py b/openlp/plugins/custom/forms/editcustomform.py index e8dfa20aa..c5a31c5ad 100644 --- a/openlp/plugins/custom/forms/editcustomform.py +++ b/openlp/plugins/custom/forms/editcustomform.py @@ -48,14 +48,12 @@ class EditCustomForm(QtGui.QDialog, Ui_CustomEditDialog): """ QtGui.QDialog.__init__(self, parent) self.setupUi(self) + # Create other objects and forms. + self.manager = manager + self.editSlideForm = EditCustomSlideForm(self) # Connecting signals and slots - self.previewButton = QtGui.QPushButton() - self.previewButton.setText( - translate('CustomPlugin.EditCustomForm', 'Save && Preview')) - self.buttonBox.addButton( - self.previewButton, QtGui.QDialogButtonBox.ActionRole) - QtCore.QObject.connect(self.buttonBox, - QtCore.SIGNAL(u'clicked(QAbstractButton*)'), self.onPreview) + QtCore.QObject.connect(self.previewButton, + QtCore.SIGNAL(u'pressed()'), self.onPreviewButtonPressed) QtCore.QObject.connect(self.addButton, QtCore.SIGNAL(u'pressed()'), self.onAddButtonPressed) QtCore.QObject.connect(self.editButton, @@ -68,32 +66,10 @@ class EditCustomForm(QtGui.QDialog, Ui_CustomEditDialog): QtCore.SIGNAL(u'pressed()'), self.onUpButtonPressed) QtCore.QObject.connect(self.downButton, QtCore.SIGNAL(u'pressed()'), self.onDownButtonPressed) - QtCore.QObject.connect(self.slideListView, - QtCore.SIGNAL(u'itemClicked(QListWidgetItem*)'), - self.onSlideListViewPressed) QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'theme_update_list'), self.loadThemes) - # Create other objects and forms. - self.manager = manager - self.editSlideForm = EditCustomSlideForm(self) - self.initialise() - - def onPreview(self, button): - log.debug(u'onPreview') - if button.text() == unicode(translate('CustomPlugin.EditCustomForm', - 'Save && Preview')) and self.saveCustom(): - Receiver.send_message(u'custom_preview') - - def initialise(self): - self.addButton.setEnabled(True) - self.deleteButton.setEnabled(False) - self.editButton.setEnabled(False) - self.editAllButton.setEnabled(True) - self.titleEdit.setText(u'') - self.creditEdit.setText(u'') - self.slideListView.clear() - # Make sure we have a new item. - self.customSlide = CustomSlide() + QtCore.QObject.connect(self.slideListView, + QtCore.SIGNAL(u'currentRowChanged(int)'), self.onCurrentRowChanged) def loadThemes(self, themelist): self.themeComboBox.clear() @@ -112,9 +88,13 @@ class EditCustomForm(QtGui.QDialog, Ui_CustomEditDialog): States whether the custom is edited while being previewed in the preview panel. """ - self.customSlide = CustomSlide() - self.initialise() - if id != 0: + self.slideListView.clear() + if id == 0: + self.customSlide = CustomSlide() + self.titleEdit.setText(u'') + self.creditEdit.setText(u'') + self.themeComboBox.setCurrentIndex(0) + else: self.customSlide = self.manager.get_object(CustomSlide, id) self.titleEdit.setText(self.customSlide.title) self.creditEdit.setText(self.customSlide.credits) @@ -128,9 +108,6 @@ class EditCustomForm(QtGui.QDialog, Ui_CustomEditDialog): if id == -1: id = 0 self.themeComboBox.setCurrentIndex(id) - else: - self.themeComboBox.setCurrentIndex(0) - self.editAllButton.setEnabled(False) # If not preview hide the preview button. self.previewButton.setVisible(False) if preview: @@ -150,9 +127,7 @@ class EditCustomForm(QtGui.QDialog, Ui_CustomEditDialog): """ Saves the custom. """ - valid, message = self._validate() - if not valid: - critical_error_message_box(message=message) + if not self._validate(): return False sxml = CustomXMLBuilder() sxml.new_document() @@ -183,16 +158,11 @@ class EditCustomForm(QtGui.QDialog, Ui_CustomEditDialog): self.slideListView.insertItem(selectedRow + 1, qw) self.slideListView.setCurrentRow(selectedRow + 1) - def onSlideListViewPressed(self, item): - self.deleteButton.setEnabled(True) - self.editButton.setEnabled(True) - def onAddButtonPressed(self): self.editSlideForm.setText(u'') if self.editSlideForm.exec_(): for slide in self.editSlideForm.getText(): self.slideListView.addItem(slide) - self.editAllButton.setEnabled(True) def onEditButtonPressed(self): self.editSlideForm.setText(self.slideListView.currentItem().text()) @@ -203,16 +173,23 @@ class EditCustomForm(QtGui.QDialog, Ui_CustomEditDialog): """ Edits all slides. """ - if self.slideListView.count() > 0: - slide_list = u'' - for row in range(0, self.slideListView.count()): - item = self.slideListView.item(row) - slide_list += item.text() - if row != self.slideListView.count() - 1: - slide_list += u'\n[---]\n' - self.editSlideForm.setText(slide_list) - if self.editSlideForm.exec_(): - self.updateSlideList(self.editSlideForm.getText(), True) + slide_list = u'' + for row in range(0, self.slideListView.count()): + item = self.slideListView.item(row) + slide_list += item.text() + if row != self.slideListView.count() - 1: + slide_list += u'\n[---]\n' + self.editSlideForm.setText(slide_list) + if self.editSlideForm.exec_(): + self.updateSlideList(self.editSlideForm.getText(), True) + + def onPreviewButtonPressed(self): + """ + Save the custom item and preview it. + """ + log.debug(u'onPreview') + if self.saveCustom(): + Receiver.send_message(u'custom_preview') def updateSlideList(self, slides, edit_all=False): """ @@ -244,13 +221,40 @@ class EditCustomForm(QtGui.QDialog, Ui_CustomEditDialog): self.slideListView.repaint() def onDeleteButtonPressed(self): + """ + Removes the current row from the list. + """ self.slideListView.takeItem(self.slideListView.currentRow()) - self.editButton.setEnabled(True) - self.editAllButton.setEnabled(True) - if self.slideListView.count() == 0: + if self.slideListView.currentRow() == 0: + self.upButton.setEnabled(False) + if self.slideListView.currentRow() == self.slideListView.count(): + self.downButton.setEnabled(False) + + def onCurrentRowChanged(self, row): + """ + Called when the *slideListView*'s current row has been changed. This + enables or disables buttons which require an slide to act on. + + ``row`` + The row (int). If there is no current row, the value is -1. + """ + if row == -1: self.deleteButton.setEnabled(False) self.editButton.setEnabled(False) - self.editAllButton.setEnabled(False) + self.upButton.setEnabled(False) + self.downButton.setEnabled(False) + else: + self.deleteButton.setEnabled(True) + self.editButton.setEnabled(True) + # Decide if the up/down buttons should be enabled or not. + if self.slideListView.count() - 1 == row: + self.downButton.setEnabled(False) + else: + self.downButton.setEnabled(True) + if row == 0: + self.upButton.setEnabled(False) + else: + self.upButton.setEnabled(True) def _validate(self): """ @@ -259,10 +263,14 @@ class EditCustomForm(QtGui.QDialog, Ui_CustomEditDialog): # We must have a title. if len(self.titleEdit.displayText()) == 0: self.titleEdit.setFocus() - return False, translate('CustomPlugin.EditCustomForm', - 'You need to type in a title.') + critical_error_message_box( + message=translate('CustomPlugin.EditCustomForm', + 'You need to type in a title.')) + return False # We must have at least one slide. if self.slideListView.count() == 0: - return False, translate('CustomPlugin.EditCustomForm', - 'You need to add at least one slide') - return True, u'' + critical_error_message_box( + message=translate('CustomPlugin.EditCustomForm', + 'You need to add at least one slide')) + return False + return True From dae7dff242f73e497868483380d5ccf7a912aeb4 Mon Sep 17 00:00:00 2001 From: Jon Tibble Date: Fri, 4 Feb 2011 19:58:44 +0000 Subject: [PATCH 29/68] Fix last commit Speed up OpenSong bible importer --- openlp/plugins/bibles/lib/opensong.py | 8 +++----- openlp/plugins/songs/forms/editsongform.py | 4 ++-- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/openlp/plugins/bibles/lib/opensong.py b/openlp/plugins/bibles/lib/opensong.py index 12a6562bc..9a0fd110d 100644 --- a/openlp/plugins/bibles/lib/opensong.py +++ b/openlp/plugins/bibles/lib/opensong.py @@ -38,7 +38,6 @@ class OpenSongBible(BibleDB): """ OpenSong Bible format importer class. """ - def __init__(self, parent, **kwargs): """ Constructor to create and set up an instance of the OpenSongBible @@ -81,14 +80,13 @@ class OpenSongBible(BibleDB): db_book.id, int(chapter.attrib[u'n'].split()[-1]), int(verse.attrib[u'n']), - unicode(verse.text) - ) - Receiver.send_message(u'openlp_process_events') + unicode(verse.text)) self.wizard.incrementProgressBar(unicode(translate( 'BiblesPlugin.Opensong', 'Importing %s %s...', 'Importing ...')) % (db_book.name, int(chapter.attrib[u'n'].split()[-1]))) - self.session.commit() + self.session.commit() + Receiver.send_message(u'openlp_process_events') except (IOError, AttributeError): log.exception(u'Loading bible from OpenSong file failed') success = False diff --git a/openlp/plugins/songs/forms/editsongform.py b/openlp/plugins/songs/forms/editsongform.py index 57ad13f38..8536d38b8 100644 --- a/openlp/plugins/songs/forms/editsongform.py +++ b/openlp/plugins/songs/forms/editsongform.py @@ -139,8 +139,8 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog): self.books = [] self.__loadObjects(Book, self.songBookComboBox, self.books) - def __loadObjects(self, class, combo, cache): - objects = self.manager.get_all_objects(class, order_by_ref=class.name) + def __loadObjects(self, cls, combo, cache): + objects = self.manager.get_all_objects(cls, order_by_ref=cls.name) combo.clear() combo.addItem(u'') for object in objects: From 860b1d376b59cde145664e01d3f797e02620968d Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Fri, 4 Feb 2011 21:10:32 +0100 Subject: [PATCH 30/68] --- openlp/core/ui/printserviceorderform.py | 31 +++++++-- resources/forms/printServiceOrder.ui | 91 +++++++++++++++++++++++++ 2 files changed, 117 insertions(+), 5 deletions(-) create mode 100644 resources/forms/printServiceOrder.ui diff --git a/openlp/core/ui/printserviceorderform.py b/openlp/core/ui/printserviceorderform.py index b130f9470..d24bfdf91 100644 --- a/openlp/core/ui/printserviceorderform.py +++ b/openlp/core/ui/printserviceorderform.py @@ -42,6 +42,16 @@ class PrintServiceOrderForm(QtGui.QDialog): QtGui.QDialog.__init__(self, parent) self.setupUi() self.retranslateUi() + # Load the settings for this dialog. + settings = QtCore.QSettings() + settings.beginGroup(u'advanced') + self.printSlideTextCheckBox.setChecked(settings.value( + u'print slide text', QtCore.QVariant(False)).toBool()) + self.printMetaDataCheckBox.setChecked(settings.value( + u'print file meta data', QtCore.QVariant(False)).toBool()) + self.printNotesCheckBox.setChecked(settings.value( + u'print notes', QtCore.QVariant(False)).toBool()) + settings.endGroup() def setupUi(self): self.dialogLayout = QtGui.QHBoxLayout(self) @@ -63,9 +73,9 @@ class PrintServiceOrderForm(QtGui.QDialog): self.printNotesCheckBox = QtGui.QCheckBox(self) self.printNotesCheckBox.setObjectName(u'printNotesCheckBox') self.verticalLayout.addWidget(self.printNotesCheckBox) - self.metaDataCheckBox = QtGui.QCheckBox(self) - self.metaDataCheckBox.setObjectName(u'metaDataCheckBox') - self.verticalLayout.addWidget(self.metaDataCheckBox) + self.printMetaDataCheckBox = QtGui.QCheckBox(self) + self.printMetaDataCheckBox.setObjectName(u'printMetaDataCheckBox') + self.verticalLayout.addWidget(self.printMetaDataCheckBox) self.verticalLayout.addWidget(save_cancel_button_box(self)) self.dialogLayout.addLayout(self.verticalLayout) QtCore.QMetaObject.connectSlotsByName(self) @@ -77,7 +87,8 @@ class PrintServiceOrderForm(QtGui.QDialog): 'OpenLP.PrintServiceOrderForm', 'Include slide text if avaialbe')) self.printNotesCheckBox.setText(translate( 'OpenLP.PrintServiceOrderForm', 'Include service item notes')) - self.metaDataCheckBox.setText(translate('OpenLP.PrintServiceOrderForm', + self.printMetaDataCheckBox.setText( + translate('OpenLP.PrintServiceOrderForm', 'Include play lenght of media items')) self.serviceTitleLabel.setText(translate( 'OpenLP.PrintServiceOrderForm', 'Service Order Title:')) @@ -118,7 +129,7 @@ class PrintServiceOrderForm(QtGui.QDialog): text += u'

%s %s

' % (translate( 'OpenLP.ServiceManager', 'Notes:'), item.notes) # Add play length of media files. - if item.is_media() and self.metaDataCheckBox.isChecked(): + if item.is_media() and self.printMetaDataCheckBox.isChecked(): path = os.path.join(item.get_frames()[0][u'path'], item.get_frames()[0][u'title']) if not os.path.isfile(path): @@ -129,4 +140,14 @@ class PrintServiceOrderForm(QtGui.QDialog): text += u'

%s %s

' % (translate( 'OpenLP.ServiceManager', u'Playing time:'), unicode(datetime.timedelta(seconds=length))) + # Save the settings for this dialog. + settings = QtCore.QSettings() + settings.beginGroup(u'advanced') + settings.setValue(u'print slide text', + QtCore.QVariant(self.printSlideTextCheckBox.isChecked())) + settings.setValue(u'print file meta data', + QtCore.QVariant(self.printMetaDataCheckBox.isChecked())) + settings.setValue(u'print notes', + QtCore.QVariant(self.printNotesCheckBox.isChecked())) + settings.endGroup() return text diff --git a/resources/forms/printServiceOrder.ui b/resources/forms/printServiceOrder.ui new file mode 100644 index 000000000..728e42d77 --- /dev/null +++ b/resources/forms/printServiceOrder.ui @@ -0,0 +1,91 @@ + + + Dialog + + + + 0 + 0 + 321 + 205 + + + + Dialog + + + + + + + + + + Service Title: + + + + + + + + + + + + Include slide text if avaialbe + + + + + + + Include service item notes + + + + + + + Include play lenght of media items + + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + Cancel + + + + + + + Print + + + + + + + + + + + + From a32cf1df433682625344f0f41e28421559d4e18d Mon Sep 17 00:00:00 2001 From: Jon Tibble Date: Fri, 4 Feb 2011 21:35:57 +0000 Subject: [PATCH 31/68] Catch failure to start process (Bug #712140) --- openlp/plugins/presentations/presentationplugin.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/openlp/plugins/presentations/presentationplugin.py b/openlp/plugins/presentations/presentationplugin.py index 8afed6022..17417df58 100644 --- a/openlp/plugins/presentations/presentationplugin.py +++ b/openlp/plugins/presentations/presentationplugin.py @@ -74,7 +74,11 @@ class PresentationPlugin(Plugin): self.insertToolboxItem() for controller in self.controllers: if self.controllers[controller].enabled(): - self.controllers[controller].start_process() + try: + self.controllers[controller].start_process() + except: + log.exception(u'Failed to start controller process') + self.controllers[controller].available = False self.mediaItem.buildFileMaskString() def finalise(self): From baf18ea1c7efca013c4df8dcd384496f54e17ae5 Mon Sep 17 00:00:00 2001 From: Jon Tibble Date: Sat, 5 Feb 2011 01:24:19 +0000 Subject: [PATCH 32/68] Start deobfuscating UI library --- openlp/core/lib/ui.py | 43 ++++++++++++++++--- openlp/core/ui/serviceitemeditdialog.py | 10 ++--- openlp/core/ui/servicenoteform.py | 4 +- openlp/plugins/alerts/forms/alertdialog.py | 4 +- .../plugins/custom/forms/editcustomdialog.py | 10 ++--- .../custom/forms/editcustomslidedialog.py | 4 +- openlp/plugins/songs/forms/authorsdialog.py | 5 ++- openlp/plugins/songs/forms/editsongdialog.py | 4 +- openlp/plugins/songs/forms/editversedialog.py | 5 ++- openlp/plugins/songs/forms/songbookdialog.py | 5 ++- openlp/plugins/songs/forms/topicsdialog.py | 5 ++- 11 files changed, 66 insertions(+), 33 deletions(-) diff --git a/openlp/core/lib/ui.py b/openlp/core/lib/ui.py index 983d278b0..4a346b3e1 100644 --- a/openlp/core/lib/ui.py +++ b/openlp/core/lib/ui.py @@ -38,6 +38,9 @@ def add_welcome_page(parent, image): """ Generate an opening welcome page for a wizard using a provided image. + ``parent`` + A ``QWizard`` object to add the welcome page to. + ``image`` A splash image for the wizard. """ @@ -58,9 +61,14 @@ def add_welcome_page(parent, image): parent.welcomeLayout.addStretch() parent.addPage(parent.welcomePage) -def save_cancel_button_box(parent): +def create_save_cancel_button_box(parent): """ - Return a standard dialog button box with save and cancel buttons. + Creates a standard dialog button box with save and cancel buttons. The + button box is connected to the parent's ``accept()`` and ``reject()`` + methods to handle the default ``accepted()`` and ``rejected()`` signals. + + ``parent`` + The parent object. This should be a ``QWidget`` descendant. """ button_box = QtGui.QDialogButtonBox(parent) button_box.setStandardButtons( @@ -109,9 +117,18 @@ def media_item_combo_box(parent, name): combo.setSizePolicy(QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Fixed) return combo -def delete_push_button(parent, icon=None): +def create_delete_push_button(parent, icon=None): """ - Return a standard push button with delete label. + Creates a standard push button with a delete label and optional icon. The + button is connected to the parent's ``onDeleteButtonClicked()`` method to + handle the ``clicked()`` signal. + + ``parent`` + The parent object. This should be a ``QWidget`` descendant. + + ``icon`` + An icon to display on the button. This can be either a ``QIcon``, a + resource path or a file name. """ delete_button = QtGui.QPushButton(parent) delete_button.setObjectName(u'deleteButton') @@ -124,9 +141,15 @@ def delete_push_button(parent, icon=None): QtCore.SIGNAL(u'clicked()'), parent.onDeleteButtonClicked) return delete_button -def up_down_push_button_set(parent): +def create_up_down_push_button_set(parent): """ - Return a standard set of two push buttons for up and down use with lists. + Creates a standard set of two push buttons, one for up and the other for + down, for use with lists. The buttons use arrow icons and no text and are + connected to the parent's ``onUpButtonClicked()`` and + ``onDownButtonClicked()`` to handle their respective ``clicked()`` signals. + + ``parent`` + The parent object. This should be a ``QWidget`` descendant. """ up_button = QtGui.QPushButton(parent) up_button.setIcon(build_icon(u':/services/service_up.png')) @@ -185,7 +208,13 @@ def shortcut_action(parent, text, shortcuts, function): def add_widget_completer(cache, widget): """ - Add a text autocompleter to a widget. + Adds a text autocompleter to a widget. + + ``cache`` + The list of items to use as suggestions. + + ``widget`` + The object to use the completer. """ completer = QtGui.QCompleter(cache) completer.setCaseSensitivity(QtCore.Qt.CaseInsensitive) diff --git a/openlp/core/ui/serviceitemeditdialog.py b/openlp/core/ui/serviceitemeditdialog.py index 4046e94ab..f22f3dcf5 100644 --- a/openlp/core/ui/serviceitemeditdialog.py +++ b/openlp/core/ui/serviceitemeditdialog.py @@ -27,8 +27,8 @@ from PyQt4 import QtCore, QtGui from openlp.core.lib import translate -from openlp.core.lib.ui import save_cancel_button_box, delete_push_button, \ - up_down_push_button_set +from openlp.core.lib.ui import create_save_cancel_button_box, \ + create_delete_push_button, create_up_down_push_button_set class Ui_ServiceItemEditDialog(object): def setupUi(self, serviceItemEditDialog): @@ -41,16 +41,16 @@ class Ui_ServiceItemEditDialog(object): self.dialogLayout.addWidget(self.listWidget, 0, 0) self.buttonLayout = QtGui.QVBoxLayout() self.buttonLayout.setObjectName(u'buttonLayout') - self.deleteButton = delete_push_button(serviceItemEditDialog) + self.deleteButton = create_delete_push_button(serviceItemEditDialog) self.buttonLayout.addWidget(self.deleteButton) self.buttonLayout.addStretch() - self.upButton, self.downButton = up_down_push_button_set( + self.upButton, self.downButton = create_up_down_push_button_set( serviceItemEditDialog) self.buttonLayout.addWidget(self.upButton) self.buttonLayout.addWidget(self.downButton) self.dialogLayout.addLayout(self.buttonLayout, 0, 1) self.dialogLayout.addWidget( - save_cancel_button_box(serviceItemEditDialog), 1, 0, 1, 2) + create_save_cancel_button_box(serviceItemEditDialog), 1, 0, 1, 2) self.retranslateUi(serviceItemEditDialog) QtCore.QMetaObject.connectSlotsByName(serviceItemEditDialog) diff --git a/openlp/core/ui/servicenoteform.py b/openlp/core/ui/servicenoteform.py index e659e50db..473cc1685 100644 --- a/openlp/core/ui/servicenoteform.py +++ b/openlp/core/ui/servicenoteform.py @@ -27,7 +27,7 @@ from PyQt4 import QtCore, QtGui from openlp.core.lib import translate -from openlp.core.lib.ui import save_cancel_button_box +from openlp.core.lib.ui import create_save_cancel_button_box class ServiceNoteForm(QtGui.QDialog): """ @@ -48,7 +48,7 @@ class ServiceNoteForm(QtGui.QDialog): self.textEdit = QtGui.QTextEdit(self) self.textEdit.setObjectName(u'textEdit') self.dialogLayout.addWidget(self.textEdit) - self.dialogLayout.addWidget(save_cancel_button_box(self)) + self.dialogLayout.addWidget(create_save_cancel_button_box(self)) QtCore.QMetaObject.connectSlotsByName(self) def retranslateUi(self): diff --git a/openlp/plugins/alerts/forms/alertdialog.py b/openlp/plugins/alerts/forms/alertdialog.py index 1a8a1fc58..93f7ead06 100644 --- a/openlp/plugins/alerts/forms/alertdialog.py +++ b/openlp/plugins/alerts/forms/alertdialog.py @@ -27,7 +27,7 @@ from PyQt4 import QtCore, QtGui from openlp.core.lib import build_icon, translate -from openlp.core.lib.ui import delete_push_button +from openlp.core.lib.ui import create_delete_push_button class Ui_AlertDialog(object): def setupUi(self, alertDialog): @@ -66,7 +66,7 @@ class Ui_AlertDialog(object): self.saveButton.setIcon(build_icon(u':/general/general_save.png')) self.saveButton.setObjectName(u'saveButton') self.manageButtonLayout.addWidget(self.saveButton) - self.deleteButton = delete_push_button(alertDialog) + self.deleteButton = create_delete_push_button(alertDialog) self.deleteButton.setEnabled(False) self.manageButtonLayout.addWidget(self.deleteButton) self.manageButtonLayout.addStretch() diff --git a/openlp/plugins/custom/forms/editcustomdialog.py b/openlp/plugins/custom/forms/editcustomdialog.py index a3b09310c..b7887aa90 100644 --- a/openlp/plugins/custom/forms/editcustomdialog.py +++ b/openlp/plugins/custom/forms/editcustomdialog.py @@ -27,8 +27,8 @@ from PyQt4 import QtCore, QtGui from openlp.core.lib import build_icon, translate -from openlp.core.lib.ui import save_cancel_button_box, delete_push_button, \ - up_down_push_button_set +from openlp.core.lib.ui import create_save_cancel_button_box, \ + create_delete_push_button, create_up_down_push_button_set class Ui_CustomEditDialog(object): def setupUi(self, customEditDialog): @@ -66,11 +66,11 @@ class Ui_CustomEditDialog(object): self.editAllButton = QtGui.QPushButton(customEditDialog) self.editAllButton.setObjectName(u'editAllButton') self.buttonLayout.addWidget(self.editAllButton) - self.deleteButton = delete_push_button(customEditDialog) + self.deleteButton = create_delete_push_button(customEditDialog) self.deleteButton.setEnabled(False) self.buttonLayout.addWidget(self.deleteButton) self.buttonLayout.addStretch() - self.upButton, self.downButton = up_down_push_button_set( + self.upButton, self.downButton = create_up_down_push_button_set( customEditDialog) self.upButton.setEnabled(False) self.downButton.setEnabled(False) @@ -94,7 +94,7 @@ class Ui_CustomEditDialog(object): self.creditLabel.setBuddy(self.creditEdit) self.bottomFormLayout.addRow(self.creditLabel, self.creditEdit) self.dialogLayout.addLayout(self.bottomFormLayout) - self.buttonBox = save_cancel_button_box(customEditDialog) + self.buttonBox = create_save_cancel_button_box(customEditDialog) self.previewButton = QtGui.QPushButton() self.buttonBox.addButton( self.previewButton, QtGui.QDialogButtonBox.ActionRole) diff --git a/openlp/plugins/custom/forms/editcustomslidedialog.py b/openlp/plugins/custom/forms/editcustomslidedialog.py index 93bff68b8..24c40d6e6 100644 --- a/openlp/plugins/custom/forms/editcustomslidedialog.py +++ b/openlp/plugins/custom/forms/editcustomslidedialog.py @@ -27,7 +27,7 @@ from PyQt4 import QtCore, QtGui from openlp.core.lib import translate, SpellTextEdit -from openlp.core.lib.ui import save_cancel_button_box +from openlp.core.lib.ui import create_save_cancel_button_box class Ui_CustomSlideEditDialog(object): def setupUi(self, customSlideEditDialog): @@ -37,7 +37,7 @@ class Ui_CustomSlideEditDialog(object): self.slideTextEdit = SpellTextEdit(self) self.slideTextEdit.setObjectName(u'slideTextEdit') self.dialogLayout.addWidget(self.slideTextEdit) - self.buttonBox = save_cancel_button_box(customSlideEditDialog) + self.buttonBox = create_save_cancel_button_box(customSlideEditDialog) self.splitButton = QtGui.QPushButton(customSlideEditDialog) self.splitButton.setObjectName(u'splitButton') self.buttonBox.addButton(self.splitButton, diff --git a/openlp/plugins/songs/forms/authorsdialog.py b/openlp/plugins/songs/forms/authorsdialog.py index 3fd3c5fef..0b3f791d1 100644 --- a/openlp/plugins/songs/forms/authorsdialog.py +++ b/openlp/plugins/songs/forms/authorsdialog.py @@ -27,7 +27,7 @@ from PyQt4 import QtCore, QtGui from openlp.core.lib import translate -from openlp.core.lib.ui import save_cancel_button_box +from openlp.core.lib.ui import create_save_cancel_button_box class Ui_AuthorsDialog(object): def setupUi(self, authorsDialog): @@ -56,7 +56,8 @@ class Ui_AuthorsDialog(object): self.displayLabel.setBuddy(self.displayEdit) self.authorLayout.addRow(self.displayLabel, self.displayEdit) self.dialogLayout.addLayout(self.authorLayout) - self.dialogLayout.addWidget(save_cancel_button_box(authorsDialog)) + self.dialogLayout.addWidget( + create_save_cancel_button_box(authorsDialog)) self.retranslateUi(authorsDialog) authorsDialog.setMaximumHeight(authorsDialog.sizeHint().height()) QtCore.QMetaObject.connectSlotsByName(authorsDialog) diff --git a/openlp/plugins/songs/forms/editsongdialog.py b/openlp/plugins/songs/forms/editsongdialog.py index c44b42d46..e9be62830 100644 --- a/openlp/plugins/songs/forms/editsongdialog.py +++ b/openlp/plugins/songs/forms/editsongdialog.py @@ -27,7 +27,7 @@ from PyQt4 import QtCore, QtGui from openlp.core.lib import build_icon, translate -from openlp.core.lib.ui import save_cancel_button_box +from openlp.core.lib.ui import create_save_cancel_button_box class Ui_EditSongDialog(object): def setupUi(self, editSongDialog): @@ -241,7 +241,7 @@ class Ui_EditSongDialog(object): self.themeTabLayout.addWidget(self.commentsGroupBox) self.songTabWidget.addTab(self.themeTab, u'') self.dialogLayout.addWidget(self.songTabWidget) - self.buttonBox = save_cancel_button_box(editSongDialog) + self.buttonBox = create_save_cancel_button_box(editSongDialog) self.dialogLayout.addWidget(self.buttonBox) self.retranslateUi(editSongDialog) QtCore.QMetaObject.connectSlotsByName(editSongDialog) diff --git a/openlp/plugins/songs/forms/editversedialog.py b/openlp/plugins/songs/forms/editversedialog.py index deaf952e2..b4bc4551f 100644 --- a/openlp/plugins/songs/forms/editversedialog.py +++ b/openlp/plugins/songs/forms/editversedialog.py @@ -27,7 +27,7 @@ from PyQt4 import QtCore, QtGui from openlp.core.lib import build_icon, translate, SpellTextEdit -from openlp.core.lib.ui import save_cancel_button_box +from openlp.core.lib.ui import create_save_cancel_button_box from openlp.plugins.songs.lib import VerseType class Ui_EditVerseDialog(object): @@ -60,7 +60,8 @@ class Ui_EditVerseDialog(object): self.verseTypeLayout.addWidget(self.insertButton) self.verseTypeLayout.addStretch() self.dialogLayout.addLayout(self.verseTypeLayout) - self.dialogLayout.addWidget(save_cancel_button_box(editVerseDialog)) + self.dialogLayout.addWidget( + create_save_cancel_button_box(editVerseDialog)) self.retranslateUi(editVerseDialog) QtCore.QMetaObject.connectSlotsByName(editVerseDialog) diff --git a/openlp/plugins/songs/forms/songbookdialog.py b/openlp/plugins/songs/forms/songbookdialog.py index fcd6bd364..89b8941b5 100644 --- a/openlp/plugins/songs/forms/songbookdialog.py +++ b/openlp/plugins/songs/forms/songbookdialog.py @@ -27,7 +27,7 @@ from PyQt4 import QtCore, QtGui from openlp.core.lib import translate -from openlp.core.lib.ui import save_cancel_button_box +from openlp.core.lib.ui import create_save_cancel_button_box class Ui_SongBookDialog(object): def setupUi(self, songBookDialog): @@ -50,7 +50,8 @@ class Ui_SongBookDialog(object): self.publisherLabel.setBuddy(self.publisherEdit) self.bookLayout.addRow(self.publisherLabel, self.publisherEdit) self.dialogLayout.addLayout(self.bookLayout) - self.dialogLayout.addWidget(save_cancel_button_box(songBookDialog)) + self.dialogLayout.addWidget( + create_save_cancel_button_box(songBookDialog)) self.retranslateUi(songBookDialog) songBookDialog.setMaximumHeight(songBookDialog.sizeHint().height()) QtCore.QMetaObject.connectSlotsByName(songBookDialog) diff --git a/openlp/plugins/songs/forms/topicsdialog.py b/openlp/plugins/songs/forms/topicsdialog.py index f2c9fdeba..596597034 100644 --- a/openlp/plugins/songs/forms/topicsdialog.py +++ b/openlp/plugins/songs/forms/topicsdialog.py @@ -27,7 +27,7 @@ from PyQt4 import QtCore, QtGui from openlp.core.lib import translate -from openlp.core.lib.ui import save_cancel_button_box +from openlp.core.lib.ui import create_save_cancel_button_box class Ui_TopicsDialog(object): def setupUi(self, topicsDialog): @@ -44,7 +44,8 @@ class Ui_TopicsDialog(object): self.nameLabel.setBuddy(self.nameEdit) self.nameLayout.addRow(self.nameLabel, self.nameEdit) self.dialogLayout.addLayout(self.nameLayout) - self.dialogLayout.addWidget(save_cancel_button_box(topicsDialog)) + self.dialogLayout.addWidget( + create_save_cancel_button_box(topicsDialog)) self.retranslateUi(topicsDialog) topicsDialog.setMaximumHeight(topicsDialog.sizeHint().height()) QtCore.QMetaObject.connectSlotsByName(topicsDialog) From c7d31937624af26face82f3aac69b41b5852e5ff Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Sat, 5 Feb 2011 07:54:23 +0000 Subject: [PATCH 33/68] Lets not delete the image before we copy it. Doh Fixes: https://launchpad.net/bugs/712097 --- openlp/core/ui/thememanager.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/openlp/core/ui/thememanager.py b/openlp/core/ui/thememanager.py index f403d7441..2bb30c5d1 100644 --- a/openlp/core/ui/thememanager.py +++ b/openlp/core/ui/thememanager.py @@ -268,8 +268,8 @@ class ThemeManager(QtGui.QWidget): newThemeName = unicode(self.fileRenameForm.fileNameEdit.text()) if self.checkIfThemeExists(newThemeName): oldThemeData = self.getThemeData(oldThemeName) - self.deleteTheme(oldThemeName) self.cloneThemeData(oldThemeData, newThemeName) + self.deleteTheme(oldThemeName) for plugin in self.mainwindow.pluginManager.plugins: if plugin.usesTheme(oldThemeName): plugin.renameTheme(oldThemeName, newThemeName) @@ -295,11 +295,13 @@ class ThemeManager(QtGui.QWidget): log.debug(u'cloneThemeData') saveTo = None saveFrom = None + print themeData.background_type if themeData.background_type == u'image': saveTo = os.path.join(self.path, newThemeName, os.path.split(unicode(themeData.background_filename))[1]) saveFrom = themeData.background_filename themeData.theme_name = newThemeName + themeData.extend_image_filename(self.path) self.saveTheme(themeData, saveFrom, saveTo) def onEditTheme(self): @@ -349,7 +351,7 @@ class ThemeManager(QtGui.QWidget): shutil.rmtree(os.path.join(self.path, theme).encode(encoding)) except OSError: log.exception(u'Error deleting theme %s', theme) - # As we do not reload the themes push out the change + # As we do not reload the themes, push out the change # Reaload the list as the internal lists and events need # to be triggered self.pushThemes() @@ -577,6 +579,7 @@ class ThemeManager(QtGui.QWidget): theme_dir = os.path.join(self.path, name) check_directory_exists(theme_dir) theme_file = os.path.join(theme_dir, name + u'.xml') + print imageTo, self.oldBackgroundImage if imageTo and self.oldBackgroundImage and \ imageTo != self.oldBackgroundImage: delete_file(self.oldBackgroundImage) @@ -589,6 +592,7 @@ class ThemeManager(QtGui.QWidget): finally: if outfile: outfile.close() + print imageFrom, imageTo if imageFrom and imageFrom != imageTo: try: encoding = get_filesystem_encoding() @@ -603,7 +607,7 @@ class ThemeManager(QtGui.QWidget): def generateAndSaveImage(self, dir, name, theme): log.debug(u'generateAndSaveImage %s %s', dir, name) - theme_xml = theme.extract_xml() + #theme_xml = theme.extract_xml() frame = self.generateImage(theme) samplepathname = os.path.join(self.path, name + u'.png') if os.path.exists(samplepathname): From fecad94099eaa832abe1a24cd4fc63177d37d726 Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Sat, 5 Feb 2011 09:30:59 +0000 Subject: [PATCH 34/68] Fix up theme handing with rename and copy --- openlp/core/ui/thememanager.py | 28 ++++++++++++++++------------ openlp/plugins/bibles/bibleplugin.py | 3 ++- 2 files changed, 18 insertions(+), 13 deletions(-) diff --git a/openlp/core/ui/thememanager.py b/openlp/core/ui/thememanager.py index 2bb30c5d1..e71eae486 100644 --- a/openlp/core/ui/thememanager.py +++ b/openlp/core/ui/thememanager.py @@ -241,7 +241,7 @@ class ThemeManager(QtGui.QWidget): QtCore.QVariant(self.global_theme)) Receiver.send_message(u'theme_update_global', self.global_theme) - self.pushThemes() + self._pushThemes() def onAddTheme(self): """ @@ -273,6 +273,7 @@ class ThemeManager(QtGui.QWidget): for plugin in self.mainwindow.pluginManager.plugins: if plugin.usesTheme(oldThemeName): plugin.renameTheme(oldThemeName, newThemeName) + self.loadThemes() def onCopyTheme(self): """ @@ -295,7 +296,6 @@ class ThemeManager(QtGui.QWidget): log.debug(u'cloneThemeData') saveTo = None saveFrom = None - print themeData.background_type if themeData.background_type == u'image': saveTo = os.path.join(self.path, newThemeName, os.path.split(unicode(themeData.background_filename))[1]) @@ -334,6 +334,10 @@ class ThemeManager(QtGui.QWidget): row = self.themeListWidget.row(item) self.themeListWidget.takeItem(row) self.deleteTheme(theme) + # As we do not reload the themes, push out the change + # Reaload the list as the internal lists and events need + # to be triggered + self._pushThemes() def deleteTheme(self, theme): """ @@ -351,10 +355,6 @@ class ThemeManager(QtGui.QWidget): shutil.rmtree(os.path.join(self.path, theme).encode(encoding)) except OSError: log.exception(u'Error deleting theme %s', theme) - # As we do not reload the themes, push out the change - # Reaload the list as the internal lists and events need - # to be triggered - self.pushThemes() def onExportTheme(self): """ @@ -451,9 +451,9 @@ class ThemeManager(QtGui.QWidget): QtCore.QVariant(textName)) self.themeListWidget.addItem(item_name) self.themelist.append(textName) - self.pushThemes() + self._pushThemes() - def pushThemes(self): + def _pushThemes(self): """ Notify listeners that the theme list has been updated """ @@ -573,13 +573,20 @@ class ThemeManager(QtGui.QWidget): Called by thememaintenance Dialog to save the theme and to trigger the reload of the theme list """ + self._writeTheme(theme, imageFrom, imageTo) + self.loadThemes() + + def _writeTheme(self, theme, imageFrom, imageTo): + """ + Writes the theme to the disk and handles the background image if + necessary + """ name = theme.theme_name theme_pretty_xml = theme.extract_formatted_xml() log.debug(u'saveTheme %s %s', name, theme_pretty_xml) theme_dir = os.path.join(self.path, name) check_directory_exists(theme_dir) theme_file = os.path.join(theme_dir, name + u'.xml') - print imageTo, self.oldBackgroundImage if imageTo and self.oldBackgroundImage and \ imageTo != self.oldBackgroundImage: delete_file(self.oldBackgroundImage) @@ -592,7 +599,6 @@ class ThemeManager(QtGui.QWidget): finally: if outfile: outfile.close() - print imageFrom, imageTo if imageFrom and imageFrom != imageTo: try: encoding = get_filesystem_encoding() @@ -602,8 +608,6 @@ class ThemeManager(QtGui.QWidget): except IOError: log.exception(u'Failed to save theme image') self.generateAndSaveImage(self.path, name, theme) - self.loadThemes() - self.pushThemes() def generateAndSaveImage(self, dir, name, theme): log.debug(u'generateAndSaveImage %s %s', dir, name) diff --git a/openlp/plugins/bibles/bibleplugin.py b/openlp/plugins/bibles/bibleplugin.py index 15181e871..e3b2ad4aa 100644 --- a/openlp/plugins/bibles/bibleplugin.py +++ b/openlp/plugins/bibles/bibleplugin.py @@ -102,7 +102,7 @@ class BiblePlugin(Plugin): Called to find out if the bible plugin is currently using a theme. Returns True if the theme is being used, otherwise returns False. """ - if self.settings_tab.bible_theme == theme: + if unicode(self.settings_tab.bible_theme) == theme: return True return False @@ -119,6 +119,7 @@ class BiblePlugin(Plugin): The new name the plugin should now use. """ self.settings_tab.bible_theme = newTheme + self.settings_tab.save() def setPluginTextStrings(self): """ From 5c3c7e0c7008df2ce11151ffcb9858ed65df095c Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Sat, 5 Feb 2011 09:40:04 +0000 Subject: [PATCH 35/68] Remove line --- openlp/core/ui/thememanager.py | 1 - 1 file changed, 1 deletion(-) diff --git a/openlp/core/ui/thememanager.py b/openlp/core/ui/thememanager.py index e71eae486..7a4dda882 100644 --- a/openlp/core/ui/thememanager.py +++ b/openlp/core/ui/thememanager.py @@ -611,7 +611,6 @@ class ThemeManager(QtGui.QWidget): def generateAndSaveImage(self, dir, name, theme): log.debug(u'generateAndSaveImage %s %s', dir, name) - #theme_xml = theme.extract_xml() frame = self.generateImage(theme) samplepathname = os.path.join(self.path, name + u'.png') if os.path.exists(samplepathname): From d7b9cc93f97cd3e18f5e603df43fd2296905f90a Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Sat, 5 Feb 2011 10:45:08 +0100 Subject: [PATCH 36/68] fixed Bug #677282 --- openlp/core/ui/maindisplay.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openlp/core/ui/maindisplay.py b/openlp/core/ui/maindisplay.py index 3dfde8640..bae00c2da 100644 --- a/openlp/core/ui/maindisplay.py +++ b/openlp/core/ui/maindisplay.py @@ -72,7 +72,7 @@ class MainDisplay(DisplayWidget): self.setWindowIcon(mainIcon) self.retranslateUi() self.setStyleSheet(u'border: 0px; margin: 0px; padding: 0px;') - self.setWindowFlags(QtCore.Qt.FramelessWindowHint | + self.setWindowFlags(QtCore.Qt.FramelessWindowHint | QtCore.Qt.Tool | QtCore.Qt.WindowStaysOnTopHint) if self.isLive: QtCore.QObject.connect(Receiver.get_receiver(), From cf32b759738f74788c29f721a5d49f43e4a5ab09 Mon Sep 17 00:00:00 2001 From: Raoul Snyman Date: Sat, 5 Feb 2011 18:51:20 +0200 Subject: [PATCH 37/68] Set remotes plugin to disabled to prevent triggering of paranoia from paranoid Windows users. --- resources/windows/OpenLP.reg | Bin 1670 -> 1670 bytes 1 file changed, 0 insertions(+), 0 deletions(-) diff --git a/resources/windows/OpenLP.reg b/resources/windows/OpenLP.reg index 503e718a201e3cfc34aad41d9a43f173fa11776d..0ceee96684508fdc7352996fb24e981b8803c2aa 100644 GIT binary patch delta 17 YcmZqUZR6eG!pdkc`95pv delta 23 fcmZqUZR6eG!aBKujcu|4Q^aH&Hjc@wSnmJ;RG0@> From 5f7d570b6533ae5f247f326a0c63a239652c43b2 Mon Sep 17 00:00:00 2001 From: Raoul Snyman Date: Sat, 5 Feb 2011 18:52:03 +0200 Subject: [PATCH 38/68] Add some code to the installer to uninstall the previous install of OpenLP. --- resources/windows/OpenLP-2.0.iss | 53 ++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) diff --git a/resources/windows/OpenLP-2.0.iss b/resources/windows/OpenLP-2.0.iss index 94ee4fc22..fbb36009a 100644 --- a/resources/windows/OpenLP-2.0.iss +++ b/resources/windows/OpenLP-2.0.iss @@ -86,3 +86,56 @@ Root: HKCU; SubKey: Software\OpenLP\OpenLP\presentations; ValueType: dword; Valu Root: HKCU; SubKey: Software\OpenLP\OpenLP\remotes; ValueType: dword; ValueName: status; ValueData: $00000001 Root: HKCU; SubKey: Software\OpenLP\OpenLP\songs; ValueType: dword; ValueName: status; ValueData: $00000001 Root: HKCU; SubKey: Software\OpenLP\OpenLP\songusage; ValueType: dword; ValueName: status; ValueData: $00000001 + + +[Code] +function GetUninstallString(): String; +var + sUnInstPath: String; + sUnInstallString: String; +begin + sUnInstPath := ExpandConstant('Software\Microsoft\Windows\CurrentVersion\Uninstall\{#emit SetupSetting("AppId")}_is1'); + sUnInstallString := ''; + if not RegQueryStringValue(HKLM, sUnInstPath, 'UninstallString', sUnInstallString) then + RegQueryStringValue(HKCU, sUnInstPath, 'UninstallString', sUnInstallString); + Result := sUnInstallString; +end; + +function IsUpgrade(): Boolean; +begin + Result := (GetUninstallString() <> ''); +end; + +// Return Values: +// 1 - uninstall string is empty +// 2 - error executing the UnInstallString +// 3 - successfully executed the UnInstallString +function UnInstallOldVersion(): Integer; +var + sUnInstallString: String; + iResultCode: Integer; +begin + Result := 0; + sUnInstallString := GetUninstallString(); + if sUnInstallString <> '' then + begin + sUnInstallString := RemoveQuotes(sUnInstallString); + if Exec(sUnInstallString, '/SILENT /NORESTART /SUPPRESSMSGBOXES','', SW_HIDE, ewWaitUntilTerminated, iResultCode) then + Result := 3 + else + Result := 2; + end + else + Result := 1; +end; + +procedure CurStepChanged(CurStep: TSetupStep); +begin + if (CurStep=ssInstall) then + begin + if (IsUpgrade()) then + begin + UnInstallOldVersion(); + end; + end; +end; From 668419190ca04e4543c5a0ed679d3af49b479442 Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Sat, 5 Feb 2011 17:31:13 +0000 Subject: [PATCH 39/68] Theme fixes --- openlp/core/ui/thememanager.py | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/openlp/core/ui/thememanager.py b/openlp/core/ui/thememanager.py index 7a4dda882..e0dbf789a 100644 --- a/openlp/core/ui/thememanager.py +++ b/openlp/core/ui/thememanager.py @@ -260,7 +260,7 @@ class ThemeManager(QtGui.QWidget): 'You must select a theme to rename.')), unicode(translate('OpenLP.ThemeManager', 'Rename Confirmation')), unicode(translate('OpenLP.ThemeManager', 'Rename %s theme?')), - False): + False, False): item = self.themeListWidget.currentItem() oldThemeName = unicode(item.data(QtCore.Qt.UserRole).toString()) self.fileRenameForm.fileNameEdit.setText(oldThemeName) @@ -676,7 +676,7 @@ class ThemeManager(QtGui.QWidget): return theme def _validate_theme_action(self, select_text, confirm_title, confirm_text, - testPlugin=True): + testPlugin=True, confirm=True): """ Check to see if theme has been selected and the destructive action is allowed. @@ -688,12 +688,13 @@ class ThemeManager(QtGui.QWidget): item = self.themeListWidget.currentItem() theme = unicode(item.text()) # confirm deletion - answer = QtGui.QMessageBox.question(self, confirm_title, - confirm_text % theme, QtGui.QMessageBox.StandardButtons( - QtGui.QMessageBox.Yes | QtGui.QMessageBox.No), - QtGui.QMessageBox.No) - if answer == QtGui.QMessageBox.No: - return False + if confirm: + answer = QtGui.QMessageBox.question(self, confirm_title, + confirm_text % theme, QtGui.QMessageBox.StandardButtons( + QtGui.QMessageBox.Yes | QtGui.QMessageBox.No), + QtGui.QMessageBox.No) + if answer == QtGui.QMessageBox.No: + return False # should be the same unless default if theme != unicode(item.data(QtCore.Qt.UserRole).toString()): critical_error_message_box( From 229583e24121ee6a4f78807780c8027f058e5aaa Mon Sep 17 00:00:00 2001 From: Jon Tibble Date: Sat, 5 Feb 2011 18:01:08 +0000 Subject: [PATCH 40/68] Fix typos --- openlp/core/lib/mediamanageritem.py | 2 +- openlp/core/lib/toolbar.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/openlp/core/lib/mediamanageritem.py b/openlp/core/lib/mediamanageritem.py index 683459825..cc80ad564 100644 --- a/openlp/core/lib/mediamanageritem.py +++ b/openlp/core/lib/mediamanageritem.py @@ -158,7 +158,7 @@ class MediaManagerItem(QtGui.QWidget): ``icon`` The icon of the button. This can be an instance of QIcon, or a - string cotaining either the absolute path to the image, or an + string containing either the absolute path to the image, or an internal resource path starting with ':/'. ``slot`` diff --git a/openlp/core/lib/toolbar.py b/openlp/core/lib/toolbar.py index b1aa3d96f..6ae80045e 100644 --- a/openlp/core/lib/toolbar.py +++ b/openlp/core/lib/toolbar.py @@ -61,7 +61,7 @@ class OpenLPToolbar(QtGui.QToolBar): ``icon`` The icon of the button. This can be an instance of QIcon, or a - string cotaining either the absolute path to the image, or an + string containing either the absolute path to the image, or an internal resource path starting with ':/'. ``tooltip`` From aaa7a549e2933cedc41f9c871355c3d9ea0b1b3f Mon Sep 17 00:00:00 2001 From: Raoul Snyman Date: Sat, 5 Feb 2011 21:04:56 +0200 Subject: [PATCH 41/68] Fixed up registry entries in setup script. --- resources/windows/OpenLP-2.0.iss | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/resources/windows/OpenLP-2.0.iss b/resources/windows/OpenLP-2.0.iss index fbb36009a..a85b41187 100644 --- a/resources/windows/OpenLP-2.0.iss +++ b/resources/windows/OpenLP-2.0.iss @@ -83,11 +83,10 @@ Root: HKCU; SubKey: Software\OpenLP\OpenLP\custom; ValueType: dword; ValueName: Root: HKCU; SubKey: Software\OpenLP\OpenLP\images; ValueType: dword; ValueName: status; ValueData: $00000001 Root: HKCU; SubKey: Software\OpenLP\OpenLP\media; ValueType: dword; ValueName: status; ValueData: $00000001 Root: HKCU; SubKey: Software\OpenLP\OpenLP\presentations; ValueType: dword; ValueName: status; ValueData: $00000001 -Root: HKCU; SubKey: Software\OpenLP\OpenLP\remotes; ValueType: dword; ValueName: status; ValueData: $00000001 +Root: HKCU; SubKey: Software\OpenLP\OpenLP\remotes; ValueType: dword; ValueName: status; ValueData: $00000000 Root: HKCU; SubKey: Software\OpenLP\OpenLP\songs; ValueType: dword; ValueName: status; ValueData: $00000001 Root: HKCU; SubKey: Software\OpenLP\OpenLP\songusage; ValueType: dword; ValueName: status; ValueData: $00000001 - [Code] function GetUninstallString(): String; var From 1bae9b520f4a008a24d1ec3a9145110b4a570a4d Mon Sep 17 00:00:00 2001 From: Jon Tibble Date: Sat, 5 Feb 2011 20:10:08 +0000 Subject: [PATCH 42/68] Fix typo --- openlp/core/ui/thememanager.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/openlp/core/ui/thememanager.py b/openlp/core/ui/thememanager.py index 7a4dda882..44bd57591 100644 --- a/openlp/core/ui/thememanager.py +++ b/openlp/core/ui/thememanager.py @@ -334,9 +334,8 @@ class ThemeManager(QtGui.QWidget): row = self.themeListWidget.row(item) self.themeListWidget.takeItem(row) self.deleteTheme(theme) - # As we do not reload the themes, push out the change - # Reaload the list as the internal lists and events need - # to be triggered + # As we do not reload the themes, push out the change. Reload the + # list as the internal lists and events need to be triggered. self._pushThemes() def deleteTheme(self, theme): From a120719884f6e8d654d74fe0afe52a70693f76e8 Mon Sep 17 00:00:00 2001 From: Jon Tibble Date: Sat, 5 Feb 2011 23:52:05 +0000 Subject: [PATCH 43/68] Fix song service load (Bug #696219) --- openlp/plugins/songs/lib/mediaitem.py | 82 +++++++++++++-------------- 1 file changed, 41 insertions(+), 41 deletions(-) diff --git a/openlp/plugins/songs/lib/mediaitem.py b/openlp/plugins/songs/lib/mediaitem.py index 95337b29f..d5cd49cbb 100644 --- a/openlp/plugins/songs/lib/mediaitem.py +++ b/openlp/plugins/songs/lib/mediaitem.py @@ -32,7 +32,7 @@ from PyQt4 import QtCore, QtGui from sqlalchemy.sql import or_ from openlp.core.lib import MediaManagerItem, BaseListWithDnD, Receiver, \ - ItemCapabilities, translate, check_item_selected + ItemCapabilities, translate, check_item_selected, PluginStatus from openlp.plugins.songs.forms import EditSongForm, SongMaintenanceForm, \ SongImportForm from openlp.plugins.songs.lib import OpenLyrics, SongXML @@ -396,46 +396,46 @@ class SongMediaItem(MediaManagerItem): Triggered by a song being loaded by the service item """ log.debug(u'serviceLoad') - if item.data_string: - search_results = self.parent.manager.get_all_objects(Song, - Song.search_title == re.compile(r'\W+', re.UNICODE).sub(u' ', - item.data_string[u'title'].split(u'@')[0].lower()).strip(), - Song.search_title.asc()) - author_list = item.data_string[u'authors'].split(u', ') - # The service item always has an author (at least it has u'' as - # author). However, songs saved in the database do not have to have - # an author. - if u'' in author_list: - author_list.remove(u'') - editId = 0 - add_song = True - if search_results: - for song in search_results: - same_authors = True - # If the author counts are different, we do not have to do - # any further checking. This is also important when a song - # does not have any author (because we can not loop over an - # empty list). - if len(song.authors) == len(author_list): - for author in song.authors: - if author.display_name not in author_list: - same_authors = False - else: - same_authors = False - # All authors are the same, so we can stop here and the song - # does not have to be saved. - if same_authors: - add_song = False - editId = song.id - break - if add_song: - if self.addSongFromService: - editId = self.openLyrics.xml_to_song(item.xml_version) - self.onSearchTextButtonClick() - # Update service with correct song id. - if editId: - Receiver.send_message(u'service_item_update', - u'%s:%s' % (editId, item._uuid)) + if self.plugin.status != PluginStatus.Active or not item.data_string: + return + search_results = self.parent.manager.get_all_objects(Song, + Song.search_title == re.compile(r'\W+', re.UNICODE).sub(u' ', + item.data_string[u'title'].split(u'@')[0].lower()).strip(), + Song.search_title.asc()) + author_list = item.data_string[u'authors'].split(u', ') + # The service item always has an author (at least it has u'' as + # author). However, songs saved in the database do not have to have + # an author. + if u'' in author_list: + author_list.remove(u'') + editId = 0 + add_song = True + if search_results: + for song in search_results: + same_authors = True + # If the author counts are different, we do not have to do any + # further checking. This is also important when a song does not + # have any author (because we can not loop over an empty list). + if len(song.authors) == len(author_list): + for author in song.authors: + if author.display_name not in author_list: + same_authors = False + else: + same_authors = False + # All authors are the same, so we can stop here and the song + # does not have to be saved. + if same_authors: + add_song = False + editId = song.id + break + if add_song: + if self.addSongFromService: + editId = self.openLyrics.xml_to_song(item.xml_version) + self.onSearchTextButtonClick() + # Update service with correct song id. + if editId: + Receiver.send_message(u'service_item_update', + u'%s:%s' % (editId, item._uuid)) def collateSongTitles(self, song_1, song_2): """ From 13f4fa033d002d640af6c861a9cd75cd74f8c6bc Mon Sep 17 00:00:00 2001 From: Jon Tibble Date: Sat, 5 Feb 2011 23:56:34 +0000 Subject: [PATCH 44/68] Loading plugins can take time --- openlp/core/ui/pluginform.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/openlp/core/ui/pluginform.py b/openlp/core/ui/pluginform.py index d6ffc69f0..926aaaa7e 100644 --- a/openlp/core/ui/pluginform.py +++ b/openlp/core/ui/pluginform.py @@ -129,7 +129,9 @@ class PluginForm(QtGui.QDialog, Ui_PluginViewDialog): if self.programaticChange: return if status == 0: + Receiver.send_message(u'cursor_busy') self.activePlugin.toggleStatus(PluginStatus.Active) + Receiver.send_message(u'cursor_normal') else: self.activePlugin.toggleStatus(PluginStatus.Inactive) status_text = unicode( From 6e5889a3cb02e0fdc2d34d76c173911ad6e20d7f Mon Sep 17 00:00:00 2001 From: Jon Tibble Date: Sun, 6 Feb 2011 00:09:22 +0000 Subject: [PATCH 45/68] Fix missing import --- openlp/core/ui/pluginform.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openlp/core/ui/pluginform.py b/openlp/core/ui/pluginform.py index 926aaaa7e..3b41d76a3 100644 --- a/openlp/core/ui/pluginform.py +++ b/openlp/core/ui/pluginform.py @@ -28,7 +28,7 @@ import logging from PyQt4 import QtCore, QtGui -from openlp.core.lib import PluginStatus, StringContent, translate +from openlp.core.lib import PluginStatus, Receiver, StringContent, translate from plugindialog import Ui_PluginViewDialog log = logging.getLogger(__name__) From 1933144731741362bc516581469476174556f034 Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Sun, 6 Feb 2011 08:16:42 +0100 Subject: [PATCH 46/68] --- openlp/core/ui/printserviceorderform.py | 133 ++++++++++++++++++---- resources/forms/printServiceOrder.ui | 145 ++++++++++++++++-------- 2 files changed, 207 insertions(+), 71 deletions(-) diff --git a/openlp/core/ui/printserviceorderform.py b/openlp/core/ui/printserviceorderform.py index 7f09ceea2..34e1845d0 100644 --- a/openlp/core/ui/printserviceorderform.py +++ b/openlp/core/ui/printserviceorderform.py @@ -38,14 +38,13 @@ class PrintServiceOrderForm(QtGui.QDialog): """ Constructor """ - self.serviceManager = parent QtGui.QDialog.__init__(self, parent) - self.setupUi() - self.retranslateUi() - self.html = u'' + self.serviceManager = parent self.printer = QtGui.QPrinter() self.printDialog = QtGui.QPrintDialog(self.printer, self) self.document = QtGui.QTextDocument() + self.setupUi() + self.retranslateUi() # Load the settings for this dialog. settings = QtCore.QSettings() settings.beginGroup(u'advanced') @@ -56,37 +55,109 @@ class PrintServiceOrderForm(QtGui.QDialog): self.printNotesCheckBox.setChecked(settings.value( u'print notes', QtCore.QVariant(False)).toBool()) settings.endGroup() + # Signals + QtCore.QObject.connect(self.printButton, + QtCore.SIGNAL('clicked()'), self.printServiceOrder) + QtCore.QObject.connect(self.zoomOutButton, + QtCore.SIGNAL('clicked()'), self.zoomOut) + QtCore.QObject.connect(self.zoomInButton, + QtCore.SIGNAL('clicked()'), self.zoomIn) + QtCore.QObject.connect(self.previewWidget, + QtCore.SIGNAL('paintRequested(QPrinter *)'), self.paintRequested) + QtCore.QObject.connect(self.serviceTitleLineEdit, + QtCore.SIGNAL('textChanged(const QString)'), self.updatePreviewText) + QtCore.QObject.connect(self.printSlideTextCheckBox, + QtCore.SIGNAL('stateChanged(int)'), self.updatePreviewText) + QtCore.QObject.connect(self.printNotesCheckBox, + QtCore.SIGNAL('stateChanged(int)'), self.updatePreviewText) + QtCore.QObject.connect(self.printMetaDataCheckBox, + QtCore.SIGNAL('stateChanged(int)'), self.updatePreviewText) + self.updatePreviewText() def setupUi(self): self.dialogLayout = QtGui.QHBoxLayout(self) self.dialogLayout.setObjectName(u'dialogLayout') - self.verticalLayout = QtGui.QVBoxLayout() - self.verticalLayout.setObjectName(u'verticalLayout') + self.perviewLayout = QtGui.QVBoxLayout() + self.perviewLayout.setObjectName(u'perviewLayout') + self.previewLabel = QtGui.QLabel(self) + sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Preferred, QtGui.QSizePolicy.Preferred) + sizePolicy.setHorizontalStretch(0) + sizePolicy.setVerticalStretch(0) + sizePolicy.setHeightForWidth(self.previewLabel.sizePolicy().hasHeightForWidth()) + self.previewLabel.setSizePolicy(sizePolicy) + self.previewLabel.setObjectName(u'previewLabel') + self.perviewLayout.addWidget(self.previewLabel) + self.previewWidget = QtGui.QPrintPreviewWidget(self.printer, self, QtCore.Qt.Widget) + sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Preferred, QtGui.QSizePolicy.Expanding) + sizePolicy.setHorizontalStretch(0) + sizePolicy.setVerticalStretch(0) + sizePolicy.setHeightForWidth(self.previewWidget.sizePolicy().hasHeightForWidth()) + self.previewWidget.setSizePolicy(sizePolicy) + self.previewWidget.setObjectName(u'previewWidget') + self.previewWidget.fitToWidth() + self.perviewLayout.addWidget(self.previewWidget) + self.dialogLayout.addLayout(self.perviewLayout) + self.settingsLayout = QtGui.QVBoxLayout() + self.settingsLayout.setObjectName(u'settingsLayout') self.serviceTitleLayout = QtGui.QHBoxLayout() self.serviceTitleLayout.setObjectName(u'serviceTitleLayout') self.serviceTitleLabel = QtGui.QLabel(self) self.serviceTitleLabel.setObjectName(u'serviceTitleLabel') self.serviceTitleLayout.addWidget(self.serviceTitleLabel) self.serviceTitleLineEdit = QtGui.QLineEdit(self) + self.serviceTitleLineEdit.setSizePolicy( + QtGui.QSizePolicy.Preferred, QtGui.QSizePolicy.Fixed) self.serviceTitleLineEdit.setObjectName(u'serviceTitleLineEdit') self.serviceTitleLayout.addWidget(self.serviceTitleLineEdit) - self.verticalLayout.addLayout(self.serviceTitleLayout) + self.settingsLayout.addLayout(self.serviceTitleLayout) self.printSlideTextCheckBox = QtGui.QCheckBox(self) self.printSlideTextCheckBox.setObjectName(u'printSlideTextCheckBox') - self.verticalLayout.addWidget(self.printSlideTextCheckBox) + self.settingsLayout.addWidget(self.printSlideTextCheckBox) self.printNotesCheckBox = QtGui.QCheckBox(self) self.printNotesCheckBox.setObjectName(u'printNotesCheckBox') - self.verticalLayout.addWidget(self.printNotesCheckBox) + self.settingsLayout.addWidget(self.printNotesCheckBox) self.printMetaDataCheckBox = QtGui.QCheckBox(self) self.printMetaDataCheckBox.setObjectName(u'printMetaDataCheckBox') - self.verticalLayout.addWidget(self.printMetaDataCheckBox) - self.verticalLayout.addWidget(save_cancel_button_box(self)) - self.dialogLayout.addLayout(self.verticalLayout) + self.settingsLayout.addWidget(self.printMetaDataCheckBox) + self.buttonLayout = QtGui.QHBoxLayout() + self.zoomOutButton = QtGui.QToolButton(self) + icon = QtGui.QIcon() + #icon.addPixmap(QtGui.QPixmap(u':/exports/export_move_to_list.png'), + icon.addPixmap(QtGui.QPixmap(u'/home/andreas/zoom-out.png'), + QtGui.QIcon.Normal, QtGui.QIcon.Off) + self.zoomOutButton.setIcon(icon) + self.zoomOutButton.setObjectName(u'zoomOutButton') + self.buttonLayout.addWidget(self.zoomOutButton) + self.zoomInButton = QtGui.QToolButton(self) + icon = QtGui.QIcon() + #icon.addPixmap(QtGui.QPixmap(u':/exports/export_remove.png'), + icon.addPixmap(QtGui.QPixmap(u'/home/andreas/zoom-in.png'), + QtGui.QIcon.Normal, QtGui.QIcon.Off) + self.zoomInButton.setIcon(icon) + self.zoomInButton.setObjectName(u'toolButton') + self.buttonLayout.addWidget(self.zoomInButton) + spacerItem = QtGui.QSpacerItem(20, 40, + QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Expanding) + self.settingsLayout.addItem(spacerItem) + self.buttonLayout.setObjectName(u'buttonLayout') + spacerItem = QtGui.QSpacerItem(40, 20, + QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum) + self.buttonLayout.addItem(spacerItem) + self.cancelButton = QtGui.QPushButton(self) + self.cancelButton.setObjectName(u'cancelButton') + self.buttonLayout.addWidget(self.cancelButton) + self.printButton = QtGui.QPushButton(self) + self.printButton.setObjectName(u'printButton') + self.buttonLayout.addWidget(self.printButton) + self.settingsLayout.addLayout(self.buttonLayout) + self.dialogLayout.addLayout(self.settingsLayout) QtCore.QMetaObject.connectSlotsByName(self) def retranslateUi(self): self.setWindowTitle( translate('OpenLP.PrintServiceOrderForm', 'Print Service Order')) + self.previewLabel.setText( + translate('OpenLP.ServiceManager', 'Preview:')) self.printSlideTextCheckBox.setText(translate( 'OpenLP.PrintServiceOrderForm', 'Include slide text if avaialbe')) self.printNotesCheckBox.setText(translate( @@ -95,14 +166,17 @@ class PrintServiceOrderForm(QtGui.QDialog): translate('OpenLP.PrintServiceOrderForm', 'Include play lenght of media items')) self.serviceTitleLabel.setText(translate( - 'OpenLP.PrintServiceOrderForm', 'Service Order Title:')) + 'OpenLP.PrintServiceOrderForm', 'Title:')) self.serviceTitleLineEdit.setText(translate('OpenLP.ServiceManager', 'Service Order Sheet')) + self.printButton.setText(translate('OpenLP.ServiceManager', 'Print')) + self.cancelButton.setText(translate('OpenLP.ServiceManager', 'Cancel')) - def serviceOrderText(self): + def updatePreviewText(self): """ Creates the html text, to print the service items. """ + text = u'' if self.serviceTitleLineEdit.text(): text += u'

%s

' % unicode(self.serviceTitleLineEdit.text()) for item in self.serviceManager.serviceItems: @@ -129,8 +203,9 @@ class PrintServiceOrderForm(QtGui.QDialog): # Add service items' notes. if self.printNotesCheckBox.isChecked(): if item.notes: - text += u'

%s %s

' % (translate( - 'OpenLP.ServiceManager', 'Notes:'), item.notes) + text += u'

%s


%s' % (translate( + 'OpenLP.ServiceManager', 'Notes:'), + item.notes.replace(u'\n', u'
')) # Add play length of media files. if item.is_media() and self.printMetaDataCheckBox.isChecked(): path = os.path.join(item.get_frames()[0][u'path'], @@ -143,6 +218,19 @@ class PrintServiceOrderForm(QtGui.QDialog): text += u'

%s %s

' % (translate( 'OpenLP.ServiceManager', u'Playing time:'), unicode(datetime.timedelta(seconds=length))) + self.document.setHtml(text) + self.previewWidget.updatePreview() + + def paintRequested(self, printer): + """ + Paint the preview. + """ + self.document.print_(printer) + + def printServiceOrder(self): + if not self.printDialog.exec_(): + return + self.document.print_(self.printer) # Save the settings for this dialog. settings = QtCore.QSettings() settings.beginGroup(u'advanced') @@ -153,12 +241,9 @@ class PrintServiceOrderForm(QtGui.QDialog): settings.setValue(u'print notes', QtCore.QVariant(self.printNotesCheckBox.isChecked())) settings.endGroup() - self.document.setHtml(text) - def printServiceOrder(self): - serviceDocument = QtGui.QTextDocument() - serviceDocument.setHtml(settingDialog.serviceOrderText()) - printDialog = QtGui.QPrintDialog() - if not printDialog.exec_(): - return - serviceDocument.print_(printDialog.printer()) + def zoomIn(self): + self.previewWidget.zoomIn() + + def zoomOut(self): + self.previewWidget.zoomOut() diff --git a/resources/forms/printServiceOrder.ui b/resources/forms/printServiceOrder.ui index 84ec84bbe..b76bc012a 100644 --- a/resources/forms/printServiceOrder.ui +++ b/resources/forms/printServiceOrder.ui @@ -13,10 +13,10 @@ Dialog - + - - + + @@ -33,37 +33,47 @@ + + true + - + 0 0 + - + - - - - - Service Title: - - - - + + - + 0 0 + + + + + 0 + 0 + + + + Service Title: + + + @@ -81,14 +91,14 @@ - + Include play lenght of media items - + Qt::Vertical @@ -100,36 +110,75 @@ + + + + - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - Cancel - - - - - - - Print - - - - + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + Cancel + + + + + + + Print + + + + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + ... + + + + ../../../../../zoom-out.png../../../../../zoom-out.png + + + + + + + ... + + + + ../../../../../zoom-in.png../../../../../zoom-in.png + + @@ -137,6 +186,8 @@ - + + + From ff8fb724e1f041fc7df8fb4a0d4ca0b95102410a Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Sun, 6 Feb 2011 15:26:13 +0100 Subject: [PATCH 47/68] fixed line break --- openlp/core/ui/printserviceorderform.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openlp/core/ui/printserviceorderform.py b/openlp/core/ui/printserviceorderform.py index 3f130365a..40a3dede9 100644 --- a/openlp/core/ui/printserviceorderform.py +++ b/openlp/core/ui/printserviceorderform.py @@ -106,7 +106,7 @@ class PrintServiceOrderForm(QtGui.QDialog, Ui_PrintServiceOrderDialog): # Add service items' notes. if self.printNotesCheckBox.isChecked(): if item.notes: - text += u'

%s


%s' % (translate( + text += u'

%s

%s' % (translate( 'OpenLP.ServiceManager', 'Notes:'), item.notes.replace(u'\n', u'
')) # Add play length of media files. From 57e489b75ab4651b3dd7c216b73de2c02fc2da1d Mon Sep 17 00:00:00 2001 From: Jon Tibble Date: Sun, 6 Feb 2011 18:01:47 +0000 Subject: [PATCH 48/68] Dedupe presentation controllers --- .../presentations/lib/impresscontroller.py | 45 ++++++++++--------- .../presentations/lib/powerpointcontroller.py | 31 +++++++------ 2 files changed, 40 insertions(+), 36 deletions(-) diff --git a/openlp/plugins/presentations/lib/impresscontroller.py b/openlp/plugins/presentations/lib/impresscontroller.py index f12d36dc8..465f733c7 100644 --- a/openlp/plugins/presentations/lib/impresscontroller.py +++ b/openlp/plugins/presentations/lib/impresscontroller.py @@ -431,35 +431,36 @@ class ImpressDocument(PresentationDocument): def get_slide_text(self, slide_no): """ - Returns the text on the slide + Returns the text on the slide. ``slide_no`` - The slide the text is required for, starting at 1 + The slide the text is required for, starting at 1 + """ + return __get_text_from_slide(slide_no) + + def get_slide_notes(self, slide_no): + """ + Returns the text in the slide notes. + + ``slide_no`` + The slide the notes are required for, starting at 1 + """ + return __get_text_from_page(slide_no, True) + + def __get_text_from_page(self, slide_no, notes=False): + """ + Return any text extracted from the presentation page. + + ``notes`` + A boolean. If set the method searches the notes of the slide. """ - doc = self.document - pages = doc.getDrawPages() text = '' + pages = self.document.getDrawPages() page = pages.getByIndex(slide_no - 1) + if notes: + page = page.getNotesPage() for idx in range(page.getCount()): shape = page.getByIndex(idx) if shape.supportsService("com.sun.star.drawing.Text"): text += shape.getString() + '\n' return text - - def get_slide_notes(self, slide_no): - """ - Returns the text on the slide - - ``slide_no`` - The slide the notes are required for, starting at 1 - """ - doc = self.document - pages = doc.getDrawPages() - text = '' - page = pages.getByIndex(slide_no - 1) - notes = page.getNotesPage() - for idx in range(notes.getCount()): - shape = notes.getByIndex(idx) - if shape.supportsService("com.sun.star.drawing.Text"): - text += shape.getString() + '\n' - return text diff --git a/openlp/plugins/presentations/lib/powerpointcontroller.py b/openlp/plugins/presentations/lib/powerpointcontroller.py index 012f8534a..fcc8bfc47 100644 --- a/openlp/plugins/presentations/lib/powerpointcontroller.py +++ b/openlp/plugins/presentations/lib/powerpointcontroller.py @@ -291,13 +291,7 @@ class PowerpointDocument(PresentationDocument): ``slide_no`` The slide the text is required for, starting at 1. """ - text = '' - shapes = self.presentation.Slides(slide_no).Shapes - for idx in range(shapes.Count): - shape = shapes(idx + 1) - if shape.HasTextFrame: - text += shape.TextFrame.TextRange.Text + '\n' - return text + return _get_text_from_shapes(self.presentation.Slides(slide_no).Shapes) def get_slide_notes(self, slide_no): """ @@ -306,10 +300,19 @@ class PowerpointDocument(PresentationDocument): ``slide_no`` The slide the notes are required for, starting at 1. """ - text = '' - shapes = self.presentation.Slides(slide_no).NotesPage.Shapes - for idx in range(shapes.Count): - shape = shapes(idx + 1) - if shape.HasTextFrame: - text += shape.TextFrame.TextRange.Text + '\n' - return text \ No newline at end of file + return _get_text_from_shapes( + self.presentation.Slides(slide_no).NotesPage.Shapes) + +def _get_text_from_shapes(shapes): + """ + Returns any text extracted from the shapes on a presentation slide. + + ``shapes`` + A set of shapes to search for text. + """ + text = '' + for idx in range(shapes.Count): + shape = shapes(idx + 1) + if shape.HasTextFrame: + text += shape.TextFrame.TextRange.Text + '\n' + return text From 1824ac31c6d3d552cdf476f8dc28e2f1d1383bb6 Mon Sep 17 00:00:00 2001 From: Jon Tibble Date: Sun, 6 Feb 2011 19:37:35 +0000 Subject: [PATCH 49/68] Remove mediaitem duplicated calls --- openlp/plugins/images/lib/mediaitem.py | 2 -- openlp/plugins/media/lib/mediaitem.py | 2 -- 2 files changed, 4 deletions(-) diff --git a/openlp/plugins/images/lib/mediaitem.py b/openlp/plugins/images/lib/mediaitem.py index 71027881c..6e720fa0b 100644 --- a/openlp/plugins/images/lib/mediaitem.py +++ b/openlp/plugins/images/lib/mediaitem.py @@ -84,8 +84,6 @@ class ImageMediaItem(MediaManagerItem): def initialise(self): log.debug(u'initialise') self.listView.clear() - self.listView.setSelectionMode( - QtGui.QAbstractItemView.ExtendedSelection) self.listView.setIconSize(QtCore.QSize(88, 50)) self.servicePath = os.path.join( AppLocation.get_section_data_path(self.settingsSection), diff --git a/openlp/plugins/media/lib/mediaitem.py b/openlp/plugins/media/lib/mediaitem.py index ea1b679b4..f0549a960 100644 --- a/openlp/plugins/media/lib/mediaitem.py +++ b/openlp/plugins/media/lib/mediaitem.py @@ -151,8 +151,6 @@ class MediaMediaItem(MediaManagerItem): return False def initialise(self): - self.listView.setSelectionMode( - QtGui.QAbstractItemView.ExtendedSelection) self.listView.setIconSize(QtCore.QSize(88, 50)) self.loadList(SettingsManager.load_list(self.settingsSection, self.settingsSection)) From 8e36c7a7eccd4108d526c829e544434b6c4e0d6f Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Sun, 6 Feb 2011 20:53:08 +0100 Subject: [PATCH 50/68] only show ccli number if present --- openlp/plugins/songs/lib/mediaitem.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/openlp/plugins/songs/lib/mediaitem.py b/openlp/plugins/songs/lib/mediaitem.py index d5cd49cbb..66cff169f 100644 --- a/openlp/plugins/songs/lib/mediaitem.py +++ b/openlp/plugins/songs/lib/mediaitem.py @@ -378,10 +378,12 @@ class SongMediaItem(MediaManagerItem): raw_footer.append(song.title) raw_footer.append(author_list) raw_footer.append(song.copyright) - raw_footer.append(unicode( - translate('SongsPlugin.MediaItem', 'CCLI License: ') + - QtCore.QSettings().value(u'general/ccli number', - QtCore.QVariant(u'')).toString())) + if QtCore.QSettings().value(u'general/ccli number', + QtCore.QVariant(u'')).toString(): + raw_footer.append(unicode( + translate('SongsPlugin.MediaItem', 'CCLI License: ') + + QtCore.QSettings().value(u'general/ccli number', + QtCore.QVariant(u'')).toString())) service_item.raw_footer = raw_footer service_item.audit = [ song.title, author_audit, song.copyright, unicode(song.ccli_number) From 5504c541ad485d0d9b04ddf9cf8999d871b36604 Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Sun, 6 Feb 2011 21:21:18 +0100 Subject: [PATCH 51/68] removed not needed import, use build_icon --- openlp/core/ui/printserviceorderdialog.py | 15 ++++----------- openlp/core/ui/printserviceorderform.py | 1 - 2 files changed, 4 insertions(+), 12 deletions(-) diff --git a/openlp/core/ui/printserviceorderdialog.py b/openlp/core/ui/printserviceorderdialog.py index 5706034a7..70780291a 100644 --- a/openlp/core/ui/printserviceorderdialog.py +++ b/openlp/core/ui/printserviceorderdialog.py @@ -26,9 +26,7 @@ from PyQt4 import QtCore, QtGui -from openlp.core.lib import translate -from openlp.core.lib.ui import save_cancel_button_box - +from openlp.core.lib import build_icon, translate class Ui_PrintServiceOrderDialog(object): def setupUi(self, printServiceOrderDialog): @@ -99,17 +97,12 @@ class Ui_PrintServiceOrderDialog(object): QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum) self.zoomButtonLayout.addItem(spacerItem) self.zoomOutButton = QtGui.QToolButton(printServiceOrderDialog) - icon = QtGui.QIcon() - icon.addPixmap(QtGui.QPixmap(u':/general/general_zoom_out.png'), - QtGui.QIcon.Normal, QtGui.QIcon.Off) - self.zoomOutButton.setIcon(icon) + self.zoomOutButton.setIcon( + build_icon(u':/general/general_zoom_out.png')) self.zoomOutButton.setObjectName(u'zoomOutButton') self.zoomButtonLayout.addWidget(self.zoomOutButton) self.zoomInButton = QtGui.QToolButton(printServiceOrderDialog) - icon = QtGui.QIcon() - icon.addPixmap(QtGui.QPixmap(u':/general/general_zoom_in.png'), - QtGui.QIcon.Normal, QtGui.QIcon.Off) - self.zoomInButton.setIcon(icon) + self.zoomInButton.setIcon(build_icon(u':/general/general_zoom_in.png')) self.zoomInButton.setObjectName(u'zoomInButton') self.zoomButtonLayout.addWidget(self.zoomInButton) self.dialogLayout.addLayout(self.zoomButtonLayout, 1, 0, 1, 1) diff --git a/openlp/core/ui/printserviceorderform.py b/openlp/core/ui/printserviceorderform.py index 40a3dede9..d7cf87147 100644 --- a/openlp/core/ui/printserviceorderform.py +++ b/openlp/core/ui/printserviceorderform.py @@ -30,7 +30,6 @@ import os from PyQt4 import QtCore, QtGui from openlp.core.lib import translate -from openlp.core.lib.ui import save_cancel_button_box from openlp.core.ui.printserviceorderdialog import Ui_PrintServiceOrderDialog class PrintServiceOrderForm(QtGui.QDialog, Ui_PrintServiceOrderDialog): From 1bcbb83144460e4292c96c5a3e3b8a647c09224f Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Sun, 6 Feb 2011 21:26:32 +0100 Subject: [PATCH 52/68] fixed doc --- openlp/core/ui/servicemanager.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openlp/core/ui/servicemanager.py b/openlp/core/ui/servicemanager.py index ea09797ba..83d7cbc3c 100644 --- a/openlp/core/ui/servicemanager.py +++ b/openlp/core/ui/servicemanager.py @@ -1185,7 +1185,7 @@ class ServiceManager(QtGui.QWidget): def printServiceOrder(self): """ - Open a Print a Service Order Sheet. + Print a Service Order Sheet. """ settingDialog = PrintServiceOrderForm(self.mainwindow, self) settingDialog.exec_() From c736d0f1f84019aab2a16f736d01444a380b98bd Mon Sep 17 00:00:00 2001 From: Jon Tibble Date: Mon, 7 Feb 2011 15:55:02 +0000 Subject: [PATCH 53/68] Cleanups --- openlp/core/lib/imagemanager.py | 2 +- openlp/core/lib/plugin.py | 3 +++ openlp/core/ui/displaytagtab.py | 18 +++++++++--------- openlp/core/ui/pluginform.py | 4 +++- openlp/plugins/songs/lib/db.py | 1 - openlp/plugins/songs/lib/opensongimport.py | 3 --- 6 files changed, 16 insertions(+), 15 deletions(-) diff --git a/openlp/core/lib/imagemanager.py b/openlp/core/lib/imagemanager.py index 02d7010be..fb242602a 100644 --- a/openlp/core/lib/imagemanager.py +++ b/openlp/core/lib/imagemanager.py @@ -61,10 +61,10 @@ class Image(object): image = None image_bytes = None + class ImageManager(QtCore.QObject): """ Image Manager handles the conversion and sizing of images. - """ log.info(u'Image Manager loaded') diff --git a/openlp/core/lib/plugin.py b/openlp/core/lib/plugin.py index fb31006b5..476df79b0 100644 --- a/openlp/core/lib/plugin.py +++ b/openlp/core/lib/plugin.py @@ -44,6 +44,9 @@ class PluginStatus(object): class StringContent(object): + """ + Provide standard strings for objects to use. + """ Name = u'name' Import = u'import' Load = u'load' diff --git a/openlp/core/ui/displaytagtab.py b/openlp/core/ui/displaytagtab.py index 983bc17a8..54d021913 100644 --- a/openlp/core/ui/displaytagtab.py +++ b/openlp/core/ui/displaytagtab.py @@ -23,27 +23,27 @@ # with this program; if not, write to the Free Software Foundation, Inc., 59 # # Temple Place, Suite 330, Boston, MA 02111-1307 USA # ############################################################################### -''' +""" The :mod:`DisplayTagTab` provides an Tag Edit facility. The Base set are protected and included each time loaded. Custom tags can be defined and saved. The Custom Tag arrays are saved in a pickle so QSettings works on them. Base Tags cannot be changed. - -''' +""" import cPickle + from PyQt4 import QtCore, QtGui from openlp.core.lib import SettingsTab, translate, DisplayTags from openlp.core.lib.ui import critical_error_message_box class DisplayTagTab(SettingsTab): - ''' + """ The :class:`DisplayTagTab` manages the settings tab . - ''' + """ def __init__(self): - ''' + """ Initialise the settings tab - ''' + """ SettingsTab.__init__(self, u'Display Tags') def resizeEvent(self, event=None): @@ -67,9 +67,9 @@ class DisplayTagTab(SettingsTab): self.selected = -1 def setupUi(self): - ''' + """ Configure the UI elements for the tab. - ''' + """ self.setObjectName(u'DisplayTagTab') self.tabTitleVisible = \ translate(u'OpenLP.DisplayTagTab', 'Display Tags') diff --git a/openlp/core/ui/pluginform.py b/openlp/core/ui/pluginform.py index 3b41d76a3..6318a44a5 100644 --- a/openlp/core/ui/pluginform.py +++ b/openlp/core/ui/pluginform.py @@ -34,7 +34,9 @@ from plugindialog import Ui_PluginViewDialog log = logging.getLogger(__name__) class PluginForm(QtGui.QDialog, Ui_PluginViewDialog): - + """ + The plugin form provides user control over the plugins OpenLP uses. + """ def __init__(self, parent=None): QtGui.QDialog.__init__(self, parent) self.parent = parent diff --git a/openlp/plugins/songs/lib/db.py b/openlp/plugins/songs/lib/db.py index 2bbf818b3..d9a3202b5 100644 --- a/openlp/plugins/songs/lib/db.py +++ b/openlp/plugins/songs/lib/db.py @@ -71,7 +71,6 @@ class Topic(BaseModel): def init_schema(url): - """ Setup the songs database connection and initialise the database schema. diff --git a/openlp/plugins/songs/lib/opensongimport.py b/openlp/plugins/songs/lib/opensongimport.py index eb16f4ba4..e7557f952 100644 --- a/openlp/plugins/songs/lib/opensongimport.py +++ b/openlp/plugins/songs/lib/opensongimport.py @@ -36,9 +36,6 @@ from openlp.plugins.songs.lib.songimport import SongImport log = logging.getLogger(__name__) -class OpenSongImportError(Exception): - pass - class OpenSongImport(SongImport): """ Import songs exported from OpenSong From 9f63c43b5b7b189012be56e3091c6282ba28e904 Mon Sep 17 00:00:00 2001 From: Jon Tibble Date: Mon, 7 Feb 2011 16:29:06 +0000 Subject: [PATCH 54/68] Missing function docstrings --- openlp/plugins/bibles/lib/__init__.py | 7 +++++++ openlp/plugins/songs/lib/__init__.py | 9 +++++++++ 2 files changed, 16 insertions(+) diff --git a/openlp/plugins/bibles/lib/__init__.py b/openlp/plugins/bibles/lib/__init__.py index e6fff1cc8..7de4e82c3 100644 --- a/openlp/plugins/bibles/lib/__init__.py +++ b/openlp/plugins/bibles/lib/__init__.py @@ -33,6 +33,13 @@ import re log = logging.getLogger(__name__) def get_reference_match(match_type): + """ + Provides the regexes and matches to use while parsing strings for bible + references. + + ``match_type`` + The type of reference information trying to be extracted in this call. + """ local_separator = unicode(u':;;\s*[:vV]\s*;;-;;\s*-\s*;;,;;\s*,\s*;;end' ).split(u';;') # English # local_separator = unicode(u',;;\s*,\s*;;-;;\s*-\s*;;.;;\.;;[Ee]nde' diff --git a/openlp/plugins/songs/lib/__init__.py b/openlp/plugins/songs/lib/__init__.py index af8b71795..c763d70b9 100644 --- a/openlp/plugins/songs/lib/__init__.py +++ b/openlp/plugins/songs/lib/__init__.py @@ -104,6 +104,15 @@ class VerseType(object): def retrieve_windows_encoding(recommendation=None): + """ + Determines which encoding to use on an information source. The process uses + both automated detection, which is passed to this method as a + recommendation, and user confirmation to return an encoding. + + ``recommendation`` + A recommended encoding discovered programmatically for the user to + confirm. + """ # map chardet result to compatible windows standard code page codepage_mapping = {'IBM866': u'cp866', 'TIS-620': u'cp874', 'SHIFT_JIS': u'cp932', 'GB2312': u'cp936', 'HZ-GB-2312': u'cp936', From 5410d8dfd114694ed0169e548b83b4e12990b7bf Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Mon, 7 Feb 2011 18:19:54 +0100 Subject: [PATCH 55/68] added a field to enter custom service notes --- openlp/core/ui/printserviceorderdialog.py | 10 +++++++++- openlp/core/ui/printserviceorderform.py | 22 ++++++++++++++-------- resources/forms/printserviceorderdialog.ui | 10 ++++++++++ 3 files changed, 33 insertions(+), 9 deletions(-) diff --git a/openlp/core/ui/printserviceorderdialog.py b/openlp/core/ui/printserviceorderdialog.py index 70780291a..5e7b5a031 100644 --- a/openlp/core/ui/printserviceorderdialog.py +++ b/openlp/core/ui/printserviceorderdialog.py @@ -26,7 +26,7 @@ from PyQt4 import QtCore, QtGui -from openlp.core.lib import build_icon, translate +from openlp.core.lib import build_icon, translate, SpellTextEdit class Ui_PrintServiceOrderDialog(object): def setupUi(self, printServiceOrderDialog): @@ -78,6 +78,12 @@ class Ui_PrintServiceOrderDialog(object): spacerItem = QtGui.QSpacerItem(20, 40, QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Expanding) self.settingsLayout.addItem(spacerItem) + self.customNotesLabel = QtGui.QLabel(self) + self.customNotesLabel.setObjectName(u'customNotesLabel') + self.settingsLayout.addWidget(self.customNotesLabel) + self.customNoteEdit = SpellTextEdit(self) + self.customNoteEdit.setObjectName(u'customNoteEdit') + self.settingsLayout.addWidget(self.customNoteEdit) self.dialogLayout.addLayout(self.settingsLayout, 0, 3, 1, 1) self.buttonLayout = QtGui.QHBoxLayout() self.buttonLayout.setObjectName(u'buttonLayout') @@ -127,3 +133,5 @@ class Ui_PrintServiceOrderDialog(object): 'Service Order Sheet')) self.printButton.setText(translate('OpenLP.ServiceManager', 'Print')) self.cancelButton.setText(translate('OpenLP.ServiceManager', 'Cancel')) + self.customNotesLabel.setText( + translate('OpenLP.ServiceManager', 'Custom Service Notes:')) diff --git a/openlp/core/ui/printserviceorderform.py b/openlp/core/ui/printserviceorderform.py index d7cf87147..546d52d55 100644 --- a/openlp/core/ui/printserviceorderform.py +++ b/openlp/core/ui/printserviceorderform.py @@ -55,21 +55,24 @@ class PrintServiceOrderForm(QtGui.QDialog, Ui_PrintServiceOrderDialog): settings.endGroup() # Signals QtCore.QObject.connect(self.printButton, - QtCore.SIGNAL('clicked()'), self.printServiceOrder) + QtCore.SIGNAL(u'clicked()'), self.printServiceOrder) QtCore.QObject.connect(self.zoomOutButton, - QtCore.SIGNAL('clicked()'), self.zoomOut) + QtCore.SIGNAL(u'clicked()'), self.zoomOut) QtCore.QObject.connect(self.zoomInButton, - QtCore.SIGNAL('clicked()'), self.zoomIn) + QtCore.SIGNAL(u'clicked()'), self.zoomIn) QtCore.QObject.connect(self.previewWidget, - QtCore.SIGNAL('paintRequested(QPrinter *)'), self.paintRequested) + QtCore.SIGNAL(u'paintRequested(QPrinter *)'), self.paintRequested) QtCore.QObject.connect(self.serviceTitleLineEdit, - QtCore.SIGNAL('textChanged(const QString)'), self.updatePreviewText) + QtCore.SIGNAL(u'textChanged(const QString)'), + self.updatePreviewText) QtCore.QObject.connect(self.printSlideTextCheckBox, - QtCore.SIGNAL('stateChanged(int)'), self.updatePreviewText) + QtCore.SIGNAL(u'stateChanged(int)'), self.updatePreviewText) QtCore.QObject.connect(self.printNotesCheckBox, - QtCore.SIGNAL('stateChanged(int)'), self.updatePreviewText) + QtCore.SIGNAL(u'stateChanged(int)'), self.updatePreviewText) QtCore.QObject.connect(self.printMetaDataCheckBox, - QtCore.SIGNAL('stateChanged(int)'), self.updatePreviewText) + QtCore.SIGNAL(u'stateChanged(int)'), self.updatePreviewText) + QtCore.QObject.connect(self.customNoteEdit, + QtCore.SIGNAL(u'textChanged()'), self.updatePreviewText) QtCore.QObject.connect(self.cancelButton, QtCore.SIGNAL(u'clicked()'), self.reject) self.updatePreviewText() @@ -120,6 +123,9 @@ class PrintServiceOrderForm(QtGui.QDialog, Ui_PrintServiceOrderDialog): text += u'

%s %s

' % (translate( 'OpenLP.ServiceManager', u'Playing time:'), unicode(datetime.timedelta(seconds=length))) + if self.customNoteEdit.toPlainText(): + text += u'

%s

%s' % (translate('OpenLP.ServiceManager', + u'Custom Service Notes:'), self.customNoteEdit.toPlainText()) self.document.setHtml(text) self.previewWidget.updatePreview() diff --git a/resources/forms/printserviceorderdialog.ui b/resources/forms/printserviceorderdialog.ui index 66f44384f..131979b65 100644 --- a/resources/forms/printserviceorderdialog.ui +++ b/resources/forms/printserviceorderdialog.ui @@ -79,6 +79,16 @@
+ + + + <b>Custom Notes:</b> + + + + + +
From 9dec924f9873550aaad58b8c422bb38b659e69fb Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Mon, 7 Feb 2011 18:27:38 +0100 Subject: [PATCH 56/68] added missing doc --- openlp/core/ui/printserviceorderform.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/openlp/core/ui/printserviceorderform.py b/openlp/core/ui/printserviceorderform.py index 546d52d55..3b01f9ac7 100644 --- a/openlp/core/ui/printserviceorderform.py +++ b/openlp/core/ui/printserviceorderform.py @@ -132,6 +132,9 @@ class PrintServiceOrderForm(QtGui.QDialog, Ui_PrintServiceOrderDialog): def paintRequested(self, printer): """ Paint the preview of the *self.document*. + + ``printer`` + A *QPrinter* object. """ self.document.print_(printer) From 91db60ad7febbfa17bf48f6d17b6bfa2e2c6a5f7 Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Mon, 7 Feb 2011 19:02:13 +0100 Subject: [PATCH 57/68] fixed typos --- openlp/core/ui/printserviceorderdialog.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/openlp/core/ui/printserviceorderdialog.py b/openlp/core/ui/printserviceorderdialog.py index 5e7b5a031..f8db4d1c0 100644 --- a/openlp/core/ui/printserviceorderdialog.py +++ b/openlp/core/ui/printserviceorderdialog.py @@ -121,12 +121,12 @@ class Ui_PrintServiceOrderDialog(object): self.previewLabel.setText( translate('OpenLP.ServiceManager', 'Preview:')) self.printSlideTextCheckBox.setText(translate( - 'OpenLP.PrintServiceOrderForm', 'Include slide text if avaialbe')) + 'OpenLP.PrintServiceOrderForm', 'Include slide text if available')) self.printNotesCheckBox.setText(translate( 'OpenLP.PrintServiceOrderForm', 'Include service item notes')) self.printMetaDataCheckBox.setText( translate('OpenLP.PrintServiceOrderForm', - 'Include play lenght of media items')) + 'Include play length of media items')) self.serviceTitleLabel.setText(translate( 'OpenLP.PrintServiceOrderForm', 'Title:')) self.serviceTitleLineEdit.setText(translate('OpenLP.ServiceManager', From 975d9f6a1c78ca633a0cfd8b9ef67f47e9f75a58 Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Mon, 7 Feb 2011 18:46:22 +0000 Subject: [PATCH 58/68] Fix Song previews when returning from blank screen --- openlp/core/ui/slidecontroller.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/openlp/core/ui/slidecontroller.py b/openlp/core/ui/slidecontroller.py index bf0453e05..d86dba4b0 100644 --- a/openlp/core/ui/slidecontroller.py +++ b/openlp/core/ui/slidecontroller.py @@ -874,7 +874,8 @@ class SlideController(QtGui.QWidget): using *Blank to Theme*. """ log.debug(u'updatePreview %s ' % self.screens.current[u'primary']) - if not self.screens.current[u'primary']: + if not self.screens.current[u'primary'] and \ + self.serviceItem.is_capable(ItemCapabilities.ProvidesOwnDisplay): # Grab now, but try again in a couple of seconds if slide change # is slow QtCore.QTimer.singleShot(0.5, self.grabMainDisplay) From b6735065c0e35e9f20a63caecc2219b10d8f5e69 Mon Sep 17 00:00:00 2001 From: Jon Tibble Date: Mon, 7 Feb 2011 19:37:07 +0000 Subject: [PATCH 59/68] Presentation dedupe --- .../presentations/lib/impresscontroller.py | 11 +- openlp/plugins/presentations/lib/mediaitem.py | 6 +- .../presentations/lib/messagelistener.py | 2 +- .../presentations/lib/powerpointcontroller.py | 11 +- .../presentations/lib/pptviewcontroller.py | 13 +- .../lib/presentationcontroller.py | 295 +++++++++--------- 6 files changed, 160 insertions(+), 178 deletions(-) diff --git a/openlp/plugins/presentations/lib/impresscontroller.py b/openlp/plugins/presentations/lib/impresscontroller.py index 465f733c7..79e7d0ea8 100644 --- a/openlp/plugins/presentations/lib/impresscontroller.py +++ b/openlp/plugins/presentations/lib/impresscontroller.py @@ -69,7 +69,8 @@ class ImpressController(PresentationController): Initialise the class """ log.debug(u'Initialising') - PresentationController.__init__(self, plugin, u'Impress') + PresentationController.__init__(self, plugin, u'Impress', + ImpressDocument) self.supports = [u'odp'] self.alsosupports = [u'ppt', u'pps', u'pptx', u'ppsx'] self.process = None @@ -183,14 +184,6 @@ class ImpressController(PresentationController): except: log.exception(u'Failed to terminate OpenOffice') - def add_doc(self, name): - """ - Called when a new Impress document is opened - """ - log.debug(u'Add Doc OpenOffice') - doc = ImpressDocument(self, name) - self.docs.append(doc) - return doc class ImpressDocument(PresentationDocument): """ diff --git a/openlp/plugins/presentations/lib/mediaitem.py b/openlp/plugins/presentations/lib/mediaitem.py index a0173cb27..09020692a 100644 --- a/openlp/plugins/presentations/lib/mediaitem.py +++ b/openlp/plugins/presentations/lib/mediaitem.py @@ -186,7 +186,7 @@ class PresentationMediaItem(MediaManagerItem): controller_name = self.findControllerByType(filename) if controller_name: controller = self.controllers[controller_name] - doc = controller.add_doc(unicode(file)) + doc = controller.add_document(unicode(file)) thumb = os.path.join(doc.get_thumbnail_folder(), u'icon.png') preview = doc.get_thumbnail_path(1, True) if not preview and not initialLoad: @@ -226,7 +226,7 @@ class PresentationMediaItem(MediaManagerItem): filepath = unicode(item.data( QtCore.Qt.UserRole).toString()) for cidx in self.controllers: - doc = self.controllers[cidx].add_doc(filepath) + doc = self.controllers[cidx].add_document(filepath) doc.presentation_deleted() doc.close_presentation() for row in row_list: @@ -260,7 +260,7 @@ class PresentationMediaItem(MediaManagerItem): return False controller = self.controllers[service_item.shortname] (path, name) = os.path.split(filename) - doc = controller.add_doc(filename) + doc = controller.add_document(filename) if doc.get_thumbnail_path(1, True) is None: doc.load_presentation() i = 1 diff --git a/openlp/plugins/presentations/lib/messagelistener.py b/openlp/plugins/presentations/lib/messagelistener.py index 4d926ad3d..b7c64ccee 100644 --- a/openlp/plugins/presentations/lib/messagelistener.py +++ b/openlp/plugins/presentations/lib/messagelistener.py @@ -59,7 +59,7 @@ class Controller(object): self.controller = controller if self.doc is not None: self.shutdown() - self.doc = self.controller.add_doc(file) + self.doc = self.controller.add_document(file) if not self.doc.load_presentation(): # Display error message to user # Inform slidecontroller that the action failed? diff --git a/openlp/plugins/presentations/lib/powerpointcontroller.py b/openlp/plugins/presentations/lib/powerpointcontroller.py index fcc8bfc47..65e9f35ff 100644 --- a/openlp/plugins/presentations/lib/powerpointcontroller.py +++ b/openlp/plugins/presentations/lib/powerpointcontroller.py @@ -53,7 +53,8 @@ class PowerpointController(PresentationController): Initialise the class """ log.debug(u'Initialising') - PresentationController.__init__(self, plugin, u'Powerpoint') + PresentationController.__init__(self, plugin, u'Powerpoint', + PowerpointDocument) self.supports = [u'ppt', u'pps', u'pptx', u'ppsx'] self.process = None @@ -97,14 +98,6 @@ class PowerpointController(PresentationController): pass self.process = None - def add_doc(self, name): - """ - Called when a new powerpoint document is opened - """ - log.debug(u'Add Doc PowerPoint') - doc = PowerpointDocument(self, name) - self.docs.append(doc) - return doc class PowerpointDocument(PresentationDocument): """ diff --git a/openlp/plugins/presentations/lib/pptviewcontroller.py b/openlp/plugins/presentations/lib/pptviewcontroller.py index 4c8e7bf95..a64cd31dd 100644 --- a/openlp/plugins/presentations/lib/pptviewcontroller.py +++ b/openlp/plugins/presentations/lib/pptviewcontroller.py @@ -49,7 +49,8 @@ class PptviewController(PresentationController): """ log.debug(u'Initialising') self.process = None - PresentationController.__init__(self, plugin, u'Powerpoint Viewer') + PresentationController.__init__(self, plugin, u'Powerpoint Viewer', + PptviewDocument) self.supports = [u'ppt', u'pps', u'pptx', u'ppsx'] def check_available(self): @@ -93,14 +94,6 @@ class PptviewController(PresentationController): while self.docs: self.docs[0].close_presentation() - def add_doc(self, name): - """ - Called when a new powerpoint document is opened - """ - log.debug(u'Add Doc PPTView') - doc = PptviewDocument(self, name) - self.docs.append(doc) - return doc class PptviewDocument(PresentationDocument): """ @@ -247,4 +240,4 @@ class PptviewDocument(PresentationDocument): """ Triggers the previous slide on the running presentation """ - self.controller.process.PrevStep(self.pptid) \ No newline at end of file + self.controller.process.PrevStep(self.pptid) diff --git a/openlp/plugins/presentations/lib/presentationcontroller.py b/openlp/plugins/presentations/lib/presentationcontroller.py index 42f7b654a..8b282e0f4 100644 --- a/openlp/plugins/presentations/lib/presentationcontroller.py +++ b/openlp/plugins/presentations/lib/presentationcontroller.py @@ -35,151 +35,6 @@ from openlp.core.utils import AppLocation log = logging.getLogger(__name__) -class PresentationController(object): - """ - This class is used to control interactions with presentation applications - by creating a runtime environment. This is a base class for presentation - controllers to inherit from. - - To create a new controller, take a copy of this file and name it so it ends - with ``controller.py``, i.e. ``foobarcontroller.py``. Make sure it inherits - :class:`~openlp.plugins.presentations.lib.presentationcontroller.PresentationController`, - and then fill in the blanks. If possible try to make sure it loads on all - platforms, usually by using :mod:``os.name`` checks, although - ``__init__``, ``check_available`` and ``presentation_deleted`` should - always be implemented. - - See :class:`~openlp.plugins.presentations.lib.impresscontroller.ImpressController`, - :class:`~openlp.plugins.presentations.lib.powerpointcontroller.PowerpointController` or - :class:`~openlp.plugins.presentations.lib.pptviewcontroller.PptviewController` - for examples. - - **Basic Attributes** - - ``name`` - The name that appears in the options and the media manager - - ``enabled`` - The controller is enabled - - ``available`` - The controller is available on this machine. Set by init via - call to check_available - - ``plugin`` - The presentationplugin object - - ``supports`` - The primary native file types this application supports - - ``alsosupports`` - Other file types the application can import, although not necessarily - the first choice due to potential incompatibilities - - **Hook Functions** - - ``kill()`` - Called at system exit to clean up any running presentations - - ``check_available()`` - Returns True if presentation application is installed/can run on this - machine - - ``presentation_deleted()`` - Deletes presentation specific files, e.g. thumbnails - - """ - log.info(u'PresentationController loaded') - - def __init__(self, plugin=None, name=u'PresentationController'): - """ - This is the constructor for the presentationcontroller object. This - provides an easy way for descendent plugins to populate common data. - This method *must* be overridden, like so:: - - class MyPresentationController(PresentationController): - def __init__(self, plugin): - PresentationController.__init( - self, plugin, u'My Presenter App') - - ``plugin`` - Defaults to *None*. The presentationplugin object - - ``name`` - Name of the application, to appear in the application - """ - self.supports = [] - self.alsosupports = [] - self.docs = [] - self.plugin = plugin - self.name = name - self.settings_section = self.plugin.settingsSection - self.available = self.check_available() - self.temp_folder = os.path.join( - AppLocation.get_section_data_path(self.settings_section), name) - self.thumbnail_folder = os.path.join( - AppLocation.get_section_data_path(self.settings_section), - u'thumbnails') - self.thumbnail_prefix = u'slide' - if not os.path.isdir(self.thumbnail_folder): - os.makedirs(self.thumbnail_folder) - if not os.path.isdir(self.temp_folder): - os.makedirs(self.temp_folder) - - def enabled(self): - """ - Return whether the controller is currently enabled - """ - if self.available: - return QtCore.QSettings().value( - self.settings_section + u'/' + self.name, - QtCore.QVariant(QtCore.Qt.Checked)).toInt()[0] == \ - QtCore.Qt.Checked - else: - return False - - def check_available(self): - """ - Presentation app is able to run on this machine - """ - return False - - def start_process(self): - """ - Loads a running version of the presentation application in the - background. - """ - pass - - def kill(self): - """ - Called at system exit to clean up any running presentations and - close the application - """ - log.debug(u'Kill') - self.close_presentation() - - def add_doc(self, name): - """ - Called when a new presentation document is opened - """ - doc = PresentationDocument(self, name) - self.docs.append(doc) - return doc - - def remove_doc(self, doc=None): - """ - Called to remove an open document from the collection - """ - log.debug(u'remove_doc Presentation') - if doc is None: - return - if doc in self.docs: - self.docs.remove(doc) - - def close_presentation(self): - pass - class PresentationDocument(object): """ Base class for presentation documents to inherit from. @@ -440,4 +295,152 @@ class PresentationDocument(object): ``slide_no`` The slide the notes are required for, starting at 1 """ - return '' \ No newline at end of file + return '' + + +class PresentationController(object): + """ + This class is used to control interactions with presentation applications + by creating a runtime environment. This is a base class for presentation + controllers to inherit from. + + To create a new controller, take a copy of this file and name it so it ends + with ``controller.py``, i.e. ``foobarcontroller.py``. Make sure it inherits + :class:`~openlp.plugins.presentations.lib.presentationcontroller.PresentationController`, + and then fill in the blanks. If possible try to make sure it loads on all + platforms, usually by using :mod:``os.name`` checks, although + ``__init__``, ``check_available`` and ``presentation_deleted`` should + always be implemented. + + See :class:`~openlp.plugins.presentations.lib.impresscontroller.ImpressController`, + :class:`~openlp.plugins.presentations.lib.powerpointcontroller.PowerpointController` or + :class:`~openlp.plugins.presentations.lib.pptviewcontroller.PptviewController` + for examples. + + **Basic Attributes** + + ``name`` + The name that appears in the options and the media manager + + ``enabled`` + The controller is enabled + + ``available`` + The controller is available on this machine. Set by init via + call to check_available + + ``plugin`` + The presentationplugin object + + ``supports`` + The primary native file types this application supports + + ``alsosupports`` + Other file types the application can import, although not necessarily + the first choice due to potential incompatibilities + + **Hook Functions** + + ``kill()`` + Called at system exit to clean up any running presentations + + ``check_available()`` + Returns True if presentation application is installed/can run on this + machine + + ``presentation_deleted()`` + Deletes presentation specific files, e.g. thumbnails + + """ + log.info(u'PresentationController loaded') + + def __init__(self, plugin=None, name=u'PresentationController', + document_class=PresentationDocument): + """ + This is the constructor for the presentationcontroller object. This + provides an easy way for descendent plugins to populate common data. + This method *must* be overridden, like so:: + + class MyPresentationController(PresentationController): + def __init__(self, plugin): + PresentationController.__init( + self, plugin, u'My Presenter App') + + ``plugin`` + Defaults to *None*. The presentationplugin object + + ``name`` + Name of the application, to appear in the application + """ + self.supports = [] + self.alsosupports = [] + self.docs = [] + self.plugin = plugin + self.name = name + self.document_class = document_class + self.settings_section = self.plugin.settingsSection + self.available = self.check_available() + self.temp_folder = os.path.join( + AppLocation.get_section_data_path(self.settings_section), name) + self.thumbnail_folder = os.path.join( + AppLocation.get_section_data_path(self.settings_section), + u'thumbnails') + self.thumbnail_prefix = u'slide' + if not os.path.isdir(self.thumbnail_folder): + os.makedirs(self.thumbnail_folder) + if not os.path.isdir(self.temp_folder): + os.makedirs(self.temp_folder) + + def enabled(self): + """ + Return whether the controller is currently enabled + """ + if self.available: + return QtCore.QSettings().value( + self.settings_section + u'/' + self.name, + QtCore.QVariant(QtCore.Qt.Checked)).toInt()[0] == \ + QtCore.Qt.Checked + else: + return False + + def check_available(self): + """ + Presentation app is able to run on this machine + """ + return False + + def start_process(self): + """ + Loads a running version of the presentation application in the + background. + """ + pass + + def kill(self): + """ + Called at system exit to clean up any running presentations and + close the application + """ + log.debug(u'Kill') + self.close_presentation() + + def add_document(self, name): + """ + Called when a new presentation document is opened + """ + document = self.document_class(self, name) + self.docs.append(document) + return document + + def remove_doc(self, doc=None): + """ + Called to remove an open document from the collection + """ + log.debug(u'remove_doc Presentation') + if doc is None: + return + if doc in self.docs: + self.docs.remove(doc) + + def close_presentation(self): + pass From 943dcf1ffc7c0b73e9adbe11b3d9a0ff3b081c46 Mon Sep 17 00:00:00 2001 From: Jon Tibble Date: Mon, 7 Feb 2011 22:07:48 +0000 Subject: [PATCH 60/68] Naming cleanups --- openlp/core/lib/db.py | 6 +- openlp/core/lib/displaytags.py | 6 +- openlp/core/ui/mainwindow.py | 110 +++++++++++++++--------------- openlp/core/ui/slidecontroller.py | 6 +- 4 files changed, 64 insertions(+), 64 deletions(-) diff --git a/openlp/core/lib/db.py b/openlp/core/lib/db.py index 3171730ea..d9d094949 100644 --- a/openlp/core/lib/db.py +++ b/openlp/core/lib/db.py @@ -86,10 +86,10 @@ class BaseModel(object): """ Creates an instance of a class and populates it, returning the instance """ - me = cls() + instance = cls() for key in kwargs: - me.__setattr__(key, kwargs[key]) - return me + instance.__setattr__(key, kwargs[key]) + return instance class Manager(object): """ diff --git a/openlp/core/lib/displaytags.py b/openlp/core/lib/displaytags.py index dd7276a7d..d414f80bb 100644 --- a/openlp/core/lib/displaytags.py +++ b/openlp/core/lib/displaytags.py @@ -60,8 +60,8 @@ class DisplayTags(object): DisplayTags.html_expands.append(tag) @staticmethod - def remove_html_tag(id): + def remove_html_tag(tag_id): """ - Removes amd individual html_expands list. + Removes an individual html_expands tag. """ - DisplayTags.html_expands.pop(id) + DisplayTags.html_expands.pop(tag_id) diff --git a/openlp/core/ui/mainwindow.py b/openlp/core/ui/mainwindow.py index 9af4931fb..e489d7b5d 100644 --- a/openlp/core/ui/mainwindow.py +++ b/openlp/core/ui/mainwindow.py @@ -77,10 +77,10 @@ class Ui_MainWindow(object): self.MainContentLayout.setMargin(0) self.MainContentLayout.setObjectName(u'MainContentLayout') mainWindow.setCentralWidget(self.MainContent) - self.ControlSplitter = QtGui.QSplitter(self.MainContent) - self.ControlSplitter.setOrientation(QtCore.Qt.Horizontal) - self.ControlSplitter.setObjectName(u'ControlSplitter') - self.MainContentLayout.addWidget(self.ControlSplitter) + self.controlSplitter = QtGui.QSplitter(self.MainContent) + self.controlSplitter.setOrientation(QtCore.Qt.Horizontal) + self.controlSplitter.setObjectName(u'controlSplitter') + self.MainContentLayout.addWidget(self.controlSplitter) # Create slide controllers self.previewController = SlideController(self, self.settingsmanager, self.screens) @@ -102,9 +102,9 @@ class Ui_MainWindow(object): self.FileExportMenu = QtGui.QMenu(self.FileMenu) self.FileExportMenu.setObjectName(u'FileExportMenu') # View Menu - self.ViewMenu = QtGui.QMenu(self.MenuBar) - self.ViewMenu.setObjectName(u'ViewMenu') - self.ViewModeMenu = QtGui.QMenu(self.ViewMenu) + self.viewMenu = QtGui.QMenu(self.MenuBar) + self.viewMenu.setObjectName(u'viewMenu') + self.ViewModeMenu = QtGui.QMenu(self.viewMenu) self.ViewModeMenu.setObjectName(u'ViewModeMenu') # Tools Menu self.ToolsMenu = QtGui.QMenu(self.MenuBar) @@ -125,38 +125,38 @@ class Ui_MainWindow(object): self.DefaultThemeLabel.setObjectName(u'DefaultThemeLabel') self.StatusBar.addPermanentWidget(self.DefaultThemeLabel) # Create the MediaManager - self.MediaManagerDock = OpenLPDockWidget(mainWindow, - u'MediaManagerDock', u':/system/system_mediamanager.png') - self.MediaManagerDock.setStyleSheet(MEDIA_MANAGER_STYLE) - self.MediaManagerDock.setMinimumWidth( + self.mediaManagerDock = OpenLPDockWidget(mainWindow, + u'mediaManagerDock', u':/system/system_mediamanager.png') + self.mediaManagerDock.setStyleSheet(MEDIA_MANAGER_STYLE) + self.mediaManagerDock.setMinimumWidth( self.settingsmanager.mainwindow_left) # Create the media toolbox - self.MediaToolBox = QtGui.QToolBox(self.MediaManagerDock) + self.MediaToolBox = QtGui.QToolBox(self.mediaManagerDock) self.MediaToolBox.setObjectName(u'MediaToolBox') - self.MediaManagerDock.setWidget(self.MediaToolBox) + self.mediaManagerDock.setWidget(self.MediaToolBox) mainWindow.addDockWidget(QtCore.Qt.LeftDockWidgetArea, - self.MediaManagerDock) + self.mediaManagerDock) # Create the service manager - self.ServiceManagerDock = OpenLPDockWidget(mainWindow, - u'ServiceManagerDock', u':/system/system_servicemanager.png') - self.ServiceManagerDock.setMinimumWidth( + self.serviceManagerDock = OpenLPDockWidget(mainWindow, + u'serviceManagerDock', u':/system/system_servicemanager.png') + self.serviceManagerDock.setMinimumWidth( self.settingsmanager.mainwindow_right) self.ServiceManagerContents = ServiceManager(mainWindow, - self.ServiceManagerDock) - self.ServiceManagerDock.setWidget(self.ServiceManagerContents) + self.serviceManagerDock) + self.serviceManagerDock.setWidget(self.ServiceManagerContents) mainWindow.addDockWidget(QtCore.Qt.RightDockWidgetArea, - self.ServiceManagerDock) + self.serviceManagerDock) # Create the theme manager - self.ThemeManagerDock = OpenLPDockWidget(mainWindow, - u'ThemeManagerDock', u':/system/system_thememanager.png') - self.ThemeManagerDock.setMinimumWidth( + self.themeManagerDock = OpenLPDockWidget(mainWindow, + u'themeManagerDock', u':/system/system_thememanager.png') + self.themeManagerDock.setMinimumWidth( self.settingsmanager.mainwindow_right) self.ThemeManagerContents = ThemeManager(mainWindow, - self.ThemeManagerDock) + self.themeManagerDock) self.ThemeManagerContents.setObjectName(u'ThemeManagerContents') - self.ThemeManagerDock.setWidget(self.ThemeManagerContents) + self.themeManagerDock.setWidget(self.ThemeManagerContents) mainWindow.addDockWidget(QtCore.Qt.RightDockWidgetArea, - self.ThemeManagerDock) + self.themeManagerDock) # Create the menu items self.FileNewItem = icon_action(mainWindow, u'FileNewItem', u':/general/general_new.png') @@ -186,14 +186,14 @@ class Ui_MainWindow(object): mainWindow.actionList.add_action(self.ExportLanguageItem, u'Export') self.ViewMediaManagerItem = icon_action(mainWindow, u'ViewMediaManagerItem', u':/system/system_mediamanager.png', - self.MediaManagerDock.isVisible()) + self.mediaManagerDock.isVisible()) self.ViewThemeManagerItem = icon_action(mainWindow, u'ViewThemeManagerItem', u':/system/system_thememanager.png', - self.ThemeManagerDock.isVisible()) + self.themeManagerDock.isVisible()) mainWindow.actionList.add_action(self.ViewMediaManagerItem, u'View') self.ViewServiceManagerItem = icon_action(mainWindow, u'ViewServiceManagerItem', u':/system/system_servicemanager.png', - self.ServiceManagerDock.isVisible()) + self.serviceManagerDock.isVisible()) mainWindow.actionList.add_action(self.ViewServiceManagerItem, u'View') self.ViewPreviewPanel = checkable_action(mainWindow, u'ViewPreviewPanel', previewVisible) @@ -215,9 +215,9 @@ class Ui_MainWindow(object): self.ToolsAddToolItem = icon_action(mainWindow, u'ToolsAddToolItem', u':/tools/tools_add.png') mainWindow.actionList.add_action(self.ToolsAddToolItem, u'Tools') - self.SettingsPluginListItem = icon_action(mainWindow, - u'SettingsPluginListItem', u':/system/settings_plugin_list.png') - mainWindow.actionList.add_action(self.SettingsPluginListItem, + self.settingsPluginListItem = icon_action(mainWindow, + u'settingsPluginListItem', u':/system/settings_plugin_list.png') + mainWindow.actionList.add_action(self.settingsPluginListItem, u'Settings') # i18n Language Items self.AutoLanguageItem = checkable_action(mainWindow, @@ -264,14 +264,14 @@ class Ui_MainWindow(object): self.FileExportMenu.menuAction(), self.FileExitItem) add_actions(self.ViewModeMenu, (self.ModeDefaultItem, self.ModeSetupItem, self.ModeLiveItem)) - add_actions(self.ViewMenu, (self.ViewModeMenu.menuAction(), + add_actions(self.viewMenu, (self.ViewModeMenu.menuAction(), None, self.ViewMediaManagerItem, self.ViewServiceManagerItem, self.ViewThemeManagerItem, None, self.ViewPreviewPanel, self.ViewLivePanel)) # i18n add Language Actions add_actions(self.SettingsLanguageMenu, (self.AutoLanguageItem, None)) add_actions(self.SettingsLanguageMenu, self.LanguageGroup.actions()) - add_actions(self.SettingsMenu, (self.SettingsPluginListItem, + add_actions(self.SettingsMenu, (self.settingsPluginListItem, self.SettingsLanguageMenu.menuAction(), None, self.SettingsShortcutsItem, self.SettingsConfigureItem)) add_actions(self.ToolsMenu, (self.ToolsAddToolItem, None)) @@ -279,7 +279,7 @@ class Ui_MainWindow(object): self.HelpOnlineHelpItem, None, self.HelpWebSiteItem, self.HelpAboutItem)) add_actions(self.MenuBar, (self.FileMenu.menuAction(), - self.ViewMenu.menuAction(), self.ToolsMenu.menuAction(), + self.viewMenu.menuAction(), self.ToolsMenu.menuAction(), self.SettingsMenu.menuAction(), self.HelpMenu.menuAction())) # Initialise the translation self.retranslateUi(mainWindow) @@ -300,18 +300,18 @@ class Ui_MainWindow(object): self.FileMenu.setTitle(translate('OpenLP.MainWindow', '&File')) self.FileImportMenu.setTitle(translate('OpenLP.MainWindow', '&Import')) self.FileExportMenu.setTitle(translate('OpenLP.MainWindow', '&Export')) - self.ViewMenu.setTitle(translate('OpenLP.MainWindow', '&View')) + self.viewMenu.setTitle(translate('OpenLP.MainWindow', '&View')) self.ViewModeMenu.setTitle(translate('OpenLP.MainWindow', 'M&ode')) self.ToolsMenu.setTitle(translate('OpenLP.MainWindow', '&Tools')) self.SettingsMenu.setTitle(translate('OpenLP.MainWindow', '&Settings')) self.SettingsLanguageMenu.setTitle(translate('OpenLP.MainWindow', '&Language')) self.HelpMenu.setTitle(translate('OpenLP.MainWindow', '&Help')) - self.MediaManagerDock.setWindowTitle( + self.mediaManagerDock.setWindowTitle( translate('OpenLP.MainWindow', 'Media Manager')) - self.ServiceManagerDock.setWindowTitle( + self.serviceManagerDock.setWindowTitle( translate('OpenLP.MainWindow', 'Service Manager')) - self.ThemeManagerDock.setWindowTitle( + self.themeManagerDock.setWindowTitle( translate('OpenLP.MainWindow', 'Theme Manager')) self.FileNewItem.setText(translate('OpenLP.MainWindow', '&New')) self.FileNewItem.setToolTip( @@ -403,11 +403,11 @@ class Ui_MainWindow(object): 'Toggle the visibility of the live panel.')) self.ViewLivePanel.setShortcut( translate('OpenLP.MainWindow', 'F12')) - self.SettingsPluginListItem.setText(translate('OpenLP.MainWindow', + self.settingsPluginListItem.setText(translate('OpenLP.MainWindow', '&Plugin List')) - self.SettingsPluginListItem.setStatusTip( + self.settingsPluginListItem.setStatusTip( translate('OpenLP.MainWindow', 'List the Plugins')) - self.SettingsPluginListItem.setShortcut( + self.settingsPluginListItem.setShortcut( translate('OpenLP.MainWindow', 'Alt+F7')) self.HelpDocumentationItem.setText( translate('OpenLP.MainWindow', '&User Guide')) @@ -501,20 +501,20 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow): QtCore.SIGNAL(u'toggled(bool)'), self.setPreviewPanelVisibility) QtCore.QObject.connect(self.ViewLivePanel, QtCore.SIGNAL(u'toggled(bool)'), self.setLivePanelVisibility) - QtCore.QObject.connect(self.MediaManagerDock, + QtCore.QObject.connect(self.mediaManagerDock, QtCore.SIGNAL(u'visibilityChanged(bool)'), self.ViewMediaManagerItem.setChecked) - QtCore.QObject.connect(self.ServiceManagerDock, + QtCore.QObject.connect(self.serviceManagerDock, QtCore.SIGNAL(u'visibilityChanged(bool)'), self.ViewServiceManagerItem.setChecked) - QtCore.QObject.connect(self.ThemeManagerDock, + QtCore.QObject.connect(self.themeManagerDock, QtCore.SIGNAL(u'visibilityChanged(bool)'), self.ViewThemeManagerItem.setChecked) QtCore.QObject.connect(self.HelpWebSiteItem, QtCore.SIGNAL(u'triggered()'), self.onHelpWebSiteClicked) QtCore.QObject.connect(self.HelpAboutItem, QtCore.SIGNAL(u'triggered()'), self.onHelpAboutItemClicked) - QtCore.QObject.connect(self.SettingsPluginListItem, + QtCore.QObject.connect(self.settingsPluginListItem, QtCore.SIGNAL(u'triggered()'), self.onPluginItemClicked) QtCore.QObject.connect(self.SettingsConfigureItem, QtCore.SIGNAL(u'triggered()'), self.onSettingsConfigureItemClicked) @@ -748,9 +748,9 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow): settings = QtCore.QSettings() settings.setValue(u'%s/view mode' % self.generalSettingsSection, mode) - self.MediaManagerDock.setVisible(media) - self.ServiceManagerDock.setVisible(service) - self.ThemeManagerDock.setVisible(theme) + self.mediaManagerDock.setVisible(media) + self.serviceManagerDock.setVisible(service) + self.themeManagerDock.setVisible(theme) self.setPreviewPanelVisibility(preview) self.setLivePanelVisibility(live) @@ -867,16 +867,16 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow): theme) def toggleMediaManager(self, visible): - if self.MediaManagerDock.isVisible() != visible: - self.MediaManagerDock.setVisible(visible) + if self.mediaManagerDock.isVisible() != visible: + self.mediaManagerDock.setVisible(visible) def toggleServiceManager(self, visible): - if self.ServiceManagerDock.isVisible() != visible: - self.ServiceManagerDock.setVisible(visible) + if self.serviceManagerDock.isVisible() != visible: + self.serviceManagerDock.setVisible(visible) def toggleThemeManager(self, visible): - if self.ThemeManagerDock.isVisible() != visible: - self.ThemeManagerDock.setVisible(visible) + if self.themeManagerDock.isVisible() != visible: + self.themeManagerDock.setVisible(visible) def setPreviewPanelVisibility(self, visible): """ diff --git a/openlp/core/ui/slidecontroller.py b/openlp/core/ui/slidecontroller.py index bf0453e05..3445c63a1 100644 --- a/openlp/core/ui/slidecontroller.py +++ b/openlp/core/ui/slidecontroller.py @@ -78,7 +78,7 @@ class SlideController(QtGui.QWidget): self.selectedRow = 0 self.serviceItem = None self.alertTab = None - self.panel = QtGui.QWidget(parent.ControlSplitter) + self.panel = QtGui.QWidget(parent.controlSplitter) self.slideList = {} # Layout for holding panel self.panelLayout = QtGui.QVBoxLayout(self.panel) @@ -455,7 +455,7 @@ class SlideController(QtGui.QWidget): self.previewListWidget.resizeRowsToContents() else: # Sort out image heights. - width = self.parent.ControlSplitter.sizes()[self.split] + width = self.parent.controlSplitter.sizes()[self.split] for framenumber in range(len(self.serviceItem.get_frames())): self.previewListWidget.setRowHeight( framenumber, width / self.ratio) @@ -584,7 +584,7 @@ class SlideController(QtGui.QWidget): Receiver.send_message(u'%s_start' % serviceItem.name.lower(), [serviceItem, self.isLive, blanked, slideno]) self.slideList = {} - width = self.parent.ControlSplitter.sizes()[self.split] + width = self.parent.controlSplitter.sizes()[self.split] self.serviceItem = serviceItem self.previewListWidget.clear() self.previewListWidget.setRowCount(0) From a97cd1bb9b42ab8bd91a9db8026b6d4c90a1bf77 Mon Sep 17 00:00:00 2001 From: Jon Tibble Date: Tue, 8 Feb 2011 02:45:37 +0000 Subject: [PATCH 61/68] Unnecessary line breaks --- openlp/core/lib/theme.py | 3 +-- openlp/core/ui/maindisplay.py | 6 ++---- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/openlp/core/lib/theme.py b/openlp/core/lib/theme.py index d119f19ff..dca226069 100644 --- a/openlp/core/lib/theme.py +++ b/openlp/core/lib/theme.py @@ -583,8 +583,7 @@ class ThemeXML(object): self.background_end_color, self.background_direction) else: - filename = \ - os.path.split(self.background_filename)[1] + filename = os.path.split(self.background_filename)[1] self.add_background_image(filename) self.add_font(self.font_main_name, self.font_main_color, diff --git a/openlp/core/ui/maindisplay.py b/openlp/core/ui/maindisplay.py index bae00c2da..c4ab75aac 100644 --- a/openlp/core/ui/maindisplay.py +++ b/openlp/core/ui/maindisplay.py @@ -326,8 +326,7 @@ class MainDisplay(DisplayWidget): vol = float(volume)/float(10) if isBackground or not self.usePhonon: js = u'show_video("init", "%s", %s, true); show_video("play");' % \ - (videoPath.replace(u'\\', u'\\\\'), \ - str(vol)) + (videoPath.replace(u'\\', u'\\\\'), str(vol)) self.frame.evaluateJavaScript(js) else: self.phononActive = True @@ -398,8 +397,7 @@ class MainDisplay(DisplayWidget): if u'video' in self.override: Receiver.send_message(u'video_background_replaced') self.override = {} - elif self.override[u'theme'] != \ - serviceItem.themedata.theme_name: + elif self.override[u'theme'] != serviceItem.themedata.theme_name: Receiver.send_message(u'live_theme_changed') self.override = {} else: From 0d6af789a00cc2604eb78ef076a658af7cc0b3c6 Mon Sep 17 00:00:00 2001 From: Jon Tibble Date: Tue, 8 Feb 2011 03:25:50 +0000 Subject: [PATCH 62/68] Fix theme importing (Support 98) --- openlp/core/theme/theme.py | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/openlp/core/theme/theme.py b/openlp/core/theme/theme.py index e506fc2c2..8a57c3ae7 100644 --- a/openlp/core/theme/theme.py +++ b/openlp/core/theme/theme.py @@ -33,11 +33,14 @@ processing version 1 themes in OpenLP version 2. from xml.etree.ElementTree import ElementTree, XML from PyQt4 import QtGui -DELPHI_COLORS = {u'clRed': 0xFF0000, - u'clBlue': 0x0000FF, - u'clYellow': 0xFFFF00, - u'clBlack': 0x000000, - u'clWhite': 0xFFFFFF} +DELPHI_COLORS = { + u'clAqua': 0x00FFFF, u'clBlack': 0x000000, u'clBlue': 0x0000FF, + u'clFuchsia': 0xFF00FF, u'clGray': 0x808080, u'clGreen': 0x008000, + u'clLime': 0x00FF00, u'clMaroon': 0x800000, u'clNavy': 0x000080, + u'clOlive': 0x808000, u'clPurple': 0x800080, u'clRed': 0xFF0000, + u'clSilver': 0xC0C0C0, u'clTeal': 0x008080, u'clWhite': 0xFFFFFF, + u'clYellow': 0xFFFF00 +} BLANK_STYLE_XML = \ ''' @@ -184,7 +187,6 @@ class Theme(object): if element.tag != u'Theme': element_text = element.text val = 0 - # easy! if element_text is None: val = element_text # strings need special handling to sort the colours out From dc7486c3f87d43ced34ddff2b87230467d6acbec Mon Sep 17 00:00:00 2001 From: Jon Tibble Date: Tue, 8 Feb 2011 16:22:54 +0000 Subject: [PATCH 63/68] D'oh --- openlp/plugins/songs/lib/easislidesimport.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/openlp/plugins/songs/lib/easislidesimport.py b/openlp/plugins/songs/lib/easislidesimport.py index 0b10ce428..5d56af8ce 100644 --- a/openlp/plugins/songs/lib/easislidesimport.py +++ b/openlp/plugins/songs/lib/easislidesimport.py @@ -81,14 +81,14 @@ class EasiSlidesImport(SongImport): def _parse_song(self, song): self._success = True - self._add_title(self.title, song.Title1, True) - self._add_alttitle(self.alternate_title, song.Title2) - self._add_number(self.song_number, song.SongNumber) + self._add_unicode_attribute(self.title, song.Title1, True) + self._add_unicode_attribute(self.alternate_title, song.Title2) + self._add_unicode_attribute(self.song_number, song.SongNumber) if self.song_number == u'0': self.song_number = u'' self._add_authors(song) self._add_copyright(song) - self._add_book(self.song_book_name, song.BookReference) + self._add_unicode_attribute(self.song_book_name, song.BookReference) self._parse_and_add_lyrics(song) return self._success From 2c0625a3923c8d113dd128e503dc98fa858ddf8c Mon Sep 17 00:00:00 2001 From: Jon Tibble Date: Tue, 8 Feb 2011 17:29:24 +0000 Subject: [PATCH 64/68] Dedupe, fix logic, fix names --- openlp/core/lib/ui.py | 22 +++++++++ openlp/core/ui/themewizard.py | 23 ++------- openlp/plugins/alerts/lib/alertstab.py | 67 ++++++++++---------------- 3 files changed, 51 insertions(+), 61 deletions(-) diff --git a/openlp/core/lib/ui.py b/openlp/core/lib/ui.py index 4a346b3e1..30f442012 100644 --- a/openlp/core/lib/ui.py +++ b/openlp/core/lib/ui.py @@ -219,3 +219,25 @@ def add_widget_completer(cache, widget): completer = QtGui.QCompleter(cache) completer.setCaseSensitivity(QtCore.Qt.CaseInsensitive) widget.setCompleter(completer) + +def create_valign_combo(parent, layout): + """ + Creates a standard label and combo box for asking users to select a + vertical alignment. + + ``parent`` + The parent object. This should be a ``QWidget`` descendant. + + ``layout`` + A layout object to add the label and combo widgets to. + """ + verticalLabel = QtGui.QLabel(parent) + verticalLabel.setObjectName(u'VerticalLabel') + verticalLabel.setText(translate('OpenLP.Ui', '&Vertical Align:')) + verticalComboBox = QtGui.QComboBox(parent) + verticalComboBox.setObjectName(u'VerticalComboBox') + verticalComboBox.addItem(translate('OpenLP.Ui', 'Top')) + verticalComboBox.addItem(translate('OpenLP.Ui', 'Middle')) + verticalComboBox.addItem(translate('OpenLP.Ui', 'Bottom')) + verticalLabel.setBuddy(verticalComboBox) + layout.addRow(verticalLabel, verticalComboBox) diff --git a/openlp/core/ui/themewizard.py b/openlp/core/ui/themewizard.py index 49522df70..e50ab0d45 100644 --- a/openlp/core/ui/themewizard.py +++ b/openlp/core/ui/themewizard.py @@ -27,7 +27,7 @@ from PyQt4 import QtCore, QtGui from openlp.core.lib import translate, build_icon -from openlp.core.lib.ui import add_welcome_page +from openlp.core.lib.ui import add_welcome_page, create_valign_combo class Ui_ThemeWizard(object): def setupUi(self, themeWizard): @@ -242,12 +242,7 @@ class Ui_ThemeWizard(object): self.horizontalComboBox.setObjectName(u'HorizontalComboBox') self.alignmentLayout.addRow(self.horizontalLabel, self.horizontalComboBox) - self.verticalLabel = QtGui.QLabel(self.alignmentPage) - self.verticalLabel.setObjectName(u'VerticalLabel') - self.verticalComboBox = QtGui.QComboBox(self.alignmentPage) - self.verticalComboBox.addItems([u'', u'', u'']) - self.verticalComboBox.setObjectName(u'VerticalComboBox') - self.alignmentLayout.addRow(self.verticalLabel, self.verticalComboBox) + create_valign_combo(self.alignmentPage, self.alignmentLayout) self.transitionsLabel = QtGui.QLabel(self.alignmentPage) self.transitionsLabel.setObjectName(u'TransitionsLabel') self.transitionsCheckBox = QtGui.QCheckBox(self.alignmentPage) @@ -450,8 +445,7 @@ class Ui_ThemeWizard(object): self.mainAreaPage.setSubTitle( translate('OpenLP.ThemeWizard', 'Define the font and display ' 'characteristics for the Display text')) - self.mainFontLabel.setText( - translate('OpenLP.ThemeWizard', 'Font:')) + self.mainFontLabel.setText(translate('OpenLP.ThemeWizard', 'Font:')) self.mainColorLabel.setText(translate('OpenLP.ThemeWizard', 'Color:')) self.mainSizeLabel.setText(translate('OpenLP.ThemeWizard', 'Size:')) self.mainSizeSpinBox.setSuffix(translate('OpenLP.ThemeWizard', 'pt')) @@ -465,8 +459,7 @@ class Ui_ThemeWizard(object): self.shadowCheckBox.setText(translate('OpenLP.ThemeWizard', '&Shadow:')) self.shadowSizeLabel.setText(translate('OpenLP.ThemeWizard', 'Size:')) self.shadowSizeSpinBox.setSuffix(translate('OpenLP.ThemeWizard', 'pt')) - self.mainBoldCheckBox.setText( - translate('OpenLP.ThemeWizard', 'Bold')) + self.mainBoldCheckBox.setText(translate('OpenLP.ThemeWizard', 'Bold')) self.mainItalicsCheckBox.setText( translate('OpenLP.ThemeWizard', 'Italic')) self.footerAreaPage.setTitle( @@ -491,14 +484,6 @@ class Ui_ThemeWizard(object): translate('OpenLP.ThemeWizard', 'Right')) self.horizontalComboBox.setItemText(2, translate('OpenLP.ThemeWizard', 'Center')) - self.verticalLabel.setText( - translate('OpenLP.ThemeWizard', 'Vertical Align:')) - self.verticalComboBox.setItemText(0, - translate('OpenLP.ThemeWizard', 'Top')) - self.verticalComboBox.setItemText(1, - translate('OpenLP.ThemeWizard', 'Middle')) - self.verticalComboBox.setItemText(2, - translate('OpenLP.ThemeWizard', 'Bottom')) self.transitionsLabel.setText( translate('OpenLP.ThemeWizard', 'Transitions:')) self.areaPositionPage.setTitle( diff --git a/openlp/plugins/alerts/lib/alertstab.py b/openlp/plugins/alerts/lib/alertstab.py index 96870d94c..01dbc2f7e 100644 --- a/openlp/plugins/alerts/lib/alertstab.py +++ b/openlp/plugins/alerts/lib/alertstab.py @@ -27,6 +27,7 @@ from PyQt4 import QtCore, QtGui from openlp.core.lib import SettingsTab, translate +from openlp.core.lib.ui import create_valign_combo class AlertsTab(SettingsTab): """ @@ -40,48 +41,43 @@ class AlertsTab(SettingsTab): def setupUi(self): self.setObjectName(u'AlertsTab') SettingsTab.setupUi(self) - self.FontGroupBox = QtGui.QGroupBox(self.leftColumn) - self.FontGroupBox.setObjectName(u'FontGroupBox') - self.FontLayout = QtGui.QFormLayout(self.FontGroupBox) - self.FontLayout.setObjectName(u'FontLayout') - self.FontLabel = QtGui.QLabel(self.FontGroupBox) + self.fontGroupBox = QtGui.QGroupBox(self.leftColumn) + self.fontGroupBox.setObjectName(u'fontGroupBox') + self.fontLayout = QtGui.QFormLayout(self.fontGroupBox) + self.fontLayout.setObjectName(u'fontLayout') + self.FontLabel = QtGui.QLabel(self.fontGroupBox) self.FontLabel.setObjectName(u'FontLabel') - self.FontComboBox = QtGui.QFontComboBox(self.FontGroupBox) + self.FontComboBox = QtGui.QFontComboBox(self.fontGroupBox) self.FontComboBox.setObjectName(u'FontComboBox') - self.FontLayout.addRow(self.FontLabel, self.FontComboBox) - self.FontColorLabel = QtGui.QLabel(self.FontGroupBox) + self.fontLayout.addRow(self.FontLabel, self.FontComboBox) + self.FontColorLabel = QtGui.QLabel(self.fontGroupBox) self.FontColorLabel.setObjectName(u'FontColorLabel') self.ColorLayout = QtGui.QHBoxLayout() self.ColorLayout.setObjectName(u'ColorLayout') - self.FontColorButton = QtGui.QPushButton(self.FontGroupBox) + self.FontColorButton = QtGui.QPushButton(self.fontGroupBox) self.FontColorButton.setObjectName(u'FontColorButton') self.ColorLayout.addWidget(self.FontColorButton) self.ColorLayout.addSpacing(20) - self.BackgroundColorLabel = QtGui.QLabel(self.FontGroupBox) + self.BackgroundColorLabel = QtGui.QLabel(self.fontGroupBox) self.BackgroundColorLabel.setObjectName(u'BackgroundColorLabel') self.ColorLayout.addWidget(self.BackgroundColorLabel) - self.BackgroundColorButton = QtGui.QPushButton(self.FontGroupBox) + self.BackgroundColorButton = QtGui.QPushButton(self.fontGroupBox) self.BackgroundColorButton.setObjectName(u'BackgroundColorButton') self.ColorLayout.addWidget(self.BackgroundColorButton) - self.FontLayout.addRow(self.FontColorLabel, self.ColorLayout) - self.FontSizeLabel = QtGui.QLabel(self.FontGroupBox) + self.fontLayout.addRow(self.FontColorLabel, self.ColorLayout) + self.FontSizeLabel = QtGui.QLabel(self.fontGroupBox) self.FontSizeLabel.setObjectName(u'FontSizeLabel') - self.FontSizeSpinBox = QtGui.QSpinBox(self.FontGroupBox) + self.FontSizeSpinBox = QtGui.QSpinBox(self.fontGroupBox) self.FontSizeSpinBox.setObjectName(u'FontSizeSpinBox') - self.FontLayout.addRow(self.FontSizeLabel, self.FontSizeSpinBox) - self.TimeoutLabel = QtGui.QLabel(self.FontGroupBox) + self.fontLayout.addRow(self.FontSizeLabel, self.FontSizeSpinBox) + self.TimeoutLabel = QtGui.QLabel(self.fontGroupBox) self.TimeoutLabel.setObjectName(u'TimeoutLabel') - self.TimeoutSpinBox = QtGui.QSpinBox(self.FontGroupBox) + self.TimeoutSpinBox = QtGui.QSpinBox(self.fontGroupBox) self.TimeoutSpinBox.setMaximum(180) self.TimeoutSpinBox.setObjectName(u'TimeoutSpinBox') - self.FontLayout.addRow(self.TimeoutLabel, self.TimeoutSpinBox) - self.LocationLabel = QtGui.QLabel(self.FontGroupBox) - self.LocationLabel.setObjectName(u'LocationLabel') - self.LocationComboBox = QtGui.QComboBox(self.FontGroupBox) - self.LocationComboBox.addItems([u'', u'', u'']) - self.LocationComboBox.setObjectName(u'LocationComboBox') - self.FontLayout.addRow(self.LocationLabel, self.LocationComboBox) - self.leftLayout.addWidget(self.FontGroupBox) + self.fontLayout.addRow(self.TimeoutLabel, self.TimeoutSpinBox) + create_valign_combo(self.fontGroupBox, self.fontLayout) + self.leftLayout.addWidget(self.fontGroupBox) self.leftLayout.addStretch() self.PreviewGroupBox = QtGui.QGroupBox(self.rightColumn) self.PreviewGroupBox.setObjectName(u'PreviewGroupBox') @@ -99,15 +95,13 @@ class AlertsTab(SettingsTab): QtCore.SIGNAL(u'pressed()'), self.onFontColorButtonClicked) QtCore.QObject.connect(self.FontComboBox, QtCore.SIGNAL(u'activated(int)'), self.onFontComboBoxClicked) - QtCore.QObject.connect(self.LocationComboBox, - QtCore.SIGNAL(u'activated(int)'), self.onLocationComboBoxClicked) QtCore.QObject.connect(self.TimeoutSpinBox, QtCore.SIGNAL(u'valueChanged(int)'), self.onTimeoutSpinBoxChanged) QtCore.QObject.connect(self.FontSizeSpinBox, QtCore.SIGNAL(u'valueChanged(int)'), self.onFontSizeSpinBoxChanged) def retranslateUi(self): - self.FontGroupBox.setTitle( + self.fontGroupBox.setTitle( translate('AlertsPlugin.AlertsTab', 'Font')) self.FontLabel.setText( translate('AlertsPlugin.AlertsTab', 'Font name:')) @@ -123,18 +117,10 @@ class AlertsTab(SettingsTab): translate('AlertsPlugin.AlertsTab', 'Alert timeout:')) self.TimeoutSpinBox.setSuffix( translate('AlertsPlugin.AlertsTab', 's')) - self.LocationLabel.setText( - translate('AlertsPlugin.AlertsTab', 'Location:')) self.PreviewGroupBox.setTitle( translate('AlertsPlugin.AlertsTab', 'Preview')) self.FontPreview.setText( translate('AlertsPlugin.AlertsTab', 'OpenLP 2.0')) - self.LocationComboBox.setItemText(0, - translate('AlertsPlugin.AlertsTab', 'Top')) - self.LocationComboBox.setItemText(1, - translate('AlertsPlugin.AlertsTab', 'Middle')) - self.LocationComboBox.setItemText(2, - translate('AlertsPlugin.AlertsTab', 'Bottom')) def onBackgroundColorButtonClicked(self): new_color = QtGui.QColorDialog.getColor( @@ -148,9 +134,6 @@ class AlertsTab(SettingsTab): def onFontComboBoxClicked(self): self.updateDisplay() - def onLocationComboBoxClicked(self, location): - self.location = location - def onFontColorButtonClicked(self): new_color = QtGui.QColorDialog.getColor( QtGui.QColor(self.font_color), self) @@ -197,14 +180,14 @@ class AlertsTab(SettingsTab): def save(self): settings = QtCore.QSettings() settings.beginGroup(self.settingsSection) - self.font_face = self.FontComboBox.currentFont().family() settings.setValue(u'background color', QtCore.QVariant(self.bg_color)) settings.setValue(u'font color', QtCore.QVariant(self.font_color)) settings.setValue(u'font size', QtCore.QVariant(self.font_size)) + self.font_face = self.FontComboBox.currentFont().family() settings.setValue(u'font face', QtCore.QVariant(self.font_face)) settings.setValue(u'timeout', QtCore.QVariant(self.timeout)) - settings.setValue(u'location', - QtCore.QVariant(self.LocationComboBox.currentIndex())) + self.location = self.LocationComboBox.currentIndex() + settings.setValue(u'location', QtCore.QVariant(self.location)) settings.endGroup() def updateDisplay(self): From 261328d952a1d7cad22bab43cbc63fb6ce48b301 Mon Sep 17 00:00:00 2001 From: Jon Tibble Date: Tue, 8 Feb 2011 19:31:55 +0000 Subject: [PATCH 65/68] Fix last commit --- openlp/core/lib/ui.py | 19 +++++++++++-------- openlp/core/ui/themewizard.py | 3 ++- openlp/plugins/alerts/lib/alertstab.py | 6 +++--- 3 files changed, 16 insertions(+), 12 deletions(-) diff --git a/openlp/core/lib/ui.py b/openlp/core/lib/ui.py index 30f442012..843f4ef92 100644 --- a/openlp/core/lib/ui.py +++ b/openlp/core/lib/ui.py @@ -220,11 +220,14 @@ def add_widget_completer(cache, widget): completer.setCaseSensitivity(QtCore.Qt.CaseInsensitive) widget.setCompleter(completer) -def create_valign_combo(parent, layout): +def create_valign_combo(form, parent, layout): """ Creates a standard label and combo box for asking users to select a vertical alignment. + ``form`` + The UI screen that the label and combo will appear on. + ``parent`` The parent object. This should be a ``QWidget`` descendant. @@ -234,10 +237,10 @@ def create_valign_combo(parent, layout): verticalLabel = QtGui.QLabel(parent) verticalLabel.setObjectName(u'VerticalLabel') verticalLabel.setText(translate('OpenLP.Ui', '&Vertical Align:')) - verticalComboBox = QtGui.QComboBox(parent) - verticalComboBox.setObjectName(u'VerticalComboBox') - verticalComboBox.addItem(translate('OpenLP.Ui', 'Top')) - verticalComboBox.addItem(translate('OpenLP.Ui', 'Middle')) - verticalComboBox.addItem(translate('OpenLP.Ui', 'Bottom')) - verticalLabel.setBuddy(verticalComboBox) - layout.addRow(verticalLabel, verticalComboBox) + form.verticalComboBox = QtGui.QComboBox(parent) + form.verticalComboBox.setObjectName(u'VerticalComboBox') + form.verticalComboBox.addItem(translate('OpenLP.Ui', 'Top')) + form.verticalComboBox.addItem(translate('OpenLP.Ui', 'Middle')) + form.verticalComboBox.addItem(translate('OpenLP.Ui', 'Bottom')) + verticalLabel.setBuddy(form.verticalComboBox) + layout.addRow(verticalLabel, form.verticalComboBox) diff --git a/openlp/core/ui/themewizard.py b/openlp/core/ui/themewizard.py index e50ab0d45..38dd9f1dc 100644 --- a/openlp/core/ui/themewizard.py +++ b/openlp/core/ui/themewizard.py @@ -242,7 +242,8 @@ class Ui_ThemeWizard(object): self.horizontalComboBox.setObjectName(u'HorizontalComboBox') self.alignmentLayout.addRow(self.horizontalLabel, self.horizontalComboBox) - create_valign_combo(self.alignmentPage, self.alignmentLayout) + create_valign_combo(themeWizard, self.alignmentPage, + self.alignmentLayout) self.transitionsLabel = QtGui.QLabel(self.alignmentPage) self.transitionsLabel.setObjectName(u'TransitionsLabel') self.transitionsCheckBox = QtGui.QCheckBox(self.alignmentPage) diff --git a/openlp/plugins/alerts/lib/alertstab.py b/openlp/plugins/alerts/lib/alertstab.py index 01dbc2f7e..a350c13cc 100644 --- a/openlp/plugins/alerts/lib/alertstab.py +++ b/openlp/plugins/alerts/lib/alertstab.py @@ -76,7 +76,7 @@ class AlertsTab(SettingsTab): self.TimeoutSpinBox.setMaximum(180) self.TimeoutSpinBox.setObjectName(u'TimeoutSpinBox') self.fontLayout.addRow(self.TimeoutLabel, self.TimeoutSpinBox) - create_valign_combo(self.fontGroupBox, self.fontLayout) + create_valign_combo(self, self.fontGroupBox, self.fontLayout) self.leftLayout.addWidget(self.fontGroupBox) self.leftLayout.addStretch() self.PreviewGroupBox = QtGui.QGroupBox(self.rightColumn) @@ -171,7 +171,7 @@ class AlertsTab(SettingsTab): u'background-color: %s' % self.font_color) self.BackgroundColorButton.setStyleSheet( u'background-color: %s' % self.bg_color) - self.LocationComboBox.setCurrentIndex(self.location) + self.verticalComboBox.setCurrentIndex(self.location) font = QtGui.QFont() font.setFamily(self.font_face) self.FontComboBox.setCurrentFont(font) @@ -186,7 +186,7 @@ class AlertsTab(SettingsTab): self.font_face = self.FontComboBox.currentFont().family() settings.setValue(u'font face', QtCore.QVariant(self.font_face)) settings.setValue(u'timeout', QtCore.QVariant(self.timeout)) - self.location = self.LocationComboBox.currentIndex() + self.location = self.verticalComboBox.currentIndex() settings.setValue(u'location', QtCore.QVariant(self.location)) settings.endGroup() From 5607b09f0defe03b10d0e19976a8e4ba21f42cf7 Mon Sep 17 00:00:00 2001 From: Jon Tibble Date: Wed, 9 Feb 2011 05:04:12 +0000 Subject: [PATCH 66/68] Dedupe translations --- openlp/core/lib/ui.py | 28 +++++++++++++++-- openlp/core/ui/displaytagtab.py | 5 ++-- openlp/core/ui/mainwindow.py | 5 ++-- openlp/core/ui/slidecontroller.py | 7 ++--- openlp/core/ui/themeform.py | 5 ++-- openlp/core/ui/themestab.py | 3 +- openlp/plugins/alerts/lib/alertstab.py | 8 ++--- openlp/plugins/bibles/bibleplugin.py | 15 +++++----- .../plugins/bibles/forms/bibleimportform.py | 5 ++-- openlp/plugins/custom/customplugin.py | 17 ++++++----- .../plugins/custom/forms/editcustomdialog.py | 8 ++--- openlp/plugins/images/imageplugin.py | 15 +++++----- openlp/plugins/images/lib/mediaitem.py | 4 +-- openlp/plugins/media/mediaplugin.py | 15 +++++----- .../presentations/presentationplugin.py | 11 +++---- openlp/plugins/songs/forms/editsongdialog.py | 17 ++++------- openlp/plugins/songs/forms/songimportform.py | 8 ++--- .../songs/forms/songmaintenancedialog.py | 30 +++++++------------ openlp/plugins/songs/lib/mediaitem.py | 7 ++--- openlp/plugins/songs/songsplugin.py | 13 ++++---- 20 files changed, 116 insertions(+), 110 deletions(-) diff --git a/openlp/core/lib/ui.py b/openlp/core/lib/ui.py index 843f4ef92..41e88b54b 100644 --- a/openlp/core/lib/ui.py +++ b/openlp/core/lib/ui.py @@ -34,6 +34,29 @@ from openlp.core.lib import build_icon, Receiver, translate log = logging.getLogger(__name__) +class UiStrings(object): + """ + Provide standard strings for objects to use. + """ + # These strings should need a good reason to be retranslated elsewhere. + # Should some/more/less of these have an & attached? + Add = translate('OpenLP.Ui', '&Add') + AllFiles = translate('OpenLP.Ui', 'All Files') + Authors = translate('OpenLP.Ui', 'Authors') + Delete = translate('OpenLP.Ui', '&Delete') + Edit = translate('OpenLP.Ui', '&Edit') + Error = translate('OpenLP.Ui', 'Error') + Import = translate('OpenLP.Ui', 'Import') + Live = translate('OpenLP.Ui', 'Live') + Load = translate('OpenLP.Ui', 'Load') + New = translate('OpenLP.Ui', 'New') + OLPV2 = translate('OpenLP.Ui', 'OpenLP 2.0') + Preview = translate('OpenLP.Ui', 'Preview') + Service = translate('OpenLP.Ui', 'Service') + Theme = translate('OpenLP.Ui', 'Theme') + Themes = translate('OpenLP.Ui', 'Themes') + + def add_welcome_page(parent, image): """ Generate an opening welcome page for a wizard using a provided image. @@ -98,13 +121,12 @@ def critical_error_message_box(title=None, message=None, parent=None, ``question`` Should this message box question the user. """ - error = translate('OpenLP.Ui', 'Error') if question: return QtGui.QMessageBox.critical(parent, error, message, QtGui.QMessageBox.StandardButtons( QtGui.QMessageBox.Yes | QtGui.QMessageBox.No)) data = {u'message': message} - data[u'title'] = title if title else error + data[u'title'] = title if title else UiStrings.Error return Receiver.send_message(u'openlp_error_message', data) def media_item_combo_box(parent, name): @@ -134,7 +156,7 @@ def create_delete_push_button(parent, icon=None): delete_button.setObjectName(u'deleteButton') delete_icon = icon if icon else u':/general/general_delete.png' delete_button.setIcon(build_icon(delete_icon)) - delete_button.setText(translate('OpenLP.Ui', '&Delete')) + delete_button.setText(UiStrings.Delete) delete_button.setToolTip( translate('OpenLP.Ui', 'Delete the selected item.')) QtCore.QObject.connect(delete_button, diff --git a/openlp/core/ui/displaytagtab.py b/openlp/core/ui/displaytagtab.py index 54d021913..abf0ca44f 100644 --- a/openlp/core/ui/displaytagtab.py +++ b/openlp/core/ui/displaytagtab.py @@ -34,7 +34,7 @@ import cPickle from PyQt4 import QtCore, QtGui from openlp.core.lib import SettingsTab, translate, DisplayTags -from openlp.core.lib.ui import critical_error_message_box +from openlp.core.lib.ui import UiStrings, critical_error_message_box class DisplayTagTab(SettingsTab): """ @@ -164,8 +164,7 @@ class DisplayTagTab(SettingsTab): self.startTagLabel.setText( translate('OpenLP.DisplayTagTab', 'Start tag')) self.endTagLabel.setText(translate('OpenLP.DisplayTagTab', 'End tag')) - self.deletePushButton.setText( - translate('OpenLP.DisplayTagTab', 'Delete')) + self.deletePushButton.setText(UiStrings.Delete) self.defaultPushButton.setText( translate('OpenLP.DisplayTagTab', 'Default')) self.newPushButton.setText(translate('OpenLP.DisplayTagTab', 'New')) diff --git a/openlp/core/ui/mainwindow.py b/openlp/core/ui/mainwindow.py index e489d7b5d..c87a9544a 100644 --- a/openlp/core/ui/mainwindow.py +++ b/openlp/core/ui/mainwindow.py @@ -30,7 +30,8 @@ from PyQt4 import QtCore, QtGui from openlp.core.lib import RenderManager, build_icon, OpenLPDockWidget, \ SettingsManager, PluginManager, Receiver, translate -from openlp.core.lib.ui import base_action, checkable_action, icon_action +from openlp.core.lib.ui import UiStrings, base_action, checkable_action, \ + icon_action from openlp.core.ui import AboutForm, SettingsForm, ServiceManager, \ ThemeManager, SlideController, PluginForm, MediaDockManager, \ ShortcutListForm @@ -295,7 +296,7 @@ class Ui_MainWindow(object): """ Set up the translation system """ - mainWindow.mainTitle = translate('OpenLP.MainWindow', 'OpenLP 2.0') + mainWindow.mainTitle = UiStrings.OLPV2 mainWindow.setWindowTitle(mainWindow.mainTitle) self.FileMenu.setTitle(translate('OpenLP.MainWindow', '&File')) self.FileImportMenu.setTitle(translate('OpenLP.MainWindow', '&Import')) diff --git a/openlp/core/ui/slidecontroller.py b/openlp/core/ui/slidecontroller.py index cf2c0983b..1caf43dfd 100644 --- a/openlp/core/ui/slidecontroller.py +++ b/openlp/core/ui/slidecontroller.py @@ -32,7 +32,7 @@ from PyQt4.phonon import Phonon from openlp.core.lib import OpenLPToolbar, Receiver, resize_image, \ ItemCapabilities, translate -from openlp.core.lib.ui import shortcut_action +from openlp.core.lib.ui import UiStrings, shortcut_action from openlp.core.ui import HideMode, MainDisplay log = logging.getLogger(__name__) @@ -87,12 +87,11 @@ class SlideController(QtGui.QWidget): # Type label for the top of the slide controller self.typeLabel = QtGui.QLabel(self.panel) if self.isLive: - self.typeLabel.setText(translate('OpenLP.SlideController', 'Live')) + self.typeLabel.setText(UiStrings.Live) self.split = 1 self.typePrefix = u'live' else: - self.typeLabel.setText(translate('OpenLP.SlideController', - 'Preview')) + self.typeLabel.setText(UiStrings.Preview) self.split = 0 self.typePrefix = u'preview' self.typeLabel.setStyleSheet(u'font-weight: bold; font-size: 12pt;') diff --git a/openlp/core/ui/themeform.py b/openlp/core/ui/themeform.py index 018df7597..f86fa0143 100644 --- a/openlp/core/ui/themeform.py +++ b/openlp/core/ui/themeform.py @@ -31,7 +31,7 @@ from PyQt4 import QtCore, QtGui from openlp.core.lib import translate, BackgroundType, BackgroundGradientType, \ Receiver -from openlp.core.lib.ui import critical_error_message_box +from openlp.core.lib.ui import UiStrings, critical_error_message_box from openlp.core.utils import get_images_filter from themewizard import Ui_ThemeWizard @@ -483,8 +483,7 @@ class ThemeForm(QtGui.QWizard, Ui_ThemeWizard): Background Image button pushed. """ images_filter = get_images_filter() - images_filter = '%s;;%s (*.*) (*)' % (images_filter, - translate('OpenLP.ThemeForm', 'All Files')) + images_filter = '%s;;%s (*.*) (*)' % (images_filter, UiStrings.AllFiles) filename = QtGui.QFileDialog.getOpenFileName(self, translate('OpenLP.ThemeForm', 'Select Image'), u'', images_filter) diff --git a/openlp/core/ui/themestab.py b/openlp/core/ui/themestab.py index 441b95155..ba4ce5acb 100644 --- a/openlp/core/ui/themestab.py +++ b/openlp/core/ui/themestab.py @@ -27,6 +27,7 @@ from PyQt4 import QtCore, QtGui from openlp.core.lib import SettingsTab, Receiver, ThemeLevel, translate +from openlp.core.lib.ui import UiStrings class ThemesTab(SettingsTab): """ @@ -98,7 +99,7 @@ class ThemesTab(SettingsTab): QtCore.SIGNAL(u'theme_update_list'), self.updateThemeList) def retranslateUi(self): - self.tabTitleVisible = translate('OpenLP.ThemesTab', 'Themes') + self.tabTitleVisible = UiStrings.Themes self.GlobalGroupBox.setTitle( translate('OpenLP.ThemesTab', 'Global Theme')) self.LevelGroupBox.setTitle( diff --git a/openlp/plugins/alerts/lib/alertstab.py b/openlp/plugins/alerts/lib/alertstab.py index a350c13cc..4090503db 100644 --- a/openlp/plugins/alerts/lib/alertstab.py +++ b/openlp/plugins/alerts/lib/alertstab.py @@ -27,7 +27,7 @@ from PyQt4 import QtCore, QtGui from openlp.core.lib import SettingsTab, translate -from openlp.core.lib.ui import create_valign_combo +from openlp.core.lib.ui import UiStrings, create_valign_combo class AlertsTab(SettingsTab): """ @@ -117,10 +117,8 @@ class AlertsTab(SettingsTab): translate('AlertsPlugin.AlertsTab', 'Alert timeout:')) self.TimeoutSpinBox.setSuffix( translate('AlertsPlugin.AlertsTab', 's')) - self.PreviewGroupBox.setTitle( - translate('AlertsPlugin.AlertsTab', 'Preview')) - self.FontPreview.setText( - translate('AlertsPlugin.AlertsTab', 'OpenLP 2.0')) + self.PreviewGroupBox.setTitle(UiStrings.Preview) + self.FontPreview.setText(UiStrings.OLPV2) def onBackgroundColorButtonClicked(self): new_color = QtGui.QColorDialog.getColor( diff --git a/openlp/plugins/bibles/bibleplugin.py b/openlp/plugins/bibles/bibleplugin.py index e3b2ad4aa..e1dadd4bf 100644 --- a/openlp/plugins/bibles/bibleplugin.py +++ b/openlp/plugins/bibles/bibleplugin.py @@ -29,6 +29,7 @@ import logging from PyQt4 import QtCore, QtGui from openlp.core.lib import Plugin, StringContent, build_icon, translate +from openlp.core.lib.ui import UiStrings from openlp.plugins.bibles.lib import BibleManager, BiblesTab, BibleMediaItem log = logging.getLogger(__name__) @@ -137,38 +138,38 @@ class BiblePlugin(Plugin): # Middle Header Bar ## Import Action ## self.textStrings[StringContent.Import] = { - u'title': translate('BiblesPlugin', '&Import'), + u'title': UiStrings.Import, u'tooltip': translate('BiblesPlugin', 'Import a Bible') } ## New Action ## self.textStrings[StringContent.New] = { - u'title': translate('BiblesPlugin', '&Add'), + u'title': UiStrings.Add, u'tooltip': translate('BiblesPlugin', 'Add a new Bible') } ## Edit Action ## self.textStrings[StringContent.Edit] = { - u'title': translate('BiblesPlugin', '&Edit'), + u'title': UiStrings.Edit, u'tooltip': translate('BiblesPlugin', 'Edit the selected Bible') } ## Delete Action ## self.textStrings[StringContent.Delete] = { - u'title': translate('BiblesPlugin', '&Delete'), + u'title': UiStrings.Delete, u'tooltip': translate('BiblesPlugin', 'Delete the selected Bible') } ## Preview Action ## self.textStrings[StringContent.Preview] = { - u'title': translate('BiblesPlugin', 'Preview'), + u'title': UiStrings.Preview, u'tooltip': translate('BiblesPlugin', 'Preview the selected Bible') } ## Send Live Action ## self.textStrings[StringContent.Live] = { - u'title': translate('BiblesPlugin', 'Live'), + u'title': UiStrings.Live, u'tooltip': translate('BiblesPlugin', 'Send the selected Bible live') } ## Add to Service Action ## self.textStrings[StringContent.Service] = { - u'title': translate('BiblesPlugin', 'Service'), + u'title': UiStrings.Service, u'tooltip': translate('BiblesPlugin', 'Add the selected Bible to the service') } diff --git a/openlp/plugins/bibles/forms/bibleimportform.py b/openlp/plugins/bibles/forms/bibleimportform.py index f21dd0e07..f528a4b1b 100644 --- a/openlp/plugins/bibles/forms/bibleimportform.py +++ b/openlp/plugins/bibles/forms/bibleimportform.py @@ -35,7 +35,7 @@ from PyQt4 import QtCore, QtGui from openlp.core.lib import Receiver, SettingsManager, translate from openlp.core.lib.db import delete_database -from openlp.core.lib.ui import critical_error_message_box +from openlp.core.lib.ui import UiStrings, critical_error_message_box from openlp.core.ui.wizard import OpenLPWizard from openlp.core.utils import AppLocation, string_is_unicode from openlp.plugins.bibles.lib.manager import BibleFormat @@ -745,8 +745,7 @@ class BibleImportForm(OpenLPWizard): """ if filters: filters += u';;' - filters += u'%s (*)' % translate('BiblesPlugin.ImportWizardForm', - 'All Files') + filters += u'%s (*)' % UiStrings.AllFiles filename = QtGui.QFileDialog.getOpenFileName(self, title, os.path.dirname(SettingsManager.get_last_dir( self.plugin.settingsSection, 1)), filters) diff --git a/openlp/plugins/custom/customplugin.py b/openlp/plugins/custom/customplugin.py index 54cb38501..210556ad8 100644 --- a/openlp/plugins/custom/customplugin.py +++ b/openlp/plugins/custom/customplugin.py @@ -30,6 +30,7 @@ from forms import EditCustomForm from openlp.core.lib import Plugin, StringContent, build_icon, translate from openlp.core.lib.db import Manager +from openlp.core.lib.ui import UiStrings from openlp.plugins.custom.lib import CustomMediaItem, CustomTab from openlp.plugins.custom.lib.db import CustomSlide, init_schema @@ -114,49 +115,49 @@ class CustomPlugin(Plugin): # Middle Header Bar ## Import Action ## self.textStrings[StringContent.Import] = { - u'title': translate('CustomsPlugin', 'Import'), + u'title': UiStrings.Import, u'tooltip': translate('CustomsPlugin', 'Import a Custom') } ## Load Action ## self.textStrings[StringContent.Load] = { - u'title': translate('CustomsPlugin', 'Load'), + u'title': UiStrings.Load, u'tooltip': translate('CustomsPlugin', 'Load a new Custom') } ## New Action ## self.textStrings[StringContent.New] = { - u'title': translate('CustomsPlugin', 'Add'), + u'title': UiStrings.Add, u'tooltip': translate('CustomsPlugin', 'Add a new Custom') } ## Edit Action ## self.textStrings[StringContent.Edit] = { - u'title': translate('CustomsPlugin', 'Edit'), + u'title': UiStrings.Edit, u'tooltip': translate('CustomsPlugin', 'Edit the selected Custom') } ## Delete Action ## self.textStrings[StringContent.Delete] = { - u'title': translate('CustomsPlugin', 'Delete'), + u'title': UiStrings.Delete, u'tooltip': translate('CustomsPlugin', 'Delete the selected Custom') } ## Preview Action ## self.textStrings[StringContent.Preview] = { - u'title': translate('CustomsPlugin', 'Preview'), + u'title': UiStrings.Preview, u'tooltip': translate('CustomsPlugin', 'Preview the selected Custom') } ## Send Live Action ## self.textStrings[StringContent.Live] = { - u'title': translate('CustomsPlugin', 'Live'), + u'title': UiStrings.Live, u'tooltip': translate('CustomsPlugin', 'Send the selected Custom live') } ## Add to Service Action ## self.textStrings[StringContent.Service] = { - u'title': translate('CustomsPlugin', 'Service'), + u'title': UiStrings.Service, u'tooltip': translate('CustomsPlugin', 'Add the selected Custom to the service') } diff --git a/openlp/plugins/custom/forms/editcustomdialog.py b/openlp/plugins/custom/forms/editcustomdialog.py index b7887aa90..1ca29732b 100644 --- a/openlp/plugins/custom/forms/editcustomdialog.py +++ b/openlp/plugins/custom/forms/editcustomdialog.py @@ -27,7 +27,7 @@ from PyQt4 import QtCore, QtGui from openlp.core.lib import build_icon, translate -from openlp.core.lib.ui import create_save_cancel_button_box, \ +from openlp.core.lib.ui import UiStrings, create_save_cancel_button_box, \ create_delete_push_button, create_up_down_push_button_set class Ui_CustomEditDialog(object): @@ -107,13 +107,11 @@ class Ui_CustomEditDialog(object): translate('CustomPlugin.EditCustomForm', 'Edit Custom Slides')) self.titleLabel.setText( translate('CustomPlugin.EditCustomForm', '&Title:')) - self.addButton.setText( - translate('CustomPlugin.EditCustomForm', '&Add')) + self.addButton.setText(UiStrings.Add) self.addButton.setToolTip( translate('CustomPlugin.EditCustomForm', 'Add a new slide at ' 'bottom.')) - self.editButton.setText( - translate('CustomPlugin.EditCustomForm', '&Edit')) + self.editButton.setText(UiStrings.Edit) self.editButton.setToolTip( translate('CustomPlugin.EditCustomForm', 'Edit the selected ' 'slide.')) diff --git a/openlp/plugins/images/imageplugin.py b/openlp/plugins/images/imageplugin.py index ea118d3ec..0af48bacd 100644 --- a/openlp/plugins/images/imageplugin.py +++ b/openlp/plugins/images/imageplugin.py @@ -27,6 +27,7 @@ import logging from openlp.core.lib import Plugin, StringContent, build_icon, translate +from openlp.core.lib.ui import UiStrings from openlp.plugins.images.lib import ImageMediaItem log = logging.getLogger(__name__) @@ -74,43 +75,43 @@ class ImagePlugin(Plugin): # Middle Header Bar ## Load Button ## self.textStrings[StringContent.Load] = { - u'title': translate('ImagePlugin', 'Load'), + u'title': UiStrings.Load, u'tooltip': translate('ImagePlugin', 'Load a new Image') } ## New Button ## self.textStrings[StringContent.New] = { - u'title': translate('ImagePlugin', 'Add'), + u'title': UiStrings.Add, u'tooltip': translate('ImagePlugin', 'Add a new Image') } ## Edit Button ## self.textStrings[StringContent.Edit] = { - u'title': translate('ImagePlugin', 'Edit'), + u'title': UiStrings.Edit, u'tooltip': translate('ImagePlugin', 'Edit the selected Image') } ## Delete Button ## self.textStrings[StringContent.Delete] = { - u'title': translate('ImagePlugin', 'Delete'), + u'title': UiStrings.Delete, u'tooltip': translate('ImagePlugin', 'Delete the selected Image') } ## Preview ## self.textStrings[StringContent.Preview] = { - u'title': translate('ImagePlugin', 'Preview'), + u'title': UiStrings.Preview, u'tooltip': translate('ImagePlugin', 'Preview the selected Image') } ## Live Button ## self.textStrings[StringContent.Live] = { - u'title': translate('ImagePlugin', 'Live'), + u'title': UiStrings.Live, u'tooltip': translate('ImagePlugin', 'Send the selected Image live') } ## Add to service Button ## self.textStrings[StringContent.Service] = { - u'title': translate('ImagePlugin', 'Service'), + u'title': UiStrings.Service, u'tooltip': translate('ImagePlugin', 'Add the selected Image to the service') } diff --git a/openlp/plugins/images/lib/mediaitem.py b/openlp/plugins/images/lib/mediaitem.py index 6e720fa0b..6ec4cf264 100644 --- a/openlp/plugins/images/lib/mediaitem.py +++ b/openlp/plugins/images/lib/mediaitem.py @@ -32,7 +32,7 @@ from PyQt4 import QtCore, QtGui from openlp.core.lib import MediaManagerItem, BaseListWithDnD, build_icon, \ ItemCapabilities, SettingsManager, translate, check_item_selected, \ check_directory_exists, Receiver -from openlp.core.lib.ui import critical_error_message_box +from openlp.core.lib.ui import UiStrings, critical_error_message_box from openlp.core.utils import AppLocation, delete_file, get_images_filter log = logging.getLogger(__name__) @@ -64,7 +64,7 @@ class ImageMediaItem(MediaManagerItem): 'Select Image(s)') file_formats = get_images_filter() self.OnNewFileMasks = u'%s;;%s (*.*) (*)' % (file_formats, - unicode(translate('ImagePlugin.MediaItem', 'All Files'))) + unicode(UiStrings.AllFiles)) self.replaceAction.setText( translate('ImagePlugin.MediaItem', 'Replace Background')) self.replaceAction.setToolTip( diff --git a/openlp/plugins/media/mediaplugin.py b/openlp/plugins/media/mediaplugin.py index ad6087daf..42dcc321c 100644 --- a/openlp/plugins/media/mediaplugin.py +++ b/openlp/plugins/media/mediaplugin.py @@ -30,6 +30,7 @@ import mimetypes from PyQt4.phonon import Phonon from openlp.core.lib import Plugin, StringContent, build_icon, translate +from openlp.core.lib.ui import UiStrings from openlp.plugins.media.lib import MediaMediaItem, MediaTab log = logging.getLogger(__name__) @@ -103,43 +104,43 @@ class MediaPlugin(Plugin): # Middle Header Bar ## Load Action ## self.textStrings[StringContent.Load] = { - u'title': translate('MediaPlugin', 'Load'), + u'title': UiStrings.Load, u'tooltip': translate('MediaPlugin', 'Load a new Media') } ## New Action ## self.textStrings[StringContent.New] = { - u'title': translate('MediaPlugin', 'Add'), + u'title': UiStrings.Add, u'tooltip': translate('MediaPlugin', 'Add a new Media') } ## Edit Action ## self.textStrings[StringContent.Edit] = { - u'title': translate('MediaPlugin', 'Edit'), + u'title': UiStrings.Edit, u'tooltip': translate('MediaPlugin', 'Edit the selected Media') } ## Delete Action ## self.textStrings[StringContent.Delete] = { - u'title': translate('MediaPlugin', 'Delete'), + u'title': UiStrings.Delete, u'tooltip': translate('MediaPlugin', 'Delete the selected Media') } ## Preview Action ## self.textStrings[StringContent.Preview] = { - u'title': translate('MediaPlugin', 'Preview'), + u'title': UiStrings.Preview, u'tooltip': translate('MediaPlugin', 'Preview the selected Media') } ## Send Live Action ## self.textStrings[StringContent.Live] = { - u'title': translate('MediaPlugin', 'Live'), + u'title': UiStrings.Live, u'tooltip': translate('MediaPlugin', 'Send the selected Media live') } ## Add to Service Action ## self.textStrings[StringContent.Service] = { - u'title': translate('MediaPlugin', 'Service'), + u'title': UiStrings.Service, u'tooltip': translate('MediaPlugin', 'Add the selected Media to the service') } diff --git a/openlp/plugins/presentations/presentationplugin.py b/openlp/plugins/presentations/presentationplugin.py index 17417df58..213ff2927 100644 --- a/openlp/plugins/presentations/presentationplugin.py +++ b/openlp/plugins/presentations/presentationplugin.py @@ -31,6 +31,7 @@ import os import logging from openlp.core.lib import Plugin, StringContent, build_icon, translate +from openlp.core.lib.ui import UiStrings from openlp.core.utils import AppLocation from openlp.plugins.presentations.lib import PresentationController, \ PresentationMediaItem, PresentationTab @@ -169,31 +170,31 @@ class PresentationPlugin(Plugin): # Middle Header Bar ## Load Action ## self.textStrings[StringContent.Load] = { - u'title': translate('PresentationPlugin', 'Load'), + u'title': UiStrings.Load, u'tooltip': translate('PresentationPlugin', 'Load a new Presentation') } ## Delete Action ## self.textStrings[StringContent.Delete] = { - u'title': translate('PresentationPlugin', 'Delete'), + u'title': UiStrings.Delete, u'tooltip': translate('PresentationPlugin', 'Delete the selected Presentation') } ## Preview Action ## self.textStrings[StringContent.Preview] = { - u'title': translate('PresentationPlugin', 'Preview'), + u'title': UiStrings.Preview, u'tooltip': translate('PresentationPlugin', 'Preview the selected Presentation') } ## Send Live Action ## self.textStrings[StringContent.Live] = { - u'title': translate('PresentationPlugin', 'Live'), + u'title': UiStrings.Live, u'tooltip': translate('PresentationPlugin', 'Send the selected Presentation live') } ## Add to Service Action ## self.textStrings[StringContent.Service] = { - u'title': translate('PresentationPlugin', 'Service'), + u'title': UiStrings.Service, u'tooltip': translate('PresentationPlugin', 'Add the selected Presentation to the service') } diff --git a/openlp/plugins/songs/forms/editsongdialog.py b/openlp/plugins/songs/forms/editsongdialog.py index e9be62830..6854a17ae 100644 --- a/openlp/plugins/songs/forms/editsongdialog.py +++ b/openlp/plugins/songs/forms/editsongdialog.py @@ -27,7 +27,7 @@ from PyQt4 import QtCore, QtGui from openlp.core.lib import build_icon, translate -from openlp.core.lib.ui import create_save_cancel_button_box +from openlp.core.lib.ui import UiStrings, create_save_cancel_button_box class Ui_EditSongDialog(object): def setupUi(self, editSongDialog): @@ -257,19 +257,15 @@ class Ui_EditSongDialog(object): translate('SongsPlugin.EditSongForm', '&Lyrics:')) self.verseOrderLabel.setText( translate('SongsPlugin.EditSongForm', '&Verse order:')) - self.verseAddButton.setText( - translate('SongsPlugin.EditSongForm', '&Add')) - self.verseEditButton.setText( - translate('SongsPlugin.EditSongForm', '&Edit')) + self.verseAddButton.setText(UiStrings.Add) + self.verseEditButton.setText(UiStrings.Edit) self.verseEditAllButton.setText( translate('SongsPlugin.EditSongForm', 'Ed&it All')) - self.verseDeleteButton.setText( - translate('SongsPlugin.EditSongForm', '&Delete')) + self.verseDeleteButton.setText(UiStrings.Delete) self.songTabWidget.setTabText( self.songTabWidget.indexOf(self.lyricsTab), translate('SongsPlugin.EditSongForm', 'Title && Lyrics')) - self.authorsGroupBox.setTitle( - translate('SongsPlugin.EditSongForm', 'Authors')) + self.authorsGroupBox.setTitle(UiStrings.Authors) self.authorAddButton.setText( translate('SongsPlugin.EditSongForm', '&Add to Song')) self.authorRemoveButton.setText( @@ -292,8 +288,7 @@ class Ui_EditSongDialog(object): self.songTabWidget.indexOf(self.authorsTab), translate('SongsPlugin.EditSongForm', 'Authors, Topics && Song Book')) - self.themeGroupBox.setTitle( - translate('SongsPlugin.EditSongForm', 'Theme')) + self.themeGroupBox.setTitle(UiStrings.Theme) self.themeAddButton.setText( translate('SongsPlugin.EditSongForm', 'New &Theme')) self.rightsGroupBox.setTitle( diff --git a/openlp/plugins/songs/forms/songimportform.py b/openlp/plugins/songs/forms/songimportform.py index a9af7f6b2..8cd8c70fa 100644 --- a/openlp/plugins/songs/forms/songimportform.py +++ b/openlp/plugins/songs/forms/songimportform.py @@ -32,7 +32,7 @@ import os from PyQt4 import QtCore, QtGui from openlp.core.lib import Receiver, SettingsManager, translate -from openlp.core.lib.ui import critical_error_message_box +from openlp.core.lib.ui import UiStrings, critical_error_message_box from openlp.core.ui.wizard import OpenLPWizard from openlp.plugins.songs.lib.importer import SongFormat @@ -215,8 +215,7 @@ class SongImportForm(OpenLPWizard): 'Select the import format, and where to import from.')) self.formatLabel.setText( translate('SongsPlugin.ImportWizardForm', 'Format:')) - self.formatComboBox.setItemText(0, - translate('SongsPlugin.ImportWizardForm', 'OpenLP 2.0')) + self.formatComboBox.setItemText(0, UiStrings.OLPV2) self.formatComboBox.setItemText(1, translate('SongsPlugin.ImportWizardForm', 'openlp.org 1.x')) self.formatComboBox.setItemText(2, @@ -489,8 +488,7 @@ class SongImportForm(OpenLPWizard): """ if filters: filters += u';;' - filters += u'%s (*)' % translate('SongsPlugin.ImportWizardForm', - 'All Files') + filters += u'%s (*)' % UiStrings.AllFiles filenames = QtGui.QFileDialog.getOpenFileNames(self, title, SettingsManager.get_last_dir(self.plugin.settingsSection, 1), filters) diff --git a/openlp/plugins/songs/forms/songmaintenancedialog.py b/openlp/plugins/songs/forms/songmaintenancedialog.py index 51fafcc7a..0fa3335dc 100644 --- a/openlp/plugins/songs/forms/songmaintenancedialog.py +++ b/openlp/plugins/songs/forms/songmaintenancedialog.py @@ -27,6 +27,7 @@ from PyQt4 import QtCore, QtGui from openlp.core.lib import build_icon, translate +from openlp.core.lib.ui import UiStrings class Ui_SongMaintenanceDialog(object): def setupUi(self, songMaintenanceDialog): @@ -145,30 +146,21 @@ class Ui_SongMaintenanceDialog(object): def retranslateUi(self, songMaintenanceDialog): songMaintenanceDialog.setWindowTitle( translate('SongsPlugin.SongMaintenanceForm', 'Song Maintenance')) - authorsString = translate('SongsPlugin.SongMaintenanceForm', 'Authors') + authorsString = UiStrings.Authors topicsString = translate('SongsPlugin.SongMaintenanceForm', 'Topics') booksString = translate('SongsPlugin.SongMaintenanceForm', 'Song Books') self.listItemAuthors.setText(authorsString) self.listItemTopics.setText(topicsString) self.listItemBooks.setText(booksString) - self.authorsAddButton.setText( - translate('SongsPlugin.SongMaintenanceForm', '&Add')) - self.authorsEditButton.setText( - translate('SongsPlugin.SongMaintenanceForm', '&Edit')) - self.authorsDeleteButton.setText( - translate('SongsPlugin.SongMaintenanceForm', '&Delete')) - self.topicsAddButton.setText( - translate('SongsPlugin.SongMaintenanceForm', '&Add')) - self.topicsEditButton.setText( - translate('SongsPlugin.SongMaintenanceForm', '&Edit')) - self.topicsDeleteButton.setText( - translate('SongsPlugin.SongMaintenanceForm', '&Delete')) - self.booksAddButton.setText( - translate('SongsPlugin.SongMaintenanceForm', '&Add')) - self.booksEditButton.setText( - translate('SongsPlugin.SongMaintenanceForm', '&Edit')) - self.booksDeleteButton.setText( - translate('SongsPlugin.SongMaintenanceForm', '&Delete')) + self.authorsAddButton.setText(UiStrings.Add) + self.authorsEditButton.setText(UiStrings.Edit) + self.authorsDeleteButton.setText(UiStrings.Delete) + self.topicsAddButton.setText(UiStrings.Add) + self.topicsEditButton.setText(UiStrings.Edit) + self.topicsDeleteButton.setText(UiStrings.Delete) + self.booksAddButton.setText(UiStrings.Add) + self.booksEditButton.setText(UiStrings.Edit) + self.booksDeleteButton.setText(UiStrings.Delete) typeListWidth = max(self.fontMetrics().width(authorsString), self.fontMetrics().width(topicsString), self.fontMetrics().width(booksString)) diff --git a/openlp/plugins/songs/lib/mediaitem.py b/openlp/plugins/songs/lib/mediaitem.py index 66cff169f..312d0d6e7 100644 --- a/openlp/plugins/songs/lib/mediaitem.py +++ b/openlp/plugins/songs/lib/mediaitem.py @@ -33,6 +33,7 @@ from sqlalchemy.sql import or_ from openlp.core.lib import MediaManagerItem, BaseListWithDnD, Receiver, \ ItemCapabilities, translate, check_item_selected, PluginStatus +from openlp.core.lib.ui import UiStrings from openlp.plugins.songs.forms import EditSongForm, SongMaintenanceForm, \ SongImportForm from openlp.plugins.songs.lib import OpenLyrics, SongXML @@ -147,10 +148,8 @@ class SongMediaItem(MediaManagerItem): translate('SongsPlugin.MediaItem', 'Titles')), (3, u':/songs/song_search_lyrics.png', translate('SongsPlugin.MediaItem', 'Lyrics')), - (4, u':/songs/song_search_author.png', - translate('SongsPlugin.MediaItem', 'Authors')), - (5, u':/slides/slide_theme.png', - translate('SongsPlugin.MediaItem', 'Themes')) + (4, u':/songs/song_search_author.png', UiStrings.Authors), + (5, u':/slides/slide_theme.png', UiStrings.Themes) ]) self.configUpdated() diff --git a/openlp/plugins/songs/songsplugin.py b/openlp/plugins/songs/songsplugin.py index 7efe73db2..6b9564af1 100644 --- a/openlp/plugins/songs/songsplugin.py +++ b/openlp/plugins/songs/songsplugin.py @@ -31,6 +31,7 @@ from PyQt4 import QtCore, QtGui from openlp.core.lib import Plugin, StringContent, build_icon, translate from openlp.core.lib.db import Manager +from openlp.core.lib.ui import UiStrings from openlp.plugins.songs.lib import SongMediaItem, SongsTab, SongXML from openlp.plugins.songs.lib.db import init_schema, Song from openlp.plugins.songs.lib.importer import SongFormat @@ -227,37 +228,37 @@ class SongsPlugin(Plugin): # Middle Header Bar ## New Action ## self.textStrings[StringContent.New] = { - u'title': translate('SongsPlugin', 'Add'), + u'title': UiStrings.Add, u'tooltip': translate('SongsPlugin', 'Add a new Song') } ## Edit Action ## self.textStrings[StringContent.Edit] = { - u'title': translate('SongsPlugin', 'Edit'), + u'title': UiStrings.Edit, u'tooltip': translate('SongsPlugin', 'Edit the selected Song') } ## Delete Action ## self.textStrings[StringContent.Delete] = { - u'title': translate('SongsPlugin', 'Delete'), + u'title': UiStrings.Delete, u'tooltip': translate('SongsPlugin', 'Delete the selected Song') } ## Preview Action ## self.textStrings[StringContent.Preview] = { - u'title': translate('SongsPlugin', 'Preview'), + u'title': UiStrings.Preview, u'tooltip': translate('SongsPlugin', 'Preview the selected Song') } ## Send Live Action ## self.textStrings[StringContent.Live] = { - u'title': translate('SongsPlugin', 'Live'), + u'title': UiStrings.Live, u'tooltip': translate('SongsPlugin', 'Send the selected Song live') } ## Add to Service Action ## self.textStrings[StringContent.Service] = { - u'title': translate('SongsPlugin', 'Service'), + u'title': UiStrings.Service, u'tooltip': translate('SongsPlugin', 'Add the selected Song to the service') } From 2ce4aeba9271085f9710b0d1350a6c0b70aff4fc Mon Sep 17 00:00:00 2001 From: Jon Tibble Date: Wed, 9 Feb 2011 14:04:50 +0000 Subject: [PATCH 67/68] Fixes --- openlp/core/lib/ui.py | 2 +- openlp/plugins/presentations/lib/impresscontroller.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/openlp/core/lib/ui.py b/openlp/core/lib/ui.py index 41e88b54b..5d1b722c5 100644 --- a/openlp/core/lib/ui.py +++ b/openlp/core/lib/ui.py @@ -122,7 +122,7 @@ def critical_error_message_box(title=None, message=None, parent=None, Should this message box question the user. """ if question: - return QtGui.QMessageBox.critical(parent, error, message, + return QtGui.QMessageBox.critical(parent, UiStrings.Error, message, QtGui.QMessageBox.StandardButtons( QtGui.QMessageBox.Yes | QtGui.QMessageBox.No)) data = {u'message': message} diff --git a/openlp/plugins/presentations/lib/impresscontroller.py b/openlp/plugins/presentations/lib/impresscontroller.py index 79e7d0ea8..7de095d54 100644 --- a/openlp/plugins/presentations/lib/impresscontroller.py +++ b/openlp/plugins/presentations/lib/impresscontroller.py @@ -429,7 +429,7 @@ class ImpressDocument(PresentationDocument): ``slide_no`` The slide the text is required for, starting at 1 """ - return __get_text_from_slide(slide_no) + return self.__get_text_from_page(slide_no) def get_slide_notes(self, slide_no): """ @@ -438,7 +438,7 @@ class ImpressDocument(PresentationDocument): ``slide_no`` The slide the notes are required for, starting at 1 """ - return __get_text_from_page(slide_no, True) + return self.__get_text_from_page(slide_no, True) def __get_text_from_page(self, slide_no, notes=False): """ From 45f9fa8f2f7b582ed671de2c08b6e077b34f95da Mon Sep 17 00:00:00 2001 From: Jon Tibble Date: Wed, 9 Feb 2011 17:30:38 +0000 Subject: [PATCH 68/68] More translation refactors --- openlp/core/lib/plugin.py | 32 +++++++++++++- openlp/core/lib/ui.py | 14 ++++++ openlp/core/ui/slidecontroller.py | 4 ++ openlp/core/ui/thememanager.py | 12 +++--- openlp/plugins/bibles/bibleplugin.py | 33 +------------- openlp/plugins/custom/customplugin.py | 43 +------------------ openlp/plugins/images/imageplugin.py | 43 +------------------ openlp/plugins/media/mediaplugin.py | 43 +------------------ .../presentations/presentationplugin.py | 31 +------------ openlp/plugins/songs/songsplugin.py | 37 +--------------- 10 files changed, 61 insertions(+), 231 deletions(-) diff --git a/openlp/core/lib/plugin.py b/openlp/core/lib/plugin.py index 476df79b0..cfd3fb4c2 100644 --- a/openlp/core/lib/plugin.py +++ b/openlp/core/lib/plugin.py @@ -31,6 +31,7 @@ import logging from PyQt4 import QtCore from openlp.core.lib import Receiver +from openlp.core.lib.ui import UiStrings log = logging.getLogger(__name__) @@ -323,4 +324,33 @@ class Plugin(QtCore.QObject): """ Called to define all translatable texts of the plugin """ - pass + ## Load Action ## + self._setSingularTextString(StringContent.Load, + UiStrings.Load, UiStrings.LoadANew) + ## New Action ## + self._setSingularTextString(StringContent.New, + UiStrings.Add, UiStrings.AddANew) + ## Edit Action ## + self._setSingularTextString(StringContent.Edit, + UiStrings.Edit, UiStrings.EditSelect) + ## Delete Action ## + self._setSingularTextString(StringContent.Delete, + UiStrings.Delete, UiStrings.DeleteSelect) + ## Preview Action ## + self._setSingularTextString(StringContent.Preview, + UiStrings.Preview, UiStrings.PreviewSelect) + ## Send Live Action ## + self._setSingularTextString(StringContent.Live, + UiStrings.Live, UiStrings.SendSelectLive) + ## Add to Service Action ## + self._setSingularTextString(StringContent.Service, + UiStrings.Service, UiStrings.AddSelectService) + + def _setSingularTextString(self, name, title, tooltip): + """ + Utility method for creating a plugin's textStrings. This method makes + use of the singular name of the plugin object so must only be called + after this has been set. + """ + self.textStrings[name] = { u'title': title, u'tooltip': tooltip % + self.getString(StringContent.Name)[u'singular']} diff --git a/openlp/core/lib/ui.py b/openlp/core/lib/ui.py index 5d1b722c5..ec1c324fe 100644 --- a/openlp/core/lib/ui.py +++ b/openlp/core/lib/ui.py @@ -41,17 +41,31 @@ class UiStrings(object): # These strings should need a good reason to be retranslated elsewhere. # Should some/more/less of these have an & attached? Add = translate('OpenLP.Ui', '&Add') + AddANew = unicode(translate('OpenLP.Ui', 'Add a new %s')) + AddSelectService = unicode(translate('OpenLP.Ui', + 'Add the selected %s to the service')) AllFiles = translate('OpenLP.Ui', 'All Files') Authors = translate('OpenLP.Ui', 'Authors') Delete = translate('OpenLP.Ui', '&Delete') + DeleteSelect = unicode(translate('OpenLP.Ui', 'Delete the selected %s')) + DeleteType = unicode(translate('OpenLP.Ui', 'Delete %s')) Edit = translate('OpenLP.Ui', '&Edit') + EditSelect = unicode(translate('OpenLP.Ui', 'Edit the selected %s')) + EditType = unicode(translate('OpenLP.Ui', 'Edit %s')) Error = translate('OpenLP.Ui', 'Error') + ExportType = unicode(translate('OpenLP.Ui', 'Export %s')) Import = translate('OpenLP.Ui', 'Import') + ImportType = unicode(translate('OpenLP.Ui', 'Import %s')) Live = translate('OpenLP.Ui', 'Live') Load = translate('OpenLP.Ui', 'Load') + LoadANew = unicode(translate('OpenLP.Ui', 'Load a new %s')) New = translate('OpenLP.Ui', 'New') + NewType = unicode(translate('OpenLP.Ui', 'New %s')) OLPV2 = translate('OpenLP.Ui', 'OpenLP 2.0') Preview = translate('OpenLP.Ui', 'Preview') + PreviewSelect = unicode(translate('OpenLP.Ui', 'Preview the selected %s')) + SendSelectLive = unicode(translate('OpenLP.Ui', + 'Send the selected %s live')) Service = translate('OpenLP.Ui', 'Service') Theme = translate('OpenLP.Ui', 'Theme') Themes = translate('OpenLP.Ui', 'Themes') diff --git a/openlp/core/ui/slidecontroller.py b/openlp/core/ui/slidecontroller.py index 1caf43dfd..c6b58ac56 100644 --- a/openlp/core/ui/slidecontroller.py +++ b/openlp/core/ui/slidecontroller.py @@ -178,10 +178,12 @@ class SlideController(QtGui.QWidget): QtCore.SIGNAL(u'triggered(bool)'), self.onHideDisplay) self.toolbar.addToolbarSeparator(u'Loop Separator') self.toolbar.addToolbarButton( + # Does not need translating - control string. u'Start Loop', u':/media/media_time.png', translate('OpenLP.SlideController', 'Start continuous loop'), self.onStartLoop) self.toolbar.addToolbarButton( + # Does not need translating - control string. u'Stop Loop', u':/media/media_stop.png', translate('OpenLP.SlideController', 'Stop continuous loop'), self.onStopLoop) @@ -196,11 +198,13 @@ class SlideController(QtGui.QWidget): else: self.toolbar.addToolbarSeparator(u'Close Separator') self.toolbar.addToolbarButton( + # Does not need translating - control string. u'Go Live', u':/general/general_live.png', translate('OpenLP.SlideController', 'Move to live'), self.onGoLive) self.toolbar.addToolbarSeparator(u'Close Separator') self.toolbar.addToolbarButton( + # Does not need translating - control string. u'Edit Song', u':/general/general_edit.png', translate('OpenLP.SlideController', 'Edit and reload song preview'), diff --git a/openlp/core/ui/thememanager.py b/openlp/core/ui/thememanager.py index 317065c6e..93a5ef187 100644 --- a/openlp/core/ui/thememanager.py +++ b/openlp/core/ui/thememanager.py @@ -35,7 +35,7 @@ from PyQt4 import QtCore, QtGui from openlp.core.lib import OpenLPToolbar, ThemeXML, get_text_file_string, \ build_icon, Receiver, SettingsManager, translate, check_item_selected, \ BackgroundType, BackgroundGradientType, check_directory_exists -from openlp.core.lib.ui import critical_error_message_box +from openlp.core.lib.ui import UiStrings, critical_error_message_box from openlp.core.theme import Theme from openlp.core.ui import FileRenameForm, ThemeForm from openlp.core.utils import AppLocation, delete_file, file_is_unicode, \ @@ -62,28 +62,28 @@ class ThemeManager(QtGui.QWidget): self.layout.setObjectName(u'layout') self.toolbar = OpenLPToolbar(self) self.toolbar.addToolbarButton( - translate('OpenLP.ThemeManager', 'New Theme'), + UiStrings.NewType % UiStrings.Theme, u':/themes/theme_new.png', translate('OpenLP.ThemeManager', 'Create a new theme.'), self.onAddTheme) self.toolbar.addToolbarButton( - translate('OpenLP.ThemeManager', 'Edit Theme'), + UiStrings.EditType % UiStrings.Theme, u':/themes/theme_edit.png', translate('OpenLP.ThemeManager', 'Edit a theme.'), self.onEditTheme) self.deleteToolbarAction = self.toolbar.addToolbarButton( - translate('OpenLP.ThemeManager', 'Delete Theme'), + UiStrings.DeleteType % UiStrings.Theme, u':/general/general_delete.png', translate('OpenLP.ThemeManager', 'Delete a theme.'), self.onDeleteTheme) self.toolbar.addSeparator() self.toolbar.addToolbarButton( - translate('OpenLP.ThemeManager', 'Import Theme'), + UiStrings.ImportType % UiStrings.Theme, u':/general/general_import.png', translate('OpenLP.ThemeManager', 'Import a theme.'), self.onImportTheme) self.toolbar.addToolbarButton( - translate('OpenLP.ThemeManager', 'Export Theme'), + UiStrings.ExportType % UiStrings.Theme, u':/general/general_export.png', translate('OpenLP.ThemeManager', 'Export a theme.'), self.onExportTheme) diff --git a/openlp/plugins/bibles/bibleplugin.py b/openlp/plugins/bibles/bibleplugin.py index e1dadd4bf..89102a8eb 100644 --- a/openlp/plugins/bibles/bibleplugin.py +++ b/openlp/plugins/bibles/bibleplugin.py @@ -141,35 +141,4 @@ class BiblePlugin(Plugin): u'title': UiStrings.Import, u'tooltip': translate('BiblesPlugin', 'Import a Bible') } - ## New Action ## - self.textStrings[StringContent.New] = { - u'title': UiStrings.Add, - u'tooltip': translate('BiblesPlugin', 'Add a new Bible') - } - ## Edit Action ## - self.textStrings[StringContent.Edit] = { - u'title': UiStrings.Edit, - u'tooltip': translate('BiblesPlugin', 'Edit the selected Bible') - } - ## Delete Action ## - self.textStrings[StringContent.Delete] = { - u'title': UiStrings.Delete, - u'tooltip': translate('BiblesPlugin', 'Delete the selected Bible') - } - ## Preview Action ## - self.textStrings[StringContent.Preview] = { - u'title': UiStrings.Preview, - u'tooltip': translate('BiblesPlugin', 'Preview the selected Bible') - } - ## Send Live Action ## - self.textStrings[StringContent.Live] = { - u'title': UiStrings.Live, - u'tooltip': translate('BiblesPlugin', - 'Send the selected Bible live') - } - ## Add to Service Action ## - self.textStrings[StringContent.Service] = { - u'title': UiStrings.Service, - u'tooltip': translate('BiblesPlugin', - 'Add the selected Bible to the service') - } + Plugin.setPluginTextStrings(self) diff --git a/openlp/plugins/custom/customplugin.py b/openlp/plugins/custom/customplugin.py index 210556ad8..f20fbc9cd 100644 --- a/openlp/plugins/custom/customplugin.py +++ b/openlp/plugins/custom/customplugin.py @@ -119,48 +119,7 @@ class CustomPlugin(Plugin): u'tooltip': translate('CustomsPlugin', 'Import a Custom') } - ## Load Action ## - self.textStrings[StringContent.Load] = { - u'title': UiStrings.Load, - u'tooltip': translate('CustomsPlugin', - 'Load a new Custom') - } - ## New Action ## - self.textStrings[StringContent.New] = { - u'title': UiStrings.Add, - u'tooltip': translate('CustomsPlugin', - 'Add a new Custom') - } - ## Edit Action ## - self.textStrings[StringContent.Edit] = { - u'title': UiStrings.Edit, - u'tooltip': translate('CustomsPlugin', - 'Edit the selected Custom') - } - ## Delete Action ## - self.textStrings[StringContent.Delete] = { - u'title': UiStrings.Delete, - u'tooltip': translate('CustomsPlugin', - 'Delete the selected Custom') - } - ## Preview Action ## - self.textStrings[StringContent.Preview] = { - u'title': UiStrings.Preview, - u'tooltip': translate('CustomsPlugin', - 'Preview the selected Custom') - } - ## Send Live Action ## - self.textStrings[StringContent.Live] = { - u'title': UiStrings.Live, - u'tooltip': translate('CustomsPlugin', - 'Send the selected Custom live') - } - ## Add to Service Action ## - self.textStrings[StringContent.Service] = { - u'title': UiStrings.Service, - u'tooltip': translate('CustomsPlugin', - 'Add the selected Custom to the service') - } + Plugin.setPluginTextStrings(self) def finalise(self): """ diff --git a/openlp/plugins/images/imageplugin.py b/openlp/plugins/images/imageplugin.py index 0af48bacd..51ef20960 100644 --- a/openlp/plugins/images/imageplugin.py +++ b/openlp/plugins/images/imageplugin.py @@ -73,45 +73,4 @@ class ImagePlugin(Plugin): u'title': translate('ImagePlugin', 'Images', 'container title') } # Middle Header Bar - ## Load Button ## - self.textStrings[StringContent.Load] = { - u'title': UiStrings.Load, - u'tooltip': translate('ImagePlugin', - 'Load a new Image') - } - ## New Button ## - self.textStrings[StringContent.New] = { - u'title': UiStrings.Add, - u'tooltip': translate('ImagePlugin', - 'Add a new Image') - } - ## Edit Button ## - self.textStrings[StringContent.Edit] = { - u'title': UiStrings.Edit, - u'tooltip': translate('ImagePlugin', - 'Edit the selected Image') - } - ## Delete Button ## - self.textStrings[StringContent.Delete] = { - u'title': UiStrings.Delete, - u'tooltip': translate('ImagePlugin', - 'Delete the selected Image') - } - ## Preview ## - self.textStrings[StringContent.Preview] = { - u'title': UiStrings.Preview, - u'tooltip': translate('ImagePlugin', - 'Preview the selected Image') - } - ## Live Button ## - self.textStrings[StringContent.Live] = { - u'title': UiStrings.Live, - u'tooltip': translate('ImagePlugin', - 'Send the selected Image live') - } - ## Add to service Button ## - self.textStrings[StringContent.Service] = { - u'title': UiStrings.Service, - u'tooltip': translate('ImagePlugin', - 'Add the selected Image to the service') - } + Plugin.setPluginTextStrings(self) diff --git a/openlp/plugins/media/mediaplugin.py b/openlp/plugins/media/mediaplugin.py index 42dcc321c..1619a07fe 100644 --- a/openlp/plugins/media/mediaplugin.py +++ b/openlp/plugins/media/mediaplugin.py @@ -102,45 +102,4 @@ class MediaPlugin(Plugin): u'title': translate('MediaPlugin', 'Media', 'container title') } # Middle Header Bar - ## Load Action ## - self.textStrings[StringContent.Load] = { - u'title': UiStrings.Load, - u'tooltip': translate('MediaPlugin', - 'Load a new Media') - } - ## New Action ## - self.textStrings[StringContent.New] = { - u'title': UiStrings.Add, - u'tooltip': translate('MediaPlugin', - 'Add a new Media') - } - ## Edit Action ## - self.textStrings[StringContent.Edit] = { - u'title': UiStrings.Edit, - u'tooltip': translate('MediaPlugin', - 'Edit the selected Media') - } - ## Delete Action ## - self.textStrings[StringContent.Delete] = { - u'title': UiStrings.Delete, - u'tooltip': translate('MediaPlugin', - 'Delete the selected Media') - } - ## Preview Action ## - self.textStrings[StringContent.Preview] = { - u'title': UiStrings.Preview, - u'tooltip': translate('MediaPlugin', - 'Preview the selected Media') - } - ## Send Live Action ## - self.textStrings[StringContent.Live] = { - u'title': UiStrings.Live, - u'tooltip': translate('MediaPlugin', - 'Send the selected Media live') - } - ## Add to Service Action ## - self.textStrings[StringContent.Service] = { - u'title': UiStrings.Service, - u'tooltip': translate('MediaPlugin', - 'Add the selected Media to the service') - } + Plugin.setPluginTextStrings(self) diff --git a/openlp/plugins/presentations/presentationplugin.py b/openlp/plugins/presentations/presentationplugin.py index 213ff2927..c4cf29aca 100644 --- a/openlp/plugins/presentations/presentationplugin.py +++ b/openlp/plugins/presentations/presentationplugin.py @@ -168,33 +168,4 @@ class PresentationPlugin(Plugin): 'container title') } # Middle Header Bar - ## Load Action ## - self.textStrings[StringContent.Load] = { - u'title': UiStrings.Load, - u'tooltip': translate('PresentationPlugin', - 'Load a new Presentation') - } - ## Delete Action ## - self.textStrings[StringContent.Delete] = { - u'title': UiStrings.Delete, - u'tooltip': translate('PresentationPlugin', - 'Delete the selected Presentation') - } - ## Preview Action ## - self.textStrings[StringContent.Preview] = { - u'title': UiStrings.Preview, - u'tooltip': translate('PresentationPlugin', - 'Preview the selected Presentation') - } - ## Send Live Action ## - self.textStrings[StringContent.Live] = { - u'title': UiStrings.Live, - u'tooltip': translate('PresentationPlugin', - 'Send the selected Presentation live') - } - ## Add to Service Action ## - self.textStrings[StringContent.Service] = { - u'title': UiStrings.Service, - u'tooltip': translate('PresentationPlugin', - 'Add the selected Presentation to the service') - } + Plugin.setPluginTextStrings(self) diff --git a/openlp/plugins/songs/songsplugin.py b/openlp/plugins/songs/songsplugin.py index 6b9564af1..74991fe37 100644 --- a/openlp/plugins/songs/songsplugin.py +++ b/openlp/plugins/songs/songsplugin.py @@ -226,42 +226,7 @@ class SongsPlugin(Plugin): u'title': translate('SongsPlugin', 'Songs', 'container title') } # Middle Header Bar - ## New Action ## - self.textStrings[StringContent.New] = { - u'title': UiStrings.Add, - u'tooltip': translate('SongsPlugin', - 'Add a new Song') - } - ## Edit Action ## - self.textStrings[StringContent.Edit] = { - u'title': UiStrings.Edit, - u'tooltip': translate('SongsPlugin', - 'Edit the selected Song') - } - ## Delete Action ## - self.textStrings[StringContent.Delete] = { - u'title': UiStrings.Delete, - u'tooltip': translate('SongsPlugin', - 'Delete the selected Song') - } - ## Preview Action ## - self.textStrings[StringContent.Preview] = { - u'title': UiStrings.Preview, - u'tooltip': translate('SongsPlugin', - 'Preview the selected Song') - } - ## Send Live Action ## - self.textStrings[StringContent.Live] = { - u'title': UiStrings.Live, - u'tooltip': translate('SongsPlugin', - 'Send the selected Song live') - } - ## Add to Service Action ## - self.textStrings[StringContent.Service] = { - u'title': UiStrings.Service, - u'tooltip': translate('SongsPlugin', - 'Add the selected Song to the service') - } + Plugin.setPluginTextStrings(self) def finalise(self): """