forked from openlp/openlp
Head
This commit is contained in:
commit
4144f9b6a1
@ -72,6 +72,14 @@ 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.sharedDirGroupBox = QtGui.QGroupBox(self.leftColumn)
|
||||
# self.sharedDirGroupBox.setObjectName(u'sharedDirGroupBox')
|
||||
# self.sharedDirLayout = QtGui.QFormLayout(self.sharedDirGroupBox)
|
||||
@ -117,6 +125,10 @@ class AdvancedTab(SettingsTab):
|
||||
'Expand new service items on creation'))
|
||||
self.enableAutoCloseCheckBox.setText(translate('OpenLP.AdvancedTab',
|
||||
'Enable application exit confirmation'))
|
||||
self.hideMouseGroupBox.setTitle(translate('OpenLP.AdvancedTab',
|
||||
'Mouse Cursor'))
|
||||
self.hideMouseCheckBox.setText(translate('OpenLP.AdvancedTab',
|
||||
'Hide the mouse cursor when moved over the display window'))
|
||||
# self.sharedDirGroupBox.setTitle(
|
||||
# translate('AdvancedTab', 'Central Data Store'))
|
||||
# self.sharedCheckBox.setText(
|
||||
@ -150,6 +162,9 @@ class AdvancedTab(SettingsTab):
|
||||
self.enableAutoCloseCheckBox.setChecked(
|
||||
settings.value(u'enable exit confirmation',
|
||||
QtCore.QVariant(True)).toBool())
|
||||
self.hideMouseCheckBox.setChecked(
|
||||
settings.value(u'hide mouse',
|
||||
QtCore.QVariant(False)).toBool())
|
||||
settings.endGroup()
|
||||
|
||||
def save(self):
|
||||
@ -168,6 +183,8 @@ class AdvancedTab(SettingsTab):
|
||||
QtCore.QVariant(self.expandServiceItemCheckBox.isChecked()))
|
||||
settings.setValue(u'enable exit confirmation',
|
||||
QtCore.QVariant(self.enableAutoCloseCheckBox.isChecked()))
|
||||
settings.setValue(u'hide mouse',
|
||||
QtCore.QVariant(self.hideMouseCheckBox.isChecked()))
|
||||
settings.endGroup()
|
||||
|
||||
# def onSharedCheckBoxChanged(self, checked):
|
||||
|
@ -55,6 +55,7 @@ class DisplayWidget(QtGui.QGraphicsView):
|
||||
self.parent = parent
|
||||
self.live = live
|
||||
|
||||
|
||||
class MainDisplay(DisplayWidget):
|
||||
"""
|
||||
This is the display screen.
|
||||
@ -231,6 +232,8 @@ class MainDisplay(DisplayWidget):
|
||||
else:
|
||||
js = u'show_image("");'
|
||||
self.frame.evaluateJavaScript(js)
|
||||
# Update the preview frame.
|
||||
Receiver.send_message(u'maindisplay_active')
|
||||
|
||||
def resetImage(self):
|
||||
"""
|
||||
@ -239,6 +242,8 @@ class MainDisplay(DisplayWidget):
|
||||
"""
|
||||
log.debug(u'resetImage')
|
||||
self.displayImage(self.serviceItem.bg_image_bytes)
|
||||
# Update the preview frame.
|
||||
Receiver.send_message(u'maindisplay_active')
|
||||
|
||||
def resetVideo(self):
|
||||
"""
|
||||
@ -253,6 +258,8 @@ class MainDisplay(DisplayWidget):
|
||||
self.phononActive = False
|
||||
else:
|
||||
self.frame.evaluateJavaScript(u'show_video("close");')
|
||||
# Update the preview frame.
|
||||
Receiver.send_message(u'maindisplay_active')
|
||||
|
||||
def videoPlay(self):
|
||||
"""
|
||||
@ -320,6 +327,8 @@ class MainDisplay(DisplayWidget):
|
||||
self.webView.setVisible(False)
|
||||
self.videoWidget.setVisible(True)
|
||||
self.audio.setVolume(vol)
|
||||
# Update the preview frame.
|
||||
Receiver.send_message(u'maindisplay_active')
|
||||
return self.preview()
|
||||
|
||||
def isLoaded(self):
|
||||
@ -387,6 +396,14 @@ class MainDisplay(DisplayWidget):
|
||||
# if was hidden keep it hidden
|
||||
if self.hideMode and self.isLive:
|
||||
self.hideDisplay(self.hideMode)
|
||||
# Hide mouse cursor when moved over display if enabled in settings
|
||||
settings = QtCore.QSettings()
|
||||
if settings.value(u'advanced/hide mouse', QtCore.QVariant(False)).toBool():
|
||||
self.setCursor(QtCore.Qt.BlankCursor)
|
||||
self.frame.evaluateJavaScript('document.body.style.cursor = "none"')
|
||||
else:
|
||||
self.setCursor(QtCore.Qt.ArrowCursor)
|
||||
self.frame.evaluateJavaScript('document.body.style.cursor = "auto"')
|
||||
|
||||
def footer(self, text):
|
||||
"""
|
||||
@ -436,6 +453,7 @@ class MainDisplay(DisplayWidget):
|
||||
# Trigger actions when display is active again
|
||||
Receiver.send_message(u'maindisplay_active')
|
||||
|
||||
|
||||
class AudioPlayer(QtCore.QObject):
|
||||
"""
|
||||
This Class will play audio only allowing components to work with a
|
||||
|
@ -187,12 +187,15 @@ class ImageMediaItem(MediaManagerItem):
|
||||
return False
|
||||
|
||||
def onResetClick(self):
|
||||
"""
|
||||
Called to reset the Live backgound with the image selected,
|
||||
"""
|
||||
self.resetAction.setVisible(False)
|
||||
self.parent.liveController.display.resetImage()
|
||||
|
||||
def onReplaceClick(self):
|
||||
"""
|
||||
Called to replace Live backgound with the video selected
|
||||
Called to replace Live backgound with the image selected.
|
||||
"""
|
||||
if check_item_selected(self.listView,
|
||||
translate('ImagePlugin.MediaItem',
|
||||
|
@ -40,6 +40,7 @@ class MediaListView(BaseListWithDnD):
|
||||
self.PluginName = u'Media'
|
||||
BaseListWithDnD.__init__(self, parent)
|
||||
|
||||
|
||||
class MediaMediaItem(MediaManagerItem):
|
||||
"""
|
||||
This is the custom media manager item for Media Slides.
|
||||
@ -92,10 +93,16 @@ class MediaMediaItem(MediaManagerItem):
|
||||
self.resetAction.setVisible(False)
|
||||
|
||||
def onResetClick(self):
|
||||
"""
|
||||
Called to reset the Live backgound with the media selected,
|
||||
"""
|
||||
self.resetAction.setVisible(False)
|
||||
self.parent.liveController.display.resetVideo()
|
||||
|
||||
def onReplaceClick(self):
|
||||
"""
|
||||
Called to replace Live backgound with the media selected.
|
||||
"""
|
||||
if check_item_selected(self.listView,
|
||||
translate('MediaPlugin.MediaItem',
|
||||
'You must select a media file to replace the background with.')):
|
||||
|
@ -332,7 +332,7 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog):
|
||||
else:
|
||||
author = Author.populate(first_name=text.rsplit(u' ', 1)[0],
|
||||
last_name=text.rsplit(u' ', 1)[1], display_name=text)
|
||||
self.manager.save_object(author, False)
|
||||
self.manager.save_object(author)
|
||||
author_item = QtGui.QListWidgetItem(
|
||||
unicode(author.display_name))
|
||||
author_item.setData(QtCore.Qt.UserRole,
|
||||
@ -386,7 +386,7 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog):
|
||||
QtGui.QMessageBox.Yes | QtGui.QMessageBox.No,
|
||||
QtGui.QMessageBox.Yes) == QtGui.QMessageBox.Yes:
|
||||
topic = Topic.populate(name=text)
|
||||
self.manager.save_object(topic, False)
|
||||
self.manager.save_object(topic)
|
||||
topic_item = QtGui.QListWidgetItem(unicode(topic.name))
|
||||
topic_item.setData(QtCore.Qt.UserRole,
|
||||
QtCore.QVariant(topic.id))
|
||||
@ -524,12 +524,13 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog):
|
||||
|
||||
def _validate_song(self):
|
||||
"""
|
||||
Check the validity of the form. Only display the 'save' if the data
|
||||
can be saved.
|
||||
Check the validity of the song.
|
||||
"""
|
||||
# This checks data in the form *not* self.song. self.song is still
|
||||
# None at this point.
|
||||
log.debug(u'Validate Song')
|
||||
# Lets be nice and assume the data is correct.
|
||||
if len(self.titleEdit.displayText()) == 0:
|
||||
if not self.titleEdit.text():
|
||||
self.songTabWidget.setCurrentIndex(0)
|
||||
self.titleEdit.setFocus()
|
||||
criticalErrorMessageBox(
|
||||
@ -550,9 +551,9 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog):
|
||||
message=translate('SongsPlugin.EditSongForm',
|
||||
'You need to have an author for this song.'))
|
||||
return False
|
||||
if self.song.verse_order:
|
||||
if self.verseOrderEdit.text():
|
||||
order = []
|
||||
order_names = self.song.verse_order.split()
|
||||
order_names = self.verseOrderEdit.text().split()
|
||||
for item in order_names:
|
||||
if len(item) == 1:
|
||||
order.append(item.lower() + u'1')
|
||||
@ -593,6 +594,19 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog):
|
||||
QtGui.QMessageBox.Yes | QtGui.QMessageBox.No)
|
||||
if answer == QtGui.QMessageBox.No:
|
||||
return False
|
||||
item = int(self.songBookComboBox.currentIndex())
|
||||
text = unicode(self.songBookComboBox.currentText())
|
||||
if self.songBookComboBox.findText(text, QtCore.Qt.MatchExactly) < 0:
|
||||
if QtGui.QMessageBox.question(self,
|
||||
translate('SongsPlugin.EditSongForm', 'Add Book'),
|
||||
translate('SongsPlugin.EditSongForm', 'This song book does '
|
||||
'not exist, do you want to add it?'),
|
||||
QtGui.QMessageBox.Yes | QtGui.QMessageBox.No,
|
||||
QtGui.QMessageBox.Yes) == QtGui.QMessageBox.Yes:
|
||||
book = Book.populate(name=text, publisher=u'')
|
||||
self.manager.save_object(book)
|
||||
else:
|
||||
return False
|
||||
return True
|
||||
|
||||
def onCopyrightInsertButtonTriggered(self):
|
||||
@ -653,33 +667,25 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog):
|
||||
"""
|
||||
log.debug(u'accept')
|
||||
self.clearCaches()
|
||||
if not self.song:
|
||||
self.song = Song()
|
||||
item = int(self.songBookComboBox.currentIndex())
|
||||
text = unicode(self.songBookComboBox.currentText())
|
||||
if self.songBookComboBox.findText(text, QtCore.Qt.MatchExactly) < 0:
|
||||
if QtGui.QMessageBox.question(self,
|
||||
translate('SongsPlugin.EditSongForm', 'Add Book'),
|
||||
translate('SongsPlugin.EditSongForm', 'This song book does '
|
||||
'not exist, do you want to add it?'),
|
||||
QtGui.QMessageBox.Yes | QtGui.QMessageBox.No,
|
||||
QtGui.QMessageBox.Yes) == QtGui.QMessageBox.Yes:
|
||||
book = Book.populate(name=text, publisher=u'')
|
||||
self.manager.save_object(book, False)
|
||||
else:
|
||||
return
|
||||
if self.saveSong():
|
||||
if self._validate_song():
|
||||
self.saveSong()
|
||||
Receiver.send_message(u'songs_load_list')
|
||||
self.close()
|
||||
|
||||
def saveSong(self, preview=False):
|
||||
"""
|
||||
Get all the data from the widgets on the form, and then save it to the
|
||||
database.
|
||||
database. The form has been validated and all reference items
|
||||
(Authors, Books and Topics) have been saved before this function is
|
||||
called.
|
||||
|
||||
``preview``
|
||||
Should be ``True`` if the song is also previewed (boolean).
|
||||
"""
|
||||
# The Song() assignment. No database calls should be made while a
|
||||
# Song() is in a partially complete state.
|
||||
if not self.song:
|
||||
self.song = Song()
|
||||
self.song.title = unicode(self.titleEdit.text())
|
||||
self.song.alternate_title = unicode(self.alternativeEdit.text())
|
||||
self.song.copyright = unicode(self.copyrightEdit.text())
|
||||
@ -703,27 +709,27 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog):
|
||||
self.song.theme_name = theme_name
|
||||
else:
|
||||
self.song.theme_name = None
|
||||
if self._validate_song():
|
||||
self.processLyrics()
|
||||
self.processTitle()
|
||||
self.song.authors = []
|
||||
for row in range(self.authorsListView.count()):
|
||||
item = self.authorsListView.item(row)
|
||||
authorId = (item.data(QtCore.Qt.UserRole)).toInt()[0]
|
||||
self.song.authors.append(self.manager.get_object(Author,
|
||||
authorId))
|
||||
self.song.topics = []
|
||||
for row in range(self.topicsListView.count()):
|
||||
item = self.topicsListView.item(row)
|
||||
topicId = (item.data(QtCore.Qt.UserRole)).toInt()[0]
|
||||
self.song.topics.append(self.manager.get_object(Topic, topicId))
|
||||
self.manager.save_object(self.song)
|
||||
if not preview:
|
||||
self.song = None
|
||||
return True
|
||||
return False
|
||||
self.processLyrics()
|
||||
self.processTitle()
|
||||
self.song.authors = []
|
||||
for row in range(self.authorsListView.count()):
|
||||
item = self.authorsListView.item(row)
|
||||
authorId = (item.data(QtCore.Qt.UserRole)).toInt()[0]
|
||||
self.song.authors.append(self.manager.get_object(Author, authorId))
|
||||
self.song.topics = []
|
||||
for row in range(self.topicsListView.count()):
|
||||
item = self.topicsListView.item(row)
|
||||
topicId = (item.data(QtCore.Qt.UserRole)).toInt()[0]
|
||||
self.song.topics.append(self.manager.get_object(Topic, topicId))
|
||||
self.manager.save_object(self.song)
|
||||
if not preview:
|
||||
self.song = None
|
||||
|
||||
def processLyrics(self):
|
||||
"""
|
||||
Process the lyric data entered by the user into the OpenLP XML format.
|
||||
"""
|
||||
# This method must only be run after the self.song = Song() assignment.
|
||||
log.debug(u'processLyrics')
|
||||
try:
|
||||
sxml = SongXML()
|
||||
@ -749,6 +755,11 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog):
|
||||
sxml.dump_xml())
|
||||
|
||||
def processTitle(self):
|
||||
"""
|
||||
Process the song title entered by the user to remove stray punctuation
|
||||
characters.
|
||||
"""
|
||||
# This method must only be run after the self.song = Song() assignment.
|
||||
log.debug(u'processTitle')
|
||||
self.song.search_title = re.sub(r'[\'"`,;:(){}?]+', u'',
|
||||
unicode(self.song.search_title)).lower()
|
||||
|
@ -72,7 +72,7 @@ def init_schema(url):
|
||||
``url``
|
||||
The database to setup
|
||||
"""
|
||||
session, metadata = init_db(url, False)
|
||||
session, metadata = init_db(url)
|
||||
|
||||
# Definition of the "authors" table
|
||||
authors_table = Table(u'authors', metadata,
|
||||
|
Loading…
Reference in New Issue
Block a user