X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=modules%2Fgui%2Fqt4%2Futil%2Finput_slider.cpp;h=b3a720fd4a63fdd64a2501c5d69f3dc9311d6e95;hb=9b10c9a754d2434b5c087b606de64e1d34e3ef6a;hp=cdb6f6ce3114778e75aa9486cc36f99ee881a759;hpb=76cee1b923e2df686ce1db526ed7cd1b408187c2;p=vlc diff --git a/modules/gui/qt4/util/input_slider.cpp b/modules/gui/qt4/util/input_slider.cpp index cdb6f6ce31..b3a720fd4a 100644 --- a/modules/gui/qt4/util/input_slider.cpp +++ b/modules/gui/qt4/util/input_slider.cpp @@ -5,6 +5,7 @@ * $Id$ * * Authors: Clément Stenac + * Jean-Baptiste Kempf * * 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 @@ -20,6 +21,9 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA. *****************************************************************************/ +#ifdef HAVE_CONFIG_H +# include "config.h" +#endif #include "util/input_slider.hpp" @@ -110,7 +114,8 @@ void InputSlider::mouseMoveEvent(QMouseEvent *event) #define SOUNDMIN 0 // % #define SOUNDMAX 200 // % OR 400 ? -SoundSlider::SoundSlider( QWidget *_parent, int _i_step, bool b_hard ) +SoundSlider::SoundSlider( QWidget *_parent, int _i_step, bool b_hard, + char *psz_colors ) : QAbstractSlider( _parent ) { paddingL = 5; @@ -118,6 +123,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; pixOutside = QPixmap( ":/pixmaps/volume-slider-outside.png" ); @@ -128,11 +135,22 @@ SoundSlider::SoundSlider( QWidget *_parent, int _i_step, bool b_hard ) pixGradient = QPixmap( mask.size() ); + /* Gradient building from the preferences */ QLinearGradient gradient( paddingL, 4, WLENGTH + paddingL , 4 ); - gradient.setColorAt( 0.0, Qt::white ); - gradient.setColorAt( 0.2, QColor( 20, 226, 20 ) ); - gradient.setColorAt( 0.5, QColor( 255, 176, 15 ) ); - gradient.setColorAt( 1.0, QColor( 235, 30, 20 ) ); + + QStringList colorList = qfu( psz_colors ).split( ";" ); + free( psz_colors ); + + /* Fill with 255 if the list is too short */ + if( colorList.size() < 12 ) + for( int i = colorList.size(); i < 12; i++) + colorList.append( "255" ); + +#define c(i) colorList.at(i).toInt() + gradient.setColorAt( 0.0, QColor( c(0), c(1), c(2) ) ); + gradient.setColorAt( 0.2, QColor( c(3), c(4), c(5) ) ); + gradient.setColorAt( 0.5, QColor( c(6), c(7), c(8) ) ); + gradient.setColorAt( 1.0, QColor( c(9), c(10), c(11) ) ); QPainter painter( &pixGradient ); painter.setPen( Qt::NoPen ); @@ -197,7 +215,11 @@ void SoundSlider::mouseMoveEvent( QMouseEvent *event ) } } else - event->ignore(); + { + int i = ( event->x() - paddingL ) * maximum() / WLENGTH; + i = __MIN( __MAX( 0, i ), maximum() ); + setToolTip( QString("%1 \%" ).arg( i ) ); + } } void SoundSlider::changeValue( int x )