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
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"