]> git.sesse.net Git - vlc/commitdiff
Qt4: Really split the TimeLabel into its own class.
authorJean-Baptiste Kempf <jb@videolan.org>
Mon, 22 Sep 2008 02:46:42 +0000 (19:46 -0700)
committerJean-Baptiste Kempf <jb@videolan.org>
Mon, 22 Sep 2008 02:48:24 +0000 (19:48 -0700)
Code simplification and TimeLabel in the FSC.

modules/gui/qt4/components/interface_widgets.cpp
modules/gui/qt4/components/interface_widgets.hpp
modules/gui/qt4/main_interface.cpp
modules/gui/qt4/main_interface.hpp

index a77f726d9d9c6eac68c3427d6489263311da307b..9863b3b56c7d6de38258acef8dc0b324a4c6c0c2 100644 (file)
@@ -1027,6 +1027,7 @@ FullscreenControllerWidget::FullscreenControllerWidget( intf_thread_t *_p_i,
     fsLayout->addWidget( slider, 0, 1, 1, 9 );
     fsLayout->addWidget( fasterButton, 0, 10 );
 
+    /* Second line */
     fsLayout->addWidget( playButton, 1, 0, 1, 2 );
     fsLayout->addLayout( controlButLayout, 1, 2 );
 
@@ -1036,8 +1037,12 @@ FullscreenControllerWidget::FullscreenControllerWidget( intf_thread_t *_p_i,
     fsLayout->addWidget( advControls, 1, 6, Qt::AlignVCenter );
 
     fsLayout->setColumnStretch( 7, 10 );
-    fsLayout->addWidget( volMuteLabel, 1, 8 );
-    fsLayout->addWidget( volumeSlider, 1, 9, 1, 2 );
+
+    TimeLabel *timeLabel = new TimeLabel( p_intf );
+
+    fsLayout->addWidget( timeLabel, 1, 8 );
+    fsLayout->addWidget( volMuteLabel, 1, 9 );
+    fsLayout->addWidget( volumeSlider, 1, 10,1, 2 );
 
     /* hiding timer */
     p_hideTimer = new QTimer( this );
@@ -1068,6 +1073,7 @@ FullscreenControllerWidget::FullscreenControllerWidget( intf_thread_t *_p_i,
     fullscreenButton->setIcon( QIcon( ":/defullscreen" ) );
 
     vlc_mutex_init_recursive( &lock );
+    setMinimumWidth( 450 );
 }
 
 FullscreenControllerWidget::~FullscreenControllerWidget()
@@ -1608,3 +1614,37 @@ void CoverArtLabel::doUpdate()
     }
 }
 
+TimeLabel::TimeLabel( intf_thread_t *_p_intf  ) :QLabel(), p_intf( _p_intf )
+{
+   b_remainingTime = false;
+   setText( " --:--/--:-- " );
+   setAlignment( Qt::AlignRight | Qt::AlignVCenter );
+   setToolTip( qtr( "Toggle between elapsed and remaining time" ) );
+
+
+   CONNECT( THEMIM->getIM(), positionUpdated( float, int, int ),
+             this, setDisplayPosition( float, int, int ) );
+}
+
+void TimeLabel::setDisplayPosition( float pos, int time, int length )
+{
+    char psz_length[MSTRTIME_MAX_SIZE], psz_time[MSTRTIME_MAX_SIZE];
+    secstotimestr( psz_length, length );
+    secstotimestr( psz_time, ( b_remainingTime && length ) ? length - time
+                                                           : time );
+
+    QString timestr;
+    timestr.sprintf( "%s/%s", psz_time,
+                            ( !length && time ) ? "--:--" : psz_length );
+
+    /* Add a minus to remaining time*/
+    if( b_remainingTime && length ) setText( " -"+timestr+" " );
+    else setText( " "+timestr+" " );
+}
+
+void TimeLabel::toggleTimeDisplay()
+{
+    b_remainingTime = !b_remainingTime;
+}
+
+
index 1415e4dbb0d02046242778ca3c3ee8547e147e95..9d169462568eaca7196a097511e7900b72770c89 100644 (file)
@@ -332,16 +332,25 @@ private:
 class TimeLabel : public QLabel
 {
     Q_OBJECT
-    void mousePressEvent( QMouseEvent *event )
+public:
+    TimeLabel( intf_thread_t *_p_intf );
+protected:
+    virtual void mousePressEvent( QMouseEvent *event )
     {
-        emit timeLabelClicked();
+        toggleTimeDisplay();
     }
-    void mouseDoubleClickEvent( QMouseEvent *event )
+    virtual void mouseDoubleClickEvent( QMouseEvent *event )
     {
+        toggleTimeDisplay();
         emit timeLabelDoubleClicked();
     }
+private slots:
+    void setDisplayPosition( float pos, int time, int length );
+private:
+    intf_thread_t *p_intf;
+    bool b_remainingTime;
+    void toggleTimeDisplay();
 signals:
-    void timeLabelClicked();
     void timeLabelDoubleClicked();
 };
 
