• Skip to content
  • Skip to link menu
Trinity API Reference
  • Trinity API Reference
  • kdecore
 

kdecore

  • kdecore
kaboutdata.cpp
1 /*
2  * This file is part of the KDE Libraries
3  * Copyright (C) 2000 Espen Sand (espen@kde.org)
4  *
5  * This library is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Library General Public
7  * License as published by the Free Software Foundation; either
8  * version 2 of the License, or (at your option) any later version.
9  *
10  * This library is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  * Library General Public License for more details.
14  *
15  * You should have received a copy of the GNU Library General Public License
16  * along with this library; see the file COPYING.LIB. If not, write to
17  * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18  * Boston, MA 02110-1301, USA.
19  *
20  */
21 
22 
23 #include <kaboutdata.h>
24 #include <kstandarddirs.h>
25 #include <tqfile.h>
26 #include <tqtextstream.h>
27 
28 TQString
29 KAboutPerson::name() const
30 {
31  return TQString::fromUtf8(mName);
32 }
33 
34 TQString
35 KAboutPerson::task() const
36 {
37  if (mTask && *mTask)
38  return i18n(mTask);
39  else
40  return TQString::null;
41 }
42 
43 TQString
44 KAboutPerson::emailAddress() const
45 {
46  return TQString::fromUtf8(mEmailAddress);
47 }
48 
49 
50 TQString
51 KAboutPerson::webAddress() const
52 {
53  return TQString::fromUtf8(mWebAddress);
54 }
55 
56 
57 KAboutTranslator::KAboutTranslator(const TQString & name,
58  const TQString & emailAddress)
59 {
60  mName=name;
61  mEmail=emailAddress;
62 }
63 
64 TQString KAboutTranslator::name() const
65 {
66  return mName;
67 }
68 
69 TQString KAboutTranslator::emailAddress() const
70 {
71  return mEmail;
72 }
73 
74 class KAboutDataPrivate
75 {
76 public:
77  KAboutDataPrivate()
78  : translatorName("_: NAME OF TRANSLATORS\nYour names")
79  , translatorEmail("_: EMAIL OF TRANSLATORS\nYour emails")
80  , productName(0)
81  , programLogo(0)
82  , customAuthorTextEnabled(false)
83  , mTranslatedProgramName( 0 )
84  {}
85  ~KAboutDataPrivate()
86  {
87  delete programLogo;
88  delete[] mTranslatedProgramName;
89  }
90  const char *translatorName;
91  const char *translatorEmail;
92  const char *productName;
93  TQImage* programLogo;
94  TQString customAuthorPlainText, customAuthorRichText;
95  bool customAuthorTextEnabled;
96  const char *mTranslatedProgramName;
97 };
98 
99 const char *KAboutData::defaultBugTracker = "http://bugs.trinitydesktop.org";
100 
101 KAboutData::KAboutData( const char *appName,
102  const char *programName,
103  const char *version,
104  const char *shortDescription,
105  int licenseType,
106  const char *copyrightStatement,
107  const char *text,
108  const char *homePageAddress,
109  const char *bugsEmailAddress
110  ) :
111  mProgramName( programName ),
112  mVersion( version ),
113  mShortDescription( shortDescription ),
114  mLicenseKey( licenseType ),
115  mCopyrightStatement( copyrightStatement ),
116  mOtherText( text ),
117  mHomepageAddress( homePageAddress ),
118  mBugEmailAddress( (bugsEmailAddress!=0)?bugsEmailAddress:defaultBugTracker ),
119  mLicenseText (0)
120 {
121  d = new KAboutDataPrivate;
122 
123  if( appName ) {
124  const char *p = strrchr(appName, '/');
125  if( p )
126  mAppName = p+1;
127  else
128  mAppName = appName;
129  } else
130  mAppName = 0;
131 }
132 
133 KAboutData::~KAboutData()
134 {
135  if (mLicenseKey == License_File)
136  delete [] mLicenseText;
137  delete d;
138 }
139 
140 void
141 KAboutData::addAuthor( const char *name, const char *task,
142  const char *emailAddress, const char *webAddress )
143 {
144  mAuthorList.append(KAboutPerson(name,task,emailAddress,webAddress));
145 }
146 
147 void
148 KAboutData::addCredit( const char *name, const char *task,
149  const char *emailAddress, const char *webAddress )
150 {
151  mCreditList.append(KAboutPerson(name,task,emailAddress,webAddress));
152 }
153 
154 void
155 KAboutData::setTranslator( const char *name, const char *emailAddress)
156 {
157  d->translatorName=name;
158  d->translatorEmail=emailAddress;
159 }
160 
161 void
162 KAboutData::setLicenseText( const char *licenseText )
163 {
164  mLicenseText = licenseText;
165  mLicenseKey = License_Custom;
166 }
167 
168 void
169 KAboutData::setLicenseTextFile( const TQString &file )
170 {
171  mLicenseText = qstrdup(TQFile::encodeName(file));
172  mLicenseKey = License_File;
173 }
174 
175 void
176 KAboutData::setAppName( const char *appName )
177 {
178  mAppName = appName;
179 }
180 
181 void
182 KAboutData::setProgramName( const char* programName )
183 {
184  mProgramName = programName;
185  translateInternalProgramName();
186 }
187 
188 void
189 KAboutData::setVersion( const char* version )
190 {
191  mVersion = version;
192 }
193 
194 void
195 KAboutData::setShortDescription( const char *shortDescription )
196 {
197  mShortDescription = shortDescription;
198 }
199 
200 void
201 KAboutData::setLicense( LicenseKey licenseKey)
202 {
203  mLicenseKey = licenseKey;
204 }
205 
206 void
207 KAboutData::setCopyrightStatement( const char *copyrightStatement )
208 {
209  mCopyrightStatement = copyrightStatement;
210 }
211 
212 void
213 KAboutData::setOtherText( const char *otherText )
214 {
215  mOtherText = otherText;
216 }
217 
218 void
219 KAboutData::setHomepage( const char *homepage )
220 {
221  mHomepageAddress = homepage;
222 }
223 
224 void
225 KAboutData::setBugAddress( const char *bugAddress )
226 {
227  mBugEmailAddress = bugAddress;
228 }
229 
230 void
231 KAboutData::setProductName( const char *productName )
232 {
233  d->productName = productName;
234 }
235 
236 const char *
237 KAboutData::appName() const
238 {
239  return mAppName;
240 }
241 
242 const char *
243 KAboutData::productName() const
244 {
245  if (d->productName)
246  return d->productName;
247  else
248  return appName();
249 }
250 
251 TQString
252 KAboutData::programName() const
253 {
254  if (mProgramName && *mProgramName)
255  return i18n(mProgramName);
256  else
257  return TQString::null;
258 }
259 
260 const char*
261 KAboutData::internalProgramName() const
262 {
263  if (d->mTranslatedProgramName)
264  return d->mTranslatedProgramName;
265  else
266  return mProgramName;
267 }
268 
269 // KCrash should call as few things as possible and should avoid e.g. malloc()
270 // because it may deadlock. Since i18n() needs it, when KLocale is available
271 // the i18n() call will be done here in advance.
272 void
273 KAboutData::translateInternalProgramName() const
274 {
275  delete[] d->mTranslatedProgramName;
276  d->mTranslatedProgramName = 0;
277  if( KGlobal::locale() )
278  d->mTranslatedProgramName = qstrdup( programName().utf8());
279 }
280 
281 TQImage
282 KAboutData::programLogo() const
283 {
284  return d->programLogo ? (*d->programLogo) : TQImage();
285 }
286 
287 void
288 KAboutData::setProgramLogo(const TQImage& image)
289 {
290  if (!d->programLogo)
291  d->programLogo = new TQImage( image );
292  else
293  *d->programLogo = image;
294 }
295 
296 TQString
297 KAboutData::version() const
298 {
299  return TQString::fromLatin1(mVersion);
300 }
301 
302 TQString
303 KAboutData::shortDescription() const
304 {
305  if (mShortDescription && *mShortDescription)
306  return i18n(mShortDescription);
307  else
308  return TQString::null;
309 }
310 
311 TQString
312 KAboutData::homepage() const
313 {
314  return TQString::fromLatin1(mHomepageAddress);
315 }
316 
317 TQString
318 KAboutData::bugAddress() const
319 {
320  return TQString::fromLatin1(mBugEmailAddress);
321 }
322 
323 const TQValueList<KAboutPerson>
324 KAboutData::authors() const
325 {
326  return mAuthorList;
327 }
328 
329 const TQValueList<KAboutPerson>
330 KAboutData::credits() const
331 {
332  return mCreditList;
333 }
334 
335 const TQValueList<KAboutTranslator>
336 KAboutData::translators() const
337 {
338  TQValueList<KAboutTranslator> personList;
339 
340  if(d->translatorName == 0)
341  return personList;
342 
343  TQStringList nameList;
344  TQStringList emailList;
345 
346  TQString names = i18n(d->translatorName);
347  if(names != TQString::fromUtf8(d->translatorName))
348  {
349  nameList = TQStringList::split(',',names);
350  }
351 
352 
353  if(d->translatorEmail)
354  {
355  TQString emails = i18n(d->translatorEmail);
356 
357  if(emails != TQString::fromUtf8(d->translatorEmail))
358  {
359  emailList = TQStringList::split(',',emails,true);
360  }
361  }
362 
363 
364  TQStringList::Iterator nit;
365  TQStringList::Iterator eit=emailList.begin();
366 
367  for(nit = nameList.begin(); nit != nameList.end(); ++nit)
368  {
369  TQString email;
370  if(eit != emailList.end())
371  {
372  email=*eit;
373  ++eit;
374  }
375 
376  TQString name=*nit;
377 
378  personList.append(KAboutTranslator(name.stripWhiteSpace(), email.stripWhiteSpace()));
379  }
380 
381  return personList;
382 }
383 
384 TQString
385 KAboutData::aboutTranslationTeam()
386 {
387  return i18n("replace this with information about your translation team",
388  "<p>KDE is translated into many languages thanks to the work "
389  "of the translation teams all over the world.</p>"
390  "<p>For more information on KDE internationalization "
391  "visit <a href=\"http://l10n.kde.org\">http://l10n.kde.org</a></p>"
392  );
393 }
394 
395 TQString
396 KAboutData::otherText() const
397 {
398  if (mOtherText && *mOtherText)
399  return i18n(mOtherText);
400  else
401  return TQString::null;
402 }
403 
404 
405 TQString
406 KAboutData::license() const
407 {
408  TQString result;
409  if (!copyrightStatement().isEmpty())
410  result = copyrightStatement() + "\n\n";
411 
412  TQString l;
413  TQString f;
414  switch ( mLicenseKey )
415  {
416  case License_File:
417  f = TQFile::decodeName(mLicenseText);
418  break;
419  case License_GPL_V2:
420  l = "GPL v2";
421  f = locate("data", "LICENSES/GPL_V2");
422  break;
423  case License_LGPL_V2:
424  l = "LGPL v2";
425  f = locate("data", "LICENSES/LGPL_V2");
426  break;
427  case License_GPL_V3:
428  l = "GPL v3";
429  f = locate("data", "LICENSES/GPL_V3");
430  break;
431  case License_LGPL_V3:
432  l = "LGPL v3";
433  f = locate("data", "LICENSES/LGPL_V3");
434  break;
435  case License_BSD:
436  l = "BSD License";
437  f = locate("data", "LICENSES/BSD");
438  break;
439  case License_Artistic:
440  l = "Artistic License";
441  f = locate("data", "LICENSES/ARTISTIC");
442  break;
443  case License_QPL_V1_0:
444  l = "QPL v1.0";
445  f = locate("data", "LICENSES/QPL_V1.0");
446  break;
447  case License_Custom:
448  if (mLicenseText && *mLicenseText)
449  return( i18n(mLicenseText) );
450  // fall through
451  default:
452  result += i18n("No licensing terms for this program have been specified.\n"
453  "Please check the documentation or the source for any\n"
454  "licensing terms.\n");
455  return result;
456  }
457 
458  if (!l.isEmpty())
459  result += i18n("This program is distributed under the terms of the %1.").arg( l );
460 
461  if (!f.isEmpty())
462  {
463  TQFile file(f);
464  if (file.open(IO_ReadOnly))
465  {
466  result += '\n';
467  result += '\n';
468  TQTextStream str(&file);
469  result += str.read();
470  }
471  }
472 
473  return result;
474 }
475 
476 TQString
477 KAboutData::copyrightStatement() const
478 {
479  if (mCopyrightStatement && *mCopyrightStatement)
480  return i18n(mCopyrightStatement);
481  else
482  return TQString::null;
483 }
484 
485 TQString
486 KAboutData::customAuthorPlainText() const
487 {
488  return d->customAuthorPlainText;
489 }
490 
491 TQString
492 KAboutData::customAuthorRichText() const
493 {
494  return d->customAuthorRichText;
495 }
496 
497 bool
498 KAboutData::customAuthorTextEnabled() const
499 {
500  return d->customAuthorTextEnabled;
501 }
502 
503 void
504 KAboutData::setCustomAuthorText(const TQString &plainText, const TQString &richText)
505 {
506  d->customAuthorPlainText = plainText;
507  d->customAuthorRichText = richText;
508 
509  d->customAuthorTextEnabled = true;
510 }
511 
512 void
513 KAboutData::unsetCustomAuthorText()
514 {
515  d->customAuthorPlainText = TQString::null;
516  d->customAuthorRichText = TQString::null;
517 
518  d->customAuthorTextEnabled = false;
519 }
520 
KAboutData::setProgramLogo
void setProgramLogo(const TQImage &image)
Defines the program logo.
Definition: kaboutdata.cpp:288
KGlobal::locale
static KLocale * locale()
Returns the global locale object.
Definition: kglobal.cpp:88
KAboutData::otherText
TQString otherText() const
Returns a translated, free form text.
Definition: kaboutdata.cpp:396
KAboutData::homepage
TQString homepage() const
Returns the application homepage.
Definition: kaboutdata.cpp:312
KAboutData::addCredit
void addCredit(const char *name, const char *task=0, const char *emailAddress=0, const char *webAddress=0)
Defines a person that deserves credit.
Definition: kaboutdata.cpp:148
KAboutData::authors
const TQValueList< KAboutPerson > authors() const
Returns a list of authors.
Definition: kaboutdata.cpp:324
KAboutData::setLicenseText
void setLicenseText(const char *license)
Defines a license text.
Definition: kaboutdata.cpp:162
KAboutData::setLicenseTextFile
void setLicenseTextFile(const TQString &file)
Defines a license text.
Definition: kaboutdata.cpp:169
KAboutData::translators
const TQValueList< KAboutTranslator > translators() const
Returns a list of translators.
Definition: kaboutdata.cpp:336
KAboutData::setAppName
void setAppName(const char *appName)
Defines the program name used internally.
Definition: kaboutdata.cpp:176
KAboutData::setCopyrightStatement
void setCopyrightStatement(const char *copyrightStatement)
Defines the copyright statement to show when displaying the license.
Definition: kaboutdata.cpp:207
KAboutData::unsetCustomAuthorText
void unsetCustomAuthorText()
Clears any custom text displayed around the list of authors and falls back to the default message tel...
Definition: kaboutdata.cpp:513
KAboutData::setOtherText
void setOtherText(const char *otherText)
Defines the additional text to show in the about dialog.
Definition: kaboutdata.cpp:213
KAboutTranslator::name
TQString name() const
The translator&#39;s name.
Definition: kaboutdata.cpp:64
KAboutData::customAuthorTextEnabled
bool customAuthorTextEnabled() const
Returns whether custom text should be displayed around the list of authors.
Definition: kaboutdata.cpp:498
KAboutPerson::emailAddress
TQString emailAddress() const
The person&#39;s email address.
Definition: kaboutdata.cpp:44
KAboutPerson::webAddress
TQString webAddress() const
The home page or a relevant link.
Definition: kaboutdata.cpp:51
KAboutData::credits
const TQValueList< KAboutPerson > credits() const
Returns a list of persons who contributed.
Definition: kaboutdata.cpp:330
KAboutTranslator
This structure is used to store information about a translator.
Definition: kaboutdata.h:134
KAboutData::setCustomAuthorText
void setCustomAuthorText(const TQString &plainText, const TQString &richText)
Sets the custom text displayed around the list of authors instead of the default message telling user...
Definition: kaboutdata.cpp:504
KAboutPerson::name
TQString name() const
The person&#39;s name.
Definition: kaboutdata.cpp:29
KAboutData::setTranslator
void setTranslator(const char *name, const char *emailAddress)
Sets the name of the translator of the gui.
Definition: kaboutdata.cpp:155
KAboutData::KAboutData
KAboutData(const char *appName, const char *programName, const char *version, const char *shortDescription=0, int licenseType=License_Unknown, const char *copyrightStatement=0, const char *text=0, const char *homePageAddress=0, const char *bugsEmailAddress=0)
Constructor.
Definition: kaboutdata.cpp:101
KAboutData::programLogo
TQImage programLogo() const
Returns the program logo image.
Definition: kaboutdata.cpp:282
KAboutData::setVersion
void setVersion(const char *version)
Defines the program version string.
Definition: kaboutdata.cpp:189
KAboutData::addAuthor
void addAuthor(const char *name, const char *task=0, const char *emailAddress=0, const char *webAddress=0)
Defines an author.
Definition: kaboutdata.cpp:141
KAboutPerson
This structure is used to store information about a person or developer.
Definition: kaboutdata.h:54
KAboutData::productName
const char * productName() const
Returns the application&#39;s product name, which will be used in KBugReport dialog.
Definition: kaboutdata.cpp:243
KAboutData::bugAddress
TQString bugAddress() const
Returns the email address for bugs.
Definition: kaboutdata.cpp:318
KAboutData::programName
TQString programName() const
Returns the translated program name.
Definition: kaboutdata.cpp:252
KAboutTranslator::emailAddress
TQString emailAddress() const
The translator&#39;s email.
Definition: kaboutdata.cpp:69
KAboutTranslator::KAboutTranslator
KAboutTranslator(const TQString &name=TQString::null, const TQString &emailAddress=TQString::null)
Convenience constructor.
Definition: kaboutdata.cpp:57
KAboutData::shortDescription
TQString shortDescription() const
Returns a short, translated description.
Definition: kaboutdata.cpp:303
KAboutData::setProductName
void setProductName(const char *name)
Defines the product name wich will be used in the KBugReport dialog.
Definition: kaboutdata.cpp:231
KAboutData::setShortDescription
void setShortDescription(const char *shortDescription)
Defines a short description of what the program does.
Definition: kaboutdata.cpp:195
KAboutData::setProgramName
void setProgramName(const char *programName)
Defines the displayable program name string.
Definition: kaboutdata.cpp:182
KAboutData::setBugAddress
void setBugAddress(const char *bugAddress)
Defines the address where bug reports should be sent.
Definition: kaboutdata.cpp:225
KAboutData::version
TQString version() const
Returns the program&#39;s version.
Definition: kaboutdata.cpp:297
KAboutPerson::task
TQString task() const
The person&#39;s task.
Definition: kaboutdata.cpp:35
KAboutData::license
TQString license() const
Returns the license.
Definition: kaboutdata.cpp:406
KAboutData::customAuthorPlainText
TQString customAuthorPlainText() const
Returns the plain text displayed around the list of authors instead of the default message telling us...
Definition: kaboutdata.cpp:486
KAboutData::LicenseKey
LicenseKey
Descibes the license of the software.
Definition: kaboutdata.h:188
KAboutData::aboutTranslationTeam
static TQString aboutTranslationTeam()
Returns a message about the translation team.
Definition: kaboutdata.cpp:385
KAboutData::copyrightStatement
TQString copyrightStatement() const
Returns the copyright statement.
Definition: kaboutdata.cpp:477
KAboutData::setLicense
void setLicense(LicenseKey licenseKey)
Defines the license identifier.
Definition: kaboutdata.cpp:201
KAboutData::appName
const char * appName() const
Returns the application&#39;s internal name.
Definition: kaboutdata.cpp:237
KAboutData::setHomepage
void setHomepage(const char *homepage)
Defines the program homepage.
Definition: kaboutdata.cpp:219
KAboutData::customAuthorRichText
TQString customAuthorRichText() const
Returns the rich text displayed around the list of authors instead of the default message telling use...
Definition: kaboutdata.cpp:492

kdecore

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

kdecore

Skip menu "kdecore"
  • arts
  • dcop
  • dnssd
  • interfaces
  •     interface
  •     library
  •   kspeech
  •   ktexteditor
  • kabc
  • kate
  • kcmshell
  • kdecore
  • kded
  • kdefx
  • kdeprint
  • kdesu
  • kdeui
  • kdoctools
  • khtml
  • kimgio
  • kinit
  • kio
  •   bookmarks
  •   httpfilter
  •   kfile
  •   kio
  •   kioexec
  •   kpasswdserver
  •   kssl
  • kioslave
  •   http
  • kjs
  • kmdi
  •   kmdi
  • knewstuff
  • kparts
  • krandr
  • kresources
  • kspell2
  • kunittest
  • kutils
  • kwallet
  • libkmid
  • libkscreensaver
Generated for kdecore by doxygen 1.8.11
This website is maintained by Timothy Pearson.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. |