More 120 cleanups

This commit is contained in:
Tim Bentley 2013-01-05 22:17:30 +00:00
parent df7324693c
commit 0e5a3aa045
41 changed files with 521 additions and 951 deletions

View File

@ -1,5 +1,5 @@
# -*- coding: utf-8 -*-
# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4
# vim: autoindent shiftwidth=4 expandtab textwidth=120 tabstop=4 softtabstop=4
###############################################################################
# OpenLP - Open Source Lyrics Projection #

View File

@ -1,5 +1,5 @@
# -*- coding: utf-8 -*-
# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4
# vim: autoindent shiftwidth=4 expandtab textwidth=120 tabstop=4 softtabstop=4
###############################################################################
# OpenLP - Open Source Lyrics Projection #
@ -48,19 +48,16 @@ class CustomPlugin(Plugin):
log.info(u'Custom Plugin loaded')
def __init__(self, plugin_helpers):
Plugin.__init__(self, u'custom', plugin_helpers,
CustomMediaItem, CustomTab)
Plugin.__init__(self, u'custom', plugin_helpers, CustomMediaItem, CustomTab)
self.weight = -5
self.manager = Manager(u'custom', init_schema)
self.iconPath = u':/plugins/plugin_custom.png'
self.icon = build_icon(self.iconPath)
def about(self):
about_text = translate('CustomPlugin', '<strong>Custom Slide Plugin'
'</strong><br />The custom slide plugin provides the ability to '
'set up custom text slides that can be displayed on the screen '
'the same way songs are. This plugin provides greater freedom '
'over the songs plugin.')
about_text = translate('CustomPlugin', '<strong>Custom Slide Plugin </strong><br />The custom slide plugin '
'provides the ability to set up custom text slides that can be displayed on the screen '
'the same way songs are. This plugin provides greater freedom over the songs plugin.')
return about_text
def usesTheme(self, theme):
@ -69,8 +66,7 @@ class CustomPlugin(Plugin):
Returns True if the theme is being used, otherwise returns False.
"""
if self.manager.get_all_objects(CustomSlide,
CustomSlide.theme_name == theme):
if self.manager.get_all_objects(CustomSlide, CustomSlide.theme_name == theme):
return True
return False
@ -85,8 +81,7 @@ class CustomPlugin(Plugin):
``newTheme``
The new name the plugin should now use.
"""
customsUsingTheme = self.manager.get_all_objects(CustomSlide,
CustomSlide.theme_name == oldTheme)
customsUsingTheme = self.manager.get_all_objects(CustomSlide, CustomSlide.theme_name == oldTheme)
for custom in customsUsingTheme:
custom.theme_name = newTheme
self.manager.save_object(custom)
@ -97,31 +92,23 @@ class CustomPlugin(Plugin):
"""
## Name PluginList ##
self.textStrings[StringContent.Name] = {
u'singular': translate('CustomPlugin', 'Custom Slide',
'name singular'),
u'plural': translate('CustomPlugin', 'Custom Slides',
'name plural')
u'singular': translate('CustomPlugin', 'Custom Slide', 'name singular'),
u'plural': translate('CustomPlugin', 'Custom Slides', 'name plural')
}
## Name for MediaDockManager, SettingsManager ##
self.textStrings[StringContent.VisibleName] = {
u'title': translate('CustomPlugin', 'Custom Slides',
'container title')
u'title': translate('CustomPlugin', 'Custom Slides', 'container title')
}
# Middle Header Bar
tooltips = {
u'load': translate('CustomPlugin', 'Load a new custom slide.'),
u'import': translate('CustomPlugin', 'Import a custom slide.'),
u'new': translate('CustomPlugin', 'Add a new custom slide.'),
u'edit': translate('CustomPlugin',
'Edit the selected custom slide.'),
u'delete': translate('CustomPlugin',
'Delete the selected custom slide.'),
u'preview': translate('CustomPlugin',
'Preview the selected custom slide.'),
u'live': translate('CustomPlugin',
'Send the selected custom slide live.'),
u'service': translate('CustomPlugin',
'Add the selected custom slide to the service.')
u'edit': translate('CustomPlugin', 'Edit the selected custom slide.'),
u'delete': translate('CustomPlugin', 'Delete the selected custom slide.'),
u'preview': translate('CustomPlugin', 'Preview the selected custom slide.'),
u'live': translate('CustomPlugin', 'Send the selected custom slide live.'),
u'service': translate('CustomPlugin', 'Add the selected custom slide to the service.')
}
self.setPluginUiTextStrings(tooltips)

View File

@ -1,5 +1,5 @@
# -*- coding: utf-8 -*-
# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4
# vim: autoindent shiftwidth=4 expandtab textwidth=120 tabstop=4 softtabstop=4
###############################################################################
# OpenLP - Open Source Lyrics Projection #

View File

@ -1,5 +1,5 @@
# -*- coding: utf-8 -*-
# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4
# vim: autoindent shiftwidth=4 expandtab textwidth=120 tabstop=4 softtabstop=4
###############################################################################
# OpenLP - Open Source Lyrics Projection #
@ -36,8 +36,7 @@ class Ui_CustomEditDialog(object):
def setupUi(self, customEditDialog):
customEditDialog.setObjectName(u'customEditDialog')
customEditDialog.resize(450, 350)
customEditDialog.setWindowIcon(
build_icon(u':/icon/openlp-logo-16x16.png'))
customEditDialog.setWindowIcon(build_icon(u':/icon/openlp-logo-16x16.png'))
self.dialogLayout = QtGui.QVBoxLayout(customEditDialog)
self.dialogLayout.setObjectName(u'dialogLayout')
self.titleLayout = QtGui.QHBoxLayout()
@ -68,15 +67,14 @@ class Ui_CustomEditDialog(object):
self.editAllButton = QtGui.QPushButton(customEditDialog)
self.editAllButton.setObjectName(u'editAllButton')
self.buttonLayout.addWidget(self.editAllButton)
self.deleteButton = create_button(customEditDialog, u'deleteButton',
role=u'delete', click=customEditDialog.onDeleteButtonClicked)
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 = create_button(customEditDialog, u'upButton', role=u'up',
enabled=False, click=customEditDialog.onUpButtonClicked)
self.downButton = create_button(customEditDialog, u'downButton',
role=u'down', enabled=False,
self.upButton = create_button(customEditDialog, u'upButton', role=u'up', enabled=False,
click=customEditDialog.onUpButtonClicked)
self.downButton = create_button(customEditDialog, u'downButton', role=u'down', enabled=False,
click=customEditDialog.onDownButtonClicked)
self.buttonLayout.addWidget(self.upButton)
self.buttonLayout.addWidget(self.downButton)
@ -99,31 +97,19 @@ class Ui_CustomEditDialog(object):
self.bottomFormLayout.addRow(self.creditLabel, self.creditEdit)
self.dialogLayout.addLayout(self.bottomFormLayout)
self.previewButton = QtGui.QPushButton()
self.buttonBox = create_button_box(customEditDialog, u'buttonBox',
[u'cancel', u'save'], [self.previewButton])
self.buttonBox = create_button_box(customEditDialog, u'buttonBox', [u'cancel', u'save'], [self.previewButton])
self.dialogLayout.addWidget(self.buttonBox)
self.retranslateUi(customEditDialog)
def retranslateUi(self, customEditDialog):
customEditDialog.setWindowTitle(
translate('CustomPlugin.EditCustomForm', 'Edit Custom Slides'))
self.titleLabel.setText(
translate('CustomPlugin.EditCustomForm', '&Title:'))
customEditDialog.setWindowTitle(translate('CustomPlugin.EditCustomForm', 'Edit Custom Slides'))
self.titleLabel.setText(translate('CustomPlugin.EditCustomForm', '&Title:'))
self.addButton.setText(UiStrings().Add)
self.addButton.setToolTip(
translate('CustomPlugin.EditCustomForm', 'Add a new slide at '
'bottom.'))
self.addButton.setToolTip(translate('CustomPlugin.EditCustomForm', 'Add a new slide at bottom.'))
self.editButton.setText(UiStrings().Edit)
self.editButton.setToolTip(
translate('CustomPlugin.EditCustomForm', 'Edit the selected '
'slide.'))
self.editAllButton.setText(
translate('CustomPlugin.EditCustomForm', 'Ed&it All'))
self.editAllButton.setToolTip(
translate('CustomPlugin.EditCustomForm', 'Edit all the slides at '
'once.'))
self.themeLabel.setText(
translate('CustomPlugin.EditCustomForm', 'The&me:'))
self.creditLabel.setText(
translate('CustomPlugin.EditCustomForm', '&Credits:'))
self.editButton.setToolTip(translate('CustomPlugin.EditCustomForm', 'Edit the selected slide.'))
self.editAllButton.setText(translate('CustomPlugin.EditCustomForm', 'Ed&it All'))
self.editAllButton.setToolTip(translate('CustomPlugin.EditCustomForm', 'Edit all the slides at once.'))
self.themeLabel.setText(translate('CustomPlugin.EditCustomForm', 'The&me:'))
self.creditLabel.setText(translate('CustomPlugin.EditCustomForm', '&Credits:'))
self.previewButton.setText(UiStrings().SaveAndPreview)

View File

@ -1,5 +1,5 @@
# -*- coding: utf-8 -*-
# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4
# vim: autoindent shiftwidth=4 expandtab textwidth=120 tabstop=4 softtabstop=4
###############################################################################
# OpenLP - Open Source Lyrics Projection #
@ -57,20 +57,13 @@ class EditCustomForm(QtGui.QDialog, Ui_CustomEditDialog):
# Create other objects and forms.
self.editSlideForm = EditCustomSlideForm(self)
# Connecting signals and slots
QtCore.QObject.connect(self.previewButton,
QtCore.SIGNAL(u'clicked()'), self.onPreviewButtonClicked)
QtCore.QObject.connect(self.addButton,
QtCore.SIGNAL(u'clicked()'), self.onAddButtonClicked)
QtCore.QObject.connect(self.editButton,
QtCore.SIGNAL(u'clicked()'), self.onEditButtonClicked)
QtCore.QObject.connect(self.editAllButton,
QtCore.SIGNAL(u'clicked()'), self.onEditAllButtonClicked)
QtCore.QObject.connect(Receiver.get_receiver(),
QtCore.SIGNAL(u'theme_update_list'), self.loadThemes)
QtCore.QObject.connect(self.slideListView,
QtCore.SIGNAL(u'currentRowChanged(int)'), self.onCurrentRowChanged)
QtCore.QObject.connect(self.slideListView,
QtCore.SIGNAL(u'doubleClicked(QModelIndex)'),
QtCore.QObject.connect(self.previewButton, QtCore.SIGNAL(u'clicked()'), self.onPreviewButtonClicked)
QtCore.QObject.connect(self.addButton, QtCore.SIGNAL(u'clicked()'), self.onAddButtonClicked)
QtCore.QObject.connect(self.editButton, QtCore.SIGNAL(u'clicked()'), self.onEditButtonClicked)
QtCore.QObject.connect(self.editAllButton, QtCore.SIGNAL(u'clicked()'), self.onEditAllButtonClicked)
QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'theme_update_list'), self.loadThemes)
QtCore.QObject.connect(self.slideListView, QtCore.SIGNAL(u'currentRowChanged(int)'), self.onCurrentRowChanged)
QtCore.QObject.connect(self.slideListView, QtCore.SIGNAL(u'doubleClicked(QModelIndex)'),
self.onEditButtonClicked)
def loadThemes(self, themelist):
@ -126,8 +119,7 @@ class EditCustomForm(QtGui.QDialog, Ui_CustomEditDialog):
return False
sxml = CustomXMLBuilder()
for count in range(self.slideListView.count()):
sxml.add_verse_to_lyrics(u'custom', unicode(count + 1),
self.slideListView.item(count).text())
sxml.add_verse_to_lyrics(u'custom', unicode(count + 1), self.slideListView.item(count).text())
self.customSlide.title = self.titleEdit.text()
self.customSlide.text = unicode(sxml.extract_xml(), u'utf-8')
self.customSlide.credits = self.creditEdit.text()
@ -244,14 +236,11 @@ class EditCustomForm(QtGui.QDialog, Ui_CustomEditDialog):
# We must have a title.
if not self.titleEdit.displayText():
self.titleEdit.setFocus()
critical_error_message_box(
message=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:
critical_error_message_box(
message=translate('CustomPlugin.EditCustomForm',
critical_error_message_box(message=translate('CustomPlugin.EditCustomForm',
'You need to add at least one slide'))
return False
return True

View File

@ -1,5 +1,5 @@
# -*- coding: utf-8 -*-
# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4
# vim: autoindent shiftwidth=4 expandtab textwidth=120 tabstop=4 softtabstop=4
###############################################################################
# OpenLP - Open Source Lyrics Projection #
@ -40,22 +40,17 @@ class Ui_CustomSlideEditDialog(object):
self.slideTextEdit = SpellTextEdit(self)
self.slideTextEdit.setObjectName(u'slideTextEdit')
self.dialogLayout.addWidget(self.slideTextEdit)
self.splitButton = create_button(customSlideEditDialog, u'splitButton',
icon=u':/general/general_add.png')
self.insertButton = create_button(customSlideEditDialog,
u'insertButton', icon=u':/general/general_add.png')
self.buttonBox = create_button_box(customSlideEditDialog, u'buttonBox',
[u'cancel', u'save'], [self.splitButton, self.insertButton])
self.splitButton = create_button(customSlideEditDialog, u'splitButton', icon=u':/general/general_add.png')
self.insertButton = create_button(customSlideEditDialog, u'insertButton', icon=u':/general/general_add.png')
self.buttonBox = create_button_box(customSlideEditDialog, u'buttonBox', [u'cancel', u'save'],
[self.splitButton, self.insertButton])
self.dialogLayout.addWidget(self.buttonBox)
self.retranslateUi(customSlideEditDialog)
def retranslateUi(self, customSlideEditDialog):
customSlideEditDialog.setWindowTitle(
translate('CustomPlugin.EditVerseForm', 'Edit Slide'))
customSlideEditDialog.setWindowTitle(translate('CustomPlugin.EditVerseForm', 'Edit Slide'))
self.splitButton.setText(UiStrings().Split)
self.splitButton.setToolTip(UiStrings().SplitToolTip)
self.insertButton.setText(
translate('CustomPlugin.EditCustomForm', 'Insert Slide'))
self.insertButton.setToolTip(
translate('CustomPlugin.EditCustomForm', 'Split a slide into two '
'by inserting a slide splitter.'))
self.insertButton.setText(translate('CustomPlugin.EditCustomForm', 'Insert Slide'))
self.insertButton.setToolTip(translate('CustomPlugin.EditCustomForm',
'Split a slide into two by inserting a slide splitter.'))

View File

@ -1,5 +1,5 @@
# -*- coding: utf-8 -*-
# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4
# vim: autoindent shiftwidth=4 expandtab textwidth=120 tabstop=4 softtabstop=4
###############################################################################
# OpenLP - Open Source Lyrics Projection #
@ -47,10 +47,8 @@ class EditCustomSlideForm(QtGui.QDialog, Ui_CustomSlideEditDialog):
QtGui.QDialog.__init__(self, parent)
self.setupUi(self)
# Connecting signals and slots
QtCore.QObject.connect(self.insertButton,
QtCore.SIGNAL(u'clicked()'), self.onInsertButtonClicked)
QtCore.QObject.connect(self.splitButton,
QtCore.SIGNAL(u'clicked()'), self.onSplitButtonClicked)
QtCore.QObject.connect(self.insertButton, QtCore.SIGNAL(u'clicked()'), self.onInsertButtonClicked)
QtCore.QObject.connect(self.splitButton, QtCore.SIGNAL(u'clicked()'), self.onSplitButtonClicked)
def setText(self, text):
"""

View File

@ -1,5 +1,5 @@
# -*- coding: utf-8 -*-
# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4
# vim: autoindent shiftwidth=4 expandtab textwidth=120 tabstop=4 softtabstop=4
###############################################################################
# OpenLP - Open Source Lyrics Projection #

View File

