← Back to team overview

openlp-core team mailing list archive

[Merge] lp:~staffj01/openlp/slideadvance into lp:openlp

 

Jonathan Stafford has proposed merging lp:~staffj01/openlp/slideadvance into lp:openlp.

Requested reviews:
  Raoul Snyman (raoul-snyman)
  Tim Bentley (trb143)

For more details, see:
https://code.launchpad.net/~staffj01/openlp/slideadvance/+merge/90623

Changing the "Wrap Slide" option into a three-way radio button selection to allow the option of the up/down arrow keys to jump between service items at the end of each song, etc.
-- 
https://code.launchpad.net/~staffj01/openlp/slideadvance/+merge/90623
Your team OpenLP Core is subscribed to branch lp:openlp.
=== modified file 'openlp/core/lib/__init__.py'
--- openlp/core/lib/__init__.py	2011-12-27 10:33:55 +0000
+++ openlp/core/lib/__init__.py	2012-01-29 22:24:34 +0000
@@ -43,6 +43,26 @@
     Audio = 1
     Video = 2
 
+
+class SlideLimits(object):
+    """
+    Provides an enumeration for behaviour of OpenLP at the end limits of each
+    service item when pressing the up/down arrow keys
+    """
+    End = 1
+    Wrap = 2
+    Next = 3
+
+
+class ServiceItemAction(object):
+    """
+    Provides an enumeration for the required action moving between service 
+    items by left/right arrow keys
+    """
+    Previous = 1
+    PreviousLastSlide = 2
+    Next = 3
+
 def translate(context, text, comment=None,
     encoding=QtCore.QCoreApplication.CodecForTr, n=-1,
     translate=QtCore.QCoreApplication.translate):

=== modified file 'openlp/core/lib/eventreceiver.py'
--- openlp/core/lib/eventreceiver.py	2011-12-27 10:33:55 +0000
+++ openlp/core/lib/eventreceiver.py	2012-01-29 22:24:34 +0000
@@ -111,6 +111,9 @@
 
     ``slidecontroller_live_spin_delay``
         Pushes out the loop delay.
+        
+    ``slidecontroller_update_slide_limits``
+        Updates the slide_limits variable from the saved settings.
 
     ``slidecontroller_live_stop_loop``
         Stop the loop on the main display.

=== modified file 'openlp/core/ui/generaltab.py'
--- openlp/core/ui/generaltab.py	2011-12-27 10:33:55 +0000
+++ openlp/core/ui/generaltab.py	2012-01-29 22:24:34 +0000
@@ -30,6 +30,7 @@
 
 from openlp.core.lib import SettingsTab, Receiver, translate
 from openlp.core.lib.ui import UiStrings
+from openlp.core.lib import SlideLimits
 from openlp.core.ui import ScreenList
 
 log = logging.getLogger(__name__)
@@ -97,9 +98,6 @@
         self.autoPreviewCheckBox = QtGui.QCheckBox(self.settingsGroupBox)
         self.autoPreviewCheckBox.setObjectName(u'autoPreviewCheckBox')
         self.settingsLayout.addRow(self.autoPreviewCheckBox)
-        self.enableLoopCheckBox = QtGui.QCheckBox(self.settingsGroupBox)
-        self.enableLoopCheckBox.setObjectName(u'enableLoopCheckBox')
-        self.settingsLayout.addRow(self.enableLoopCheckBox)
         # Moved here from image tab
         self.timeoutLabel = QtGui.QLabel(self.settingsGroupBox)
         self.timeoutLabel.setObjectName(u'timeoutLabel')
@@ -180,6 +178,38 @@
         self.audioLayout.addWidget(self.startPausedCheckBox)
         self.rightLayout.addWidget(self.audioGroupBox)
         self.rightLayout.addStretch()
