]> git.sesse.net Git - vlc/commitdiff
Qt4 - MainInterface, avoid the bug that makes the popupMenu toggle the TimeDisplay().
authorJean-Baptiste Kempf <jb@videolan.org>
Sun, 9 Sep 2007 23:14:38 +0000 (23:14 +0000)
committerJean-Baptiste Kempf <jb@videolan.org>
Sun, 9 Sep 2007 23:14:38 +0000 (23:14 +0000)
modules/gui/qt4/components/interface_widgets.hpp
modules/gui/qt4/main_interface.cpp
modules/gui/qt4/main_interface.hpp

index a42a63a023b3ad5f279c7c30adb1868e23667afe..c41d3587de7338fdbad8d326576fb2860ea5ade2 100644 (file)
@@ -186,7 +186,7 @@ public:
     virtual ~VolumeClickHandler() {};
     bool eventFilter( QObject *obj, QEvent *e )
     {
-        if (e->type() == QEvent::MouseButtonPress )
+        if (e->type() == QEvent::MouseButtonPress  )
         {
             aout_VolumeMute( p_intf, NULL );
             audio_volume_t i_volume;
@@ -201,6 +201,18 @@ private:
     intf_thread_t *p_intf;
 };
 
+#include <QLabel>
+#include <QMouseEvent>
+class TimeLabel : public QLabel
+{
+    Q_OBJECT
+    void mousePressEvent( QMouseEvent *event )
+    {
+        if( event->button() == Qt::LeftButton ) emit timeLabelClicked();
+    }
+signals:
+    void timeLabelClicked();
+};
 
 /******************** Playlist Widgets ****************/
 #include <QModelIndex>
index 321f1b1850f766bbda9a56b37e898dec572a847a..830092503472829fd3cbc7722255a70a0da1e4b6 100644 (file)
@@ -137,7 +137,7 @@ MainInterface::MainInterface( intf_thread_t *_p_intf ) : QVLCMW( _p_intf )
      * TODO: do we add a label for the current Volume ?
      **/
     b_remainingTime = false;
-    timeLabel = new QLabel;
+    timeLabel = new TimeLabel;
     nameLabel = new QLabel;
     speedLabel = new QLabel( "1.00x" );
     timeLabel->setFrameStyle( QFrame::Sunken | QFrame::Panel );
@@ -147,7 +147,7 @@ MainInterface::MainInterface( intf_thread_t *_p_intf ) : QVLCMW( _p_intf )
     statusBar()->addPermanentWidget( timeLabel, 2 );
     speedLabel->setContextMenuPolicy ( Qt::CustomContextMenu );
     timeLabel->setContextMenuPolicy ( Qt::CustomContextMenu );
-    timeLabel->installEventFilter( this );
+    CONNECT( timeLabel, timeLabelClicked(), this, toggleTimeDisplay() );
     CONNECT( speedLabel, customContextMenuRequested( QPoint ),
              this, showSpeedMenu( QPoint ) );
     CONNECT( timeLabel, customContextMenuRequested( QPoint ),
@@ -675,6 +675,7 @@ void MainInterface::setDisplayPosition( float pos, int time, int length )
 
 void MainInterface::toggleTimeDisplay()
 {
+    msg_Dbg( p_intf, "coincoin" );
     b_remainingTime = ( b_remainingTime ? false : true );
 }
 
@@ -697,7 +698,7 @@ void MainInterface::setStatus( int status )
 void MainInterface::setRate( int rate )
 {
     QString str;
-    str.setNum( ( 1000/(double)rate), 'f', 2 );
+    str.setNum( ( 1000 / (double)rate), 'f', 2 );
     str.append( "x" );
     speedLabel->setText( str );
     speedControl->updateControls( rate );
@@ -932,12 +933,6 @@ void MainInterface::customEvent( QEvent *event )
     }
 }
 
-bool MainInterface::eventFilter(QObject *obj, QEvent *event)
-{
-    if( (obj == timeLabel) && (event->type() == QEvent::MouseButtonPress) ) toggleTimeDisplay();
-}
-
-
 void MainInterface::keyPressEvent( QKeyEvent *e )
 {
     int i_vlck = qtEventToVLCKey( e );
index ea5c908842678b090b274ba938564725bd23031e..321534006847f8e6e3ad340cdf38eca39062813e 100644 (file)
@@ -72,8 +72,6 @@ protected:
     void dragLeaveEvent( QDragLeaveEvent * );
     void closeEvent( QCloseEvent *);
  
-    bool eventFilter(QObject *obj, QEvent *event);
-
     friend class VolumeClickHandler;
 private:
     QSettings           *settings;