Commit 94b8b916 authored by Jean-Baptiste Kempf's avatar Jean-Baptiste Kempf

Qt4 - Did you really think I couldn't do more ugly ????

parent 5a1d728e
......@@ -524,7 +524,7 @@ ControlsWidget::ControlsWidget( intf_thread_t *_p_i,
volumeSlider->setMaximumSize( QSize( 200, 40 ) );
volumeSlider->setMinimumSize( QSize( 80, 20 ) );
volumeSlider->setFocusPolicy( Qt::NoFocus );
controlLayout->addWidget( volumeSlider, 3, 16, 1, 2, Qt::AlignBottom );
controlLayout->addWidget( volumeSlider, 2, 16, 2 , 2, Qt::AlignBottom );
/* Set the volume from the config */
volumeSlider->setValue( ( config_GetInt( p_intf, "volume" ) ) *
......
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://web.resource.org/cc/"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
width="210mm"
height="297mm"
id="svg2"
sodipodi:version="0.32"
inkscape:version="0.45.1"
sodipodi:docbase="/home/jb/qt4/pixmaps"
sodipodi:docname="volume-slider.svg"
inkscape:output_extension="org.inkscape.output.svg.inkscape">
<defs
id="defs4" />
<sodipodi:namedview
id="base"
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1.0"
inkscape:pageopacity="0.0"
inkscape:pageshadow="2"
inkscape:zoom="5.6"
inkscape:cx="106.87195"
inkscape:cy="320.89619"
inkscape:document-units="px"
inkscape:current-layer="layer1"
showgrid="true"
inkscape:window-width="872"
inkscape:window-height="625"
inkscape:window-x="0"
inkscape:window-y="36" />
<metadata
id="metadata7">
<rdf:RDF>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
</cc:Work>
</rdf:RDF>
</metadata>
<g
inkscape:label="Calque 1"
inkscape:groupmode="layer"
id="layer1">
<path
style="fill:none;fill-opacity:1;fill-rule:evenodd;stroke:#000000;stroke-width:0.65841436px;stroke-linecap:butt;stroke-linejoin:round;stroke-opacity:1"
d="M 61.298632,747.87419 C 63.795859,749.12213 81.883538,750.23841 106.98714,749.75013 C 132.09075,749.26185 156.24053,749.62667 158.08578,747.22095 C 159.44576,745.4479 160.32608,727.31021 157.69485,725.62013 C 151.96332,721.93866 120.60673,732.80257 108.78734,735.75216 C 90.729054,740.25869 68.425988,743.27519 61.863585,743.91032 C 58.528343,744.54544 58.801405,746.62625 61.298632,747.87419 z "
id="path2168"
sodipodi:nodetypes="csssscz"
inkscape:export-xdpi="90"
inkscape:export-ydpi="90"
inkscape:export-filename="/home/jb/qt4/pixmaps/volume-slider-outside.png" />
</g>
</svg>
......@@ -60,5 +60,7 @@
<file>pixmaps/volume-high.png</file>
<file>pixmaps/volume-low.png</file>
<file>pixmaps/volume-muted.png</file>
<file>pixmaps/volume-slider-inside.png</file>
<file>pixmaps/volume-slider-outside.png</file>
</qresource>
</RCC>
......@@ -26,8 +26,9 @@
#include <QPaintEvent>
#include <QPainter>
#include <QBitmap>
#include <QStyle>
InputSlider::InputSlider( QWidget *_parent ) : DirectSlider( _parent )
{
InputSlider::InputSlider( Qt::Horizontal, _parent );
......@@ -75,22 +76,26 @@ void InputSlider::mouseMoveEvent(QMouseEvent *event)
}
#define WLENGTH 100 // px
#define WHEIGHT 25 // px
#define WHEIGHT 28 // px
#define SOUNDMIN 0 // %
#define SOUNDMAX 200 // % OR 400 ?
SoundSlider::SoundSlider( QWidget *_parent, int _i_step, bool b_hard )
: QAbstractSlider( _parent )
{
padding = 5;
padding = 3;
f_step = ( _i_step * 100 ) / AOUT_VOLUME_MAX ;
setRange( SOUNDMIN, b_hard ? (2 * SOUNDMAX) : SOUNDMAX );
pixGradient = QPixmap( QSize( WLENGTH, WHEIGHT ) );
// QBixmap mask = QBitmap( QPixmap );
pixOutside = QPixmap( ":/pixmaps/volume-slider-outside.png" );
const QPixmap temp( ":/pixmaps/volume-slider-inside.png" );
const QBitmap mask( temp.createHeuristicMask() );
pixGradient = QPixmap( mask.size() );
QPainter p( &pixGradient );
QLinearGradient gradient( 0, 0, WLENGTH, 0 );
QLinearGradient gradient( 0, padding, WLENGTH + 2 * padding, padding );
gradient.setColorAt( 0.0, Qt::white );
gradient.setColorAt( 0.2, QColor( 20, 226, 20 ) );
gradient.setColorAt( 0.5, QColor( 255, 176, 15 ) );
......@@ -98,15 +103,10 @@ SoundSlider::SoundSlider( QWidget *_parent, int _i_step, bool b_hard )
p.setPen( Qt::NoPen );
p.setBrush( gradient );
//static const QPointF points[3] = { QPointF( 0.0, WHEIGHT ),
// QPointF( WLENGTH, WHEIGHT ), QPointF( WLENGTH, 0.0 ) };
// p.drawConvexPolygon( points, 3 );
p.drawRect( pixGradient.rect() );
p.end();
// pixGradient.setMask( mask );
pixGradient.setMask( mask );
}
void SoundSlider::wheelEvent( QWheelEvent *event )
......@@ -147,7 +147,7 @@ void SoundSlider::mouseMoveEvent( QMouseEvent *event )
if( b_sliding )
{
QRect rect( padding - 15, padding - 1,
WLENGTH + 15 * 2, WHEIGHT + 2 );
WLENGTH + 15 * 2, WHEIGHT + 4 );
if( !rect.contains( event->pos() ) )
{ /* We are outside */
if ( !b_outside )
......@@ -175,21 +175,12 @@ void SoundSlider::paintEvent(QPaintEvent *e)
{
QPainter painter( this );
const int offset = int( double( ( width() - 2 * padding ) * value() ) / maximum() );
const QRectF boundsG( padding, 0, offset , pixGradient.height() );
const QRectF boundsG( padding, padding, offset , pixGradient.height() );
painter.drawPixmap( boundsG, pixGradient, boundsG );
painter.end();
/* QPainter painter( this );
printf( "%i\n", value() );
QLinearGradient gradient( 0.0, 0.0, WLENGTH, WHEIGHT );
gradient.setColorAt( 0.0, Qt::white );
gradient.setColorAt( 1.0, Qt::blue );
const QRectF boundsO( 0, 0, pixOutside.width(), pixOutside.height() );
painter.drawPixmap( boundsO, pixOutside, boundsO );
painter.setPen( QPen( QBrush( Qt::black ), 0, Qt::SolidLine, Qt::RoundCap ) );
painter.setBrush( gradient );
painter.setRenderHint( QPainter::Antialiasing );
painter.end();*/
painter.end();
}
......@@ -70,7 +70,7 @@ private:
float f_step;
void changeValue( int x );
QPixmap pixGradient;
QPixmap pixLimit;
QPixmap pixOutside;
};
#endif
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