This commit is contained in:
Tim Bentley 2009-09-16 20:03:11 +01:00
commit 0c6a1d5762
5 changed files with 119 additions and 77 deletions

View File

@ -1,6 +1,5 @@
*.pyc
*.*~
*.log
\#*\#
*.eric4project
*.ropeproject
@ -10,3 +9,4 @@ list
openlp.org 2.0.e4*
documentation/build/html
documentation/build/doctrees
*.log*

View File

@ -39,11 +39,13 @@ class OpenLPToolbar(QtGui.QToolBar):
QtGui.QToolBar.__init__(self, None)
# useful to be able to reuse button icons...
self.icons = {}
self.setIconSize(QtCore.QSize(20, 20))
self.actions = {}
self.log = logging.getLogger(u'OpenLPToolbar')
self.log.debug(u'Init done')
def addToolbarButton(self, title, icon, tooltip=None, slot=None, objectname=None):
def addToolbarButton(self, title, icon, tooltip=None, slot=None,
objectname=None):
"""
A method to help developers easily add a button to the toolbar.
@ -73,8 +75,8 @@ class OpenLPToolbar(QtGui.QToolBar):
ButtonIcon.addPixmap(QtGui.QPixmap(icon), QtGui.QIcon.Normal,
QtGui.QIcon.Off)
else:
ButtonIcon.addPixmap(QtGui.QPixmap.fromImage(QtGui.QImage(icon)),
QtGui.QIcon.Normal, QtGui.QIcon.Off)
ButtonIcon.addPixmap(QtGui.QPixmap.fromImage(
QtGui.QImage(icon)), QtGui.QIcon.Normal, QtGui.QIcon.Off)
if ButtonIcon is not None:
if slot is not None:
ToolbarButton = self.addAction(ButtonIcon, title, slot)

View File

@ -157,13 +157,13 @@ class SlideController(QtGui.QWidget):
self.DelaySpinBox.setSuffix(translate(u'SlideController', u's'))
self.ControllerLayout.addWidget(self.Toolbar)
sizeToolbarPolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Fixed,
QtGui.QSizePolicy.Fixed)
sizeToolbarPolicy.setHorizontalStretch(0)
sizeToolbarPolicy.setVerticalStretch(0)
sizeToolbarPolicy.setHeightForWidth(
self.Toolbar.sizePolicy().hasHeightForWidth())
self.Toolbar.setSizePolicy(sizeToolbarPolicy)
#sizeToolbarPolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Fixed,
# QtGui.QSizePolicy.Fixed)
#sizeToolbarPolicy.setHorizontalStretch(0)
#sizeToolbarPolicy.setVerticalStretch(0)
#sizeToolbarPolicy.setHeightForWidth(
# self.Toolbar.sizePolicy().hasHeightForWidth())
#self.Toolbar.setSizePolicy(sizeToolbarPolicy)
# Screen preview area
self.PreviewFrame = QtGui.QFrame(self.Splitter)
self.PreviewFrame.setGeometry(QtCore.QRect(0, 0, 300, 225))

View File

@ -59,42 +59,43 @@ class BibleMediaItem(MediaManagerItem):
self.addToolbar()
# Create buttons for the toolbar
## New Bible Button ##
self.addToolbarButton(
translate(u'BibleMediaItem',u'New Bible'),
translate(u'BibleMediaItem',u'Register a new Bible'),
self.addToolbarButton(translate(u'BibleMediaItem', u'New Bible'),
translate(u'BibleMediaItem', u'Register a new Bible'),
u':/themes/theme_import.png', self.onBibleNewClick, u'BibleNewItem')
## Separator Line ##
self.addToolbarSeparator()
## Preview Bible Button ##
self.addToolbarButton(
translate(u'BibleMediaItem',u'Preview Bible'),
translate(u'BibleMediaItem',u'Preview the selected Bible Verse'),
u':/system/system_preview.png', self.onPreviewClick, u'BiblePreviewItem')
self.addToolbarButton(translate(u'BibleMediaItem', u'Preview Bible'),
translate(u'BibleMediaItem', u'Preview the selected Bible Verse'),
u':/system/system_preview.png', self.onPreviewClick,
u'BiblePreviewItem')
## Live Bible Button ##
self.addToolbarButton(
translate(u'BibleMediaItem',u'Go Live'),
translate(u'BibleMediaItem',u'Send the selected Bible Verse(s) live'),
self.addToolbarButton(translate(u'BibleMediaItem',u'Go Live'),
translate(u'BibleMediaItem',
u'Send the selected Bible Verse(s) live'),
u':/system/system_live.png', self.onLiveClick, u'BibleLiveItem')
## Add Bible Button ##
self.addToolbarButton(
translate(u'BibleMediaItem',u'Add Bible Verse(s) To Service'),
translate(u'BibleMediaItem',u'Add the selected Bible(s) to the service'),
u':/system/system_add.png',
self.onAddClick, u'BibleAddItem')
translate(u'BibleMediaItem', u'Add Bible Verse(s) To Service'),
translate(u'BibleMediaItem',
u'Add the selected Bible(s) to the service'),
u':/system/system_add.png', self.onAddClick, u'BibleAddItem')
# Create the tab widget
self.SearchTabWidget = QtGui.QTabWidget(self)
sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum)
sizePolicy = QtGui.QSizePolicy(
QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum)
sizePolicy.setHorizontalStretch(0)
sizePolicy.setVerticalStretch(0)
sizePolicy.setHeightForWidth(self.SearchTabWidget.sizePolicy().hasHeightForWidth())
sizePolicy.setHeightForWidth(
self.SearchTabWidget.sizePolicy().hasHeightForWidth())
self.SearchTabWidget.setSizePolicy(sizePolicy)
self.SearchTabWidget.setObjectName(u'SearchTabWidget')
# Add the Quick Search tab
self.QuickTab = QtGui.QWidget()
self.QuickTab.setObjectName(u'QuickTab')
self.QuickLayout = QtGui.QGridLayout(self.QuickTab)
self.QuickLayout.setMargin(8)
self.QuickLayout.setSpacing(8)
self.QuickLayout.setMargin(5)
self.QuickLayout.setSpacing(4)
self.QuickLayout.setObjectName(u'QuickLayout')
self.QuickVersionLabel = QtGui.QLabel(self.QuickTab)
self.QuickVersionLabel.setObjectName(u'QuickVersionLabel')
@ -137,8 +138,8 @@ class BibleMediaItem(MediaManagerItem):
self.AdvancedTab = QtGui.QWidget()
self.AdvancedTab.setObjectName(u'AdvancedTab')
self.AdvancedLayout = QtGui.QGridLayout(self.AdvancedTab)
self.AdvancedLayout.setMargin(8)
self.AdvancedLayout.setSpacing(8)
self.AdvancedLayout.setMargin(5)
self.AdvancedLayout.setSpacing(4)
self.AdvancedLayout.setObjectName(u'AdvancedLayout')
self.AdvancedVersionLabel = QtGui.QLabel(self.AdvancedTab)
self.AdvancedVersionLabel.setObjectName(u'AdvancedVersionLabel')
@ -180,8 +181,10 @@ class BibleMediaItem(MediaManagerItem):
self.AdvancedClearLabel.setObjectName(u'QuickSearchLabel')
self.AdvancedLayout.addWidget(self.AdvancedClearLabel, 5, 0, 1, 1)
self.ClearAdvancedSearchComboBox = QtGui.QComboBox(self.QuickTab)
self.ClearAdvancedSearchComboBox.setObjectName(u'ClearAdvancedSearchComboBox')
self.AdvancedLayout.addWidget(self.ClearAdvancedSearchComboBox, 5, 2, 1, 1)
self.ClearAdvancedSearchComboBox.setObjectName(
u'ClearAdvancedSearchComboBox')
self.AdvancedLayout.addWidget(
self.ClearAdvancedSearchComboBox, 5, 2, 1, 1)
self.AdvancedSearchButton = QtGui.QPushButton(self.AdvancedTab)
self.AdvancedSearchButton.setObjectName(u'AdvancedSearchButton')
self.AdvancedLayout.addWidget(self.AdvancedSearchButton, 5, 3, 1, 1)
@ -190,7 +193,8 @@ class BibleMediaItem(MediaManagerItem):
self.PageLayout.addWidget(self.SearchTabWidget)
self.ListView = BibleListView()
self.ListView.setAlternatingRowColors(True)
self.ListView.setSelectionMode(QtGui.QAbstractItemView.ExtendedSelection)
self.ListView.setSelectionMode(
QtGui.QAbstractItemView.ExtendedSelection)
self.ListView.setDragEnabled(True)
self.PageLayout.addWidget(self.ListView)
# Combo Boxes
@ -215,7 +219,8 @@ class BibleMediaItem(MediaManagerItem):
self.ListView.setContextMenuPolicy(QtCore.Qt.ActionsContextMenu)
self.ListView.addAction(contextMenuAction(
self.ListView, u':/system/system_preview.png',
translate(u'BibleMediaItem',u'&Preview Verse'), self.onPreviewClick))
translate(u'BibleMediaItem',u'&Preview Verse'),
self.onPreviewClick))
self.ListView.addAction(contextMenuAction(
self.ListView, u':/system/system_live.png',
translate(u'BibleMediaItem',u'&Show Live'), self.onLiveClick))
@ -225,25 +230,37 @@ class BibleMediaItem(MediaManagerItem):
def retranslateUi(self):
log.debug(u'retranslateUi')
self.QuickVersionLabel.setText(translate(u'BibleMediaItem', u'Version:'))
self.QuickSearchLabel.setText(translate(u'BibleMediaItem', u'Search Type:'))
self.QuickVersionLabel.setText(
translate(u'BibleMediaItem', u'Version:'))
self.QuickSearchLabel.setText(
translate(u'BibleMediaItem', u'Search Type:'))
self.QuickSearchLabel.setText(translate(u'BibleMediaItem', u'Find:'))
self.QuickSearchButton.setText(translate(u'BibleMediaItem', u'Search'))
self.QuickClearLabel.setText(translate(u'BibleMediaItem', u'Results:'))
self.AdvancedVersionLabel.setText(translate(u'BibleMediaItem', u'Version:'))
self.AdvancedVersionLabel.setText(
translate(u'BibleMediaItem', u'Version:'))
self.AdvancedBookLabel.setText(translate(u'BibleMediaItem', u'Book:'))
self.AdvancedChapterLabel.setText(translate(u'BibleMediaItem', u'Chapter:'))
self.AdvancedChapterLabel.setText(
translate(u'BibleMediaItem', u'Chapter:'))
self.AdvancedVerseLabel.setText(translate(u'BibleMediaItem', u'Verse:'))
self.AdvancedFromLabel.setText(translate(u'BibleMediaItem', u'From:'))
self.AdvancedToLabel.setText(translate(u'BibleMediaItem', u'To:'))
self.AdvancedClearLabel.setText(translate(u'BibleMediaItem', u'Results:'))
self.AdvancedSearchButton.setText(translate(u'BibleMediaItem', u'Search'))
self.QuickSearchComboBox.addItem(translate(u'BibleMediaItem', u'Verse Search'))
self.QuickSearchComboBox.addItem(translate(u'BibleMediaItem', u'Text Search'))
self.ClearQuickSearchComboBox.addItem(translate(u'BibleMediaItem', u'Clear'))
self.ClearQuickSearchComboBox.addItem(translate(u'BibleMediaItem', u'Keep'))
self.ClearAdvancedSearchComboBox.addItem(translate(u'BibleMediaItem', u'Clear'))
self.ClearAdvancedSearchComboBox.addItem(translate(u'BibleMediaItem', u'Keep'))
self.AdvancedClearLabel.setText(
translate(u'BibleMediaItem', u'Results:'))
self.AdvancedSearchButton.setText(
translate(u'BibleMediaItem', u'Search'))
self.QuickSearchComboBox.addItem(
translate(u'BibleMediaItem', u'Verse Search'))
self.QuickSearchComboBox.addItem(
translate(u'BibleMediaItem', u'Text Search'))
self.ClearQuickSearchComboBox.addItem(
translate(u'BibleMediaItem', u'Clear'))
self.ClearQuickSearchComboBox.addItem(
translate(u'BibleMediaItem', u'Keep'))
self.ClearAdvancedSearchComboBox.addItem(
translate(u'BibleMediaItem', u'Clear'))
self.ClearAdvancedSearchComboBox.addItem(
translate(u'BibleMediaItem', u'Keep'))
def initialise(self):
log.debug(u'initialise')
@ -279,14 +296,17 @@ class BibleMediaItem(MediaManagerItem):
self.initialiseBible(bible)
def onAdvancedVersionComboBox(self):
self.initialiseBible(unicode(self.AdvancedVersionComboBox.currentText()))
self.initialiseBible(
unicode(self.AdvancedVersionComboBox.currentText()))
def onAdvancedBookComboBox(self):
self.initialiseChapterVerse(unicode(self.AdvancedVersionComboBox.currentText()),
self.initialiseChapterVerse(
unicode(self.AdvancedVersionComboBox.currentText()),
unicode(self.AdvancedBookComboBox.currentText()))
def onBibleNewClick(self):
self.bibleimportform = BibleImportForm(self.parent.config, self.parent.biblemanager, self)
self.bibleimportform = BibleImportForm(
self.parent.config, self.parent.biblemanager, self)
self.bibleimportform.exec_()
self.reloadBibles()
@ -301,8 +321,9 @@ class BibleMediaItem(MediaManagerItem):
bible = unicode(self.AdvancedVersionComboBox.currentText())
book = unicode(self.AdvancedBookComboBox.currentText())
# get the verse count for new chapter
vse = self.parent.biblemanager.get_book_verse_count(bible, book, int(t2))[0]
self.adjustComboBox(1, vse, self.AdvancedToVerse)
verses = self.parent.biblemanager.get_book_verse_count(
bible, book, int(t2))[0]
self.adjustComboBox(1, verses, self.AdvancedToVerse)
def onAdvancedSearchButton(self):
log.debug(u'Advanced Search Button pressed')
@ -312,8 +333,8 @@ class BibleMediaItem(MediaManagerItem):
chapter_to = int(self.AdvancedToChapter.currentText())
verse_from = int(self.AdvancedFromVerse.currentText())
verse_to = int(self.AdvancedToVerse.currentText())
self.search_results = self.parent.biblemanager.get_verse_text(bible, book,
chapter_from, chapter_to, verse_from, verse_to)
self.search_results = self.parent.biblemanager.get_verse_text(
bible, book, chapter_from, chapter_to, verse_from, verse_to)
if self.ClearAdvancedSearchComboBox.currentIndex() == 0:
self.ListView.clear()
self.displayResults(bible)

View File

@ -50,7 +50,8 @@ class SongMediaItem(MediaManagerItem):
self.ConfigSection = u'song'
MediaManagerItem.__init__(self, parent, icon, title)
self.edit_song_form = EditSongForm(self.parent.songmanager, self)
self.song_maintenance_form = SongMaintenanceForm(self.parent.songmanager, self)
self.song_maintenance_form = SongMaintenanceForm(
self.parent.songmanager, self)
def setupUi(self):
# Add a toolbar
@ -73,30 +74,39 @@ class SongMediaItem(MediaManagerItem):
## Preview Song Button ##
self.addToolbarButton(translate(u'SongMediaItem', u'Preview Song'),
translate(u'SongMediaItem', u'Preview the selected song'),
':/system/system_preview.png', self.onPreviewClick, 'SongPreviewItem')
':/system/system_preview.png', self.onPreviewClick,
'SongPreviewItem')
## Live Song Button ##
self.addToolbarButton(translate(u'SongMediaItem', u'Go Live'),
translate(u'SongMediaItem', u'Send the selected song live'),
':/system/system_live.png', self.onLiveClick, 'SongLiveItem')
## Add Song Button ##
self.addToolbarButton(translate(u'SongMediaItem', u'Add Song To Service'),
translate(u'SongMediaItem', u'Add the selected song(s) to the service'),
self.addToolbarButton(
translate(u'SongMediaItem', u'Add Song To Service'),
translate(u'SongMediaItem',
u'Add the selected song(s) to the service'),
':/system/system_add.png', self.onAddClick, 'SongAddItem')
self.addToolbarSeparator()
## Song Maintenance Button ##
self.addToolbarButton(translate(u'SongMediaItem', u'Song Maintenance'),
translate(u'SongMediaItem', u'Maintain the lists of authors, topics and books'),
':/songs/song_maintenance.png', self.onSongMaintenanceClick, 'SongMaintenanceItem')
translate(u'SongMediaItem',
u'Maintain the lists of authors, topics and books'),
':/songs/song_maintenance.png', self.onSongMaintenanceClick,
'SongMaintenanceItem')
## Add the SongListView widget ##
# Create the tab widget
self.SongWidget = QtGui.QWidget(self)
sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum)
sizePolicy = QtGui.QSizePolicy(
QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum)
sizePolicy.setHorizontalStretch(0)
sizePolicy.setVerticalStretch(0)
sizePolicy.setHeightForWidth(self.SongWidget.sizePolicy().hasHeightForWidth())
sizePolicy.setHeightForWidth(
self.SongWidget.sizePolicy().hasHeightForWidth())
self.SongWidget.setSizePolicy(sizePolicy)
self.SongWidget.setObjectName(u'SongWidget')
self.SearchLayout = QtGui.QGridLayout(self.SongWidget)
self.SearchLayout.setMargin(5)
self.SearchLayout.setSpacing(4)
self.SearchLayout.setObjectName(u'SearchLayout')
self.SearchTypeComboBox = QtGui.QComboBox(self.SongWidget)
self.SearchTypeComboBox.setObjectName(u'SearchTypeComboBox')
@ -130,7 +140,8 @@ class SongMediaItem(MediaManagerItem):
QtCore.QObject.connect(self.ClearTextButton,
QtCore.SIGNAL(u'pressed()'), self.onClearTextButtonClick)
QtCore.QObject.connect(self.SearchTextEdit,
QtCore.SIGNAL(u'textChanged(const QString&)'), self.onSearchTextEditChanged)
QtCore.SIGNAL(u'textChanged(const QString&)'),
self.onSearchTextEditChanged)
QtCore.QObject.connect(self.ListView,
QtCore.SIGNAL(u'doubleClicked(QModelIndex)'), self.onPreviewClick)
QtCore.QObject.connect(Receiver.get_receiver(),
@ -143,18 +154,20 @@ class SongMediaItem(MediaManagerItem):
self.onSongEditClick))
self.ListView.addAction(contextMenuSeparator(self.ListView))
self.ListView.addAction(contextMenuAction(self.ListView,
':/system/system_preview.png', translate(u'SongMediaItem', u'&Preview Song'),
self.onPreviewClick))
':/system/system_preview.png',
translate(u'SongMediaItem', u'&Preview Song'), self.onPreviewClick))
self.ListView.addAction(contextMenuAction(self.ListView,
':/system/system_live.png', translate(u'SongMediaItem', u'&Show Live'),
self.onLiveClick))
':/system/system_live.png',
translate(u'SongMediaItem', u'&Show Live'), self.onLiveClick))
self.ListView.addAction(contextMenuAction(self.ListView,
':/system/system_add.png', translate(u'SongMediaItem', u'&Add to Service'),
self.onAddClick))
':/system/system_add.png',
translate(u'SongMediaItem', u'&Add to Service'), self.onAddClick))
def retranslateUi(self):
self.SearchTypeLabel.setText(translate(u'SongMediaItem', u'Search Type:'))
self.SearchTextLabel.setText(translate(u'SongMediaItem', u'Search Text:'))
self.SearchTypeLabel.setText(
translate(u'SongMediaItem', u'Search Type:'))
self.SearchTextLabel.setText(
translate(u'SongMediaItem', u'Search Text:'))
self.ClearTextButton.setText(translate(u'SongMediaItem', u'Clear'))
self.SearchTextButton.setText(translate(u'SongMediaItem', u'Search'))
@ -169,15 +182,18 @@ class SongMediaItem(MediaManagerItem):
search_type = self.SearchTypeComboBox.currentIndex()
if search_type == 0:
log.debug(u'Titles Search')
search_results = self.parent.songmanager.search_song_title(search_keywords)
search_results = self.parent.songmanager.search_song_title(
search_keywords)
self.displayResultsSong(search_results)
elif search_type == 1:
log.debug(u'Lyrics Search')
search_results = self.parent.songmanager.search_song_lyrics(search_keywords)
search_results = self.parent.songmanager.search_song_lyrics(
search_keywords)
self.displayResultsSong(search_results)
elif search_type == 2:
log.debug(u'Authors Search')
search_results = self.parent.songmanager.get_song_from_author(search_keywords)
search_results = self.parent.songmanager.get_song_from_author(
search_keywords)
self.displayResultsAuthor(search_results)
def displayResultsSong(self, searchresults):
@ -190,7 +206,8 @@ class SongMediaItem(MediaManagerItem):
if author_list != u'':
author_list = author_list + u', '
author_list = author_list + author.display_name
song_detail = unicode(u'%s (%s)' % (unicode(song.title), unicode(author_list)))
song_detail = unicode(u'%s (%s)' % \
(unicode(song.title), unicode(author_list)))
song_name = QtGui.QListWidgetItem(song_detail)
song_name.setData(QtCore.Qt.UserRole, QtCore.QVariant(song.id))
self.ListView.addItem(song_name)
@ -200,7 +217,8 @@ class SongMediaItem(MediaManagerItem):
self.ListView.clear()
for author in searchresults:
for song in author.songs:
song_detail = unicode(u'%s (%s)' % (unicode(author.display_name), unicode(song.title)))
song_detail = unicode(u'%s (%s)' % \
(unicode(author.display_name), unicode(song.title)))
song_name = QtGui.QListWidgetItem(song_detail)
song_name.setData(QtCore.Qt.UserRole, QtCore.QVariant(song.id))
self.ListView.addItem(song_name)
@ -285,7 +303,8 @@ class SongMediaItem(MediaManagerItem):
raw_footer.append(song.title)
raw_footer.append(author_list)
raw_footer.append(song.copyright )
raw_footer.append(unicode(translate(u'SongMediaItem', u'CCL Licence: ') + ccl ))
raw_footer.append(unicode(
translate(u'SongMediaItem', u'CCL Licence: ') + ccl ))
service_item.raw_footer = raw_footer
service_item.audit = u'%s,%s,%s' % (service_item.title, author_list, ccl)
return True