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

« back to all changes in this revision

Viewing changes to plasma/generic/runners/kill/killrunner_config.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
/* Copyright 2009  <Jan Gerrit Marker> <jangerrit@weiler-marker.com>
 
2
 *
 
3
 * This library is free software; you can redistribute it and/or
 
4
 * modify it under the terms of the GNU Lesser General Public
 
5
 * License as published by the Free Software Foundation; either
 
6
 * version 2.1 of the License, or (at your option) version 3, or any
 
7
 * later version accepted by the membership of KDE e.V. (or its
 
8
 * successor approved by the membership of KDE e.V.), which shall
 
9
 * act as a proxy defined in Section 6 of version 3 of the license.
 
10
 *
 
11
 * This library is distributed in the hope that it will be useful,
 
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 
14
 * Lesser General Public License for more details.
 
15
 *
 
16
 * You should have received a copy of the GNU Lesser General Public
 
17
 * License along with this library.  If not, see <http://www.gnu.org/licenses/>.
 
18
 */
 
19
 
 
20
//Project-Includes
 
21
#include "killrunner_config.h"
 
22
//KDE-Includes
 
23
#include <plasma/abstractrunner.h>
 
24
 
 
25
K_EXPORT_RUNNER_CONFIG(kill, KillRunnerConfig)
 
26
 
 
27
KillRunnerConfigForm::KillRunnerConfigForm(QWidget* parent) : QWidget(parent)
 
28
{
 
29
    setupUi(this);
 
30
}
 
31
 
 
32
KillRunnerConfig::KillRunnerConfig(QWidget* parent, const QVariantList& args) :
 
33
        KCModule(ConfigFactory::componentData(), parent, args)
 
34
{
 
35
    m_ui = new KillRunnerConfigForm(this);
 
36
 
 
37
    QGridLayout* layout = new QGridLayout(this);
 
38
    layout->addWidget(m_ui, 0, 0);
 
39
 
 
40
    m_ui->sorting->addItem(i18n("CPU usage"), CPU);
 
41
    m_ui->sorting->addItem(i18n("inverted CPU usage"), CPUI);
 
42
    m_ui->sorting->addItem(i18n("nothing"), NONE);
 
43
 
 
44
    connect(m_ui->useTriggerWord,SIGNAL(stateChanged(int)),this,SLOT(changed()));
 
45
    connect(m_ui->triggerWord,SIGNAL(textChanged(QString)),this,SLOT(changed()));
 
46
    connect(m_ui->sorting,SIGNAL(currentIndexChanged(int)),this,SLOT(changed()));
 
47
 
 
48
    load();
 
49
}
 
50
 
 
51
void KillRunnerConfig::load()
 
52
{
 
53
    KCModule::load();
 
54
 
 
55
    KSharedConfig::Ptr cfg = KSharedConfig::openConfig("krunnerrc");
 
56
    KConfigGroup grp = cfg->group("Runners");
 
57
    grp = KConfigGroup(&grp, "Kill Runner");
 
58
 
 
59
    m_ui->useTriggerWord->setChecked(grp.readEntry(CONFIG_USE_TRIGGERWORD,true));
 
60
    m_ui->triggerWord->setText(grp.readEntry(CONFIG_TRIGGERWORD,i18n("kill")));
 
61
    m_ui->sorting->setCurrentIndex(m_ui->sorting->findData(grp.readEntry<int>(CONFIG_SORTING, (int) NONE)));
 
62
 
 
63
    emit changed(false);
 
64
}
 
65
 
 
66
void KillRunnerConfig::save()
 
67
{
 
68
    KCModule::save();
 
69
 
 
70
    KSharedConfig::Ptr cfg = KSharedConfig::openConfig("krunnerrc");
 
71
    KConfigGroup grp = cfg->group("Runners");
 
72
    grp = KConfigGroup(&grp, "Kill Runner");
 
73
 
 
74
    grp.writeEntry(CONFIG_USE_TRIGGERWORD,m_ui->useTriggerWord->isChecked());
 
75
    grp.writeEntry(CONFIG_TRIGGERWORD,m_ui->triggerWord->text());
 
76
    grp.writeEntry(CONFIG_SORTING,m_ui->sorting->itemData(m_ui->sorting->currentIndex()));
 
77
 
 
78
    emit changed(false);
 
79
}
 
80
 
 
81
void KillRunnerConfig::defaults()
 
82
{
 
83
    KCModule::defaults();
 
84
 
 
85
    m_ui->useTriggerWord->setChecked(true);
 
86
    m_ui->triggerWord->setText(i18n("kill"));
 
87
    m_ui->sorting->setCurrentIndex(m_ui->sorting->findData((int) NONE));
 
88
 
 
89
    emit changed(true);
 
90
}