This commit is contained in:
Raoul Snyman 2010-09-14 22:34:44 +02:00
commit ef9684320c
34 changed files with 5990 additions and 6137 deletions

View File

@ -38,63 +38,48 @@ log = logging.getLogger(__name__)
# TODO make external and configurable in alpha 4 via a settings dialog
html_expands = []
html_expands.append({u'desc':u'Red', u'start tag':u'{r}', \
u'start html':u'<span style="-webkit-text-fill-color:red">', \
u'end tag':u'{/r}', u'end html':u'</span>', \
u'protected':False})
html_expands.append({u'desc':u'Black', u'start tag':u'{b}', \
u'start html':u'<span style="-webkit-text-fill-color:black">', \
u'end tag':u'{/b}', u'end html':u'</span>', \
u'protected':False})
html_expands.append({u'desc':u'Blue', u'start tag':u'{bl}', \
u'start html':u'<span style="-webkit-text-fill-color:blue">', \
u'end tag':u'{/bl}', u'end html':u'</span>', \
u'protected':False})
html_expands.append({u'desc':u'Yellow', u'start tag':u'{y}', \
u'start html':u'<span style="-webkit-text-fill-color:yellow">', \
u'end tag':u'{/y}', u'end html':u'</span>', \
u'protected':False})
html_expands.append({u'desc':u'Green', u'start tag':u'{g}', \
u'start html':u'<span style="-webkit-text-fill-color:green">', \
u'end tag':u'{/g}', u'end html':u'</span>', \
u'protected':False})
html_expands.append({u'desc':u'Pink', u'start tag':u'{pk}', \
u'start html':u'<span style="-webkit-text-fill-color:#CC33CC">', \
u'end tag':u'{/pk}', u'end html':u'</span>', \
u'protected':False})
html_expands.append({u'desc':u'Orange', u'start tag':u'{o}', \
u'start html':u'<span style="-webkit-text-fill-color:#CC0033">', \
u'end tag':u'{/o}', u'end html':u'</span>', \
u'protected':False})
html_expands.append({u'desc':u'Purple', u'start tag':u'{pp}', \
u'start html':u'<span style="-webkit-text-fill-color:#9900FF">', \
u'end tag':u'{/pp}', u'end html':u'</span>', \
u'protected':False})
html_expands.append({u'desc':u'White', u'start tag':u'{w}', \
u'start html':u'<span style="-webkit-text-fill-color:white">', \
u'end tag':u'{/w}', u'end html':u'</span>', \
u'protected':False})
html_expands.append({u'desc':u'Superscript', u'start tag':u'{su}', \
u'start html':u'<sup>', \
u'end tag':u'{/su}', u'end html':u'</sup>', \
u'protected':True})
html_expands.append({u'desc':u'Subscript', u'start tag':u'{sb}', \
u'start html':u'<sub>', \
u'end tag':u'{/sb}', u'end html':u'</sub>', \
u'protected':True})
html_expands.append({u'desc':u'Paragraph', u'start tag':u'{p}', \
u'start html':u'<p>', \
u'end tag':u'{/p}', u'end html':u'</p>', \
u'protected':True})
html_expands.append({u'desc':u'Bold', u'start tag':u'{st}', \
u'start html':u'<strong>', \
u'end tag':u'{/st}', \
u'end html':u'</strong>', \
u'protected':True})
html_expands.append({u'desc':u'Italics', u'start tag':u'{it}', \
u'start html':u'<em>', \
u'end tag':u'{/it}', u'end html':u'</em>', \
u'protected':True})
html_expands.append({u'desc':u'Red', u'start tag':u'{r}',
u'start html':u'<span style="-webkit-text-fill-color:red">',
u'end tag':u'{/r}', u'end html':u'</span>', u'protected':False})
html_expands.append({u'desc':u'Black', u'start tag':u'{b}',
u'start html':u'<span style="-webkit-text-fill-color:black">',
u'end tag':u'{/b}', u'end html':u'</span>', u'protected':False})
html_expands.append({u'desc':u'Blue', u'start tag':u'{bl}',
u'start html':u'<span style="-webkit-text-fill-color:blue">',
u'end tag':u'{/bl}', u'end html':u'</span>', u'protected':False})
html_expands.append({u'desc':u'Yellow', u'start tag':u'{y}',
u'start html':u'<span style="-webkit-text-fill-color:yellow">',
u'end tag':u'{/y}', u'end html':u'</span>', u'protected':False})
html_expands.append({u'desc':u'Green', u'start tag':u'{g}',
u'start html':u'<span style="-webkit-text-fill-color:green">',
u'end tag':u'{/g}', u'end html':u'</span>', u'protected':False})
html_expands.append({u'desc':u'Pink', u'start tag':u'{pk}',
u'start html':u'<span style="-webkit-text-fill-color:#CC33CC">',
u'end tag':u'{/pk}', u'end html':u'</span>', u'protected':False})
html_expands.append({u'desc':u'Orange', u'start tag':u'{o}',
u'start html':u'<span style="-webkit-text-fill-color:#CC0033">',
u'end tag':u'{/o}', u'end html':u'</span>', u'protected':False})
html_expands.append({u'desc':u'Purple', u'start tag':u'{pp}',
u'start html':u'<span style="-webkit-text-fill-color:#9900FF">',
u'end tag':u'{/pp}', u'end html':u'</span>', u'protected':False})
html_expands.append({u'desc':u'White', u'start tag':u'{w}',
u'start html':u'<span style="-webkit-text-fill-color:white">',
u'end tag':u'{/w}', u'end html':u'</span>', u'protected':False})
html_expands.append({u'desc':u'Superscript', u'start tag':u'{su}',
u'start html':u'<sup>', u'end tag':u'{/su}', u'end html':u'</sup>',
u'protected':True})
html_expands.append({u'desc':u'Subscript', u'start tag':u'{sb}',
u'start html':u'<sub>', u'end tag':u'{/sb}', u'end html':u'</sub>',
u'protected':True})
html_expands.append({u'desc':u'Paragraph', u'start tag':u'{p}',
u'start html':u'<p>', u'end tag':u'{/p}', u'end html':u'</p>',
u'protected':True})
html_expands.append({u'desc':u'Bold', u'start tag':u'{st}',
u'start html':u'<strong>', u'end tag':u'{/st}', u'end html':u'</strong>',
u'protected':True})
html_expands.append({u'desc':u'Italics', u'start tag':u'{it}',
u'start html':u'<em>', u'end tag':u'{/it}', u'end html':u'</em>',
u'protected':True})
def translate(context, text, comment=None):
"""

View File

@ -81,17 +81,14 @@ body {
</style>
<script language="javascript">
var timer = null;
var video_timer = null;
var transition = %s;
function show_video(state, path, volume, loop){
var vid = document.getElementById('video');
if(path != null)
if(path != null){
vid.src = path;
if(loop != null){
if(loop)
vid.loop = 'loop';
else
vid.loop = '';
vid.load();
}
if(volume != null){
vid.volume = volume;
@ -100,23 +97,55 @@ body {
case 'play':
vid.play();
vid.style.display = 'block';
if(loop)
video_timer = setInterval('video_loop()', 200);
break;
case 'pause':
if(video_timer!=null){
clearInterval(video_timer);
video_timer = null;
}
vid.pause();
vid.style.display = 'block';
break;
case 'stop':
if(video_timer!=null){
clearInterval(video_timer);
video_timer = null;
}
vid.pause();
vid.style.display = 'none';
vid.load();
break;
case 'close':
if(video_timer!=null){
clearInterval(video_timer);
video_timer = null;
}
vid.pause();
vid.style.display = 'none';
vid.src = '';
break;
}
}
function video_loop(){
// The preferred method would be to use the video tag loop attribute
// But QtWebKit doesn't support this. Neither does it support the
// onended event, hence the setInterval()
// In addition, setting the currentTime attribute to zero to restart
// the video raises an INDEX_SIZE_ERROR: DOM Exception 1
// To complicate it further, sometimes vid.currentTime stops
// slightly short of vid.duration and vid.ended is intermittent!
//
// Note, currently the background may go black between loops. Not
// desirable. Need to investigate using two <video>'s, and hiding/
// preloading one, and toggle between the two when looping.
var vid = document.getElementById('video');
if(vid.ended||vid.currentTime+0.2>=vid.duration){
vid.load();
vid.play();
}
}
function show_image(src){
var img = document.getElementById('image');
img.src = src;

View File

@ -432,7 +432,7 @@ class MediaManagerItem(QtGui.QWidget):
raise NotImplementedError(u'MediaManagerItem.onDeleteClick needs to '
u'be defined by the plugin')
def generateSlideData(self, service_item, item):
def generateSlideData(self, service_item, item=None):
raise NotImplementedError(u'MediaManagerItem.generateSlideData needs '
u'to be defined by the plugin')

View File

@ -199,18 +199,18 @@ class Ui_AboutDialog(object):
'Preamble\n'
'\n'
'The licenses for most software are designed to take away your '
'freedom to share and change it. By contrast, the GNU General '
'freedom to share and change it. By contrast, the GNU General '
'Public License is intended to guarantee your freedom to share '
'and change free software--to make sure the software is free for '
'all its users. This General Public License applies to most of '
'all its users. This General Public License applies to most of '
'the Free Software Foundation\'s software and to any other '
'program whose authors commit to using it. (Some other Free '
'program whose authors commit to using it. (Some other Free '
'Software Foundation software is covered by the GNU Lesser '
'General Public License instead.) You can apply it to your '
'General Public License instead.) You can apply it to your '
'programs, too.\n'
'\n'
'When we speak of free software, we are referring to freedom, not '
'price. Our General Public Licenses are designed to make sure '
'price. Our General Public Licenses are designed to make sure '
'that you have the freedom to distribute copies of free software '
'(and charge for this service if you wish), that you receive '
'source code or can get it if you want it, that you can change '
@ -225,8 +225,8 @@ class Ui_AboutDialog(object):
'\n'
'For example, if you distribute copies of such a program, whether '
'gratis or for a fee, you must give the recipients all the rights '
'that you have. You must make sure that they, too, receive or '
'can get the source code. And you must show them these terms so '
'that you have. You must make sure that they, too, receive or '
'can get the source code. And you must show them these terms so '
'they know their rights.\n'
'\n'
'We protect your rights with two steps: (1) copyright the '
@ -235,15 +235,15 @@ class Ui_AboutDialog(object):
'\n'
'Also, for each author\'s protection and ours, we want to make '
'certain that everyone understands that there is no warranty for '
'this free software. If the software is modified by someone else '
'this free software. If the software is modified by someone else '
'and passed on, we want its recipients to know that what they '
'have is not the original, so that any problems introduced by '
'others will not reflect on the original authors\' reputations.\n'
'\n'
'Finally, any free program is threatened constantly by software '
'patents. We wish to avoid the danger that redistributors of a '
'patents. We wish to avoid the danger that redistributors of a '
'free program will individually obtain patent licenses, in effect '
'making the program proprietary. To prevent this, we have made '
'making the program proprietary. To prevent this, we have made '
'it clear that any patent must be licensed for everyone\'s free '
'use or not licensed at all.\n'
'\n'
@ -255,17 +255,17 @@ class Ui_AboutDialog(object):
'\n'
'0. This License applies to any program or other work which '
'contains a notice placed by the copyright holder saying it may '
'be distributed under the terms of this General Public License. '
'be distributed under the terms of this General Public License. '
'The "Program", below, refers to any such program or work, and a '
'"work based on the Program" means either the Program or any '
'derivative work under copyright law: that is to say, a work '
'containing the Program or a portion of it, either verbatim or '
'with modifications and/or translated into another language. '
'with modifications and/or translated into another language. '
'(Hereinafter, translation is included without limitation in the '
'term "modification".) Each licensee is addressed as "you".\n'
'term "modification".) Each licensee is addressed as "you".\n'
'\n'
'Activities other than copying, distribution and modification are '
'not covered by this License; they are outside its scope. The '
'not covered by this License; they are outside its scope. The '
'act of running the Program is not restricted, and the output '
'from the Program is covered only if its contents constitute a '
'work based on the Program (independent of having been made by '
@ -305,17 +305,17 @@ class Ui_AboutDialog(object):
'notice that there is no warranty (or else, saying that you '
'provide a warranty) and that users may redistribute the program '
'under these conditions, and telling the user how to view a copy '
'of this License. (Exception: if the Program itself is '
'of this License. (Exception: if the Program itself is '
'interactive but does not normally print such an announcement, '
'your work based on the Program is not required to print an '
'announcement.)\n'
'\n'
'These requirements apply to the modified work as a whole. If '
'These requirements apply to the modified work as a whole. If '
'identifiable sections of that work are not derived from the '
'Program, and can be reasonably considered independent and '
'separate works in themselves, then this License, and its terms, '
'do not apply to those sections when you distribute them as '
'separate works. But when you distribute the same sections as '
'separate works. But when you distribute the same sections as '
'part of a whole which is a work based on the Program, the '
'distribution of the whole must be on the terms of this License, '
'whose permissions for other licensees extend to the entire '
@ -350,17 +350,17 @@ class Ui_AboutDialog(object):
'medium customarily used for software interchange; or,\n'
'\n'
'c) Accompany it with the information you received as to the '
'offer to distribute corresponding source code. (This '
'offer to distribute corresponding source code. (This '
'alternative is allowed only for noncommercial distribution and '
'only if you received the program in object code or executable '
'form with such an offer, in accord with Subsection b above.)\n'
'\n'
'The source code for a work means the preferred form of the work '
'for making modifications to it. For an executable work, '
'for making modifications to it. For an executable work, '
'complete source code means all the source code for all modules '
'it contains, plus any associated interface definition files, '
'plus the scripts used to control compilation and installation of '
'the executable. However, as a special exception, the source '
'the executable. However, as a special exception, the source '
'code distributed need not include anything that is normally '
'distributed (in either source or binary form) with the major '
'components (compiler, kernel, and so on) of the operating system '
@ -374,7 +374,7 @@ class Ui_AboutDialog(object):
'not compelled to copy the source along with the object code.\n'
'\n'
'4. You may not copy, modify, sublicense, or distribute the '
'Program except as expressly provided under this License. Any '
'Program except as expressly provided under this License. Any '
'attempt otherwise to copy, modify, sublicense or distribute the '
'Program is void, and will automatically terminate your rights '
'under this License. However, parties who have received copies, '
@ -383,10 +383,10 @@ class Ui_AboutDialog(object):
'compliance.\n'
'\n'
'5. You are not required to accept this License, since you have '
'not signed it. However, nothing else grants you permission to '
'modify or distribute the Program or its derivative works. These '
'not signed it. However, nothing else grants you permission to '
'modify or distribute the Program or its derivative works. These '
'actions are prohibited by law if you do not accept this '
'License. Therefore, by modifying or distributing the Program '
'License. Therefore, by modifying or distributing the Program '
'(or any work based on the Program), you indicate your acceptance '
'of this License to do so, and all its terms and conditions for '
'copying, distributing or modifying the Program or works based on '
@ -395,7 +395,7 @@ class Ui_AboutDialog(object):
'6. Each time you redistribute the Program (or any work based on '
'the Program), the recipient automatically receives a license '
'from the original licensor to copy, distribute or modify the '
'Program subject to these terms and conditions. You may not '
'Program subject to these terms and conditions. You may not '
'impose any further restrictions on the recipients\' exercise of '
'the rights granted herein. You are not responsible for enforcing '
'compliance by third parties to this License.\n'
@ -405,10 +405,10 @@ class Ui_AboutDialog(object):
'patent issues), conditions are imposed on you (whether by court '
'order, agreement or otherwise) that contradict the conditions of '
'this License, they do not excuse you from the conditions of this '
'License. If you cannot distribute so as to satisfy '
'License. If you cannot distribute so as to satisfy '
'simultaneously your obligations under this License and any other '
'pertinent obligations, then as a consequence you may not '
'distribute the Program at all. For example, if a patent license '
'distribute the Program at all. For example, if a patent license '
'would not permit royalty-free redistribution of the Program by '
'all those who receive copies directly or indirectly through you, '
'then the only way you could satisfy both it and this License '
@ -423,7 +423,7 @@ class Ui_AboutDialog(object):
'any patents or other property right claims or to contest '
'validity of any such claims; this section has the sole purpose '
'of protecting the integrity of the free software distribution '
'system, which is implemented by public license practices. Many '
'system, which is implemented by public license practices. Many '
'people have made generous contributions to the wide range of '
'software distributed through that system in reliance on '
'consistent application of that system; it is up to the '
@ -439,29 +439,29 @@ class Ui_AboutDialog(object):
'interfaces, the original copyright holder who places the Program '
'under this License may add an explicit geographical distribution '
'limitation excluding those countries, so that distribution is '
'permitted only in or among countries not thus excluded. In such '
'permitted only in or among countries not thus excluded. In such '
'case, this License incorporates the limitation as if written in '
'the body of this License.\n'
'\n'
'9. The Free Software Foundation may publish revised and/or new '
'versions of the General Public License from time to time. Such '
'versions of the General Public License from time to time. Such '
'new versions will be similar in spirit to the present version, '
'but may differ in detail to address new problems or concerns.\n'
'\n'
'Each version is given a distinguishing version number. If the '
'Each version is given a distinguishing version number. If the '
'Program specifies a version number of this License which applies '
'to it and \"any later version\', you have the option of '
'to it and "any later version", you have the option of '
'following the terms and conditions either of that version or of '
'any later version published by the Free Software Foundation. If '
'any later version published by the Free Software Foundation. If '
'the Program does not specify a version number of this License, '
'you may choose any version ever published by the Free Software '
'Foundation.\n'
'\n'
'10. If you wish to incorporate parts of the Program into other '
'free programs whose distribution conditions are different, write '
'to the author to ask for permission. For software which is '
'to the author to ask for permission. For software which is '
'copyrighted by the Free Software Foundation, write to the Free '
'Software Foundation; we sometimes make exceptions for this. Our '
'Software Foundation; we sometimes make exceptions for this. Our '
'decision will be guided by the two goals of preserving the free '
'status of all derivatives of our free software and of promoting '
'the sharing and reuse of software generally.\n'
@ -470,12 +470,12 @@ class Ui_AboutDialog(object):
'\n'
'11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO '
'WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE '
'LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT '
'LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT '
'HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT '
'WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, '
'BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY '
'AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE '
'QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE '
'AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE '
'QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE '
'PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY '
'SERVICING, REPAIR OR CORRECTION.\n'
'\n'
@ -499,7 +499,7 @@ class Ui_AboutDialog(object):
'this is to make it free software which everyone can redistribute '
'and change under these terms.\n'
'\n'
'To do so, attach the following notices to the program. It is '
'To do so, attach the following notices to the program. It is '
'safest to attach them to the start of each source file to most '
'effectively convey the exclusion of warranty; and each file '
'should have at least the "copyright" line and a pointer to where '
@ -507,7 +507,7 @@ class Ui_AboutDialog(object):
'\n'
'<one line to give the program\'s name and a brief idea of what '
'it does.>\n'
'Copyright (C) <year> <name of author>\n'
'Copyright (C) <year> <name of author>\n'
'\n'
'This program is free software; you can redistribute it and/or '
'modify it under the terms of the GNU General Public License as '
@ -516,7 +516,7 @@ class Ui_AboutDialog(object):
'\n'
'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 '
'MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the '
'GNU General Public License for more details.\n'
'\n'
'You should have received a copy of the GNU General Public '
@ -537,14 +537,14 @@ class Ui_AboutDialog(object):
'under certain conditions; type "show c" for details.\n'
'\n'
'The hypothetical commands "show w" and "show c" should show '
'the appropriate parts of the General Public License. Of course, '
'the appropriate parts of the General Public License. Of course, '
'the commands you use may be called something other than "show '
'w" and "show c"; they could even be mouse-clicks or menu items--'
'whatever suits your program.\n'
'\n'
'You should also get your employer (if you work as a programmer) '
'or your school, if any, to sign a "copyright disclaimer" for the '
'program, if necessary. Here is a sample; alter the names:\n'
'program, if necessary. Here is a sample; alter the names:\n'
'\n'
'Yoyodyne, Inc., hereby disclaims all copyright interest in the '
'program "Gnomovision" (which makes passes at compilers) written '
@ -554,9 +554,9 @@ class Ui_AboutDialog(object):
'Ty Coon, President of Vice\n'
'\n'
'This General Public License does not permit incorporating your '
'program into proprietary programs. If your program is a '
'program into proprietary programs. If your program is a '
'subroutine library, you may consider it more useful to permit '
'linking proprietary applications with the library. If this is '
'linking proprietary applications with the library. If this is '
'what you want to do, use the GNU Lesser General Public License '
'instead of this License.'))
self.aboutNotebook.setTabText(
@ -565,3 +565,4 @@ class Ui_AboutDialog(object):
self.contributeButton.setText(translate('OpenLP.AboutForm',
'Contribute'))
self.closeButton.setText(translate('OpenLP.AboutForm', 'Close'))

View File

@ -120,7 +120,7 @@ class MainDisplay(DisplayWidget):
self.setScene(self.scene)
self.webView = QtWebKit.QGraphicsWebView()
self.scene.addItem(self.webView)
self.webView.resize(self.screen[u'size'].width(), \
self.webView.resize(self.screen[u'size'].width(),
self.screen[u'size'].height())
self.page = self.webView.page()
self.frame = self.page.mainFrame()
@ -303,6 +303,9 @@ class MainDisplay(DisplayWidget):
Generates a preview of the image displayed.
"""
log.debug(u'preview for %s', self.isLive)
# We must have a service item to preview
if not hasattr(self, u'serviceItem'):
return
if self.isLive:
# Wait for the fade to finish before geting the preview.
# Important otherwise preview will have incorrect text if at all !
@ -336,7 +339,7 @@ class MainDisplay(DisplayWidget):
self.loaded = False
self.initialFrame = False
self.serviceItem = serviceItem
html = build_html(self.serviceItem, self.screen, self.parent.alertTab,\
html = build_html(self.serviceItem, self.screen, self.parent.alertTab,
self.isLive)
self.webView.setHtml(html)
if serviceItem.foot_text and serviceItem.foot_text:

View File

@ -93,6 +93,7 @@ class Ui_PluginViewDialog(object):
self.pluginListButtonBox.setStandardButtons(QtGui.QDialogButtonBox.Ok)
self.pluginListButtonBox.setObjectName(u'pluginListButtonBox')
self.pluginLayout.addWidget(self.pluginListButtonBox)
self.versionNumberLabel.setText(u'')
self.retranslateUi(pluginViewDialog)
QtCore.QObject.connect(self.pluginListButtonBox,
QtCore.SIGNAL(u'accepted()'), pluginViewDialog.close)
@ -105,8 +106,6 @@ class Ui_PluginViewDialog(object):
translate('OpenLP.PluginForm', 'Plugin Details'))
self.versionLabel.setText(
translate('OpenLP.PluginForm', 'Version:'))
self.versionNumberLabel.setText(
translate('OpenLP.PluginForm', 'TextLabel'))
self.aboutLabel.setText(
translate('OpenLP.PluginForm', 'About:'))
self.statusLabel.setText(
@ -115,3 +114,4 @@ class Ui_PluginViewDialog(object):
translate('OpenLP.PluginForm', 'Active'))
self.statusComboBox.setItemText(1,
translate('OpenLP.PluginForm', 'Inactive'))

