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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 00019 00020 As a special exception, permission is given to link this program 00021 with any edition of TQt, and distribute the resulting executable, 00022 without including the source code for TQt in the source distribution. 00023 */ 00024 00025 #include "aboutdialog.h" 00026 00027 #include "core.h" 00028 #include "plugin.h" 00029 00030 #include <tdelocale.h> 00031 #include <kiconloader.h> 00032 #include <tdeaboutdata.h> 00033 #include <kactivelabel.h> 00034 #include <ktextbrowser.h> 00035 00036 #include <tqlayout.h> 00037 #include <tqlabel.h> 00038 00039 #include <kdebug.h> 00040 00041 using namespace Kontact; 00042 00043 AboutDialog::AboutDialog( Kontact::Core *core, const char *name ) 00044 : KDialogBase( IconList, i18n("About Kontact"), Ok, Ok, core, name, false, 00045 true ), 00046 mCore( core ) 00047 { 00048 addAboutData( i18n( "Kontact Container" ), TQString( "kontact" ), 00049 TDEGlobal::instance()->aboutData() ); 00050 00051 TQValueList<Plugin*> plugins = mCore->pluginList(); 00052 TQValueList<Plugin*>::ConstIterator end = plugins.end(); 00053 TQValueList<Plugin*>::ConstIterator it = plugins.begin(); 00054 for ( ; it != end; ++it ) 00055 addAboutPlugin( *it ); 00056 00057 addLicenseText( TDEGlobal::instance()->aboutData() ); 00058 } 00059 00060 void AboutDialog::addAboutPlugin( Kontact::Plugin *plugin ) 00061 { 00062 addAboutData( plugin->title(), plugin->icon(), plugin->aboutData() ); 00063 } 00064 00065 void AboutDialog::addAboutData( const TQString &title, const TQString &icon, 00066 const TDEAboutData *about ) 00067 { 00068 TQPixmap pixmap = TDEGlobal::iconLoader()->loadIcon( icon, 00069 TDEIcon::Desktop, 48 ); 00070 00071 TQFrame *topFrame = addPage( title, TQString(), pixmap ); 00072 00073 TQBoxLayout *topLayout = new TQVBoxLayout( topFrame ); 00074 00075 if ( !about ) { 00076 TQLabel *label = new TQLabel( i18n( "No about information available." ), 00077 topFrame ); 00078 topLayout->addWidget( label ); 00079 } else { 00080 TQString text; 00081 00082 text += "<p><b>" + about->programName() + "</b><br>"; 00083 00084 text += i18n( "Version %1</p>" ).arg( about->version() ); 00085 00086 if ( !about->shortDescription().isEmpty() ) { 00087 text += "<p>" + about->shortDescription() + "<br>" + 00088 about->copyrightStatement() + "</p>"; 00089 } 00090 00091 TQString home = about->homepage(); 00092 if ( !home.isEmpty() ) { 00093 text += "<a href=\"" + home + "\">" + home + "</a><br>"; 00094 } 00095 00096 text.replace( "\n", "<br>" ); 00097 00098 KActiveLabel *label = new KActiveLabel( text, topFrame ); 00099 label->setAlignment( AlignTop ); 00100 topLayout->addWidget( label ); 00101 00102 00103 TQTextEdit *personView = new TQTextEdit( topFrame ); 00104 personView->setReadOnly( true ); 00105 topLayout->addWidget( personView, 1 ); 00106 00107 text = ""; 00108 00109 const TQValueList<TDEAboutPerson> authors = about->authors(); 00110 if ( !authors.isEmpty() ) { 00111 text += i18n( "<p><b>Authors:</b></p>" ); 00112 00113 TQValueList<TDEAboutPerson>::ConstIterator it; 00114 for ( it = authors.begin(); it != authors.end(); ++it ) { 00115 text += formatPerson( (*it).name(), (*it).emailAddress() ); 00116 if ( !(*it).task().isEmpty() ) 00117 text += "<i>" + (*it).task() + "</i><br>"; 00118 } 00119 } 00120 00121 const TQValueList<TDEAboutPerson> credits = about->credits(); 00122 if ( !credits.isEmpty() ) { 00123 text += i18n( "<p><b>Thanks to:</b></p>" ); 00124 00125 TQValueList<TDEAboutPerson>::ConstIterator it; 00126 for ( it = credits.begin(); it != credits.end(); ++it ) { 00127 text += formatPerson( (*it).name(), (*it).emailAddress() ); 00128 if ( !(*it).task().isEmpty() ) 00129 text += "<i>" + (*it).task() + "</i><br>"; 00130 } 00131 } 00132 00133 const TQValueList<TDEAboutTranslator> translators = about->translators(); 00134 if ( !translators.isEmpty() ) { 00135 text += i18n("<p><b>Translators:</b></p>"); 00136 00137 TQValueList<TDEAboutTranslator>::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 TQString AboutDialog::formatPerson( const TQString &name, const TQString &email ) 00148 { 00149 TQString text = name; 00150 if ( !email.isEmpty() ) { 00151 text += " <<a href=\"mailto:" + email + "\">" + email + "</a>>"; 00152 } 00153 00154 text += "<br>"; 00155 return text; 00156 } 00157 00158 void AboutDialog::addLicenseText( const TDEAboutData *about ) 00159 { 00160 if ( !about || about->license().isEmpty() ) 00161 return; 00162 00163 TQPixmap pixmap = TDEGlobal::iconLoader()->loadIcon( "signature", 00164 TDEIcon::Desktop, 48 ); 00165 00166 TQString title = i18n( "%1 License" ).arg( about->programName() ); 00167 00168 TQFrame *topFrame = addPage( title, TQString(), pixmap ); 00169 TQBoxLayout *topLayout = new TQVBoxLayout( topFrame ); 00170 00171 KTextBrowser *textBrowser = new KTextBrowser( topFrame ); 00172 textBrowser->setText( TQString( "<pre>%1</pre>" ).arg( about->license() ) ); 00173 00174 topLayout->addWidget( textBrowser ); 00175 } 00176 00177 #include "aboutdialog.moc"