This commit is contained in:
Andreas Preikschat 2011-05-16 13:42:51 +02:00
commit a2ab806ca9
14 changed files with 162 additions and 133 deletions

View File

@ -223,28 +223,6 @@ def resize_image(image, width, height, background=QtCore.Qt.black):
painter.drawImage((width - realw) / 2, (height - realh) / 2, preview)
return new_image
def check_search_result(treeWidget, search_results):
"""
Checks if the given ``search_results`` is empty and adds a
"No Search Results" item to the given ``treeWidget``.
``treeWidget``
The ``QTreeWidget`` where the "No Search Results" item should be added
to, if the ``search_results`` is empty.
``search_results``
This can either be a list or a dict.
"""
if search_results or treeWidget.count():
return
message = translate('OpenLP.MediaManagerItem', 'No Search Results')
item = QtGui.QListWidgetItem(message)
item.setFlags(QtCore.Qt.NoItemFlags)
font = QtGui.QFont()
font.setItalic(True)
item.setFont(font)
treeWidget.addItem(item)
def check_item_selected(list_widget, message):
"""
Check if a list item is selected so an action may be performed on it

View File

@ -244,7 +244,6 @@ class MediaManagerItem(QtGui.QWidget):
"""
# Add the List widget
self.listView = ListWidgetWithDnD(self, self.plugin.name)
self.listView.setUniformItemSizes(True)
self.listView.setSpacing(1)
self.listView.setSelectionMode(
QtGui.QAbstractItemView.ExtendedSelection)
@ -552,6 +551,20 @@ class MediaManagerItem(QtGui.QWidget):
"""
pass
def check_search_result(self):
"""
Checks if the listView is empty and adds a "No Search Results" item.
"""
if self.listView.count():
return
message = translate('OpenLP.MediaManagerItem', 'No Search Results')
item = QtGui.QListWidgetItem(message)
item.setFlags(QtCore.Qt.NoItemFlags)
font = QtGui.QFont()
font.setItalic(True)
item.setFont(font)
self.listView.addItem(item)
def _getIdOfItemToGenerate(self, item, remoteItem):
"""
Utility method to check items being submitted for slide generation.

View File

@ -162,8 +162,10 @@ class Renderer(object):
self.theme_data = self.theme_manager.getThemeData(theme)
self._calculate_default(self.screens.current[u'size'])
self._build_text_rectangle(self.theme_data)
self.image_manager.add_image(self.theme_data.theme_name,
self.theme_data.background_filename)
# if No file do not update cache
if self.theme_data.background_filename:
self.image_manager.add_image(self.theme_data.theme_name,
self.theme_data.background_filename)
return self._rect, self._rect_footer
def generate_preview(self, theme_data, force_page=False):

View File

@ -50,7 +50,6 @@ class SettingsTab(QtGui.QWidget):
self.setupUi()
self.retranslateUi()
self.initialise()
self.preLoad()
self.load()
def setupUi(self):
@ -86,12 +85,6 @@ class SettingsTab(QtGui.QWidget):
left_width = max(left_width, self.leftColumn.minimumSizeHint().width())
self.leftColumn.setFixedWidth(left_width)
def preLoad(self):
"""
Setup the tab's interface.
"""
pass
def retranslateUi(self):
"""
Setup the interface translation strings.
@ -118,9 +111,9 @@ class SettingsTab(QtGui.QWidget):
def cancel(self):
"""
Reset any settings
Reset any settings if cancel pressed
"""
pass
self.load()
def postSetUp(self, postUpdate=False):
"""

View File