View File

@ -279,7 +279,8 @@ class ServiceManager(QtGui.QWidget):
self.editAction.setVisible(False)
self.maintainAction.setVisible(False)
self.notesAction.setVisible(False)
if serviceItem[u'service_item'].is_capable(ItemCapabilities.AllowsEdit):
if serviceItem[u'service_item'].is_capable(ItemCapabilities.AllowsEdit) \
and hasattr(serviceItem[u'service_item'], u'editId'):
self.editAction.setVisible(True)
if serviceItem[u'service_item']\
.is_capable(ItemCapabilities.AllowsMaintain):

View File

@ -209,7 +209,7 @@ class SlideController(QtGui.QWidget):
self.Toolbar.addToolbarSeparator(u'Close Separator')
self.Toolbar.addToolbarButton(
u'Edit Song', u':/general/general_edit.png',
translate('OpenLP.SlideController', 'Edit and re-preview Song'),
translate('OpenLP.SlideController', 'Edit and re-preview song'),
self.onEditSong)
if isLive:
self.Toolbar.addToolbarSeparator(u'Loop Separator')
@ -269,11 +269,11 @@ class SlideController(QtGui.QWidget):
if isLive:
self.SongMenu = QtGui.QToolButton(self.Toolbar)
self.SongMenu.setText(translate('OpenLP.SlideController',
'Go to'))
'Go To'))
self.SongMenu.setPopupMode(QtGui.QToolButton.InstantPopup)
self.Toolbar.addToolbarWidget(u'Song Menu', self.SongMenu)
self.SongMenu.setMenu(QtGui.QMenu(
translate('OpenLP.SlideController', 'Go to'),
translate('OpenLP.SlideController', 'Go To'),
self.Toolbar))
self.Toolbar.makeWidgetsInvisible([u'Song Menu'])
# Screen preview area

