1
/* Copyright 2009 <Jan Gerrit Marker> <jangerrit@weiler-marker.com>
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.
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.
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/>.
21
#include "killrunner_config.h"
23
#include <plasma/abstractrunner.h>
25
K_EXPORT_RUNNER_CONFIG(kill, KillRunnerConfig)
27
KillRunnerConfigForm::KillRunnerConfigForm(QWidget* parent) : QWidget(parent)
32
KillRunnerConfig::KillRunnerConfig(QWidget* parent, const QVariantList& args) :
33
KCModule(ConfigFactory::componentData(), parent, args)
35
m_ui = new KillRunnerConfigForm(this);
37
QGridLayout* layout = new QGridLayout(this);
38
layout->addWidget(m_ui, 0, 0);
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);
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()));
51
void KillRunnerConfig::load()
55
KSharedConfig::Ptr cfg = KSharedConfig::openConfig("krunnerrc");
56
KConfigGroup grp = cfg->group("Runners");
57
grp = KConfigGroup(&grp, "Kill Runner");
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)));
66
void KillRunnerConfig::save()
70
KSharedConfig::Ptr cfg = KSharedConfig::openConfig("krunnerrc");
71
KConfigGroup grp = cfg->group("Runners");
72
grp = KConfigGroup(&grp, "Kill Runner");
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()));
81
void KillRunnerConfig::defaults()
85
m_ui->useTriggerWord->setChecked(true);
86
m_ui->triggerWord->setText(i18n("kill"));
87
m_ui->sorting->setCurrentIndex(m_ui->sorting->findData((int) NONE));