forked from openlp/openlp
correct coding rules, some optimizations
This commit is contained in:
parent
8e8a6e42ff
commit
22304d491d
@ -92,7 +92,7 @@ class MediaManagerItem(QtGui.QWidget):
|
|||||||
"""
|
"""
|
||||||
QtGui.QWidget.__init__(self)
|
QtGui.QWidget.__init__(self)
|
||||||
self.parent = parent
|
self.parent = parent
|
||||||
# TODO: may the plugin is not the parent?
|
# TODO: plugin is not the parent, so add this to the calling plugins
|
||||||
self.plugin = parent
|
self.plugin = parent
|
||||||
self.settingsSection = self.plugin.name_lower
|
self.settingsSection = self.plugin.name_lower
|
||||||
if isinstance(icon, QtGui.QIcon):
|
if isinstance(icon, QtGui.QIcon):
|
||||||
@ -103,8 +103,8 @@ class MediaManagerItem(QtGui.QWidget):
|
|||||||
else:
|
else:
|
||||||
self.icon = None
|
self.icon = None
|
||||||
if title:
|
if title:
|
||||||
nameString = self.plugin.getString(StringType.Name)
|
name_string = self.plugin.getString(StringType.Name)
|
||||||
self.title = nameString[u'plural']
|
self.title = name_string[u'plural']
|
||||||
self.toolbar = None
|
self.toolbar = None
|
||||||
self.remoteTriggered = None
|
self.remoteTriggered = None
|
||||||
self.serviceItemIconName = None
|
self.serviceItemIconName = None
|
||||||
|
@ -269,7 +269,7 @@ class Plugin(QtCore.QObject):
|
|||||||
Called by the plugin to remove toolbar
|
Called by the plugin to remove toolbar
|
||||||
"""
|
"""
|
||||||
if self.mediaItem:
|
if self.mediaItem:
|
||||||
self.mediadock.remove_dock(self.name)
|
self.mediadock.remove_dock(self.mediaItem)
|
||||||
if self.settings_tab:
|
if self.settings_tab:
|
||||||
self.settingsForm.removeTab(self.name)
|
self.settingsForm.removeTab(self.name)
|
||||||
|
|
||||||
@ -315,5 +315,4 @@ class Plugin(QtCore.QObject):
|
|||||||
"""
|
"""
|
||||||
self.name = u'Plugin'
|
self.name = u'Plugin'
|
||||||
self.name_lower = u'plugin'
|
self.name_lower = u'plugin'
|
||||||
|
|
||||||
self.strings = {}
|
self.strings = {}
|
||||||
|
@ -61,24 +61,23 @@ class MediaDockManager(object):
|
|||||||
match = False
|
match = False
|
||||||
for dock_index in range(0, self.media_dock.count()):
|
for dock_index in range(0, self.media_dock.count()):
|
||||||
if self.media_dock.widget(dock_index).settingsSection == \
|
if self.media_dock.widget(dock_index).settingsSection == \
|
||||||
media_item.plugin.name:
|
media_item.plugin.name_lower:
|
||||||
match = True
|
match = True
|
||||||
break
|
break
|
||||||
if not match:
|
if not match:
|
||||||
self.media_dock.addItem(media_item, icon, media_item.plugin.name)
|
self.media_dock.addItem(media_item, icon, media_item.plugin.name)
|
||||||
|
|
||||||
def remove_dock(self, name):
|
def remove_dock(self, media_item):
|
||||||
"""
|
"""
|
||||||
Removes a MediaManagerItem from the dock
|
Removes a MediaManagerItem from the dock
|
||||||
|
|
||||||
``name``
|
``media_item``
|
||||||
The item to remove
|
The item to add to the dock
|
||||||
"""
|
"""
|
||||||
log.debug(u'remove %s dock' % name)
|
log.debug(u'remove %s dock' % media_item.plugin.name)
|
||||||
for dock_index in range(0, self.media_dock.count()):
|
for dock_index in range(0, self.media_dock.count()):
|
||||||
if self.media_dock.widget(dock_index):
|
if self.media_dock.widget(dock_index):
|
||||||
log.debug(u'%s %s' % (name, self.media_dock.widget(dock_index).settingsSection))
|
|
||||||
if self.media_dock.widget(dock_index).settingsSection == \
|
if self.media_dock.widget(dock_index).settingsSection == \
|
||||||
name:
|
media_item.plugin.name_lower:
|
||||||
self.media_dock.widget(dock_index).hide()
|
self.media_dock.widget(dock_index).hide()
|
||||||
self.media_dock.removeItem(dock_index)
|
self.media_dock.removeItem(dock_index)
|
||||||
|
@ -78,8 +78,8 @@ class PluginForm(QtGui.QDialog, Ui_PluginViewDialog):
|
|||||||
elif plugin.status == PluginStatus.Disabled:
|
elif plugin.status == PluginStatus.Disabled:
|
||||||
status_text = unicode(
|
status_text = unicode(
|
||||||
translate('OpenLP.PluginForm', '%s (Disabled)'))
|
translate('OpenLP.PluginForm', '%s (Disabled)'))
|
||||||
nameString = plugin.getString(StringType.Name)
|
name_string = plugin.getString(StringType.Name)
|
||||||
item.setText(status_text % nameString[u'plural'])
|
item.setText(status_text % name_string[u'plural'])
|
||||||
# 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)
|
||||||
@ -110,8 +110,8 @@ class PluginForm(QtGui.QDialog, Ui_PluginViewDialog):
|
|||||||
plugin_name_more = self.pluginListWidget.currentItem().text().split(u' ')[0]
|
plugin_name_more = self.pluginListWidget.currentItem().text().split(u' ')[0]
|
||||||
self.activePlugin = None
|
self.activePlugin = None
|
||||||
for plugin in self.parent.plugin_manager.plugins:
|
for plugin in self.parent.plugin_manager.plugins:
|
||||||
nameString = plugin.getString(StringType.Name)
|
name_string = plugin.getString(StringType.Name)
|
||||||
if nameString[u'plural'] == plugin_name_more:
|
if name_string[u'plural'] == plugin_name_more:
|
||||||
self.activePlugin = plugin
|
self.activePlugin = plugin
|
||||||
break
|
break
|
||||||
if self.activePlugin:
|
if self.activePlugin:
|
||||||
@ -139,6 +139,6 @@ class PluginForm(QtGui.QDialog, Ui_PluginViewDialog):
|
|||||||
elif self.activePlugin.status == PluginStatus.Disabled:
|
elif self.activePlugin.status == PluginStatus.Disabled:
|
||||||
status_text = unicode(
|
status_text = unicode(
|
||||||
translate('OpenLP.PluginForm', '%s (Disabled)'))
|
translate('OpenLP.PluginForm', '%s (Disabled)'))
|
||||||
nameString = self.activePlugin.getString(StringType.Name)
|
name_string = self.activePlugin.getString(StringType.Name)
|
||||||
self.pluginListWidget.currentItem().setText(
|
self.pluginListWidget.currentItem().setText(
|
||||||
status_text % nameString[u'plural'])
|
status_text % name_string[u'plural'])
|
||||||
|
@ -57,7 +57,7 @@ class LanguageManager(object):
|
|||||||
lang_path = AppLocation.get_directory(AppLocation.AppDir)
|
lang_path = AppLocation.get_directory(AppLocation.AppDir)
|
||||||
lang_path = os.path.join(lang_path, u'i18n')
|
lang_path = os.path.join(lang_path, u'i18n')
|
||||||
app_translator = QtCore.QTranslator()
|
app_translator = QtCore.QTranslator()
|
||||||
if app_translator.load("openlp_" + language, lang_path):
|
if app_translator.load(language, lang_path):
|
||||||
return app_translator
|
return app_translator
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
@ -130,7 +130,7 @@ class LanguageManager(object):
|
|||||||
LanguageManager.__qmList__ = {}
|
LanguageManager.__qmList__ = {}
|
||||||
qm_files = LanguageManager.find_qm_files()
|
qm_files = LanguageManager.find_qm_files()
|
||||||
for i, qmf in enumerate(qm_files):
|
for i, qmf in enumerate(qm_files):
|
||||||
reg_ex = QtCore.QRegExp("^.*openlp_(.*).qm")
|
reg_ex = QtCore.QRegExp("^(.*).qm")
|
||||||
if reg_ex.exactMatch(qmf):
|
if reg_ex.exactMatch(qmf):
|
||||||
lang_name = reg_ex.cap(1)
|
lang_name = reg_ex.cap(1)
|
||||||
LanguageManager.__qmList__[u'%#2i %s' % (i+1,
|
LanguageManager.__qmList__[u'%#2i %s' % (i+1,
|
||||||
|
@ -101,16 +101,16 @@ class AlertsPlugin(Plugin):
|
|||||||
'<br />The alert plugin controls the displaying of nursery alerts '
|
'<br />The alert plugin controls the displaying of nursery alerts '
|
||||||
'on the display screen')
|
'on the display screen')
|
||||||
return about_text
|
return about_text
|
||||||
|
|
||||||
def setPluginStrings(self):
|
def setPluginStrings(self):
|
||||||
"""
|
"""
|
||||||
Called to define all translatable texts of the plugin
|
Called to define all translatable texts of the plugin
|
||||||
"""
|
"""
|
||||||
self.name = u'Alerts'
|
self.name = u'Alerts'
|
||||||
self.name_lower = u'alerts'
|
self.name_lower = u'alerts'
|
||||||
|
|
||||||
self.strings = {}
|
self.strings = {}
|
||||||
# for names in mediamanagerdock and pluginlist
|
# for names in mediamanagerdock and pluginlist
|
||||||
self.strings[StringType.Name] = {
|
self.strings[StringType.Name] = {
|
||||||
u'singular': translate('AlertsPlugin', 'Alert'),
|
u'singular': translate('AlertsPlugin', 'Alert'),
|
||||||
u'plural': translate('AlertsPlugin', 'Alerts')
|
u'plural': translate('AlertsPlugin', 'Alerts')
|
||||||
}
|
}
|
||||||
|
@ -123,14 +123,12 @@ class BiblePlugin(Plugin):
|
|||||||
"""
|
"""
|
||||||
self.name = u'Bibles'
|
self.name = u'Bibles'
|
||||||
self.name_lower = u'Bibles'
|
self.name_lower = u'Bibles'
|
||||||
|
|
||||||
self.strings = {}
|
self.strings = {}
|
||||||
# for names in mediamanagerdock and pluginlist
|
# for names in mediamanagerdock and pluginlist
|
||||||
self.strings[StringType.Name] = {
|
self.strings[StringType.Name] = {
|
||||||
u'singular': translate('BiblesPlugin', 'Bible'),
|
u'singular': translate('BiblesPlugin', 'Bible'),
|
||||||
u'plural': translate('BiblesPlugin', 'Bibles')
|
u'plural': translate('BiblesPlugin', 'Bibles')
|
||||||
}
|
}
|
||||||
|
|
||||||
# Middle Header Bar
|
# Middle Header Bar
|
||||||
## Import Button ##
|
## Import Button ##
|
||||||
self.strings[StringType.Import] = {
|
self.strings[StringType.Import] = {
|
||||||
@ -166,4 +164,4 @@ class BiblePlugin(Plugin):
|
|||||||
self.strings[StringType.Service] = {
|
self.strings[StringType.Service] = {
|
||||||
u'title': translate('BiblesPlugin', 'Service'),
|
u'title': translate('BiblesPlugin', 'Service'),
|
||||||
u'tooltip': translate('BiblesPlugin', 'Add the selected Bible to the service')
|
u'tooltip': translate('BiblesPlugin', 'Add the selected Bible to the service')
|
||||||
}
|
}
|
||||||
|
@ -102,14 +102,12 @@ class CustomPlugin(Plugin):
|
|||||||
"""
|
"""
|
||||||
self.name = u'Custom'
|
self.name = u'Custom'
|
||||||
self.name_lower = u'custom'
|
self.name_lower = u'custom'
|
||||||
|
|
||||||
self.strings = {}
|
self.strings = {}
|
||||||
# for names in mediamanagerdock and pluginlist
|
# for names in mediamanagerdock and pluginlist
|
||||||
self.strings[StringType.Name] = {
|
self.strings[StringType.Name] = {
|
||||||
u'singular': translate('CustomsPlugin', 'Custom'),
|
u'singular': translate('CustomsPlugin', 'Custom'),
|
||||||
u'plural': translate('CustomsPlugin', 'Customs')
|
u'plural': translate('CustomsPlugin', 'Customs')
|
||||||
}
|
}
|
||||||
|
|
||||||
# Middle Header Bar
|
# Middle Header Bar
|
||||||
## Import Button ##
|
## Import Button ##
|
||||||
self.strings[StringType.Import] = {
|
self.strings[StringType.Import] = {
|
||||||
@ -150,4 +148,4 @@ class CustomPlugin(Plugin):
|
|||||||
self.strings[StringType.Service] = {
|
self.strings[StringType.Service] = {
|
||||||
u'title': translate('CustomsPlugin', 'Service'),
|
u'title': translate('CustomsPlugin', 'Service'),
|
||||||
u'tooltip': translate('CustomsPlugin', 'Add the selected Custom to the service')
|
u'tooltip': translate('CustomsPlugin', 'Add the selected Custom to the service')
|
||||||
}
|
}
|
||||||
|
@ -64,14 +64,12 @@ class ImagePlugin(Plugin):
|
|||||||
"""
|
"""
|
||||||
self.name = u'Images'
|
self.name = u'Images'
|
||||||
self.name_lower = u'images'
|
self.name_lower = u'images'
|
||||||
|
|
||||||
self.strings = {}
|
self.strings = {}
|
||||||
# for names in mediamanagerdock and pluginlist
|
# for names in mediamanagerdock and pluginlist
|
||||||
self.strings[StringType.Name] = {
|
self.strings[StringType.Name] = {
|
||||||
u'singular': translate('ImagePlugin', 'Image'),
|
u'singular': translate('ImagePlugin', 'Image'),
|
||||||
u'plural': translate('ImagePlugin', 'Images')
|
u'plural': translate('ImagePlugin', 'Images')
|
||||||
}
|
}
|
||||||
|
|
||||||
# Middle Header Bar
|
# Middle Header Bar
|
||||||
## Load Button ##
|
## Load Button ##
|
||||||
self.strings[StringType.Load] = {
|
self.strings[StringType.Load] = {
|
||||||
@ -107,4 +105,4 @@ class ImagePlugin(Plugin):
|
|||||||
self.strings[StringType.Service] = {
|
self.strings[StringType.Service] = {
|
||||||
u'title': translate('ImagePlugin', 'Service'),
|
u'title': translate('ImagePlugin', 'Service'),
|
||||||
u'tooltip': translate('ImagePlugin', 'Add the selected Image to the service')
|
u'tooltip': translate('ImagePlugin', 'Add the selected Image to the service')
|
||||||
}
|
}
|
||||||
|
@ -82,14 +82,12 @@ class MediaPlugin(Plugin):
|
|||||||
"""
|
"""
|
||||||
self.name = u'Media'
|
self.name = u'Media'
|
||||||
self.name_lower = u'media'
|
self.name_lower = u'media'
|
||||||
|
|
||||||
self.strings = {}
|
self.strings = {}
|
||||||
# for names in mediamanagerdock and pluginlist
|
# for names in mediamanagerdock and pluginlist
|
||||||
self.strings[StringType.Name] = {
|
self.strings[StringType.Name] = {
|
||||||
u'singular': translate('MediaPlugin', 'Media'),
|
u'singular': translate('MediaPlugin', 'Media'),
|
||||||
u'plural': translate('MediaPlugin', 'Medias')
|
u'plural': translate('MediaPlugin', 'Medias')
|
||||||
}
|
}
|
||||||
|
|
||||||
# Middle Header Bar
|
# Middle Header Bar
|
||||||
## Load Button ##
|
## Load Button ##
|
||||||
self.strings[StringType.Load] = {
|
self.strings[StringType.Load] = {
|
||||||
@ -125,4 +123,4 @@ class MediaPlugin(Plugin):
|
|||||||
self.strings[StringType.Service] = {
|
self.strings[StringType.Service] = {
|
||||||
u'title': translate('MediaPlugin', 'Service'),
|
u'title': translate('MediaPlugin', 'Service'),
|
||||||
u'tooltip': translate('MediaPlugin', 'Add the selected Media to the service')
|
u'tooltip': translate('MediaPlugin', 'Add the selected Media to the service')
|
||||||
}
|
}
|
||||||
|
@ -150,14 +150,12 @@ class PresentationPlugin(Plugin):
|
|||||||
"""
|
"""
|
||||||
self.name = u'Presentations'
|
self.name = u'Presentations'
|
||||||
self.name_lower = u'presentations'
|
self.name_lower = u'presentations'
|
||||||
|
|
||||||
self.strings = {}
|
self.strings = {}
|
||||||
# for names in mediamanagerdock and pluginlist
|
# for names in mediamanagerdock and pluginlist
|
||||||
self.strings[StringType.Name] = {
|
self.strings[StringType.Name] = {
|
||||||
u'singular': translate('PresentationPlugin', 'Presentation'),
|
u'singular': translate('PresentationPlugin', 'Presentation'),
|
||||||
u'plural': translate('PresentationPlugin', 'Presentations')
|
u'plural': translate('PresentationPlugin', 'Presentations')
|
||||||
}
|
}
|
||||||
|
|
||||||
# Middle Header Bar
|
# Middle Header Bar
|
||||||
## Load Button ##
|
## Load Button ##
|
||||||
self.strings[StringType.Load] = {
|
self.strings[StringType.Load] = {
|
||||||
@ -183,4 +181,4 @@ class PresentationPlugin(Plugin):
|
|||||||
self.strings[StringType.Service] = {
|
self.strings[StringType.Service] = {
|
||||||
u'title': translate('PresentationPlugin', 'Service'),
|
u'title': translate('PresentationPlugin', 'Service'),
|
||||||
u'tooltip': translate('PresentationPlugin', 'Add the selected Presentation to the service')
|
u'tooltip': translate('PresentationPlugin', 'Add the selected Presentation to the service')
|
||||||
}
|
}
|
||||||
|
@ -83,10 +83,9 @@ class RemotesPlugin(Plugin):
|
|||||||
"""
|
"""
|
||||||
self.name = u'Remotes'
|
self.name = u'Remotes'
|
||||||
self.name_lower = u'remotes'
|
self.name_lower = u'remotes'
|
||||||
|
|
||||||
self.strings = {}
|
self.strings = {}
|
||||||
# for names in mediamanagerdock and pluginlist
|
# for names in mediamanagerdock and pluginlist
|
||||||
self.strings[StringType.Name] = {
|
self.strings[StringType.Name] = {
|
||||||
u'singular': translate('RemotePlugin', 'Remote'),
|
u'singular': translate('RemotePlugin', 'Remote'),
|
||||||
u'plural': translate('RemotePlugin', 'Remotes')
|
u'plural': translate('RemotePlugin', 'Remotes')
|
||||||
}
|
}
|
||||||
|
@ -154,14 +154,12 @@ class SongsPlugin(Plugin):
|
|||||||
"""
|
"""
|
||||||
self.name = u'Songs'
|
self.name = u'Songs'
|
||||||
self.name_lower = u'songs'
|
self.name_lower = u'songs'
|
||||||
|
|
||||||
self.strings = {}
|
self.strings = {}
|
||||||
# for names in mediamanagerdock and pluginlist
|
# for names in mediamanagerdock and pluginlist
|
||||||
self.strings[StringType.Name] = {
|
self.strings[StringType.Name] = {
|
||||||
u'singular': translate('SongsPlugin', 'Song'),
|
u'singular': translate('SongsPlugin', 'Song'),
|
||||||
u'plural': translate('SongsPlugin', 'Songs')
|
u'plural': translate('SongsPlugin', 'Songs')
|
||||||
}
|
}
|
||||||
|
|
||||||
# Middle Header Bar
|
# Middle Header Bar
|
||||||
## New Button ##
|
## New Button ##
|
||||||
self.strings[StringType.New] = {
|
self.strings[StringType.New] = {
|
||||||
@ -192,4 +190,4 @@ class SongsPlugin(Plugin):
|
|||||||
self.strings[StringType.Service] = {
|
self.strings[StringType.Service] = {
|
||||||
u'title': translate('SongsPlugin', 'Service'),
|
u'title': translate('SongsPlugin', 'Service'),
|
||||||
u'tooltip': translate('SongsPlugin', 'Add the selected Song to the service')
|
u'tooltip': translate('SongsPlugin', 'Add the selected Song to the service')
|
||||||
}
|
}
|
||||||
|
@ -169,10 +169,9 @@ class SongUsagePlugin(Plugin):
|
|||||||
"""
|
"""
|
||||||
self.name = u'SongUsage'
|
self.name = u'SongUsage'
|
||||||
self.name_lower = u'songusage'
|
self.name_lower = u'songusage'
|
||||||
|
|
||||||
self.strings = {}
|
self.strings = {}
|
||||||
# for names in mediamanagerdock and pluginlist
|
# for names in mediamanagerdock and pluginlist
|
||||||
self.strings[StringType.Name] = {
|
self.strings[StringType.Name] = {
|
||||||
u'singular': translate('SongUsagePlugin', 'SongUsage'),
|
u'singular': translate('SongUsagePlugin', 'SongUsage'),
|
||||||
u'plural': translate('SongUsagePlugin', 'SongUsage')
|
u'plural': translate('SongUsagePlugin', 'SongUsage')
|
||||||
}
|
}
|
||||||
|
@ -52,6 +52,7 @@ This is done easily via the ``-d``, ``-p`` and ``-u`` options::
|
|||||||
import os
|
import os
|
||||||
import urllib
|
import urllib
|
||||||
import re
|
import re
|
||||||
|
from shutil import copy
|
||||||
|
|
||||||
from optparse import OptionParser
|
from optparse import OptionParser
|
||||||
from PyQt4 import QtCore
|
from PyQt4 import QtCore
|
||||||
@ -227,6 +228,7 @@ def update_translations():
|
|||||||
else:
|
else:
|
||||||
os.chdir(os.path.abspath(u'..'))
|
os.chdir(os.path.abspath(u'..'))
|
||||||
run(u'pylupdate4 -verbose -noobsolete openlp.pro')
|
run(u'pylupdate4 -verbose -noobsolete openlp.pro')
|
||||||
|
os.chdir(os.path.abspath(u'scripts'))
|
||||||
|
|
||||||
def generate_binaries():
|
def generate_binaries():
|
||||||
print u'Generate the related *.qm files'
|
print u'Generate the related *.qm files'
|
||||||
@ -239,6 +241,17 @@ def generate_binaries():
|
|||||||
else:
|
else:
|
||||||
os.chdir(os.path.abspath(u'..'))
|
os.chdir(os.path.abspath(u'..'))
|
||||||
run(u'lrelease openlp.pro')
|
run(u'lrelease openlp.pro')
|
||||||
|
os.chdir(os.path.abspath(u'scripts'))
|
||||||
|
src_path = os.path.join(os.path.abspath(u'..'), u'resources', u'i18n')
|
||||||
|
dest_path = os.path.join(os.path.abspath(u'..'), u'openlp', u'i18n')
|
||||||
|
if not os.path.exists(dest_path):
|
||||||
|
os.makedirs(dest_path)
|
||||||
|
src_list = os.listdir(src_path)
|
||||||
|
for file in src_list:
|
||||||
|
if re.search('.qm$', file):
|
||||||
|
copy(os.path.join(src_path, u'%s' % file),
|
||||||
|
os.path.join(dest_path, u'%s' % file))
|
||||||
|
|
||||||
|
|
||||||
def create_translation(language):
|
def create_translation(language):
|
||||||
"""
|
"""
|
||||||
|
Loading…
Reference in New Issue
Block a user