Head r851

This commit is contained in:
Jon Tibble 2010-06-17 18:00:14 +01:00
commit d395438173
25 changed files with 216 additions and 237 deletions

View File

@ -29,7 +29,7 @@ import os
from PyQt4 import QtCore, QtGui
from openlp.core.lib import context_menu_action, context_menu_separator, \
SettingsManager, OpenLPToolbar, ServiceItem, build_icon
SettingsManager, OpenLPToolbar, ServiceItem, build_icon, translate
log = logging.getLogger(__name__)
@ -110,7 +110,6 @@ class MediaManagerItem(QtGui.QWidget):
self.remoteTriggered = None
self.ServiceItemIconName = None
self.singleServiceItem = True
self.addToServiceItem = False
self.PageLayout = QtGui.QVBoxLayout(self)
self.PageLayout.setSpacing(0)
self.PageLayout.setContentsMargins(4, 0, 4, 0)
@ -133,6 +132,7 @@ class MediaManagerItem(QtGui.QWidget):
self.hasEditIcon = True
self.hasFileIcon = False
self.hasDeleteIcon = True
self.addToServiceItem = False
def retranslateUi(self):
"""
@ -208,50 +208,62 @@ class MediaManagerItem(QtGui.QWidget):
## Import Button ##
if self.hasImportIcon:
self.addToolbarButton(
u'Import %s' % self.PluginNameShort,
u'%s %s' % (self.trUtf8('Import a'), self.PluginNameVisible),
unicode(translate(u'MediaManagerItem', u'Import %s')) % \
self.PluginNameShort,
unicode(translate(u'MediaManagerItem', u'Import a %s')) % \
self.PluginNameVisible,
u':/general/general_import.png', self.onImportClick)
## File Button ##
if self.hasFileIcon:
self.addToolbarButton(
u'Load %s' % self.PluginNameShort,
u'%s %s' % (self.trUtf8('Load a new'), self.PluginNameVisible),
unicode(translate(u'MediaManagerItem', u'Load %s')) % \
self.PluginNameShort,
unicode(translate(u'MediaManagerItem', u'Load a new %s')) % \
self.PluginNameVisible,
u':/general/general_open.png', self.onFileClick)
## New Button ##
if self.hasNewIcon:
self.addToolbarButton(
u'New %s' % self.PluginNameShort,
u'%s %s' % (self.trUtf8('Add a new'), self.PluginNameVisible),
unicode(translate(u'MediaManagerItem', u'New %s')) % \
self.PluginNameShort,
unicode(translate(u'MediaManagerItem', u'Add a new %s')) % \
self.PluginNameVisible,
u':/general/general_new.png', self.onNewClick)
## Edit Button ##
if self.hasEditIcon:
self.addToolbarButton(
u'Edit %s' % self.PluginNameShort,
u'%s %s' % (self.trUtf8('Edit the selected'),
self.PluginNameVisible),
unicode(translate(u'MediaManagerItem', u'Edit %s')) % \
self.PluginNameShort,
unicode(translate(
u'MediaManagerItem', u'Edit the selected %s')) % \
self.PluginNameVisible,
u':/general/general_edit.png', self.onEditClick)
## Delete Button ##
if self.hasDeleteIcon:
self.addToolbarButton(
u'Delete %s' % self.PluginNameShort,
self.trUtf8('Delete the selected item'),
unicode(translate(u'MediaManagerItem', u'Delete %s')) % \
self.PluginNameShort,
translate(u'MediaManagerItem', u'Delete the selected item'),
u':/general/general_delete.png', self.onDeleteClick)
## Separator Line ##
self.addToolbarSeparator()
## Preview ##
self.addToolbarButton(
u'Preview %s' % self.PluginNameShort,
self.trUtf8('Preview the selected item'),
unicode(translate(u'MediaManagerItem', u'Preview %s')) % \
self.PluginNameShort,
translate(u'MediaManagerItem', u'Preview the selected item'),
u':/general/general_preview.png', self.onPreviewClick)
## Live Button ##
self.addToolbarButton(
u'Go Live',
self.trUtf8('Send the selected item live'),
translate(u'MediaManagerItem', u'Send the selected item live'),
u':/general/general_live.png', self.onLiveClick)
## Add to service Button ##
self.addToolbarButton(
u'Add %s to Service' % self.PluginNameShort,
self.trUtf8('Add the selected item(s) to the service'),
unicode(translate(u'MediaManagerItem', u'Add %s to Service')) % \
self.PluginNameShort,
translate(u'MediaManagerItem',
u'Add the selected item(s) to the service'),
u':/general/general_add.png', self.onAddClick)
def addListViewToToolBar(self):
@ -273,34 +285,40 @@ class MediaManagerItem(QtGui.QWidget):
self.ListView.addAction(
context_menu_action(
self.ListView, u':/general/general_edit.png',
u'%s %s' % (self.trUtf8('&Edit'), self.PluginNameVisible),
unicode(translate(u'MediaManagerItem', u'&Edit %s')) % \
self.PluginNameVisible,
self.onEditClick))
self.ListView.addAction(context_menu_separator(self.ListView))
if self.hasDeleteIcon:
self.ListView.addAction(
context_menu_action(
self.ListView, u':/general/general_delete.png',
u'%s %s' % (self.trUtf8('&Delete'), self.PluginNameVisible),
unicode(translate(u'MediaManagerItem', u'&Delete %s')) % \
self.PluginNameVisible,
self.onDeleteClick))
self.ListView.addAction(context_menu_separator(self.ListView))
self.ListView.addAction(
context_menu_action(
self.ListView, u':/general/general_preview.png',
u'%s %s' % (self.trUtf8('&Preview'), self.PluginNameVisible),
unicode(translate(u'MediaManagerItem', u'&Preview %s')) % \
self.PluginNameVisible,
self.onPreviewClick))
self.ListView.addAction(
context_menu_action(
self.ListView, u':/general/general_live.png',
self.trUtf8('&Show Live'), self.onLiveClick))
translate(u'MediaManagerItem', u'&Show Live'),
self.onLiveClick))
self.ListView.addAction(
context_menu_action(
self.ListView, u':/general/general_add.png',
self.trUtf8('&Add to Service'), self.onAddClick))
translate(u'MediaManagerItem', u'&Add to Service'),
self.onAddClick))
if self.addToServiceItem:
self.ListView.addAction(
context_menu_action(
self.ListView, u':/general/general_add.png',
self.trUtf8('&Add to selected Service Item'),
translate(u'MediaManagerItem',
u'&Add to selected Service Item'),
self.onAddEditClick))
QtCore.QObject.connect(
self.ListView, QtCore.SIGNAL(u'doubleClicked(QModelIndex)'),
@ -325,6 +343,19 @@ class MediaManagerItem(QtGui.QWidget):
"""
pass
def checkItemSelected(self, message):
"""
Check if a list item is selected so an action may be performed on it
``message``
The message to give the user if no item is selected
"""
if not self.ListView.selectedIndexes():
QtGui.QMessageBox.information(self,
translate(u'MediaManagerItem', u'No Items Selected'), message)
return False
return True
def onFileClick(self):
files = QtGui.QFileDialog.getOpenFileNames(
self, self.OnNewPrompt,
@ -391,8 +422,9 @@ class MediaManagerItem(QtGui.QWidget):
def onPreviewClick(self):
if not self.ListView.selectedIndexes() and not self.remoteTriggered:
QtGui.QMessageBox.information(self,
self.trUtf8('No Items Selected'),
self.trUtf8('You must select one or more items.'))
translate(u'MediaManagerItem', u'No Items Selected'),
translate(u'MediaManagerItem',
u'You must select one or more items to preview.'))
else:
log.debug(self.PluginNameShort + u' Preview requested')
service_item = self.buildServiceItem()
@ -403,8 +435,9 @@ class MediaManagerItem(QtGui.QWidget):
def onLiveClick(self):
if not self.ListView.selectedIndexes():
QtGui.QMessageBox.information(self,
self.trUtf8('No Items Selected'),
self.trUtf8('You must select one or more items.'))
translate(u'MediaManagerItem', u'No Items Selected'),
translate(u'MediaManagerItem',
u'You must select one or more items to send live.'))
else:
log.debug(self.PluginNameShort + u' Live requested')
service_item = self.buildServiceItem()
@ -415,8 +448,9 @@ class MediaManagerItem(QtGui.QWidget):
def onAddClick(self):
if not self.ListView.selectedIndexes() and not self.remoteTriggered:
QtGui.QMessageBox.information(self,
self.trUtf8('No Items Selected'),
self.trUtf8('You must select one or more items.'))
translate(u'MediaManagerItem', u'No Items Selected'),
translate(u'MediaManagerItem',
u'You must select one or more items.'))
else:
#Is it posssible to process multiple list items to generate multiple
#service items?
@ -438,16 +472,17 @@ class MediaManagerItem(QtGui.QWidget):
def onAddEditClick(self):
if not self.ListView.selectedIndexes() and not self.remoteTriggered:
QtGui.QMessageBox.information(self,
self.trUtf8('No items selected'),
self.trUtf8('You must select one or more items'))
translate(u'MediaManagerItem', u'No items selected'),
translate(u'MediaManagerItem',
u'You must select one or more items'))
else:
log.debug(self.PluginNameShort + u' Add requested')
service_item = self.parent.service_manager.getServiceItem()
if not service_item:
QtGui.QMessageBox.information(self,
self.trUtf8('No Service Item Selected'),
self.trUtf8(
'You must select an existing service item to add to.'))
translate(u'MediaManagerItem', u'No Service Item Selected'),
translate(u'MediaManagerItem',
u'You must select an existing service item to add to.'))
elif self.title.lower() == service_item.name.lower():
self.generateSlideData(service_item)
self.parent.service_manager.addServiceItem(service_item,
@ -455,9 +490,9 @@ class MediaManagerItem(QtGui.QWidget):
else:
#Turn off the remote edit update message indicator
QtGui.QMessageBox.information(self,
self.trUtf8('Invalid Service Item'),
self.trUtf8(unicode(
'You must select a %s service item.' % self.title)))
translate(u'MediaManagerItem', u'Invalid Service Item'),
translate(unicode(u'MediaManagerItem',
u'You must select a %s service item.')) % self.title)
def buildServiceItem(self, item=None):
"""

View File

@ -231,7 +231,8 @@ class Plugin(QtCore.QObject):
Show a dialog when the user clicks on the 'About' button in the plugin
manager.
"""
pass
raise NotImplementedError(
u'Plugin.about needs to be defined by the plugin')
def initialise(self):
"""

View File

@ -24,13 +24,15 @@
###############################################################################
from PyQt4 import QtCore, QtGui
from openlp.core.lib import build_icon
from openlp.core.lib import build_icon, translate
class SplashScreen(object):
def __init__(self, version):
self.splash_screen = QtGui.QSplashScreen()
self.setupUi()
self.message = self.splash_screen.trUtf8('Starting')\
self.message = translate(
u'Splashscreen', u'Starting')\
+ '..... ' + version
def setupUi(self):
@ -58,7 +60,7 @@ class SplashScreen(object):
def retranslateUi(self):
self.splash_screen.setWindowTitle(
self.splash_screen.trUtf8('Splash Screen'))
translate(u'Splashscreen', u'Splash Screen'))
def show(self):
self.splash_screen.show()

View File

@ -69,9 +69,9 @@ class alertsPlugin(Plugin):
self.toolsAlertItem.setIcon(AlertIcon)
self.toolsAlertItem.setObjectName(u'toolsAlertItem')
self.toolsAlertItem.setText(
translate(u'AlertsPlugin.AlertsPlugin', u'&Alert'))
translate(u'AlertsPlugin', u'&Alert'))
self.toolsAlertItem.setStatusTip(
translate(u'AlertsPlugin.AlertsPlugin', u'Show an alert message'))
translate(u'AlertsPlugin', u'Show an alert message'))
self.toolsAlertItem.setShortcut(u'F7')
self.service_manager.parent.ToolsMenu.addAction(self.toolsAlertItem)
QtCore.QObject.connect(self.toolsAlertItem,
@ -99,7 +99,7 @@ class alertsPlugin(Plugin):
self.alertForm.exec_()
def about(self):
about_text = translate(u'AlertsPlugin.AlertsPlugin',
about_text = translate(u'AlertsPlugin',
u'<b>Alerts Plugin</b><br>This plugin '
u'controls the displaying of alerts on the presentations screen')
return about_text

View File

@ -70,7 +70,8 @@ class BiblePlugin(Plugin):
self.ImportBibleItem = QtGui.QAction(import_menu)
self.ImportBibleItem.setObjectName(u'ImportBibleItem')
import_menu.addAction(self.ImportBibleItem)
self.ImportBibleItem.setText(import_menu.trUtf8('&Bible'))
self.ImportBibleItem.setText(
translate(u'BiblePlugin', u'&Bible'))
# Signals and slots
QtCore.QObject.connect(self.ImportBibleItem,
QtCore.SIGNAL(u'triggered()'), self.onBibleImportClick)
@ -80,7 +81,8 @@ class BiblePlugin(Plugin):
self.ExportBibleItem = QtGui.QAction(export_menu)
self.ExportBibleItem.setObjectName(u'ExportBibleItem')
export_menu.addAction(self.ExportBibleItem)
self.ExportBibleItem.setText(export_menu.trUtf8('&Bible'))
self.ExportBibleItem.setText(translate(
u'BiblePlugin', u'&Bible'))
self.ExportBibleItem.setVisible(False)
def onBibleImportClick(self):
@ -88,7 +90,7 @@ class BiblePlugin(Plugin):
self.media_item.onImportClick()
def about(self):
about_text = translate(u'BiblesPlugin.BiblePlugin',
about_text = translate(u'BiblePlugin',
u'<strong>Bible Plugin</strong><br />This '
u'plugin allows bible verses from different sources to be '
u'displayed on the screen during the service.')

View File

@ -301,17 +301,20 @@ class ImportWizardForm(QtGui.QWizard, Ui_BibleImportWizard):
self.setField(u'csv_versefile', QtCore.QVariant(''))
self.setField(u'opensong_file', QtCore.QVariant(''))
self.setField(u'web_location', QtCore.QVariant(WebDownload.Crosswalk))
self.setField(u'web_biblename', QtCore.QVariant(self.BibleComboBox))
self.setField(u'web_biblename',
QtCore.QVariant(self.BibleComboBox.currentIndex()))
self.setField(u'proxy_server',
settings.value(u'proxy address', QtCore.QVariant(u'')))
self.setField(u'proxy_username',
settings.value(u'proxy username', QtCore.QVariant(u'')))
self.setField(u'proxy_password',
settings.value(u'proxy password', QtCore.QVariant(u'')))
self.setField(u'license_version', QtCore.QVariant(self.VersionNameEdit))
self.setField(u'license_copyright', QtCore.QVariant(self.CopyrightEdit))
self.setField(u'license_version',
QtCore.QVariant(self.VersionNameEdit.text()))
self.setField(u'license_copyright',
QtCore.QVariant(self.CopyrightEdit.text()))
self.setField(u'license_permission',
QtCore.QVariant(self.PermissionEdit))
QtCore.QVariant(self.PermissionEdit.text()))
self.onLocationComboBoxChanged(WebDownload.Crosswalk)
settings.endGroup()

View File

@ -27,12 +27,12 @@ import logging
import chardet
import re
from PyQt4 import QtCore
from PyQt4 import QtCore, QtGui
from sqlalchemy import Column, ForeignKey, or_, Table, types
from sqlalchemy.orm import class_mapper, mapper, relation
from sqlalchemy.orm.exc import UnmappedClassError
from openlp.core.lib.db import BaseModel, init_db, Manager
from openlp.core.lib.db import BaseModel, init_db, Manager, translate
log = logging.getLogger(__name__)
@ -339,6 +339,14 @@ class BibleDB(QtCore.QObject, Manager):
.order_by(Verse.verse)\
.all()
verse_list.extend(verses)
else:
log.debug(u'OpenLP failed to find book %s', book)
QtGui.QMessageBox.information(self.bible_plugin.media_item,
translate(u'BibleDB', u'Book not found'),
translate(u'BibleDB', u'The book you requested could not '
u'be found in this bible. Please check your spelling '
u'and that this is a complete bible not just one '
u'testament.'))
return verse_list
def verse_search(self, text):

View File

@ -57,7 +57,6 @@ class BibleMediaItem(MediaManagerItem):
self.IconPath = u'songs/song'
self.ListViewWithDnD_class = BibleListView
self.lastReference = []
self.addToServiceItem = True
MediaManagerItem.__init__(self, parent, icon, title)
# place to store the search results
self.search_results = {}

View File

@ -69,7 +69,7 @@ class CustomPlugin(Plugin):
self.remove_toolbox_item()
def about(self):
about_text = translate(u'CustomPlugin.CustomPlugin',
about_text = translate(u'CustomPlugin',
u'<b>Custom Plugin</b><br>This plugin '
u'allows slides to be displayed on the screen in the same way '
u'songs are. This plugin provides greater freedom over the '

View File

@ -117,16 +117,24 @@ class CustomMediaItem(MediaManagerItem):
self.parent.edit_custom_form.exec_()
def onEditClick(self):
"""
Edit a custom item
"""
if self.checkItemSelected(translate(u'CustomPlugin.MediaItem',
u'You must select an item to edit.')):
item = self.ListView.currentItem()
if item:
item_id = (item.data(QtCore.Qt.UserRole)).toInt()[0]
self.parent.edit_custom_form.loadCustom(item_id, False)
self.parent.edit_custom_form.exec_()
self.initialise()
def onDeleteClick(self):
"""
Remove a custom item from the list and database
"""
if self.checkItemSelected(translate(u'CustomPlugin.MediaItem',
u'You must select an item to delete.')):
item = self.ListView.currentItem()
if item:
item_id = (item.data(QtCore.Qt.UserRole)).toInt()[0]
self.parent.custommanager.delete_object(CustomSlide, item_id)
row = self.ListView.row(item)

View File

@ -56,7 +56,7 @@ class ImagePlugin(Plugin):
return ImageMediaItem(self, self.icon, self.name)
def about(self):
about_text = translate(u'ImagePlugin.ImagePlugin', u'<b>Image Plugin'
about_text = translate(u'ImagePlugin', u'<b>Image Plugin'
u'</b><br>Allows images of all types to be displayed. If a number '
u'of images are selected together and presented on the live '
u'controller it is possible to turn them into a timed loop.<br<br>'

View File

@ -54,7 +54,6 @@ class ImageMediaItem(MediaManagerItem):
# be instanced by the base MediaManagerItem
self.ListViewWithDnD_class = ImageListView
MediaManagerItem.__init__(self, parent, icon, title)
self.addToServiceItem = True
def initPluginNameVisible(self):
self.PluginNameVisible = translate(u'ImagePlugin.MediaItem', u'Image')
@ -74,6 +73,7 @@ class ImageMediaItem(MediaManagerItem):
self.hasFileIcon = True
self.hasNewIcon = False
self.hasEditIcon = False
self.addToServiceItem = True
def initialise(self):
log.debug(u'initialise')
@ -116,14 +116,18 @@ class ImageMediaItem(MediaManagerItem):
self.PageLayout.addWidget(self.ImageWidget)
def onDeleteClick(self):
"""
Remove an image item from the list
"""
if self.checkItemSelected(translate(u'ImagePlugin.MediaItem',
u'You must select an item to delete.')):
items = self.ListView.selectedIndexes()
if items:
for item in items:
text = self.ListView.item(item.row())
if text:
try:
os.remove(
os.path.join(self.servicePath, unicode(text.text())))
os.remove(os.path.join(self.servicePath,
unicode(text.text())))
except OSError:
#if not present do not worry
pass

View File

@ -137,8 +137,12 @@ class MediaMediaItem(MediaManagerItem):
self.settingsSection))
def onDeleteClick(self):
"""
Remove a media item from the list
"""
if self.checkItemSelected(translate(u'MediaPlugin.MediaItem',
u'You must select an item to delete.')):
item = self.ListView.currentItem()
if item:
row = self.ListView.row(item)
self.ListView.takeItem(row)
SettingsManager.set_list(self.settingsSection,
@ -152,4 +156,3 @@ class MediaMediaItem(MediaManagerItem):
item_name.setIcon(build_icon(img))
item_name.setData(QtCore.Qt.UserRole, QtCore.QVariant(file))
self.ListView.addItem(item_name)

View File

@ -81,7 +81,7 @@ class MediaPlugin(Plugin):
return MediaMediaItem(self, self.icon, self.name)
def about(self):
about_text = translate(u'MediaPlugin.MediaPlugin',
about_text = translate(u'MediaPlugin',
u'<b>Media Plugin</b><br>This plugin '
u'allows the playing of audio and video media')
return about_text

View File

@ -181,7 +181,7 @@ class ImpressController(PresentationController):
class ImpressDocument(PresentationDocument):
def __init__(self, controller, presentation):
log.debug(u'Init Presentation OpenOffice')
PresentationDocument.__init__(controller, presentation)
PresentationDocument.__init__(self, controller, presentation)
self.document = None
self.presentation = None
self.control = None

View File

@ -174,8 +174,12 @@ class PresentationMediaItem(MediaManagerItem):
self.ListView.addItem(item_name)
def onDeleteClick(self):
"""
Remove a presentation item from the list
"""
if self.checkItemSelected(translate(u'PresentationPlugin.MediaItem',
u'You must select an item to delete.')):
item = self.ListView.currentItem()
if item:
row = self.ListView.row(item)
self.ListView.takeItem(row)
SettingsManager.set_list(self.settingsSection,

View File

@ -29,6 +29,7 @@ import os
from PyQt4 import QtCore
from openlp.core.lib import Receiver
from openlp.core.ui import HideMode
log = logging.getLogger(__name__)
@ -55,7 +56,7 @@ class Controller(object):
self.doc.start_presentation()
if isBlank:
self.blank()
Receiver.send_message(u'maindisplay_hide')
Receiver.send_message(u'maindisplay_hide', HideMode.Screen)
self.doc.slidenumber = 0
def activate(self):
@ -179,6 +180,7 @@ class Controller(object):
self.doc.slidenumber != self.doc.get_slide_number():
self.doc.goto_slide(self.doc.slidenumber)
self.doc.unblank_screen()
Receiver.send_message(u'maindisplay_hide', HideMode.Screen)
def poll(self):
self.doc.poll_slidenumber(self.isLive)

View File

@ -104,7 +104,7 @@ class PowerpointController(PresentationController):
class PowerpointDocument(PresentationDocument):
def __init__(self, controller, presentation):
log.debug(u'Init Presentation Powerpoint')
PresentationDocument.__init__(controller, presentation)
PresentationDocument.__init__(self, controller, presentation)
self.presentation = None
def load_presentation(self):
@ -142,7 +142,7 @@ class PowerpointDocument(PresentationDocument):
if self.check_thumbnails():
return
self.presentation.Export(os.path.join(self.thumbnailpath, ''), 'png',
640, 480)
320, 240)
def close_presentation(self):
"""

View File

@ -102,7 +102,7 @@ class PptviewController(PresentationController):
class PptviewDocument(PresentationDocument):
def __init__(self, controller, presentation):
log.debug(u'Init Presentation PowerPoint')
PresentationDocument.__init__(controller, presentation)
PresentationDocument.__init__(self, controller, presentation)
self.presentation = None
self.pptid = None
self.blanked = False

View File

@ -108,7 +108,7 @@ class PresentationPlugin(Plugin):
return False
def about(self):
about_text = translate(u'PresentationPlugin.PresentationPlugin',
about_text = translate(u'PresentationPlugin',
u'<b>Presentation Plugin</b> <br> Delivers '
u'the ability to show presentations using a number of different '
u'programs. The choice of available presentation programs is '

View File

@ -69,7 +69,7 @@ class RemotesPlugin(Plugin):
"""
Information about this plugin
"""
about_text = translate(u'RemotePlugin.RemotePlugin',
about_text = translate(u'RemotePlugin',
u'<b>Remote Plugin</b><br>This plugin '
u'provides the ability to send messages to a running version of '
u'openlp on a different computer via a web browser or other app<br>'

View File

@ -276,15 +276,23 @@ class SongMediaItem(MediaManagerItem):
self.edit_song_form.exec_()
def onEditClick(self):
"""
Edit a song
"""
if self.checkItemSelected(translate(u'SongsPlugin.MediaItem',
u'You must select an item to edit.')):
item = self.ListView.currentItem()
if item:
item_id = (item.data(QtCore.Qt.UserRole)).toInt()[0]
self.edit_song_form.loadSong(item_id, False)
self.edit_song_form.exec_()
def onDeleteClick(self):
"""
Remove a song from the list and database
"""
if self.checkItemSelected(translate(u'SongsPlugin.MediaItem',
u'You must select an item to delete.')):
items = self.ListView.selectedIndexes()
if items:
if len(items) == 1:
del_message = translate(u'SongsPlugin.MediaItem',
u'Delete song?')
@ -372,4 +380,3 @@ class SongMediaItem(MediaManagerItem):
song.title, author_audit, song.copyright, song.ccli_number
]
return True

View File

@ -95,36 +95,44 @@ class SongsPlugin(Plugin):
# Main song import menu item - will eventually be the only one
self.SongImportItem = QtGui.QAction(import_menu)
self.SongImportItem.setObjectName(u'SongImportItem')
self.SongImportItem.setText(import_menu.trUtf8('&Song'))
self.SongImportItem.setText(translate(
u'SongsPlugin', u'&Song'))
self.SongImportItem.setToolTip(
import_menu.trUtf8('Import songs using the import wizard.'))
translate(u'SongsPlugin',
u'Import songs using the import wizard.'))
import_menu.addAction(self.SongImportItem)
# Songs of Fellowship import menu item - will be removed and the
# functionality will be contained within the import wizard
self.ImportSofItem = QtGui.QAction(import_menu)
self.ImportSofItem.setObjectName(u'ImportSofItem')
self.ImportSofItem.setText(
import_menu.trUtf8('Songs of Fellowship (temp menu item)'))
translate(u'SongsPlugin',
u'Songs of Fellowship (temp menu item)'))
self.ImportSofItem.setToolTip(
import_menu.trUtf8('Import songs from the VOLS1_2.RTF, sof3words' \
+ '.rtf and sof4words.rtf supplied with the music books'))
translate(u'SongsPlugin',
u'Import songs from the VOLS1_2.RTF, sof3words' \
+ u'.rtf and sof4words.rtf supplied with the music books'))
self.ImportSofItem.setStatusTip(
import_menu.trUtf8('Import songs from the VOLS1_2.RTF, sof3words' \
+ '.rtf and sof4words.rtf supplied with the music books'))
translate(u'SongsPlugin',
u'Import songs from the VOLS1_2.RTF, sof3words' \
+ u'.rtf and sof4words.rtf supplied with the music books'))
import_menu.addAction(self.ImportSofItem)
# OpenOffice.org import menu item - will be removed and the
# functionality will be contained within the import wizard
self.ImportOooItem = QtGui.QAction(import_menu)
self.ImportOooItem.setObjectName(u'ImportOooItem')
self.ImportOooItem.setText(
import_menu.trUtf8('Generic Document/Presentation Import '
'(temp menu item)'))
translate(u'SongsPlugin',
u'Generic Document/Presentation Import '
u'(temp menu item)'))
self.ImportOooItem.setToolTip(
import_menu.trUtf8('Import songs from '
'Word/Writer/Powerpoint/Impress'))
translate(u'SongsPlugin',
u'Import songs from '
u'Word/Writer/Powerpoint/Impress'))
self.ImportOooItem.setStatusTip(
import_menu.trUtf8('Import songs from '
'Word/Writer/Powerpoint/Impress'))
translate(u'SongsPlugin',
u'Import songs from '
u'Word/Writer/Powerpoint/Impress'))
import_menu.addAction(self.ImportOooItem)
# Signals and slots
QtCore.QObject.connect(self.SongImportItem,
@ -152,7 +160,7 @@ class SongsPlugin(Plugin):
def onImportSofItemClick(self):
filenames = QtGui.QFileDialog.getOpenFileNames(
None, translate(u'SongsPlugin.Songsplugin',
None, translate(u'SongsPlugin',
u'Open Songs of Fellowship file'),
u'', u'Songs of Fellowship file (*.rtf *.RTF)')
try:
@ -162,18 +170,20 @@ class SongsPlugin(Plugin):
except:
log.exception('Could not import SoF file')
QtGui.QMessageBox.critical(None,
self.ImportSongMenu.trUtf8('Import Error'),
self.ImportSongMenu.trUtf8('Error importing Songs of '
'Fellowship file.\nOpenOffice.org must be installed'
' and you must be using an unedited copy of the RTF'
' included with the Songs of Fellowship Music Editions'),
translate(u'SongsPlugin',
u'Import Error'),
translate(u'SongsPlugin',
u'Error importing Songs of '
u'Fellowship file.\nOpenOffice.org must be installed'
u' and you must be using an unedited copy of the RTF'
u' included with the Songs of Fellowship Music Editions'),
QtGui.QMessageBox.StandardButtons(QtGui.QMessageBox.Ok),
QtGui.QMessageBox.Ok)
Receiver.send_message(u'songs_load_list')
def onImportOooItemClick(self):
filenames = QtGui.QFileDialog.getOpenFileNames(
None, translate(u'SongsPlugin.Songsplugin',
None, translate(u'SongsPlugin',
u'Open documents or presentations'),
u'', u'All Files(*.*)')
oooimport = OooImport(self.manager)
@ -181,7 +191,7 @@ class SongsPlugin(Plugin):
Receiver.send_message(u'songs_load_list')
def about(self):
about_text = translate(u'SongsPlugin.Songsplugin',
about_text = translate(u'SongsPlugin',
u'<strong>Song Plugin</strong><br />'
u'This plugin allows songs to be managed and displayed.')
return about_text

View File

@ -59,20 +59,25 @@ class SongUsagePlugin(Plugin):
self.toolsMenu = tools_menu
self.SongUsageMenu = QtGui.QMenu(tools_menu)
self.SongUsageMenu.setObjectName(u'SongUsageMenu')
self.SongUsageMenu.setTitle(tools_menu.trUtf8('&Song Usage'))
self.SongUsageMenu.setTitle(translate(
u'SongUsagePlugin', u'&Song Usage'))
#SongUsage Delete
self.SongUsageDelete = QtGui.QAction(tools_menu)
self.SongUsageDelete.setText(
tools_menu.trUtf8('&Delete recorded data'))
translate(u'SongUsagePlugin',
u'&Delete recorded data'))
self.SongUsageDelete.setStatusTip(
tools_menu.trUtf8('Delete song usage to specified date'))
translate(u'SongUsagePlugin',
u'Delete song usage to specified date'))
self.SongUsageDelete.setObjectName(u'SongUsageDelete')
#SongUsage Report
self.SongUsageReport = QtGui.QAction(tools_menu)
self.SongUsageReport.setText(
tools_menu.trUtf8('&Extract recorded data'))
translate(u'SongUsagePlugin',
u'&Extract recorded data'))
self.SongUsageReport.setStatusTip(
tools_menu.trUtf8('Generate report on Song Usage'))
translate(u'SongUsagePlugin',
u'Generate report on Song Usage'))
self.SongUsageReport.setObjectName(u'SongUsageReport')
#SongUsage activation
SongUsageIcon = build_icon(u':/tools/tools_alert.png')
@ -80,9 +85,11 @@ class SongUsagePlugin(Plugin):
self.SongUsageStatus.setIcon(SongUsageIcon)
self.SongUsageStatus.setCheckable(True)
self.SongUsageStatus.setChecked(False)
self.SongUsageStatus.setText(tools_menu.trUtf8('Song Usage Status'))
self.SongUsageStatus.setText(translate(
u'SongUsagePlugin', u'Song Usage Status'))
self.SongUsageStatus.setStatusTip(
tools_menu.trUtf8('Start/Stop live song usage recording'))
translate(u'SongUsagePlugin',
u'Start/Stop live song usage recording'))
self.SongUsageStatus.setShortcut(u'F4')
self.SongUsageStatus.setObjectName(u'SongUsageStatus')
#Add Menus together
@ -156,7 +163,7 @@ class SongUsagePlugin(Plugin):
self.SongUsagedetailform.exec_()
def about(self):
about_text = translate(u'SongsPlugin.SongUsagePlugin',
about_text = translate(u'SongUsagePlugin',
u'<b>SongUsage Plugin</b><br>This plugin '
u'records the use of songs and when they have been used during '
u'a live service')

View File

@ -1,116 +0,0 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4
###############################################################################
# OpenLP - Open Source Lyrics Projection #
# --------------------------------------------------------------------------- #
# Copyright (c) 2008-2010 Raoul Snyman #
# Portions copyright (c) 2008-2010 Tim Bentley, Jonathan Corwin, Michael #
# Gorven, Scott Guerrieri, Christian Richter, Maikel Stuivenberg, Martin #
# Thompson, Jon Tibble, Carsten Tinggaard #
# --------------------------------------------------------------------------- #
# This program is free software; you can redistribute it and/or modify it #
# under the terms of the GNU General Public License as published by the Free #
# Software Foundation; version 2 of the License. #
# #
# This program is distributed in the hope that it will be useful, but WITHOUT #
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or #
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for #
# more details. #
# #
# You should have received a copy of the GNU General Public License along #
# with this program; if not, write to the Free Software Foundation, Inc., 59 #
# Temple Place, Suite 330, Boston, MA 02111-1307 USA #
###############################################################################
import os
from cgi import escape
from ast import parse, NodeVisitor, Str
ts_file = u"""<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE TS>
<TS version="1.1">
%s
</TS>
"""
ts_context = u""" <context>
<name>%s</name>
%s </context>
"""
ts_message = u""" <message>
<location filename="%s" line="%d"/>
<source>%s</source>
<translation type="unfinished"></translation>
</message>
"""
class StringExtractor(NodeVisitor):
def __init__(self, strings, filename, base_path):
self.base_path = base_path
self.filename = filename
self.strings = strings
self.classname = 'unknown'
def visit_ClassDef(self, node):
self.classname = node.name
self.generic_visit(node)
def visit_Call(self, node):
if hasattr(node.func, 'attr') and node.func.attr == 'trUtf8' and isinstance(node.args[0], Str):
string = node.args[0].s
key = '%s-%s' % (self.classname, string)
self.strings[key] = [self.classname, self.filename[len(self.base_path) + 1:], node.lineno, escape(string)]
self.generic_visit(node)
def parse_file(base_path, filename, strings):
file = open(filename, u'r')
try:
ast = parse(file.read())
except SyntaxError, e:
print "Unable to parse %s: %s" % (filename, e)
return
file.close()
StringExtractor(strings, filename, base_path).visit(ast)
def write_file(filename, strings):
translation_file = u''
translation_contexts = []
translation_messages = []
class_name = strings[strings.keys()[0]][0]
current_context = u''
for key, translation in strings.iteritems():
if class_name != translation[0]:
current_context = ts_context % (class_name, u''.join(translation_messages))
translation_contexts.append(current_context)
translation_messages = []
class_name = translation[0]
translation_messages.append(ts_message % (translation[1], translation[2], translation[3]))
current_context = ts_context % (class_name, u''.join(translation_messages))
translation_contexts.append(current_context)
translation_file = ts_file % (u''.join(translation_contexts))
file = open(filename, u'w')
file.write(translation_file.encode('utf8'))
file.close()
def main():
strings = {}
start_dir = os.path.abspath(u'..')
for root, dirs, files in os.walk(start_dir):
for file in files:
if file.startswith(u'hook-') or file.startswith(u'test_'):
continue
if file.endswith(u'.py'):
print u'Parsing "%s"' % file
parse_file(start_dir, os.path.join(root, file), strings)
print u'Generating TS file...',
write_file(os.path.join(start_dir, u'resources', u'i18n', u'openlp_en.ts'), strings)
print u'done.'
if __name__ == u'__main__':
if os.path.split(os.path.abspath(u'.'))[1] != u'scripts':
print u'You need to run this script from the scripts directory.'
else:
main()