@ -1,5 +1,5 @@
# -*- coding: utf-8 -*-
# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4
# vim: autoindent shiftwidth=4 expandtab textwidth=120 tabstop=4 softtabstop=4
###############################################################################
# OpenLP - Open Source Lyrics Projection #
@ -54,17 +54,14 @@ class CustomTab(SettingsTab):
self.leftLayout.addWidget(self.customModeGroupBox)
self.leftLayout.addStretch()
self.rightLayout.addStretch()
QtCore.QObject.connect(self.displayFooterCheckBox,
QtCore.SIGNAL(u'stateChanged(int)'),
QtCore.QObject.connect(self.displayFooterCheckBox, QtCore.SIGNAL(u'stateChanged(int)'),
self.onDisplayFooterCheckBoxChanged)
QtCore.QObject.connect(self.add_from_service_checkbox,
QtCore.SIGNAL(u'stateChanged(int)'), self.on_add_from_service_check_box_changed)
QtCore.QObject.connect(self.add_from_service_checkbox, QtCore.SIGNAL(u'stateChanged(int)'),
self.on_add_from_service_check_box_changed)
def retranslateUi(self):
self.customModeGroupBox.setTitle(translate('CustomPlugin.CustomTab',
'Custom Display'))
self.displayFooterCheckBox.setText(
translate('CustomPlugin.CustomTab', 'Display footer'))
self.customModeGroupBox.setTitle(translate('CustomPlugin.CustomTab', 'Custom Display'))
self.displayFooterCheckBox.setText(translate('CustomPlugin.CustomTab', 'Display footer'))
self.add_from_service_checkbox.setText(translate('CustomPlugin.CustomTab',
'Import missing custom slides from service files'))

View File

@ -1,5 +1,5 @@
# -*- coding: utf-8 -*-
# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4
# vim: autoindent shiftwidth=4 expandtab textwidth=120 tabstop=4 softtabstop=4
###############################################################################
# OpenLP - Open Source Lyrics Projection #

View File

@ -1,5 +1,5 @@
# -*- coding: utf-8 -*-
# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4
# vim: autoindent shiftwidth=4 expandtab textwidth=120 tabstop=4 softtabstop=4
###############################################################################
# OpenLP - Open Source Lyrics Projection #

View File

@ -1,5 +1,5 @@
# -*- coding: utf-8 -*-
# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4
# vim: autoindent shiftwidth=4 expandtab textwidth=120 tabstop=4 softtabstop=4
###############################################################################
# OpenLP - Open Source Lyrics Projection #
@ -58,12 +58,11 @@ class CustomMediaItem(MediaManagerItem):
def __init__(self, parent, plugin, icon):
self.IconPath = u'custom/custom'
MediaManagerItem.__init__(self, parent, plugin, icon)
self.edit_custom_form = EditCustomForm(self, self.plugin.formParent,
self.plugin.manager)
self.edit_custom_form = EditCustomForm(self, self.plugin.formParent, self.plugin.manager)
self.singleServiceItem = False
self.quickPreviewAllowed = True
self.hasSearch = True
# Holds information about whether the edit is remotly triggered and
# Holds information about whether the edit is remotely triggered and
# which Custom is required.
self.remoteCustom = -1
self.manager = plugin.manager
@ -72,22 +71,16 @@ class CustomMediaItem(MediaManagerItem):
self.toolbar.addSeparator()
self.addSearchToToolBar()
# Signals and slots
QtCore.QObject.connect(self.searchTextEdit,
QtCore.SIGNAL(u'cleared()'), self.onClearTextButtonClick)
QtCore.QObject.connect(self.searchTextEdit,
QtCore.SIGNAL(u'searchTypeChanged(int)'),
QtCore.QObject.connect(self.searchTextEdit, QtCore.SIGNAL(u'cleared()'), self.onClearTextButtonClick)
QtCore.QObject.connect(self.searchTextEdit, QtCore.SIGNAL(u'searchTypeChanged(int)'),
self.onSearchTextButtonClicked)
QtCore.QObject.connect(Receiver.get_receiver(),
QtCore.SIGNAL(u'custom_edit'), self.onRemoteEdit)
QtCore.QObject.connect(Receiver.get_receiver(),
QtCore.SIGNAL(u'custom_edit_clear'), self.onRemoteEditClear)
QtCore.QObject.connect(Receiver.get_receiver(),
QtCore.SIGNAL(u'custom_load_list'), self.loadList)
QtCore.QObject.connect(Receiver.get_receiver(),
QtCore.SIGNAL(u'custom_preview'), self.onPreviewClick)
QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'custom_edit'), self.onRemoteEdit)
QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'custom_edit_clear'), self.onRemoteEditClear)
QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'custom_load_list'), self.loadList)
QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'custom_preview'), self.onPreviewClick)
QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'config_updated'), self.config_updated)
QtCore.QObject.connect(Receiver.get_receiver(),
QtCore.SIGNAL(u'custom_create_from_service'), self.create_from_service_item)
QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'custom_create_from_service'),
self.create_from_service_item)
def config_updated(self):
self.add_custom_from_service = Settings().value(self.settingsSection + u'/add custom from service', True)
@ -101,13 +94,11 @@ class CustomMediaItem(MediaManagerItem):
(CustomSearch.Titles, u':/songs/song_search_title.png',
translate('SongsPlugin.MediaItem', 'Titles'),
translate('SongsPlugin.MediaItem', 'Search Titles...')),
(CustomSearch.Themes, u':/slides/slide_theme.png',
UiStrings().Themes, UiStrings().SearchThemes)
(CustomSearch.Themes, u':/slides/slide_theme.png', UiStrings().Themes, UiStrings().SearchThemes)
])
self.loadList(self.manager.get_all_objects(
CustomSlide, order_by_ref=CustomSlide.title))
self.searchTextEdit.setCurrentSearchType(Settings().value(
u'%s/last search type' % self.settingsSection, CustomSearch.Titles))
self.loadList(self.manager.get_all_objects(CustomSlide, order_by_ref=CustomSlide.title))
self.searchTextEdit.setCurrentSearchType(Settings().value( u'%s/last search type' % self.settingsSection,
CustomSearch.Titles))
self.config_updated()
def loadList(self, custom_slides):
@ -180,11 +171,9 @@ class CustomMediaItem(MediaManagerItem):
if QtGui.QMessageBox.question(self,
UiStrings().ConfirmDelete,
translate('CustomPlugin.MediaItem',
'Are you sure you want to delete the %n selected custom'
' slide(s)?', '',
'Are you sure you want to delete the %n selected custom slide(s)?', '',
QtCore.QCoreApplication.CodecForTr, len(items)),
QtGui.QMessageBox.StandardButtons(QtGui.QMessageBox.Yes |
QtGui.QMessageBox.No),
QtGui.QMessageBox.StandardButtons(QtGui.QMessageBox.Yes | QtGui.QMessageBox.No),
QtGui.QMessageBox.Yes) == QtGui.QMessageBox.No:
return
row_list = [item.row() for item in self.listView.selectedIndexes()]
@ -219,8 +208,7 @@ class CustomMediaItem(MediaManagerItem):
service_item.title = title
for slide in raw_slides:
service_item.add_from_text(slide)
if Settings().value(self.settingsSection + u'/display footer',
True) or credit:
if Settings().value(self.settingsSection + u'/display footer', True) or credit:
service_item.raw_footer.append(u' '.join([title, credit]))
else:
service_item.raw_footer.append(u'')
@ -228,8 +216,7 @@ class CustomMediaItem(MediaManagerItem):
def onSearchTextButtonClicked(self):
# Save the current search type to the configuration.
Settings().setValue(u'%s/last search type' %
self.settingsSection, self.searchTextEdit.currentSearchType())
Settings().setValue(u'%s/last search type' % self.settingsSection, self.searchTextEdit.currentSearchType())
# Reload the list considering the new search type.
search_keywords = self.searchTextEdit.displayText()
search_results = []
@ -237,14 +224,14 @@ class CustomMediaItem(MediaManagerItem):
if search_type == CustomSearch.Titles:
log.debug(u'Titles Search')
search_results = self.plugin.manager.get_all_objects(CustomSlide,
CustomSlide.title.like(u'%' + self.whitespace.sub(u' ',
search_keywords) + u'%'), order_by_ref=CustomSlide.title)
CustomSlide.title.like(u'%' + self.whitespace.sub(u' ', search_keywords) + u'%'),
order_by_ref=CustomSlide.title)
self.loadList(search_results)
elif search_type == CustomSearch.Themes:
log.debug(u'Theme Search')
search_results = self.plugin.manager.get_all_objects(CustomSlide,
CustomSlide.theme_name.like(u'%' + self.whitespace.sub(u' ',
search_keywords) + u'%'), order_by_ref=CustomSlide.title)
CustomSlide.theme_name.like(u'%' + self.whitespace.sub(u' ', search_keywords) + u'%'),
order_by_ref=CustomSlide.title)
self.loadList(search_results)
self.checkSearchResult()
@ -269,7 +256,7 @@ class CustomMediaItem(MediaManagerItem):
return
custom = self.plugin.manager.get_object_filtered(CustomSlide,
and_(CustomSlide.title == item.title, CustomSlide.theme_name == item.theme,
CustomSlide.credits == item.raw_footer[0][len(item.title) + 1:]))
CustomSlide.credits == item.raw_footer[0][len(item.title) + 1:]))
if custom:
Receiver.send_message(u'service_item_update', u'%s:%s:%s' % (custom.id, item._uuid, False))
else:
@ -312,10 +299,8 @@ class CustomMediaItem(MediaManagerItem):
def search(self, string, showError):
search_results = self.manager.get_all_objects(CustomSlide,
or_(func.lower(CustomSlide.title).like(u'%' +
string.lower() + u'%'),
func.lower(CustomSlide.text).like(u'%' +
string.lower() + u'%')),
or_(func.lower(CustomSlide.title).like(u'%' + string.lower() + u'%'),
func.lower(CustomSlide.text).like(u'%' + string.lower() + u'%')),
order_by_ref=CustomSlide.title)
return [[custom.id, custom.title] for custom in search_results]

View File

@ -1,5 +1,5 @@
# -*- coding: utf-8 -*-
# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4
# vim: autoindent shiftwidth=4 expandtab textwidth=120 tabstop=4 softtabstop=4
###############################################################################
# OpenLP - Open Source Lyrics Projection #

View File

@ -1,5 +1,5 @@
# -*- coding: utf-8 -*-
# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4
# vim: autoindent shiftwidth=4 expandtab textwidth=120 tabstop=4 softtabstop=4
###############################################################################
# OpenLP - Open Source Lyrics Projection #

View File

@ -1,5 +1,5 @@
# -*- coding: utf-8 -*-
# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4
# vim: autoindent shiftwidth=4 expandtab textwidth=120 tabstop=4 softtabstop=4
###############################################################################
# OpenLP - Open Source Lyrics Projection #
@ -76,8 +76,7 @@ class ImpressController(PresentationController):
Initialise the class
"""
log.debug(u'Initialising')
PresentationController.__init__(self, plugin, u'Impress',
ImpressDocument)
PresentationController.__init__(self, plugin, u'Impress', ImpressDocument)
self.supports = [u'odp']
self.alsosupports = [u'ppt', u'pps', u'pptx', u'ppsx']
self.process = None
@ -121,10 +120,8 @@ class ImpressController(PresentationController):
loop = 0
log.debug(u'get UNO Desktop Openoffice - getComponentContext')
context = uno.getComponentContext()
log.debug(u'get UNO Desktop Openoffice - createInstaneWithContext - '
u'UnoUrlResolver')
resolver = context.ServiceManager.createInstanceWithContext(
u'com.sun.star.bridge.UnoUrlResolver', context)
log.debug(u'get UNO Desktop Openoffice - createInstaneWithContext - UnoUrlResolver')
resolver = context.ServiceManager.createInstanceWithContext(u'com.sun.star.bridge.UnoUrlResolver', context)
while uno_instance is None and loop < 3:
try:
uno_instance = get_uno_instance(resolver)
@ -136,8 +133,7 @@ class ImpressController(PresentationController):
self.manager = uno_instance.ServiceManager
log.debug(u'get UNO Desktop Openoffice - createInstanceWithContext'
u' - Desktop')
desktop = self.manager.createInstanceWithContext(
"com.sun.star.frame.Desktop", uno_instance)
desktop = self.manager.createInstanceWithContext("com.sun.star.frame.Desktop", uno_instance)
return desktop
except:
log.warn(u'Failed to get UNO desktop')
@ -166,8 +162,7 @@ class ImpressController(PresentationController):
try:
return Dispatch(u'com.sun.star.ServiceManager')
except pywintypes.com_error:
log.warn(u'Failed to get COM service manager. '
u'Impress Controller has been disabled')
log.warn(u'Failed to get COM service manager. Impress Controller has been disabled')
return None
def kill(self):
@ -193,8 +188,7 @@ class ImpressController(PresentationController):
list = docs.createEnumeration()
while list.hasMoreElements():
doc = list.nextElement()
if doc.getImplementationName() != \
u'com.sun.star.comp.framework.BackingComp':
if doc.getImplementationName() != u'com.sun.star.comp.framework.BackingComp':
cnt = cnt + 1
if cnt > 0:
log.debug(u'OpenOffice not terminated as docs are still open')
@ -235,8 +229,7 @@ class ImpressDocument(PresentationDocument):
if desktop is None:
self.controller.start_process()
desktop = self.controller.get_com_desktop()
url = u'file:///' + self.filepath.replace(u'\\', u'/').replace(
u':', u'|').replace(u' ', u'%20')
url = u'file:///' + self.filepath.replace(u'\\', u'/').replace(u':', u'|').replace(u' ', u'%20')
else:
desktop = self.controller.get_uno_desktop()
url = uno.systemPathToFileUrl(self.filepath)
@ -258,12 +251,10 @@ class ImpressDocument(PresentationDocument):
if os.name == u'nt':
# As we can't start minimized the Impress window gets in the way.
# Either window.setPosSize(0, 0, 200, 400, 12) or .setVisible(False)
window = self.document.getCurrentController().getFrame() \
.getContainerWindow()
window = self.document.getCurrentController().getFrame().getContainerWindow()
window.setVisible(False)
self.presentation = self.document.getPresentation()
self.presentation.Display = \
self.controller.plugin.renderer.screens.current[u'number'] + 1
self.presentation.Display = self.controller.plugin.renderer.screens.current[u'number'] + 1
self.control = None
self.create_thumbnails()
return True
@ -276,8 +267,8 @@ class ImpressDocument(PresentationDocument):
if self.check_thumbnails():
return
if os.name == u'nt':
thumbdirurl = u'file:///' + self.get_temp_folder().replace(
u'\\', u'/').replace(u':', u'|').replace(u' ', u'%20')
thumbdirurl = u'file:///' + self.get_temp_folder().replace(u'\\', u'/') \
.replace(u':', u'|').replace(u' ', u'%20')
else:
thumbdirurl = uno.systemPathToFileUrl(self.get_temp_folder())
props = []
@ -293,15 +284,13 @@ class ImpressDocument(PresentationDocument):
page = pages.getByIndex(idx)
doc.getCurrentController().setCurrentPage(page)
urlpath = u'%s/%s.png' % (thumbdirurl, unicode(idx + 1))
path = os.path.join(self.get_temp_folder(),
unicode(idx + 1) + u'.png')
path = os.path.join(self.get_temp_folder(), unicode(idx + 1) + u'.png')
try:
doc.storeToURL(urlpath, props)
self.convert_thumbnail(path, idx + 1)
delete_file(path)
except ErrorCodeIOException, exception:
log.exception(u'ERROR! ErrorCodeIOException %d' %
exception.ErrCode)
log.exception(u'ERROR! ErrorCodeIOException %d' % exception.ErrCode)
except:
log.exception(u'%s - Unable to store openoffice preview' % path)
@ -312,8 +301,7 @@ class ImpressDocument(PresentationDocument):
"""
log.debug(u'create property OpenOffice')
if os.name == u'nt':
prop = self.controller.manager.\
Bridge_GetStruct(u'com.sun.star.beans.PropertyValue')
prop = self.controller.manager.Bridge_GetStruct(u'com.sun.star.beans.PropertyValue')
else:
prop = PropertyValue()
prop.Name = name

View File

