revert nonfunctional old_battery_percent
[kdebase.git] / apps / kinfocenter / helpwidget.cpp
blob6561010d38ef7b3d2335e66824cea613bc26468c
1 /*
2 Copyright (c) 2000 Matthias Elter <elter@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 along
15 with this program; if not, write to the Free Software Foundation, Inc.,
16 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19 #include "helpwidget.h"
20 #include "global.h"
21 #include "quickhelp.h"
23 #include <klocale.h>
24 #include <kdebug.h>
25 #include <kprocess.h>
26 #include <kapplication.h>
27 #include <krun.h>
28 #include <ktoolinvocation.h>
30 #include <QVBoxLayout>
32 #include "helpwidget.moc"
34 HelpWidget::HelpWidget(QWidget *parent)
35 : QWidget(parent)
37 QVBoxLayout *l = new QVBoxLayout(this);
39 _browser = new QuickHelp(this);
40 connect(_browser, SIGNAL(urlClick(const QString &)),
41 SLOT(urlClicked(const QString &)));
42 connect(_browser, SIGNAL(mailClick(const QString &,const QString &)),
43 SLOT(mailClicked(const QString &,const QString &)));
45 l->addWidget(_browser);
47 setBaseText();
50 void HelpWidget::setText( const QString& docPath, const QString& text)
52 docpath = docPath;
53 if (text.isEmpty() && docPath.isEmpty())
54 setBaseText();
55 else if (docPath.isEmpty())
56 _browser->setText(text);
57 else
59 QByteArray a = docPath.toLocal8Bit();
60 QString path = QString::fromLocal8Bit (a.data(), a.size());
62 _browser->setText(text + i18n("<p>Use the \"Whats This\" (Shift+F1) to get help on specific options.</p><p>To read the full manual click <a href=\"%1\">here</a>.</p>",
63 path));
67 void HelpWidget::setBaseText()
69 _browser->setText(i18n("<h1>KDE Info Center</h1>"
70 "There is no quick help available for the active info module."
71 "<br /><br />"
72 "Click <a href = \"kinfocenter/index.html\">here</a> to read the general Info Center manual.") );
75 void HelpWidget::urlClicked(const QString & _url)
77 KUrl url(KUrl("help:/"), _url);
79 if (url.protocol() == "help" || url.protocol() == "man" || url.protocol() == "info") {
80 KProcess::startDetached("khelpcenter", QStringList() << url.url());
81 } else {
82 new KRun(url, this);
86 void HelpWidget::mailClicked(const QString &,const QString & addr)
88 KToolInvocation::invokeMailer(addr, QString());