Set the value in the verse number spinbox to the next expected verse number to be inserted.

This commit is contained in:
Erik Lundin 2012-09-09 23:07:07 +02:00
commit b186a4f4ed
5 changed files with 48 additions and 72 deletions

View File

@ -365,7 +365,7 @@ class Renderer(object):
The theme information
"""
if not theme_data.font_main_override:
return QtCore.QRect(10, 0, self.width, self.footer_start)
return QtCore.QRect(10, 0, self.width - 20, self.footer_start)
else:
return QtCore.QRect(theme_data.font_main_x, theme_data.font_main_y,
theme_data.font_main_width - 1, theme_data.font_main_height - 1)

View File

@ -287,7 +287,7 @@ class MediaController(object):
"""
player.resize(display)
def video(self, controller, file, muted, isBackground):
def video(self, controller, file, muted, isBackground, hidden=False):
"""
Loads and starts a video to run with the option of sound
"""
@ -333,11 +333,19 @@ class MediaController(object):
if controller.isLive and not controller.media_info.is_background:
display.frame.evaluateJavaScript(u'show_video( \
"setBackBoard", null, null, null,"visible");')
# now start playing
if controller.isLive and \
(Settings().value(u'general/auto unblank',
QtCore.QVariant(False)).toBool() or \
controller.media_info.is_background) or not controller.isLive:
# now start playing - Preview is autoplay!
autoplay = False
# Preview requested
if not controller.isLive:
autoplay = True
# Visible or background requested
elif not hidden or controller.media_info.is_background:
autoplay = True
# Unblank on load set
elif Settings().value(u'general/auto unblank',
QtCore.QVariant(False)).toBool():
autoplay = True
if autoplay:
if not self.video_play([controller]):
critical_error_message_box(
translate('MediaPlugin.MediaItem', 'Unsupported File'),

View File

@ -63,37 +63,32 @@ if VLC_AVAILABLE:
VLC_AVAILABLE = False
log.debug(u'VLC could not be loaded: %s' % version)
AUDIO_EXT = [
u'*.mp3'
, u'*.wav'
, u'*.wma'
, u'*.ogg'
]
AUDIO_EXT = [u'*.mp3', u'*.wav', u'*.wma', u'*.ogg']
VIDEO_EXT = [
u'*.3gp'
, u'*.asf', u'*.wmv'
, u'*.au'
, u'*.avi'
, u'*.flv'
, u'*.mov'
, u'*.mp4'
, u'*.ogm'
, u'*.mkv', u'*.mka'
, u'*.ts', u'*.mpg'
, u'*.mpg', u'*.mp2'
, u'*.nsc'
, u'*.nsv'
, u'*.nut'
, u'*.ra', u'*.ram', u'*.rm', u'*.rv' ,u'*.rmbv'
, u'*.a52', u'*.dts', u'*.aac', u'*.flac' ,u'*.dv', u'*.vid'
, u'*.tta', u'*.tac'
, u'*.ty'
, u'*.dts'
, u'*.xa'
, u'*.iso'
, u'*.vob'
]
u'*.3gp',
u'*.asf', u'*.wmv',
u'*.au',
u'*.avi',
u'*.flv',
u'*.mov',
u'*.mp4',
u'*.ogm', u'*.ogv',
u'*.mkv', u'*.mka',
u'*.ts', u'*.mpg',
u'*.mpg', u'*.mp2',
u'*.nsc',
u'*.nsv',
u'*.nut',
u'*.ra', u'*.ram', u'*.rm', u'*.rv' ,u'*.rmbv',
u'*.a52', u'*.dts', u'*.aac', u'*.flac' ,u'*.dv', u'*.vid',
u'*.tta', u'*.tac',
u'*.ty',
u'*.dts',
u'*.xa',
u'*.iso',
u'*.vob'
]
class VlcPlayer(MediaPlayer):

View File

@ -1347,7 +1347,7 @@ class SlideController(Controller):
"""
log.debug(u'SlideController onMediaStart')
file = os.path.join(item.get_frame_path(), item.get_frame_title())
self.mediaController.video(self, file, False, False)
self.mediaController.video(self, file, False, False, self.hideMode())
if not self.isLive or self.mediaController.withLivePreview:
self.previewDisplay.show()
self.slidePreview.hide()

View File

@ -92,6 +92,12 @@ class EditVerseForm(QtGui.QDialog, Ui_EditVerseDialog):
self.verseNumberBox.value())
def onVerseTypeComboBoxChanged(self):
self.updateSuggestedVerseNumber()
def onCursorPositionChanged(self):
self.updateSuggestedVerseNumber()
def updateSuggestedVerseNumber(self):
"""
Adjusts the verse number SpinBox in regard to the selected verse type
and the cursor's position.
@ -115,43 +121,10 @@ class EditVerseForm(QtGui.QDialog, Ui_EditVerseDialog):
if match:
verse_tag = match.group(1)
try:
verse_num = int(match.group(2))
verse_num = int(match.group(2)) + 1
except ValueError:
verse_num = 1
if VerseType.from_loose_input(verse_tag, False):
self.verseNumberBox.setValue(verse_num)
def onCursorPositionChanged(self):
"""
Determines the previous verse type and number in regard to the cursor's
position and adjusts the ComboBox and SpinBox to these values.
"""
position = self.verseTextEdit.textCursor().position()
text = unicode(self.verseTextEdit.toPlainText())
if not text:
return
if text.rfind(u'[', 0, position) > text.rfind(u']', 0, position) and \
text.find(u']', position) < text.find(u'[', position):
return
position = text.rfind(u'---[', 0, position)
if position == -1:
return
text = text[position:]
position = text.find(u']---')
if position == -1:
return
text = text[:position + 4]
match = VERSE_REGEX.match(text)
if match:
verse_type = match.group(1)
verse_type_index = VerseType.from_loose_input(verse_type, None)
try:
verse_number = int(match.group(2))
except ValueError:
verse_number = 1
if verse_type_index is not None:
self.verseTypeComboBox.setCurrentIndex(verse_type_index)
self.verseNumberBox.setValue(verse_number)
self.verseNumberBox.setValue(verse_num)
def setVerse(self, text, single=False,
tag=u'%s1' % VerseType.Tags[VerseType.Verse]):