index 017f586e23c241bfee415f4ed81da3b85c8bc525..1f694559cd7f48b2557dcaaf66375e13ed56c49a 100644 (file)
@@ -146,8 +146,6 @@ MainInterface::MainInterface( intf_thread_t *_p_intf ) : QVLCMW( _p_intf )
     /* Connect the input manager to the GUI elements it manages */
 
     /* It is also connected to the control->slider, see the ControlsWidget */
-    CONNECT( THEMIM->getIM(), positionUpdated( float, int, int ),
-             this, setDisplayPosition( float, int, int ) );
     /* Change the SpeedRate in the Status */
     CONNECT( THEMIM->getIM(), rateChanged( int ), this, setRate( int ) );
 
@@ -291,11 +289,7 @@ inline void MainInterface::createStatusBar()
      *  Status Bar  *
      ****************/
     /* Widgets Creation*/
-    b_remainingTime = false;
-    timeLabel = new TimeLabel;
-    timeLabel->setText( " --:--/--:-- " );
-    timeLabel->setAlignment( Qt::AlignRight | Qt::AlignVCenter );
-    timeLabel->setToolTip( qtr( "Toggle between elapsed and remaining time" ) );
+    timeLabel = new TimeLabel( p_intf );
     nameLabel = new QLabel;
     nameLabel->setTextInteractionFlags( Qt::TextSelectableByMouse
                                       | Qt::TextSelectableByKeyboard );
@@ -318,9 +312,7 @@ inline void MainInterface::createStatusBar()
        - double clicking opens the goto time dialog
        - right-clicking and clicking just toggle between remaining and
          elapsed time.*/
-    CONNECT( timeLabel, timeLabelClicked(), this, toggleTimeDisplay() );
     CONNECT( timeLabel, timeLabelDoubleClicked(), THEDP, gotoTimeDialog() );
-    CONNECT( timeLabel, timeLabelDoubleClicked(), this, toggleTimeDisplay() );
 
     /* Speed Label behaviour:
        - right click gives the vertical speed slider */
@@ -854,27 +846,6 @@ void MainInterface::visual()
 /************************************************************************
  * Other stuff
  ************************************************************************/
-void MainInterface::setDisplayPosition( float pos, int time, int length )
-{
-    char psz_length[MSTRTIME_MAX_SIZE], psz_time[MSTRTIME_MAX_SIZE];
-    secstotimestr( psz_length, length );
-    secstotimestr( psz_time, ( b_remainingTime && length ) ? length - time
-                                                           : time );
-
-    QString timestr;
-    timestr.sprintf( "%s/%s", psz_time,
-                            ( !length && time ) ? "--:--" : psz_length );
-
-    /* Add a minus to remaining time*/
-    if( b_remainingTime && length ) timeLabel->setText( " -"+timestr+" " );
-    else timeLabel->setText( " "+timestr+" " );
-}
-
-void MainInterface::toggleTimeDisplay()
-{
-    b_remainingTime = !b_remainingTime;
-}
-
 void MainInterface::setName( QString name )
 {
     input_name = name; /* store it for the QSystray use */
index 65c61a35f2c2d0fd79ba3398e20ed3506f9d885b..2d4f57dcd726530044d9130fb785a4c9d56847e7 100644 (file)
@@ -133,7 +133,6 @@ private:
     bool                 playlistVisible; ///< Is the playlist visible ?
     bool                 visualSelectorEnabled;
     bool                 notificationEnabled; /// Systray Notifications
-    bool                 b_remainingTime; /* Show elapsed or remaining time */
     bool                 bgWasVisible;
     int                  i_visualmode; ///< Visual Mode
     pl_dock_e            i_pl_dock;
@@ -171,8 +170,6 @@ private slots:
     void setRate( int );
     void setName( QString );
     void setVLCWindowsTitle( QString title = "" );
-    void setDisplayPosition( float, int, int );
-    void toggleTimeDisplay();
 #if 0
     void visual();
 #endif