when a new activity is added, don't move more than necessary to show it
[kdebase.git] / runtime / khelpcenter / htmlsearchconfig.cpp
blob3d6bd882c0c247eb2c7520bd0316f7fcfb0e83f7
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. "
61 "You can get ht://dig at the"), gb);
62 l->setMinimumSize(l->sizeHint());
63 grid->addWidget(l, 1, 1, 0, 1);
64 gb->setWhatsThis( i18n( "Information about where to get the ht://dig package." ) );
66 KUrlLabel *url = new KUrlLabel(gb);
67 url->setUrl(QLatin1String("http://www.htdig.org"));
68 url->setText(i18n("ht://dig home page"));
69 url->setAlignment(Qt::AlignHCenter);
70 grid->addWidget(url, 2,2, 0, 1);
71 connect(url, SIGNAL(leftClickedUrl(const QString&)),
72 this, SLOT(urlClicked(const QString&)));
74 gb = new QGroupBox(i18n("Program Locations"), this);
76 vbox->addWidget(gb);
77 grid = new QGridLayout(gb);
78 grid->setMargin( 6 );
79 grid->setSpacing( 6 );
80 grid->addItem( new QSpacerItem( 0, gb->fontMetrics().lineSpacing() ), 0, 0 );
82 mHtsearchUrl = new KUrlRequester(gb);
83 l = new QLabel(i18n("htsearch:"), gb);
84 l->setBuddy( mHtsearchUrl );
85 grid->addWidget(l, 1,0);
86 grid->addWidget(mHtsearchUrl, 1,1);
87 connect( mHtsearchUrl->lineEdit(), SIGNAL( textChanged( const QString & ) ),
88 SIGNAL( changed() ) );
89 QString wtstr = i18n( "Enter the URL of the htsearch CGI program." );
90 mHtsearchUrl->setWhatsThis( wtstr );
91 l->setWhatsThis( wtstr );
93 mIndexerBin = new KUrlRequester(gb);
94 l = new QLabel(i18n("Indexer:"), gb);
95 l->setBuddy( mIndexerBin );
96 grid->addWidget(l, 2,0);
97 grid->addWidget(mIndexerBin, 2,1);
98 connect( mIndexerBin->lineEdit(), SIGNAL( textChanged( const QString & ) ),
99 SIGNAL( changed() ) );
100 wtstr = i18n( "Enter the path to your htdig indexer program here." );
101 mIndexerBin->setWhatsThis( wtstr );
102 l->setWhatsThis( wtstr );
104 mDbDir = new KUrlRequester(gb);
105 mDbDir->setMode( KFile::Directory | KFile::LocalOnly );
106 l = new QLabel(i18n("htdig database:"), gb);
107 l->setBuddy( mDbDir );
108 grid->addWidget(l, 3,0);
109 grid->addWidget(mDbDir, 3,1);
110 connect( mDbDir->lineEdit(), SIGNAL( textChanged( const QString & ) ),
111 SIGNAL( changed() ) );
112 wtstr = i18n( "Enter the path to the htdig database folder." );
113 mDbDir->setWhatsThis( wtstr );
114 l->setWhatsThis( wtstr );
117 HtmlSearchConfig::~HtmlSearchConfig()
119 kDebug() << "~HtmlSearchConfig()";
122 void HtmlSearchConfig::makeReadOnly()
124 mHtsearchUrl->setEnabled( false );
125 mIndexerBin->setEnabled( false );
126 mDbDir->setEnabled( false );
129 void HtmlSearchConfig::load( KConfig *config )
131 mHtsearchUrl->lineEdit()->setText(config->group("htdig").readPathEntry("htsearch", KGlobal::mainComponent().dirs()->findExe("htsearch")));
132 mIndexerBin->lineEdit()->setText(config->group("htdig").readPathEntry("indexer", QString()));
133 mDbDir->lineEdit()->setText(config->group("htdig").readPathEntry("dbdir", "/opt/www/htdig/db/" ) );
136 void HtmlSearchConfig::save( KConfig *config )
138 config->group("htdig").writePathEntry("htsearch", mHtsearchUrl->lineEdit()->text());
139 config->group("htdig").writePathEntry("indexer", mIndexerBin->lineEdit()->text());
140 config->group("htdig").writePathEntry("dbdir", mDbDir->lineEdit()->text());
143 void HtmlSearchConfig::defaults()
145 mHtsearchUrl->lineEdit()->setText(KGlobal::mainComponent().dirs()->findExe("htsearch"));
146 mIndexerBin->lineEdit()->setText("");
147 mDbDir->lineEdit()->setText(QLatin1String("/opt/www/htdig/db/") );
150 void HtmlSearchConfig::urlClicked(const QString &url)
152 KToolInvocation::invokeBrowser(url);
155 } // End namespace KHC
156 // vim:ts=2:sw=2:et
158 #include "htmlsearchconfig.moc"