- reorganisation of methods in openlp.core.lib.ui to make them more comprehensive

- some small restatements of some code in bibles parse_reference() method
This commit is contained in:
M2j 2012-04-01 23:19:56 +02:00
parent dbfeb49572
commit d7ab06cc7e
24 changed files with 230 additions and 200 deletions

View File

@ -170,31 +170,42 @@ def add_welcome_page(parent, image):
parent.welcomeLayout.addStretch()
parent.addPage(parent.welcomePage)
def create_accept_reject_button_box(parent, okay=False):
def create_button_box(dialog, standard_buttons, custom_buttons=[]):
"""
Creates a standard dialog button box with two buttons. The buttons default
to save and cancel but the ``okay`` parameter can be used to make the
buttons okay and cancel instead.
The button box is connected to the parent's ``accept()`` and ``reject()``
methods to handle the default ``accepted()`` and ``rejected()`` signals.
Creates a QDialogButtonBox with the given buttons. The ``accepted()`` and
``rejected()`` signals of the button box are connected with the dialogs
``accept()`` and ``reject()`` slots.
``parent``
The parent object. This should be a ``QWidget`` descendant.
``dialog``
The parent object. This has to be a ``QDialog`` descendant.
``okay``
If true creates an okay/cancel combination instead of save/cancel.
``standard_buttons``
A list of strings for the used buttons. It might contain: ``ok``,
``save``, and ``cancel``.
``custom_buttons``
A list of additional buttons. If a item is a instance of
QtGui.QAbstractButton it is added with QDialogButtonBox.ActionRole.
Otherwhise the item has to be a tuple of a button and a ButtonRole.
"""
button_box = QtGui.QDialogButtonBox(parent)
accept_button = QtGui.QDialogButtonBox.Save
if okay:
accept_button = QtGui.QDialogButtonBox.Ok
button_box.setStandardButtons(
accept_button | QtGui.QDialogButtonBox.Cancel)
button_box.setObjectName(u'%sButtonBox' % parent)
buttons = QtGui.QDialogButtonBox.NoButton
if u'ok' in standard_buttons:
buttons |= QtGui.QDialogButtonBox.Ok
if u'save' in standard_buttons:
buttons |= QtGui.QDialogButtonBox.Save
if u'cancel' in standard_buttons:
buttons |= QtGui.QDialogButtonBox.Cancel
button_box = QtGui.QDialogButtonBox(dialog)
button_box.setStandardButtons(buttons)
for button in custom_buttons:
if isinstance(button, QtGui.QAbstractButton):
button_box.addButton(button, QtGui.QDialogButtonBox.ActionRole)
else:
button_box.addButton(*button)
QtCore.QObject.connect(button_box, QtCore.SIGNAL(u'accepted()'),
parent.accept)
dialog.accept)
QtCore.QObject.connect(button_box, QtCore.SIGNAL(u'rejected()'),
parent.reject)
dialog.reject)
return button_box
def critical_error_message_box(title=None, message=None, parent=None,
@ -223,9 +234,15 @@ def critical_error_message_box(title=None, message=None, parent=None,
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):
def create_horizontal_adjusting_combo_box(parent, name):
"""
Provide a standard combo box for media items.
Creates a QComboBox with adapting width for media items.
``parent``
The parent widget.
``name``
A string set as object name for the combo box.
"""
combo = QtGui.QComboBox(parent)
combo.setObjectName(name)
@ -233,55 +250,71 @@ def media_item_combo_box(parent, name):
combo.setSizePolicy(QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Fixed)
return combo
def create_delete_push_button(parent, icon=None):
def create_button(parent, name, **kwargs):
"""
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.
Return an button with the object name set and the given parameters.
``parent``
The parent object. This should be a ``QWidget`` descendant.
A QtCore.QWidget for the buttons parent (required).
``name``
A string which is set as object name (required).
``role``
A string which can have one value out of ``delete``, ``up``, and
``down``. This decides about default values for properties like text,
icon, or tooltip.
``text``
A string for the action text.
``icon``
An icon to display on the button. This can be either a ``QIcon``, a
resource path or a file name.
Either a QIcon, a resource string, or a file location string for the
action icon.
``tooltip``
A string for the action tool tip.
``enabled``
False in case the button should be disabled.
"""
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(UiStrings().Delete)
delete_button.setToolTip(
if u'role' in kwargs:
role = kwargs.pop(u'role')
if role == u'delete':
kwargs.setdefault(u'text', UiStrings().Delete)
kwargs.setdefault(u'tooltip',
translate('OpenLP.Ui', 'Delete the selected item.'))
QtCore.QObject.connect(delete_button,
QtCore.SIGNAL(u'clicked()'), parent.onDeleteButtonClicked)
return delete_button
def create_up_down_push_button_set(parent):
"""
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'))
up_button.setObjectName(u'upButton')
up_button.setToolTip(
elif role == u'up':
kwargs.setdefault(u'icon', u':/services/service_up.png')
kwargs.setdefault(u'tooltip',
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(
elif role == u'down':
kwargs.setdefault(u'icon', u':/services/service_down.png')
kwargs.setdefault(u'tooltip',
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
else:
log.warn(u'The role "%s" is not defined increate_push_button().',
role)
if kwargs.pop(u'class', u'') == u'toolbutton':
button = QtGui.QToolButton(parent)
else:
button = QtGui.QPushButton(parent)
button.setObjectName(name)
if kwargs.get(u'text'):
button.setText(kwargs.pop(u'text'))
if kwargs.get(u'icon'):
button.setIcon(build_icon(kwargs.pop(u'icon')))
if kwargs.get(u'tooltip'):
button.setToolTip(kwargs.pop(u'tooltip'))
if not kwargs.pop(u'enabled', True):
button.setEnabled(False)
if kwargs.get(u'click'):
QtCore.QObject.connect(button, QtCore.SIGNAL(u'clicked()'),
kwargs.pop(u'click'))
for key in kwargs.keys():
if key not in [u'text', u'icon', u'tooltip', u'click']:
log.warn(u'Parameter %s was not consumed in create_button().', key)
return button
def create_action(parent, name, **kwargs):
"""
@ -381,61 +414,38 @@ def create_widget_action(parent, name=u'', **kwargs):
parent.addAction(action)
return action
def context_menu(base, icon, text):
def set_case_insensitive_completer(cache, widget):
"""
Utility method to help build context menus.
``base``
The parent object to add this menu to
``icon``
An icon for this menu
``text``
The text to display for this menu
"""
action = QtGui.QMenu(text, base)
action.setIcon(build_icon(icon))
return action
def add_widget_completer(cache, widget):
"""
Adds a text autocompleter to a widget.
Sets a case insensitive text completer for a widget.
``cache``
The list of items to use as suggestions.
``widget``
The object to use the completer.
A widget to set the completer (QComboBox or QTextEdit instance)
"""
completer = QtGui.QCompleter(cache)
completer.setCaseSensitivity(QtCore.Qt.CaseInsensitive)
widget.setCompleter(completer)
def create_valign_combo(form, parent, layout):
def create_valign_selection_widgets(parent):
"""
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.
``layout``
A layout object to add the label and combo widgets to.
Returns a tuple of QLabel and QComboBox.
"""
verticalLabel = QtGui.QLabel(parent)
verticalLabel.setObjectName(u'VerticalLabel')
verticalLabel.setText(translate('OpenLP.Ui', '&Vertical Align:'))
form.verticalComboBox = QtGui.QComboBox(parent)
form.verticalComboBox.setObjectName(u'VerticalComboBox')
form.verticalComboBox.addItem(UiStrings().Top)
form.verticalComboBox.addItem(UiStrings().Middle)
form.verticalComboBox.addItem(UiStrings().Bottom)
verticalLabel.setBuddy(form.verticalComboBox)
layout.addRow(verticalLabel, form.verticalComboBox)
label = QtGui.QLabel(parent)
label.setText(translate('OpenLP.Ui', '&Vertical Align:'))
combo_box = QtGui.QComboBox(parent)
combo_box.addItem(UiStrings().Top)
combo_box.addItem(UiStrings().Middle)
combo_box.addItem(UiStrings().Bottom)
label.setBuddy(combo_box)
return label, combo_box
def find_and_set_in_combo_box(combo_box, value_to_find):
"""

View File

@ -28,7 +28,7 @@
from PyQt4 import QtCore, QtGui
from openlp.core.lib import translate
from openlp.core.lib.ui import create_accept_reject_button_box
from openlp.core.lib.ui import create_button_box
class Ui_FileRenameDialog(object):
def setupUi(self, fileRenameDialog):
@ -44,7 +44,8 @@ class Ui_FileRenameDialog(object):
QtCore.QRegExp(r'[^/\\?*|<>\[\]":+%]+'), self))
self.fileNameEdit.setObjectName(u'fileNameEdit')
self.dialogLayout.addWidget(self.fileNameEdit, 0, 1)
self.buttonBox = create_accept_reject_button_box(fileRenameDialog, True)
self.buttonBox = create_button_box(fileRenameDialog, [u'cancel', u'ok'])
self.buttonBox.setObjectName(u'buttonBox')
self.dialogLayout.addWidget(self.buttonBox, 1, 0, 1, 2)
self.retranslateUi(fileRenameDialog)
self.setMaximumHeight(self.sizeHint().height())

View File

@ -28,7 +28,7 @@
from PyQt4 import QtCore, QtGui
from openlp.core.lib import translate
from openlp.core.lib.ui import create_accept_reject_button_box
from openlp.core.lib.ui import create_button_box
class Ui_FirstTimeLanguageDialog(object):
def setupUi(self, languageDialog):
@ -52,7 +52,8 @@ class Ui_FirstTimeLanguageDialog(object):
self.languageComboBox.setObjectName("languageComboBox")
self.languageLayout.addWidget(self.languageComboBox)
self.dialogLayout.addLayout(self.languageLayout)
self.buttonBox = create_accept_reject_button_box(languageDialog, True)
self.buttonBox = create_button_box(languageDialog, [u'cancel', u'ok'])
self.buttonBox.setObjectName(u'buttonBox')
self.dialogLayout.addWidget(self.buttonBox)
self.retranslateUi(languageDialog)

View File

@ -28,8 +28,7 @@
from PyQt4 import QtCore, QtGui
from openlp.core.lib import translate
from openlp.core.lib.ui import create_accept_reject_button_box, \
create_delete_push_button, create_up_down_push_button_set
from openlp.core.lib.ui import create_button_box, create_button
class Ui_ServiceItemEditDialog(object):
def setupUi(self, serviceItemEditDialog):
@ -44,16 +43,22 @@ class Ui_ServiceItemEditDialog(object):
self.dialogLayout.addWidget(self.listWidget, 0, 0)
self.buttonLayout = QtGui.QVBoxLayout()
self.buttonLayout.setObjectName(u'buttonLayout')
self.deleteButton = create_delete_push_button(serviceItemEditDialog)
self.deleteButton = create_button(serviceItemEditDialog,
u'deleteButton', role=u'delete',
click=serviceItemEditDialog.onDeleteButtonClicked)
self.buttonLayout.addWidget(self.deleteButton)
self.buttonLayout.addStretch()
self.upButton, self.downButton = create_up_down_push_button_set(
serviceItemEditDialog)
self.upButton = create_button(serviceItemEditDialog, u'upButton',
role=u'up', click=serviceItemEditDialog.onUpButtonClicked)
self.downButton = create_button(serviceItemEditDialog, u'downButton',
role=u'down', click=serviceItemEditDialog.onDownButtonClicked)
self.buttonLayout.addWidget(self.upButton)
self.buttonLayout.addWidget(self.downButton)
self.dialogLayout.addLayout(self.buttonLayout, 0, 1)
self.dialogLayout.addWidget(
create_accept_reject_button_box(serviceItemEditDialog), 1, 0, 1, 2)
self.buttonBox = create_button_box(serviceItemEditDialog,
[u'cancel', u'save'])
self.buttonBox.setObjectName(u'buttonBox')
self.dialogLayout.addWidget(self.buttonBox , 1, 0, 1, 2)
self.retranslateUi(serviceItemEditDialog)
QtCore.QMetaObject.connectSlotsByName(serviceItemEditDialog)

View File

@ -28,7 +28,7 @@
from PyQt4 import QtCore, QtGui
from openlp.core.lib import translate, SpellTextEdit
from openlp.core.lib.ui import create_accept_reject_button_box
from openlp.core.lib.ui import create_button_box
class ServiceNoteForm(QtGui.QDialog):
"""
@ -55,7 +55,9 @@ class ServiceNoteForm(QtGui.QDialog):
self.textEdit = SpellTextEdit(self, False)
self.textEdit.setObjectName(u'textEdit')
self.dialogLayout.addWidget(self.textEdit)
self.dialogLayout.addWidget(create_accept_reject_button_box(self))
self.buttonBox = create_button_box(self, [u'cancel', u'save'])
self.buttonBox.setObjectName(u'buttonBox')
self.dialogLayout.addWidget(self.buttonBox)
QtCore.QMetaObject.connectSlotsByName(self)
def retranslateUi(self):

View File

@ -28,7 +28,7 @@
from PyQt4 import QtCore, QtGui
from openlp.core.lib import translate, build_icon
from openlp.core.lib.ui import create_accept_reject_button_box
from openlp.core.lib.ui import create_button_box
class Ui_SettingsDialog(object):
def setupUi(self, settingsDialog):
@ -49,7 +49,8 @@ class Ui_SettingsDialog(object):
self.stackedLayout = QtGui.QStackedLayout()
self.stackedLayout.setObjectName(u'stackedLayout')
self.dialogLayout.addLayout(self.stackedLayout, 0, 1, 1, 1)
self.buttonBox = create_accept_reject_button_box(settingsDialog, True)
self.buttonBox = create_button_box(settingsDialog, [u'cancel', u'ok'])
self.buttonBox.setObjectName(u'buttonBox')
self.dialogLayout.addWidget(self.buttonBox, 1, 1, 1, 1)
self.retranslateUi(settingsDialog)
QtCore.QMetaObject.connectSlotsByName(settingsDialog)

View File

@ -28,7 +28,7 @@
from PyQt4 import QtCore, QtGui
from openlp.core.lib import translate
from openlp.core.lib.ui import UiStrings, create_accept_reject_button_box
from openlp.core.lib.ui import UiStrings, create_button_box
class Ui_StartTimeDialog(object):
def setupUi(self, StartTimeDialog):
@ -99,7 +99,8 @@ class Ui_StartTimeDialog(object):
self.secondFinishLabel.setAlignment(QtCore.Qt.AlignRight)
self.dialogLayout.addWidget(self.secondFinishLabel, 3, 3, 1, 1)
self.dialogLayout.addWidget(self.secondSpinBox, 3, 1, 1, 1)
self.buttonBox = create_accept_reject_button_box(StartTimeDialog, True)
self.buttonBox = create_button_box(StartTimeDialog, [u'cancel', u'ok'])
self.buttonBox.setObjectName(u'buttonBox')
self.dialogLayout.addWidget(self.buttonBox, 5, 2, 1, 2)
self.retranslateUi(StartTimeDialog)
self.setMaximumHeight(self.sizeHint().height())

View File

@ -30,7 +30,8 @@ from PyQt4 import QtCore, QtGui
from openlp.core.lib import translate, build_icon
from openlp.core.lib.theme import HorizontalType, BackgroundType, \
BackgroundGradientType
from openlp.core.lib.ui import UiStrings, add_welcome_page, create_valign_combo
from openlp.core.lib.ui import UiStrings, add_welcome_page, \
create_valign_selection_widgets
class Ui_ThemeWizard(object):
def setupUi(self, themeWizard):
@ -257,8 +258,11 @@ class Ui_ThemeWizard(object):
self.horizontalComboBox.setObjectName(u'HorizontalComboBox')
self.alignmentLayout.addRow(self.horizontalLabel,
self.horizontalComboBox)
create_valign_combo(themeWizard, self.alignmentPage,
self.alignmentLayout)
self.verticalLabel, self.verticalComboBox = \
create_valign_selection_widgets(self.alignmentPage)
self.verticalLabel.setObjectName(u'verticalLabel')
self.verticalComboBox.setObjectName(u'verticalComboBox')
self.alignmentLayout.addRow(self.verticalLabel, self.verticalComboBox)
self.transitionsLabel = QtGui.QLabel(self.alignmentPage)
self.transitionsLabel.setObjectName(u'TransitionsLabel')
self.transitionsCheckBox = QtGui.QCheckBox(self.alignmentPage)

View File

@ -28,7 +28,7 @@
from PyQt4 import QtCore, QtGui
from openlp.core.lib import build_icon, translate
from openlp.core.lib.ui import create_delete_push_button
from openlp.core.lib.ui import create_button
class Ui_AlertDialog(object):
def setupUi(self, alertDialog):
@ -67,7 +67,8 @@ 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 = create_delete_push_button(alertDialog)
self.deleteButton = create_button(alertDialog, u'deleteButton',
role=u'delete', click=alertDialog.onDeleteButtonClicked)
self.deleteButton.setEnabled(False)
self.manageButtonLayout.addWidget(self.deleteButton)
self.manageButtonLayout.addStretch()

View File

@ -29,7 +29,7 @@ from PyQt4 import QtCore, QtGui
from openlp.core.lib import SettingsTab, translate, Receiver
from openlp.core.ui import AlertLocation
from openlp.core.lib.ui import UiStrings, create_valign_combo
from openlp.core.lib.ui import UiStrings, create_valign_selection_widgets
class AlertsTab(SettingsTab):
"""
@ -76,7 +76,11 @@ class AlertsTab(SettingsTab):
self.timeoutSpinBox.setMaximum(180)
self.timeoutSpinBox.setObjectName(u'timeoutSpinBox')
self.fontLayout.addRow(self.timeoutLabel, self.timeoutSpinBox)
create_valign_combo(self, self.fontGroupBox, self.fontLayout)
self.verticalLabel, self.verticalComboBox = \
create_valign_selection_widgets(self.fontGroupBox)
self.verticalLabel.setObjectName(u'verticalLabel')
self.verticalComboBox.setObjectName(u'verticalComboBox')
self.fontLayout.addRow(self.verticalLabel, self.verticalComboBox)
self.leftLayout.addWidget(self.fontGroupBox)
self.leftLayout.addStretch()
self.previewGroupBox = QtGui.QGroupBox(self.rightColumn)

View File

@ -368,17 +368,9 @@ def parse_reference(reference, bible, language_selection, book_ref_id=False):
if db_book:
book_ref_id = db_book.book_reference_id
elif language_selection == LanguageSelection.Application:
book_list = []
for key, value in booknames.iteritems():
if regex_book.match(unicode(value)):
book_list.append(key)
books = []
if book_list:
for value in book_list:
item = BiblesResourcesDB.get_book(value)
if item:
books.append(item)
if books:
books = filter(lambda key:
regex_book.match(unicode(booknames[key])), booknames.keys())
books = filter(None, map(BiblesResourcesDB.get_book, books))
for value in books:
if bible.get_book_by_book_ref_id(value[u'id']):
book_ref_id = value[u'id']
@ -386,18 +378,15 @@ def parse_reference(reference, bible, language_selection, book_ref_id=False):
elif language_selection == LanguageSelection.English:
books = BiblesResourcesDB.get_books_like(book)
if books:
book_list = []
for value in books:
if regex_book.match(value[u'name']):
book_list.append(value)
book_list = filter(
lambda value: regex_book.match(value[u'name']), books)
if not book_list:
book_list = books
for value in book_list:
if bible.get_book_by_book_ref_id(value[u'id']):
book_ref_id = value[u'id']
break
else:
if not bible.get_book_by_book_ref_id(book_ref_id):
elif bible.get_book_by_book_ref_id(book_ref_id):
book_ref_id = False
ranges = match.group(u'ranges')
range_list = get_reference_match(u'range_separator').split(ranges)

View File

@ -33,8 +33,8 @@ from PyQt4 import QtCore, QtGui
from openlp.core.lib import MediaManagerItem, Receiver, ItemCapabilities, \
translate, create_separated_list
from openlp.core.lib.searchedit import SearchEdit
from openlp.core.lib.ui import UiStrings, add_widget_completer, \
media_item_combo_box, critical_error_message_box, \
from openlp.core.lib.ui import UiStrings, set_case_insensitive_completer, \
create_horizontal_adjusting_combo_box, critical_error_message_box, \
find_and_set_in_combo_box, build_icon
from openlp.plugins.bibles.forms import BibleImportForm
from openlp.plugins.bibles.lib import LayoutStyle, DisplayStyle, \
@ -142,20 +142,22 @@ class BibleMediaItem(MediaManagerItem):
versionLabel = QtGui.QLabel(tab)
versionLabel.setObjectName(prefix + u'VersionLabel')
layout.addWidget(versionLabel, idx, 0, QtCore.Qt.AlignRight)
versionComboBox = media_item_combo_box(tab,
versionComboBox = create_horizontal_adjusting_combo_box(tab,
prefix + u'VersionComboBox')
versionLabel.setBuddy(versionComboBox)
layout.addWidget(versionComboBox, idx, 1, 1, 2)
secondLabel = QtGui.QLabel(tab)
secondLabel.setObjectName(prefix + u'SecondLabel')
layout.addWidget(secondLabel, idx + 1, 0, QtCore.Qt.AlignRight)
secondComboBox = media_item_combo_box(tab, prefix + u'SecondComboBox')
secondComboBox = create_horizontal_adjusting_combo_box(
tab, prefix + u'SecondComboBox')
versionLabel.setBuddy(secondComboBox)
layout.addWidget(secondComboBox, idx + 1, 1, 1, 2)
styleLabel = QtGui.QLabel(tab)
styleLabel.setObjectName(prefix + u'StyleLabel')
layout.addWidget(styleLabel, idx + 2, 0, QtCore.Qt.AlignRight)
styleComboBox = media_item_combo_box(tab, prefix + u'StyleComboBox')
styleComboBox = create_horizontal_adjusting_combo_box(
tab, prefix + u'StyleComboBox')
styleComboBox.addItems([u'', u'', u''])
layout.addWidget(styleComboBox, idx + 2, 1, 1, 2)
searchButtonLayout = QtGui.QHBoxLayout()
@ -209,8 +211,8 @@ class BibleMediaItem(MediaManagerItem):
self.advancedBookLabel.setObjectName(u'advancedBookLabel')
self.advancedLayout.addWidget(self.advancedBookLabel, 0, 0,
QtCore.Qt.AlignRight)
self.advancedBookComboBox = media_item_combo_box(self.advancedTab,
u'advancedBookComboBox')
self.advancedBookComboBox = create_horizontal_adjusting_combo_box(
self.advancedTab, u'advancedBookComboBox')
self.advancedBookLabel.setBuddy(self.advancedBookComboBox)
self.advancedLayout.addWidget(self.advancedBookComboBox, 0, 1, 1, 2)
self.advancedChapterLabel = QtGui.QLabel(self.advancedTab)
@ -520,7 +522,7 @@ class BibleMediaItem(MediaManagerItem):
book.book_reference_id)
books.append(data[u'name'] + u' ')
books.sort(cmp=locale.strcoll)
add_widget_completer(books, self.quickSearchEdit)
set_case_insensitive_completer(books, self.quickSearchEdit)
def onQuickVersionComboBox(self):
self.updateAutoCompleter()

View File

@ -28,8 +28,7 @@
from PyQt4 import QtCore, QtGui
from openlp.core.lib import build_icon, translate
from openlp.core.lib.ui import UiStrings, create_accept_reject_button_box, \
create_delete_push_button, create_up_down_push_button_set
from openlp.core.lib.ui import UiStrings, create_button_box, create_button
class Ui_CustomEditDialog(object):
def setupUi(self, customEditDialog):
@ -67,14 +66,16 @@ class Ui_CustomEditDialog(object):
self.editAllButton = QtGui.QPushButton(customEditDialog)
self.editAllButton.setObjectName(u'editAllButton')
self.buttonLayout.addWidget(self.editAllButton)
self.deleteButton = create_delete_push_button(customEditDialog)
self.deleteButton = create_button(customEditDialog, u'deleteButton',
role=u'delete', click=customEditDialog.onDeleteButtonClicked)
self.deleteButton.setEnabled(False)
self.buttonLayout.addWidget(self.deleteButton)
self.buttonLayout.addStretch()
self.upButton, self.downButton = create_up_down_push_button_set(
customEditDialog)
self.upButton.setEnabled(False)
self.downButton.setEnabled(False)
self.upButton = create_button(customEditDialog, u'upButton', role=u'up',
enable=False, click=customEditDialog.onUpButtonClicked)
self.downButton = create_button(customEditDialog, u'downButton',
role=u'down', enable=False,
click=customEditDialog.onDownButtonClicked)
self.buttonLayout.addWidget(self.upButton)
self.buttonLayout.addWidget(self.downButton)
self.centralLayout.addLayout(self.buttonLayout)
@ -95,10 +96,10 @@ class Ui_CustomEditDialog(object):
self.creditLabel.setBuddy(self.creditEdit)
self.bottomFormLayout.addRow(self.creditLabel, self.creditEdit)
self.dialogLayout.addLayout(self.bottomFormLayout)
self.buttonBox = create_accept_reject_button_box(customEditDialog)
self.previewButton = QtGui.QPushButton()
self.buttonBox.addButton(
self.previewButton, QtGui.QDialogButtonBox.ActionRole)
self.buttonBox = create_button_box(customEditDialog,
[u'cancel', u'save'], [self.previewButton])
self.buttonBox.setObjectName(u'buttonBox')
self.dialogLayout.addWidget(self.buttonBox)
self.retranslateUi(customEditDialog)
QtCore.QMetaObject.connectSlotsByName(customEditDialog)

View File

@ -28,7 +28,7 @@
from PyQt4 import QtCore, QtGui
from openlp.core.lib import translate, SpellTextEdit, build_icon
from openlp.core.lib.ui import create_accept_reject_button_box, UiStrings
from openlp.core.lib.ui import create_button_box, UiStrings
class Ui_CustomSlideEditDialog(object):
def setupUi(self, customSlideEditDialog):
@ -38,17 +38,15 @@ class Ui_CustomSlideEditDialog(object):
self.slideTextEdit = SpellTextEdit(self)
self.slideTextEdit.setObjectName(u'slideTextEdit')
self.dialogLayout.addWidget(self.slideTextEdit)
self.buttonBox = create_accept_reject_button_box(customSlideEditDialog)
self.splitButton = QtGui.QPushButton(customSlideEditDialog)
self.splitButton.setIcon(build_icon(u':/general/general_add.png'))
self.splitButton.setObjectName(u'splitButton')
self.buttonBox.addButton(self.splitButton,
QtGui.QDialogButtonBox.ActionRole)
self.insertButton = QtGui.QPushButton(customSlideEditDialog)
self.insertButton.setIcon(build_icon(u':/general/general_add.png'))
self.insertButton.setObjectName(u'insertButton')
self.buttonBox.addButton(self.insertButton,
QtGui.QDialogButtonBox.ActionRole)
self.buttonBox = create_button_box(customSlideEditDialog,
[u'cancel', u'save'], [self.splitButton, self.insertButton])
self.buttonBox.setObjectName(u'buttonBox')
self.dialogLayout.addWidget(self.buttonBox)
self.retranslateUi(customSlideEditDialog)
QtCore.QMetaObject.connectSlotsByName(customSlideEditDialog)

View File

@ -35,7 +35,7 @@ from openlp.core.lib import MediaManagerItem, build_icon, ItemCapabilities, \
SettingsManager, translate, check_item_selected, Receiver, MediaType, \
ServiceItem, build_html
from openlp.core.lib.ui import UiStrings, critical_error_message_box, \
media_item_combo_box
create_horizontal_adjusting_combo_box
from openlp.core.ui import Controller, Display
from openlp.core.ui.media import get_media_players, set_media_players
@ -131,7 +131,7 @@ class MediaMediaItem(MediaManagerItem):
self.displayLayout.setObjectName(u'displayLayout')
self.displayTypeLabel = QtGui.QLabel(self.mediaWidget)
self.displayTypeLabel.setObjectName(u'displayTypeLabel')
self.displayTypeComboBox = media_item_combo_box(
self.displayTypeComboBox = create_horizontal_adjusting_combo_box(
self.mediaWidget, u'displayTypeComboBox')
self.displayTypeLabel.setBuddy(self.displayTypeComboBox)
self.displayLayout.addRow(self.displayTypeLabel,

View File

@ -28,7 +28,7 @@
from PyQt4 import QtCore, QtGui
from openlp.core.lib import SettingsTab, translate, Receiver
from openlp.core.lib.ui import UiStrings, create_up_down_push_button_set
from openlp.core.lib.ui import UiStrings, create_button
from openlp.core.ui.media import get_media_players, set_media_players
class MediaQCheckBox(QtGui.QCheckBox):
"""
@ -87,8 +87,10 @@ class MediaTab(SettingsTab):
self.orderingButtonLayout = QtGui.QVBoxLayout()
self.orderingButtonLayout.setObjectName(u'orderingButtonLayout')
self.orderingButtonLayout.addStretch(1)
self.orderingUpButton, self.orderingDownButton = \
create_up_down_push_button_set(self)
self.orderingUpButton = create_button(self, u'orderingUpButton',
role=u'up', click=self.onUpButtonClicked)
self.orderingDownButton = create_button(self, u'orderingDownButton',
role=u'down', click=self.onDownButtonClicked)
self.orderingButtonLayout.addWidget(self.orderingUpButton)
self.orderingButtonLayout.addWidget(self.orderingDownButton)
self.orderingButtonLayout.addStretch(1)

View File

@ -35,7 +35,7 @@ from openlp.core.lib import MediaManagerItem, build_icon, SettingsManager, \
translate, check_item_selected, Receiver, ItemCapabilities, create_thumb, \
validate_thumb
from openlp.core.lib.ui import UiStrings, critical_error_message_box, \
media_item_combo_box
create_horizontal_adjusting_combo_box
from openlp.plugins.presentations.lib import MessageListener
log = logging.getLogger(__name__)
@ -110,7 +110,7 @@ class PresentationMediaItem(MediaManagerItem):
self.displayLayout.setObjectName(u'displayLayout')
self.displayTypeLabel = QtGui.QLabel(self.presentationWidget)
self.displayTypeLabel.setObjectName(u'displayTypeLabel')
self.displayTypeComboBox = media_item_combo_box(
self.displayTypeComboBox = create_horizontal_adjusting_combo_box(
self.presentationWidget, u'displayTypeComboBox')
self.displayTypeLabel.setBuddy(self.displayTypeComboBox)
self.displayLayout.addRow(self.displayTypeLabel,

View File

@ -28,7 +28,7 @@
from PyQt4 import QtCore, QtGui
from openlp.core.lib import translate
from openlp.core.lib.ui import create_accept_reject_button_box
from openlp.core.lib.ui import create_button_box
class Ui_AuthorsDialog(object):
def setupUi(self, authorsDialog):
@ -57,8 +57,9 @@ class Ui_AuthorsDialog(object):
self.displayLabel.setBuddy(self.displayEdit)
self.authorLayout.addRow(self.displayLabel, self.displayEdit)
self.dialogLayout.addLayout(self.authorLayout)
self.dialogLayout.addWidget(
create_accept_reject_button_box(authorsDialog))
self.buttonBox = create_button_box(authorsDialog, [u'cancel', u'save'])
self.buttonBox.setObjectName(u'buttonBox')
self.dialogLayout.addWidget(self.buttonBox)
self.retranslateUi(authorsDialog)
authorsDialog.setMaximumHeight(authorsDialog.sizeHint().height())
QtCore.QMetaObject.connectSlotsByName(authorsDialog)

View File

@ -28,8 +28,7 @@
from PyQt4 import QtCore, QtGui
from openlp.core.lib import build_icon, translate
from openlp.core.lib.ui import UiStrings, create_accept_reject_button_box, \
create_up_down_push_button_set
from openlp.core.lib.ui import UiStrings, create_button_box, create_button
from openlp.plugins.songs.lib.ui import SongStrings
class Ui_EditSongDialog(object):
@ -272,8 +271,10 @@ class Ui_EditSongDialog(object):
self.audioRemoveAllButton.setObjectName(u'audioRemoveAllButton')
self.audioButtonsLayout.addWidget(self.audioRemoveAllButton)
self.audioButtonsLayout.addStretch(1)
self.upButton, self.downButton = \
create_up_down_push_button_set(self)
self.upButton = create_button(self, u'upButton', role=u'up',
click=self.onUpButtonClicked)
self.downButton = create_button(self, u'downButton', role=u'down',
click=self.onDownButtonClicked)
self.audioButtonsLayout.addWidget(self.upButton)
self.audioButtonsLayout.addWidget(self.downButton)
self.audioLayout.addLayout(self.audioButtonsLayout)
@ -286,7 +287,8 @@ class Ui_EditSongDialog(object):
self.warningLabel.setObjectName(u'warningLabel')
self.warningLabel.setVisible(False)
self.bottomLayout.addWidget(self.warningLabel)
self.buttonBox = create_accept_reject_button_box(editSongDialog)
self.buttonBox = create_button_box(editSongDialog, [u'cancel', u'save'])
self.buttonBox.setObjectName(u'buttonBox')
self.bottomLayout.addWidget(self.buttonBox)
self.dialogLayout.addLayout(self.bottomLayout)
self.retranslateUi(editSongDialog)

View File

@ -34,7 +34,7 @@ from PyQt4 import QtCore, QtGui
from openlp.core.lib import PluginStatus, Receiver, MediaType, translate, \
create_separated_list
from openlp.core.lib.ui import UiStrings, add_widget_completer, \
from openlp.core.lib.ui import UiStrings, set_case_insensitive_completer, \
critical_error_message_box, find_and_set_in_combo_box
from openlp.core.utils import AppLocation
from openlp.plugins.songs.forms import EditVerseForm, MediaFilesForm
@ -148,7 +148,7 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog):
self.authorsComboBox.setItemData(
row, QtCore.QVariant(author.id))
self.authors.append(author.display_name)
add_widget_completer(self.authors, self.authorsComboBox)
set_case_insensitive_completer(self.authors, self.authorsComboBox)
def loadTopics(self):
self.topics = []
@ -167,7 +167,7 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog):
combo.addItem(object.name)
cache.append(object.name)
combo.setItemData(row, QtCore.QVariant(object.id))
add_widget_completer(cache, combo)
set_case_insensitive_completer(cache, combo)
def loadThemes(self, theme_list):
self.themeComboBox.clear()
@ -176,7 +176,7 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog):
for theme in theme_list:
self.themeComboBox.addItem(theme)
self.themes.append(theme)
add_widget_completer(self.themes, self.themeComboBox)
set_case_insensitive_completer(self.themes, self.themeComboBox)
def loadMediaFiles(self):
self.audioAddFromMediaButton.setVisible(False)

View File

@ -28,7 +28,7 @@
from PyQt4 import QtCore, QtGui
from openlp.core.lib import build_icon, translate, SpellTextEdit
from openlp.core.lib.ui import create_accept_reject_button_box, UiStrings
from openlp.core.lib.ui import create_button_box, UiStrings
from openlp.plugins.songs.lib import VerseType
class Ui_EditVerseDialog(object):
@ -65,8 +65,10 @@ class Ui_EditVerseDialog(object):
self.verseTypeLayout.addWidget(self.insertButton)
self.verseTypeLayout.addStretch()
self.dialogLayout.addLayout(self.verseTypeLayout)
self.dialogLayout.addWidget(
create_accept_reject_button_box(editVerseDialog))
self.buttonBox = create_button_box(editVerseDialog,
[u'cancel', u'save'])
self.buttonBox.setObjectName(u'buttonBox')
self.dialogLayout.addWidget(self.buttonBox)
self.retranslateUi(editVerseDialog)
QtCore.QMetaObject.connectSlotsByName(editVerseDialog)

View File

@ -28,7 +28,7 @@
from PyQt4 import QtCore, QtGui
from openlp.core.lib import translate
from openlp.core.lib.ui import create_accept_reject_button_box
from openlp.core.lib.ui import create_button_box
class Ui_SongBookDialog(object):
def setupUi(self, songBookDialog):
@ -51,8 +51,9 @@ class Ui_SongBookDialog(object):
self.publisherLabel.setBuddy(self.publisherEdit)
self.bookLayout.addRow(self.publisherLabel, self.publisherEdit)
self.dialogLayout.addLayout(self.bookLayout)
self.dialogLayout.addWidget(
create_accept_reject_button_box(songBookDialog))
self.buttonBox = create_button_box(songBookDialog, [u'cancel', u'save'])
self.buttonBox.setObjectName(u'buttonBox')
self.dialogLayout.addWidget(self.buttonBox)
self.retranslateUi(songBookDialog)
songBookDialog.setMaximumHeight(songBookDialog.sizeHint().height())
QtCore.QMetaObject.connectSlotsByName(songBookDialog)

View File

@ -28,7 +28,7 @@
from PyQt4 import QtCore, QtGui
from openlp.core.lib import translate
from openlp.core.lib.ui import create_accept_reject_button_box
from openlp.core.lib.ui import create_button_box
class Ui_TopicsDialog(object):
def setupUi(self, topicsDialog):
@ -45,8 +45,9 @@ class Ui_TopicsDialog(object):
self.nameLabel.setBuddy(self.nameEdit)
self.nameLayout.addRow(self.nameLabel, self.nameEdit)
self.dialogLayout.addLayout(self.nameLayout)
self.dialogLayout.addWidget(
create_accept_reject_button_box(topicsDialog))
self.buttonBox = create_button_box(topicsDialog, [u'cancel', u'save'])
self.buttonBox.setObjectName(u'buttonBox')
self.dialogLayout.addWidget(self.buttonBox)
self.retranslateUi(topicsDialog)
topicsDialog.setMaximumHeight(topicsDialog.sizeHint().height())
QtCore.QMetaObject.connectSlotsByName(topicsDialog)

View File

@ -28,7 +28,7 @@
from PyQt4 import QtCore, QtGui
from openlp.core.lib import build_icon, translate
from openlp.core.lib.ui import create_accept_reject_button_box
from openlp.core.lib.ui import create_button_box
class Ui_SongUsageDetailDialog(object):
def setupUi(self, songUsageDetailDialog):
@ -74,8 +74,9 @@ class Ui_SongUsageDetailDialog(object):
self.saveFilePushButton.setObjectName(u'saveFilePushButton')
self.fileHorizontalLayout.addWidget(self.saveFilePushButton)
self.verticalLayout.addWidget(self.fileGroupBox)
self.buttonBox = create_accept_reject_button_box(
songUsageDetailDialog, True)
self.buttonBox = create_button_box(songUsageDetailDialog,
[u'cancel', u'ok'])
self.buttonBox.setObjectName(u'buttonBox')
self.verticalLayout.addWidget(self.buttonBox)
self.retranslateUi(songUsageDetailDialog)
QtCore.QObject.connect(self.saveFilePushButton,