OSDN Git Service

kstyles: remove opacity support from oxygen
authorIvailo Monev <xakepa10@gmail.com>
Fri, 13 Feb 2015 16:45:02 +0000 (16:45 +0000)
committerIvailo Monev <xakepa10@gmail.com>
Fri, 13 Feb 2015 16:45:02 +0000 (16:45 +0000)
kstyles/oxygen/oxygenstyle.cpp
kstyles/oxygen/oxygenstyle.h

index 66a8598..3c64433 100644 (file)
@@ -3092,28 +3092,6 @@ namespace Oxygen
         if( flags & ( State_Sunken|State_On ) )
         {
 
-            {
-
-                // fill hole
-                qreal opacity = 1.0;
-                const qreal bias = 0.75;
-                opacity = 1.0 - bias;
-
-                if( opacity > 0 )
-                {
-                    QColor color( helper().backgroundColor( helper().calcMidColor( palette.color( QPalette::Window ) ), widget, slitRect.center() ) );
-                    color = helper().alphaColor( color, opacity );
-                    painter->save();
-                    painter->setRenderHint( QPainter::Antialiasing );
-                    painter->setPen( Qt::NoPen );
-                    painter->setBrush( color );
-                    painter->drawRoundedRect( slitRect.adjusted( 1, 1, -1, -1 ), 3.5, 3.5 );
-                    painter->restore();
-                }
-
-            }
-
-
             HoleOptions options( HoleContrast );
             if( hasFocus && enabled ) options |= HoleFocus;
             if( mouseOver && enabled ) options |= HoleHover;
@@ -3597,9 +3575,6 @@ namespace Oxygen
                 if( hasFocus ) opts |= Focus;
                 if( mouseOver ) opts |= Hover;
 
-                // adjust opacity and animation mode
-                qreal opacity( -1 );
-
                 // paint frame
                 painter->save();
                 if( reverseLayout )
@@ -3609,7 +3584,7 @@ namespace Oxygen
                     if( flags & ( State_On|State_Sunken ) ) opts |= Sunken;
 
                     painter->setClipRect( frameRect.adjusted( 0, 0, -8, 0 ), Qt::IntersectClip );
-                    renderButtonSlab( painter, frameRect, background, opts, opacity, TileSet::Bottom | TileSet::Top | TileSet::Left );
+                    renderButtonSlab( painter, frameRect, background, opts, TileSet::Bottom | TileSet::Top | TileSet::Left );
 
                 } else {
 
@@ -3618,7 +3593,7 @@ namespace Oxygen
                     if( flags & ( State_On|State_Sunken ) ) opts |= Sunken;
 
                     painter->setClipRect( frameRect.adjusted( 8, 0, 0, 0 ), Qt::IntersectClip );
-                    renderButtonSlab( painter, frameRect, background, opts, opacity, TileSet::Bottom | TileSet::Top | TileSet::Right );
+                    renderButtonSlab( painter, frameRect, background, opts, TileSet::Bottom | TileSet::Top | TileSet::Right );
 
                 }
 
@@ -7232,7 +7207,7 @@ namespace Oxygen
             if( handleActive && mouseOver ) opts |= Hover;
 
             const QColor color( helper().backgroundColor( palette.color( QPalette::Button ), widget, r.center() ) );
-            const QColor glow( slabShadowColor( color, opts, -1 ) );
+            const QColor glow( slabShadowColor( color, opts ) );
 
             const bool sunken( flags & (State_On|State_Sunken) );
             painter->drawPixmap( r.topLeft(), helper().sliderSlab( color, glow, sunken, 0.0 ) );
@@ -7827,7 +7802,7 @@ namespace Oxygen
     }
 
     //_________________________________________________________________________________
-    void Style::renderDialSlab( QPainter *painter, const QRect& r, const QColor &color, const QStyleOption *option, StyleOptions opts, qreal opacity ) const
+    void Style::renderDialSlab( QPainter *painter, const QRect& r, const QColor &color, const QStyleOption *option, StyleOptions opts ) const
     {
 
         // cast option
@@ -7839,7 +7814,7 @@ namespace Oxygen
         const QRect rect( centerRect( r, dimension, dimension ) );
 
         // calculate glow color
-        const QColor glow( slabShadowColor( color, opts, opacity ) );
+        const QColor glow( slabShadowColor( color, opts ) );
 
         // get main slab
         QPixmap pix( helper().dialSlab( color, glow, 0.0, dimension ) );
@@ -7903,7 +7878,7 @@ namespace Oxygen
     }
 
     //____________________________________________________________________________________
-    void Style::renderButtonSlab( QPainter *painter, QRect r, const QColor &color, StyleOptions options, qreal opacity,
+    void Style::renderButtonSlab( QPainter *painter, QRect r, const QColor &color, StyleOptions options,
         TileSet::Tiles tiles ) const
     {
         if( ( r.width() <= 0 ) || ( r.height() <= 0 ) ) return;
@@ -7924,7 +7899,7 @@ namespace Oxygen
 
         } else {
 
-            QColor glow = slabShadowColor( color, options, opacity );
+            QColor glow = slabShadowColor( color, options );
             tile = helper().slab( color, glow, 0.0 );
 
         }
@@ -7938,7 +7913,7 @@ namespace Oxygen
     void Style::renderSlab(
         QPainter *painter, QRect r,
         const QColor &color,
-        StyleOptions options, qreal opacity,
+        StyleOptions options,
         TileSet::Tiles tiles ) const
     {
 
@@ -7991,8 +7966,8 @@ namespace Oxygen
 
         } else {
 
-            // calculate proper glow color based on current settings and opacity
-            const QColor glow( slabShadowColor( color, options, opacity) );
+            // calculate proper glow color based on current settings
+            const QColor glow( slabShadowColor( color, options) );
             if( color.isValid() || glow.isValid() ) tile = helper().slab( color, glow , 0.0 );
             else return;
 
@@ -8436,11 +8411,9 @@ namespace Oxygen
     }
 
     //__________________________________________________________________________
-    void Style::renderMenuItemRect( const QStyleOption* opt, const QRect& r, const QColor& base, const QPalette& palette, QPainter* painter, qreal opacity ) const
+    void Style::renderMenuItemRect( const QStyleOption* opt, const QRect& r, const QColor& base, const QPalette& palette, QPainter* painter ) const
     {
 
-        if( opacity == 0 ) return;
-
         // get relevant color
         // TODO: this is inconsistent with MenuBar color.
         // this should change to properly account for 'sunken' state
@@ -8484,23 +8457,10 @@ namespace Oxygen
             pp.setCompositionMode( QPainter::CompositionMode_DestinationIn );
             pp.drawRect( maskr );
 
-            if( opacity >= 0 && opacity < 1 )
-            {
-                pp.setCompositionMode( QPainter::CompositionMode_DestinationIn );
-                pp.fillRect( pm.rect(), helper().alphaColor( Qt::black, opacity ) );
-            }
-
             pp.end();
 
             painter->drawPixmap( handleRTL( opt, r ), pm );
 
-        } else {
-
-            if( opacity >= 0 && opacity < 1 )
-            { color.setAlphaF( opacity ); }
-
-            helper().holeFlat( color, 0.0 )->render( r.adjusted( 1,2,-2,-1 ), painter, TileSet::Full );
-
         }
 
     }
@@ -8618,8 +8578,7 @@ namespace Oxygen
         QPainter* painter, const QRect& rect,
         const QPalette& palette,
         StyleOptions options,