+        # Service Item Slide Limits
+        self.slideGroupBox = QtGui.QGroupBox(self.rightColumn)
+        self.slideGroupBox.setObjectName(u'slideGroupBox')
+        self.slideLayout = QtGui.QFormLayout(self.slideGroupBox)
+        self.slideLayout.setLabelAlignment(
+            QtCore.Qt.AlignLeft | QtCore.Qt.AlignTop)
+        self.slideLayout.setFormAlignment(
+            QtCore.Qt.AlignLeft | QtCore.Qt.AlignTop)
+        self.slideLayout.setObjectName(u'slideLayout')
+        self.endSlideRadioButton = QtGui.QRadioButton(self.slideGroupBox)
+        self.endSlideRadioButton.setObjectName(u'endSlideRadioButton')
+        self.endSlideLabel = QtGui.QLabel(self.slideGroupBox)
+        self.endSlideLabel.setWordWrap(True)
+        self.endSlideLabel.setObjectName(u'endSlideLabel')
+        self.slideLayout.addRow(self.endSlideRadioButton, self.endSlideLabel)
+        self.wrapSlideRadioButton = QtGui.QRadioButton(self.slideGroupBox)
+        self.wrapSlideRadioButton.setObjectName(u'wrapSlideRadioButton')
+        self.wrapSlideLabel = QtGui.QLabel(self.slideGroupBox)
+        self.wrapSlideLabel.setWordWrap(True)
+        self.wrapSlideLabel.setObjectName(u'wrapSlideLabel')
+        self.slideLayout.addRow(self.wrapSlideRadioButton,
+            self.wrapSlideLabel)
+        self.nextSlideRadioButton = QtGui.QRadioButton(self.slideGroupBox)
+        self.nextSlideRadioButton.setChecked(True)
+        self.nextSlideRadioButton.setObjectName(u'nextSlideRadioButton')
+        self.nextSlideLabel = QtGui.QLabel(self.slideGroupBox)
+        self.nextSlideLabel.setWordWrap(True)
+        self.nextSlideLabel.setObjectName(u'nextSlideLabel')
+        self.slideLayout.addRow(self.nextSlideRadioButton,
+            self.nextSlideLabel)
+        self.rightLayout.addWidget(self.slideGroupBox)
+        self.rightLayout.addStretch()
         # Signals and slots
         QtCore.QObject.connect(self.overrideCheckBox,
             QtCore.SIGNAL(u'toggled(bool)'), self.onOverrideCheckBoxToggled)
@@ -196,6 +226,12 @@
         # Reload the tab, as the screen resolution/count may have changed.
         QtCore.QObject.connect(Receiver.get_receiver(),
             QtCore.SIGNAL(u'config_screen_changed'), self.load)
+        QtCore.QObject.connect(self.endSlideRadioButton,
+            QtCore.SIGNAL(u'pressed()'), self.onEndSlideButtonPressed)
+        QtCore.QObject.connect(self.wrapSlideRadioButton,
+            QtCore.SIGNAL(u'pressed()'), self.onWrapSlideButtonPressed)
+        QtCore.QObject.connect(self.nextSlideRadioButton,
+            QtCore.SIGNAL(u'pressed()'), self.onNextSlideButtonPressed)
         # Remove for now
         self.usernameLabel.setVisible(False)
         self.usernameEdit.setVisible(False)
@@ -231,8 +267,6 @@
             'Unblank display when adding new live item'))
         self.autoPreviewCheckBox.setText(translate('OpenLP.GeneralTab',
             'Automatically preview next item in service'))
-        self.enableLoopCheckBox.setText(translate('OpenLP.GeneralTab',
-            'Enable slide wrap-around'))
         self.timeoutLabel.setText(translate('OpenLP.GeneralTab',
             'Timed slide interval:'))
         self.timeoutSpinBox.setSuffix(translate('OpenLP.GeneralTab', ' sec'))
@@ -256,6 +290,25 @@
             translate('OpenLP.GeneralTab', 'Background Audio'))
         self.startPausedCheckBox.setText(
             translate('OpenLP.GeneralTab', 'Start background audio paused'))
