Head 1495

This commit is contained in:
Jon Tibble 2011-04-28 22:38:12 +01:00
commit e506d40cef
122 changed files with 2970 additions and 2218 deletions

View File

@ -21,20 +21,35 @@ You will see the Bible Importer window, click :guilabel:`Next`.
.. image:: pics/bibleimport01.png
After clicking :guilabel:`Next` you can select from the various types of
software that OpenLP will convert Bibles from.
After clicking :guilabel:`Next` you can select from the various types of
software that OpenLP will convert Bibles from. Click on the file folder icon to
choose the file(s) of the Bible database you want to import. See the sections
below for more information on the different formats that OpenLP will import.
Click :guilabel:`Next` to continue.
.. image:: pics/bibleimport02.png
Click on the file folder icon to choose the file of the Bible database you
want to import. See the following sections for information on the different
formats that OpenLP will import.
After selecting your file(s), you'll be asked to fill in the details of the
Bible you are importing. Remember to check what information you need to display
for your Bible's translation, as some of them have strict rules around the
copyright notice. Click :guilabel:`Next` to continue.
Importing from OpenLP Version 1
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
.. image:: pics/bibleimportdetails1.png
Converting from OpenLP Version 1 is a simple process. First you will need to
locate your Version 1 Bibles.
After filling in the copyright details, OpenLP will start to import your Bible.
It may take some time to import your Bible so please be patient.
.. image:: pics/bibleimportfinished1.png
When the import has finished click :guilabel:`Finish` and you should be
ready to use your Bible in OpenLP.
Importing from openlp.org 1.x
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Importing Bibles from openlp.org 1.x is a simple process. First you will need to
locate your version 1.x Bibles. Version 1.x Bibles have the `.bible` file
extension.
Windows XP::
@ -44,22 +59,15 @@ Windows Vista / Windows 7::
C:\ProgramData\openlp.org\Data\Bibles\
OpenLP Version 1 Bibles have the `.bible` file extension. After selecting
all of the OpenLP Version 1 Bibles you want to convert, click :guilabel:`Next`
.. image:: pics/bibleimportdetails1.png
Enter your Bible name and copyright details. Click :guilabel:`Next`. It may
take some time to convert your Bibles so please be patient.
.. image:: pics/bibleimportfinished1.png
When the import has finished click :guilabel:`Finish` and you should be
ready to use your OpenLP Version 1 Bibles.
After selecting all of the openlp.org 1.x Bibles you want to convert, click
:guilabel:`Next` to continue the import process.
Importing OSIS Bibles
^^^^^^^^^^^^^^^^^^^^^
Importing OSIS files is very simple. Select OSIS as your import source, select
your OSIS Bible file and continue the import process.
**About OSIS Formatted Bibles**
The OSIS XML standard was designed to provide a common format for distribution
@ -69,24 +77,11 @@ of electronic Bibles. More information can be found out at the `Bible Technologi
If you have any software installed that is part of the `Sword Project
<http://www.crosswire.org/sword/index.jsp>`_ it can be easily converted.
Importing OSIS files is very simple. Select your OSIS Bible file and click
:guilabel:`Next`
.. image:: pics/bibleimportdetails1.png
Enter you Bible name and copyright details. Click :guilabel:`Next`. It may take
some time to convert your Bibles so please be patient.
.. image:: pics/bibleimportfinished1.png
Click :guilabel:`Finish` and you should be ready to use your OpenLP Version
1 Bibles.
You can use the commands below convert Bibles from that software to OSIS format.
The following commands are used in all platforms and the commands are case
sensitive across all platforms. To convert a Bible using Command Prompt in
Windows or a Terminal in Linux or MAC you would type::
sensitive across all platforms. To convert a Bible using the command prompt in
Windows or a terminal in Linux or Mac OS X you would type::
mod2osis biblename > biblename.osis
@ -114,17 +109,9 @@ You may also import downloaded bibles from OpenSong. The process is the same,
except you will need to extract the bible from a zip file. This is usually done
by right clicking on the downloaded file and select `Extract` or `Extract Here`.
After selecting the OpenSong Bibles you want to convert, click :guilabel:`Next`
.. image:: pics/bibleimportdetails1.png
Enter your Bible name and copyright details. Click :guilabel:`Next`. It may
take some time to convert your Bibles so please be patient.
.. image:: pics/bibleimportfinished1.png
When the import has finished then click :guilabel:`Finish` and you should now be
ready to use your OpenSong Bibles.
After selecting the OpenSong Bibles you want to import, follow the rest of the
import process. When the import has finished you should be ready to use your
OpenSong Bibles.
Importing Web Download Bibles
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -139,8 +126,6 @@ as another option and does require an internet connection.
To use the web download feature select web download from the import wizard.
.. image:: pics/bibleimport01.png
You can select from several options of location to download from and also
what Bible translation you need. You will probably want to choose the location
from where you get the best performance or has the translation you need.
@ -154,30 +139,20 @@ not be needed.
.. image:: pics/webbibleproxy1.png
After selecting your download location and the Bible you wish to use, click
:guilabel:`Next` When your import is completed click :guilabel:`Finish`
.. image:: pics/biblewebcomplete.png
You should now be ready to use the web bible.
:guilabel:`Next` to continue the import process. When your import is completed
you should now be ready to use the web bible.
Importing CSV formatted Bibles
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
If you have a Bible in .csv format OpenLP can import it. CSV Bibles will
consist of two files a `books` file and a `verse` file.
Select CSV from the list of Bible types to import.
.. image:: pics/bibleimport02.png
consist of two files a `books` file and a `verse` file. Select CSV from the list
of Bible types to import.
You are now ready to select your .csv files. You will need to select both your
books and verse file location.
.. image:: pics/csvimport1.png
After you have selected the file locations you can click :guilabel:`Next`
.. image:: pics/bibleimportfinished1.png
Click :guilabel:`Finish` and you should now be ready to use your imported CSV
Bible
After you have selected the file locations you can continue with the import
process. Once it is complete you should be ready to use your imported CSV Bible.

View File

@ -1,3 +1,5 @@
.. _dualmonitors:
==================
Dual Monitor Setup
==================
@ -32,6 +34,14 @@ projector hooked up to your computer as the second monitor. With the option of
extending your desktop across the second monitor, or your operating system's
equivalent.
**Special Note For Projectors Using USB Connections**
Users have reported experiencing difficulties when using a projector with a USB
connection, as third party software is often required to properly configure
dual monitors. If possible, it is best to use a direct output (VGA, DVI, HDMI,
S-Video) from your machine's video card. If a USB connection is your only option
please consult the manufacturer's manual for instructions on a proper setup.
Microsoft Windows
-----------------

Binary file not shown.

Before

Width:  |  Height:  |  Size: 29 KiB

After

Width:  |  Height:  |  Size: 61 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 37 KiB

After

Width:  |  Height:  |  Size: 50 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 36 KiB

After

Width:  |  Height:  |  Size: 52 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 22 KiB

After

Width:  |  Height:  |  Size: 34 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 60 KiB

After

Width:  |  Height:  |  Size: 81 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 22 KiB

After

Width:  |  Height:  |  Size: 35 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 28 KiB

After

Width:  |  Height:  |  Size: 44 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 24 KiB

After

Width:  |  Height:  |  Size: 36 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 29 KiB

After

Width:  |  Height:  |  Size: 43 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 45 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 37 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 61 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 45 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 29 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 45 KiB

View File

@ -99,4 +99,134 @@ completed.
Press :guilabel:`Finish` and OpenLP will be ready to use your songs imported
from CCLI SongSelect.
Creating or editing a song slide
================================
If you want to create a new song slide or, once you have a song imported, you
want to edit and rearrange the Title & Lyrics, Author, Topics & Song Book,
assign a Theme, or edit Copyright Info & Comments, you will do this through the
`Song Editor`.
**Edit:** To edit an existing song you can either click on a song in the
`Media Manager` and then click the button to :guilabel:`Edit the selected song`
or right click a song from either the `Media Manager` or additionally from the
`Service Manager` and click :guilabel:`Edit item`. If you are adding a new song
click :guilabel:`Add a new Song` in the `Media Manager`.
.. image:: pics/song_edit_lyrics.png
**Title:** This is where you would name your song or edit a song name.
**Alternate title:**Alternate Title was for songs with two names
"Lord the Light" - "Shine Jesus Shine". You can also add a name in this box that
will bring up the song in Titles search. **Example:** You could use an alternate
title of "hymn" on all your hymn song titles for grouping. When you search "hymn"
it will show all the hymns that have "hymn" for the Alternate title.
**Lyrics:** The *Lyrics* window shows all lyrics imported or added. On the left
side of the lyrics you will see a capital letter followed by a number. A V1
would represent verse 1, C1 would be Chorus 1. You will use these letters and
numbers for the order to display the lyrics.
**Verse Order:** After you entered or edited your song, you will want OpenLP to
display the verses in the correct order you want them displayed. On the left side
of your lyrics you will see C1, V1, V2 etc. the way they were imported or added.
To put your lyrics in the correct order is as simple as typing in the
:guilabel:`Verse order box` at the bottom, the correct order you want them
displayed, with only a blank space in between each entry. The correct format will
look like this: V1 C1 V2 C1 V3 C1. If you forget to put a space in between the
order, or if you do not have the corresponding verse number, OpenLP will politely
tell you with a pop-up error message what is wrong so you can correct your
mistake and save it. Verse order is optional and if left blank the verses will
display in the order seen in *Lyrics*.
.. image:: pics/song_edit_verse_error.png
Adding or editing the lyrics
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
**Add:** To Add a new verse, click on :guilabel:`Add`. The main window is where
you will type your lyrics. OpenLP is packaged with a spell checker for most
languages. If you misspell a word it will be underlined. Right click the
underlined word and left click *Spelling Suggestions* or you can ignore it and
continue typing. You also have the ability to format the font using *Formatting
Tags*. Highlight the word/words you want to format and right click the highlight.
Left click *Formatting Tags* and choose the format you want to apply to the font
and the format tags will be entered with your lyrics. These tags are not visible
when displayed. To remove the format, delete the tag on each end of the word or
sentence.
**Edit:** To edit an existing verse, click on the verse you wish to *Edit* then click on
:guilabel:`Edit`, make your changes and click :guilabel:`Save`.
**Edit All:** To edit the whole song at once, click on :guilabel:`Edit All`.
**Delete:** To delete a verse, click on the verse you want to delete and it will
highlight, click on the :guilabel:`Delete` button and it will be deleted.
**Warning:**, once you click the :guilabel:`Delete` button, you will not be
asked again, it will be deleted immediately.
.. image:: pics/song_edit_verse_type.png
**Verse type:** gives you 7 ways to classify your lyrics. Verse, Chorus, Bridge,
Pre-Chorus, Intro, Ending, Other.
If you have more than one verse, you would number them Verse 1, 2, 3 as needed.
If you find the verse has too many lines for your screen, you can edit and
shorten the verse and :guilabel:`Add` another slide.
Authors, Topics & Song Book
^^^^^^^^^^^^^^^^^^^^^^^^^^^
Once your *Title & Lyrics* are added or edited the way you want them you must
add or enter the author or authors of the song. OpenLP requires all songs to
have an author entered. You can add a blank space for the author name.
.. image:: pics/song_edit_authors.png
**Authors:** Click the drop down arrow to view all authors or start typing a name
in the box and a list will appear. If the authors name has not been added, type
the authors name in the box and click :guilabel:`Add to Song`. The authors name
will appear below and will also be added to your database. If you accidently add
the wrong author you can click on the authors name and click :guilabel:`Remove`.
:guilabel:`Manage Authors, Topics, Song Books`: Clicking this button will bring
up your complete list of authors.
.. image:: pics/song_edit_maintenance.png
**Add:** Clicking the :guilabel:`Add` button will bring up a box where you will
add the Authors First name, Last name and Display name. Click :guilabel:`Save`
when you are finished.
.. image:: pics/song_edit_author_maintenance.png
**Edit:** The :guilabel:`Edit` button will bring up window where you can edit
the info that is already there.
**Delete:** The :guilabel:`Delete` button will remove the author you have
highlighted. Note: You cannot delete an author that is assigned to a song.
Authors names are displayed in the footer.
Theme, Copyright info & Comments
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
On this tab you can assign a *Theme* to a song, enter the *Copyright information*
and add the *CCLI number*. If you imported a song from SongSelect this
information will usually be entered.
.. image:: pics/song_edit_theme_copyright.png
**Theme:** Click the drop down arrow to display your list of themes or start
typing a theme name in the box and the list will appear. You can also create a
new theme by clicking the :guilabel:`New Theme` button.
**Copyright information:** Add or edit the copyright information in this box. If
you would like to use the © symbol click "guilabel:`©` button. This information
is displayed in the footer.
**CCLI number:** Enter the CCLI number in this box. Note: this is the CCLI number
of the song, not your contract number. This number is not displayed in the footer
**Comments:** You can add comments in this box. This information is not
dispayed in the footer.

View File

@ -175,3 +175,23 @@ only download the section you search for. If you do not have an internet
connection where you intend to use OpenLP you will need another scripture
source. For more information about acquiring Bibles please see :ref:`bibleimporter`.
OpenLP is using a large amount of RAM when showing a presentation
-----------------------------------------------------------------
OpenLP uses a large amount of RAM when showing a presentation due to the way it
handles presentations. OpenLP itself is unable to show those presentations or
load the presentation files, so it interacts with the presentation through
either Microsoft PowerPoint or LibreOffice Impress. In order to show the slides
in the slide controller, OpenLP requests that the presentation application
export the slides to images, and then uses those images as slides. This results
in a large amount of RAM being used, especially in presentations with more than
about 20 slides.
OpenLP is not displaying correctly, or is not on the correct screen
-------------------------------------------------------------------
Please read the documentation on :ref:`dualmonitors`. It is very important to
have dual monitors setup properly for OpenLP to function as expected.

View File

@ -116,7 +116,7 @@ class OpenLP(QtGui.QApplication):
self.processEvents()
# start the main app window
self.mainWindow = MainWindow(screens, self.clipboard(),
self.arguments())
self.arguments())
self.mainWindow.show()
if show_splash:
# now kill the splashscreen
@ -140,7 +140,7 @@ class OpenLP(QtGui.QApplication):
self.sharedMemory = QtCore.QSharedMemory('OpenLP')
if self.sharedMemory.attach():
status = QtGui.QMessageBox.critical(None,
UiStrings.Error, UiStrings.OpenLPStart,
UiStrings().Error, UiStrings().OpenLPStart,
QtGui.QMessageBox.StandardButtons(
QtGui.QMessageBox.Yes | QtGui.QMessageBox.No))
if status == QtGui.QMessageBox.No:
@ -250,4 +250,4 @@ if __name__ == u'__main__':
"""
Instantiate and run the application.
"""
main()
main()

View File

@ -166,58 +166,6 @@ def build_icon(icon):
QtGui.QIcon.Normal, QtGui.QIcon.Off)
return button_icon
def context_menu_action(base, icon, text, slot, shortcuts=None):
"""
Utility method to help build context menus for plugins
``base``
The parent menu to add this menu item to
``icon``
An icon for this action
``text``
The text to display for this action
``slot``
The code to run when this action is triggered
"""
action = QtGui.QAction(text, base)
if icon:
action.setIcon(build_icon(icon))
QtCore.QObject.connect(action, QtCore.SIGNAL(u'triggered()'), slot)
if shortcuts:
action.setShortcuts(shortcuts)
return action
def context_menu(base, icon, text):
"""
Utility method to help build context menus for plugins
``base``
The parent object to add this menu to
``icon``
An icon for this menu
``text``
The text to display for this menu
"""
action = QtGui.QMenu(text, base)
action.setIcon(build_icon(icon))
return action
def context_menu_separator(base):
"""
Add a separator to a context menu
``base``
The menu object to add the separator to
"""
action = QtGui.QAction(u'', base)
action.setSeparator(True)
return action
def image_to_byte(image):
"""
Resize an image to fit on the current screen for the web and returns
@ -326,8 +274,8 @@ def check_directory_exists(dir):
from listwidgetwithdnd import ListWidgetWithDnD
from displaytags import DisplayTags
from spelltextedit import SpellTextEdit
from eventreceiver import Receiver
from spelltextedit import SpellTextEdit
from imagemanager import ImageManager
from settingsmanager import SettingsManager
from plugin import PluginStatus, StringContent, Plugin
@ -343,3 +291,4 @@ from dockwidget import OpenLPDockWidget
from renderer import Renderer
from rendermanager import RenderManager
from mediamanageritem import MediaManagerItem
from openlp.core.utils.actions import ActionList

View File

@ -307,7 +307,7 @@ sup {
</head>
<body>
<img id="bgimage" class="size" %s />
<img id="image" class="size" style="display:none" />
<img id="image" class="size" %s />
<video id="video1" class="size" style="visibility:hidden" autobuffer preload>
</video>
<video id="video2" class="size" style="visibility:hidden" autobuffer preload>
@ -320,7 +320,7 @@ sup {
</html>
"""
def build_html(item, screen, alert, islive, background):
def build_html(item, screen, alert, islive, background, image=None):
"""
Build the full web paged structure for display
@ -332,6 +332,10 @@ def build_html(item, screen, alert, islive, background):
Alert display display information
`islive`
Item is going live, rather than preview/theme building
`background`
Theme background image - bytes
`image`
Image media item - bytes
"""
width = screen[u'size'].width()
height = screen[u'size'].height()
@ -339,11 +343,15 @@ def build_html(item, screen, alert, islive, background):
webkitvers = webkit_version()
# Image generated and poked in
if background:
image = u'src="data:image/png;base64,%s"' % background
bgimage_src = u'src="data:image/png;base64,%s"' % background
elif item.bg_image_bytes:
image = u'src="data:image/png;base64,%s"' % item.bg_image_bytes
bgimage_src = u'src="data:image/png;base64,%s"' % item.bg_image_bytes
else:
image = u'style="display:none;"'
bgimage_src = u'style="display:none;"'
if image:
image_src = u'src="data:image/png;base64,%s"' % image
else:
image_src = u'style="display:none;"'
html = HTMLSRC % (build_background_css(item, width, height),
width, height,
build_alert_css(alert, width),
@ -351,7 +359,7 @@ def build_html(item, screen, alert, islive, background):
build_lyrics_css(item, webkitvers),
u'true' if theme and theme.display_slide_transition and islive \
else u'false',
image,
bgimage_src, image_src,
build_lyrics_html(item, webkitvers))
return html
@ -452,7 +460,7 @@ def build_lyrics_css(item, webkitvers):
.lyricsshadow {
%s
}
"""
"""
theme = item.themedata
lyricstable = u''
lyrics = u''
@ -460,8 +468,7 @@ def build_lyrics_css(item, webkitvers):
outline = u''
shadow = u''
if theme and item.main:
lyricstable = u'left: %spx; top: %spx;' % \
(item.main.x(), item.main.y())
lyricstable = u'left: %spx; top: %spx;' % (item.main.x(), item.main.y())
lyrics = build_lyrics_format_css(theme, item.main.width(),
item.main.height())
# For performance reasons we want to show as few DIV's as possible,

View File

@ -31,10 +31,10 @@ import os
from PyQt4 import QtCore, QtGui
from openlp.core.lib import context_menu_action, context_menu_separator, \
SettingsManager, OpenLPToolbar, ServiceItem, StringContent, build_icon, \
translate, Receiver, ListWidgetWithDnD
from openlp.core.lib.ui import UiStrings
from openlp.core.lib import SettingsManager, OpenLPToolbar, ServiceItem, \
StringContent, build_icon, translate, Receiver, ListWidgetWithDnD
from openlp.core.lib.ui import UiStrings, context_menu_action, \
context_menu_separator
log = logging.getLogger(__name__)
@ -260,39 +260,42 @@ class MediaManagerItem(QtGui.QWidget):
context_menu_action(
self.listView, u':/general/general_edit.png',
self.plugin.getString(StringContent.Edit)[u'title'],
self.onEditClick))
self.onEditClick, context=QtCore.Qt.WidgetShortcut))
self.listView.addAction(context_menu_separator(self.listView))
if self.hasDeleteIcon:
self.listView.addAction(
context_menu_action(
self.listView, u':/general/general_delete.png',
self.plugin.getString(StringContent.Delete)[u'title'],
self.onDeleteClick, [QtCore.Qt.Key_Delete]))
self.onDeleteClick, [QtCore.Qt.Key_Delete],
context=QtCore.Qt.WidgetShortcut))
self.listView.addAction(context_menu_separator(self.listView))
self.listView.addAction(
context_menu_action(
self.listView, u':/general/general_preview.png',
self.plugin.getString(StringContent.Preview)[u'title'],
self.onPreviewClick, [QtCore.Qt.Key_Enter]))
self.onPreviewClick, [QtCore.Qt.Key_Enter,
QtCore.Qt.Key_Return], context=QtCore.Qt.WidgetShortcut))
self.listView.addAction(
context_menu_action(
self.listView, u':/general/general_live.png',
self.plugin.getString(StringContent.Live)[u'title'],
self.onLiveClick, [QtCore.Qt.ShiftModifier + \
QtCore.Qt.Key_Enter, QtCore.Qt.ShiftModifier + \
QtCore.Qt.Key_Return]))
QtCore.Qt.Key_Return], context=QtCore.Qt.WidgetShortcut))
self.listView.addAction(
context_menu_action(
self.listView, u':/general/general_add.png',
self.plugin.getString(StringContent.Service)[u'title'],
self.onAddClick, [QtCore.Qt.Key_Plus, QtCore.Qt.Key_Equal]))
self.onAddClick, [QtCore.Qt.Key_Plus, QtCore.Qt.Key_Equal],
context=QtCore.Qt.WidgetShortcut))
if self.addToServiceItem:
self.listView.addAction(
context_menu_action(
self.listView, u':/general/general_add.png',
translate('OpenLP.MediaManagerItem',
'&Add to selected Service Item'),
self.onAddEditClick))
self.onAddEditClick, context=QtCore.Qt.WidgetShortcut))
QtCore.QObject.connect(self.listView,
QtCore.SIGNAL(u'doubleClicked(QModelIndex)'),
self.onClickPressed)
@ -432,7 +435,7 @@ class MediaManagerItem(QtGui.QWidget):
item to the preview slide controller.
"""
if not self.listView.selectedIndexes() and not self.remoteTriggered:
QtGui.QMessageBox.information(self, UiStrings.NISp,
QtGui.QMessageBox.information(self, UiStrings().NISp,
translate('OpenLP.MediaManagerItem',
'You must select one or more items to preview.'))
else:
@ -450,7 +453,7 @@ class MediaManagerItem(QtGui.QWidget):
item to the live slide controller.
"""
if not self.listView.selectedIndexes():
QtGui.QMessageBox.information(self, UiStrings.NISp,
QtGui.QMessageBox.information(self, UiStrings().NISp,
translate('OpenLP.MediaManagerItem',
'You must select one or more items to send live.'))
else:
@ -465,7 +468,7 @@ class MediaManagerItem(QtGui.QWidget):
Add a selected item to the current service
"""
if not self.listView.selectedIndexes() and not self.remoteTriggered:
QtGui.QMessageBox.information(self, UiStrings.NISp,
QtGui.QMessageBox.information(self, UiStrings().NISp,
translate('OpenLP.MediaManagerItem',
'You must select one or more items.'))
else:
@ -491,14 +494,14 @@ class MediaManagerItem(QtGui.QWidget):
Add a selected item to an existing item in the current service.
"""
if not self.listView.selectedIndexes() and not self.remoteTriggered:
QtGui.QMessageBox.information(self, UiStrings.NISp,
QtGui.QMessageBox.information(self, UiStrings().NISp,
translate('OpenLP.MediaManagerItem',
'You must select one or more items.'))
else:
log.debug(u'%s Add requested', self.plugin.name)
serviceItem = self.parent.serviceManager.getServiceItem()
if not serviceItem:
QtGui.QMessageBox.information(self, UiStrings.NISs,
QtGui.QMessageBox.information(self, UiStrings().NISs,
translate('OpenLP.MediaManagerItem',
'You must select an existing service item to add to.'))
elif self.plugin.name.lower() == serviceItem.name.lower():
@ -551,4 +554,4 @@ class MediaManagerItem(QtGui.QWidget):
item_id = remoteItem
else:
item_id = (item.data(QtCore.Qt.UserRole)).toInt()[0]
return item_id
return item_id

View File

@ -115,8 +115,8 @@ class Plugin(QtCore.QObject):
"""
log.info(u'loaded')
def __init__(self, name, pluginHelpers=None, mediaItemClass=None,
settingsTabClass=None, version=None):
def __init__(self, name, plugin_helpers=None, media_item_class=None,
settings_tab_class=None, version=None):
"""
This is the constructor for the plugin object. This provides an easy
way for descendent plugins to populate common data. This method *must*
@ -132,15 +132,16 @@ class Plugin(QtCore.QObject):
``version``
Defaults to *None*. The version of the plugin.
``pluginHelpers``
``plugin_helpers``
Defaults to *None*. A list of helper objects.
``mediaItemClass``
``media_item_class``
The class name of the plugin's media item.
``settingsTabClass``
``settings_tab_class``
The class name of the plugin's settings tab.
"""
log.debug(u'Plugin %s initialised' % name)
QtCore.QObject.__init__(self)
self.name = name
self.textStrings = {}
@ -152,20 +153,20 @@ class Plugin(QtCore.QObject):
self.version = get_application_version()[u'version']
self.settingsSection = self.name.lower()
self.icon = None
self.mediaItemClass = mediaItemClass
self.settingsTabClass = settingsTabClass
self.media_item_class = media_item_class
self.settings_tab_class = settings_tab_class
self.weight = 0
self.status = PluginStatus.Inactive
# Set up logging
self.log = logging.getLogger(self.name)
self.previewController = pluginHelpers[u'preview']
self.liveController = pluginHelpers[u'live']
self.renderManager = pluginHelpers[u'render']
self.serviceManager = pluginHelpers[u'service']
self.settingsForm = pluginHelpers[u'settings form']
self.mediadock = pluginHelpers[u'toolbox']
self.pluginManager = pluginHelpers[u'pluginmanager']
self.formparent = pluginHelpers[u'formparent']
self.previewController = plugin_helpers[u'preview']
self.liveController = plugin_helpers[u'live']
self.renderManager = plugin_helpers[u'render']
self.serviceManager = plugin_helpers[u'service']
self.settingsForm = plugin_helpers[u'settings form']
self.mediadock = plugin_helpers[u'toolbox']
self.pluginManager = plugin_helpers[u'pluginmanager']
self.formparent = plugin_helpers[u'formparent']
QtCore.QObject.connect(Receiver.get_receiver(),
QtCore.SIGNAL(u'%s_add_service_item' % self.name),
self.processAddServiceEvent)
@ -212,8 +213,8 @@ class Plugin(QtCore.QObject):
Construct a MediaManagerItem object with all the buttons and things
you need, and return it for integration into openlp.org.
"""
if self.mediaItemClass:
return self.mediaItemClass(self, self, self.icon)
if self.media_item_class:
return self.media_item_class(self, self, self.icon)
return None
def addImportMenuItem(self, importMenu):
@ -243,14 +244,15 @@ class Plugin(QtCore.QObject):
"""
pass
def getSettingsTab(self):
def getSettingsTab(self, parent):
"""
Create a tab for the settings window to display the configurable
options for this plugin to the user.
"""
if self.settingsTabClass:
return self.settingsTabClass(self.name,
self.getString(StringContent.VisibleName)[u'title'])
if self.settings_tab_class:
return self.settings_tab_class(parent, self.name,
self.getString(StringContent.VisibleName)[u'title'],
self.icon_path)
return None
def addToMenu(self, menubar):
@ -287,31 +289,14 @@ class Plugin(QtCore.QObject):
"""
if self.mediaItem:
self.mediaItem.initialise()
self.insertToolboxItem()
self.mediadock.insert_dock(self.mediaItem, self.icon, self.weight)
def finalise(self):
"""
Called by the plugin Manager to cleanup things.
"""
self.removeToolboxItem()
def removeToolboxItem(self):
"""
Called by the plugin to remove toolbar
"""
if self.mediaItem:
self.mediadock.remove_dock(self.mediaItem)
if self.settings_tab:
self.settingsForm.removeTab(self.settings_tab)
def insertToolboxItem(self):
"""
Called by plugin to replace toolbar
"""
if self.mediaItem:
self.mediadock.insert_dock(self.mediaItem, self.icon, self.weight)
if self.settings_tab:
self.settingsForm.insertTab(self.settings_tab, self.weight)
def usesTheme(self, theme):
"""
@ -345,28 +330,28 @@ class Plugin(QtCore.QObject):
"""
## Load Action ##
self.__setNameTextString(StringContent.Load,
UiStrings.Load, tooltips[u'load'])
UiStrings().Load, tooltips[u'load'])
## Import Action ##
self.__setNameTextString(StringContent.Import,
UiStrings.Import, tooltips[u'import'])
UiStrings().Import, tooltips[u'import'])
## New Action ##
self.__setNameTextString(StringContent.New,
UiStrings.Add, tooltips[u'new'])
UiStrings().Add, tooltips[u'new'])
## Edit Action ##
self.__setNameTextString(StringContent.Edit,
UiStrings.Edit, tooltips[u'edit'])
UiStrings().Edit, tooltips[u'edit'])
## Delete Action ##
self.__setNameTextString(StringContent.Delete,
UiStrings.Delete, tooltips[u'delete'])
UiStrings().Delete, tooltips[u'delete'])
## Preview Action ##
self.__setNameTextString(StringContent.Preview,
UiStrings.Preview, tooltips[u'preview'])
UiStrings().Preview, tooltips[u'preview'])
## Send Live Action ##
self.__setNameTextString(StringContent.Live,
UiStrings.Live, tooltips[u'live'])
UiStrings().Live, tooltips[u'live'])
## Add to Service Action ##
self.__setNameTextString(StringContent.Service,
UiStrings.Service, tooltips[u'service'])
UiStrings().Service, tooltips[u'service'])
def __setNameTextString(self, name, title, tooltip):
"""
@ -374,4 +359,4 @@ class Plugin(QtCore.QObject):
use of the singular name of the plugin object so must only be called
after this has been set.
"""
self.textStrings[name] = {u'title': title, u'tooltip': tooltip}
self.textStrings[name] = {u'title': title, u'tooltip': tooltip}

View File

@ -137,7 +137,7 @@ class PluginManager(object):
if plugin.status is not PluginStatus.Disabled:
plugin.mediaItem = plugin.getMediaManagerItem()
def hook_settings_tabs(self, settingsform=None):
def hook_settings_tabs(self, settings_form=None):
"""
Loop through all the plugins. If a plugin has a valid settings tab
item, add it to the settings tab.
@ -148,16 +148,8 @@ class PluginManager(object):
"""
for plugin in self.plugins:
if plugin.status is not PluginStatus.Disabled:
plugin.settings_tab = plugin.getSettingsTab()
visible_title = plugin.getString(StringContent.VisibleName)
if plugin.settings_tab:
log.debug(u'Inserting settings tab item from %s' %
visible_title[u'title'])
settingsform.addTab(visible_title[u'title'],
plugin.settings_tab)
else:
log.debug(
u'No tab settings in %s' % visible_title[u'title'])
plugin.settings_tab = plugin.getSettingsTab(settings_form)
settings_form.plugins = self.plugins
def hook_import_menu(self, import_menu):
"""
@ -207,8 +199,6 @@ class PluginManager(object):
if plugin.isActive():
plugin.initialise()
log.info(u'Initialisation Complete for %s ' % plugin.name)
if not plugin.isActive():
plugin.removeToolboxItem()
log.info(u'Initialise Plugins - Finished')
def finalise_plugins(self):

View File

@ -29,6 +29,7 @@ import logging
from PyQt4 import QtCore, QtGui
from openlp.core.lib import build_icon
from openlp.core.lib.ui import icon_action
log = logging.getLogger(__name__)
@ -109,6 +110,21 @@ class SearchEdit(QtGui.QLineEdit):
"""
return self._currentSearchType
def setCurrentSearchType(self, identifier):
"""
Set a new current search type.
``identifier``
The search type identifier (int).
"""
menu = self.menuButton.menu()
for action in menu.actions():
if identifier == action.data().toInt()[0]:
self.menuButton.setDefaultAction(action)
self._currentSearchType = identifier
self.emit(QtCore.SIGNAL(u'searchTypeChanged(int)'), identifier)
return True
def setSearchTypes(self, items):
"""
A list of tuples to be used in the search type menu. The first item in
@ -132,7 +148,8 @@ class SearchEdit(QtGui.QLineEdit):
menu = QtGui.QMenu(self)
first = None
for identifier, icon, title in items:
action = QtGui.QAction(build_icon(icon), title, menu)
action = icon_action(menu, u'', icon)
action.setText(title)
action.setData(QtCore.QVariant(identifier))
menu.addAction(action)
QtCore.QObject.connect(action, QtCore.SIGNAL(u'triggered(bool)'),

View File

@ -441,10 +441,10 @@ class ServiceItem(object):
start = None
end = None
if self.start_time != 0:
start = UiStrings.StartTimeCode % \
start = UiStrings().StartTimeCode % \
unicode(datetime.timedelta(seconds=self.start_time))
if self.media_length != 0:
end = UiStrings.LengthTime % \
end = UiStrings().LengthTime % \
unicode(datetime.timedelta(seconds=self.media_length))
if not start and not end:
return None
@ -453,4 +453,4 @@ class ServiceItem(object):
elif not start and end:
return end
else:
return u'%s : %s' % (start, end)
return u'%s : %s' % (start, end)

View File

@ -31,7 +31,7 @@ class SettingsTab(QtGui.QWidget):
SettingsTab is a helper widget for plugins to define Tabs for the settings
dialog.
"""
def __init__(self, title, visible_title=None):
def __init__(self, parent, title, visible_title=None, icon_path=None):
"""
Constructor to create the Settings tab item.
@ -41,10 +41,12 @@ class SettingsTab(QtGui.QWidget):
``visible_title``
The title of the tab, which is usually displayed on the tab.
"""
QtGui.QWidget.__init__(self)
QtGui.QWidget.__init__(self, parent)
self.tabTitle = title
self.tabTitleVisible = visible_title
self.settingsSection = self.tabTitle.lower()
if icon_path:
self.icon_path = icon_path
self.setupUi()
self.retranslateUi()
self.initialise()

View File

