00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
#include <kaboutdata.h>
00024
#include <kstandarddirs.h>
00025
#include <qfile.h>
00026
#include <qtextstream.h>
00027
00028
QString
00029 KAboutPerson::name()
const
00030
{
00031
return QString::fromUtf8(mName);
00032 }
00033
00034
QString
00035 KAboutPerson::task()
const
00036
{
00037
if (mTask && *mTask)
00038
return i18n(mTask);
00039
else
00040
return QString::null;
00041 }
00042
00043
QString
00044 KAboutPerson::emailAddress()
const
00045
{
00046
return QString::fromUtf8(mEmailAddress);
00047 }
00048
00049
00050
QString
00051 KAboutPerson::webAddress()
const
00052
{
00053
return QString::fromUtf8(mWebAddress);
00054 }
00055
00056
00057 KAboutTranslator::KAboutTranslator(
const QString & name,
00058
const QString & emailAddress)
00059 {
00060 mName=name;
00061 mEmail=emailAddress;
00062 }
00063
00064 QString KAboutTranslator::name()
const
00065
{
00066
return mName;
00067 }
00068
00069 QString KAboutTranslator::emailAddress()
const
00070
{
00071
return mEmail;
00072 }
00073
00074
class KAboutDataPrivate
00075 {
00076
public:
00077 KAboutDataPrivate()
00078 : translatorName(
"_: NAME OF TRANSLATORS\nYour names")
00079 , translatorEmail(
"_: EMAIL OF TRANSLATORS\nYour emails")
00080 {};
00081
const char *translatorName;
00082
const char *translatorEmail;
00083
const char *productName;
00084 };
00085
00086
00087
00088 KAboutData::KAboutData(
const char *appName,
00089
const char *programName,
00090
const char *version,
00091
const char *shortDescription,
00092
int licenseType,
00093
const char *copyrightStatement,
00094
const char *text,
00095
const char *homePageAddress,
00096
const char *bugsEmailAddress
00097 ) :
00098 mProgramName( programName ),
00099 mVersion( version ),
00100 mShortDescription( shortDescription ),
00101 mLicenseKey( licenseType ),
00102 mCopyrightStatement( copyrightStatement ),
00103 mOtherText( text ),
00104 mHomepageAddress( homePageAddress ),
00105 mBugEmailAddress( bugsEmailAddress )
00106 {
00107 d =
new KAboutDataPrivate;
00108 d->productName = 0;
00109
00110
if( appName ) {
00111
const char *p = strrchr(appName,
'/');
00112
if( p )
00113 mAppName = p+1;
00114
else
00115 mAppName = appName;
00116 }
else
00117 mAppName = 0;
00118 }
00119
00120 KAboutData::~KAboutData()
00121 {
00122
delete d;
00123 }
00124
00125
void
00126 KAboutData::addAuthor(
const char *name,
const char *task,
00127
const char *emailAddress,
const char *webAddress )
00128 {
00129 mAuthorList.append(
KAboutPerson(name,task,emailAddress,webAddress));
00130 }
00131
00132
void
00133 KAboutData::addCredit(
const char *name,
const char *task,
00134
const char *emailAddress,
const char *webAddress )
00135 {
00136 mCreditList.append(
KAboutPerson(name,task,emailAddress,webAddress));
00137 }
00138
00139
void
00140 KAboutData::setTranslator(
const char *name,
const char *emailAddress)
00141 {
00142 d->translatorName=name;
00143 d->translatorEmail=emailAddress;
00144 }
00145
00146
void
00147 KAboutData::setLicenseText(
const char *licenseText )
00148 {
00149 mLicenseText = licenseText;
00150 mLicenseKey = License_Custom;
00151 }
00152
00153
void
00154 KAboutData::setLicenseTextFile(
const QString &file )
00155 {
00156 mLicenseText = qstrdup(QFile::encodeName(file));
00157 mLicenseKey = License_File;
00158 }
00159
00160
void
00161 KAboutData::setAppName(
const char *appName )
00162 {
00163 mAppName = appName;
00164 }
00165
00166
void
00167 KAboutData::setProgramName(
const char* programName )
00168 {
00169 mProgramName = programName;
00170 }
00171
00172
void
00173 KAboutData::setVersion(
const char* version )
00174 {
00175 mVersion = version;
00176 }
00177
00178
void
00179 KAboutData::setShortDescription(
const char *shortDescription )
00180 {
00181 mShortDescription = shortDescription;
00182 }
00183
00184
void
00185 KAboutData::setLicense( LicenseKey licenseKey)
00186 {
00187 mLicenseKey = licenseKey;
00188 }
00189
00190
void
00191 KAboutData::setCopyrightStatement(
const char *copyrightStatement )
00192 {
00193 mCopyrightStatement = copyrightStatement;
00194 }
00195
00196
void
00197 KAboutData::setOtherText(
const char *otherText )
00198 {
00199 mOtherText = otherText;
00200 }
00201
00202
void
00203 KAboutData::setHomepage(
const char *homepage )
00204 {
00205 mHomepageAddress = homepage;
00206 }
00207
00208
void
00209 KAboutData::setBugAddress(
const char *bugAddress )
00210 {
00211 mBugEmailAddress = bugAddress;
00212 }
00213
00214
void
00215 KAboutData::setProductName(
const char *productName )
00216 {
00217 d->productName = productName;
00218 }
00219
00220
const char *
00221 KAboutData::appName()
const
00222
{
00223
return mAppName;
00224 }
00225
00226
const char *
00227 KAboutData::productName()
const
00228
{
00229
if (d->productName)
00230
return d->productName;
00231
else
00232
return appName();
00233 }
00234
00235
QString
00236 KAboutData::programName()
const
00237
{
00238
if (mProgramName && *mProgramName)
00239
return i18n(mProgramName);
00240
else
00241
return QString::null;
00242 }
00243
00244
QString
00245 KAboutData::version()
const
00246
{
00247
return QString::fromLatin1(mVersion);
00248 }
00249
00250
QString
00251 KAboutData::shortDescription()
const
00252
{
00253
if (mShortDescription && *mShortDescription)
00254
return i18n(mShortDescription);
00255
else
00256
return QString::null;
00257 }
00258
00259
QString
00260 KAboutData::homepage()
const
00261
{
00262
return QString::fromLatin1(mHomepageAddress);
00263 }
00264
00265
QString
00266 KAboutData::bugAddress()
const
00267
{
00268
return QString::fromLatin1(mBugEmailAddress);
00269 }
00270
00271
const QValueList<KAboutPerson>
00272 KAboutData::authors()
const
00273
{
00274
return mAuthorList;
00275 }
00276
00277
const QValueList<KAboutPerson>
00278 KAboutData::credits()
const
00279
{
00280
return mCreditList;
00281 }
00282
00283
const QValueList<KAboutTranslator>
00284 KAboutData::translators()
const
00285
{
00286
QValueList<KAboutTranslator> personList;
00287
00288
if(d->translatorName == 0)
00289
return personList;
00290
00291
QStringList nameList;
00292
QStringList emailList;
00293
00294
QString names = i18n(d->translatorName);
00295
if(names != QString::fromUtf8(d->translatorName))
00296 {
00297 nameList = QStringList::split(
',',names);
00298 }
00299
00300
00301
if(d->translatorEmail)
00302 {
00303
QString emails = i18n(d->translatorEmail);
00304
00305
if(emails != QString::fromUtf8(d->translatorEmail))
00306 {
00307 emailList = QStringList::split(
',',emails,
true);
00308 }
00309 }
00310
00311
00312 QStringList::Iterator nit;
00313 QStringList::Iterator eit=emailList.begin();
00314
00315
for(nit = nameList.begin(); nit != nameList.end(); ++nit)
00316 {
00317
QString email;
00318
if(eit != emailList.end())
00319 {
00320 email=*eit;
00321 ++eit;
00322 }
00323
00324
QString name=*nit;
00325
00326 personList.append(
KAboutTranslator( name, email));
00327 }
00328
00329
return personList;
00330 }
00331
00332
QString
00333 KAboutData::aboutTranslationTeam()
00334 {
00335
return i18n(
"replace this with information about your translation team",
00336
"<p>KDE is translated into many languages thanks to the work "
00337
"of the translation teams all over the world.</p>"
00338
"<p>For more information on KDE internationalization "
00339
"visit http://i18n.kde.org</p>");
00340 }
00341
00342
QString
00343 KAboutData::otherText()
const
00344
{
00345
if (mOtherText && *mOtherText)
00346
return i18n(mOtherText);
00347
else
00348
return QString::null;
00349 }
00350
00351
00352
QString
00353 KAboutData::license()
const
00354
{
00355
QString result;
00356
if (!
copyrightStatement().isEmpty())
00357 result =
copyrightStatement() +
"\n\n";
00358
00359
QString l;
00360
QString f;
00361
switch ( mLicenseKey )
00362 {
00363
case License_File:
00364 f = QFile::decodeName(mLicenseText);
00365
break;
00366
case License_GPL_V2:
00367 l =
"GPL v2";
00368 f = locate(
"data",
"LICENSES/GPL_V2");
00369
break;
00370
case License_LGPL_V2:
00371 l =
"LGPL v2";
00372 f = locate(
"data",
"LICENSES/LGPL_V2");
00373
break;
00374
case License_BSD:
00375 l =
"BSD License";
00376 f = locate(
"data",
"LICENSES/BSD");
00377
break;
00378
case License_Artistic:
00379 l =
"Artistic License";
00380 f = locate(
"data",
"LICENSES/ARTISTIC");
00381
break;
00382
case License_QPL_V1_0:
00383 l =
"QPL v1.0";
00384 f = locate(
"data",
"LICENSES/QPL_V1.0");
00385
break;
00386
case License_Custom:
00387
if (mLicenseText && *mLicenseText)
00388
return( i18n(mLicenseText) );
00389
00390
default:
00391 result += i18n(
"No licensing terms for this program have been specified.\n"
00392
"Please check the documentation or the source for any\n"
00393
"licensing terms.\n");
00394
return result;
00395 }
00396
00397
if (!l.isEmpty())
00398 result += i18n(
"This program is distributed under the terms of the %1.").arg( l );
00399
00400
if (!f.isEmpty())
00401 {
00402
QFile file(f);
00403
if (file.open(IO_ReadOnly))
00404 {
00405 result +=
'\n';
00406 result +=
'\n';
00407
QTextStream str(&file);
00408 result += str.read();
00409 }
00410 }
00411
00412
return result;
00413 }
00414
00415
QString
00416 KAboutData::copyrightStatement()
const
00417
{
00418
if (mCopyrightStatement && *mCopyrightStatement)
00419
return i18n(mCopyrightStatement);
00420
else
00421
return QString::null;
00422 }