2008-02-05 17:20:08 +00:00
|
|
|
/********************************************************************
|
|
|
|
KWin - the KDE window manager
|
|
|
|
This file is part of the KDE project.
|
|
|
|
|
|
|
|
Copyright (C) 2007 Rivo Laks <rivolaks@hot.ee>
|
|
|
|
|
|
|
|
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 "showfps_config.h"
|
2011-07-17 15:09:18 +00:00
|
|
|
#include "showfps.h"
|
2008-02-05 17:20:08 +00:00
|
|
|
|
|
|
|
#include <kwineffects.h>
|
|
|
|
|
|
|
|
#include <klocale.h>
|
|
|
|
#include <kdebug.h>
|
|
|
|
|
|
|
|
namespace KWin
|
|
|
|
{
|
|
|
|
|
2009-02-05 15:35:38 +00:00
|
|
|
KWIN_EFFECT_CONFIG_FACTORY
|
|
|
|
|
2008-02-05 17:20:08 +00:00
|
|
|
ShowFpsEffectConfig::ShowFpsEffectConfig(QWidget* parent, const QVariantList& args) :
|
|
|
|
KCModule(EffectFactory::componentData(), parent, args)
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2008-02-05 17:20:08 +00:00
|
|
|
m_ui = new Ui::ShowFpsEffectConfigForm;
|
|
|
|
m_ui->setupUi(this);
|
|
|
|
|
|
|
|
connect(m_ui->textPosition, SIGNAL(currentIndexChanged(int)), this, SLOT(changed()));
|
2011-08-17 21:51:55 +00:00
|
|
|
connect(m_ui->textFont, SIGNAL(fontSelected(QFont)), this, SLOT(changed()));
|
|
|
|
connect(m_ui->textColor, SIGNAL(changed(QColor)), this, SLOT(changed()));
|
2008-02-05 17:20:08 +00:00
|
|
|
connect(m_ui->textAlpha, SIGNAL(valueChanged(double)), this, SLOT(changed()));
|
|
|
|
|
|
|
|
load();
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
|
|
|
|
2008-02-05 17:20:08 +00:00
|
|
|
ShowFpsEffectConfig::~ShowFpsEffectConfig()
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2008-02-05 17:20:08 +00:00
|
|
|
delete m_ui;
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
|
|
|
|
2008-02-05 17:20:08 +00:00
|
|
|
void ShowFpsEffectConfig::load()
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2008-02-05 17:20:08 +00:00
|
|
|
KCModule::load();
|
|
|
|
|
|
|
|
KConfigGroup conf = EffectsHandler::effectConfig("ShowFps");
|
|
|
|
|
|
|
|
int position = conf.readEntry("TextPosition", int(ShowFpsEffect::INSIDE_GRAPH));
|
2011-01-30 14:34:42 +00:00
|
|
|
if (position > -1)
|
2008-02-05 17:20:08 +00:00
|
|
|
m_ui->textPosition->setCurrentIndex(position);
|
|
|
|
|
|
|
|
QFont font = conf.readEntry("TextFont", QFont());
|
|
|
|
m_ui->textFont->setFont(font);
|
|
|
|
|
|
|
|
QColor color = conf.readEntry("TextColor", QColor());
|
2011-01-30 14:34:42 +00:00
|
|
|
if (color.isValid())
|
2008-02-05 17:20:08 +00:00
|
|
|
m_ui->textColor->setColor(color);
|
|
|
|
|
|
|
|
double alpha = conf.readEntry("TextAlpha", 1.0);
|
|
|
|
m_ui->textAlpha->setValue(alpha);
|
|
|
|
|
|
|
|
emit changed(false);
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
|
|
|
|
2008-02-05 17:20:08 +00:00
|
|
|
void ShowFpsEffectConfig::save()
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2008-02-05 17:20:08 +00:00
|
|
|
KCModule::save();
|
|
|
|
|
|
|
|
KConfigGroup conf = EffectsHandler::effectConfig("ShowFps");
|
|
|
|
|
|
|
|
int position = m_ui->textPosition->currentIndex();
|
|
|
|
conf.writeEntry("TextPosition", position);
|
|
|
|
|
|
|
|
QFont font = m_ui->textFont->font();
|
|
|
|
conf.writeEntry("TextFont", font);
|
|
|
|
|
|
|
|
QColor color = m_ui->textColor->color();
|
|
|
|
conf.writeEntry("TextColor", color);
|
|
|
|
|
|
|
|
double alpha = m_ui->textAlpha->value();
|
|
|
|
conf.writeEntry("TextAlpha", alpha);
|
|
|
|
|
|
|
|
conf.sync();
|
|
|
|
|
|
|
|
emit changed(false);
|
|
|
|
EffectsHandler::sendReloadMessage("showfps");
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
|
|
|
|
2008-02-05 17:20:08 +00:00
|
|
|
void ShowFpsEffectConfig::defaults()
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2008-02-05 17:20:08 +00:00
|
|
|
m_ui->textPosition->setCurrentIndex(0);
|
|
|
|
m_ui->textFont->setFont(QFont());
|
|
|
|
m_ui->textColor->setColor(QColor());
|
|
|
|
m_ui->textAlpha->setValue(1.0);
|
|
|
|
|
|
|
|
emit changed(true);
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2008-02-05 17:20:08 +00:00
|
|
|
|
|
|
|
} // namespace
|
|
|
|
|
|
|
|
#include "showfps_config.moc"
|