@ -36,7 +36,9 @@ except ImportError:
# http://john.nachtimwald.com/2009/08/22/qplaintextedit-with-in-line-spell-check
from PyQt4 import QtCore, QtGui
from openlp.core.lib import translate, DisplayTags
from openlp.core.lib.ui import checkable_action
log = logging.getLogger(__name__)
@ -80,6 +82,19 @@ class SpellTextEdit(QtGui.QPlainTextEdit):
if not cursor.hasSelection():
cursor.select(QtGui.QTextCursor.WordUnderCursor)
self.setTextCursor(cursor)
# Add menu with available languages.
if ENCHANT_AVAILABLE:
lang_menu = QtGui.QMenu(
translate('OpenLP.SpellTextEdit', 'Language:'))
for lang in enchant.list_languages():
action = checkable_action(
lang_menu, lang, lang == self.dictionary.tag)
action.setText(lang)
lang_menu.addAction(action)
popupMenu.insertSeparator(popupMenu.actions()[0])
popupMenu.insertMenu(popupMenu.actions()[0], lang_menu)
QtCore.QObject.connect(lang_menu,
QtCore.SIGNAL(u'triggered(QAction*)'), self.setLanguage)
# Check if the selected word is misspelled and offer spelling
# suggestions if it is.
if ENCHANT_AVAILABLE and self.textCursor().hasSelection():
@ -93,19 +108,30 @@ class SpellTextEdit(QtGui.QPlainTextEdit):
spell_menu.addAction(action)
# Only add the spelling suggests to the menu if there are
# suggestions.
if len(spell_menu.actions()) != 0:
popupMenu.insertSeparator(popupMenu.actions()[0])
if len(spell_menu.actions()):
popupMenu.insertMenu(popupMenu.actions()[0], spell_menu)
tagMenu = QtGui.QMenu(translate('OpenLP.SpellTextEdit',
'Formatting Tags'))
for html in DisplayTags.get_html_tags():
action = SpellAction( html[u'desc'], tagMenu)
action = SpellAction(html[u'desc'], tagMenu)
action.correct.connect(self.htmlTag)
tagMenu.addAction(action)
popupMenu.insertSeparator(popupMenu.actions()[0])
popupMenu.insertMenu(popupMenu.actions()[0], tagMenu)
popupMenu.exec_(event.globalPos())
def setLanguage(self, action):
"""
Changes the language for this spelltextedit.
``action``
The action.
"""
self.dictionary = enchant.Dict(action.text())
self.highlighter.spellingDictionary = self.dictionary
self.highlighter.highlightBlock(self.toPlainText())
self.highlighter.rehighlight()
def correctWord(self, word):
"""
Replaces the selected text with word.

View File

@ -192,7 +192,7 @@ class VerticalType(object):
Bottom = 2
Names = [u'top', u'middle', u'bottom']
TranslatedNames = [UiStrings.Top, UiStrings.Middle, UiStrings.Bottom]
TranslatedNames = [UiStrings().Top, UiStrings().Middle, UiStrings().Bottom]
BOOLEAN_LIST = [u'bold', u'italics', u'override', u'outline', u'shadow',

View File

@ -51,8 +51,7 @@ class OpenLPToolbar(QtGui.QToolBar):
log.debug(u'Init done for %s' % parent.__class__.__name__)
def addToolbarButton(self, title, icon, tooltip=None, slot=None,
checkable=False, shortcut=0, alternate=0,
context=QtCore.Qt.WidgetShortcut):
checkable=False, shortcuts=None, context=QtCore.Qt.WidgetShortcut):
"""
A method to help developers easily add a button to the toolbar.
@ -74,16 +73,12 @@ class OpenLPToolbar(QtGui.QToolBar):
If *True* the button has two, *off* and *on*, states. Default is
*False*, which means the buttons has only one state.
``shortcut``
The primary shortcut for this action
``alternate``
The alternate shortcut for this action
``shortcuts``
The list of shortcuts for this action
``context``
Specify the context in which this shortcut is valid
"""
newAction = None
if icon:
actionIcon = build_icon(icon)
if slot and not checkable:
@ -92,7 +87,7 @@ class OpenLPToolbar(QtGui.QToolBar):
newAction = self.addAction(actionIcon, title)
self.icons[title] = actionIcon
else:
newAction = QtGui.QAction(title, newAction)
newAction = QtGui.QAction(title, self)
self.addAction(newAction)
QtCore.QObject.connect(newAction,
QtCore.SIGNAL(u'triggered()'), slot)
@ -103,8 +98,9 @@ class OpenLPToolbar(QtGui.QToolBar):
QtCore.QObject.connect(newAction,
QtCore.SIGNAL(u'toggled(bool)'), slot)
self.actions[title] = newAction
newAction.setShortcuts([shortcut, alternate])
newAction.setShortcutContext(context)
if shortcuts is not None:
newAction.setShortcuts(shortcuts)
newAction.setShortcutContext(context)
return newAction
def addToolbarSeparator(self, handle):

View File

@ -31,6 +31,7 @@ import logging
from PyQt4 import QtCore, QtGui
from openlp.core.lib import build_icon, Receiver, translate
from openlp.core.utils.actions import ActionList
log = logging.getLogger(__name__)
@ -38,67 +39,96 @@ class UiStrings(object):
"""
Provide standard strings for objects to use.
"""
# These strings should need a good reason to be retranslated elsewhere.
# Should some/more/less of these have an &amp; attached?
About = translate('OpenLP.Ui', 'About')
Add = translate('OpenLP.Ui', '&Add')
Advanced = translate('OpenLP.Ui', 'Advanced')
AllFiles = translate('OpenLP.Ui', 'All Files')
Bottom = translate('OpenLP.Ui', 'Bottom')
Browse = translate('OpenLP.Ui', 'Browse...')
Cancel = translate('OpenLP.Ui', 'Cancel')
CCLINumberLabel = translate('OpenLP.Ui', 'CCLI number:')
CreateService = translate('OpenLP.Ui', 'Create a new service.')
Default = unicode(translate('OpenLP.Ui', 'Default'))
Delete = translate('OpenLP.Ui', '&Delete')
Edit = translate('OpenLP.Ui', '&Edit')
EmptyField = translate('OpenLP.Ui', 'Empty Field')
Error = translate('OpenLP.Ui', 'Error')
Export = translate('OpenLP.Ui', 'Export')
FontSizePtUnit = translate('OpenLP.Ui', 'pt',
'Abbreviated font pointsize unit')
Hours = translate('OpenLP.Ui', 'h', 'The abbreviated unit for hours')
Image = translate('OpenLP.Ui', 'Image')
Import = translate('OpenLP.Ui', 'Import')
LengthTime = unicode(translate('OpenLP.Ui', 'Length %s'))
Live = translate('OpenLP.Ui', 'Live')
LiveBGError = translate('OpenLP.Ui', 'Live Background Error')
LivePanel = translate('OpenLP.Ui', 'Live Panel')
Load = translate('OpenLP.Ui', 'Load')
Minutes = translate('OpenLP.Ui', 'm', 'The abbreviated unit for minutes')
Middle = translate('OpenLP.Ui', 'Middle')
New = translate('OpenLP.Ui', 'New')
NewService = translate('OpenLP.Ui', 'New Service')
NewTheme = translate('OpenLP.Ui', 'New Theme')
NFSs = translate('OpenLP.Ui', 'No File Selected', 'Singular')
NFSp = translate('OpenLP.Ui', 'No Files Selected', 'Plural')
NISs = translate('OpenLP.Ui', 'No Item Selected', 'Singular')
NISp = translate('OpenLP.Ui', 'No Items Selected', 'Plural')
OLPV1 = translate('OpenLP.Ui', 'openlp.org 1.x')
OLPV2 = translate('OpenLP.Ui', 'OpenLP 2.0')
OpenFile = translate('OpenLP.Ui', 'Open File')
OpenLPStart = translate('OpenLP.Ui', 'OpenLP is already running. Do you '
'wish to continue?')
OpenService = translate('OpenLP.Ui', 'Open Service')
Preview = translate('OpenLP.Ui', 'Preview')
PreviewPanel = translate('OpenLP.Ui', 'Preview Panel')
PrintServiceOrder = translate('OpenLP.Ui', 'Print Service Order')
ReplaceBG = translate('OpenLP.Ui', 'Replace Background')
ReplaceLiveBG = translate('OpenLP.Ui', 'Replace Live Background')
ResetBG = translate('OpenLP.Ui', 'Reset Background')
ResetLiveBG = translate('OpenLP.Ui', 'Reset Live Background')
Seconds = translate('OpenLP.Ui', 's', 'The abbreviated unit for seconds')
SaveAndPreview = translate('OpenLP.Ui', 'Save && Preview')
Search = translate('OpenLP.Ui', 'Search')
SelectDelete = translate('OpenLP.Ui', 'You must select an item to delete.')
SelectEdit = translate('OpenLP.Ui', 'You must select an item to edit.')
SaveService = translate('OpenLP.Ui', 'Save Service')
Service = translate('OpenLP.Ui', 'Service')
StartTimeCode = unicode(translate('OpenLP.Ui', 'Start %s'))
Theme = translate('OpenLP.Ui', 'Theme', 'Singular')
Themes = translate('OpenLP.Ui', 'Themes', 'Plural')
Top = translate('OpenLP.Ui', 'Top')
Version = translate('OpenLP.Ui', 'Version')
__instance__ = None
def __new__(cls):
"""
Override the default object creation method to return a single instance.
"""
if not cls.__instance__:
cls.__instance__ = object.__new__(cls)
return cls.__instance__
def __init__(self):
"""
These strings should need a good reason to be retranslated elsewhere.
Should some/more/less of these have an &amp; attached?
"""
self.About = translate('OpenLP.Ui', 'About')
self.Add = translate('OpenLP.Ui', '&Add')
self.Advanced = translate('OpenLP.Ui', 'Advanced')
self.AllFiles = translate('OpenLP.Ui', 'All Files')
self.Bottom = translate('OpenLP.Ui', 'Bottom')
self.Browse = translate('OpenLP.Ui', 'Browse...')
self.Cancel = translate('OpenLP.Ui', 'Cancel')
self.CCLINumberLabel = translate('OpenLP.Ui', 'CCLI number:')
self.CreateService = translate('OpenLP.Ui', 'Create a new service.')
self.Continuous = translate('OpenLP.Ui', 'Continuous')
self.Default = unicode(translate('OpenLP.Ui', 'Default'))
self.Delete = translate('OpenLP.Ui', '&Delete')
self.DisplayStyle = translate('OpenLP.Ui', 'Display style:')
self.Edit = translate('OpenLP.Ui', '&Edit')
self.EmptyField = translate('OpenLP.Ui', 'Empty Field')
self.Error = translate('OpenLP.Ui', 'Error')
self.Export = translate('OpenLP.Ui', 'Export')
self.File = translate('OpenLP.Ui', 'File')
self.FontSizePtUnit = translate('OpenLP.Ui', 'pt',
'Abbreviated font pointsize unit')
self.Help = translate('OpenLP.Ui', 'Help')
self.Hours = translate('OpenLP.Ui', 'h',
'The abbreviated unit for hours')
self.Image = translate('OpenLP.Ui', 'Image')
self.Import = translate('OpenLP.Ui', 'Import')
self.LayoutStyle = translate('OpenLP.Ui', 'Layout style:')
self.LengthTime = unicode(translate('OpenLP.Ui', 'Length %s'))
self.Live = translate('OpenLP.Ui', 'Live')
self.LiveBGError = translate('OpenLP.Ui', 'Live Background Error')
self.LivePanel = translate('OpenLP.Ui', 'Live Panel')
self.LiveToolbar = translate('OpenLP.Ui', 'Live Toolbar')
self.Load = translate('OpenLP.Ui', 'Load')
self.Minutes = translate('OpenLP.Ui', 'm',
'The abbreviated unit for minutes')
self.Middle = translate('OpenLP.Ui', 'Middle')
self.New = translate('OpenLP.Ui', 'New')
self.NewService = translate('OpenLP.Ui', 'New Service')
self.NewTheme = translate('OpenLP.Ui', 'New Theme')
self.NFSs = translate('OpenLP.Ui', 'No File Selected', 'Singular')
self.NFSp = translate('OpenLP.Ui', 'No Files Selected', 'Plural')
self.NISs = translate('OpenLP.Ui', 'No Item Selected', 'Singular')
self.NISp = translate('OpenLP.Ui', 'No Items Selected', 'Plural')
self.OLPV1 = translate('OpenLP.Ui', 'openlp.org 1.x')
self.OLPV2 = translate('OpenLP.Ui', 'OpenLP 2.0')
self.OpenLPStart = translate('OpenLP.Ui', 'OpenLP is already running. '
'Do you wish to continue?')
self.OpenService = translate('OpenLP.Ui', 'Open Service')
self.Preview = translate('OpenLP.Ui', 'Preview')
self.PreviewPanel = translate('OpenLP.Ui', 'Preview Panel')
self.PrintServiceOrder = translate('OpenLP.Ui', 'Print Service Order')
self.ReplaceBG = translate('OpenLP.Ui', 'Replace Background')
self.ReplaceLiveBG = translate('OpenLP.Ui', 'Replace Live Background')
self.ResetBG = translate('OpenLP.Ui', 'Reset Background')
self.ResetLiveBG = translate('OpenLP.Ui', 'Reset Live Background')
self.Seconds = translate('OpenLP.Ui', 's',
'The abbreviated unit for seconds')
self.SaveAndPreview = translate('OpenLP.Ui', 'Save && Preview')
self.Search = translate('OpenLP.Ui', 'Search')
self.SelectDelete = translate('OpenLP.Ui', 'You must select an item '
'to delete.')
self.SelectEdit = translate('OpenLP.Ui', 'You must select an item to '
'edit.')
self.Settings = translate('OpenLP.Ui', 'Settings')
self.SaveService = translate('OpenLP.Ui', 'Save Service')
self.Service = translate('OpenLP.Ui', 'Service')
self.StartTimeCode = unicode(translate('OpenLP.Ui', 'Start %s'))
self.Theme = translate('OpenLP.Ui', 'Theme', 'Singular')
self.Themes = translate('OpenLP.Ui', 'Themes', 'Plural')
self.Tools = translate('OpenLP.Ui', 'Tools')
self.Top = translate('OpenLP.Ui', 'Top')
self.VersePerSlide = translate('OpenLP.Ui', 'Verse Per Slide')
self.VersePerLine = translate('OpenLP.Ui', 'Verse Per Line')
self.Version = translate('OpenLP.Ui', 'Version')
self.View = translate('OpenLP.Ui', 'View')
self.ViewMode = translate('OpenLP.Ui', 'View Model')
def add_welcome_page(parent, image):
"""
@ -145,7 +175,8 @@ def create_accept_reject_button_box(parent, okay=False):
accept_button = QtGui.QDialogButtonBox.Save
if okay:
accept_button = QtGui.QDialogButtonBox.Ok
button_box.setStandardButtons(accept_button | QtGui.QDialogButtonBox.Cancel)
button_box.setStandardButtons(
accept_button | QtGui.QDialogButtonBox.Cancel)
button_box.setObjectName(u'%sButtonBox' % parent)
QtCore.QObject.connect(button_box, QtCore.SIGNAL(u'accepted()'),
parent.accept)
@ -172,11 +203,11 @@ def critical_error_message_box(title=None, message=None, parent=None,
Should this message box question the user.
"""
if question:
return QtGui.QMessageBox.critical(parent, UiStrings.Error, message,
return QtGui.QMessageBox.critical(parent, UiStrings().Error, message,
QtGui.QMessageBox.StandardButtons(
QtGui.QMessageBox.Yes | QtGui.QMessageBox.No))
data = {u'message': message}
data[u'title'] = title if title else UiStrings.Error
data[u'title'] = title if title else UiStrings().Error
return Receiver.send_message(u'openlp_error_message', data)
def media_item_combo_box(parent, name):
@ -206,7 +237,7 @@ def create_delete_push_button(parent, icon=None):
delete_button.setObjectName(u'deleteButton')
delete_icon = icon if icon else u':/general/general_delete.png'
delete_button.setIcon(build_icon(delete_icon))
delete_button.setText(UiStrings.Delete)
delete_button.setText(UiStrings().Delete)
delete_button.setToolTip(
translate('OpenLP.Ui', 'Delete the selected item.'))
QtCore.QObject.connect(delete_button,
@ -239,43 +270,126 @@ def create_up_down_push_button_set(parent):
QtCore.SIGNAL(u'clicked()'), parent.onDownButtonClicked)
return up_button, down_button
def base_action(parent, name):
def base_action(parent, name, category=None):
"""
Return the most basic action with the object name set.
``category``
The category the action should be listed in the shortcut dialog. If you
not wish, that this action is added to the shortcut dialog, then do not
state any.
"""
action = QtGui.QAction(parent)
action.setObjectName(name)
if category is not None:
action_list = ActionList.get_instance()
action_list.add_action(action, category)
return action
def checkable_action(parent, name, checked=None):
def checkable_action(parent, name, checked=None, category=None):
"""
Return a standard action with the checkable attribute set.
"""
action = base_action(parent, name)
action = base_action(parent, name, category)
action.setCheckable(True)
if checked is not None:
action.setChecked(checked)
return action
def icon_action(parent, name, icon, checked=None):
def icon_action(parent, name, icon, checked=None, category=None):
"""
Return a standard action with an icon.
"""
if checked is not None:
action = checkable_action(parent, name, checked)
action = checkable_action(parent, name, checked, category)
else:
action = base_action(parent, name)
action = base_action(parent, name, category)
action.setIcon(build_icon(icon))
return action
def shortcut_action(parent, text, shortcuts, function):
def shortcut_action(parent, name, shortcuts, function, icon=None, checked=None,
category=None, context=QtCore.Qt.WindowShortcut):
"""
Return a shortcut enabled action.
"""
action = QtGui.QAction(text, parent)
action = QtGui.QAction(parent)
action.setObjectName(name)
if icon is not None:
action.setIcon(build_icon(icon))
if checked is not None:
action.setCheckable(True)
action.setChecked(checked)
action.setShortcuts(shortcuts)
action.setShortcutContext(QtCore.Qt.WidgetWithChildrenShortcut)
QtCore.QObject.connect(action, QtCore.SIGNAL(u'triggered()'), function)
action.setShortcutContext(context)
action_list = ActionList.get_instance()
action_list.add_action(action, category)
QtCore.QObject.connect(action, QtCore.SIGNAL(u'triggered(bool)'), function)
return action
def context_menu_action(base, icon, text, slot, shortcuts=None, category=None,
context=QtCore.Qt.WindowShortcut):
"""
Utility method to help build context menus for plugins
``base``
The parent menu to add this menu item to
``icon``
An icon for this action
``text``
The text to display for this action
``slot``
The code to run when this action is triggered
``shortcuts``
The action's shortcuts.
``category``
The category the shortcut should be listed in the shortcut dialog. If
left to None, then the action will be hidden in the shortcut dialog.
``context``
The context the shortcut is valid.
"""
action = QtGui.QAction(text, base)
if icon:
action.setIcon(build_icon(icon))
QtCore.QObject.connect(action, QtCore.SIGNAL(u'triggered(bool)'), slot)
if shortcuts is not None:
action.setShortcuts(shortcuts)
action.setShortcutContext(context)
action_list = ActionList.get_instance()
action_list.add_action(action)
return action
def context_menu(base, icon, text):
"""
Utility method to help build context menus for plugins
``base``
The parent object to add this menu to
``icon``
An icon for this menu
``text``
The text to display for this menu
"""
action = QtGui.QMenu(text, base)
action.setIcon(build_icon(icon))
return action
def context_menu_separator(base):
"""
Add a separator to a context menu
``base``
The menu object to add the separator to
"""
action = QtGui.QAction(u'', base)
action.setSeparator(True)
return action
def add_widget_completer(cache, widget):
@ -311,8 +425,25 @@ def create_valign_combo(form, parent, layout):
verticalLabel.setText(translate('OpenLP.Ui', '&Vertical Align:'))
form.verticalComboBox = QtGui.QComboBox(parent)
form.verticalComboBox.setObjectName(u'VerticalComboBox')
form.verticalComboBox.addItem(UiStrings.Top)
form.verticalComboBox.addItem(UiStrings.Middle)
form.verticalComboBox.addItem(UiStrings.Bottom)
form.verticalComboBox.addItem(UiStrings().Top)
form.verticalComboBox.addItem(UiStrings().Middle)
form.verticalComboBox.addItem(UiStrings().Bottom)
verticalLabel.setBuddy(form.verticalComboBox)
layout.addRow(verticalLabel, form.verticalComboBox)
def find_and_set_in_combo_box(combo_box, value_to_find):
"""
Find a string in a combo box and set it as the selected item if present
``combo_box``
The combo box to check for selected items
``value_to_find``
The value to find
"""
index = combo_box.findText(value_to_find,
QtCore.Qt.MatchExactly)
if index == -1:
# Not Found.
index = 0
combo_box.setCurrentIndex(index)

View File

@ -87,7 +87,7 @@ class Ui_AboutDialog(object):
QtCore.QMetaObject.connectSlotsByName(aboutDialog)
def retranslateUi(self, aboutDialog):
aboutDialog.setWindowTitle(u'%s OpenLP' % UiStrings.About)
aboutDialog.setWindowTitle(u'%s OpenLP' % UiStrings().About)
self.aboutTextEdit.setPlainText(translate('OpenLP.AboutForm',
'OpenLP <version><revision> - Open Source Lyrics '
'Projection\n'
@ -105,7 +105,7 @@ class Ui_AboutDialog(object):
'consider contributing by using the button below.'
))
self.aboutNotebook.setTabText(
self.aboutNotebook.indexOf(self.aboutTab), UiStrings.About)
self.aboutNotebook.indexOf(self.aboutTab), UiStrings().About)
lead = u'Raoul "superfly" Snyman'
developers = [u'Tim "TRB143" Bentley', u'Jonathan "gushie" Corwin',
u'Michael "cocooncrash" Gorven',
@ -615,4 +615,4 @@ class Ui_AboutDialog(object):
self.aboutNotebook.indexOf(self.licenseTab),
translate('OpenLP.AboutForm', 'License'))
self.contributeButton.setText(translate('OpenLP.AboutForm',
'Contribute'))
'Contribute'))

View File

@ -37,13 +37,15 @@ class AdvancedTab(SettingsTab):
The :class:`AdvancedTab` manages the advanced settings tab including the UI
and the loading and saving of the displayed settings.
"""
def __init__(self):
def __init__(self, parent):
"""
Initialise the settings tab
"""
SettingsTab.__init__(self, u'Advanced')
advancedTranslated = translate('OpenLP.AdvancedTab', 'Advanced')
self.default_image = u':/graphics/openlp-splash-screen.png'
self.default_color = u'#ffffff'
self.icon_path = u':/system/system_settings.png'
SettingsTab.__init__(self, parent, u'Advanced', advancedTranslated)
def setupUi(self):
"""
@ -80,14 +82,6 @@ class AdvancedTab(SettingsTab):
u'enableAutoCloseCheckBox')
self.uiLayout.addRow(self.enableAutoCloseCheckBox)
self.leftLayout.addWidget(self.uiGroupBox)
self.hideMouseGroupBox = QtGui.QGroupBox(self.leftColumn)
self.hideMouseGroupBox.setObjectName(u'hideMouseGroupBox')
self.hideMouseLayout = QtGui.QVBoxLayout(self.hideMouseGroupBox)
self.hideMouseLayout.setObjectName(u'hideMouseLayout')
self.hideMouseCheckBox = QtGui.QCheckBox(self.hideMouseGroupBox)
self.hideMouseCheckBox.setObjectName(u'hideMouseCheckBox')
self.hideMouseLayout.addWidget(self.hideMouseCheckBox)
self.leftLayout.addWidget(self.hideMouseGroupBox)
self.leftLayout.addStretch()
self.defaultImageGroupBox = QtGui.QGroupBox(self.rightColumn)
self.defaultImageGroupBox.setObjectName(u'defaultImageGroupBox')
@ -107,26 +101,42 @@ class AdvancedTab(SettingsTab):
self.defaultBrowseButton.setObjectName(u'defaultBrowseButton')
self.defaultBrowseButton.setIcon(
build_icon(u':/general/general_open.png'))
self.defaultRevertButton = QtGui.QToolButton(self.defaultImageGroupBox)
self.defaultRevertButton.setObjectName(u'defaultRevertButton')
self.defaultRevertButton.setIcon(
build_icon(u':/general/general_revert.png'))
self.defaultFileLayout = QtGui.QHBoxLayout()
self.defaultFileLayout.setObjectName(u'defaultFileLayout')
self.defaultFileLayout.addWidget(self.defaultFileEdit)
self.defaultFileLayout.addWidget(self.defaultBrowseButton)
self.defaultFileLayout.addWidget(self.defaultRevertButton)
self.defaultImageLayout.addRow(self.defaultFileLabel,
self.defaultFileLayout)
self.rightLayout.addWidget(self.defaultImageGroupBox)
self.hideMouseGroupBox = QtGui.QGroupBox(self.leftColumn)
self.hideMouseGroupBox.setObjectName(u'hideMouseGroupBox')
self.hideMouseLayout = QtGui.QVBoxLayout(self.hideMouseGroupBox)
self.hideMouseLayout.setObjectName(u'hideMouseLayout')
self.hideMouseCheckBox = QtGui.QCheckBox(self.hideMouseGroupBox)
self.hideMouseCheckBox.setObjectName(u'hideMouseCheckBox')
self.hideMouseLayout.addWidget(self.hideMouseCheckBox)
self.rightLayout.addWidget(self.hideMouseGroupBox)
self.rightLayout.addStretch()
QtCore.QObject.connect(self.defaultColorButton,
QtCore.SIGNAL(u'pressed()'), self.onDefaultColorButtonPressed)
QtCore.QObject.connect(self.defaultBrowseButton,
QtCore.SIGNAL(u'pressed()'), self.onDefaultBrowseButtonPressed)
QtCore.QObject.connect(self.defaultRevertButton,
QtCore.SIGNAL(u'pressed()'), self.onDefaultRevertButtonPressed)
def retranslateUi(self):
"""
Setup the interface translation strings.
"""
self.tabTitleVisible = UiStrings.Advanced
self.uiGroupBox.setTitle(translate('OpenLP.AdvancedTab', 'UI Settings'))
self.tabTitleVisible = UiStrings().Advanced
self.uiGroupBox.setTitle(
translate('OpenLP.AdvancedTab', 'UI Settings'))
self.recentLabel.setText(
translate('OpenLP.AdvancedTab',
'Number of recent files to display:'))
@ -148,8 +158,14 @@ class AdvancedTab(SettingsTab):
'Default Image'))
self.defaultColorLabel.setText(translate('OpenLP.AdvancedTab',
'Background color:'))
self.defaultColorButton.setToolTip(translate('OpenLP.AdvancedTab',
'Click to select a color.'))
self.defaultFileLabel.setText(translate('OpenLP.AdvancedTab',
'Image file:'))
self.defaultBrowseButton.setToolTip(translate('OpenLP.AdvancedTab',
'Browse for an image file to display.'))
self.defaultRevertButton.setToolTip(translate('OpenLP.AdvancedTab',
'Revert to the default OpenLP logo.'))
def load(self):
"""
@ -224,9 +240,13 @@ class AdvancedTab(SettingsTab):
def onDefaultBrowseButtonPressed(self):
file_filters = u'%s;;%s (*.*) (*)' % (get_images_filter(),
UiStrings.AllFiles)
UiStrings().AllFiles)
filename = QtGui.QFileDialog.getOpenFileName(self,
UiStrings.OpenFile, '', file_filters)
if filename:
self.defaultFileEdit.setText(filename)
self.defaultFileEdit.setFocus()
def onDefaultRevertButtonPressed(self):
self.defaultFileEdit.setText(u':/graphics/openlp-splash-screen.png')
self.defaultFileEdit.setFocus()

View File

@ -136,10 +136,10 @@ class Ui_DisplayTagDialog(object):
translate('OpenLP.DisplayTagDialog', 'Start tag'))
self.endTagLabel.setText(
translate('OpenLP.DisplayTagDialog', 'End tag'))
self.deletePushButton.setText(UiStrings.Delete)
self.deletePushButton.setText(UiStrings().Delete)
self.defaultPushButton.setText(
translate('OpenLP.DisplayTagDialog', 'Default'))
self.newPushButton.setText(UiStrings.New)
self.newPushButton.setText(UiStrings().New)
self.tagTableWidget.horizontalHeaderItem(0).setText(
translate('OpenLP.DisplayTagDialog', 'Description'))
self.tagTableWidget.horizontalHeaderItem(1).setText(
@ -151,4 +151,4 @@ class Ui_DisplayTagDialog(object):
self.tagTableWidget.setColumnWidth(0, 120)
self.tagTableWidget.setColumnWidth(1, 40)
self.tagTableWidget.setColumnWidth(2, 240)
self.tagTableWidget.setColumnWidth(3, 240)
self.tagTableWidget.setColumnWidth(3, 240)

View File

@ -178,11 +178,11 @@ class ExceptionForm(QtGui.QDialog, Ui_ExceptionDialog):
self,translate('ImagePlugin.ExceptionDialog',
'Select Attachment'),
SettingsManager.get_last_dir(u'exceptions'),
u'%s (*.*) (*)' % UiStrings.AllFiles)
u'%s (*.*) (*)' % UiStrings().AllFiles)
log.info(u'New files(s) %s', unicode(files))
if files:
self.fileAttachment = unicode(files)
def __buttonState(self, state):
self.saveReportButton.setEnabled(state)
self.sendReportButton.setEnabled(state)
self.sendReportButton.setEnabled(state)

View File

@ -140,6 +140,8 @@ class FirstTimeForm(QtGui.QWizard, Ui_FirstTimeWizard):
return FirstTimePage.Songs
elif self.currentId() == FirstTimePage.Progress:
return -1
elif self.currentId() == FirstTimePage.NoInternet:
return FirstTimePage.Progress
else:
return self.currentId() + 1
@ -147,11 +149,7 @@ class FirstTimeForm(QtGui.QWizard, Ui_FirstTimeWizard):
"""
Detects Page changes and updates as approprate.
"""
if pageId == FirstTimePage.NoInternet:
self.finishButton.setVisible(True)
self.finishButton.setEnabled(True)
self.nextButton.setVisible(False)
elif pageId == FirstTimePage.Defaults:
if pageId == FirstTimePage.Defaults:
self.themeComboBox.clear()
for iter in xrange(self.themesListWidget.count()):
item = self.themesListWidget.item(iter)

View File

@ -36,7 +36,7 @@ class GeneralTab(SettingsTab):
"""
GeneralTab is the general settings tab in the settings dialog.
"""
def __init__(self, screens):
def __init__(self, parent, screens):
"""
Initialise the general settings tab
"""
@ -44,7 +44,9 @@ class GeneralTab(SettingsTab):
self.monitorNumber = 0
# Set to True to allow PostSetup to work on application start up
self.overrideChanged = True
SettingsTab.__init__(self, u'General')
self.icon_path = u':/icon/openlp-logo-16x16.png'
generalTranslated = translate('GeneralTab', 'General')
SettingsTab.__init__(self, parent, u'General', generalTranslated)
def preLoad(self):
"""
@ -236,7 +238,7 @@ class GeneralTab(SettingsTab):
self.timeoutSpinBox.setSuffix(translate('OpenLP.GeneralTab', ' sec'))
self.ccliGroupBox.setTitle(
translate('OpenLP.GeneralTab', 'CCLI Details'))
self.numberLabel.setText(UiStrings.CCLINumberLabel)
self.numberLabel.setText(UiStrings().CCLINumberLabel)
self.usernameLabel.setText(
translate('OpenLP.GeneralTab', 'SongSelect username:'))
self.passwordLabel.setText(
@ -392,4 +394,4 @@ class GeneralTab(SettingsTab):
"""
Called when the width, height, x position or y position has changed.
"""
self.overrideChanged = True
self.overrideChanged = True

View File

@ -34,7 +34,7 @@ from PyQt4 import QtCore, QtGui, QtWebKit
from PyQt4.phonon import Phonon
from openlp.core.lib import Receiver, build_html, ServiceItem, image_to_byte, \
build_icon, translate
translate
from openlp.core.ui import HideMode
@ -69,8 +69,6 @@ class MainDisplay(DisplayWidget):
self.hideMode = None
self.videoHide = False
self.override = {}
mainIcon = build_icon(u':/icon/openlp-logo-16x16.png')
self.setWindowIcon(mainIcon)
self.retranslateUi()
self.setStyleSheet(u'border: 0px; margin: 0px; padding: 0px;')
self.setWindowFlags(QtCore.Qt.FramelessWindowHint | QtCore.Qt.Tool |
@ -144,7 +142,8 @@ class MainDisplay(DisplayWidget):
image_file = QtCore.QSettings().value(u'advanced/default image',
QtCore.QVariant(u':/graphics/openlp-splash-screen.png'))\
.toString()
background_color = QtGui.QColor(QtCore.QSettings().value(
background_color = QtGui.QColor()
background_color.setNamedColor(QtCore.QSettings().value(
u'advanced/default color',
QtCore.QVariant(u'#ffffff')).toString())
if not background_color.isValid():
@ -453,7 +452,7 @@ class MainDisplay(DisplayWidget):
painter.end()
return preview
def buildHtml(self, serviceItem):
def buildHtml(self, serviceItem, image=None):
"""
Store the serviceItem and build the new HTML from it. Add the
HTML to the display
@ -480,8 +479,12 @@ class MainDisplay(DisplayWidget):
if self.serviceItem.themedata.background_filename:
self.serviceItem.bg_image_bytes = self.imageManager. \
get_image_bytes(self.serviceItem.themedata.theme_name)
if image:
image_bytes = self.imageManager.get_image_bytes(image)
else:
image_bytes = None
html = build_html(self.serviceItem, self.screen, self.alertTab,
self.isLive, background)
self.isLive, background, image_bytes)
log.debug(u'buildHtml - pre setHtml')
self.webView.setHtml(html)
log.debug(u'buildHtml - post setHtml')

View File

