• 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>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 TDEAboutData::otherText() const
397 {
398  if (mOtherText && *mOtherText)
399  return i18n(mOtherText);
400  else
401  return TQString::null;
402 }
403 
404 
405 TQString
406 TDEAboutData::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 TDEAboutData::copyrightStatement() const
478 {
479  if (mCopyrightStatement && *mCopyrightStatement)
480  return i18n(mCopyrightStatement);
481  else
482  return TQString::null;
483 }
484 
485 TQString
486 TDEAboutData::customAuthorPlainText() const
487 {
488  return d->customAuthorPlainText;
489 }
490 
491 TQString
492 TDEAboutData::customAuthorRichText() const
493 {
494  return d->customAuthorRichText;
495 }
496 
497 bool
498 TDEAboutData::customAuthorTextEnabled() const
499 {
500  return d->customAuthorTextEnabled;
501 }
502 
503 void
504 TDEAboutData::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 TDEAboutData::unsetCustomAuthorText()
514 {
515  d->customAuthorPlainText = TQString::null;
516  d->customAuthorRichText = TQString::null;
517 
518  d->customAuthorTextEnabled = false;
519 }
520 

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.8.1.2
This website is maintained by Timothy Pearson.