kontact
aboutdialog.cpp00001
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 <klocale.h>
00031 #include <kiconloader.h>
00032 #include <kaboutdata.h>
00033 #include <kactivelabel.h>
00034 #include <ktextbrowser.h>
00035
00036 #include <qlayout.h>
00037 #include <qlabel.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" ), QString( "kontact" ),
00049 KGlobal::instance()->aboutData() );
00050
00051 QValueList<Plugin*> plugins = mCore->pluginList();
00052 QValueList<Plugin*>::ConstIterator end = plugins.end();
00053 QValueList<Plugin*>::ConstIterator it = plugins.begin();
00054 for ( ; it != end; ++it )
00055 addAboutPlugin( *it );
00056
00057 addLicenseText( KGlobal::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 QString &title, const QString &icon,
00066 const KAboutData *about )
00067 {
00068 QPixmap pixmap = KGlobal::iconLoader()->loadIcon( icon,
00069 KIcon::Desktop, 48 );
00070
00071 QFrame *topFrame = addPage( title, QString::null, pixmap );
00072
00073 QBoxLayout *topLayout = new QVBoxLayout( topFrame );
00074
00075 if ( !about ) {
00076 QLabel *label = new QLabel( i18n( "No about information available." ),
00077 topFrame );
00078 topLayout->addWidget( label );
00079 } else {
00080 QString 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 QString 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 QTextEdit *personView = new QTextEdit( topFrame );
00104 personView->setReadOnly( true );
00105 topLayout->addWidget( personView, 1 );
00106
00107 text = "";
00108
00109 const QValueList<KAboutPerson> authors = about->authors();
00110 if ( !authors.isEmpty() ) {
00111 text += i18n( "<p><b>Authors:</b></p>" );
00112
00113 QValueList<KAboutPerson>::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 QValueList<KAboutPerson> credits = about->credits();
00122 if ( !credits.isEmpty() ) {
00123 text += i18n( "<p><b>Thanks to:</b></p>" );
00124
00125 QValueList<KAboutPerson>::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 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
00154 text += "<br>";
00155 return text;
00156 }
00157
00158 void AboutDialog::addLicenseText( const KAboutData *about )
00159 {
00160 if ( !about || about->license().isEmpty() )
00161 return;
00162
00163 QPixmap pixmap = KGlobal::iconLoader()->loadIcon( "signature",
00164 KIcon::Desktop, 48 );
00165
00166 QString title = i18n( "%1 License" ).arg( about->programName() );
00167
00168 QFrame *topFrame = addPage( title, QString::null, pixmap );
00169 QBoxLayout *topLayout = new QVBoxLayout( topFrame );
00170
00171 KTextBrowser *textBrowser = new KTextBrowser( topFrame );
00172 textBrowser->setText( QString( "<pre>%1</pre>" ).arg( about->license() ) );
00173
00174 topLayout->addWidget( textBrowser );
00175 }
00176
00177 #include "aboutdialog.moc"
|