+        # Slide Limits
+        self.slideGroupBox.setTitle(
+            translate('OpenLP.GeneralTab', 'Service Item Slide Limits'))
+        self.endSlideRadioButton.setText(
+            translate('OpenLP.GeneralTab', '&End Slide'))
+        self.endSlideLabel.setText(
+            translate('OpenLP.GeneralTab', 'Up and down arrow keys '
+            'stop at the top and bottom slides of each Service Item.'))
+        self.wrapSlideRadioButton.setText(
+            translate('OpenLP.GeneralTab', '&Wrap Slide'))
+        self.wrapSlideLabel.setText(
+            translate('OpenLP.GeneralTab', 'Up and down arrow keys '
+            'wrap around at the top and bottom slides of each Service Item.'))
+        self.nextSlideRadioButton.setText(
+            translate('OpenLP.GeneralTab', '&Next Slide'))
+        self.nextSlideLabel.setText(
+            translate('OpenLP.GeneralTab', 'Up and down arrow keys '
+            'advance to the the next or previous Service Item from the '
+            'top and bottom slides of each Service Item.'))
 
     def load(self):
         """
@@ -289,8 +342,6 @@
             QtCore.QVariant(True)).toBool())
         self.autoPreviewCheckBox.setChecked(settings.value(u'auto preview',
             QtCore.QVariant(False)).toBool())
-        self.enableLoopCheckBox.setChecked(settings.value(u'enable slide loop',
-            QtCore.QVariant(True)).toBool())
         self.timeoutSpinBox.setValue(settings.value(u'loop delay',
            QtCore.QVariant(5)).toInt()[0])
         self.overrideCheckBox.setChecked(settings.value(u'override position',
@@ -311,6 +362,16 @@
         self.customHeightValueEdit.setEnabled(self.overrideCheckBox.isChecked())
         self.customWidthValueEdit.setEnabled(self.overrideCheckBox.isChecked())
         self.display_changed = False
+        settings.beginGroup(self.settingsSection)
+        self.slide_limits = settings.value(
+            u'slide limits', QtCore.QVariant(SlideLimits.End)).toInt()[0]
+        settings.endGroup()
+        if self.slide_limits == SlideLimits.End:
+            self.endSlideRadioButton.setChecked(True)
+        elif self.slide_limits == SlideLimits.Wrap:
+            self.wrapSlideRadioButton.setChecked(True)
+        else:
+            self.nextSlideRadioButton.setChecked(True)
 
     def save(self):
         """
@@ -336,8 +397,6 @@
             QtCore.QVariant(self.autoUnblankCheckBox.isChecked()))
         settings.setValue(u'auto preview',
             QtCore.QVariant(self.autoPreviewCheckBox.isChecked()))
-        settings.setValue(u'enable slide loop',
-            QtCore.QVariant(self.enableLoopCheckBox.isChecked()))
         settings.setValue(u'loop delay',
             QtCore.QVariant(self.timeoutSpinBox.value()))
         settings.setValue(u'ccli number',
@@ -358,7 +417,8 @@
             QtCore.QVariant(self.overrideCheckBox.isChecked()))
         settings.setValue(u'audio start paused',
             QtCore.QVariant(self.startPausedCheckBox.isChecked()))
-        settings.endGroup()
+        settings.setValue(u'slide limits', QtCore.QVariant(self.slide_limits))
+        settings.endGroup()        
         # On save update the screens as well
         self.postSetUp(True)
 
@@ -386,6 +446,7 @@
         if self.display_changed:
             Receiver.send_message(u'config_screen_changed')
         self.display_changed = False
+        Receiver.send_message(u'slidecontroller_update_slide_limits')
 
     def onOverrideCheckBoxToggled(self, checked):
         """
@@ -405,3 +466,12 @@
         Called when the width, height, x position or y position has changed.
         """
         self.display_changed = True
+        
+    def onEndSlideButtonPressed(self):
+        self.slide_limits = SlideLimits.End
+
+    def onWrapSlideButtonPressed(self):
+        self.slide_limits = SlideLimits.Wrap
+
+    def onNextSlideButtonPressed(self):
+        self.slide_limits = SlideLimits.Next

=== modified file 'openlp/core/ui/mainwindow.py'
--- openlp/core/ui/mainwindow.py	2011-12-27 10:33:55 +0000
+++ openlp/core/ui/mainwindow.py	2012-01-29 22:24:34 +0000
@@ -38,6 +38,7 @@
     PluginManager, Receiver, translate, ImageManager, PluginStatus
 from openlp.core.lib.ui import UiStrings, base_action, checkable_action, \
     icon_action, shortcut_action
+from openlp.core.lib import SlideLimits
 from openlp.core.ui import AboutForm, SettingsForm, ServiceManager, \
     ThemeManager, SlideController, PluginForm, MediaDockManager, \
     ShortcutListForm, FormattingTagForm
@@ -1307,6 +1308,18 @@
         Load the main window settings.
         """
         log.debug(u'Loading QSettings')
+       # Migrate Wrap Settings to Slide Advance Settings
+        if QtCore.QSettings().contains(self.generalSettingsSection + 
+            u'/enable slide loop'):
+            if QtCore.QSettings().value(self.generalSettingsSection +
+                u'/enable slide loop', QtCore.QVariant(True)).toBool():
+                QtCore.QSettings().setValue(self.generalSettingsSection +
+                    u'/slide limits', QtCore.QVariant(SlideLimits.Wrap))
+            else:
+                QtCore.QSettings().setValue(self.generalSettingsSection +
+                    u'/slide limits', QtCore.QVariant(SlideLimits.End))
+            QtCore.QSettings().remove(self.generalSettingsSection + 
+                u'/enable slide loop')
         settings = QtCore.QSettings()
         # Remove obsolete entries.
         settings.remove(u'custom slide')

=== modified file 'openlp/core/ui/servicemanager.py'
--- openlp/core/ui/servicemanager.py	2012-01-01 13:43:43 +0000
+++ openlp/core/ui/servicemanager.py	2012-01-29 22:24:34 +0000
@@ -826,7 +826,7 @@
                 lookFor = 1
             serviceIterator += 1
 
-    def previousItem(self):
+    def previousItem(self, message):
         """
         Called by the SlideController to select the previous service item.
         """
@@ -834,15 +834,26 @@
             return
         selected = self.serviceManagerList.selectedItems()[0]
         prevItem = None
+        prevItemLastSlide = None
         serviceIterator = QtGui.QTreeWidgetItemIterator(self.serviceManagerList)
         while serviceIterator.value():
             if serviceIterator.value() == selected:
-                if prevItem:
+                if message == u'last slide' and prevItemLastSlide:
+                    pos = prevItem.data(0, QtCore.Qt.UserRole).toInt()[0]
+                    check_expanded = self.serviceItems[pos - 1][u'expanded']
+                    self.serviceManagerList.setCurrentItem(prevItemLastSlide)
+                    if not check_expanded:
+                        self.serviceManagerList.collapseItem(prevItem)
+                    self.makeLive()
+                    self.serviceManagerList.setCurrentItem(prevItem)
+                elif prevItem:
                     self.serviceManagerList.setCurrentItem(prevItem)
                     self.makeLive()
                 return
             if serviceIterator.value().parent() is None:
                 prevItem = serviceIterator.value()
+            if serviceIterator.value().parent() is prevItem:
+                prevItemLastSlide = serviceIterator.value()
             serviceIterator += 1
 
     def onSetItem(self, message):

=== modified file 'openlp/core/ui/slidecontroller.py'
--- openlp/core/ui/slidecontroller.py	2011-12-29 17:50:42 +0000
+++ openlp/core/ui/slidecontroller.py	2012-01-29 22:24:34 +0000
@@ -35,6 +35,7 @@
 from openlp.core.lib import OpenLPToolbar, Receiver, ItemCapabilities, \
     translate, build_icon, ServiceItem, build_html, PluginManager, ServiceItem
 from openlp.core.lib.ui import UiStrings, shortcut_action
+from openlp.core.lib import SlideLimits, ServiceItemAction
 from openlp.core.ui import HideMode, MainDisplay, Display, ScreenList
 from openlp.core.utils.actions import ActionList, CategoryOrder
 
@@ -102,6 +103,8 @@
         self.songEdit = False
         self.selectedRow = 0
         self.serviceItem = None
+        self.slide_limits = None
+        self.updateSlideLimits()
         self.panel = QtGui.QWidget(parent.controlSplitter)
         self.slideList = {}
         # Layout for holding panel
@@ -450,6 +453,9 @@
         QtCore.QObject.connect(Receiver.get_receiver(),
             QtCore.SIGNAL(u'slidecontroller_%s_unblank' % self.typePrefix),
             self.onSlideUnblank)
+        QtCore.QObject.connect(Receiver.get_receiver(),
+            QtCore.SIGNAL(u'slidecontroller_update_slide_limits'),
+            self.updateSlideLimits)
 
     def slideShortcutActivated(self):
         """
