[vlc-commits] Qt4: use QVLCBool for random and repeat/loop

Rémi Denis-Courmont git at videolan.org
Tue Apr 17 18:58:27 CEST 2012


vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Tue Apr 17 19:58:05 2012 +0300| [5c524ec7b9e79fc24dca0f8fd87bcde45e2dac6c] | committer: Rémi Denis-Courmont

Qt4: use QVLCBool for random and repeat/loop

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=5c524ec7b9e79fc24dca0f8fd87bcde45e2dac6c
---

 modules/gui/qt4/input_manager.cpp |   55 ++++++++-----------------------------
 modules/gui/qt4/input_manager.hpp |    7 +++-
 2 files changed, 17 insertions(+), 45 deletions(-)

diff --git a/modules/gui/qt4/input_manager.cpp b/modules/gui/qt4/input_manager.cpp
index 8d62aea..47f8243 100644
--- a/modules/gui/qt4/input_manager.cpp
+++ b/modules/gui/qt4/input_manager.cpp
@@ -56,11 +56,6 @@ static int VolumeChanged( vlc_object_t *, const char *,
 static int SoundMuteChanged( vlc_object_t *, const char *,
                         vlc_value_t, vlc_value_t, void * );
 
-static int RandomChanged( vlc_object_t *, const char *,
-                        vlc_value_t, vlc_value_t, void * );
-static int LoopOrRepeatChanged( vlc_object_t *, const char *,
-                        vlc_value_t, vlc_value_t, void * );
-
 static int InputEvent( vlc_object_t *, const char *,
                        vlc_value_t, vlc_value_t, void * );
 static int VbiEvent( vlc_object_t *, const char *,
@@ -929,7 +924,9 @@ void InputManager::AtoBLoop( float, int64_t i_time, int )
  **********************************************************************/
 
 MainInputManager::MainInputManager( intf_thread_t *_p_intf )
-                 : QObject(NULL), p_intf( _p_intf )
+    : QObject(NULL), p_intf( _p_intf ),
+      random( VLC_OBJECT(THEPL), "random" ),
+      repeat( VLC_OBJECT(THEPL), "repeat" ), loop( VLC_OBJECT(THEPL), "loop" )
 {
     p_input = NULL;
     im = new InputManager( this, p_intf );
@@ -940,9 +937,9 @@ MainInputManager::MainInputManager( intf_thread_t *_p_intf )
     var_AddCallback( THEPL, "leaf-to-parent", LeafToParent, this );
     var_AddCallback( THEPL, "playlist-item-append", PLItemAppended, this );
     var_AddCallback( THEPL, "playlist-item-deleted", PLItemRemoved, this );
-    var_AddCallback( THEPL, "random", RandomChanged, this );
-    var_AddCallback( THEPL, "repeat", LoopOrRepeatChanged, this );
-    var_AddCallback( THEPL, "loop", LoopOrRepeatChanged, this );
+    random.addCallback( this, SLOT(notifyRandom(bool)) );
+    repeat.addCallback( this, SLOT(notifyRepeatLoop(bool)) );
+    loop.addCallback( this, SLOT(notifyRepeatLoop(bool)) );
 
     var_AddCallback( THEPL, "volume", VolumeChanged, this );
     var_AddCallback( THEPL, "mute", SoundMuteChanged, this );
@@ -980,9 +977,6 @@ MainInputManager::~MainInputManager()
     var_DelCallback( THEPL, "item-current", PLItemChanged, this );
     var_DelCallback( THEPL, "playlist-item-append", PLItemAppended, this );
     var_DelCallback( THEPL, "playlist-item-deleted", PLItemRemoved, this );
-    var_DelCallback( THEPL, "random", RandomChanged, this );
-    var_DelCallback( THEPL, "repeat", LoopOrRepeatChanged, this );
-    var_DelCallback( THEPL, "loop", LoopOrRepeatChanged, this );
 
     /* Save some interface state in configuration, at module quit */
     config_PutInt( p_intf, "random", var_GetBool( THEPL, "random" ) );
@@ -1030,12 +1024,6 @@ void MainInputManager::customEvent( QEvent *event )
         plEv = static_cast<PLEvent*>( event );
         emit playlistNotEmpty( plEv->i_item >= 0 );
         return;
-    case RandomChanged_Type:
-        emit randomChanged( var_GetBool( THEPL, "random" ) );
-        return;
-    case LoopOrRepeatChanged_Type:
-        notifyRepeatLoop();
-        return;
     case LeafToParent_Type:
         plEv = static_cast<PLEvent*>( event );
         emit leafBecameParent( plEv->i_item );
@@ -1143,7 +1131,12 @@ void MainInputManager::toggleRandom()
     var_ToggleBool( THEPL, "random" );
 }
 
-void MainInputManager::notifyRepeatLoop()
+void MainInputManager::notifyRandom(bool value)
+{
+    emit randomChanged(value);
+}
+
+void MainInputManager::notifyRepeatLoop(bool)
 {
     int i_value = var_GetBool( THEPL, "loop" ) * REPEAT_ALL
               + var_GetBool( THEPL, "repeat" ) * REPEAT_ONE;
@@ -1265,27 +1258,3 @@ static int PLItemRemoved
     }
     return VLC_SUCCESS;
 }
-
-static int RandomChanged
-( vlc_object_t * obj, const char *var, vlc_value_t old, vlc_value_t cur, void *data )
-{
-    VLC_UNUSED( obj ); VLC_UNUSED( var ); VLC_UNUSED( old ); VLC_UNUSED( cur );
-
-    MainInputManager *mim = static_cast<MainInputManager*>(data);
-
-    IMEvent *event = new IMEvent( RandomChanged_Type );
-    QApplication::postEvent( mim, event );
-    return VLC_SUCCESS;
-}
-
-static int LoopOrRepeatChanged
-( vlc_object_t * obj, const char *var, vlc_value_t old, vlc_value_t cur, void *data )
-{
-    VLC_UNUSED( obj ); VLC_UNUSED( var ); VLC_UNUSED( old ); VLC_UNUSED( cur );
-
-    MainInputManager *mim = static_cast<MainInputManager*>(data);
-
-    IMEvent *event = new IMEvent( LoopOrRepeatChanged_Type );
-    QApplication::postEvent( mim, event );
-    return VLC_SUCCESS;
-}
diff --git a/modules/gui/qt4/input_manager.hpp b/modules/gui/qt4/input_manager.hpp
index efcfb67..61957ac 100644
--- a/modules/gui/qt4/input_manager.hpp
+++ b/modules/gui/qt4/input_manager.hpp
@@ -33,6 +33,7 @@
 
 #include "qt4.hpp"
 #include "util/singleton.hpp"
+#include "variables.hpp"
 
 #include <QObject>
 #include <QEvent>
@@ -273,8 +274,8 @@ private:
     InputManager            *im;
     input_thread_t          *p_input;
     intf_thread_t           *p_intf;
+    QVLCBool random, repeat, loop;
 
-    void notifyRepeatLoop();
 public slots:
     void togglePlayPause();
     void play();
@@ -287,7 +288,9 @@ public slots:
     void activatePlayQuit( bool );
 
     void loopRepeatLoopStatus();
-
+private slots:
+    void notifyRandom( bool );
+    void notifyRepeatLoop( bool );
 signals:
     void inputChanged( input_thread_t * );
     void volumeChanged();



More information about the vlc-commits mailing list