2 Copyright (c) 2000,2001 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 "aboutwidget.h"
22 #include "moduletreeview.h"
24 #include <kstandarddirs.h>
28 #include <kglobalsettings.h>
29 #include <khtml_part.h>
30 #include <kapplication.h>
34 #include <QTextStream>
36 #include "aboutwidget.moc"
38 static const char kcc_infotext
[]= I18N_NOOP("KDE Info Center");
40 static const char title_infotext
[]= I18N_NOOP("Get system and desktop environment information");
42 static const char intro_infotext
[]= I18N_NOOP("Welcome to the \"KDE Info Center\", "
43 "a central place to find information about your "
46 static const char use_text
[]= I18N_NOOP("Click on the \"Help\" tab on the left to view help "
48 "control module. Use the \"Search\" tab if you are unsure "
50 "a particular configuration option.");
52 static const char version_text
[]= I18N_NOOP("KDE version:");
53 static const char user_text
[]= I18N_NOOP("User:");
54 static const char host_text
[]= I18N_NOOP("Hostname:");
55 static const char system_text
[]= I18N_NOOP("System:");
56 static const char release_text
[]= I18N_NOOP("Release:");
57 static const char machine_text
[]= I18N_NOOP("Machine:");
59 AboutWidget::AboutWidget(QWidget
*parent
, ConfigModuleList
* configModules
, const QString
&caption
) :
60 KHBox(parent
), _configModules(configModules
), _caption(caption
) {
62 setMinimumSize(400, 400);
64 // set qwhatsthis help
65 this->setWhatsThis(i18n(intro_infotext
));
66 _viewer
= new KHTMLPart( this );
67 _viewer
->widget()->setSizePolicy(QSizePolicy::Ignored
, QSizePolicy::Ignored
);
68 connect(_viewer
->browserExtension(),
69 SIGNAL(openUrlRequest(const KUrl
&, const KParts::OpenUrlArguments
&, const KParts::BrowserArguments
&)), this, SLOT(slotModuleLinkClicked(const KUrl
&)));
73 void AboutWidget::updatePixmap() {
74 QString file
= KStandardDirs::locate("data", "kinfocenter/about/main.html");
76 f
.open(QIODevice::ReadOnly
);
78 QString res
= t
.readAll();
80 res
= res
.arg(KStandardDirs::locate("data", "kdeui/about/kde_infopage.css") );
81 if ( kapp
->layoutDirection() == Qt::RightToLeft
)
82 res
= res
.arg( "@import \"%1\";" ).arg(KStandardDirs::locate("data", "kdeui/about/kde_infopage_rtl.css") );
86 QString title
, intro
, caption
;
87 res
= res
.arg(i18n(kcc_infotext
));
88 res
= res
.arg(i18n(title_infotext
));
89 res
= res
.arg(i18n(intro_infotext
));
93 if (_configModules
== NULL
) {
94 content
+= "<table class=\"kc_table\">\n";
95 #define KC_HTMLROW( a, b ) "<tr><td class=\"kc_leftcol\">" + i18n( a ) + "</td><td class=\"kc_rightcol\">" + b + "</tr>\n"
96 content
+= KC_HTMLROW( version_text
, KCGlobal::kdeVersion() );
97 content
+= KC_HTMLROW( user_text
, KCGlobal::userName() );
98 content
+= KC_HTMLROW( host_text
, KCGlobal::hostName() );
99 content
+= KC_HTMLROW( system_text
, KCGlobal::systemName() );
100 content
+= KC_HTMLROW( release_text
, KCGlobal::systemRelease() );
101 content
+= KC_HTMLROW( machine_text
, KCGlobal::systemMachine() );
103 content
+= "</table>\n";
104 content
+= "<p class=\"kc_use_text\">" + i18n(use_text
) + "</p>\n";
106 content
+= "<div id=\"tableTitle\">" + _caption
+ "</div>";
108 content
+= "<table class=\"kc_table\">\n";
111 foreach(ConfigModule
* configModule
, *_configModules
) {
115 content
+= "<tr><td class=\"kc_leftcol\">";
116 szName
= configModule
->moduleName();
117 szComment
= configModule
->comment();
118 content
+= "<a href=\"%1\">" + szName
+ "</a></td><td class=\"kc_rightcol\">" + szComment
;
119 KUrl
moduleURL(QString("kcm://%1").arg(QString().sprintf("%p", (void*)configModule
)) );
120 QString
linkURL(moduleURL
.url() );
121 content
= content
.arg(linkURL
);
122 _moduleMap
.insert(linkURL
, configModule
);
124 content
+= "</td></tr>\n";
127 content
+= "</table>";
130 _viewer
->begin(KUrl(file
));
131 _viewer
->write(res
.arg(content
) );
135 void AboutWidget::slotModuleLinkClicked(const KUrl
& url
) {
136 ConfigModule
* module
= _moduleMap
[url
.url()];
138 emit
moduleSelected(module
);