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 -*- # -*- 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 # # OpenLP - Open Source Lyrics Projection #

View File

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

View File

@ -1,5 +1,5 @@
# -*- coding: utf-8 -*- # -*- 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 # # OpenLP - Open Source Lyrics Projection #

View File

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

View File

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

View File

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

View File

@ -1,5 +1,5 @@
# -*- coding: utf-8 -*- # -*- 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 # # OpenLP - Open Source Lyrics Projection #
@ -47,10 +47,8 @@ class EditCustomSlideForm(QtGui.QDialog, Ui_CustomSlideEditDialog):
QtGui.QDialog.__init__(self, parent) QtGui.QDialog.__init__(self, parent)
self.setupUi(self) self.setupUi(self)
# Connecting signals and slots # Connecting signals and slots
QtCore.QObject.connect(self.insertButton, QtCore.QObject.connect(self.insertButton, QtCore.SIGNAL(u'clicked()'), self.onInsertButtonClicked)
QtCore.SIGNAL(u'clicked()'), self.onInsertButtonClicked) QtCore.QObject.connect(self.splitButton, QtCore.SIGNAL(u'clicked()'), self.onSplitButtonClicked)
QtCore.QObject.connect(self.splitButton,
QtCore.SIGNAL(u'clicked()'), self.onSplitButtonClicked)
def setText(self, text): def setText(self, text):
""" """

View File

@ -1,5 +1,5 @@
# -*- coding: utf-8 -*- # -*- 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 # # OpenLP - Open Source Lyrics Projection #

View File

@ -1,5 +1,5 @@
# -*- coding: utf-8 -*- # -*- 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 # # OpenLP - Open Source Lyrics Projection #
@ -54,17 +54,14 @@ class CustomTab(SettingsTab):
self.leftLayout.addWidget(self.customModeGroupBox) self.leftLayout.addWidget(self.customModeGroupBox)
self.leftLayout.addStretch() self.leftLayout.addStretch()
self.rightLayout.addStretch() self.rightLayout.addStretch()
QtCore.QObject.connect(self.displayFooterCheckBox, QtCore.QObject.connect(self.displayFooterCheckBox, QtCore.SIGNAL(u'stateChanged(int)'),
QtCore.SIGNAL(u'stateChanged(int)'),
self.onDisplayFooterCheckBoxChanged) self.onDisplayFooterCheckBoxChanged)
QtCore.QObject.connect(self.add_from_service_checkbox, QtCore.QObject.connect(self.add_from_service_checkbox, QtCore.SIGNAL(u'stateChanged(int)'),
QtCore.SIGNAL(u'stateChanged(int)'), self.on_add_from_service_check_box_changed) self.on_add_from_service_check_box_changed)
def retranslateUi(self): def retranslateUi(self):
self.customModeGroupBox.setTitle(translate('CustomPlugin.CustomTab', self.customModeGroupBox.setTitle(translate('CustomPlugin.CustomTab', 'Custom Display'))
'Custom Display')) self.displayFooterCheckBox.setText(translate('CustomPlugin.CustomTab', 'Display footer'))
self.displayFooterCheckBox.setText(
translate('CustomPlugin.CustomTab', 'Display footer'))
self.add_from_service_checkbox.setText(translate('CustomPlugin.CustomTab', self.add_from_service_checkbox.setText(translate('CustomPlugin.CustomTab',
'Import missing custom slides from service files')) 'Import missing custom slides from service files'))

View File

@ -1,5 +1,5 @@
# -*- coding: utf-8 -*- # -*- 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 # # OpenLP - Open Source Lyrics Projection #

View File

@ -1,5 +1,5 @@
# -*- coding: utf-8 -*- # -*- 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 # # OpenLP - Open Source Lyrics Projection #

View File

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

View File

@ -1,5 +1,5 @@
# -*- coding: utf-8 -*- # -*- 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 # # OpenLP - Open Source Lyrics Projection #

View File

@ -1,5 +1,5 @@
# -*- coding: utf-8 -*- # -*- 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 # # OpenLP - Open Source Lyrics Projection #

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -1,5 +1,5 @@
# -*- coding: utf-8 -*- # -*- 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 # # OpenLP - Open Source Lyrics Projection #

View File

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

View File

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

View File