@ -33,12 +33,13 @@ from PyQt4 import QtCore, QtGui
from openlp.core.lib import RenderManager, build_icon, OpenLPDockWidget, \
SettingsManager, PluginManager, Receiver, translate
from openlp.core.lib.ui import UiStrings, base_action, checkable_action, \
icon_action
icon_action, shortcut_action
from openlp.core.ui import AboutForm, SettingsForm, ServiceManager, \
ThemeManager, SlideController, PluginForm, MediaDockManager, \
ShortcutListForm, DisplayTagForm
from openlp.core.utils import AppLocation, add_actions, LanguageManager, \
ActionList, get_application_version
get_application_version
from openlp.core.utils.actions import ActionList, CategoryOrder
log = logging.getLogger(__name__)
@ -70,7 +71,7 @@ class Ui_MainWindow(object):
mainWindow.setObjectName(u'MainWindow')
mainWindow.resize(self.settingsmanager.width,
self.settingsmanager.height)
mainWindow.setWindowIcon(build_icon(u':/icon/openlp-logo-16x16.png'))
mainWindow.setWindowIcon(build_icon(u':/icon/openlp-logo-64x64.png'))
mainWindow.setDockNestingEnabled(True)
# Set up the main container, which contains all the other form widgets.
self.MainContent = QtGui.QWidget(mainWindow)
@ -161,74 +162,86 @@ class Ui_MainWindow(object):
mainWindow.addDockWidget(QtCore.Qt.RightDockWidgetArea,
self.themeManagerDock)
# Create the menu items
self.FileNewItem = icon_action(mainWindow, u'FileNewItem',
u':/general/general_new.png')
mainWindow.actionList.add_action(self.FileNewItem, u'File')
self.FileOpenItem = icon_action(mainWindow, u'FileOpenItem',
u':/general/general_open.png')
mainWindow.actionList.add_action(self.FileOpenItem, u'File')
self.FileSaveItem = icon_action(mainWindow, u'FileSaveItem',
u':/general/general_save.png')
mainWindow.actionList.add_action(self.FileSaveItem, u'File')
self.FileSaveAsItem = base_action(mainWindow, u'FileSaveAsItem')
mainWindow.actionList.add_action(self.FileSaveAsItem, u'File')
self.printServiceOrderItem = base_action(
mainWindow, u'printServiceItem')
mainWindow.actionList.add_action(
self.printServiceOrderItem, u'Print Service Order')
self.FileExitItem = icon_action(mainWindow, u'FileExitItem',
u':/system/system_exit.png')
mainWindow.actionList.add_action(self.FileExitItem, u'File')
self.ImportThemeItem = base_action(mainWindow, u'ImportThemeItem')
mainWindow.actionList.add_action(self.ImportThemeItem, u'Import')
self.ImportLanguageItem = base_action(mainWindow, u'ImportLanguageItem')
mainWindow.actionList.add_action(self.ImportLanguageItem, u'Import')
self.ExportThemeItem = base_action(mainWindow, u'ExportThemeItem')
mainWindow.actionList.add_action(self.ExportThemeItem, u'Export')
self.ExportLanguageItem = base_action(mainWindow, u'ExportLanguageItem')
mainWindow.actionList.add_action(self.ExportLanguageItem, u'Export')
self.ViewMediaManagerItem = icon_action(mainWindow,
u'ViewMediaManagerItem', u':/system/system_mediamanager.png',
self.mediaManagerDock.isVisible())
self.ViewThemeManagerItem = icon_action(mainWindow,
u'ViewThemeManagerItem', u':/system/system_thememanager.png',
self.themeManagerDock.isVisible())
mainWindow.actionList.add_action(self.ViewMediaManagerItem, u'View')
self.ViewServiceManagerItem = icon_action(mainWindow,
u'ViewServiceManagerItem', u':/system/system_servicemanager.png',
self.serviceManagerDock.isVisible())
mainWindow.actionList.add_action(self.ViewServiceManagerItem, u'View')
self.ViewPreviewPanel = checkable_action(mainWindow,
u'ViewPreviewPanel', previewVisible)
mainWindow.actionList.add_action(self.ViewPreviewPanel, u'View')
self.ViewLivePanel = checkable_action(mainWindow, u'ViewLivePanel',
liveVisible)
mainWindow.actionList.add_action(self.ViewLivePanel, u'View')
self.ModeDefaultItem = checkable_action(mainWindow, u'ModeDefaultItem')
mainWindow.actionList.add_action(self.ModeDefaultItem, u'View Mode')
self.ModeSetupItem = checkable_action(mainWindow, u'ModeLiveItem')
mainWindow.actionList.add_action(self.ModeSetupItem, u'View Mode')
self.ModeLiveItem = checkable_action(mainWindow, u'ModeLiveItem', True)
mainWindow.actionList.add_action(self.ModeLiveItem, u'View Mode')
action_list = ActionList.get_instance()
action_list.add_category(UiStrings().File, CategoryOrder.standardMenu)
self.FileNewItem = shortcut_action(mainWindow, u'FileNewItem',
[QtGui.QKeySequence(u'Ctrl+N')],
self.ServiceManagerContents.onNewServiceClicked,
u':/general/general_new.png', category=UiStrings().File)
self.FileOpenItem = shortcut_action(mainWindow, u'FileOpenItem',
[QtGui.QKeySequence(u'Ctrl+O')],
self.ServiceManagerContents.onLoadServiceClicked,
u':/general/general_open.png', category=UiStrings().File)
self.FileSaveItem = shortcut_action(mainWindow, u'FileSaveItem',
[QtGui.QKeySequence(u'Ctrl+S')],
self.ServiceManagerContents.saveFile,
u':/general/general_save.png', category=UiStrings().File)
self.FileSaveAsItem = shortcut_action(mainWindow, u'FileSaveAsItem',
[QtGui.QKeySequence(u'Ctrl+Shift+S')],
self.ServiceManagerContents.saveFileAs, category=UiStrings().File)
self.printServiceOrderItem = shortcut_action(mainWindow,
u'printServiceItem', [QtGui.QKeySequence(u'Ctrl+P')],
self.ServiceManagerContents.printServiceOrder,
category=UiStrings().File)
self.FileExitItem = shortcut_action(mainWindow, u'FileExitItem',
[QtGui.QKeySequence(u'Alt+F4')], mainWindow.close,
u':/system/system_exit.png', category=UiStrings().File)
action_list.add_category(UiStrings().Import, CategoryOrder.standardMenu)
self.ImportThemeItem = base_action(
mainWindow, u'ImportThemeItem', UiStrings().Import)
self.ImportLanguageItem = base_action(
mainWindow, u'ImportLanguageItem')#, UiStrings().Import)
action_list.add_category(UiStrings().Export, CategoryOrder.standardMenu)
self.ExportThemeItem = base_action(
mainWindow, u'ExportThemeItem', UiStrings().Export)
self.ExportLanguageItem = base_action(
mainWindow, u'ExportLanguageItem')#, UiStrings().Export)
action_list.add_category(UiStrings().View, CategoryOrder.standardMenu)
self.ViewMediaManagerItem = shortcut_action(mainWindow,
u'ViewMediaManagerItem', [QtGui.QKeySequence(u'F8')],
self.toggleMediaManager, u':/system/system_mediamanager.png',
self.mediaManagerDock.isVisible(), UiStrings().View)
self.ViewThemeManagerItem = shortcut_action(mainWindow,
u'ViewThemeManagerItem', [QtGui.QKeySequence(u'F10')],
self.toggleThemeManager, u':/system/system_thememanager.png',
self.themeManagerDock.isVisible(), UiStrings().View)
self.ViewServiceManagerItem = shortcut_action(mainWindow,
u'ViewServiceManagerItem', [QtGui.QKeySequence(u'F9')],
self.toggleServiceManager, u':/system/system_servicemanager.png',
self.serviceManagerDock.isVisible(), UiStrings().View)
self.ViewPreviewPanel = shortcut_action(mainWindow,
u'ViewPreviewPanel', [QtGui.QKeySequence(u'F11')],
self.setPreviewPanelVisibility, checked=previewVisible,
category=UiStrings().View)
self.ViewLivePanel = shortcut_action(mainWindow, u'ViewLivePanel',
[QtGui.QKeySequence(u'F12')], self.setLivePanelVisibility,
checked=liveVisible, category=UiStrings().View)
action_list.add_category(UiStrings().ViewMode, CategoryOrder.standardMenu)
self.ModeDefaultItem = checkable_action(
mainWindow, u'ModeDefaultItem', category=UiStrings().ViewMode)
self.ModeSetupItem = checkable_action(
mainWindow, u'ModeLiveItem', category=UiStrings().ViewMode)
self.ModeLiveItem = checkable_action(
mainWindow, u'ModeLiveItem', True, UiStrings().ViewMode)
self.ModeGroup = QtGui.QActionGroup(mainWindow)
self.ModeGroup.addAction(self.ModeDefaultItem)
self.ModeGroup.addAction(self.ModeSetupItem)
self.ModeGroup.addAction(self.ModeLiveItem)
self.ModeDefaultItem.setChecked(True)
action_list.add_category(UiStrings().Tools, CategoryOrder.standardMenu)
self.ToolsAddToolItem = icon_action(mainWindow, u'ToolsAddToolItem',
u':/tools/tools_add.png')
mainWindow.actionList.add_action(self.ToolsAddToolItem, u'Tools')
u':/tools/tools_add.png', category=UiStrings().Tools)
self.ToolsOpenDataFolder = icon_action(mainWindow,
u'ToolsOpenDataFolder', u':/general/general_open.png')
mainWindow.actionList.add_action(self.ToolsOpenDataFolder, u'Tools')
self.settingsPluginListItem = icon_action(mainWindow,
u'settingsPluginListItem', u':/system/settings_plugin_list.png')
mainWindow.actionList.add_action(self.settingsPluginListItem,
u'Settings')
u'ToolsOpenDataFolder', u':/general/general_open.png',
category=UiStrings().Tools)
action_list.add_category(UiStrings().Settings, CategoryOrder.standardMenu)
self.settingsPluginListItem = shortcut_action(mainWindow,
u'settingsPluginListItem', [QtGui.QKeySequence(u'Alt+F7')],
self.onPluginItemClicked, u':/system/settings_plugin_list.png',
category=UiStrings().Settings)
# i18n Language Items
self.AutoLanguageItem = checkable_action(mainWindow,
u'AutoLanguageItem', LanguageManager.auto_language)
mainWindow.actionList.add_action(self.AutoLanguageItem, u'Settings')
self.LanguageGroup = QtGui.QActionGroup(mainWindow)
self.LanguageGroup.setExclusive(True)
self.LanguageGroup.setObjectName(u'LanguageGroup')
@ -241,24 +254,26 @@ class Ui_MainWindow(object):
add_actions(self.LanguageGroup, [languageItem])
self.SettingsShortcutsItem = icon_action(mainWindow,
u'SettingsShortcutsItem',
u':/system/system_configure_shortcuts.png')
u':/system/system_configure_shortcuts.png',
category=UiStrings().Settings)
self.DisplayTagItem = icon_action(mainWindow,
u'DisplayTagItem', u':/system/tag_editor.png')
u'DisplayTagItem', u':/system/tag_editor.png',
category=UiStrings().Settings)
self.SettingsConfigureItem = icon_action(mainWindow,
u'SettingsConfigureItem', u':/system/system_settings.png')
mainWindow.actionList.add_action(self.SettingsShortcutsItem,
u'Settings')
u'SettingsConfigureItem', u':/system/system_settings.png',
category=UiStrings().Settings)
action_list.add_category(UiStrings().Help, CategoryOrder.standardMenu)
self.HelpDocumentationItem = icon_action(mainWindow,
u'HelpDocumentationItem', u':/system/system_help_contents.png')
u'HelpDocumentationItem', u':/system/system_help_contents.png',
category=None)#UiStrings().Help)
self.HelpDocumentationItem.setEnabled(False)
mainWindow.actionList.add_action(self.HelpDocumentationItem, u'Help')
self.HelpAboutItem = icon_action(mainWindow, u'HelpAboutItem',
u':/system/system_about.png')
mainWindow.actionList.add_action(self.HelpAboutItem, u'Help')
self.HelpOnlineHelpItem = base_action(mainWindow, u'HelpOnlineHelpItem')
mainWindow.actionList.add_action(self.HelpOnlineHelpItem, u'Help')
self.helpWebSiteItem = base_action(mainWindow, u'helpWebSiteItem')
mainWindow.actionList.add_action(self.helpWebSiteItem, u'Help')
self.HelpAboutItem = shortcut_action(mainWindow, u'HelpAboutItem',
[QtGui.QKeySequence(u'Ctrl+F1')], self.onHelpAboutItemClicked,
u':/system/system_about.png', category=UiStrings().Help)
self.HelpOnlineHelpItem = base_action(
mainWindow, u'HelpOnlineHelpItem', category=UiStrings().Help)
self.helpWebSiteItem = base_action(
mainWindow, u'helpWebSiteItem', category=UiStrings().Help)
add_actions(self.FileImportMenu,
(self.ImportThemeItem, self.ImportLanguageItem))
add_actions(self.FileExportMenu,
@ -294,21 +309,18 @@ class Ui_MainWindow(object):
# Connect up some signals and slots
QtCore.QObject.connect(self.FileMenu,
QtCore.SIGNAL(u'aboutToShow()'), self.updateFileMenu)
QtCore.QObject.connect(self.FileExitItem,
QtCore.SIGNAL(u'triggered()'), mainWindow.close)
QtCore.QMetaObject.connectSlotsByName(mainWindow)
# Hide the entry, as it does not have any functionality yet.
self.ToolsAddToolItem.setVisible(False)
self.ImportLanguageItem.setVisible(False)
self.ExportLanguageItem.setVisible(False)
self.SettingsShortcutsItem.setVisible(False)
self.HelpDocumentationItem.setVisible(False)
def retranslateUi(self, mainWindow):
"""
Set up the translation system
"""
mainWindow.mainTitle = UiStrings.OLPV2
mainWindow.mainTitle = UiStrings().OLPV2
mainWindow.setWindowTitle(mainWindow.mainTitle)
self.FileMenu.setTitle(translate('OpenLP.MainWindow', '&File'))
self.FileImportMenu.setTitle(translate('OpenLP.MainWindow', '&Import'))
@ -327,38 +339,29 @@ class Ui_MainWindow(object):
self.themeManagerDock.setWindowTitle(
translate('OpenLP.MainWindow', 'Theme Manager'))
self.FileNewItem.setText(translate('OpenLP.MainWindow', '&New'))
self.FileNewItem.setToolTip(UiStrings.NewService)
self.FileNewItem.setStatusTip(UiStrings.CreateService)
self.FileNewItem.setShortcut(translate('OpenLP.MainWindow', 'Ctrl+N'))
self.FileNewItem.setToolTip(UiStrings().NewService)
self.FileNewItem.setStatusTip(UiStrings().CreateService)
self.FileOpenItem.setText(translate('OpenLP.MainWindow', '&Open'))
self.FileOpenItem.setToolTip(UiStrings.OpenService)
self.FileOpenItem.setToolTip(UiStrings().OpenService)
self.FileOpenItem.setStatusTip(
translate('OpenLP.MainWindow', 'Open an existing service.'))
self.FileOpenItem.setShortcut(translate('OpenLP.MainWindow', 'Ctrl+O'))
self.FileSaveItem.setText(translate('OpenLP.MainWindow', '&Save'))
self.FileSaveItem.setToolTip(UiStrings.SaveService)
self.FileSaveItem.setToolTip(UiStrings().SaveService)
self.FileSaveItem.setStatusTip(
translate('OpenLP.MainWindow', 'Save the current service to disk.'))
self.FileSaveItem.setShortcut(translate('OpenLP.MainWindow', 'Ctrl+S'))
self.FileSaveAsItem.setText(
translate('OpenLP.MainWindow', 'Save &As...'))
self.FileSaveAsItem.setToolTip(
translate('OpenLP.MainWindow', 'Save Service As'))
self.FileSaveAsItem.setStatusTip(translate('OpenLP.MainWindow',
'Save the current service under a new name.'))
self.FileSaveAsItem.setShortcut(
translate('OpenLP.MainWindow', 'Ctrl+Shift+S'))
self.printServiceOrderItem.setText(UiStrings.PrintServiceOrder)
self.printServiceOrderItem.setText(UiStrings().PrintServiceOrder)
self.printServiceOrderItem.setStatusTip(translate('OpenLP.MainWindow',
'Print the current Service Order.'))
self.printServiceOrderItem.setShortcut(
translate('OpenLP.MainWindow', 'Ctrl+P'))
self.FileExitItem.setText(
translate('OpenLP.MainWindow', 'E&xit'))
self.FileExitItem.setStatusTip(
translate('OpenLP.MainWindow', 'Quit OpenLP'))
self.FileExitItem.setShortcut(
translate('OpenLP.MainWindow', 'Alt+F4'))
self.ImportThemeItem.setText(
translate('OpenLP.MainWindow', '&Theme'))
self.ImportLanguageItem.setText(
@ -379,53 +382,39 @@ class Ui_MainWindow(object):
translate('OpenLP.MainWindow', 'Toggle Media Manager'))
self.ViewMediaManagerItem.setStatusTip(translate('OpenLP.MainWindow',
'Toggle the visibility of the media manager.'))
self.ViewMediaManagerItem.setShortcut(
translate('OpenLP.MainWindow', 'F8'))
self.ViewThemeManagerItem.setText(
translate('OpenLP.MainWindow', '&Theme Manager'))
self.ViewThemeManagerItem.setToolTip(
translate('OpenLP.MainWindow', 'Toggle Theme Manager'))
self.ViewThemeManagerItem.setStatusTip(translate('OpenLP.MainWindow',
'Toggle the visibility of the theme manager.'))
self.ViewThemeManagerItem.setShortcut(
translate('OpenLP.MainWindow', 'F10'))
self.ViewServiceManagerItem.setText(
translate('OpenLP.MainWindow', '&Service Manager'))
self.ViewServiceManagerItem.setToolTip(
translate('OpenLP.MainWindow', 'Toggle Service Manager'))
self.ViewServiceManagerItem.setStatusTip(translate('OpenLP.MainWindow',
'Toggle the visibility of the service manager.'))
self.ViewServiceManagerItem.setShortcut(
translate('OpenLP.MainWindow', 'F9'))
self.ViewPreviewPanel.setText(
translate('OpenLP.MainWindow', '&Preview Panel'))
self.ViewPreviewPanel.setToolTip(
translate('OpenLP.MainWindow', 'Toggle Preview Panel'))
self.ViewPreviewPanel.setStatusTip(translate('OpenLP.MainWindow',
'Toggle the visibility of the preview panel.'))
self.ViewPreviewPanel.setShortcut(
translate('OpenLP.MainWindow', 'F11'))
self.ViewLivePanel.setText(
translate('OpenLP.MainWindow', '&Live Panel'))
self.ViewLivePanel.setToolTip(
translate('OpenLP.MainWindow', 'Toggle Live Panel'))
self.ViewLivePanel.setStatusTip(translate('OpenLP.MainWindow',
'Toggle the visibility of the live panel.'))
self.ViewLivePanel.setShortcut(
translate('OpenLP.MainWindow', 'F12'))
self.settingsPluginListItem.setText(translate('OpenLP.MainWindow',
'&Plugin List'))
self.settingsPluginListItem.setStatusTip(
translate('OpenLP.MainWindow', 'List the Plugins'))
self.settingsPluginListItem.setShortcut(
translate('OpenLP.MainWindow', 'Alt+F7'))
self.HelpDocumentationItem.setText(
translate('OpenLP.MainWindow', '&User Guide'))
self.HelpAboutItem.setText(translate('OpenLP.MainWindow', '&About'))
self.HelpAboutItem.setStatusTip(
translate('OpenLP.MainWindow', 'More information about OpenLP'))
self.HelpAboutItem.setShortcut(
translate('OpenLP.MainWindow', 'Ctrl+F1'))
self.HelpOnlineHelpItem.setText(
translate('OpenLP.MainWindow', '&Online Help'))
# Uncomment after 1.9.5 beta string freeze
@ -467,8 +456,6 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow):
"""
log.info(u'MainWindow loaded')
actionList = ActionList()
def __init__(self, screens, clipboard, arguments):
"""
This constructor sets up the interface, the various managers, and the
@ -485,7 +472,6 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow):
self.serviceSettingsSection = u'servicemanager'
self.songsSettingsSection = u'songs'
self.serviceNotSaved = False
self.actionList = ActionList()
self.settingsmanager = SettingsManager(screens)
self.aboutForm = AboutForm(self)
self.settingsForm = SettingsForm(self.screens, self, self)
@ -510,16 +496,6 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow):
QtCore.QObject.connect(self.ExportThemeItem,
QtCore.SIGNAL(u'triggered()'),
self.themeManagerContents.onExportTheme)
QtCore.QObject.connect(self.ViewMediaManagerItem,
QtCore.SIGNAL(u'triggered(bool)'), self.toggleMediaManager)
QtCore.QObject.connect(self.ViewServiceManagerItem,
QtCore.SIGNAL(u'triggered(bool)'), self.toggleServiceManager)
QtCore.QObject.connect(self.ViewThemeManagerItem,
QtCore.SIGNAL(u'triggered(bool)'), self.toggleThemeManager)
QtCore.QObject.connect(self.ViewPreviewPanel,
QtCore.SIGNAL(u'toggled(bool)'), self.setPreviewPanelVisibility)
QtCore.QObject.connect(self.ViewLivePanel,
QtCore.SIGNAL(u'toggled(bool)'), self.setLivePanelVisibility)
QtCore.QObject.connect(self.mediaManagerDock,
QtCore.SIGNAL(u'visibilityChanged(bool)'),
self.ViewMediaManagerItem.setChecked)
@ -533,32 +509,14 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow):
QtCore.SIGNAL(u'triggered()'), self.onHelpWebSiteClicked)
QtCore.QObject.connect(self.HelpOnlineHelpItem,
QtCore.SIGNAL(u'triggered()'), self.onHelpOnLineHelpClicked)
QtCore.QObject.connect(self.HelpAboutItem,
QtCore.SIGNAL(u'triggered()'), self.onHelpAboutItemClicked)
QtCore.QObject.connect(self.ToolsOpenDataFolder,
QtCore.SIGNAL(u'triggered()'), self.onToolsOpenDataFolderClicked)
QtCore.QObject.connect(self.settingsPluginListItem,
QtCore.SIGNAL(u'triggered()'), self.onPluginItemClicked)
QtCore.QObject.connect(self.DisplayTagItem,
QtCore.SIGNAL(u'triggered()'), self.onDisplayTagItemClicked)
QtCore.QObject.connect(self.SettingsConfigureItem,
QtCore.SIGNAL(u'triggered()'), self.onSettingsConfigureItemClicked)
QtCore.QObject.connect(self.SettingsShortcutsItem,
QtCore.SIGNAL(u'triggered()'), self.onSettingsShortcutsItemClicked)
QtCore.QObject.connect(self.FileNewItem, QtCore.SIGNAL(u'triggered()'),
self.ServiceManagerContents.onNewServiceClicked)
QtCore.QObject.connect(self.FileOpenItem,
QtCore.SIGNAL(u'triggered()'),
self.ServiceManagerContents.onLoadServiceClicked)
QtCore.QObject.connect(self.FileSaveItem,
QtCore.SIGNAL(u'triggered()'),
self.ServiceManagerContents.saveFile)
QtCore.QObject.connect(self.FileSaveAsItem,
QtCore.SIGNAL(u'triggered()'),
self.ServiceManagerContents.saveFileAs)
QtCore.QObject.connect(self.printServiceOrderItem,
QtCore.SIGNAL(u'triggered()'),
self.ServiceManagerContents.printServiceOrder)
# i18n set signals for languages
self.LanguageGroup.triggered.connect(LanguageManager.set_language)
QtCore.QObject.connect(self.ModeDefaultItem,
@ -781,7 +739,8 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow):
"""
Show the shortcuts dialog
"""
self.shortcutForm.exec_(self.actionList)
if self.shortcutForm.exec_():
self.shortcutForm.save()
def onModeDefaultItemClicked(self):
"""
@ -928,17 +887,14 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow):
unicode(translate('OpenLP.MainWindow', 'Default Theme: %s')) %
theme)
def toggleMediaManager(self, visible):
if self.mediaManagerDock.isVisible() != visible:
self.mediaManagerDock.setVisible(visible)
def toggleMediaManager(self):
self.mediaManagerDock.setVisible(not self.mediaManagerDock.isVisible())
def toggleServiceManager(self, visible):
if self.serviceManagerDock.isVisible() != visible:
self.serviceManagerDock.setVisible(visible)
def toggleServiceManager(self):
self.serviceManagerDock.setVisible(not self.serviceManagerDock.isVisible())
def toggleThemeManager(self, visible):
if self.themeManagerDock.isVisible() != visible:
self.themeManagerDock.setVisible(visible)
def toggleThemeManager(self):
self.themeManagerDock.setVisible(not self.themeManagerDock.isVisible())
def setPreviewPanelVisibility(self, visible):
"""
@ -1022,8 +978,9 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow):
self.FileMenu.addSeparator()
for fileId, filename in enumerate(recentFilesToDisplay):
log.debug('Recent file name: %s', filename)
action = QtGui.QAction(u'&%d %s' % (fileId + 1,
QtCore.QFileInfo(filename).fileName()), self)
action = base_action(self, u'')
action.setText(u'&%d %s' %
(fileId + 1, QtCore.QFileInfo(filename).fileName()))
action.setData(QtCore.QVariant(filename))
self.connect(action, QtCore.SIGNAL(u'triggered()'),
self.ServiceManagerContents.onRecentServiceClicked)

View File

@ -84,5 +84,5 @@ class MediaDockManager(object):
if self.media_dock.widget(dock_index):
if self.media_dock.widget(dock_index).settingsSection == \
media_item.plugin.name.lower():
self.media_dock.widget(dock_index).hide()
self.media_dock.widget(dock_index).setVisible(False)
self.media_dock.removeItem(dock_index)

View File

@ -78,11 +78,11 @@ class Ui_PluginViewDialog(object):
translate('OpenLP.PluginForm', 'Plugin List'))
self.pluginInfoGroupBox.setTitle(
translate('OpenLP.PluginForm', 'Plugin Details'))
self.versionLabel.setText(u'%s:' % UiStrings.Version)
self.aboutLabel.setText(u'%s:' % UiStrings.About)
self.versionLabel.setText(u'%s:' % UiStrings().Version)
self.aboutLabel.setText(u'%s:' % UiStrings().About)
self.statusLabel.setText(
translate('OpenLP.PluginForm', 'Status:'))
self.statusComboBox.setItemText(0,
translate('OpenLP.PluginForm', 'Active'))
self.statusComboBox.setItemText(1,
translate('OpenLP.PluginForm', 'Inactive'))
translate('OpenLP.PluginForm', 'Inactive'))

View File

@ -132,6 +132,8 @@ class Ui_PrintServiceDialog(object):
self.groupLayout = QtGui.QVBoxLayout()
self.slideTextCheckBox = QtGui.QCheckBox()
self.groupLayout.addWidget(self.slideTextCheckBox)
self.pageBreakAfterText = QtGui.QCheckBox()
self.groupLayout.addWidget(self.pageBreakAfterText)
self.notesCheckBox = QtGui.QCheckBox()
self.groupLayout.addWidget(self.notesCheckBox)
self.metaDataCheckBox = QtGui.QCheckBox()
@ -146,9 +148,11 @@ class Ui_PrintServiceDialog(object):
QtCore.SIGNAL(u'toggled(bool)'), self.toggleOptions)
def retranslateUi(self, printServiceDialog):
printServiceDialog.setWindowTitle(UiStrings.PrintServiceOrder)
printServiceDialog.setWindowTitle(UiStrings().PrintServiceOrder)
self.slideTextCheckBox.setText(translate('OpenLP.PrintServiceForm',
'Include slide text if available'))
self.pageBreakAfterText.setText(translate('OpenLP.PrintServiceForm',
'Add page break before each text item.'))
self.notesCheckBox.setText(translate('OpenLP.PrintServiceForm',
'Include service item notes'))
self.metaDataCheckBox.setText(translate('OpenLP.PrintServiceForm',
@ -160,4 +164,4 @@ class Ui_PrintServiceDialog(object):
self.zoomComboBox.addItem(ZoomSize.Sizes[ZoomSize.OneHundred])
self.zoomComboBox.addItem(ZoomSize.Sizes[ZoomSize.SeventyFive])
self.zoomComboBox.addItem(ZoomSize.Sizes[ZoomSize.Fifty])
self.zoomComboBox.addItem(ZoomSize.Sizes[ZoomSize.TwentyFive])
self.zoomComboBox.addItem(ZoomSize.Sizes[ZoomSize.TwentyFive])

View File

@ -24,12 +24,82 @@
# Temple Place, Suite 330, Boston, MA 02111-1307 USA #
###############################################################################
import datetime
import os
from PyQt4 import QtCore, QtGui
from lxml import html
from openlp.core.lib import translate
from openlp.core.lib import translate, get_text_file_string
from openlp.core.lib.ui import UiStrings
from openlp.core.ui.printservicedialog import Ui_PrintServiceDialog, ZoomSize
from openlp.core.utils import AppLocation
DEFAULT_CSS = """/*
Edit this file to customize the service order print. Note, that not all CSS
properties are supported. See:
http://doc.trolltech.com/4.7/richtext-html-subset.html#css-properties
*/
.serviceTitle {
font-weight:600;
font-size:x-large;
color:black;
}
.item {
color:black;
}
.itemTitle {
font-weight:600;
font-size:large;
}
.itemText {}
.itemFooter {
font-size:8px;
}
.itemNotes {}
.itemNotesTitle {
font-weight:bold;
font-size:12px;
}
.itemNotesText {
font-size:11px;
}
.media {}
.mediaTitle {
font-weight:bold;
font-size:11px;
}
.mediaText {}
.imageList {}
.customNotes {
margin-top: 10px;
}
.customNotesTitle {
font-weight:bold;
font-size:11px;
}
.customNotesText {
font-size:11px;
}
.newPage {
page-break-before:always;
}
"""
class PrintServiceForm(QtGui.QDialog, Ui_PrintServiceDialog):
@ -50,6 +120,10 @@ class PrintServiceForm(QtGui.QDialog, Ui_PrintServiceDialog):
settings.beginGroup(u'advanced')
self.slideTextCheckBox.setChecked(settings.value(
u'print slide text', QtCore.QVariant(False)).toBool())
self.pageBreakAfterText.setChecked(settings.value(
u'add page break', QtCore.QVariant(False)).toBool())
if not self.slideTextCheckBox.isChecked():
self.pageBreakAfterText.setDisabled(True)
self.metaDataCheckBox.setChecked(settings.value(
u'print file meta data', QtCore.QVariant(False)).toBool())
self.notesCheckBox.setChecked(settings.value(
@ -76,6 +150,9 @@ class PrintServiceForm(QtGui.QDialog, Ui_PrintServiceDialog):
QtCore.SIGNAL(u'triggered()'), self.copyText)
QtCore.QObject.connect(self.htmlCopy,
QtCore.SIGNAL(u'triggered()'), self.copyHtmlText)
QtCore.QObject.connect(self.slideTextCheckBox,
QtCore.SIGNAL(u'stateChanged(int)'),
self.onSlideTextCheckBoxChanged)
self.updatePreviewText()
def toggleOptions(self, checked):
@ -93,59 +170,121 @@ class PrintServiceForm(QtGui.QDialog, Ui_PrintServiceDialog):
"""
Creates the html text and updates the html of *self.document*.
"""
text = u''
if self.titleLineEdit.text():
text += u'<h2>%s</h2>' % unicode(self.titleLineEdit.text())
for item in self.serviceManager.serviceItems:
item = item[u'service_item']
# Add the title of the service item.
text += u'<h3><img src="%s" /> %s</h3>' % (item.icon,
item.get_display_title())
# Add slide text of the service item.
if self.slideTextCheckBox.isChecked():
if item.is_text():
# Add the text of the service item.
verse = None
for slide in item.get_frames():
if not verse:
text += u'<p>' + slide[u'html']
verse = slide[u'verseTag']
elif verse != slide[u'verseTag']:
text += u'<\p><p>' + slide[u'html']
verse = slide[u'verseTag']
else:
text += u'<br/>' + slide[u'html']
text += u'</p>'
elif item.is_image():
# Add the image names of the service item.
text += u'<ol>'
for slide in range(len(item.get_frames())):
text += u'<li><p>%s</p></li>' % \
item.get_frame_title(slide)
text += u'</ol>'
if item.foot_text:
# add footer
text += u'<p>%s</p>' % item.foot_text
# Add service items' notes.
if self.notesCheckBox.isChecked():
if item.notes:
text += u'<p><strong>%s</strong></p>%s' % (translate(
'OpenLP.ServiceManager', 'Notes:'),
item.notes.replace(u'\n', u'<br />'))
# Add play length of media files.
if item.is_media() and self.metaDataCheckBox.isChecked():
tme = item.media_length
if item.end_time > 0:
tme = item.end_time - item.start_time
text += u'<p><strong>%s</strong> %s</p>' % (translate(
'OpenLP.ServiceManager', u'Playing time:'),
unicode(datetime.timedelta(seconds=tme)))
html_data = self._addElement(u'html')
self._addElement(u'head', parent=html_data)
self._addElement(u'title', unicode(self.titleLineEdit.text()),
html_data.head)
css_path = os.path.join(
AppLocation.get_data_path(), u'service_print.css')
custom_css = get_text_file_string(css_path)
if not custom_css:
custom_css = DEFAULT_CSS
self._addElement(u'style', custom_css, html_data.head,
attribute=(u'type', u'text/css'))
self._addElement(u'body', parent=html_data)
self._addElement(u'h1', unicode(self.titleLineEdit.text()),
html_data.body, classId=u'serviceTitle')
for index, item in enumerate(self.serviceManager.serviceItems):
self._addPreviewItem(html_data.body, item[u'service_item'], index)
# Add the custom service notes:
if self.footerTextEdit.toPlainText():
text += u'<h4>%s</h4>%s' % (translate('OpenLP.ServiceManager',
u'Custom Service Notes:'), self.footerTextEdit.toPlainText())
self.document.setHtml(text)
div = self._addElement(u'div', parent=html_data.body,
classId=u'customNotes')
self._addElement(u'span', translate('OpenLP.ServiceManager',
'Custom Service Notes: '), div, classId=u'customNotesTitle')
self._addElement(u'span', self.footerTextEdit.toPlainText(), div,
classId=u'customNotesText')
self.document.setHtml(html.tostring(html_data))
self.previewWidget.updatePreview()
def _addPreviewItem(self, body, item, index):
div = self._addElement(u'div', classId=u'item', parent=body)
# Add the title of the service item.
item_title = self._addElement(u'h2', parent=div, classId=u'itemTitle')
self._addElement(u'img', parent=item_title,
attribute=(u'src', item.icon))
self._addElement(u'span', u'&nbsp;' + item.get_display_title(),
item_title)
if self.slideTextCheckBox.isChecked():
# Add the text of the service item.
if item.is_text():
verse_def = None
for slide in item.get_frames():
if not verse_def or verse_def != slide[u'verseTag']:
p = self._addElement(u'div', parent=div,
classId=u'itemText')
else:
self._addElement(u'br', parent=p)
self._addElement(u'p', slide[u'html'], p)
verse_def = slide[u'verseTag']
# Break the page before the div element.
if index != 0 and self.pageBreakAfterText.isChecked():
div.set(u'class', u'item newPage')
# Add the image names of the service item.
elif item.is_image():
ol = self._addElement(u'ol', parent=div, classId=u'imageList')
for slide in range(len(item.get_frames())):
self._addElement(u'li', item.get_frame_title(slide), ol)
# add footer
foot_text = item.foot_text
foot_text = foot_text.partition(u'<br>')[2]
if foot_text:
foot = self._addElement(u'div', foot_text, parent=div,
classId=u'itemFooter')
# Add service items' notes.
if self.notesCheckBox.isChecked():
if item.notes:
p = self._addElement(u'div', classId=u'itemNotes', parent=div)
self._addElement(u'span',
translate('OpenLP.ServiceManager', 'Notes: '), p,
classId=u'itemNotesTitle')
notes = self._addElement(u'span',
item.notes.replace(u'\n', u'<br />'), p,
classId=u'itemNotesText')
# Add play length of media files.
if item.is_media() and self.metaDataCheckBox.isChecked():
tme = item.media_length
if item.end_time > 0:
tme = item.end_time - item.start_time
title = self._addElement(u'div', classId=u'media', parent=div)
self._addElement(u'span', translate('OpenLP.ServiceManager',
'Playing time: '), title, classId=u'mediaTitle')
self._addElement(u'span', unicode(datetime.timedelta(seconds=tme)),
title, classId=u'mediaText')
def _addElement(self, tag, text=None, parent=None, classId=None,
attribute=None):
"""
Creates a html element. If ``text`` is given, the element's text will
set and if a ``parent`` is given, the element is appended.
``tag``
The html tag, e. g. ``u'span'``. Defaults to ``None``.
``text``
The text for the tag. Defaults to ``None``.
``parent``
The parent element. Defaults to ``None``.
``classId``
Value for the class attribute
``attribute``
Tuple name/value pair to add as an optional attribute
"""
if text is not None:
element = html.fragment_fromstring(unicode(text), create_parent=tag)
else:
element = html.Element(tag)
if parent is not None:
parent.append(element)
if classId is not None:
element.set(u'class', classId)
if attribute is not None:
element.set(attribute[0], attribute[1])
return element
def paintRequested(self, printer):
"""
Paint the preview of the *self.document*.
@ -228,9 +367,16 @@ class PrintServiceForm(QtGui.QDialog, Ui_PrintServiceDialog):
Called when html copy check box is selected.
"""
if value == QtCore.Qt.Checked:
self.copyTextButton.setText(UiStrings.CopyToHtml)
self.copyTextButton.setText(UiStrings().CopyToHtml)
else:
self.copyTextButton.setText(UiStrings.CopyToText)
self.copyTextButton.setText(UiStrings().CopyToText)
def onSlideTextCheckBoxChanged(self, state):
"""
Disable or enable the ``pageBreakAfterText`` checkbox as it should only
be enabled, when the ``slideTextCheckBox`` is enabled.
"""
self.pageBreakAfterText.setDisabled(state == QtCore.Qt.Unchecked)
def saveOptions(self):
"""
@ -241,6 +387,8 @@ class PrintServiceForm(QtGui.QDialog, Ui_PrintServiceDialog):
settings.beginGroup(u'advanced')
settings.setValue(u'print slide text',
QtCore.QVariant(self.slideTextCheckBox.isChecked()))
settings.setValue(u'add page break',
QtCore.QVariant(self.pageBreakAfterText.isChecked()))
settings.setValue(u'print file meta data',
QtCore.QVariant(self.metaDataCheckBox.isChecked()))
settings.setValue(u'print notes',

View File

@ -32,14 +32,16 @@ log = logging.getLogger(__name__)
from PyQt4 import QtCore, QtGui
from openlp.core.lib import OpenLPToolbar, ServiceItem, context_menu_action, \
Receiver, build_icon, ItemCapabilities, SettingsManager, translate
from openlp.core.lib import OpenLPToolbar, ServiceItem, Receiver, build_icon, \
ItemCapabilities, SettingsManager, translate
from openlp.core.lib.theme import ThemeLevel
from openlp.core.lib.ui import UiStrings, critical_error_message_box
from openlp.core.lib.ui import UiStrings, critical_error_message_box, \
context_menu_action, find_and_set_in_combo_box
from openlp.core.ui import ServiceNoteForm, ServiceItemEditForm, StartTimeForm
from openlp.core.ui.printserviceform import PrintServiceForm
from openlp.core.utils import AppLocation, delete_file, file_is_unicode, \
split_filename
from openlp.core.utils.actions import ActionList, CategoryOrder
class ServiceManagerList(QtGui.QTreeWidget):
"""
@ -109,18 +111,18 @@ class ServiceManager(QtGui.QWidget):
# Create the top toolbar
self.toolbar = OpenLPToolbar(self)
self.toolbar.addToolbarButton(
UiStrings.NewService, u':/general/general_new.png',
UiStrings.CreateService, self.onNewServiceClicked)
UiStrings().NewService, u':/general/general_new.png',
UiStrings().CreateService, self.onNewServiceClicked)
self.toolbar.addToolbarButton(
UiStrings.OpenService, u':/general/general_open.png',
UiStrings().OpenService, u':/general/general_open.png',
translate('OpenLP.ServiceManager', 'Load an existing service'),
self.onLoadServiceClicked)
self.toolbar.addToolbarButton(
UiStrings.SaveService, u':/general/general_save.png',
UiStrings().SaveService, u':/general/general_save.png',
translate('OpenLP.ServiceManager', 'Save this service'),
self.saveFile)
self.toolbar.addSeparator()
self.themeLabel = QtGui.QLabel(u'%s:' % UiStrings.Theme, self)
self.themeLabel = QtGui.QLabel(u'%s:' % UiStrings().Theme, self)
self.themeLabel.setMargin(3)
self.themeLabel.setObjectName(u'themeLabel')
self.toolbar.addToolbarWidget(u'ThemeLabel', self.themeLabel)
@ -164,38 +166,57 @@ class ServiceManager(QtGui.QWidget):
u':/services/service_top.png',
translate('OpenLP.ServiceManager',
'Move item to the top of the service.'),
self.onServiceTop, shortcut=QtCore.Qt.Key_Home)
self.onServiceTop, shortcuts=[QtCore.Qt.Key_Home])
self.serviceManagerList.moveTop.setObjectName(u'moveTop')
action_list = ActionList.get_instance()
action_list.add_category(
UiStrings().Service, CategoryOrder.standardToolbar)
action_list.add_action(
self.serviceManagerList.moveTop, UiStrings().Service)
self.serviceManagerList.moveUp = self.orderToolbar.addToolbarButton(
translate('OpenLP.ServiceManager', 'Move &up'),
u':/services/service_up.png',
translate('OpenLP.ServiceManager',
'Move item up one position in the service.'),
self.onServiceUp, shortcut=QtCore.Qt.Key_PageUp)
self.onServiceUp, shortcuts=[QtCore.Qt.Key_PageUp])
self.serviceManagerList.moveUp.setObjectName(u'moveUp')
action_list.add_action(
self.serviceManagerList.moveUp, UiStrings().Service)
self.serviceManagerList.moveDown = self.orderToolbar.addToolbarButton(
translate('OpenLP.ServiceManager', 'Move &down'),
u':/services/service_down.png',
translate('OpenLP.ServiceManager',
'Move item down one position in the service.'),
self.onServiceDown, shortcut=QtCore.Qt.Key_PageDown)
self.onServiceDown, shortcuts=[QtCore.Qt.Key_PageDown])
self.serviceManagerList.moveDown.setObjectName(u'moveDown')
action_list.add_action(
self.serviceManagerList.moveDown, UiStrings().Service)
self.serviceManagerList.moveBottom = self.orderToolbar.addToolbarButton(
translate('OpenLP.ServiceManager', 'Move to &bottom'),
u':/services/service_bottom.png',
translate('OpenLP.ServiceManager',
'Move item to the end of the service.'),
self.onServiceEnd, shortcut=QtCore.Qt.Key_End)
self.onServiceEnd, shortcuts=[QtCore.Qt.Key_End])
self.serviceManagerList.moveBottom.setObjectName(u'moveBottom')
action_list.add_action(
self.serviceManagerList.moveBottom, UiStrings().Service)
self.serviceManagerList.down = self.orderToolbar.addToolbarButton(
translate('OpenLP.ServiceManager', 'Move &down'),
None,
translate('OpenLP.ServiceManager',
'Moves the selection down the window.'),
self.onMoveSelectionDown, shortcut=QtCore.Qt.Key_Down)
self.onMoveSelectionDown, shortcuts=[QtCore.Qt.Key_Down])
self.serviceManagerList.down.setObjectName(u'down')
action_list.add_action(self.serviceManagerList.down)
self.serviceManagerList.down.setVisible(False)
self.serviceManagerList.up = self.orderToolbar.addToolbarButton(
translate('OpenLP.ServiceManager', 'Move up'),
None,
translate('OpenLP.ServiceManager',
'Moves the selection up the window.'),
self.onMoveSelectionUp, shortcut=QtCore.Qt.Key_Up)
self.onMoveSelectionUp, shortcuts=[QtCore.Qt.Key_Up])
self.serviceManagerList.up.setObjectName(u'up')
action_list.add_action(self.serviceManagerList.up)
self.serviceManagerList.up.setVisible(False)
self.orderToolbar.addSeparator()
self.serviceManagerList.delete = self.orderToolbar.addToolbarButton(
@ -210,22 +231,29 @@ class ServiceManager(QtGui.QWidget):
u':/services/service_expand_all.png',
translate('OpenLP.ServiceManager',
'Expand all the service items.'),
self.onExpandAll, shortcut=QtCore.Qt.Key_Plus)
self.onExpandAll, shortcuts=[QtCore.Qt.Key_Plus])
self.serviceManagerList.expand.setObjectName(u'expand')
action_list.add_action(
self.serviceManagerList.expand, UiStrings().Service)
self.serviceManagerList.collapse = self.orderToolbar.addToolbarButton(
translate('OpenLP.ServiceManager', '&Collapse all'),
u':/services/service_collapse_all.png',
translate('OpenLP.ServiceManager',
'Collapse all the service items.'),
self.onCollapseAll, shortcut=QtCore.Qt.Key_Minus)
self.onCollapseAll, shortcuts=[QtCore.Qt.Key_Minus])
self.serviceManagerList.collapse.setObjectName(u'collapse')
action_list.add_action(
self.serviceManagerList.collapse, UiStrings().Service)
self.orderToolbar.addSeparator()
self.serviceManagerList.makeLive = self.orderToolbar.addToolbarButton(
translate('OpenLP.ServiceManager', 'Go Live'),
u':/general/general_live.png',
translate('OpenLP.ServiceManager',
'Send the selected item to Live.'),
self.makeLive, shortcut=QtCore.Qt.Key_Enter,
alternate=QtCore.Qt.Key_Return)
self.orderToolbar.setObjectName(u'orderToolbar')
'Send the selected item to Live.'), self.makeLive,
shortcuts=[QtCore.Qt.Key_Enter, QtCore.Qt.Key_Return])
self.serviceManagerList.makeLive.setObjectName(u'orderToolbar')
action_list.add_action(
self.serviceManagerList.makeLive, UiStrings().Service)
self.layout.addWidget(self.orderToolbar)
# Connect up our signals and slots
QtCore.QObject.connect(self.themeComboBox,
@ -300,7 +328,6 @@ class ServiceManager(QtGui.QWidget):
self.themeMenu = QtGui.QMenu(
translate('OpenLP.ServiceManager', '&Change Item Theme'))
self.menu.addMenu(self.themeMenu)
self.setServiceHotkeys()
self.serviceManagerList.addActions(
[self.serviceManagerList.moveDown,
self.serviceManagerList.moveUp,
@ -314,26 +341,14 @@ class ServiceManager(QtGui.QWidget):
])
self.configUpdated()
def setServiceHotkeys(self):
actionList = self.mainwindow.actionList
actionList.add_action(self.serviceManagerList.moveDown, u'Service')
actionList.add_action(self.serviceManagerList.moveUp, u'Service')
actionList.add_action(self.serviceManagerList.moveTop, u'Service')
actionList.add_action(self.serviceManagerList.moveBottom, u'Service')
actionList.add_action(self.serviceManagerList.makeLive, u'Service')
actionList.add_action(self.serviceManagerList.up, u'Service')
actionList.add_action(self.serviceManagerList.down, u'Service')
actionList.add_action(self.serviceManagerList.expand, u'Service')
actionList.add_action(self.serviceManagerList.collapse, u'Service')
def setModified(self, modified=True):
"""
Setter for property "modified". Sets whether or not the current service
has been modified.
"""
self._modified = modified
serviceFile = self.shortFileName() or u'Untitled Service'
serviceFile = self.shortFileName() or translate(
'OpenLP.ServiceManager', 'Untitled Service')
self.mainwindow.setServiceModified(modified, serviceFile)
def isModified(self):
@ -514,7 +529,7 @@ class ServiceManager(QtGui.QWidget):
save the file.
"""
fileName = unicode(QtGui.QFileDialog.getSaveFileName(self.mainwindow,
UiStrings.SaveService,
UiStrings().SaveService,
SettingsManager.get_last_dir(
self.mainwindow.serviceSettingsSection),
translate('OpenLP.ServiceManager', 'OpenLP Service Files (*.osz)')))
@ -600,7 +615,7 @@ class ServiceManager(QtGui.QWidget):
u'%s' % fileName)
QtGui.QMessageBox.information(self,
translate('OpenLP.ServiceManager', 'Corrupt File'),
translate('OpenLP.ServiceManager', 'This file is either'
translate('OpenLP.ServiceManager', 'This file is either '
'corrupt or not an OpenLP 2.0 service file.'))
return
finally:
@ -671,6 +686,7 @@ class ServiceManager(QtGui.QWidget):
self.serviceItems[item][u'service_item'].notes = \
self.serviceNoteForm.textEdit.toPlainText()
self.repaintServiceList(item, -1)
self.setModified()
def onStartTimeForm(self):
item = self.findServiceItem()[0]
@ -691,9 +707,9 @@ class ServiceManager(QtGui.QWidget):
Called by the SlideController to request a preview item be made live
and allows the next preview to be updated if relevent.
"""
id, row = message.split(u':')
uuid, row = message.split(u':')
for sitem in self.serviceItems:
if sitem[u'service_item']._uuid == id:
if sitem[u'service_item']._uuid == uuid:
item = self.serviceManagerList.topLevelItem(sitem[u'order'] - 1)
self.serviceManagerList.setCurrentItem(item)
self.makeLive(int(row))
@ -774,7 +790,7 @@ class ServiceManager(QtGui.QWidget):
# Top Item was selected so set the last one
if setLastItem:
lastItem.setSelected(True)
self.setModified(True)
self.setModified()
def onMoveSelectionDown(self):
"""
@ -796,7 +812,7 @@ class ServiceManager(QtGui.QWidget):
serviceIterator += 1
if setSelected:
firstItem.setSelected(True)
self.setModified(True)
self.setModified()
def onCollapseAll(self):
"""
@ -840,7 +856,7 @@ class ServiceManager(QtGui.QWidget):
self.serviceItems.remove(self.serviceItems[item])
self.serviceItems.insert(0, temp)
self.repaintServiceList(0, child)
self.setModified(True)
self.setModified()
def onServiceUp(self):
"""
@ -852,7 +868,7 @@ class ServiceManager(QtGui.QWidget):
self.serviceItems.remove(self.serviceItems[item])
self.serviceItems.insert(item - 1, temp)
self.repaintServiceList(item - 1, child)
self.setModified(True)
self.setModified()
def onServiceDown(self):
"""
@ -864,7 +880,7 @@ class ServiceManager(QtGui.QWidget):
self.serviceItems.remove(self.serviceItems[item])
self.serviceItems.insert(item + 1, temp)
self.repaintServiceList(item + 1, child)
self.setModified(True)
self.setModified()
def onServiceEnd(self):
"""
@ -876,7 +892,7 @@ class ServiceManager(QtGui.QWidget):
self.serviceItems.remove(self.serviceItems[item])
self.serviceItems.insert(len(self.serviceItems), temp)
self.repaintServiceList(len(self.serviceItems) - 1, child)
self.setModified(True)
self.setModified()
def onDeleteFromService(self):
"""
@ -886,7 +902,7 @@ class ServiceManager(QtGui.QWidget):
if item != -1:
self.serviceItems.remove(self.serviceItems[item])
self.repaintServiceList(item - 1, -1)
self.setModified(True)
self.setModified()
def repaintServiceList(self, serviceItem, serviceItemChild):
"""
@ -1011,7 +1027,7 @@ class ServiceManager(QtGui.QWidget):
item[u'service_item'], False, expand=item[u'expanded'])
# Set to False as items may have changed rendering
# does not impact the saved song so True may also be valid
self.setModified(True)
self.setModified()
Receiver.send_message(u'cursor_normal')
def serviceItemUpdate(self, message):
@ -1021,8 +1037,8 @@ class ServiceManager(QtGui.QWidget):
editId, uuid = message.split(u':')
for item in self.serviceItems:
if item[u'service_item']._uuid == uuid:
item[u'service_item'].edit_id = editId
self.setModified(True)
item[u'service_item'].edit_id = int(editId)
self.setModified()
def replaceServiceItem(self, newItem):
"""
@ -1038,7 +1054,7 @@ class ServiceManager(QtGui.QWidget):
self.repaintServiceList(itemcount + 1, 0)
self.mainwindow.liveController.replaceServiceManagerItem(
newItem)
self.setModified(True)
self.setModified()
def addServiceItem(self, item, rebuild=False, expand=None, replace=False):
"""
@ -1083,7 +1099,7 @@ class ServiceManager(QtGui.QWidget):
if rebuild:
self.mainwindow.liveController.replaceServiceManagerItem(item)
self.dropPosition = 0
self.setModified(True)
self.setModified()
def makePreview(self):
"""
@ -1220,7 +1236,7 @@ class ServiceManager(QtGui.QWidget):
self.serviceItems.remove(serviceItem)
self.serviceItems.insert(endpos, serviceItem)
self.repaintServiceList(endpos, child)
self.setModified(True)
self.setModified()
else:
# we are not over anything so drop
replace = False
@ -1259,15 +1275,9 @@ class ServiceManager(QtGui.QWidget):
for theme in theme_list:
self.themeComboBox.addItem(theme)
action = context_menu_action(self.serviceManagerList, None, theme,
self.onThemeChangeAction)
self.onThemeChangeAction, context=QtCore.Qt.WidgetShortcut)
self.themeMenu.addAction(action)
index = self.themeComboBox.findText(self.service_theme,
QtCore.Qt.MatchExactly)
# Not Found
if index == -1:
index = 0
self.service_theme = u''
self.themeComboBox.setCurrentIndex(index)
find_and_set_in_combo_box(self.themeComboBox, self.service_theme)
self.mainwindow.renderManager.set_service_theme(self.service_theme)
self.regenerateServiceItems()

