~openlp-core/openlp/trunk

« back to all changes in this revision

Viewing changes to openlp/core/ui/slidecontroller.py

  • Committer: Raoul Snyman
  • Author(s): Tim Bentley
  • Date: 2011-11-30 20:27:54 UTC
  • mfrom: (1799.1.5 openlp-eclipse)
  • Revision ID: raoul.snyman@saturnlaboratories.co.za-20111130202754-qsbwt5gjxuk2gy5h
Stop keyboard floods getting the slide controller and service manager out of set.

Show diffs side-by-side

added added

removed removed

Lines of Context:
26
26
###############################################################################
27
27
 
28
28
import logging
29
 
import os
30
29
import time
31
30
import copy
 
31
from collections import deque
32
32
 
33
33
from PyQt4 import QtCore, QtGui
34
34
from PyQt4.phonon import Phonon
91
91
            self.typeLabel.setText(UiStrings().Live)
92
92
            self.split = 1
93
93
            self.typePrefix = u'live'
 
94
            self.keypress_queue = deque() 
 
95
            self.keypress_loop = False           
94
96
        else:
95
97
            self.typeLabel.setText(UiStrings().Preview)
96
98
            self.split = 0
578
580
        self.display.videoStop()
579
581
 
580
582
    def servicePrevious(self):
581
 
        time.sleep(0.1)
582
 
        Receiver.send_message('servicemanager_previous_item')
 
583
        """
 
584
        Live event to select the previous service item from the service manager.
 
585
        """
 
586
        self.keypress_queue.append(u'previous')
 
587
        self._process_queue()
 
588
        
583
589
 
584
590
    def serviceNext(self):
585
 
        time.sleep(0.1)
586
 
        Receiver.send_message('servicemanager_next_item')
 
591
        """
 
592
        Live event to select the next service item from the service manager.
 
593
        """
 
594
        self.keypress_queue.append(u'next')
 
595
        self._process_queue()
 
596
        
 
597
    def _process_queue(self):
 
598
        """
 
599
        Process the service item request queue.  The key presses can arrive 
 
600
        faster than the processing so implement a FIFO queue. 
 
601
        """
 
602
        if len(self.keypress_queue):
 
603
            while len(self.keypress_queue) and not self.keypress_loop:
 
604
                self.keypress_loop = True                
 
605
                if self.keypress_queue.popleft() == u'previous':
 
606
                    Receiver.send_message('servicemanager_previous_item')                    
 
607
                else:
 
608
                    Receiver.send_message('servicemanager_next_item')
 
609
            self.keypress_loop = False
 
610
     
587
611
 
588
612
    def screenSizeChanged(self):
589
613
        """
771
795
        log.debug(u'processManagerItem live = %s' % self.isLive)
772
796
        self.onStopLoop()
773
797
        old_item = self.serviceItem
774
 
        # take a copy not a link to the servicemeanager copy.
 
798
        # take a copy not a link to the servicemanager copy.
775
799
        self.serviceItem = copy.copy(serviceItem)
776
800
        if old_item and self.isLive and old_item.is_capable(
777
801
            ItemCapabilities.ProvidesOwnDisplay):