Commit f673748b authored by Jean-Baptiste Kempf's avatar Jean-Baptiste Kempf

Qt4 - Make the gradient fit INSIDE the boundaries...

parent 94b8b916
......@@ -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 );
......
......@@ -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 );
......@@ -92,10 +93,12 @@ 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() );
......
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