]> git.sesse.net Git - vlc/blob - modules/gui/qt4/util/directslider.hpp
qt4/*: buildsytem fix + cosmetic+ copyright dates + svn Id
[vlc] / modules / gui / qt4 / util / directslider.hpp
1 /*****************************************************************************
2  * directslider.hpp : A slider that goes where you click
3  ****************************************************************************
4  * Copyright (C) 2006 the VideoLAN team
5  * $Id$
6  *
7  * Authors: ClĂ©ment Stenac <zorglub@videolan.org>
8  *          with precious help from ahigerd on #qt@freenode
9  *
10  * This program is free software; you can redistribute it and/or modify
11  * it under the terms of the GNU General Public License as published by
12  * the Free Software Foundation; either version 2 of the License, or
13  * (at your option) any later version.
14  *
15  * This program is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU General Public License for more details.
19  *
20  * You should have received a copy of the GNU General Public License
21  * along with this program; if not, write to the Free Software
22  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA. *****************************************************************************/
23
24 #ifndef _DIRECTSLIDER_H_
25 #define _DIRECTSLIDER_H_
26
27 #include <QSlider>
28 #include <QMouseEvent>
29
30 class DirectSlider : public QSlider
31 {
32 public:
33     DirectSlider( QWidget *_parent ) : QSlider( _parent ) {};
34     DirectSlider( Qt::Orientation q,QWidget *_parent ) : QSlider( q,_parent )
35     {};
36     virtual ~DirectSlider()   {};
37
38     void mousePressEvent(QMouseEvent* event)
39     {
40         if(event->button() == Qt::LeftButton)
41         {
42             int pos = (int)(minimum() + 
43                           (double)(event->x())/width()*(maximum()-minimum()) );
44             setSliderPosition( pos );
45             QSlider::mousePressEvent(event);
46         }
47     }
48 };
49 #endif