Add config dialog for MagicLamp effect. Currently only one option to change the animation duration is available.

FEATURE: 177961

svn path=/trunk/KDE/kdebase/workspace/; revision=910997
This commit is contained in:
Martin Gräßlin 2009-01-14 15:31:08 +00:00
parent a46f5f8945
commit 07d5e9cf57
8 changed files with 215 additions and 2 deletions

View file

@ -89,6 +89,8 @@ SET(kwin4_effect_builtins_config_sources
desktopgrid_config.ui
diminactive_config.cpp
diminactive_config.ui
magiclamp_config.cpp
magiclamp_config.ui
maketransparent_config.cpp
maketransparent_config.ui
presentwindows_config.cpp
@ -105,6 +107,7 @@ install( FILES
boxswitch_config.desktop
desktopgrid_config.desktop
diminactive_config.desktop
magiclamp_config.desktop
maketransparent_config.desktop
presentwindows_config.desktop
shadow_config.desktop

View file

@ -24,6 +24,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "boxswitch_config.h"
#include "desktopgrid_config.h"
#include "diminactive_config.h"
#include "magiclamp_config.h"
#include "maketransparent_config.h"
#include "presentwindows_config.h"
#include "shadow_config.h"
@ -65,6 +66,7 @@ KWIN_EFFECT_CONFIG_FACTORY
registerPlugin<KWin::BoxSwitchEffectConfig>("boxswitch"); \
registerPlugin<KWin::DesktopGridEffectConfig>("desktopgrid"); \
registerPlugin<KWin::DimInactiveEffectConfig>("diminactive"); \
registerPlugin<KWin::MagicLampEffectConfig>("magiclamp"); \
registerPlugin<KWin::MakeTransparentEffectConfig>("maketransparent"); \
registerPlugin<KWin::PresentWindowsEffectConfig>("presentwindows"); \
registerPlugin<KWin::ShadowEffectConfig>("shadow"); \

View file

@ -21,6 +21,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
// based on minimize animation by Rivo Laks <rivolaks@hot.ee>
#include "magiclamp.h"
#include <kwinconfig.h>
#include <kconfiggroup.h>
namespace KWin
{
@ -30,8 +32,14 @@ KWIN_EFFECT( magiclamp, MagicLampEffect )
MagicLampEffect::MagicLampEffect()
{
mActiveAnimations = 0;
reconfigure( ReconfigureAll );
}
void MagicLampEffect::reconfigure( ReconfigureFlags )
{
KConfigGroup conf = effects->effectConfig( "MagicLamp" );
mAnimationDuration = animationTime( conf, "AnimationDuration", 250 );
}
void MagicLampEffect::prePaintScreen( ScreenPrePaintData& data, int time )
{
@ -247,14 +255,14 @@ void MagicLampEffect::postPaintScreen()
void MagicLampEffect::windowMinimized( EffectWindow* w )
{
mTimeLineWindows[w].setCurveShape(TimeLine::LinearCurve);
mTimeLineWindows[w].setDuration( animationTime( 250 ));
mTimeLineWindows[w].setDuration( mAnimationDuration );
mTimeLineWindows[w].setProgress(0.0f);
}
void MagicLampEffect::windowUnminimized( EffectWindow* w )
{
mTimeLineWindows[w].setCurveShape(TimeLine::LinearCurve);
mTimeLineWindows[w].setDuration( animationTime( 250 ));
mTimeLineWindows[w].setDuration( mAnimationDuration );
mTimeLineWindows[w].setProgress(1.0f);
}

View file

@ -32,6 +32,7 @@ class MagicLampEffect
public:
MagicLampEffect();
virtual void reconfigure( ReconfigureFlags );
virtual void prePaintScreen( ScreenPrePaintData& data, int time );
virtual void prePaintWindow( EffectWindow* w, WindowPrePaintData& data, int time );
virtual void paintWindow( EffectWindow* w, int mask, QRegion region, WindowPaintData& data );
@ -43,6 +44,7 @@ class MagicLampEffect
private:
QHash< EffectWindow*, TimeLine > mTimeLineWindows;
int mActiveAnimations;
int mAnimationDuration;
enum IconPosition
{

View file

@ -0,0 +1,81 @@
/********************************************************************
KWin - the KDE window manager
This file is part of the KDE project.
Copyright (C) 2009 Martin Gräßlin <kde@martin-graesslin.com>
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 "magiclamp_config.h"
#include <kwineffects.h>
#include <kconfiggroup.h>
#include <QVBoxLayout>
#ifndef KDE_USE_FINAL
KWIN_EFFECT_CONFIG_FACTORY
#endif
namespace KWin
{
MagicLampEffectConfigForm::MagicLampEffectConfigForm(QWidget* parent) : QWidget(parent)
{
setupUi(this);
}
MagicLampEffectConfig::MagicLampEffectConfig(QWidget* parent, const QVariantList& args) :
KCModule(EffectFactory::componentData(), parent, args)
{
m_ui = new MagicLampEffectConfigForm(this);
QVBoxLayout* layout = new QVBoxLayout(this);
layout->addWidget(m_ui);
connect(m_ui->animationDurationSpin, SIGNAL(valueChanged(int)), this, SLOT(changed()));
load();
}
void MagicLampEffectConfig::load()
{
KCModule::load();
KConfigGroup conf = EffectsHandler::effectConfig( "MagicLamp" );
int duration = conf.readEntry( "AnimationDuration", 0 );
m_ui->animationDurationSpin->setValue( duration );
emit changed(false);
}
void MagicLampEffectConfig::save()
{
KConfigGroup conf = EffectsHandler::effectConfig( "MagicLamp" );
conf.writeEntry( "AnimationDuration", m_ui->animationDurationSpin->value() );
conf.sync();
emit changed(false);
EffectsHandler::sendReloadMessage( "magiclamp" );
}
void MagicLampEffectConfig::defaults()
{
m_ui->animationDurationSpin->setValue( 0 );
emit changed(true);
}
} // namespace
#include "magiclamp_config.moc"

View file

@ -0,0 +1,9 @@
[Desktop Entry]
Type=Service
X-KDE-ServiceTypes=KCModule
X-KDE-Library=kcm_kwin4_effect_builtins
X-KDE-ParentComponents=kwin4_effect_magiclamp
X-KDE-PluginKeyword=magiclamp
Name=Magic Lamp

View file

@ -0,0 +1,56 @@
/********************************************************************
KWin - the KDE window manager
This file is part of the KDE project.
Copyright (C) 2009 Martin Gräßlin <kde@martin-graesslin.com>
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_MAGICLAMP_CONFIG_H
#define KWIN_MAGICLAMP_CONFIG_H
#include <kcmodule.h>
#include "ui_magiclamp_config.h"
class KFileDialog;
namespace KWin
{
class MagicLampEffectConfigForm : public QWidget, public Ui::MagicLampEffectConfigForm
{
Q_OBJECT
public:
explicit MagicLampEffectConfigForm(QWidget* parent);
};
class MagicLampEffectConfig : public KCModule
{
Q_OBJECT
public:
explicit MagicLampEffectConfig(QWidget* parent = 0, const QVariantList& args = QVariantList());
public slots:
virtual void save();
virtual void load();
virtual void defaults();
private:
MagicLampEffectConfigForm* m_ui;
};
} // namespace
#endif

View file

@ -0,0 +1,52 @@
<ui version="4.0" >
<class>KWin::MagicLampEffectConfigForm</class>
<widget class="QWidget" name="KWin::MagicLampEffectConfigForm" >
<property name="geometry" >
<rect>
<x>0</x>
<y>0</y>
<width>400</width>
<height>300</height>
</rect>
</property>
<layout class="QFormLayout" name="formLayout" >
<item row="0" column="0" >
<widget class="QLabel" name="label_3" >
<property name="text" >
<string>Animation duration:</string>
</property>
<property name="alignment" >
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
<property name="buddy" >
<cstring>animationDurationSpin</cstring>
</property>
</widget>
</item>
<item row="0" column="1" >
<widget class="QSpinBox" name="animationDurationSpin" >
<property name="sizePolicy" >
<sizepolicy vsizetype="Fixed" hsizetype="Expanding" >
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="specialValueText" >
<string comment="Duration of rotation" >Default</string>
</property>
<property name="suffix" >
<string> msec</string>
</property>
<property name="maximum" >
<number>5000</number>
</property>
<property name="singleStep" >
<number>10</number>
</property>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>