~ubuntu-branches/ubuntu/utopic/kde-workspace/utopic-proposed

« back to all changes in this revision

Viewing changes to powerdevil/daemon/actions/bundled/disabledesktopeffectsconfig.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Michał Zając
  • Date: 2011-07-09 08:31:15 UTC
  • Revision ID: james.westby@ubuntu.com-20110709083115-ohyxn6z93mily9fc
Tags: upstream-4.6.90
Import upstream version 4.6.90

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/***************************************************************************
 
2
 *   Copyright (C) 2010 by Dario Freddi <drf@kde.org>                      *
 
3
 *                                                                         *
 
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.                                   *
 
8
 *                                                                         *
 
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.                          *
 
13
 *                                                                         *
 
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
 ***************************************************************************/
 
19
 
 
20
#include "disabledesktopeffectsconfig.h"
 
21
 
 
22
#include <QHBoxLayout>
 
23
 
 
24
#include <KComboBox>
 
25
#include <KIntSpinBox>
 
26
#include <KLocalizedString>
 
27
#include <KPluginFactory>
 
28
 
 
29
K_PLUGIN_FACTORY(PowerDevilDisableDesktopEffectsConfigFactory, registerPlugin<PowerDevil::BundledActions::DisableDesktopEffectsConfig>(); )
 
30
K_EXPORT_PLUGIN(PowerDevilDisableDesktopEffectsConfigFactory("powerdevildisabledesktopeffectsaction_config"))
 
31
 
 
32
namespace PowerDevil {
 
33
namespace BundledActions {
 
34
 
 
35
DisableDesktopEffectsConfig::DisableDesktopEffectsConfig(QObject* parent, const QVariantList& )
 
36
        : ActionConfig(parent)
 
37
{
 
38
 
 
39
}
 
40
 
 
41
DisableDesktopEffectsConfig::~DisableDesktopEffectsConfig()
 
42
{
 
43
 
 
44
}
 
45
 
 
46
void DisableDesktopEffectsConfig::save()
 
47
{
 
48
    configGroup().writeEntry("onIdle", m_comboBox->currentIndex() == 1);
 
49
    configGroup().writeEntry("idleTime", m_idleTime->value() * 60 * 1000);
 
50
 
 
51
    configGroup().sync();
 
52
}
 
53
 
 
54
void DisableDesktopEffectsConfig::load()
 
55
{
 
56
    m_comboBox->setCurrentIndex(configGroup().readEntry<bool>("onIdle", false) ? 1 : 0);
 
57
    m_idleTime->setValue((configGroup().readEntry<int>("idleTime", 600000) / 60) / 1000);
 
58
}
 
59
 
 
60
QList< QPair< QString, QWidget* > > DisableDesktopEffectsConfig::buildUi()
 
61
{
 
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)));
 
75
 
 
76
    hlay->addWidget(m_comboBox);
 
77
    hlay->addWidget(m_idleTime);
 
78
    hlay->addStretch();
 
79
 
 
80
    tempWidget->setLayout(hlay);
 
81
 
 
82
    QList< QPair< QString, QWidget* > > retlist;
 
83
    retlist.append(qMakePair< QString, QWidget* >(i18n("Disable effects"), tempWidget));
 
84
 
 
85
    connect(m_comboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(setChanged()));
 
86
    connect(m_idleTime, SIGNAL(valueChanged(int)), this, SLOT(setChanged()));
 
87
 
 
88
    return retlist;
 
89
}
 
90
 
 
91
void DisableDesktopEffectsConfig::onIndexChanged(const QString &text)
 
92
{
 
93
    m_idleTime->setEnabled(text == i18n("After"));
 
94
}
 
95
 
 
96
}
 
97
}
 
98
 
 
99
#include "disabledesktopeffectsconfig.moc"