This commit is contained in:
Tim Bentley 2010-06-18 06:59:31 +01:00
commit d143b197a3
39 changed files with 365 additions and 360 deletions

View File

@ -80,9 +80,9 @@ def str_to_bool(stringvalue):
``stringvalue`` ``stringvalue``
The string value to examine and convert to a boolean type. The string value to examine and convert to a boolean type.
""" """
if stringvalue is True or stringvalue is False: if isinstance(stringvalue, bool):
return stringvalue return stringvalue
return stringvalue.strip().lower() in (u'true', u'yes', u'y') return unicode(stringvalue).strip().lower() in (u'true', u'yes', u'y')
def build_icon(icon): def build_icon(icon):
""" """

View File

@ -29,7 +29,7 @@ import os
from PyQt4 import QtCore, QtGui from PyQt4 import QtCore, QtGui
from openlp.core.lib import context_menu_action, context_menu_separator, \ 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__) log = logging.getLogger(__name__)
@ -110,7 +110,6 @@ class MediaManagerItem(QtGui.QWidget):
self.remoteTriggered = None self.remoteTriggered = None
self.ServiceItemIconName = None self.ServiceItemIconName = None
self.singleServiceItem = True self.singleServiceItem = True
self.addToServiceItem = False
self.PageLayout = QtGui.QVBoxLayout(self) self.PageLayout = QtGui.QVBoxLayout(self)
self.PageLayout.setSpacing(0) self.PageLayout.setSpacing(0)
self.PageLayout.setContentsMargins(4, 0, 4, 0) self.PageLayout.setContentsMargins(4, 0, 4, 0)
@ -133,6 +132,7 @@ class MediaManagerItem(QtGui.QWidget):
self.hasEditIcon = True self.hasEditIcon = True
self.hasFileIcon = False self.hasFileIcon = False
self.hasDeleteIcon = True self.hasDeleteIcon = True
self.addToServiceItem = False
def retranslateUi(self): def retranslateUi(self):
""" """
@ -208,50 +208,62 @@ class MediaManagerItem(QtGui.QWidget):
## Import Button ## ## Import Button ##
if self.hasImportIcon: if self.hasImportIcon:
self.addToolbarButton( self.addToolbarButton(
u'Import %s' % self.PluginNameShort, unicode(translate(u'MediaManagerItem', u'Import %s')) % \
u'%s %s' % (self.trUtf8('Import a'), self.PluginNameVisible), self.PluginNameShort,
unicode(translate(u'MediaManagerItem', u'Import a %s')) % \
self.PluginNameVisible,
u':/general/general_import.png', self.onImportClick) u':/general/general_import.png', self.onImportClick)
## File Button ## ## File Button ##
if self.hasFileIcon: if self.hasFileIcon:
self.addToolbarButton( self.addToolbarButton(
u'Load %s' % self.PluginNameShort, unicode(translate(u'MediaManagerItem', u'Load %s')) % \
u'%s %s' % (self.trUtf8('Load a new'), self.PluginNameVisible), self.PluginNameShort,
unicode(translate(u'MediaManagerItem', u'Load a new %s')) % \
self.PluginNameVisible,
u':/general/general_open.png', self.onFileClick) u':/general/general_open.png', self.onFileClick)
## New Button ## ## New Button ##
if self.hasNewIcon: if self.hasNewIcon:
self.addToolbarButton( self.addToolbarButton(
u'New %s' % self.PluginNameShort, unicode(translate(u'MediaManagerItem', u'New %s')) % \
u'%s %s' % (self.trUtf8('Add a new'), self.PluginNameVisible), self.PluginNameShort,
unicode(translate(u'MediaManagerItem', u'Add a new %s')) % \
self.PluginNameVisible,
u':/general/general_new.png', self.onNewClick) u':/general/general_new.png', self.onNewClick)
## Edit Button ## ## Edit Button ##
if self.hasEditIcon: if self.hasEditIcon:
self.addToolbarButton( self.addToolbarButton(
u'Edit %s' % self.PluginNameShort, unicode(translate(u'MediaManagerItem', u'Edit %s')) % \
u'%s %s' % (self.trUtf8('Edit the selected'), self.PluginNameShort,
self.PluginNameVisible), unicode(translate(
u'MediaManagerItem', u'Edit the selected %s')) % \
self.PluginNameVisible,
u':/general/general_edit.png', self.onEditClick) u':/general/general_edit.png', self.onEditClick)
## Delete Button ## ## Delete Button ##
if self.hasDeleteIcon: if self.hasDeleteIcon:
self.addToolbarButton( self.addToolbarButton(
u'Delete %s' % self.PluginNameShort, unicode(translate(u'MediaManagerItem', u'Delete %s')) % \
self.trUtf8('Delete the selected item'), self.PluginNameShort,
translate(u'MediaManagerItem', u'Delete the selected item'),
u':/general/general_delete.png', self.onDeleteClick) u':/general/general_delete.png', self.onDeleteClick)
## Separator Line ## ## Separator Line ##
self.addToolbarSeparator() self.addToolbarSeparator()
## Preview ## ## Preview ##
self.addToolbarButton( self.addToolbarButton(
u'Preview %s' % self.PluginNameShort, unicode(translate(u'MediaManagerItem', u'Preview %s')) % \
self.trUtf8('Preview the selected item'), self.PluginNameShort,
translate(u'MediaManagerItem', u'Preview the selected item'),
u':/general/general_preview.png', self.onPreviewClick) u':/general/general_preview.png', self.onPreviewClick)
## Live Button ## ## Live Button ##
self.addToolbarButton( self.addToolbarButton(
u'Go Live', 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) u':/general/general_live.png', self.onLiveClick)
## Add to service Button ## ## Add to service Button ##
self.addToolbarButton( self.addToolbarButton(
u'Add %s to Service' % self.PluginNameShort, unicode(translate(u'MediaManagerItem', u'Add %s to Service')) % \
self.trUtf8('Add the selected item(s) to the service'), self.PluginNameShort,
translate(u'MediaManagerItem',
u'Add the selected item(s) to the service'),
u':/general/general_add.png', self.onAddClick) u':/general/general_add.png', self.onAddClick)
def addListViewToToolBar(self): def addListViewToToolBar(self):
@ -273,34 +285,40 @@ class MediaManagerItem(QtGui.QWidget):
self.ListView.addAction( self.ListView.addAction(
context_menu_action( context_menu_action(
self.ListView, u':/general/general_edit.png', 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.onEditClick))
self.ListView.addAction(context_menu_separator(self.ListView)) self.ListView.addAction(context_menu_separator(self.ListView))
if self.hasDeleteIcon: if self.hasDeleteIcon:
self.ListView.addAction( self.ListView.addAction(
context_menu_action( context_menu_action(
self.ListView, u':/general/general_delete.png', 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.onDeleteClick))
self.ListView.addAction(context_menu_separator(self.ListView)) self.ListView.addAction(context_menu_separator(self.ListView))
self.ListView.addAction( self.ListView.addAction(
context_menu_action( context_menu_action(
self.ListView, u':/general/general_preview.png', 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.onPreviewClick))
self.ListView.addAction( self.ListView.addAction(
context_menu_action( context_menu_action(
self.ListView, u':/general/general_live.png', self.ListView, u':/general/general_live.png',
self.trUtf8('&Show Live'), self.onLiveClick)) translate(u'MediaManagerItem', u'&Show Live'),
self.onLiveClick))
self.ListView.addAction( self.ListView.addAction(
context_menu_action( context_menu_action(
self.ListView, u':/general/general_add.png', 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: if self.addToServiceItem:
self.ListView.addAction( self.ListView.addAction(
context_menu_action( context_menu_action(
self.ListView, u':/general/general_add.png', 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)) self.onAddEditClick))
QtCore.QObject.connect( QtCore.QObject.connect(
self.ListView, QtCore.SIGNAL(u'doubleClicked(QModelIndex)'), self.ListView, QtCore.SIGNAL(u'doubleClicked(QModelIndex)'),
@ -325,6 +343,19 @@ class MediaManagerItem(QtGui.QWidget):
""" """
pass 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): def onFileClick(self):
files = QtGui.QFileDialog.getOpenFileNames( files = QtGui.QFileDialog.getOpenFileNames(
self, self.OnNewPrompt, self, self.OnNewPrompt,
@ -343,7 +374,7 @@ class MediaManagerItem(QtGui.QWidget):
filelist = [] filelist = []
while count < self.ListView.count(): while count < self.ListView.count():
bitem = self.ListView.item(count) bitem = self.ListView.item(count)
filename = unicode((bitem.data(QtCore.Qt.UserRole)).toString()) filename = unicode(bitem.data(QtCore.Qt.UserRole).toString())
filelist.append(filename) filelist.append(filename)
count += 1 count += 1
return filelist return filelist
@ -391,8 +422,9 @@ class MediaManagerItem(QtGui.QWidget):
def onPreviewClick(self): def onPreviewClick(self):
if not self.ListView.selectedIndexes() and not self.remoteTriggered: if not self.ListView.selectedIndexes() and not self.remoteTriggered:
QtGui.QMessageBox.information(self, QtGui.QMessageBox.information(self,
self.trUtf8('No Items Selected'), translate(u'MediaManagerItem', u'No Items Selected'),
self.trUtf8('You must select one or more items.')) translate(u'MediaManagerItem',
u'You must select one or more items to preview.'))
else: else:
log.debug(self.PluginNameShort + u' Preview requested') log.debug(self.PluginNameShort + u' Preview requested')
service_item = self.buildServiceItem() service_item = self.buildServiceItem()
@ -403,8 +435,9 @@ class MediaManagerItem(QtGui.QWidget):
def onLiveClick(self): def onLiveClick(self):
if not self.ListView.selectedIndexes(): if not self.ListView.selectedIndexes():
QtGui.QMessageBox.information(self, QtGui.QMessageBox.information(self,
self.trUtf8('No Items Selected'), translate(u'MediaManagerItem', u'No Items Selected'),
self.trUtf8('You must select one or more items.')) translate(u'MediaManagerItem',
u'You must select one or more items to send live.'))
else: else:
log.debug(self.PluginNameShort + u' Live requested') log.debug(self.PluginNameShort + u' Live requested')
service_item = self.buildServiceItem() service_item = self.buildServiceItem()
@ -415,8 +448,9 @@ class MediaManagerItem(QtGui.QWidget):
def onAddClick(self): def onAddClick(self):
if not self.ListView.selectedIndexes() and not self.remoteTriggered: if not self.ListView.selectedIndexes() and not self.remoteTriggered:
QtGui.QMessageBox.information(self, QtGui.QMessageBox.information(self,
self.trUtf8('No Items Selected'), translate(u'MediaManagerItem', u'No Items Selected'),
self.trUtf8('You must select one or more items.')) translate(u'MediaManagerItem',
u'You must select one or more items.'))
else: else:
#Is it posssible to process multiple list items to generate multiple #Is it posssible to process multiple list items to generate multiple
#service items? #service items?
@ -438,16 +472,17 @@ class MediaManagerItem(QtGui.QWidget):
def onAddEditClick(self): def onAddEditClick(self):
if not self.ListView.selectedIndexes() and not self.remoteTriggered: if not self.ListView.selectedIndexes() and not self.remoteTriggered:
QtGui.QMessageBox.information(self, QtGui.QMessageBox.information(self,
self.trUtf8('No items selected'), translate(u'MediaManagerItem', u'No items selected'),
self.trUtf8('You must select one or more items')) translate(u'MediaManagerItem',
u'You must select one or more items'))
else: else:
log.debug(self.PluginNameShort + u' Add requested') log.debug(self.PluginNameShort + u' Add requested')
service_item = self.parent.service_manager.getServiceItem() service_item = self.parent.service_manager.getServiceItem()
if not service_item: if not service_item:
QtGui.QMessageBox.information(self, QtGui.QMessageBox.information(self,
self.trUtf8('No Service Item Selected'), translate(u'MediaManagerItem', u'No Service Item Selected'),
self.trUtf8( translate(u'MediaManagerItem',
'You must select an existing service item to add to.')) u'You must select an existing service item to add to.'))
elif self.title.lower() == service_item.name.lower(): elif self.title.lower() == service_item.name.lower():
self.generateSlideData(service_item) self.generateSlideData(service_item)
self.parent.service_manager.addServiceItem(service_item, self.parent.service_manager.addServiceItem(service_item,
@ -455,9 +490,9 @@ class MediaManagerItem(QtGui.QWidget):
else: else:
#Turn off the remote edit update message indicator #Turn off the remote edit update message indicator
QtGui.QMessageBox.information(self, QtGui.QMessageBox.information(self,
self.trUtf8('Invalid Service Item'), translate(u'MediaManagerItem', u'Invalid Service Item'),
self.trUtf8(unicode( translate(unicode(u'MediaManagerItem',
'You must select a %s service item.' % self.title))) u'You must select a %s service item.')) % self.title)
def buildServiceItem(self, item=None): 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 Show a dialog when the user clicks on the 'About' button in the plugin
manager. manager.
""" """
pass raise NotImplementedError(
u'Plugin.about needs to be defined by the plugin')
def initialise(self): def initialise(self):
""" """

View File

@ -468,7 +468,7 @@ class Renderer(object):
self._get_extent_and_render(line, footer, self._get_extent_and_render(line, footer,
tlcorner=(x + display_shadow_size, tlcorner=(x + display_shadow_size,
y + display_shadow_size), y + display_shadow_size),
draw=True, color = self._theme.display_shadow_color) draw=True, color=self._theme.display_shadow_color)
self._get_extent_and_render(line, footer, tlcorner=(x, y), self._get_extent_and_render(line, footer, tlcorner=(x, y),
draw=True, outline_size=display_outline_size) draw=True, outline_size=display_outline_size)
y += h y += h

View File

@ -44,8 +44,8 @@ class AboutForm(QtGui.QDialog, Ui_AboutDialog):
about_text = about_text.replace(u'<version>', about_text = about_text.replace(u'<version>',
self.applicationVersion[u'version']) self.applicationVersion[u'version'])
if self.applicationVersion[u'build']: if self.applicationVersion[u'build']:
build_text = u' %s %s' % (translate(u'AboutForm', u'build'), build_text = unicode(translate(u'AboutForm', u' build %s')) % \
self.applicationVersion[u'build']) self.applicationVersion[u'build']
else: else:
build_text = u'' build_text = u''
about_text = about_text.replace(u'<revision>', build_text) about_text = about_text.replace(u'<revision>', build_text)

View File

@ -155,7 +155,7 @@ class AmendThemeForm(QtGui.QDialog, Ui_AmendThemeDialog):
self.theme.background_direction) self.theme.background_direction)
else: else:
filename = \ filename = \
os.path.split(unicode(self.theme.background_filename))[0] os.path.split(unicode(self.theme.background_filename))[1]
new_theme.add_background_image(filename) new_theme.add_background_image(filename)
save_to = os.path.join(self.path, theme_name, filename) save_to = os.path.join(self.path, theme_name, filename)
save_from = self.theme.background_filename save_from = self.theme.background_filename

View File

@ -452,8 +452,8 @@ class Ui_MainWindow(object):
translate(u'MainWindow', u'Choose System language, if available')) translate(u'MainWindow', u'Choose System language, if available'))
for item in self.LanguageGroup.actions(): for item in self.LanguageGroup.actions():
item.setText(item.objectName()) item.setText(item.objectName())
item.setStatusTip(translate(u'MainWindow', item.setStatusTip(unicode(translate(u'MainWindow',
u'Set the interface language to %1').arg(item.objectName())) u'Set the interface language to %s')) % item.objectName())
self.ToolsAddToolItem.setText(translate(u'MainWindow', u'Add &Tool...')) self.ToolsAddToolItem.setText(translate(u'MainWindow', u'Add &Tool...'))
self.ToolsAddToolItem.setStatusTip( self.ToolsAddToolItem.setStatusTip(
translate(u'MainWindow', translate(u'MainWindow',
@ -488,7 +488,7 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow):
self.displayManager = DisplayManager(screens) self.displayManager = DisplayManager(screens)
self.aboutForm = AboutForm(self, applicationVersion) self.aboutForm = AboutForm(self, applicationVersion)
self.settingsForm = SettingsForm(self.screens, self, self) self.settingsForm = SettingsForm(self.screens, self, self)
self.recentFiles = [] self.recentFiles = QtCore.QStringList()
# Set up the path with plugins # Set up the path with plugins
pluginpath = AppLocation.get_directory(AppLocation.PluginsDir) pluginpath = AppLocation.get_directory(AppLocation.PluginsDir)
self.plugin_manager = PluginManager(pluginpath) self.plugin_manager = PluginManager(pluginpath)
@ -849,5 +849,4 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow):
if filename and filename not in self.recentFiles: if filename and filename not in self.recentFiles:
self.recentFiles.insert(0, QtCore.QString(filename)) self.recentFiles.insert(0, QtCore.QString(filename))
while self.recentFiles.count() > recentFileCount: while self.recentFiles.count() > recentFileCount:
self.recentFiles.pop() self.recentFiles.removeLast()

View File

@ -27,7 +27,7 @@ import logging
from PyQt4 import QtCore, QtGui from PyQt4 import QtCore, QtGui
from openlp.core.lib.plugin import PluginStatus from openlp.core.lib import PluginStatus, translate
from plugindialog import Ui_PluginViewDialog from plugindialog import Ui_PluginViewDialog
log = logging.getLogger(__name__) log = logging.getLogger(__name__)
@ -63,14 +63,14 @@ class PluginForm(QtGui.QDialog, Ui_PluginViewDialog):
# sometimes when it's loaded from the config, it isn't cast to int. # sometimes when it's loaded from the config, it isn't cast to int.
plugin.status = int(plugin.status) plugin.status = int(plugin.status)
# Set the little status text in brackets next to the plugin name. # Set the little status text in brackets next to the plugin name.
status_text = 'Inactive' status_text = unicode(translate(u'PluginForm', u'%s (Inactive)'))
if plugin.status == PluginStatus.Active: if plugin.status == PluginStatus.Active:
status_text = 'Active' status_text = unicode(translate(u'PluginForm', u'%s (Active)'))
elif plugin.status == PluginStatus.Inactive: elif plugin.status == PluginStatus.Inactive:
status_text = 'Inactive' status_text = unicode(translate(u'PluginForm', u'%s (Inactive)'))
elif plugin.status == PluginStatus.Disabled: elif plugin.status == PluginStatus.Disabled:
status_text = 'Disabled' status_text = unicode(translate(u'PluginForm', u'%s (Disabled)'))
item.setText(u'%s (%s)' % (plugin.name, status_text)) item.setText(status_text % plugin.name)
# If the plugin has an icon, set it! # If the plugin has an icon, set it!
if plugin.icon: if plugin.icon:
item.setIcon(plugin.icon) item.setIcon(plugin.icon)

View File

@ -599,11 +599,11 @@ class ServiceManager(QtGui.QWidget):
path_from = unicode(os.path.join( path_from = unicode(os.path.join(
frame[u'path'], frame[u'path'],
frame[u'title'])) frame[u'title']))
zip.write(path_from) zip.write(path_from.encode(u'utf-8'))
file = open(servicefile, u'wb') file = open(servicefile, u'wb')
cPickle.dump(service, file) cPickle.dump(service, file)
file.close() file.close()
zip.write(servicefile) zip.write(servicefile.encode(u'utf-8'))
except IOError: except IOError:
log.exception(u'Failed to save service to disk') log.exception(u'Failed to save service to disk')
finally: finally:
@ -669,7 +669,18 @@ class ServiceManager(QtGui.QWidget):
try: try:
zip = zipfile.ZipFile(unicode(filename)) zip = zipfile.ZipFile(unicode(filename))
for file in zip.namelist(): for file in zip.namelist():
osfile = unicode(QtCore.QDir.toNativeSeparators(file)) try:
ucsfile = file.decode(u'utf-8')
except UnicodeDecodeError:
QtGui.QMessageBox.critical(
self, translate(u'ServiceManager', u'Error'),
translate(u'ServiceManager',
u'File is not a valid service.\n'
u'The content encoding is not UTF-8.'))
log.exception(u'Filename "%s" is not valid UTF-8' % \
file.decode(u'utf-8', u'replace'))
continue
osfile = unicode(QtCore.QDir.toNativeSeparators(ucsfile))
names = osfile.split(os.path.sep) names = osfile.split(os.path.sep)
file_path = os.path.join(self.servicePath, file_path = os.path.join(self.servicePath,
names[len(names) - 1]) names[len(names) - 1])
@ -679,22 +690,29 @@ class ServiceManager(QtGui.QWidget):
file_to.close() file_to.close()
if file_path.endswith(u'osd'): if file_path.endswith(u'osd'):
p_file = file_path p_file = file_path
file_to = open(p_file, u'r') if 'p_file' in locals():
items = cPickle.load(file_to) file_to = open(p_file, u'r')
file_to.close() items = cPickle.load(file_to)
self.onNewService() file_to.close()
for item in items: self.onNewService()
serviceitem = ServiceItem() for item in items:
serviceitem.RenderManager = self.parent.RenderManager serviceitem = ServiceItem()
serviceitem.set_from_service(item, self.servicePath) serviceitem.RenderManager = self.parent.RenderManager
self.validateItem(serviceitem) serviceitem.set_from_service(item, self.servicePath)
self.addServiceItem(serviceitem) self.validateItem(serviceitem)
try: self.addServiceItem(serviceitem)
if os.path.isfile(p_file): try:
os.remove(p_file) if os.path.isfile(p_file):
except (IOError, OSError): os.remove(p_file)
log.exception(u'Failed to remove osd file') except (IOError, OSError):
except IOError: log.exception(u'Failed to remove osd file')
else:
QtGui.QMessageBox.critical(
self, translate(u'ServiceManager', u'Error'),
translate(u'ServiceManager',
u'File is not a valid service.'))
log.exception(u'File contains no service data')
except (IOError, NameError):
log.exception(u'Problem loading a service file') log.exception(u'Problem loading a service file')
finally: finally:
if file_to: if file_to:

View File

@ -563,8 +563,7 @@ class SlideController(QtGui.QWidget):
if self.isLive and frame[u'verseTag'] is not None: if self.isLive and frame[u'verseTag'] is not None:
if tag1 not in self.slideList: if tag1 not in self.slideList:
self.slideList[tag1] = framenumber self.slideList[tag1] = framenumber
self.SongMenu.menu().addAction( self.SongMenu.menu().addAction(tag1,
translate(u'SlideController', u'%s'%tag1),
self.onSongBarHandler) self.onSongBarHandler)
item.setText(frame[u'text']) item.setText(frame[u'text'])
else: else:

View File

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

View File

@ -36,7 +36,7 @@ from openlp.core.theme import Theme
from openlp.core.lib import OpenLPToolbar, context_menu_action, \ from openlp.core.lib import OpenLPToolbar, context_menu_action, \
ThemeXML, str_to_bool, get_text_file_string, build_icon, Receiver, \ ThemeXML, str_to_bool, get_text_file_string, build_icon, Receiver, \
context_menu_separator, SettingsManager, translate context_menu_separator, SettingsManager, translate
from openlp.core.utils import AppLocation from openlp.core.utils import AppLocation, get_filesystem_encoding
log = logging.getLogger(__name__) log = logging.getLogger(__name__)
@ -136,8 +136,8 @@ class ThemeManager(QtGui.QWidget):
self.ThemeListWidget.item(count).setText(newName) self.ThemeListWidget.item(count).setText(newName)
#Set the new name #Set the new name
if themeName == newName: if themeName == newName:
name = u'%s (%s)' % (newName, name = unicode(translate(u'ThemeManager', u'%s (default)')) % \
translate(u'ThemeManager', u'default')) newName
self.ThemeListWidget.item(count).setText(name) self.ThemeListWidget.item(count).setText(name)
def changeGlobalFromScreen(self, index = -1): def changeGlobalFromScreen(self, index = -1):
@ -158,8 +158,8 @@ class ThemeManager(QtGui.QWidget):
if count == selected_row: if count == selected_row:
self.global_theme = unicode( self.global_theme = unicode(
self.ThemeListWidget.item(count).text()) self.ThemeListWidget.item(count).text())
name = u'%s (%s)' % (self.global_theme, name = unicode(translate(u'ThemeManager', u'%s (default)')) % \
translate(u'ThemeManager', u'default')) self.global_theme
self.ThemeListWidget.item(count).setText(name) self.ThemeListWidget.item(count).setText(name)
QtCore.QSettings().setValue( QtCore.QSettings().setValue(
self.settingsSection + u'/global theme', self.settingsSection + u'/global theme',
@ -231,7 +231,9 @@ class ThemeManager(QtGui.QWidget):
try: try:
os.remove(os.path.join(self.path, th)) os.remove(os.path.join(self.path, th))
os.remove(os.path.join(self.thumbPath, th)) os.remove(os.path.join(self.thumbPath, th))
shutil.rmtree(os.path.join(self.path, theme)) encoding = get_filesystem_encoding()
shutil.rmtree(
os.path.join(self.path, theme).encode(encoding))
except OSError: except OSError:
#if not present do not worry #if not present do not worry
pass pass
@ -265,8 +267,8 @@ class ThemeManager(QtGui.QWidget):
for files in os.walk(source): for files in os.walk(source):
for name in files[2]: for name in files[2]:
zip.write( zip.write(
os.path.join(source, name), os.path.join(source, name).encode(u'utf-8'),
os.path.join(theme, name)) os.path.join(theme, name).encode(u'utf-8'))
QtGui.QMessageBox.information(self, QtGui.QMessageBox.information(self,
translate(u'ThemeManager', u'Theme Exported'), translate(u'ThemeManager', u'Theme Exported'),
translate(u'ThemeManager', translate(u'ThemeManager',
@ -316,8 +318,8 @@ class ThemeManager(QtGui.QWidget):
if os.path.exists(theme): if os.path.exists(theme):
textName = os.path.splitext(name)[0] textName = os.path.splitext(name)[0]
if textName == self.global_theme: if textName == self.global_theme:
name = u'%s (%s)' % (textName, name = unicode(translate(u'ThemeManager',
translate(u'ThemeManager', u'default')) u'%s (default)')) % textName
else: else:
name = textName name = textName
thumb = os.path.join(self.thumbPath, u'%s.png' % textName) thumb = os.path.join(self.thumbPath, u'%s.png' % textName)
@ -388,7 +390,17 @@ class ThemeManager(QtGui.QWidget):
filexml = None filexml = None
themename = None themename = None
for file in zip.namelist(): for file in zip.namelist():
osfile = unicode(QtCore.QDir.toNativeSeparators(file)) try:
ucsfile = file.decode(u'utf-8')
except UnicodeDecodeError:
QtGui.QMessageBox.critical(
self, translate(u'ThemeManager', u'Error'),
translate(u'ThemeManager', u'File is not a valid '
u'theme.\nThe content encoding is not UTF-8.'))
log.exception(u'Filename "%s" is not valid UTF-8' % \
file.decode(u'utf-8', u'replace'))
continue
osfile = unicode(QtCore.QDir.toNativeSeparators(ucsfile))
theme_dir = None theme_dir = None
if osfile.endswith(os.path.sep): if osfile.endswith(os.path.sep):
theme_dir = os.path.join(dir, osfile) theme_dir = os.path.join(dir, osfile)
@ -406,7 +418,7 @@ class ThemeManager(QtGui.QWidget):
if not os.path.exists(theme_dir): if not os.path.exists(theme_dir):
os.mkdir(os.path.join(dir, names[0])) os.mkdir(os.path.join(dir, names[0]))
xml_data = zip.read(file) xml_data = zip.read(file)
if os.path.splitext(file)[1].lower() in [u'.xml']: if os.path.splitext(ucsfile)[1].lower() in [u'.xml']:
if self.checkVersion1(xml_data): if self.checkVersion1(xml_data):
# upgrade theme xml # upgrade theme xml
filexml = self.migrateVersion122(xml_data) filexml = self.migrateVersion122(xml_data)
@ -417,8 +429,14 @@ class ThemeManager(QtGui.QWidget):
else: else:
outfile = open(fullpath, u'wb') outfile = open(fullpath, u'wb')
outfile.write(zip.read(file)) outfile.write(zip.read(file))
self.generateAndSaveImage(dir, themename, filexml) if filexml:
except IOError: self.generateAndSaveImage(dir, themename, filexml)
else:
QtGui.QMessageBox.critical(
self, translate(u'ThemeManager', u'Error'),
translate(u'ThemeManager', u'File is not a valid theme.'))
log.exception(u'Theme file dosen\'t contain XML data %s' % filename)
except (IOError, NameError):
QtGui.QMessageBox.critical( QtGui.QMessageBox.critical(
self, translate(u'ThemeManager', u'Error'), self, translate(u'ThemeManager', u'Error'),
translate(u'ThemeManager', u'File is not a valid theme.')) translate(u'ThemeManager', u'File is not a valid theme.'))
@ -527,7 +545,10 @@ class ThemeManager(QtGui.QWidget):
outfile.close() outfile.close()
if image_from and image_from != image_to: if image_from and image_from != image_to:
try: try:
shutil.copyfile(image_from, image_to) encoding = get_filesystem_encoding()
shutil.copyfile(
unicode(image_from).encode(encoding),
unicode(image_to).encode(encoding))
except IOError: except IOError:
log.exception(u'Failed to save theme image') log.exception(u'Failed to save theme image')
self.generateAndSaveImage(self.path, name, theme_xml) self.generateAndSaveImage(self.path, name, theme_xml)

View File

@ -149,27 +149,6 @@ def check_latest_version(current_version):
log.exception(u'Reason for failure: %s', e.reason) log.exception(u'Reason for failure: %s', e.reason)
return version_string return version_string
def string_to_unicode(string):
"""
Converts a QString to a Python unicode object.
"""
if isinstance(string, QtCore.QString):
string = unicode(string.toUtf8(), u'utf8')
return string
def variant_to_unicode(variant):
"""
Converts a QVariant to a Python unicode object.
``variant``
The QVariant instance to convert to unicode.
"""
if isinstance(variant, QtCore.QVariant):
string = variant.toString()
if not isinstance(string, unicode):
string = string_to_unicode(string)
return string
def add_actions(target, actions): def add_actions(target, actions):
""" """
Adds multiple actions to a menu or toolbar in one command. Adds multiple actions to a menu or toolbar in one command.
@ -187,7 +166,17 @@ def add_actions(target, actions):
else: else:
target.addAction(action) target.addAction(action)
def get_filesystem_encoding():
"""
Returns the name of the encoding used to convert Unicode filenames into
system file names.
"""
encoding = sys.getfilesystemencoding()
if encoding is None:
encoding = sys.getdefaultencoding()
return encoding
from languagemanager import LanguageManager from languagemanager import LanguageManager
__all__ = [u'AppLocation', u'check_latest_version', u'add_actions', __all__ = [u'AppLocation', u'check_latest_version', u'add_actions',
u'LanguageManager'] u'get_filesystem_encoding', u'LanguageManager']

View File

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

View File

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

View File

@ -32,7 +32,7 @@ from PyQt4 import QtCore, QtGui
from bibleimportwizard import Ui_BibleImportWizard from bibleimportwizard import Ui_BibleImportWizard
from openlp.core.lib import Receiver, SettingsManager, translate from openlp.core.lib import Receiver, SettingsManager, translate
from openlp.core.utils import AppLocation, variant_to_unicode from openlp.core.utils import AppLocation
from openlp.plugins.bibles.lib.manager import BibleFormat from openlp.plugins.bibles.lib.manager import BibleFormat
log = logging.getLogger(__name__) log = logging.getLogger(__name__)
@ -167,9 +167,9 @@ class ImportWizardForm(QtGui.QWizard, Ui_BibleImportWizard):
return True return True
elif self.currentId() == 2: elif self.currentId() == 2:
# License details # License details
license_version = variant_to_unicode(self.field(u'license_version')) license_version = unicode(self.field(u'license_version').toString())
license_copyright = variant_to_unicode( license_copyright = \
self.field(u'license_copyright')) unicode(self.field(u'license_copyright').toString())
if license_version == u'': if license_version == u'':
QtGui.QMessageBox.critical(self, QtGui.QMessageBox.critical(self,
translate(u'BiblesPlugin.ImportWizardForm', translate(u'BiblesPlugin.ImportWizardForm',
@ -303,17 +303,20 @@ class ImportWizardForm(QtGui.QWizard, Ui_BibleImportWizard):
self.setField(u'csv_versefile', QtCore.QVariant('')) self.setField(u'csv_versefile', QtCore.QVariant(''))
self.setField(u'opensong_file', QtCore.QVariant('')) self.setField(u'opensong_file', QtCore.QVariant(''))
self.setField(u'web_location', QtCore.QVariant(WebDownload.Crosswalk)) 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', self.setField(u'proxy_server',
settings.value(u'proxy address', QtCore.QVariant(u''))) settings.value(u'proxy address', QtCore.QVariant(u'')))
self.setField(u'proxy_username', self.setField(u'proxy_username',
settings.value(u'proxy username', QtCore.QVariant(u''))) settings.value(u'proxy username', QtCore.QVariant(u'')))
self.setField(u'proxy_password', self.setField(u'proxy_password',
settings.value(u'proxy password', QtCore.QVariant(u''))) settings.value(u'proxy password', QtCore.QVariant(u'')))
self.setField(u'license_version', QtCore.QVariant(self.VersionNameEdit)) self.setField(u'license_version',
self.setField(u'license_copyright', QtCore.QVariant(self.CopyrightEdit)) QtCore.QVariant(self.VersionNameEdit.text()))
self.setField(u'license_copyright',
QtCore.QVariant(self.CopyrightEdit.text()))
self.setField(u'license_permission', self.setField(u'license_permission',
QtCore.QVariant(self.PermissionEdit)) QtCore.QVariant(self.PermissionEdit.text()))
self.onLocationComboBoxChanged(WebDownload.Crosswalk) self.onLocationComboBoxChanged(WebDownload.Crosswalk)
settings.endGroup() settings.endGroup()
@ -391,37 +394,35 @@ class ImportWizardForm(QtGui.QWizard, Ui_BibleImportWizard):
def performImport(self): def performImport(self):
bible_type = self.field(u'source_format').toInt()[0] bible_type = self.field(u'source_format').toInt()[0]
license_version = variant_to_unicode(self.field(u'license_version')) license_version = unicode(self.field(u'license_version').toString())
license_copyright = variant_to_unicode(self.field(u'license_copyright')) license_copyright = unicode(self.field(u'license_copyright').toString())
license_permission = variant_to_unicode( license_permission = \
self.field(u'license_permission')) unicode(self.field(u'license_permission').toString())
importer = None importer = None
if bible_type == BibleFormat.OSIS: if bible_type == BibleFormat.OSIS:
# Import an OSIS bible # Import an OSIS bible
importer = self.manager.import_bible(BibleFormat.OSIS, importer = self.manager.import_bible(BibleFormat.OSIS,
name=license_version, name=license_version,
filename=variant_to_unicode(self.field(u'osis_location')) filename=unicode(self.field(u'osis_location').toString())
) )
elif bible_type == BibleFormat.CSV: elif bible_type == BibleFormat.CSV:
# Import a CSV bible # Import a CSV bible
importer = self.manager.import_bible(BibleFormat.CSV, importer = self.manager.import_bible(BibleFormat.CSV,
name=license_version, name=license_version,
booksfile=variant_to_unicode(self.field(u'csv_booksfile')), booksfile=unicode(self.field(u'csv_booksfile').toString()),
versefile=variant_to_unicode(self.field(u'csv_versefile')) versefile=unicode(self.field(u'csv_versefile').toString())
) )
elif bible_type == BibleFormat.OpenSong: elif bible_type == BibleFormat.OpenSong:
# Import an OpenSong bible # Import an OpenSong bible
importer = self.manager.import_bible(BibleFormat.OpenSong, importer = self.manager.import_bible(BibleFormat.OpenSong,
name=license_version, name=license_version,
filename=variant_to_unicode(self.field(u'opensong_file')) filename=unicode(self.field(u'opensong_file').toString())
) )
elif bible_type == BibleFormat.WebDownload: elif bible_type == BibleFormat.WebDownload:
# Import a bible from the web # Import a bible from the web
self.ImportProgressBar.setMaximum(1) self.ImportProgressBar.setMaximum(1)
download_location = self.field(u'web_location').toInt()[0] download_location = self.field(u'web_location').toInt()[0]
bible_version = self.BibleComboBox.currentText() bible_version = unicode(self.BibleComboBox.currentText())
if not isinstance(bible_version, unicode):
bible_version = unicode(bible_version, u'utf8')
if download_location == WebDownload.Crosswalk: if download_location == WebDownload.Crosswalk:
bible = \ bible = \
self.web_bible_list[WebDownload.Crosswalk][bible_version] self.web_bible_list[WebDownload.Crosswalk][bible_version]
@ -433,10 +434,10 @@ class ImportWizardForm(QtGui.QWizard, Ui_BibleImportWizard):
name=license_version, name=license_version,
download_source=WebDownload.get_name(download_location), download_source=WebDownload.get_name(download_location),
download_name=bible, download_name=bible,
proxy_server=variant_to_unicode(self.field(u'proxy_server')), proxy_server=unicode(self.field(u'proxy_server').toString()),
proxy_username=variant_to_unicode( proxy_username=\
self.field(u'proxy_username')), unicode(self.field(u'proxy_username').toString()),
proxy_password=variant_to_unicode(self.field(u'proxy_password')) proxy_password=unicode(self.field(u'proxy_password').toString())
) )
success = importer.do_import() success = importer.do_import()
if success: if success:

View File

@ -29,8 +29,9 @@ import chardet
import re import re
from sqlalchemy import or_ from sqlalchemy import or_
from PyQt4 import QtCore from PyQt4 import QtCore, QtGui
from openlp.core.lib import translate
from openlp.plugins.bibles.lib.models import * from openlp.plugins.bibles.lib.models import *
log = logging.getLogger(__name__) log = logging.getLogger(__name__)
@ -304,14 +305,22 @@ class BibleDB(QtCore.QObject):
if db_book: if db_book:
book = db_book.name book = db_book.name
log.debug(u'Book name corrected to "%s"', book) log.debug(u'Book name corrected to "%s"', book)
verses = self.session.query(Verse)\ verses = self.session.query(Verse)\
.filter_by(book_id=db_book.id)\ .filter_by(book_id=db_book.id)\
.filter_by(chapter=chapter)\ .filter_by(chapter=chapter)\
.filter(Verse.verse >= start_verse)\ .filter(Verse.verse >= start_verse)\
.filter(Verse.verse <= end_verse)\ .filter(Verse.verse <= end_verse)\
.order_by(Verse.verse)\ .order_by(Verse.verse)\
.all() .all()
verse_list.extend(verses) 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 return verse_list
def verse_search(self, text): def verse_search(self, text):
@ -383,4 +392,3 @@ class BibleDB(QtCore.QObject):
log.debug(u'...............................Verses ') log.debug(u'...............................Verses ')
verses = self.session.query(Verse).all() verses = self.session.query(Verse).all()
log.debug(verses) log.debug(verses)

View File

@ -57,7 +57,6 @@ class BibleMediaItem(MediaManagerItem):
self.IconPath = u'songs/song' self.IconPath = u'songs/song'
self.ListViewWithDnD_class = BibleListView self.ListViewWithDnD_class = BibleListView
self.lastReference = [] self.lastReference = []
self.addToServiceItem = True
MediaManagerItem.__init__(self, parent, icon, title) MediaManagerItem.__init__(self, parent, icon, title)
# place to store the search results # place to store the search results
self.search_results = {} self.search_results = {}
@ -454,7 +453,7 @@ class BibleMediaItem(MediaManagerItem):
def onQuickSearchButton(self): def onQuickSearchButton(self):
log.debug(u'Quick Search Button pressed') log.debug(u'Quick Search Button pressed')
bible = unicode(self.QuickVersionComboBox.currentText()) bible = unicode(self.QuickVersionComboBox.currentText())
text = unicode(self.QuickSearchEdit.displayText()) text = unicode(self.QuickSearchEdit.text())
if self.ClearQuickSearchComboBox.currentIndex() == 0: if self.ClearQuickSearchComboBox.currentIndex() == 0:
self.ListView.clear() self.ListView.clear()
self.lastReference = [] self.lastReference = []

View File

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

View File

@ -115,16 +115,24 @@ class CustomMediaItem(MediaManagerItem):
self.parent.edit_custom_form.exec_() self.parent.edit_custom_form.exec_()
def onEditClick(self): def onEditClick(self):
item = self.ListView.currentItem() """
if item: Edit a custom item
"""
if self.checkItemSelected(translate(u'CustomPlugin.MediaItem',
u'You must select an item to edit.')):
item = self.ListView.currentItem()
item_id = (item.data(QtCore.Qt.UserRole)).toInt()[0] item_id = (item.data(QtCore.Qt.UserRole)).toInt()[0]
self.parent.edit_custom_form.loadCustom(item_id, False) self.parent.edit_custom_form.loadCustom(item_id, False)
self.parent.edit_custom_form.exec_() self.parent.edit_custom_form.exec_()
self.initialise() self.initialise()
def onDeleteClick(self): def onDeleteClick(self):
item = self.ListView.currentItem() """
if item: 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()
item_id = (item.data(QtCore.Qt.UserRole)).toInt()[0] item_id = (item.data(QtCore.Qt.UserRole)).toInt()[0]
self.parent.custommanager.delete_custom(item_id) self.parent.custommanager.delete_custom(item_id)
row = self.ListView.row(item) row = self.ListView.row(item)

View File

@ -56,7 +56,7 @@ class ImagePlugin(Plugin):
return ImageMediaItem(self, self.icon, self.name) return ImageMediaItem(self, self.icon, self.name)
def about(self): 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'</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'of images are selected together and presented on the live '
u'controller it is possible to turn them into a timed loop.<br<br>' 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 # be instanced by the base MediaManagerItem
self.ListViewWithDnD_class = ImageListView self.ListViewWithDnD_class = ImageListView
MediaManagerItem.__init__(self, parent, icon, title) MediaManagerItem.__init__(self, parent, icon, title)
self.addToServiceItem = True
def initPluginNameVisible(self): def initPluginNameVisible(self):
self.PluginNameVisible = translate(u'ImagePlugin.MediaItem', u'Image') self.PluginNameVisible = translate(u'ImagePlugin.MediaItem', u'Image')
@ -74,6 +73,7 @@ class ImageMediaItem(MediaManagerItem):
self.hasFileIcon = True self.hasFileIcon = True
self.hasNewIcon = False self.hasNewIcon = False
self.hasEditIcon = False self.hasEditIcon = False
self.addToServiceItem = True
def initialise(self): def initialise(self):
log.debug(u'initialise') log.debug(u'initialise')
@ -116,16 +116,21 @@ class ImageMediaItem(MediaManagerItem):
self.PageLayout.addWidget(self.ImageWidget) self.PageLayout.addWidget(self.ImageWidget)
def onDeleteClick(self): def onDeleteClick(self):
items = self.ListView.selectedIndexes() """
if items: 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()
for item in items: for item in items:
text = self.ListView.item(item.row()) text = self.ListView.item(item.row())
try: if text:
os.remove( try:
os.path.join(self.servicePath, unicode(text.text()))) os.remove(os.path.join(self.servicePath,
except OSError: unicode(text.text())))
#if not present do not worry except OSError:
pass #if not present do not worry
pass
self.ListView.takeItem(item.row()) self.ListView.takeItem(item.row())
SettingsManager.set_list(self.settingsSection, SettingsManager.set_list(self.settingsSection,
self.settingsSection, self.getFileList()) self.settingsSection, self.getFileList())
@ -157,7 +162,7 @@ class ImageMediaItem(MediaManagerItem):
service_item.add_capability(ItemCapabilities.AllowsAdditions) service_item.add_capability(ItemCapabilities.AllowsAdditions)
for item in items: for item in items:
bitem = self.ListView.item(item.row()) bitem = self.ListView.item(item.row())
filename = unicode((bitem.data(QtCore.Qt.UserRole)).toString()) filename = unicode(bitem.data(QtCore.Qt.UserRole).toString())
frame = QtGui.QImage(unicode(filename)) frame = QtGui.QImage(unicode(filename))
(path, name) = os.path.split(filename) (path, name) = os.path.split(filename)
service_item.add_from_image(path, name, frame) service_item.add_from_image(path, name, frame)
@ -174,7 +179,7 @@ class ImageMediaItem(MediaManagerItem):
items = self.ListView.selectedIndexes() items = self.ListView.selectedIndexes()
for item in items: for item in items:
bitem = self.ListView.item(item.row()) bitem = self.ListView.item(item.row())
filename = unicode((bitem.data(QtCore.Qt.UserRole)).toString()) filename = unicode(bitem.data(QtCore.Qt.UserRole).toString())
frame = QtGui.QImage(unicode(filename)) frame = QtGui.QImage(unicode(filename))
self.parent.maindisplay.addImageWithText(frame) self.parent.maindisplay.addImageWithText(frame)

View File

@ -112,7 +112,7 @@ class MediaMediaItem(MediaManagerItem):
items = self.ListView.selectedIndexes() items = self.ListView.selectedIndexes()
for item in items: for item in items:
bitem = self.ListView.item(item.row()) bitem = self.ListView.item(item.row())
filename = unicode((bitem.data(QtCore.Qt.UserRole)).toString()) filename = unicode(bitem.data(QtCore.Qt.UserRole).toString())
Receiver.send_message(u'videodisplay_background', filename) Receiver.send_message(u'videodisplay_background', filename)
def generateSlideData(self, service_item, item=None): def generateSlideData(self, service_item, item=None):
@ -120,7 +120,7 @@ class MediaMediaItem(MediaManagerItem):
item = self.ListView.currentItem() item = self.ListView.currentItem()
if item is None: if item is None:
return False return False
filename = unicode((item.data(QtCore.Qt.UserRole)).toString()) filename = unicode(item.data(QtCore.Qt.UserRole).toString())
service_item.title = unicode( service_item.title = unicode(
translate(u'MediaPlugin.MediaItem', u'Media')) translate(u'MediaPlugin.MediaItem', u'Media'))
service_item.add_capability(ItemCapabilities.RequiresMedia) service_item.add_capability(ItemCapabilities.RequiresMedia)
@ -137,8 +137,12 @@ class MediaMediaItem(MediaManagerItem):
self.settingsSection)) self.settingsSection))
def onDeleteClick(self): def onDeleteClick(self):
item = self.ListView.currentItem() """
if item: 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()
row = self.ListView.row(item) row = self.ListView.row(item)
self.ListView.takeItem(row) self.ListView.takeItem(row)
SettingsManager.set_list(self.settingsSection, SettingsManager.set_list(self.settingsSection,
@ -152,4 +156,3 @@ class MediaMediaItem(MediaManagerItem):
item_name.setIcon(build_icon(img)) item_name.setIcon(build_icon(img))
item_name.setData(QtCore.Qt.UserRole, QtCore.QVariant(file)) item_name.setData(QtCore.Qt.UserRole, QtCore.QVariant(file))
self.ListView.addItem(item_name) self.ListView.addItem(item_name)

View File

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

View File

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

View File

@ -174,13 +174,17 @@ class PresentationMediaItem(MediaManagerItem):
self.ListView.addItem(item_name) self.ListView.addItem(item_name)
def onDeleteClick(self): def onDeleteClick(self):
item = self.ListView.currentItem() """
if item: 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()
row = self.ListView.row(item) row = self.ListView.row(item)
self.ListView.takeItem(row) self.ListView.takeItem(row)
SettingsManager.set_list(self.settingsSection, SettingsManager.set_list(self.settingsSection,
self.settingsSection, self.getFileList()) self.settingsSection, self.getFileList())
filepath = unicode((item.data(QtCore.Qt.UserRole)).toString()) filepath = unicode(item.data(QtCore.Qt.UserRole).toString())
#not sure of this has errors #not sure of this has errors
#John please can you look at . #John please can you look at .
for cidx in self.controllers: for cidx in self.controllers:
@ -198,7 +202,7 @@ class PresentationMediaItem(MediaManagerItem):
if shortname: if shortname:
for item in items: for item in items:
bitem = self.ListView.item(item.row()) bitem = self.ListView.item(item.row())
filename = unicode((bitem.data(QtCore.Qt.UserRole)).toString()) filename = unicode(bitem.data(QtCore.Qt.UserRole).toString())
if shortname == self.Automatic: if shortname == self.Automatic:
service_item.shortname = self.findControllerByType(filename) service_item.shortname = self.findControllerByType(filename)
if not service_item.shortname: if not service_item.shortname:

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -291,7 +291,7 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog):
rowLabel = [] rowLabel = []
for row in range(0, self.VerseListWidget.rowCount()): for row in range(0, self.VerseListWidget.rowCount()):
item = self.VerseListWidget.item(row, 0) item = self.VerseListWidget.item(row, 0)
data = unicode((item.data(QtCore.Qt.UserRole)).toString()) data = unicode(item.data(QtCore.Qt.UserRole).toString())
bit = data.split(u':') bit = data.split(u':')
rowTag = u'%s\n%s' % (bit[0][0:1], bit[1]) rowTag = u'%s\n%s' % (bit[0][0:1], bit[1])
rowLabel.append(rowTag) rowLabel.append(rowTag)
@ -382,7 +382,7 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog):
item = self.VerseListWidget.currentItem() item = self.VerseListWidget.currentItem()
if item: if item:
tempText = item.text() tempText = item.text()
verseId = unicode((item.data(QtCore.Qt.UserRole)).toString()) verseId = unicode(item.data(QtCore.Qt.UserRole).toString())
self.verse_form.setVerse(tempText, True, verseId) self.verse_form.setVerse(tempText, True, verseId)
if self.verse_form.exec_(): if self.verse_form.exec_():
afterText, verse, subVerse = self.verse_form.getVerse() afterText, verse, subVerse = self.verse_form.getVerse()
@ -413,7 +413,7 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog):
if self.VerseListWidget.rowCount() > 0: if self.VerseListWidget.rowCount() > 0:
for row in range(0, self.VerseListWidget.rowCount()): for row in range(0, self.VerseListWidget.rowCount()):
item = self.VerseListWidget.item(row, 0) item = self.VerseListWidget.item(row, 0)
field = unicode((item.data(QtCore.Qt.UserRole)).toString()) field = unicode(item.data(QtCore.Qt.UserRole).toString())
verse_list += u'---[%s]---\n' % field verse_list += u'---[%s]---\n' % field
verse_list += item.text() verse_list += item.text()
verse_list += u'\n' verse_list += u'\n'
@ -504,7 +504,7 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog):
def onCopyrightInsertButtonTriggered(self): def onCopyrightInsertButtonTriggered(self):
text = self.CopyrightEditItem.text() text = self.CopyrightEditItem.text()
pos = self.CopyrightEditItem.cursorPosition() pos = self.CopyrightEditItem.cursorPosition()
text = text[:pos] + u'©' + text[pos:] text = text[:pos] + u'\xa9' + text[pos:]
self.CopyrightEditItem.setText(text) self.CopyrightEditItem.setText(text)
self.CopyrightEditItem.setFocus() self.CopyrightEditItem.setFocus()
self.CopyrightEditItem.setCursorPosition(pos + 1) self.CopyrightEditItem.setCursorPosition(pos + 1)
@ -562,7 +562,7 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog):
text = u' ' text = u' '
for i in range (0, self.VerseListWidget.rowCount()): for i in range (0, self.VerseListWidget.rowCount()):
item = self.VerseListWidget.item(i, 0) item = self.VerseListWidget.item(i, 0)
verseId = unicode((item.data(QtCore.Qt.UserRole)).toString()) verseId = unicode(item.data(QtCore.Qt.UserRole).toString())
bits = verseId.split(u':') bits = verseId.split(u':')
sxml.add_verse_to_lyrics(bits[0], bits[1], unicode(item.text())) sxml.add_verse_to_lyrics(bits[0], bits[1], unicode(item.text()))
text = text + unicode(self.VerseListWidget.item(i, 0).text()) \ text = text + unicode(self.VerseListWidget.item(i, 0).text()) \

View File

@ -104,7 +104,7 @@ class EditVerseForm(QtGui.QDialog, Ui_EditVerseDialog):
verse_type = match.group(1) verse_type = match.group(1)
verse_number = int(match.group(2)) verse_number = int(match.group(2))
verse_type_index = VerseType.from_string(verse_type) verse_type_index = VerseType.from_string(verse_type)
if verse_type_index: if verse_type_index is not None:
self.VerseTypeComboBox.setCurrentIndex(verse_type_index) self.VerseTypeComboBox.setCurrentIndex(verse_type_index)
self.VerseNumberBox.setValue(verse_number) self.VerseNumberBox.setValue(verse_number)
@ -112,8 +112,9 @@ class EditVerseForm(QtGui.QDialog, Ui_EditVerseDialog):
tag=u'%s:1' % VerseType.to_string(VerseType.Verse)): tag=u'%s:1' % VerseType.to_string(VerseType.Verse)):
if single: if single:
verse_type, verse_number = tag.split(u':') verse_type, verse_number = tag.split(u':')
self.VerseTypeComboBox.setCurrentIndex( verse_type_index = VerseType.from_string(verse_type)
VerseType.from_string(verse_type)) if verse_type_index is not None:
self.VerseTypeComboBox.setCurrentIndex(verse_type_index)
self.VerseNumberBox.setValue(int(verse_number)) self.VerseNumberBox.setValue(int(verse_number))
self.InsertButton.setVisible(False) self.InsertButton.setVisible(False)
else: else:

View File

@ -29,7 +29,7 @@ from PyQt4 import QtCore, QtGui
from songimportwizard import Ui_SongImportWizard from songimportwizard import Ui_SongImportWizard
from openlp.core.lib import Receiver, SettingsManager, translate from openlp.core.lib import Receiver, SettingsManager, translate
#from openlp.core.utils import AppLocation, variant_to_unicode #from openlp.core.utils import AppLocation
from openlp.plugins.songs.lib.manager import SongFormat from openlp.plugins.songs.lib.manager import SongFormat
log = logging.getLogger(__name__) log = logging.getLogger(__name__)
@ -203,20 +203,20 @@ class ImportWizardForm(QtGui.QWizard, Ui_SongImportWizard):
# # Import an OSIS bible # # Import an OSIS bible
# importer = self.manager.import_bible(BibleFormat.OSIS, # importer = self.manager.import_bible(BibleFormat.OSIS,
# name=license_version, # name=license_version,
# filename=variant_to_unicode(self.field(u'osis_location')) # filename=unicode(self.field(u'osis_location').toString())
# ) # )
# elif bible_type == BibleFormat.CSV: # elif bible_type == BibleFormat.CSV:
# # Import a CSV bible # # Import a CSV bible
# importer = self.manager.import_bible(BibleFormat.CSV, # importer = self.manager.import_bible(BibleFormat.CSV,
# name=license_version, # name=license_version,
# booksfile=variant_to_unicode(self.field(u'csv_booksfile')), # booksfile=unicode(self.field(u'csv_booksfile').toString()),
# versefile=variant_to_unicode(self.field(u'csv_versefile')) # versefile=unicode(self.field(u'csv_versefile').toString())
# ) # )
# elif bible_type == BibleFormat.OpenSong: # elif bible_type == BibleFormat.OpenSong:
# # Import an OpenSong bible # # Import an OpenSong bible
# importer = self.manager.import_bible(BibleFormat.OpenSong, # importer = self.manager.import_bible(BibleFormat.OpenSong,
# name=license_version, # name=license_version,
# filename=variant_to_unicode(self.field(u'opensong_file')) # filename=unicode(self.field(u'opensong_file').toString())
# ) # )
# elif bible_type == BibleFormat.WebDownload: # elif bible_type == BibleFormat.WebDownload:
# # Import a bible from the web # # Import a bible from the web
@ -234,9 +234,9 @@ class ImportWizardForm(QtGui.QWizard, Ui_SongImportWizard):
# name=license_version, # name=license_version,
# download_source=WebDownload.get_name(download_location), # download_source=WebDownload.get_name(download_location),
# download_name=bible, # download_name=bible,
# proxy_server=variant_to_unicode(self.field(u'proxy_server')), # proxy_server=unicode(self.field(u'proxy_server').toString()),
# proxy_username=variant_to_unicode(self.field(u'proxy_username')), # proxy_username=unicode(self.field(u'proxy_username').toString()),
# proxy_password=variant_to_unicode(self.field(u'proxy_password')) # proxy_password=unicode(self.field(u'proxy_password').toString())
# ) # )
# success = importer.do_import() # success = importer.do_import()
# if success: # if success:

View File

@ -275,15 +275,23 @@ class SongMediaItem(MediaManagerItem):
self.edit_song_form.exec_() self.edit_song_form.exec_()
def onEditClick(self): def onEditClick(self):
item = self.ListView.currentItem() """
if item: Edit a song
"""
if self.checkItemSelected(translate(u'SongsPlugin.MediaItem',
u'You must select an item to edit.')):
item = self.ListView.currentItem()
item_id = (item.data(QtCore.Qt.UserRole)).toInt()[0] item_id = (item.data(QtCore.Qt.UserRole)).toInt()[0]
self.edit_song_form.loadSong(item_id, False) self.edit_song_form.loadSong(item_id, False)
self.edit_song_form.exec_() self.edit_song_form.exec_()
def onDeleteClick(self): def onDeleteClick(self):
items = self.ListView.selectedIndexes() """
if items: 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 len(items) == 1: if len(items) == 1:
del_message = translate(u'SongsPlugin.MediaItem', del_message = translate(u'SongsPlugin.MediaItem',
u'Delete song?') u'Delete song?')
@ -371,4 +379,3 @@ class SongMediaItem(MediaManagerItem):
song.title, author_audit, song.copyright, song.ccli_number song.title, author_audit, song.copyright, song.ccli_number
] ]
return True return True

View File

@ -66,7 +66,7 @@ class SongImport(object):
self.copyright_string = unicode(QtGui.QApplication.translate( \ self.copyright_string = unicode(QtGui.QApplication.translate( \
u'SongsPlugin.SongImport', u'copyright')) u'SongsPlugin.SongImport', u'copyright'))
self.copyright_symbol = unicode(QtGui.QApplication.translate( \ self.copyright_symbol = unicode(QtGui.QApplication.translate( \
u'SongsPlugin.SongImport', u'©')) u'SongsPlugin.SongImport', u'\xa9'))
@staticmethod @staticmethod
def process_songs_text(manager, text): def process_songs_text(manager, text):

View File

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

View File

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