1
/***************************************************************************
2
* Copyright (C) 2010 by Dario Freddi <drf@kde.org> *
4
* This program is free software; you can redistribute it and/or modify *
5
* it under the terms of the GNU General Public License as published by *
6
* the Free Software Foundation; either version 2 of the License, or *
7
* (at your option) any later version. *
9
* This program is distributed in the hope that it will be useful, *
10
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
11
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
12
* GNU General Public License for more details. *
14
* You should have received a copy of the GNU General Public License *
15
* along with this program; if not, write to the *
16
* Free Software Foundation, Inc., *
17
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA . *
18
***************************************************************************/
20
#include "disabledesktopeffectsconfig.h"
22
#include <QHBoxLayout>
25
#include <KIntSpinBox>
26
#include <KLocalizedString>
27
#include <KPluginFactory>
29
K_PLUGIN_FACTORY(PowerDevilDisableDesktopEffectsConfigFactory, registerPlugin<PowerDevil::BundledActions::DisableDesktopEffectsConfig>(); )
30
K_EXPORT_PLUGIN(PowerDevilDisableDesktopEffectsConfigFactory("powerdevildisabledesktopeffectsaction_config"))
32
namespace PowerDevil {
33
namespace BundledActions {
35
DisableDesktopEffectsConfig::DisableDesktopEffectsConfig(QObject* parent, const QVariantList& )
36
: ActionConfig(parent)
41
DisableDesktopEffectsConfig::~DisableDesktopEffectsConfig()
46
void DisableDesktopEffectsConfig::save()
48
configGroup().writeEntry("onIdle", m_comboBox->currentIndex() == 1);
49
configGroup().writeEntry("idleTime", m_idleTime->value() * 60 * 1000);
54
void DisableDesktopEffectsConfig::load()
56
m_comboBox->setCurrentIndex(configGroup().readEntry<bool>("onIdle", false) ? 1 : 0);
57
m_idleTime->setValue((configGroup().readEntry<int>("idleTime", 600000) / 60) / 1000);
60
QList< QPair< QString, QWidget* > > DisableDesktopEffectsConfig::buildUi()
62
QWidget *tempWidget = new QWidget;
63
QHBoxLayout *hlay = new QHBoxLayout;
64
m_comboBox = new KComboBox;
65
m_idleTime = new KIntSpinBox(0, 180, 1, 0, 0);
66
m_idleTime->setMaximumWidth(150);
67
m_idleTime->setMinimum(1);
68
m_idleTime->setMaximum(360);
69
m_idleTime->setSuffix(i18n(" min"));
70
m_idleTime->setDisabled(true);
71
m_comboBox->addItem(i18n("On Profile Load"));
72
m_comboBox->addItem(i18n("After"));
73
connect(m_comboBox, SIGNAL(currentIndexChanged(QString)),
74
this, SLOT(onIndexChanged(QString)));
76
hlay->addWidget(m_comboBox);
77
hlay->addWidget(m_idleTime);
80
tempWidget->setLayout(hlay);
82
QList< QPair< QString, QWidget* > > retlist;
83
retlist.append(qMakePair< QString, QWidget* >(i18n("Disable effects"), tempWidget));
85
connect(m_comboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(setChanged()));
86
connect(m_idleTime, SIGNAL(valueChanged(int)), this, SLOT(setChanged()));
91
void DisableDesktopEffectsConfig::onIndexChanged(const QString &text)
93
m_idleTime->setEnabled(text == i18n("After"));
99
#include "disabledesktopeffectsconfig.moc"