2 Copyright (C) 2002 Cornelius Schumacher <schumacher@kde.org>
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 2 of the License, or
7 (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
22 #include <KComponentData>
24 #include <KFileDialog>
25 #include <KPluginFactory>
26 #include <KPluginLoader>
33 #include <QListWidget>
34 #include <QPushButton>
35 #include <QHBoxLayout>
39 K_PLUGIN_FACTORY(KCMCgiFactory
, registerPlugin
<KCMCgi
>();)
40 K_EXPORT_PLUGIN(KCMCgiFactory("kcmcgi"))
42 KCMCgi::KCMCgi(QWidget
*parent
, const QVariantList
&)
43 : KCModule(KCMCgiFactory::componentData(), parent
)
45 setButtons(Default
|Apply
);
47 QVBoxLayout
*topLayout
= new QVBoxLayout(this);
48 topLayout
->setSpacing(KDialog::spacingHint());
50 QGroupBox
*topBox
= new QGroupBox(i18n("Paths to Local CGI Programs"), this);
51 QVBoxLayout
*vbox
= new QVBoxLayout
;
53 topBox
->setLayout(vbox
);
54 topLayout
->addWidget(topBox
);
56 mListBox
= new QListWidget( topBox
);
58 vbox
->addWidget(mListBox
);
59 KHBox
*buttonBox
= new KHBox( topBox
);
60 buttonBox
->setSpacing( KDialog::spacingHint() );
62 mAddButton
= new QPushButton( i18n("Add..."), buttonBox
);
63 connect( mAddButton
, SIGNAL( clicked() ), SLOT( addPath() ) );
65 mRemoveButton
= new QPushButton( i18n("Remove"), buttonBox
);
66 connect( mRemoveButton
, SIGNAL( clicked() ), SLOT( removePath() ) );
67 connect( mListBox
, SIGNAL(itemClicked(QListWidgetItem
*)),this, SLOT(slotItemSelected(QListWidgetItem
*)));
69 vbox
->addWidget(buttonBox
);
70 mConfig
= new KConfig("kcmcgirc", KConfig::NoGlobals
);
75 new KAboutData( I18N_NOOP("kcmcgi"), 0,
76 ki18n("CGI KIO Slave Control Module"),
77 0, KLocalizedString(), KAboutData::License_GPL
,
78 ki18n("(c) 2002 Cornelius Schumacher") );
80 about
->addAuthor( ki18n("Cornelius Schumacher"), KLocalizedString(), "schumacher@kde.org" );
89 void KCMCgi::slotItemSelected( QListWidgetItem
* )
94 void KCMCgi::updateButton()
96 mRemoveButton
->setEnabled( !mListBox
->selectedItems().isEmpty() );
99 void KCMCgi::defaults()
110 for( i
= 0; i
< mListBox
->count(); ++i
) {
111 paths
.append( mListBox
->item(i
)->text() );
114 mConfig
->group("General").writeEntry( "Paths", paths
);
121 QStringList paths
= mConfig
->group("General").readEntry( "Paths" , QStringList() );
123 mListBox
->addItems( paths
);
126 void KCMCgi::addPath()
128 QString path
= KFileDialog::getExistingDirectory( QString(), this );
130 if ( !path
.isEmpty() ) {
131 mListBox
->addItem( path
);
132 emit
changed( true );
137 void KCMCgi::removePath()
139 int index
= mListBox
->currentRow();
141 delete mListBox
->takeItem( index
);
142 emit
changed( true );
147 QString
KCMCgi::quickHelp() const
149 return i18n("<h1>CGI Scripts</h1> The CGI KIO slave lets you execute "
150 "local CGI programs without the need to run a web server. "
151 "In this control module you can configure the paths that "
152 "are searched for CGI scripts.");