Stop keyboard floods getting the slide controller and service manager out of set.

bzr-revno: 1808
Fixes: https://launchpad.net/bugs/892571
This commit is contained in:
Tim Bentley 2011-11-30 22:27:54 +02:00 committed by Raoul Snyman
commit 8fee84d052

View File

@ -26,9 +26,9 @@
###############################################################################
import logging
import os
import time
import copy
from collections import deque
from PyQt4 import QtCore, QtGui
from PyQt4.phonon import Phonon
@ -91,6 +91,8 @@ class SlideController(QtGui.QWidget):
self.typeLabel.setText(UiStrings().Live)
self.split = 1
self.typePrefix = u'live'
self.keypress_queue = deque()
self.keypress_loop = False
else:
self.typeLabel.setText(UiStrings().Preview)
self.split = 0
@ -578,12 +580,34 @@ class SlideController(QtGui.QWidget):
self.display.videoStop()
def servicePrevious(self):
time.sleep(0.1)
Receiver.send_message('servicemanager_previous_item')
"""
Live event to select the previous service item from the service manager.
"""
self.keypress_queue.append(u'previous')
self._process_queue()
def serviceNext(self):
time.sleep(0.1)
"""
Live event to select the next service item from the service manager.
"""
self.keypress_queue.append(u'next')
self._process_queue()
def _process_queue(self):
"""
Process the service item request queue. The key presses can arrive
faster than the processing so implement a FIFO queue.
"""
if len(self.keypress_queue):
while len(self.keypress_queue) and not self.keypress_loop:
self.keypress_loop = True
if self.keypress_queue.popleft() == u'previous':
Receiver.send_message('servicemanager_previous_item')
else:
Receiver.send_message('servicemanager_next_item')
self.keypress_loop = False
def screenSizeChanged(self):
"""
@ -771,7 +795,7 @@ class SlideController(QtGui.QWidget):
log.debug(u'processManagerItem live = %s' % self.isLive)
self.onStopLoop()
old_item = self.serviceItem
# take a copy not a link to the servicemeanager copy.
# take a copy not a link to the servicemanager copy.
self.serviceItem = copy.copy(serviceItem)
if old_item and self.isLive and old_item.is_capable(
ItemCapabilities.ProvidesOwnDisplay):