Converted shadow config dialog to .ui

Added dummy options to get them in before string freeze.

svn path=/trunk/KDE/kdebase/workspace/; revision=880730
This commit is contained in:
Lucas Murray 2008-11-06 10:48:13 +00:00
parent 585addb450
commit 75036cf270
4 changed files with 415 additions and 96 deletions

View file

@ -94,6 +94,7 @@ SET(kwin4_effect_builtins_config_sources
presentwindows_config.cpp
presentwindows_config.ui
shadow_config.cpp
shadow_config.ui
showfps_config.cpp
showfps_config.ui
thumbnailaside_config.cpp

View file

@ -3,6 +3,7 @@
This file is part of the KDE project.
Copyright (C) 2007 Rivo Laks <rivolaks@hot.ee>
Copyright (C) 2008 Lucas Murray <lmurray@undefinedfire.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
@ -20,21 +21,12 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "shadow_config.h"
#include "shadow_helper.h"
#include <kwineffects.h>
#include <klocale.h>
#include <kdebug.h>
#include <kconfiggroup.h>
#include <kcolorbutton.h>
#include <kcolorscheme.h>
#include <QWidget>
#include <QGridLayout>
#include <QLabel>
#include <QSpinBox>
#include <QCheckBox>
#include <QVBoxLayout>
#include <QColor>
#ifndef KDE_USE_FINAL
KWIN_EFFECT_CONFIG_FACTORY
#endif
@ -42,101 +34,84 @@ KWIN_EFFECT_CONFIG_FACTORY
namespace KWin
{
ShadowEffectConfig::ShadowEffectConfig(QWidget* parent, const QVariantList& args) :
KCModule(EffectFactory::componentData(), parent, args)
ShadowEffectConfigForm::ShadowEffectConfigForm(QWidget* parent) : QWidget(parent)
{
setupUi(this);
}
ShadowEffectConfig::ShadowEffectConfig(QWidget* parent, const QVariantList& args)
: KCModule( EffectFactory::componentData(), parent, args )
{
kDebug() ;
m_ui = new ShadowEffectConfigForm( this );
QGridLayout* layout = new QGridLayout(this);
QVBoxLayout* layout = new QVBoxLayout( this );
layout->addWidget(new QLabel(i18n("X offset:"), this), 0, 0);
mShadowXOffset = new QSpinBox(this);
mShadowXOffset->setRange(-20, 20);
connect(mShadowXOffset, SIGNAL(valueChanged(int)), this, SLOT(changed()));
layout->addWidget(mShadowXOffset, 0, 1);
layout->addWidget( m_ui );
layout->addWidget(new QLabel(i18n("Y offset:"), this), 1, 0);
mShadowYOffset = new QSpinBox(this);
mShadowYOffset->setRange(-20, 20);
connect(mShadowYOffset, SIGNAL(valueChanged(int)), this, SLOT(changed()));
layout->addWidget(mShadowYOffset, 1, 1);
connect( m_ui->xOffsetSpin, SIGNAL( valueChanged( int )), this, SLOT( changed() ));
connect( m_ui->yOffsetSpin, SIGNAL( valueChanged( int )), this, SLOT( changed() ));
connect( m_ui->opacitySpin, SIGNAL( valueChanged( int )), this, SLOT( changed() ));
connect( m_ui->fuzzinessSpin, SIGNAL( valueChanged( int )), this, SLOT( changed() ));
connect( m_ui->sizeSpin, SIGNAL( valueChanged( int )), this, SLOT( changed() ));
connect( m_ui->colorButton, SIGNAL( changed( int )), this, SLOT( changed() ));
connect( m_ui->strongerActiveBox, SIGNAL( stateChanged( int )), this, SLOT( changed() ));
layout->addWidget(new QLabel(i18n("Shadow opacity:"), this), 2, 0);
mShadowOpacity = new QSpinBox(this);
mShadowOpacity->setRange(0, 100);
mShadowOpacity->setSuffix("%");
connect(mShadowOpacity, SIGNAL(valueChanged(int)), this, SLOT(changed()));
layout->addWidget(mShadowOpacity, 2, 1);
layout->addWidget(new QLabel(i18n("Shadow fuzziness:"), this), 3, 0);
mShadowFuzzyness = new QSpinBox(this);
mShadowFuzzyness->setRange(0, 20);
connect(mShadowFuzzyness, SIGNAL(valueChanged(int)), this, SLOT(changed()));
layout->addWidget(mShadowFuzzyness, 3, 1);
layout->addWidget(new QLabel(i18n("Shadow size (relative to window):"), this), 4, 0);
mShadowSize = new QSpinBox(this);
mShadowSize->setRange(0, 20);
connect(mShadowSize, SIGNAL(valueChanged(int)), this, SLOT(changed()));
layout->addWidget(mShadowSize, 4, 1);
layout->addWidget(new QLabel(i18n("Shadow color:"), this), 5, 0);
mShadowColor = new KColorButton(this);
mShadowColor->setDefaultColor(schemeShadowColor());
connect(mShadowColor, SIGNAL(changed(QColor)), this, SLOT(changed()));
layout->addWidget(mShadowColor, 5, 1);
mIntensifyActiveShadow = new QCheckBox(i18n("Active window has stronger shadow"), this);
connect(mIntensifyActiveShadow, SIGNAL(toggled(bool)), this, SLOT(changed()));
layout->addWidget(mIntensifyActiveShadow, 6, 0, 1, 2);
layout->addItem(new QSpacerItem(10, 10, QSizePolicy::Minimum, QSizePolicy::Expanding), 6, 0, 1, 2);
connect( m_ui->forceDecoratedBox, SIGNAL( stateChanged( int )), this, SLOT( changed() ));
connect( m_ui->forceUndecoratedBox, SIGNAL( stateChanged( int )), this, SLOT( changed() ));
connect( m_ui->forceOtherBox, SIGNAL( stateChanged( int )), this, SLOT( changed() ));
load();
}
ShadowEffectConfig::~ShadowEffectConfig()
{
kDebug() ;
}
void ShadowEffectConfig::load()
{
kDebug() ;
KCModule::load();
KConfigGroup conf = EffectsHandler::effectConfig("Shadow");
mShadowXOffset->setValue( conf.readEntry( "XOffset", 0 ) );
mShadowYOffset->setValue( conf.readEntry( "YOffset", 3 ) );
mShadowOpacity->setValue( (int)( conf.readEntry( "Opacity", 0.25 ) * 100 ) );
mShadowFuzzyness->setValue( conf.readEntry( "Fuzzyness", 10 ) );
mShadowSize->setValue( conf.readEntry( "Size", 5 ) );
mShadowColor->setColor( conf.readEntry( "Color", schemeShadowColor() ) );
mIntensifyActiveShadow->setChecked( conf.readEntry( "IntensifyActiveShadow", true ) );
KConfigGroup conf = EffectsHandler::effectConfig( "Shadow" );
m_ui->xOffsetSpin->setValue( conf.readEntry( "XOffset", 0 ));
m_ui->yOffsetSpin->setValue( conf.readEntry( "YOffset", 3 ));
m_ui->opacitySpin->setValue( (int)( conf.readEntry( "Opacity", 0.25 ) * 100 ));
m_ui->fuzzinessSpin->setValue( conf.readEntry( "Fuzzyness", 10 ));
m_ui->sizeSpin->setValue( conf.readEntry( "Size", 5 ));
m_ui->colorButton->setColor( conf.readEntry( "Color", schemeShadowColor() ));
m_ui->strongerActiveBox->setChecked( conf.readEntry( "IntensifyActiveShadow", true ));
m_ui->forceDecoratedBox->setChecked( conf.readEntry( "forceDecoratedToDefault", false ));
m_ui->forceUndecoratedBox->setChecked( conf.readEntry( "forceUndecoratedToDefault", false ));
m_ui->forceOtherBox->setChecked( conf.readEntry( "forceOtherToDefault", false ));
emit changed(false);
}
void ShadowEffectConfig::save()
{
kDebug() ;
KCModule::save();
KConfigGroup conf = EffectsHandler::effectConfig("Shadow");
conf.writeEntry( "XOffset", mShadowXOffset->value() );
conf.writeEntry( "YOffset", mShadowYOffset->value() );
conf.writeEntry( "Opacity", mShadowOpacity->value() / 100.0 );
conf.writeEntry( "Fuzzyness", mShadowFuzzyness->value() );
conf.writeEntry( "Size", mShadowSize->value() );
QColor userColor = mShadowColor->color();
if (userColor == schemeShadowColor()) {
KConfigGroup conf = EffectsHandler::effectConfig( "Shadow" );
conf.writeEntry( "XOffset", m_ui->xOffsetSpin->value() );
conf.writeEntry( "YOffset", m_ui->yOffsetSpin->value() );
conf.writeEntry( "Opacity", m_ui->opacitySpin->value() / 100.0 );
conf.writeEntry( "Fuzzyness", m_ui->fuzzinessSpin->value() );
conf.writeEntry( "Size", m_ui->sizeSpin->value() );
QColor userColor = m_ui->colorButton->color();
if( userColor == schemeShadowColor() )
// If the user has reset the color to the default we want to start
// picking up color scheme changes again in the shadow effect
conf.deleteEntry( "Color" );
} else {
else
conf.writeEntry( "Color", userColor );
}
conf.writeEntry( "IntensifyActiveShadow", mIntensifyActiveShadow->isChecked() );
conf.writeEntry( "IntensifyActiveShadow", m_ui->strongerActiveBox->isChecked() );
conf.writeEntry( "forceDecoratedToDefault", m_ui->forceDecoratedBox->isChecked() );
conf.writeEntry( "forceUndecoratedToDefault", m_ui->forceUndecoratedBox->isChecked() );
conf.writeEntry( "forceOtherToDefault", m_ui->forceOtherBox->isChecked() );
conf.sync();
emit changed(false);
@ -145,18 +120,21 @@ void ShadowEffectConfig::save()
void ShadowEffectConfig::defaults()
{
kDebug() ;
mShadowXOffset->setValue( 0 );
mShadowYOffset->setValue( 3 );
mShadowOpacity->setValue( 25 );
mShadowFuzzyness->setValue( 10 );
mShadowSize->setValue( 5 );
mIntensifyActiveShadow->setChecked( true );
mShadowColor->setColor( schemeShadowColor() );
m_ui->xOffsetSpin->setValue( 0 );
m_ui->yOffsetSpin->setValue( 3 );
m_ui->opacitySpin->setValue( 25 );
m_ui->fuzzinessSpin->setValue( 10 );
m_ui->sizeSpin->setValue( 5 );
m_ui->colorButton->setColor( schemeShadowColor() );
m_ui->strongerActiveBox->setChecked( true );
m_ui->forceDecoratedBox->setChecked( false );
m_ui->forceUndecoratedBox->setChecked( false );
m_ui->forceOtherBox->setChecked( false );
emit changed(true);
}
} // namespace
#include "shadow_config.moc"

View file

@ -3,6 +3,7 @@
This file is part of the KDE project.
Copyright (C) 2007 Rivo Laks <rivolaks@hot.ee>
Copyright (C) 2008 Lucas Murray <lmurray@undefinedfire.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
@ -23,13 +24,18 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include <kcmodule.h>
class QSpinBox;
class QCheckBox;
class KColorButton;
#include "ui_shadow_config.h"
namespace KWin
{
class ShadowEffectConfigForm : public QWidget, public Ui::ShadowEffectConfigForm
{
Q_OBJECT
public:
explicit ShadowEffectConfigForm(QWidget* parent);
};
class ShadowEffectConfig : public KCModule
{
Q_OBJECT
@ -37,18 +43,13 @@ class ShadowEffectConfig : public KCModule
explicit ShadowEffectConfig(QWidget* parent = 0, const QVariantList& args = QVariantList());
~ShadowEffectConfig();
public slots:
virtual void save();
virtual void load();
virtual void defaults();
private:
QSpinBox* mShadowXOffset;
QSpinBox* mShadowYOffset;
QSpinBox* mShadowOpacity;
QSpinBox* mShadowFuzzyness;
QSpinBox* mShadowSize;
KColorButton* mShadowColor;
QCheckBox* mIntensifyActiveShadow;
ShadowEffectConfigForm* m_ui;
};
} // namespace

339
effects/shadow_config.ui Normal file
View file

@ -0,0 +1,339 @@
<ui version="4.0" >
<class>KWin::ShadowEffectConfigForm</class>
<widget class="QWidget" name="KWin::ShadowEffectConfigForm" >
<property name="geometry" >
<rect>
<x>0</x>
<y>0</y>
<width>521</width>
<height>267</height>
</rect>
</property>
<layout class="QHBoxLayout" name="horizontalLayout" >
<item>
<widget class="QGroupBox" name="groupBox" >
<property name="title" >
<string>Default shadow</string>
</property>
<layout class="QGridLayout" name="gridLayout_3" >
<item row="0" column="0" >
<widget class="QLabel" name="label" >
<property name="text" >
<string>&amp;X offset:</string>
</property>
<property name="alignment" >
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
<property name="buddy" >
<cstring>xOffsetSpin</cstring>
</property>
</widget>
</item>
<item row="7" column="0" colspan="2" >
<widget class="QCheckBox" name="strongerActiveBox" >
<property name="text" >
<string>&amp;Active windows has stronger shadow</string>
</property>
</widget>
</item>
<item row="2" column="0" >
<widget class="QLabel" name="label_3" >
<property name="text" >
<string>&amp;Y offset:</string>
</property>
<property name="alignment" >
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
<property name="buddy" >
<cstring>yOffsetSpin</cstring>
</property>
</widget>
</item>
<item row="2" column="1" >
<widget class="QSpinBox" name="yOffsetSpin" >
<property name="sizePolicy" >
<sizepolicy vsizetype="Fixed" hsizetype="Expanding" >
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="specialValueText" >
<string/>
</property>
<property name="suffix" >
<string/>
</property>
<property name="minimum" >
<number>-100</number>
</property>
<property name="maximum" >
<number>100</number>
</property>
<property name="singleStep" >
<number>1</number>
</property>
<property name="value" >
<number>0</number>
</property>
</widget>
</item>
<item row="3" column="0" >
<widget class="QLabel" name="label_4" >
<property name="text" >
<string>&amp;Opacity:</string>
</property>
<property name="alignment" >
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
<property name="buddy" >
<cstring>opacitySpin</cstring>
</property>
</widget>
</item>
<item row="3" column="1" >
<widget class="QSpinBox" name="opacitySpin" >
<property name="sizePolicy" >
<sizepolicy vsizetype="Fixed" hsizetype="Expanding" >
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="specialValueText" >
<string/>
</property>
<property name="suffix" >
<string>%</string>
</property>
<property name="minimum" >
<number>0</number>
</property>
<property name="maximum" >
<number>100</number>
</property>
<property name="singleStep" >
<number>1</number>
</property>
<property name="value" >
<number>0</number>
</property>
</widget>
</item>
<item row="4" column="0" >
<widget class="QLabel" name="label_5" >
<property name="text" >
<string>&amp;Fuzziness:</string>
</property>
<property name="alignment" >
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
<property name="buddy" >
<cstring>fuzzinessSpin</cstring>
</property>
</widget>
</item>
<item row="5" column="0" >
<widget class="QLabel" name="label_6" >
<property name="text" >
<string>&amp;Size:</string>
</property>
<property name="alignment" >
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
<property name="buddy" >
<cstring>sizeSpin</cstring>
</property>
</widget>
</item>
<item row="4" column="1" >
<widget class="QSpinBox" name="fuzzinessSpin" >
<property name="sizePolicy" >
<sizepolicy vsizetype="Fixed" hsizetype="Expanding" >
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="specialValueText" >
<string/>
</property>
<property name="suffix" >
<string/>
</property>
<property name="minimum" >
<number>0</number>
</property>
<property name="maximum" >
<number>100</number>
</property>
<property name="singleStep" >
<number>1</number>
</property>
<property name="value" >
<number>0</number>
</property>
</widget>
</item>
<item row="5" column="1" >
<widget class="QSpinBox" name="sizeSpin" >
<property name="sizePolicy" >
<sizepolicy vsizetype="Fixed" hsizetype="Expanding" >
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="specialValueText" >
<string/>
</property>
<property name="suffix" >
<string/>
</property>
<property name="minimum" >
<number>0</number>
</property>
<property name="maximum" >
<number>100</number>
</property>
<property name="singleStep" >
<number>1</number>
</property>
<property name="value" >
<number>0</number>
</property>
</widget>
</item>
<item row="0" column="1" >
<widget class="QSpinBox" name="xOffsetSpin" >
<property name="sizePolicy" >
<sizepolicy vsizetype="Fixed" hsizetype="Expanding" >
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="specialValueText" >
<string/>
</property>
<property name="suffix" >
<string/>
</property>
<property name="minimum" >
<number>-100</number>
</property>
<property name="maximum" >
<number>100</number>
</property>
<property name="singleStep" >
<number>1</number>
</property>
<property name="value" >
<number>0</number>
</property>
</widget>
</item>
<item row="6" column="1" >
<widget class="KColorButton" name="colorButton" />
</item>
<item row="6" column="0" >
<widget class="QLabel" name="label_7" >
<property name="text" >
<string>&amp;Color:</string>
</property>
<property name="alignment" >
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
<property name="buddy" >
<cstring>colorButton</cstring>
</property>
</widget>
</item>
<item row="8" column="0" colspan="2" >
<spacer name="verticalSpacer_2" >
<property name="orientation" >
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0" >
<size>
<width>20</width>
<height>0</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="groupBox_3" >
<property name="enabled" >
<bool>false</bool>
</property>
<property name="title" >
<string>Decoration shadows</string>
</property>
<layout class="QGridLayout" name="gridLayout_4" >
<item row="1" column="0" >
<widget class="QCheckBox" name="forceDecoratedBox" >
<property name="text" >
<string>&amp;Decorated windows</string>
</property>
</widget>
</item>
<item row="0" column="0" >
<widget class="QLabel" name="label_2" >
<property name="text" >
<string>Force default shadows for:</string>
</property>
</widget>
</item>
<item row="2" column="0" >
<widget class="QCheckBox" name="forceUndecoratedBox" >
<property name="text" >
<string>&amp;Undecorated normal windows</string>
</property>
</widget>
</item>
<item row="3" column="0" >
<widget class="QCheckBox" name="forceOtherBox" >
<property name="text" >
<string>All &amp;other windows</string>
</property>
</widget>
</item>
<item row="4" column="0" >
<spacer name="verticalSpacer" >
<property name="orientation" >
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0" >
<size>
<width>20</width>
<height>0</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>KColorButton</class>
<extends>QPushButton</extends>
<header>kcolorbutton.h</header>
</customwidget>
</customwidgets>
<tabstops>
<tabstop>xOffsetSpin</tabstop>
<tabstop>yOffsetSpin</tabstop>
<tabstop>opacitySpin</tabstop>
<tabstop>fuzzinessSpin</tabstop>
<tabstop>sizeSpin</tabstop>
<tabstop>colorButton</tabstop>
<tabstop>strongerActiveBox</tabstop>
<tabstop>forceDecoratedBox</tabstop>
<tabstop>forceUndecoratedBox</tabstop>
<tabstop>forceOtherBox</tabstop>
</tabstops>
<resources/>
<connections/>
</ui>