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

tdecore

  • tdecore
tdeaboutdata.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 <tdeaboutdata.h>
24 #include <kstandarddirs.h>
25 #include <tqfile.h>
26 #include <tqtextstream.h>
27 
28 TQString
29 TDEAboutPerson::name() const
30 {
31  return TQString::fromUtf8(mName);
32 }
33 
34 TQString
35 TDEAboutPerson::task() const
36 {
37  if (mTask && *mTask)
38  return i18n(mTask);
39  else
40  return TQString::null;
41 }
42 
43 TQString
44 TDEAboutPerson::emailAddress() const
45 {
46  return TQString::fromUtf8(mEmailAddress);
47 }
48 
49 
50 TQString
51 TDEAboutPerson::webAddress() const
52 {
53  return TQString::fromUtf8(mWebAddress);
54 }
55 
56 
57 TDEAboutTranslator::TDEAboutTranslator(const TQString & name,
58  const TQString & emailAddress)
59 {
60  mName=name;
61  mEmail=emailAddress;
62 }
63 
64 TQString TDEAboutTranslator::name() const
65 {
66  return mName;
67 }
68 
69 TQString TDEAboutTranslator::emailAddress() const
70 {
71  return mEmail;
72 }
73 
74 class TDEAboutDataPrivate
75 {
76 public:
77  TDEAboutDataPrivate()
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  ~TDEAboutDataPrivate()
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 *TDEAboutData::defaultBugTracker = "http://bugs.trinitydesktop.org";
100 
101 TDEAboutData::TDEAboutData( 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 TDEAboutDataPrivate;
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 TDEAboutData::~TDEAboutData()
134 {
135  if (mLicenseKey == License_File)
136  delete [] mLicenseText;
137  delete d;
138 }
139 
140 void
141 TDEAboutData::addAuthor( const char *name, const char *task,
142  const char *emailAddress, const char *webAddress )
143 {
144  mAuthorList.append(TDEAboutPerson(name,task,emailAddress,webAddress));
145 }
146 
147 void
148 TDEAboutData::addCredit( const char *name, const char *task,
149  const char *emailAddress, const char *webAddress )
150 {
151  mCreditList.append(TDEAboutPerson(name,task,emailAddress,webAddress));
152 }
153 
154 void
155 TDEAboutData::setTranslator( const char *name, const char *emailAddress)
156 {
157  d->translatorName=name;
158  d->translatorEmail=emailAddress;
159 }
160 
161 void
162 TDEAboutData::setLicenseText( const char *licenseText )
163 {
164  mLicenseText = licenseText;
165  mLicenseKey = License_Custom;
166 }
167 
168 void
169 TDEAboutData::setLicenseTextFile( const TQString &file )
170 {
171  mLicenseText = tqstrdup(TQFile::encodeName(file));
172  mLicenseKey = License_File;
173 }
174 
175 void
176 TDEAboutData::setAppName( const char *appName )
177 {
178  mAppName = appName;
179 }
180 
181 void
182 TDEAboutData::setProgramName( const char* programName )
183 {
184  mProgramName = programName;
185  translateInternalProgramName();
186 }
187 
188 void
189 TDEAboutData::setVersion( const char* version )
190 {
191  mVersion = version;
192 }
193 
194 void
195 TDEAboutData::setShortDescription( const char *shortDescription )
196 {
197  mShortDescription = shortDescription;
198 }
199 
200 void
201 TDEAboutData::setLicense( LicenseKey licenseKey)
202 {
203  mLicenseKey = licenseKey;
204 }
205 
206 void
207 TDEAboutData::setCopyrightStatement( const char *copyrightStatement )
208 {
209  mCopyrightStatement = copyrightStatement;
210 }
211 
212 void
213 TDEAboutData::setOtherText( const char *otherText )
214 {
215  mOtherText = otherText;
216 }
217 
218 void
219 TDEAboutData::setHomepage( const char *homepage )
220 {
221  mHomepageAddress = homepage;
222 }
223 
224 void
225 TDEAboutData::setBugAddress( const char *bugAddress )
226 {
227  mBugEmailAddress = bugAddress;
228 }
229 
230 void
231 TDEAboutData::setProductName( const char *productName )
232 {
233  d->productName = productName;
234 }
235 
236 const char *
237 TDEAboutData::appName() const
238 {
239  return mAppName;
240 }
241 
242 const char *
243 TDEAboutData::productName() const
244 {
245  if (d->productName)
246  return d->productName;
247  else
248  return appName();
249 }
250 
251 TQString
252 TDEAboutData::programName() const
253 {
254  if (mProgramName && *mProgramName)
255  return i18n(mProgramName);
256  else
257  return TQString::null;
258 }
259 
260 const char*
261 TDEAboutData::internalProgramName() const
262 {
263  if (d->mTranslatedProgramName)
264  return d->mTranslatedProgramName;
265  else
266  return mProgramName;
267 }
268 
269 // TDECrash should call as few things as possible and should avoid e.g. malloc()
270 // because it may deadlock. Since i18n() needs it, when TDELocale is available
271 // the i18n() call will be done here in advance.
272 void
273 TDEAboutData::translateInternalProgramName() const
274 {
275  delete[] d->mTranslatedProgramName;
276  d->mTranslatedProgramName = 0;
277  if( TDEGlobal::locale() )
278  d->mTranslatedProgramName = tqstrdup( programName().utf8());
279 }
280 
281 TQImage
282 TDEAboutData::programLogo() const
283 {
284  return d->programLogo ? (*d->programLogo) : TQImage();
285 }
286 
287 void
288 TDEAboutData::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 TDEAboutData::version() const
298 {
299  return TQString::fromLatin1(mVersion);
300 }
301 
302 TQString
303 TDEAboutData::shortDescription() const
304 {
305  if (mShortDescription && *mShortDescription)
306  return i18n(mShortDescription);
307  else
308  return TQString::null;
309 }
310 
311 TQString
312 TDEAboutData::homepage() const
313 {
314  return TQString::fromLatin1(mHomepageAddress);
315 }
316 
317 TQString
318 TDEAboutData::bugAddress() const
319 {
320  return TQString::fromLatin1(mBugEmailAddress);
321 }
322 
323 const TQValueList<TDEAboutPerson>
324 TDEAboutData::authors() const
325 {
326  return mAuthorList;
327 }
328 
329 const TQValueList<TDEAboutPerson>
330 TDEAboutData::credits() const
331 {
332  return mCreditList;
333 }
334 
335 const TQValueList<TDEAboutTranslator>
336 TDEAboutData::translators() const
337 {
338  TQValueList<TDEAboutTranslator> 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(TDEAboutTranslator(name.stripWhiteSpace(), email.stripWhiteSpace()));
379  }
380 
381  return personList;
382 }
383 
384 TQString
385 TDEAboutData::aboutTranslationTeam()
386 {
387  return i18n("replace this with information about your translation team",
388  "<p>TDE 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 TDE internationalization "
391  "visit the <a href=\"https://wiki.trinitydesktop.org/"
392  "TDE_Weblate_Translation_Workspace\">TDE Weblate "
393  "Translation Workspace (TWTW)</a></p>"
394  );
395 }
396 
397 TQString
398 TDEAboutData::otherText() const
399 {
400  if (mOtherText && *mOtherText)
401  return i18n(mOtherText);
402  else
403  return TQString::null;
404 }
405 
406 
407 TQString
408 TDEAboutData::license() const
409 {
410  TQString result;
411  if (!copyrightStatement().isEmpty())
412  result = copyrightStatement() + "\n\n";
413 
414  TQString l;
415  TQString f;
416  switch ( mLicenseKey )
417  {
418  case License_File:
419  f = TQFile::decodeName(mLicenseText);
420  break;
421  case License_GPL_V2:
422  l = "GPL v2";
423  f = locate("data", "LICENSES/GPL_V2");
424  break;
425  case License_LGPL_V2:
426  l = "LGPL v2";
427  f = locate("data", "LICENSES/LGPL_V2");
428  break;
429  case License_GPL_V3:
430  l = "GPL v3";
431  f = locate("data", "LICENSES/GPL_V3");
432  break;
433  case License_LGPL_V3:
434  l = "LGPL v3";
435  f = locate("data", "LICENSES/LGPL_V3");
436  break;
437  case License_BSD:
438  l = "BSD License";
439  f = locate("data", "LICENSES/BSD");
440  break;
441  case License_Artistic:
442  l = "Artistic License";
443  f = locate("data", "LICENSES/ARTISTIC");
444  break;
445  case License_QPL_V1_0:
446  l = "QPL v1.0";
447  f = locate("data", "LICENSES/QPL_V1.0");
448  break;
449  case License_MIT:
450  l = "MIT";
451  f = locate("data", "LICENSES/MIT");
452  break;
453  case License_Custom:
454  if (mLicenseText && *mLicenseText)
455  return( i18n(mLicenseText) );
456  // fall through
457  default:
458  result += i18n("No licensing terms for this program have been specified.\n"
459  "Please check the documentation or the source for any\n"
460  "licensing terms.\n");
461  return result;
462  }
463 
464  if (!l.isEmpty())
465  result += i18n("This program is distributed under the terms of the %1.").arg( l );
466 
467  if (!f.isEmpty())
468  {
469  TQFile file(f);
470  if (file.open(IO_ReadOnly))
471  {
472  result += '\n';
473  result += '\n';
474  TQTextStream str(&file);
475  result += str.read();
476  }
477  }
478 
479  return result;
480 }
481 
482 TQString
483 TDEAboutData::copyrightStatement() const
484 {
485  if (mCopyrightStatement && *mCopyrightStatement)
486  return i18n(mCopyrightStatement);
487  else
488  return TQString::null;
489 }
490 
491 TQString
492 TDEAboutData::customAuthorPlainText() const
493 {
494  return d->customAuthorPlainText;
495 }
496 
497 TQString
498 TDEAboutData::customAuthorRichText() const
499 {
500  return d->customAuthorRichText;
501 }
502 
503 bool
504 TDEAboutData::customAuthorTextEnabled() const
505 {
506  return d->customAuthorTextEnabled;
507 }
508 
509 void
510 TDEAboutData::setCustomAuthorText(const TQString &plainText, const TQString &richText)
511 {
512  d->customAuthorPlainText = plainText;
513  d->customAuthorRichText = richText;
514 
515  d->customAuthorTextEnabled = true;
516 }
517 
518 void
519 TDEAboutData::unsetCustomAuthorText()
520 {
521  d->customAuthorPlainText = TQString::null;
522  d->customAuthorRichText = TQString::null;
523 
524  d->customAuthorTextEnabled = false;
525 }
526 
TDEAboutData::setProductName
void setProductName(const char *name)
Defines the product name wich will be used in the KBugReport dialog.
Definition: tdeaboutdata.cpp:231
TDEAboutData::authors
const TQValueList< TDEAboutPerson > authors() const
Returns a list of authors.
Definition: tdeaboutdata.cpp:324
TDEAboutData::setProgramName
void setProgramName(const char *programName)
Defines the displayable program name string.
Definition: tdeaboutdata.cpp:182
TDEAboutData::setShortDescription
void setShortDescription(const char *shortDescription)
Defines a short description of what the program does.
Definition: tdeaboutdata.cpp:195
TDEAboutData::addAuthor
void addAuthor(const char *name, const char *task=0, const char *emailAddress=0, const char *webAddress=0)
Defines an author.
Definition: tdeaboutdata.cpp:141
TDEAboutData::setLicense
void setLicense(LicenseKey licenseKey)
Defines the license identifier.
Definition: tdeaboutdata.cpp:201
TDEAboutData::shortDescription
TQString shortDescription() const
Returns a short, translated description.
Definition: tdeaboutdata.cpp:303
TDEAboutData::license
TQString license() const
Returns the license.
Definition: tdeaboutdata.cpp:408
TDEAboutData::setProgramLogo
void setProgramLogo(const TQImage &image)
Defines the program logo.
Definition: tdeaboutdata.cpp:288
TDEAboutData::copyrightStatement
TQString copyrightStatement() const
Returns the copyright statement.
Definition: tdeaboutdata.cpp:483
TDEAboutData::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: tdeaboutdata.cpp:148
TDEAboutData::customAuthorPlainText
TQString customAuthorPlainText() const
Returns the plain text displayed around the list of authors instead of the default message telling us...
Definition: tdeaboutdata.cpp:492
TDEAboutData::setOtherText
void setOtherText(const char *otherText)
Defines the additional text to show in the about dialog.
Definition: tdeaboutdata.cpp:213
TDEAboutData::unsetCustomAuthorText
void unsetCustomAuthorText()
Clears any custom text displayed around the list of authors and falls back to the default message tel...
Definition: tdeaboutdata.cpp:519
TDEAboutData::aboutTranslationTeam
static TQString aboutTranslationTeam()
Returns a message about the translation team.
Definition: tdeaboutdata.cpp:385
TDEAboutData::setTranslator
void setTranslator(const char *name, const char *emailAddress)
Sets the name of the translator of the gui.
Definition: tdeaboutdata.cpp:155
TDEAboutData::setLicenseText
void setLicenseText(const char *license)
Defines a license text.
Definition: tdeaboutdata.cpp:162
TDEAboutData::bugAddress
TQString bugAddress() const
Returns the email address for bugs.
Definition: tdeaboutdata.cpp:318
TDEAboutData::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: tdeaboutdata.cpp:510
TDEAboutData::setCopyrightStatement
void setCopyrightStatement(const char *copyrightStatement)
Defines the copyright statement to show when displaying the license.
Definition: tdeaboutdata.cpp:207
TDEAboutData::programLogo
TQImage programLogo() const
Returns the program logo image.
Definition: tdeaboutdata.cpp:282
TDEAboutData::setVersion
void setVersion(const char *version)
Defines the program version string.
Definition: tdeaboutdata.cpp:189
TDEAboutData::setHomepage
void setHomepage(const char *homepage)
Defines the program homepage.
Definition: tdeaboutdata.cpp:219
TDEAboutData::credits
const TQValueList< TDEAboutPerson > credits() const
Returns a list of persons who contributed.
Definition: tdeaboutdata.cpp:330
TDEAboutData::LicenseKey
LicenseKey
Descibes the license of the software.
Definition: tdeaboutdata.h:189
TDEAboutData::homepage
TQString homepage() const
Returns the application homepage.
Definition: tdeaboutdata.cpp:312
TDEAboutData::customAuthorRichText
TQString customAuthorRichText() const
Returns the rich text displayed around the list of authors instead of the default message telling use...
Definition: tdeaboutdata.cpp:498
TDEAboutData::version
TQString version() const
Returns the program's version.
Definition: tdeaboutdata.cpp:297
TDEAboutData::appName
const char * appName() const
Returns the application's internal name.
Definition: tdeaboutdata.cpp:237
TDEAboutData::translators
const TQValueList< TDEAboutTranslator > translators() const
Returns a list of translators.
Definition: tdeaboutdata.cpp:336
TDEAboutData::TDEAboutData
TDEAboutData(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: tdeaboutdata.cpp:101
TDEAboutData::productName
const char * productName() const
Returns the application's product name, which will be used in KBugReport dialog.
Definition: tdeaboutdata.cpp:243
TDEAboutData::setAppName
void setAppName(const char *appName)
Defines the program name used internally.
Definition: tdeaboutdata.cpp:176
TDEAboutData::programName
TQString programName() const
Returns the translated program name.
Definition: tdeaboutdata.cpp:252
TDEAboutData::otherText
TQString otherText() const
Returns a translated, free form text.
Definition: tdeaboutdata.cpp:398
TDEAboutData::setBugAddress
void setBugAddress(const char *bugAddress)
Defines the address where bug reports should be sent.
Definition: tdeaboutdata.cpp:225
TDEAboutData::customAuthorTextEnabled
bool customAuthorTextEnabled() const
Returns whether custom text should be displayed around the list of authors.
Definition: tdeaboutdata.cpp:504
TDEAboutData::setLicenseTextFile
void setLicenseTextFile(const TQString &file)
Defines a license text.
Definition: tdeaboutdata.cpp:169
TDEAboutPerson
This structure is used to store information about a person or developer.
Definition: tdeaboutdata.h:55
TDEAboutPerson::webAddress
TQString webAddress() const
The home page or a relevant link.
Definition: tdeaboutdata.cpp:51
TDEAboutPerson::name
TQString name() const
The person's name.
Definition: tdeaboutdata.cpp:29
TDEAboutPerson::task
TQString task() const
The person's task.
Definition: tdeaboutdata.cpp:35
TDEAboutPerson::emailAddress
TQString emailAddress() const
The person's email address.
Definition: tdeaboutdata.cpp:44
TDEAboutTranslator
This structure is used to store information about a translator.
Definition: tdeaboutdata.h:135
TDEAboutTranslator::emailAddress
TQString emailAddress() const
The translator's email.
Definition: tdeaboutdata.cpp:69
TDEAboutTranslator::TDEAboutTranslator
TDEAboutTranslator(const TQString &name=TQString::null, const TQString &emailAddress=TQString::null)
Convenience constructor.
Definition: tdeaboutdata.cpp:57
TDEAboutTranslator::name
TQString name() const
The translator's name.
Definition: tdeaboutdata.cpp:64
TDEGlobal::locale
static TDELocale * locale()
Returns the global locale object.
Definition: tdeglobal.cpp:108

tdecore

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

tdecore

Skip menu "tdecore"
  • arts
  • dcop
  • dnssd
  • interfaces
  •   kspeech
  •     interface
  •     library
  •   tdetexteditor
  • kate
  • kded
  • kdoctools
  • kimgio
  • kjs
  • libtdemid
  • libtdescreensaver
  • tdeabc
  • tdecmshell
  • tdecore
  • tdefx
  • tdehtml
  • tdeinit
  • tdeio
  •   bookmarks
  •   httpfilter
  •   kpasswdserver
  •   kssl
  •   tdefile
  •   tdeio
  •   tdeioexec
  • tdeioslave
  •   http
  • tdemdi
  •   tdemdi
  • tdenewstuff
  • tdeparts
  • tdeprint
  • tderandr
  • tderesources
  • tdespell2
  • tdesu
  • tdeui
  • tdeunittest
  • tdeutils
  • tdewallet
Generated for tdecore by doxygen 1.9.1
This website is maintained by Timothy Pearson.