completed detection + cleaned detection

This commit is contained in:
Andreas Preikschat 2011-10-31 08:41:28 +01:00
parent 360843baf7
commit 2458ffc3bc
1 changed files with 23 additions and 39 deletions

View File

@ -322,7 +322,7 @@ class SlideController(QtGui.QWidget):
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: if self.isLive:
self.old_shortcut = u'' self.current_shortcut = u''
self.shortcutTimer = QtCore.QTimer() self.shortcutTimer = QtCore.QTimer()
self.shortcutTimer.setObjectName(u'shortcutTimer') self.shortcutTimer.setObjectName(u'shortcutTimer')
self.shortcutTimer.setSingleShot(True) self.shortcutTimer.setSingleShot(True)
@ -462,53 +462,37 @@ class SlideController(QtGui.QWidget):
""" """
#FIXME: translatable verse types #FIXME: translatable verse types
verse_type = unicode(self.sender().objectName()) verse_type = unicode(self.sender().objectName())
key = u''
if verse_type.startswith(u'verseShortcut'): 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'): elif verse_type.startswith(u'chorusShortcut'):
key = u'C' self.current_shortcut = u'C'
elif verse_type.startswith(u'bridgeShortcut'): elif verse_type.startswith(u'bridgeShortcut'):
key = u'B' self.current_shortcut = u'B'
elif verse_type.startswith(u'preChorusShortcut'): elif verse_type.startswith(u'preChorusShortcut'):
key = u'P' self.current_shortcut = u'P'
elif verse_type.startswith(u'introShortcut'): elif verse_type.startswith(u'introShortcut'):
key = u'I' self.current_shortcut = u'I'
elif verse_type.startswith(u'endingShortcut'): elif verse_type.startswith(u'endingShortcut'):
key = u'E' self.current_shortcut = u'E'
elif verse_type.startswith(u'otherShortcut'): elif verse_type.startswith(u'otherShortcut'):
key = u'O' self.current_shortcut = u'O'
elif verse_type.isnumeric(): elif verse_type.isnumeric():
key = verse_type self.current_shortcut += verse_type
# The timer was not interrupted by a user input, thus it timed out. matches = [match for match in self.slideList.keys()
elif verse_type == u'shortcutTimer': if match.startswith(self.current_shortcut)]
key = self.old_shortcut if len(matches) == 1:
self.old_shortcut = u'' self.shortcutTimer.stop()
keys = self.slideList.keys() self.current_shortcut = u''
if verse_type != u'shortcutTimer': self.__checkUpdateSelectedSlide(self.slideList[matches[0]])
self.old_shortcut += key self.slideSelected()
elif verse_type != u'shortcutTimer':
# Start the time as we did not have any match.
self.shortcutTimer.start(350) self.shortcutTimer.start(350)
return else:
# matches = [match for match in keys if match.startswith(key)] # Reset the key sequenze as we do not have any match and the timer
# # Stop here and start the timer. # timed out.
# if len(matches) > 1: self.current_shortcut = u''
# 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.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()
def setPreviewHotkeys(self, parent=None): def setPreviewHotkeys(self, parent=None):
self.previousItem.setObjectName(u'previousItemPreview') self.previousItem.setObjectName(u'previousItemPreview')