]> git.sesse.net Git - vlc/commitdiff
Qt: input slider and other widgets cleaning.
authorJean-Baptiste Kempf <jb@videolan.org>
Thu, 25 Dec 2008 16:55:06 +0000 (17:55 +0100)
committerJean-Baptiste Kempf <jb@videolan.org>
Tue, 30 Dec 2008 12:19:33 +0000 (13:19 +0100)
Code comments, remove useless include, document and rename a few variables.

Signed-off-by: Jean-Baptiste Kempf <jb@videolan.org>
modules/gui/qt4/components/extended_panels.cpp
modules/gui/qt4/components/playlist/standardpanel.cpp
modules/gui/qt4/util/customwidgets.hpp
modules/gui/qt4/util/input_slider.cpp
modules/gui/qt4/util/input_slider.hpp
modules/gui/qt4/util/qvlcframe.hpp

index 1aa6ead23da0321db755c2f31f9b1bba25fde9da..a03747aa80792f02b5646711187362b6bb921f30 100644 (file)
@@ -45,6 +45,7 @@
 #include <vlc_vout.h>
 #include <vlc_osd.h>
 
+#include <vlc_charset.h> /* us_strtod */
 
 #if 0
 class ConfClickHandler : public QObject
index 767169bbf4716dc1968f1651b1c7d83c61eaecd9..19215f90d1585e7653ab715fc53c8cf0e6642a1f 100644 (file)
@@ -62,7 +62,7 @@ StandardPLPanel::StandardPLPanel( PlaylistWidget *_parent,
     layout->setSpacing( 0 ); layout->setMargin( 0 );
 
     /* Create and configure the QTreeView */
-    view = new QVLCTreeView( 0 );
+    view = new QVLCTreeView;
     view->header()->setSortIndicator( 0 , Qt::AscendingOrder );
     view->setSortingEnabled( true );
     view->setModel( model );
index 411c33aa344b4a768928c2a850dae2a0fe019a3f..4d6fff16176b5fa8165c9948c142c024b0ca7e13 100644 (file)
@@ -66,15 +66,13 @@ private:
 #include <QPoint>
 #include <QModelIndex>
 
+/**
+  Special QTreeView that can emit rightClicked()
+  */
 class QVLCTreeView : public QTreeView
 {
     Q_OBJECT;
 public:
-    QVLCTreeView( QWidget * parent ) : QTreeView( parent )
-    {
-    };
-    virtual ~QVLCTreeView()   {};
-
     void mouseReleaseEvent( QMouseEvent* e )
     {
         if( e->button() & Qt::RightButton )
@@ -94,15 +92,20 @@ public:
         }
         QTreeView::mousePressEvent( e );
     }
+
 signals:
     void rightClicked( QModelIndex, QPoint  );
 };
 
+/* VLC Key/Wheel hotkeys interactions */
+
 class QKeyEvent;
 class QWheelEvent;
+
 int qtKeyModifiersToVLC( QInputEvent* e );
 int qtEventToVLCKey( QKeyEvent *e );
 int qtWheelEventToVLCKey( QWheelEvent *e );
 QString VLCKeyToString( int val );
 
 #endif
+
index b9b26f610fb53b28e2663f8083de1652a473d457..c5e490c38334db6eae1bb02238beadac46a1053a 100644 (file)
 #include <QPaintEvent>
 #include <QPainter>
 #include <QBitmap>
-#include <QStyle>
 
 InputSlider::InputSlider( QWidget *_parent ) : QSlider( _parent )
 {
     InputSlider::InputSlider( Qt::Horizontal, _parent );
 }
 
