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_text
[] = I18N_NOOP("KDE Control Center");
40 static const char title_text
[] = I18N_NOOP("Configure your desktop environment.");
42 static const char intro_text
[] = I18N_NOOP("Welcome to the \"KDE Control Center\", "
43 "a central place to configure your "
44 "desktop environment. "
45 "Select an item from the index on the left "
46 "to load a configuration module.");
48 static const char kcc_infotext
[] = I18N_NOOP("KDE Info Center");
50 static const char title_infotext
[] = I18N_NOOP("Get system and desktop environment information");
52 static const char intro_infotext
[] = I18N_NOOP("Welcome to the \"KDE Info Center\", "
53 "a central place to find information about your "
56 static const char use_text
[] = I18N_NOOP("Click on the \"Help\" tab on the left to view help "
58 "control module. Use the \"Search\" tab if you are unsure "
60 "a particular configuration option.");
62 static const char version_text
[] = I18N_NOOP("KDE version:");
63 static const char user_text
[] = I18N_NOOP("User:");
64 static const char host_text
[] = I18N_NOOP("Hostname:");
65 static const char system_text
[] = I18N_NOOP("System:");
66 static const char release_text
[] = I18N_NOOP("Release:");
67 static const char machine_text
[] = I18N_NOOP("Machine:");
69 AboutWidget::AboutWidget(QWidget
*parent
, Q3ListViewItem
* category
, const QString
&caption
)
78 setMinimumSize(400, 400);
80 // set qwhatsthis help
81 this->setWhatsThis( i18n(intro_text
));
82 _viewer
= new KHTMLPart( this );
83 _viewer
->widget()->setSizePolicy( QSizePolicy::Ignored
, QSizePolicy::Ignored
);
84 connect( _viewer
->browserExtension(),
85 SIGNAL(openUrlRequest(const KUrl
&, const KParts::OpenUrlArguments
&, const KParts::BrowserArguments
&)),
86 this, SLOT(slotModuleLinkClicked(const KUrl
&)) );
90 void AboutWidget::setCategory( Q3ListViewItem
* category
, const QString
&caption
)
99 // Update the pixmap to be shown:
103 void AboutWidget::updatePixmap()
105 QString file
= KStandardDirs::locate( "data", "kinfocenter/about/main.html" );
107 f
.open( QIODevice::ReadOnly
);
109 QString res
= t
.readAll();
111 res
= res
.arg( KStandardDirs::locate( "data", "kdeui/about/kde_infopage.css" ) );
112 if ( kapp
->layoutDirection() == Qt::RightToLeft
)
113 res
= res
.arg( "@import \"%1\";" ).arg( KStandardDirs::locate( "data", "kdeui/about/kde_infopage_rtl.css" ) );
118 QString title
, intro
, caption
;
119 if (KCGlobal::isInfoCenter())
121 res
= res
.arg(i18n(kcc_infotext
))
122 .arg(i18n(title_infotext
))
123 .arg(i18n(intro_infotext
));
127 res
= res
.arg(i18n(kcc_text
))
128 .arg(i18n(title_text
))
129 .arg(i18n(intro_text
));
136 content
+= "<table class=\"kc_table\">\n";
137 #define KC_HTMLROW( a, b ) "<tr><td class=\"kc_leftcol\">" + i18n( a ) + "</td><td class=\"kc_rightcol\">" + b + "</tr>\n"
138 content
+= KC_HTMLROW( version_text
, KCGlobal::kdeVersion() );
139 content
+= KC_HTMLROW( user_text
, KCGlobal::userName() );
140 content
+= KC_HTMLROW( host_text
, KCGlobal::hostName() );
141 content
+= KC_HTMLROW( system_text
, KCGlobal::systemName() );
142 content
+= KC_HTMLROW( release_text
, KCGlobal::systemRelease() );
143 content
+= KC_HTMLROW( machine_text
, KCGlobal::systemMachine() );
145 content
+= "</table>\n";
146 content
+= "<p class=\"kc_use_text\">" + i18n( use_text
) + "</p>\n";
150 content
+= "<div id=\"tableTitle\">" + _caption
+ "</div>";
152 content
+= "<table class=\"kc_table\">\n";
154 Q3ListViewItem
* pEntry
= _category
;
155 while (pEntry
!= NULL
)
159 ConfigModule
*module
= static_cast<ModuleTreeItem
*>(pEntry
)->module();
160 /* TODO: work out link */
161 content
+= "<tr><td class=\"kc_leftcol\">";
164 szName
= module
->moduleName();
165 szComment
= module
->comment();
166 content
+= "<a href=\"%1\" class=\"kcm_link\">" + szName
+ "</a></td><td class=\"kc_rightcol\">" + szComment
;
167 KUrl
moduleURL(QString("kcm://%1").arg(QString().sprintf("%p",(void*)module
)) );
168 QString
linkURL( moduleURL
.url() );
169 content
= content
.arg( linkURL
);
170 _moduleMap
.insert( linkURL
, module
);
174 szName
= static_cast<ModuleTreeItem
*>(pEntry
)->caption();
175 content
+= szName
+ "</td><td class=\"kc_rightcol\">" + szName
;
177 content
+= "</td></tr>\n";
178 pEntry
= pEntry
->nextSibling();
180 content
+= "</table>";
182 _viewer
->begin(KUrl(file
));
183 _viewer
->write( res
.arg( content
) );
187 void AboutWidget::slotModuleLinkClicked( const KUrl
& url
)
189 ConfigModule
* module
;
190 module
= _moduleMap
[url
.url()];
192 emit
moduleSelected( module
);