-        CheckBoxState state,
-        qreal opacity ) const
+        CheckBoxState state) const
     {
 
         const int s( CheckBox_Size );
@@ -8628,7 +8587,7 @@ namespace Oxygen
         const int y = r.y();
 
         const QColor color( palette.color( QPalette::Button ) );
-        const QColor glow( slabShadowColor( color, options, opacity ) );
+        const QColor glow( slabShadowColor( color, options ) );
         painter->drawPixmap( x, y, helper().roundSlab( color, glow, 0.0 ) );
 
         // draw the radio mark
@@ -8681,7 +8640,7 @@ namespace Oxygen
     //______________________________________________________________________________
     void Style::renderScrollBarHandle(
         QPainter* painter, const QRect& r, const QPalette& palette,
-        const Qt::Orientation& orientation, const bool& hover, const qreal& opacity ) const
+        const Qt::Orientation& orientation, const bool& hover ) const
     {
 
         if( !r.isValid() ) return;
@@ -8704,8 +8663,7 @@ namespace Oxygen
         const QColor shadow( helper().alphaColor( helper().calcShadowColor( color ), 0.4 ) );
         const QColor hovered( helper().viewHoverBrush().brush( QPalette::Active ).color() );
 
-        if( opacity >= 0 ) glow = KColorUtils::mix( shadow, hovered, opacity );
-        else if( hover ) glow = hovered;
+        if( hover ) glow = hovered;
         else glow = shadow;
 
         helper().scrollHandle( color, glow )->
@@ -8865,19 +8823,14 @@ namespace Oxygen
     }
 
     //____________________________________________________________________________________
-    QColor Style::slabShadowColor( QColor color, StyleOptions options, qreal opacity ) const
+    QColor Style::slabShadowColor( QColor color, StyleOptions options ) const
     {
 
         QColor glow;
-        if( opacity < 0 )
-        {
-
-            if( options & Hover ) glow = helper().viewHoverBrush().brush( QPalette::Active ).color();
-            else if( options & Focus ) glow = helper().viewFocusBrush().brush( QPalette::Active ).color();
-            else if( ( options & SubtleShadow ) && color.isValid() ) glow = helper().alphaColor( helper().calcShadowColor( color ), 0.15 );
-
-
-        }
+        
+        if( options & Hover ) glow = helper().viewHoverBrush().brush( QPalette::Active ).color();
+        else if( options & Focus ) glow = helper().viewFocusBrush().brush( QPalette::Active ).color();
+        else if( ( options & SubtleShadow ) && color.isValid() ) glow = helper().alphaColor( helper().calcShadowColor( color ), 0.15 );
 
         return glow;
     }
index 1cd754b..5e7cb65 100644 (file)
@@ -668,33 +668,17 @@ namespace Oxygen
         //@{
 
         //! qdial slab
-        void renderDialSlab( QPainter* p, const QRect& r, const QColor& c, const QStyleOption* option, StyleOptions opts = 0 ) const
-        { renderDialSlab( p, r, c, option, opts, -1 ); }
-
-        //! qdial slab
-        void renderDialSlab( QPainter*, const QRect&, const QColor&, const QStyleOption*, StyleOptions, qreal ) const;
+        void renderDialSlab( QPainter* p, const QRect& r, const QColor& c, const QStyleOption* option, StyleOptions opts = 0 ) const;
 
         //! generic button slab
-        void renderButtonSlab( QPainter* p, QRect r, const QColor& c, StyleOptions opts = 0, TileSet::Tiles tiles = TileSet::Ring) const
-        { renderButtonSlab( p, r, c, opts, -1, tiles ); }
-
-        //! generic button slab
-        void renderButtonSlab( QPainter*, QRect, const QColor&, StyleOptions, qreal, TileSet::Tiles ) const;
+        void renderButtonSlab( QPainter* p, QRect r, const QColor& c, StyleOptions opts = 0, TileSet::Tiles tiles = TileSet::Ring) const;
 
         //! generic slab
         void renderSlab( QPainter* painter, const SlabRect& slab, const QColor& color, StyleOptions options = 0 ) const
         { renderSlab( painter, slab._r, color, options, slab._tiles ); }
 
         //! generic slab