@ -1,5 +1,5 @@
# -*- coding: utf-8 -*-
# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4
# vim: autoindent shiftwidth=4 expandtab textwidth=120 tabstop=4 softtabstop=4
###############################################################################
# OpenLP - Open Source Lyrics Projection #
@ -32,11 +32,9 @@ import os
from PyQt4 import QtCore, QtGui
from openlp.core.lib import MediaManagerItem, build_icon, SettingsManager, \
translate, check_item_selected, Receiver, ItemCapabilities, create_thumb, \
validate_thumb, ServiceItemContext, Settings
from openlp.core.lib.ui import UiStrings, critical_error_message_box, \
create_horizontal_adjusting_combo_box
from openlp.core.lib import MediaManagerItem, build_icon, SettingsManager, translate, check_item_selected, Receiver, \
ItemCapabilities, create_thumb, validate_thumb, ServiceItemContext, Settings
from openlp.core.lib.ui import UiStrings, critical_error_message_box, create_horizontal_adjusting_combo_box
from openlp.core.utils import locale_compare
from openlp.plugins.presentations.lib import MessageListener
@ -62,11 +60,9 @@ class PresentationMediaItem(MediaManagerItem):
self.message_listener = MessageListener(self)
self.hasSearch = True
self.singleServiceItem = False
QtCore.QObject.connect(Receiver.get_receiver(),
QtCore.SIGNAL(u'mediaitem_presentation_rebuild'),
QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'mediaitem_presentation_rebuild'),
self.populateDisplayTypes)
QtCore.QObject.connect(Receiver.get_receiver(),
QtCore.SIGNAL(u'mediaitem_suffixes'), self.buildFileMaskString)
QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'mediaitem_suffixes'), self.buildFileMaskString)
# Allow DnD from the desktop
self.listView.activateDnD()
@ -74,12 +70,9 @@ class PresentationMediaItem(MediaManagerItem):
"""
The name of the plugin media displayed in UI
"""
self.onNewPrompt = translate('PresentationPlugin.MediaItem',
'Select Presentation(s)')
self.Automatic = translate('PresentationPlugin.MediaItem',
'Automatic')
self.displayTypeLabel.setText(
translate('PresentationPlugin.MediaItem', 'Present using:'))
self.onNewPrompt = translate('PresentationPlugin.MediaItem', 'Select Presentation(s)')
self.Automatic = translate('PresentationPlugin.MediaItem', 'Automatic')
self.displayTypeLabel.setText(translate('PresentationPlugin.MediaItem', 'Present using:'))
def buildFileMaskString(self):
"""
@ -88,14 +81,12 @@ class PresentationMediaItem(MediaManagerItem):
fileType = u''
for controller in self.controllers:
if self.controllers[controller].enabled():
types = self.controllers[controller].supports + \
self.controllers[controller].alsosupports
types = self.controllers[controller].supports + self.controllers[controller].alsosupports
for type in types:
if fileType.find(type) == -1:
fileType += u'*.%s ' % type
self.plugin.serviceManager.supportedSuffixes(type)
self.onNewFileMasks = translate('PresentationPlugin.MediaItem',
'Presentations (%s)') % fileType
self.onNewFileMasks = translate('PresentationPlugin.MediaItem', 'Presentations (%s)') % fileType
def requiredIcons(self):
"""
@ -117,11 +108,10 @@ class PresentationMediaItem(MediaManagerItem):
self.displayLayout.setObjectName(u'displayLayout')
self.displayTypeLabel = QtGui.QLabel(self.presentationWidget)
self.displayTypeLabel.setObjectName(u'displayTypeLabel')
self.displayTypeComboBox = create_horizontal_adjusting_combo_box(
self.presentationWidget, u'displayTypeComboBox')
self.displayTypeComboBox = create_horizontal_adjusting_combo_box(self.presentationWidget,
u'displayTypeComboBox')
self.displayTypeLabel.setBuddy(self.displayTypeComboBox)
self.displayLayout.addRow(self.displayTypeLabel,
self.displayTypeComboBox)
self.displayLayout.addRow(self.displayTypeLabel, self.displayTypeComboBox)
# Add the Presentation widget to the page layout
self.pageLayout.addWidget(self.presentationWidget)
@ -130,8 +120,7 @@ class PresentationMediaItem(MediaManagerItem):
Populate the media manager tab
"""
self.listView.setIconSize(QtCore.QSize(88, 50))
files = SettingsManager.load_list(
self.settingsSection, u'presentations')
files = SettingsManager.load_list(self.settingsSection, u'presentations')
self.loadList(files, True)
self.populateDisplayTypes()
@ -166,8 +155,7 @@ class PresentationMediaItem(MediaManagerItem):
if not initialLoad:
Receiver.send_message(u'cursor_busy')
self.plugin.formParent.displayProgressBar(len(files))
# Sort the presentations by its filename considering language specific
# characters.
# Sort the presentations by its filename considering language specific characters.
files.sort(cmp=locale_compare,
key=lambda filename: os.path.split(unicode(filename))[1])
for file in files:
@ -185,19 +173,16 @@ class PresentationMediaItem(MediaManagerItem):
else:
if titles.count(filename) > 0:
if not initialLoad:
critical_error_message_box(
critical_error_message_box(translate('PresentationPlugin.MediaItem', 'File Exists'),
translate('PresentationPlugin.MediaItem',
'File Exists'),
translate('PresentationPlugin.MediaItem',
'A presentation with that filename already exists.')
'A presentation with that filename already exists.')
)
continue
controller_name = self.findControllerByType(filename)
if controller_name:
controller = self.controllers[controller_name]
doc = controller.add_document(unicode(file))
thumb = os.path.join(doc.get_thumbnail_folder(),
u'icon.png')
thumb = os.path.join(doc.get_thumbnail_folder(), u'icon.png')
preview = doc.get_thumbnail_path(1, True)
if not preview and not initialLoad:
doc.load_presentation()
@ -215,8 +200,7 @@ class PresentationMediaItem(MediaManagerItem):
icon = build_icon(u':/general/general_delete.png')
else:
critical_error_message_box(UiStrings().UnsupportedFile,
translate('PresentationPlugin.MediaItem',
'This type of presentation is not supported.'))
translate('PresentationPlugin.MediaItem', 'This type of presentation is not supported.'))
continue
item_name = QtGui.QListWidgetItem(filename)
item_name.setData(QtCore.Qt.UserRole, file)
@ -249,8 +233,7 @@ class PresentationMediaItem(MediaManagerItem):
Receiver.send_message(u'cursor_normal')
for row in row_list:
self.listView.takeItem(row)
SettingsManager.set_list(self.settingsSection,
u'presentations', self.getFileList())
SettingsManager.set_list(self.settingsSection, u'presentations', self.getFileList())
def generateSlideData(self, service_item, item=None, xmlVersion=False,
remote=False, context=ServiceItemContext.Service):
@ -296,21 +279,15 @@ class PresentationMediaItem(MediaManagerItem):
else:
# File is no longer present
if not remote:
critical_error_message_box(
critical_error_message_box(translate('PresentationPlugin.MediaItem', 'Missing Presentation'),
translate('PresentationPlugin.MediaItem',
'Missing Presentation'),
translate('PresentationPlugin.MediaItem',
'The presentation %s is incomplete,'
' please reload.') % filename)
'The presentation %s is incomplete, please reload.') % filename)
return False
else:
# File is no longer present
if not remote:
critical_error_message_box(
translate('PresentationPlugin.MediaItem',
'Missing Presentation'),
translate('PresentationPlugin.MediaItem',
'The presentation %s no longer exists.') % filename)
critical_error_message_box(translate('PresentationPlugin.MediaItem', 'Missing Presentation'),
translate('PresentationPlugin.MediaItem', 'The presentation %s no longer exists.') % filename)
return False
def findControllerByType(self, filename):

View File

@ -1,5 +1,5 @@
# -*- coding: utf-8 -*-
# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4
# vim: autoindent shiftwidth=4 expandtab textwidth=120 tabstop=4 softtabstop=4
###############################################################################
# OpenLP - Open Source Lyrics Projection #
@ -271,8 +271,7 @@ class Controller(object):
return
if not self.activate():
return
if self.doc.slidenumber and \
self.doc.slidenumber != self.doc.get_slide_number():
if self.doc.slidenumber and self.doc.slidenumber != self.doc.get_slide_number():
self.doc.goto_slide(self.doc.slidenumber)
self.doc.unblank_screen()
Receiver.send_message(u'live_display_hide', HideMode.Screen)
@ -296,30 +295,19 @@ class MessageListener(object):
self.preview_handler = Controller(False)
self.live_handler = Controller(True)
# messages are sent from core.ui.slidecontroller
QtCore.QObject.connect(Receiver.get_receiver(),
QtCore.SIGNAL(u'presentations_start'), self.startup)
QtCore.QObject.connect(Receiver.get_receiver(),
QtCore.SIGNAL(u'presentations_stop'), self.shutdown)
QtCore.QObject.connect(Receiver.get_receiver(),
QtCore.SIGNAL(u'presentations_hide'), self.hide)
QtCore.QObject.connect(Receiver.get_receiver(),
QtCore.SIGNAL(u'presentations_first'), self.first)
QtCore.QObject.connect(Receiver.get_receiver(),
QtCore.SIGNAL(u'presentations_previous'), self.previous)
QtCore.QObject.connect(Receiver.get_receiver(),
QtCore.SIGNAL(u'presentations_next'), self.next)
QtCore.QObject.connect(Receiver.get_receiver(),
QtCore.SIGNAL(u'presentations_last'), self.last)
QtCore.QObject.connect(Receiver.get_receiver(),
QtCore.SIGNAL(u'presentations_slide'), self.slide)
QtCore.QObject.connect(Receiver.get_receiver(),
QtCore.SIGNAL(u'presentations_blank'), self.blank)
QtCore.QObject.connect(Receiver.get_receiver(),
QtCore.SIGNAL(u'presentations_unblank'), self.unblank)
QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'presentations_start'), self.startup)
QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'presentations_stop'), self.shutdown)
QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'presentations_hide'), self.hide)
QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'presentations_first'), self.first)
QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'presentations_previous'), self.previous)
QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'presentations_next'), self.next)
QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'presentations_last'), self.last)
QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'presentations_slide'), self.slide)
QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'presentations_blank'), self.blank)
QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'presentations_unblank'), self.unblank)
self.timer = QtCore.QTimer()
self.timer.setInterval(500)
QtCore.QObject.connect(
self.timer, QtCore.SIGNAL(u'timeout()'), self.timeout)
QtCore.QObject.connect(self.timer, QtCore.SIGNAL(u'timeout()'), self.timeout)
def startup(self, message):
"""
@ -340,8 +328,7 @@ class MessageListener(object):
controller = self.live_handler
else:
controller = self.preview_handler
controller.add_handler(self.controllers[self.handler], file, hide_mode,
message[3])
controller.add_handler(self.controllers[self.handler], file, hide_mode, message[3])
def slide(self, message):
"""
@ -433,7 +420,7 @@ class MessageListener(object):
def timeout(self):
"""
The presentation may be timed or might be controlled by the
application directly, rather than through OpenLP. Poll occassionally
application directly, rather than through OpenLP. Poll occasionally
to check which slide is currently displayed so the slidecontroller
view can be updated
"""

View File

@ -1,5 +1,5 @@
# -*- coding: utf-8 -*-
# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4
# vim: autoindent shiftwidth=4 expandtab textwidth=120 tabstop=4 softtabstop=4
###############################################################################
# OpenLP - Open Source Lyrics Projection #
@ -56,8 +56,7 @@ class PowerpointController(PresentationController):
Initialise the class
"""
log.debug(u'Initialising')
PresentationController.__init__(self, plugin, u'Powerpoint',
PowerpointDocument)
PresentationController.__init__(self, plugin, u'Powerpoint', PowerpointDocument)
self.supports = [u'ppt', u'pps', u'pptx', u'ppsx']
self.process = None
@ -68,8 +67,7 @@ class PowerpointController(PresentationController):
log.debug(u'check_available')
if os.name == u'nt':
try:
_winreg.OpenKey(_winreg.HKEY_CLASSES_ROOT,
u'PowerPoint.Application').Close()
_winreg.OpenKey(_winreg.HKEY_CLASSES_ROOT, u'PowerPoint.Application').Close()
return True
except WindowsError:
pass
@ -126,13 +124,11 @@ class PowerpointDocument(PresentationDocument):
if not self.controller.process or not self.controller.process.Visible:
self.controller.start_process()
try:
self.controller.process.Presentations.Open(self.filepath, False,
False, True)
self.controller.process.Presentations.Open(self.filepath, False, False, True)
except pywintypes.com_error:
log.debug(u'PPT open failed')
return False
self.presentation = self.controller.process.Presentations(
self.controller.process.Presentations.Count)
self.presentation = self.controller.process.Presentations(self.controller.process.Presentations.Count)
self.create_thumbnails()
return True
@ -153,8 +149,7 @@ class PowerpointDocument(PresentationDocument):
return
for num in range(self.presentation.Slides.Count):
self.presentation.Slides(num + 1).Export(os.path.join(
self.get_thumbnail_folder(), 'slide%d.png' % (num + 1)),
'png', 320, 240)
self.get_thumbnail_folder(), 'slide%d.png' % (num + 1)), 'png', 320, 240)
def close_presentation(self):
"""
@ -254,8 +249,7 @@ class PowerpointDocument(PresentationDocument):
dpi = win32ui.GetActiveWindow().GetDC().GetDeviceCaps(88)
except win32ui.error:
try:
dpi = \
win32ui.GetForegroundWindow().GetDC().GetDeviceCaps(88)
dpi = win32ui.GetForegroundWindow().GetDC().GetDeviceCaps(88)
except win32ui.error:
dpi = 96
renderer = self.controller.plugin.renderer
@ -322,8 +316,7 @@ class PowerpointDocument(PresentationDocument):
``slide_no``
The slide the notes are required for, starting at 1.
"""
return _get_text_from_shapes(
self.presentation.Slides(slide_no).NotesPage.Shapes)
return _get_text_from_shapes(self.presentation.Slides(slide_no).NotesPage.Shapes)
def _get_text_from_shapes(shapes):
"""

View File

@ -1,5 +1,5 @@
# -*- coding: utf-8 -*-
# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4
# vim: autoindent shiftwidth=4 expandtab textwidth=120 tabstop=4 softtabstop=4
###############################################################################
# OpenLP - Open Source Lyrics Projection #
@ -40,7 +40,7 @@ log = logging.getLogger(__name__)
class PptviewController(PresentationController):
"""
Class to control interactions with PowerPOint Viewer Presentations
Class to control interactions with PowerPoint Viewer Presentations
It creates the runtime Environment , Loads the and Closes the Presentation
As well as triggering the correct activities based on the users input
"""
@ -52,8 +52,7 @@ class PptviewController(PresentationController):
"""
log.debug(u'Initialising')
self.process = None
PresentationController.__init__(self, plugin, u'Powerpoint Viewer',
PptviewDocument)
PresentationController.__init__(self, plugin, u'Powerpoint Viewer', PptviewDocument)
self.supports = [u'ppt', u'pps', u'pptx', u'ppsx']
def check_available(self):
@ -84,8 +83,8 @@ class PptviewController(PresentationController):
if self.process:
return
log.debug(u'start PPTView')
dllpath = os.path.join(self.plugin.pluginManager.basepath,
u'presentations', u'lib', u'pptviewlib', u'pptviewlib.dll')
dllpath = os.path.join(self.plugin.pluginManager.basepath, u'presentations', u'lib', u'pptviewlib',
u'pptviewlib.dll')
self.process = cdll.LoadLibrary(dllpath)
if log.isEnabledFor(logging.DEBUG):
self.process.SetDebug(1)
@ -117,7 +116,7 @@ class PptviewDocument(PresentationDocument):
def load_presentation(self):
"""
Called when a presentation is added to the SlideController.
It builds the environment, starts communcations with the background
It builds the environment, starts communication with the background
PptView task started earlier.
"""
log.debug(u'LoadPresentation')
@ -127,8 +126,7 @@ class PptviewDocument(PresentationDocument):
filepath = str(self.filepath.replace(u'/', u'\\'))
if not os.path.isdir(self.get_temp_folder()):
os.makedirs(self.get_temp_folder())
self.pptid = self.controller.process.OpenPPT(filepath, None, rect,
str(self.get_temp_folder()) + '\\slide')
self.pptid = self.controller.process.OpenPPT(filepath, None, rect, str(self.get_temp_folder()) + '\\slide')
if self.pptid >= 0:
self.create_thumbnails()
self.stop_presentation()
@ -146,14 +144,13 @@ class PptviewDocument(PresentationDocument):
return
log.debug(u'create_thumbnails proceeding')
for idx in range(self.get_slide_count()):
path = u'%s\\slide%s.bmp' % (self.get_temp_folder(),
unicode(idx + 1))
path = u'%s\\slide%s.bmp' % (self.get_temp_folder(), unicode(idx + 1))
self.convert_thumbnail(path, idx + 1)
def close_presentation(self):
"""
Close presentation and clean up objects
Triggerent by new object being added to SlideController orOpenLP
Triggered by new object being added to SlideController orOpenLP
being shut down
"""
log.debug(u'ClosePresentation')
@ -187,7 +184,7 @@ class PptviewDocument(PresentationDocument):
def unblank_screen(self):
"""
Unblanks (restores) the presentationn
Unblanks (restores) the presentation
"""
self.controller.process.Unblank(self.pptid)
self.blanked = False

View File

@ -1,5 +1,5 @@
# -*- coding: utf-8 -*-
# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4
# vim: autoindent shiftwidth=4 expandtab textwidth=120 tabstop=4 softtabstop=4
###############################################################################
# OpenLP - Open Source Lyrics Projection #
@ -33,8 +33,7 @@ import shutil
from PyQt4 import QtCore
from openlp.core.lib import Receiver, check_directory_exists, create_thumb, \
validate_thumb, Settings
from openlp.core.lib import Receiver, check_directory_exists, create_thumb, validate_thumb, Settings
from openlp.core.utils import AppLocation
log = logging.getLogger(__name__)
@ -124,7 +123,7 @@ class PresentationDocument(object):
def get_file_name(self):
"""
Return just the filename of the presention, without the directory
Return just the filename of the presentation, without the directory
"""
return os.path.split(self.filepath)[1]
@ -179,7 +178,7 @@ class PresentationDocument(object):
def unblank_screen(self):
"""
Unblanks (restores) the presentationn
Unblanks (restores) the presentation
"""
pass
@ -275,8 +274,7 @@ class PresentationDocument(object):
prefix = u'live'
else:
prefix = u'preview'
Receiver.send_message(u'slidecontroller_%s_change' % prefix,
self.slidenumber - 1)
Receiver.send_message(u'slidecontroller_%s_change' % prefix, self.slidenumber - 1)
def get_slide_text(self, slide_no):
"""
@ -379,11 +377,8 @@ class PresentationController(object):
self.document_class = document_class
self.settings_section = self.plugin.settingsSection
self.available = None
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.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'
check_directory_exists(self.thumbnail_folder)
check_directory_exists(self.temp_folder)
@ -392,8 +387,7 @@ class PresentationController(object):
"""
Return whether the controller is currently enabled
"""
if Settings().value(self.settings_section + u'/' + self.name,
QtCore.Qt.Checked) == QtCore.Qt.Checked:
if Settings().value(self.settings_section + u'/' + self.name, QtCore.Qt.Checked) == QtCore.Qt.Checked:
return self.is_available()
else:
return False

View File

@ -1,5 +1,5 @@
# -*- coding: utf-8 -*-
# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4
# vim: autoindent shiftwidth=4 expandtab textwidth=120 tabstop=4 softtabstop=4
###############################################################################
# OpenLP - Open Source Lyrics Projection #
@ -78,25 +78,21 @@ class PresentationTab(SettingsTab):
"""
Make any translation changes
"""
self.ControllersGroupBox.setTitle(
translate('PresentationPlugin.PresentationTab',
'Available Controllers'))
self.ControllersGroupBox.setTitle(translate('PresentationPlugin.PresentationTab', 'Available Controllers'))
for key in self.controllers:
controller = self.controllers[key]
checkbox = self.PresenterCheckboxes[controller.name]
self.setControllerText(checkbox, controller)
self.AdvancedGroupBox.setTitle(UiStrings().Advanced)
self.OverrideAppCheckBox.setText(
translate('PresentationPlugin.PresentationTab',
'Allow presentation application to be overridden'))
translate('PresentationPlugin.PresentationTab', 'Allow presentation application to be overridden'))
def setControllerText(self, checkbox, controller):
if checkbox.isEnabled():
checkbox.setText(controller.name)
else:
checkbox.setText(
translate('PresentationPlugin.PresentationTab',
'%s (unavailable)') % controller.name)
translate('PresentationPlugin.PresentationTab', '%s (unavailable)') % controller.name)
def load(self):
"""
@ -105,11 +101,9 @@ class PresentationTab(SettingsTab):
for key in self.controllers:
controller = self.controllers[key]
checkbox = self.PresenterCheckboxes[controller.name]
checkbox.setChecked(Settings().value(
self.settingsSection + u'/' + controller.name,
QtCore.Qt.Checked))
self.OverrideAppCheckBox.setChecked(Settings().value(
self.settingsSection + u'/override app', QtCore.Qt.Unchecked))
checkbox.setChecked(Settings().value(self.settingsSection + u'/' + controller.name, QtCore.Qt.Checked))
self.OverrideAppCheckBox.setChecked(Settings().value(self.settingsSection + u'/override app',
QtCore.Qt.Unchecked))
def save(self):
"""
@ -125,8 +119,7 @@ class PresentationTab(SettingsTab):
if controller.is_available():
checkbox = self.PresenterCheckboxes[controller.name]
setting_key = self.settingsSection + u'/' + controller.name
if Settings().value(setting_key, QtCore.Qt.Checked) != \
checkbox.checkState():
if Settings().value(setting_key, QtCore.Qt.Checked) != checkbox.checkState():
changed = True
Settings().setValue(setting_key, checkbox.checkState())
if checkbox.isChecked():
@ -134,10 +127,8 @@ class PresentationTab(SettingsTab):
else:
controller.kill()
setting_key = self.settingsSection + u'/override app'
if Settings().value(setting_key, QtCore.Qt.Checked) != \
self.OverrideAppCheckBox.checkState():
Settings().setValue(setting_key,
self.OverrideAppCheckBox.checkState())
if Settings().value(setting_key, QtCore.Qt.Checked) != self.OverrideAppCheckBox.checkState():
Settings().setValue(setting_key, self.OverrideAppCheckBox.checkState())
changed = True
if changed:
self.parent.resetSupportedSuffixes()

View File

@ -1,5 +1,5 @@
# -*- coding: utf-8 -*-
# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4
# vim: autoindent shiftwidth=4 expandtab textwidth=120 tabstop=4 softtabstop=4
###############################################################################
# OpenLP - Open Source Lyrics Projection #
@ -64,8 +64,7 @@ class PresentationPlugin(Plugin):
Create the settings Tab
"""
visible_name = self.getString(StringContent.VisibleName)
self.settingsTab = PresentationTab(parent, self.name,
visible_name[u'title'], self.controllers, self.iconPath)
self.settingsTab = PresentationTab(parent, self.name, visible_name[u'title'], self.controllers, self.iconPath)
def initialise(self):
"""
@ -120,12 +119,10 @@ class PresentationPlugin(Plugin):
AppLocation.get_directory(AppLocation.PluginsDir),
u'presentations', u'lib')
for filename in os.listdir(controller_dir):
if filename.endswith(u'controller.py') and \
not filename == 'presentationcontroller.py':
if filename.endswith(u'controller.py') and not filename == 'presentationcontroller.py':
path = os.path.join(controller_dir, filename)
if os.path.isfile(path):
modulename = u'openlp.plugins.presentations.lib.' + \
os.path.splitext(filename)[0]
modulename = u'openlp.plugins.presentations.lib.' + os.path.splitext(filename)[0]
log.debug(u'Importing controller %s', modulename)
try:
__import__(modulename, globals(), locals(), [])
@ -155,30 +152,22 @@ class PresentationPlugin(Plugin):
"""
## Name PluginList ##
self.textStrings[StringContent.Name] = {
u'singular': translate('PresentationPlugin', 'Presentation',
'name singular'),
u'plural': translate('PresentationPlugin', 'Presentations',
'name plural')
u'singular': translate('PresentationPlugin', 'Presentation', 'name singular'),
u'plural': translate('PresentationPlugin', 'Presentations', 'name plural')
}
## Name for MediaDockManager, SettingsManager ##
self.textStrings[StringContent.VisibleName] = {
u'title': translate('PresentationPlugin', 'Presentations',
'container title')
u'title': translate('PresentationPlugin', 'Presentations', 'container title')
}
# Middle Header Bar
tooltips = {
u'load': translate('PresentationPlugin',
'Load a new presentation.'),
u'load': translate('PresentationPlugin', 'Load a new presentation.'),
u'import': u'',
u'new': u'',
u'edit': u'',
u'delete': translate('PresentationPlugin',
'Delete the selected presentation.'),
u'preview': translate('PresentationPlugin',
'Preview the selected presentation.'),
u'live': translate('PresentationPlugin',
'Send the selected presentation live.'),
u'service': translate('PresentationPlugin',
'Add the selected presentation to the service.')
u'delete': translate('PresentationPlugin', 'Delete the selected presentation.'),
u'preview': translate('PresentationPlugin', 'Preview the selected presentation.'),
u'live': translate('PresentationPlugin', 'Send the selected presentation live.'),
u'service': translate('PresentationPlugin', 'Add the selected presentation to the service.')
}
self.setPluginUiTextStrings(tooltips)

View File

@ -1,5 +1,5 @@
# -*- coding: utf-8 -*-
# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4
# vim: autoindent shiftwidth=4 expandtab textwidth=120 tabstop=4 softtabstop=4
###############################################################################
# OpenLP - Open Source Lyrics Projection #

View File

