From f673748bdc97383b10aa5667202e15052807e291 Mon Sep 17 00:00:00 2001 From: Jean-Baptiste Kempf Date: Mon, 26 Nov 2007 06:58:18 +0000 Subject: [PATCH] Qt4 - Make the gradient fit INSIDE the boundaries... --- modules/gui/qt4/components/interface_widgets.cpp | 2 +- modules/gui/qt4/util/input_slider.cpp | 8 ++++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/modules/gui/qt4/components/interface_widgets.cpp b/modules/gui/qt4/components/interface_widgets.cpp index a9235a89ef..5e7adda529 100644 --- a/modules/gui/qt4/components/interface_widgets.cpp +++ b/modules/gui/qt4/components/interface_widgets.cpp @@ -522,7 +522,7 @@ ControlsWidget::ControlsWidget( intf_thread_t *_p_i, volumeSlider->setOrientation( Qt::Horizontal ); } volumeSlider->setMaximumSize( QSize( 200, 40 ) ); - volumeSlider->setMinimumSize( QSize( 80, 20 ) ); + volumeSlider->setMinimumSize( QSize( 106, 30 ) ); volumeSlider->setFocusPolicy( Qt::NoFocus ); controlLayout->addWidget( volumeSlider, 2, 16, 2 , 2, Qt::AlignBottom ); diff --git a/modules/gui/qt4/util/input_slider.cpp b/modules/gui/qt4/util/input_slider.cpp index 055c66d173..59f205f3f4 100644 --- a/modules/gui/qt4/util/input_slider.cpp +++ b/modules/gui/qt4/util/input_slider.cpp @@ -84,6 +84,7 @@ SoundSlider::SoundSlider( QWidget *_parent, int _i_step, bool b_hard ) : QAbstractSlider( _parent ) { padding = 3; + f_step = ( _i_step * 100 ) / AOUT_VOLUME_MAX ; setRange( SOUNDMIN, b_hard ? (2 * SOUNDMAX) : SOUNDMAX ); @@ -91,11 +92,13 @@ SoundSlider::SoundSlider( QWidget *_parent, int _i_step, bool b_hard ) const QPixmap temp( ":/pixmaps/volume-slider-inside.png" ); const QBitmap mask( temp.createHeuristicMask() ); + + setMinimumSize( pixOutside.size() ); pixGradient = QPixmap( mask.size() ); QPainter p( &pixGradient ); - QLinearGradient gradient( 0, padding, WLENGTH + 2 * padding, padding ); + QLinearGradient gradient( padding, 2, WLENGTH , 2 ); gradient.setColorAt( 0.0, Qt::white ); gradient.setColorAt( 0.2, QColor( 20, 226, 20 ) ); gradient.setColorAt( 0.5, QColor( 255, 176, 15 ) ); @@ -175,7 +178,8 @@ void SoundSlider::paintEvent(QPaintEvent *e) { QPainter painter( this ); const int offset = int( double( ( width() - 2 * padding ) * value() ) / maximum() ); - const QRectF boundsG( padding, padding, offset , pixGradient.height() ); + + const QRectF boundsG( 0, 0, offset , pixGradient.height() ); painter.drawPixmap( boundsG, pixGradient, boundsG ); const QRectF boundsO( 0, 0, pixOutside.width(), pixOutside.height() ); -- GitLab