/*****************************************************************************
* directslider.hpp : A slider that goes where you click
****************************************************************************
- * Copyright (C) 2000-2005 the VideoLAN team
- * $Id: wxwidgets.cpp 15731 2006-05-25 14:43:53Z zorglub $
+ * Copyright (C) 2006 the VideoLAN team
+ * $Id$
*
* Authors: Clément Stenac <zorglub@videolan.org>
* with precious help from ahigerd on #qt@freenode
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA. *****************************************************************************/
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
+ *****************************************************************************/
#ifndef _DIRECTSLIDER_H_
#define _DIRECTSLIDER_H_
#include <QSlider>
#include <QMouseEvent>
+#include <QLayout>
class DirectSlider : public QSlider
{
void mousePressEvent(QMouseEvent* event)
{
- if(event->button() == Qt::LeftButton)
+ if( event->button() != Qt::LeftButton && event->button() != Qt::MidButton )
{
- int pos = (int)(minimum() +
- (double)(event->x())/width()*(maximum()-minimum()) );
- setSliderPosition( pos );
- QSlider::mousePressEvent(event);
+ QSlider::mousePressEvent( event );
+ return;
}
+
+ QMouseEvent newEvent( event->type(), event->pos(), event->globalPos(),
+ Qt::MouseButton( event->button() ^ Qt::LeftButton ^ Qt::MidButton ),
+ Qt::MouseButtons( event->buttons() ^ Qt::LeftButton ^ Qt::MidButton ),
+ event->modifiers() );
+ QSlider::mousePressEvent( &newEvent );
}
};
#endif