add more spacing
[personal-kdebase.git] / workspace / kwin / effects / showfps_config.cpp
blob26a7e857bd12b0f236aa4dc40f99fde0620a20e7
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>
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2 of the License, or
10 (at your option) any later version.
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program. If not, see <http://www.gnu.org/licenses/>.
19 *********************************************************************/
21 #include "showfps_config.h"
23 #include <kwineffects.h>
25 #include <klocale.h>
26 #include <kdebug.h>
28 #ifndef KDE_USE_FINAL
29 KWIN_EFFECT_CONFIG_FACTORY
30 #endif
32 namespace KWin
35 ShowFpsEffectConfig::ShowFpsEffectConfig(QWidget* parent, const QVariantList& args) :
36 KCModule(EffectFactory::componentData(), parent, args)
38 m_ui = new Ui::ShowFpsEffectConfigForm;
39 m_ui->setupUi(this);
41 connect(m_ui->textPosition, SIGNAL(currentIndexChanged(int)), this, SLOT(changed()));
42 connect(m_ui->textFont, SIGNAL(fontSelected(const QFont&)), this, SLOT(changed()));
43 connect(m_ui->textColor, SIGNAL(changed(const QColor&)), this, SLOT(changed()));
44 connect(m_ui->textAlpha, SIGNAL(valueChanged(double)), this, SLOT(changed()));
46 load();
49 ShowFpsEffectConfig::~ShowFpsEffectConfig()
51 delete m_ui;
54 void ShowFpsEffectConfig::load()
56 KCModule::load();
58 KConfigGroup conf = EffectsHandler::effectConfig("ShowFps");
60 int position = conf.readEntry("TextPosition", int(ShowFpsEffect::INSIDE_GRAPH));
61 if(position > -1)
62 m_ui->textPosition->setCurrentIndex(position);
64 QFont font = conf.readEntry("TextFont", QFont());
65 m_ui->textFont->setFont(font);
67 QColor color = conf.readEntry("TextColor", QColor());
68 if(color.isValid())
69 m_ui->textColor->setColor(color);
71 double alpha = conf.readEntry("TextAlpha", 1.0);
72 m_ui->textAlpha->setValue(alpha);
74 emit changed(false);
77 void ShowFpsEffectConfig::save()
79 KCModule::save();
81 KConfigGroup conf = EffectsHandler::effectConfig("ShowFps");
83 int position = m_ui->textPosition->currentIndex();
84 conf.writeEntry("TextPosition", position);
86 QFont font = m_ui->textFont->font();
87 conf.writeEntry("TextFont", font);
89 QColor color = m_ui->textColor->color();
90 conf.writeEntry("TextColor", color);
92 double alpha = m_ui->textAlpha->value();
93 conf.writeEntry("TextAlpha", alpha);
95 conf.sync();
97 emit changed(false);
98 EffectsHandler::sendReloadMessage("showfps");
101 void ShowFpsEffectConfig::defaults()
103 m_ui->textPosition->setCurrentIndex(0);
104 m_ui->textFont->setFont(QFont());
105 m_ui->textColor->setColor(QColor());
106 m_ui->textAlpha->setValue(1.0);
108 emit changed(true);
111 } // namespace
113 #include "showfps_config.moc"