kontact Library API Documentation

aboutdialog.cpp

00001 /* 00002 This file is part of KDE Kontact. 00003 00004 Copyright (c) 2003 Cornelius Schumacher <schumacher@kde.org> 00005 00006 This program is free software; you can redistribute it and/or modify 00007 it under the terms of the GNU General Public License as published by 00008 the Free Software Foundation; either version 2 of the License, or 00009 (at your option) any later version. 00010 00011 This program is distributed in the hope that it will be useful, 00012 but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00014 GNU General Public License for more details. 00015 00016 You should have received a copy of the GNU General Public License 00017 along with this program; if not, write to the Free Software 00018 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 00019 00020 As a special exception, permission is given to link this program 00021 with any edition of Qt, and distribute the resulting executable, 00022 without including the source code for Qt in the source distribution. 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 += " &lt;<a href=\"mailto:" + email + "\">" + email + "</a>&gt;"; 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 }
KDE Logo
This file is part of the documentation for kontact Library Version 3.3.0.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Fri Aug 27 12:53:43 2004 by doxygen 1.3.8 written by Dimitri van Heesch, © 1997-2003