00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
#include "aboutdialog.h"
00026
#include "aboutdialog.moc"
00027
00028
#include "core.h"
00029
#include "plugin.h"
00030
00031
#include <klocale.h>
00032
#include <kiconloader.h>
00033
#include <kaboutdata.h>
00034
#include <kactivelabel.h>
00035
#include <ktextbrowser.h>
00036
00037
#include <qlayout.h>
00038
#include <qlabel.h>
00039
00040
#include <kdebug.h>
00041
00042
using namespace Kontact;
00043
00044 AboutDialog::AboutDialog(
Kontact::Core *core,
const char *name )
00045 : KDialogBase( IconList, i18n("About Kontact"), Ok, Ok, core, name, false,
00046 true ),
00047 mCore( core )
00048 {
00049 addAboutData( i18n(
"Kontact Container"),
QString(
"kontact" ),
00050 KGlobal::instance()->aboutData() );
00051
00052
QValueList<Plugin*> plugins = mCore->pluginList();
00053
QValueList<Plugin*>::ConstIterator end = plugins.end();
00054
QValueList<Plugin*>::ConstIterator it = plugins.begin();
00055
for ( ; it != end; ++it ) {
00056 addAboutPlugin( *it );
00057 }
00058
00059 addLicenseText( KGlobal::instance()->aboutData() );
00060 }
00061
00062
void AboutDialog::addAboutPlugin(
Kontact::Plugin *plugin )
00063 {
00064 addAboutData( plugin->
title(), plugin->
icon(), plugin->
aboutData() );
00065 }
00066
00067
void AboutDialog::addAboutData(
const QString &title,
const QString &icon,
00068
const KAboutData *about )
00069 {
00070
QPixmap pixmap = KGlobal::iconLoader()->loadIcon( icon,
00071 KIcon::Desktop, 48 );
00072
00073
QFrame *topFrame = addPage( title, QString::null, pixmap );
00074
00075
QBoxLayout *topLayout =
new QVBoxLayout( topFrame );
00076
00077
if ( !about ) {
00078
QLabel *label =
new QLabel( i18n(
"No about information available."),
00079 topFrame );
00080 topLayout->
addWidget( label );
00081 }
else {
00082
QString text;
00083
00084 text +=
"<p><b>" + about->programName() +
"</b><br>";
00085
00086 text += i18n(
"Version %1</p>").arg( about->version() );
00087
00088
if (!about->shortDescription().isEmpty()) {
00089 text +=
"<p>" + about->shortDescription() +
"<br>" +
00090 about->copyrightStatement() +
"</p>";
00091 }
00092
00093
QString home = about->homepage();
00094
if ( !home.isEmpty() ) {
00095 text +=
"<a href=\"" + home +
"\">" + home +
"</a><br>";
00096 }
00097
00098 text.replace(
"\n",
"<br>" );
00099
00100 KActiveLabel *label =
new KActiveLabel( text, topFrame );
00101 label->setAlignment( AlignTop );
00102 topLayout->
addWidget( label );
00103
00104
00105
QTextEdit *personView =
new QTextEdit( topFrame );
00106 personView->setReadOnly(
true );
00107 topLayout->
addWidget( personView, 1 );
00108
00109 text =
"";
00110
00111
QValueList<KAboutPerson> authors = about->authors();
00112
if ( !authors.isEmpty() ) {
00113 text += i18n(
"<p><b>Authors:</b></p>");
00114
00115
QValueList<KAboutPerson>::ConstIterator it;
00116
for( it = authors.begin(); it != authors.end(); ++it ) {
00117 text += formatPerson( (*it).name(), (*it).emailAddress() );
00118
if (!(*it).task().isEmpty()) text +=
"<i>" + (*it).task() +
"</i><br>";
00119 }
00120 }
00121
00122
QValueList<KAboutPerson> credits = about->credits();
00123
if ( !credits.isEmpty() ) {
00124 text += i18n(
"<p><b>Thanks to:</b></p>");
00125
00126
QValueList<KAboutPerson>::ConstIterator it;
00127
for( it = credits.begin(); it != credits.end(); ++it ) {
00128 text += formatPerson( (*it).name(), (*it).emailAddress() );
00129
if (!(*it).task().isEmpty()) text +=
"<i>" + (*it).task() +
"</i><br>";
00130 }
00131 }
00132
00133
QValueList<KAboutTranslator> translators = about->translators();
00134
if ( !translators.isEmpty() ) {
00135 text += i18n(
"<p><b>Translators:</b></p>");
00136
00137
QValueList<KAboutTranslator>::ConstIterator it;
00138
for( it = translators.begin(); it != translators.end(); ++it ) {
00139 text += formatPerson( (*it).name(), (*it).emailAddress() );
00140 }
00141 }
00142
00143 personView->setText( text );
00144 }
00145 }
00146
00147
QString AboutDialog::formatPerson(
const QString &name,
const QString &email )
00148 {
00149
QString text = name;
00150
if ( !email.isEmpty() ) {
00151 text +=
" <<a href=\"mailto:" + email +
"\">" + email +
"</a>>";
00152 }
00153 text +=
"<br>";
00154
return text;
00155 }
00156
00157
void AboutDialog::addLicenseText(
const KAboutData *about)
00158 {
00159
if ( !about || about->license().isEmpty() )
return;
00160
00161
QPixmap pixmap = KGlobal::iconLoader()->loadIcon(
"signature",
00162 KIcon::Desktop, 48 );
00163
00164
QString title = i18n(
"%1 license").arg(about->programName());
00165
00166
QFrame *topFrame = addPage( title, QString::null, pixmap );
00167
QBoxLayout *topLayout =
new QVBoxLayout( topFrame );
00168
00169 KTextBrowser *textBrowser =
new KTextBrowser( topFrame );
00170 textBrowser->setText(
QString(
"<pre>%1</pre>").arg(about->license()) );
00171
00172 topLayout->
addWidget(textBrowser);
00173 }