added option to configure shadow color

default is set to Qt::black
BUG: 349360
wilder-pre-rebase
Hugo Pereira Da Costa 11 years ago
parent 6946054e74
commit 5a1f5c22c0
  1. 20
      kdecoration/breezedecoration.cpp
  2. 4
      kdecoration/breezesettingsdata.kcfg
  3. 5
      kdecoration/config/breezeconfigwidget.cpp
  4. 85
      kdecoration/config/ui/breezeconfigurationui.ui

@ -66,6 +66,7 @@ namespace Breeze
static int g_sDecoCount = 0; static int g_sDecoCount = 0;
static int g_shadowSize = 0; static int g_shadowSize = 0;
static int g_shadowStrength = 0; static int g_shadowStrength = 0;
static QColor g_shadowColor = Qt::black;
static QSharedPointer<KDecoration2::DecorationShadow> g_sShadow; static QSharedPointer<KDecoration2::DecorationShadow> g_sShadow;
//________________________________________________________________ //________________________________________________________________
@ -587,11 +588,17 @@ namespace Breeze
{ {
// assign global shadow if exists and parameters match // assign global shadow if exists and parameters match
if( !( g_sShadow && g_shadowSize == m_internalSettings->shadowSize() && g_shadowStrength == m_internalSettings->shadowStrength() ) ) if(
!g_sShadow ||
g_shadowSize != m_internalSettings->shadowSize() ||
g_shadowStrength != m_internalSettings->shadowStrength() ||
g_shadowColor != m_internalSettings->shadowColor()
)
{ {
// assign parameters // assign parameters
g_shadowSize = m_internalSettings->shadowSize(); g_shadowSize = m_internalSettings->shadowSize();
g_shadowStrength = m_internalSettings->shadowStrength(); g_shadowStrength = m_internalSettings->shadowStrength();
g_shadowColor = m_internalSettings->shadowColor();
const int shadowOffset = qMax( 6*g_shadowSize/16, Metrics::Shadow_Overlap*2 ); const int shadowOffset = qMax( 6*g_shadowSize/16, Metrics::Shadow_Overlap*2 );
// create image // create image
@ -609,17 +616,14 @@ namespace Breeze
return color; return color;
}; };
auto c = client().data(); QRadialGradient radialGradient( g_shadowSize, g_shadowSize, g_shadowSize );
const QColor shadowColor( c->palette().color( QPalette::Shadow ) );
QRadialGradient radialGradient( g_shadowSize, g_shadowSize, g_shadowSize);
for( int i = 0; i < 10; ++i ) for( int i = 0; i < 10; ++i )
{ {
const qreal x( qreal( i )/9 ); const qreal x( qreal( i )/9 );
radialGradient.setColorAt(x, gradientStopColor(shadowColor, alpha(x)*g_shadowStrength)); radialGradient.setColorAt(x, gradientStopColor( g_shadowColor, alpha(x)*g_shadowStrength ) );
} }
radialGradient.setColorAt(1, gradientStopColor( shadowColor, 0 ) ); radialGradient.setColorAt(1, gradientStopColor( g_shadowColor, 0 ) );
// fill // fill
QPainter painter(&image); QPainter painter(&image);
@ -628,7 +632,7 @@ namespace Breeze
// contrast pixel // contrast pixel
painter.setBrush( Qt::NoBrush ); painter.setBrush( Qt::NoBrush );
painter.setPen( gradientStopColor(shadowColor, g_shadowStrength) ); painter.setPen( gradientStopColor( g_shadowColor, g_shadowStrength ) );
painter.setRenderHints(QPainter::Antialiasing ); painter.setRenderHints(QPainter::Antialiasing );
painter.drawRoundedRect( QRect( g_shadowSize-shadowOffset, g_shadowSize-shadowOffset, shadowOffset, shadowOffset ), 3, 3 ); painter.drawRoundedRect( QRect( g_shadowSize-shadowOffset, g_shadowSize-shadowOffset, shadowOffset, shadowOffset ), 3, 3 );
painter.end(); painter.end();

@ -19,6 +19,10 @@
<max>64</max> <max>64</max>
</entry> </entry>
<entry name="ShadowColor" type = "Color">
<default>0, 0, 0</default>
</entry>
<!-- close button --> <!-- close button -->
<entry name="OutlineCloseButton" type = "Bool"> <entry name="OutlineCloseButton" type = "Bool">
<default>true</default> <default>true</default>

@ -59,6 +59,7 @@ namespace Breeze
// track shadows changes // track shadows changes
connect( m_ui.shadowSize, SIGNAL(valueChanged(int)), SLOT(updateChanged()) ); connect( m_ui.shadowSize, SIGNAL(valueChanged(int)), SLOT(updateChanged()) );
connect( m_ui.shadowStrength, SIGNAL(valueChanged(int)), SLOT(updateChanged()) ); connect( m_ui.shadowStrength, SIGNAL(valueChanged(int)), SLOT(updateChanged()) );
connect( m_ui.shadowColor, SIGNAL(changed(QColor)), SLOT(updateChanged()) );
// track exception changes // track exception changes
connect( m_ui.exceptions, SIGNAL(changed(bool)), SLOT(updateChanged()) ); connect( m_ui.exceptions, SIGNAL(changed(bool)), SLOT(updateChanged()) );
@ -85,6 +86,7 @@ namespace Breeze
// load shadows // load shadows
m_ui.shadowSize->setValue( m_internalSettings->shadowSize() ); m_ui.shadowSize->setValue( m_internalSettings->shadowSize() );
m_ui.shadowStrength->setValue( qRound(qreal(m_internalSettings->shadowStrength()*100)/255 ) ); m_ui.shadowStrength->setValue( qRound(qreal(m_internalSettings->shadowStrength()*100)/255 ) );
m_ui.shadowColor->setColor( m_internalSettings->shadowColor() );
// load exceptions // load exceptions
ExceptionList exceptions; ExceptionList exceptions;
@ -113,6 +115,7 @@ namespace Breeze
m_internalSettings->setShadowSize( m_ui.shadowSize->value() ); m_internalSettings->setShadowSize( m_ui.shadowSize->value() );
m_internalSettings->setShadowStrength( qRound( qreal(m_ui.shadowStrength->value()*255)/100 ) ); m_internalSettings->setShadowStrength( qRound( qreal(m_ui.shadowStrength->value()*255)/100 ) );
m_internalSettings->setShadowColor( m_ui.shadowColor->color() );
// save configuration // save configuration
m_internalSettings->save(); m_internalSettings->save();
@ -160,6 +163,7 @@ namespace Breeze
m_ui.shadowSize->setValue( m_internalSettings->shadowSize() ); m_ui.shadowSize->setValue( m_internalSettings->shadowSize() );
m_ui.shadowStrength->setValue( qRound(qreal(m_internalSettings->shadowStrength()*100)/255 ) ); m_ui.shadowStrength->setValue( qRound(qreal(m_internalSettings->shadowStrength()*100)/255 ) );
m_ui.shadowColor->setColor( m_internalSettings->shadowColor() );
} }
@ -186,6 +190,7 @@ namespace Breeze
// shadows // shadows
else if( m_ui.shadowSize->value() != m_internalSettings->shadowSize() ) modified = true; else if( m_ui.shadowSize->value() != m_internalSettings->shadowSize() ) modified = true;
else if( qRound( qreal(m_ui.shadowStrength->value()*255)/100 ) != m_internalSettings->shadowStrength() ) modified = true; else if( qRound( qreal(m_ui.shadowStrength->value()*255)/100 ) != m_internalSettings->shadowStrength() ) modified = true;
else if( m_ui.shadowColor->color() != m_internalSettings->shadowColor() ) modified = true;
// exceptions // exceptions
else if( m_ui.exceptions->isChanged() ) modified = true; else if( m_ui.exceptions->isChanged() ) modified = true;

