Wednesday, September 29, 2010

Make an impact on future generations

Always in demand





===================================================================================================================== Hi. Here's a small, shader based effect plugin that allows to modify desktop's brightness, saturation and contrast . (NVIDIA's digital vibrance on Intel GPU, yay~) I would appreciate if someone could commit it (apply in kwin/effects/). And note that I've written that based on 4.3.4 (shouldn't make much of a difference, since it's so simple) and I've been building it out-of-tree, so please test beforehand whenever I've integrated it properly with the tree or not. (: Thanks. Index: configs_builtins.cpp =================================================================== --- configs_builtins.cpp (revision 1065667) +++ configs_builtins.cpp (working copy) @@ -42,6 +42,7 @@ #include "lookingglass/lookingglass_config.h" #include "mousemark/mousemark_config.h" #include "magnifier/magnifier_config.h" +#include "saturation/saturation_config.h" #include "sharpen/sharpen_config.h" #include "snow/snow_config.h" #include "trackmouse/trackmouse_config.h" @@ -76,6 +77,7 @@ KWIN_EFFECT_CONFIG_SINGLE( lookingglass, LookingGlassEffectConfig ) KWIN_EFFECT_CONFIG_SINGLE( mousemark, MouseMarkEffectConfig ) KWIN_EFFECT_CONFIG_SINGLE( magnifier, MagnifierEffectConfig ) + KWIN_EFFECT_CONFIG_SINGLE( saturation, SaturationEffectConfig ) KWIN_EFFECT_CONFIG_SINGLE( sharpen, SharpenEffectConfig ) KWIN_EFFECT_CONFIG_SINGLE( snow, SnowEffectConfig ) KWIN_EFFECT_CONFIG_SINGLE( trackmouse, TrackMouseEffectConfig ) Index: saturation/saturation_config.cpp =================================================================== --- saturation/saturation_config.cpp (revision 0) +++ saturation/saturation_config.cpp (revision 0) @@ -0,0 +1,102 @@ +/******************************************************************** + KWin - the KDE window manager + This file is part of the KDE project. + +Copyright (C) 2009 j < j... @jabster.pl > + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program. If not, see < http://www.gnu.org/licenses/ >. +*********************************************************************/ + +#include "saturation_config.h" + +#include + +#include +#include +#include +#include + +#include +#include +#include + +namespace KWin +{ + +KWIN_EFFECT_CONFIG_FACTORY + +SaturationEffectConfig :: SaturationEffectConfig( QWidget* parent, const QVariantList& args ) : + KCModule( EffectFactory::componentData(), parent, args ) +{ + QFormLayout * layout = new QFormLayout( this ); + + brightness = new QDoubleSpinBox( this ); + saturation = new QDoubleSpinBox( this ); + contrast = new QDoubleSpinBox( this ); + + brightness->setRange( 0.1, 2.0 ); + saturation->setRange( 0.0, 5.0 ); + contrast ->setRange( 0.1, 2.0 ); + brightness->setSingleStep( 0.1 ); + saturation->setSingleStep( 0.1 ); + contrast ->setSingleStep( 0.1 ); + + layout->addRow( i18n( "Brightness" ), brightness ); + layout->addRow( i18n( "Saturation" ), saturation ); + layout->addRow( i18n( " Contrast " ), contrast ); + + this->connect( brightness, SIGNAL(valueChanged(double)), SLOT(changed()) ); + this->connect( saturation, SIGNAL(valueChanged(double)), SLOT(changed()) ); + this->connect( contrast , SIGNAL(valueChanged(double)), SLOT(changed()) ); + + load( ); +} + +SaturationEffectConfig :: ~SaturationEffectConfig( ) +{ +} + +void SaturationEffectConfig :: load( ) +{ + KCModule :: load( ); + KConfigGroup config = EffectsHandler :: effectConfig( "Saturation" ); + brightness->setValue( config.readEntry( "brightness", 1.0 ) ); + saturation->setValue( config.readEntry( "saturation", 1.0 ) ); + contrast ->setValue( config.readEntry( " contrast ", 1.0 ) ); + + emit changed( false ); +} + +void SaturationEffectConfig :: save( ) +{ + KConfigGroup config = EffectsHandler :: effectConfig( "Saturation" ); + config.writeEntry( "brightness", brightness->value() ); + config.writeEntry( "saturation", saturation->value() ); + config.writeEntry( " contrast ", contrast ->value() ); + + emit changed( false ); + EffectsHandler :: sendReloadMessage( "saturation" ); +} + +void SaturationEffectConfig :: defaults( ) +{ + brightness->setValue( 1.0 ); + saturation->setValue( 1.0 ); + contrast ->setValue( 1.0 ); + emit changed( true ); +} + +} + +#include "saturation_config.moc" Index: saturation/saturation.h =================================================================== --- saturation/saturation.h (revision 0) +++ saturation/saturation.h (revision 0) @@ -0,0 +1,43 @@ +/******************************************************************** + KWin - the KDE window manager + This file is part of the KDE project. + +Copyright (C) 2009 j < j... @jabster.pl > + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program. If not, see < http://www.gnu.org/licenses/ >. +*********************************************************************/ + +#ifndef KWIN_SATURATION_H +#define KWIN_SATURATION_H + +#include + +namespace KWin +{ + +class SaturationEffect : public QObject, public ShaderEffect +{ + Q_OBJECT + + public: + SaturationEffect( ); + virtual void reconfigure( ReconfigureFlags ); + + public slots: + void toggle( ); +}; + +} + +