-        void renderSlab( QPainter* painter, QRect rect, const QColor& color, StyleOptions options = 0, TileSet::Tiles tiles = TileSet::Ring) const
-        { renderSlab( painter, rect, color, options, -1, tiles ); }
-
-        //! generic slab
-        void renderSlab( QPainter* painter, const SlabRect& slab, const QColor& color, StyleOptions options, qreal opacity ) const
-        { renderSlab( painter, slab._r, color, options, opacity, slab._tiles ); }
-
-        //! generic slab
-        void renderSlab( QPainter*, QRect, const QColor&, StyleOptions, qreal, TileSet::Tiles ) const;
+        void renderSlab( QPainter* painter, QRect rect, const QColor& color, StyleOptions options = 0, TileSet::Tiles tiles = TileSet::Ring) const;
 
         // render tab background
         void renderTabBackground( QPainter*, const QRect&, const QPalette&, const QTabBar::Shape, const QWidget* ) const;
@@ -721,10 +705,10 @@ namespace Oxygen
         void renderHeaderBackground( const QRect&, const QPalette&, QPainter*, const QWidget*, bool horizontal, bool reverse ) const;
         void renderHeaderLines( const QRect&, const QPalette&, QPainter*, TileSet::Tiles ) const;
 
-        void renderMenuItemRect( const QStyleOption* opt, const QRect& rect, const QPalette& pal, QPainter* p, qreal opacity = -1 ) const
-        { renderMenuItemRect( opt, rect, pal.color(QPalette::Window), p, opacity ); }
+        void renderMenuItemRect( const QStyleOption* opt, const QRect& rect, const QPalette& pal, QPainter* p ) const
+        { renderMenuItemRect( opt, rect, pal.color(QPalette::Window), p ); }
 
-        void renderMenuItemRect( const QStyleOption*, const QRect&, const QColor&, const QPalette&, QPainter* p, qreal opacity = -1 ) const;
+        void renderMenuItemRect( const QStyleOption*, const QRect&, const QColor&, const QPalette&, QPainter* p ) const;
 
         //! checkbox state (used for checkboxes _and_ radio buttons)
         enum CheckBoxState
@@ -739,7 +723,7 @@ namespace Oxygen
         void renderCheckBox( QPainter*, const QRect&, const QPalette&, StyleOptions, CheckBoxState) const;
 
         //! radio button
-        void renderRadioButton( QPainter*, const QRect&, const QPalette&, StyleOptions, CheckBoxState, qreal opacity = -1 ) const;
+        void renderRadioButton( QPainter*, const QRect&, const QPalette&, StyleOptions, CheckBoxState ) const;
 
         //! scrollbar hole
         void renderScrollBarHole( QPainter*, const QRect&, const QColor&, const Qt::Orientation&, const TileSet::Tiles& = TileSet::Full ) const;
@@ -747,11 +731,7 @@ namespace Oxygen
         //! scrollbar handle (non animated)
         void renderScrollBarHandle(
             QPainter* painter, const QRect& r, const QPalette& palette,
-            const Qt::Orientation& orientation, const bool& hover) const
-        { renderScrollBarHandle( painter, r, palette, orientation, hover, -1 ); }
-
-        //! scrollbar handle (animated)
-        void renderScrollBarHandle( QPainter*, const QRect&, const QPalette&, const Qt::Orientation&, const bool&, const qreal& ) const;
+            const Qt::Orientation& orientation, const bool& hover) const;
 
         //! scrollbar arrow
         void renderScrollBarArrow( QPainter*, const QRect&, const QColor&, const QColor&, ArrowOrientation ) const;
@@ -765,7 +745,7 @@ namespace Oxygen
         //@}
 
         //! slab glowing color
-        QColor slabShadowColor( QColor, StyleOptions, qreal ) const;
+        QColor slabShadowColor( QColor, StyleOptions ) const;
 
         //! returns point position for generic arrows
         QPolygonF genericArrow( ArrowOrientation, ArrowSize = ArrowNormal ) const;