[vlc-devel] commit: qt4: fix synchronization of advanced buttons in both controllers ( Lukas Durfina )

git version control git at videolan.org
Thu Aug 7 21:13:08 CEST 2008


vlc | branch: master | Lukas Durfina <lukas.durfina at gmail.com> | Wed Aug  6 09:41:50 2008 +0200| [bcdcaf27097dfa3a7d63d16c49917521174715dd] | committer: Jean-Baptiste Kempf 

qt4: fix synchronization of advanced buttons in both controllers

Signed-off-by: Jean-Baptiste Kempf <jb at videolan.org>

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

 modules/gui/qt4/components/interface_widgets.cpp |   48 +++++++++++++++++-----
 modules/gui/qt4/components/interface_widgets.hpp |    8 +++-
 modules/gui/qt4/input_manager.hpp                |    2 +
 3 files changed, 46 insertions(+), 12 deletions(-)

diff --git a/modules/gui/qt4/components/interface_widgets.cpp b/modules/gui/qt4/components/interface_widgets.cpp
index 01dc734..6dd508a 100644
--- a/modules/gui/qt4/components/interface_widgets.cpp
+++ b/modules/gui/qt4/components/interface_widgets.cpp
@@ -58,6 +58,10 @@
 
 #define I_PLAY_TOOLTIP N_("Play\nIf the playlist is empty, open a media")
 
+/* init static variables in advanced controls */
+mtime_t AdvControlsWidget::timeA = 0;
+mtime_t AdvControlsWidget::timeB = 0;
+
 /**********************************************************************
  * Video Widget. A simple frame on which video is drawn
  * This class handles resize issues
@@ -298,7 +302,7 @@ void VisualSelector::next()
     aButton->setMinimumSize( QSize( 26, 26 ) ); \
     aButton->setIconSize( QSize( 20, 20 ) ); }
 
-AdvControlsWidget::AdvControlsWidget( intf_thread_t *_p_i ) :
+AdvControlsWidget::AdvControlsWidget( intf_thread_t *_p_i, bool b_fsCreation = false ) :
                                            QFrame( NULL ), p_intf( _p_i )
 {
     QHBoxLayout *advLayout = new QHBoxLayout( this );
@@ -314,8 +318,15 @@ AdvControlsWidget::AdvControlsWidget( intf_thread_t *_p_i ) :
       qtr( "Loop from point A to point B continuously.\nClick to set point A" ),
       fromAtoB() );
     timeA = timeB = 0;
-    CONNECT( THEMIM->getIM(), positionUpdated( float, int, int ),
-             this, AtoBLoop( float, int, int ) );
+    /* in FS controller we skip this, because we dont want to have it double
+       controlled */
+    if( !b_fsCreation )
+        CONNECT( THEMIM->getIM(), positionUpdated( float, int, int ),
+                 this, AtoBLoop( float, int, int ) );
+    /* set up synchronization between main controller and fs controller */
+    CONNECT( THEMIM->getIM(), advControlsSetIcon(), this, setIcon() );
+    connect( this, SIGNAL( timeChanged() ),
+        THEMIM->getIM(), SIGNAL( advControlsSetIcon()));
 #if 0
     frameButton = new QPushButton( "Fr" );
     frameButton->setMaximumSize( QSize( 26, 26 ) );
@@ -368,22 +379,39 @@ void AdvControlsWidget::fromAtoB()
     if( !timeA )
     {
         timeA = var_GetTime( THEMIM->getInput(), "time"  );
-        ABButton->setToolTip( qtr( "Click to set point B" ) );
-        ABButton->setIcon( QIcon( ":/atob_noa" ) );
+        emit timeChanged();
         return;
     }
     if( !timeB )
     {
         timeB = var_GetTime( THEMIM->getInput(), "time"  );
         var_SetTime( THEMIM->getInput(), "time" , timeA );
-        ABButton->setIcon( QIcon( ":/atob" ) );
-        ABButton->setToolTip( qtr( "Stop the A to B loop" ) );
+        emit timeChanged();
         return;
     }
     timeA = 0;
     timeB = 0;
-    ABButton->setToolTip( qtr( "Loop from point A to point B continuously\nClick to set point A" ) );
-    ABButton->setIcon( QIcon( ":/atob_nob" ) );
+    emit timeChanged();
+}
+
+/* setting/synchro icons after click on main or fs controller */
+void AdvControlsWidget::setIcon()
+{
+    if( !timeA && !timeB)
+    {
+        ABButton->setIcon( QIcon( ":/atob_nob" ) );
+        ABButton->setToolTip( qtr( "Loop from point A to point B continuously\nClick to set point A" ) );
+    }
+    else if( timeA && !timeB )
+    {
+        ABButton->setIcon( QIcon( ":/atob_noa" ) );
+        ABButton->setToolTip( qtr( "Click to set point B" ) );
+    }
+    else if( timeA && timeB )
+    {
+        ABButton->setIcon( QIcon( ":/atob" ) );
+        ABButton->setToolTip( qtr( "Stop the A to B loop" ) );
+    }
 }
 
 /* Function called regularly when in an AtoB loop */
@@ -441,7 +469,7 @@ ControlsWidget::ControlsWidget( intf_thread_t *_p_i,
     /* advanced Controls handling */
     b_advancedVisible = b_advControls;
 
-    advControls = new AdvControlsWidget( p_intf );
+    advControls = new AdvControlsWidget( p_intf, b_fsCreation );
     if( !b_advancedVisible ) advControls->hide();
 
     /** Disc and Menus handling */
diff --git a/modules/gui/qt4/components/interface_widgets.hpp b/modules/gui/qt4/components/interface_widgets.hpp
index 30613f0..6150a01 100644
--- a/modules/gui/qt4/components/interface_widgets.hpp
+++ b/modules/gui/qt4/components/interface_widgets.hpp
@@ -145,7 +145,7 @@ class AdvControlsWidget : public QFrame
 {
     Q_OBJECT
 public:
-    AdvControlsWidget( intf_thread_t *);
+    AdvControlsWidget( intf_thread_t *, bool );
     virtual ~AdvControlsWidget();
 
     void enableInput( bool );
@@ -156,7 +156,7 @@ private:
     QPushButton *recordButton, *ABButton;
     QPushButton *snapshotButton, *frameButton;
 
-    mtime_t timeA, timeB;
+    static mtime_t timeA, timeB;
 
 private slots:
     void snapshot();
@@ -166,6 +166,10 @@ private slots:
     void fromAtoB();
     void record();
     void AtoBLoop( float, int, int );
+    void setIcon();
+
+signals:
+    void timeChanged();
 };
 
 /* Button Bar */
diff --git a/modules/gui/qt4/input_manager.hpp b/modules/gui/qt4/input_manager.hpp
index 6d133f6..910dd0b 100644
--- a/modules/gui/qt4/input_manager.hpp
+++ b/modules/gui/qt4/input_manager.hpp
@@ -124,6 +124,8 @@ signals:
     void toggleTelexButtons();
     void toggleTelexTransparency();
     void setNewTelexPage( int );
+    /// Advanced buttons
+    void advControlsSetIcon();
 };
 
 class MainInputManager : public QObject




More information about the vlc-devel mailing list