From bbb6d2d96a2b15ad86e1836811e5852b3f5ab4ab Mon Sep 17 00:00:00 2001 From: Rivo Laks Date: Mon, 22 Oct 2007 13:34:26 +0000 Subject: [PATCH] - Add config module for MakeTransparent effect. Defaults are 70% translucency for window decorations and 80% for moving windows. - Set it's user-visible name to Translucency svn path=/trunk/KDE/kdebase/workspace/; revision=728122 --- effects/CMakeLists.txt | 2 + effects/configs_builtins.cpp | 2 + effects/maketransparent.cpp | 10 ++- effects/maketransparent.desktop | 2 +- effects/maketransparent_config.cpp | 105 +++++++++++++++++++++++++ effects/maketransparent_config.desktop | 10 +++ effects/maketransparent_config.h | 41 ++++++++++ 7 files changed, 167 insertions(+), 5 deletions(-) create mode 100644 effects/maketransparent_config.cpp create mode 100644 effects/maketransparent_config.desktop create mode 100644 effects/maketransparent_config.h diff --git a/effects/CMakeLists.txt b/effects/CMakeLists.txt index bb15421d2f..b187624b03 100644 --- a/effects/CMakeLists.txt +++ b/effects/CMakeLists.txt @@ -58,11 +58,13 @@ KWIN4_ADD_EFFECT_CONFIG( builtins presentwindows_config.cpp shadow_config.cpp desktopgrid_config.cpp + maketransparent_config.cpp configs_builtins.cpp) install( FILES presentwindows_config.desktop shadow_config.desktop desktopgrid_config.desktop + maketransparent_config.desktop DESTINATION ${SERVICES_INSTALL_DIR}/kwin ) if(OPENGL_FOUND) diff --git a/effects/configs_builtins.cpp b/effects/configs_builtins.cpp index 53113d60c4..0df228a717 100644 --- a/effects/configs_builtins.cpp +++ b/effects/configs_builtins.cpp @@ -11,6 +11,7 @@ License. See the file "COPYING" for the exact licensing terms. #include "shadow_config.h" #include "presentwindows_config.h" #include "desktopgrid_config.h" +#include "maketransparent_config.h" #include @@ -21,6 +22,7 @@ KWIN_EFFECT_CONFIG_FACTORY K_PLUGIN_FACTORY_DEFINITION(EffectFactory, registerPlugin("shadow"); registerPlugin("presentwindows"); registerPlugin("desktopgrid"); + registerPlugin("maketransparent"); ) K_EXPORT_PLUGIN(EffectFactory("kwin")) diff --git a/effects/maketransparent.cpp b/effects/maketransparent.cpp index 33658a8930..c9b9057b64 100644 --- a/effects/maketransparent.cpp +++ b/effects/maketransparent.cpp @@ -10,6 +10,8 @@ License. See the file "COPYING" for the exact licensing terms. #include "maketransparent.h" +#include + namespace KWin { @@ -17,10 +19,10 @@ KWIN_EFFECT( maketransparent, MakeTransparentEffect ) MakeTransparentEffect::MakeTransparentEffect() { - // TODO options - decoration = 0.7; - moveresize = 0.5; - dialogs = 1.0; + KConfigGroup conf = effects->effectConfig("MakeTransparent"); + decoration = conf.readEntry( "Decoration", 0.7 ); + moveresize = conf.readEntry( "MoveResize", 0.8 ); + dialogs = conf.readEntry( "Dialogs", 1.0 ); } void MakeTransparentEffect::prePaintWindow( EffectWindow* w, WindowPrePaintData& data, int time ) diff --git a/effects/maketransparent.desktop b/effects/maketransparent.desktop index 2333ed046a..59b072d50e 100644 --- a/effects/maketransparent.desktop +++ b/effects/maketransparent.desktop @@ -1,6 +1,6 @@ [Desktop Entry] Encoding=UTF-8 -Name=Make Transparent +Name=Translucency Name[be]=Зрабіць празрыстым Name[bg]=Прозрачност Name[csb]=Robi transparentné diff --git a/effects/maketransparent_config.cpp b/effects/maketransparent_config.cpp new file mode 100644 index 0000000000..386b0f6e00 --- /dev/null +++ b/effects/maketransparent_config.cpp @@ -0,0 +1,105 @@ +/***************************************************************** + KWin - the KDE window manager + This file is part of the KDE project. + +Copyright (C) 2007 Rivo Laks + +You can Freely distribute this program under the GNU General Public +License. See the file "COPYING" for the exact licensing terms. +******************************************************************/ + +#include "maketransparent_config.h" + +#include + +#include +#include +#include + +#include +#include +#include + +#ifndef KDE_USE_FINAL +KWIN_EFFECT_CONFIG_FACTORY +#endif + +namespace KWin +{ + +MakeTransparentEffectConfig::MakeTransparentEffectConfig(QWidget* parent, const QVariantList& args) : + KCModule(EffectFactory::componentData(), parent, args) + { + kDebug() ; + + QGridLayout* layout = new QGridLayout(this); + + layout->addWidget(new QLabel(i18n("Changes opacity of following elements:"), this), 0, 0, 1, 2); + + layout->addWidget(new QLabel(i18n("Decorations:"), this), 1, 0); + mDecoration = new QSpinBox(this); + mDecoration->setRange(0, 100); + mDecoration->setSuffix("%"); + connect(mDecoration, SIGNAL(valueChanged(int)), this, SLOT(changed())); + layout->addWidget(mDecoration, 1, 1); + + layout->addWidget(new QLabel(i18n("Moved/resized windows:"), this), 2, 0); + mMoveResize = new QSpinBox(this); + mMoveResize->setRange(0, 100); + mMoveResize->setSuffix("%"); + connect(mMoveResize, SIGNAL(valueChanged(int)), this, SLOT(changed())); + layout->addWidget(mMoveResize, 2, 1); + + layout->addWidget(new QLabel(i18n("Dialogs:"), this), 3, 0); + mDialogs = new QSpinBox(this); + mDialogs->setRange(0, 100); + mDialogs->setSuffix("%"); + connect(mDialogs, SIGNAL(valueChanged(int)), this, SLOT(changed())); + layout->addWidget(mDialogs, 3, 1); + + layout->addItem(new QSpacerItem(10, 10, QSizePolicy::Minimum, QSizePolicy::Expanding), 4, 0, 1, 2); + + load(); + } + +void MakeTransparentEffectConfig::load() + { + kDebug() ; + KCModule::load(); + + KConfigGroup conf = EffectsHandler::effectConfig("MakeTransparent"); + mDecoration->setValue( (int)( conf.readEntry( "Decoration", 0.7 ) * 100 ) ); + mMoveResize->setValue( (int)( conf.readEntry( "MoveResize", 0.8 ) * 100 ) ); + mDialogs->setValue( (int)( conf.readEntry( "Dialogs", 1.0 ) * 100 ) ); + + emit changed(false); + } + +void MakeTransparentEffectConfig::save() + { + kDebug() ; + KCModule::save(); + + KConfigGroup conf = EffectsHandler::effectConfig("MakeTransparent"); + conf.writeEntry( "Decoration", mDecoration->value() / 100.0 ); + conf.writeEntry( "MoveResize", mMoveResize->value() / 100.0 ); + conf.writeEntry( "Dialogs", mDialogs->value() / 100.0 ); + conf.sync(); + + emit changed(false); + EffectsHandler::sendReloadMessage( "translucentdecorations" ); + } + +void MakeTransparentEffectConfig::defaults() + { + kDebug() ; + mDecoration->setValue( 70 ); + mMoveResize->setValue( 80 ); + mDialogs->setValue( 100 ); + emit changed(true); + } + + +} // namespace + +#include "maketransparent_config.moc" diff --git a/effects/maketransparent_config.desktop b/effects/maketransparent_config.desktop new file mode 100644 index 0000000000..f07c83cd6e --- /dev/null +++ b/effects/maketransparent_config.desktop @@ -0,0 +1,10 @@ +[Desktop Entry] +Encoding=UTF-8 +Type=Service +ServiceTypes=KCModule + +X-KDE-Library=kcm_kwin4_effect_builtins +X-KDE-ParentComponents=kwin4_effect_maketransparent +X-KDE-PluginKeyword=maketransparent + +Name=Translucency diff --git a/effects/maketransparent_config.h b/effects/maketransparent_config.h new file mode 100644 index 0000000000..8901a4d2fb --- /dev/null +++ b/effects/maketransparent_config.h @@ -0,0 +1,41 @@ +/***************************************************************** + KWin - the KDE window manager + This file is part of the KDE project. + +Copyright (C) 2007 Rivo Laks + +You can Freely distribute this program under the GNU General Public +License. See the file "COPYING" for the exact licensing terms. +******************************************************************/ + +#ifndef KWIN_MAKETRANSPARENT_CONFIG_H +#define KWIN_MAKETRANSPARENT_CONFIG_H + +#define KDE3_SUPPORT +#include +#undef KDE3_SUPPORT + +class QSpinBox; + +namespace KWin +{ + +class MakeTransparentEffectConfig : public KCModule + { + Q_OBJECT + public: + explicit MakeTransparentEffectConfig(QWidget* parent = 0, const QVariantList& args = QVariantList()); + + virtual void save(); + virtual void load(); + virtual void defaults(); + + private: + QSpinBox* mDecoration; + QSpinBox* mMoveResize; + QSpinBox* mDialogs; + }; + +} // namespace + +#endif