From b603017b1c43c86b77fd6d91b27e5119c4493a66 Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Sun, 23 Oct 2011 19:47:15 +0200 Subject: [PATCH 01/17] started work on shortcuts allowing jumping between different verses Fixes: https://launchpad.net/bugs/827862 --- openlp/core/lib/ui.py | 1 + openlp/core/ui/slidecontroller.py | 104 +++++++++++++++++++++++++++++- 2 files changed, 102 insertions(+), 3 deletions(-) diff --git a/openlp/core/lib/ui.py b/openlp/core/lib/ui.py index 756df36c3..2e9669e89 100644 --- a/openlp/core/lib/ui.py +++ b/openlp/core/lib/ui.py @@ -105,6 +105,7 @@ class UiStrings(object): self.PlaySlidesInLoop = translate('OpenLP.Ui','Play Slides in Loop') self.PlaySlidesToEnd = translate('OpenLP.Ui','Play Slides to End') self.Preview = translate('OpenLP.Ui', 'Preview') + self.PreviewToolbar = translate('OpenLP.Ui', 'Preview Toolbar') self.PrintService = translate('OpenLP.Ui', 'Print Service') self.ReplaceBG = translate('OpenLP.Ui', 'Replace Background') self.ReplaceLiveBG = translate('OpenLP.Ui', 'Replace live background.') diff --git a/openlp/core/ui/slidecontroller.py b/openlp/core/ui/slidecontroller.py index 97c30436e..8b2409039 100644 --- a/openlp/core/ui/slidecontroller.py +++ b/openlp/core/ui/slidecontroller.py @@ -321,6 +321,78 @@ class SlideController(QtGui.QWidget): self.slidePreview.setObjectName(u'slidePreview') self.slideLayout.insertWidget(0, self.slidePreview) self.grid.addLayout(self.slideLayout, 0, 0, 1, 1) + self.verseShortcut1 = shortcut_action(self, 'verseShortcut1', + [QtGui.QKeySequence(u'V'), QtGui.QKeySequence(u'1')], + self.slideShortcutActivated, category=UiStrings().LiveToolbar if self.isLive else UiStrings().PreviewToolbar, + context=QtCore.Qt.WidgetWithChildrenShortcut) + self.verseShortcut2 = shortcut_action(self, 'verseShortcut2', + [QtGui.QKeySequence(u'2')], self.slideShortcutActivated, + category=UiStrings().LiveToolbar if self.isLive else UiStrings().PreviewToolbar, + context=QtCore.Qt.WidgetWithChildrenShortcut) + self.verseShortcut3 = shortcut_action(self, 'verseShortcut3', + [QtGui.QKeySequence(u'3')], self.slideShortcutActivated, + category=UiStrings().LiveToolbar if self.isLive else UiStrings().PreviewToolbar, + context=QtCore.Qt.WidgetWithChildrenShortcut) + self.verseShortcut4 = shortcut_action(self, 'verseShortcut4', + [QtGui.QKeySequence(u'4')], self.slideShortcutActivated, + category=UiStrings().LiveToolbar if self.isLive else UiStrings().PreviewToolbar, + context=QtCore.Qt.WidgetWithChildrenShortcut) + self.verseShortcut5 = shortcut_action(self, 'verseShortcut5', + [QtGui.QKeySequence(u'5')], self.slideShortcutActivated, + category=UiStrings().LiveToolbar if self.isLive else UiStrings().PreviewToolbar, + context=QtCore.Qt.WidgetWithChildrenShortcut) + self.verseShortcut6 = shortcut_action(self, 'verseShortcut6', + [QtGui.QKeySequence(u'6')], self.slideShortcutActivated, + category=UiStrings().LiveToolbar if self.isLive else UiStrings().PreviewToolbar, + context=QtCore.Qt.WidgetWithChildrenShortcut) + self.verseShortcut7 = shortcut_action(self, 'verseShortcut7', + [QtGui.QKeySequence(u'7')], self.slideShortcutActivated, + category=UiStrings().LiveToolbar if self.isLive else UiStrings().PreviewToolbar, + context=QtCore.Qt.WidgetWithChildrenShortcut) + self.verseShortcut8 = shortcut_action(self, 'verseShortcut8', + [QtGui.QKeySequence(u'8')], self.slideShortcutActivated, + category=UiStrings().LiveToolbar if self.isLive else UiStrings().PreviewToolbar, + context=QtCore.Qt.WidgetWithChildrenShortcut) + self.verseShortcut9 = shortcut_action(self, 'verseShortcut9', + [QtGui.QKeySequence(u'9')], self.slideShortcutActivated, + category=UiStrings().LiveToolbar if self.isLive else UiStrings().PreviewToolbar, + context=QtCore.Qt.WidgetWithChildrenShortcut) + self.verseShortcut10 = shortcut_action(self, 'verseShortcut10', + [QtGui.QKeySequence(u'0')], self.slideShortcutActivated, + category=UiStrings().LiveToolbar if self.isLive else UiStrings().PreviewToolbar, + context=QtCore.Qt.WidgetWithChildrenShortcut) + self.chorusShortcut = shortcut_action(self, 'chorusShortcut', + [QtGui.QKeySequence(u'C')], self.slideShortcutActivated, + category=UiStrings().LiveToolbar if self.isLive else UiStrings().PreviewToolbar, + context=QtCore.Qt.WidgetWithChildrenShortcut) + self.bridgeShortcut = shortcut_action(self, 'bridgeShortcut', + [QtGui.QKeySequence(u'B')], self.slideShortcutActivated, + category=UiStrings().LiveToolbar if self.isLive else UiStrings().PreviewToolbar, + context=QtCore.Qt.WidgetWithChildrenShortcut) + self.preChorusShortcut = shortcut_action(self, 'preChorusShortcut', + [QtGui.QKeySequence(u'P')], self.slideShortcutActivated, + category=UiStrings().LiveToolbar if self.isLive else UiStrings().PreviewToolbar, + context=QtCore.Qt.WidgetWithChildrenShortcut) + self.introShortcut = shortcut_action(self, 'introShortcut', + [QtGui.QKeySequence(u'I')], self.slideShortcutActivated, + category=UiStrings().LiveToolbar if self.isLive else UiStrings().PreviewToolbar, + context=QtCore.Qt.WidgetWithChildrenShortcut) + self.endingShortcut = shortcut_action(self, 'endingShortcut', + [QtGui.QKeySequence(u'E')], self.slideShortcutActivated, + category=UiStrings().LiveToolbar if self.isLive else UiStrings().PreviewToolbar, + context=QtCore.Qt.WidgetWithChildrenShortcut) + self.otherShortcut = shortcut_action(self, 'otherShortcut', + [QtGui.QKeySequence(u'O')], self.slideShortcutActivated, + category=UiStrings().LiveToolbar if self.isLive else UiStrings().PreviewToolbar, + context=QtCore.Qt.WidgetWithChildrenShortcut) + self.previewListWidget.addActions([ + self.verseShortcut1, self.verseShortcut2, self.verseShortcut3, + self.verseShortcut4, self.verseShortcut5, self.verseShortcut6, + self.verseShortcut7, self.verseShortcut8, self.verseShortcut9, + self.verseShortcut10, self.chorusShortcut, self.bridgeShortcut, + self.preChorusShortcut, self.introShortcut, self.endingShortcut, + self.otherShortcut + ]) # Signals QtCore.QObject.connect(self.previewListWidget, QtCore.SIGNAL(u'clicked(QModelIndex)'), self.onSlideSelected) @@ -367,6 +439,32 @@ class SlideController(QtGui.QWidget): QtCore.SIGNAL(u'slidecontroller_%s_unblank' % self.typePrefix), self.onSlideUnblank) + def slideShortcutActivated(self): + """ + Called, when a shortcut + """ + verse_type = unicode(self.sender().objectName()) + keys = self.slideList.keys() + key = u'' + if verse_type.startswith(u'verseShortcut'): + key = u'V%s' % verse_type[13:] + elif verse_type == u'chorusShortcut': + key = u'C1' + elif verse_type == u'bridgeShortcut': + key = u'B1' + elif verse_type == u'preChorusShortcut': + key = u'P1' + elif verse_type == u'introShortcut': + key = u'I1' + elif verse_type == u'endingShortcut': + key = u'E1' + elif verse_type == u'otherShortcut': + key = u'O1' + if key in keys: + self.__checkUpdateSelectedSlide(self.slideList[key]) + self.slideSelected() + print self.slideList + def setPreviewHotkeys(self, parent=None): self.previousItem.setObjectName(u'previousItemPreview') self.nextItem.setObjectName(u'nextItemPreview') @@ -643,9 +741,9 @@ class SlideController(QtGui.QWidget): verse_def = u'%s%s' % (verse_def[0], verse_def[1:]) two_line_def = u'%s\n%s' % (verse_def[0], verse_def[1:]) row = two_line_def - if self.isLive: - if verse_def not in self.slideList: - self.slideList[verse_def] = framenumber + if verse_def not in self.slideList: + self.slideList[verse_def] = framenumber + if self.isLive: self.songMenu.menu().addAction(verse_def, self.onSongBarHandler) else: From cc186aff9d125184e6e4060817840a6a7ee725eb Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Sun, 23 Oct 2011 20:28:42 +0200 Subject: [PATCH 02/17] clean ups + fixes --- openlp/core/ui/slidecontroller.py | 140 +++++++++++++++++++++--------- 1 file changed, 98 insertions(+), 42 deletions(-) diff --git a/openlp/core/ui/slidecontroller.py b/openlp/core/ui/slidecontroller.py index 8b2409039..e9f13c7db 100644 --- a/openlp/core/ui/slidecontroller.py +++ b/openlp/core/ui/slidecontroller.py @@ -321,70 +321,122 @@ class SlideController(QtGui.QWidget): self.slidePreview.setObjectName(u'slidePreview') self.slideLayout.insertWidget(0, self.slidePreview) self.grid.addLayout(self.slideLayout, 0, 0, 1, 1) - self.verseShortcut1 = shortcut_action(self, 'verseShortcut1', + if self.isLive: + category = UiStrings().LiveToolbar + else: + category = UiStrings().PreviewToolbar + self.verseShortcut1 = shortcut_action( + self, u'verseShortcut1%s' % self.typePrefix.capitalize(), [QtGui.QKeySequence(u'V'), QtGui.QKeySequence(u'1')], - self.slideShortcutActivated, category=UiStrings().LiveToolbar if self.isLive else UiStrings().PreviewToolbar, + self.slideShortcutActivated, category=category, context=QtCore.Qt.WidgetWithChildrenShortcut) - self.verseShortcut2 = shortcut_action(self, 'verseShortcut2', + self.verseShortcut1.setText(translate( + 'OpenLP.SlideController', 'Go to "1. Verse"')) + self.verseShortcut2 = shortcut_action( + self, u'verseShortcut2%s' % self.typePrefix.capitalize(), [QtGui.QKeySequence(u'2')], self.slideShortcutActivated, - category=UiStrings().LiveToolbar if self.isLive else UiStrings().PreviewToolbar, + category=category, context=QtCore.Qt.WidgetWithChildrenShortcut) - self.verseShortcut3 = shortcut_action(self, 'verseShortcut3', + self.verseShortcut2.setText(translate( + 'OpenLP.SlideController', 'Go to "2. Verse"')) + self.verseShortcut3 = shortcut_action( + self, u'verseShortcut3%s' % self.typePrefix.capitalize(), [QtGui.QKeySequence(u'3')], self.slideShortcutActivated, - category=UiStrings().LiveToolbar if self.isLive else UiStrings().PreviewToolbar, + category=category, context=QtCore.Qt.WidgetWithChildrenShortcut) - self.verseShortcut4 = shortcut_action(self, 'verseShortcut4', + self.verseShortcut3.setText(translate( + 'OpenLP.SlideController', 'Go to "3. Verse"')) + self.verseShortcut4 = shortcut_action( + self, u'verseShortcut4%s' % self.typePrefix.capitalize(), [QtGui.QKeySequence(u'4')], self.slideShortcutActivated, - category=UiStrings().LiveToolbar if self.isLive else UiStrings().PreviewToolbar, + category=category, context=QtCore.Qt.WidgetWithChildrenShortcut) - self.verseShortcut5 = shortcut_action(self, 'verseShortcut5', + self.verseShortcut4.setText(translate( + 'OpenLP.SlideController', 'Go to "4. Verse"')) + self.verseShortcut5 = shortcut_action( + self, u'verseShortcut5%s' % self.typePrefix.capitalize(), [QtGui.QKeySequence(u'5')], self.slideShortcutActivated, - category=UiStrings().LiveToolbar if self.isLive else UiStrings().PreviewToolbar, + category=category, context=QtCore.Qt.WidgetWithChildrenShortcut) - self.verseShortcut6 = shortcut_action(self, 'verseShortcut6', + self.verseShortcut5.setText(translate( + 'OpenLP.SlideController', 'Go to "5. Verse"')) + self.verseShortcut6 = shortcut_action( + self, u'verseShortcut6%s' % self.typePrefix.capitalize(), [QtGui.QKeySequence(u'6')], self.slideShortcutActivated, - category=UiStrings().LiveToolbar if self.isLive else UiStrings().PreviewToolbar, + category=category, context=QtCore.Qt.WidgetWithChildrenShortcut) - self.verseShortcut7 = shortcut_action(self, 'verseShortcut7', + self.verseShortcut6.setText(translate( + 'OpenLP.SlideController', 'Go to "6. Verse"')) + self.verseShortcut7 = shortcut_action( + self, u'verseShortcut7%s' % self.typePrefix.capitalize(), [QtGui.QKeySequence(u'7')], self.slideShortcutActivated, - category=UiStrings().LiveToolbar if self.isLive else UiStrings().PreviewToolbar, + category=category, context=QtCore.Qt.WidgetWithChildrenShortcut) - self.verseShortcut8 = shortcut_action(self, 'verseShortcut8', + self.verseShortcut7.setText(translate( + 'OpenLP.SlideController', 'Go to "7. Verse"')) + self.verseShortcut8 = shortcut_action( + self, u'verseShortcut8%s' % self.typePrefix.capitalize(), [QtGui.QKeySequence(u'8')], self.slideShortcutActivated, - category=UiStrings().LiveToolbar if self.isLive else UiStrings().PreviewToolbar, + category=category, context=QtCore.Qt.WidgetWithChildrenShortcut) - self.verseShortcut9 = shortcut_action(self, 'verseShortcut9', + self.verseShortcut8.setText(translate( + 'OpenLP.SlideController', 'Go to "8. Verse"')) + self.verseShortcut9 = shortcut_action( + self, u'verseShortcut9%s' % self.typePrefix.capitalize(), [QtGui.QKeySequence(u'9')], self.slideShortcutActivated, - category=UiStrings().LiveToolbar if self.isLive else UiStrings().PreviewToolbar, + category=category, context=QtCore.Qt.WidgetWithChildrenShortcut) - self.verseShortcut10 = shortcut_action(self, 'verseShortcut10', + self.verseShortcut9.setText(translate( + 'OpenLP.SlideController', 'Go to "9. Verse"')) + self.verseShortcut10 = shortcut_action( + self, u'verseShortcut10%s' % self.typePrefix.capitalize(), [QtGui.QKeySequence(u'0')], self.slideShortcutActivated, - category=UiStrings().LiveToolbar if self.isLive else UiStrings().PreviewToolbar, + category=category, context=QtCore.Qt.WidgetWithChildrenShortcut) - self.chorusShortcut = shortcut_action(self, 'chorusShortcut', + self.verseShortcut10.setText(translate( + 'OpenLP.SlideController', 'Go to "10. Verse"')) + self.chorusShortcut = shortcut_action( + self, u'chorusShortcut%s' % self.typePrefix.capitalize(), [QtGui.QKeySequence(u'C')], self.slideShortcutActivated, - category=UiStrings().LiveToolbar if self.isLive else UiStrings().PreviewToolbar, + category=category, context=QtCore.Qt.WidgetWithChildrenShortcut) - self.bridgeShortcut = shortcut_action(self, 'bridgeShortcut', + self.chorusShortcut.setText(translate( + 'OpenLP.SlideController', 'Go to "Chorus"')) + self.bridgeShortcut = shortcut_action( + self, u'bridgeShortcut%s' % self.typePrefix.capitalize(), [QtGui.QKeySequence(u'B')], self.slideShortcutActivated, - category=UiStrings().LiveToolbar if self.isLive else UiStrings().PreviewToolbar, + category=category, context=QtCore.Qt.WidgetWithChildrenShortcut) - self.preChorusShortcut = shortcut_action(self, 'preChorusShortcut', + self.bridgeShortcut.setText(translate( + 'OpenLP.SlideController', 'Go to "Bridge"')) + self.preChorusShortcut = shortcut_action( + self, u'preChorusShortcut%s' % self.typePrefix.capitalize(), [QtGui.QKeySequence(u'P')], self.slideShortcutActivated, - category=UiStrings().LiveToolbar if self.isLive else UiStrings().PreviewToolbar, + category=category, context=QtCore.Qt.WidgetWithChildrenShortcut) - self.introShortcut = shortcut_action(self, 'introShortcut', + self.preChorusShortcut.setText(translate( + 'OpenLP.SlideController', 'Go to "Pre-Chorus"')) + self.introShortcut = shortcut_action( + self, u'introShortcut%s' % self.typePrefix.capitalize(), [QtGui.QKeySequence(u'I')], self.slideShortcutActivated, - category=UiStrings().LiveToolbar if self.isLive else UiStrings().PreviewToolbar, + category=category, context=QtCore.Qt.WidgetWithChildrenShortcut) - self.endingShortcut = shortcut_action(self, 'endingShortcut', + self.introShortcut.setText(translate( + 'OpenLP.SlideController', 'Go to "Intro"')) + self.endingShortcut = shortcut_action( + self, u'endingShortcut%s' % self.typePrefix.capitalize(), [QtGui.QKeySequence(u'E')], self.slideShortcutActivated, - category=UiStrings().LiveToolbar if self.isLive else UiStrings().PreviewToolbar, + category=category, context=QtCore.Qt.WidgetWithChildrenShortcut) - self.otherShortcut = shortcut_action(self, 'otherShortcut', + self.endingShortcut.setText(translate( + 'OpenLP.SlideController', 'Go to "Ending"')) + self.otherShortcut = shortcut_action( + self, u'otherShortcut%s' % self.typePrefix.capitalize(), [QtGui.QKeySequence(u'O')], self.slideShortcutActivated, - category=UiStrings().LiveToolbar if self.isLive else UiStrings().PreviewToolbar, + category=category, context=QtCore.Qt.WidgetWithChildrenShortcut) + self.otherShortcut.setText(translate( + 'OpenLP.SlideController', 'Go to "Other"')) self.previewListWidget.addActions([ self.verseShortcut1, self.verseShortcut2, self.verseShortcut3, self.verseShortcut4, self.verseShortcut5, self.verseShortcut6, @@ -441,34 +493,38 @@ class SlideController(QtGui.QWidget): def slideShortcutActivated(self): """ - Called, when a shortcut + Called, when a shortcut has been activated to jump to a chorus, verse, + etc. """ + #FIXME: translatable verse types verse_type = unicode(self.sender().objectName()) - keys = self.slideList.keys() + # Remove the "Live" or "Preview" suffix. + verse_type = verse_type[:-len(self.typePrefix)] key = u'' if verse_type.startswith(u'verseShortcut'): key = u'V%s' % verse_type[13:] - elif verse_type == u'chorusShortcut': + elif verse_type.startswith(u'chorusShortcut'): key = u'C1' - elif verse_type == u'bridgeShortcut': + elif verse_type.startswith(u'bridgeShortcut'): key = u'B1' - elif verse_type == u'preChorusShortcut': + elif verse_type.startswith(u'preChorusShortcut'): key = u'P1' - elif verse_type == u'introShortcut': + elif verse_type.startswith(u'introShortcut'): key = u'I1' - elif verse_type == u'endingShortcut': + elif verse_type.startswith(u'endingShortcut'): key = u'E1' - elif verse_type == u'otherShortcut': + elif verse_type.startswith(u'otherShortcut'): key = u'O1' - if key in keys: + if key in self.slideList.keys(): self.__checkUpdateSelectedSlide(self.slideList[key]) self.slideSelected() - print self.slideList def setPreviewHotkeys(self, parent=None): self.previousItem.setObjectName(u'previousItemPreview') self.nextItem.setObjectName(u'nextItemPreview') action_list = ActionList.get_instance() + action_list.add_category( + UiStrings().PreviewToolbar, CategoryOrder.standardToolbar) action_list.add_action(self.previousItem) action_list.add_action(self.nextItem) From a42940b6bb43886458b90546225b2999032c9e0c Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Mon, 24 Oct 2011 17:36:59 +0200 Subject: [PATCH 03/17] - shortcuts only for live controller - removed v shortcut --- openlp/core/ui/slidecontroller.py | 229 ++++++++++++++---------------- 1 file changed, 104 insertions(+), 125 deletions(-) diff --git a/openlp/core/ui/slidecontroller.py b/openlp/core/ui/slidecontroller.py index e9f13c7db..aaecb7735 100644 --- a/openlp/core/ui/slidecontroller.py +++ b/openlp/core/ui/slidecontroller.py @@ -322,129 +322,110 @@ class SlideController(QtGui.QWidget): self.slideLayout.insertWidget(0, self.slidePreview) self.grid.addLayout(self.slideLayout, 0, 0, 1, 1) if self.isLive: - category = UiStrings().LiveToolbar - else: - category = UiStrings().PreviewToolbar - self.verseShortcut1 = shortcut_action( - self, u'verseShortcut1%s' % self.typePrefix.capitalize(), - [QtGui.QKeySequence(u'V'), QtGui.QKeySequence(u'1')], - self.slideShortcutActivated, category=category, - context=QtCore.Qt.WidgetWithChildrenShortcut) - self.verseShortcut1.setText(translate( - 'OpenLP.SlideController', 'Go to "1. Verse"')) - self.verseShortcut2 = shortcut_action( - self, u'verseShortcut2%s' % self.typePrefix.capitalize(), - [QtGui.QKeySequence(u'2')], self.slideShortcutActivated, - category=category, - context=QtCore.Qt.WidgetWithChildrenShortcut) - self.verseShortcut2.setText(translate( - 'OpenLP.SlideController', 'Go to "2. Verse"')) - self.verseShortcut3 = shortcut_action( - self, u'verseShortcut3%s' % self.typePrefix.capitalize(), - [QtGui.QKeySequence(u'3')], self.slideShortcutActivated, - category=category, - context=QtCore.Qt.WidgetWithChildrenShortcut) - self.verseShortcut3.setText(translate( - 'OpenLP.SlideController', 'Go to "3. Verse"')) - self.verseShortcut4 = shortcut_action( - self, u'verseShortcut4%s' % self.typePrefix.capitalize(), - [QtGui.QKeySequence(u'4')], self.slideShortcutActivated, - category=category, - context=QtCore.Qt.WidgetWithChildrenShortcut) - self.verseShortcut4.setText(translate( - 'OpenLP.SlideController', 'Go to "4. Verse"')) - self.verseShortcut5 = shortcut_action( - self, u'verseShortcut5%s' % self.typePrefix.capitalize(), - [QtGui.QKeySequence(u'5')], self.slideShortcutActivated, - category=category, - context=QtCore.Qt.WidgetWithChildrenShortcut) - self.verseShortcut5.setText(translate( - 'OpenLP.SlideController', 'Go to "5. Verse"')) - self.verseShortcut6 = shortcut_action( - self, u'verseShortcut6%s' % self.typePrefix.capitalize(), - [QtGui.QKeySequence(u'6')], self.slideShortcutActivated, - category=category, - context=QtCore.Qt.WidgetWithChildrenShortcut) - self.verseShortcut6.setText(translate( - 'OpenLP.SlideController', 'Go to "6. Verse"')) - self.verseShortcut7 = shortcut_action( - self, u'verseShortcut7%s' % self.typePrefix.capitalize(), - [QtGui.QKeySequence(u'7')], self.slideShortcutActivated, - category=category, - context=QtCore.Qt.WidgetWithChildrenShortcut) - self.verseShortcut7.setText(translate( - 'OpenLP.SlideController', 'Go to "7. Verse"')) - self.verseShortcut8 = shortcut_action( - self, u'verseShortcut8%s' % self.typePrefix.capitalize(), - [QtGui.QKeySequence(u'8')], self.slideShortcutActivated, - category=category, - context=QtCore.Qt.WidgetWithChildrenShortcut) - self.verseShortcut8.setText(translate( - 'OpenLP.SlideController', 'Go to "8. Verse"')) - self.verseShortcut9 = shortcut_action( - self, u'verseShortcut9%s' % self.typePrefix.capitalize(), - [QtGui.QKeySequence(u'9')], self.slideShortcutActivated, - category=category, - context=QtCore.Qt.WidgetWithChildrenShortcut) - self.verseShortcut9.setText(translate( - 'OpenLP.SlideController', 'Go to "9. Verse"')) - self.verseShortcut10 = shortcut_action( - self, u'verseShortcut10%s' % self.typePrefix.capitalize(), - [QtGui.QKeySequence(u'0')], self.slideShortcutActivated, - category=category, - context=QtCore.Qt.WidgetWithChildrenShortcut) - self.verseShortcut10.setText(translate( - 'OpenLP.SlideController', 'Go to "10. Verse"')) - self.chorusShortcut = shortcut_action( - self, u'chorusShortcut%s' % self.typePrefix.capitalize(), - [QtGui.QKeySequence(u'C')], self.slideShortcutActivated, - category=category, - context=QtCore.Qt.WidgetWithChildrenShortcut) - self.chorusShortcut.setText(translate( - 'OpenLP.SlideController', 'Go to "Chorus"')) - self.bridgeShortcut = shortcut_action( - self, u'bridgeShortcut%s' % self.typePrefix.capitalize(), - [QtGui.QKeySequence(u'B')], self.slideShortcutActivated, - category=category, - context=QtCore.Qt.WidgetWithChildrenShortcut) - self.bridgeShortcut.setText(translate( - 'OpenLP.SlideController', 'Go to "Bridge"')) - self.preChorusShortcut = shortcut_action( - self, u'preChorusShortcut%s' % self.typePrefix.capitalize(), - [QtGui.QKeySequence(u'P')], self.slideShortcutActivated, - category=category, - context=QtCore.Qt.WidgetWithChildrenShortcut) - self.preChorusShortcut.setText(translate( - 'OpenLP.SlideController', 'Go to "Pre-Chorus"')) - self.introShortcut = shortcut_action( - self, u'introShortcut%s' % self.typePrefix.capitalize(), - [QtGui.QKeySequence(u'I')], self.slideShortcutActivated, - category=category, - context=QtCore.Qt.WidgetWithChildrenShortcut) - self.introShortcut.setText(translate( - 'OpenLP.SlideController', 'Go to "Intro"')) - self.endingShortcut = shortcut_action( - self, u'endingShortcut%s' % self.typePrefix.capitalize(), - [QtGui.QKeySequence(u'E')], self.slideShortcutActivated, - category=category, - context=QtCore.Qt.WidgetWithChildrenShortcut) - self.endingShortcut.setText(translate( - 'OpenLP.SlideController', 'Go to "Ending"')) - self.otherShortcut = shortcut_action( - self, u'otherShortcut%s' % self.typePrefix.capitalize(), - [QtGui.QKeySequence(u'O')], self.slideShortcutActivated, - category=category, - context=QtCore.Qt.WidgetWithChildrenShortcut) - self.otherShortcut.setText(translate( - 'OpenLP.SlideController', 'Go to "Other"')) - self.previewListWidget.addActions([ - self.verseShortcut1, self.verseShortcut2, self.verseShortcut3, - self.verseShortcut4, self.verseShortcut5, self.verseShortcut6, - self.verseShortcut7, self.verseShortcut8, self.verseShortcut9, - self.verseShortcut10, self.chorusShortcut, self.bridgeShortcut, - self.preChorusShortcut, self.introShortcut, self.endingShortcut, - self.otherShortcut - ]) + self.verseShortcut1 = shortcut_action(self, u'verseShortcut1', + [QtGui.QKeySequence(u'1')], self.slideShortcutActivated, + category=UiStrings().LiveToolbar, + context=QtCore.Qt.WidgetWithChildrenShortcut) + self.verseShortcut1.setText(translate( + 'OpenLP.SlideController', 'Go to "1. Verse"')) + self.verseShortcut2 = shortcut_action(self, u'verseShortcut2', + [QtGui.QKeySequence(u'2')], self.slideShortcutActivated, + category=UiStrings().LiveToolbar, + context=QtCore.Qt.WidgetWithChildrenShortcut) + self.verseShortcut2.setText(translate( + 'OpenLP.SlideController', 'Go to "2. Verse"')) + self.verseShortcut3 = shortcut_action(self, u'verseShortcut3', + [QtGui.QKeySequence(u'3')], self.slideShortcutActivated, + category=UiStrings().LiveToolbar, + context=QtCore.Qt.WidgetWithChildrenShortcut) + self.verseShortcut3.setText(translate( + 'OpenLP.SlideController', 'Go to "3. Verse"')) + self.verseShortcut4 = shortcut_action(self, u'verseShortcut4', + [QtGui.QKeySequence(u'4')], self.slideShortcutActivated, + category=UiStrings().LiveToolbar, + context=QtCore.Qt.WidgetWithChildrenShortcut) + self.verseShortcut4.setText(translate( + 'OpenLP.SlideController', 'Go to "4. Verse"')) + self.verseShortcut5 = shortcut_action(self, u'verseShortcut5', + [QtGui.QKeySequence(u'5')], self.slideShortcutActivated, + category=UiStrings().LiveToolbar, + context=QtCore.Qt.WidgetWithChildrenShortcut) + self.verseShortcut5.setText(translate( + 'OpenLP.SlideController', 'Go to "5. Verse"')) + self.verseShortcut6 = shortcut_action(self, u'verseShortcut6', + [QtGui.QKeySequence(u'6')], self.slideShortcutActivated, + category=UiStrings().LiveToolbar, + context=QtCore.Qt.WidgetWithChildrenShortcut) + self.verseShortcut6.setText(translate( + 'OpenLP.SlideController', 'Go to "6. Verse"')) + self.verseShortcut7 = shortcut_action(self, u'verseShortcut7', + [QtGui.QKeySequence(u'7')], self.slideShortcutActivated, + category=UiStrings().LiveToolbar, + context=QtCore.Qt.WidgetWithChildrenShortcut) + self.verseShortcut7.setText(translate( + 'OpenLP.SlideController', 'Go to "7. Verse"')) + self.verseShortcut8 = shortcut_action(self, u'verseShortcut8', + [QtGui.QKeySequence(u'8')], self.slideShortcutActivated, + category=UiStrings().LiveToolbar, + context=QtCore.Qt.WidgetWithChildrenShortcut) + self.verseShortcut8.setText(translate( + 'OpenLP.SlideController', 'Go to "8. Verse"')) + self.verseShortcut9 = shortcut_action(self, u'verseShortcut9', + [QtGui.QKeySequence(u'9')], self.slideShortcutActivated, + category=UiStrings().LiveToolbar, + context=QtCore.Qt.WidgetWithChildrenShortcut) + self.verseShortcut9.setText(translate( + 'OpenLP.SlideController', 'Go to "9. Verse"')) + self.verseShortcut10 = shortcut_action(self, u'verseShortcut10', + [QtGui.QKeySequence(u'0')], self.slideShortcutActivated, + category=UiStrings().LiveToolbar, + context=QtCore.Qt.WidgetWithChildrenShortcut) + self.verseShortcut10.setText(translate( + 'OpenLP.SlideController', 'Go to "10. Verse"')) + 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.verseShortcut1, self.verseShortcut2, self.verseShortcut3, + self.verseShortcut4, self.verseShortcut5, self.verseShortcut6, + self.verseShortcut7, self.verseShortcut8, self.verseShortcut9, + self.verseShortcut10, self.chorusShortcut, self.bridgeShortcut, + self.preChorusShortcut, self.introShortcut, self.endingShortcut, + self.otherShortcut + ]) # Signals QtCore.QObject.connect(self.previewListWidget, QtCore.SIGNAL(u'clicked(QModelIndex)'), self.onSlideSelected) @@ -498,8 +479,6 @@ class SlideController(QtGui.QWidget): """ #FIXME: translatable verse types verse_type = unicode(self.sender().objectName()) - # Remove the "Live" or "Preview" suffix. - verse_type = verse_type[:-len(self.typePrefix)] key = u'' if verse_type.startswith(u'verseShortcut'): key = u'V%s' % verse_type[13:] From ee960bb88c083b98d31d187ad034872414ce815a Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Mon, 24 Oct 2011 18:13:30 +0200 Subject: [PATCH 04/17] use '1' etc shortcuts for bible verses, images, etc --- openlp/core/lib/ui.py | 1 - openlp/core/ui/slidecontroller.py | 8 ++++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/openlp/core/lib/ui.py b/openlp/core/lib/ui.py index 2e9669e89..756df36c3 100644 --- a/openlp/core/lib/ui.py +++ b/openlp/core/lib/ui.py @@ -105,7 +105,6 @@ class UiStrings(object): self.PlaySlidesInLoop = translate('OpenLP.Ui','Play Slides in Loop') self.PlaySlidesToEnd = translate('OpenLP.Ui','Play Slides to End') self.Preview = translate('OpenLP.Ui', 'Preview') - self.PreviewToolbar = translate('OpenLP.Ui', 'Preview Toolbar') self.PrintService = translate('OpenLP.Ui', 'Print Service') self.ReplaceBG = translate('OpenLP.Ui', 'Replace Background') self.ReplaceLiveBG = translate('OpenLP.Ui', 'Replace live background.') diff --git a/openlp/core/ui/slidecontroller.py b/openlp/core/ui/slidecontroller.py index aaecb7735..6eb0bf2e4 100644 --- a/openlp/core/ui/slidecontroller.py +++ b/openlp/core/ui/slidecontroller.py @@ -497,13 +497,15 @@ class SlideController(QtGui.QWidget): if key in self.slideList.keys(): self.__checkUpdateSelectedSlide(self.slideList[key]) self.slideSelected() + elif key.startswith(u'V'): + if key[1:] in self.slideList.keys(): + self.__checkUpdateSelectedSlide(self.slideList[key[1:]]) + self.slideSelected() def setPreviewHotkeys(self, parent=None): self.previousItem.setObjectName(u'previousItemPreview') self.nextItem.setObjectName(u'nextItemPreview') action_list = ActionList.get_instance() - action_list.add_category( - UiStrings().PreviewToolbar, CategoryOrder.standardToolbar) action_list.add_action(self.previousItem) action_list.add_action(self.nextItem) @@ -783,6 +785,7 @@ class SlideController(QtGui.QWidget): self.onSongBarHandler) else: row += 1 + self.slideList[unicode(row)] = row - 1 item.setText(frame[u'text']) else: label = QtGui.QLabel() @@ -800,6 +803,7 @@ class SlideController(QtGui.QWidget): self.previewListWidget.setCellWidget(framenumber, 0, label) slideHeight = width * self.parent().renderer.screen_ratio row += 1 + self.slideList[unicode(row)] = row - 1 text.append(unicode(row)) self.previewListWidget.setItem(framenumber, 0, item) if slideHeight != 0: From 33960f9eb4515afeefd23135e65dea1dd66b411a Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Tue, 25 Oct 2011 18:31:22 +0200 Subject: [PATCH 05/17] allow all possible 'shortcut' combinations --- openlp/core/ui/slidecontroller.py | 134 +++++++++++++++--------------- 1 file changed, 68 insertions(+), 66 deletions(-) diff --git a/openlp/core/ui/slidecontroller.py b/openlp/core/ui/slidecontroller.py index 6eb0bf2e4..ed3572df3 100644 --- a/openlp/core/ui/slidecontroller.py +++ b/openlp/core/ui/slidecontroller.py @@ -322,66 +322,45 @@ class SlideController(QtGui.QWidget): self.slideLayout.insertWidget(0, self.slidePreview) self.grid.addLayout(self.slideLayout, 0, 0, 1, 1) if self.isLive: - self.verseShortcut1 = shortcut_action(self, u'verseShortcut1', - [QtGui.QKeySequence(u'1')], self.slideShortcutActivated, + self.old_shortcut = u'' + self.shortcutTimer = QtCore.QTimer() + 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.verseShortcut1.setText(translate( - 'OpenLP.SlideController', 'Go to "1. Verse"')) - self.verseShortcut2 = shortcut_action(self, u'verseShortcut2', - [QtGui.QKeySequence(u'2')], self.slideShortcutActivated, - category=UiStrings().LiveToolbar, - context=QtCore.Qt.WidgetWithChildrenShortcut) - self.verseShortcut2.setText(translate( - 'OpenLP.SlideController', 'Go to "2. Verse"')) - self.verseShortcut3 = shortcut_action(self, u'verseShortcut3', - [QtGui.QKeySequence(u'3')], self.slideShortcutActivated, - category=UiStrings().LiveToolbar, - context=QtCore.Qt.WidgetWithChildrenShortcut) - self.verseShortcut3.setText(translate( - 'OpenLP.SlideController', 'Go to "3. Verse"')) - self.verseShortcut4 = shortcut_action(self, u'verseShortcut4', - [QtGui.QKeySequence(u'4')], self.slideShortcutActivated, - category=UiStrings().LiveToolbar, - context=QtCore.Qt.WidgetWithChildrenShortcut) - self.verseShortcut4.setText(translate( - 'OpenLP.SlideController', 'Go to "4. Verse"')) - self.verseShortcut5 = shortcut_action(self, u'verseShortcut5', - [QtGui.QKeySequence(u'5')], self.slideShortcutActivated, - category=UiStrings().LiveToolbar, - context=QtCore.Qt.WidgetWithChildrenShortcut) - self.verseShortcut5.setText(translate( - 'OpenLP.SlideController', 'Go to "5. Verse"')) - self.verseShortcut6 = shortcut_action(self, u'verseShortcut6', - [QtGui.QKeySequence(u'6')], self.slideShortcutActivated, - category=UiStrings().LiveToolbar, - context=QtCore.Qt.WidgetWithChildrenShortcut) - self.verseShortcut6.setText(translate( - 'OpenLP.SlideController', 'Go to "6. Verse"')) - self.verseShortcut7 = shortcut_action(self, u'verseShortcut7', - [QtGui.QKeySequence(u'7')], self.slideShortcutActivated, - category=UiStrings().LiveToolbar, - context=QtCore.Qt.WidgetWithChildrenShortcut) - self.verseShortcut7.setText(translate( - 'OpenLP.SlideController', 'Go to "7. Verse"')) - self.verseShortcut8 = shortcut_action(self, u'verseShortcut8', - [QtGui.QKeySequence(u'8')], self.slideShortcutActivated, - category=UiStrings().LiveToolbar, - context=QtCore.Qt.WidgetWithChildrenShortcut) - self.verseShortcut8.setText(translate( - 'OpenLP.SlideController', 'Go to "8. Verse"')) - self.verseShortcut9 = shortcut_action(self, u'verseShortcut9', - [QtGui.QKeySequence(u'9')], self.slideShortcutActivated, - category=UiStrings().LiveToolbar, - context=QtCore.Qt.WidgetWithChildrenShortcut) - self.verseShortcut9.setText(translate( - 'OpenLP.SlideController', 'Go to "9. Verse"')) - self.verseShortcut10 = shortcut_action(self, u'verseShortcut10', + self.verseShortcut.setText(translate( + 'OpenLP.SlideController', 'Go to "Verse"')) + self.verseShortcut0 = shortcut_action(self, u'0', [QtGui.QKeySequence(u'0')], self.slideShortcutActivated, - category=UiStrings().LiveToolbar, context=QtCore.Qt.WidgetWithChildrenShortcut) - self.verseShortcut10.setText(translate( - 'OpenLP.SlideController', 'Go to "10. Verse"')) + self.verseShortcut1 = shortcut_action(self, u'1', + [QtGui.QKeySequence(u'1')], self.slideShortcutActivated, + context=QtCore.Qt.WidgetWithChildrenShortcut) + self.verseShortcut2 = shortcut_action(self, u'2', + [QtGui.QKeySequence(u'2')], self.slideShortcutActivated, + context=QtCore.Qt.WidgetWithChildrenShortcut) + self.verseShortcut3 = shortcut_action(self, u'3', + [QtGui.QKeySequence(u'3')], self.slideShortcutActivated, + context=QtCore.Qt.WidgetWithChildrenShortcut) + self.verseShortcut4 = shortcut_action(self, u'4', + [QtGui.QKeySequence(u'4')], self.slideShortcutActivated, + context=QtCore.Qt.WidgetWithChildrenShortcut) + self.verseShortcut5 = shortcut_action(self, u'5', + [QtGui.QKeySequence(u'5')], self.slideShortcutActivated, + context=QtCore.Qt.WidgetWithChildrenShortcut) + self.verseShortcut6 = shortcut_action(self, u'6', + [QtGui.QKeySequence(u'6')], self.slideShortcutActivated, + context=QtCore.Qt.WidgetWithChildrenShortcut) + self.verseShortcut7 = shortcut_action(self, u'7', + [QtGui.QKeySequence(u'7')], self.slideShortcutActivated, + context=QtCore.Qt.WidgetWithChildrenShortcut) + self.verseShortcut8 = shortcut_action(self, u'8', + [QtGui.QKeySequence(u'8')], self.slideShortcutActivated, + context=QtCore.Qt.WidgetWithChildrenShortcut) + self.verseShortcut9 = 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, @@ -418,14 +397,17 @@ class SlideController(QtGui.QWidget): context=QtCore.Qt.WidgetWithChildrenShortcut) self.otherShortcut.setText(translate( 'OpenLP.SlideController', 'Go to "Other"')) - self.previewListWidget.addActions([ + self.previewListWidget.addActions([self.verseShortcut, self.verseShortcut1, self.verseShortcut2, self.verseShortcut3, self.verseShortcut4, self.verseShortcut5, self.verseShortcut6, self.verseShortcut7, self.verseShortcut8, self.verseShortcut9, - self.verseShortcut10, self.chorusShortcut, self.bridgeShortcut, + self.verseShortcut0, self.chorusShortcut, self.bridgeShortcut, self.preChorusShortcut, self.introShortcut, self.endingShortcut, self.otherShortcut ]) + QtCore.QObject.connect( + self.shortcutTimer, QtCore.SIGNAL(u'timeout()'), + self.slideShortcutActivated) # Signals QtCore.QObject.connect(self.previewListWidget, QtCore.SIGNAL(u'clicked(QModelIndex)'), self.onSlideSelected) @@ -477,26 +459,46 @@ class SlideController(QtGui.QWidget): Called, when a shortcut has been activated to jump to a chorus, verse, etc. """ + return_ = False + if not self.old_shortcut or self.shortcutTimer.isActive(): + self.shortcutTimer.start(350) + return_ = True #FIXME: translatable verse types + # TODO: Do not restart timer, when the current key is valid (and there + # no other combination is valid). verse_type = unicode(self.sender().objectName()) key = u'' - if verse_type.startswith(u'verseShortcut'): - key = u'V%s' % verse_type[13:] + if verse_type.startswith(u'verseShortcut'): + key = u'V' elif verse_type.startswith(u'chorusShortcut'): - key = u'C1' + key = u'C' elif verse_type.startswith(u'bridgeShortcut'): - key = u'B1' + key = u'B' elif verse_type.startswith(u'preChorusShortcut'): - key = u'P1' + key = u'P' elif verse_type.startswith(u'introShortcut'): - key = u'I1' + key = u'I' elif verse_type.startswith(u'endingShortcut'): - key = u'E1' + key = u'E' elif verse_type.startswith(u'otherShortcut'): - key = u'O1' + key = u'O' + elif verse_type.isnumeric(): + key = verse_type + if return_: + self.old_shortcut += key + print u'old', self.old_shortcut + return + key = self.old_shortcut + key + print u'key', key + self.old_shortcut = u'' if key in self.slideList.keys(): self.__checkUpdateSelectedSlide(self.slideList[key]) self.slideSelected() + elif len(key) == 1: + key += u'1' + if key in self.slideList.keys(): + self.__checkUpdateSelectedSlide(self.slideList[key]) + self.slideSelected() elif key.startswith(u'V'): if key[1:] in self.slideList.keys(): self.__checkUpdateSelectedSlide(self.slideList[key[1:]]) From c9c31990e2682f9d3efe08c27e58655b69ef88ef Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Wed, 26 Oct 2011 16:53:51 +0200 Subject: [PATCH 06/17] fixed detection --- openlp/core/ui/slidecontroller.py | 68 +++++++++++++++++-------------- 1 file changed, 37 insertions(+), 31 deletions(-) diff --git a/openlp/core/ui/slidecontroller.py b/openlp/core/ui/slidecontroller.py index ed3572df3..4c3efcdbb 100644 --- a/openlp/core/ui/slidecontroller.py +++ b/openlp/core/ui/slidecontroller.py @@ -324,6 +324,7 @@ class SlideController(QtGui.QWidget): if self.isLive: self.old_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, @@ -331,34 +332,34 @@ class SlideController(QtGui.QWidget): context=QtCore.Qt.WidgetWithChildrenShortcut) self.verseShortcut.setText(translate( 'OpenLP.SlideController', 'Go to "Verse"')) - self.verseShortcut0 = shortcut_action(self, u'0', + self.shortcut0 = shortcut_action(self, u'0', [QtGui.QKeySequence(u'0')], self.slideShortcutActivated, context=QtCore.Qt.WidgetWithChildrenShortcut) - self.verseShortcut1 = shortcut_action(self, u'1', + self.shortcut1 = shortcut_action(self, u'1', [QtGui.QKeySequence(u'1')], self.slideShortcutActivated, context=QtCore.Qt.WidgetWithChildrenShortcut) - self.verseShortcut2 = shortcut_action(self, u'2', + self.shortcut2 = shortcut_action(self, u'2', [QtGui.QKeySequence(u'2')], self.slideShortcutActivated, context=QtCore.Qt.WidgetWithChildrenShortcut) - self.verseShortcut3 = shortcut_action(self, u'3', + self.shortcut3 = shortcut_action(self, u'3', [QtGui.QKeySequence(u'3')], self.slideShortcutActivated, context=QtCore.Qt.WidgetWithChildrenShortcut) - self.verseShortcut4 = shortcut_action(self, u'4', + self.shortcut4 = shortcut_action(self, u'4', [QtGui.QKeySequence(u'4')], self.slideShortcutActivated, context=QtCore.Qt.WidgetWithChildrenShortcut) - self.verseShortcut5 = shortcut_action(self, u'5', + self.shortcut5 = shortcut_action(self, u'5', [QtGui.QKeySequence(u'5')], self.slideShortcutActivated, context=QtCore.Qt.WidgetWithChildrenShortcut) - self.verseShortcut6 = shortcut_action(self, u'6', + self.shortcut6 = shortcut_action(self, u'6', [QtGui.QKeySequence(u'6')], self.slideShortcutActivated, context=QtCore.Qt.WidgetWithChildrenShortcut) - self.verseShortcut7 = shortcut_action(self, u'7', + self.shortcut7 = shortcut_action(self, u'7', [QtGui.QKeySequence(u'7')], self.slideShortcutActivated, context=QtCore.Qt.WidgetWithChildrenShortcut) - self.verseShortcut8 = shortcut_action(self, u'8', + self.shortcut8 = shortcut_action(self, u'8', [QtGui.QKeySequence(u'8')], self.slideShortcutActivated, context=QtCore.Qt.WidgetWithChildrenShortcut) - self.verseShortcut9 = shortcut_action(self, u'9', + self.shortcut9 = shortcut_action(self, u'9', [QtGui.QKeySequence(u'9')], self.slideShortcutActivated, context=QtCore.Qt.WidgetWithChildrenShortcut) self.chorusShortcut = shortcut_action(self, u'chorusShortcut', @@ -397,11 +398,11 @@ class SlideController(QtGui.QWidget): context=QtCore.Qt.WidgetWithChildrenShortcut) self.otherShortcut.setText(translate( 'OpenLP.SlideController', 'Go to "Other"')) - self.previewListWidget.addActions([self.verseShortcut, - self.verseShortcut1, self.verseShortcut2, self.verseShortcut3, - self.verseShortcut4, self.verseShortcut5, self.verseShortcut6, - self.verseShortcut7, self.verseShortcut8, self.verseShortcut9, - self.verseShortcut0, self.chorusShortcut, self.bridgeShortcut, + 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 ]) @@ -459,13 +460,7 @@ class SlideController(QtGui.QWidget): Called, when a shortcut has been activated to jump to a chorus, verse, etc. """ - return_ = False - if not self.old_shortcut or self.shortcutTimer.isActive(): - self.shortcutTimer.start(350) - return_ = True #FIXME: translatable verse types - # TODO: Do not restart timer, when the current key is valid (and there - # no other combination is valid). verse_type = unicode(self.sender().objectName()) key = u'' if verse_type.startswith(u'verseShortcut'): @@ -484,25 +479,36 @@ class SlideController(QtGui.QWidget): key = u'O' elif verse_type.isnumeric(): key = verse_type - if return_: + # The timer was not interrupted by a user input, thus it timed out. + elif verse_type == u'shortcutTimer': + key = self.old_shortcut + self.old_shortcut = u'' + keys = self.slideList.keys() + if verse_type != u'shortcutTimer': self.old_shortcut += key - print u'old', self.old_shortcut + self.shortcutTimer.start(350) return +# matches = [match for match in keys if match.startswith(key)] +# # Stop here and start the timer. +# if len(matches) > 1: +# self.shortcutTimer.start(350) +# return +# # Stop the timer and use the match we have. +# elif len(matches) == 1: +# print u'exactly one match', matches[0] +# self.shortcutTimer.stop() +# key = matches[0] +# self.old_shortcut = u'' key = self.old_shortcut + key - print u'key', key - self.old_shortcut = u'' - if key in self.slideList.keys(): + if key in keys: self.__checkUpdateSelectedSlide(self.slideList[key]) self.slideSelected() + #TODO: remove and use list with matches. elif len(key) == 1: key += u'1' - if key in self.slideList.keys(): + if key in keys: self.__checkUpdateSelectedSlide(self.slideList[key]) self.slideSelected() - elif key.startswith(u'V'): - if key[1:] in self.slideList.keys(): - self.__checkUpdateSelectedSlide(self.slideList[key[1:]]) - self.slideSelected() def setPreviewHotkeys(self, parent=None): self.previousItem.setObjectName(u'previousItemPreview') From 360843baf72a3662de9668c37225e6eebf6c4180 Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Wed, 26 Oct 2011 21:19:42 +0200 Subject: [PATCH 07/17] fixed spelling mistake --- openlp/core/ui/slidecontroller.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openlp/core/ui/slidecontroller.py b/openlp/core/ui/slidecontroller.py index 4c3efcdbb..5512ee36d 100644 --- a/openlp/core/ui/slidecontroller.py +++ b/openlp/core/ui/slidecontroller.py @@ -399,7 +399,7 @@ class SlideController(QtGui.QWidget): self.otherShortcut.setText(translate( 'OpenLP.SlideController', 'Go to "Other"')) self.previewListWidget.addActions([ - self.shortcut0. self.shortcut1, self.shortcut2, self.shortcut3, + 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, From 2458ffc3bc56d9e04a62ce17acb40311cddb2904 Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Mon, 31 Oct 2011 08:41:28 +0100 Subject: [PATCH 08/17] completed detection + cleaned detection --- openlp/core/ui/slidecontroller.py | 62 ++++++++++++------------------- 1 file changed, 23 insertions(+), 39 deletions(-) diff --git a/openlp/core/ui/slidecontroller.py b/openlp/core/ui/slidecontroller.py index 5512ee36d..dab9f0744 100644 --- a/openlp/core/ui/slidecontroller.py +++ b/openlp/core/ui/slidecontroller.py @@ -322,7 +322,7 @@ class SlideController(QtGui.QWidget): self.slideLayout.insertWidget(0, self.slidePreview) self.grid.addLayout(self.slideLayout, 0, 0, 1, 1) if self.isLive: - self.old_shortcut = u'' + self.current_shortcut = u'' self.shortcutTimer = QtCore.QTimer() self.shortcutTimer.setObjectName(u'shortcutTimer') self.shortcutTimer.setSingleShot(True) @@ -462,53 +462,37 @@ class SlideController(QtGui.QWidget): """ #FIXME: translatable verse types verse_type = unicode(self.sender().objectName()) - key = u'' if verse_type.startswith(u'verseShortcut'): - key = u'V' + print u'"%s"' % self.current_shortcut + self.current_shortcut = u'V' elif verse_type.startswith(u'chorusShortcut'): - key = u'C' + self.current_shortcut = u'C' elif verse_type.startswith(u'bridgeShortcut'): - key = u'B' + self.current_shortcut = u'B' elif verse_type.startswith(u'preChorusShortcut'): - key = u'P' + self.current_shortcut = u'P' elif verse_type.startswith(u'introShortcut'): - key = u'I' + self.current_shortcut = u'I' elif verse_type.startswith(u'endingShortcut'): - key = u'E' + self.current_shortcut = u'E' elif verse_type.startswith(u'otherShortcut'): - key = u'O' + self.current_shortcut = u'O' elif verse_type.isnumeric(): - key = verse_type - # The timer was not interrupted by a user input, thus it timed out. - elif verse_type == u'shortcutTimer': - key = self.old_shortcut - self.old_shortcut = u'' - keys = self.slideList.keys() - if verse_type != u'shortcutTimer': - self.old_shortcut += key - self.shortcutTimer.start(350) - return -# matches = [match for match in keys if match.startswith(key)] -# # Stop here and start the timer. -# if len(matches) > 1: -# self.shortcutTimer.start(350) -# return -# # Stop the timer and use the match we have. -# elif len(matches) == 1: -# print u'exactly one match', matches[0] -# self.shortcutTimer.stop() -# key = matches[0] -# self.old_shortcut = u'' - key = self.old_shortcut + key - if key in keys: - self.__checkUpdateSelectedSlide(self.slideList[key]) + self.current_shortcut += verse_type + matches = [match for match in self.slideList.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() - #TODO: remove and use list with matches. - elif len(key) == 1: - key += u'1' - if key in keys: - self.__checkUpdateSelectedSlide(self.slideList[key]) - self.slideSelected() + elif verse_type != u'shortcutTimer': + # Start the time as we did not have any match. + self.shortcutTimer.start(350) + else: + # Reset the key sequenze as we do not have any match and the timer + # timed out. + self.current_shortcut = u'' def setPreviewHotkeys(self, parent=None): self.previousItem.setObjectName(u'previousItemPreview') From ffafcaaadc55e022bca6a3de631fd861c67ca09d Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Mon, 31 Oct 2011 09:44:38 +0100 Subject: [PATCH 09/17] fix for translated verse tags --- openlp/core/ui/slidecontroller.py | 50 +++++++++++++++++++++++++------ 1 file changed, 41 insertions(+), 9 deletions(-) diff --git a/openlp/core/ui/slidecontroller.py b/openlp/core/ui/slidecontroller.py index dab9f0744..03ec3c16b 100644 --- a/openlp/core/ui/slidecontroller.py +++ b/openlp/core/ui/slidecontroller.py @@ -460,25 +460,57 @@ class SlideController(QtGui.QWidget): Called, when a shortcut has been activated to jump to a chorus, verse, etc. """ - #FIXME: translatable verse types + try: + from openlp.plugins.songs.lib import VerseTypae + SONGS_PLUGIN_AVAILABLE = True + except ImportError: + SONGS_PLUGIN_AVAILABLE = False verse_type = unicode(self.sender().objectName()) if verse_type.startswith(u'verseShortcut'): - print u'"%s"' % self.current_shortcut - self.current_shortcut = u'V' + if SONGS_PLUGIN_AVAILABLE: + self.current_shortcut = \ + VerseType.TranslatedTags[VerseType.Verse] + else: + self.current_shortcut = u'V' elif verse_type.startswith(u'chorusShortcut'): - self.current_shortcut = u'C' + if SONGS_PLUGIN_AVAILABLE: + self.current_shortcut = \ + VerseType.TranslatedTags[VerseType.Chorus] + else: + self.current_shortcut = u'C' elif verse_type.startswith(u'bridgeShortcut'): - self.current_shortcut = u'B' + if SONGS_PLUGIN_AVAILABLE: + self.current_shortcut = \ + VerseType.TranslatedTags[VerseType.Bridge] + else: + self.current_shortcut = u'B' elif verse_type.startswith(u'preChorusShortcut'): - self.current_shortcut = u'P' + if SONGS_PLUGIN_AVAILABLE: + self.current_shortcut = \ + VerseType.TranslatedTags[VerseType.PreChorus] + else: + self.current_shortcut = u'P' elif verse_type.startswith(u'introShortcut'): - self.current_shortcut = u'I' + if SONGS_PLUGIN_AVAILABLE: + self.current_shortcut = \ + VerseType.TranslatedTags[VerseType.Intro] + else: + self.current_shortcut = u'I' elif verse_type.startswith(u'endingShortcut'): - self.current_shortcut = u'E' + if SONGS_PLUGIN_AVAILABLE: + self.current_shortcut = \ + VerseType.TranslatedTags[VerseType.Ending] + else: + self.current_shortcut = u'E' elif verse_type.startswith(u'otherShortcut'): - self.current_shortcut = u'O' + 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() matches = [match for match in self.slideList.keys() if match.startswith(self.current_shortcut)] if len(matches) == 1: From f346ebebe0354d01421e2a0a2f685580de63df89 Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Mon, 31 Oct 2011 09:53:18 +0100 Subject: [PATCH 10/17] fixed import and added note --- openlp/core/ui/slidecontroller.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/openlp/core/ui/slidecontroller.py b/openlp/core/ui/slidecontroller.py index 03ec3c16b..d24cc2784 100644 --- a/openlp/core/ui/slidecontroller.py +++ b/openlp/core/ui/slidecontroller.py @@ -459,9 +459,15 @@ class SlideController(QtGui.QWidget): """ 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 sequenzes". 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 timeframe of 350ms you have to press "3". """ try: - from openlp.plugins.songs.lib import VerseTypae + from openlp.plugins.songs.lib import VerseType SONGS_PLUGIN_AVAILABLE = True except ImportError: SONGS_PLUGIN_AVAILABLE = False From cac0728d0bdebc7682b92c69c2cd49a7d94f103d Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Mon, 31 Oct 2011 09:54:04 +0100 Subject: [PATCH 11/17] fixed spelling --- openlp/core/ui/slidecontroller.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openlp/core/ui/slidecontroller.py b/openlp/core/ui/slidecontroller.py index d24cc2784..a2b7c76de 100644 --- a/openlp/core/ui/slidecontroller.py +++ b/openlp/core/ui/slidecontroller.py @@ -461,7 +461,7 @@ class SlideController(QtGui.QWidget): etc. **Note**: This implementation is based on shortcuts. But it rather works - like "key sequenzes". You have to press one key after the other and + like "key sequences". 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 timeframe of 350ms you have to press "3". From 5348139cfe23e85fa65153de3af86b793ab3f83f Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Mon, 31 Oct 2011 09:55:59 +0100 Subject: [PATCH 12/17] fixed spelling --- openlp/core/ui/slidecontroller.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/openlp/core/ui/slidecontroller.py b/openlp/core/ui/slidecontroller.py index a2b7c76de..82d7a6629 100644 --- a/openlp/core/ui/slidecontroller.py +++ b/openlp/core/ui/slidecontroller.py @@ -461,10 +461,10 @@ class SlideController(QtGui.QWidget): etc. **Note**: This implementation is based on shortcuts. But it rather works - like "key sequences". You have to press one key after the other and + 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 timeframe of 350ms you have to press "3". + within a time frame of 350ms you have to press "3". """ try: from openlp.plugins.songs.lib import VerseType @@ -528,7 +528,7 @@ class SlideController(QtGui.QWidget): # Start the time as we did not have any match. self.shortcutTimer.start(350) else: - # Reset the key sequenze as we do not have any match and the timer + # Reset the key sequence as we do not have any match and the timer # timed out. self.current_shortcut = u'' From 94c99d1b3d9819ff1b3b7a83190e2f7b744cb264 Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Mon, 31 Oct 2011 10:13:25 +0100 Subject: [PATCH 13/17] fixed detection for more than one match --- openlp/core/ui/slidecontroller.py | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/openlp/core/ui/slidecontroller.py b/openlp/core/ui/slidecontroller.py index 82d7a6629..5ccb4dde9 100644 --- a/openlp/core/ui/slidecontroller.py +++ b/openlp/core/ui/slidecontroller.py @@ -517,7 +517,8 @@ class SlideController(QtGui.QWidget): elif verse_type.isnumeric(): self.current_shortcut += verse_type self.current_shortcut = self.current_shortcut.upper() - matches = [match for match in self.slideList.keys() + keys = self.slideList.keys() + matches = [match for match in keys if match.startswith(self.current_shortcut)] if len(matches) == 1: self.shortcutTimer.stop() @@ -528,8 +529,14 @@ class SlideController(QtGui.QWidget): # Start the time as we did not have any match. self.shortcutTimer.start(350) else: - # Reset the key sequence as we do not have any match and the timer - # timed out. + # The timer timed out. + if self.current_shortcut in keys: + # We had more than one match (e. g. "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): From 71c6a7315ccdde27873fe38be6a3e41d48d38b4e Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Mon, 31 Oct 2011 10:14:07 +0100 Subject: [PATCH 14/17] fixed comment --- openlp/core/ui/slidecontroller.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/openlp/core/ui/slidecontroller.py b/openlp/core/ui/slidecontroller.py index 5ccb4dde9..d871dc474 100644 --- a/openlp/core/ui/slidecontroller.py +++ b/openlp/core/ui/slidecontroller.py @@ -531,8 +531,8 @@ class SlideController(QtGui.QWidget): else: # The timer timed out. if self.current_shortcut in keys: - # We had more than one match (e. g. "V1" and "V10", but "V1" was - # the slide we wanted to go. + # 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() From 3bd0ad91817f29354844972cb6c3cce08d0cd5e5 Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Wed, 2 Nov 2011 18:58:46 +0000 Subject: [PATCH 15/17] Fix crash with two soft breaks --- openlp/core/lib/renderer.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/openlp/core/lib/renderer.py b/openlp/core/lib/renderer.py index 02f6970ac..bcb1f2b70 100644 --- a/openlp/core/lib/renderer.py +++ b/openlp/core/lib/renderer.py @@ -229,6 +229,7 @@ class Renderer(object): # Songs and Custom elif item.is_capable(ItemCapabilities.CanSoftBreak): pages = [] + # if u'[---]' in text: while True: slides = text.split(u'\n[---]\n', 2) @@ -250,7 +251,12 @@ class Renderer(object): # render the first virtual slide. text_contains_break = u'[---]' in text 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: text_to_render = text text = u'' From 0304057e0035d1d55209cbec99f3824932943436 Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Wed, 2 Nov 2011 20:09:06 +0000 Subject: [PATCH 16/17] remove # --- openlp/core/lib/renderer.py | 1 - 1 file changed, 1 deletion(-) diff --git a/openlp/core/lib/renderer.py b/openlp/core/lib/renderer.py index bcb1f2b70..226e8b472 100644 --- a/openlp/core/lib/renderer.py +++ b/openlp/core/lib/renderer.py @@ -229,7 +229,6 @@ class Renderer(object): # Songs and Custom elif item.is_capable(ItemCapabilities.CanSoftBreak): pages = [] - # if u'[---]' in text: while True: slides = text.split(u'\n[---]\n', 2) From 46643ab832472d7b04de564a2f6e03b283f345b3 Mon Sep 17 00:00:00 2001 From: Raoul Snyman Date: Mon, 7 Nov 2011 23:22:35 -0700 Subject: [PATCH 17/17] Added the quoting to database fields. --- openlp/core/lib/db.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/openlp/core/lib/db.py b/openlp/core/lib/db.py index 1b8d086df..cafc867b3 100644 --- a/openlp/core/lib/db.py +++ b/openlp/core/lib/db.py @@ -29,6 +29,7 @@ The :mod:`db` module provides the core database functionality for OpenLP """ import logging import os +from urllib import quote_plus as urlquote from PyQt4 import QtCore 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) else: self.db_url = u'%s://%s:%s@%s/%s' % (db_type, - unicode(settings.value(u'db username').toString()), - unicode(settings.value(u'db password').toString()), - unicode(settings.value(u'db hostname').toString()), - unicode(settings.value(u'db database').toString())) + urlquote(unicode(settings.value(u'db username').toString())), + urlquote(unicode(settings.value(u'db password').toString())), + urlquote(unicode(settings.value(u'db hostname').toString())), + urlquote(unicode(settings.value(u'db database').toString()))) settings.endGroup() if upgrade_mod: db_ver, up_ver = upgrade_db(self.db_url, upgrade_mod)