add more spacing
[personal-kdebase.git] / workspace / plasma / runners / shell / shell_config.cpp
blob77a8ec559eb6ee19637e9caa94c80b3a61ec63ca
2 /***************************************************************************
3 * Copyright 2008 by Montel Laurent <montel@kde.org> *
4 * *
5 * This program is free software; you can redistribute it and/or modify *
6 * it under the terms of the GNU General Public License as published by *
7 * the Free Software Foundation; either version 2 of the License, or *
8 * (at your option) any later version. *
9 * *
10 * This program is distributed in the hope that it will be useful, *
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13 * GNU General Public License for more details. *
14 * *
15 * You should have received a copy of the GNU General Public License *
16 * along with this program; if not, write to the *
17 * Free Software Foundation, Inc., *
18 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA . *
19 ***************************************************************************/
21 #include "shell_config.h"
23 #include <QGridLayout>
25 #include <KConfigGroup>
26 #include <KDebug>
27 #include <KPluginFactory>
28 #include <KPluginLoader>
30 #include <Plasma/AbstractRunner>
32 K_EXPORT_RUNNER_CONFIG(shell, ShellConfig)
34 ShellConfigForm::ShellConfigForm(QWidget* parent) : QWidget(parent)
36 setupUi(this);
39 ShellConfig::ShellConfig(QWidget* parent, const QVariantList& args) :
40 KCModule(ConfigFactory::componentData(), parent, args)
42 m_ui = new ShellConfigForm(this);
44 QGridLayout* layout = new QGridLayout(this);
46 layout->addWidget(m_ui, 0, 0);
47 connect(m_ui->cbRunAsOther, SIGNAL(clicked(bool)), this, SLOT(slotUpdateUser(bool)) );
48 connect(m_ui->cbPriority, SIGNAL(clicked(bool)), this, SLOT(slotPriority(bool)));
49 load();
52 ShellConfig::~ShellConfig()
54 save();
57 void ShellConfig::load()
59 KCModule::load();
61 //FIXME: This shouldn't be hardcoded!
62 KSharedConfig::Ptr cfg = KSharedConfig::openConfig( "krunnerrc" );
63 KConfigGroup conf = cfg->group( "Runners" );
64 KConfigGroup grp = KConfigGroup( &conf, "Shell");
66 m_ui->cbRunInTerminal->setChecked(grp.readEntry("RunInTerminal", false));
67 m_ui->cbRunAsOther->setChecked(grp.readEntry("RunAsOther", false));
68 m_ui->cbPriority->setChecked(grp.readEntry("Priority", false));
69 m_ui->cbRealtime->setChecked(grp.readEntry("RealTime", false));
70 //m_ui->lePassword->text();
71 //m_ui->leUsername->text();
73 //TODO load
74 emit changed(false);
77 void ShellConfig::save()
79 kDebug()<<" save :";
80 //FIXME: This shouldn't be hardcoded!
81 KSharedConfig::Ptr cfg = KSharedConfig::openConfig( "krunnerrc" );
82 KConfigGroup conf = cfg->group( "Runners" );
83 KConfigGroup grp = KConfigGroup( &conf, "Shell");
84 grp.writeEntry("RunInTerminal", m_ui->cbRunInTerminal->isChecked());
85 bool runAsOther = m_ui->cbRunAsOther->isChecked();
86 grp.writeEntry("RunAsOther", runAsOther);
87 grp.writeEntry("Priority", m_ui->cbPriority->isChecked());
88 grp.writeEntry("RealTime", m_ui->cbRealtime->isChecked());
89 //m_ui->lePassword->text();
90 //m_ui->leUsername->text();
91 grp.sync();
92 emit changed(false);
95 void ShellConfig::slotUpdateUser(bool b)
97 m_ui->leUsername->setEnabled(b);
98 m_ui->lePassword->setEnabled(b);
101 void ShellConfig::slotPriority(bool b)
103 m_ui->slPriority->setEnabled(b);
104 m_ui->textLabel1->setEnabled(b);
107 void ShellConfig::defaults()
109 m_ui->cbRunInTerminal->setChecked(false);
110 m_ui->cbRunAsOther->setChecked(false);
111 m_ui->cbPriority->setChecked(false);
112 m_ui->cbRealtime->setChecked(false);
113 m_ui->lePassword->clear();
114 m_ui->leUsername->clear();
115 emit changed(true);
119 #include "shell_config.moc"