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