kaboutapplication.cpp

00001 /*
00002  * This file is part of the KDE Libraries
00003  * Copyright (C) 2000 Waldo Bastian (bastian@kde.org) and
00004  * Espen Sand (espen@kde.org)
00005  *
00006  * This library is free software; you can redistribute it and/or
00007  * modify it under the terms of the GNU Library General Public
00008  * License as published by the Free Software Foundation; either
00009  * version 2 of the License, or (at your option) any later version.
00010  *
00011  * This library 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 GNU
00014  * Library General Public License for more details.
00015  *
00016  * You should have received a copy of the GNU Library General Public License
00017  * along with this library; see the file COPYING.LIB.  If not, write to
00018  * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00019  * Boston, MA 02110-1301, USA.
00020  *
00021  */
00022 
00023 // I (espen) prefer that header files are included alphabetically
00024 
00025 #include <qlabel.h>
00026 #include <kaboutapplication.h>
00027 #include <kaboutdialog_private.h>
00028 #include <kaboutdata.h>
00029 #include <kapplication.h>
00030 #include <kglobal.h>
00031 #include <klocale.h>
00032 #include <kurllabel.h>
00033 #include <kactivelabel.h>
00034 #include "ktextedit.h"
00035 
00036 KAboutApplication::KAboutApplication( QWidget *parent, const char *name,
00037               bool modal )
00038   :KAboutDialog( AbtTabbed|AbtProduct,
00039                  kapp ? kapp->caption() : QString::null,
00040                  Close, Close,
00041      parent, name, modal )
00042 {
00043   buildDialog(KGlobal::instance()->aboutData());
00044 }
00045 
00046 KAboutApplication::KAboutApplication( const KAboutData *aboutData, QWidget *parent,
00047                                       const char *name, bool modal )
00048   :KAboutDialog( AbtTabbed|AbtProduct, aboutData->programName(), Close, Close,
00049      parent, name, modal )
00050 {
00051   buildDialog(aboutData);
00052 }
00053 
00054 void KAboutApplication::buildDialog( const KAboutData *aboutData )
00055 {
00056   if( !aboutData )
00057   {
00058     //
00059     // Recovery
00060     //
00061     setProduct( kapp ? kapp->caption() : QString::null, i18n("??"), QString::null, QString::null );
00062     KAboutContainer *appPage = addContainerPage( i18n("&About"));
00063 
00064     QString appPageText =
00065       i18n("No information available.\n"
00066      "The supplied KAboutData object does not exist.");
00067     QLabel *appPageLabel = new QLabel( "\n\n\n\n"+appPageText+"\n\n\n\n", 0 );
00068     appPage->addWidget( appPageLabel );
00069     return;
00070   }
00071 
00072   setProduct( aboutData->programName(), aboutData->version(),
00073         QString::null, QString::null );
00074 
00075   if (!aboutData->programLogo().isNull())
00076     setProgramLogo( aboutData->programLogo() );
00077 
00078   QString appPageText = aboutData->shortDescription() + "\n";
00079 
00080   if (!aboutData->otherText().isEmpty())
00081     appPageText += "\n" + aboutData->otherText()+"\n";
00082 
00083   if (!aboutData->copyrightStatement().isEmpty())
00084     appPageText += "\n" + aboutData->copyrightStatement()+"\n";
00085 
00086   KAboutContainer *appPage = addContainerPage( i18n("&About"));
00087 
00088   QLabel *appPageLabel = new QLabel( appPageText, 0 );
00089   appPage->addWidget( appPageLabel );
00090 
00091   if (!aboutData->homepage().isEmpty())
00092   {
00093     KURLLabel *url = new KURLLabel();
00094     url->setText(aboutData->homepage());
00095     url->setURL(aboutData->homepage());
00096     appPage->addWidget( url );
00097     connect( url, SIGNAL(leftClickedURL(const QString &)),
00098              this, SLOT(openURLSlot(const QString &)));
00099   }
00100 
00101   int authorCount = aboutData->authors().count();
00102   if (authorCount)
00103   {
00104     QString authorPageTitle = authorCount == 1 ?
00105       i18n("A&uthor") : i18n("A&uthors");
00106     KAboutContainer *authorPage = addScrolledContainerPage( authorPageTitle );
00107 
00108     if (!aboutData->customAuthorTextEnabled() || !aboutData->customAuthorRichText().isEmpty ())
00109     {
00110       QString text;
00111       KActiveLabel* activeLabel = new KActiveLabel( authorPage );
00112       if (!aboutData->customAuthorTextEnabled())
00113       {
00114         if ( aboutData->bugAddress().isEmpty() || aboutData->bugAddress() == "submit@bugs.kde.org")
00115           text = i18n( "Please use <a href=\"http://bugs.kde.org\">http://bugs.kde.org</a> to report bugs.\n" );
00116         else {
00117           if( aboutData->authors().count() == 1 && ( aboutData->authors().first().emailAddress() == aboutData->bugAddress() ) )
00118           {
00119             text = i18n( "Please report bugs to <a href=\"mailto:%1\">%2</a>.\n" ).arg( aboutData->authors().first().emailAddress() ).arg( aboutData->authors().first().emailAddress() );
00120           }
00121           else {
00122             text = i18n( "Please report bugs to <a href=\"mailto:%1\">%2</a>.\n" ).arg(aboutData->bugAddress()).arg(aboutData->bugAddress() );
00123           }
00124         }
00125       }
00126       else
00127       {
00128         text = aboutData->customAuthorRichText();
00129       }
00130       activeLabel->setText( text );
00131       authorPage->addWidget( activeLabel );
00132     }
00133 
00134     QValueList<KAboutPerson>::ConstIterator it;
00135     for (it = aboutData->authors().begin();
00136    it != aboutData->authors().end(); ++it)
00137     {
00138       authorPage->addPerson( (*it).name(), (*it).emailAddress(),
00139            (*it).webAddress(), (*it).task() );
00140     }
00141   }
00142 
00143   int creditsCount = aboutData->credits().count();
00144   if (creditsCount)
00145   {
00146     KAboutContainer *creditsPage =
00147       addScrolledContainerPage( i18n("&Thanks To") );
00148     QValueList<KAboutPerson>::ConstIterator it;
00149     for (it = aboutData->credits().begin();
00150    it != aboutData->credits().end(); ++it)
00151     {
00152       creditsPage->addPerson( (*it).name(), (*it).emailAddress(),
00153             (*it).webAddress(), (*it).task() );
00154     }
00155   }
00156 
00157   const QValueList<KAboutTranslator> translatorList = aboutData->translators();
00158 
00159   if(translatorList.count() > 0)
00160   {
00161       QString text = "<qt>";
00162 
00163       QValueList<KAboutTranslator>::ConstIterator it;
00164       for(it = translatorList.begin(); it != translatorList.end(); ++it)
00165       {
00166    text += QString("<p>%1<br>&nbsp;&nbsp;&nbsp;"
00167        "<a href=\"mailto:%2\">%2</a></p>")
00168      .arg((*it).name())
00169      .arg((*it).emailAddress())
00170      .arg((*it).emailAddress());
00171       }
00172 
00173       text += KAboutData::aboutTranslationTeam() + "</qt>";
00174       addTextPage( i18n("T&ranslation"), text, true);
00175   }
00176 
00177   if (!aboutData->license().isEmpty() )
00178   {
00179     addLicensePage( i18n("&License Agreement"), aboutData->license() );
00180   }
00181 
00182   //
00183   // Make sure the dialog has a reasonable width
00184   //
00185   setInitialSize( QSize(400,1) );
00186 }
KDE Home | KDE Accessibility Home | Description of Access Keys