View File

@ -32,18 +32,29 @@ from openlp.core.lib.ui import create_accept_reject_button_box
class Ui_SettingsDialog(object):
def setupUi(self, settingsDialog):
settingsDialog.setObjectName(u'settingsDialog')
settingsDialog.resize(700, 500)
settingsDialog.resize(800, 500)
settingsDialog.setWindowIcon(
build_icon(u':/system/system_settings.png'))
self.settingsLayout = QtGui.QVBoxLayout(settingsDialog)
self.settingsLayout.setObjectName(u'settingsLayout')
self.settingsTabWidget = QtGui.QTabWidget(settingsDialog)
self.settingsTabWidget.setObjectName(u'settingsTabWidget')
self.settingsLayout.addWidget(self.settingsTabWidget)
self.dialogLayout = QtGui.QGridLayout(settingsDialog)
self.dialogLayout.setObjectName(u'dialogLayout')
self.dialogLayout.setMargin(8)
self.settingListWidget = QtGui.QListWidget(settingsDialog)
self.settingListWidget.setUniformItemSizes(True)
self.settingListWidget.setMinimumSize(QtCore.QSize(150, 0))
self.settingListWidget.setHorizontalScrollBarPolicy(
QtCore.Qt.ScrollBarAlwaysOff)
self.settingListWidget.setObjectName(u'settingListWidget')
self.dialogLayout.addWidget(self.settingListWidget, 0, 0, 1, 1)
self.stackedLayout = QtGui.QStackedLayout()
self.stackedLayout.setObjectName(u'stackedLayout')
self.dialogLayout.addLayout(self.stackedLayout, 0, 1, 1, 1)
self.buttonBox = create_accept_reject_button_box(settingsDialog, True)
self.settingsLayout.addWidget(self.buttonBox)
self.dialogLayout.addWidget(self.buttonBox, 1, 1, 1, 1)
self.retranslateUi(settingsDialog)
QtCore.QMetaObject.connectSlotsByName(settingsDialog)
QtCore.QObject.connect(self.settingListWidget,
QtCore.SIGNAL(u'currentRowChanged(int)'),
self.stackedLayout.setCurrentIndex)
def retranslateUi(self, settingsDialog):
settingsDialog.setWindowTitle(translate('OpenLP.SettingsForm',

View File

@ -28,9 +28,9 @@ The :mod:`settingsform` provides a user interface for the OpenLP settings
"""
import logging
from PyQt4 import QtGui
from PyQt4 import QtGui, QtCore
from openlp.core.lib import Receiver
from openlp.core.lib import Receiver, build_icon, PluginStatus
from openlp.core.ui import AdvancedTab, GeneralTab, ThemesTab
from settingsdialog import Ui_SettingsDialog
@ -47,48 +47,52 @@ class SettingsForm(QtGui.QDialog, Ui_SettingsDialog):
QtGui.QDialog.__init__(self, parent)
self.setupUi(self)
# General tab
generalTab = GeneralTab(screens)
self.addTab(u'General', generalTab)
self.generalTab = GeneralTab(self, screens)
# Themes tab
themesTab = ThemesTab(mainWindow)
self.addTab(u'Themes', themesTab)
self.themesTab = ThemesTab(self, mainWindow)
# Advanced tab
advancedTab = AdvancedTab()
self.addTab(u'Advanced', advancedTab)
self.advancedTab = AdvancedTab(self)
def addTab(self, name, tab):
"""
Add a tab to the form
"""
log.info(u'Adding %s tab' % tab.tabTitle)
self.settingsTabWidget.addTab(tab, tab.tabTitleVisible)
def exec_(self):
# load all the settings
self.settingListWidget.clear()
for tabIndex in range(0, self.stackedLayout.count() + 1):
# take at 0 and the rest shuffell up.
self.stackedLayout.takeAt(0)
self.insertTab(self.generalTab, 0, PluginStatus.Active)
self.insertTab(self.themesTab, 1, PluginStatus.Active)
self.insertTab(self.advancedTab, 2, PluginStatus.Active)
count = 3
for plugin in self.plugins:
if plugin.settings_tab:
self.insertTab(plugin.settings_tab, count, plugin.status)
count += 1
self.settingListWidget.setCurrentRow(0)
return QtGui.QDialog.exec_(self)
def insertTab(self, tab, location):
def insertTab(self, tab, location, is_active):
"""
Add a tab to the form at a specific location
"""
log.debug(u'Inserting %s tab' % tab.tabTitle)
# 14 : There are 3 tables currently and locations starts at -10
self.settingsTabWidget.insertTab(
location + 14, tab, tab.tabTitleVisible)
def removeTab(self, tab):
"""
Remove a tab from the form
"""
log.debug(u'remove %s tab' % tab.tabTitleVisible)
for tabIndex in range(0, self.settingsTabWidget.count()):
if self.settingsTabWidget.widget(tabIndex):
if self.settingsTabWidget.widget(tabIndex).tabTitleVisible == \
tab.tabTitleVisible:
self.settingsTabWidget.removeTab(tabIndex)
# add the tab to get it to display in the correct part of the screen
pos = self.stackedLayout.addWidget(tab)
if is_active:
item_name = QtGui.QListWidgetItem(tab.tabTitleVisible)
icon = build_icon(tab.icon_path)
item_name.setIcon(icon)
self.settingListWidget.insertItem(location, item_name)
else:
# then remove tab to stop the UI displaying it even if
# it is not required.
self.stackedLayout.takeAt(pos)
def accept(self):
"""
Process the form saving the settings
"""
for tabIndex in range(0, self.settingsTabWidget.count()):
self.settingsTabWidget.widget(tabIndex).save()
for tabIndex in range(0, self.stackedLayout.count()):
self.stackedLayout.widget(tabIndex).save()
# Must go after all settings are save
Receiver.send_message(u'config_updated')
return QtGui.QDialog.accept(self)
@ -97,13 +101,17 @@ class SettingsForm(QtGui.QDialog, Ui_SettingsDialog):
"""
Process the form saving the settings
"""
for tabIndex in range(0, self.settingsTabWidget.count()):
self.settingsTabWidget.widget(tabIndex).cancel()
for tabIndex in range(0, self.stackedLayout.count()):
self.stackedLayout.widget(tabIndex).cancel()
return QtGui.QDialog.reject(self)
def postSetUp(self):
"""
Run any post-setup code for the tabs on the form
"""
for tabIndex in range(0, self.settingsTabWidget.count()):
self.settingsTabWidget.widget(tabIndex).postSetUp()
self.generalTab.postSetUp()
self.themesTab.postSetUp()
self.advancedTab.postSetUp()
for plugin in self.plugins:
if plugin.settings_tab:
plugin.settings_tab.postSetUp()

View File

@ -31,41 +31,72 @@ from openlp.core.lib import translate, build_icon
class Ui_ShortcutListDialog(object):
def setupUi(self, shortcutListDialog):
shortcutListDialog.setObjectName(u'shortcutListDialog')
self.dialogLayout = QtGui.QVBoxLayout(shortcutListDialog)
self.dialogLayout.setObjectName(u'dialogLayout')
shortcutListDialog.resize(500, 438)
self.shortcutListLayout = QtGui.QVBoxLayout(shortcutListDialog)
self.shortcutListLayout.setObjectName(u'shortcutListLayout')
self.descriptionLabel = QtGui.QLabel(shortcutListDialog)
self.descriptionLabel.setObjectName(u'descriptionLabel')
self.descriptionLabel.setWordWrap(True)
self.shortcutListLayout.addWidget(self.descriptionLabel)
self.treeWidget = QtGui.QTreeWidget(shortcutListDialog)
self.treeWidget.setAlternatingRowColors(True)
self.treeWidget.setObjectName(u'treeWidget')
self.treeWidget.setAlternatingRowColors(True)
self.treeWidget.setColumnCount(3)
self.dialogLayout.addWidget(self.treeWidget)
self.defaultButton = QtGui.QRadioButton(shortcutListDialog)
self.defaultButton.setChecked(True)
self.defaultButton.setObjectName(u'defaultButton')
self.dialogLayout.addWidget(self.defaultButton)
self.customLayout = QtGui.QHBoxLayout()
self.customLayout.setObjectName(u'customLayout')
self.customButton = QtGui.QRadioButton(shortcutListDialog)
self.customButton.setObjectName(u'customButton')
self.customLayout.addWidget(self.customButton)
self.shortcutButton = QtGui.QPushButton(shortcutListDialog)
self.shortcutButton.setIcon(
self.treeWidget.setColumnWidth(0, 250)
self.shortcutListLayout.addWidget(self.treeWidget)
self.detailsLayout = QtGui.QGridLayout()
self.detailsLayout.setObjectName(u'detailsLayout')
self.detailsLayout.setContentsMargins(-1, 0, -1, -1)
self.defaultRadioButton = QtGui.QRadioButton(shortcutListDialog)
self.defaultRadioButton.setObjectName(u'defaultRadioButton')
self.defaultRadioButton.setChecked(True)
self.detailsLayout.addWidget(self.defaultRadioButton, 0, 0, 1, 1)
self.customRadioButton = QtGui.QRadioButton(shortcutListDialog)
self.customRadioButton.setObjectName(u'customRadioButton')
self.detailsLayout.addWidget(self.customRadioButton, 1, 0, 1, 1)
self.primaryLayout = QtGui.QHBoxLayout()
self.primaryLayout.setObjectName(u'primaryLayout')
self.primaryPushButton = QtGui.QPushButton(shortcutListDialog)
self.primaryPushButton.setObjectName(u'primaryPushButton')
self.primaryPushButton.setMinimumSize(QtCore.QSize(84, 0))
self.primaryPushButton.setIcon(
build_icon(u':/system/system_configure_shortcuts.png'))
self.shortcutButton.setCheckable(True)
self.shortcutButton.setObjectName(u'shortcutButton')
self.customLayout.addWidget(self.shortcutButton)
self.clearShortcutButton = QtGui.QToolButton(shortcutListDialog)
self.clearShortcutButton.setIcon(
self.primaryPushButton.setCheckable(True)
self.primaryLayout.addWidget(self.primaryPushButton)
self.clearPrimaryButton = QtGui.QToolButton(shortcutListDialog)
self.clearPrimaryButton.setObjectName(u'clearPrimaryButton')
self.clearPrimaryButton.setMinimumSize(QtCore.QSize(0, 16))
self.clearPrimaryButton.setIcon(
build_icon(u':/system/clear_shortcut.png'))
self.clearShortcutButton.setAutoRaise(True)
self.clearShortcutButton.setObjectName(u'clearShortcutButton')
self.customLayout.addWidget(self.clearShortcutButton)
self.customLayout.addStretch()
self.dialogLayout.addLayout(self.customLayout)
self.primaryLayout.addWidget(self.clearPrimaryButton)
self.detailsLayout.addLayout(self.primaryLayout, 1, 1, 1, 1)
self.alternateLayout = QtGui.QHBoxLayout()
self.alternateLayout.setObjectName(u'alternateLayout')
self.alternatePushButton = QtGui.QPushButton(shortcutListDialog)
self.alternatePushButton.setObjectName(u'alternatePushButton')
self.alternatePushButton.setCheckable(True)
self.alternatePushButton.setIcon(
build_icon(u':/system/system_configure_shortcuts.png'))
self.alternateLayout.addWidget(self.alternatePushButton)
self.clearAlternateButton = QtGui.QToolButton(shortcutListDialog)
self.clearAlternateButton.setObjectName(u'clearAlternateButton')
self.clearAlternateButton.setIcon(
build_icon(u':/system/clear_shortcut.png'))
self.alternateLayout.addWidget(self.clearAlternateButton)
self.detailsLayout.addLayout(self.alternateLayout, 1, 2, 1, 1)
self.primaryLabel = QtGui.QLabel(shortcutListDialog)
self.primaryLabel.setObjectName(u'primaryLabel')
self.detailsLayout.addWidget(self.primaryLabel, 0, 1, 1, 1)
self.alternateLabel = QtGui.QLabel(shortcutListDialog)
self.alternateLabel.setObjectName(u'alternateLabel')
self.detailsLayout.addWidget(self.alternateLabel, 0, 2, 1, 1)
self.shortcutListLayout.addLayout(self.detailsLayout)
self.buttonBox = QtGui.QDialogButtonBox(shortcutListDialog)
self.buttonBox.setStandardButtons(QtGui.QDialogButtonBox.Cancel |
QtGui.QDialogButtonBox.Ok | QtGui.QDialogButtonBox.Reset)
self.buttonBox.setObjectName(u'buttonBox')
self.dialogLayout.addWidget(self.buttonBox)
self.buttonBox.setOrientation(QtCore.Qt.Horizontal)
self.buttonBox.setStandardButtons(QtGui.QDialogButtonBox.Cancel |
QtGui.QDialogButtonBox.Ok | QtGui.QDialogButtonBox.RestoreDefaults)
self.shortcutListLayout.addWidget(self.buttonBox)
self.retranslateUi(shortcutListDialog)
QtCore.QObject.connect(self.buttonBox, QtCore.SIGNAL(u'accepted()'),
shortcutListDialog.accept)
@ -76,13 +107,24 @@ class Ui_ShortcutListDialog(object):
def retranslateUi(self, shortcutListDialog):
shortcutListDialog.setWindowTitle(
translate('OpenLP.ShortcutListDialog', 'Customize Shortcuts'))
self.descriptionLabel.setText(translate('OpenLP.ShortcutListDialog',
'Select an action and click one of the buttons below to start '
'capturing a new primary or alternate shortcut, respectively.'))
self.treeWidget.setHeaderLabels([
translate('OpenLP.ShortcutListDialog', 'Action'),
translate('OpenLP.ShortcutListDialog', 'Shortcut'),
translate('OpenLP.ShortcutListDialog', 'Alternate')])
self.defaultButton.setText(
translate('OpenLP.ShortcutListDialog', 'Default: %s'))
self.customButton.setText(
translate('OpenLP.ShortcutListDialog', 'Custom:'))
self.shortcutButton.setText(
translate('OpenLP.ShortcutListDialog', 'None'))
self.defaultRadioButton.setText(
translate('OpenLP.ShortcutListDialog', 'Default'))
self.customRadioButton.setText(
translate('OpenLP.ShortcutListDialog', 'Custom'))
self.primaryPushButton.setToolTip(
translate('OpenLP.ShortcutListDialog', 'Capture shortcut.'))
self.alternatePushButton.setToolTip(
translate('OpenLP.ShortcutListDialog', 'Capture shortcut.'))
self.clearPrimaryButton.setToolTip(
translate('OpenLP.ShortcutListDialog',
'Restore the default shortcut of this action.'))
self.clearAlternateButton.setToolTip(
translate('OpenLP.ShortcutListDialog',
'Restore the default shortcut of this action.'))

View File

@ -29,7 +29,9 @@ import re
from PyQt4 import QtCore, QtGui
from openlp.core.lib import Receiver
from openlp.core.utils import translate
from openlp.core.utils.actions import ActionList
from shortcutlistdialog import Ui_ShortcutListDialog
REMOVE_AMPERSAND = re.compile(r'&{1}')
@ -41,72 +43,421 @@ class ShortcutListForm(QtGui.QDialog, Ui_ShortcutListDialog):
The shortcut list dialog
"""
def __init__(self, parent):
"""
Do some initialisation stuff
"""
def __init__(self, parent=None):
QtGui.QDialog.__init__(self, parent)
self.setupUi(self)
self.actionList = None
self.captureShortcut = False
QtCore.QObject.connect(self.shortcutButton,
QtCore.SIGNAL(u'toggled(bool)'), self.onShortcutButtonClicked)
self.changedActions = {}
self.action_list = ActionList.get_instance()
QtCore.QObject.connect(self.primaryPushButton,
QtCore.SIGNAL(u'toggled(bool)'), self.onPrimaryPushButtonClicked)
QtCore.QObject.connect(self.alternatePushButton,
QtCore.SIGNAL(u'toggled(bool)'), self.onAlternatePushButtonClicked)
QtCore.QObject.connect(self.treeWidget, QtCore.SIGNAL(
u'currentItemChanged(QTreeWidgetItem*, QTreeWidgetItem*)'),
self.onCurrentItemChanged)
QtCore.QObject.connect(self.treeWidget,
QtCore.SIGNAL(u'itemDoubleClicked(QTreeWidgetItem*, int)'),
self.onItemDoubleClicked)
QtCore.QObject.connect(self.clearPrimaryButton,
QtCore.SIGNAL(u'clicked(bool)'), self.onClearPrimaryButtonClicked)
QtCore.QObject.connect(self.clearAlternateButton,
QtCore.SIGNAL(u'clicked(bool)'), self.onClearAlternateButtonClicked)
QtCore.QObject.connect(self.buttonBox,
QtCore.SIGNAL(u'clicked(QAbstractButton*)'),
self.onRestoreDefaultsClicked)
QtCore.QObject.connect(self.defaultRadioButton,
QtCore.SIGNAL(u'clicked(bool)'), self.onDefaultRadioButtonClicked)
QtCore.QObject.connect(self.customRadioButton,
QtCore.SIGNAL(u'clicked(bool)'), self.onCustomRadioButtonClicked)
def keyPressEvent(self, event):
if self.primaryPushButton.isChecked() or \
self.alternatePushButton.isChecked():
event.ignore()
elif event.key() == QtCore.Qt.Key_Escape:
event.accept()
self.close()
def keyReleaseEvent(self, event):
Qt = QtCore.Qt
if not self.captureShortcut:
if not self.primaryPushButton.isChecked() and \
not self.alternatePushButton.isChecked():
return
key = event.key()
if key == Qt.Key_Shift or key == Qt.Key_Control or \
key == Qt.Key_Meta or key == Qt.Key_Alt:
if key == QtCore.Qt.Key_Shift or key == QtCore.Qt.Key_Control or \
key == QtCore.Qt.Key_Meta or key == QtCore.Qt.Key_Alt:
return
key_string = QtGui.QKeySequence(key).toString()
if event.modifiers() & Qt.ControlModifier == Qt.ControlModifier:
if event.modifiers() & QtCore.Qt.ControlModifier == \
QtCore.Qt.ControlModifier:
key_string = u'Ctrl+' + key_string
if event.modifiers() & Qt.AltModifier == Qt.AltModifier:
if event.modifiers() & QtCore.Qt.AltModifier == QtCore.Qt.AltModifier:
key_string = u'Alt+' + key_string
if event.modifiers() & Qt.ShiftModifier == Qt.ShiftModifier:
if event.modifiers() & QtCore.Qt.ShiftModifier == \
QtCore.Qt.ShiftModifier:
key_string = u'Shift+' + key_string
key_sequence = QtGui.QKeySequence(key_string)
existing_key = QtGui.QKeySequence(u'Ctrl+Shift+F8')
if key_sequence == existing_key:
QtGui.QMessageBox.warning(
self,
translate('OpenLP.ShortcutListDialog', 'Duplicate Shortcut'),
unicode(translate('OpenLP.ShortcutListDialog', 'The shortcut '
'"%s" is already assigned to another action, please '
'use a different shortcut.')) % key_sequence.toString(),
QtGui.QMessageBox.StandardButtons(QtGui.QMessageBox.Ok),
QtGui.QMessageBox.Ok
)
else:
self.shortcutButton.setText(key_sequence.toString())
self.shortcutButton.setChecked(False)
self.captureShortcut = False
if self._validiate_shortcut(self._currentItemAction(), key_sequence):
if self.primaryPushButton.isChecked():
self._adjustButton(self.primaryPushButton,
False, text=key_sequence.toString())
elif self.alternatePushButton.isChecked():
self._adjustButton(self.alternatePushButton,
False, text=key_sequence.toString())
def exec_(self, actionList):
self.actionList = actionList
self.refreshActions()
def exec_(self):
self.changedActions = {}
self.reloadShortcutList()
self._adjustButton(self.primaryPushButton, False, False, u'')
self._adjustButton(self.alternatePushButton, False, False, u'')
return QtGui.QDialog.exec_(self)
def refreshActions(self):
def reloadShortcutList(self):
"""
Reload the ``treeWidget`` list to add new and remove old actions.
"""
self.treeWidget.clear()
for category in self.actionList.categories:
for category in self.action_list.categories:
# Check if the category is for internal use only.
if category.name is None:
continue
item = QtGui.QTreeWidgetItem([category.name])
for action in category.actions:
actionText = REMOVE_AMPERSAND.sub('', unicode(action.text()))
if (len(action.shortcuts()) == 2):
shortcutText = action.shortcuts()[0].toString()
alternateText = action.shortcuts()[1].toString()
else:
shortcutText = action.shortcut().toString()
alternateText = u''
actionItem = QtGui.QTreeWidgetItem(
[actionText, shortcutText, alternateText])
actionItem = QtGui.QTreeWidgetItem([actionText])
actionItem.setIcon(0, action.icon())
actionItem.setData(0,
QtCore.Qt.UserRole, QtCore.QVariant(action))
item.addChild(actionItem)
item.setExpanded(True)
self.treeWidget.addTopLevelItem(item)
item.setExpanded(True)
self.refreshShortcutList()
def onShortcutButtonClicked(self, toggled):
self.captureShortcut = toggled
def refreshShortcutList(self):
"""
This refreshes the item's shortcuts shown in the list. Note, this
neither adds new actions nor removes old actions.
"""
iterator = QtGui.QTreeWidgetItemIterator(self.treeWidget)
while iterator.value():
item = iterator.value()
iterator += 1
action = self._currentItemAction(item)
if action is None:
continue
shortcuts = self._actionShortcuts(action)
if len(shortcuts) == 0:
item.setText(1, u'')
item.setText(2, u'')
elif len(shortcuts) == 1:
item.setText(1, shortcuts[0].toString())
item.setText(2, u'')
else:
item.setText(1, shortcuts[0].toString())
item.setText(2, shortcuts[1].toString())
self.onCurrentItemChanged()
def onPrimaryPushButtonClicked(self, toggled):
"""
Save the new primary shortcut.
"""
self.customRadioButton.setChecked(True)
if toggled:
self.alternatePushButton.setChecked(False)
return
action = self._currentItemAction()
if action is None:
return
shortcuts = self._actionShortcuts(action)
new_shortcuts = [QtGui.QKeySequence(self.primaryPushButton.text())]
if len(shortcuts) == 2:
new_shortcuts.append(shortcuts[1])
self.changedActions[action] = new_shortcuts
self.refreshShortcutList()
def onAlternatePushButtonClicked(self, toggled):
"""
Save the new alternate shortcut.
"""
self.customRadioButton.setChecked(True)
if toggled:
self.primaryPushButton.setChecked(False)
return
action = self._currentItemAction()
if action is None:
return
shortcuts = self._actionShortcuts(action)
new_shortcuts = []
if len(shortcuts) != 0:
new_shortcuts.append(shortcuts[0])
new_shortcuts.append(
QtGui.QKeySequence(self.alternatePushButton.text()))
self.changedActions[action] = new_shortcuts
if not self.primaryPushButton.text():
# When we do not have a primary shortcut, the just entered alternate
# shortcut will automatically become the primary shortcut. That is
# why we have to adjust the primary button's text.
self.primaryPushButton.setText(self.alternatePushButton.text())
self.alternatePushButton.setText(u'')
self.refreshShortcutList()
def onItemDoubleClicked(self, item, column):
"""
A item has been double clicked. The ``primaryPushButton`` will be
checked and the item's shortcut will be displayed.
"""
action = self._currentItemAction(item)
if action is None:
return
self.primaryPushButton.setChecked(column in [0, 1])
self.alternatePushButton.setChecked(column not in [0, 1])
if column in [0, 1]:
self.primaryPushButton.setFocus(QtCore.Qt.OtherFocusReason)
else:
self.alternatePushButton.setFocus(QtCore.Qt.OtherFocusReason)
self.onCurrentItemChanged(item)
def onCurrentItemChanged(self, item=None, previousItem=None):
"""
A item has been pressed. We adjust the button's text to the action's
shortcut which is encapsulate in the item.
"""
action = self._currentItemAction(item)
self.primaryPushButton.setEnabled(action is not None)
self.alternatePushButton.setEnabled(action is not None)
primary_text = u''
alternate_text = u''
primary_label_text = u''
alternate_label_text = u''
if action is None:
self.primaryPushButton.setChecked(False)
self.alternatePushButton.setChecked(False)
else:
if len(action.defaultShortcuts) != 0:
primary_label_text = action.defaultShortcuts[0].toString()
if len(action.defaultShortcuts) == 2:
alternate_label_text = action.defaultShortcuts[1].toString()
shortcuts = self._actionShortcuts(action)
# We do not want to loose pending changes, that is why we have to
# keep the text when, this function has not been triggered by a signal.
if item is None:
primary_text = self.primaryPushButton.text()
alternate_text = self.alternatePushButton.text()
elif len(shortcuts) == 1:
primary_text = shortcuts[0].toString()
elif len(shortcuts) == 2:
primary_text = shortcuts[0].toString()
alternate_text = shortcuts[1].toString()
self.primaryPushButton.setText(primary_text)
self.alternatePushButton.setText(alternate_text)
self.primaryLabel.setText(primary_label_text)
self.alternateLabel.setText(alternate_label_text)
# We do not want to toggle and radio button, as the function has not
# been triggered by a signal.
if item is None:
return
if primary_label_text == primary_text and \
alternate_label_text == alternate_text:
self.defaultRadioButton.toggle()
else:
self.customRadioButton.toggle()
def onRestoreDefaultsClicked(self, button):
"""
Restores all default shortcuts.
"""
if self.buttonBox.buttonRole(button) != QtGui.QDialogButtonBox.ResetRole:
return
if QtGui.QMessageBox.question(self,
translate('OpenLP.ShortcutListDialog', 'Restore Default Shortcuts'),
translate('OpenLP.ShortcutListDialog', 'Do you want to restore all '
'shortcuts to their defaults?'), QtGui.QMessageBox.StandardButtons(
QtGui.QMessageBox.Yes |
QtGui.QMessageBox.No)) == QtGui.QMessageBox.No:
return
self._adjustButton(self.primaryPushButton, False, text=u'')
self._adjustButton(self.alternatePushButton, False, text=u'')
for category in self.action_list.categories:
for action in category.actions:
self.changedActions[action] = action.defaultShortcuts
self.refreshShortcutList()
def onDefaultRadioButtonClicked(self, toggled):
"""
The default radio button has been clicked, which means we have to make
sure, that we use the default shortcuts for the action.
"""
if not toggled:
return
action = self._currentItemAction()
if action is None:
return
temp_shortcuts = self._actionShortcuts(action)
self.changedActions[action] = action.defaultShortcuts
self.refreshShortcutList()
primary_button_text = u''
alternate_button_text = u''
if len(temp_shortcuts) != 0:
primary_button_text = temp_shortcuts[0].toString()
if len(temp_shortcuts) == 2:
alternate_button_text = temp_shortcuts[1].toString()
self.primaryPushButton.setText(primary_button_text)
self.alternatePushButton.setText(alternate_button_text)
def onCustomRadioButtonClicked(self, toggled):
"""
The custom shortcut radio button was clicked, thus we have to restore
the custom shortcuts by calling those functions triggered by button
clicks.
"""
if not toggled:
return
self.onPrimaryPushButtonClicked(False)
self.onAlternatePushButtonClicked(False)
self.refreshShortcutList()
def save(self):
"""
Save the shortcuts. **Note**, that we do not have to load the shortcuts,
as they are loaded in :class:`~openlp.core.utils.ActionList`.
"""
settings = QtCore.QSettings()
settings.beginGroup(u'shortcuts')
for category in self.action_list.categories:
# Check if the category is for internal use only.
if category.name is None:
continue
for action in category.actions:
if self.changedActions .has_key(action):
action.setShortcuts(self.changedActions[action])
settings.setValue(
action.objectName(), QtCore.QVariant(action.shortcuts()))
settings.endGroup()
def onClearPrimaryButtonClicked(self, toggled):
"""
Restore the defaults of this action.
"""
self.primaryPushButton.setChecked(False)
action = self._currentItemAction()
if action is None:
return
shortcuts = self._actionShortcuts(action)
new_shortcuts = []
if len(action.defaultShortcuts) != 0:
new_shortcuts.append(action.defaultShortcuts[0])
# We have to check if the primary default shortcut is available. But
# we only have to check, if the action has a default primary
# shortcut (an "empty" shortcut is always valid and if the action
# does not have a default primary shortcut, then the alternative
# shortcut (not the default one) will become primary shortcut, thus
# the check will assume that an action were going to have the same
# shortcut twice.
if not self._validiate_shortcut(action, new_shortcuts[0]) and \
new_shortcuts[0] != shortcuts[0]:
return
if len(shortcuts) == 2:
new_shortcuts.append(shortcuts[1])
self.changedActions[action] = new_shortcuts
self.refreshShortcutList()
self.onCurrentItemChanged(self.treeWidget.currentItem())
def onClearAlternateButtonClicked(self, toggled):
"""
Restore the defaults of this action.
"""
self.alternatePushButton.setChecked(False)
action = self._currentItemAction()
if action is None:
return
shortcuts = self._actionShortcuts(action)
new_shortcuts = []
if len(shortcuts) != 0:
new_shortcuts.append(shortcuts[0])
if len(action.defaultShortcuts) == 2:
new_shortcuts.append(action.defaultShortcuts[1])
if len(new_shortcuts) == 2:
if not self._validiate_shortcut(action, new_shortcuts[1]):
return
self.changedActions[action] = new_shortcuts
self.refreshShortcutList()
self.onCurrentItemChanged(self.treeWidget.currentItem())
def _validiate_shortcut(self, changing_action, key_sequence):
"""
Checks if the given ``changing_action `` can use the given
``key_sequence``. Returns ``True`` if the ``key_sequence`` can be used
by the action, otherwise displays a dialog and returns ``False``.
``changing_action``
The action which wants to use the ``key_sequence``.
``key_sequence``
The key sequence which the action want so use.
"""
is_valid = True
for category in self.action_list.categories:
for action in category.actions:
shortcuts = self._actionShortcuts(action)
if key_sequence not in shortcuts:
continue
if action is changing_action:
if self.primaryPushButton.isChecked() and \
shortcuts.index(key_sequence) == 0:
continue
if self.alternatePushButton.isChecked() and \
shortcuts.index(key_sequence) == 1:
continue
# Have the same parent, thus they cannot have the same shortcut.
if action.parent() is changing_action.parent():
is_valid = False
# The new shortcut is already assigned, but if both shortcuts
# are only valid in a different widget the new shortcut is
# vaild, because they will not interfere.
if action.shortcutContext() in [QtCore.Qt.WindowShortcut,
QtCore.Qt.ApplicationShortcut]:
is_valid = False
if changing_action.shortcutContext() in \
[QtCore.Qt.WindowShortcut, QtCore.Qt.ApplicationShortcut]:
is_valid = False
if not is_valid:
Receiver.send_message(u'openlp_warning_message', {
u'title': translate('OpenLP.ShortcutListDialog',
'Duplicate Shortcut'),
u'message': unicode(translate('OpenLP.ShortcutListDialog',
'The shortcut "%s" is already assigned to another action, '
'please use a different shortcut.')) % key_sequence.toString()
})
return is_valid
def _actionShortcuts(self, action):
"""
This returns the shortcuts for the given ``action``, which also includes
those shortcuts which are not saved yet but already assigned (as changes
are applied when closing the dialog).
"""
if self.changedActions.has_key(action):
return self.changedActions[action]
return action.shortcuts()
def _currentItemAction(self, item=None):
"""
Returns the action of the given ``item``. If no item is given, we return
the action of the current item of the ``treeWidget``.
"""
if item is None:
item = self.treeWidget.currentItem()
if item is None:
return
return item.data(0, QtCore.Qt.UserRole).toPyObject()
def _adjustButton(self, button, checked=None, enabled=None, text=None):
"""
Can be called to adjust more properties of the given ``button`` at once.
"""
# Set the text before checking the button, because this emits a signal.
if text is not None:
button.setText(text)
if checked is not None:
button.setChecked(checked)
if enabled is not None:
button.setEnabled(enabled)

View File

@ -32,8 +32,9 @@ from PyQt4.phonon import Phonon
from openlp.core.lib import OpenLPToolbar, Receiver, resize_image, \
ItemCapabilities, translate
from openlp.core.lib.ui import icon_action, UiStrings, shortcut_action
from openlp.core.lib.ui import UiStrings, shortcut_action
from openlp.core.ui import HideMode, MainDisplay
from openlp.core.utils.actions import ActionList, CategoryOrder
log = logging.getLogger(__name__)
@ -87,11 +88,11 @@ class SlideController(QtGui.QWidget):
# Type label for the top of the slide controller
self.typeLabel = QtGui.QLabel(self.panel)
if self.isLive:
self.typeLabel.setText(UiStrings.Live)
self.typeLabel.setText(UiStrings().Live)
self.split = 1
self.typePrefix = u'live'
else:
self.typeLabel.setText(UiStrings.Preview)
self.typeLabel.setText(UiStrings().Preview)
self.split = 0
self.typePrefix = u'preview'
self.typeLabel.setStyleSheet(u'font-weight: bold; font-size: 12pt;')
@ -140,12 +141,16 @@ class SlideController(QtGui.QWidget):
translate('OpenLP.SlideController', 'Previous Slide'),
u':/slides/slide_previous.png',
translate('OpenLP.SlideController', 'Move to previous'),
self.onSlideSelectedPrevious)
self.onSlideSelectedPrevious,
shortcuts=[QtCore.Qt.Key_Up, QtCore.Qt.Key_PageUp],
context=QtCore.Qt.WidgetWithChildrenShortcut)
self.nextItem = self.toolbar.addToolbarButton(
translate('OpenLP.SlideController', 'Next Slide'),
u':/slides/slide_next.png',
translate('OpenLP.SlideController', 'Move to next'),
self.onSlideSelectedNext)
self.onSlideSelectedNext,
shortcuts=[QtCore.Qt.Key_Down, QtCore.Qt.Key_PageDown],
context=QtCore.Qt.WidgetWithChildrenShortcut)
self.toolbar.addToolbarSeparator(u'Close Separator')
if self.isLive:
self.hideMenu = QtGui.QToolButton(self.toolbar)
@ -154,16 +159,20 @@ class SlideController(QtGui.QWidget):
self.toolbar.addToolbarWidget(u'Hide Menu', self.hideMenu)
self.hideMenu.setMenu(QtGui.QMenu(
translate('OpenLP.SlideController', 'Hide'), self.toolbar))
self.blankScreen = icon_action(self.hideMenu, u'Blank Screen',
u':/slides/slide_blank.png', False)
self.blankScreen = shortcut_action(self.hideMenu, u'blankScreen',
[QtCore.Qt.Key_Period], self.onBlankDisplay,
u':/slides/slide_blank.png', False, UiStrings().LiveToolbar)
self.blankScreen.setText(
translate('OpenLP.SlideController', 'Blank Screen'))
self.themeScreen = icon_action(self.hideMenu, u'Blank Theme',
u':/slides/slide_theme.png', False)
self.themeScreen = shortcut_action(self.hideMenu, u'themeScreen',
[QtGui.QKeySequence(u'T')], self.onThemeDisplay,
u':/slides/slide_theme.png', False, UiStrings().LiveToolbar)
self.themeScreen.setText(
translate('OpenLP.SlideController', 'Blank to Theme'))
self.desktopScreen = icon_action(self.hideMenu, u'Desktop Screen',
u':/slides/slide_desktop.png', False)
self.desktopScreen = shortcut_action(self.hideMenu,
u'desktopScreen', [QtGui.QKeySequence(u'D')],
self.onHideDisplay, u':/slides/slide_desktop.png', False,
UiStrings().LiveToolbar)
self.desktopScreen.setText(
translate('OpenLP.SlideController', 'Show Desktop'))
self.hideMenu.setDefaultAction(self.blankScreen)
@ -185,7 +194,7 @@ class SlideController(QtGui.QWidget):
self.delaySpinBox.setMinimum(1)
self.delaySpinBox.setMaximum(180)
self.toolbar.addToolbarWidget(u'Image SpinBox', self.delaySpinBox)
self.delaySpinBox.setSuffix(UiStrings.Seconds)
self.delaySpinBox.setSuffix(UiStrings().Seconds)
self.delaySpinBox.setToolTip(translate('OpenLP.SlideController',
'Delay between slides in seconds'))
else:
@ -291,12 +300,6 @@ class SlideController(QtGui.QWidget):
QtCore.QObject.connect(self.previewListWidget,
QtCore.SIGNAL(u'clicked(QModelIndex)'), self.onSlideSelected)
if self.isLive:
QtCore.QObject.connect(self.blankScreen,
QtCore.SIGNAL(u'triggered(bool)'), self.onBlankDisplay)
QtCore.QObject.connect(self.themeScreen,
QtCore.SIGNAL(u'triggered(bool)'), self.onThemeDisplay)
QtCore.QObject.connect(self.desktopScreen,
QtCore.SIGNAL(u'triggered(bool)'), self.onHideDisplay)
QtCore.QObject.connect(self.volumeSlider,
QtCore.SIGNAL(u'sliderReleased()'), self.mediaVolume)
QtCore.QObject.connect(Receiver.get_receiver(),
@ -362,33 +365,38 @@ class SlideController(QtGui.QWidget):
QtCore.SIGNAL(u'config_screen_changed'), self.screenSizeChanged)
def setPreviewHotkeys(self, parent=None):
actionList = self.parent.actionList
self.previousItem.setShortcuts([QtCore.Qt.Key_Up, 0])
actionList.add_action(self.previousItem, u'Preview')
self.nextItem.setShortcuts([QtCore.Qt.Key_Down, 0])
actionList.add_action(self.nextItem, u'Preview')
self.previousItem.setObjectName(u'previousItemPreview')
self.nextItem.setObjectName(u'nextItemPreview')
action_list = ActionList.get_instance()
action_list.add_action(self.previousItem)
action_list.add_action(self.nextItem)
def setLiveHotkeys(self, parent=None):
actionList = self.parent.actionList
self.previousItem.setShortcuts([QtCore.Qt.Key_Up, QtCore.Qt.Key_PageUp])
self.previousItem.setShortcutContext(
QtCore.Qt.WidgetWithChildrenShortcut)
actionList.add_action(self.previousItem, u'Live')
self.nextItem.setShortcuts([QtCore.Qt.Key_Down, QtCore.Qt.Key_PageDown])
self.nextItem.setShortcutContext(QtCore.Qt.WidgetWithChildrenShortcut)
actionList.add_action(self.nextItem, u'Live')
self.previousService = shortcut_action(parent,
translate('OpenLP.SlideController', 'Previous Service'),
[QtCore.Qt.Key_Left, 0], self.servicePrevious)
actionList.add_action(self.previousService, u'Live')
self.nextService = shortcut_action(parent,
translate('OpenLP.SlideController', 'Next Service'),
[QtCore.Qt.Key_Right, 0], self.serviceNext)
actionList.add_action(self.nextService, u'Live')
self.escapeItem = shortcut_action(parent,
translate('OpenLP.SlideController', 'Escape Item'),
[QtCore.Qt.Key_Escape, 0], self.liveEscape)
actionList.add_action(self.escapeItem, u'Live')
self.previousItem.setObjectName(u'previousItemLive')
self.nextItem.setObjectName(u'nextItemLive')
action_list = ActionList.get_instance()
action_list.add_category(
UiStrings().LiveToolbar, CategoryOrder.standardToolbar)
action_list.add_action(self.previousItem)
action_list.add_action(self.nextItem)
self.previousService = shortcut_action(parent, u'previousService',
[QtCore.Qt.Key_Left], self.servicePrevious,
category=UiStrings().LiveToolbar,
context=QtCore.Qt.WidgetWithChildrenShortcut)
self.previousService.setText(
translate('OpenLP.SlideController', 'Previous Service'))
self.nextService = shortcut_action(parent, 'nextService',
[QtCore.Qt.Key_Right], self.serviceNext,
category=UiStrings().LiveToolbar,
context=QtCore.Qt.WidgetWithChildrenShortcut)
self.nextService.setText(
translate('OpenLP.SlideController', 'Next Service'))
self.escapeItem = shortcut_action(parent, 'escapeItem',
[QtCore.Qt.Key_Escape], self.liveEscape,
category=UiStrings().LiveToolbar,
context=QtCore.Qt.WidgetWithChildrenShortcut)
self.escapeItem.setText(
translate('OpenLP.SlideController', 'Escape Item'))
def liveEscape(self):
self.display.setVisible(False)
@ -460,7 +468,7 @@ class SlideController(QtGui.QWidget):
request = unicode(self.sender().text())
slideno = self.slideList[request]
self.__updatePreviewSelection(slideno)
self.onSlideSelected()
self.slideSelected()
def receiveSpinDelay(self, value):
"""
@ -556,7 +564,7 @@ class SlideController(QtGui.QWidget):
# If service item is the same as the current on only change slide
if item.__eq__(self.serviceItem):
self.__checkUpdateSelectedSlide(slideno)
self.onSlideSelected()
self.slideSelected()
return
self._processItem(item, slideno)
@ -567,24 +575,15 @@ class SlideController(QtGui.QWidget):
"""
log.debug(u'processManagerItem live = %s' % self.isLive)
self.onStopLoop()
# If old item was a command tell it to stop
if self.serviceItem:
if self.serviceItem.is_command():
Receiver.send_message(u'%s_stop' %
self.serviceItem.name.lower(), [serviceItem, self.isLive])
if self.serviceItem.is_media():
self.onMediaClose()
if self.isLive:
if serviceItem.is_capable(ItemCapabilities.ProvidesOwnDisplay):
self._forceUnblank()
blanked = self.blankScreen.isChecked()
else:
blanked = False
old_item = self.serviceItem
self.serviceItem = serviceItem
if old_item and self.isLive and old_item.is_capable(
ItemCapabilities.ProvidesOwnDisplay):
self._resetBlank()
Receiver.send_message(u'%s_start' % serviceItem.name.lower(),
[serviceItem, self.isLive, blanked, slideno])
[serviceItem, self.isLive, self.hideMode(), slideno])
self.slideList = {}
width = self.parent.controlSplitter.sizes()[self.split]
self.serviceItem = serviceItem
self.previewListWidget.clear()
self.previewListWidget.setRowCount(0)
self.previewListWidget.setColumnWidth(0, width)
@ -643,12 +642,25 @@ class SlideController(QtGui.QWidget):
self.previewListWidget.viewport().size().width())
self.__updatePreviewSelection(slideno)
self.enableToolBar(serviceItem)
# Pass to display for viewing
self.display.buildHtml(self.serviceItem)
# Pass to display for viewing.
# Postpone image build, we need to do this later to avoid the theme
# flashing on the screen
if not self.serviceItem.is_image():
self.display.buildHtml(self.serviceItem)
if serviceItem.is_media():
self.onMediaStart(serviceItem)
self.onSlideSelected()
self.slideSelected(True)
self.previewListWidget.setFocus()
if old_item:
# Close the old item after the new one is opened
# This avoids the service theme/desktop flashing on screen
# However opening a new item of the same type will automatically
# close the previous, so make sure we don't close the new one.
if old_item.is_command() and not serviceItem.is_command():
Receiver.send_message(u'%s_stop' %
old_item.name.lower(), [old_item, self.isLive])
if old_item.is_media() and not serviceItem.is_media():
self.onMediaClose()
Receiver.send_message(u'slidecontroller_%s_started' % self.typePrefix,
[serviceItem])
@ -695,7 +707,7 @@ class SlideController(QtGui.QWidget):
self.updatePreview()
else:
self.previewListWidget.selectRow(0)
self.onSlideSelected()
self.slideSelected()
def onSlideSelectedIndex(self, message):
"""
@ -710,7 +722,7 @@ class SlideController(QtGui.QWidget):
self.updatePreview()
else:
self.__checkUpdateSelectedSlide(index)
self.onSlideSelected()
self.slideSelected()
def mainDisplaySetBackground(self):
"""
@ -741,80 +753,85 @@ class SlideController(QtGui.QWidget):
"""
self.onBlankDisplay(False)
def onBlankDisplay(self, checked):
def onBlankDisplay(self, checked=None):
"""
Handle the blank screen button actions
"""
if checked is None:
checked = self.blankScreen.isChecked()
log.debug(u'onBlankDisplay %s' % checked)
self.hideMenu.setDefaultAction(self.blankScreen)
self.blankScreen.setChecked(checked)
self.themeScreen.setChecked(False)
self.desktopScreen.setChecked(False)
if checked:
Receiver.send_message(u'maindisplay_hide', HideMode.Blank)
QtCore.QSettings().setValue(
self.parent.generalSettingsSection + u'/screen blank',
QtCore.QVariant(u'blanked'))
else:
Receiver.send_message(u'maindisplay_show')
QtCore.QSettings().remove(
self.parent.generalSettingsSection + u'/screen blank')
self.blankPlugin(checked)
self.blankPlugin()
self.updatePreview()
def onThemeDisplay(self, checked):
def onThemeDisplay(self, checked=None):
"""
Handle the Theme screen button
"""
if checked is None:
checked = self.themeScreen.isChecked()
log.debug(u'onThemeDisplay %s' % checked)
self.hideMenu.setDefaultAction(self.themeScreen)
self.blankScreen.setChecked(False)
self.themeScreen.setChecked(checked)
self.desktopScreen.setChecked(False)
if checked:
Receiver.send_message(u'maindisplay_hide', HideMode.Theme)
QtCore.QSettings().setValue(
self.parent.generalSettingsSection + u'/screen blank',
QtCore.QVariant(u'themed'))
else:
Receiver.send_message(u'maindisplay_show')
QtCore.QSettings().remove(
self.parent.generalSettingsSection + u'/screen blank')
self.blankPlugin(checked)
self.blankPlugin()
self.updatePreview()
def onHideDisplay(self, checked):
def onHideDisplay(self, checked=None):
"""
Handle the Hide screen button
"""
if checked is None:
checked = self.desktopScreen.isChecked()
log.debug(u'onHideDisplay %s' % checked)
self.hideMenu.setDefaultAction(self.desktopScreen)
self.blankScreen.setChecked(False)
self.themeScreen.setChecked(False)
self.desktopScreen.setChecked(checked)
if checked:
Receiver.send_message(u'maindisplay_hide', HideMode.Screen)
QtCore.QSettings().setValue(
self.parent.generalSettingsSection + u'/screen blank',
QtCore.QVariant(u'hidden'))
else:
Receiver.send_message(u'maindisplay_show')
QtCore.QSettings().remove(
self.parent.generalSettingsSection + u'/screen blank')
self.hidePlugin(checked)
self.updatePreview()
def blankPlugin(self, blank):
def blankPlugin(self):
"""
Blank the display screen within a plugin if required.
Blank/Hide the display screen within a plugin if required.
"""
log.debug(u'blankPlugin %s ', blank)
hide_mode = self.hideMode()
log.debug(u'blankPlugin %s ', hide_mode)
if self.serviceItem is not None:
if blank:
if hide_mode:
if not self.serviceItem.is_command():
Receiver.send_message(u'maindisplay_hide', hide_mode)
Receiver.send_message(u'%s_blank'
% self.serviceItem.name.lower(),
[self.serviceItem, self.isLive])
[self.serviceItem, self.isLive, hide_mode])
else:
if not self.serviceItem.is_command():
Receiver.send_message(u'maindisplay_show')
Receiver.send_message(u'%s_unblank'
% self.serviceItem.name.lower(),
[self.serviceItem, self.isLive])
@ -826,15 +843,24 @@ class SlideController(QtGui.QWidget):
log.debug(u'hidePlugin %s ', hide)
if self.serviceItem is not None:
if hide:
Receiver.send_message(u'maindisplay_hide', HideMode.Screen)
Receiver.send_message(u'%s_hide'
% self.serviceItem.name.lower(),
[self.serviceItem, self.isLive])
else:
if not self.serviceItem.is_command():
Receiver.send_message(u'maindisplay_show')
Receiver.send_message(u'%s_unblank'
% self.serviceItem.name.lower(),
[self.serviceItem, self.isLive])
def onSlideSelected(self):
def onSlideSelected(self, start=False):
"""
Slide selected in controller
"""
self.slideSelected()
def slideSelected(self, start=False):
"""
Generate the preview when you click on a slide.
if this is the Live Controller also display on the screen
@ -843,7 +869,7 @@ class SlideController(QtGui.QWidget):
self.selectedRow = 0
if row > -1 and row < self.previewListWidget.rowCount():
if self.serviceItem.is_command():
if self.isLive:
if self.isLive and not start:
Receiver.send_message(
u'%s_slide' % self.serviceItem.name.lower(),
[self.serviceItem, self.isLive, row])
@ -853,7 +879,11 @@ class SlideController(QtGui.QWidget):
if self.serviceItem.is_text():
frame = self.display.text(toDisplay)
else:
frame = self.display.image(toDisplay)
if start:
self.display.buildHtml(self.serviceItem, toDisplay)
frame = self.display.preview()
else:
frame = self.display.image(toDisplay)
# reset the store used to display first image
self.serviceItem.bg_image_bytes = None
self.slidePreview.setPixmap(QtGui.QPixmap.fromImage(frame))
@ -919,7 +949,7 @@ class SlideController(QtGui.QWidget):
Receiver.send_message('servicemanager_next_item')
return
self.__checkUpdateSelectedSlide(row)
self.onSlideSelected()
self.slideSelected()
def onSlideSelectedPreviousNoloop(self):
self.onSlideSelectedPrevious(False)
@ -942,7 +972,7 @@ class SlideController(QtGui.QWidget):
else:
row = 0
self.__checkUpdateSelectedSlide(row)
self.onSlideSelected()
self.slideSelected()
def __checkUpdateSelectedSlide(self, row):
if row + 1 < self.previewListWidget.rowCount():
@ -963,7 +993,7 @@ class SlideController(QtGui.QWidget):
else:
self.previewListWidget.selectRow(
self.previewListWidget.rowCount() - 1)
self.onSlideSelected()
self.slideSelected()
def onStartLoop(self):
"""
@ -1095,20 +1125,33 @@ class SlideController(QtGui.QWidget):
self.slidePreview.clear()
self.slidePreview.show()
def _forceUnblank(self):
def _resetBlank(self):
"""
Used by command items which provide their own displays to reset the
screen hide attributes
"""
blank = None
if self.blankScreen.isChecked:
blank = self.blankScreen
if self.themeScreen.isChecked:
blank = self.themeScreen
if self.desktopScreen.isChecked:
blank = self.desktopScreen
if blank:
blank.setChecked(False)
self.hideMenu.setDefaultAction(blank)
QtCore.QSettings().remove(
self.parent.generalSettingsSection + u'/screen blank')
hide_mode = self.hideMode()
if hide_mode == HideMode.Blank:
self.onBlankDisplay(True)
elif hide_mode == HideMode.Theme:
self.onThemeDisplay(True)
elif hide_mode == HideMode.Screen:
self.onHideDisplay(True)
else:
self.hidePlugin(False)
def hideMode(self):
"""
Determine what the hide mode should be according to the blank button
"""
if not self.isLive:
return None
elif self.blankScreen.isChecked():
return HideMode.Blank
elif self.themeScreen.isChecked():
return HideMode.Theme
elif self.desktopScreen.isChecked():
return HideMode.Screen
else:
return None

View File

@ -107,15 +107,15 @@ class Ui_StartTimeDialog(object):
def retranslateUi(self, StartTimeDialog):
self.setWindowTitle(translate('OpenLP.StartTimeForm',
'Item Start and Finish Time'))
self.hourSpinBox.setSuffix(UiStrings.Hours)
self.minuteSpinBox.setSuffix(UiStrings.Minutes)
self.secondSpinBox.setSuffix(UiStrings.Seconds)
self.hourFinishSpinBox.setSuffix(UiStrings.Hours)
self.minuteFinishSpinBox.setSuffix(UiStrings.Minutes)
self.secondFinishSpinBox.setSuffix(UiStrings.Seconds)
self.hourSpinBox.setSuffix(UiStrings().Hours)
self.minuteSpinBox.setSuffix(UiStrings().Minutes)
self.secondSpinBox.setSuffix(UiStrings().Seconds)
self.hourFinishSpinBox.setSuffix(UiStrings().Hours)
self.minuteFinishSpinBox.setSuffix(UiStrings().Minutes)
self.secondFinishSpinBox.setSuffix(UiStrings().Seconds)
self.hourLabel.setText(translate('OpenLP.StartTimeForm', 'Hours:'))
self.minuteLabel.setText(translate('OpenLP.StartTimeForm', 'Minutes:'))
self.secondLabel.setText(translate('OpenLP.StartTimeForm', 'Seconds:'))
self.startLabel.setText(translate('OpenLP.StartTimeForm', 'Start'))
self.finishLabel.setText(translate('OpenLP.StartTimeForm', 'Finish'))
self.lengthLabel.setText(translate('OpenLP.StartTimeForm', 'Length'))
self.lengthLabel.setText(translate('OpenLP.StartTimeForm', 'Length'))

View File

@ -53,11 +53,12 @@ class StartTimeForm(QtGui.QDialog, Ui_StartTimeDialog):
self.hourFinishSpinBox.setValue(hours)
self.minuteFinishSpinBox.setValue(minutes)
self.secondFinishSpinBox.setValue(seconds)
self.hourFinishLabel.setText(u'%s%s' % (unicode(hour), UiStrings.Hours))
self.hourFinishLabel.setText(u'%s%s' % (unicode(hour),
UiStrings().Hours))
self.minuteFinishLabel.setText(u'%s%s' %
(unicode(minutes), UiStrings.Minutes))
(unicode(minutes), UiStrings().Minutes))
self.secondFinishLabel.setText(u'%s%s' %
(unicode(seconds), UiStrings.Seconds))
(unicode(seconds), UiStrings().Seconds))
return QtGui.QDialog.exec_(self)
def accept(self):

View File

@ -56,6 +56,7 @@ class ThemeForm(QtGui.QWizard, Ui_ThemeWizard):
self.setupUi(self)
self.registerFields()
self.updateThemeAllowed = True
self.temp_background_filename = u''
QtCore.QObject.connect(self.backgroundComboBox,
QtCore.SIGNAL(u'currentIndexChanged(int)'),
self.onBackgroundComboBoxCurrentIndexChanged)
@ -63,26 +64,19 @@ class ThemeForm(QtGui.QWizard, Ui_ThemeWizard):
QtCore.SIGNAL(u'currentIndexChanged(int)'),
self.onGradientComboBoxCurrentIndexChanged)
QtCore.QObject.connect(self.colorButton,
QtCore.SIGNAL(u'clicked()'),
self.onColorButtonClicked)
QtCore.SIGNAL(u'clicked()'), self.onColorButtonClicked)
QtCore.QObject.connect(self.gradientStartButton,
QtCore.SIGNAL(u'clicked()'),
self.onGradientStartButtonClicked)
QtCore.SIGNAL(u'clicked()'), self.onGradientStartButtonClicked)
QtCore.QObject.connect(self.gradientEndButton,
QtCore.SIGNAL(u'clicked()'),
self.onGradientEndButtonClicked)
QtCore.SIGNAL(u'clicked()'), self.onGradientEndButtonClicked)
QtCore.QObject.connect(self.imageBrowseButton,
QtCore.SIGNAL(u'clicked()'),
self.onImageBrowseButtonClicked)
QtCore.SIGNAL(u'clicked()'), self.onImageBrowseButtonClicked)
QtCore.QObject.connect(self.mainColorButton,
QtCore.SIGNAL(u'clicked()'),
self.onMainColorButtonClicked)
QtCore.SIGNAL(u'clicked()'), self.onMainColorButtonClicked)
QtCore.QObject.connect(self.outlineColorButton,
QtCore.SIGNAL(u'clicked()'),
self.onOutlineColorButtonClicked)
QtCore.SIGNAL(u'clicked()'), self.onOutlineColorButtonClicked)
QtCore.QObject.connect(self.shadowColorButton,
QtCore.SIGNAL(u'clicked()'),
self.onShadowColorButtonClicked)
QtCore.SIGNAL(u'clicked()'), self.onShadowColorButtonClicked)
QtCore.QObject.connect(self.outlineCheckBox,
QtCore.SIGNAL(u'stateChanged(int)'),
self.onOutlineCheckCheckBoxStateChanged)
@ -90,8 +84,7 @@ class ThemeForm(QtGui.QWizard, Ui_ThemeWizard):
QtCore.SIGNAL(u'stateChanged(int)'),
self.onShadowCheckCheckBoxStateChanged)
QtCore.QObject.connect(self.footerColorButton,
QtCore.SIGNAL(u'clicked()'),
self.onFooterColorButtonClicked)
QtCore.SIGNAL(u'clicked()'), self.onFooterColorButtonClicked)
QtCore.QObject.connect(self.mainPositionCheckBox,
QtCore.SIGNAL(u'stateChanged(int)'),
self.onMainPositionCheckBoxStateChanged)
@ -99,26 +92,23 @@ class ThemeForm(QtGui.QWizard, Ui_ThemeWizard):
QtCore.SIGNAL(u'stateChanged(int)'),
self.onFooterPositionCheckBoxStateChanged)
QtCore.QObject.connect(self,
QtCore.SIGNAL(u'currentIdChanged(int)'),
self.onCurrentIdChanged)
QtCore.SIGNAL(u'currentIdChanged(int)'), self.onCurrentIdChanged)
QtCore.QObject.connect(Receiver.get_receiver(),
QtCore.SIGNAL(u'theme_line_count'),
self.updateLinesText)
QtCore.SIGNAL(u'theme_line_count'), self.updateLinesText)
QtCore.QObject.connect(self.mainSizeSpinBox,
QtCore.SIGNAL(u'valueChanged(int)'),
self.calculateLines)
QtCore.SIGNAL(u'valueChanged(int)'), self.calculateLines)
QtCore.QObject.connect(self.lineSpacingSpinBox,
QtCore.SIGNAL(u'valueChanged(int)'),
self.calculateLines)
QtCore.SIGNAL(u'valueChanged(int)'), self.calculateLines)
QtCore.QObject.connect(self.outlineSizeSpinBox,
QtCore.SIGNAL(u'valueChanged(int)'),
self.calculateLines)
QtCore.SIGNAL(u'valueChanged(int)'), self.calculateLines)
QtCore.QObject.connect(self.shadowSizeSpinBox,
QtCore.SIGNAL(u'valueChanged(int)'),
self.calculateLines)
QtCore.SIGNAL(u'valueChanged(int)'), self.calculateLines)
QtCore.QObject.connect(self.mainFontComboBox,
QtCore.SIGNAL(u'activated(int)'),
self.calculateLines)
QtCore.SIGNAL(u'activated(int)'), self.calculateLines)
QtCore.QObject.connect(self.footerFontComboBox,
QtCore.SIGNAL(u'activated(int)'), self.updateTheme)
QtCore.QObject.connect(self.footerSizeSpinBox,
QtCore.SIGNAL(u'valueChanged(int)'), self.updateTheme)
def setDefaults(self):
"""
@ -290,6 +280,7 @@ class ThemeForm(QtGui.QWizard, Ui_ThemeWizard):
Run the wizard.
"""
log.debug(u'Editing theme %s' % self.theme.theme_name)
self.temp_background_filename = u''
self.updateThemeAllowed = False
self.setDefaults()
self.updateThemeAllowed = True
@ -301,7 +292,7 @@ class ThemeForm(QtGui.QWizard, Ui_ThemeWizard):
'Edit Theme - %s')) % self.theme.theme_name)
self.next()
else:
self.setWindowTitle(UiStrings.NewTheme)
self.setWindowTitle(UiStrings().NewTheme)
return QtGui.QWizard.exec_(self)
def initializePage(self, id):
@ -389,7 +380,7 @@ class ThemeForm(QtGui.QWizard, Ui_ThemeWizard):
Handle the display and state of the Footer Area page.
"""
self.footerFontComboBox.setCurrentFont(
QtGui.QFont(self.theme.font_main_name))
QtGui.QFont(self.theme.font_footer_name))
self.footerColorButton.setStyleSheet(u'background-color: %s' %
self.theme.font_footer_color)
self.setField(u'footerSizeSpinBox',
@ -443,6 +434,16 @@ class ThemeForm(QtGui.QWizard, Ui_ThemeWizard):
# do not allow updates when screen is building for the first time.
if self.updateThemeAllowed:
self.theme.background_type = BackgroundType.to_string(index)
if self.theme.background_type != \
BackgroundType.to_string(BackgroundType.Image) and \
self.temp_background_filename == u'':
self.temp_background_filename = self.theme.background_filename
self.theme.background_filename = u''
if self.theme.background_type == \
BackgroundType.to_string(BackgroundType.Image) and \
self.temp_background_filename != u'':
self.theme.background_filename = self.temp_background_filename
self.temp_background_filename = u''
self.setBackgroundPageValues()
def onGradientComboBoxCurrentIndexChanged(self, index):
@ -484,7 +485,7 @@ class ThemeForm(QtGui.QWizard, Ui_ThemeWizard):
"""
images_filter = get_images_filter()
images_filter = u'%s;;%s (*.*) (*)' % (
images_filter, UiStrings.AllFiles)
images_filter, UiStrings().AllFiles)
filename = QtGui.QFileDialog.getOpenFileName(self,
translate('OpenLP.ThemeForm', 'Select Image'), u'',
images_filter)

View File

@ -63,7 +63,7 @@ class ThemeManager(QtGui.QWidget):
self.layout.setMargin(0)
self.layout.setObjectName(u'layout')
self.toolbar = OpenLPToolbar(self)
self.toolbar.addToolbarButton(UiStrings.NewTheme,
self.toolbar.addToolbarButton(UiStrings().NewTheme,
u':/themes/theme_new.png',
translate('OpenLP.ThemeManager', 'Create a new theme.'),
self.onAddTheme)
@ -280,6 +280,8 @@ class ThemeManager(QtGui.QWidget):
self.fileRenameForm.fileNameEdit.setText(oldThemeName)
if self.fileRenameForm.exec_():
newThemeName = unicode(self.fileRenameForm.fileNameEdit.text())
if oldThemeName == newThemeName:
return
if self.checkIfThemeExists(newThemeName):
oldThemeData = self.getThemeData(oldThemeName)
self.cloneThemeData(oldThemeData, newThemeName)
@ -333,6 +335,7 @@ class ThemeManager(QtGui.QWidget):
self.oldBackgroundImage = theme.background_filename
self.themeForm.theme = theme
self.themeForm.exec_(True)
self.oldBackgroundImage = None
def onDeleteTheme(self):
"""
@ -445,10 +448,11 @@ class ThemeManager(QtGui.QWidget):
files = SettingsManager.get_files(self.settingsSection, u'.png')
if firstTime:
self.firstTime()
files = SettingsManager.get_files(self.settingsSection, u'.png')
# No themes have been found so create one
if len(files) == 0:
theme = ThemeXML()
theme.theme_name = UiStrings.Default
theme.theme_name = UiStrings().Default
self._writeTheme(theme, None, None)
QtCore.QSettings().setValue(
self.settingsSection + u'/global theme',
@ -802,4 +806,4 @@ class ThemeManager(QtGui.QWidget):
vAlignCorrection = VerticalType.Bottom
newtheme.display_horizontal_align = theme.HorizontalAlign
newtheme.display_vertical_align = vAlignCorrection
return newtheme.extract_xml()
return newtheme.extract_xml()

View File

@ -28,15 +28,17 @@ from PyQt4 import QtCore, QtGui
from openlp.core.lib import SettingsTab, Receiver, translate
from openlp.core.lib.theme import ThemeLevel
from openlp.core.lib.ui import UiStrings
from openlp.core.lib.ui import UiStrings, find_and_set_in_combo_box
class ThemesTab(SettingsTab):
"""
ThemesTab is the theme settings tab in the settings dialog.
"""
def __init__(self, parent):
self.parent = parent
SettingsTab.__init__(self, u'Themes')
def __init__(self, parent, mainwindow):
self.mainwindow = mainwindow
generalTranslated = translate('ThemeTab', 'Themes')
SettingsTab.__init__(self, parent, u'Themes', generalTranslated)
self.icon_path = u':/themes/theme_new.png'
def setupUi(self):
self.setObjectName(u'ThemesTab')
@ -100,7 +102,7 @@ class ThemesTab(SettingsTab):
QtCore.SIGNAL(u'theme_update_list'), self.updateThemeList)
def retranslateUi(self):
self.tabTitleVisible = UiStrings.Themes
self.tabTitleVisible = UiStrings().Themes
self.GlobalGroupBox.setTitle(
translate('OpenLP.ThemesTab', 'Global Theme'))
self.LevelGroupBox.setTitle(
@ -147,7 +149,7 @@ class ThemesTab(SettingsTab):
settings.setValue(u'global theme',
QtCore.QVariant(self.global_theme))
settings.endGroup()
self.parent.renderManager.set_global_theme(
self.mainwindow.renderManager.set_global_theme(
self.global_theme, self.theme_level)
Receiver.send_message(u'theme_update_global', self.global_theme)
@ -165,7 +167,7 @@ class ThemesTab(SettingsTab):
def onDefaultComboBoxChanged(self, value):
self.global_theme = unicode(self.DefaultComboBox.currentText())
self.parent.renderManager.set_global_theme(
self.mainwindow.renderManager.set_global_theme(
self.global_theme, self.theme_level)
self.__previewGlobalTheme()
@ -185,13 +187,8 @@ class ThemesTab(SettingsTab):
self.DefaultComboBox.clear()
for theme in theme_list:
self.DefaultComboBox.addItem(theme)
id = self.DefaultComboBox.findText(
self.global_theme, QtCore.Qt.MatchExactly)
if id == -1:
id = 0 # Not Found
self.global_theme = u''
self.DefaultComboBox.setCurrentIndex(id)
self.parent.renderManager.set_global_theme(
find_and_set_in_combo_box(self.DefaultComboBox, self.global_theme)
self.mainwindow.renderManager.set_global_theme(
self.global_theme, self.theme_level)
if self.global_theme is not u'':
self.__previewGlobalTheme()
@ -200,10 +197,10 @@ class ThemesTab(SettingsTab):
"""
Utility method to update the global theme preview image.
"""
image = self.parent.themeManagerContents.getPreviewImage(
image = self.mainwindow.themeManagerContents.getPreviewImage(
self.global_theme)
preview = QtGui.QPixmap(unicode(image))
if not preview.isNull():
preview = preview.scaled(300, 255, QtCore.Qt.KeepAspectRatio,
QtCore.Qt.SmoothTransformation)
self.DefaultListView.setPixmap(preview)
self.DefaultListView.setPixmap(preview)

View File

@ -424,7 +424,7 @@ class Ui_ThemeWizard(object):
self.backgroundComboBox.setItemText(BackgroundType.Gradient,
translate('OpenLP.ThemeWizard', 'Gradient'))
self.backgroundComboBox.setItemText(
BackgroundType.Image, UiStrings.Image)
BackgroundType.Image, UiStrings().Image)
self.colorLabel.setText(translate('OpenLP.ThemeWizard', 'Color:'))
self.gradientStartLabel.setText(
translate(u'OpenLP.ThemeWizard', 'Starting color:'))
@ -442,7 +442,7 @@ class Ui_ThemeWizard(object):
translate('OpenLP.ThemeWizard', 'Top Left - Bottom Right'))
self.gradientComboBox.setItemText(BackgroundGradientType.LeftBottom,
translate('OpenLP.ThemeWizard', 'Bottom Left - Top Right'))
self.imageLabel.setText(u'%s:' % UiStrings.Image)
self.imageLabel.setText(u'%s:' % UiStrings().Image)
self.mainAreaPage.setTitle(
translate('OpenLP.ThemeWizard', 'Main Area Font Details'))
self.mainAreaPage.setSubTitle(
@ -451,17 +451,17 @@ class Ui_ThemeWizard(object):
self.mainFontLabel.setText(translate('OpenLP.ThemeWizard', 'Font:'))
self.mainColorLabel.setText(translate('OpenLP.ThemeWizard', 'Color:'))
self.mainSizeLabel.setText(translate('OpenLP.ThemeWizard', 'Size:'))
self.mainSizeSpinBox.setSuffix(UiStrings.FontSizePtUnit)
self.mainSizeSpinBox.setSuffix(UiStrings().FontSizePtUnit)
self.lineSpacingLabel.setText(
translate('OpenLP.ThemeWizard', 'Line Spacing:'))
self.lineSpacingSpinBox.setSuffix(UiStrings.FontSizePtUnit)
self.lineSpacingSpinBox.setSuffix(UiStrings().FontSizePtUnit)
self.outlineCheckBox.setText(
translate('OpenLP.ThemeWizard', '&Outline:'))
self.outlineSizeLabel.setText(translate('OpenLP.ThemeWizard', 'Size:'))
self.outlineSizeSpinBox.setSuffix(UiStrings.FontSizePtUnit)
self.outlineSizeSpinBox.setSuffix(UiStrings().FontSizePtUnit)
self.shadowCheckBox.setText(translate('OpenLP.ThemeWizard', '&Shadow:'))
self.shadowSizeLabel.setText(translate('OpenLP.ThemeWizard', 'Size:'))
self.shadowSizeSpinBox.setSuffix(UiStrings.FontSizePtUnit)
self.shadowSizeSpinBox.setSuffix(UiStrings().FontSizePtUnit)
self.mainBoldCheckBox.setText(translate('OpenLP.ThemeWizard', 'Bold'))
self.mainItalicsCheckBox.setText(
translate('OpenLP.ThemeWizard', 'Italic'))
@ -473,7 +473,7 @@ class Ui_ThemeWizard(object):
self.footerFontLabel.setText(translate('OpenLP.ThemeWizard', 'Font:'))
self.footerColorLabel.setText(translate('OpenLP.ThemeWizard', 'Color:'))
self.footerSizeLabel.setText(translate('OpenLP.ThemeWizard', 'Size:'))
self.footerSizeSpinBox.setSuffix(UiStrings.FontSizePtUnit)
self.footerSizeSpinBox.setSuffix(UiStrings().FontSizePtUnit)
self.alignmentPage.setTitle(
translate('OpenLP.ThemeWizard', 'Text Formatting Details'))
self.alignmentPage.setSubTitle(
@ -537,4 +537,4 @@ class Ui_ThemeWizard(object):
labelWidth = max(self.backgroundLabel.minimumSizeHint().width(),
self.horizontalLabel.minimumSizeHint().width())
self.spacer.changeSize(labelWidth, 0,
QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Fixed)
QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Fixed)

View File

@ -95,6 +95,10 @@ class OpenLPWizard(QtGui.QWizard):
self.customSignals()
QtCore.QObject.connect(self, QtCore.SIGNAL(u'currentIdChanged(int)'),
self.onCurrentIdChanged)
QtCore.QObject.connect(self.errorCopyToButton,
QtCore.SIGNAL(u'clicked()'), self.onErrorCopyToButtonClicked)
QtCore.QObject.connect(self.errorSaveToButton,
QtCore.SIGNAL(u'clicked()'), self.onErrorSaveToButtonClicked)
def setupUi(self, image):
"""
@ -129,10 +133,36 @@ class OpenLPWizard(QtGui.QWizard):
self.progressLayout.setObjectName(u'progressLayout')
self.progressLabel = QtGui.QLabel(self.progressPage)
self.progressLabel.setObjectName(u'progressLabel')
self.progressLabel.setWordWrap(True)
self.progressLayout.addWidget(self.progressLabel)
self.progressBar = QtGui.QProgressBar(self.progressPage)
self.progressBar.setObjectName(u'progressBar')
self.progressLayout.addWidget(self.progressBar)
# Add a QTextEdit and a copy to file and copy to clipboard button to be
# able to provide feedback to the user. Hidden by default.
self.errorReportTextEdit = QtGui.QTextEdit(self.progressPage)
self.errorReportTextEdit.setObjectName(u'progresserrorReportTextEdit')
self.errorReportTextEdit.setHidden(True)
self.errorReportTextEdit.setReadOnly(True)
self.progressLayout.addWidget(self.errorReportTextEdit)
self.errorButtonLayout = QtGui.QHBoxLayout()
self.errorButtonLayout.setObjectName(u'errorButtonLayout')
spacer = QtGui.QSpacerItem(40, 20,
QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum)
self.errorButtonLayout.addItem(spacer)
self.errorCopyToButton = QtGui.QPushButton(self.progressPage)
self.errorCopyToButton.setObjectName(u'errorCopyToButton')
self.errorCopyToButton.setHidden(True)
self.errorCopyToButton.setIcon(
build_icon(u':/system/system_edit_copy.png'))
self.errorButtonLayout.addWidget(self.errorCopyToButton)
self.errorSaveToButton = QtGui.QPushButton(self.progressPage)
self.errorSaveToButton.setObjectName(u'errorSaveToButton')
self.errorSaveToButton.setHidden(True)
self.errorSaveToButton.setIcon(
build_icon(u':/general/general_save.png'))
self.errorButtonLayout.addWidget(self.errorSaveToButton)
self.progressLayout.addLayout(self.errorButtonLayout)
self.addPage(self.progressPage)
def exec_(self):
@ -160,6 +190,18 @@ class OpenLPWizard(QtGui.QWizard):
self.performWizard()
self.postWizard()
def onErrorCopyToButtonClicked(self):
"""
Called when the ``onErrorCopyToButtonClicked`` has been clicked.
"""
pass
def onErrorSaveToButtonClicked(self):
"""
Called when the ``onErrorSaveToButtonClicked`` has been clicked.
"""
pass
def incrementProgressBar(self, status_text, increment=1):
"""
Update the wizard progress page.
@ -212,7 +254,7 @@ class OpenLPWizard(QtGui.QWizard):
"""
if filters:
filters += u';;'
filters += u'%s (*)' % UiStrings.AllFiles
filters += u'%s (*)' % UiStrings().AllFiles
filename = QtGui.QFileDialog.getOpenFileName(self, title,
os.path.dirname(SettingsManager.get_last_dir(
self.plugin.settingsSection, 1)), filters)
@ -220,3 +262,4 @@ class OpenLPWizard(QtGui.QWizard):
editbox.setText(filename)
SettingsManager.set_last_dir(self.plugin.settingsSection,
filename, 1)

View File

@ -495,7 +495,7 @@ def get_uno_instance(resolver):
from languagemanager import LanguageManager
from actions import ActionList
__all__ = [u'AppLocation', u'check_latest_version', u'add_actions',
u'get_filesystem_encoding', u'LanguageManager', u'ActionList',
u'get_web_page', u'file_is_unicode', u'string_is_unicode',
__all__ = [u'AppLocation', u'get_application_version', u'check_latest_version',
u'add_actions', u'get_filesystem_encoding', u'LanguageManager',
u'ActionList', u'get_web_page', u'file_is_unicode', u'string_is_unicode',
u'get_uno_command', u'get_uno_instance', u'delete_file']

View File

@ -27,6 +27,8 @@
The :mod:`~openlp.core.utils.actions` module provides action list classes used
by the shortcuts system.
"""
from PyQt4 import QtCore, QtGui
class ActionCategory(object):
"""
The :class:`~openlp.core.utils.ActionCategory` class encapsulates a
@ -67,6 +69,7 @@ class CategoryActionList(object):
Python 3 "next" method.
"""
if self.index >= len(self.actions):
self.index = 0
raise StopIteration
else:
self.index += 1
@ -94,6 +97,12 @@ class CategoryActionList(object):
self.actions.append((weight, action))
self.actions.sort(key=lambda act: act[0])
def remove(self, remove_action):
for action in self.actions:
if action[1] == remove_action:
self.actions.remove(action)
return
class CategoryList(object):
"""
@ -126,6 +135,7 @@ class CategoryList(object):
Python 3 "next" method for iterator.
"""
if self.index >= len(self.categories):
self.index = 0
raise StopIteration
else:
self.index += 1
@ -163,6 +173,11 @@ class CategoryList(object):
self.categories.append(category)
self.categories.sort(key=lambda cat: cat.weight)
def remove(self, name):
for category in self.categories:
if category.name == name:
self.categories.remove(category)
class ActionList(object):
"""
@ -171,13 +186,101 @@ class ActionList(object):
has a weight by which it is sorted when iterating through the list of
actions or categories.
"""
instance = None
def __init__(self):
self.categories = CategoryList()
def add_action(self, action, category=u'Default', weight=None):
@staticmethod
def get_instance():
if ActionList.instance is None:
ActionList.instance = ActionList()
return ActionList.instance
def add_action(self, action, category=None, weight=None):
"""
Add an action to the list of actions.
``action``
The action to add (QAction).
``category``
The category this action belongs to. The category can be a QString
or python unicode string. **Note**, if the category is ``None``, the
category and its actions are being hidden in the shortcut dialog.
However, if they are added, it is possible to avoid assigning
shortcuts twice, which is important.
``weight``
The weight specifies how important a category is. However, this only
has an impact on the order the categories are displayed.
"""
if category is not None:
category = unicode(category)
if category not in self.categories:
self.categories.append(category)
action.defaultShortcuts = action.shortcuts()
if weight is None:
self.categories[category].actions.append(action)
else:
self.categories[category].actions.add(action, weight)
if category is None:
# Stop here, as this action is not configurable.
return
# Load the shortcut from the config.
settings = QtCore.QSettings()
settings.beginGroup(u'shortcuts')
shortcuts = settings.value(action.objectName(),
QtCore.QVariant(action.shortcuts())).toStringList()
action.setShortcuts(
[QtGui.QKeySequence(shortcut) for shortcut in shortcuts])
settings.endGroup()
def remove_action(self, action, category=None):
"""
This removes an action from its category. Empty categories are
automatically removed.
``action``
The QAction object to be removed.
``category``
The name (unicode string) of the category, which contains the
action. Defaults to None.
"""
if category is not None:
category = unicode(category)
if category not in self.categories:
return
self.categories[category].actions.remove(action)
# Remove empty categories.
if len(self.categories[category].actions) == 0:
self.categories.remove(category)
def add_category(self, name, weight):
"""
Add an empty category to the list of categories. This is ony convenient
for categories with a given weight.
``name``
The category's name.
``weight``
The category's weight (int).
"""
if name in self.categories:
# Only change the weight and resort the categories again.
for category in self.categories:
if category.name == name:
category.weight = weight
self.categories.categories.sort(key=lambda cat: cat.weight)
return
self.categories.add(name, weight)
class CategoryOrder(object):
"""
An enumeration class for category weights.
"""
standardMenu = -20
standardToolbar = -10

View File

@ -30,6 +30,8 @@ from PyQt4 import QtCore, QtGui
from openlp.core.lib import Plugin, StringContent, build_icon, translate
from openlp.core.lib.db import Manager
from openlp.core.lib.ui import icon_action, UiStrings
from openlp.core.utils.actions import ActionList
from openlp.plugins.alerts.lib import AlertsManager, AlertsTab
from openlp.plugins.alerts.lib.db import init_schema
from openlp.plugins.alerts.forms import AlertForm
@ -41,9 +43,10 @@ class AlertsPlugin(Plugin):
def __init__(self, plugin_helpers):
Plugin.__init__(self, u'Alerts', plugin_helpers,
settingsTabClass=AlertsTab)
settings_tab_class=AlertsTab)
self.weight = -3
self.icon = build_icon(u':/plugins/plugin_alerts.png')
self.icon_path = u':/plugins/plugin_alerts.png'
self.icon = build_icon(self.icon_path)
self.alertsmanager = AlertsManager(self)
self.manager = Manager(u'alerts', init_schema)
self.alertForm = AlertForm(self)
@ -58,9 +61,8 @@ class AlertsPlugin(Plugin):
use it as their parent.
"""
log.info(u'add tools menu')
self.toolsAlertItem = QtGui.QAction(tools_menu)
self.toolsAlertItem.setIcon(build_icon(u':/plugins/plugin_alerts.png'))
self.toolsAlertItem.setObjectName(u'toolsAlertItem')
self.toolsAlertItem = icon_action(tools_menu, u'toolsAlertItem',
u':/plugins/plugin_alerts.png')
self.toolsAlertItem.setText(translate('AlertsPlugin', '&Alert'))
self.toolsAlertItem.setStatusTip(
translate('AlertsPlugin', 'Show an alert message.'))
@ -74,6 +76,8 @@ class AlertsPlugin(Plugin):
log.info(u'Alerts Initialising')
Plugin.initialise(self)
self.toolsAlertItem.setVisible(True)
action_list = ActionList.get_instance()
action_list.add_action(self.toolsAlertItem, UiStrings().Tools)
self.liveController.alertTab = self.settings_tab
def finalise(self):
@ -84,6 +88,8 @@ class AlertsPlugin(Plugin):
self.manager.finalise()
Plugin.finalise(self)
self.toolsAlertItem.setVisible(False)
action_list = ActionList.get_instance()
action_list.remove_action(self.toolsAlertItem, u'Tools')
def toggleAlertsState(self):
self.alertsActive = not self.alertsActive
@ -112,4 +118,4 @@ class AlertsPlugin(Plugin):
## Name for MediaDockManager, SettingsManager ##
self.textStrings[StringContent.VisibleName] = {
u'title': translate('AlertsPlugin', 'Alerts', 'container title')
}
}

View File

@ -61,6 +61,12 @@ class AlertForm(QtGui.QDialog, Ui_AlertDialog):
QtCore.QObject.connect(self.alertListWidget,
QtCore.SIGNAL(u'currentRowChanged(int)'), self.onCurrentRowChanged)
def exec_(self):
self.displayButton.setEnabled(False)
self.displayCloseButton.setEnabled(False)
self.alertTextEdit.setText(u'')
return QtGui.QDialog.exec_(self)
def loadList(self):
"""
Loads the list with alerts.
@ -125,6 +131,12 @@ class AlertForm(QtGui.QDialog, Ui_AlertDialog):
# Only enable the button, if we are editing an item.
if self.item_id:
self.saveButton.setEnabled(True)
if self.alertTextEdit.text():
self.displayButton.setEnabled(True)
self.displayCloseButton.setEnabled(True)
else:
self.displayButton.setEnabled(False)
self.displayCloseButton.setEnabled(False)
def onDoubleClick(self):
"""

View File

@ -33,8 +33,8 @@ class AlertsTab(SettingsTab):
"""
AlertsTab is the alerts settings tab in the settings dialog.
"""
def __init__(self, name, visible_title):
SettingsTab.__init__(self, name, visible_title)
def __init__(self, parent, name, visible_title, icon_path):
SettingsTab.__init__(self, parent, name, visible_title, icon_path)
def setupUi(self):
self.setObjectName(u'AlertsTab')
@ -109,12 +109,12 @@ class AlertsTab(SettingsTab):
translate('AlertsPlugin.AlertsTab', 'Background color:'))
self.FontSizeLabel.setText(
translate('AlertsPlugin.AlertsTab', 'Font size:'))
self.FontSizeSpinBox.setSuffix(UiStrings.FontSizePtUnit)
self.FontSizeSpinBox.setSuffix(UiStrings().FontSizePtUnit)
self.TimeoutLabel.setText(
translate('AlertsPlugin.AlertsTab', 'Alert timeout:'))
self.TimeoutSpinBox.setSuffix(UiStrings.Seconds)
self.PreviewGroupBox.setTitle(UiStrings.Preview)
self.FontPreview.setText(UiStrings.OLPV2)
self.TimeoutSpinBox.setSuffix(UiStrings().Seconds)
self.PreviewGroupBox.setTitle(UiStrings().Preview)
self.FontPreview.setText(UiStrings().OLPV2)
def onBackgroundColorButtonClicked(self):
new_color = QtGui.QColorDialog.getColor(
@ -191,4 +191,4 @@ class AlertsTab(SettingsTab):
font.setPointSize(self.font_size)
self.FontPreview.setFont(font)
self.FontPreview.setStyleSheet(u'background-color: %s; color: %s' %
(self.bg_color, self.font_color))
(self.bg_color, self.font_color))

View File

@ -29,6 +29,8 @@ import logging
from PyQt4 import QtCore, QtGui
from openlp.core.lib import Plugin, StringContent, build_icon, translate
from openlp.core.lib.ui import base_action, UiStrings
from openlp.core.utils.actions import ActionList
from openlp.plugins.bibles.lib import BibleManager, BiblesTab, BibleMediaItem
log = logging.getLogger(__name__)
@ -50,6 +52,10 @@ class BiblePlugin(Plugin):
self.manager = BibleManager(self)
Plugin.initialise(self)
self.importBibleItem.setVisible(True)
action_list = ActionList.get_instance()
action_list.add_action(self.importBibleItem, UiStrings().Import)
# Do not add the action to the list yet.
#action_list.add_action(self.exportBibleItem, UiStrings().Export)
# Set to invisible until we can export bibles
self.exportBibleItem.setVisible(False)
@ -60,25 +66,25 @@ class BiblePlugin(Plugin):
log.info(u'Plugin Finalise')
self.manager.finalise()
Plugin.finalise(self)
action_list = ActionList.get_instance()
action_list.remove_action(self.importBibleItem, UiStrings().Import)
self.importBibleItem.setVisible(False)
#action_list.remove_action(self.exportBibleItem, UiStrings().Export)
self.exportBibleItem.setVisible(False)
def addImportMenuItem(self, import_menu):
self.importBibleItem = QtGui.QAction(import_menu)
self.importBibleItem.setObjectName(u'importBibleItem')
self.importBibleItem = base_action(import_menu, u'importBibleItem')
self.importBibleItem.setText(translate('BiblesPlugin', '&Bible'))
import_menu.addAction(self.importBibleItem)
self.importBibleItem.setText(
translate('BiblesPlugin', '&Bible'))
# signals and slots
QtCore.QObject.connect(self.importBibleItem,
QtCore.SIGNAL(u'triggered()'), self.onBibleImportClick)
self.importBibleItem.setVisible(False)
def addExportMenuItem(self, export_menu):
self.exportBibleItem = QtGui.QAction(export_menu)
self.exportBibleItem.setObjectName(u'exportBibleItem')
export_menu.addAction(self.exportBibleItem)
self.exportBibleItem = base_action(export_menu, u'exportBibleItem')
self.exportBibleItem.setText(translate('BiblesPlugin', '&Bible'))
export_menu.addAction(self.exportBibleItem)
self.exportBibleItem.setVisible(False)
def onBibleImportClick(self):
@ -140,4 +146,4 @@ class BiblePlugin(Plugin):
u'service': translate('BiblesPlugin',
'Add the selected Bible to the service')
}
self.setPluginUiTextStrings(tooltips)
self.setPluginUiTextStrings(tooltips)

View File

@ -85,8 +85,18 @@ class BibleImportForm(OpenLPWizard):
"""
OpenLPWizard.setupUi(self, image)
QtCore.QObject.connect(self.formatComboBox,
QtCore.SIGNAL(u'currentIndexChanged(int)'), self.selectStack,
QtCore.SLOT(u'setCurrentIndex(int)'))
QtCore.SIGNAL(u'currentIndexChanged(int)'),
self.onCurrentIndexChanged)
def onCurrentIndexChanged(self, index):
"""
Called when the format combo box's index changed. We have to check if
the import is available and accordingly to disable or enable the next
button.
"""
self.selectStack.setCurrentIndex(index)
next_button = self.button(QtGui.QWizard.NextButton)
next_button.setEnabled(BibleFormat.get_availability(index))
def customInit(self):
"""
@ -367,7 +377,7 @@ class BibleImportForm(OpenLPWizard):
self.formatComboBox.setItemText(BibleFormat.OpenSong, WizardStrings.OS)
self.formatComboBox.setItemText(BibleFormat.WebDownload,
translate('BiblesPlugin.ImportWizardForm', 'Web Download'))
self.formatComboBox.setItemText(BibleFormat.OpenLP1, UiStrings.OLPV1)
self.formatComboBox.setItemText(BibleFormat.OpenLP1, UiStrings().OLPV1)
self.openlp1FileLabel.setText(
translate('BiblesPlugin.ImportWizardForm', 'Bible file:'))
self.osisFileLabel.setText(
@ -441,13 +451,13 @@ class BibleImportForm(OpenLPWizard):
elif self.currentPage() == self.selectPage:
if self.field(u'source_format').toInt()[0] == BibleFormat.OSIS:
if not self.field(u'osis_location').toString():
critical_error_message_box(UiStrings.NFSs,
critical_error_message_box(UiStrings().NFSs,
WizardStrings.YouSpecifyFile % WizardStrings.OSIS)
self.osisFileEdit.setFocus()
return False
elif self.field(u'source_format').toInt()[0] == BibleFormat.CSV:
if not self.field(u'csv_testamentsfile').toString():
answer = critical_error_message_box(UiStrings.NFSs,
answer = critical_error_message_box(UiStrings().NFSs,
translate('BiblesPlugin.ImportWizardForm',
'You have not specified a testaments file. Do you '
'want to proceed with the import?'), question=True)
@ -455,14 +465,14 @@ class BibleImportForm(OpenLPWizard):
self.csvTestamentsEdit.setFocus()
return False
if not self.field(u'csv_booksfile').toString():
critical_error_message_box(UiStrings.NFSs,
critical_error_message_box(UiStrings().NFSs,
translate('BiblesPlugin.ImportWizardForm',
'You need to specify a file with books of '
'the Bible to use in the import.'))
self.csvBooksEdit.setFocus()
return False
elif not self.field(u'csv_versefile').toString():
critical_error_message_box(UiStrings.NFSs,
critical_error_message_box(UiStrings().NFSs,
translate('BiblesPlugin.ImportWizardForm',
'You need to specify a file of Bible '
'verses to import.'))
@ -471,14 +481,14 @@ class BibleImportForm(OpenLPWizard):
elif self.field(u'source_format').toInt()[0] == \
BibleFormat.OpenSong:
if not self.field(u'opensong_file').toString():
critical_error_message_box(UiStrings.NFSs,
critical_error_message_box(UiStrings().NFSs,
WizardStrings.YouSpecifyFile % WizardStrings.OS)
self.openSongFileEdit.setFocus()
return False
elif self.field(u'source_format').toInt()[0] == BibleFormat.OpenLP1:
if not self.field(u'openlp1_location').toString():
critical_error_message_box(UiStrings.NFSs,
WizardStrings.YouSpecifyFile % UiStrings.OLPV1)
critical_error_message_box(UiStrings().NFSs,
WizardStrings.YouSpecifyFile % UiStrings().OLPV1)
self.openlp1FileEdit.setFocus()
return False
return True
@ -487,13 +497,13 @@ class BibleImportForm(OpenLPWizard):
license_copyright = \
unicode(self.field(u'license_copyright').toString())
if not license_version:
critical_error_message_box(UiStrings.EmptyField,
critical_error_message_box(UiStrings().EmptyField,
translate('BiblesPlugin.ImportWizardForm',
'You need to specify a version name for your Bible.'))
self.versionNameEdit.setFocus()
return False
elif not license_copyright:
critical_error_message_box(UiStrings.EmptyField,
critical_error_message_box(UiStrings().EmptyField,
translate('BiblesPlugin.ImportWizardForm',
'You need to set a copyright for your Bible. '
'Bibles in the Public Domain need to be marked as such.'))
@ -566,7 +576,7 @@ class BibleImportForm(OpenLPWizard):
"""
Show the file open dialog for the openlp.org 1.x file.
"""
self.getFileName(WizardStrings.OpenTypeFile % UiStrings.OLPV1,
self.getFileName(WizardStrings.OpenTypeFile % UiStrings().OLPV1,
self.openlp1FileEdit, u'%s (*.bible)' %
translate('BiblesPlugin.ImportWizardForm',
'openlp.org 1.x Bible Files'))
@ -755,4 +765,4 @@ class BibleImportForm(OpenLPWizard):
self.progressLabel.setText(translate(
'BiblesPlugin.ImportWizardForm', 'Your Bible import failed.'))
del self.manager.db_cache[importer.name]
delete_database(self.plugin.settingsSection, importer.file)
delete_database(self.plugin.settingsSection, importer.file)

View File

@ -30,6 +30,7 @@ from PyQt4 import QtCore, QtGui
from openlp.core.lib import Receiver, SettingsTab, translate
from openlp.plugins.bibles.lib import LayoutStyle, DisplayStyle
from openlp.core.lib.ui import UiStrings, find_and_set_in_combo_box
log = logging.getLogger(__name__)
@ -39,117 +40,115 @@ class BiblesTab(SettingsTab):
"""
log.info(u'Bible Tab loaded')
def __init__(self, title, visible_title):
def __init__(self, parent, title, visible_title, icon_path):
self.paragraph_style = True
self.show_new_chapters = False
self.display_style = 0
SettingsTab.__init__(self, title, visible_title)
SettingsTab.__init__(self, parent, title, visible_title, icon_path)
def setupUi(self):
self.setObjectName(u'BiblesTab')
SettingsTab.setupUi(self)
self.VerseDisplayGroupBox = QtGui.QGroupBox(self.leftColumn)
self.VerseDisplayGroupBox.setObjectName(u'VerseDisplayGroupBox')
self.VerseDisplayLayout = QtGui.QFormLayout(self.VerseDisplayGroupBox)
self.VerseDisplayLayout.setObjectName(u'VerseDisplayLayout')
self.NewChaptersCheckBox = QtGui.QCheckBox(self.VerseDisplayGroupBox)
self.NewChaptersCheckBox.setObjectName(u'NewChaptersCheckBox')
self.VerseDisplayLayout.addRow(self.NewChaptersCheckBox)
self.DisplayStyleLabel = QtGui.QLabel(self.VerseDisplayGroupBox)
self.DisplayStyleLabel.setObjectName(u'DisplayStyleLabel')
self.DisplayStyleComboBox = QtGui.QComboBox(self.VerseDisplayGroupBox)
self.DisplayStyleComboBox.addItems([u'', u'', u'', u''])
self.DisplayStyleComboBox.setObjectName(u'DisplayStyleComboBox')
self.VerseDisplayLayout.addRow(self.DisplayStyleLabel,
self.DisplayStyleComboBox)
self.LayoutStyleLabel = QtGui.QLabel(self.VerseDisplayGroupBox)
self.LayoutStyleLabel.setObjectName(u'LayoutStyleLabel')
self.LayoutStyleComboBox = QtGui.QComboBox(self.VerseDisplayGroupBox)
self.LayoutStyleComboBox.setObjectName(u'LayoutStyleComboBox')
self.LayoutStyleComboBox.addItems([u'', u'', u''])
self.VerseDisplayLayout.addRow(self.LayoutStyleLabel,
self.LayoutStyleComboBox)
self.BibleSecondCheckBox = QtGui.QCheckBox(self.VerseDisplayGroupBox)
self.BibleSecondCheckBox.setObjectName(u'BibleSecondCheckBox')
self.VerseDisplayLayout.addRow(self.BibleSecondCheckBox)
self.BibleThemeLabel = QtGui.QLabel(self.VerseDisplayGroupBox)
self.BibleThemeLabel.setObjectName(u'BibleThemeLabel')
self.BibleThemeComboBox = QtGui.QComboBox(self.VerseDisplayGroupBox)
self.BibleThemeComboBox.setSizeAdjustPolicy(
self.verseDisplayGroupBox = QtGui.QGroupBox(self.leftColumn)
self.verseDisplayGroupBox.setObjectName(u'verseDisplayGroupBox')
self.verseDisplayLayout = QtGui.QFormLayout(self.verseDisplayGroupBox)
self.verseDisplayLayout.setObjectName(u'verseDisplayLayout')
self.newChaptersCheckBox = QtGui.QCheckBox(self.verseDisplayGroupBox)
self.newChaptersCheckBox.setObjectName(u'newChaptersCheckBox')
self.verseDisplayLayout.addRow(self.newChaptersCheckBox)
self.displayStyleLabel = QtGui.QLabel(self.verseDisplayGroupBox)
self.displayStyleLabel.setObjectName(u'displayStyleLabel')
self.displayStyleComboBox = QtGui.QComboBox(self.verseDisplayGroupBox)
self.displayStyleComboBox.addItems([u'', u'', u'', u''])
self.displayStyleComboBox.setObjectName(u'displayStyleComboBox')
self.verseDisplayLayout.addRow(self.displayStyleLabel,
self.displayStyleComboBox)
self.layoutStyleLabel = QtGui.QLabel(self.verseDisplayGroupBox)
self.layoutStyleLabel.setObjectName(u'layoutStyleLabel')
self.layoutStyleComboBox = QtGui.QComboBox(self.verseDisplayGroupBox)
self.layoutStyleComboBox.setObjectName(u'layoutStyleComboBox')
self.layoutStyleComboBox.addItems([u'', u'', u''])
self.verseDisplayLayout.addRow(self.layoutStyleLabel,
self.layoutStyleComboBox)
self.bibleSecondCheckBox = QtGui.QCheckBox(self.verseDisplayGroupBox)
self.bibleSecondCheckBox.setObjectName(u'bibleSecondCheckBox')
self.verseDisplayLayout.addRow(self.bibleSecondCheckBox)
self.bibleThemeLabel = QtGui.QLabel(self.verseDisplayGroupBox)
self.bibleThemeLabel.setObjectName(u'BibleThemeLabel')
self.bibleThemeComboBox = QtGui.QComboBox(self.verseDisplayGroupBox)
self.bibleThemeComboBox.setSizeAdjustPolicy(
QtGui.QComboBox.AdjustToMinimumContentsLength)
self.BibleThemeComboBox.setSizePolicy(
self.bibleThemeComboBox.setSizePolicy(
QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Fixed)
self.BibleThemeComboBox.addItem(u'')
self.BibleThemeComboBox.setObjectName(u'BibleThemeComboBox')
self.VerseDisplayLayout.addRow(self.BibleThemeLabel,
self.BibleThemeComboBox)
self.ChangeNoteLabel = QtGui.QLabel(self.VerseDisplayGroupBox)
self.ChangeNoteLabel.setWordWrap(True)
self.ChangeNoteLabel.setObjectName(u'ChangeNoteLabel')
self.VerseDisplayLayout.addRow(self.ChangeNoteLabel)
self.leftLayout.addWidget(self.VerseDisplayGroupBox)
self.bibleThemeComboBox.addItem(u'')
self.bibleThemeComboBox.setObjectName(u'BibleThemeComboBox')
self.verseDisplayLayout.addRow(self.bibleThemeLabel,
self.bibleThemeComboBox)
self.changeNoteLabel = QtGui.QLabel(self.verseDisplayGroupBox)
self.changeNoteLabel.setWordWrap(True)
self.changeNoteLabel.setObjectName(u'changeNoteLabel')
self.verseDisplayLayout.addRow(self.changeNoteLabel)
self.leftLayout.addWidget(self.verseDisplayGroupBox)
self.leftLayout.addStretch()
self.rightColumn.setSizePolicy(
QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Preferred)
self.rightLayout.addStretch()
# Signals and slots
QtCore.QObject.connect(
self.NewChaptersCheckBox, QtCore.SIGNAL(u'stateChanged(int)'),
self.newChaptersCheckBox, QtCore.SIGNAL(u'stateChanged(int)'),
self.onNewChaptersCheckBoxChanged)
QtCore.QObject.connect(
self.DisplayStyleComboBox, QtCore.SIGNAL(u'activated(int)'),
self.displayStyleComboBox, QtCore.SIGNAL(u'activated(int)'),
self.onDisplayStyleComboBoxChanged)
QtCore.QObject.connect(
self.BibleThemeComboBox, QtCore.SIGNAL(u'activated(int)'),
self.bibleThemeComboBox, QtCore.SIGNAL(u'activated(int)'),
self.onBibleThemeComboBoxChanged)
QtCore.QObject.connect(
self.LayoutStyleComboBox, QtCore.SIGNAL(u'activated(int)'),
self.layoutStyleComboBox, QtCore.SIGNAL(u'activated(int)'),
self.onLayoutStyleComboBoxChanged)
QtCore.QObject.connect(
self.BibleSecondCheckBox, QtCore.SIGNAL(u'stateChanged(int)'),
self.bibleSecondCheckBox, QtCore.SIGNAL(u'stateChanged(int)'),
self.onBibleSecondCheckBox)
QtCore.QObject.connect(Receiver.get_receiver(),
QtCore.SIGNAL(u'theme_update_list'), self.updateThemeList)
def retranslateUi(self):
self.VerseDisplayGroupBox.setTitle(
self.verseDisplayGroupBox.setTitle(
translate('BiblesPlugin.BiblesTab', 'Verse Display'))
self.NewChaptersCheckBox.setText(
self.newChaptersCheckBox.setText(
translate('BiblesPlugin.BiblesTab',
'Only show new chapter numbers'))
self.LayoutStyleLabel.setText(
translate('BiblesPlugin.BiblesTab', 'Layout style:'))
self.DisplayStyleLabel.setText(
translate('BiblesPlugin.BiblesTab', 'Display style:'))
self.BibleThemeLabel.setText(
self.layoutStyleLabel.setText(UiStrings().LayoutStyle)
self.displayStyleLabel.setText(UiStrings().DisplayStyle)
self.bibleThemeLabel.setText(
translate('BiblesPlugin.BiblesTab', 'Bible theme:'))
self.LayoutStyleComboBox.setItemText(LayoutStyle.VersePerSlide,
translate('BiblesPlugin.BiblesTab', 'Verse Per Slide'))
self.LayoutStyleComboBox.setItemText(LayoutStyle.VersePerLine,
translate('BiblesPlugin.BiblesTab', 'Verse Per Line'))
self.LayoutStyleComboBox.setItemText(LayoutStyle.Continuous,
translate('BiblesPlugin.BiblesTab', 'Continuous'))
self.DisplayStyleComboBox.setItemText(DisplayStyle.NoBrackets,
self.layoutStyleComboBox.setItemText(LayoutStyle.VersePerSlide,
UiStrings().VersePerSlide)
self.layoutStyleComboBox.setItemText(LayoutStyle.VersePerLine,
UiStrings().VersePerLine)
self.layoutStyleComboBox.setItemText(LayoutStyle.Continuous,
UiStrings().Continuous)
self.displayStyleComboBox.setItemText(DisplayStyle.NoBrackets,
translate('BiblesPlugin.BiblesTab', 'No Brackets'))
self.DisplayStyleComboBox.setItemText(DisplayStyle.Round,
self.displayStyleComboBox.setItemText(DisplayStyle.Round,
translate('BiblesPlugin.BiblesTab', '( And )'))
self.DisplayStyleComboBox.setItemText(DisplayStyle.Curly,
self.displayStyleComboBox.setItemText(DisplayStyle.Curly,
translate('BiblesPlugin.BiblesTab', '{ And }'))
self.DisplayStyleComboBox.setItemText(DisplayStyle.Square,
self.displayStyleComboBox.setItemText(DisplayStyle.Square,
translate('BiblesPlugin.BiblesTab', '[ And ]'))
self.ChangeNoteLabel.setText(translate('BiblesPlugin.BiblesTab',
self.changeNoteLabel.setText(translate('BiblesPlugin.BiblesTab',
'Note:\nChanges do not affect verses already in the service.'))
self.BibleSecondCheckBox.setText(
self.bibleSecondCheckBox.setText(
translate('BiblesPlugin.BiblesTab', 'Display second Bible verses'))
def onBibleThemeComboBoxChanged(self):
self.bible_theme = self.BibleThemeComboBox.currentText()
self.bible_theme = self.bibleThemeComboBox.currentText()
def onDisplayStyleComboBoxChanged(self):
self.display_style = self.DisplayStyleComboBox.currentIndex()
self.display_style = self.displayStyleComboBox.currentIndex()
def onLayoutStyleComboBoxChanged(self):
self.layout_style = self.LayoutStyleComboBox.currentIndex()
self.layout_style = self.layoutStyleComboBox.currentIndex()
def onNewChaptersCheckBoxChanged(self, check_state):
self.show_new_chapters = False
@ -176,10 +175,10 @@ class BiblesTab(SettingsTab):
settings.value(u'bible theme', QtCore.QVariant(u'')).toString())
self.second_bibles = settings.value(
u'second bibles', QtCore.QVariant(True)).toBool()
self.NewChaptersCheckBox.setChecked(self.show_new_chapters)
self.DisplayStyleComboBox.setCurrentIndex(self.display_style)
self.LayoutStyleComboBox.setCurrentIndex(self.layout_style)
self.BibleSecondCheckBox.setChecked(self.second_bibles)
self.newChaptersCheckBox.setChecked(self.show_new_chapters)
self.displayStyleComboBox.setCurrentIndex(self.display_style)
self.layoutStyleComboBox.setCurrentIndex(self.layout_style)
self.bibleSecondCheckBox.setChecked(self.second_bibles)
settings.endGroup()
def save(self):
@ -204,14 +203,8 @@ class BiblesTab(SettingsTab):
[u'Bible Theme', u'Song Theme']
"""
self.BibleThemeComboBox.clear()
self.BibleThemeComboBox.addItem(u'')
self.bibleThemeComboBox.clear()
self.bibleThemeComboBox.addItem(u'')
for theme in theme_list:
self.BibleThemeComboBox.addItem(theme)
index = self.BibleThemeComboBox.findText(
unicode(self.bible_theme), QtCore.Qt.MatchExactly)
if index == -1:
# Not Found.
index = 0
self.bible_theme = u''
self.BibleThemeComboBox.setCurrentIndex(index)
self.bibleThemeComboBox.addItem(theme)
find_and_set_in_combo_box(self.bibleThemeComboBox, self.bible_theme)

View File

@ -177,10 +177,7 @@ class BibleDB(QtCore.QObject, Manager):
Returns the version name of the Bible.
"""
version_name = self.get_object(BibleMeta, u'Version')
if version_name:
self.name = version_name.value
else:
self.name = None
self.name = version_name.value if version_name else None
return self.name
def clean_filename(self, old_filename):
@ -256,10 +253,10 @@ class BibleDB(QtCore.QObject, Manager):
# Text list has book and chapter as first two elements of the array.
for verse_number, verse_text in textlist.iteritems():
verse = Verse.populate(
book_id = book_id,
chapter = chapter,
verse = verse_number,
text = verse_text
book_id=book_id,
chapter=chapter,
verse=verse_number,
text=verse_text
)
self.session.add(verse)
self.session.commit()
@ -383,15 +380,13 @@ class BibleDB(QtCore.QObject, Manager):
log.debug(u'BibleDB.verse_search("%s")', text)
verses = self.session.query(Verse)
if text.find(u',') > -1:
or_clause = []
keywords = [u'%%%s%%' % keyword.strip()
for keyword in text.split(u',')]
for keyword in keywords:
or_clause.append(Verse.text.like(keyword))
keywords = \
[u'%%%s%%' % keyword.strip() for keyword in text.split(u',')]
or_clause = [Verse.text.like(keyword) for keyword in keywords]
verses = verses.filter(or_(*or_clause))
else:
keywords = [u'%%%s%%' % keyword.strip()
for keyword in text.split(u' ')]
keywords = \
[u'%%%s%%' % keyword.strip() for keyword in text.split(u' ')]
for keyword in keywords:
verses = verses.filter(Verse.text.like(keyword))
verses = verses.all()

View File

@ -32,7 +32,7 @@ from openlp.core.lib import MediaManagerItem, Receiver, ItemCapabilities, \
translate
from openlp.core.lib.searchedit import SearchEdit
from openlp.core.lib.ui import UiStrings, add_widget_completer, \
media_item_combo_box, critical_error_message_box
media_item_combo_box, critical_error_message_box, find_and_set_in_combo_box
from openlp.plugins.bibles.forms import BibleImportForm
from openlp.plugins.bibles.lib import LayoutStyle, DisplayStyle, \
VerseReferenceList, get_reference_match
@ -58,6 +58,7 @@ class BibleMediaItem(MediaManagerItem):
MediaManagerItem.__init__(self, parent, plugin, icon)
# Place to store the search results for both bibles.
self.settings = self.parent.settings_tab
self.quickPreviewAllowed = True
self.search_results = {}
self.second_search_results = {}
QtCore.QObject.connect(Receiver.get_receiver(),
@ -99,13 +100,13 @@ class BibleMediaItem(MediaManagerItem):
self.quickSearchEdit = SearchEdit(self.quickTab)
self.quickSearchEdit.setObjectName(u'quickSearchEdit')
self.quickSearchLabel.setBuddy(self.quickSearchEdit)
self.quickSearchEdit.setSearchTypes([
(BibleSearch.Reference, u':/bibles/bibles_search_reference.png',
translate('BiblesPlugin.MediaItem', 'Scripture Reference')),
(BibleSearch.Text, u':/bibles/bibles_search_text.png',
translate('BiblesPlugin.MediaItem', 'Text Search'))
])
self.quickLayout.addRow(self.quickSearchLabel, self.quickSearchEdit)
self.quickLayoutLabel = QtGui.QLabel(self.quickTab)
self.quickLayoutLabel.setObjectName(u'quickClearLabel')
self.quickLayoutComboBox = media_item_combo_box(self.quickTab,
u'quickLayoutComboBox')
self.quickLayoutComboBox.addItems([u'', u'', u''])
self.quickLayout.addRow(self.quickLayoutLabel, self.quickLayoutComboBox)
self.quickClearLabel = QtGui.QLabel(self.quickTab)
self.quickClearLabel.setObjectName(u'quickClearLabel')
self.quickClearComboBox = media_item_combo_box(self.quickTab,
@ -192,7 +193,7 @@ class BibleMediaItem(MediaManagerItem):
self.advancedSearchButtonLayout.addWidget(self.advancedSearchButton)
self.advancedLayout.addLayout(
self.advancedSearchButtonLayout, 7, 0, 1, 3)
self.searchTabWidget.addTab(self.advancedTab, UiStrings.Advanced)
self.searchTabWidget.addTab(self.advancedTab, UiStrings().Advanced)
# Add the search tab widget to the page layout.
self.pageLayout.addWidget(self.searchTabWidget)
# Combo Boxes
@ -210,6 +211,9 @@ class BibleMediaItem(MediaManagerItem):
QtCore.SIGNAL(u'searchTypeChanged(int)'), self.updateAutoCompleter)
QtCore.QObject.connect(self.quickVersionComboBox,
QtCore.SIGNAL(u'activated(int)'), self.updateAutoCompleter)
QtCore.QObject.connect(
self.quickLayoutComboBox, QtCore.SIGNAL(u'activated(int)'),
self.onlayoutStyleComboBoxChanged)
# Buttons
QtCore.QObject.connect(self.advancedSearchButton,
QtCore.SIGNAL(u'pressed()'), self.onAdvancedSearchButton)
@ -234,18 +238,19 @@ class BibleMediaItem(MediaManagerItem):
self.advancedSecondComboBox.setVisible(False)
self.quickSecondLabel.setVisible(False)
self.quickSecondComboBox.setVisible(False)
self.quickLayoutComboBox.setCurrentIndex(self.settings.layout_style)
def retranslateUi(self):
log.debug(u'retranslateUi')
self.quickVersionLabel.setText(u'%s:' % UiStrings.Version)
self.quickVersionLabel.setText(u'%s:' % UiStrings().Version)
self.quickSecondLabel.setText(
translate('BiblesPlugin.MediaItem', 'Second:'))
self.quickSearchLabel.setText(
translate('BiblesPlugin.MediaItem', 'Find:'))
self.quickSearchButton.setText(UiStrings.Search)
self.quickSearchButton.setText(UiStrings().Search)
self.quickClearLabel.setText(
translate('BiblesPlugin.MediaItem', 'Results:'))
self.advancedVersionLabel.setText(u'%s:' % UiStrings.Version)
self.advancedVersionLabel.setText(u'%s:' % UiStrings().Version)
self.advancedSecondLabel.setText(
translate('BiblesPlugin.MediaItem', 'Second:'))
self.advancedBookLabel.setText(
@ -260,7 +265,7 @@ class BibleMediaItem(MediaManagerItem):
translate('BiblesPlugin.MediaItem', 'To:'))
self.advancedClearLabel.setText(
translate('BiblesPlugin.MediaItem', 'Results:'))
self.advancedSearchButton.setText(UiStrings.Search)
self.advancedSearchButton.setText(UiStrings().Search)
self.quickClearComboBox.addItem(
translate('BiblesPlugin.MediaItem', 'Clear'))
self.quickClearComboBox.addItem(
@ -269,12 +274,31 @@ class BibleMediaItem(MediaManagerItem):
translate('BiblesPlugin.MediaItem', 'Clear'))
self.advancedClearComboBox.addItem(
translate('BiblesPlugin.MediaItem', 'Keep'))
self.quickLayoutLabel.setText(UiStrings().LayoutStyle)
self.quickLayoutComboBox.setItemText(LayoutStyle.VersePerSlide,
UiStrings().VersePerSlide)
self.quickLayoutComboBox.setItemText(LayoutStyle.VersePerLine,
UiStrings().VersePerLine)
self.quickLayoutComboBox.setItemText(LayoutStyle.Continuous,
UiStrings().Continuous)
def initialise(self):
log.debug(u'bible manager initialise')
self.parent.manager.media = self
self.loadBibles()
self.updateAutoCompleter()
bible = QtCore.QSettings().value(
self.settingsSection + u'/quick bible', QtCore.QVariant(
self.quickVersionComboBox.currentText())).toString()
find_and_set_in_combo_box(self.quickVersionComboBox, bible)
self.quickSearchEdit.setSearchTypes([
(BibleSearch.Reference, u':/bibles/bibles_search_reference.png',
translate('BiblesPlugin.MediaItem', 'Scripture Reference')),
(BibleSearch.Text, u':/bibles/bibles_search_text.png',
translate('BiblesPlugin.MediaItem', 'Text Search'))
])
self.quickSearchEdit.setCurrentSearchType(QtCore.QSettings().value(
u'%s/last search type' % self.settingsSection,
QtCore.QVariant(BibleSearch.Reference)).toInt()[0])
self.configUpdated()
log.debug(u'bible manager initialise complete')
@ -298,23 +322,28 @@ class BibleMediaItem(MediaManagerItem):
bibles = self.parent.manager.get_bibles().keys()
bibles.sort()
# Load the bibles into the combo boxes.
first = True
for bible in bibles:
if bible:
self.quickVersionComboBox.addItem(bible)
self.quickSecondComboBox.addItem(bible)
self.advancedVersionComboBox.addItem(bible)
self.advancedSecondComboBox.addItem(bible)
if first:
first = False
self.initialiseBible(bible)
# set the default value
bible = QtCore.QSettings().value(
self.settingsSection + u'/advanced bible',
QtCore.QVariant(u'')).toString()
if bible in bibles:
find_and_set_in_combo_box(self.advancedVersionComboBox, bible)
self.initialiseAdvancedBible(unicode(bible))
elif len(bibles):
self.initialiseAdvancedBible(bibles[0])
def reloadBibles(self):
log.debug(u'Reloading Bibles')
self.parent.manager.reload_bibles()
self.loadBibles()
def initialiseBible(self, bible):
def initialiseAdvancedBible(self, bible):
"""
This initialises the given bible, which means that its book names and
their chapter numbers is added to the combo boxes on the
@ -324,7 +353,7 @@ class BibleMediaItem(MediaManagerItem):
``bible``
The bible to initialise (unicode).
"""
log.debug(u'initialiseBible %s', bible)
log.debug(u'initialiseAdvancedBible %s', bible)
book_data = self.parent.manager.get_books(bible)
self.advancedBookComboBox.clear()
first = True
@ -360,6 +389,13 @@ class BibleMediaItem(MediaManagerItem):
completion depends on the bible. It is only updated when we are doing a
reference search, otherwise the auto completion list is removed.
"""
# Save the current search type to the configuration.
QtCore.QSettings().setValue(u'%s/last search type' %
self.settingsSection,
QtCore.QVariant(self.quickSearchEdit.currentSearchType()))
# Save the current bible to the configuration.
QtCore.QSettings().setValue(self.settingsSection + u'/quick bible',
QtCore.QVariant(self.quickVersionComboBox.currentText()))
books = []
# We have to do a 'Reference Search'.
if self.quickSearchEdit.currentSearchType() == BibleSearch.Reference:
@ -367,12 +403,14 @@ class BibleMediaItem(MediaManagerItem):
bible = unicode(self.quickVersionComboBox.currentText())
if bible:
book_data = bibles[bible].get_books()
books = [book.name for book in book_data]
books = [book.name + u' ' for book in book_data]
books.sort()
add_widget_completer(books, self.quickSearchEdit)
def onAdvancedVersionComboBox(self):
self.initialiseBible(
QtCore.QSettings().setValue(self.settingsSection + u'/advanced bible',
QtCore.QVariant(self.advancedVersionComboBox.currentText()))
self.initialiseAdvancedBible(
unicode(self.advancedVersionComboBox.currentText()))
def onAdvancedBookComboBox(self):
@ -804,3 +842,11 @@ class BibleMediaItem(MediaManagerItem):
if self.settings.display_style == DisplayStyle.Square:
return u'{su}[%s]{/su}' % verse_text
return u'{su}%s{/su}' % verse_text
def onlayoutStyleComboBoxChanged(self):
self.settings.layout_style = self.quickLayoutComboBox.currentIndex()
self.settings.layoutStyleComboBox.setCurrentIndex(
self.settings.layout_style)
QtCore.QSettings().setValue(
self.settingsSection + u'/verse layout style',
QtCore.QVariant(self.settings.layout_style))

View File

@ -37,6 +37,9 @@ from openlp.plugins.bibles.lib.db import BibleDB
log = logging.getLogger(__name__)
def replacement(match):
return match.group(2).upper()
class OSISBible(BibleDB):
"""
`OSIS <http://www.bibletechnologies.net/>`_ Bible format importer class.
@ -60,6 +63,7 @@ class OSISBible(BibleDB):
self.lg_regex = re.compile(r'<lg(.*?)>')
self.l_regex = re.compile(r'<l (.*?)>')
self.w_regex = re.compile(r'<w (.*?)>')
self.q_regex = re.compile(r'<q(.*?)>')
self.q1_regex = re.compile(r'<q(.*?)level="1"(.*?)>')
self.q2_regex = re.compile(r'<q(.*?)level="2"(.*?)>')
self.trans_regex = re.compile(r'<transChange(.*?)>(.*?)</transChange>')
@ -106,6 +110,7 @@ class OSISBible(BibleDB):
detect_file.close()
try:
osis = codecs.open(self.filename, u'r', details['encoding'])
repl = replacement
for file_record in osis:
if self.stop_import_flag:
break
@ -148,12 +153,13 @@ class OSISBible(BibleDB):
verse_text = self.rf_regex.sub(u'', verse_text)
verse_text = self.lb_regex.sub(u' ', verse_text)
verse_text = self.lg_regex.sub(u'', verse_text)
verse_text = self.l_regex.sub(u'', verse_text)
verse_text = self.l_regex.sub(u' ', verse_text)
verse_text = self.w_regex.sub(u'', verse_text)
verse_text = self.q1_regex.sub(u'"', verse_text)
verse_text = self.q2_regex.sub(u'\'', verse_text)
verse_text = self.q_regex.sub(u'', verse_text)
verse_text = self.divine_name_regex.sub(repl, verse_text)
verse_text = self.trans_regex.sub(u'', verse_text)
verse_text = self.divine_name_regex.sub(u'', verse_text)
verse_text = verse_text.replace(u'</lb>', u'')\
.replace(u'</l>', u'').replace(u'<lg>', u'')\
.replace(u'</lg>', u'').replace(u'</q>', u'')\

View File

@ -96,4 +96,7 @@ class VerseReferenceList(object):
version[u'copyright'])
if version[u'permission'].strip():
result = result + u', ' + version[u'permission']
result = result.rstrip()
if result.endswith(u','):
return result[:len(result)-1]
return result

View File

@ -107,11 +107,11 @@ class Ui_CustomEditDialog(object):
translate('CustomPlugin.EditCustomForm', 'Edit Custom Slides'))
self.titleLabel.setText(
translate('CustomPlugin.EditCustomForm', '&Title:'))
self.addButton.setText(UiStrings.Add)
self.addButton.setText(UiStrings().Add)
self.addButton.setToolTip(
translate('CustomPlugin.EditCustomForm', 'Add a new slide at '
'bottom.'))
self.editButton.setText(UiStrings.Edit)
self.editButton.setText(UiStrings().Edit)
self.editButton.setToolTip(
translate('CustomPlugin.EditCustomForm', 'Edit the selected '
'slide.'))
@ -124,4 +124,4 @@ class Ui_CustomEditDialog(object):
translate('CustomPlugin.EditCustomForm', 'The&me:'))
self.creditLabel.setText(
translate('CustomPlugin.EditCustomForm', '&Credits:'))
self.previewButton.setText(UiStrings.SaveAndPreview)
self.previewButton.setText(UiStrings().SaveAndPreview)

View File

@ -29,7 +29,7 @@ import logging
from PyQt4 import QtCore, QtGui
from openlp.core.lib import Receiver, translate
from openlp.core.lib.ui import critical_error_message_box
from openlp.core.lib.ui import critical_error_message_box, find_and_set_in_combo_box
from openlp.plugins.custom.lib import CustomXMLBuilder, CustomXMLParser
from openlp.plugins.custom.lib.db import CustomSlide
from editcustomdialog import Ui_CustomEditDialog
@ -98,11 +98,7 @@ class EditCustomForm(QtGui.QDialog, Ui_CustomEditDialog):
for slide in slideList:
self.slideListView.addItem(slide[1])
theme = self.customSlide.theme_name
id = self.themeComboBox.findText(theme, QtCore.Qt.MatchExactly)
# No theme match
if id == -1:
id = 0
self.themeComboBox.setCurrentIndex(id)
find_and_set_in_combo_box(self.themeComboBox, theme)
# If not preview hide the preview button.
self.previewButton.setVisible(False)
if preview:
@ -265,4 +261,4 @@ class EditCustomForm(QtGui.QDialog, Ui_CustomEditDialog):
message=translate('CustomPlugin.EditCustomForm',
'You need to add at least one slide'))
return False
return True
return True

View File

@ -32,8 +32,8 @@ class CustomTab(SettingsTab):
"""
CustomTab is the Custom settings tab in the settings dialog.
"""
def __init__(self, title, visible_title):
SettingsTab.__init__(self, title, visible_title)
def __init__(self, parent, title, visible_title, icon_path):
SettingsTab.__init__(self, parent, title, visible_title, icon_path)
def setupUi(self):
self.setObjectName(u'CustomTab')

View File

@ -110,7 +110,7 @@ class CustomMediaItem(MediaManagerItem):
"""
Edit a custom item
"""
if check_item_selected(self.listView, UiStrings.SelectEdit):
if check_item_selected(self.listView, UiStrings().SelectEdit):
item = self.listView.currentItem()
item_id = (item.data(QtCore.Qt.UserRole)).toInt()[0]
self.parent.edit_custom_form.loadCustom(item_id, False)
@ -121,7 +121,7 @@ class CustomMediaItem(MediaManagerItem):
"""
Remove a custom item from the list and database
"""
if check_item_selected(self.listView, UiStrings.SelectDelete):
if check_item_selected(self.listView, UiStrings().SelectDelete):
row_list = [item.row() for item in self.listView.selectedIndexes()]
row_list.sort(reverse=True)
id_list = [(item.data(QtCore.Qt.UserRole)).toInt()[0]
@ -160,4 +160,4 @@ class CustomMediaItem(MediaManagerItem):
else:
raw_footer.append(u'')
service_item.raw_footer = raw_footer
return True
return True

View File

@ -55,11 +55,11 @@ class ImageMediaItem(MediaManagerItem):
'Select Image(s)')
file_formats = get_images_filter()
self.onNewFileMasks = u'%s;;%s (*.*) (*)' % (file_formats,
UiStrings.AllFiles)
self.replaceAction.setText(UiStrings.ReplaceBG)
self.replaceAction.setToolTip(UiStrings.ReplaceLiveBG)
self.resetAction.setText(UiStrings.ResetBG)
self.resetAction.setToolTip(UiStrings.ResetLiveBG)
UiStrings().AllFiles)
self.replaceAction.setText(UiStrings().ReplaceBG)
self.replaceAction.setToolTip(UiStrings().ReplaceLiveBG)
self.resetAction.setText(UiStrings().ResetBG)
self.resetAction.setToolTip(UiStrings().ResetLiveBG)
def requiredIcons(self):
MediaManagerItem.requiredIcons(self)
@ -199,7 +199,7 @@ class ImageMediaItem(MediaManagerItem):
filepath)
self.resetAction.setVisible(True)
else:
critical_error_message_box(UiStrings.LiveBGError,
critical_error_message_box(UiStrings().LiveBGError,
unicode(translate('ImagePlugin.MediaItem',
'There was a problem replacing your background, '
'the image file "%s" no longer exists.')) % filepath)

View File

@ -60,11 +60,11 @@ class MediaMediaItem(MediaManagerItem):
self.onNewFileMasks = unicode(translate('MediaPlugin.MediaItem',
'Videos (%s);;Audio (%s);;%s (*)')) % (
u' '.join(self.parent.video_extensions_list),
u' '.join(self.parent.audio_extensions_list), UiStrings.AllFiles)
self.replaceAction.setText(UiStrings.ReplaceBG)
self.replaceAction.setToolTip(UiStrings.ReplaceLiveBG)
self.resetAction.setText(UiStrings.ResetBG)
self.resetAction.setToolTip(UiStrings.ResetLiveBG)
u' '.join(self.parent.audio_extensions_list), UiStrings().AllFiles)
self.replaceAction.setText(UiStrings().ReplaceBG)
self.replaceAction.setToolTip(UiStrings().ReplaceLiveBG)
self.resetAction.setText(UiStrings().ResetBG)
self.resetAction.setToolTip(UiStrings().ResetLiveBG)
def requiredIcons(self):
MediaManagerItem.requiredIcons(self)
@ -110,7 +110,7 @@ class MediaMediaItem(MediaManagerItem):
self.parent.liveController.display.video(filename, 0, True)
self.resetAction.setVisible(True)
else:
critical_error_message_box(UiStrings.LiveBGError,
critical_error_message_box(UiStrings().LiveBGError,
unicode(translate('MediaPlugin.MediaItem',
'There was a problem replacing your background, '
'the media file "%s" no longer exists.')) % filename)
@ -208,4 +208,4 @@ class MediaMediaItem(MediaManagerItem):
img = QtGui.QPixmap(u':/media/media_video.png').toImage()
item_name.setIcon(build_icon(img))
item_name.setData(QtCore.Qt.UserRole, QtCore.QVariant(file))
self.listView.addItem(item_name)
self.listView.addItem(item_name)

View File

@ -32,8 +32,8 @@ class MediaTab(SettingsTab):
"""
MediaTab is the Media settings tab in the settings dialog.
"""
def __init__(self, title, visible_title):
SettingsTab.__init__(self, title, visible_title)
def __init__(self, parent, title, visible_title, icon_path):
SettingsTab.__init__(self, parent, title, visible_title, icon_path)
def setupUi(self):
self.setObjectName(u'MediaTab')

View File

@ -203,7 +203,7 @@ class PresentationMediaItem(MediaManagerItem):
"""
Remove a presentation item from the list
"""
if check_item_selected(self.listView, UiStrings.SelectDelete):
if check_item_selected(self.listView, UiStrings().SelectDelete):
items = self.listView.selectedIndexes()
row_list = [item.row() for item in items]
row_list.sort(reverse=True)
@ -296,4 +296,4 @@ class PresentationMediaItem(MediaManagerItem):
if self.controllers[controller].enabled():
if filetype in self.controllers[controller].alsosupports:
return controller
return None
return None

View File

@ -49,7 +49,7 @@ class Controller(object):
self.doc = None
log.info(u'%s controller loaded' % live)
def add_handler(self, controller, file, is_blank):
def add_handler(self, controller, file, hide_mode, slide_no):
"""
Add a handler, which is an instance of a presentation and
slidecontroller combination. If the slidecontroller has a display
@ -64,12 +64,21 @@ class Controller(object):
# Display error message to user
# Inform slidecontroller that the action failed?
return
self.doc.slidenumber = slide_no
if self.is_live:
self.doc.start_presentation()
if is_blank:
self.blank()
Receiver.send_message(u'maindisplay_hide', HideMode.Screen)
self.doc.slidenumber = 0
if hide_mode == HideMode.Screen:
Receiver.send_message(u'maindisplay_hide', HideMode.Screen)
self.stop()
elif hide_mode == HideMode.Theme:
self.blank(hide_mode)
elif hide_mode == HideMode.Blank:
self.blank(hide_mode)
else:
self.doc.start_presentation()
Receiver.send_message(u'maindisplay_hide', HideMode.Screen)
self.doc.slidenumber = 0
if slide_no > 1:
self.slide(slide_no)
def activate(self):
"""
@ -164,14 +173,10 @@ class Controller(object):
Based on the handler passed at startup triggers slide show to shut down
"""
log.debug(u'Live = %s, shutdown' % self.is_live)
if self.is_live:
Receiver.send_message(u'maindisplay_show')
self.doc.close_presentation()
self.doc = None
#self.doc.slidenumber = 0
#self.timer.stop()
def blank(self):
def blank(self, hide_mode):
"""
Instruct the controller to blank the presentation
"""
@ -182,6 +187,8 @@ class Controller(object):
return
if not self.doc.is_active():
return
if hide_mode == HideMode.Theme:
Receiver.send_message(u'maindisplay_hide', HideMode.Theme)
self.doc.blank_screen()
def stop(self):
@ -261,7 +268,7 @@ class MessageListener(object):
is_live = message[1]
item = message[0]
log.debug(u'Startup called with message %s' % message)
is_blank = message[2]
hide_mode = message[2]
file = os.path.join(item.get_frame_path(),
item.get_frame_title())
self.handler = item.title
@ -273,7 +280,8 @@ class MessageListener(object):
controller = self.live_handler
else:
controller = self.preview_handler
controller.add_handler(self.controllers[self.handler], file, is_blank)
controller.add_handler(self.controllers[self.handler], file, hide_mode,
message[3])
def slide(self, message):
"""
@ -333,7 +341,6 @@ class MessageListener(object):
"""
is_live = message[1]
if is_live:
Receiver.send_message(u'maindisplay_show')
self.live_handler.shutdown()
else:
self.preview_handler.shutdown()
@ -351,8 +358,9 @@ class MessageListener(object):
React to the message to blank the display
"""
is_live = message[1]
hide_mode = message[2]
if is_live:
self.live_handler.blank()
self.live_handler.blank(hide_mode)
def unblank(self, message):
"""

View File

@ -251,14 +251,13 @@ class PowerpointDocument(PresentationDocument):
win32ui.GetForegroundWindow().GetDC().GetDeviceCaps(88)
except win32ui.error:
dpi = 96
self.presentation.SlideShowSettings.Run()
self.presentation.SlideShowWindow.View.GotoSlide(1)
rendermanager = self.controller.plugin.renderManager
rect = rendermanager.screens.current[u'size']
self.presentation.SlideShowWindow.Top = rect.y() * 72 / dpi
self.presentation.SlideShowWindow.Height = rect.height() * 72 / dpi
self.presentation.SlideShowWindow.Left = rect.x() * 72 / dpi
self.presentation.SlideShowWindow.Width = rect.width() * 72 / dpi
ppt_window = self.presentation.SlideShowSettings.Run()
ppt_window.Top = rect.y() * 72 / dpi
ppt_window.Height = rect.height() * 72 / dpi
ppt_window.Left = rect.x() * 72 / dpi
ppt_window.Width = rect.width() * 72 / dpi
def get_slide_number(self):
"""

View File

@ -27,6 +27,8 @@
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
#include <io.h>
#include <direct.h>
#include <time.h>
#include <sys/types.h>
#include <sys/stat.h>
@ -88,7 +90,12 @@ DllExport BOOL CheckInstalled()
char cmdLine[MAX_PATH * 2];
DEBUG("CheckInstalled\n");
return GetPPTViewerPath(cmdLine, sizeof(cmdLine));
BOOL found = GetPPTViewerPath(cmdLine, sizeof(cmdLine));
if(found)
{
DEBUG("Exe: %s\n", cmdLine);
}
return found;
}
// Open the PointPoint, count the slides and take a snapshot of each slide
@ -160,7 +167,7 @@ DllExport int OpenPPT(char *filename, HWND hParentWnd, RECT rect,
pptView[id].rect.bottom = rect.bottom;
pptView[id].rect.right = rect.right;
}
strcat_s(cmdLine, MAX_PATH * 2, "/F /S \"");
strcat_s(cmdLine, MAX_PATH * 2, " /F /S \"");
strcat_s(cmdLine, MAX_PATH * 2, filename);
strcat_s(cmdLine, MAX_PATH * 2, "\"");
memset(&si, 0, sizeof(si));
@ -189,7 +196,7 @@ DllExport int OpenPPT(char *filename, HWND hParentWnd, RECT rect,
Sleep(10);
if (!CreateProcess(NULL, cmdLine, NULL, NULL, FALSE, 0, 0, NULL, &si, &pi))
{
DEBUG("OpenPPT: CreateProcess failed\n");
DEBUG("OpenPPT: CreateProcess failed: %s\n", cmdLine);
ClosePPT(id);
return -1;
}
@ -344,16 +351,71 @@ BOOL SavePPTInfo(int id)
// Get the path of the PowerPoint viewer from the registry
BOOL GetPPTViewerPath(char *pptViewerPath, int stringSize)
{
char cwd[MAX_PATH];
DEBUG("GetPPTViewerPath: start\n");
if(GetPPTViewerPathFromReg(pptViewerPath, stringSize))
{
if(_access(pptViewerPath, 0) != -1)
{
DEBUG("GetPPTViewerPath: exit registry\n");
return TRUE;
}
}
// This is where it gets ugly. PPT2007 it seems no longer stores its
// location in the registry. So we have to use the defaults which will
// upset those who like to put things somewhere else
// Viewer 2007 in 64bit Windows:
if(_access("C:\\Program Files (x86)\\Microsoft Office\\Office12\\PPTVIEW.EXE",
0) != -1)
{
strcpy_s(
"C:\\Program Files (x86)\\Microsoft Office\\Office12\\PPTVIEW.EXE",
stringSize, pptViewerPath);
DEBUG("GetPPTViewerPath: exit 64bit 2007\n");
return TRUE;
}
// Viewer 2007 in 32bit Windows:
if(_access("C:\\Program Files\\Microsoft Office\\Office12\\PPTVIEW.EXE", 0)
!= -1)
{
strcpy_s("C:\\Program Files\\Microsoft Office\\Office12\\PPTVIEW.EXE",
stringSize, pptViewerPath);
DEBUG("GetPPTViewerPath: exit 32bit 2007\n");
return TRUE;
}
// Give them the opportunity to place it in the same folder as the app
_getcwd(cwd, MAX_PATH);
strcat_s(cwd, MAX_PATH, "\\PPTVIEW.EXE");
if(_access(cwd, 0) != -1)
{
strcpy_s(pptViewerPath, stringSize, cwd);
DEBUG("GetPPTViewerPath: exit local\n");
return TRUE;
}
DEBUG("GetPPTViewerPath: exit fail\n");
return FALSE;
}
BOOL GetPPTViewerPathFromReg(char *pptViewerPath, int stringSize)
{
HKEY hKey;
DWORD dwType, dwSize;
LRESULT lResult;
DEBUG("GetPPTViewerPath: start\n");
// The following registry settings are for, respectively, (I think)
// PPT Viewer 2007 (older versions. Latest not in registry) & PPT Viewer 2010
// PPT Viewer 2003 (recent versions)
// PPT Viewer 2003 (older versions)
// PPT Viewer 97
if ((RegOpenKeyEx(HKEY_CLASSES_ROOT,
"PowerPointViewer.Show.12\\shell\\Show\\command", 0, KEY_READ, &hKey)
!= ERROR_SUCCESS)
&& (RegOpenKeyEx(HKEY_CLASSES_ROOT,
"PowerPointViewer.Show.11\\shell\\Show\\command", 0, KEY_READ, &hKey)
!= ERROR_SUCCESS)
&& (RegOpenKeyEx(HKEY_CLASSES_ROOT,
"Applications\\PPTVIEW.EXE\\shell\\open\\command", 0, KEY_READ, &hKey)
!= ERROR_SUCCESS)
&& (RegOpenKeyEx(HKEY_CLASSES_ROOT,
@ -373,7 +435,6 @@ BOOL GetPPTViewerPath(char *pptViewerPath, int stringSize)
}
// remove "%1" from end of key value
pptViewerPath[strlen(pptViewerPath) - 4] = '\0';
DEBUG("GetPPTViewerPath: exit ok\n");
return TRUE;
}

View File

@ -49,6 +49,7 @@ LRESULT CALLBACK CbtProc(int nCode, WPARAM wParam, LPARAM lParam);
LRESULT CALLBACK CwpProc(int nCode, WPARAM wParam, LPARAM lParam);
LRESULT CALLBACK GetMsgProc(int nCode, WPARAM wParam, LPARAM lParam);
BOOL GetPPTViewerPath(char *pptViewerPath, int stringSize);
BOOL GetPPTViewerPathFromReg(char *pptViewerPath, int stringSize);
HBITMAP CaptureWindow(HWND hWnd);
VOID SaveBitmap(CHAR* filename, HBITMAP hBmp) ;
VOID CaptureAndSaveWindow(HWND hWnd, CHAR* filename);

View File

@ -33,12 +33,12 @@ class PresentationTab(SettingsTab):
"""
PresentationsTab is the Presentations settings tab in the settings dialog.
"""
def __init__(self, title, visible_title, controllers):
def __init__(self, parent, title, visible_title, controllers, icon_path):
"""
Constructor
"""
self.controllers = controllers
SettingsTab.__init__(self, title, visible_title)
SettingsTab.__init__(self, parent, title, visible_title, icon_path)
def setupUi(self):
"""
@ -86,7 +86,7 @@ class PresentationTab(SettingsTab):
checkbox.setText(
unicode(translate('PresentationPlugin.PresentationTab',
'%s (unavailable)')) % controller.name)
self.AdvancedGroupBox.setTitle(UiStrings.Advanced)
self.AdvancedGroupBox.setTitle(UiStrings().Advanced)
self.OverrideAppCheckBox.setText(
translate('PresentationPlugin.PresentationTab',
'Allow presentation application to be overriden'))
@ -131,4 +131,4 @@ class PresentationTab(SettingsTab):
QtCore.QVariant(self.OverrideAppCheckBox.checkState()))
changed = True
if changed:
Receiver.send_message(u'mediaitem_presentation_rebuild')
Receiver.send_message(u'mediaitem_presentation_rebuild')

View File

@ -56,13 +56,13 @@ class PresentationPlugin(Plugin):
self.icon_path = u':/plugins/plugin_presentations.png'
self.icon = build_icon(self.icon_path)
def getSettingsTab(self):
def getSettingsTab(self, parent):
"""
Create the settings Tab
"""
visible_name = self.getString(StringContent.VisibleName)
return PresentationTab(self.name, visible_name[u'title'],
self.controllers)
return PresentationTab(parent, self.name, visible_name[u'title'],
self.controllers, self.icon_path)
def initialise(self):
"""
@ -71,7 +71,6 @@ class PresentationPlugin(Plugin):
"""
log.info(u'Presentations Initialising')
Plugin.initialise(self)
self.insertToolboxItem()
for controller in self.controllers:
if self.controllers[controller].enabled():
try:

View File

@ -32,8 +32,8 @@ class RemoteTab(SettingsTab):
"""
RemoteTab is the Remotes settings tab in the settings dialog.
"""
def __init__(self, title, visible_title):
SettingsTab.__init__(self, title, visible_title)
def __init__(self, parent, title, visible_title, icon_path):
SettingsTab.__init__(self, parent, title, visible_title, icon_path)
def setupUi(self):
self.setObjectName(u'RemoteTab')

View File

@ -39,8 +39,9 @@ class RemotesPlugin(Plugin):
remotes constructor
"""
Plugin.__init__(self, u'Remotes', plugin_helpers,
settingsTabClass=RemoteTab)
self.icon = build_icon(u':/plugins/plugin_remote.png')
settings_tab_class=RemoteTab)
self.icon_path = u':/plugins/plugin_remote.png'
self.icon = build_icon(self.icon_path)
self.weight = -1
self.server = None
@ -50,7 +51,6 @@ class RemotesPlugin(Plugin):
"""
log.debug(u'initialise')
Plugin.initialise(self)
self.insertToolboxItem()
self.server = HttpServer(self)
def finalise(self):

View File

@ -260,11 +260,11 @@ class Ui_EditSongDialog(object):
translate('SongsPlugin.EditSongForm', '&Lyrics:'))
self.verseOrderLabel.setText(
translate('SongsPlugin.EditSongForm', '&Verse order:'))
self.verseAddButton.setText(UiStrings.Add)
self.verseEditButton.setText(UiStrings.Edit)
self.verseAddButton.setText(UiStrings().Add)
self.verseEditButton.setText(UiStrings().Edit)
self.verseEditAllButton.setText(
translate('SongsPlugin.EditSongForm', 'Ed&it All'))
self.verseDeleteButton.setText(UiStrings.Delete)
self.verseDeleteButton.setText(UiStrings().Delete)
self.songTabWidget.setTabText(
self.songTabWidget.indexOf(self.lyricsTab),
translate('SongsPlugin.EditSongForm', 'Title && Lyrics'))
@ -289,13 +289,13 @@ class Ui_EditSongDialog(object):
self.songTabWidget.indexOf(self.authorsTab),
translate('SongsPlugin.EditSongForm',
'Authors, Topics && Song Book'))
self.themeGroupBox.setTitle(UiStrings.Theme)
self.themeGroupBox.setTitle(UiStrings().Theme)
self.themeAddButton.setText(
translate('SongsPlugin.EditSongForm', 'New &Theme'))
self.rightsGroupBox.setTitle(
translate('SongsPlugin.EditSongForm', 'Copyright Information'))
self.copyrightInsertButton.setText(SongStrings.CopyrightSymbol)
self.CCLILabel.setText(UiStrings.CCLINumberLabel)
self.CCLILabel.setText(UiStrings().CCLINumberLabel)
self.commentsGroupBox.setTitle(
translate('SongsPlugin.EditSongForm', 'Comments'))
self.songTabWidget.setTabText(
@ -313,4 +313,4 @@ def editSongDialogComboBox(parent, name):
comboBox.setEditable(True)
comboBox.setInsertPolicy(QtGui.QComboBox.NoInsert)
comboBox.setObjectName(name)
return comboBox
return comboBox

View File

@ -31,7 +31,7 @@ from PyQt4 import QtCore, QtGui
from openlp.core.lib import Receiver, translate
from openlp.core.lib.ui import UiStrings, add_widget_completer, \
critical_error_message_box
critical_error_message_box, find_and_set_in_combo_box
from openlp.plugins.songs.forms import EditVerseForm
from openlp.plugins.songs.lib import SongXML, VerseType, clean_song
from openlp.plugins.songs.lib.db import Book, Song, Author, Topic
@ -96,7 +96,7 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog):
QtCore.SIGNAL(u'theme_update_list'), self.loadThemes)
self.previewButton = QtGui.QPushButton()
self.previewButton.setObjectName(u'previewButton')
self.previewButton.setText(UiStrings.SaveAndPreview)
self.previewButton.setText(UiStrings().SaveAndPreview)
self.buttonBox.addButton(
self.previewButton, QtGui.QDialogButtonBox.ActionRole)
QtCore.QObject.connect(self.buttonBox,
@ -208,20 +208,9 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog):
self.alternativeEdit.setText(u'')
if self.song.song_book_id != 0:
book_name = self.manager.get_object(Book, self.song.song_book_id)
id = self.songBookComboBox.findText(
unicode(book_name.name), QtCore.Qt.MatchExactly)
if id == -1:
# Not Found
id = 0
self.songBookComboBox.setCurrentIndex(id)
find_and_set_in_combo_box(self.songBookComboBox, unicode(book_name.name))
if self.song.theme_name:
id = self.themeComboBox.findText(
unicode(self.song.theme_name), QtCore.Qt.MatchExactly)
if id == -1:
# Not Found
id = 0
self.song.theme_name = None
self.themeComboBox.setCurrentIndex(id)
find_and_set_in_combo_box(self.themeComboBox, unicode(self.song.theme_name))
if self.song.copyright:
self.copyrightEdit.setText(self.song.copyright)
else:
@ -366,7 +355,7 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog):
self.__addAuthorToList(author)
self.authorsComboBox.setCurrentIndex(0)
else:
QtGui.QMessageBox.warning(self, UiStrings.NISs,
QtGui.QMessageBox.warning(self, UiStrings().NISs,
translate('SongsPlugin.EditSongForm', 'You have not selected '
'a valid author. Either select an author from the list, '
'or type in a new author and click the "Add Author to '
@ -425,7 +414,7 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog):
self.topicsListView.addItem(topic_item)
self.topicsComboBox.setCurrentIndex(0)
else:
QtGui.QMessageBox.warning(self, UiStrings.NISs,
QtGui.QMessageBox.warning(self, UiStrings().NISs,
translate('SongsPlugin.EditSongForm', 'You have not selected '
'a valid topic. Either select a topic from the list, or '
'type in a new topic and click the "Add Topic to Song" '
@ -790,4 +779,4 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog):
self.song.verse_order)
except:
log.exception(u'Problem processing song Lyrics \n%s',
sxml.dump_xml())
sxml.dump_xml())

View File

@ -175,7 +175,7 @@ class SongExportForm(OpenLPWizard):
self.availableSongsPage.setSubTitle(
translate('SongsPlugin.ExportWizardForm',
'Check the songs you want to export.'))
self.searchLabel.setText(u'%s:' % UiStrings.Search)
self.searchLabel.setText(u'%s:' % UiStrings().Search)
self.uncheckButton.setText(
translate('SongsPlugin.ExportWizardForm', 'Uncheck All'))
self.checkButton.setText(
@ -207,7 +207,7 @@ class SongExportForm(OpenLPWizard):
self.availableListWidget) if item.checkState()
]
if not items:
critical_error_message_box(UiStrings.NISp,
critical_error_message_box(UiStrings().NISp,
translate('SongsPlugin.ExportWizardForm',
'You need to add at least one Song to export.'))
return False
@ -360,4 +360,4 @@ class SongExportForm(OpenLPWizard):
SettingsManager.get_last_dir(self.plugin.settingsSection, 1),
options=QtGui.QFileDialog.ShowDirsOnly))
SettingsManager.set_last_dir(self.plugin.settingsSection, path, 1)
self.directoryLineEdit.setText(path)
self.directoryLineEdit.setText(path)

View File

@ -26,6 +26,7 @@
"""
The song import functions for OpenLP.
"""
import codecs
import logging
import os
@ -55,6 +56,7 @@ class SongImportForm(OpenLPWizard):
``plugin``
The songs plugin.
"""
self.clipboard = plugin.formparent.clipboard
OpenLPWizard.__init__(self, parent, plugin, u'songImportWizard',
u':/wizards/wizard_importsong.bmp')
@ -66,7 +68,17 @@ class SongImportForm(OpenLPWizard):
self.formatStack.setCurrentIndex(0)
QtCore.QObject.connect(self.formatComboBox,
QtCore.SIGNAL(u'currentIndexChanged(int)'),
self.formatStack.setCurrentIndex)
self.onCurrentIndexChanged)
def onCurrentIndexChanged(self, index):
"""
Called when the format combo box's index changed. We have to check if
the import is available and accordingly to disable or enable the next
button.
"""
self.formatStack.setCurrentIndex(index)
next_button = self.button(QtGui.QWizard.NextButton)
next_button.setEnabled(SongFormat.get_availability(index))
def customInit(self):
"""
@ -225,8 +237,8 @@ class SongImportForm(OpenLPWizard):
self.sourcePage.setTitle(WizardStrings.ImportSelect)
self.sourcePage.setSubTitle(WizardStrings.ImportSelectLong)
self.formatLabel.setText(WizardStrings.FormatLabel)
self.formatComboBox.setItemText(SongFormat.OpenLP2, UiStrings.OLPV2)
self.formatComboBox.setItemText(SongFormat.OpenLP1, UiStrings.OLPV1)
self.formatComboBox.setItemText(SongFormat.OpenLP2, UiStrings().OLPV2)
self.formatComboBox.setItemText(SongFormat.OpenLP1, UiStrings().OLPV1)
self.formatComboBox.setItemText(
SongFormat.OpenLyrics, WizardStrings.OL)
self.formatComboBox.setItemText(SongFormat.OpenSong, WizardStrings.OS)
@ -251,10 +263,10 @@ class SongImportForm(OpenLPWizard):
# self.formatComboBox.setItemText(SongFormat.CSV, WizardStrings.CSV)
self.openLP2FilenameLabel.setText(
translate('SongsPlugin.ImportWizardForm', 'Filename:'))
self.openLP2BrowseButton.setText(UiStrings.Browse)
self.openLP2BrowseButton.setText(UiStrings().Browse)
self.openLP1FilenameLabel.setText(
translate('SongsPlugin.ImportWizardForm', 'Filename:'))
self.openLP1BrowseButton.setText(UiStrings.Browse)
self.openLP1BrowseButton.setText(UiStrings().Browse)
self.openLP1DisabledLabel.setText(WizardStrings.NoSqlite)
self.openLyricsAddButton.setText(
translate('SongsPlugin.ImportWizardForm', 'Add Files...'))
@ -295,10 +307,10 @@ class SongImportForm(OpenLPWizard):
'find OpenOffice.org on your computer.'))
self.easiSlidesFilenameLabel.setText(
translate('SongsPlugin.ImportWizardForm', 'Filename:'))
self.easiSlidesBrowseButton.setText(UiStrings.Browse)
self.easiSlidesBrowseButton.setText(UiStrings().Browse)
self.ewFilenameLabel.setText(
translate('SongsPlugin.ImportWizardForm', 'Filename:'))
self.ewBrowseButton.setText(UiStrings.Browse)
self.ewBrowseButton.setText(UiStrings().Browse)
self.songBeamerAddButton.setText(
translate('SongsPlugin.ImportWizardForm', 'Add Files...'))
self.songBeamerRemoveButton.setText(
@ -313,13 +325,17 @@ class SongImportForm(OpenLPWizard):
translate('SongsPlugin.ImportWizardForm', 'Remove File(s)'))
# self.csvFilenameLabel.setText(
# translate('SongsPlugin.ImportWizardForm', 'Filename:'))
# self.csvBrowseButton.setText(UiStrings.Browse)
# self.csvBrowseButton.setText(UiStrings().Browse)
self.progressPage.setTitle(WizardStrings.Importing)
self.progressPage.setSubTitle(
translate('SongsPlugin.ImportWizardForm',
'Please wait while your songs are imported.'))
self.progressLabel.setText(WizardStrings.Ready)
self.progressBar.setFormat(WizardStrings.PercentSymbolFormat)
self.errorCopyToButton.setText(translate('SongsPlugin.ImportWizardForm',
'Copy'))
self.errorSaveToButton.setText(translate('SongsPlugin.ImportWizardForm',
'Save to File'))
# Align all QFormLayouts towards each other.
width = max(self.formatLabel.minimumSizeHint().width(),
self.openLP2FilenameLabel.minimumSizeHint().width())
@ -336,49 +352,49 @@ class SongImportForm(OpenLPWizard):
source_format = self.formatComboBox.currentIndex()
if source_format == SongFormat.OpenLP2:
if self.openLP2FilenameEdit.text().isEmpty():
critical_error_message_box(UiStrings.NFSs,
WizardStrings.YouSpecifyFile % UiStrings.OLPV2)
critical_error_message_box(UiStrings().NFSs,
WizardStrings.YouSpecifyFile % UiStrings().OLPV2)
self.openLP2BrowseButton.setFocus()
return False
elif source_format == SongFormat.OpenLP1:
if self.openLP1FilenameEdit.text().isEmpty():
critical_error_message_box(UiStrings.NFSs,
WizardStrings.YouSpecifyFile % UiStrings.OLPV1)
critical_error_message_box(UiStrings().NFSs,
WizardStrings.YouSpecifyFile % UiStrings().OLPV1)
self.openLP1BrowseButton.setFocus()
return False
elif source_format == SongFormat.OpenLyrics:
if self.openLyricsFileListWidget.count() == 0:
critical_error_message_box(UiStrings.NFSp,
critical_error_message_box(UiStrings().NFSp,
WizardStrings.YouSpecifyFile % WizardStrings.OL)
self.openLyricsAddButton.setFocus()
return False
elif source_format == SongFormat.OpenSong:
if self.openSongFileListWidget.count() == 0:
critical_error_message_box(UiStrings.NFSp,
critical_error_message_box(UiStrings().NFSp,
WizardStrings.YouSpecifyFile % WizardStrings.OS)
self.openSongAddButton.setFocus()
return False
elif source_format == SongFormat.WordsOfWorship:
if self.wordsOfWorshipFileListWidget.count() == 0:
critical_error_message_box(UiStrings.NFSp,
critical_error_message_box(UiStrings().NFSp,
WizardStrings.YouSpecifyFile % WizardStrings.WoW)
self.wordsOfWorshipAddButton.setFocus()
return False
elif source_format == SongFormat.CCLI:
if self.ccliFileListWidget.count() == 0:
critical_error_message_box(UiStrings.NFSp,
critical_error_message_box(UiStrings().NFSp,
WizardStrings.YouSpecifyFile % WizardStrings.CCLI)
self.ccliAddButton.setFocus()
return False
elif source_format == SongFormat.SongsOfFellowship:
if self.songsOfFellowshipFileListWidget.count() == 0:
critical_error_message_box(UiStrings.NFSp,
critical_error_message_box(UiStrings().NFSp,
WizardStrings.YouSpecifyFile % WizardStrings.SoF)
self.songsOfFellowshipAddButton.setFocus()
return False
elif source_format == SongFormat.Generic:
if self.genericFileListWidget.count() == 0:
critical_error_message_box(UiStrings.NFSp,
critical_error_message_box(UiStrings().NFSp,
translate('SongsPlugin.ImportWizardForm',
'You need to specify at least one document or '
'presentation file to import from.'))
@ -386,31 +402,31 @@ class SongImportForm(OpenLPWizard):
return False
elif source_format == SongFormat.EasiSlides:
if self.easiSlidesFilenameEdit.text().isEmpty():
critical_error_message_box(UiStrings.NFSp,
critical_error_message_box(UiStrings().NFSp,
WizardStrings.YouSpecifyFile % WizardStrings.ES)
self.easiSlidesBrowseButton.setFocus()
return False
elif source_format == SongFormat.EasyWorship:
if self.ewFilenameEdit.text().isEmpty():
critical_error_message_box(UiStrings.NFSs,
critical_error_message_box(UiStrings().NFSs,
WizardStrings.YouSpecifyFile % WizardStrings.EW)
self.ewBrowseButton.setFocus()
return False
elif source_format == SongFormat.SongBeamer:
if self.songBeamerFileListWidget.count() == 0:
critical_error_message_box(UiStrings.NFSp,
critical_error_message_box(UiStrings().NFSp,
WizardStrings.YouSpecifyFile % WizardStrings.SB)
self.songBeamerAddButton.setFocus()
return False
elif source_format == SongFormat.SongShowPlus:
if self.songShowPlusFileListWidget.count() == 0:
critical_error_message_box(UiStrings.NFSp,
critical_error_message_box(UiStrings().NFSp,
WizardStrings.YouSpecifyFile % WizardStrings.SSP)
self.wordsOfWorshipAddButton.setFocus()
return False
elif source_format == SongFormat.FoilPresenter:
if self.foilPresenterFileListWidget.count() == 0:
critical_error_message_box(UiStrings.NFSp,
critical_error_message_box(UiStrings().NFSp,
WizardStrings.YouSpecifyFile % WizardStrings.FP)
self.foilPresenterAddButton.setFocus()
return False
@ -436,7 +452,7 @@ class SongImportForm(OpenLPWizard):
"""
if filters:
filters += u';;'
filters += u'%s (*)' % UiStrings.AllFiles
filters += u'%s (*)' % UiStrings().AllFiles
filenames = QtGui.QFileDialog.getOpenFileNames(self, title,
SettingsManager.get_last_dir(self.plugin.settingsSection, 1),
filters)
@ -449,10 +465,7 @@ class SongImportForm(OpenLPWizard):
"""
Return a list of file from the listbox
"""
files = []
for row in range(0, listbox.count()):
files.append(unicode(listbox.item(row).text()))
return files
return [unicode(listbox.item(i).text()) for i in range(listbox.count())]
def removeSelectedItems(self, listbox):
"""
@ -466,7 +479,7 @@ class SongImportForm(OpenLPWizard):
"""
Get OpenLP v2 song database file
"""
self.getFileName(WizardStrings.OpenTypeFile % UiStrings.OLPV2,
self.getFileName(WizardStrings.OpenTypeFile % UiStrings().OLPV2,
self.openLP2FilenameEdit, u'%s (*.sqlite)'
% (translate('SongsPlugin.ImportWizardForm',
'OpenLP 2.0 Databases'))
@ -476,7 +489,7 @@ class SongImportForm(OpenLPWizard):
"""
Get OpenLP v1 song database file
"""
self.getFileName(WizardStrings.OpenTypeFile % UiStrings.OLPV1,
self.getFileName(WizardStrings.OpenTypeFile % UiStrings().OLPV1,
self.openLP1FilenameEdit, u'%s (*.olp)'
% translate('SongsPlugin.ImportWizardForm',
'openlp.org v1.x Databases')
@ -649,6 +662,10 @@ class SongImportForm(OpenLPWizard):
self.songShowPlusFileListWidget.clear()
self.foilPresenterFileListWidget.clear()
#self.csvFilenameEdit.setText(u'')
self.errorReportTextEdit.clear()
self.errorReportTextEdit.setHidden(True)
self.errorCopyToButton.setHidden(True)
self.errorSaveToButton.setHidden(True)
def preWizard(self):
"""
@ -733,12 +750,30 @@ class SongImportForm(OpenLPWizard):
importer = self.plugin.importSongs(SongFormat.FoilPresenter,
filenames=self.getListOfFiles(self.foilPresenterFileListWidget)
)
if importer.do_import():
self.progressLabel.setText(WizardStrings.FinishedImport)
importer.do_import()
if importer.error_log:
self.progressLabel.setText(translate(
'SongsPlugin.SongImportForm', 'Your song import failed.'))
else:
self.progressLabel.setText(
translate('SongsPlugin.SongImportForm',
'Your song import failed.'))
self.progressLabel.setText(WizardStrings.FinishedImport)
def onErrorCopyToButtonClicked(self):
"""
Copy the error report to the clipboard.
"""
self.clipboard.setText(self.errorReportTextEdit.toPlainText())
def onErrorSaveToButtonClicked(self):
"""
Save the error report to a file.
"""
filename = QtGui.QFileDialog.getSaveFileName(self,
SettingsManager.get_last_dir(self.plugin.settingsSection, 1))
if not filename:
return
file = codecs.open(filename, u'w', u'utf-8')
file.write(self.errorReportTextEdit.toPlainText())
file.close()
def addFileSelectItem(self, prefix, obj_prefix=None, can_disable=False,
single_select=False):

View File

@ -149,17 +149,17 @@ class Ui_SongMaintenanceDialog(object):
self.listItemAuthors.setText(SongStrings.Authors)
self.listItemTopics.setText(SongStrings.Topics)
self.listItemBooks.setText(SongStrings.SongBooks)
self.authorsAddButton.setText(UiStrings.Add)
self.authorsEditButton.setText(UiStrings.Edit)
self.authorsDeleteButton.setText(UiStrings.Delete)
self.topicsAddButton.setText(UiStrings.Add)
self.topicsEditButton.setText(UiStrings.Edit)
self.topicsDeleteButton.setText(UiStrings.Delete)
self.booksAddButton.setText(UiStrings.Add)
self.booksEditButton.setText(UiStrings.Edit)
self.booksDeleteButton.setText(UiStrings.Delete)
self.authorsAddButton.setText(UiStrings().Add)
self.authorsEditButton.setText(UiStrings().Edit)
self.authorsDeleteButton.setText(UiStrings().Delete)
self.topicsAddButton.setText(UiStrings().Add)
self.topicsEditButton.setText(UiStrings().Edit)
self.topicsDeleteButton.setText(UiStrings().Delete)
self.booksAddButton.setText(UiStrings().Add)
self.booksEditButton.setText(UiStrings().Edit)
self.booksDeleteButton.setText(UiStrings().Delete)
typeListWidth = max(self.fontMetrics().width(SongStrings.Authors),
self.fontMetrics().width(SongStrings.Topics),
self.fontMetrics().width(SongStrings.SongBooks))
self.typeListWidget.setFixedWidth(typeListWidth +
self.typeListWidget.iconSize().width() + 32)
self.typeListWidget.iconSize().width() + 32)

View File

@ -115,7 +115,7 @@ class SongMaintenanceForm(QtGui.QDialog, Ui_SongMaintenanceDialog):
else:
critical_error_message_box(dlg_title, err_text)
else:
critical_error_message_box(dlg_title, UiStrings.NISs)
critical_error_message_box(dlg_title, UiStrings().NISs)
def resetAuthors(self):
"""
@ -386,7 +386,8 @@ class SongMaintenanceForm(QtGui.QDialog, Ui_SongMaintenanceDialog):
existing_author = self.manager.get_object_filtered(Author,
and_(Author.first_name == old_author.first_name,
Author.last_name == old_author.last_name,
Author.display_name == old_author.display_name))
Author.display_name == old_author.display_name,
Author.id != old_author.id))
# Find the songs, which have the old_author as author.
songs = self.manager.get_all_objects(Song,
Song.authors.contains(old_author))
@ -408,7 +409,7 @@ class SongMaintenanceForm(QtGui.QDialog, Ui_SongMaintenanceDialog):
"""
# Find the duplicate.
existing_topic = self.manager.get_object_filtered(Topic,
Topic.name == old_topic.name)
and_(Topic.name == old_topic.name, Topic.id != old_topic.id))
# Find the songs, which have the old_topic as topic.
songs = self.manager.get_all_objects(Song,
Song.topics.contains(old_topic))
@ -431,7 +432,8 @@ class SongMaintenanceForm(QtGui.QDialog, Ui_SongMaintenanceDialog):
# Find the duplicate.
existing_book = self.manager.get_object_filtered(Book,
and_(Book.name == old_book.name,
Book.publisher == old_book.publisher))
Book.publisher == old_book.publisher,
Book.id != old_book.id))
# Find the songs, which have the old_book as book.
songs = self.manager.get_all_objects(Song,
Song.song_book_id == old_book.id)
@ -504,3 +506,4 @@ class SongMaintenanceForm(QtGui.QDialog, Ui_SongMaintenanceDialog):
else:
deleteButton.setEnabled(True)
editButton.setEnabled(True)

View File

@ -278,24 +278,29 @@ def clean_song(manager, song):
# List for later comparison.
compare_order = []
for verse in verses:
type = VerseType.Tags[VerseType.from_loose_input(verse[0][u'type'])]
verse_type = VerseType.Tags[VerseType.from_loose_input(
verse[0][u'type'])]
sxml.add_verse_to_lyrics(
type,
verse_type,
verse[0][u'label'],
verse[1],
verse[0][u'lang'] if verse[0].has_key(u'lang') else None
)
compare_order.append((u'%s%s' % (type, verse[0][u'label'])).upper())
compare_order.append((u'%s%s' % (verse_type, verse[0][u'label'])
).upper())
if verse[0][u'label'] == u'1':
compare_order.append(verse_type.upper())
song.lyrics = unicode(sxml.extract_xml(), u'utf-8')
# Rebuild the verse order, to convert translated verse tags, which might
# have been added prior to 1.9.5.
order = song.verse_order.strip().split()
new_order = []
for verse_def in order:
new_order.append((u'%s%s' % (
VerseType.Tags[VerseType.from_loose_input(verse_def[0])],
verse_def[1:])).upper()
)
verse_type = VerseType.Tags[VerseType.from_loose_input(verse_def[0])]
if len(verse_def) > 1:
new_order.append((u'%s%s' % (verse_type, verse_def[1:])).upper())
else:
new_order.append(verse_type.upper())
song.verse_order = u' '.join(new_order)
# Check if the verse order contains tags for verses which do not exist.
for order in new_order:

View File

@ -59,16 +59,10 @@ class CCLIFileImport(SongImport):
Import either a ``.usr`` or a ``.txt`` SongSelect file.
"""
log.debug(u'Starting CCLI File Import')
song_total = len(self.import_source)
self.import_wizard.progressBar.setMaximum(song_total)
song_count = 1
self.import_wizard.progressBar.setMaximum(len(self.import_source))
for filename in self.import_source:
self.import_wizard.incrementProgressBar(unicode(translate(
'SongsPlugin.CCLIFileImport', 'Importing song %d of %d')) %
(song_count, song_total))
filename = unicode(filename)
log.debug(u'Importing CCLI File: %s', filename)
self.set_defaults()
lines = []
if os.path.isfile(filename):
detect_file = open(filename, u'r')
@ -81,19 +75,23 @@ class CCLIFileImport(SongImport):
detect_file.close()
infile = codecs.open(filename, u'r', details['encoding'])
lines = infile.readlines()
infile.close()
ext = os.path.splitext(filename)[1]
if ext.lower() == u'.usr':
log.info(u'SongSelect .usr format file found: %s', filename)
self.do_import_usr_file(lines)
if not self.do_import_usr_file(lines):
self.log_error(filename)
elif ext.lower() == u'.txt':
log.info(u'SongSelect .txt format file found: %s', filename)
self.do_import_txt_file(lines)
if not self.do_import_txt_file(lines):
self.log_error(filename)
else:
self.log_error(filename,
translate('SongsPlugin.CCLIFileImport',
'The file does not have a valid extension.'))
log.info(u'Extension %s is not valid', filename)
song_count += 1
if self.stop_import_flag:
return False
return True
return
def do_import_usr_file(self, textList):
"""
@ -218,7 +216,7 @@ class CCLIFileImport(SongImport):
else:
self.add_author(author)
self.topics = [topic.strip() for topic in song_topics.split(u'/t')]
self.finish()
return self.finish()
def do_import_txt_file(self, textList):
"""
@ -334,6 +332,5 @@ class CCLIFileImport(SongImport):
if len(author_list) < 2:
author_list = song_author.split(u'|')
# Clean spaces before and after author names.
for author_name in author_list:
self.add_author(author_name.strip())
self.finish()
[self.add_author(author_name.strip()) for author_name in author_list]
return self.finish()

View File

@ -26,11 +26,13 @@
import logging
import os
from lxml import etree, objectify
import re
from lxml import etree, objectify
from openlp.core.lib import translate
from openlp.core.ui.wizard import WizardStrings
from openlp.plugins.songs.lib import VerseType
from openlp.plugins.songs.lib.songimport import SongImport
log = logging.getLogger(__name__)
@ -56,26 +58,16 @@ class EasiSlidesImport(SongImport):
multiple opensong files. If `self.commit` is set False, the
import will not be committed to the database (useful for test scripts).
"""
self.import_wizard.progressBar.setMaximum(1)
log.info(u'Importing EasiSlides XML file %s', self.import_source)
parser = etree.XMLParser(remove_blank_text=True)
file = etree.parse(self.import_source, parser)
xml = unicode(etree.tostring(file))
song_xml = objectify.fromstring(xml)
self.import_wizard.incrementProgressBar(
WizardStrings.ImportingType % os.path.split(self.import_source)[-1])
self.import_wizard.progressBar.setMaximum(len(song_xml.Item))
for song in song_xml.Item:
self.import_wizard.incrementProgressBar(
unicode(translate('SongsPlugin.ImportWizardForm',
u'Importing %s, song %s...')) %
(os.path.split(self.import_source)[-1], song.Title1))
success = self._parse_song(song)
if not success or self.stop_import_flag:
return False
elif self.commit:
self.finish()
return True
if self.stop_import_flag:
return
self._parse_song(song)
def _parse_song(self, song):
self._success = True
@ -90,7 +82,11 @@ class EasiSlidesImport(SongImport):
self._add_copyright(song.LicenceAdmin2)
self._add_unicode_attribute(u'song_book_name', song.BookReference)
self._parse_and_add_lyrics(song)
return self._success
if self._success:
if not self.finish():
self.log_error(song.Title1 if song.Title1 else u'')
else:
self.set_defaults()
def _add_unicode_attribute(self, self_attribute, import_attribute,
mandatory=False):
@ -122,10 +118,8 @@ class EasiSlidesImport(SongImport):
def _add_authors(self, song):
try:
authors = unicode(song.Writer).split(u',')
for author in authors:
author = author.strip()
if len(author):
self.authors.append(author)
self.authors = \
[author.strip() for author in authors if author.strip()]
except UnicodeDecodeError:
log.exception(u'Unicode decode error while decoding Writer')
self._success = False
@ -188,12 +182,13 @@ class EasiSlidesImport(SongImport):
# if the regions are inside verses
regionsInVerses = (regions and regionlines[regionlines.keys()[0]] > 1)
MarkTypes = {
u'CHORUS': u'C',
u'VERSE': u'V',
u'INTRO': u'I',
u'ENDING': u'E',
u'BRIDGE': u'B',
u'PRECHORUS': u'P'}
u'CHORUS': VerseType.Tags[VerseType.Chorus],
u'VERSE': VerseType.Tags[VerseType.Verse],
u'INTRO': VerseType.Tags[VerseType.Intro],
u'ENDING': VerseType.Tags[VerseType.Ending],
u'BRIDGE': VerseType.Tags[VerseType.Bridge],
u'PRECHORUS': VerseType.Tags[VerseType.PreChorus]
}
verses = {}
# list as [region, versetype, versenum, instance]
our_verse_order = []

View File

@ -33,6 +33,7 @@ import struct
from openlp.core.lib import translate
from openlp.core.ui.wizard import WizardStrings
from openlp.plugins.songs.lib import VerseType
from openlp.plugins.songs.lib import retrieve_windows_encoding
from songimport import SongImport
@ -142,12 +143,12 @@ class EasyWorshipSongImport(SongImport):
# Open the DB and MB files if they exist
import_source_mb = self.import_source.replace('.DB', '.MB')
if not os.path.isfile(self.import_source):
return False
return
if not os.path.isfile(import_source_mb):
return False
return
db_size = os.path.getsize(self.import_source)
if db_size < 0x800:
return False
return
db_file = open(self.import_source, 'rb')
self.memo_file = open(import_source_mb, 'rb')
# Don't accept files that are clearly not paradox files
@ -156,7 +157,7 @@ class EasyWorshipSongImport(SongImport):
if header_size != 0x800 or block_size < 1 or block_size > 4:
db_file.close()
self.memo_file.close()
return False
return
# Take a stab at how text is encoded
self.encoding = u'cp1252'
db_file.seek(106)
@ -183,7 +184,7 @@ class EasyWorshipSongImport(SongImport):
self.encoding = u'cp874'
self.encoding = retrieve_windows_encoding(self.encoding)
if not self.encoding:
return False
return
# There does not appear to be a _reliable_ way of getting the number
# of songs/records, so let's use file blocks for measuring progress.
total_blocks = (db_size - header_size) / (block_size * 1024)
@ -203,8 +204,8 @@ class EasyWorshipSongImport(SongImport):
field_size))
self.set_record_struct(field_descs)
# Pick out the field description indexes we will need
success = True
try:
success = True
fi_title = self.find_field(u'Title')
fi_author = self.find_field(u'Author')
fi_copy = self.find_field(u'Copyright')
@ -223,31 +224,25 @@ class EasyWorshipSongImport(SongImport):
# Loop through each record within the current block
for i in range(rec_count):
if self.stop_import_flag:
success = False
break
raw_record = db_file.read(record_size)
self.fields = self.record_struct.unpack(raw_record)
self.set_defaults()
# Get title and update progress bar message
title = self.get_field(fi_title)
if title:
self.import_wizard.incrementProgressBar(
WizardStrings.ImportingType % title, 0)
self.title = title
# Get remaining fields
self.title = self.get_field(fi_title)
# Get remaining fields.
copy = self.get_field(fi_copy)
admin = self.get_field(fi_admin)
ccli = self.get_field(fi_ccli)
authors = self.get_field(fi_author)
words = self.get_field(fi_words)
# Set the SongImport object members
# Set the SongImport object members.
if copy:
self.copyright = copy
if admin:
if copy:
self.copyright += u', '
self.copyright += \
unicode(translate('SongsPlugin.ImportWizardForm',
unicode(translate('SongsPlugin.EasyWorshipSongImport',
'Administered by %s')) % admin
if ccli:
self.ccli_number = ccli
@ -264,19 +259,17 @@ class EasyWorshipSongImport(SongImport):
# Format the lyrics
words = strip_rtf(words, self.encoding)
for verse in words.split(u'\n\n'):
self.add_verse(verse.strip(), u'V')
self.add_verse(
verse.strip(), VerseType.Tags[VerseType.Verse])
if self.stop_import_flag:
success = False
break
self.finish()
if not self.stop_import_flag:
self.import_wizard.incrementProgressBar(u'')
if not self.finish():
self.log_error(self.import_source)
db_file.close()
self.memo_file.close()
return success
def find_field(self, field_name):
return [i for i, x in enumerate(self.field_descs) \
return [i for i, x in enumerate(self.field_descs)
if x.name == field_name][0]
def set_record_struct(self, field_descs):

Some files were not shown because too many files have changed in this diff Show More