Commit 97a8dff3 authored by Jean-Baptiste Kempf's avatar Jean-Baptiste Kempf

Qt4 - Input Slider simplification... Draging still kind of suck...

parent 011e78e6
......@@ -146,7 +146,6 @@ noinst_HEADERS = \
components/playlist/playlist.hpp \
components/playlist/selector.hpp \
util/input_slider.hpp \
util/directslider.hpp \
util/customwidgets.hpp \
util/qvlcframe.hpp
......
......@@ -476,7 +476,7 @@ MainInputManager::MainInputManager( intf_thread_t *_p_intf ) : QObject(NULL),
var_AddCallback( p_intf->p_libvlc, "volume-change", VolumeChanged, this );
/* Warn our embedded IM about input changes */
CONNECT( this, inputChanged( input_thread_t * ),
im, setInput( input_thread_t * ) );
im, setInput( input_thread_t * ) );
}
MainInputManager::~MainInputManager()
......
/*****************************************************************************
* directslider.hpp : A slider that goes where you click
****************************************************************************
* Copyright (C) 2006 the VideoLAN team
* $Id$
*
* Authors: Clément Stenac <zorglub@videolan.org>
* with precious help from ahigerd on #qt@freenode
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* 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.
*****************************************************************************/
#ifndef _DIRECTSLIDER_H_
#define _DIRECTSLIDER_H_
#include <QSlider>
#include <QMouseEvent>
#include <QLayout>
class DirectSlider : public QSlider
{
public:
DirectSlider( QWidget *_parent ) : QSlider( _parent ) {};
DirectSlider( Qt::Orientation q,QWidget *_parent ) : QSlider( q,_parent )
{};
virtual ~DirectSlider() {};
void mousePressEvent(QMouseEvent* event)
{
if( event->button() != Qt::LeftButton && event->button() != Qt::MidButton )
{
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
......@@ -29,13 +29,13 @@
#include <QBitmap>
#include <QStyle>
InputSlider::InputSlider( QWidget *_parent ) : DirectSlider( _parent )
InputSlider::InputSlider( QWidget *_parent ) : QSlider( _parent )
{
InputSlider::InputSlider( Qt::Horizontal, _parent );
}
InputSlider::InputSlider( Qt::Orientation q,QWidget *_parent ) :
DirectSlider( q, _parent )
QSlider( q, _parent )
{
mymove = false;
setMinimum( 0 );
......@@ -68,6 +68,21 @@ void InputSlider::userDrag( int new_value )
}
}
void InputSlider::mousePressEvent(QMouseEvent* event)
{
if( event->button() != Qt::LeftButton && event->button() != Qt::MidButton )
{
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 );
}
void InputSlider::mouseMoveEvent(QMouseEvent *event)
{
char psz_length[MSTRTIME_MAX_SIZE];
......
......@@ -24,9 +24,10 @@
#ifndef _INPUTSLIDER_H_
#define _INPUTSLIDER_H_
#include "util/directslider.hpp"
#include <QSlider>
#include <QMouseEvent>
class InputSlider : public DirectSlider
class InputSlider : public QSlider
{
Q_OBJECT
public:
......@@ -34,7 +35,8 @@ public:
InputSlider( Qt::Orientation q,QWidget *_parent );
virtual ~InputSlider() {};
protected:
void mouseMoveEvent(QMouseEvent *event);
virtual void mouseMoveEvent(QMouseEvent *event);
virtual void mousePressEvent(QMouseEvent* event);
private:
bool mymove;
int inputLength;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment