delay a few things on startup, such as setting the visibility mode, which ensures...
[personal-kdebase.git] / runtime / khelpcenter / htmlsearchconfig.cpp
blob037b4ff76a3d1b10a61202b0cc220f1bb0216b0e
1 /**
2 * kcmhtmlsearch.cpp
4 * Copyright (c) 2000 Matthias Hölzer-Klüpfel <hoelzer@kde.org>
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program 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
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
21 #include "htmlsearchconfig.h"
23 #include <QLayout>
24 //Added by qt3to4:
25 #include <QLabel>
26 #include <QVBoxLayout>
27 #include <QGridLayout>
29 #include <kdebug.h>
30 #include <kstandarddirs.h>
31 #include <klocale.h>
32 #include <kurllabel.h>
33 #include <kapplication.h>
34 #include <kfiledialog.h>
35 #include <kurlrequester.h>
36 #include <klineedit.h>
37 #include <ktoolinvocation.h>
39 namespace KHC {
41 HtmlSearchConfig::HtmlSearchConfig(QWidget *parent, const char *name)
42 : QWidget(parent)
44 setObjectName( name );
46 QVBoxLayout *vbox = new QVBoxLayout(this);
47 vbox->setMargin( 5 );
50 QGroupBox *gb = new QGroupBox(i18n("ht://dig"), this);
51 vbox->addWidget(gb);
53 QGridLayout *grid = new QGridLayout(gb);
54 grid->setMargin( 6 );
55 grid->setSpacing( 6 );
57 grid->addItem( new QSpacerItem( 0, gb->fontMetrics().lineSpacing() ), 0, 0 );
59 QLabel *l = new QLabel(i18n("The fulltext search feature makes use of the "
60 "ht://dig HTML search engine."), gb);
61 l->setMinimumSize(l->sizeHint());
62 grid->addWidget(l, 1, 1, 0, 1);
63 gb->setWhatsThis( i18n( "Information about where to get the ht://dig package." ) );
65 KUrlLabel *url = new KUrlLabel(gb);
66 url->setUrl(QLatin1String("http://www.htdig.org"));
67 url->setText(i18n("You can get ht://dig at the ht://dig home page"));
68 url->setAlignment(Qt::AlignHCenter);
69 grid->addWidget(url, 2,2, 0, 1);
70 connect(url, SIGNAL(leftClickedUrl(const QString&)),
71 this, SLOT(urlClicked(const QString&)));
73 gb = new QGroupBox(i18n("Program Locations"), this);
75 vbox->addWidget(gb);
76 grid = new QGridLayout(gb);
77 grid->setMargin( 6 );
78 grid->setSpacing( 6 );
79 grid->addItem( new QSpacerItem( 0, gb->fontMetrics().lineSpacing() ), 0, 0 );
81 mHtsearchUrl = new KUrlRequester(gb);
82 l = new QLabel(i18n("htsearch:"), gb);
83 l->setBuddy( mHtsearchUrl );
84 grid->addWidget(l, 1,0);
85 grid->addWidget(mHtsearchUrl, 1,1);
86 connect( mHtsearchUrl->lineEdit(), SIGNAL( textChanged( const QString & ) ),
87 SIGNAL( changed() ) );
88 QString wtstr = i18n( "Enter the URL of the htsearch CGI program." );
89 mHtsearchUrl->setWhatsThis( wtstr );
90 l->setWhatsThis( wtstr );
92 mIndexerBin = new KUrlRequester(gb);
93 l = new QLabel(i18n("Indexer:"), gb);
94 l->setBuddy( mIndexerBin );
95 grid->addWidget(l, 2,0);
96 grid->addWidget(mIndexerBin, 2,1);
97 connect( mIndexerBin->lineEdit(), SIGNAL( textChanged( const QString & ) ),
98 SIGNAL( changed() ) );
99 wtstr = i18n( "Enter the path to your htdig indexer program here." );
100 mIndexerBin->setWhatsThis( wtstr );
101 l->setWhatsThis( wtstr );
103 mDbDir = new KUrlRequester(gb);
104 mDbDir->setMode( KFile::Directory | KFile::LocalOnly );
105 l = new QLabel(i18n("htdig database:"), gb);
106 l->setBuddy( mDbDir );
107 grid->addWidget(l, 3,0);
108 grid->addWidget(mDbDir, 3,1);
109 connect( mDbDir->lineEdit(), SIGNAL( textChanged( const QString & ) ),
110 SIGNAL( changed() ) );
111 wtstr = i18n( "Enter the path to the htdig database folder." );
112 mDbDir->setWhatsThis( wtstr );
113 l->setWhatsThis( wtstr );
116 HtmlSearchConfig::~HtmlSearchConfig()
118 kDebug() << "~HtmlSearchConfig()";
121 void HtmlSearchConfig::makeReadOnly()
123 mHtsearchUrl->setEnabled( false );
124 mIndexerBin->setEnabled( false );
125 mDbDir->setEnabled( false );
128 void HtmlSearchConfig::load( KConfig *config )
130 mHtsearchUrl->lineEdit()->setText(config->group("htdig").readPathEntry("htsearch", KGlobal::mainComponent().dirs()->findExe("htsearch")));
131 mIndexerBin->lineEdit()->setText(config->group("htdig").readPathEntry("indexer", QString()));
132 mDbDir->lineEdit()->setText(config->group("htdig").readPathEntry("dbdir", "/opt/www/htdig/db/" ) );
135 void HtmlSearchConfig::save( KConfig *config )
137 config->group("htdig").writePathEntry("htsearch", mHtsearchUrl->lineEdit()->text());
138 config->group("htdig").writePathEntry("indexer", mIndexerBin->lineEdit()->text());
139 config->group("htdig").writePathEntry("dbdir", mDbDir->lineEdit()->text());
142 void HtmlSearchConfig::defaults()
144 mHtsearchUrl->lineEdit()->setText(KGlobal::mainComponent().dirs()->findExe("htsearch"));
145 mIndexerBin->lineEdit()->setText("");
146 mDbDir->lineEdit()->setText(QLatin1String("/opt/www/htdig/db/") );
149 void HtmlSearchConfig::urlClicked(const QString &url)
151 KToolInvocation::invokeBrowser(url);
154 } // End namespace KHC
155 // vim:ts=2:sw=2:et
157 #include "htmlsearchconfig.moc"