@ -47,7 +47,7 @@ class DisplayTagForm(QtGui.QDialog, Ui_DisplayTagDialog):
"""
QtGui.QDialog.__init__(self, parent)
self.setupUi(self)
self.preLoad()
self._loadDisplayTags()
QtCore.QObject.connect(self.tagTableWidget,
QtCore.SIGNAL(u'clicked(QModelIndex)'), self.onRowSelected)
QtCore.QObject.connect(self.defaultPushButton,
@ -66,12 +66,12 @@ class DisplayTagForm(QtGui.QDialog, Ui_DisplayTagDialog):
Load Display and set field state.
"""
# Create initial copy from master
self.preLoad()
self._loadDisplayTags()
self._resetTable()
self.selected = -1
return QtGui.QDialog.exec_(self)
def preLoad(self):
def _loadDisplayTags(self):
"""
Load the Tags from store so can be used in the system or used to
update the display. If Cancel was selected this is needed to reset the

View File

@ -101,6 +101,7 @@ class GeneralTab(SettingsTab):
self.timeoutLabel.setObjectName(u'timeoutLabel')
self.timeoutSpinBox = QtGui.QSpinBox(self.settingsGroupBox)
self.timeoutSpinBox.setObjectName(u'timeoutSpinBox')
self.timeoutSpinBox.setRange(1, 180)
self.settingsLayout.addRow(self.timeoutLabel, self.timeoutSpinBox)
self.leftLayout.addWidget(self.settingsGroupBox)
self.leftLayout.addStretch()

View File

@ -672,12 +672,15 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow):
'The Main Display has been blanked out'))
def onErrorMessage(self, data):
Receiver.send_message(u'close_splash')
QtGui.QMessageBox.critical(self, data[u'title'], data[u'message'])
def onWarningMessage(self, data):
Receiver.send_message(u'close_splash')
QtGui.QMessageBox.warning(self, data[u'title'], data[u'message'])
def onInformationMessage(self, data):
Receiver.send_message(u'close_splash')
QtGui.QMessageBox.information(self, data[u'title'], data[u'message'])
def onHelpWebSiteClicked(self):

View File

@ -199,8 +199,7 @@ class SlideController(QtGui.QWidget):
'Start/Stop continuous loop'))
self.addAction(self.toogleLoop)
self.delaySpinBox = QtGui.QSpinBox()
self.delaySpinBox.setMinimum(1)
self.delaySpinBox.setMaximum(180)
self.delaySpinBox.setRange(1, 180)
self.toolbar.addToolbarWidget(u'Image SpinBox', self.delaySpinBox)
self.delaySpinBox.setSuffix(UiStrings().Seconds)
self.delaySpinBox.setToolTip(translate('OpenLP.SlideController',

View File

@ -23,6 +23,7 @@
# with this program; if not, write to the Free Software Foundation, Inc., 59 #
# Temple Place, Suite 330, Boston, MA 02111-1307 USA #
###############################################################################
from openlp.core.lib import Receiver
from PyQt4 import QtCore, QtGui
@ -30,6 +31,8 @@ class SplashScreen(QtGui.QSplashScreen):
def __init__(self):
QtGui.QSplashScreen.__init__(self)
self.setupUi()
QtCore.QObject.connect(Receiver.get_receiver(),
QtCore.SIGNAL(u'close_splash'), self.close)
def setupUi(self):
self.setObjectName(u'splash_screen')

View File

@ -401,7 +401,7 @@ class BibleDB(QtCore.QObject, Manager):
"""
log.debug(u'BibleDB.get_chapter_count("%s")', book)
count = self.session.query(Verse.chapter).join(Book)\
.filter(Book.name==book)\
.filter(Book.name == book)\
.distinct().count()
if not count:
return 0
@ -420,8 +420,8 @@ class BibleDB(QtCore.QObject, Manager):
"""
log.debug(u'BibleDB.get_verse_count("%s", %s)', book, chapter)
count = self.session.query(Verse).join(Book)\
.filter(Book.name==book)\
.filter(Verse.chapter==chapter)\
.filter(Book.name == book)\
.filter(Verse.chapter == chapter)\
.count()
if not count:
return 0

View File

@ -285,7 +285,7 @@ class BibleManager(object):
Does a verse search for the given bible and text.
``bible``
The bible to seach in (unicode).
The bible to search in (unicode).
``second_bible``
The second bible (unicode). We do not search in this bible.
@ -294,6 +294,15 @@ class BibleManager(object):
The text to search for (unicode).
"""
log.debug(u'BibleManager.verse_search("%s", "%s")', bible, text)
if not bible:
Receiver.send_message(u'openlp_information_message', {
u'title': translate('BiblesPlugin.BibleManager',
'No Bibles Available'),
u'message': translate('BiblesPlugin.BibleManager',
'There are no Bibles currently installed. Please use the '
'Import Wizard to install one or more Bibles.')
})
return None
# Check if the bible or second_bible is a web bible.
webbible = self.db_cache[bible].get_object(BibleMeta,
u'download source')

