This commit is contained in:
rimach 2011-11-11 17:47:26 +01:00
commit 7077d5cda6
3 changed files with 188 additions and 8 deletions

View File

@ -29,6 +29,7 @@ The :mod:`db` module provides the core database functionality for OpenLP
""" """
import logging import logging
import os import os
from urllib import quote_plus as urlquote
from PyQt4 import QtCore from PyQt4 import QtCore
from sqlalchemy import Table, MetaData, Column, types, create_engine from sqlalchemy import Table, MetaData, Column, types, create_engine
@ -193,10 +194,10 @@ class Manager(object):
AppLocation.get_section_data_path(plugin_name), plugin_name) AppLocation.get_section_data_path(plugin_name), plugin_name)
else: else:
self.db_url = u'%s://%s:%s@%s/%s' % (db_type, self.db_url = u'%s://%s:%s@%s/%s' % (db_type,
unicode(settings.value(u'db username').toString()), urlquote(unicode(settings.value(u'db username').toString())),
unicode(settings.value(u'db password').toString()), urlquote(unicode(settings.value(u'db password').toString())),
unicode(settings.value(u'db hostname').toString()), urlquote(unicode(settings.value(u'db hostname').toString())),
unicode(settings.value(u'db database').toString())) urlquote(unicode(settings.value(u'db database').toString())))
settings.endGroup() settings.endGroup()
if upgrade_mod: if upgrade_mod:
db_ver, up_ver = upgrade_db(self.db_url, upgrade_mod) db_ver, up_ver = upgrade_db(self.db_url, upgrade_mod)

View File

@ -250,7 +250,12 @@ class Renderer(object):
# render the first virtual slide. # render the first virtual slide.
text_contains_break = u'[---]' in text text_contains_break = u'[---]' in text
if text_contains_break: if text_contains_break:
text_to_render, text = text.split(u'\n[---]\n', 1) try:
text_to_render, text = \
text.split(u'\n[---]\n', 1)
except:
text_to_render = text.split(u'\n[---]\n')[0]
text = u''
else: else:
text_to_render = text text_to_render = text
text = u'' text = u''

View File

