From baf18ea1c7efca013c4df8dcd384496f54e17ae5 Mon Sep 17 00:00:00 2001 From: Jon Tibble Date: Sat, 5 Feb 2011 01:24:19 +0000 Subject: [PATCH] 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)