@ -11,7 +11,16 @@
</rect> </rect>
</property> </property>
<layout class="QVBoxLayout" name="verticalLayout"> <layout class="QVBoxLayout" name="verticalLayout">
<property name="margin"> <property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number> <number>0</number>
</property> </property>
<item> <item>
@ -225,33 +234,7 @@
<attribute name="title"> <attribute name="title">
<string>Shadows</string> <string>Shadows</string>
</attribute> </attribute>
<layout class="QGridLayout" name="gridLayout_6"> <layout class="QGridLayout" name="gridLayout">
<item row="1" column="1">
<widget class="QSpinBox" name="shadowStrength">
<property name="suffix">
<string>%</string>
</property>
<property name="minimum">
<number>10</number>
</property>
<property name="maximum">
<number>100</number>
</property>
</widget>
</item>
<item row="1" column="2">
<spacer name="horizontalSpacer_5">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="0" column="0"> <item row="0" column="0">
<widget class="QLabel" name="label"> <widget class="QLabel" name="label">
<property name="text"> <property name="text">
@ -291,7 +274,46 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="2" column="0" colspan="3"> <item row="1" column="1">
<widget class="QSpinBox" name="shadowStrength">
<property name="suffix">
<string>%</string>
</property>
<property name="minimum">
<number>10</number>
</property>
<property name="maximum">
<number>100</number>
</property>
</widget>
</item>
<item row="1" column="2">
<spacer name="horizontalSpacer_5">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label_5">
<property name="text">
<string>Color:</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="KColorButton" name="shadowColor"/>
</item>
<item row="3" column="0" colspan="3">
<spacer name="verticalSpacer_3"> <spacer name="verticalSpacer_3">
<property name="orientation"> <property name="orientation">
<enum>Qt::Vertical</enum> <enum>Qt::Vertical</enum>
@ -328,6 +350,11 @@
</layout> </layout>
</widget> </widget>
<customwidgets> <customwidgets>
<customwidget>
<class>KColorButton</class>
<extends>QPushButton</extends>
<header>kcolorbutton.h</header>
</customwidget>
<customwidget> <customwidget>
<class>Breeze::ExceptionListWidget</class> <class>Breeze::ExceptionListWidget</class>
<extends>QWidget</extends> <extends>QWidget</extends>

Loading…
Cancel
Save