@ -311,6 +311,94 @@ class SlideController(Controller):
self.slidePreview.setObjectName(u'slidePreview') self.slidePreview.setObjectName(u'slidePreview')
self.slideLayout.insertWidget(0, self.slidePreview) self.slideLayout.insertWidget(0, self.slidePreview)
self.grid.addLayout(self.slideLayout, 0, 0, 1, 1) self.grid.addLayout(self.slideLayout, 0, 0, 1, 1)
if self.isLive:
self.current_shortcut = u''
self.shortcutTimer = QtCore.QTimer()
self.shortcutTimer.setObjectName(u'shortcutTimer')
self.shortcutTimer.setSingleShot(True)
self.verseShortcut = shortcut_action(self, u'verseShortcut',
[QtGui.QKeySequence(u'V')], self.slideShortcutActivated,
category=UiStrings().LiveToolbar,
context=QtCore.Qt.WidgetWithChildrenShortcut)
self.verseShortcut.setText(translate(
'OpenLP.SlideController', 'Go to "Verse"'))
self.shortcut0 = shortcut_action(self, u'0',
[QtGui.QKeySequence(u'0')], self.slideShortcutActivated,
context=QtCore.Qt.WidgetWithChildrenShortcut)
self.shortcut1 = shortcut_action(self, u'1',
[QtGui.QKeySequence(u'1')], self.slideShortcutActivated,
context=QtCore.Qt.WidgetWithChildrenShortcut)
self.shortcut2 = shortcut_action(self, u'2',
[QtGui.QKeySequence(u'2')], self.slideShortcutActivated,
context=QtCore.Qt.WidgetWithChildrenShortcut)
self.shortcut3 = shortcut_action(self, u'3',
[QtGui.QKeySequence(u'3')], self.slideShortcutActivated,
context=QtCore.Qt.WidgetWithChildrenShortcut)
self.shortcut4 = shortcut_action(self, u'4',
[QtGui.QKeySequence(u'4')], self.slideShortcutActivated,
context=QtCore.Qt.WidgetWithChildrenShortcut)
self.shortcut5 = shortcut_action(self, u'5',
[QtGui.QKeySequence(u'5')], self.slideShortcutActivated,
context=QtCore.Qt.WidgetWithChildrenShortcut)
self.shortcut6 = shortcut_action(self, u'6',
[QtGui.QKeySequence(u'6')], self.slideShortcutActivated,
context=QtCore.Qt.WidgetWithChildrenShortcut)
self.shortcut7 = shortcut_action(self, u'7',
[QtGui.QKeySequence(u'7')], self.slideShortcutActivated,
context=QtCore.Qt.WidgetWithChildrenShortcut)
self.shortcut8 = shortcut_action(self, u'8',
[QtGui.QKeySequence(u'8')], self.slideShortcutActivated,
context=QtCore.Qt.WidgetWithChildrenShortcut)
self.shortcut9 = shortcut_action(self, u'9',
[QtGui.QKeySequence(u'9')], self.slideShortcutActivated,
context=QtCore.Qt.WidgetWithChildrenShortcut)
self.chorusShortcut = shortcut_action(self, u'chorusShortcut',
[QtGui.QKeySequence(u'C')], self.slideShortcutActivated,
category=UiStrings().LiveToolbar,
context=QtCore.Qt.WidgetWithChildrenShortcut)
self.chorusShortcut.setText(translate(
'OpenLP.SlideController', 'Go to "Chorus"'))
self.bridgeShortcut = shortcut_action(self, u'bridgeShortcut',
[QtGui.QKeySequence(u'B')], self.slideShortcutActivated,
category=UiStrings().LiveToolbar,
context=QtCore.Qt.WidgetWithChildrenShortcut)
self.bridgeShortcut.setText(translate(
'OpenLP.SlideController', 'Go to "Bridge"'))
self.preChorusShortcut = shortcut_action(self, u'preChorusShortcut',
[QtGui.QKeySequence(u'P')], self.slideShortcutActivated,
category=UiStrings().LiveToolbar,
context=QtCore.Qt.WidgetWithChildrenShortcut)
self.preChorusShortcut.setText(translate(
'OpenLP.SlideController', 'Go to "Pre-Chorus"'))
self.introShortcut = shortcut_action(self, u'introShortcut',
[QtGui.QKeySequence(u'I')], self.slideShortcutActivated,
category=UiStrings().LiveToolbar,
context=QtCore.Qt.WidgetWithChildrenShortcut)
self.introShortcut.setText(translate(
'OpenLP.SlideController', 'Go to "Intro"'))
self.endingShortcut = shortcut_action(self, u'endingShortcut',
[QtGui.QKeySequence(u'E')], self.slideShortcutActivated,
category=UiStrings().LiveToolbar,
context=QtCore.Qt.WidgetWithChildrenShortcut)
self.endingShortcut.setText(translate(
'OpenLP.SlideController', 'Go to "Ending"'))
self.otherShortcut = shortcut_action(self, u'otherShortcut',
[QtGui.QKeySequence(u'O')], self.slideShortcutActivated,
category=UiStrings().LiveToolbar,
context=QtCore.Qt.WidgetWithChildrenShortcut)
self.otherShortcut.setText(translate(
'OpenLP.SlideController', 'Go to "Other"'))
self.previewListWidget.addActions([
self.shortcut0, self.shortcut1, self.shortcut2, self.shortcut3,
self.shortcut4, self.shortcut5, self.shortcut6, self.shortcut7,
self.shortcut8, self.shortcut9, self.verseShortcut,
self.chorusShortcut, self.bridgeShortcut,
self.preChorusShortcut, self.introShortcut, self.endingShortcut,
self.otherShortcut
])
QtCore.QObject.connect(
self.shortcutTimer, QtCore.SIGNAL(u'timeout()'),
self.slideShortcutActivated)
# Signals # Signals
QtCore.QObject.connect(self.previewListWidget, QtCore.QObject.connect(self.previewListWidget,
QtCore.SIGNAL(u'clicked(QModelIndex)'), self.onSlideSelected) QtCore.SIGNAL(u'clicked(QModelIndex)'), self.onSlideSelected)
@ -354,6 +442,90 @@ class SlideController(Controller):
QtCore.SIGNAL(u'slidecontroller_%s_unblank' % self.typePrefix), QtCore.SIGNAL(u'slidecontroller_%s_unblank' % self.typePrefix),
self.onSlideUnblank) self.onSlideUnblank)
def slideShortcutActivated(self):
"""
Called, when a shortcut has been activated to jump to a chorus, verse,
etc.
**Note**: This implementation is based on shortcuts. But it rather works
like "key sequenes". You have to press one key after the other and
**not** at the same time.
For example to jump to "V3" you have to press "V" and afterwards but
within a time frame of 350ms you have to press "3".
"""
try:
from openlp.plugins.songs.lib import VerseType
SONGS_PLUGIN_AVAILABLE = True
except ImportError:
SONGS_PLUGIN_AVAILABLE = False
verse_type = unicode(self.sender().objectName())
if verse_type.startswith(u'verseShortcut'):
if SONGS_PLUGIN_AVAILABLE:
self.current_shortcut = \
VerseType.TranslatedTags[VerseType.Verse]
else:
self.current_shortcut = u'V'
elif verse_type.startswith(u'chorusShortcut'):
if SONGS_PLUGIN_AVAILABLE:
self.current_shortcut = \
VerseType.TranslatedTags[VerseType.Chorus]
else:
self.current_shortcut = u'C'
elif verse_type.startswith(u'bridgeShortcut'):
if SONGS_PLUGIN_AVAILABLE:
self.current_shortcut = \
VerseType.TranslatedTags[VerseType.Bridge]
else:
self.current_shortcut = u'B'
elif verse_type.startswith(u'preChorusShortcut'):
if SONGS_PLUGIN_AVAILABLE:
self.current_shortcut = \
VerseType.TranslatedTags[VerseType.PreChorus]
else:
self.current_shortcut = u'P'
elif verse_type.startswith(u'introShortcut'):
if SONGS_PLUGIN_AVAILABLE:
self.current_shortcut = \
VerseType.TranslatedTags[VerseType.Intro]
else:
self.current_shortcut = u'I'
elif verse_type.startswith(u'endingShortcut'):
if SONGS_PLUGIN_AVAILABLE:
self.current_shortcut = \
VerseType.TranslatedTags[VerseType.Ending]
else:
self.current_shortcut = u'E'
elif verse_type.startswith(u'otherShortcut'):
if SONGS_PLUGIN_AVAILABLE:
self.current_shortcut = \
VerseType.TranslatedTags[VerseType.Other]
else:
self.current_shortcut = u'O'
elif verse_type.isnumeric():
self.current_shortcut += verse_type
self.current_shortcut = self.current_shortcut.upper()
keys = self.slideList.keys()
matches = [match for match in keys
if match.startswith(self.current_shortcut)]
if len(matches) == 1:
self.shortcutTimer.stop()
self.current_shortcut = u''
self.__checkUpdateSelectedSlide(self.slideList[matches[0]])
self.slideSelected()
elif verse_type != u'shortcutTimer':
# Start the time as we did not have any match.
self.shortcutTimer.start(350)
else:
# The timer timed out.
if self.current_shortcut in keys:
# We had more than one match for example "V1" and "V10", but
# "V1" was the slide we wanted to go.
self.__checkUpdateSelectedSlide(
self.slideList[self.current_shortcut])
self.slideSelected()
# Reset the shortcut.
self.current_shortcut = u''
def setPreviewHotkeys(self, parent=None): def setPreviewHotkeys(self, parent=None):
self.previousItem.setObjectName(u'previousItemPreview') self.previousItem.setObjectName(u'previousItemPreview')
self.nextItem.setObjectName(u'nextItemPreview') self.nextItem.setObjectName(u'nextItemPreview')
@ -647,13 +819,14 @@ class SlideController(Controller):
verse_def = u'%s%s' % (verse_def[0], verse_def[1:]) verse_def = u'%s%s' % (verse_def[0], verse_def[1:])
two_line_def = u'%s\n%s' % (verse_def[0], verse_def[1:]) two_line_def = u'%s\n%s' % (verse_def[0], verse_def[1:])
row = two_line_def row = two_line_def
if self.isLive:
if verse_def not in self.slideList: if verse_def not in self.slideList:
self.slideList[verse_def] = framenumber self.slideList[verse_def] = framenumber
if self.isLive:
self.songMenu.menu().addAction(verse_def, self.songMenu.menu().addAction(verse_def,
self.onSongBarHandler) self.onSongBarHandler)
else: else:
row += 1 row += 1
self.slideList[unicode(row)] = row - 1
item.setText(frame[u'text']) item.setText(frame[u'text'])
else: else:
label = QtGui.QLabel() label = QtGui.QLabel()
@ -671,6 +844,7 @@ class SlideController(Controller):
self.previewListWidget.setCellWidget(framenumber, 0, label) self.previewListWidget.setCellWidget(framenumber, 0, label)
slideHeight = width * self.parent().renderer.screen_ratio slideHeight = width * self.parent().renderer.screen_ratio
row += 1 row += 1
self.slideList[unicode(row)] = row - 1
text.append(unicode(row)) text.append(unicode(row))
self.previewListWidget.setItem(framenumber, 0, item) self.previewListWidget.setItem(framenumber, 0, item)
if slideHeight != 0: if slideHeight != 0: