← Back to team overview

openlp-core team mailing list archive

[Merge] lp:~whydoubt/openlp/loop-button into lp:openlp

 

Jeffrey Smith has proposed merging lp:~whydoubt/openlp/loop-button into lp:openlp.

Requested reviews:
  Jonathan Corwin (j-corwin)

For more details, see:
https://code.launchpad.net/~whydoubt/openlp/loop-button/+merge/62778

Make 'continuous loop' button into a selection ('loop' or 'play to end')
-- 
https://code.launchpad.net/~whydoubt/openlp/loop-button/+merge/62778
Your team OpenLP Core is subscribed to branch lp:openlp.
=== modified file 'openlp/core/ui/slidecontroller.py'
--- openlp/core/ui/slidecontroller.py	2011-05-28 04:05:33 +0000
+++ openlp/core/ui/slidecontroller.py	2011-05-28 20:26:31 +0000
@@ -66,7 +66,7 @@
             float(self.screens.current[u'size'].height())
         self.image_manager = self.parent.image_manager
         self.loopList = [
-            u'Start Loop',
+            u'Play Slides Menu',
             u'Loop Separator',
             u'Image SpinBox'
         ]
@@ -153,6 +153,7 @@
             context=QtCore.Qt.WidgetWithChildrenShortcut)
         self.toolbar.addToolbarSeparator(u'Close Separator')
         if self.isLive:
+            # Hide Menu
             self.hideMenu = QtGui.QToolButton(self.toolbar)
             self.hideMenu.setText(translate('OpenLP.SlideController', 'Hide'))
             self.hideMenu.setPopupMode(QtGui.QToolButton.MenuButtonPopup)
@@ -180,27 +181,34 @@
             self.hideMenu.menu().addAction(self.themeScreen)
             self.hideMenu.menu().addAction(self.desktopScreen)
             self.toolbar.addToolbarSeparator(u'Loop Separator')
-            startLoop = self.toolbar.addToolbarButton(
-                # Does not need translating - control string.
-                u'Start Loop', u':/media/media_time.png',
-                translate('OpenLP.SlideController', 'Enable timed slides.'),
-                self.onStartLoop)
-            startLoop.setObjectName(u'startLoop')
-            action_list = ActionList.get_instance()
-            action_list.add_action(startLoop, UiStrings().LiveToolbar)
-            stopLoop = self.toolbar.addToolbarButton(
-                # Does not need translating - control string.
-                u'Stop Loop', u':/media/media_stop.png',
-                translate('OpenLP.SlideController', 'Stop timed slides.'),
-                self.onStopLoop)
-            stopLoop.setObjectName(u'stopLoop')
-            action_list.add_action(stopLoop, UiStrings().LiveToolbar)
-            self.toogleLoop = shortcut_action(self, u'toogleLoop',
-                [QtGui.QKeySequence(u'L')], self.onToggleLoop,
-                category=UiStrings().LiveToolbar)
-            self.toogleLoop.setText(translate('OpenLP.SlideController',
-                'Start/Stop continuous loop'))
-            self.addAction(self.toogleLoop)
+            # Play Slides Menu
+            self.playSlidesMenu = QtGui.QToolButton(self.toolbar)
+            self.playSlidesMenu.setText(translate('OpenLP.SlideController',
+                'Play Slides'))
+            self.playSlidesMenu.setPopupMode(QtGui.QToolButton.MenuButtonPopup)
+            self.toolbar.addToolbarWidget(u'Play Slides Menu',
+                self.playSlidesMenu)
+            self.playSlidesMenu.setMenu(QtGui.QMenu(
+                translate('OpenLP.SlideController', 'Play Slides'),
+                self.toolbar))
+            self.playSlidesLoop = shortcut_action(self.playSlidesMenu,
+                u'playSlidesLoop', [], self.onPlaySlidesLoop,
+                u':/media/media_time.png', False, UiStrings().LiveToolbar)
+            self.playSlidesLoop.setText(
+                translate('OpenLP.SlideController', 'Play Slides in Loop'))
+            self.playSlidesOnce = shortcut_action(self.playSlidesMenu,
+                u'playSlidesOnce', [], self.onPlaySlidesOnce,
+                u':/media/media_time.png', False, UiStrings().LiveToolbar)
+            self.playSlidesOnce.setText(
+                translate('OpenLP.SlideController', 'Play Slides to End'))
+            if QtCore.QSettings().value(self.parent.generalSettingsSection +
+                u'/enable slide loop', QtCore.QVariant(True)).toBool():
+                self.playSlidesMenu.setDefaultAction(self.playSlidesLoop)
+            else:
+                self.playSlidesMenu.setDefaultAction(self.playSlidesOnce)
+            self.playSlidesMenu.menu().addAction(self.playSlidesLoop)
+            self.playSlidesMenu.menu().addAction(self.playSlidesOnce)
+            # Loop Delay Spinbox
             self.delaySpinBox = QtGui.QSpinBox()
             self.delaySpinBox.setRange(1, 180)
             self.toolbar.addToolbarWidget(u'Image SpinBox', self.delaySpinBox)
@@ -321,7 +329,6 @@
                 QtCore.SIGNAL(u'slidecontroller_live_spin_delay'),
                 self.receiveSpinDelay)
             self.toolbar.makeWidgetsInvisible(self.loopList)
-            self.toolbar.actions[u'Stop Loop'].setVisible(False)
         else:
             QtCore.QObject.connect(self.previewListWidget,
                 QtCore.SIGNAL(u'doubleClicked(QModelIndex)'),
@@ -496,10 +503,6 @@
         self.mediabar.setVisible(False)
         self.toolbar.makeWidgetsInvisible([u'Song Menu'])
         self.toolbar.makeWidgetsInvisible(self.loopList)
-        self.toogleLoop.setEnabled(False)
-        self.toolbar.actions[u'Start Loop'].setEnabled(False)
-        self.toolbar.actions[u'Stop Loop'].setEnabled(False)
-        self.toolbar.actions[u'Stop Loop'].setVisible(False)
         if item.is_text():
             if QtCore.QSettings().value(
                 self.parent.songsSettingsSection + u'/display songbar',
@@ -508,9 +511,6 @@
         if item.is_capable(ItemCapabilities.AllowsLoop) and \
             len(item.get_frames()) > 1:
             self.toolbar.makeWidgetsVisible(self.loopList)
-            self.toogleLoop.setEnabled(True)
-            self.toolbar.actions[u'Start Loop'].setEnabled(True)
-            self.toolbar.actions[u'Stop Loop'].setEnabled(True)
         if item.is_media():
             self.toolbar.setVisible(False)
             self.mediabar.setVisible(True)
@@ -943,7 +943,7 @@
             rect.y(), rect.width(), rect.height())
         self.slidePreview.setPixmap(winimg)
 
-    def onSlideSelectedNext(self):
+    def onSlideSelectedNext(self, wrap=None):
         """
         Go to the next slide.
         """
@@ -956,8 +956,11 @@
         else:
             row = self.previewListWidget.currentRow() + 1
             if row == self.previewListWidget.rowCount():
-                if QtCore.QSettings().value(self.parent.generalSettingsSection +
-                    u'/enable slide loop', QtCore.QVariant(True)).toBool():
+                if wrap is None:
+                    wrap = QtCore.QSettings().value(
+                        self.parent.generalSettingsSection +
+                        u'/enable slide loop', QtCore.QVariant(True)).toBool()
+                if wrap:
                     row = 0
                 else:
                     row = self.previewListWidget.rowCount() - 1
@@ -1006,11 +1009,11 @@
                         self.previewListWidget.rowCount() - 1)
             self.slideSelected()
 
-    def onToggleLoop(self, toggled):
+    def onToggleLoop(self):
         """
         Toggles the loop state.
         """
-        if self.toolbar.actions[u'Start Loop'].isVisible():
+        if self.playSlidesLoop.isChecked() or self.playSlidesOnce.isChecked():
             self.onStartLoop()
         else:
             self.onStopLoop()
@@ -1022,8 +1025,6 @@
         if self.previewListWidget.rowCount() > 1:
             self.timer_id = self.startTimer(
                 int(self.delaySpinBox.value()) * 1000)
-            self.toolbar.actions[u'Stop Loop'].setVisible(True)
-            self.toolbar.actions[u'Start Loop'].setVisible(False)
 
     def onStopLoop(self):
         """
@@ -1032,15 +1033,39 @@
         if self.timer_id != 0:
             self.killTimer(self.timer_id)
             self.timer_id = 0
-            self.toolbar.actions[u'Start Loop'].setVisible(True)
-            self.toolbar.actions[u'Stop Loop'].setVisible(False)
+
+    def onPlaySlidesLoop(self, checked=None):
+        """
+        Start or stop 'Play Slides in Loop'
+        """
+        if checked is None:
+            checked = self.playSlidesLoop.isChecked()
+        else:
+            self.playSlidesLoop.setChecked(checked)
+        log.debug(u'onPlaySlidesLoop %s' % checked)
+        self.playSlidesMenu.setDefaultAction(self.playSlidesLoop)
+        self.playSlidesOnce.setChecked(False)
+        self.onToggleLoop()
+
+    def onPlaySlidesOnce(self, checked=None):
+        """
+        Start or stop 'Play Slides to End'
+        """
+        if checked is None:
+            checked = self.playSlidesOnce.isChecked()
+        else:
+            self.playSlidesOnce.setChecked(checked)
+        log.debug(u'onPlaySlidesOnce %s' % checked)
+        self.playSlidesMenu.setDefaultAction(self.playSlidesOnce)
+        self.playSlidesLoop.setChecked(False)
+        self.onToggleLoop()
 
     def timerEvent(self, event):
         """
         If the timer event is for this window select next slide
         """
         if event.timerId() == self.timer_id:
-            self.onSlideSelectedNext()
+            self.onSlideSelectedNext(self.playSlidesLoop.isChecked())
 
     def onEditSong(self):
         """


Follow ups