1 | /** |
2 | * kcmhtmlsearch.cpp |
3 | * |
4 | * Copyright (c) 2000 Matthias Hölzer-Klüpfel <hoelzer@kde.org> |
5 | * |
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. |
10 | * |
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. |
15 | * |
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. |
19 | */ |
20 | |
21 | #include "htmlsearchconfig.h" |
22 | |
23 | #include <QLayout> |
24 | |
25 | #include <QGroupBox> |
26 | #include <QLabel> |
27 | #include <QVBoxLayout> |
28 | #include <QGridLayout> |
29 | |
30 | #include <KDebug> |
31 | #include <KStandardDirs> |
32 | #include <KLocale> |
33 | #include <KUrlLabel> |
34 | #include <KApplication> |
35 | #include <KFileDialog> |
36 | #include <KUrlRequester> |
37 | #include <KLineEdit> |
38 | #include <KToolInvocation> |
39 | |
40 | namespace KHC { |
41 | |
42 | HtmlSearchConfig::HtmlSearchConfig(QWidget *parent, const char *name) |
43 | : QWidget(parent) |
44 | { |
45 | setObjectName( name ); |
46 | |
47 | QVBoxLayout *vbox = new QVBoxLayout(this); |
48 | vbox->setMargin( 5 ); |
49 | |
50 | |
51 | QGroupBox *gb = new QGroupBox(i18n("ht://dig" ), this); |
52 | vbox->addWidget(gb); |
53 | |
54 | QGridLayout *grid = new QGridLayout(gb); |
55 | grid->setMargin( 6 ); |
56 | grid->setSpacing( 6 ); |
57 | |
58 | grid->addItem( new QSpacerItem( 0, gb->fontMetrics().lineSpacing() ), 0, 0 ); |
59 | |
60 | QLabel *l = new QLabel(i18n("The fulltext search feature makes use of the " |
61 | "ht://dig HTML search engine." ), 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." ) ); |
65 | |
66 | KUrlLabel *url = new KUrlLabel(gb); |
67 | url->setUrl(QLatin1String("http://www.htdig.org" )); |
68 | url->setText(i18n("You can get ht://dig at the 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&))); |
73 | |
74 | gb = new QGroupBox(i18n("Program Locations" ), this); |
75 | |
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 ); |
81 | |
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 ); |
92 | |
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 ); |
103 | |
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 ); |
115 | } |
116 | |
117 | HtmlSearchConfig::~HtmlSearchConfig() |
118 | { |
119 | kDebug() << "~HtmlSearchConfig()" ; |
120 | } |
121 | |
122 | void HtmlSearchConfig::makeReadOnly() |
123 | { |
124 | mHtsearchUrl->setEnabled( false ); |
125 | mIndexerBin->setEnabled( false ); |
126 | mDbDir->setEnabled( false ); |
127 | } |
128 | |
129 | void HtmlSearchConfig::load( KConfig *config ) |
130 | { |
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/" ) ); |
134 | } |
135 | |
136 | void HtmlSearchConfig::save( KConfig *config ) |
137 | { |
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()); |
141 | } |
142 | |
143 | void HtmlSearchConfig::defaults() |
144 | { |
145 | mHtsearchUrl->lineEdit()->setText(KGlobal::mainComponent().dirs()->findExe("htsearch" )); |
146 | mIndexerBin->lineEdit()->setText("" ); |
147 | mDbDir->lineEdit()->setText(QLatin1String("/opt/www/htdig/db/" ) ); |
148 | } |
149 | |
150 | void HtmlSearchConfig::urlClicked(const QString &url) |
151 | { |
152 | KToolInvocation::invokeBrowser(url); |
153 | } |
154 | |
155 | } // End namespace KHC |
156 | // vim:ts=2:sw=2:et |
157 | |
158 | #include "htmlsearchconfig.moc" |
159 | |
160 | |