-InputSlider::InputSlider( Qt::Orientation q,QWidget *_parent ) :
+InputSlider::InputSlider( Qt::Orientation q, QWidget *_parent ) :
                                  QSlider( q, _parent )
 {
-    b_sliding = false;
+    b_isSliding = false;
     setMinimum( 0 );
     setMouseTracking(true);
     setMaximum( 1000 );
@@ -61,14 +60,15 @@ void InputSlider::setPosition( float pos, int a, int b )
     else
         setEnabled( true );
 
-    if( !b_sliding )
+    if( !b_isSliding )
         setValue( (int)(pos * 1000.0 ) );
+
     inputLength = b;
 }
 
 void InputSlider::userDrag( int new_value )
 {
-    if( b_sliding )
+    if( b_isSliding )
     {
         float f_pos = (float)(new_value)/1000.0;
         emit sliderDragged( f_pos );
@@ -77,12 +77,12 @@ void InputSlider::userDrag( int new_value )
 
 void InputSlider::mouseReleaseEvent( QMouseEvent *event )
 {
-    b_sliding = false;
+    b_isSliding = false;
 }
 
 void InputSlider::mousePressEvent(QMouseEvent* event)
 {
-    b_sliding = true ;
+    b_isSliding = true ;
     if( event->button() != Qt::LeftButton &&
         event->button() != Qt::MidButton )
     {
@@ -99,7 +99,7 @@ void InputSlider::mousePressEvent(QMouseEvent* event)
 
 void InputSlider::mouseMoveEvent(QMouseEvent *event)
 {
-    if( b_sliding )
+    if( b_isSliding )
     {
         QSlider::mouseMoveEvent( event );
     }
@@ -111,7 +111,7 @@ void InputSlider::mouseMoveEvent(QMouseEvent *event)
 void InputSlider::wheelEvent( QWheelEvent *event)
 {
     /* Don't do anything if we are for somehow reason sliding */
-    if( !b_sliding )
+    if( !b_isSliding )
     {
         setValue( value() + event->delta()/12 ); /* 12 = 8 * 15 / 10
          Since delta is in 1/8 of ° and mouse have steps of 15 °
@@ -140,8 +140,8 @@ SoundSlider::SoundSlider( QWidget *_parent, int _i_step, bool b_hard,
     f_step = ( _i_step * 100 ) / AOUT_VOLUME_MAX ;
     setRange( SOUNDMIN, b_hard ? (2 * SOUNDMAX) : SOUNDMAX  );
     setMouseTracking( true );
-    b_sliding = false;
-    b_outside = true;
+    b_isSliding = false;
+    b_mouseOutside = true;
 
     pixOutside = QPixmap( ":/volslide-outside" );
 
@@ -191,7 +191,7 @@ void SoundSlider::mousePressEvent( QMouseEvent *event )
     if( event->button() != Qt::RightButton )
     {
         /* We enter the sliding mode */
-        b_sliding = true;
+        b_isSliding = true;
         i_oldvalue = value();
         emit sliderPressed();
         changeValue( event->x() - paddingL );
@@ -202,31 +202,31 @@ void SoundSlider::mouseReleaseEvent( QMouseEvent *event )
 {
     if( event->button() != Qt::RightButton )
     {
-        if( !b_outside && value() != i_oldvalue )
+        if( !b_mouseOutside && value() != i_oldvalue )
         {
             emit sliderReleased();
             setValue( value() );
         }
-        b_sliding = false;
-        b_outside = false;
+        b_isSliding = false;
+        b_mouseOutside = false;
     }
 }
 
 void SoundSlider::mouseMoveEvent( QMouseEvent *event )
 {
-    if( b_sliding )
+    if( b_isSliding )
     {
         QRect rect( paddingL - 15,    -1,
                     WLENGTH + 15 * 2 , WHEIGHT + 5 );
         if( !rect.contains( event->pos() ) )
         { /* We are outside */
-            if ( !b_outside )
+            if ( !b_mouseOutside )
                 setValue( i_oldvalue );
-            b_outside = true;
+            b_mouseOutside = true;
         }
         else
         { /* We are inside */
-            b_outside = false;
+            b_mouseOutside = false;
             changeValue( event->x() - paddingL );
             emit sliderMoved( value() );
         }
@@ -244,7 +244,7 @@ void SoundSlider::changeValue( int x )
     setValue( (x * maximum() + 40 ) / WLENGTH );
 }
 
-void SoundSlider::paintEvent(QPaintEvent *e)
+void SoundSlider::paintEvent( QPaintEvent *e )
 {
     QPainter painter( this );
     const int offset = int( ( WLENGTH * value() + 100 ) / maximum() ) + paddingL;
index fa6214d9444adf8a13a43b41d4ea42ce4920b177..4ebf5fe3885dcbe7c271bdca2551766b547f8b7f 100644 (file)
@@ -39,28 +39,29 @@ class InputSlider : public QSlider
     Q_OBJECT
 public:
     InputSlider( QWidget *_parent );
-    InputSlider( Qt::Orientation q,QWidget *_parent );
-    virtual ~InputSlider()   {};
+    InputSlider( Qt::Orientation q, QWidget *_parent );
+    virtual ~InputSlider() {};
 protected:
     virtual void mouseMoveEvent(QMouseEvent *event);
     virtual void mousePressEvent(QMouseEvent* event);
     virtual void mouseReleaseEvent(QMouseEvent* event);
     virtual void wheelEvent(QWheelEvent *event);
 private:
-    bool b_sliding;
-    int inputLength;
-    char psz_length[MSTRTIME_MAX_SIZE];
+    bool b_isSliding; /* Whether we are currently sliding by user action */
+    int inputLength;  /* InputLength that can change */
+    char psz_length[MSTRTIME_MAX_SIZE]; /* Used for the ToolTip */
+
 public slots:
     void setPosition( float, int, int );
 private slots:
     void userDrag( int );
+
 signals:
     void sliderDragged( float );
 };
 
 
 /* Sound Slider inherited directly from QAbstractSlider */
-
 class QPaintEvent;
 
 class SoundSlider : public QAbstractSlider
@@ -73,19 +74,23 @@ public:
 protected:
     const static int paddingL = 3;
     const static int paddingR = 2;
+
     virtual void paintEvent(QPaintEvent *);
     virtual void wheelEvent( QWheelEvent *event );
     virtual void mousePressEvent( QMouseEvent * );
     virtual void mouseMoveEvent( QMouseEvent * );
     virtual void mouseReleaseEvent( QMouseEvent * );
+
 private:
-    bool b_sliding;
-    bool b_outside;
-    int i_oldvalue;
-    float f_step;
-    void changeValue( int x );
-    QPixmap pixGradient;
-    QPixmap pixOutside;
+    bool b_isSliding; /* Whether we are currently sliding by user action */
+    bool b_mouseOutside; /* Whether the mouse is outside or inside the Widget */
+    int i_oldvalue; /* Store the old Value before changing */
+    float f_step; /* How much do we increase each time we wheel */
+
+    QPixmap pixGradient; /* Gradient pix storage */
+    QPixmap pixOutside; /* OutLine pix storage */
+
+    void changeValue( int x ); /* Function to modify the value from pixel x() */
 };
 
 #endif
index b5f8e4851d51b3a4f983e9f38be735e4260999e3..ddc271da3420946560fd732317eaac30fad29562 100644 (file)
@@ -36,8 +36,6 @@
 #include <QSettings>
 
 #include "qt4.hpp"
-#include <vlc_common.h>
-#include <vlc_charset.h>
 
 class QVLCTools
 {