View File

@ -29,7 +29,7 @@ import logging
from PyQt4 import QtCore, QtGui
from openlp.core.lib import MediaManagerItem, Receiver, ItemCapabilities, \
translate, check_search_result
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, find_and_set_in_combo_box
@ -63,10 +63,43 @@ class BibleMediaItem(MediaManagerItem):
self.quickPreviewAllowed = True
self.search_results = {}
self.second_search_results = {}
check_search_result(self.listView, self.search_results)
self.check_search_result()
QtCore.QObject.connect(Receiver.get_receiver(),
QtCore.SIGNAL(u'bibles_load_list'), self.reloadBibles)
def __checkSecondBible(self, bible, second_bible):
"""
Check if the first item is a second bible item or not.
"""
bitem = self.listView.item(0)
if not bitem.flags() & QtCore.Qt.ItemIsSelectable:
# The item is the "No Search Results" item.
self.listView.clear()
self.displayResults(bible, second_bible)
return
else:
item_second_bible = self._decodeQtObject(bitem, 'second_bible')
if item_second_bible and second_bible or not item_second_bible and \
not second_bible:
self.displayResults(bible, second_bible)
elif critical_error_message_box(
message=translate('BiblePlugin.MediaItem',
'You cannot combine single and dual Bible verse search results. '
'Do you want to delete your search results and start a new '
'search?'),
parent=self, question=True) == QtGui.QMessageBox.Yes:
self.listView.clear()
self.displayResults(bible, second_bible)
def _decodeQtObject(self, bitem, key):
reference = bitem.data(QtCore.Qt.UserRole)
if isinstance(reference, QtCore.QVariant):
reference = reference.toPyObject()
obj = reference[QtCore.QString(key)]
if isinstance(obj, QtCore.QVariant):
obj = obj.toPyObject()
return unicode(obj).strip()
def requiredIcons(self):
MediaManagerItem.requiredIcons(self)
self.hasImportIcon = True
@ -114,6 +147,12 @@ class BibleMediaItem(MediaManagerItem):
secondComboBox = media_item_combo_box(tab, prefix + u'SecondComboBox')
versionLabel.setBuddy(secondComboBox)
layout.addWidget(secondComboBox, idx + 1, 1, 1, 2)
styleLabel = QtGui.QLabel(tab)
styleLabel.setObjectName(prefix + u'StyleLabel')
layout.addWidget(styleLabel, idx + 2, 0, QtCore.Qt.AlignRight)
styleComboBox = media_item_combo_box(tab, prefix + u'StyleComboBox')
styleComboBox.addItems([u'', u'', u''])
layout.addWidget(styleComboBox, idx + 2, 1, 1, 2)
searchButtonLayout = QtGui.QHBoxLayout()
searchButtonLayout.setObjectName(prefix + u'SearchButtonLayout')
searchButtonLayout.addStretch()
@ -125,7 +164,7 @@ class BibleMediaItem(MediaManagerItem):
searchButton = QtGui.QPushButton(tab)
searchButton.setObjectName(prefix + u'SearchButton')
searchButtonLayout.addWidget(searchButton)
layout.addLayout(searchButtonLayout, idx + 2, 1, 1, 2)
layout.addLayout(searchButtonLayout, idx + 3, 1, 1, 2)
self.pageLayout.addWidget(tab)
tab.setVisible(False)
QtCore.QObject.connect(lockButton, QtCore.SIGNAL(u'toggled(bool)'),
@ -134,6 +173,8 @@ class BibleMediaItem(MediaManagerItem):
setattr(self, prefix + u'VersionComboBox', versionComboBox)
setattr(self, prefix + u'SecondLabel', secondLabel)
setattr(self, prefix + u'SecondComboBox', secondComboBox)
setattr(self, prefix + u'StyleLabel', styleLabel)
setattr(self, prefix + u'StyleComboBox', styleComboBox)
setattr(self, prefix + u'LockButton', lockButton)
setattr(self, prefix + u'SearchButtonLayout', searchButtonLayout)
setattr(self, prefix + u'SearchButton', searchButton)
@ -154,14 +195,6 @@ class BibleMediaItem(MediaManagerItem):
self.quickSearchEdit.setObjectName(u'quickSearchEdit')
self.quickSearchLabel.setBuddy(self.quickSearchEdit)
self.quickLayout.addWidget(self.quickSearchEdit, 0, 1, 1, 2)
self.quickLayoutLabel = QtGui.QLabel(self.quickTab)
self.quickLayoutLabel.setObjectName(u'quickClearLabel')
self.quickLayout.addWidget(
self.quickLayoutLabel, 1, 0, QtCore.Qt.AlignRight)
self.quickLayoutComboBox = media_item_combo_box(self.quickTab,
u'quickLayoutComboBox')
self.quickLayoutComboBox.addItems([u'', u'', u''])
self.quickLayout.addWidget(self.quickLayoutComboBox, 1, 1, 1, 2)
self.addSearchFields(
u'quick', translate('BiblesPlugin.MediaItem', 'Quick'))
self.quickTab.setVisible(True)
@ -218,8 +251,11 @@ class BibleMediaItem(MediaManagerItem):
QtCore.QObject.connect(self.quickVersionComboBox,
QtCore.SIGNAL(u'activated(int)'), self.updateAutoCompleter)
QtCore.QObject.connect(
self.quickLayoutComboBox, QtCore.SIGNAL(u'activated(int)'),
self.onLayoutStyleComboBoxChanged)
self.quickStyleComboBox, QtCore.SIGNAL(u'activated(int)'),
self.onQuickStyleComboBoxChanged)
QtCore.QObject.connect(
self.advancedStyleComboBox, QtCore.SIGNAL(u'activated(int)'),
self.onAdvancedStyleComboBoxChanged)
# Buttons
QtCore.QObject.connect(self.advancedSearchButton,
QtCore.SIGNAL(u'pressed()'), self.onAdvancedSearchButton)
@ -247,21 +283,26 @@ class BibleMediaItem(MediaManagerItem):
self.advancedSecondComboBox.setVisible(False)
self.quickSecondLabel.setVisible(False)
self.quickSecondComboBox.setVisible(False)
self.quickLayoutComboBox.setCurrentIndex(self.settings.layout_style)
self.quickStyleComboBox.setCurrentIndex(self.settings.layout_style)
self.advancedStyleComboBox.setCurrentIndex(self.settings.layout_style)
def retranslateUi(self):
log.debug(u'retranslateUi')
self.quickSearchLabel.setText(
translate('BiblesPlugin.MediaItem', 'Find:'))
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.quickStyleLabel.setText(UiStrings().LayoutStyle)
self.quickStyleComboBox.setItemText(LayoutStyle.VersePerSlide,
UiStrings().VersePerSlide)
self.quickStyleComboBox.setItemText(LayoutStyle.VersePerLine,
UiStrings().VersePerLine)
self.quickStyleComboBox.setItemText(LayoutStyle.Continuous,
UiStrings().Continuous)
self.quickLockButton.setToolTip(translate('BiblesPlugin.MediaItem',
'Toggle to keep or clear the previous results.'))
self.advancedVersionLabel.setText(u'%s:' % UiStrings().Version)
self.advancedSecondLabel.setText(
translate('BiblesPlugin.MediaItem', 'Second:'))
self.quickSearchButton.setText(UiStrings().Search)
self.advancedBookLabel.setText(
translate('BiblesPlugin.MediaItem', 'Book:'))
self.advancedChapterLabel.setText(
@ -272,16 +313,19 @@ class BibleMediaItem(MediaManagerItem):
translate('BiblesPlugin.MediaItem', 'From:'))
self.advancedToLabel.setText(
translate('BiblesPlugin.MediaItem', 'To:'))
self.advancedSearchButton.setText(UiStrings().Search)
self.advancedVersionLabel.setText(u'%s:' % UiStrings().Version)
self.advancedSecondLabel.setText(
translate('BiblesPlugin.MediaItem', 'Second:'))
self.advancedStyleLabel.setText(UiStrings().LayoutStyle)
self.advancedStyleComboBox.setItemText(LayoutStyle.VersePerSlide,
UiStrings().VersePerSlide)
self.advancedStyleComboBox.setItemText(LayoutStyle.VersePerLine,
UiStrings().VersePerLine)
self.advancedStyleComboBox.setItemText(LayoutStyle.Continuous,
UiStrings().Continuous)
self.advancedLockButton.setToolTip(translate('BiblesPlugin.MediaItem',
'Toggle to keep or clear the previous results.'))
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)
self.advancedSearchButton.setText(UiStrings().Search)
def initialise(self):
log.debug(u'bible manager initialise')
@ -303,28 +347,6 @@ class BibleMediaItem(MediaManagerItem):
self.configUpdated()
log.debug(u'bible manager initialise complete')
def onImportClick(self):
if not hasattr(self, u'import_wizard'):
self.import_wizard = BibleImportForm(self, self.parent.manager,
self.parent)
# If the import was not cancelled then reload.
if self.import_wizard.exec_():
self.reloadBibles()
def onSearchTabBarCurrentChanged(self, index):
if index == 0:
self.advancedTab.setVisible(False)
self.quickTab.setVisible(True)
else:
self.quickTab.setVisible(False)
self.advancedTab.setVisible(True)
def onLockButtonToggled(self, checked):
if checked:
self.sender().setIcon(self.lockIcon)
else:
self.sender().setIcon(self.unlockIcon)
def loadBibles(self):
log.debug(u'Loading Bibles')
self.quickVersionComboBox.clear()
@ -422,6 +444,47 @@ class BibleMediaItem(MediaManagerItem):
books.sort()
add_widget_completer(books, self.quickSearchEdit)
def onImportClick(self):
if not hasattr(self, u'import_wizard'):
self.import_wizard = BibleImportForm(self, self.parent.manager,
self.parent)
# If the import was not cancelled then reload.
if self.import_wizard.exec_():
self.reloadBibles()
def onSearchTabBarCurrentChanged(self, index):
if index == 0:
self.advancedTab.setVisible(False)
self.quickTab.setVisible(True)
self.quickSearchEdit.setFocus()
else:
self.quickTab.setVisible(False)
self.advancedTab.setVisible(True)
def onLockButtonToggled(self, checked):
if checked:
self.sender().setIcon(self.lockIcon)
else:
self.sender().setIcon(self.unlockIcon)
def onQuickStyleComboBoxChanged(self):
self.settings.layout_style = self.quickStyleComboBox.currentIndex()
self.advancedStyleComboBox.setCurrentIndex(self.settings.layout_style)
self.settings.layoutStyleComboBox.setCurrentIndex(
self.settings.layout_style)
QtCore.QSettings().setValue(
self.settingsSection + u'/verse layout style',
QtCore.QVariant(self.settings.layout_style))
def onAdvancedStyleComboBoxChanged(self):
self.settings.layout_style = self.advancedStyleComboBox.currentIndex()
self.quickStyleComboBox.setCurrentIndex(self.settings.layout_style)
self.settings.layoutStyleComboBox.setCurrentIndex(
self.settings.layout_style)
QtCore.QSettings().setValue(
self.settingsSection + u'/verse layout style',
QtCore.QVariant(self.settings.layout_style))
def onAdvancedVersionComboBox(self):
QtCore.QSettings().setValue(self.settingsSection + u'/advanced bible',
QtCore.QVariant(self.advancedVersionComboBox.currentText()))
@ -537,7 +600,7 @@ class BibleMediaItem(MediaManagerItem):
elif self.search_results:
self.displayResults(bible, second_bible)
self.advancedSearchButton.setEnabled(True)
check_search_result(self.listView, self.search_results)
self.check_search_result()
Receiver.send_message(u'cursor_normal')
Receiver.send_message(u'openlp_process_events')
@ -578,28 +641,10 @@ class BibleMediaItem(MediaManagerItem):
elif self.search_results:
self.displayResults(bible, second_bible)
self.quickSearchButton.setEnabled(True)
check_search_result(self.listView, self.search_results)
self.check_search_result()
Receiver.send_message(u'cursor_normal')
Receiver.send_message(u'openlp_process_events')
def __checkSecondBible(self, bible, second_bible):
"""
Check if the first item is a second bible item or not.
"""
bitem = self.listView.item(0)
item_second_bible = self._decodeQtObject(bitem, 'second_bible')
if item_second_bible and second_bible or not item_second_bible and \
not second_bible:
self.displayResults(bible, second_bible)
elif critical_error_message_box(
message=translate('BiblePlugin.MediaItem',
'You cannot combine single and dual Bible verse search results. '
'Do you want to delete your search results and start a new '
'search?'),
parent=self, question=True) == QtGui.QMessageBox.Yes:
self.listView.clear()
self.displayResults(bible, second_bible)
def displayResults(self, bible, second_bible=u''):
"""
Displays the search results in the media manager. All data needed for
@ -657,15 +702,6 @@ class BibleMediaItem(MediaManagerItem):
self.search_results = {}
self.second_search_results = {}
def _decodeQtObject(self, bitem, key):
reference = bitem.data(QtCore.Qt.UserRole)
if isinstance(reference, QtCore.QVariant):
reference = reference.toPyObject()
obj = reference[QtCore.QString(key)]
if isinstance(obj, QtCore.QVariant):
obj = obj.toPyObject()
return unicode(obj).strip()
def generateSlideData(self, service_item, item=None, xmlVersion=False):
"""
Generates and formats the slides for the service item as well as the
@ -860,11 +896,3 @@ 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

@ -26,7 +26,7 @@
-->
<head>
<meta charset="utf-8" />
<title>OpenLP 2.0 Remote</title>
<title>OpenLP 2.0 Stage View</title>
<link rel="stylesheet" href="/files/stage.css" />
<script type="text/javascript" src="/files/jquery.js"></script>
<script type="text/javascript" src="/files/stage.js"></script>

View File

@ -32,7 +32,7 @@ from PyQt4 import QtCore, QtGui
from sqlalchemy.sql import or_
from openlp.core.lib import MediaManagerItem, Receiver, ItemCapabilities, \
translate, check_item_selected, PluginStatus, check_search_result
translate, check_item_selected, PluginStatus
from openlp.core.lib.searchedit import SearchEdit
from openlp.core.lib.ui import UiStrings
from openlp.plugins.songs.forms import EditSongForm, SongMaintenanceForm, \
@ -199,7 +199,7 @@ class SongMediaItem(MediaManagerItem):
search_results = self.parent.manager.get_all_objects(Song,
Song.theme_name == search_keywords)
self.displayResultsSong(search_results)
check_search_result(self.listView, search_results)
self.check_search_result()
def onSongListLoad(self):
"""