• 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_Custom:
450  if (mLicenseText && *mLicenseText)
451  return( i18n(mLicenseText) );
452  // fall through
453  default:
454  result += i18n("No licensing terms for this program have been specified.\n"
455  "Please check the documentation or the source for any\n"
456  "licensing terms.\n");
457  return result;
458  }
459 
460  if (!l.isEmpty())
461  result += i18n("This program is distributed under the terms of the %1.").arg( l );
462 
463  if (!f.isEmpty())
464  {
465  TQFile file(f);
466  if (file.open(IO_ReadOnly))
467  {
468  result += '\n';
469  result += '\n';
470  TQTextStream str(&file);
471  result += str.read();
472  }
473  }
474 
475  return result;
476 }
477 
478 TQString
479 TDEAboutData::copyrightStatement() const
480 {
481  if (mCopyrightStatement && *mCopyrightStatement)
482  return i18n(mCopyrightStatement);
483  else
484  return TQString::null;
485 }
486 
487 TQString
488 TDEAboutData::customAuthorPlainText() const
489 {
490  return d->customAuthorPlainText;
491 }
492 
493 TQString
494 TDEAboutData::customAuthorRichText() const
495 {
496  return d->customAuthorRichText;
497 }
498 
499 bool
500 TDEAboutData::customAuthorTextEnabled() const
501 {
502  return d->customAuthorTextEnabled;
503 }
504 
505 void
506 TDEAboutData::setCustomAuthorText(const TQString &plainText, const TQString &richText)
507 {
508  d->customAuthorPlainText = plainText;
509  d->customAuthorRichText = richText;
510 
511  d->customAuthorTextEnabled = true;
512 }
513 
514 void
515 TDEAboutData::unsetCustomAuthorText()
516 {
517  d->customAuthorPlainText = TQString::null;
518  d->customAuthorRichText = TQString::null;
519 
520  d->customAuthorTextEnabled = false;
521 }
522 

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
  •     tdecore
  • tdeabc
  • tdecmshell
  • tdecore
  • tdefx
  • tdehtml
  • tdeinit
  • tdeio
  •   bookmarks
  •   httpfilter
  •   kpasswdserver
  •   kssl
  • tdeioslave
  •   http
  •   tdefile
  •   tdeio
  •   tdeioexec
  • 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.