This commit is contained in:
Tim Bentley 2010-06-25 21:44:21 +01:00
commit 89ccc8f390
15 changed files with 145 additions and 64 deletions

View File

@ -22,15 +22,19 @@
# with this program; if not, write to the Free Software Foundation, Inc., 59 # # with this program; if not, write to the Free Software Foundation, Inc., 59 #
# Temple Place, Suite 330, Boston, MA 02111-1307 USA # # Temple Place, Suite 330, Boston, MA 02111-1307 USA #
############################################################################### ###############################################################################
"""
Extend QListWidget to handle drag and drop functionality
"""
from PyQt4 import QtCore, QtGui from PyQt4 import QtCore, QtGui
class BaseListWithDnD(QtGui.QListWidget): class BaseListWithDnD(QtGui.QListWidget):
""" """
Please put a short description of what this class does in here. Provide a list widget to store objects and handle drag and drop events
""" """
def __init__(self, parent=None): def __init__(self, parent=None):
"""
Initialise the list widget
"""
QtGui.QListWidget.__init__(self, parent) QtGui.QListWidget.__init__(self, parent)
# this must be set by the class which is inheriting # this must be set by the class which is inheriting
assert(self.PluginName) assert(self.PluginName)

View File

@ -22,7 +22,10 @@
# with this program; if not, write to the Free Software Foundation, Inc., 59 # # with this program; if not, write to the Free Software Foundation, Inc., 59 #
# Temple Place, Suite 330, Boston, MA 02111-1307 USA # # Temple Place, Suite 330, Boston, MA 02111-1307 USA #
############################################################################### ###############################################################################
"""
Provide additional functionality required by OpenLP from the inherited
QDockWidget.
"""
import logging import logging
from PyQt4 import QtGui from PyQt4 import QtGui

View File

@ -22,7 +22,9 @@
# with this program; if not, write to the Free Software Foundation, Inc., 59 # # with this program; if not, write to the Free Software Foundation, Inc., 59 #
# Temple Place, Suite 330, Boston, MA 02111-1307 USA # # Temple Place, Suite 330, Boston, MA 02111-1307 USA #
############################################################################### ###############################################################################
"""
Provide event handling code for OpenLP
"""
import logging import logging
from PyQt4 import QtCore from PyQt4 import QtCore
@ -241,7 +243,11 @@ class Receiver(object):
``Receiver.send_message(u'<<Message ID>>', data)`` ``Receiver.send_message(u'<<Message ID>>', data)``
To receive a Message To receive a Message
``QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'<<Message ID>>'), <<ACTION>>)`` ``QtCore.QObject.connect(
Receiver.get_receiver(),
QtCore.SIGNAL(u'<<Message ID>>'),
<<ACTION>>
)``
""" """
eventreceiver = EventReceiver() eventreceiver = EventReceiver()

View File