@ -1,5 +1,5 @@
# -*- coding: utf-8 -*- # -*- 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 # # OpenLP - Open Source Lyrics Projection #
@ -41,8 +41,7 @@ class RemotesPlugin(Plugin):
""" """
remotes constructor remotes constructor
""" """
Plugin.__init__(self, u'remotes', plugin_helpers, Plugin.__init__(self, u'remotes', plugin_helpers, settings_tab_class=RemoteTab)
settings_tab_class=RemoteTab)
self.iconPath = u':/plugins/plugin_remote.png' self.iconPath = u':/plugins/plugin_remote.png'
self.icon = build_icon(self.iconPath) self.icon = build_icon(self.iconPath)
self.weight = -1 self.weight = -1

View File

@ -1,5 +1,5 @@
# -*- coding: utf-8 -*- # -*- 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 # # OpenLP - Open Source Lyrics Projection #

View File

@ -1,5 +1,5 @@
# -*- coding: utf-8 -*- # -*- 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 # # OpenLP - Open Source Lyrics Projection #

View File

@ -1,5 +1,5 @@
# -*- coding: utf-8 -*- # -*- 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 # # OpenLP - Open Source Lyrics Projection #
@ -59,18 +59,13 @@ class Ui_AuthorsDialog(object):
self.displayLabel.setBuddy(self.displayEdit) self.displayLabel.setBuddy(self.displayEdit)
self.authorLayout.addRow(self.displayLabel, self.displayEdit) self.authorLayout.addRow(self.displayLabel, self.displayEdit)
self.dialogLayout.addLayout(self.authorLayout) self.dialogLayout.addLayout(self.authorLayout)
self.buttonBox = create_button_box(authorsDialog, u'buttonBox', self.buttonBox = create_button_box(authorsDialog, u'buttonBox', [u'cancel', u'save'])
[u'cancel', u'save'])
self.dialogLayout.addWidget(self.buttonBox) self.dialogLayout.addWidget(self.buttonBox)
self.retranslateUi(authorsDialog) self.retranslateUi(authorsDialog)
authorsDialog.setMaximumHeight(authorsDialog.sizeHint().height()) authorsDialog.setMaximumHeight(authorsDialog.sizeHint().height())
def retranslateUi(self, authorsDialog): def retranslateUi(self, authorsDialog):
authorsDialog.setWindowTitle( authorsDialog.setWindowTitle(translate('SongsPlugin.AuthorsForm', 'Author Maintenance'))
translate('SongsPlugin.AuthorsForm', 'Author Maintenance')) self.displayLabel.setText(translate('SongsPlugin.AuthorsForm', 'Display name:'))
self.displayLabel.setText( self.firstNameLabel.setText(translate('SongsPlugin.AuthorsForm', 'First name:'))
translate('SongsPlugin.AuthorsForm', 'Display name:')) self.lastNameLabel.setText(translate('SongsPlugin.AuthorsForm', 'Last 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 -*- # -*- 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 # # OpenLP - Open Source Lyrics Projection #
@ -44,11 +44,9 @@ class AuthorsForm(QtGui.QDialog, Ui_AuthorsDialog):
QtGui.QDialog.__init__(self, parent) QtGui.QDialog.__init__(self, parent)
self.setupUi(self) self.setupUi(self)
self._autoDisplayName = False self._autoDisplayName = False
QtCore.QObject.connect(self.firstNameEdit, QtCore.QObject.connect(self.firstNameEdit, QtCore.SIGNAL(u'textEdited(QString)'),
QtCore.SIGNAL(u'textEdited(QString)'),
self.onFirstNameEditTextEdited) self.onFirstNameEditTextEdited)
QtCore.QObject.connect(self.lastNameEdit, QtCore.QObject.connect(self.lastNameEdit, QtCore.SIGNAL(u'textEdited(QString)'),
QtCore.SIGNAL(u'textEdited(QString)'),
self.onLastNameEditTextEdited) self.onLastNameEditTextEdited)
def exec_(self, clear=True): def exec_(self, clear=True):
@ -82,24 +80,20 @@ class AuthorsForm(QtGui.QDialog, Ui_AuthorsDialog):
def accept(self): def accept(self):
if not self.firstNameEdit.text(): if not self.firstNameEdit.text():
critical_error_message_box( critical_error_message_box(
message=translate('SongsPlugin.AuthorsForm', message=translate('SongsPlugin.AuthorsForm', 'You need to type in the first name of the author.'))
'You need to type in the first name of the author.'))
self.firstNameEdit.setFocus() self.firstNameEdit.setFocus()
return False return False
elif not self.lastNameEdit.text(): elif not self.lastNameEdit.text():
critical_error_message_box( critical_error_message_box(
message=translate('SongsPlugin.AuthorsForm', message=translate('SongsPlugin.AuthorsForm', 'You need to type in the last name of the author.'))
'You need to type in the last name of the author.'))
self.lastNameEdit.setFocus() self.lastNameEdit.setFocus()
return False return False
elif not self.displayEdit.text(): elif not self.displayEdit.text():
if critical_error_message_box( if critical_error_message_box(
message=translate('SongsPlugin.AuthorsForm', message=translate('SongsPlugin.AuthorsForm',
'You have not set a display name for the ' 'You have not set a display name for the author, combine the first and last names?'),
'author, combine the first and last names?'),
parent=self, question=True) == QtGui.QMessageBox.Yes: parent=self, question=True) == QtGui.QMessageBox.Yes:
self.displayEdit.setText(self.firstNameEdit.text() + \ self.displayEdit.setText(self.firstNameEdit.text() + u' ' + self.lastNameEdit.text())
u' ' + self.lastNameEdit.text())
return QtGui.QDialog.accept(self) return QtGui.QDialog.accept(self)
else: else:
self.displayEdit.setFocus() self.displayEdit.setFocus()

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -1,5 +1,5 @@
# -*- coding: utf-8 -*- # -*- 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 # # OpenLP - Open Source Lyrics Projection #
@ -53,15 +53,12 @@ class Ui_SongBookDialog(object):
self.publisherLabel.setBuddy(self.publisherEdit) self.publisherLabel.setBuddy(self.publisherEdit)
self.bookLayout.addRow(self.publisherLabel, self.publisherEdit) self.bookLayout.addRow(self.publisherLabel, self.publisherEdit)
self.dialogLayout.addLayout(self.bookLayout) self.dialogLayout.addLayout(self.bookLayout)
self.buttonBox = create_button_box(songBookDialog, u'buttonBox', self.buttonBox = create_button_box(songBookDialog, u'buttonBox', [u'cancel', u'save'])
[u'cancel', u'save'])
self.dialogLayout.addWidget(self.buttonBox) self.dialogLayout.addWidget(self.buttonBox)
self.retranslateUi(songBookDialog) self.retranslateUi(songBookDialog)
songBookDialog.setMaximumHeight(songBookDialog.sizeHint().height()) songBookDialog.setMaximumHeight(songBookDialog.sizeHint().height())
def retranslateUi(self, songBookDialog): def retranslateUi(self, songBookDialog):
songBookDialog.setWindowTitle( songBookDialog.setWindowTitle(translate('SongsPlugin.SongBookForm', 'Song Book Maintenance'))
translate('SongsPlugin.SongBookForm', 'Song Book Maintenance'))
self.nameLabel.setText(translate('SongsPlugin.SongBookForm', '&Name:')) self.nameLabel.setText(translate('SongsPlugin.SongBookForm', '&Name:'))
self.publisherLabel.setText( self.publisherLabel.setText(translate('SongsPlugin.SongBookForm', '&Publisher:'))
translate('SongsPlugin.SongBookForm', '&Publisher:'))

View File

@ -1,5 +1,5 @@
# -*- coding: utf-8 -*- # -*- 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 # # OpenLP - Open Source Lyrics Projection #
@ -54,8 +54,7 @@ class SongBookForm(QtGui.QDialog, Ui_SongBookDialog):
def accept(self): def accept(self):
if not self.nameEdit.text(): if not self.nameEdit.text():
critical_error_message_box( critical_error_message_box(
message=translate('SongsPlugin.SongBookForm', message=translate('SongsPlugin.SongBookForm', 'You need to type in a name for the book.'))
'You need to type in a name for the book.'))
self.nameEdit.setFocus() self.nameEdit.setFocus()
return False return False
else: else:

View File

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

View File

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

View File

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