30 #include <QtCore/QFile>
31 #include <QtCore/QTextIStream>
32 #include <QtCore/QSharedData>
33 #include <QtCore/QVariant>
34 #include <QtCore/QList>
56 class KAboutPerson::Private
70 const QByteArray &_emailAddress,
71 const QByteArray &_webAddress )
76 d->_emailAddress = QString::fromUtf8(_emailAddress);
77 d->_webAddress = QString::fromUtf8(_webAddress);
82 const QByteArray &_emailAddress,
83 const QByteArray &_webAddress,
84 const QByteArray &_ocsUsername )
89 d->_emailAddress = QString::fromUtf8(_emailAddress);
90 d->_webAddress = QString::fromUtf8(_webAddress);
91 d->_ocsUsername = QString::fromUtf8( _ocsUsername );
98 d->_emailAddress = _email;
113 if (!d->_nameNoop.isEmpty())
115 return d->_name.toString();
120 if (!d->_task.isEmpty())
121 return d->_task.toString();
127 return d->_emailAddress;
133 return d->_webAddress;
138 return d->_ocsUsername;
155 Private(
const Private& other);
159 QString _pathToLicenseTextFile;
166 _licenseKey( licenseType ),
167 _aboutData( aboutData )
171 KAboutLicense::Private::Private(
const QString &pathToFile,
const KAboutData *aboutData )
174 _pathToLicenseTextFile( pathToFile ),
175 _aboutData( aboutData )
182 _licenseText( licenseText ),
183 _aboutData( aboutData )
187 KAboutLicense::Private::Private(
const KAboutLicense::Private& other)
189 _licenseKey( other._licenseKey ),
190 _licenseText( other._licenseText ),
191 _pathToLicenseTextFile( other._pathToLicenseTextFile ),
192 _aboutData( other._aboutData )
197 : d(new Private(licenseType,aboutData))
202 : d(new Private(pathToFile,aboutData))
207 : d(new Private(licenseText,aboutData))
223 const QString lineFeed = QString::fromLatin1(
"\n\n" );
225 if (d->_aboutData && !d->_aboutData->copyrightStatement().isEmpty()) {
226 result = d->_aboutData->copyrightStatement() + lineFeed;
229 bool knownLicense =
false;
231 switch ( d->_licenseKey )
234 pathToFile = d->_pathToLicenseTextFile;
265 if (!d->_licenseText.isEmpty()) {
266 result = d->_licenseText.toString();
271 result +=
i18n(
"No licensing terms for this program have been specified.\n"
272 "Please check the documentation or the source for any\n"
273 "licensing terms.\n");
278 if (!pathToFile.isEmpty()) {
283 if (!pathToFile.isEmpty()) {
284 QFile file(pathToFile);
285 if (file.open(QIODevice::ReadOnly)) {
286 QTextStream str(&file);
287 result += str.readAll();
300 switch (d->_licenseKey) {
302 licenseShort =
i18nc(
"@item license (short name)",
"GPL v2");
303 licenseFull =
i18nc(
"@item license",
"GNU General Public License Version 2");
306 licenseShort =
i18nc(
"@item license (short name)",
"LGPL v2");
307 licenseFull =
i18nc(
"@item license",
"GNU Lesser General Public License Version 2");
310 licenseShort =
i18nc(
"@item license (short name)",
"BSD License");
311 licenseFull =
i18nc(
"@item license",
"BSD License");
314 licenseShort =
i18nc(
"@item license (short name)",
"Artistic License");
315 licenseFull =
i18nc(
"@item license",
"Artistic License");
318 licenseShort =
i18nc(
"@item license (short name)",
"QPL v1.0");
319 licenseFull =
i18nc(
"@item license",
"Q Public License");
322 licenseShort =
i18nc(
"@item license (short name)",
"GPL v3");
323 licenseFull =
i18nc(
"@item license",
"GNU General Public License Version 3");
326 licenseShort =
i18nc(
"@item license (short name)",
"LGPL v3");
327 licenseFull =
i18nc(
"@item license",
"GNU Lesser General Public License Version 3");
331 licenseShort = licenseFull =
i18nc(
"@item license",
"Custom");
334 licenseShort = licenseFull =
i18nc(
"@item license",
"Not specified");
354 return d->_licenseKey;
361 static QHash<QByteArray, KAboutData::LicenseKey> ldict;
362 if (ldict.isEmpty()) {
382 keyword = keyword.toLower();
383 keyword.remove(QLatin1Char(
' '));
384 keyword.remove(QLatin1Char(
'.'));
392 class KAboutData::Private
401 QByteArray _catalogName;
405 QList<KAboutPerson> _authorList;
406 QList<KAboutPerson> _creditList;
407 QList<KAboutLicense> _licenseList;
417 QByteArray _ocsProviderUrl;
421 QByteArray _translatedProgramName;
423 QByteArray _bugEmailAddress;
428 const QByteArray &_catalogName,
430 const QByteArray &_version,
435 const QByteArray &homePageAddress,
436 const QByteArray &bugsEmailAddress
440 d->_appName = _appName;
441 int p = d->_appName.indexOf(
'/');
443 d->_appName = d->_appName.mid(p + 1);
446 d->_catalogName = _catalogName;
447 d->_programName = _programName;
448 if (!d->_programName.isEmpty())
449 d->_translatedProgramName = _programName.
toString(0).toUtf8();
450 d->_version = _version;
451 d->_shortDescription = _shortDescription;
453 d->_copyrightStatement = _copyrightStatement;
454 d->_otherText = text;
455 d->_homepageAddress = QString::fromLatin1(homePageAddress);
456 d->_bugEmailAddress = bugsEmailAddress;
458 if (d->_homepageAddress.contains(QLatin1String(
"http://"))) {
459 const int dot = d->_homepageAddress.indexOf(QLatin1Char(
'.'));
461 d->organizationDomain = d->_homepageAddress.mid(dot + 1);
462 const int slash = d->organizationDomain.indexOf(QLatin1Char(
'/'));
464 d->organizationDomain.truncate(slash);
467 d->organizationDomain = QString::fromLatin1(
"kde.org");
471 d->organizationDomain = QString::fromLatin1(
"kde.org");
483 QList<KAboutLicense>::iterator it = d->_licenseList.begin(), itEnd = d->_licenseList.end();
484 for ( ; it != itEnd; ++it) {
487 al.d->_aboutData =
this;
493 if (
this != &other) {
495 QList<KAboutLicense>::iterator it = d->_licenseList.begin(), itEnd = d->_licenseList.end();
496 for ( ; it != itEnd; ++it) {
499 al.d->_aboutData =
this;
507 const QByteArray &emailAddress,
508 const QByteArray &webAddress )
510 d->_authorList.append(
KAboutPerson(name,task,emailAddress,webAddress));
516 const QByteArray &emailAddress,
517 const QByteArray &webAddress,
518 const QByteArray &ocsUsername )
520 d->_authorList.append(
KAboutPerson(name,task,emailAddress,webAddress,ocsUsername));
526 const QByteArray &emailAddress,
527 const QByteArray &webAddress )
529 d->_creditList.append(
KAboutPerson(name,task,emailAddress,webAddress));
535 const QByteArray &emailAddress,
536 const QByteArray &webAddress,
537 const QByteArray &ocsUsername )
539 d->_creditList.append(
KAboutPerson(name,task,emailAddress,webAddress,ocsUsername));
546 d->translatorName = name;
547 d->translatorEmail = emailAddress;
561 if (d->_licenseList.count() == 1 && firstLicense.d->_licenseKey ==
License_Unknown) {
579 if (d->_licenseList.count() == 1 && firstLicense.d->_licenseKey ==
License_Unknown) {
589 d->_appName = _appName;
595 d->_programName = _programName;
602 d->_ocsProviderUrl = _ocsProviderUrl;
608 d->_version = _version;
614 d->_shortDescription = _shortDescription;
620 d->_catalogName = _catalogName;
634 if (d->_licenseList.count() == 1 && firstLicense.d->_licenseKey ==
License_Unknown) {
644 d->_copyrightStatement = _copyrightStatement;
650 d->_otherText = _otherText;
656 d->_homepageAddress = QString::fromLatin1(_homepage);
662 d->_bugEmailAddress = _bugAddress;
668 d->organizationDomain = QString::fromLatin1(domain);
674 d->productName = QString::fromUtf8(_productName);
680 return QString::fromUtf8(d->_appName);
685 if (!d->productName.isEmpty())
686 return d->productName;
692 if (!d->_programName.isEmpty())
693 return d->_programName.toString();
702 return d->_translatedProgramName.constData();
711 d->_translatedProgramName.clear();
713 d->_translatedProgramName =
programName().toUtf8();
718 return d->programIconName.isEmpty() ?
appName() : d->programIconName;
723 d->programIconName = iconName;
729 return d->programLogo;
734 d->programLogo = image ;
740 if( !d->_ocsProviderUrl.isEmpty() )
741 return QString::fromUtf8( d->_ocsProviderUrl );
747 return QString::fromUtf8(d->_version);
755 return d->_version.constData();
760 if (!d->_shortDescription.isEmpty())
761 return d->_shortDescription.toString();
767 if (!d->_catalogName.isEmpty())
768 return QString::fromUtf8(d->_catalogName);
770 return QString::fromUtf8(d->_appName);
775 return d->_homepageAddress;
780 return QString::fromUtf8(d->_bugEmailAddress);
785 return d->organizationDomain;
794 if (d->_bugEmailAddress.isEmpty())
796 return d->_bugEmailAddress.constData();
801 return d->_authorList;
806 return d->_creditList;
809 #define NAME_OF_TRANSLATORS "Your names"
810 #define EMAIL_OF_TRANSLATORS "Your emails"
813 QList<KAboutPerson> personList;
826 if (!d->translatorName.isEmpty()) {
827 translatorName = d->translatorName.toString();
834 if (!d->translatorEmail.isEmpty()) {
835 translatorEmail = d->translatorEmail.toString();
843 if ( translatorName.isEmpty() || translatorName == QString::fromUtf8(
NAME_OF_TRANSLATORS ) )
849 if( !translatorEmail.isEmpty() && translatorEmail != QString::fromUtf8(
EMAIL_OF_TRANSLATORS ) )
851 emailList = translatorEmail.split(
QString(QLatin1Char(
',')), QString::KeepEmptyParts);
854 QStringList::const_iterator nit;
855 QStringList::const_iterator eit = emailList.constBegin();
857 for( nit = nameList.constBegin(); nit != nameList.constEnd(); ++nit )
860 if ( eit != emailList.constEnd() )
866 personList.append(
KAboutPerson( (*nit).trimmed(), email.trimmed() ) );
874 return i18nc(
"replace this with information about your translation team",
875 "<p>KDE is translated into many languages thanks to the work "
876 "of the translation teams all over the world.</p>"
877 "<p>For more information on KDE internationalization "
878 "visit <a href=\"http://l10n.kde.org\">http://l10n.kde.org</a></p>"
884 if (!d->_otherText.isEmpty())
885 return d->_otherText.toString();
891 return d->_licenseList.at(0).text();
896 return d->_licenseList.at(0).name(formatName);
901 return d->_licenseList;
906 if (!d->_copyrightStatement.isEmpty())
907 return d->_copyrightStatement.toString();
913 if (!d->customAuthorPlainText.isEmpty())
914 return d->customAuthorPlainText.toString();
920 if (!d->customAuthorRichText.isEmpty())
921 return d->customAuthorRichText.toString();
927 return d->customAuthorTextEnabled;
933 d->customAuthorPlainText = plainText;
934 d->customAuthorRichText = richText;
936 d->customAuthorTextEnabled =
true;
946 d->customAuthorTextEnabled =
false;