@ -22,7 +22,9 @@
# with this program; if not, write to the Free Software Foundation, Inc., 59 # # with this program; if not, write to the Free Software Foundation, Inc., 59 #
# Temple Place, Suite 330, Boston, MA 02111-1307 USA # # Temple Place, Suite 330, Boston, MA 02111-1307 USA #
############################################################################### ###############################################################################
"""
Provides the generic functions for interfacing plugins with the Media Manager.
"""
import logging import logging
import os import os
@ -204,7 +206,9 @@ class MediaManagerItem(QtGui.QWidget):
self.addListViewToToolBar() self.addListViewToToolBar()
def addMiddleHeaderBar(self): def addMiddleHeaderBar(self):
# Create buttons for the toolbar """
Create buttons for the media item toolbar
"""
## Import Button ## ## Import Button ##
if self.hasImportIcon: if self.hasImportIcon:
self.addToolbarButton( self.addToolbarButton(
@ -267,6 +271,9 @@ class MediaManagerItem(QtGui.QWidget):
u':/general/general_add.png', self.onAddClick) u':/general/general_add.png', self.onAddClick)
def addListViewToToolBar(self): def addListViewToToolBar(self):
"""
Creates the main widget for listing items the media item is tracking
"""
#Add the List widget #Add the List widget
self.ListView = self.ListViewWithDnD_class(self) self.ListView = self.ListViewWithDnD_class(self)
self.ListView.uniformItemSizes = True self.ListView.uniformItemSizes = True
@ -344,6 +351,9 @@ class MediaManagerItem(QtGui.QWidget):
pass pass
def onFileClick(self): def onFileClick(self):
"""
Add a file to the list widget to make it available for showing
"""
files = QtGui.QFileDialog.getOpenFileNames( files = QtGui.QFileDialog.getOpenFileNames(
self, self.OnNewPrompt, self, self.OnNewPrompt,
SettingsManager.get_last_dir(self.settingsSection), SettingsManager.get_last_dir(self.settingsSection),
@ -357,6 +367,9 @@ class MediaManagerItem(QtGui.QWidget):
self.settingsSection, self.getFileList()) self.settingsSection, self.getFileList())
def getFileList(self): def getFileList(self):
"""
Return the current list of files
"""
count = 0 count = 0
filelist = [] filelist = []
while count < self.ListView.count(): while count < self.ListView.count():
@ -380,6 +393,15 @@ class MediaManagerItem(QtGui.QWidget):
return False return False
def IconFromFile(self, file, thumb): def IconFromFile(self, file, thumb):
"""
Create a thumbnail icon from a given file
``file``
The file to create the icon from
``thumb``
The filename to save the thumbnail to
"""
icon = build_icon(unicode(file)) icon = build_icon(unicode(file))
pixmap = icon.pixmap(QtCore.QSize(88, 50)) pixmap = icon.pixmap(QtCore.QSize(88, 50))
ext = os.path.splitext(thumb)[1].lower() ext = os.path.splitext(thumb)[1].lower()
@ -407,6 +429,10 @@ class MediaManagerItem(QtGui.QWidget):
u'to be defined by the plugin') u'to be defined by the plugin')
def onPreviewClick(self): def onPreviewClick(self):
"""
Preview an item by building a service item then adding that service
item to the preview slide controller.
"""
if not self.ListView.selectedIndexes() and not self.remoteTriggered: if not self.ListView.selectedIndexes() and not self.remoteTriggered:
QtGui.QMessageBox.information(self, QtGui.QMessageBox.information(self,
translate('MediaManagerItem', 'No Items Selected'), translate('MediaManagerItem', 'No Items Selected'),
@ -420,6 +446,10 @@ class MediaManagerItem(QtGui.QWidget):
self.parent.preview_controller.addServiceItem(service_item) self.parent.preview_controller.addServiceItem(service_item)
def onLiveClick(self): def onLiveClick(self):
"""
Send an item live by building a service item then adding that service
item to the live slide controller.
"""
if not self.ListView.selectedIndexes(): if not self.ListView.selectedIndexes():
QtGui.QMessageBox.information(self, QtGui.QMessageBox.information(self,
translate('MediaManagerItem', 'No Items Selected'), translate('MediaManagerItem', 'No Items Selected'),
@ -433,6 +463,9 @@ class MediaManagerItem(QtGui.QWidget):
self.parent.live_controller.addServiceItem(service_item) self.parent.live_controller.addServiceItem(service_item)
def onAddClick(self): def onAddClick(self):
"""
Add a selected item to the current service
"""
if not self.ListView.selectedIndexes() and not self.remoteTriggered: if not self.ListView.selectedIndexes() and not self.remoteTriggered:
QtGui.QMessageBox.information(self, QtGui.QMessageBox.information(self,
translate('MediaManagerItem', 'No Items Selected'), translate('MediaManagerItem', 'No Items Selected'),
@ -457,6 +490,9 @@ class MediaManagerItem(QtGui.QWidget):
self.parent.service_manager.addServiceItem(service_item) self.parent.service_manager.addServiceItem(service_item)
def onAddEditClick(self): def onAddEditClick(self):
"""
Add a selected item to an existing item in the current service.
"""
if not self.ListView.selectedIndexes() and not self.remoteTriggered: if not self.ListView.selectedIndexes() and not self.remoteTriggered:
QtGui.QMessageBox.information(self, QtGui.QMessageBox.information(self,
translate('MediaManagerItem', 'No items selected'), translate('MediaManagerItem', 'No items selected'),

View File

@ -22,7 +22,9 @@
# with this program; if not, write to the Free Software Foundation, Inc., 59 # # with this program; if not, write to the Free Software Foundation, Inc., 59 #
# Temple Place, Suite 330, Boston, MA 02111-1307 USA # # Temple Place, Suite 330, Boston, MA 02111-1307 USA #
############################################################################### ###############################################################################
"""
Provide the generic plugin functionality for OpenLP plugins.
"""
import logging import logging
from PyQt4 import QtCore from PyQt4 import QtCore

View File

@ -304,7 +304,7 @@ class ServiceItem(object):
def merge(self, other): def merge(self, other):
""" """
Updates the _uuid with the value from the original one Updates the _uuid with the value from the original one
The _uuid is unique for a give service item but this allows one to The _uuid is unique for a given service item but this allows one to
replace an original version. replace an original version.
""" """
self._uuid = other._uuid self._uuid = other._uuid

View File

@ -22,7 +22,12 @@
# with this program; if not, write to the Free Software Foundation, Inc., 59 # # with this program; if not, write to the Free Software Foundation, Inc., 59 #
# Temple Place, Suite 330, Boston, MA 02111-1307 USA # # Temple Place, Suite 330, Boston, MA 02111-1307 USA #
############################################################################### ###############################################################################
"""
Provide handling for persisting OpenLP settings. OpenLP uses QSettings to
manage settings persistence. QSettings provides a single API for saving and
retrieving settings from the application but writes to disk in an OS dependant
format.
"""
import os import os
from PyQt4 import QtCore from PyQt4 import QtCore
@ -56,6 +61,9 @@ class SettingsManager(object):
u'user interface/preview panel', QtCore.QVariant(True)).toBool() u'user interface/preview panel', QtCore.QVariant(True)).toBool()
def togglePreviewPanel(self, isVisible): def togglePreviewPanel(self, isVisible):
"""
Toggle the preview panel visibility.
"""
QtCore.QSettings().setValue(u'user interface/preview panel', QtCore.QSettings().setValue(u'user interface/preview panel',
QtCore.QVariant(isVisible)) QtCore.QVariant(isVisible))

View File

@ -22,7 +22,9 @@
# with this program; if not, write to the Free Software Foundation, Inc., 59 # # with this program; if not, write to the Free Software Foundation, Inc., 59 #
# Temple Place, Suite 330, Boston, MA 02111-1307 USA # # Temple Place, Suite 330, Boston, MA 02111-1307 USA #
############################################################################### ###############################################################################
"""
Provide the theme XML and handling functions for OpenLP v2 themes.
"""
import os import os
from xml.dom.minidom import Document from xml.dom.minidom import Document

View File

@ -22,7 +22,9 @@
# with this program; if not, write to the Free Software Foundation, Inc., 59 # # with this program; if not, write to the Free Software Foundation, Inc., 59 #
# Temple Place, Suite 330, Boston, MA 02111-1307 USA # # Temple Place, Suite 330, Boston, MA 02111-1307 USA #
############################################################################### ###############################################################################
"""
Provide common toolbar handling for OpenLP
"""
import logging import logging
from PyQt4 import QtCore, QtGui from PyQt4 import QtCore, QtGui

View File

@ -73,6 +73,14 @@ class ServiceItemEditForm(QtGui.QDialog, Ui_ServiceItemEditDialog):
for frame in self.itemList: for frame in self.itemList:
item_name = QtGui.QListWidgetItem(frame[u'title']) item_name = QtGui.QListWidgetItem(frame[u'title'])
self.listWidget.addItem(item_name) self.listWidget.addItem(item_name)
if self.listWidget.count() == 1:
self.downButton.setEnabled(False)
self.upButton.setEnabled(False)
self.deleteButton.setEnabled(False)
else:
self.downButton.setEnabled(True)
self.upButton.setEnabled(True)
self.deleteButton.setEnabled(True)
def onItemDelete(self): def onItemDelete(self):
""" """

View File

@ -68,7 +68,8 @@ class OSISBible(BibleDB):
self.q1_regex = re.compile(r'<q(.*?)level="1"(.*?)>') self.q1_regex = re.compile(r'<q(.*?)level="1"(.*?)>')
self.q2_regex = re.compile(r'<q(.*?)level="2"(.*?)>') self.q2_regex = re.compile(r'<q(.*?)level="2"(.*?)>')
self.trans_regex = re.compile(r'<transChange(.*?)>(.*?)</transChange>') self.trans_regex = re.compile(r'<transChange(.*?)>(.*?)</transChange>')
self.divineName_regex = re.compile(r'<divineName(.*?)>(.*?)</divineName>') self.divineName_regex = re.compile(
r'<divineName(.*?)>(.*?)</divineName>')
self.spaces_regex = re.compile(r'([ ]{2,})') self.spaces_regex = re.compile(r'([ ]{2,})')
self.books = {} self.books = {}
filepath = os.path.join( filepath = os.path.join(

View File

@ -589,7 +589,7 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog):
def onCopyrightInsertButtonTriggered(self): def onCopyrightInsertButtonTriggered(self):
text = self.CopyrightEditItem.text() text = self.CopyrightEditItem.text()
pos = self.CopyrightEditItem.cursorPosition() pos = self.CopyrightEditItem.cursorPosition()
text = text[:pos] + u'\xa9' + text[pos:] text = text[:pos] + '\xa9' + text[pos:]
self.CopyrightEditItem.setText(text) self.CopyrightEditItem.setText(text)
self.CopyrightEditItem.setFocus() self.CopyrightEditItem.setFocus()
self.CopyrightEditItem.setCursorPosition(pos + 1) self.CopyrightEditItem.setCursorPosition(pos + 1)

View File

@ -94,6 +94,10 @@ class VerseType(object):
from manager import SongManager from manager import SongManager
from songstab import SongsTab from songstab import SongsTab
from mediaitem import SongMediaItem from mediaitem import SongMediaItem
from sofimport import SofImport from songimport import SongImport
from oooimport import OooImport try:
from songimport import SongImport from sofimport import SofImport
from oooimport import OooImport
except ImportError:
pass

View File

@ -25,9 +25,7 @@
import re import re
from PyQt4 import QtGui from openlp.core.lib import SongXMLBuilder, translate
from openlp.core.lib import SongXMLBuilder
from openlp.plugins.songs.lib import VerseType from openlp.plugins.songs.lib import VerseType
from openlp.plugins.songs.lib.models import Song, Author, Topic, Book from openlp.plugins.songs.lib.models import Song, Author, Topic, Book
@ -63,10 +61,10 @@ class SongImport(object):
self.verses = [] self.verses = []
self.versecount = 0 self.versecount = 0
self.choruscount = 0 self.choruscount = 0
self.copyright_string = unicode(QtGui.QApplication.translate( self.copyright_string = unicode(translate(
u'SongsPlugin.SongImport', u'copyright')) 'SongsPlugin.SongImport', 'copyright'))
self.copyright_symbol = unicode(QtGui.QApplication.translate( self.copyright_symbol = unicode(translate(
u'SongsPlugin.SongImport', u'\xa9')) 'SongsPlugin.SongImport', '\xa9'))
@staticmethod @staticmethod
def process_songs_text(manager, text): def process_songs_text(manager, text):

View File

@ -29,8 +29,13 @@ from PyQt4 import QtCore, QtGui
from openlp.core.lib import Plugin, build_icon, PluginStatus, Receiver, \ from openlp.core.lib import Plugin, build_icon, PluginStatus, Receiver, \
translate translate
from openlp.plugins.songs.lib import SongManager, SongMediaItem, SongsTab, \ from openlp.plugins.songs.lib import SongManager, SongMediaItem, SongsTab
SofImport, OooImport
try:
from openlp.plugins.songs.lib import SofImport, OooImport
OOo_available = True
except ImportError:
OOo_available = False
log = logging.getLogger(__name__) log = logging.getLogger(__name__)
@ -95,46 +100,48 @@ class SongsPlugin(Plugin):
self.SongImportItem.setToolTip(translate('SongsPlugin', self.SongImportItem.setToolTip(translate('SongsPlugin',
'Import songs using the import wizard.')) 'Import songs using the import wizard.'))
import_menu.addAction(self.SongImportItem) import_menu.addAction(self.SongImportItem)
# Songs of Fellowship import menu item - will be removed and the
# functionality will be contained within the import wizard
self.ImportSofItem = QtGui.QAction(import_menu)
self.ImportSofItem.setObjectName(u'ImportSofItem')
self.ImportSofItem.setText(
translate('SongsPlugin',
'Songs of Fellowship (temp menu item)'))
self.ImportSofItem.setToolTip(
translate('SongsPlugin',
'Import songs from the VOLS1_2.RTF, sof3words' \
+ '.rtf and sof4words.rtf supplied with the music books'))
self.ImportSofItem.setStatusTip(
translate('SongsPlugin',
'Import songs from the VOLS1_2.RTF, sof3words' \
+ '.rtf and sof4words.rtf supplied with the music books'))
import_menu.addAction(self.ImportSofItem)
# OpenOffice.org import menu item - will be removed and the
# functionality will be contained within the import wizard
self.ImportOooItem = QtGui.QAction(import_menu)
self.ImportOooItem.setObjectName(u'ImportOooItem')
self.ImportOooItem.setText(
translate('SongsPlugin',
'Generic Document/Presentation Import '
'(temp menu item)'))
self.ImportOooItem.setToolTip(
translate('SongsPlugin',
'Import songs from '
'Word/Writer/Powerpoint/Impress'))
self.ImportOooItem.setStatusTip(
translate('SongsPlugin',
'Import songs from '
'Word/Writer/Powerpoint/Impress'))
import_menu.addAction(self.ImportOooItem)
# Signals and slots # Signals and slots
QtCore.QObject.connect(self.SongImportItem, QtCore.QObject.connect(self.SongImportItem,
QtCore.SIGNAL(u'triggered()'), self.onSongImportItemClicked) QtCore.SIGNAL(u'triggered()'), self.onSongImportItemClicked)
QtCore.QObject.connect(self.ImportSofItem, if OOo_available:
QtCore.SIGNAL(u'triggered()'), self.onImportSofItemClick) # Songs of Fellowship import menu item - will be removed and the
QtCore.QObject.connect(self.ImportOooItem, # functionality will be contained within the import wizard
QtCore.SIGNAL(u'triggered()'), self.onImportOooItemClick) self.ImportSofItem = QtGui.QAction(import_menu)
self.ImportSofItem.setObjectName(u'ImportSofItem')
self.ImportSofItem.setText(
translate('SongsPlugin',
'Songs of Fellowship (temp menu item)'))
self.ImportSofItem.setToolTip(
translate('SongsPlugin',
'Import songs from the VOLS1_2.RTF, sof3words' \
+ '.rtf and sof4words.rtf supplied with the music books'))
self.ImportSofItem.setStatusTip(
translate('SongsPlugin',
'Import songs from the VOLS1_2.RTF, sof3words' \
+ '.rtf and sof4words.rtf supplied with the music books'))
import_menu.addAction(self.ImportSofItem)
# OpenOffice.org import menu item - will be removed and the
# functionality will be contained within the import wizard
self.ImportOooItem = QtGui.QAction(import_menu)
self.ImportOooItem.setObjectName(u'ImportOooItem')
self.ImportOooItem.setText(
translate('SongsPlugin',
'Generic Document/Presentation Import '
'(temp menu item)'))
self.ImportOooItem.setToolTip(
translate('SongsPlugin',
'Import songs from '
'Word/Writer/Powerpoint/Impress'))
self.ImportOooItem.setStatusTip(
translate('SongsPlugin',
'Import songs from '
'Word/Writer/Powerpoint/Impress'))
import_menu.addAction(self.ImportOooItem)
# Signals and slots
QtCore.QObject.connect(self.ImportSofItem,
QtCore.SIGNAL(u'triggered()'), self.onImportSofItemClick)
QtCore.QObject.connect(self.ImportOooItem,
QtCore.SIGNAL(u'triggered()'), self.onImportOooItemClick)
def add_export_menu_item(self, export_menu): def add_export_menu_item(self, export_menu):
""" """