@ -1,5 +1,5 @@
# -*- coding: utf-8 -*-
# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4
# vim: autoindent shiftwidth=4 expandtab textwidth=120 tabstop=4 softtabstop=4
###############################################################################
# OpenLP - Open Source Lyrics Projection #
@ -156,9 +156,7 @@ class HttpServer(object):
"""
log.debug(u'Initialise httpserver')
self.plugin = plugin
self.html_dir = os.path.join(
AppLocation.get_directory(AppLocation.PluginsDir),
u'remotes', u'html')
self.html_dir = os.path.join(AppLocation.get_directory(AppLocation.PluginsDir), u'remotes', u'html')
self.connections = []
self.current_item = None
self.current_slide = None
@ -171,20 +169,15 @@ class HttpServer(object):
clients. Listen out for socket connections.
"""
log.debug(u'Start TCP server')
port = Settings().value(
self.plugin.settingsSection + u'/port', 4316)
address = Settings().value(
self.plugin.settingsSection + u'/ip address', u'0.0.0.0')
port = Settings().value(self.plugin.settingsSection + u'/port', 4316)
address = Settings().value(self.plugin.settingsSection + u'/ip address', u'0.0.0.0')
self.server = QtNetwork.QTcpServer()
self.server.listen(QtNetwork.QHostAddress(address), port)
QtCore.QObject.connect(Receiver.get_receiver(),
QtCore.SIGNAL(u'slidecontroller_live_changed'),
QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'slidecontroller_live_changed'),
self.slide_change)
QtCore.QObject.connect(Receiver.get_receiver(),
QtCore.SIGNAL(u'slidecontroller_live_started'),
QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'slidecontroller_live_started'),
self.item_change)
QtCore.QObject.connect(self.server,
QtCore.SIGNAL(u'newConnection()'), self.new_connection)
QtCore.QObject.connect(self.server, QtCore.SIGNAL(u'newConnection()'), self.new_connection)
log.debug(u'TCP listening on port %d' % port)
def slide_change(self, row):
@ -234,8 +227,7 @@ class HttpConnection(object):
"""
Initialise the http connection. Listen out for socket signals.
"""
log.debug(u'Initialise HttpConnection: %s' %
socket.peerAddress())
log.debug(u'Initialise HttpConnection: %s' % socket.peerAddress())
self.socket = socket
self.parent = parent
self.routes = [
@ -252,10 +244,8 @@ class HttpConnection(object):
(r'^/api/(.*)/live$', self.go_live),
(r'^/api/(.*)/add$', self.add_to_service)
]
QtCore.QObject.connect(self.socket, QtCore.SIGNAL(u'readyRead()'),
self.ready_read)
QtCore.QObject.connect(self.socket, QtCore.SIGNAL(u'disconnected()'),
self.disconnected)
QtCore.QObject.connect(self.socket, QtCore.SIGNAL(u'readyRead()'), self.ready_read)
QtCore.QObject.connect(self.socket, QtCore.SIGNAL(u'disconnected()'), self.disconnected)
self.translate()
def _get_service_items(self):
@ -281,13 +271,10 @@ class HttpConnection(object):
Translate various strings in the mobile app.
"""
self.template_vars = {
'app_title': translate('RemotePlugin.Mobile', 'OpenLP 2.0 Remote'),
'stage_title': translate('RemotePlugin.Mobile',
'OpenLP 2.0 Stage View'),
'service_manager': translate('RemotePlugin.Mobile',
'Service Manager'),
'slide_controller': translate('RemotePlugin.Mobile',
'Slide Controller'),
'app_title': translate('RemotePlugin.Mobile', 'OpenLP 2.1 Remote'),
'stage_title': translate('RemotePlugin.Mobile', 'OpenLP 2.1 Stage View'),
'service_manager': translate('RemotePlugin.Mobile', 'Service Manager'),
'slide_controller': translate('RemotePlugin.Mobile', 'Slide Controller'),
'alerts': translate('RemotePlugin.Mobile', 'Alerts'),
'search': translate('RemotePlugin.Mobile', 'Search'),
'home': translate('RemotePlugin.Mobile', 'Home'),
@ -301,10 +288,8 @@ class HttpConnection(object):
'text': translate('RemotePlugin.Mobile', 'Text'),
'show_alert': translate('RemotePlugin.Mobile', 'Show Alert'),
'go_live': translate('RemotePlugin.Mobile', 'Go Live'),
'add_to_service': translate('RemotePlugin.Mobile',
'Add to Service'),
'add_and_go_to_service': translate('RemotePlugin.Mobile',
'Add &amp; Go to Service'),
'add_to_service': translate('RemotePlugin.Mobile', 'Add to Service'),
'add_and_go_to_service': translate('RemotePlugin.Mobile', 'Add &amp; Go to Service'),
'no_results': translate('RemotePlugin.Mobile', 'No Results'),
'options': translate('RemotePlugin.Mobile', 'Options'),
'service': translate('RemotePlugin.Mobile', 'Service'),
@ -367,8 +352,7 @@ class HttpConnection(object):
if ext == u'.html':
mimetype = u'text/html'
variables = self.template_vars
html = Template(filename=path, input_encoding=u'utf-8',
output_encoding=u'utf-8').render(**variables)
html = Template(filename=path, input_encoding=u'utf-8', output_encoding=u'utf-8').render(**variables)
elif ext == u'.css':
mimetype = u'text/css'
elif ext == u'.js':
@ -404,13 +388,11 @@ class HttpConnection(object):
result = {
u'service': self.parent.plugin.serviceManager.serviceId,
u'slide': self.parent.current_slide or 0,
u'item': self.parent.current_item._uuid \
if self.parent.current_item else u'',
u'item': self.parent.current_item._uuid if self.parent.current_item else u'',
u'twelve':Settings().value(u'remotes/twelve hour', True),
u'blank': self.parent.plugin.liveController.blankScreen.isChecked(),
u'theme': self.parent.plugin.liveController.themeScreen.isChecked(),
u'display': \
self.parent.plugin.liveController.desktopScreen.isChecked()
u'display': self.parent.plugin.liveController.desktopScreen.isChecked()
}
return HttpResponse(json.dumps({u'results': result}),
{u'Content-Type': u'application/json'})
@ -433,8 +415,7 @@ class HttpConnection(object):
plugin = self.parent.plugin.pluginManager.get_plugin_by_name("alerts")
if plugin.status == PluginStatus.Active:
try:
text = json.loads(
self.url_params[u'data'][0])[u'request'][u'text']
text = json.loads(self.url_params[u'data'][0])[u'request'][u'text']
except KeyError, ValueError:
return HttpResponse(code=u'400 Bad Request')
text = urllib.unquote(text)
@ -498,8 +479,7 @@ class HttpConnection(object):
def service(self, action):
event = u'servicemanager_%s' % action
if action == u'list':
return HttpResponse(
json.dumps({u'results': {u'items': self._get_service_items()}}),
return HttpResponse(json.dumps({u'results': {u'items': self._get_service_items()}}),
{u'Content-Type': u'application/json'})
else:
event += u'_item'
@ -525,10 +505,8 @@ class HttpConnection(object):
if action == u'search':
searches = []
for plugin in self.parent.plugin.pluginManager.plugins:
if plugin.status == PluginStatus.Active and \
plugin.mediaItem and plugin.mediaItem.hasSearch:
searches.append([plugin.name, unicode(
plugin.textStrings[StringContent.Name][u'plural'])])
if plugin.status == PluginStatus.Active and plugin.mediaItem and plugin.mediaItem.hasSearch:
searches.append([plugin.name, unicode(plugin.textStrings[StringContent.Name][u'plural'])])
return HttpResponse(
json.dumps({u'results': {u'items': searches}}),
{u'Content-Type': u'application/json'})
@ -546,13 +524,11 @@ class HttpConnection(object):
return HttpResponse(code=u'400 Bad Request')
text = urllib.unquote(text)
plugin = self.parent.plugin.pluginManager.get_plugin_by_name(type)
if plugin.status == PluginStatus.Active and \
plugin.mediaItem and plugin.mediaItem.hasSearch:
if plugin.status == PluginStatus.Active and plugin.mediaItem and plugin.mediaItem.hasSearch:
results = plugin.mediaItem.search(text, False)
else:
results = []
return HttpResponse(
json.dumps({u'results': {u'items': results}}),
return HttpResponse(json.dumps({u'results': {u'items': results}}),
{u'Content-Type': u'application/json'})
def go_live(self, type):

View File

@ -1,5 +1,5 @@
# -*- coding: utf-8 -*-
# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4
# vim: autoindent shiftwidth=4 expandtab textwidth=120 tabstop=4 softtabstop=4
###############################################################################
# OpenLP - Open Source Lyrics Projection #
@ -45,19 +45,16 @@ class RemoteTab(SettingsTab):
SettingsTab.setupUi(self)
self.serverSettingsGroupBox = QtGui.QGroupBox(self.leftColumn)
self.serverSettingsGroupBox.setObjectName(u'serverSettingsGroupBox')
self.serverSettingsLayout = QtGui.QFormLayout(
self.serverSettingsGroupBox)
self.serverSettingsLayout = QtGui.QFormLayout(self.serverSettingsGroupBox)
self.serverSettingsLayout.setObjectName(u'serverSettingsLayout')
self.addressLabel = QtGui.QLabel(self.serverSettingsGroupBox)
self.addressLabel.setObjectName(u'addressLabel')
self.addressEdit = QtGui.QLineEdit(self.serverSettingsGroupBox)
self.addressEdit.setSizePolicy(
QtGui.QSizePolicy.Preferred, QtGui.QSizePolicy.Fixed)
self.addressEdit.setSizePolicy(QtGui.QSizePolicy.Preferred, QtGui.QSizePolicy.Fixed)
self.addressEdit.setValidator(QtGui.QRegExpValidator(QtCore.QRegExp(
u'\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}'), self))
self.addressEdit.setObjectName(u'addressEdit')
QtCore.QObject.connect(self.addressEdit,
QtCore.SIGNAL(u'textChanged(const QString&)'), self.setUrls)
QtCore.QObject.connect(self.addressEdit, QtCore.SIGNAL(u'textChanged(const QString&)'), self.setUrls)
self.serverSettingsLayout.addRow(self.addressLabel, self.addressEdit)
self.twelveHourCheckBox = QtGui.QCheckBox(self.serverSettingsGroupBox)
self.twelveHourCheckBox.setObjectName(u'twelveHourCheckBox')
@ -67,8 +64,7 @@ class RemoteTab(SettingsTab):
self.portSpinBox = QtGui.QSpinBox(self.serverSettingsGroupBox)
self.portSpinBox.setMaximum(32767)
self.portSpinBox.setObjectName(u'portSpinBox')
QtCore.QObject.connect(self.portSpinBox,
QtCore.SIGNAL(u'valueChanged(int)'), self.setUrls)
QtCore.QObject.connect(self.portSpinBox, QtCore.SIGNAL(u'valueChanged(int)'), self.setUrls)
self.serverSettingsLayout.addRow(self.portLabel, self.portSpinBox)
self.remoteUrlLabel = QtGui.QLabel(self.serverSettingsGroupBox)
self.remoteUrlLabel.setObjectName(u'remoteUrlLabel')
@ -89,8 +85,7 @@ class RemoteTab(SettingsTab):
self.qrLayout = QtGui.QVBoxLayout(self.androidAppGroupBox)
self.qrLayout.setObjectName(u'qrLayout')
self.qrCodeLabel = QtGui.QLabel(self.androidAppGroupBox)
self.qrCodeLabel.setPixmap(QtGui.QPixmap(
u':/remotes/android_app_qr.png'))
self.qrCodeLabel.setPixmap(QtGui.QPixmap(u':/remotes/android_app_qr.png'))
self.qrCodeLabel.setAlignment(QtCore.Qt.AlignCenter)
self.qrCodeLabel.setObjectName(u'qrCodeLabel')
self.qrLayout.addWidget(self.qrCodeLabel)
@ -101,26 +96,18 @@ class RemoteTab(SettingsTab):
self.qrLayout.addWidget(self.qrDescriptionLabel)
self.leftLayout.addStretch()
self.rightLayout.addStretch()
QtCore.QObject.connect(self.twelveHourCheckBox,
QtCore.SIGNAL(u'stateChanged(int)'),
QtCore.QObject.connect(self.twelveHourCheckBox, QtCore.SIGNAL(u'stateChanged(int)'),
self.onTwelveHourCheckBoxChanged)
def retranslateUi(self):
self.serverSettingsGroupBox.setTitle(
translate('RemotePlugin.RemoteTab', 'Server Settings'))
self.addressLabel.setText(translate('RemotePlugin.RemoteTab',
'Serve on IP address:'))
self.portLabel.setText(translate('RemotePlugin.RemoteTab',
'Port number:'))
self.remoteUrlLabel.setText(translate('RemotePlugin.RemoteTab',
'Remote URL:'))
self.stageUrlLabel.setText(translate('RemotePlugin.RemoteTab',
'Stage view URL:'))
self.twelveHourCheckBox.setText(
translate('RemotePlugin.RemoteTab',
'Display stage time in 12h format'))
self.androidAppGroupBox.setTitle(
translate('RemotePlugin.RemoteTab', 'Android App'))
self.addressLabel.setText(translate('RemotePlugin.RemoteTab', 'Serve on IP address:'))
self.portLabel.setText(translate('RemotePlugin.RemoteTab', 'Port number:'))
self.remoteUrlLabel.setText(translate('RemotePlugin.RemoteTab', 'Remote URL:'))
self.stageUrlLabel.setText(translate('RemotePlugin.RemoteTab', 'Stage view URL:'))
self.twelveHourCheckBox.setText(translate('RemotePlugin.RemoteTab', 'Display stage time in 12h format'))
self.androidAppGroupBox.setTitle(translate('RemotePlugin.RemoteTab', 'Android App'))
self.qrDescriptionLabel.setText(translate('RemotePlugin.RemoteTab',
'Scan the QR code or click <a href="https://play.google.com/store/'
'apps/details?id=org.openlp.android">download</a> to install the '
@ -133,13 +120,11 @@ class RemoteTab(SettingsTab):
for iface in ifaces:
if not iface.isValid():
continue
if not (iface.flags() & (QtNetwork.QNetworkInterface.IsUp |
QtNetwork.QNetworkInterface.IsRunning)):
if not (iface.flags() & (QtNetwork.QNetworkInterface.IsUp | QtNetwork.QNetworkInterface.IsRunning)):
continue
for addr in iface.addressEntries():
ip = addr.ip()
if ip.protocol() == 0 and \
ip != QtNetwork.QHostAddress.LocalHost:
if ip.protocol() == 0 and ip != QtNetwork.QHostAddress.LocalHost:
ipAddress = ip
break
else:
@ -150,27 +135,20 @@ class RemoteTab(SettingsTab):
self.stageUrl.setText(u'<a href="%s">%s</a>' % (url, url))
def load(self):
self.portSpinBox.setValue(
Settings().value(self.settingsSection + u'/port', 4316))
self.addressEdit.setText(
Settings().value(self.settingsSection + u'/ip address', ZERO_URL))
self.twelveHour = Settings().value(
self.settingsSection + u'/twelve hour', True)
self.portSpinBox.setValue(Settings().value(self.settingsSection + u'/port', 4316))
self.addressEdit.setText(Settings().value(self.settingsSection + u'/ip address', ZERO_URL))
self.twelveHour = Settings().value(self.settingsSection + u'/twelve hour', True)
self.twelveHourCheckBox.setChecked(self.twelveHour)
self.setUrls()
def save(self):
changed = False
if Settings().value(self.settingsSection + u'/ip address', ZERO_URL !=
self.addressEdit.text() or Settings().value(self.settingsSection +
u'/port', 4316) != self.portSpinBox.value()):
if Settings().value(self.settingsSection + u'/ip address', ZERO_URL != self.addressEdit.text() or
Settings().value(self.settingsSection + u'/port', 4316) != self.portSpinBox.value()):
changed = True
Settings().setValue(self.settingsSection + u'/port',
self.portSpinBox.value())
Settings().setValue(self.settingsSection + u'/ip address',
self.addressEdit.text())
Settings().setValue(self.settingsSection + u'/twelve hour',
self.twelveHour)
Settings().setValue(self.settingsSection + u'/port', self.portSpinBox.value())
Settings().setValue(self.settingsSection + u'/ip address', self.addressEdit.text())
Settings().setValue(self.settingsSection + u'/twelve hour', self.twelveHour)
if changed:
Receiver.send_message(u'remotes_config_updated')

View File

@ -1,5 +1,5 @@
# -*- coding: utf-8 -*-
# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4
# vim: autoindent shiftwidth=4 expandtab textwidth=120 tabstop=4 softtabstop=4
###############################################################################
# OpenLP - Open Source Lyrics Projection #
@ -41,8 +41,7 @@ class RemotesPlugin(Plugin):
"""
remotes constructor
"""
Plugin.__init__(self, u'remotes', plugin_helpers,
settings_tab_class=RemoteTab)
Plugin.__init__(self, u'remotes', plugin_helpers, settings_tab_class=RemoteTab)
self.iconPath = u':/plugins/plugin_remote.png'
self.icon = build_icon(self.iconPath)
self.weight = -1

View File

@ -1,5 +1,5 @@
# -*- coding: utf-8 -*-
# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4
# vim: autoindent shiftwidth=4 expandtab textwidth=120 tabstop=4 softtabstop=4
###############################################################################
# OpenLP - Open Source Lyrics Projection #

View File

@ -1,5 +1,5 @@
# -*- coding: utf-8 -*-
# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4
# vim: autoindent shiftwidth=4 expandtab textwidth=120 tabstop=4 softtabstop=4
###############################################################################
# OpenLP - Open Source Lyrics Projection #

View File

@ -1,5 +1,5 @@
# -*- coding: utf-8 -*-
# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4
# vim: autoindent shiftwidth=4 expandtab textwidth=120 tabstop=4 softtabstop=4
###############################################################################
# OpenLP - Open Source Lyrics Projection #
@ -59,18 +59,13 @@ class Ui_AuthorsDialog(object):
self.displayLabel.setBuddy(self.displayEdit)
self.authorLayout.addRow(self.displayLabel, self.displayEdit)
self.dialogLayout.addLayout(self.authorLayout)
self.buttonBox = create_button_box(authorsDialog, u'buttonBox',
[u'cancel', u'save'])
self.buttonBox = create_button_box(authorsDialog, u'buttonBox', [u'cancel', u'save'])
self.dialogLayout.addWidget(self.buttonBox)
self.retranslateUi(authorsDialog)
authorsDialog.setMaximumHeight(authorsDialog.sizeHint().height())
def retranslateUi(self, authorsDialog):
authorsDialog.setWindowTitle(
translate('SongsPlugin.AuthorsForm', 'Author Maintenance'))
self.displayLabel.setText(
translate('SongsPlugin.AuthorsForm', 'Display name:'))
self.firstNameLabel.setText(
translate('SongsPlugin.AuthorsForm', 'First name:'))
self.lastNameLabel.setText(
translate('SongsPlugin.AuthorsForm', 'Last name:'))
authorsDialog.setWindowTitle(translate('SongsPlugin.AuthorsForm', 'Author Maintenance'))
self.displayLabel.setText(translate('SongsPlugin.AuthorsForm', 'Display name:'))
self.firstNameLabel.setText(translate('SongsPlugin.AuthorsForm', 'First name:'))
self.lastNameLabel.setText(translate('SongsPlugin.AuthorsForm', 'Last name:'))

View File

@ -1,5 +1,5 @@
# -*- coding: utf-8 -*-
# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4
# vim: autoindent shiftwidth=4 expandtab textwidth=120 tabstop=4 softtabstop=4
###############################################################################
# OpenLP - Open Source Lyrics Projection #
@ -44,11 +44,9 @@ class AuthorsForm(QtGui.QDialog, Ui_AuthorsDialog):
QtGui.QDialog.__init__(self, parent)
self.setupUi(self)
self._autoDisplayName = False
QtCore.QObject.connect(self.firstNameEdit,
QtCore.SIGNAL(u'textEdited(QString)'),
QtCore.QObject.connect(self.firstNameEdit, QtCore.SIGNAL(u'textEdited(QString)'),
self.onFirstNameEditTextEdited)
QtCore.QObject.connect(self.lastNameEdit,
QtCore.SIGNAL(u'textEdited(QString)'),
QtCore.QObject.connect(self.lastNameEdit, QtCore.SIGNAL(u'textEdited(QString)'),
self.onLastNameEditTextEdited)
def exec_(self, clear=True):
@ -82,24 +80,20 @@ class AuthorsForm(QtGui.QDialog, Ui_AuthorsDialog):
def accept(self):
if not self.firstNameEdit.text():
critical_error_message_box(
message=translate('SongsPlugin.AuthorsForm',
'You need to type in the first name of the author.'))
message=translate('SongsPlugin.AuthorsForm', 'You need to type in the first name of the author.'))
self.firstNameEdit.setFocus()
return False
elif not self.lastNameEdit.text():
critical_error_message_box(
message=translate('SongsPlugin.AuthorsForm',
'You need to type in the last name of the author.'))
message=translate('SongsPlugin.AuthorsForm', 'You need to type in the last name of the author.'))
self.lastNameEdit.setFocus()
return False
elif not self.displayEdit.text():
if critical_error_message_box(
message=translate('SongsPlugin.AuthorsForm',
'You have not set a display name for the '
'author, combine the first and last names?'),
'You have not set a display name for the author, combine the first and last names?'),
parent=self, question=True) == QtGui.QMessageBox.Yes:
self.displayEdit.setText(self.firstNameEdit.text() + \
u' ' + self.lastNameEdit.text())
self.displayEdit.setText(self.firstNameEdit.text() + u' ' + self.lastNameEdit.text())
return QtGui.QDialog.accept(self)
else:
self.displayEdit.setFocus()

View File

@ -1,5 +1,5 @@
# -*- coding: utf-8 -*-
# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4
# vim: autoindent shiftwidth=4 expandtab textwidth=120 tabstop=4 softtabstop=4
###############################################################################
# OpenLP - Open Source Lyrics Projection #
@ -37,8 +37,7 @@ class Ui_EditSongDialog(object):
def setupUi(self, editSongDialog):
editSongDialog.setObjectName(u'editSongDialog')
editSongDialog.resize(650, 400)
editSongDialog.setWindowIcon(
build_icon(u':/icon/openlp-logo-16x16.png'))
editSongDialog.setWindowIcon(build_icon(u':/icon/openlp-logo-16x16.png'))
editSongDialog.setModal(True)
self.dialogLayout = QtGui.QVBoxLayout(editSongDialog)
self.dialogLayout.setSpacing(8)
@ -68,16 +67,12 @@ class Ui_EditSongDialog(object):
self.lyricsLabel = QtGui.QLabel(self.lyricsTab)
self.lyricsLabel.setFixedHeight(self.titleEdit.sizeHint().height())
self.lyricsLabel.setObjectName(u'lyricsLabel')
self.lyricsTabLayout.addWidget(self.lyricsLabel, 2, 0,
QtCore.Qt.AlignTop)
self.lyricsTabLayout.addWidget(self.lyricsLabel, 2, 0, QtCore.Qt.AlignTop)
self.verseListWidget = SingleColumnTableWidget(self.lyricsTab)
self.verseListWidget.setAlternatingRowColors(True)
self.verseListWidget.setSelectionBehavior(
QtGui.QAbstractItemView.SelectRows)
self.verseListWidget.setSelectionMode(
QtGui.QAbstractItemView.SingleSelection)
self.verseListWidget.setEditTriggers(
QtGui.QAbstractItemView.NoEditTriggers)
self.verseListWidget.setSelectionBehavior(QtGui.QAbstractItemView.SelectRows)
self.verseListWidget.setSelectionMode(QtGui.QAbstractItemView.SingleSelection)
self.verseListWidget.setEditTriggers(QtGui.QAbstractItemView.NoEditTriggers)
self.verseListWidget.setObjectName(u'verseListWidget')
self.lyricsLabel.setBuddy(self.verseListWidget)
self.lyricsTabLayout.addWidget(self.verseListWidget, 2, 1)
@ -118,8 +113,7 @@ class Ui_EditSongDialog(object):
self.authorsLayout.setObjectName(u'authorsLayout')
self.authorAddLayout = QtGui.QHBoxLayout()
self.authorAddLayout.setObjectName(u'authorAddLayout')
self.authorsComboBox = editSongDialogComboBox(
self.authorsGroupBox, u'authorsComboBox')
self.authorsComboBox = editSongDialogComboBox(self.authorsGroupBox, u'authorsComboBox')
self.authorAddLayout.addWidget(self.authorsComboBox)
self.authorAddButton = QtGui.QPushButton(self.authorsGroupBox)
self.authorAddButton.setObjectName(u'authorAddButton')
@ -153,8 +147,7 @@ class Ui_EditSongDialog(object):
self.topicsLayout.setObjectName(u'topicsLayout')
self.topicAddLayout = QtGui.QHBoxLayout()
self.topicAddLayout.setObjectName(u'topicAddLayout')
self.topicsComboBox = editSongDialogComboBox(
self.topicsGroupBox, u'topicsComboBox')
self.topicsComboBox = editSongDialogComboBox(self.topicsGroupBox, u'topicsComboBox')
self.topicAddLayout.addWidget(self.topicsComboBox)
self.topicAddButton = QtGui.QPushButton(self.topicsGroupBox)
self.topicAddButton.setObjectName(u'topicAddButton')
@ -178,18 +171,15 @@ class Ui_EditSongDialog(object):
self.songBookLayout.setObjectName(u'songBookLayout')
self.songBookNameLabel = QtGui.QLabel(self.songBookGroupBox)
self.songBookNameLabel.setObjectName(u'songBookNameLabel')
self.songBookComboBox = editSongDialogComboBox(
self.songBookGroupBox, u'songBookComboBox')
self.songBookComboBox = editSongDialogComboBox(self.songBookGroupBox, u'songBookComboBox')
self.songBookNameLabel.setBuddy(self.songBookComboBox)
self.songBookLayout.addRow(self.songBookNameLabel,
self.songBookComboBox)
self.songBookLayout.addRow(self.songBookNameLabel, self.songBookComboBox)
self.songBookNumberLabel = QtGui.QLabel(self.songBookGroupBox)
self.songBookNumberLabel.setObjectName(u'songBookNumberLabel')
self.songBookNumberEdit = QtGui.QLineEdit(self.songBookGroupBox)
self.songBookNumberEdit.setObjectName(u'songBookNumberEdit')
self.songBookNumberLabel.setBuddy(self.songBookNumberEdit)
self.songBookLayout.addRow(self.songBookNumberLabel,
self.songBookNumberEdit)
self.songBookLayout.addRow(self.songBookNumberLabel, self.songBookNumberEdit)
self.authorsRightLayout.addWidget(self.songBookGroupBox)
self.authorsTabLayout.addLayout(self.authorsRightLayout)
self.songTabWidget.addTab(self.authorsTab, u'')
@ -204,8 +194,7 @@ class Ui_EditSongDialog(object):
self.themeGroupBox.setObjectName(u'themeGroupBox')
self.themeLayout = QtGui.QHBoxLayout(self.themeGroupBox)
self.themeLayout.setObjectName(u'themeLayout')
self.themeComboBox = editSongDialogComboBox(
self.themeGroupBox, u'themeComboBox')
self.themeComboBox = editSongDialogComboBox(self.themeGroupBox, u'themeComboBox')
self.themeLayout.addWidget(self.themeComboBox)
self.themeAddButton = QtGui.QPushButton(self.themeGroupBox)
self.themeAddButton.setObjectName(u'themeAddButton')
@ -269,10 +258,8 @@ class Ui_EditSongDialog(object):
self.audioRemoveAllButton.setObjectName(u'audioRemoveAllButton')
self.audioButtonsLayout.addWidget(self.audioRemoveAllButton)
self.audioButtonsLayout.addStretch(1)
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.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)
@ -285,89 +272,59 @@ class Ui_EditSongDialog(object):
self.warningLabel.setObjectName(u'warningLabel')
self.warningLabel.setVisible(False)
self.bottomLayout.addWidget(self.warningLabel)
self.buttonBox = create_button_box(editSongDialog, u'buttonBox',
[u'cancel', u'save'])
self.buttonBox = create_button_box(editSongDialog, u'buttonBox', [u'cancel', u'save'])
self.bottomLayout.addWidget(self.buttonBox)
self.dialogLayout.addLayout(self.bottomLayout)
self.retranslateUi(editSongDialog)
def retranslateUi(self, editSongDialog):
editSongDialog.setWindowTitle(
translate('SongsPlugin.EditSongForm', 'Song Editor'))
self.titleLabel.setText(
translate('SongsPlugin.EditSongForm', '&Title:'))
self.alternativeTitleLabel.setText(
translate('SongsPlugin.EditSongForm', 'Alt&ernate title:'))
self.lyricsLabel.setText(
translate('SongsPlugin.EditSongForm', '&Lyrics:'))
self.verseOrderLabel.setText(
translate('SongsPlugin.EditSongForm', '&Verse order:'))
editSongDialog.setWindowTitle(translate('SongsPlugin.EditSongForm', 'Song Editor'))
self.titleLabel.setText(translate('SongsPlugin.EditSongForm', '&Title:'))
self.alternativeTitleLabel.setText(translate('SongsPlugin.EditSongForm', 'Alt&ernate title:'))
self.lyricsLabel.setText(translate('SongsPlugin.EditSongForm', '&Lyrics:'))
self.verseOrderLabel.setText(translate('SongsPlugin.EditSongForm', '&Verse order:'))
self.verseAddButton.setText(UiStrings().Add)
self.verseEditButton.setText(UiStrings().Edit)
self.verseEditAllButton.setText(
translate('SongsPlugin.EditSongForm', 'Ed&it All'))
self.verseEditAllButton.setText(translate('SongsPlugin.EditSongForm', 'Ed&it All'))
self.verseDeleteButton.setText(UiStrings().Delete)
self.songTabWidget.setTabText(
self.songTabWidget.indexOf(self.lyricsTab),
self.songTabWidget.setTabText(self.songTabWidget.indexOf(self.lyricsTab),
translate('SongsPlugin.EditSongForm', 'Title && Lyrics'))
self.authorsGroupBox.setTitle(SongStrings.Authors)
self.authorAddButton.setText(
translate('SongsPlugin.EditSongForm', '&Add to Song'))
self.authorRemoveButton.setText(
translate('SongsPlugin.EditSongForm', '&Remove'))
self.maintenanceButton.setText(translate('SongsPlugin.EditSongForm',
'&Manage Authors, Topics, Song Books'))
self.authorAddButton.setText(translate('SongsPlugin.EditSongForm', '&Add to Song'))
self.authorRemoveButton.setText(translate('SongsPlugin.EditSongForm', '&Remove'))
self.maintenanceButton.setText(translate('SongsPlugin.EditSongForm', '&Manage Authors, Topics, Song Books'))
self.topicsGroupBox.setTitle(SongStrings.Topic)
self.topicAddButton.setText(
translate('SongsPlugin.EditSongForm', 'A&dd to Song'))
self.topicRemoveButton.setText(
translate('SongsPlugin.EditSongForm', 'R&emove'))
self.topicAddButton.setText(translate('SongsPlugin.EditSongForm', 'A&dd to Song'))
self.topicRemoveButton.setText(translate('SongsPlugin.EditSongForm', 'R&emove'))
self.songBookGroupBox.setTitle(SongStrings.SongBook)
self.songBookNameLabel.setText(translate('SongsPlugin.EditSongForm',
'Book:'))
self.songBookNumberLabel.setText(translate('SongsPlugin.EditSongForm',
'Number:'))
self.songTabWidget.setTabText(
self.songTabWidget.indexOf(self.authorsTab),
translate('SongsPlugin.EditSongForm',
'Authors, Topics && Song Book'))
self.songBookNameLabel.setText(translate('SongsPlugin.EditSongForm', 'Book:'))
self.songBookNumberLabel.setText(translate('SongsPlugin.EditSongForm', 'Number:'))
self.songTabWidget.setTabText(self.songTabWidget.indexOf(self.authorsTab),
translate('SongsPlugin.EditSongForm', 'Authors, Topics && Song Book'))
self.themeGroupBox.setTitle(UiStrings().Theme)
self.themeAddButton.setText(
translate('SongsPlugin.EditSongForm', 'New &Theme'))
self.rightsGroupBox.setTitle(
translate('SongsPlugin.EditSongForm', 'Copyright Information'))
self.themeAddButton.setText(translate('SongsPlugin.EditSongForm', 'New &Theme'))
self.rightsGroupBox.setTitle(translate('SongsPlugin.EditSongForm', 'Copyright Information'))
self.copyrightInsertButton.setText(SongStrings.CopyrightSymbol)
self.CCLILabel.setText(UiStrings().CCLINumberLabel)
self.commentsGroupBox.setTitle(
translate('SongsPlugin.EditSongForm', 'Comments'))
self.songTabWidget.setTabText(
self.songTabWidget.indexOf(self.themeTab),
translate('SongsPlugin.EditSongForm',
'Theme, Copyright Info && Comments'))
self.songTabWidget.setTabText(
self.songTabWidget.indexOf(self.audioTab),
self.commentsGroupBox.setTitle(translate('SongsPlugin.EditSongForm', 'Comments'))
self.songTabWidget.setTabText(self.songTabWidget.indexOf(self.themeTab),
translate('SongsPlugin.EditSongForm', 'Theme, Copyright Info && Comments'))
self.songTabWidget.setTabText(self.songTabWidget.indexOf(self.audioTab),
translate('SongsPlugin.EditSongForm', 'Linked Audio'))
self.audioAddFromFileButton.setText(
translate('SongsPlugin.EditSongForm', 'Add &File(s)'))
self.audioAddFromMediaButton.setText(
translate('SongsPlugin.EditSongForm', 'Add &Media'))
self.audioRemoveButton.setText(
translate('SongsPlugin.EditSongForm', '&Remove'))
self.audioRemoveAllButton.setText(
translate('SongsPlugin.EditSongForm', 'Remove &All'))
self.audioAddFromFileButton.setText(translate('SongsPlugin.EditSongForm', 'Add &File(s)'))
self.audioAddFromMediaButton.setText(translate('SongsPlugin.EditSongForm', 'Add &Media'))
self.audioRemoveButton.setText(translate('SongsPlugin.EditSongForm', '&Remove'))
self.audioRemoveAllButton.setText(translate('SongsPlugin.EditSongForm', 'Remove &All'))
self.warningLabel.setText(
translate('SongsPlugin.EditSongForm', '<strong>Warning:</strong>'
' Not all of the verses are in use.'))
translate('SongsPlugin.EditSongForm', '<strong>Warning:</strong> Not all of the verses are in use.'))
def editSongDialogComboBox(parent, name):
"""
Utility method to generate a standard combo box for this dialog.
"""
comboBox = QtGui.QComboBox(parent)
comboBox.setSizeAdjustPolicy(
QtGui.QComboBox.AdjustToMinimumContentsLength)
comboBox.setSizePolicy(
QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Fixed)
comboBox.setSizeAdjustPolicy(QtGui.QComboBox.AdjustToMinimumContentsLength)
comboBox.setSizePolicy(QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Fixed)
comboBox.setEditable(True)
comboBox.setInsertPolicy(QtGui.QComboBox.NoInsert)
comboBox.setObjectName(name)

View File

@ -1,5 +1,5 @@
# -*- coding: utf-8 -*-
# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4
# vim: autoindent shiftwidth=4 expandtab textwidth=120 tabstop=4 softtabstop=4
###############################################################################
# OpenLP - Open Source Lyrics Projection #
@ -34,10 +34,9 @@ import shutil
from PyQt4 import QtCore, QtGui
from openlp.core.lib import PluginStatus, Receiver, MediaType, translate, \
create_separated_list, check_directory_exists
from openlp.core.lib.ui import UiStrings, set_case_insensitive_completer, \
critical_error_message_box, find_and_set_in_combo_box
from openlp.core.lib import PluginStatus, Receiver, MediaType, translate, create_separated_list, check_directory_exists
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
from openlp.plugins.songs.lib import SongXML, VerseType, clean_song
@ -64,61 +63,42 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog):
self.width = 400
self.setupUi(self)
# Connecting signals and slots
QtCore.QObject.connect(self.authorAddButton,
QtCore.SIGNAL(u'clicked()'), self.onAuthorAddButtonClicked)
QtCore.QObject.connect(self.authorRemoveButton,
QtCore.SIGNAL(u'clicked()'), self.onAuthorRemoveButtonClicked)
QtCore.QObject.connect(self.authorsListView,
QtCore.SIGNAL(u'itemClicked(QListWidgetItem*)'),
QtCore.QObject.connect(self.authorAddButton, QtCore.SIGNAL(u'clicked()'), self.onAuthorAddButtonClicked)
QtCore.QObject.connect(self.authorRemoveButton, QtCore.SIGNAL(u'clicked()'), self.onAuthorRemoveButtonClicked)
QtCore.QObject.connect(self.authorsListView, QtCore.SIGNAL(u'itemClicked(QListWidgetItem*)'),
self.onAuthorsListViewClicked)
QtCore.QObject.connect(self.topicAddButton,
QtCore.SIGNAL(u'clicked()'), self.onTopicAddButtonClicked)
QtCore.QObject.connect(self.topicRemoveButton,
QtCore.SIGNAL(u'clicked()'), self.onTopicRemoveButtonClicked)
QtCore.QObject.connect(self.topicsListView,
QtCore.SIGNAL(u'itemClicked(QListWidgetItem*)'),
QtCore.QObject.connect(self.topicAddButton, QtCore.SIGNAL(u'clicked()'), self.onTopicAddButtonClicked)
QtCore.QObject.connect(self.topicRemoveButton, QtCore.SIGNAL(u'clicked()'), self.onTopicRemoveButtonClicked)
QtCore.QObject.connect(self.topicsListView, QtCore.SIGNAL(u'itemClicked(QListWidgetItem*)'),
self.onTopicListViewClicked)
QtCore.QObject.connect(self.copyrightInsertButton,
QtCore.SIGNAL(u'clicked()'), self.onCopyrightInsertButtonTriggered)
QtCore.QObject.connect(self.verseAddButton,
QtCore.SIGNAL(u'clicked()'), self.onVerseAddButtonClicked)
QtCore.QObject.connect(self.verseListWidget,
QtCore.SIGNAL(u'doubleClicked(QModelIndex)'),
QtCore.QObject.connect(self.copyrightInsertButton, QtCore.SIGNAL(u'clicked()'),
self.onCopyrightInsertButtonTriggered)
QtCore.QObject.connect(self.verseAddButton, QtCore.SIGNAL(u'clicked()'), self.onVerseAddButtonClicked)
QtCore.QObject.connect(self.verseListWidget, QtCore.SIGNAL(u'doubleClicked(QModelIndex)'),
self.onVerseEditButtonClicked)
QtCore.QObject.connect(self.verseEditButton,
QtCore.SIGNAL(u'clicked()'), self.onVerseEditButtonClicked)
QtCore.QObject.connect(self.verseEditAllButton,
QtCore.SIGNAL(u'clicked()'), self.onVerseEditAllButtonClicked)
QtCore.QObject.connect(self.verseDeleteButton,
QtCore.SIGNAL(u'clicked()'), self.onVerseDeleteButtonClicked)
QtCore.QObject.connect(self.verseListWidget,
QtCore.SIGNAL(u'itemClicked(QTableWidgetItem*)'),
QtCore.QObject.connect(self.verseEditButton, QtCore.SIGNAL(u'clicked()'), self.onVerseEditButtonClicked)
QtCore.QObject.connect(self.verseEditAllButton, QtCore.SIGNAL(u'clicked()'), self.onVerseEditAllButtonClicked)
QtCore.QObject.connect(self.verseDeleteButton, QtCore.SIGNAL(u'clicked()'), self.onVerseDeleteButtonClicked)
QtCore.QObject.connect(self.verseListWidget, QtCore.SIGNAL(u'itemClicked(QTableWidgetItem*)'),
self.onVerseListViewClicked)
QtCore.QObject.connect(self.verseOrderEdit,
QtCore.SIGNAL(u'textChanged(QString)'),
QtCore.QObject.connect(self.verseOrderEdit, QtCore.SIGNAL(u'textChanged(QString)'),
self.onVerseOrderTextChanged)
QtCore.QObject.connect(self.themeAddButton,
QtCore.SIGNAL(u'clicked()'),
QtCore.QObject.connect(self.themeAddButton, QtCore.SIGNAL(u'clicked()'),
self.mediaitem.plugin.renderer.theme_manager.onAddTheme)
QtCore.QObject.connect(self.maintenanceButton,
QtCore.SIGNAL(u'clicked()'), self.onMaintenanceButtonClicked)
QtCore.QObject.connect(self.audioAddFromFileButton,
QtCore.SIGNAL(u'clicked()'), self.onAudioAddFromFileButtonClicked)
QtCore.QObject.connect(self.audioAddFromMediaButton,
QtCore.SIGNAL(u'clicked()'), self.onAudioAddFromMediaButtonClicked)
QtCore.QObject.connect(self.audioRemoveButton,
QtCore.SIGNAL(u'clicked()'), self.onAudioRemoveButtonClicked)
QtCore.QObject.connect(self.audioRemoveAllButton,
QtCore.SIGNAL(u'clicked()'), self.onAudioRemoveAllButtonClicked)
QtCore.QObject.connect(Receiver.get_receiver(),
QtCore.SIGNAL(u'theme_update_list'), self.loadThemes)
QtCore.QObject.connect(self.maintenanceButton, QtCore.SIGNAL(u'clicked()'), self.onMaintenanceButtonClicked)
QtCore.QObject.connect(self.audioAddFromFileButton, QtCore.SIGNAL(u'clicked()'),
self.onAudioAddFromFileButtonClicked)
QtCore.QObject.connect(self.audioAddFromMediaButton, QtCore.SIGNAL(u'clicked()'),
self.onAudioAddFromMediaButtonClicked)
QtCore.QObject.connect(self.audioRemoveButton, QtCore.SIGNAL(u'clicked()'), self.onAudioRemoveButtonClicked)
QtCore.QObject.connect(self.audioRemoveAllButton, QtCore.SIGNAL(u'clicked()'),
self.onAudioRemoveAllButtonClicked)
QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'theme_update_list'), self.loadThemes)
self.previewButton = QtGui.QPushButton()
self.previewButton.setObjectName(u'previewButton')
self.previewButton.setText(UiStrings().SaveAndPreview)
self.buttonBox.addButton(
self.previewButton, QtGui.QDialogButtonBox.ActionRole)
QtCore.QObject.connect(self.buttonBox,
QtCore.SIGNAL(u'clicked(QAbstractButton*)'), self.onPreview)
self.buttonBox.addButton(self.previewButton, QtGui.QDialogButtonBox.ActionRole)
QtCore.QObject.connect(self.buttonBox, QtCore.SIGNAL(u'clicked(QAbstractButton*)'), self.onPreview)
# Create other objects and forms
self.manager = manager
self.verseForm = EditVerseForm(self)
@ -234,19 +214,13 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog):
self.song.alternate_title if self.song.alternate_title else u'')
if self.song.song_book_id != 0:
book_name = self.manager.get_object(Book, self.song.song_book_id)
find_and_set_in_combo_box(
self.songBookComboBox, unicode(book_name.name))
find_and_set_in_combo_box(self.songBookComboBox, unicode(book_name.name))
if self.song.theme_name:
find_and_set_in_combo_box(
self.themeComboBox, unicode(self.song.theme_name))
self.copyrightEdit.setText(
self.song.copyright if self.song.copyright else u'')
self.commentsEdit.setPlainText(
self.song.comments if self.song.comments else u'')
self.CCLNumberEdit.setText(
self.song.ccli_number if self.song.ccli_number else u'')
self.songBookNumberEdit.setText(
self.song.song_number if self.song.song_number else u'')
find_and_set_in_combo_box(self.themeComboBox, unicode(self.song.theme_name))
self.copyrightEdit.setText(self.song.copyright if self.song.copyright else u'')
self.commentsEdit.setPlainText(self.song.comments if self.song.comments else u'')
self.CCLNumberEdit.setText(self.song.ccli_number if self.song.ccli_number else u'')
self.songBookNumberEdit.setText(self.song.song_number if self.song.song_number else u'')
# lazy xml migration for now
self.verseListWidget.clear()
self.verseListWidget.setRowCount(0)
@ -282,11 +256,9 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog):
else:
verses = self.song.lyrics.split(u'\n\n')
for count, verse in enumerate(verses):
self.verseListWidget.setRowCount(
self.verseListWidget.rowCount() + 1)
self.verseListWidget.setRowCount(self.verseListWidget.rowCount() + 1)
item = QtGui.QTableWidgetItem(verse)
verse_def = u'%s%s' % \
(VerseType.Tags[VerseType.Verse], unicode(count + 1))
verse_def = u'%s%s' % (VerseType.Tags[VerseType.Verse], unicode(count + 1))
item.setData(QtCore.Qt.UserRole, verse_def)
self.verseListWidget.setItem(count, 0, item)
if self.song.verse_order:
@ -295,8 +267,7 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog):
for verse_def in self.song.verse_order.split():
verse_index = None
if verse_tags_translated:
verse_index = VerseType.from_translated_tag(verse_def[0],
None)
verse_index = VerseType.from_translated_tag(verse_def[0], None)
if verse_index is None:
verse_index = VerseType.from_tag(verse_def[0])
verse_tag = VerseType.TranslatedTags[verse_index].upper()
@ -319,8 +290,7 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog):
self.topicsListView.addItem(topic_name)
self.audioListWidget.clear()
for media in self.song.media_files:
media_file = QtGui.QListWidgetItem(
os.path.split(media.file_name)[1])
media_file = QtGui.QListWidgetItem(os.path.split(media.file_name)[1])
media_file.setData(QtCore.Qt.UserRole, media.file_name)
self.audioListWidget.addItem(media_file)
self.titleEdit.setFocus()
@ -353,13 +323,10 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog):
if item == 0 and text:
if QtGui.QMessageBox.question(self,
translate('SongsPlugin.EditSongForm', 'Add Author'),
translate('SongsPlugin.EditSongForm', 'This author does not '
'exist, do you want to add them?'),
QtGui.QMessageBox.Yes | QtGui.QMessageBox.No,
QtGui.QMessageBox.Yes) == QtGui.QMessageBox.Yes:
translate('SongsPlugin.EditSongForm', 'This author does not exist, do you want to add them?'),
QtGui.QMessageBox.Yes | QtGui.QMessageBox.No, QtGui.QMessageBox.Yes) == QtGui.QMessageBox.Yes:
if text.find(u' ') == -1:
author = Author.populate(first_name=u'', last_name=u'',
display_name=text)
author = Author.populate(first_name=u'', last_name=u'', display_name=text)
else:
author = Author.populate(first_name=text.rsplit(u' ', 1)[0],
last_name=text.rsplit(u' ', 1)[1], display_name=text)
@ -375,17 +342,15 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog):
if self.authorsListView.findItems(unicode(author.display_name),
QtCore.Qt.MatchExactly):
critical_error_message_box(
message=translate('SongsPlugin.EditSongForm',
'This author is already in the list.'))
message=translate('SongsPlugin.EditSongForm', 'This author is already in the list.'))
else:
self.__addAuthorToList(author)
self.authorsComboBox.setCurrentIndex(0)
else:
QtGui.QMessageBox.warning(self, UiStrings().NISs,
translate('SongsPlugin.EditSongForm', 'You have not selected '
'a valid author. Either select an author from the list, '
'or type in a new author and click the "Add Author to '
'Song" button to add the new author.'))
translate('SongsPlugin.EditSongForm', 'You have not selected a valid author. Either select an author '
'from the list, or type in a new author and click the "Add Author to Song" button to add '
'the new author.'))
def __addAuthorToList(self, author):
"""
@ -409,12 +374,9 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog):
item = int(self.topicsComboBox.currentIndex())
text = self.topicsComboBox.currentText()
if item == 0 and text:
if QtGui.QMessageBox.question(self,
translate('SongsPlugin.EditSongForm', 'Add Topic'),
translate('SongsPlugin.EditSongForm', 'This topic does not '
'exist, do you want to add it?'),
QtGui.QMessageBox.Yes | QtGui.QMessageBox.No,
QtGui.QMessageBox.Yes) == QtGui.QMessageBox.Yes:
if QtGui.QMessageBox.question(self, translate('SongsPlugin.EditSongForm', 'Add Topic'),
translate('SongsPlugin.EditSongForm', 'This topic does not exist, do you want to add it?'),
QtGui.QMessageBox.Yes | QtGui.QMessageBox.No, QtGui.QMessageBox.Yes) == QtGui.QMessageBox.Yes:
topic = Topic.populate(name=text)
self.manager.save_object(topic)
topic_item = QtGui.QListWidgetItem(unicode(topic.name))
@ -430,8 +392,7 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog):
if self.topicsListView.findItems(unicode(topic.name),
QtCore.Qt.MatchExactly):
critical_error_message_box(
message=translate('SongsPlugin.EditSongForm',
'This topic is already in the list.'))
message=translate('SongsPlugin.EditSongForm', 'This topic is already in the list.'))
else:
topic_item = QtGui.QListWidgetItem(unicode(topic.name))
topic_item.setData(QtCore.Qt.UserRole, topic.id)
@ -439,10 +400,8 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog):
self.topicsComboBox.setCurrentIndex(0)
else:
QtGui.QMessageBox.warning(self, UiStrings().NISs,
translate('SongsPlugin.EditSongForm', 'You have not selected '
'a valid topic. Either select a topic from the list, or '
'type in a new topic and click the "Add Topic to Song" '
'button to add the new topic.'))
translate('SongsPlugin.EditSongForm', 'You have not selected a valid topic. Either select a topic '
'from the list, or type in a new topic and click the "Add Topic to Song" button to add the new topic.'))
def onTopicListViewClicked(self):
self.topicRemoveButton.setEnabled(True)
@ -465,10 +424,8 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog):
item = QtGui.QTableWidgetItem(after_text)
item.setData(QtCore.Qt.UserRole, verse_def)
item.setText(after_text)
self.verseListWidget.setRowCount(
self.verseListWidget.rowCount() + 1)
self.verseListWidget.setItem(
self.verseListWidget.rowCount() - 1, 0, item)
self.verseListWidget.setRowCount(self.verseListWidget.rowCount() + 1)
self.verseListWidget.setItem(self.verseListWidget.rowCount() - 1, 0, item)
self.tagRows()
# Check if all verse tags are used.
self.onVerseOrderTextChanged(self.verseOrderEdit.text())
@ -551,10 +508,8 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog):
parts = parts.rstrip(u'\n')
item = QtGui.QTableWidgetItem(parts)
item.setData(QtCore.Qt.UserRole, verse_def)
self.verseListWidget.setRowCount(
self.verseListWidget.rowCount() + 1)
self.verseListWidget.setItem(
self.verseListWidget.rowCount() - 1, 0, item)
self.verseListWidget.setRowCount(self.verseListWidget.rowCount() + 1)
self.verseListWidget.setItem(self.verseListWidget.rowCount() - 1, 0, item)
self.tagRows()
self.verseEditButton.setEnabled(False)
self.verseDeleteButton.setEnabled(False)
@ -576,8 +531,7 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog):
verse = verse.data(QtCore.Qt.UserRole)
if verse not in verse_names:
verses.append(verse)
verse_names.append(u'%s%s' % (
VerseType.translated_tag(verse[0]), verse[1:]))
verse_names.append(u'%s%s' % (VerseType.translated_tag(verse[0]), verse[1:]))
verses_not_used = []
for verse in verses:
if not verse in order:
@ -617,23 +571,20 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog):
verse = verse.data(QtCore.Qt.UserRole)
if verse not in verse_names:
verses.append(verse)
verse_names.append(u'%s%s' % (
VerseType.translated_tag(verse[0]), verse[1:]))
verse_names.append(u'%s%s' % (VerseType.translated_tag(verse[0]), verse[1:]))
for count, item in enumerate(order):
if item not in verses:
invalid_verses.append(order_names[count])
if invalid_verses:
valid = create_separated_list(verse_names)
if len(invalid_verses) > 1:
critical_error_message_box(message=translate(
'SongsPlugin.EditSongForm', 'The verse order is invalid. '
'There are no verses corresponding to %s. Valid entries '
'are %s.') % (u', '.join(invalid_verses), valid))
critical_error_message_box(message=translate('SongsPlugin.EditSongForm',
'The verse order is invalid. There are no verses corresponding to %s. Valid entries are %s.') %
(u', '.join(invalid_verses), valid))
else:
critical_error_message_box(message=translate(
'SongsPlugin.EditSongForm', 'The verse order is invalid. '
'There is no verse corresponding to %s. Valid entries '
'are %s.') % (invalid_verses[0], valid))
critical_error_message_box(message=translate('SongsPlugin.EditSongForm',
'The verse order is invalid. There is no verse corresponding to %s. Valid entries are %s.') %
(invalid_verses[0], valid))
return len(invalid_verses) == 0
def __validateSong(self):
@ -648,22 +599,19 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog):
self.songTabWidget.setCurrentIndex(0)
self.titleEdit.setFocus()
critical_error_message_box(
message=translate('SongsPlugin.EditSongForm',
'You need to type in a song title.'))
message=translate('SongsPlugin.EditSongForm', 'You need to type in a song title.'))
return False
if self.verseListWidget.rowCount() == 0:
self.songTabWidget.setCurrentIndex(0)
self.verseListWidget.setFocus()
critical_error_message_box(
message=translate('SongsPlugin.EditSongForm',
'You need to type in at least one verse.'))
message=translate('SongsPlugin.EditSongForm', 'You need to type in at least one verse.'))
return False
if self.authorsListView.count() == 0:
self.songTabWidget.setCurrentIndex(1)
self.authorsListView.setFocus()
critical_error_message_box(
message=translate('SongsPlugin.EditSongForm',
'You need to have an author for this song.'))
message=translate('SongsPlugin.EditSongForm', 'You need to have an author for this song.'))
return False
if self.verseOrderEdit.text():
result = self.__validateVerseList(self.verseOrderEdit.text(),
@ -672,12 +620,9 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog):
return False
text = self.songBookComboBox.currentText()
if self.songBookComboBox.findText(text, QtCore.Qt.MatchExactly) < 0:
if QtGui.QMessageBox.question(self,
translate('SongsPlugin.EditSongForm', 'Add Book'),
translate('SongsPlugin.EditSongForm', 'This song book does '
'not exist, do you want to add it?'),
QtGui.QMessageBox.Yes | QtGui.QMessageBox.No,
QtGui.QMessageBox.Yes) == QtGui.QMessageBox.Yes:
if QtGui.QMessageBox.question(self, translate('SongsPlugin.EditSongForm', 'Add Book'),
translate('SongsPlugin.EditSongForm', 'This song book does not exist, do you want to add it?'),
QtGui.QMessageBox.Yes | QtGui.QMessageBox.No, QtGui.QMessageBox.Yes) == QtGui.QMessageBox.Yes:
book = Book.populate(name=text, publisher=u'')
self.manager.save_object(book)
else:
@ -737,8 +682,7 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog):
"""
if self.mediaForm.exec_():
for filename in self.mediaForm.getSelectedFiles():
item = QtGui.QListWidgetItem(
os.path.split(unicode(filename))[1])
item = QtGui.QListWidgetItem(os.path.split(unicode(filename))[1])
item.setData(QtCore.Qt.UserRole, filename)
self.audioListWidget.addItem(item)
@ -871,9 +815,8 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog):
self.manager.save_object(self.song)
audio_files = map(lambda a: a.file_name, self.song.media_files)
log.debug(audio_files)
save_path = os.path.join(
AppLocation.get_section_data_path(self.mediaitem.plugin.name),
'audio', str(self.song.id))
save_path = os.path.join(AppLocation.get_section_data_path(self.mediaitem.plugin.name), 'audio',
str(self.song.id))
check_directory_exists(save_path)
self.song.media_files = []
files = []
@ -881,8 +824,7 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog):
item = self.audioListWidget.item(row)
filename = item.data(QtCore.Qt.UserRole)
if not filename.startswith(save_path):
oldfile, filename = filename, os.path.join(save_path,
os.path.split(filename)[1])
oldfile, filename = filename, os.path.join(save_path, os.path.split(filename)[1])
shutil.copyfile(oldfile, filename)
files.append(filename)
media_file = MediaFile()
@ -924,10 +866,8 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog):
multiple.append(verse_tag)
self.song.lyrics = unicode(sxml.extract_xml(), u'utf-8')
for verse in multiple:
self.song.verse_order = re.sub(u'([' + verse.upper() +
verse.lower() + u'])(\W|$)', r'\g<1>1\2',
self.song.verse_order = re.sub(u'([' + verse.upper() + verse.lower() + u'])(\W|$)', r'\g<1>1\2',
self.song.verse_order)
except:
log.exception(u'Problem processing song Lyrics \n%s',
sxml.dump_xml())
log.exception(u'Problem processing song Lyrics \n%s', sxml.dump_xml())

View File

@ -1,5 +1,5 @@
# -*- coding: utf-8 -*-
# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4
# vim: autoindent shiftwidth=4 expandtab textwidth=120 tabstop=4 softtabstop=4
###############################################################################
# OpenLP - Open Source Lyrics Projection #
@ -67,34 +67,22 @@ class Ui_EditVerseDialog(object):
self.verseTypeLayout.addWidget(self.insertButton)
self.verseTypeLayout.addStretch()
self.dialogLayout.addLayout(self.verseTypeLayout)
self.buttonBox = create_button_box(editVerseDialog, u'buttonBox',
[u'cancel', u'ok'])
self.buttonBox = create_button_box(editVerseDialog, u'buttonBox', [u'cancel', u'ok'])
self.dialogLayout.addWidget(self.buttonBox)
self.retranslateUi(editVerseDialog)
def retranslateUi(self, editVerseDialog):
editVerseDialog.setWindowTitle(
translate('SongsPlugin.EditVerseForm', 'Edit Verse'))
self.verseTypeLabel.setText(
translate('SongsPlugin.EditVerseForm', '&Verse type:'))
self.verseTypeComboBox.setItemText(VerseType.Verse,
VerseType.TranslatedNames[VerseType.Verse])
self.verseTypeComboBox.setItemText(VerseType.Chorus,
VerseType.TranslatedNames[VerseType.Chorus])
self.verseTypeComboBox.setItemText(VerseType.Bridge,
VerseType.TranslatedNames[VerseType.Bridge])
self.verseTypeComboBox.setItemText(VerseType.PreChorus,
VerseType.TranslatedNames[VerseType.PreChorus])
self.verseTypeComboBox.setItemText(VerseType.Intro,
VerseType.TranslatedNames[VerseType.Intro])
self.verseTypeComboBox.setItemText(VerseType.Ending,
VerseType.TranslatedNames[VerseType.Ending])
self.verseTypeComboBox.setItemText(VerseType.Other,
VerseType.TranslatedNames[VerseType.Other])
editVerseDialog.setWindowTitle(translate('SongsPlugin.EditVerseForm', 'Edit Verse'))
self.verseTypeLabel.setText(translate('SongsPlugin.EditVerseForm', '&Verse type:'))
self.verseTypeComboBox.setItemText(VerseType.Verse, VerseType.TranslatedNames[VerseType.Verse])
self.verseTypeComboBox.setItemText(VerseType.Chorus, VerseType.TranslatedNames[VerseType.Chorus])
self.verseTypeComboBox.setItemText(VerseType.Bridge, VerseType.TranslatedNames[VerseType.Bridge])
self.verseTypeComboBox.setItemText(VerseType.PreChorus, VerseType.TranslatedNames[VerseType.PreChorus])
self.verseTypeComboBox.setItemText(VerseType.Intro, VerseType.TranslatedNames[VerseType.Intro])
self.verseTypeComboBox.setItemText(VerseType.Ending, VerseType.TranslatedNames[VerseType.Ending])
self.verseTypeComboBox.setItemText(VerseType.Other, VerseType.TranslatedNames[VerseType.Other])
self.splitButton.setText(UiStrings().Split)
self.splitButton.setToolTip(UiStrings().SplitToolTip)
self.insertButton.setText(
translate('SongsPlugin.EditVerseForm', '&Insert'))
self.insertButton.setToolTip(
translate('SongsPlugin.EditVerseForm', 'Split a slide into two '
'by inserting a verse splitter.'))
self.insertButton.setText(translate('SongsPlugin.EditVerseForm', '&Insert'))
self.insertButton.setToolTip(translate('SongsPlugin.EditVerseForm',
'Split a slide into two by inserting a verse splitter.'))

View File

@ -1,5 +1,5 @@
# -*- coding: utf-8 -*-
# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4
# vim: autoindent shiftwidth=4 expandtab textwidth=120 tabstop=4 softtabstop=4
###############################################################################
# OpenLP - Open Source Lyrics Projection #
@ -51,18 +51,13 @@ class EditVerseForm(QtGui.QDialog, Ui_EditVerseDialog):
"""
QtGui.QDialog.__init__(self, parent)
self.setupUi(self)
QtCore.QObject.connect(self.verseTextEdit,
QtCore.SIGNAL('customContextMenuRequested(QPoint)'),
QtCore.QObject.connect(self.verseTextEdit, QtCore.SIGNAL('customContextMenuRequested(QPoint)'),
self.contextMenu)
QtCore.QObject.connect(self.insertButton, QtCore.SIGNAL(u'clicked()'),
self.onInsertButtonClicked)
QtCore.QObject.connect(self.splitButton, QtCore.SIGNAL(u'clicked()'),
self.onSplitButtonClicked)
QtCore.QObject.connect(self.verseTextEdit,
QtCore.SIGNAL(u'cursorPositionChanged()'),
QtCore.QObject.connect(self.insertButton, QtCore.SIGNAL(u'clicked()'), self.onInsertButtonClicked)
QtCore.QObject.connect(self.splitButton, QtCore.SIGNAL(u'clicked()'), self.onSplitButtonClicked)
QtCore.QObject.connect(self.verseTextEdit, QtCore.SIGNAL(u'cursorPositionChanged()'),
self.onCursorPositionChanged)
QtCore.QObject.connect(self.verseTypeComboBox,
QtCore.SIGNAL(u'currentIndexChanged(int)'),
QtCore.QObject.connect(self.verseTypeComboBox, QtCore.SIGNAL(u'currentIndexChanged(int)'),
self.onVerseTypeComboBoxChanged)
def contextMenu(self, point):
@ -72,8 +67,7 @@ class EditVerseForm(QtGui.QDialog, Ui_EditVerseDialog):
if self.verseTextEdit.textCursor().columnNumber() != 0:
self.verseTextEdit.insertPlainText(u'\n')
verse_tag = VerseType.translated_name(verse_tag)
self.verseTextEdit.insertPlainText(u'---[%s:%s]---\n' %
(verse_tag, verse_num))
self.verseTextEdit.insertPlainText(u'---[%s:%s]---\n' % (verse_tag, verse_num))
self.verseTextEdit.setFocus()
def onSplitButtonClicked(self):
@ -139,8 +133,7 @@ class EditVerseForm(QtGui.QDialog, Ui_EditVerseDialog):
self.insertButton.setVisible(False)
else:
if not text:
text = u'---[%s:1]---\n' % \
VerseType.TranslatedNames[VerseType.Verse]
text = u'---[%s:1]---\n' % VerseType.TranslatedNames[VerseType.Verse]
self.verseTypeComboBox.setCurrentIndex(0)
self.verseNumberBox.setValue(1)
self.insertButton.setVisible(True)
@ -149,14 +142,12 @@ class EditVerseForm(QtGui.QDialog, Ui_EditVerseDialog):
self.verseTextEdit.moveCursor(QtGui.QTextCursor.End)
def getVerse(self):
return self.verseTextEdit.toPlainText(), \
VerseType.Tags[self.verseTypeComboBox.currentIndex()], \
return self.verseTextEdit.toPlainText(), VerseType.Tags[self.verseTypeComboBox.currentIndex()], \
unicode(self.verseNumberBox.value())
def getVerseAll(self):
text = self.verseTextEdit.toPlainText()
if not text.startswith(u'---['):
text = u'---[%s:1]---\n%s' % \
(VerseType.TranslatedNames[VerseType.Verse], text)
text = u'---[%s:1]---\n%s' % (VerseType.TranslatedNames[VerseType.Verse], text)
return text

View File

@ -1,5 +1,5 @@
# -*- coding: utf-8 -*-
# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4
# vim: autoindent shiftwidth=4 expandtab textwidth=120 tabstop=4 softtabstop=4
###############################################################################
# OpenLP - Open Source Lyrics Projection #
@ -38,8 +38,7 @@ class Ui_MediaFilesDialog(object):
mediaFilesDialog.setWindowModality(QtCore.Qt.ApplicationModal)
mediaFilesDialog.resize(400, 300)
mediaFilesDialog.setModal(True)
mediaFilesDialog.setWindowIcon(
build_icon(u':/icon/openlp-logo-16x16.png'))
mediaFilesDialog.setWindowIcon(build_icon(u':/icon/openlp-logo-16x16.png'))
self.filesVerticalLayout = QtGui.QVBoxLayout(mediaFilesDialog)
self.filesVerticalLayout.setSpacing(8)
self.filesVerticalLayout.setMargin(8)
@ -50,21 +49,15 @@ class Ui_MediaFilesDialog(object):
self.filesVerticalLayout.addWidget(self.selectLabel)
self.fileListWidget = QtGui.QListWidget(mediaFilesDialog)
self.fileListWidget.setAlternatingRowColors(True)
self.fileListWidget.setSelectionMode(
QtGui.QAbstractItemView.ExtendedSelection)
self.fileListWidget.setSelectionMode(QtGui.QAbstractItemView.ExtendedSelection)
self.fileListWidget.setObjectName(u'fileListWidget')
self.filesVerticalLayout.addWidget(self.fileListWidget)
self.buttonBox = create_button_box(mediaFilesDialog, u'buttonBox',
[u'cancel', u'ok'])
self.buttonBox = create_button_box(mediaFilesDialog, u'buttonBox', [u'cancel', u'ok'])
self.filesVerticalLayout.addWidget(self.buttonBox)
self.retranslateUi(mediaFilesDialog)
def retranslateUi(self, mediaFilesDialog):
mediaFilesDialog.setWindowTitle(
translate('SongsPlugin.MediaFilesForm', 'Select Media File(s)'))
self.selectLabel.setText(
translate('SongsPlugin.MediaFilesForm', u'Select one or more '
'audio files from the list below, and click OK to import them '
'into this song.'))
mediaFilesDialog.setWindowTitle(translate('SongsPlugin.MediaFilesForm', 'Select Media File(s)'))
self.selectLabel.setText(translate('SongsPlugin.MediaFilesForm',
'Select one or more audio files from the list below, and click OK to import them into this song.'))

View File

@ -1,5 +1,5 @@
# -*- coding: utf-8 -*-
# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4
# vim: autoindent shiftwidth=4 expandtab textwidth=120 tabstop=4 softtabstop=4
###############################################################################
# OpenLP - Open Source Lyrics Projection #

View File

@ -1,5 +1,5 @@
# -*- coding: utf-8 -*-
# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4
# vim: autoindent shiftwidth=4 expandtab textwidth=120 tabstop=4 softtabstop=4
###############################################################################
# OpenLP - Open Source Lyrics Projection #
@ -53,15 +53,12 @@ class Ui_SongBookDialog(object):
self.publisherLabel.setBuddy(self.publisherEdit)
self.bookLayout.addRow(self.publisherLabel, self.publisherEdit)
self.dialogLayout.addLayout(self.bookLayout)
self.buttonBox = create_button_box(songBookDialog, u'buttonBox',
[u'cancel', u'save'])
self.buttonBox = create_button_box(songBookDialog, u'buttonBox', [u'cancel', u'save'])
self.dialogLayout.addWidget(self.buttonBox)
self.retranslateUi(songBookDialog)
songBookDialog.setMaximumHeight(songBookDialog.sizeHint().height())
def retranslateUi(self, songBookDialog):
songBookDialog.setWindowTitle(
translate('SongsPlugin.SongBookForm', 'Song Book Maintenance'))
songBookDialog.setWindowTitle(translate('SongsPlugin.SongBookForm', 'Song Book Maintenance'))
self.nameLabel.setText(translate('SongsPlugin.SongBookForm', '&Name:'))
self.publisherLabel.setText(
translate('SongsPlugin.SongBookForm', '&Publisher:'))
self.publisherLabel.setText(translate('SongsPlugin.SongBookForm', '&Publisher:'))

View File

@ -1,5 +1,5 @@
# -*- coding: utf-8 -*-
# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4
# vim: autoindent shiftwidth=4 expandtab textwidth=120 tabstop=4 softtabstop=4
###############################################################################
# OpenLP - Open Source Lyrics Projection #
@ -54,8 +54,7 @@ class SongBookForm(QtGui.QDialog, Ui_SongBookDialog):
def accept(self):
if not self.nameEdit.text():
critical_error_message_box(
message=translate('SongsPlugin.SongBookForm',
'You need to type in a name for the book.'))
message=translate('SongsPlugin.SongBookForm', 'You need to type in a name for the book.'))
self.nameEdit.setFocus()
return False
else:

View File

@ -1,5 +1,5 @@
# -*- coding: utf-8 -*-
# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4
# vim: autoindent shiftwidth=4 expandtab textwidth=120 tabstop=4 softtabstop=4
###############################################################################
# OpenLP - Open Source Lyrics Projection #
@ -34,8 +34,7 @@ import logging
from PyQt4 import QtCore, QtGui
from openlp.core.lib import build_icon, Receiver, translate, \
create_separated_list
from openlp.core.lib import build_icon, Receiver, translate, create_separated_list
from openlp.core.lib.ui import UiStrings, critical_error_message_box
from openlp.core.ui.wizard import OpenLPWizard, WizardStrings
from openlp.plugins.songs.lib import natcmp
@ -61,11 +60,9 @@ class SongExportForm(OpenLPWizard):
``plugin``
The songs plugin.
"""
OpenLPWizard.__init__(self, parent, plugin, u'songExportWizard',
u':/wizards/wizard_exportsong.bmp')
OpenLPWizard.__init__(self, parent, plugin, u'songExportWizard', u':/wizards/wizard_exportsong.bmp')
self.stop_export_flag = False
QtCore.QObject.connect(Receiver.get_receiver(),
QtCore.SIGNAL(u'openlp_stop_wizard'), self.stop_export)
QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'openlp_stop_wizard'), self.stop_export)
def stop_export(self):
"""
@ -90,18 +87,13 @@ class SongExportForm(OpenLPWizard):
"""
Song wizard specific signals.
"""
QtCore.QObject.connect(self.availableListWidget,
QtCore.SIGNAL(u'itemActivated(QListWidgetItem*)'),
QtCore.QObject.connect(self.availableListWidget, QtCore.SIGNAL(u'itemActivated(QListWidgetItem*)'),
self.onItemActivated)
QtCore.QObject.connect(self.searchLineEdit,
QtCore.SIGNAL(u'textEdited(const QString&)'),
QtCore.QObject.connect(self.searchLineEdit, QtCore.SIGNAL(u'textEdited(const QString&)'),
self.onSearchLineEditChanged)
QtCore.QObject.connect(self.uncheckButton,
QtCore.SIGNAL(u'clicked()'), self.onUncheckButtonClicked)
QtCore.QObject.connect(self.checkButton,
QtCore.SIGNAL(u'clicked()'), self.onCheckButtonClicked)
QtCore.QObject.connect(self.directoryButton,
QtCore.SIGNAL(u'clicked()'), self.onDirectoryButtonClicked)
QtCore.QObject.connect(self.uncheckButton, QtCore.SIGNAL(u'clicked()'), self.onUncheckButtonClicked)
QtCore.QObject.connect(self.checkButton, QtCore.SIGNAL(u'clicked()'), self.onCheckButtonClicked)
QtCore.QObject.connect(self.directoryButton, QtCore.SIGNAL(u'clicked()'), self.onDirectoryButtonClicked)
def addCustomPages(self):
"""
@ -125,8 +117,7 @@ class SongExportForm(OpenLPWizard):
self.searchLineEdit = QtGui.QLineEdit(self.availableSongsPage)
self.searchLineEdit.setObjectName(u'searchLineEdit')
self.horizontalLayout.addWidget(self.searchLineEdit)
spacerItem = QtGui.QSpacerItem(40, 20,
QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum)
spacerItem = QtGui.QSpacerItem(40, 20, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum)
self.horizontalLayout.addItem(spacerItem)
self.uncheckButton = QtGui.QPushButton(self.availableSongsPage)
self.uncheckButton.setObjectName(u'uncheckButton')
@ -167,35 +158,23 @@ class SongExportForm(OpenLPWizard):
"""
Song wizard localisation.
"""
self.setWindowTitle(
translate('SongsPlugin.ExportWizardForm', 'Song Export Wizard'))
self.setWindowTitle(translate('SongsPlugin.ExportWizardForm', 'Song Export Wizard'))
self.titleLabel.setText(WizardStrings.HeaderStyle %
translate('OpenLP.Ui', 'Welcome to the Song Export Wizard'))
self.informationLabel.setText(
translate('SongsPlugin.ExportWizardForm', 'This wizard will help to'
' export your songs to the open and free <strong>OpenLyrics'
'</strong> worship song format.'))
self.availableSongsPage.setTitle(
translate('SongsPlugin.ExportWizardForm', 'Select Songs'))
self.availableSongsPage.setSubTitle(
translate('SongsPlugin.ExportWizardForm',
self.informationLabel.setText(translate('SongsPlugin.ExportWizardForm', 'This wizard will help to'
' export your songs to the open and free <strong>OpenLyrics </strong> worship song format.'))
self.availableSongsPage.setTitle(translate('SongsPlugin.ExportWizardForm', 'Select Songs'))
self.availableSongsPage.setSubTitle(translate('SongsPlugin.ExportWizardForm',
'Check the songs you want to export.'))
self.searchLabel.setText(u'%s:' % UiStrings().Search)
self.uncheckButton.setText(
translate('SongsPlugin.ExportWizardForm', 'Uncheck All'))
self.checkButton.setText(
translate('SongsPlugin.ExportWizardForm', 'Check All'))
self.exportSongPage.setTitle(
translate('SongsPlugin.ExportWizardForm', 'Select Directory'))
self.exportSongPage.setSubTitle(
translate('SongsPlugin.ExportWizardForm',
self.uncheckButton.setText(translate('SongsPlugin.ExportWizardForm', 'Uncheck All'))
self.checkButton.setText(translate('SongsPlugin.ExportWizardForm', 'Check All'))
self.exportSongPage.setTitle(translate('SongsPlugin.ExportWizardForm', 'Select Directory'))
self.exportSongPage.setSubTitle(translate('SongsPlugin.ExportWizardForm',
'Select the directory where you want the songs to be saved.'))
self.directoryLabel.setText(
translate('SongsPlugin.ExportWizardForm', 'Directory:'))
self.progressPage.setTitle(
translate('SongsPlugin.ExportWizardForm', 'Exporting'))
self.progressPage.setSubTitle(
translate('SongsPlugin.ExportWizardForm',
self.directoryLabel.setText(translate('SongsPlugin.ExportWizardForm', 'Directory:'))
self.progressPage.setTitle(translate('SongsPlugin.ExportWizardForm', 'Exporting'))
self.progressPage.setSubTitle(translate('SongsPlugin.ExportWizardForm',
'Please wait while your songs are exported.'))
self.progressLabel.setText(WizardStrings.Ready)
self.progressBar.setFormat(WizardStrings.PercentSymbolFormat)
@ -213,8 +192,7 @@ class SongExportForm(OpenLPWizard):
]
if not items:
critical_error_message_box(UiStrings().NISp,
translate('SongsPlugin.ExportWizardForm',
'You need to add at least one Song to export.'))
translate('SongsPlugin.ExportWizardForm', 'You need to add at least one Song to export.'))
return False
self.selectedListWidget.clear()
# Add the songs to the list of selected songs.
@ -227,10 +205,8 @@ class SongExportForm(OpenLPWizard):
elif self.currentPage() == self.exportSongPage:
if not self.directoryLineEdit.text():
critical_error_message_box(
translate('SongsPlugin.ExportWizardForm',
'No Save Location specified'),
translate('SongsPlugin.ExportWizardForm',
'You need to specify a directory.'))
translate('SongsPlugin.ExportWizardForm', 'No Save Location specified'),
translate('SongsPlugin.ExportWizardForm', 'You need to specify a directory.'))
return False
return True
elif self.currentPage() == self.progressPage:
@ -257,13 +233,11 @@ class SongExportForm(OpenLPWizard):
# No need to export temporary songs.
if song.temporary:
continue
authors = create_separated_list([author.display_name
for author in song.authors])
authors = create_separated_list([author.display_name for author in song.authors])
title = u'%s (%s)' % (unicode(song.title), authors)
item = QtGui.QListWidgetItem(title)
item.setData(QtCore.Qt.UserRole, song)
item.setFlags(QtCore.Qt.ItemIsSelectable|
QtCore.Qt.ItemIsUserCheckable | QtCore.Qt.ItemIsEnabled)
item.setFlags(QtCore.Qt.ItemIsSelectable | QtCore.Qt.ItemIsUserCheckable | QtCore.Qt.ItemIsEnabled)
item.setCheckState(QtCore.Qt.Unchecked)
self.availableListWidget.addItem(item)
Receiver.send_message(u'cursor_normal')
@ -273,8 +247,7 @@ class SongExportForm(OpenLPWizard):
Perform pre export tasks.
"""
OpenLPWizard.preWizard(self)
self.progressLabel.setText(
translate('SongsPlugin.ExportWizardForm', 'Starting export...'))
self.progressLabel.setText(translate('SongsPlugin.ExportWizardForm', 'Starting export...'))
Receiver.send_message(u'openlp_process_events')
def performWizard(self):
@ -288,14 +261,10 @@ class SongExportForm(OpenLPWizard):
]
exporter = OpenLyricsExport(self, songs, self.directoryLineEdit.text())
if exporter.do_export():
self.progressLabel.setText(
translate('SongsPlugin.SongExportForm', 'Finished export. To '
'import these files use the <strong>OpenLyrics</strong> '
'importer.'))
self.progressLabel.setText(translate('SongsPlugin.SongExportForm',
'Finished export. To import these files use the <strong>OpenLyrics</strong> importer.'))
else:
self.progressLabel.setText(
translate('SongsPlugin.SongExportForm',
'Your song export failed.'))
self.progressLabel.setText(translate('SongsPlugin.SongExportForm', 'Your song export failed.'))
def _findListWidgetItems(self, listWidget, text=u''):
"""
@ -334,8 +303,7 @@ class SongExportForm(OpenLPWizard):
The text of the *searchLineEdit*.
"""
search_result = [
song for song in self._findListWidgetItems(
self.availableListWidget, text)
song for song in self._findListWidgetItems(self.availableListWidget, text)
]
for item in self._findListWidgetItems(self.availableListWidget):
item.setHidden(item not in search_result)
@ -363,5 +331,4 @@ class SongExportForm(OpenLPWizard):
Called when the *directoryButton* was clicked. Opens a dialog and writes
the path to *directoryLineEdit*.
"""
self.getFolder(translate('SongsPlugin.ExportWizardForm',
'Select Destination Folder'), self.directoryLineEdit)
self.getFolder(translate('SongsPlugin.ExportWizardForm', 'Select Destination Folder'), self.directoryLineEdit)

View File

@ -1,5 +1,5 @@
# -*- coding: utf-8 -*-
# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4
# vim: autoindent shiftwidth=4 expandtab textwidth=120 tabstop=4 softtabstop=4
###############################################################################
# OpenLP - Open Source Lyrics Projection #
@ -60,20 +60,17 @@ class SongImportForm(OpenLPWizard):
The songs plugin.
"""
self.clipboard = plugin.formParent.clipboard
OpenLPWizard.__init__(self, parent, plugin, u'songImportWizard',
u':/wizards/wizard_importsong.bmp')
OpenLPWizard.__init__(self, parent, plugin, u'songImportWizard', u':/wizards/wizard_importsong.bmp')
def setupUi(self, image):
"""
Set up the song wizard UI.
"""
self.formatWidgets = dict([(format, {}) for format in
SongFormat.get_format_list()])
self.formatWidgets = dict([(format, {}) for format in SongFormat.get_format_list()])
OpenLPWizard.setupUi(self, image)
self.currentFormat = SongFormat.OpenLyrics
self.formatStack.setCurrentIndex(self.currentFormat)
QtCore.QObject.connect(self.formatComboBox,
QtCore.SIGNAL(u'currentIndexChanged(int)'),
QtCore.QObject.connect(self.formatComboBox, QtCore.SIGNAL(u'currentIndexChanged(int)'),
self.onCurrentIndexChanged)
def onCurrentIndexChanged(self, index):
@ -102,17 +99,13 @@ class SongImportForm(OpenLPWizard):
if select_mode == SongFormatSelect.MultipleFiles:
QtCore.QObject.connect(self.formatWidgets[format][u'addButton'],
QtCore.SIGNAL(u'clicked()'), self.onAddButtonClicked)
QtCore.QObject.connect(
self.formatWidgets[format][u'removeButton'],
QtCore.QObject.connect(self.formatWidgets[format][u'removeButton'],
QtCore.SIGNAL(u'clicked()'), self.onRemoveButtonClicked)
else:
QtCore.QObject.connect(
self.formatWidgets[format][u'browseButton'],
QtCore.QObject.connect(self.formatWidgets[format][u'browseButton'],
QtCore.SIGNAL(u'clicked()'), self.onBrowseButtonClicked)
QtCore.QObject.connect(
self.formatWidgets[format][u'filepathEdit'],
QtCore.SIGNAL(u'textChanged (const QString&)'),
self.onFilepathEditTextChanged)
QtCore.QObject.connect(self.formatWidgets[format][u'filepathEdit'],
QtCore.SIGNAL(u'textChanged (const QString&)'), self.onFilepathEditTextChanged)
def addCustomPages(self):
"""
@ -130,16 +123,13 @@ class SongImportForm(OpenLPWizard):
self.formatComboBox = QtGui.QComboBox(self.sourcePage)
self.formatComboBox.setObjectName(u'FormatComboBox')
self.formatLayout.addRow(self.formatLabel, self.formatComboBox)
self.formatSpacer = QtGui.QSpacerItem(10, 0, QtGui.QSizePolicy.Fixed,
QtGui.QSizePolicy.Minimum)
self.formatLayout.setItem(1, QtGui.QFormLayout.LabelRole,
self.formatSpacer)
self.formatSpacer = QtGui.QSpacerItem(10, 0, QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Minimum)
self.formatLayout.setItem(1, QtGui.QFormLayout.LabelRole, self.formatSpacer)
self.sourceLayout.addLayout(self.formatLayout)
self.formatHSpacing = self.formatLayout.horizontalSpacing()
self.formatVSpacing = self.formatLayout.verticalSpacing()
self.formatLayout.setVerticalSpacing(0)
self.stackSpacer = QtGui.QSpacerItem(10, 0, QtGui.QSizePolicy.Fixed,
QtGui.QSizePolicy.Expanding)
self.stackSpacer = QtGui.QSpacerItem(10, 0, QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Expanding)
self.formatStack = QtGui.QStackedLayout()
self.formatStack.setObjectName(u'FormatStack')
self.disablableFormats = []
@ -152,63 +142,48 @@ class SongImportForm(OpenLPWizard):
"""
Song wizard localisation.
"""
self.setWindowTitle(
translate('SongsPlugin.ImportWizardForm', 'Song Import Wizard'))
self.titleLabel.setText(WizardStrings.HeaderStyle %
translate('OpenLP.Ui', 'Welcome to the Song Import Wizard'))
self.informationLabel.setText(
translate('SongsPlugin.ImportWizardForm',
self.setWindowTitle(translate('SongsPlugin.ImportWizardForm', 'Song Import Wizard'))
self.titleLabel.setText(WizardStrings.HeaderStyle % translate('OpenLP.Ui', 'Welcome to the Song Import Wizard'))
self.informationLabel.setText(translate('SongsPlugin.ImportWizardForm',
'This wizard will help you to import songs from a variety of '
'formats. Click the next button below to start the process by '
'selecting a format to import from.'))
'formats. Click the next button below to start the process by selecting a format to import from.'))
self.sourcePage.setTitle(WizardStrings.ImportSelect)
self.sourcePage.setSubTitle(WizardStrings.ImportSelectLong)
self.formatLabel.setText(WizardStrings.FormatLabel)
for format in SongFormat.get_format_list():
format_name, custom_combo_text, description_text, select_mode = \
SongFormat.get(format, u'name', u'comboBoxText',
u'descriptionText', u'selectMode')
combo_box_text = (custom_combo_text if custom_combo_text else
format_name)
SongFormat.get(format, u'name', u'comboBoxText', u'descriptionText', u'selectMode')
combo_box_text = (custom_combo_text if custom_combo_text else format_name)
self.formatComboBox.setItemText(format, combo_box_text)
if description_text is not None:
self.formatWidgets[format][u'descriptionLabel'].setText(
description_text)
self.formatWidgets[format][u'descriptionLabel'].setText(description_text)
if select_mode == SongFormatSelect.MultipleFiles:
self.formatWidgets[format][u'addButton'].setText(
translate('SongsPlugin.ImportWizardForm', 'Add Files...'))
self.formatWidgets[format][u'removeButton'].setText(
translate('SongsPlugin.ImportWizardForm', 'Remove File(s)'))
else:
self.formatWidgets[format][u'browseButton'].setText(
UiStrings().Browse)
self.formatWidgets[format][u'browseButton'].setText(UiStrings().Browse)
f_label = 'Filename:'
if select_mode == SongFormatSelect.SingleFolder:
f_label = 'Folder:'
self.formatWidgets[format][u'filepathLabel'].setText(
translate('SongsPlugin.ImportWizardForm', f_label))
self.formatWidgets[format][u'filepathLabel'].setText(translate('SongsPlugin.ImportWizardForm', f_label))
for format in self.disablableFormats:
self.formatWidgets[format][u'disabledLabel'].setText(
SongFormat.get(format, u'disabledLabelText'))
self.formatWidgets[format][u'disabledLabel'].setText(SongFormat.get(format, u'disabledLabelText'))
self.progressPage.setTitle(WizardStrings.Importing)
self.progressPage.setSubTitle(
translate('SongsPlugin.ImportWizardForm',
'Please wait while your songs are imported.'))
translate('SongsPlugin.ImportWizardForm', 'Please wait while your songs are imported.'))
self.progressLabel.setText(WizardStrings.Ready)
self.progressBar.setFormat(WizardStrings.PercentSymbolFormat)
self.errorCopyToButton.setText(translate('SongsPlugin.ImportWizardForm',
'Copy'))
self.errorSaveToButton.setText(translate('SongsPlugin.ImportWizardForm',
'Save to File'))
self.errorCopyToButton.setText(translate('SongsPlugin.ImportWizardForm', 'Copy'))
self.errorSaveToButton.setText(translate('SongsPlugin.ImportWizardForm', 'Save to File'))
# Align all QFormLayouts towards each other.
formats = filter(lambda f: u'filepathLabel' in self.formatWidgets[f],
SongFormat.get_format_list())
formats = filter(lambda f: u'filepathLabel' in self.formatWidgets[f], SongFormat.get_format_list())
labels = [self.formatWidgets[f][u'filepathLabel'] for f in formats]
# Get max width of all labels
max_label_width = max(self.formatLabel.minimumSizeHint().width(),
max([label.minimumSizeHint().width() for label in labels]))
self.formatSpacer.changeSize(max_label_width, 0,
QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Fixed)
self.formatSpacer.changeSize(max_label_width, 0, QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Fixed)
spacers = [self.formatWidgets[f][u'filepathSpacer'] for f in formats]
for index, spacer in enumerate(spacers):
spacer.changeSize(
@ -218,8 +193,7 @@ class SongImportForm(OpenLPWizard):
for format in SongFormat.get_format_list():
if SongFormat.get(format, u'descriptionText') is not None:
self.formatWidgets[format][u'descriptionSpacer'].changeSize(
max_label_width + self.formatHSpacing, 0,
QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Fixed)
max_label_width + self.formatHSpacing, 0, QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Fixed)
def customPageChanged(self, pageId):
"""
@ -239,18 +213,14 @@ class SongImportForm(OpenLPWizard):
elif self.currentPage() == self.sourcePage:
format = self.currentFormat
Settings().setValue(u'songs/last import type', format)
select_mode, class_, error_msg = SongFormat.get(format,
u'selectMode', u'class', u'invalidSourceMsg')
select_mode, class_, error_msg = SongFormat.get(format, u'selectMode', u'class', u'invalidSourceMsg')
if select_mode == SongFormatSelect.MultipleFiles:
import_source = self.getListOfFiles(
self.formatWidgets[format][u'fileListWidget'])
import_source = self.getListOfFiles(self.formatWidgets[format][u'fileListWidget'])
error_title = UiStrings().IFSp
focus_button = self.formatWidgets[format][u'addButton']
else:
import_source = \
self.formatWidgets[format][u'filepathEdit'].text()
error_title = (UiStrings().IFSs if select_mode ==
SongFormatSelect.SingleFile else UiStrings().IFdSs)
import_source = self.formatWidgets[format][u'filepathEdit'].text()
error_title = (UiStrings().IFSs if select_mode == SongFormatSelect.SingleFile else UiStrings().IFdSs)
focus_button = self.formatWidgets[format][u'browseButton']
if not class_.isValidSource(import_source):
critical_error_message_box(error_title, error_msg)
@ -280,12 +250,10 @@ class SongImportForm(OpenLPWizard):
filters += u';;'
filters += u'%s (*)' % UiStrings().AllFiles
filenames = QtGui.QFileDialog.getOpenFileNames(self, title,
SettingsManager.get_last_dir(self.plugin.settingsSection, 1),
filters)
SettingsManager.get_last_dir(self.plugin.settingsSection, 1), filters)
if filenames:
listbox.addItems(filenames)
SettingsManager.set_last_dir(self.plugin.settingsSection,
os.path.split(unicode(filenames[0]))[0], 1)
SettingsManager.set_last_dir(self.plugin.settingsSection, os.path.split(unicode(filenames[0]))[0], 1)
def getListOfFiles(self, listbox):
"""
@ -307,22 +275,17 @@ class SongImportForm(OpenLPWizard):
u'name', u'filter')
filepathEdit = self.formatWidgets[format][u'filepathEdit']
if select_mode == SongFormatSelect.SingleFile:
self.getFileName(WizardStrings.OpenTypeFile % format_name,
filepathEdit, filter)
self.getFileName(WizardStrings.OpenTypeFile % format_name, filepathEdit, filter)
elif select_mode == SongFormatSelect.SingleFolder:
self.getFolder(WizardStrings.OpenTypeFolder % format_name,
filepathEdit)
self.getFolder(WizardStrings.OpenTypeFolder % format_name, filepathEdit)
def onAddButtonClicked(self):
format = self.currentFormat
select_mode, format_name, filter, custom_title = SongFormat.get(format,
u'selectMode', u'name', u'filter',
u'getFilesTitle')
title = custom_title if custom_title \
else WizardStrings.OpenTypeFile % format_name
select_mode, format_name, filter, custom_title = \
SongFormat.get(format, u'selectMode', u'name', u'filter', u'getFilesTitle')
title = custom_title if custom_title else WizardStrings.OpenTypeFile % format_name
if select_mode == SongFormatSelect.MultipleFiles:
self.getFiles(title, self.formatWidgets[format][u'fileListWidget'],
filter)
self.getFiles(title, self.formatWidgets[format][u'fileListWidget'], filter)
self.sourcePage.emit(QtCore.SIGNAL(u'completeChanged()'))
def onRemoveButtonClicked(self):
@ -343,10 +306,8 @@ class SongImportForm(OpenLPWizard):
self.restart()
self.finishButton.setVisible(False)
self.cancelButton.setVisible(True)
last_import_type = Settings().value(
u'songs/last import type', SongFormat.OpenLyrics)
if last_import_type < 0 or \
last_import_type >= self.formatComboBox.count():
last_import_type = Settings().value(u'songs/last import type', SongFormat.OpenLyrics)
if last_import_type < 0 or last_import_type >= self.formatComboBox.count():
last_import_type = 0
self.formatComboBox.setCurrentIndex(last_import_type)
for format in SongFormat.get_format_list():
@ -377,15 +338,14 @@ class SongImportForm(OpenLPWizard):
source_format = self.currentFormat
select_mode = SongFormat.get(source_format, u'selectMode')
if select_mode == SongFormatSelect.SingleFile:
importer = self.plugin.importSongs(source_format, filename=
self.formatWidgets[source_format][u'filepathEdit'].text())
importer = self.plugin.importSongs(source_format,
filename = self.formatWidgets[source_format][u'filepathEdit'].text())
elif select_mode == SongFormatSelect.SingleFolder:
importer = self.plugin.importSongs(source_format, folder=
self.formatWidgets[source_format][u'filepathEdit'].text())
importer = self.plugin.importSongs(source_format,
folder = self.formatWidgets[source_format][u'filepathEdit'].text())
else:
importer = self.plugin.importSongs(source_format,
filenames=self.getListOfFiles(
self.formatWidgets[source_format][u'fileListWidget']))
filenames=self.getListOfFiles(self.formatWidgets[source_format][u'fileListWidget']))
importer.doImport()
self.progressLabel.setText(WizardStrings.FinishedImport)
@ -409,8 +369,8 @@ class SongImportForm(OpenLPWizard):
def addFileSelectItem(self):
format = self.currentFormat
prefix, can_disable, description_text, select_mode = SongFormat.get(
format, u'prefix', u'canDisable', u'descriptionText', u'selectMode')
prefix, can_disable, description_text, select_mode = \
SongFormat.get(format, u'prefix', u'canDisable', u'descriptionText', u'selectMode')
page = QtGui.QWidget()
page.setObjectName(prefix + u'Page')
if can_disable:
@ -423,8 +383,7 @@ class SongImportForm(OpenLPWizard):
if description_text is not None:
descriptionLayout = QtGui.QHBoxLayout()
descriptionLayout.setObjectName(prefix + u'DescriptionLayout')
descriptionSpacer = QtGui.QSpacerItem(0, 0, QtGui.QSizePolicy.Fixed,
QtGui.QSizePolicy.Fixed)
descriptionSpacer = QtGui.QSpacerItem(0, 0, QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Fixed)
descriptionLayout.addSpacerItem(descriptionSpacer)
descriptionLabel = QtGui.QLabel(importWidget)
descriptionLabel.setWordWrap(True)
@ -434,16 +393,14 @@ class SongImportForm(OpenLPWizard):
importLayout.addLayout(descriptionLayout)
self.formatWidgets[format][u'descriptionLabel'] = descriptionLabel
self.formatWidgets[format][u'descriptionSpacer'] = descriptionSpacer
if select_mode == SongFormatSelect.SingleFile or \
select_mode == SongFormatSelect.SingleFolder:
if select_mode == SongFormatSelect.SingleFile or select_mode == SongFormatSelect.SingleFolder:
filepathLayout = QtGui.QHBoxLayout()
filepathLayout.setObjectName(prefix + u'FilepathLayout')
filepathLayout.setContentsMargins(0, self.formatVSpacing, 0, 0)
filepathLabel = QtGui.QLabel(importWidget)
filepathLabel.setObjectName(prefix + u'FilepathLabel')
filepathLayout.addWidget(filepathLabel)
filepathSpacer = QtGui.QSpacerItem(0, 0, QtGui.QSizePolicy.Fixed,
QtGui.QSizePolicy.Fixed)
filepathSpacer = QtGui.QSpacerItem(0, 0, QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Fixed)
filepathLayout.addSpacerItem(filepathSpacer)
filepathEdit = QtGui.QLineEdit(importWidget)
filepathEdit.setObjectName(prefix + u'FilepathEdit')
@ -461,8 +418,7 @@ class SongImportForm(OpenLPWizard):
self.formatWidgets[format][u'browseButton'] = browseButton
elif select_mode == SongFormatSelect.MultipleFiles:
fileListWidget = QtGui.QListWidget(importWidget)
fileListWidget.setSelectionMode(
QtGui.QAbstractItemView.ExtendedSelection)
fileListWidget.setSelectionMode(QtGui.QAbstractItemView.ExtendedSelection)
fileListWidget.setObjectName(prefix + u'FileListWidget')
importLayout.addWidget(fileListWidget)
buttonLayout = QtGui.QHBoxLayout()
@ -533,20 +489,16 @@ class SongImportSourcePage(QtGui.QWizardPage):
"""
wizard = self.wizard()
format = wizard.currentFormat
select_mode, format_available = SongFormat.get(format, u'selectMode',
u'availability')
select_mode, format_available = SongFormat.get(format, u'selectMode', u'availability')
if format_available:
if select_mode == SongFormatSelect.MultipleFiles:
if wizard.formatWidgets[format][u'fileListWidget'].count() > 0:
return True
else:
filepath = unicode(
wizard.formatWidgets[format][u'filepathEdit'].text())
filepath = unicode(wizard.formatWidgets[format][u'filepathEdit'].text())
if filepath:
if select_mode == SongFormatSelect.SingleFile and \
os.path.isfile(filepath):
if select_mode == SongFormatSelect.SingleFile and os.path.isfile(filepath):
return True
elif select_mode == SongFormatSelect.SingleFolder and \
os.path.isdir(filepath):
elif select_mode == SongFormatSelect.SingleFolder and os.path.isdir(filepath):
return True
return False

View File

@ -1,5 +1,5 @@
# -*- coding: utf-8 -*-
# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4
# vim: autoindent shiftwidth=4 expandtab textwidth=120 tabstop=4 softtabstop=4
###############################################################################
# OpenLP - Open Source Lyrics Projection #
@ -34,14 +34,12 @@ import sqlite3
from PyQt4 import QtCore, QtGui
from openlp.core.lib import Plugin, StringContent, build_icon, translate, \
Receiver
from openlp.core.lib import Plugin, StringContent, build_icon, translate, Receiver
from openlp.core.lib.db import Manager
from openlp.core.lib.ui import UiStrings, create_action
from openlp.core.utils import get_filesystem_encoding
from openlp.core.utils.actions import ActionList
from openlp.plugins.songs.lib import clean_song, upgrade, SongMediaItem, \
SongsTab
from openlp.plugins.songs.lib import clean_song, upgrade, SongMediaItem, SongsTab
from openlp.plugins.songs.lib.db import init_schema, Song
from openlp.plugins.songs.lib.importer import SongFormat
from openlp.plugins.songs.lib.olpimport import OpenLPSongImport
@ -81,8 +79,7 @@ class SongsPlugin(Plugin):
action_list.add_action(self.songImportItem, UiStrings().Import)
action_list.add_action(self.songExportItem, UiStrings().Export)
action_list.add_action(self.toolsReindexItem, UiStrings().Tools)
QtCore.QObject.connect(Receiver.get_receiver(),
QtCore.SIGNAL(u'servicemanager_new_service'),
QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'servicemanager_new_service'),
self.clearTemporarySongs)
@ -98,8 +95,7 @@ class SongsPlugin(Plugin):
# Main song import menu item - will eventually be the only one
self.songImportItem = create_action(import_menu, u'songImportItem',
text=translate('SongsPlugin', '&Song'),
tooltip=translate('SongsPlugin',
'Import songs using the import wizard.'),
tooltip=translate('SongsPlugin', 'Import songs using the import wizard.'),
triggers=self.onSongImportItemClicked)
import_menu.addAction(self.songImportItem)
@ -115,8 +111,7 @@ class SongsPlugin(Plugin):
# Main song import menu item - will eventually be the only one
self.songExportItem = create_action(export_menu, u'songExportItem',
text=translate('SongsPlugin', '&Song'),
tooltip=translate('SongsPlugin',
'Exports songs using the export wizard.'),
tooltip=translate('SongsPlugin', 'Exports songs using the export wizard.'),
triggers=self.onSongExportItemClicked)
export_menu.addAction(self.songExportItem)
@ -133,8 +128,7 @@ class SongsPlugin(Plugin):
self.toolsReindexItem = create_action(tools_menu, u'toolsReindexItem',
text=translate('SongsPlugin', '&Re-index Songs'),
icon=u':/plugins/plugin_songs.png',
statustip=translate('SongsPlugin',
'Re-index the songs database to improve searching and ordering.'),
statustip=translate('SongsPlugin', 'Re-index the songs database to improve searching and ordering.'),
visible=False, triggers=self.onToolsReindexItemTriggered)
tools_menu.addAction(self.toolsReindexItem)
@ -145,8 +139,7 @@ class SongsPlugin(Plugin):
maxSongs = self.manager.get_object_count(Song)
if maxSongs == 0:
return
progressDialog = QtGui.QProgressDialog(
translate('SongsPlugin', 'Reindexing songs...'), UiStrings().Cancel,
progressDialog = QtGui.QProgressDialog(translate('SongsPlugin', 'Reindexing songs...'), UiStrings().Cancel,
0, maxSongs, self.formParent)
progressDialog.setWindowTitle(translate('SongsPlugin', 'Reindexing songs'))
progressDialog.setWindowModality(QtCore.Qt.WindowModal)
@ -167,8 +160,7 @@ class SongsPlugin(Plugin):
def about(self):
return translate('SongsPlugin', '<strong>Songs Plugin</strong>'
'<br />The songs plugin provides the ability to display and '
'manage songs.')
'<br />The songs plugin provides the ability to display and manage songs.')
def usesTheme(self, theme):
"""
@ -239,8 +231,7 @@ class SongsPlugin(Plugin):
Receiver.send_message(u'openlp_process_events')
self.onToolsReindexItemTriggered()
Receiver.send_message(u'openlp_process_events')
db_dir = unicode(os.path.join(
unicode(gettempdir(), get_filesystem_encoding()), u'openlp'))
db_dir = unicode(os.path.join(unicode(gettempdir(), get_filesystem_encoding()), u'openlp'))
if not os.path.exists(db_dir):
return
song_dbs = []