Rev 16739 | Rev 16782 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
12529 | cbradney | 1 | /* |
4430 | cbradney | 2 | For general Scribus (>=1.3.2) copyright and licensing information please refer |
3 | to the COPYING file provided with the program. Following this notice may exist |
||
4 | a copyright and/or license notice that predates the release of Scribus 1.3.2 |
||
5 | for which a new license (GPL+exception) is in place. |
||
6 | */ |
||
1641 | cbradney | 7 | /*************************************************************************** |
12531 | cbradney | 8 | * * |
9 | * This program is free software; you can redistribute it and/or modify * |
||
10 | * it under the terms of the GNU General Public License as published by * |
||
11 | * the Free Software Foundation; either version 2 of the License, or * |
||
12 | * (at your option) any later version. * |
||
13 | * * |
||
14 | ***************************************************************************/ |
||
15 | #include <iostream> // only for debugging |
||
16 | |||
11800 | cbradney | 17 | #include <QFile> |
12574 | jghali | 18 | #include <QLabel> |
9338 | fschmid | 19 | #include <QPixmap> |
12574 | jghali | 20 | #include <QPushButton> |
21 | #include <QShowEvent> |
||
22 | #include <QString> |
||
9338 | fschmid | 23 | #include <QTabWidget> |
11800 | cbradney | 24 | #include <QTextStream> |
12574 | jghali | 25 | #include <QToolTip> |
9338 | fschmid | 26 | #include <QWidget> |
1641 | cbradney | 27 | |
12570 | cbradney | 28 | #include "about.h" |
5364 | cbradney | 29 | #include "commonstrings.h" |
2688 | craig | 30 | #include "scconfig.h" |
11800 | cbradney | 31 | #include "scpaths.h" |
10108 | cbradney | 32 | #include "sctextbrowser.h" |
9898 | avox | 33 | |
34 | #ifdef HAVE_CAIRO |
||
35 | #include <cairo.h> |
||
36 | #endif |
||
37 | |||
10212 | cbradney | 38 | #include "util_ghostscript.h" |
10200 | cbradney | 39 | #include "util_icon.h" |
5923 | cbradney | 40 | #include "upgradechecker.h" |
2011 | cbradney | 41 | #include "langmgr.h" |
42 | |||
12531 | cbradney | 43 | |
44 | /* |
||
45 | * The content for the About dialog is mostly built from the files in |
||
46 | * // SCRIBUS_INSTALL_DIRECTORY/share/doc/scribus-1.3.5svn/ |
||
47 | * |
||
48 | * The format of the files should follow this pattern: |
||
49 | * - AUTHOR |
||
50 | * Tr(Title) |
||
51 | * first_name name email_address |
||
52 | * first_name name email_address |
||
53 | * |
||
54 | * Tr(Title) |
||
55 | * ... |
||
56 | * |
||
57 | * - TRANSLATION |
||
58 | * Tr(Title) |
||
59 | * |
||
60 | * Language(language_code) |
||
61 | * first_name name (email_address) |
||
62 | * |
||
63 | * Language(language_code) |
||
64 | * first_name name (email_address) |
||
65 | * |
||
66 | * |
||
67 | * Tr(Title) |
||
68 | * ... |
||
69 | * - LINKS |
||
70 | * Tr(Title) |
||
71 | * url |
||
72 | * |
||
73 | * |
||
74 | * Tr(Title) |
||
75 | * ... |
||
76 | * |
||
77 | * |
||
78 | * Text which has to be translated has to be added to the local tr...Title() |
||
79 | * methods, otherwise in won't be added to the list of translatable strings |
||
80 | * |
||
81 | * a.l.e |
||
82 | */ |
||
83 | |||
1641 | cbradney | 84 | /*! |
12531 | cbradney | 85 | \fn About::About( QWidget* parent, AboutMode diaMode ) |
86 | \author Franz Schmid |
||
87 | \date |
||
88 | \brief Constructor for About dialog box |
||
89 | \param parent QWidget pointer to parent window |
||
90 | \param diaMode a dialog mode. See AboutMode. |
||
91 | \retval About dialog |
||
92 | */ |
||
10913 | jghali | 93 | About::About( QWidget* parent, AboutMode diaMode ) : QDialog( parent ) |
1641 | cbradney | 94 | { |
10913 | jghali | 95 | m_mode = diaMode; |
96 | m_firstShow = true; |
||
10493 | fschmid | 97 | setWindowTitle( tr("About Scribus %1").arg(VERSION) ); |
98 | setWindowIcon(loadIcon("AppIcon.png", true)); |
||
9338 | fschmid | 99 | setModal(true); |
100 | aboutLayout = new QVBoxLayout( this ); |
||
1641 | cbradney | 101 | aboutLayout->setSpacing( 6 ); |
102 | aboutLayout->setMargin( 10 ); |
||
10493 | fschmid | 103 | tabWidget2 = new QTabWidget( this ); |
10040 | fschmid | 104 | // tabWidget2->setMinimumSize( QSize( 438, 258 ) ); |
10493 | fschmid | 105 | tab = new QWidget( tabWidget2 ); |
9338 | fschmid | 106 | tabLayout1 = new QVBoxLayout( tab ); |
1641 | cbradney | 107 | tabLayout1->setSpacing( 6 ); |
108 | tabLayout1->setMargin( 15 ); |
||
10493 | fschmid | 109 | pixmapLabel1 = new QLabel( tab ); |
14713 | cbradney | 110 | pixmapLabel1->setPixmap(loadIcon("Splash.png", true)); |
10040 | fschmid | 111 | pixmapLabel1->setFixedSize(QSize(pixmapLabel1->pixmap()->width(), pixmapLabel1->pixmap()->height())); |
1641 | cbradney | 112 | pixmapLabel1->setAlignment(Qt::AlignCenter); |
113 | tabLayout1->addWidget( pixmapLabel1 ); |
||
10493 | fschmid | 114 | buildID = new QLabel( tab ); |
1641 | cbradney | 115 | buildID->setAlignment(Qt::AlignCenter); |
13438 | cbradney | 116 | buildID->setTextInteractionFlags(Qt::TextSelectableByMouse); |
16755 | craig | 117 | QString BUILD_DAY = "4"; |
118 | QString BUILD_MONTH = CommonStrings::august; |
||
16207 | mrdocs | 119 | QString BUILD_YEAR = "2011"; |
9697 | craig | 120 | QString BUILD_TIME = ""; |
121 | QString BUILD_TZ = ""; |
||
122 | QString BUILD_NAME = ""; |
||
3587 | avox | 123 | |
9697 | craig | 124 | // This is the old way: |
125 | QString built = tr("%1 %2 %3").arg(BUILD_DAY).arg(BUILD_MONTH).arg(BUILD_YEAR); |
||
3587 | avox | 126 | |
9697 | craig | 127 | // This is my way, only activated when envvar BUILD_NAME is set :-) AV |
128 | //#include "about_builddate.inc" |
||
129 | QString version = VERSION; |
||
130 | if (BUILD_NAME != "") |
||
131 | version += " \"" + BUILD_NAME + "\""; |
||
132 | if (BUILD_NAME == "BleedingEdge") |
||
12531 | cbradney | 133 | built = tr("%3-%2-%1 %4 %5").arg(BUILD_DAY).arg(BUILD_MONTH).arg(BUILD_YEAR).arg(BUILD_TIME).arg(BUILD_TZ); |
9697 | craig | 134 | |
3579 | avox | 135 | QString bu; |
1641 | cbradney | 136 | bu += "C"; |
137 | bu += "-"; |
||
138 | #ifdef HAVE_CUPS |
||
139 | bu += "C"; |
||
140 | #else |
||
141 | bu += "*"; |
||
142 | #endif |
||
143 | bu += "-"; |
||
144 | bu += "T"; |
||
145 | bu += "-"; |
||
146 | #ifdef HAVE_FONTCONFIG |
||
147 | bu += "F"; |
||
148 | #else |
||
149 | bu += "*"; |
||
150 | #endif |
||
3113 | fschmid | 151 | bu += "-"; |
152 | #ifdef HAVE_CAIRO |
||
153 | bu += "C"; |
||
9898 | avox | 154 | bu += cairo_version_string(); |
3113 | fschmid | 155 | #else |
9319 | fschmid | 156 | bu += "Q"; |
3113 | fschmid | 157 | #endif |
1641 | cbradney | 158 | |
3587 | avox | 159 | // Some more information if we are not on a 32bit little endian Unix machine |
160 | #if defined(Q_OS_WIN) |
||
161 | bu += "-Windows"; |
||
162 | #elif defined(Q_OS_MAC) |
||
163 | bu += "-Mac/"; |
||
164 | # if defined(Q_WS_MACX) |
||
165 | bu += "Aqua"; |
||
166 | # elif define(Q_WS_X11) |
||
167 | bu += "X11"; |
||
168 | # else |
||
169 | bu += "?"; |
||
170 | # endif |
||
9898 | avox | 171 | #elif defined(Q_OS_DARWIN) |
172 | // dunno if anyone uses this... |
||
173 | bu += "-Darwin"; |
||
174 | #endif |
||
10501 | cbradney | 175 | if (QSysInfo::WordSize != 32) |
10493 | fschmid | 176 | bu += QString("-%1bit").arg(QSysInfo::WordSize); |
177 | #if Q_BYTE_ORDER == Q_BIG_ENDIAN |
||
10501 | cbradney | 178 | if (QSysInfo::ByteOrder==QSysInfo::BigEndian) |
3587 | avox | 179 | bu += "-Big"; |
10493 | fschmid | 180 | #endif |
2840 | craig | 181 | QString gsver(getGSVersion()); |
12574 | jghali | 182 | if (!gsver.isEmpty()) |
3583 | cbradney | 183 | gsver = tr("Using Ghostscript version %1").arg(gsver); |
2840 | craig | 184 | else |
3583 | cbradney | 185 | gsver = tr("No Ghostscript version available"); |
9770 | fschmid | 186 | buildID->setText( tr("<p align=\"center\"><b>%1 %2</b></p><p align=\"center\">%3<br>%4 %5<br>%6</p>").arg( tr("Scribus Version")).arg(version).arg(built).arg( tr("Build ID:")).arg(bu).arg(gsver)); |
9755 | fschmid | 187 | tabLayout1->addWidget( buildID, 0, Qt::AlignHCenter ); |
9338 | fschmid | 188 | tabWidget2->addTab( tab, tr( "&About" ) ); |
10493 | fschmid | 189 | tab_2 = new QWidget( tabWidget2 ); |
9338 | fschmid | 190 | tabLayout = new QHBoxLayout( tab_2 ); |
1641 | cbradney | 191 | tabLayout->setSpacing( 6 ); |
192 | tabLayout->setMargin( 10 ); |
||
4363 | mrdocs | 193 | |
2618 | cbradney | 194 | |
12574 | jghali | 195 | /*! AUTHORS tab */ |
196 | // /usr/local/scribus14/share/doc/scribus-1.3.5svn/AUTHORS |
||
12531 | cbradney | 197 | textView1 = new ScTextBrowser( tab_2 ); |
12574 | jghali | 198 | textView1->setText(About::parseAuthorFile(ScPaths::instance().docDir() + "AUTHORS")); |
2916 | mrdocs | 199 | |
1641 | cbradney | 200 | tabLayout->addWidget( textView1 ); |
9338 | fschmid | 201 | tabWidget2->addTab( tab_2, tr( "A&uthors" ) ); |
10493 | fschmid | 202 | tab_3 = new QWidget( tabWidget2 ); |
9338 | fschmid | 203 | tabLayout_2 = new QHBoxLayout( tab_3 ); |
1641 | cbradney | 204 | tabLayout_2->setSpacing( 6 ); |
205 | tabLayout_2->setMargin( 10 ); |
||
10108 | cbradney | 206 | textView2 = new ScTextBrowser( tab_3); |
12787 | pierre | 207 | // LanguageManager langmgr; |
208 | // langmgr.init(false); |
||
12531 | cbradney | 209 | |
12574 | jghali | 210 | /*! TRANSLATION tab */ |
211 | // /usr/local/scribus14/share/doc/scribus-1.3.5svn/TRANSLATION |
||
212 | textView2->setText(About::parseTranslationFile(ScPaths::instance().docDir() + "TRANSLATION")); |
||
12531 | cbradney | 213 | |
12574 | jghali | 214 | tabLayout_2->addWidget( textView2 ); |
9338 | fschmid | 215 | tabWidget2->addTab( tab_3, tr( "&Translations" ) ); |
1641 | cbradney | 216 | |
12531 | cbradney | 217 | /*! ONLINE tab (03/04/2004 petr vanek) */ |
12574 | jghali | 218 | // /usr/local/scribus14/share/doc/scribus-1.3.5svn/LINKS |
10493 | fschmid | 219 | tab_4 = new QWidget( tabWidget2 ); |
10108 | cbradney | 220 | textView4 = new ScTextBrowser( tab_4 ); |
12574 | jghali | 221 | textView4->setText(About::parseLinksFile(ScPaths::instance().docDir() + "LINKS")); |
9338 | fschmid | 222 | tabLayout_4 = new QHBoxLayout( tab_4 ); |
1641 | cbradney | 223 | tabLayout_4->setSpacing( 6 ); |
224 | tabLayout_4->setMargin( 10 ); |
||
225 | tabLayout_4->addWidget( textView4 ); |
||
9338 | fschmid | 226 | tabWidget2->addTab( tab_4, tr( "&Online" ) ); |
12531 | cbradney | 227 | /*! UPDATE tab */ |
10493 | fschmid | 228 | tab_5 = new QWidget( tabWidget2 ); |
229 | tabWidget2->addTab( tab_5, tr( "&Updates" ) ); |
||
9338 | fschmid | 230 | updateLayout = new QVBoxLayout( tab_5 ); |
5923 | cbradney | 231 | updateLayout->setSpacing( 6 ); |
232 | updateLayout->setMargin( 10 ); |
||
10926 | cbradney | 233 | checkForUpdateButton = new QPushButton( tr( "Check for Updates" ), tab_5 ); |
10108 | cbradney | 234 | textView5 = new ScTextBrowser( tab_5); |
5923 | cbradney | 235 | updateLayout->addWidget( checkForUpdateButton ); |
236 | updateLayout->addWidget( textView5 ); |
||
11800 | cbradney | 237 | |
12531 | cbradney | 238 | /*! LICENCE tab */ |
11800 | cbradney | 239 | tab_Licence = new QWidget( tabWidget2 ); |
240 | tabWidget2->addTab( tab_Licence, tr( "&Licence" ) ); |
||
241 | licenceLayout = new QVBoxLayout( tab_Licence ); |
||
242 | licenceLayout->setSpacing( 6 ); |
||
243 | licenceLayout->setMargin( 10 ); |
||
244 | textViewLicence = new ScTextBrowser( tab_Licence); |
||
245 | licenceLayout->addWidget( textViewLicence ); |
||
246 | |||
247 | QFile licenceFile(ScPaths::instance().docDir() + "/COPYING"); |
||
12531 | cbradney | 248 | if (!licenceFile.open(QIODevice::ReadOnly | QIODevice::Text)) |
249 | textViewLicence->setText( tr("Unable to open licence file. Please check your install directory or the Scribus website for licencing information.") ); |
||
250 | else |
||
11800 | cbradney | 251 | { |
252 | QTextStream inTS(&licenceFile); |
||
253 | QString licenceText = inTS.readAll(); |
||
254 | textViewLicence->setText(licenceText); |
||
12531 | cbradney | 255 | } |
11800 | cbradney | 256 | |
257 | //Add tab widget to about window |
||
1641 | cbradney | 258 | aboutLayout->addWidget( tabWidget2 ); |
7368 | subik | 259 | |
9338 | fschmid | 260 | layout2 = new QHBoxLayout; |
1641 | cbradney | 261 | layout2->setSpacing( 6 ); |
262 | layout2->setMargin( 0 ); |
||
263 | QSpacerItem* spacer = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum ); |
||
264 | layout2->addItem( spacer ); |
||
10493 | fschmid | 265 | okButton = new QPushButton( tr( "&Close" ), this ); |
1641 | cbradney | 266 | okButton->setDefault( true ); |
267 | layout2->addWidget( okButton ); |
||
268 | aboutLayout->addLayout( layout2 ); |
||
269 | setMaximumSize(sizeHint()); |
||
270 | |||
4363 | mrdocs | 271 | |
12574 | jghali | 272 | //tooltips |
10397 | cbradney | 273 | buildID->setToolTip( "<qt>" + tr( "This panel shows the version, build date and compiled in library support in Scribus.")+"<br>" |
12531 | cbradney | 274 | + tr("The C-C-T-F equates to C=littlecms C=CUPS T=TIFF support F=Fontconfig support.Last Letter is the renderer C=cairo or Q=Qt")+"<br>" |
275 | + tr("Missing library support is indicated by a *. This also indicates the version of Ghostscript which Scribus has detected.")+"<br>" |
||
276 | + tr("The Windows version does not use fontconfig or CUPS libraries." ) + "</qt>" ); |
||
10397 | cbradney | 277 | checkForUpdateButton->setToolTip( "<qt>" + tr( "Check for updates to Scribus. No data from your machine will be transferred off it." ) + "</qt>" ); |
5220 | mrdocs | 278 | // signals and slots connections |
279 | connect( okButton, SIGNAL( clicked() ), this, SLOT( accept() ) ); |
||
5923 | cbradney | 280 | connect( checkForUpdateButton, SIGNAL( clicked() ), this, SLOT( runUpdateCheck() ) ); |
5273 | mrdocs | 281 | } |
5923 | cbradney | 282 | |
12531 | cbradney | 283 | |
10913 | jghali | 284 | void About::showEvent (QShowEvent * event) |
285 | { |
||
286 | if (m_mode == About::CheckUpdates && m_firstShow) |
||
287 | tabWidget2->setCurrentIndex(4); |
||
288 | QDialog::showEvent(event); |
||
289 | } |
||
290 | |||
12531 | cbradney | 291 | |
292 | |||
293 | QString About::trAuthorTitle(QString title) |
||
294 | { |
||
295 | QString result; |
||
296 | if ( title == "Development Team:" ) |
||
297 | result = tr("Development Team:"); |
||
298 | else if ( title == "Mac OS® X Aqua Port:" ) |
||
299 | result = tr("Mac OS® X Aqua Port:"); |
||
300 | else if ( title == "OS/2®/eComStation™ Port:" ) |
||
301 | result = tr("OS/2®/eComStation™ Port:"); |
||
302 | else if ( title == "Windows® Port:" ) |
||
303 | result = tr("Windows® Port:"); |
||
304 | else if ( title == "Contributions from:" ) |
||
305 | result = tr("Contributions from:"); |
||
306 | else if ( title == "Official Documentation:" ) |
||
307 | result = tr("Official Documentation:"); |
||
308 | else if ( title == "Doc Translators:" ) |
||
309 | result = tr("Doc Translators:"); |
||
310 | else if ( title == "Other Documentation:" ) |
||
311 | result = tr("Other Documentation:"); |
||
312 | else if ( title == "Webmasters:" ) |
||
313 | result = tr("Webmasters:"); |
||
314 | else if ( title == "Splash Screen:" ) |
||
315 | result = tr("Splash Screen:"); |
||
316 | else if ( title == "Tango Project Icons:" ) |
||
317 | result = tr("Tango Project Icons:"); |
||
318 | else |
||
12967 | fschmid | 319 | { |
12531 | cbradney | 320 | std::cout << "please add the untranslated title \"" << qPrintable(title) << "\" to About::trAuthorTitle()" << std::endl; |
321 | result = title; |
||
12967 | fschmid | 322 | } |
12531 | cbradney | 323 | return result; |
324 | } |
||
325 | QString About::trTranslationTitle(QString title) |
||
326 | { |
||
327 | QString result; |
||
328 | if ( title == "Official Translations and Translators:" ) |
||
329 | result = tr("Official Translations and Translators:"); |
||
330 | else if ( title == "Previous Translation Contributors:" ) |
||
331 | result = tr("Previous Translation Contributors:"); |
||
332 | else |
||
12967 | fschmid | 333 | { |
16755 | craig | 334 | std::cout << "please add the untranslated title \"" << qPrintable(title) << "\" to About::trTranslationTitle()" << std::endl; |
12531 | cbradney | 335 | result = title; |
12967 | fschmid | 336 | } |
12531 | cbradney | 337 | return result; |
338 | } |
||
339 | |||
340 | |||
341 | QString About::trLinksTitle(QString title) |
||
342 | { |
||
343 | QString result; |
||
344 | if ( title == "Homepage" ) |
||
345 | result = tr("Homepage"); |
||
346 | else if ( title == "Online Reference" ) |
||
347 | result = tr("Online Reference"); |
||
348 | else if ( title == "Wiki" ) |
||
349 | result = tr("Wiki"); |
||
350 | else if ( title == "Bugs and Feature Requests" ) |
||
351 | result = tr("Bugs and Feature Requests"); |
||
352 | else if ( title == "Developer Blog" ) |
||
353 | result = tr("Developer Blog"); |
||
354 | else if ( title == "Mailing List" ) |
||
355 | result = tr("Mailing List"); |
||
356 | else |
||
12967 | fschmid | 357 | { |
12531 | cbradney | 358 | std::cout << "please add the untranslated title \"" << qPrintable(title) << "\" to About::trLinksTitle()" << std::endl; |
359 | result = title; |
||
12967 | fschmid | 360 | } |
12531 | cbradney | 361 | return result; |
362 | } |
||
363 | |||
364 | |||
365 | /*! |
||
366 | * parse a text file and return an author list in an html table: |
||
367 | * left the names and right the contact address |
||
368 | * the html table can be "split" in sections |
||
369 | * @param QString fileName the file to be parsed |
||
370 | * @return QString the html table |
||
371 | */ |
||
372 | QString About::parseAuthorFile(QString fileName) |
||
373 | { |
||
374 | QString result; |
||
375 | QString file; |
||
376 | QFile authorsFile(fileName); |
||
377 | if (authorsFile.open(QIODevice::ReadOnly | QIODevice::Text)) |
||
378 | { |
||
379 | QTextStream inTS(&authorsFile); |
||
15266 | jghali | 380 | inTS.setCodec("UTF-8"); |
381 | inTS.setAutoDetectUnicode(true); |
||
12531 | cbradney | 382 | QString lineTS; |
383 | QStringList fieldTS; |
||
384 | QString name; |
||
385 | QString contact; |
||
386 | bool isTitle = true; |
||
387 | bool startText = false; |
||
388 | bool startTitle = false; |
||
389 | result = "<table>"; |
||
390 | while (!inTS.atEnd()) |
||
391 | { |
||
392 | lineTS = inTS.readLine(); |
||
393 | // convert (r) "�" to ®, "�" to ™ |
||
394 | // lineTS = QString::fromUtf8(lineTS); |
||
395 | lineTS.replace("<", "<"); |
||
396 | lineTS.replace(">", ">"); |
||
397 | lineTS.replace("�", "®"); |
||
398 | lineTS.replace("�", "™"); |
||
399 | name = ""; |
||
400 | contact = ""; |
||
401 | if (!lineTS.isEmpty()) |
||
402 | { |
||
403 | if (isTitle) |
||
404 | { |
||
405 | startTitle = false; |
||
406 | result += "<tr><td><b>"+About::trAuthorTitle(lineTS)+"</b></td><td></td></tr>"; |
||
407 | |||
408 | } // if is title |
||
409 | else |
||
410 | { |
||
411 | startText = false; |
||
412 | fieldTS = lineTS.split(" "); |
||
413 | contact = (fieldTS.isEmpty() ? "" : fieldTS.takeLast()); |
||
414 | name = (fieldTS.isEmpty() ? "" : fieldTS.join(" ")); |
||
415 | result += "<tr><td>"+name+"</td><td>"+(contact == "@" ? "" : contact)+"</td></tr>"; |
||
416 | } // else is title |
||
417 | } // if is empty line |
||
418 | else |
||
419 | { |
||
420 | // empty lines switch between title and text |
||
421 | if (!startText && !startTitle) |
||
422 | { |
||
423 | isTitle = !isTitle; |
||
424 | if (isTitle) |
||
425 | { |
||
426 | result += "<tr><td></td><td></td></tr>"; |
||
427 | startTitle = true; |
||
428 | } |
||
429 | else |
||
430 | { |
||
431 | startText = true; |
||
432 | } |
||
433 | } |
||
434 | } // else is empty line |
||
435 | } // while ! atEnd |
||
436 | result += "<table>"; |
||
437 | } // if file found |
||
438 | else |
||
439 | { |
||
440 | if (!fileName.isEmpty()) |
||
441 | { |
||
442 | QStringList field = fileName.split("/"); |
||
443 | if (!field.isEmpty()) |
||
444 | { |
||
445 | file = field.takeLast(); |
||
446 | } |
||
447 | } |
||
448 | result = tr("Unable to open %1 file. Please check your install directory or the Scribus website for %1 information.").arg(file); |
||
449 | result = ""; |
||
450 | } // else file found |
||
451 | return result; |
||
452 | } // parseTextFile() |
||
453 | |||
454 | /*! |
||
455 | * parse a text file and return an author list in an html table: |
||
456 | * left the names and right the contact address |
||
457 | * the html table can be "split" in sections |
||
458 | * @param QString fileName the file to be parsed |
||
459 | * @return QString the html table |
||
460 | */ |
||
461 | QString About::parseTranslationFile(QString fileName) |
||
462 | { |
||
463 | QString result; |
||
464 | QString file; |
||
465 | QFile translationFile(fileName); |
||
466 | if (translationFile.open(QIODevice::ReadOnly | QIODevice::Text)) |
||
467 | { |
||
468 | QTextStream inTS(&translationFile); |
||
15266 | jghali | 469 | inTS.setCodec("UTF-8"); |
470 | inTS.setAutoDetectUnicode(true); |
||
12531 | cbradney | 471 | QString lineTS; |
472 | QStringList fieldTS; |
||
473 | QString code; |
||
474 | QString name; |
||
475 | QString contact; |
||
12787 | pierre | 476 | // LanguageManager langmgr; |
477 | // langmgr.init(false); |
||
12531 | cbradney | 478 | bool isSectionTitle = true; |
479 | bool isTitle = false; |
||
480 | bool startText = false; |
||
481 | bool startTitle = false; |
||
482 | result = "<table>"; |
||
483 | while (!inTS.atEnd()) |
||
484 | { |
||
485 | lineTS = inTS.readLine(); |
||
486 | lineTS.replace("<", "<"); |
||
487 | lineTS.replace(">", ">"); |
||
488 | name = ""; |
||
489 | contact = ""; |
||
490 | if (!lineTS.isEmpty()) |
||
491 | { |
||
492 | if (isSectionTitle) |
||
493 | { |
||
494 | result += "<tr><td><b><i>"+About::trTranslationTitle(lineTS)+"</i></b></td><td></td></tr>"; |
||
495 | isSectionTitle = false; |
||
496 | isTitle = false; |
||
497 | startTitle = false; |
||
498 | } |
||
499 | else if (isTitle) |
||
500 | { |
||
501 | startTitle = false; |
||
502 | fieldTS = lineTS.split(" "); |
||
503 | code = (fieldTS.isEmpty() ? "" : fieldTS.takeLast()); |
||
504 | if (!code.isEmpty()) |
||
505 | { |
||
506 | code.replace("(", ""); |
||
507 | code.replace(")", ""); |
||
12967 | fschmid | 508 | code = LanguageManager::instance()->getLangFromAbbrev(code); |
12531 | cbradney | 509 | } |
510 | result += "<tr><td><b>"+code+"</b></td><td></td></tr>"; |
||
511 | isTitle = false; |
||
512 | |||
513 | } // if is title |
||
514 | else |
||
515 | { |
||
516 | startText = false; |
||
517 | fieldTS = lineTS.split(" "); |
||
518 | contact = (fieldTS.isEmpty() ? "" : fieldTS.takeLast()); |
||
519 | contact.replace("(", ""); |
||
520 | contact.replace(")", ""); |
||
521 | name = (fieldTS.isEmpty() ? "" : fieldTS.join(" ")); |
||
522 | result += "<tr><td>"+name+"</td><td>"+(contact == "@" ? "" : contact)+"</td></tr>"; |
||
523 | } // else is title |
||
524 | } // if is empty line |
||
525 | else |
||
526 | { |
||
527 | // empty lines switch between title and text |
||
528 | if (!startText && !startTitle) |
||
529 | { |
||
530 | isTitle = !isTitle; |
||
531 | if (isTitle) |
||
532 | { |
||
533 | result += "<tr><td></td><td></td></tr>"; |
||
534 | startTitle = true; |
||
535 | } |
||
536 | else |
||
537 | { |
||
538 | startText = true; |
||
539 | } |
||
540 | // |
||
541 | // multiple empty lines start a section instead of marking a title |
||
542 | } |
||
543 | else if (startTitle) |
||
544 | { |
||
545 | isTitle = false; |
||
546 | isSectionTitle = true; |
||
547 | } |
||
548 | } // else is empty line |
||
549 | } // while ! atEnd |
||
550 | result += "<table>"; |
||
551 | } // if file found |
||
552 | else |
||
553 | { |
||
554 | if (!fileName.isEmpty()) |
||
555 | { |
||
556 | QStringList field = fileName.split("/"); |
||
557 | if (!field.isEmpty()) |
||
558 | { |
||
559 | file = field.takeLast(); |
||
560 | } |
||
561 | } |
||
562 | result = tr("Unable to open %1 file. Please check your install directory or the Scribus website for %1 information.").arg(file); |
||
563 | result = ""; |
||
564 | } // else file found |
||
565 | return result; |
||
566 | } // parseTranslationFile() |
||
567 | |||
568 | /*! |
||
569 | * parse a text file and return a links list in html format: |
||
570 | * left the names and right the contact address |
||
571 | * the html table can be "split" in sections |
||
572 | * @param QString fileName the file to be parsed |
||
573 | * @return QString the html table |
||
574 | */ |
||
575 | QString About::parseLinksFile(QString fileName) |
||
576 | { |
||
577 | QString result; |
||
578 | QString file; |
||
579 | QFile linksFile(fileName); |
||
580 | if (linksFile.open(QIODevice::ReadOnly | QIODevice::Text)) |
||
581 | { |
||
582 | QTextStream inTS(&linksFile); |
||
583 | inTS.setCodec("UTF-8"); |
||
15266 | jghali | 584 | inTS.setAutoDetectUnicode(true); |
12531 | cbradney | 585 | QString lineTS; |
586 | bool isTitle = true; |
||
587 | result = "<table>"; |
||
588 | while (!inTS.atEnd()) |
||
589 | { |
||
590 | lineTS = inTS.readLine(); |
||
591 | // convert (r) "�" to ®, "�" to ™ |
||
592 | // lineTS = QString::fromUtf8(lineTS); |
||
593 | lineTS.replace("<", "<"); |
||
594 | lineTS.replace(">", ">"); |
||
595 | lineTS.replace("�", "®"); |
||
596 | lineTS.replace("�", "™"); |
||
597 | if (!lineTS.isEmpty()) |
||
598 | { |
||
599 | if (isTitle) |
||
600 | { |
||
601 | isTitle = false; |
||
602 | result += "<tr><td><b>"+About::trLinksTitle(lineTS)+"</b></td></tr>"; |
||
603 | |||
604 | } // if is title |
||
605 | else |
||
606 | { |
||
607 | result += "<tr><td><a href=\""+lineTS+"\">"+lineTS+"</a></td></tr>"; |
||
608 | } // else is title |
||
609 | } // if is empty line |
||
610 | else |
||
611 | { |
||
612 | // empty lines switch to title (one line) |
||
613 | result += "<tr><td></td></tr>"; |
||
614 | isTitle = true; |
||
615 | } // else is empty line |
||
616 | } // while ! atEnd |
||
617 | result += "<table>"; |
||
618 | } // if file found |
||
619 | else |
||
620 | { |
||
621 | if (!fileName.isEmpty()) |
||
622 | { |
||
623 | QStringList field = fileName.split("/"); |
||
624 | if (!field.isEmpty()) |
||
625 | { |
||
626 | file = field.takeLast(); |
||
627 | } |
||
628 | } |
||
629 | result = tr("Unable to open %1 file. Please check your install directory or the Scribus website for %1 information.").arg(file); |
||
630 | result = ""; |
||
631 | } // else file found |
||
632 | return result; |
||
633 | } // parseLinksFile() |
||
634 | |||
10913 | jghali | 635 | void About::setVisible (bool visible) |
636 | { |
||
637 | QDialog::setVisible(visible); |
||
638 | if (m_firstShow && (m_mode == About::CheckUpdates) && visible) |
||
639 | { |
||
640 | m_firstShow = false; |
||
641 | runUpdateCheck(); |
||
642 | } |
||
643 | } |
||
644 | |||
5923 | cbradney | 645 | void About::runUpdateCheck() |
646 | { |
||
10926 | cbradney | 647 | textView5->clear(); |
5924 | cbradney | 648 | UpgradeCheckerGUI uc(textView5); |
10926 | cbradney | 649 | disconnect( checkForUpdateButton, SIGNAL( clicked() ), this, SLOT( runUpdateCheck() ) ); |
650 | connect(checkForUpdateButton, SIGNAL( clicked() ), &uc, SLOT( abort() )); |
||
651 | checkForUpdateButton->setText( tr("Abort Update Check") ); |
||
652 | uc.fetch(); |
||
653 | checkForUpdateButton->setText( tr("Check for Updates") ); |
||
654 | connect( checkForUpdateButton, SIGNAL( clicked() ), this, SLOT( runUpdateCheck() ) ); |
||
5923 | cbradney | 655 | } |