@@ -592,14 +598,14 @@
         """
         Live event to select the previous service item from the service manager.
         """
-        self.keypress_queue.append(u'previous')
+        self.keypress_queue.append(ServiceItemAction.Previous)
         self._process_queue()
 
     def serviceNext(self):
         """
         Live event to select the next service item from the service manager.
         """
-        self.keypress_queue.append(u'next')
+        self.keypress_queue.append(ServiceItemAction.Next)
         self._process_queue()
 
     def _process_queue(self):
@@ -610,8 +616,12 @@
         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')
+                keypressCommand = self.keypress_queue.popleft()
+                if keypressCommand == ServiceItemAction.Previous:
+                    Receiver.send_message('servicemanager_previous_item', None)
+                elif keypressCommand == ServiceItemAction.PreviousLastSlide:
+                    # Go to the last slide of the previous item
+                    Receiver.send_message('servicemanager_previous_item', u'last slide')
                 else:
                     Receiver.send_message('servicemanager_next_item')
             self.keypress_loop = False
@@ -699,6 +709,14 @@
         Adjusts the value of the ``delaySpinBox`` to the given one.
         """
         self.delaySpinBox.setValue(int(value))
+    
+    def updateSlideLimits(self):
+        """
+        Updates the Slide Limits variable from the settings.
+        """
+        self.slide_limits = QtCore.QSettings().value(
+            self.parent().generalSettingsSection + u'/slide limits',
+            QtCore.QVariant(SlideLimits.End)).toInt()[0]
 
     def enableToolBar(self, item):
         """
@@ -1177,10 +1195,14 @@
             row = self.previewListWidget.currentRow() + 1
             if row == self.previewListWidget.rowCount():
                 if wrap is None:
-                    wrap = QtCore.QSettings().value(
-                        self.parent().generalSettingsSection +
-                        u'/enable slide loop', QtCore.QVariant(True)).toBool()
-                if wrap:
+                    if self.slide_limits == SlideLimits.Wrap:
+                        row = 0
+                    elif self.slide_limits == SlideLimits.Next:
+                        self.serviceNext()
+                        return
+                    else:
+                        row = self.previewListWidget.rowCount() - 1
+                elif wrap:
                     row = 0
                 else:
                     row = self.previewListWidget.rowCount() - 1
@@ -1200,9 +1222,12 @@
         else:
             row = self.previewListWidget.currentRow() - 1
             if row == -1:
-                if QtCore.QSettings().value(self.parent().generalSettingsSection
-                    + u'/enable slide loop', QtCore.QVariant(True)).toBool():
+                if self.slide_limits == SlideLimits.Wrap:
                     row = self.previewListWidget.rowCount() - 1
+                elif self.slide_limits == SlideLimits.Next:
+                    self.keypress_queue.append(ServiceItemAction.PreviousLastSlide)
+                    self._process_queue()
+                    return
                 else:
                     row = 0
             self.__checkUpdateSelectedSlide(row)


Follow ups