View File

@ -576,7 +576,7 @@ class ThemeManager(QtGui.QWidget):
translate('OpenLP.ThemeManager', 'Theme Exists'),
translate('OpenLP.ThemeManager',
'A theme with this name already '
'exists. Would you like to overwrite it?'),
'exists. Would you like to overwrite it?'),
(QtGui.QMessageBox.Yes | QtGui.QMessageBox.No),
QtGui.QMessageBox.No)
if self.saveThemeName != u'':

View File

@ -112,7 +112,11 @@ class AppLocation(object):
The directory type you want, for instance the data directory.
"""
if dir_type == AppLocation.AppDir:
return os.path.abspath(os.path.split(sys.argv[0])[0])
if hasattr(sys, u'frozen') and sys.frozen == 1:
app_path = os.path.abspath(os.path.split(sys.argv[0])[0])
else:
app_path = os.path.split(openlp.__file__)[0]
return app_path
elif dir_type == AppLocation.ConfigDir:
if sys.platform == u'win32':
path = os.path.join(os.getenv(u'APPDATA'), u'openlp')

View File

@ -55,7 +55,7 @@ class LanguageManager(object):
if LanguageManager.AutoLanguage:
language = QtCore.QLocale.system().name()
lang_path = AppLocation.get_directory(AppLocation.AppDir)
lang_path = os.path.join(lang_path, u'resources', u'i18n')
lang_path = os.path.join(lang_path, u'i18n')
app_translator = QtCore.QTranslator()
if app_translator.load("openlp_" + language, lang_path):
return app_translator
@ -66,7 +66,7 @@ class LanguageManager(object):
Find all available language files in this OpenLP install
"""
trans_dir = AppLocation.get_directory(AppLocation.AppDir)
trans_dir = QtCore.QDir(os.path.join(trans_dir, u'openlp', u'i18n'))
trans_dir = QtCore.QDir(os.path.join(trans_dir, u'i18n'))
file_names = trans_dir.entryList(QtCore.QStringList("*.qm"),
QtCore.QDir.Files, QtCore.QDir.Name)
for name in file_names:

View File

@ -353,7 +353,7 @@ class BibleDB(QtCore.QObject, Manager):
QtGui.QMessageBox.information(self.bible_plugin.mediaItem,
translate('BiblesPlugin.BibleDB', 'Book not found'),
translate('BiblesPlugin.BibleDB', 'The book you requested '
'could not be found in this bible. Please check your '
'could not be found in this bible. Please check your '
'spelling and that this is a complete bible not just '
'one testament.'))
return verse_list

View File

@ -246,7 +246,7 @@ class BibleManager(object):
translate('BiblesPlugin.BibleManager',
'Scripture Reference Error'),
translate('BiblesPlugin.BibleManager', 'Your scripture '
'reference is either not supported by OpenLP or invalid. '
'reference is either not supported by OpenLP or invalid. '
'Please make sure your reference conforms to one of the '
'following patterns:\n\n'
'Book Chapter\n'

View File

@ -678,7 +678,8 @@ class BibleMediaItem(MediaManagerItem):
self.dual_search_results[count].text)
}
bible_text = u' %s %d:%d (%s, %s)' % (verse.book.name,
verse.chapter, verse.verse, version.value, dual_version.value)
verse.chapter, verse.verse, version.value,
dual_version.value)
else:
vdict = {
'book': QtCore.QVariant(verse.book.name),

View File

@ -89,7 +89,7 @@ class OpenSongBible(BibleDB):
Receiver.send_message(u'openlp_process_events')
self.wizard.incrementProgressBar(
QtCore.QString('%s %s %s' % (
translate('BiblesPlugin.Opensong', 'Importing'), \
translate('BiblesPlugin.Opensong', 'Importing'),
db_book.name, chapter.attrib[u'n'])))
self.session.commit()
except IOError:

View File

@ -212,7 +212,7 @@ class PresentationMediaItem(MediaManagerItem):
self, translate('PresentationPlugin.MediaItem',
'Unsupported File'),
translate('PresentationPlugin.MediaItem',
'This type of presentation is not supported'))
'This type of presentation is not supported.'))
continue
item_name = QtGui.QListWidgetItem(filename)
item_name.setData(QtCore.Qt.UserRole, QtCore.QVariant(file))

View File

@ -258,10 +258,11 @@ class Ui_EditSongDialog(object):
self.TopicBookLayout.addWidget(self.TopicGroupBox)
self.SongBookGroup = QtGui.QGroupBox(self.TopicBookWidget)
self.SongBookGroup.setObjectName(u'SongBookGroup')
self.SongbookLayout = QtGui.QGridLayout(self.SongBookGroup)
self.SongbookLayout = QtGui.QFormLayout(self.SongBookGroup)
self.SongbookLayout.setMargin(8)
self.SongbookLayout.setSpacing(8)
self.SongbookLayout.setObjectName(u'SongbookLayout')
self.SongbookNameLabel = QtGui.QLabel(self.SongBookGroup)
self.SongbookCombo = QtGui.QComboBox(self.SongBookGroup)
sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.MinimumExpanding,
QtGui.QSizePolicy.Fixed)
@ -272,13 +273,11 @@ class Ui_EditSongDialog(object):
self.SongbookCombo.setEditable(True)
self.SongbookCombo.setSizePolicy(sizePolicy)
self.SongbookCombo.setObjectName(u'SongbookCombo')
self.SongbookLayout.addWidget(self.SongbookCombo, 0, 0, 1, 1)
self.SongbookLayout.addRow(self.SongbookNameLabel, self.SongbookCombo)
self.songBookNumberLabel = QtGui.QLabel(self.SongBookGroup)
self.SongbookLayout.addWidget(self.songBookNumberLabel, 0, 1, 1, 1)
self.songBookNumberEdit = QtGui.QLineEdit(self.SongBookGroup)
self.songBookNumberLabel.setBuddy(self.songBookNumberEdit)
self.songBookNumberEdit.setMaximumWidth(35)
self.SongbookLayout.addWidget(self.songBookNumberEdit, 0, 2, 1, 1)
self.SongbookLayout.addRow(self.songBookNumberLabel,
self.songBookNumberEdit)
self.TopicBookLayout.addWidget(self.SongBookGroup)
self.AuthorsTabLayout.addWidget(self.TopicBookWidget)
self.SongTabWidget.addTab(self.AuthorsTab, u'')
@ -446,8 +445,10 @@ class Ui_EditSongDialog(object):
translate('SongsPlugin.EditSongForm', 'R&emove'))
self.SongBookGroup.setTitle(
translate('SongsPlugin.EditSongForm', 'Song Book'))
self.SongbookNameLabel.setText(translate('SongsPlugin.EditSongForm',
'Book:'))
self.songBookNumberLabel.setText(translate('SongsPlugin.EditSongForm',
'Song No.:'))
'Number:'))
self.SongTabWidget.setTabText(
self.SongTabWidget.indexOf(self.AuthorsTab),
translate('SongsPlugin.EditSongForm',

View File

@ -57,7 +57,7 @@ class CCLIFileImport(SongImport):
self.filenames = kwargs[u'filenames']
log.debug(self.filenames)
else:
raise KeyError(u'Keyword argument "filenames" not supplied.')
raise KeyError(u'Keyword argument "filenames" not supplied.')
def do_import(self):
"""
@ -66,11 +66,11 @@ class CCLIFileImport(SongImport):
log.debug(u'Starting CCLI File Import')
song_total = len(self.filenames)
self.import_wizard.importProgressBar.setMaximum(song_total)
song_count = 1
song_count = 1
for filename in self.filenames:
self.import_wizard.incrementProgressBar(
u'Importing song %s of %s' % (song_count, song_total))
filename = unicode(filename)
u'Importing song %s of %s' % (song_count, song_total))
filename = unicode(filename)
log.debug(u'Importing CCLI File: %s', filename)
lines = []
if os.path.isfile(filename):
@ -81,33 +81,34 @@ class CCLIFileImport(SongImport):
lines = infile.readlines()
ext = os.path.splitext(filename)[1]
if ext.lower() == ".usr":
log.info(u'SongSelect .usr format file found %s: ' , filename)
log.info(u'SongSelect .usr format file found %s: ',
filename)
self.do_import_usr_file(lines)
elif ext.lower() == ".txt":
log.info(u'SongSelect .txt format file found %s: ', filename)
log.info(u'SongSelect .txt format file found %s: ',
filename)
self.do_import_txt_file(lines)
else:
log.info(u'Extension %s is not valid', filename)
pass
song_count += 1
if self.stop_import_flag:
return False
return False
return True
def do_import_usr_file(self, textList):
"""
The :method:`do_import_usr_file` method provides OpenLP
with the ability to import CCLI SongSelect songs in
*USR* file format
*USR* file format
``textList``
An array of strings containing the usr file content.
**SongSelect .usr file format**
``[File]``
USR file format first line
``Type=``
Indicates the file type
Indicates the file type
e.g. *Type=SongSelect Import File*
``Version=3.0``
File format version
@ -116,7 +117,7 @@ class CCLIFileImport(SongImport):
``Title=``
Contains the song title (e.g. *Title=Above All*)
``Author=``
Contains a | delimited list of the song authors
Contains a | delimited list of the song authors
e.g. *Author=LeBlanc, Lenny | Baloche, Paul*
``Copyright=``
Contains a | delimited list of the song copyrights
@ -136,7 +137,7 @@ class CCLIFileImport(SongImport):
Contains a list of the songs fields in order /t delimited
e.g. *Fields=Vers 1/tVers 2/tChorus 1/tAndere 1*
``Words=``
Contains the songs various lyrics in order as shown by the
Contains the songs various lyrics in order as shown by the
*Fields* description
e.g. *Words=Above all powers....* [/n = CR, /n/t = CRLF]
"""
@ -174,8 +175,8 @@ class CCLIFileImport(SongImport):
verse_type = u'O'
verse_text = unicode(words_list[counter])
verse_text = verse_text.replace("/n", "\n")
if len(verse_text) > 0:
self.add_verse(verse_text, verse_type);
if len(verse_text) > 0:
self.add_verse(verse_text, verse_type)
#Handle multiple authors
author_list = song_author.split(u'/')
if len(author_list) < 2:
@ -192,10 +193,10 @@ class CCLIFileImport(SongImport):
"""
The :method:`do_import_txt_file` method provides OpenLP
with the ability to import CCLI SongSelect songs in
*TXT* file format
*TXT* file format
``textList``
An array of strings containing the txt file content.
An array of strings containing the txt file content.
**SongSelect .txt file format**
@ -225,38 +226,38 @@ class CCLIFileImport(SongImport):
e.g. CCLI Number (e.g.CCLI-Liednummer: 2672885)
``Song Copyright``
e.g. © 1999 Integrity's Hosanna! Music | LenSongs Publishing
``Song Authors``
``Song Authors``
e.g. Lenny LeBlanc | Paul Baloche
``Licencing info``
e.g. For use solely with the SongSelect Terms of Use.
e.g. For use solely with the SongSelect Terms of Use.
All rights Reserved. www.ccli.com
``CCLI Licence number of user``
e.g. CCL-Liedlizenznummer: 14 / CCLI License No. 14
``CCLI Licence number of user``
e.g. CCL-Liedlizenznummer: 14 / CCLI License No. 14
"""
log.debug(u'TXT file text: %s', textList)
self.set_defaults()
line_number = 0
verse_text = u''
song_comments = u''
song_copyright = u'';
song_copyright = u''
verse_start = False
for line in textList:
clean_line = line.strip()
if not clean_line:
if line_number==0:
if line_number == 0:
continue
elif verse_start:
if verse_text:
if verse_text:
self.add_verse(verse_text, verse_type)
verse_text = ''
verse_start = False
else:
#line_number=0, song title
if line_number==0:
if line_number == 0:
song_name = clean_line
line_number += 1
#line_number=1, verses
elif line_number==1:
#line_number=1, verses
elif line_number == 1:
#line_number=1, ccli number, first line after verses
if clean_line.startswith(u'CCLI'):
line_number += 1
@ -285,15 +286,16 @@ class CCLIFileImport(SongImport):
verse_text = verse_text + line
else:
#line_number=2, copyright
if line_number==2:
if line_number == 2:
line_number += 1
song_copyright = clean_line
#n=3, authors
elif line_number==3:
#n=3, authors
elif line_number == 3:
line_number += 1
song_author = clean_line
#line_number=4, comments lines before last line
elif (line_number==4) and (not clean_line.startswith(u'CCL')):
#line_number=4, comments lines before last line
elif (line_number == 4) and \
(not clean_line.startswith(u'CCL')):
song_comments = song_comments + clean_line
# split on known separators
author_list = song_author.split(u'/')
@ -307,4 +309,3 @@ class CCLIFileImport(SongImport):
self.ccli_number = song_ccli
self.comments = song_comments
self.finish()

View File

@ -90,9 +90,9 @@ class OpenLP1SongImport(SongImport):
cursor.execute(u'SELECT authorid, authorname FROM authors')
authors = cursor.fetchall()
if new_db:
# "cache" our list of tracks
cursor.execute(u'SELECT trackid, fulltrackname FROM tracks')
tracks = cursor.fetchall()
# "cache" our list of tracks
cursor.execute(u'SELECT trackid, fulltrackname FROM tracks')
tracks = cursor.fetchall()
# Import the songs
cursor.execute(u'SELECT songid, songtitle, lyrics || \'\' AS lyrics, '
u'copyrightinfo FROM songs')

View File

@ -30,6 +30,7 @@ from zipfile import ZipFile
from lxml import objectify
from lxml.etree import Error, LxmlError
from openlp.core.lib import translate
from openlp.plugins.songs.lib.songimport import SongImport
log = logging.getLogger(__name__)
@ -170,7 +171,7 @@ class OpenSongImport(SongImport):
self.authors = []
try:
tree = objectify.parse(file)
except Error, LxmlError:
except (Error, LxmlError):
log.exception(u'Error parsing XML')
return
root = tree.getroot()
@ -276,7 +277,8 @@ class OpenSongImport(SongImport):
if len(our_verse_order) > 0:
order = our_verse_order
else:
log.warn(u'No verse order available for %s, skipping.', self.title)
log.warn(u'No verse order available for %s, skipping.',
self.title)
for tag in order:
if len(tag) == 1:
tag = tag + u'1' # Assume it's no.1 if it's not there

View File

@ -119,7 +119,7 @@ class WowImport(SongImport):
# TODO: check that it is a valid words of worship file (could
# check header for WoW File Song Word)
self.author = u''
self.copyright= u''
self.copyright = u''
# Get the song title
self.file_name = os.path.split(file)[1]
self.import_wizard.incrementProgressBar(

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -24,13 +24,31 @@
# with this program; if not, write to the Free Software Foundation, Inc., 59 #
# Temple Place, Suite 330, Boston, MA 02111-1307 USA #
###############################################################################
# Short description
# Steps for creating languages:
# 1. make sure that the openlp_en.ts file exist
# 2. go to scripts folder and start:
# python translation_utils.py -a
###############################################################################
"""
This script is used to maintain the translation files in OpenLP. It downloads
the latest translation files from the Pootle translation server, updates the
local translation files from both the source code and the files from Pootle,
and can also generate the compiled translation files.
Create New Language
-------------------
To create a new language, simply run this script with the ``-a`` command line
option::
@:~$ ./translation_utils.py -a
Update Translation Files
------------------------
The best way to update the translations is to download the files from Pootle,
and then update the local files using both the downloaded files and the source.
This is done easily via the ``-d``, ``-p`` and ``-u`` options::
@:~$ ./translation_utils.py -dpu
"""
import os
import urllib
import re
@ -39,201 +57,277 @@ from optparse import OptionParser
from PyQt4 import QtCore
from BeautifulSoup import BeautifulSoup
class TranslationUtils(object):
SERVER_URL = u'http://pootle.projecthq.biz/export/openlp/'
IGNORED_PATHS = [u'scripts']
IGNORED_FILES = [u'setup.py']
verbose_mode = False
class Command(object):
"""
Provide an enumeration of commands.
"""
Download = 1
Create = 2
Prepare = 3
Update = 4
Generate = 5
class CommandStack(object):
"""
This class provides an iterable stack.
"""
def __init__(self):
self.ignore_paths = [u'./scripts']
self.ignore_files = [u'setup.py']
self.server_url = u'http://pootle.projecthq.biz/export/openlp/'
self.cmd_stack = []
self.stack_count = 0
self.verbose = False
self.current_index = 0
self.data = []
def process_stack(self):
if len(self.cmd_stack) > 0:
if len(self.cmd_stack) == self.stack_count:
print u'Process %d commands' % self.stack_count
print u'%d. ' % (self.stack_count-len(self.cmd_stack)+1),
command = self.cmd_stack.pop(0)
if len(command) > 1:
command[0](command[1])
else:
command[0]()
def __len__(self):
return len(self.data)
def __getitem__(self, index):
if self.data[index].get(u'arguments'):
return self.data[index][u'command'], self.data[index][u'arguments']
else:
print "Finished all commands"
return self.data[index][u'command']
def __iter__(self):
return self
def next(self):
if self.current_index == len(self.data):
raise StopIteration
else:
current_item = self.data[self.current_index][u'command']
self.current_index += 1
return current_item
def append(self, command, **kwargs):
data = {u'command': command}
if u'arguments' in kwargs:
data[u'arguments'] = kwargs[u'arguments']
self.data.append(data)
def reset(self):
self.current_index = 0
def downloadTranslations(self):
print 'Download Translation files from HQ-Server'
page = urllib.urlopen(u'%s' % (self.server_url))
soup = BeautifulSoup(page)
languages = soup.findAll(text=re.compile(".*\.ts"))
for language in languages:
filename = os.path.join(u'..', u'resources', u'i18n',
u'openlp_%s' % language)
self.printVerbose(u'Get Translation File: %s' % filename)
self.get_and_write_file(language, filename)
print u' done'
self.process_stack()
def print_verbose(text):
"""
This method checks to see if we are in verbose mode, and if so prints
``text`` out.
def get_and_write_file(self, language, filename):
page = urllib.urlopen(u'%s%s' % (self.server_url, language))
content = page.read().decode('utf8')
page.close()
file = open(filename, u'w')
file.write(content.encode('utf8'))
file.close()
def creation(self, language):
print "Create new Translation File"
"""
Use this option to create a new translation file
this function:
* create the new *.ts file
"""
filename = os.path.join(u'..', u'resources', u'i18n',
u'openlp_%s.ts' % language)
self.get_and_write_file(u'en.ts', filename)
self.printVerbose("""
Please remind: For permanent providing this language:
this language name have to append to the global list
variable "translations" in this file
and this file have to be uploaded to the Pootle Server
Please contact the developers!
""")
print u' done'
self.process_stack()
def preparation(self):
print u'Generating the openlp.pro file'
stringlist = []
start_dir = os.path.join(u'..')
for root, dirs, files in os.walk(start_dir):
for file in files:
path = u'%s' % root
path = path.replace('\\','/')
path = path.replace('..','.')
if file.startswith(u'hook-') or file.startswith(u'test_'):
continue
``text``
The text to print.
"""
global verbose_mode
if verbose_mode:
print u' %s' % text
cond = False
for search in self.ignore_paths:
if path.startswith(search):
cond = True
if cond:
continue
cond = False
for search in self.ignore_files:
if search == file:
cond = True
if cond:
continue
if file.endswith(u'.py'):
def run(command):
"""
This method runs an external application.
``command``
The command to run.
"""
print_verbose(command)
process = QtCore.QProcess()
process.start(command)
while (process.waitForReadyRead()):
print_verbose(u'ReadyRead: %s' % QtCore.QString(process.readAll()))
print_verbose(u'Error(s):\n%s' % process.readAllStandardError())
print_verbose(u'Output:\n%s' % process.readAllStandardOutput())
print u' Done.'
def download_file(source_filename, dest_filename):
"""
Download a file and save it to disk.
``source_filename``
The file to download.
``dest_filename``
The new local file name.
"""
print_verbose(u'Downloading from: %s' % (SERVER_URL + source_filename))
page = urllib.urlopen(SERVER_URL + source_filename)
content = page.read().decode('utf8')
page.close()
file = open(dest_filename, u'w')
file.write(content.encode('utf8'))
file.close()
def download_translations():
"""
This method downloads the translation files from the Pootle server.
"""
print 'Download translation files from Pootle'
page = urllib.urlopen(SERVER_URL)
soup = BeautifulSoup(page)
languages = soup.findAll(text=re.compile(r'.*\.ts'))
for language in languages:
filename = os.path.join(os.path.abspath(u'..'), u'resources', u'i18n',
language)
print_verbose(u'Get Translation File: %s' % filename)
download_file(language, filename)
print u' Done.'
def prepare_project():
"""
This method creates the project file needed to update the translation files
and compile them into .qm files.
"""
print u'Generating the openlp.pro file'
lines = []
start_dir = os.path.abspath(u'..')
start_dir = start_dir + os.sep
print_verbose(u'Starting directory: %s' % start_dir)
for root, dirs, files in os.walk(start_dir):
for file in files:
path = root.replace(start_dir, u'').replace(u'\\', u'/') #.replace(u'..', u'.')
if file.startswith(u'hook-') or file.startswith(u'test_'):
continue
ignore = False
for ignored_path in IGNORED_PATHS:
if path.startswith(ignored_path):
ignore = True
break
if ignore:
continue
ignore = False
for ignored_file in IGNORED_FILES:
if file == ignored_file:
ignore = True
break
if ignore:
continue
if file.endswith(u'.py') or file.endswith(u'.pyw'):
if path:
line = u'%s/%s' % (path, file)
self.printVerbose(u'Parsing "%s"' % line)
stringlist.append(u'SOURCES += %s' % line)
elif file.endswith(u'.pyw'):
line = u'%s/%s' % (path, file)
self.printVerbose(u'Parsing "%s"' % line)
stringlist.append(u'SOURCES += %s' % line)
elif file.endswith(u'.ts'):
line = u'%s/%s' % (path, file)
self.printVerbose(u'Parsing "%s"' % line)
stringlist.append(u'TRANSLATIONS += %s' % line)
stringlist.sort()
self.write_file(os.path.join(start_dir, u'openlp.pro'), stringlist)
print u' done'
self.process_stack()
else:
line = file
print_verbose(u'Parsing "%s"' % line)
lines.append(u'SOURCES += %s' % line)
elif file.endswith(u'.ts'):
line = u'%s/%s' % (path, file)
print_verbose(u'Parsing "%s"' % line)
lines.append(u'TRANSLATIONS += %s' % line)
lines.sort()
file = open(os.path.join(start_dir, u'openlp.pro'), u'w')
file.write(u'\n'.join(lines).encode('utf8'))
file.close()
print u' Done.'
def update(self):
print u'Update the translation files'
cmd = u'pylupdate4 -verbose -noobsolete ../openlp.pro'
self.start_cmd(cmd)
def update_translations():
print u'Update the translation files'
if not os.path.exists(os.path.join(os.path.abspath(u'..'), u'openlp.pro')):
print u'You have no generated a project file yet, please run this ' + \
u'script with the -p option.'
return
else:
os.chdir(os.path.abspath(u'..'))
run(u'pylupdate4 -verbose -noobsolete openlp.pro')
def generate(self):
print u'Generate the related *.qm files'
cmd = u'lrelease ../openlp.pro'
self.start_cmd(cmd)
def write_file(self, filename, stringlist):
content = u''
for line in stringlist:
content = u'%s%s\n' % (content, line)
file = open(filename, u'w')
file.write(content.encode('utf8'))
file.close()
def generate_binaries():
print u'Generate the related *.qm files'
if not os.path.exists(os.path.join(os.path.abspath(u'..'), u'openlp.pro')):
print u'You have no generated a project file yet, please run this ' + \
u'script with the -p option. It is also recommended that you ' + \
u'this script with the -u option to update the translation ' + \
u'files as well.'
return
else:
os.chdir(os.path.abspath(u'..'))
run(u'lrelease openlp.pro')
def printVerbose(self, data):
if self.verbose:
print u' %s' % data
def create_translation(language):
"""
This method creates a new translation file.
def start_cmd(self, command):
self.printVerbose(command)
self.process = QtCore.QProcess()
self.process.start(command)
while (self.process.waitForReadyRead()):
self.printVerbose(u'ReadyRead: %s' % QtCore.QString(self.process.readAll()))
self.printVerbose(self.process.readAllStandardError())
self.printVerbose(self.process.readAllStandardOutput())
print u' done'
self.process_stack()
``language``
The language file to create.
"""
print "Create new Translation File"
filename = os.path.join(os.path.abspath(u'..'), u'resources', u'i18n', language)
download_file(u'en.ts', filename)
print u'\n** Please Note **\n'
print u'In order to get this file into OpenLP and onto the Pootle ' + \
u'translation server you will need to subscribe to the OpenLP' + \
u'Translators mailing list, and request that your language file ' + \
u'be added to the project.\n'
print u' Done'
def process_stack(command_stack):
"""
This method looks at the commands in the command stack, and processes them
in the order they are in the stack.
``command_stack``
The command stack to process.
"""
if command_stack:
print u'Processing %d commands...' % len(command_stack)
for command in command_stack:
print u'%d.' % (command_stack.current_index),
if command == Command.Download:
download_translations()
elif command == Command.Prepare:
prepare_project()
elif command == Command.Update:
update_translations()
elif command == Command.Generate:
generate_binaries()
elif command == Command.Create:
command, arguments = command_stack[command_stack.current_index]
create_translation(*arguments)
print u'Finished processing commands.'
else:
print u'No commands to process.'
def main():
# start Main Class
Util = TranslationUtils()
global verbose_mode
# Set up command line options.
usage = u'''
This script handle the translation files for OpenLP.
Usage: %prog [options]
If no option will be used, options "-d -p -u -g" will be set automatically
'''
usage = u'%prog [options]\nOptions are parsed in the order they are ' + \
u'listed below. If no options are given, "-dpug" will be used.\n\n' + \
u'This script is used to manage OpenLP\'s translation files.'
parser = OptionParser(usage=usage)
parser.add_option('-d', '--download-ts', action='store_true',
dest='download', help='Load languages from Pootle Server')
parser.add_option('-c', '--create', metavar='lang',
help='creation of new translation file, Parameter: language (e.g. "en_GB"')
parser.add_option('-p', '--prepare', action='store_true', dest='prepare',
help='preparation (generate pro file)')
parser.add_option('-d', '--download-ts', dest='download',
action='store_true', help='download language files from Pootle')
parser.add_option('-c', '--create', dest=u'create', metavar='LANG',
help='create a new translation file for language LANG, e.g. "en_GB"')
parser.add_option('-p', '--prepare', dest='prepare', action='store_true',
help='generate a project file, used to update the translations')
parser.add_option('-u', '--update', action='store_true', dest='update',
help='update translation files')
parser.add_option('-g', '--generate', action='store_true', dest='generate',
help='generate qm files')
parser.add_option('-v', '--verbose', action='store_true', dest='verbose',
help='Give more informations while processing')
help='update translation files (needs a project file)')
parser.add_option('-g', '--generate', dest='generate', action='store_true',
help='compile .ts files into .qm files')
parser.add_option('-v', '--verbose', dest='verbose', action='store_true',
help='show extra information while processing translations')
(options, args) = parser.parse_args()
# Create and populate the command stack
command_stack = CommandStack()
if options.download:
Util.cmd_stack.append([Util.downloadTranslations])
command_stack.append(Command.Download)
if options.create:
Util.cmd_stack.append([Util.creation, u'%s' % options.create])
command_stack.append(Command.Create, arguments=[options.create])
if options.prepare:
Util.cmd_stack.append([Util.preparation])
command_stack.append(Command.Prepare)
if options.update:
Util.cmd_stack.append([Util.update])
command_stack.append(Command.Update)
if options.generate:
Util.cmd_stack.append([Util.generate])
if options.verbose:
Util.verbose = True
command_stack.append(Command.Generate)
verbose_mode = options.verbose
if not command_stack:
command_stack.append(Command.Download)
command_stack.append(Command.Prepare)
command_stack.append(Command.Update)
command_stack.append(Command.Generate)
# Process the commands
process_stack(command_stack)
if len(Util.cmd_stack) == 0:
Util.cmd_stack.append([Util.downloadTranslations])
Util.cmd_stack.append([Util.preparation])
Util.cmd_stack.append([Util.update])
Util.cmd_stack.append([Util.generate])
Util.stack_count = len(Util.cmd_stack)
Util.process_stack()
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()