Plasma
shell_config.cpp
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #include "shell_config.h"
00022
00023 #include <QGridLayout>
00024
00025 #include <KConfigGroup>
00026 #include <KDebug>
00027 #include <KPluginFactory>
00028 #include <KPluginLoader>
00029
00030 #include <Plasma/AbstractRunner>
00031
00032 K_EXPORT_RUNNER_CONFIG(shell, ShellConfig)
00033
00034 ShellConfigForm::ShellConfigForm(QWidget* parent) : QWidget(parent)
00035 {
00036 setupUi(this);
00037 }
00038
00039 ShellConfig::ShellConfig(QWidget* parent, const QVariantList& args) :
00040 KCModule(ConfigFactory::componentData(), parent, args)
00041 {
00042 m_ui = new ShellConfigForm(this);
00043
00044 QGridLayout* layout = new QGridLayout(this);
00045
00046 layout->addWidget(m_ui, 0, 0);
00047 connect(m_ui->cbRunAsOther, SIGNAL(clicked(bool)), this, SLOT(slotUpdateUser(bool)) );
00048 connect(m_ui->cbPriority, SIGNAL(clicked(bool)), this, SLOT(slotPriority(bool)));
00049 load();
00050 }
00051
00052 ShellConfig::~ShellConfig()
00053 {
00054 save();
00055 }
00056
00057 void ShellConfig::load()
00058 {
00059 KCModule::load();
00060
00061
00062 KSharedConfig::Ptr cfg = KSharedConfig::openConfig( "krunnerrc" );
00063 KConfigGroup conf = cfg->group( "Runners" );
00064 KConfigGroup grp = KConfigGroup( &conf, "Shell");
00065
00066 m_ui->cbRunInTerminal->setChecked(grp.readEntry("RunInTerminal", false));
00067 m_ui->cbRunAsOther->setChecked(grp.readEntry("RunAsOther", false));
00068 m_ui->cbPriority->setChecked(grp.readEntry("Priority", false));
00069 m_ui->cbRealtime->setChecked(grp.readEntry("RealTime", false));
00070
00071
00072
00073
00074 emit changed(false);
00075 }
00076
00077 void ShellConfig::save()
00078 {
00079 kDebug()<<" save :";
00080
00081 KSharedConfig::Ptr cfg = KSharedConfig::openConfig( "krunnerrc" );
00082 KConfigGroup conf = cfg->group( "Runners" );
00083 KConfigGroup grp = KConfigGroup( &conf, "Shell");
00084 grp.writeEntry("RunInTerminal", m_ui->cbRunInTerminal->isChecked());
00085 bool runAsOther = m_ui->cbRunAsOther->isChecked();
00086 grp.writeEntry("RunAsOther", runAsOther);
00087 grp.writeEntry("Priority", m_ui->cbPriority->isChecked());
00088 grp.writeEntry("RealTime", m_ui->cbRealtime->isChecked());
00089
00090
00091 grp.sync();
00092 emit changed(false);
00093 }
00094
00095 void ShellConfig::slotUpdateUser(bool b)
00096 {
00097 m_ui->leUsername->setEnabled(b);
00098 m_ui->lePassword->setEnabled(b);
00099 }
00100
00101 void ShellConfig::slotPriority(bool b)
00102 {
00103 m_ui->slPriority->setEnabled(b);
00104 m_ui->textLabel1->setEnabled(b);
00105 }
00106
00107 void ShellConfig::defaults()
00108 {
00109 m_ui->cbRunInTerminal->setChecked(false);
00110 m_ui->cbRunAsOther->setChecked(false);
00111 m_ui->cbPriority->setChecked(false);
00112 m_ui->cbRealtime->setChecked(false);
00113 m_ui->lePassword->clear();
00114 m_ui->leUsername->clear();
00115 emit changed(true);
00116 }
00117
00118
00119 #include "shell_config.moc"