1 /********************************************************************
2 KWin - the KDE window manager
3 This file is part of the KDE project.
5 Copyright (C) 2007 Rivo Laks <rivolaks@hot.ee>
6 Copyright (C) 2008 Lucas Murray <lmurray@undefinedfire.com>
8 This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 2 of the License, or
11 (at your option) any later version.
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with this program. If not, see <http://www.gnu.org/licenses/>.
20 *********************************************************************/
22 #include "shadow_config.h"
23 #include "shadow_helper.h"
24 #include <kwineffects.h>
26 #include <kcolorscheme.h>
28 #include <QtDBus/QtDBus>
29 #include <QVBoxLayout>
32 KWIN_EFFECT_CONFIG_FACTORY
38 ShadowEffectConfigForm::ShadowEffectConfigForm(QWidget
* parent
) : QWidget(parent
)
43 ShadowEffectConfig::ShadowEffectConfig(QWidget
* parent
, const QVariantList
& args
)
44 : KCModule( EffectFactory::componentData(), parent
, args
)
46 m_ui
= new ShadowEffectConfigForm( this );
48 QVBoxLayout
* layout
= new QVBoxLayout( this );
50 layout
->addWidget( m_ui
);
52 connect( m_ui
->xOffsetSpin
, SIGNAL( valueChanged( int )), this, SLOT( changed() ));
53 connect( m_ui
->yOffsetSpin
, SIGNAL( valueChanged( int )), this, SLOT( changed() ));
54 connect( m_ui
->opacitySpin
, SIGNAL( valueChanged( int )), this, SLOT( changed() ));
55 connect( m_ui
->fuzzinessSpin
, SIGNAL( valueChanged( int )), this, SLOT( changed() ));
56 connect( m_ui
->sizeSpin
, SIGNAL( valueChanged( int )), this, SLOT( changed() ));
57 connect( m_ui
->colorButton
, SIGNAL( changed( int )), this, SLOT( changed() ));
58 connect( m_ui
->strongerActiveBox
, SIGNAL( stateChanged( int )), this, SLOT( changed() ));
60 connect( m_ui
->forceDecoratedBox
, SIGNAL( stateChanged( int )), this, SLOT( changed() ));
61 connect( m_ui
->forceUndecoratedBox
, SIGNAL( stateChanged( int )), this, SLOT( changed() ));
62 connect( m_ui
->forceOtherBox
, SIGNAL( stateChanged( int )), this, SLOT( changed() ));
67 ShadowEffectConfig::~ShadowEffectConfig()
71 void ShadowEffectConfig::load()
75 KConfigGroup conf
= EffectsHandler::effectConfig( "Shadow" );
77 m_ui
->xOffsetSpin
->setValue( conf
.readEntry( "XOffset", 0 ));
78 m_ui
->yOffsetSpin
->setValue( conf
.readEntry( "YOffset", 3 ));
79 m_ui
->opacitySpin
->setValue( (int)( conf
.readEntry( "Opacity", 0.25 ) * 100 ));
80 m_ui
->fuzzinessSpin
->setValue( conf
.readEntry( "Fuzzyness", 10 ));
81 m_ui
->sizeSpin
->setValue( conf
.readEntry( "Size", 5 ));
82 m_ui
->colorButton
->setColor( conf
.readEntry( "Color", schemeShadowColor() ));
83 m_ui
->strongerActiveBox
->setChecked( conf
.readEntry( "IntensifyActiveShadow", true ));
85 m_ui
->forceDecoratedBox
->setChecked( conf
.readEntry( "forceDecoratedToDefault", false ));
86 m_ui
->forceUndecoratedBox
->setChecked( conf
.readEntry( "forceUndecoratedToDefault", false ));
87 m_ui
->forceOtherBox
->setChecked( conf
.readEntry( "forceOtherToDefault", false ));
92 void ShadowEffectConfig::save()
96 KConfigGroup conf
= EffectsHandler::effectConfig( "Shadow" );
98 conf
.writeEntry( "XOffset", m_ui
->xOffsetSpin
->value() );
99 conf
.writeEntry( "YOffset", m_ui
->yOffsetSpin
->value() );
100 conf
.writeEntry( "Opacity", m_ui
->opacitySpin
->value() / 100.0 );
101 conf
.writeEntry( "Fuzzyness", m_ui
->fuzzinessSpin
->value() );
102 conf
.writeEntry( "Size", m_ui
->sizeSpin
->value() );
103 QColor userColor
= m_ui
->colorButton
->color();
104 if( userColor
== schemeShadowColor() )
105 // If the user has reset the color to the default we want to start
106 // picking up color scheme changes again in the shadow effect
107 conf
.deleteEntry( "Color" );
109 conf
.writeEntry( "Color", userColor
);
110 conf
.writeEntry( "IntensifyActiveShadow", m_ui
->strongerActiveBox
->isChecked() );
112 conf
.writeEntry( "forceDecoratedToDefault", m_ui
->forceDecoratedBox
->isChecked() );
113 conf
.writeEntry( "forceUndecoratedToDefault", m_ui
->forceUndecoratedBox
->isChecked() );
114 conf
.writeEntry( "forceOtherToDefault", m_ui
->forceOtherBox
->isChecked() );
119 EffectsHandler::sendReloadMessage( "shadow" );
121 // We also need to reload decorations
122 QDBusMessage message
= QDBusMessage::createMethodCall( "org.kde.kwin", "/KWin", "org.kde.KWin", "reconfigure" );
123 QDBusConnection::sessionBus().send( message
);
126 void ShadowEffectConfig::defaults()
128 m_ui
->xOffsetSpin
->setValue( 0 );
129 m_ui
->yOffsetSpin
->setValue( 3 );
130 m_ui
->opacitySpin
->setValue( 25 );
131 m_ui
->fuzzinessSpin
->setValue( 10 );
132 m_ui
->sizeSpin
->setValue( 5 );
133 m_ui
->colorButton
->setColor( schemeShadowColor() );
134 m_ui
->strongerActiveBox
->setChecked( true );
136 m_ui
->forceDecoratedBox
->setChecked( false );
137 m_ui
->forceUndecoratedBox
->setChecked( false );
138 m_ui
->forceOtherBox
->setChecked( false );
145 #include "shadow_config.moc"