• Skip to content
  • Skip to link menu
  • KDE API Reference
  • kdelibs-4.14.38 API Reference
  • KDE Home
  • Contact Us
 

KDECore

  • kdecore
  • kernel
kaboutdata.cpp
Go to the documentation of this file.
1/*
2 * This file is part of the KDE Libraries
3 * Copyright (C) 2000 Espen Sand (espen@kde.org)
4 * Copyright (C) 2006 Nicolas GOUTTE <goutte@kde.org>
5 * Copyright (C) 2008 Friedrich W. H. Kossebau <kossebau@kde.org>
6 * Copyright (C) 2010 Teo Mrnjavac <teo@kde.org>
7 *
8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Library General Public
10 * License as published by the Free Software Foundation; either
11 * version 2 of the License, or (at your option) any later version.
12 *
13 * This library is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Library General Public License for more details.
17 *
18 * You should have received a copy of the GNU Library General Public License
19 * along with this library; see the file COPYING.LIB. If not, write to
20 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
21 * Boston, MA 02110-1301, USA.
22 *
23 */
24
25#include "kaboutdata.h"
26
27#include "kstandarddirs.h"
28#include "klocalizedstring.h"
29
30#include <QtCore/QFile>
31#include <QtCore/QTextIStream>
32#include <QtCore/QSharedData>
33#include <QtCore/QVariant>
34#include <QtCore/QList>
35#include <QHash>
36
37// -----------------------------------------------------------------------------
38// Design notes:
39//
40// These classes deal with a lot of text, some of which needs to be
41// marked for translation. Since at the time when these object and calls are
42// made the translation catalogs are usually still not initialized, the
43// translation has to be delayed. This is achieved by using KLocalizedString
44// for translatable strings. KLocalizedStrings are produced by ki18n* calls,
45// instead of the more usuall i18n* calls which produce QString by trying to
46// translate immediately.
47//
48// All the non-translatable string arguments to methods are taken QByteArray,
49// all the translatable are KLocalizedString. The getter methods always return
50// proper QString: the non-translatable strings supplied by the code are
51// treated with QString::fromUtf8(), those coming from the outside with
52// QTextCodec::toUnicode(), and translatable strings are finalized to QStrings
53// at the point of getter calls (i.e. delayed translation).
54// -----------------------------------------------------------------------------
55
56class KAboutPerson::Private
57{
58public:
59 KLocalizedString _name;
60 KLocalizedString _task;
61 QString _emailAddress;
62 QString _webAddress;
63 QString _ocsUsername;
64
65 QString _nameNoop;
66};
67
68KAboutPerson::KAboutPerson( const KLocalizedString &_name,
69 const KLocalizedString &_task,
70 const QByteArray &_emailAddress,
71 const QByteArray &_webAddress )
72 : d(new Private)
73{
74 d->_name = _name;
75 d->_task = _task;
76 d->_emailAddress = QString::fromUtf8(_emailAddress);
77 d->_webAddress = QString::fromUtf8(_webAddress);
78}
79
80KAboutPerson::KAboutPerson( const KLocalizedString &_name,
81 const KLocalizedString &_task,
82 const QByteArray &_emailAddress,
83 const QByteArray &_webAddress,
84 const QByteArray &_ocsUsername )
85 : d(new Private)
86{
87 d->_name = _name;
88 d->_task = _task;
89 d->_emailAddress = QString::fromUtf8(_emailAddress);
90 d->_webAddress = QString::fromUtf8(_webAddress);
91 d->_ocsUsername = QString::fromUtf8( _ocsUsername );
92}
93
94KAboutPerson::KAboutPerson( const QString &_name, const QString &_email )
95 : d(new Private)
96{
97 d->_nameNoop = _name;
98 d->_emailAddress = _email;
99}
100
101KAboutPerson::KAboutPerson(const KAboutPerson& other): d(new Private)
102{
103 *d = *other.d;
104}
105
106KAboutPerson::~KAboutPerson()
107{
108 delete d;
109}
110
111QString KAboutPerson::name() const
112{
113 if (!d->_nameNoop.isEmpty())
114 return d->_nameNoop;
115 return d->_name.toString();
116}
117
118QString KAboutPerson::task() const
119{
120 if (!d->_task.isEmpty())
121 return d->_task.toString();
122 return QString();
123}
124
125QString KAboutPerson::emailAddress() const
126{
127 return d->_emailAddress;
128}
129
130
131QString KAboutPerson::webAddress() const
132{
133 return d->_webAddress;
134}
135
136QString KAboutPerson::ocsUsername() const
137{
138 return d->_ocsUsername;
139}
140
141KAboutPerson &KAboutPerson::operator=(const KAboutPerson& other)
142{
143 *d = *other.d;
144 return *this;
145}
146
147
148
149class KAboutLicense::Private : public QSharedData
150{
151public:
152 Private( enum KAboutData::LicenseKey licenseType, const KAboutData *aboutData );
153 Private( const QString &pathToFile, const KAboutData *aboutData );
154 Private( const KLocalizedString &licenseText, const KAboutData *aboutData );
155 Private( const Private& other);
156public:
157 enum KAboutData::LicenseKey _licenseKey;
158 KLocalizedString _licenseText;
159 QString _pathToLicenseTextFile;
160 // needed for access to the possibly changing copyrightStatement()
161 const KAboutData * _aboutData;
162};
163
164KAboutLicense::Private::Private( enum KAboutData::LicenseKey licenseType, const KAboutData *aboutData )
165 : QSharedData(),
166 _licenseKey( licenseType ),
167 _aboutData( aboutData )
168{
169}
170
171KAboutLicense::Private::Private( const QString &pathToFile, const KAboutData *aboutData )
172 : QSharedData(),
173 _licenseKey( KAboutData::License_File ),
174 _pathToLicenseTextFile( pathToFile ),
175 _aboutData( aboutData )
176{
177}
178
179KAboutLicense::Private::Private( const KLocalizedString &licenseText, const KAboutData *aboutData )
180 : QSharedData(),
181 _licenseKey( KAboutData::License_Custom ),
182 _licenseText( licenseText ),
183 _aboutData( aboutData )
184{
185}
186
187KAboutLicense::Private::Private(const KAboutLicense::Private& other)
188 : QSharedData(other),
189 _licenseKey( other._licenseKey ),
190 _licenseText( other._licenseText ),
191 _pathToLicenseTextFile( other._pathToLicenseTextFile ),
192 _aboutData( other._aboutData )
193{}
194
195
196KAboutLicense::KAboutLicense( enum KAboutData::LicenseKey licenseType, const KAboutData *aboutData )
197 : d(new Private(licenseType,aboutData))
198{
199}
200
201KAboutLicense::KAboutLicense( const QString &pathToFile, const KAboutData *aboutData )
202 : d(new Private(pathToFile,aboutData))
203{
204}
205
206KAboutLicense::KAboutLicense( const KLocalizedString &licenseText, const KAboutData *aboutData )
207 : d(new Private(licenseText,aboutData))
208{
209}
210
211KAboutLicense::KAboutLicense(const KAboutLicense& other)
212 : d(other.d)
213{
214}
215
216KAboutLicense::~KAboutLicense()
217{}
218
219QString KAboutLicense::text() const
220{
221 QString result;
222
223 const QString lineFeed = QString::fromLatin1( "\n\n" );
224
225 if (d->_aboutData && !d->_aboutData->copyrightStatement().isEmpty()) {
226 result = d->_aboutData->copyrightStatement() + lineFeed;
227 }
228
229 bool knownLicense = false;
230 QString pathToFile;
231 switch ( d->_licenseKey )
232 {
233 case KAboutData::License_File:
234 pathToFile = d->_pathToLicenseTextFile;
235 break;
236 case KAboutData::License_GPL_V2:
237 knownLicense = true;
238 pathToFile = KStandardDirs::locate("data", QString::fromLatin1("LICENSES/GPL_V2"));
239 break;
240 case KAboutData::License_LGPL_V2:
241 knownLicense = true;
242 pathToFile = KStandardDirs::locate("data", QString::fromLatin1("LICENSES/LGPL_V2"));
243 break;
244 case KAboutData::License_BSD:
245 knownLicense = true;
246 pathToFile = KStandardDirs::locate("data", QString::fromLatin1("LICENSES/BSD"));
247 break;
248 case KAboutData::License_Artistic:
249 knownLicense = true;
250 pathToFile = KStandardDirs::locate("data", QString::fromLatin1("LICENSES/ARTISTIC"));
251 break;
252 case KAboutData::License_QPL_V1_0:
253 knownLicense = true;
254 pathToFile = KStandardDirs::locate("data", QString::fromLatin1("LICENSES/QPL_V1.0"));
255 break;
256 case KAboutData::License_GPL_V3:
257 knownLicense = true;
258 pathToFile = KStandardDirs::locate("data", QString::fromLatin1("LICENSES/GPL_V3"));
259 break;
260 case KAboutData::License_LGPL_V3:
261 knownLicense = true;
262 pathToFile = KStandardDirs::locate("data", QString::fromLatin1("LICENSES/LGPL_V3"));
263 break;
264 case KAboutData::License_Custom:
265 if (!d->_licenseText.isEmpty()) {
266 result = d->_licenseText.toString();
267 break;
268 }
269 // fall through
270 default:
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");
274 }
275
276 if (knownLicense) {
277 result += i18n("This program is distributed under the terms of the %1.", name(KAboutData::ShortName));
278 if (!pathToFile.isEmpty()) {
279 result += lineFeed;
280 }
281 }
282
283 if (!pathToFile.isEmpty()) {
284 QFile file(pathToFile);
285 if (file.open(QIODevice::ReadOnly)) {
286 QTextStream str(&file);
287 result += str.readAll();
288 }
289 }
290
291 return result;
292}
293
294
295QString KAboutLicense::name(KAboutData::NameFormat formatName) const
296{
297 QString licenseShort;
298 QString licenseFull;
299
300 switch (d->_licenseKey) {
301 case KAboutData::License_GPL_V2:
302 licenseShort = i18nc("@item license (short name)","GPL v2");
303 licenseFull = i18nc("@item license","GNU General Public License Version 2");
304 break;
305 case KAboutData::License_LGPL_V2:
306 licenseShort = i18nc("@item license (short name)","LGPL v2");
307 licenseFull = i18nc("@item license","GNU Lesser General Public License Version 2");
308 break;
309 case KAboutData::License_BSD:
310 licenseShort = i18nc("@item license (short name)","BSD License");
311 licenseFull = i18nc("@item license","BSD License");
312 break;
313 case KAboutData::License_Artistic:
314 licenseShort = i18nc("@item license (short name)","Artistic License");
315 licenseFull = i18nc("@item license","Artistic License");
316 break;
317 case KAboutData::License_QPL_V1_0:
318 licenseShort = i18nc("@item license (short name)","QPL v1.0");
319 licenseFull = i18nc("@item license","Q Public License");
320 break;
321 case KAboutData::License_GPL_V3:
322 licenseShort = i18nc("@item license (short name)","GPL v3");
323 licenseFull = i18nc("@item license","GNU General Public License Version 3");
324 break;
325 case KAboutData::License_LGPL_V3:
326 licenseShort = i18nc("@item license (short name)","LGPL v3");
327 licenseFull = i18nc("@item license","GNU Lesser General Public License Version 3");
328 break;
329 case KAboutData::License_Custom:
330 case KAboutData::License_File:
331 licenseShort = licenseFull = i18nc("@item license","Custom");
332 break;
333 default:
334 licenseShort = licenseFull = i18nc("@item license","Not specified");
335 }
336
337 const QString result =
338 (formatName == KAboutData::ShortName ) ? licenseShort :
339 (formatName == KAboutData::FullName ) ? licenseFull :
340 QString();
341
342 return result;
343}
344
345
346KAboutLicense &KAboutLicense::operator=(const KAboutLicense& other)
347{
348 d = other.d;
349 return *this;
350}
351
352KAboutData::LicenseKey KAboutLicense::key() const
353{
354 return d->_licenseKey;
355}
356
357KAboutLicense KAboutLicense::byKeyword(const QString &rawKeyword)
358{
359 // Setup keyword->enum dictionary on first call.
360 // Use normalized keywords, by the algorithm below.
361 static QHash<QByteArray, KAboutData::LicenseKey> ldict;
362 if (ldict.isEmpty()) {
363 ldict.insert("gpl", KAboutData::License_GPL);
364 ldict.insert("gplv2", KAboutData::License_GPL_V2);
365 ldict.insert("gplv2+", KAboutData::License_GPL_V2);
366 ldict.insert("lgpl", KAboutData::License_LGPL);
367 ldict.insert("lgplv2", KAboutData::License_LGPL_V2);
368 ldict.insert("lgplv2+", KAboutData::License_LGPL_V2);
369 ldict.insert("bsd", KAboutData::License_BSD);
370 ldict.insert("artistic", KAboutData::License_Artistic);
371 ldict.insert("qpl", KAboutData::License_QPL);
372 ldict.insert("qplv1", KAboutData::License_QPL_V1_0);
373 ldict.insert("qplv10", KAboutData::License_QPL_V1_0);
374 ldict.insert("gplv3", KAboutData::License_GPL_V3);
375 ldict.insert("gplv3+", KAboutData::License_GPL_V3);
376 ldict.insert("lgplv3", KAboutData::License_LGPL_V3);
377 ldict.insert("lgplv3+", KAboutData::License_LGPL_V3);
378 }
379
380 // Normalize keyword.
381 QString keyword = rawKeyword;
382 keyword = keyword.toLower();
383 keyword.remove(QLatin1Char(' '));
384 keyword.remove(QLatin1Char('.'));
385
386 KAboutData::LicenseKey license = ldict.value(keyword.toLatin1(),
387 KAboutData::License_Custom);
388 return KAboutLicense(license, 0);
389}
390
391
392class KAboutData::Private
393{
394public:
395 Private()
396 : customAuthorTextEnabled(false)
397 {}
398 QByteArray _appName;
399 KLocalizedString _programName;
400 KLocalizedString _shortDescription;
401 QByteArray _catalogName;
402 KLocalizedString _copyrightStatement;
403 KLocalizedString _otherText;
404 QString _homepageAddress;
405 QList<KAboutPerson> _authorList;
406 QList<KAboutPerson> _creditList;
407 QList<KAboutLicense> _licenseList;
408 KLocalizedString translatorName;
409 KLocalizedString translatorEmail;
410 QString productName;
411 QString programIconName;
412 QVariant programLogo;
413 KLocalizedString customAuthorPlainText, customAuthorRichText;
414 bool customAuthorTextEnabled;
415
416 QString organizationDomain;
417 QByteArray _ocsProviderUrl;
418
419 // Everything dr.konqi needs, we store as utf-8, so we
420 // can just give it a pointer, w/o any allocations.
421 QByteArray _translatedProgramName; // ### I don't see it ever being translated, and I did not change that
422 QByteArray _version;
423 QByteArray _bugEmailAddress;
424};
425
426
427KAboutData::KAboutData( const QByteArray &_appName,
428 const QByteArray &_catalogName,
429 const KLocalizedString &_programName,
430 const QByteArray &_version,
431 const KLocalizedString &_shortDescription,
432 enum LicenseKey licenseType,
433 const KLocalizedString &_copyrightStatement,
434 const KLocalizedString &text,
435 const QByteArray &homePageAddress,
436 const QByteArray &bugsEmailAddress
437 )
438 : d(new Private)
439{
440 d->_appName = _appName;
441 int p = d->_appName.indexOf('/');
442 if (p >= 0) {
443 d->_appName = d->_appName.mid(p + 1);
444 }
445
446 d->_catalogName = _catalogName;
447 d->_programName = _programName;
448 if (!d->_programName.isEmpty()) // KComponentData("klauncher") gives empty program name
449 d->_translatedProgramName = _programName.toString(0).toUtf8();
450 d->_version = _version;
451 d->_shortDescription = _shortDescription;
452 d->_licenseList.append(KAboutLicense(licenseType,this));
453 d->_copyrightStatement = _copyrightStatement;
454 d->_otherText = text;
455 d->_homepageAddress = QString::fromLatin1(homePageAddress);
456 d->_bugEmailAddress = bugsEmailAddress;
457
458 if (d->_homepageAddress.contains(QLatin1String("http://"))) {
459 const int dot = d->_homepageAddress.indexOf(QLatin1Char('.'));
460 if (dot >= 0) {
461 d->organizationDomain = d->_homepageAddress.mid(dot + 1);
462 const int slash = d->organizationDomain.indexOf(QLatin1Char('/'));
463 if (slash >= 0)
464 d->organizationDomain.truncate(slash);
465 }
466 else {
467 d->organizationDomain = QString::fromLatin1("kde.org");
468 }
469 }
470 else {
471 d->organizationDomain = QString::fromLatin1("kde.org");
472 }
473}
474
475KAboutData::~KAboutData()
476{
477 delete d;
478}
479
480KAboutData::KAboutData(const KAboutData& other): d(new Private)
481{
482 *d = *other.d;
483 QList<KAboutLicense>::iterator it = d->_licenseList.begin(), itEnd = d->_licenseList.end();
484 for ( ; it != itEnd; ++it) {
485 KAboutLicense& al = *it;
486 al.d.detach();
487 al.d->_aboutData = this;
488 }
489}
490
491KAboutData &KAboutData::operator=(const KAboutData& other)
492{
493 if (this != &other) {
494 *d = *other.d;
495 QList<KAboutLicense>::iterator it = d->_licenseList.begin(), itEnd = d->_licenseList.end();
496 for ( ; it != itEnd; ++it) {
497 KAboutLicense& al = *it;
498 al.d.detach();
499 al.d->_aboutData = this;
500 }
501 }
502 return *this;
503}
504
505KAboutData &KAboutData::addAuthor( const KLocalizedString &name,
506 const KLocalizedString &task,
507 const QByteArray &emailAddress,
508 const QByteArray &webAddress )
509{
510 d->_authorList.append(KAboutPerson(name,task,emailAddress,webAddress));
511 return *this;
512}
513
514KAboutData &KAboutData::addAuthor( const KLocalizedString &name,
515 const KLocalizedString &task,
516 const QByteArray &emailAddress,
517 const QByteArray &webAddress,
518 const QByteArray &ocsUsername )
519{
520 d->_authorList.append(KAboutPerson(name,task,emailAddress,webAddress,ocsUsername));
521 return *this;
522}
523
524KAboutData &KAboutData::addCredit( const KLocalizedString &name,
525 const KLocalizedString &task,
526 const QByteArray &emailAddress,
527 const QByteArray &webAddress )
528{
529 d->_creditList.append(KAboutPerson(name,task,emailAddress,webAddress));
530 return *this;
531}
532
533KAboutData &KAboutData::addCredit( const KLocalizedString &name,
534 const KLocalizedString &task,
535 const QByteArray &emailAddress,
536 const QByteArray &webAddress,
537 const QByteArray &ocsUsername )
538{
539 d->_creditList.append(KAboutPerson(name,task,emailAddress,webAddress,ocsUsername));
540 return *this;
541}
542
543KAboutData &KAboutData::setTranslator( const KLocalizedString& name,
544 const KLocalizedString& emailAddress )
545{
546 d->translatorName = name;
547 d->translatorEmail = emailAddress;
548 return *this;
549}
550
551KAboutData &KAboutData::setLicenseText( const KLocalizedString &licenseText )
552{
553 d->_licenseList[0] = KAboutLicense(licenseText,this);
554 return *this;
555}
556
557KAboutData &KAboutData::addLicenseText( const KLocalizedString &licenseText )
558{
559 // if the default license is unknown, overwrite instead of append
560 KAboutLicense &firstLicense = d->_licenseList[0];
561 if (d->_licenseList.count() == 1 && firstLicense.d->_licenseKey == License_Unknown) {
562 firstLicense = KAboutLicense(licenseText,this);
563 } else {
564 d->_licenseList.append(KAboutLicense(licenseText,this));
565 }
566 return *this;
567}
568
569KAboutData &KAboutData::setLicenseTextFile( const QString &pathToFile )
570{
571 d->_licenseList[0] = KAboutLicense(pathToFile,this);
572 return *this;
573}
574
575KAboutData &KAboutData::addLicenseTextFile( const QString &pathToFile )
576{
577 // if the default license is unknown, overwrite instead of append
578 KAboutLicense &firstLicense = d->_licenseList[0];
579 if (d->_licenseList.count() == 1 && firstLicense.d->_licenseKey == License_Unknown) {
580 firstLicense = KAboutLicense(pathToFile,this);
581 } else {
582 d->_licenseList.append(KAboutLicense(pathToFile,this));
583 }
584 return *this;
585}
586
587KAboutData &KAboutData::setAppName( const QByteArray &_appName )
588{
589 d->_appName = _appName;
590 return *this;
591}
592
593KAboutData &KAboutData::setProgramName( const KLocalizedString &_programName )
594{
595 d->_programName = _programName;
596 translateInternalProgramName();
597 return *this;
598}
599
600KAboutData &KAboutData::setOcsProvider(const QByteArray &_ocsProviderUrl )
601{
602 d->_ocsProviderUrl = _ocsProviderUrl;
603 return *this;
604}
605
606KAboutData &KAboutData::setVersion( const QByteArray &_version )
607{
608 d->_version = _version;
609 return *this;
610}
611
612KAboutData &KAboutData::setShortDescription( const KLocalizedString &_shortDescription )
613{
614 d->_shortDescription = _shortDescription;
615 return *this;
616}
617
618KAboutData &KAboutData::setCatalogName( const QByteArray &_catalogName )
619{
620 d->_catalogName = _catalogName;
621 return *this;
622}
623
624KAboutData &KAboutData::setLicense( LicenseKey licenseKey)
625{
626 d->_licenseList[0] = KAboutLicense(licenseKey,this);
627 return *this;
628}
629
630KAboutData &KAboutData::addLicense( LicenseKey licenseKey)
631{
632 // if the default license is unknown, overwrite instead of append
633 KAboutLicense &firstLicense = d->_licenseList[0];
634 if (d->_licenseList.count() == 1 && firstLicense.d->_licenseKey == License_Unknown) {
635 firstLicense = KAboutLicense(licenseKey,this);
636 } else {
637 d->_licenseList.append(KAboutLicense(licenseKey,this));
638 }
639 return *this;
640}
641
642KAboutData &KAboutData::setCopyrightStatement( const KLocalizedString &_copyrightStatement )
643{
644 d->_copyrightStatement = _copyrightStatement;
645 return *this;
646}
647
648KAboutData &KAboutData::setOtherText( const KLocalizedString &_otherText )
649{
650 d->_otherText = _otherText;
651 return *this;
652}
653
654KAboutData &KAboutData::setHomepage( const QByteArray &_homepage )
655{
656 d->_homepageAddress = QString::fromLatin1(_homepage);
657 return *this;
658}
659
660KAboutData &KAboutData::setBugAddress( const QByteArray &_bugAddress )
661{
662 d->_bugEmailAddress = _bugAddress;
663 return *this;
664}
665
666KAboutData &KAboutData::setOrganizationDomain( const QByteArray &domain )
667{
668 d->organizationDomain = QString::fromLatin1(domain);
669 return *this;
670}
671
672KAboutData &KAboutData::setProductName( const QByteArray &_productName )
673{
674 d->productName = QString::fromUtf8(_productName);
675 return *this;
676}
677
678QString KAboutData::appName() const
679{
680 return QString::fromUtf8(d->_appName);
681}
682
683QString KAboutData::productName() const
684{
685 if (!d->productName.isEmpty())
686 return d->productName;
687 return appName();
688}
689
690QString KAboutData::programName() const
691{
692 if (!d->_programName.isEmpty())
693 return d->_programName.toString();
694 return QString();
695}
696
700const char* KAboutData::internalProgramName() const
701{
702 return d->_translatedProgramName.constData();
703}
704
709void KAboutData::translateInternalProgramName() const
710{
711 d->_translatedProgramName.clear();
712 if( KGlobal::locale())
713 d->_translatedProgramName = programName().toUtf8();
714}
715
716QString KAboutData::programIconName() const
717{
718 return d->programIconName.isEmpty() ? appName() : d->programIconName;
719}
720
721KAboutData &KAboutData::setProgramIconName( const QString &iconName )
722{
723 d->programIconName = iconName;
724 return *this;
725}
726
727QVariant KAboutData::programLogo() const
728{
729 return d->programLogo;
730}
731
732KAboutData &KAboutData::setProgramLogo(const QVariant& image)
733{
734 d->programLogo = image ;
735 return *this;
736}
737
738QString KAboutData::ocsProviderUrl() const
739{
740 if( !d->_ocsProviderUrl.isEmpty() )
741 return QString::fromUtf8( d->_ocsProviderUrl );
742 return QString();
743}
744
745QString KAboutData::version() const
746{
747 return QString::fromUtf8(d->_version);
748}
749
753const char* KAboutData::internalVersion() const
754{
755 return d->_version.constData();
756}
757
758QString KAboutData::shortDescription() const
759{
760 if (!d->_shortDescription.isEmpty())
761 return d->_shortDescription.toString();
762 return QString();
763}
764
765QString KAboutData::catalogName() const
766{
767 if (!d->_catalogName.isEmpty())
768 return QString::fromUtf8(d->_catalogName);
769 // Fallback to appname for catalog name if empty.
770 return QString::fromUtf8(d->_appName);
771}
772
773QString KAboutData::homepage() const
774{
775 return d->_homepageAddress;
776}
777
778QString KAboutData::bugAddress() const
779{
780 return QString::fromUtf8(d->_bugEmailAddress);
781}
782
783QString KAboutData::organizationDomain() const
784{
785 return d->organizationDomain;
786}
787
788
792const char* KAboutData::internalBugAddress() const
793{
794 if (d->_bugEmailAddress.isEmpty())
795 return 0;
796 return d->_bugEmailAddress.constData();
797}
798
799QList<KAboutPerson> KAboutData::authors() const
800{
801 return d->_authorList;
802}
803
804QList<KAboutPerson> KAboutData::credits() const
805{
806 return d->_creditList;
807}
808
809#define NAME_OF_TRANSLATORS "Your names"
810#define EMAIL_OF_TRANSLATORS "Your emails"
811QList<KAboutPerson> KAboutData::translators() const
812{
813 QList<KAboutPerson> personList;
814
815 KLocale *tmpLocale = NULL;
816 if (KGlobal::locale()) {
817 // There could be many catalogs loaded into the global locale,
818 // e.g. in systemsettings. The tmp locale is needed to make sure we
819 // use the translators name from this aboutdata's catalog, rather than
820 // from any other loaded catalog.
821 tmpLocale = new KLocale(*KGlobal::locale());
822 tmpLocale->setActiveCatalog(catalogName());
823 }
824
825 QString translatorName;
826 if (!d->translatorName.isEmpty()) {
827 translatorName = d->translatorName.toString();
828 }
829 else {
830 translatorName = ki18nc("NAME OF TRANSLATORS", NAME_OF_TRANSLATORS).toString(tmpLocale);
831 }
832
833 QString translatorEmail;
834 if (!d->translatorEmail.isEmpty()) {
835 translatorEmail = d->translatorEmail.toString();
836 }
837 else {
838 translatorEmail = ki18nc("EMAIL OF TRANSLATORS", EMAIL_OF_TRANSLATORS).toString(tmpLocale);
839 }
840
841 delete tmpLocale;
842
843 if ( translatorName.isEmpty() || translatorName == QString::fromUtf8( NAME_OF_TRANSLATORS ) )
844 return personList;
845
846 const QStringList nameList(translatorName.split(QString(QLatin1Char(','))));
847
848 QStringList emailList;
849 if( !translatorEmail.isEmpty() && translatorEmail != QString::fromUtf8( EMAIL_OF_TRANSLATORS ) )
850 {
851 emailList = translatorEmail.split(QString(QLatin1Char(',')), QString::KeepEmptyParts);
852 }
853
854 QStringList::const_iterator nit;
855 QStringList::const_iterator eit = emailList.constBegin();
856
857 for( nit = nameList.constBegin(); nit != nameList.constEnd(); ++nit )
858 {
859 QString email;
860 if ( eit != emailList.constEnd() )
861 {
862 email = *eit;
863 ++eit;
864 }
865
866 personList.append( KAboutPerson( (*nit).trimmed(), email.trimmed() ) );
867 }
868
869 return personList;
870}
871
872QString KAboutData::aboutTranslationTeam()
873{
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>"
879 );
880}
881
882QString KAboutData::otherText() const
883{
884 if (!d->_otherText.isEmpty())
885 return d->_otherText.toString();
886 return QString();
887}
888
889QString KAboutData::license() const
890{
891 return d->_licenseList.at(0).text();
892}
893
894QString KAboutData::licenseName( NameFormat formatName ) const
895{
896 return d->_licenseList.at(0).name(formatName);
897}
898
899QList<KAboutLicense> KAboutData::licenses() const
900{
901 return d->_licenseList;
902}
903
904QString KAboutData::copyrightStatement() const
905{
906 if (!d->_copyrightStatement.isEmpty())
907 return d->_copyrightStatement.toString();
908 return QString();
909}
910
911QString KAboutData::customAuthorPlainText() const
912{
913 if (!d->customAuthorPlainText.isEmpty())
914 return d->customAuthorPlainText.toString();
915 return QString();
916}
917
918QString KAboutData::customAuthorRichText() const
919{
920 if (!d->customAuthorRichText.isEmpty())
921 return d->customAuthorRichText.toString();
922 return QString();
923}
924
925bool KAboutData::customAuthorTextEnabled() const
926{
927 return d->customAuthorTextEnabled;
928}
929
930KAboutData &KAboutData::setCustomAuthorText( const KLocalizedString &plainText,
931 const KLocalizedString &richText )
932{
933 d->customAuthorPlainText = plainText;
934 d->customAuthorRichText = richText;
935
936 d->customAuthorTextEnabled = true;
937
938 return *this;
939}
940
941KAboutData &KAboutData::unsetCustomAuthorText()
942{
943 d->customAuthorPlainText = KLocalizedString();
944 d->customAuthorRichText = KLocalizedString();
945
946 d->customAuthorTextEnabled = false;
947
948 return *this;
949}
950
KAboutData
This class is used to store information about a program.
Definition: kaboutdata.h:193
KAboutData::setProductName
KAboutData & setProductName(const QByteArray &name)
Defines the product name which will be used in the KBugReport dialog.
Definition: kaboutdata.cpp:672
KAboutData::programLogo
QVariant programLogo() const
Returns the program logo image.
Definition: kaboutdata.cpp:727
KAboutData::setProgramIconName
KAboutData & setProgramIconName(const QString &iconName)
Defines the program icon.
Definition: kaboutdata.cpp:721
KAboutData::ocsProviderUrl
QString ocsProviderUrl() const
Returns the chosen Open Collaboration Services provider URL.
Definition: kaboutdata.cpp:738
KAboutData::aboutTranslationTeam
static QString aboutTranslationTeam()
Returns a message about the translation team.
Definition: kaboutdata.cpp:872
KAboutData::setOtherText
KAboutData & setOtherText(const KLocalizedString &otherText)
Defines the additional text to show in the about dialog.
Definition: kaboutdata.cpp:648
KAboutData::internalBugAddress
const char * internalBugAddress() const
Definition: kaboutdata.cpp:792
KAboutData::setCatalogName
KAboutData & setCatalogName(const QByteArray &catalogName)
Defines the translation catalog that the program uses.
Definition: kaboutdata.cpp:618
KAboutData::setLicense
KAboutData & setLicense(LicenseKey licenseKey)
Defines the license identifier.
Definition: kaboutdata.cpp:624
KAboutData::setLicenseTextFile
KAboutData & setLicenseTextFile(const QString &file)
Defines a license text by pointing to a file where it resides.
Definition: kaboutdata.cpp:569
KAboutData::customAuthorRichText
QString customAuthorRichText() const
Returns the rich text displayed around the list of authors instead of the default message telling use...
Definition: kaboutdata.cpp:918
KAboutData::credits
QList< KAboutPerson > credits() const
Returns a list of persons who contributed.
Definition: kaboutdata.cpp:804
KAboutData::translateInternalProgramName
void translateInternalProgramName() const
Definition: kaboutdata.cpp:709
KAboutData::internalVersion
const char * internalVersion() const
Definition: kaboutdata.cpp:753
KAboutData::addLicense
KAboutData & addLicense(LicenseKey licenseKey)
Adds a license identifier.
Definition: kaboutdata.cpp:630
KAboutData::programName
QString programName() const
Returns the translated program name.
Definition: kaboutdata.cpp:690
KAboutData::programIconName
QString programIconName() const
Returns the program's icon name.
Definition: kaboutdata.cpp:716
KAboutData::setOcsProvider
KAboutData & setOcsProvider(const QByteArray &providerUrl)
Specifies an Open Collaboration Services provider by URL.
Definition: kaboutdata.cpp:600
KAboutData::customAuthorTextEnabled
bool customAuthorTextEnabled() const
Returns whether custom text should be displayed around the list of authors.
Definition: kaboutdata.cpp:925
KAboutData::internalProgramName
const char * internalProgramName() const
Definition: kaboutdata.cpp:700
KAboutData::setProgramLogo
KAboutData & setProgramLogo(const QVariant &image)
Defines the program logo.
Definition: kaboutdata.cpp:732
KAboutData::addCredit
KAboutData & addCredit(const KLocalizedString &name, const KLocalizedString &task=KLocalizedString(), const QByteArray &emailAddress=QByteArray(), const QByteArray &webAddress=QByteArray())
Defines a person that deserves credit.
Definition: kaboutdata.cpp:524
KAboutData::customAuthorPlainText
QString customAuthorPlainText() const
Returns the plain text displayed around the list of authors instead of the default message telling us...
Definition: kaboutdata.cpp:911
KAboutData::authors
QList< KAboutPerson > authors() const
Returns a list of authors.
Definition: kaboutdata.cpp:799
KAboutData::shortDescription
QString shortDescription() const
Returns a short, translated description.
Definition: kaboutdata.cpp:758
KAboutData::copyrightStatement
QString copyrightStatement() const
Returns the copyright statement.
Definition: kaboutdata.cpp:904
KAboutData::homepage
QString homepage() const
Returns the application homepage.
Definition: kaboutdata.cpp:773
KAboutData::setBugAddress
KAboutData & setBugAddress(const QByteArray &bugAddress)
Defines the address where bug reports should be sent.
Definition: kaboutdata.cpp:660
KAboutData::productName
QString productName() const
Returns the application's product name, which will be used in KBugReport dialog.
Definition: kaboutdata.cpp:683
KAboutData::NameFormat
NameFormat
Format of the license name.
Definition: kaboutdata.h:219
KAboutData::FullName
@ FullName
Definition: kaboutdata.h:221
KAboutData::ShortName
@ ShortName
Definition: kaboutdata.h:220
KAboutData::KAboutData
KAboutData(const QByteArray &appName, const QByteArray &catalogName, const KLocalizedString &programName, const QByteArray &version, const KLocalizedString &shortDescription=KLocalizedString(), enum LicenseKey licenseType=License_Unknown, const KLocalizedString &copyrightStatement=KLocalizedString(), const KLocalizedString &otherText=KLocalizedString(), const QByteArray &homePageAddress=QByteArray(), const QByteArray &bugsEmailAddress="submit@bugs.kde.org")
Constructor.
Definition: kaboutdata.cpp:427
KAboutData::operator=
KAboutData & operator=(const KAboutData &other)
Assignment operator.
Definition: kaboutdata.cpp:491
KAboutData::version
QString version() const
Returns the program's version.
Definition: kaboutdata.cpp:745
KAboutData::organizationDomain
QString organizationDomain() const
Returns the domain name of the organization that wrote this application.
Definition: kaboutdata.cpp:783
KAboutData::translators
QList< KAboutPerson > translators() const
Returns a list of translators.
Definition: kaboutdata.cpp:811
KAboutData::bugAddress
QString bugAddress() const
Returns the email address for bugs.
Definition: kaboutdata.cpp:778
KAboutData::licenseName
QString licenseName(NameFormat formatName) const
Returns the license name.
Definition: kaboutdata.cpp:894
KAboutData::setVersion
KAboutData & setVersion(const QByteArray &version)
Defines the program version string.
Definition: kaboutdata.cpp:606
KAboutData::license
QString license() const
Returns the license.
Definition: kaboutdata.cpp:889
KAboutData::catalogName
QString catalogName() const
Returns the program's translation catalog name.
Definition: kaboutdata.cpp:765
KAboutData::~KAboutData
~KAboutData()
Definition: kaboutdata.cpp:475
KAboutData::addAuthor
KAboutData & addAuthor(const KLocalizedString &name, const KLocalizedString &task=KLocalizedString(), const QByteArray &emailAddress=QByteArray(), const QByteArray &webAddress=QByteArray())
Defines an author.
Definition: kaboutdata.cpp:505
KAboutData::setOrganizationDomain
KAboutData & setOrganizationDomain(const QByteArray &domain)
Defines the Internet domain of the organization that wrote this application.
Definition: kaboutdata.cpp:666
KAboutData::LicenseKey
LicenseKey
Describes the license of the software.
Definition: kaboutdata.h:199
KAboutData::License_QPL
@ License_QPL
Definition: kaboutdata.h:209
KAboutData::License_LGPL_V3
@ License_LGPL_V3
Definition: kaboutdata.h:212
KAboutData::License_File
@ License_File
Definition: kaboutdata.h:201
KAboutData::License_GPL
@ License_GPL
Definition: kaboutdata.h:203
KAboutData::License_Artistic
@ License_Artistic
Definition: kaboutdata.h:208
KAboutData::License_Custom
@ License_Custom
Definition: kaboutdata.h:200
KAboutData::License_GPL_V3
@ License_GPL_V3
Definition: kaboutdata.h:211
KAboutData::License_QPL_V1_0
@ License_QPL_V1_0
Definition: kaboutdata.h:210
KAboutData::License_Unknown
@ License_Unknown
Definition: kaboutdata.h:202
KAboutData::License_LGPL_V2
@ License_LGPL_V2
Definition: kaboutdata.h:206
KAboutData::License_BSD
@ License_BSD
Definition: kaboutdata.h:207
KAboutData::License_GPL_V2
@ License_GPL_V2
Definition: kaboutdata.h:204
KAboutData::License_LGPL
@ License_LGPL
Definition: kaboutdata.h:205
KAboutData::setShortDescription
KAboutData & setShortDescription(const KLocalizedString &shortDescription)
Defines a short description of what the program does.
Definition: kaboutdata.cpp:612
KAboutData::unsetCustomAuthorText
KAboutData & unsetCustomAuthorText()
Clears any custom text displayed around the list of authors and falls back to the default message tel...
Definition: kaboutdata.cpp:941
KAboutData::setAppName
KAboutData & setAppName(const QByteArray &appName)
Defines the program name used internally.
Definition: kaboutdata.cpp:587
KAboutData::setCustomAuthorText
KAboutData & setCustomAuthorText(const KLocalizedString &plainText, const KLocalizedString &richText)
Sets the custom text displayed around the list of authors instead of the default message telling user...
Definition: kaboutdata.cpp:930
KAboutData::addLicenseTextFile
KAboutData & addLicenseTextFile(const QString &file)
Adds a license text by pointing to a file where it resides.
Definition: kaboutdata.cpp:575
KAboutData::setCopyrightStatement
KAboutData & setCopyrightStatement(const KLocalizedString &copyrightStatement)
Defines the copyright statement to show when displaying the license.
Definition: kaboutdata.cpp:642
KAboutData::setLicenseText
KAboutData & setLicenseText(const KLocalizedString &license)
Defines a license text, which is marked for translation.
Definition: kaboutdata.cpp:551
KAboutData::appName
QString appName() const
Returns the application's internal name.
Definition: kaboutdata.cpp:678
KAboutData::otherText
QString otherText() const
Returns a translated, free form text.
Definition: kaboutdata.cpp:882
KAboutData::setHomepage
KAboutData & setHomepage(const QByteArray &homepage)
Defines the program homepage.
Definition: kaboutdata.cpp:654
KAboutData::setProgramName
KAboutData & setProgramName(const KLocalizedString &programName)
Defines the displayable program name string.
Definition: kaboutdata.cpp:593
KAboutData::setTranslator
KAboutData & setTranslator(const KLocalizedString &name, const KLocalizedString &emailAddress)
Sets the name(s) of the translator(s) of the GUI.
Definition: kaboutdata.cpp:543
KAboutData::addLicenseText
KAboutData & addLicenseText(const KLocalizedString &license)
Adds a license text, which is marked for translation.
Definition: kaboutdata.cpp:557
KAboutData::licenses
QList< KAboutLicense > licenses() const
Returns a list of licenses.
Definition: kaboutdata.cpp:899
KAboutLicense
This class is used to store information about a license.
Definition: kaboutdata.h:895
KAboutLicense::text
QString text() const
Returns the full license text.
Definition: kaboutdata.cpp:219
KAboutLicense::key
KAboutData::LicenseKey key() const
Returns the license key.
Definition: kaboutdata.cpp:352
KAboutLicense::byKeyword
static KAboutLicense byKeyword(const QString &keyword)
Fetch a known license by a keyword.
Definition: kaboutdata.cpp:357
KAboutLicense::KAboutLicense
KAboutLicense(const KAboutLicense &other)
Copy constructor.
Definition: kaboutdata.cpp:211
KAboutLicense::name
QString name(KAboutData::NameFormat formatName) const
Returns the license name.
Definition: kaboutdata.cpp:295
KAboutLicense::~KAboutLicense
~KAboutLicense()
Definition: kaboutdata.cpp:216
KAboutLicense::operator=
KAboutLicense & operator=(const KAboutLicense &other)
Assignment operator.
Definition: kaboutdata.cpp:346
KAboutPerson
This class is used to store information about a person or developer.
Definition: kaboutdata.h:69
KAboutPerson::emailAddress
QString emailAddress() const
The person's email address.
Definition: kaboutdata.cpp:125
KAboutPerson::ocsUsername
QString ocsUsername() const
The person's Open Collaboration Services username.
Definition: kaboutdata.cpp:136
KAboutPerson::name
QString name() const
The person's name.
Definition: kaboutdata.cpp:111
KAboutPerson::webAddress
QString webAddress() const
The home page or a relevant link.
Definition: kaboutdata.cpp:131
KAboutPerson::task
QString task() const
The person's task.
Definition: kaboutdata.cpp:118
KAboutPerson::~KAboutPerson
~KAboutPerson()
Definition: kaboutdata.cpp:106
KAboutPerson::KAboutPerson
KAboutPerson(const KLocalizedString &name, const KLocalizedString &task=KLocalizedString(), const QByteArray &emailAddress=QByteArray(), const QByteArray &webAddress=QByteArray())
Convenience constructor.
Definition: kaboutdata.cpp:68
KAboutPerson::operator=
KAboutPerson & operator=(const KAboutPerson &other)
Assignment operator.
Definition: kaboutdata.cpp:141
KLocale
KLocale provides support for country specific stuff like the national language.
Definition: klocale.h:70
KLocale::setActiveCatalog
void setActiveCatalog(const QString &catalog)
Sets the active catalog for translation lookup.
Definition: klocale.cpp:146
KLocalizedString
Class for producing and handling localized messages.
Definition: klocalizedstring.h:300
KLocalizedString::toString
QString toString() const
Finalizes the translation, creates QString with placeholders substituted.
Definition: klocalizedstring.cpp:192
KStandardDirs::locate
static QString locate(const char *type, const QString &filename, const KComponentData &cData=KGlobal::mainComponent())
This function is just for convenience.
Definition: kstandarddirs.cpp:2091
QHash
Definition: ksycocafactory.h:28
QList
Definition: kaboutdata.h:33
QStringList
QString
QVariant
EMAIL_OF_TRANSLATORS
#define EMAIL_OF_TRANSLATORS
Definition: kaboutdata.cpp:810
NAME_OF_TRANSLATORS
#define NAME_OF_TRANSLATORS
Definition: kaboutdata.cpp:809
kaboutdata.h
ki18nc
KLocalizedString ki18nc(const char *ctxt, const char *msg)
Creates localized string from a given message, with added context.
Definition: klocalizedstring.cpp:929
klocalizedstring.h
i18n
QString i18n(const char *text)
Returns a localized version of a string.
Definition: klocalizedstring.h:630
i18nc
QString i18nc(const char *ctxt, const char *text)
Returns a localized version of a string and a context.
Definition: klocalizedstring.h:797
kstandarddirs.h
KGlobal::locale
KLocale * locale()
Returns the global locale object.
Definition: kglobal.cpp:170
This file is part of the KDE documentation.
Documentation copyright © 1996-2023 The KDE developers.
Generated on Mon Feb 20 2023 00:00:00 by doxygen 1.9.6 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

KDECore

Skip menu "KDECore"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members
  • Modules
  • Related Pages

kdelibs-4.14.38 API Reference

Skip menu "kdelibs-4.14.38 API Reference"
  • DNSSD
  • Interfaces
  •   KHexEdit
  •   KMediaPlayer
  •   KSpeech
  •   KTextEditor
  • kconf_update
  • KDE3Support
  •   KUnitTest
  • KDECore
  • KDED
  • KDEsu
  • KDEUI
  • KDEWebKit
  • KDocTools
  • KFile
  • KHTML
  • KImgIO
  • KInit
  • kio
  • KIOSlave
  • KJS
  •   KJS-API
  •   WTF
  • kjsembed
  • KNewStuff
  • KParts
  • KPty
  • Kross
  • KUnitConversion
  • KUtils
  • Nepomuk
  • Plasma
  • Solid
  • Sonnet
  • ThreadWeaver
Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal