]> git.sesse.net Git - vlc/commitdiff
Qt4 - Did you really think I couldn't do more ugly ????
authorJean-Baptiste Kempf <jb@videolan.org>
Mon, 26 Nov 2007 06:45:58 +0000 (06:45 +0000)
committerJean-Baptiste Kempf <jb@videolan.org>
Mon, 26 Nov 2007 06:45:58 +0000 (06:45 +0000)
modules/gui/qt4/components/interface_widgets.cpp
modules/gui/qt4/pixmaps/volume-slider-inside.png [new file with mode: 0644]
modules/gui/qt4/pixmaps/volume-slider-outside.png [new file with mode: 0644]
modules/gui/qt4/pixmaps/volume-slider.svg [new file with mode: 0644]
modules/gui/qt4/res.qrc
modules/gui/qt4/util/input_slider.cpp
modules/gui/qt4/util/input_slider.hpp

index afb2a42394d295b7e2da665a5d28966b612cf210..a9235a89ef0ae1b3413e3659bcd773becd4f5d58 100644 (file)
@@ -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" ) ) *
diff --git a/modules/gui/qt4/pixmaps/volume-slider-inside.png b/modules/gui/qt4/pixmaps/volume-slider-inside.png
new file mode 100644 (file)
index 0000000..678bc36
Binary files /dev/null and b/modules/gui/qt4/pixmaps/volume-slider-inside.png differ
diff --git a/modules/gui/qt4/pixmaps/volume-slider-outside.png b/modules/gui/qt4/pixmaps/volume-slider-outside.png
new file mode 100644 (file)
index 0000000..b8dd088
Binary files /dev/null and b/modules/gui/qt4/pixmaps/volume-slider-outside.png differ
diff --git a/modules/gui/qt4/pixmaps/volume-slider.svg b/modules/gui/qt4/pixmaps/volume-slider.svg
new file mode 100644 (file)
index 0000000..1a10a5a
--- /dev/null
@@ -0,0 +1,62 @@
+<?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>
index cad89db835233d2cc36d90587307d19bc6288cf3..76a89927663867c75283850c26ccc18af9bf9437 100644 (file)
@@ -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>
index af54164aa57691ebf37ed4d26ad4ea3e2fd4f51a..055c66d1739781a527b4cf48f52a23dd1a18342d 100644 (file)
@@ -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();
 }
 
index 6fb8c55c3b902fc153c185b0050cc07c1eb8d8c7..dad1e36ef4b9db6d2d2b208362bba1fae1ec36f1 100644 (file)
@@ -70,7 +70,7 @@ private:
     float f_step;
     void changeValue( int x );
     QPixmap pixGradient;
-    QPixmap pixLimit;
+    QPixmap pixOutside;
 };
 
 #endif