• Skip to content
  • Skip to link menu
KDE 4.2 API Reference
  • KDE API Reference
  • API Reference
  • Sitemap
  • Contact Us
 

Plasma

shell_config.cpp

Go to the documentation of this file.
00001 
00002 /***************************************************************************
00003  *   Copyright 2008 by Montel Laurent <montel@kde.org>                     *
00004  *                                                                         *
00005  *   This program is free software; you can redistribute it and/or modify  *
00006  *   it under the terms of the GNU General Public License as published by  *
00007  *   the Free Software Foundation; either version 2 of the License, or     *
00008  *   (at your option) any later version.                                   *
00009  *                                                                         *
00010  *   This program is distributed in the hope that it will be useful,       *
00011  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
00012  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
00013  *   GNU General Public License for more details.                          *
00014  *                                                                         *
00015  *   You should have received a copy of the GNU General Public License     *
00016  *   along with this program; if not, write to the                         *
00017  *   Free Software Foundation, Inc.,                                       *
00018  *   51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA .        *
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     //FIXME: This shouldn't be hardcoded!
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     //m_ui->lePassword->text();
00071     //m_ui->leUsername->text();
00072 
00073     //TODO load
00074     emit changed(false);
00075 }
00076 
00077 void ShellConfig::save()
00078 {
00079     kDebug()<<" save :";
00080     //FIXME: This shouldn't be hardcoded!
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     //m_ui->lePassword->text();
00090     //m_ui->leUsername->text();
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"

Plasma

Skip menu "Plasma"
  • Main Page
  • Namespace List
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Namespace Members
  • Class Members

API Reference

Skip menu "API Reference"
  • KWin
  •   KWin Libraries
  • Libraries
  •   libkworkspace
  •   libsolidcontrol
  •   libtaskmanager
  • Plasma
  •   Animators
  •   Applets
  •   Engines
  • Solid Modules
Generated for API Reference by doxygen 1.5.7
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal