• Skip to content
  • Skip to link menu
KDE 4.2 API Reference
  • KDE API Reference
  • kdepim
  • Sitemap
  • Contact Us
 

kontact

aboutdialog.cpp

Go to the documentation of this file.
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 along
00017   with this program; if not, write to the Free Software Foundation, Inc.,
00018   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 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 "core.h"
00027 #include "plugin.h"
00028 
00029 #include <kdebug.h>
00030 #include <klocale.h>
00031 #include <kcomponentdata.h>
00032 #include <kaboutdata.h>
00033 #include <ktextbrowser.h>
00034 #include <kicon.h>
00035 
00036 #include <QLayout>
00037 #include <QLabel>
00038 #include <QTextEdit>
00039 
00040 using namespace Kontact;
00041 
00042 AboutDialog::AboutDialog( Kontact::Core *core )
00043   : KPageDialog( core ), mCore( core )
00044 {
00045   setCaption( i18n( "About Kontact" ) );
00046   setButtons( Ok );
00047   setDefaultButton( Ok );
00048   setModal( false );
00049   showButtonSeparator( true );
00050   setFaceType( KPageDialog::List );
00051   addAboutData( i18n( "Kontact Container" ), QString( "kontact" ),
00052                 KGlobal::mainComponent().aboutData() );
00053 
00054   QList<Plugin*> plugins = mCore->pluginList();
00055   QList<Plugin*>::ConstIterator end = plugins.end();
00056   QList<Plugin*>::ConstIterator it = plugins.begin();
00057   for ( ; it != end; ++it ) {
00058     addAboutPlugin( *it );
00059   }
00060 
00061   addLicenseText( KGlobal::mainComponent().aboutData() );
00062 
00063   setInitialSize( QSize( 600, 400 ) );
00064   restoreDialogSize( KConfigGroup( KGlobal::config(), "AboutDialog" ) );
00065   connect( this, SIGNAL(finished(int)), this, SLOT(saveSize()) );
00066 }
00067 
00068 void AboutDialog::saveSize()
00069 {
00070   KConfigGroup group( KGlobal::config(), "AboutDialog" );
00071   saveDialogSize( group );
00072   group.sync();
00073 }
00074 
00075 void AboutDialog::addAboutPlugin( Kontact::Plugin *plugin )
00076 {
00077   addAboutData( plugin->title(), plugin->icon(), plugin->aboutData() );
00078 }
00079 
00080 void AboutDialog::addAboutData( const QString &title, const QString &icon,
00081                                 const KAboutData *about )
00082 {
00083   QIcon pixmap = KIcon( icon );
00084 
00085   QFrame *topFrame = new QFrame();
00086   KPageWidgetItem *pageItem = new KPageWidgetItem( topFrame, title );
00087   pageItem->setIcon( KIcon( pixmap ) );
00088 
00089   addPage( pageItem );
00090 
00091   QBoxLayout *topLayout = new QVBoxLayout( topFrame );
00092 
00093   if ( !about ) {
00094     QLabel *label = new QLabel( i18n( "No about information available." ), topFrame );
00095     topLayout->addWidget( label );
00096   } else {
00097     QString text;
00098 
00099     text += "<p>";
00100     text += "<b>" + about->programName() + "</b>";
00101     text += "<br>";
00102 
00103     text += i18n( "Version %1", about->version() );
00104     text += "</p>";
00105 
00106     if ( !about->shortDescription().isEmpty() ) {
00107       text += "<p>" + about->shortDescription() + "<br>" +
00108                about->copyrightStatement() + "</p>";
00109     }
00110 
00111     QString home = about->homepage();
00112     if ( !home.isEmpty() ) {
00113       text += "<a href=\"" + home + "\">" + home + "</a><br>";
00114     }
00115 
00116     text.replace( "\n", "<br>" );
00117 
00118     QLabel *label = new QLabel( text, topFrame );
00119     label->setAlignment( Qt::AlignTop );
00120     label->setOpenExternalLinks(true);
00121     label->setTextInteractionFlags(
00122       Qt::TextSelectableByMouse | Qt::TextSelectableByKeyboard | Qt::LinksAccessibleByMouse );
00123     topLayout->addWidget( label );
00124 
00125     QTextEdit *personView = new QTextEdit( topFrame ); //krazy:exclude=qclasses
00126     personView->setReadOnly( true );
00127     topLayout->addWidget( personView, 1 );
00128 
00129     text = "";
00130 
00131     const QList<KAboutPerson> authors = about->authors();
00132     if ( !authors.isEmpty() ) {
00133       text += i18n( "<p><b>Authors:</b></p>" );
00134 
00135       QList<KAboutPerson>::ConstIterator it;
00136       for ( it = authors.begin(); it != authors.end(); ++it ) {
00137         text += formatPerson( (*it).name(), (*it).emailAddress() );
00138         if ( !(*it).task().isEmpty() ) {
00139           text += "<i>" + (*it).task() + "</i><br>";
00140         }
00141       }
00142     }
00143 
00144     const QList<KAboutPerson> credits = about->credits();
00145     if ( !credits.isEmpty() ) {
00146       text += i18n( "<p><b>Thanks to:</b></p>" );
00147 
00148       QList<KAboutPerson>::ConstIterator it;
00149       for ( it = credits.begin(); it != credits.end(); ++it ) {
00150         text += formatPerson( (*it).name(), (*it).emailAddress() );
00151         if ( !(*it).task().isEmpty() ) {
00152           text += "<i>" + (*it).task() + "</i><br>";
00153         }
00154       }
00155     }
00156 
00157     const QList<KAboutPerson> translators = about->translators();
00158     if ( !translators.isEmpty() ) {
00159       text += i18n( "<p><b>Translators:</b></p>" );
00160 
00161       QList<KAboutPerson>::ConstIterator it;
00162       for ( it = translators.begin(); it != translators.end(); ++it ) {
00163        text += formatPerson( (*it).name(), (*it).emailAddress() );
00164       }
00165     }
00166 
00167     personView->setText( text );
00168   }
00169 }
00170 
00171 QString AboutDialog::formatPerson( const QString &name, const QString &email )
00172 {
00173   QString text = name;
00174   if ( !email.isEmpty() ) {
00175     text += " &lt;<a href=\"mailto:" + email + "\">" + email + "</a>&gt;";
00176   }
00177 
00178   text += "<br>";
00179   return text;
00180 }
00181 
00182 void AboutDialog::addLicenseText( const KAboutData *about )
00183 {
00184   if ( !about || about->license().isEmpty() ) {
00185     return;
00186   }
00187 
00188   QPixmap pixmap = KIconLoader::global()->loadIcon( "help-about",
00189                                                     KIconLoader::Desktop, 48 );
00190 
00191   QString title = i18n( "%1 License", about->programName() );
00192 
00193   QFrame *topFrame = new QFrame();
00194   KPageWidgetItem *page = new KPageWidgetItem( topFrame, title );
00195   page->setIcon( KIcon( pixmap ) );
00196   addPage( page );
00197   QBoxLayout *topLayout = new QVBoxLayout( topFrame );
00198 
00199   KTextBrowser *textBrowser = new KTextBrowser( topFrame );
00200   textBrowser->setHtml( QString( "<pre>%1</pre>" ).arg( about->license() ) );
00201 
00202   topLayout->addWidget( textBrowser );
00203 }
00204 
00205 #include "aboutdialog.moc"

kontact

Skip menu "kontact"
  • Main Page
  • Namespace List
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Namespace Members
  • Class Members

kdepim

Skip menu "kdepim"
  • akonadi
  •   clients
  •   kabc
  •   kcal
  •   kcm
  • akregator
  • console
  •   kabcclient
  •   konsolekalendar
  • kaddressbook
  • kalarm
  •   lib
  • kdgantt
  • kdgantt1
  • kjots
  • kleopatra
  • kmail
  • kmobiletools
  • knode
  • knotes
  • kontact
  • kontactinterfaces
  • korganizer
  •   korgac
  • kpilot
  • ktimetracker
  •   doc
  • libkdepim
  • libkholidays
  • libkleo
  • libkpgp
  • maildir
Generated for kdepim by doxygen 1.5.4
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal