KDE3Support
k3aboutapplication.cpp
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #include "k3aboutapplication.h"
00024
00025 #include <QList>
00026 #include <QPixmap>
00027
00028 #include "k3aboutdialog_p.h"
00029 #include <kaboutdata.h>
00030 #include <kapplication.h>
00031 #include <QtGui/QLabel>
00032 #include <kglobal.h>
00033 #include <klocale.h>
00034 #include <QtGui/QStyle>
00035
00036 K3AboutApplication::K3AboutApplication( const KAboutData *aboutData, QWidget *parent, bool modal )
00037 :K3AboutDialog( Tabbed|Product, aboutData->programName(), parent ),
00038 d( 0 )
00039 {
00040 setButtons( Close );
00041 setDefaultButton( Close );
00042 setModal( modal );
00043
00044 if( aboutData == 0 )
00045 aboutData = KGlobal::mainComponent().aboutData();
00046
00047 if( !aboutData )
00048 {
00049
00050 setProduct(KGlobal::caption(), i18n("??"), QString(), QString());
00051 K3AboutContainer *appPage = addContainerPage( i18n("&About"));
00052
00053 QString appPageText =
00054 i18n("No information available.\n"
00055 "The supplied KAboutData object does not exist.");
00056 QLabel *appPageLabel = new QLabel( "\n\n\n\n"+appPageText+"\n\n\n\n", 0 );
00057 appPage->addWidget( appPageLabel );
00058 return;
00059 }
00060
00061 setProduct( aboutData->programName(), aboutData->version(),
00062 QString(), QString() );
00063
00064 if ( aboutData->programLogo().canConvert<QPixmap>() )
00065 setProgramLogo( aboutData->programLogo().value<QPixmap>() );
00066 else if ( aboutData->programLogo().canConvert<QImage>() )
00067 setProgramLogo( QPixmap::fromImage(aboutData->programLogo().value<QImage>() ) );
00068
00069 QString appPageText = aboutData->shortDescription() + '\n';
00070
00071 if (!aboutData->otherText().isEmpty())
00072 appPageText += '\n' + aboutData->otherText() + '\n';
00073
00074 if (!aboutData->copyrightStatement().isEmpty())
00075 appPageText += '\n' + aboutData->copyrightStatement() + '\n';
00076
00077 K3AboutContainer *appPage = addContainerPage( i18n("&About"));
00078
00079 QLabel *appPageLabel = new QLabel( appPageText, 0 );
00080 appPage->addWidget( appPageLabel );
00081
00082 if (!aboutData->homepage().isEmpty())
00083 {
00084 QLabel *url = new QLabel(appPage);
00085 url->setOpenExternalLinks(true);
00086 url->setTextInteractionFlags(Qt::LinksAccessibleByMouse);
00087 url->setText(QString("<a href=\"%1\">%1</a>").arg(aboutData->homepage()));
00088 appPage->addWidget( url );
00089 }
00090
00091 int authorCount = aboutData->authors().count();
00092 if (authorCount)
00093 {
00094 QString authorPageTitle = authorCount == 1 ?
00095 i18n("A&uthor") : i18n("A&uthors");
00096 K3AboutContainer *authorPage = addScrolledContainerPage( authorPageTitle, Qt::AlignLeft, Qt::AlignLeft );
00097
00098 if (!aboutData->customAuthorTextEnabled() || !aboutData->customAuthorRichText().isEmpty ())
00099 {
00100 QString text;
00101 QLabel* activeLabel = new QLabel( authorPage );
00102 activeLabel->setOpenExternalLinks(true);
00103 activeLabel->setTextInteractionFlags(Qt::LinksAccessibleByMouse);
00104 if (!aboutData->customAuthorTextEnabled())
00105 {
00106 if ( aboutData->bugAddress().isEmpty() || aboutData->bugAddress() == "submit@bugs.kde.org")
00107 text = i18n( "Please use <a href=\"http://bugs.kde.org\">http://bugs.kde.org</a> to report bugs.\n" );
00108 else {
00109 if( aboutData->authors().count() == 1 && ( aboutData->authors().first().emailAddress() == aboutData->bugAddress() ) )
00110 {
00111 text = i18n( "Please report bugs to <a href=\"mailto:%1\">%2</a>.\n" , aboutData->authors().first().emailAddress() , aboutData->authors().first().emailAddress() );
00112 }
00113 else {
00114 text = i18n( "Please report bugs to <a href=\"mailto:%1\">%2</a>.\n" , aboutData->bugAddress(), aboutData->bugAddress() );
00115 }
00116 }
00117 }
00118 else
00119 {
00120 text = aboutData->customAuthorRichText();
00121 }
00122 activeLabel->setText( text );
00123 authorPage->addWidget( activeLabel );
00124 }
00125
00126 QList<KAboutPerson> lst = aboutData->authors();
00127 for (int i = 0; i < lst.size(); ++i)
00128 {
00129 authorPage->addPerson( lst.at(i).name(), lst.at(i).emailAddress(),
00130 lst.at(i).webAddress(), lst.at(i).task() );
00131 }
00132 }
00133
00134 int creditsCount = aboutData->credits().count();
00135 if (creditsCount)
00136 {
00137 K3AboutContainer *creditsPage = addScrolledContainerPage( i18n("&Thanks To") );
00138
00139 QList<KAboutPerson> lst = aboutData->credits();
00140 for (int i = 0; i < lst.size(); ++i)
00141 {
00142 creditsPage->addPerson( lst.at(i).name(), lst.at(i).emailAddress(),
00143 lst.at(i).webAddress(), lst.at(i).task() );
00144 }
00145 }
00146
00147 const QList<KAboutPerson> translatorList = aboutData->translators();
00148
00149 if(translatorList.count() > 0)
00150 {
00151 QString text = "<qt>";
00152
00153 QList<KAboutPerson>::ConstIterator it;
00154 for(it = translatorList.begin(); it != translatorList.end(); ++it)
00155 {
00156 text += QString("<p>%1<br> "
00157 "<a href=\"mailto:%2\">%2</a></p>")
00158 .arg((*it).name())
00159 .arg((*it).emailAddress())
00160 .arg((*it).emailAddress());
00161 }
00162
00163 text += KAboutData::aboutTranslationTeam() + "</qt>";
00164 addTextPage( i18n("T&ranslation"), text, true);
00165 }
00166
00167 if (!aboutData->license().isEmpty() )
00168 {
00169 addLicensePage( i18n("&License Agreement"), aboutData->license() );
00170 }
00171
00172 setInitialSize( QSize(400,1) );
00173 }