Rev 22476 | Rev 22796 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
22350 | jghali | 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); |
22629 | jghali | 117 | QString BUILD_DAY = "12"; |
118 | QString BUILD_MONTH = CommonStrings::august; |
||
22327 | mrdocs | 119 | QString BUILD_YEAR = "2018"; |
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); |
||
19449 | jghali | 253 | inTS.setAutoDetectUnicode(true); |
254 | inTS.setCodec("UTF-8"); |
||
11800 | cbradney | 255 | QString licenceText = inTS.readAll(); |
256 | textViewLicence->setText(licenceText); |
||
12531 | cbradney | 257 | } |
11800 | cbradney | 258 | |
259 | //Add tab widget to about window |
||
1641 | cbradney | 260 | aboutLayout->addWidget( tabWidget2 ); |
7368 | subik | 261 | |
9338 | fschmid | 262 | layout2 = new QHBoxLayout; |
1641 | cbradney | 263 | layout2->setSpacing( 6 ); |
264 | layout2->setMargin( 0 ); |
||
265 | QSpacerItem* spacer = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum ); |
||
266 | layout2->addItem( spacer ); |
||
10493 | fschmid | 267 | okButton = new QPushButton( tr( "&Close" ), this ); |
1641 | cbradney | 268 | okButton->setDefault( true ); |
269 | layout2->addWidget( okButton ); |
||
270 | aboutLayout->addLayout( layout2 ); |
||
271 | setMaximumSize(sizeHint()); |
||
272 | |||
4363 | mrdocs | 273 | |
12574 | jghali | 274 | //tooltips |
10397 | cbradney | 275 | buildID->setToolTip( "<qt>" + tr( "This panel shows the version, build date and compiled in library support in Scribus.")+"<br>" |
12531 | cbradney | 276 | + 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>" |
277 | + tr("Missing library support is indicated by a *. This also indicates the version of Ghostscript which Scribus has detected.")+"<br>" |
||
278 | + tr("The Windows version does not use fontconfig or CUPS libraries." ) + "</qt>" ); |
||
10397 | cbradney | 279 | checkForUpdateButton->setToolTip( "<qt>" + tr( "Check for updates to Scribus. No data from your machine will be transferred off it." ) + "</qt>" ); |
5220 | mrdocs | 280 | // signals and slots connections |
281 | connect( okButton, SIGNAL( clicked() ), this, SLOT( accept() ) ); |
||
5923 | cbradney | 282 | connect( checkForUpdateButton, SIGNAL( clicked() ), this, SLOT( runUpdateCheck() ) ); |
5273 | mrdocs | 283 | } |
5923 | cbradney | 284 | |
12531 | cbradney | 285 | |
10913 | jghali | 286 | void About::showEvent (QShowEvent * event) |
287 | { |
||
288 | if (m_mode == About::CheckUpdates && m_firstShow) |
||
289 | tabWidget2->setCurrentIndex(4); |
||
290 | QDialog::showEvent(event); |
||
291 | } |
||
292 | |||
12531 | cbradney | 293 | |
294 | |||
295 | QString About::trAuthorTitle(QString title) |
||
296 | { |
||
297 | QString result; |
||
298 | if ( title == "Development Team:" ) |
||
299 | result = tr("Development Team:"); |
||
300 | else if ( title == "Mac OS® X Aqua Port:" ) |
||
301 | result = tr("Mac OS® X Aqua Port:"); |
||
302 | else if ( title == "OS/2®/eComStation™ Port:" ) |
||
303 | result = tr("OS/2®/eComStation™ Port:"); |
||
304 | else if ( title == "Windows® Port:" ) |
||
305 | result = tr("Windows® Port:"); |
||
19795 | craig | 306 | else if ( title == "Haiku Port:" ) |
307 | result = tr("Haiku Port:"); |
||
12531 | cbradney | 308 | else if ( title == "Contributions from:" ) |
309 | result = tr("Contributions from:"); |
||
310 | else if ( title == "Official Documentation:" ) |
||
311 | result = tr("Official Documentation:"); |
||
312 | else if ( title == "Doc Translators:" ) |
||
313 | result = tr("Doc Translators:"); |
||
314 | else if ( title == "Other Documentation:" ) |
||
315 | result = tr("Other Documentation:"); |
||
316 | else if ( title == "Webmasters:" ) |
||
317 | result = tr("Webmasters:"); |
||
318 | else if ( title == "Splash Screen:" ) |
||
319 | result = tr("Splash Screen:"); |
||
320 | else if ( title == "Tango Project Icons:" ) |
||
321 | result = tr("Tango Project Icons:"); |
||
322 | else |
||
12967 | fschmid | 323 | { |
12531 | cbradney | 324 | std::cout << "please add the untranslated title \"" << qPrintable(title) << "\" to About::trAuthorTitle()" << std::endl; |
325 | result = title; |
||
12967 | fschmid | 326 | } |
12531 | cbradney | 327 | return result; |
328 | } |
||
329 | QString About::trTranslationTitle(QString title) |
||
330 | { |
||
331 | QString result; |
||
332 | if ( title == "Official Translations and Translators:" ) |
||
333 | result = tr("Official Translations and Translators:"); |
||
334 | else if ( title == "Previous Translation Contributors:" ) |
||
335 | result = tr("Previous Translation Contributors:"); |
||
336 | else |
||
12967 | fschmid | 337 | { |
16755 | craig | 338 | std::cout << "please add the untranslated title \"" << qPrintable(title) << "\" to About::trTranslationTitle()" << std::endl; |
12531 | cbradney | 339 | result = title; |
12967 | fschmid | 340 | } |
12531 | cbradney | 341 | return result; |
342 | } |
||
343 | |||
344 | |||
345 | QString About::trLinksTitle(QString title) |
||
346 | { |
||
347 | QString result; |
||
348 | if ( title == "Homepage" ) |
||
349 | result = tr("Homepage"); |
||
350 | else if ( title == "Online Reference" ) |
||
351 | result = tr("Online Reference"); |
||
352 | else if ( title == "Wiki" ) |
||
353 | result = tr("Wiki"); |
||
354 | else if ( title == "Bugs and Feature Requests" ) |
||
355 | result = tr("Bugs and Feature Requests"); |
||
356 | else if ( title == "Developer Blog" ) |
||
357 | result = tr("Developer Blog"); |
||
358 | else if ( title == "Mailing List" ) |
||
359 | result = tr("Mailing List"); |
||
360 | else |
||
12967 | fschmid | 361 | { |
12531 | cbradney | 362 | std::cout << "please add the untranslated title \"" << qPrintable(title) << "\" to About::trLinksTitle()" << std::endl; |
363 | result = title; |
||
12967 | fschmid | 364 | } |
12531 | cbradney | 365 | return result; |
366 | } |
||
367 | |||
368 | |||
369 | /*! |
||
370 | * parse a text file and return an author list in an html table: |
||
371 | * left the names and right the contact address |
||
372 | * the html table can be "split" in sections |
||
373 | * @param QString fileName the file to be parsed |
||
374 | * @return QString the html table |
||
375 | */ |
||
376 | QString About::parseAuthorFile(QString fileName) |
||
377 | { |
||
378 | QString result; |
||
379 | QString file; |
||
380 | QFile authorsFile(fileName); |
||
381 | if (authorsFile.open(QIODevice::ReadOnly | QIODevice::Text)) |
||
382 | { |
||
383 | QTextStream inTS(&authorsFile); |
||
15266 | jghali | 384 | inTS.setCodec("UTF-8"); |
385 | inTS.setAutoDetectUnicode(true); |
||
12531 | cbradney | 386 | QString lineTS; |
387 | QStringList fieldTS; |
||
388 | QString name; |
||
389 | QString contact; |
||
390 | bool isTitle = true; |
||
391 | bool startText = false; |
||
392 | bool startTitle = false; |
||
393 | result = "<table>"; |
||
394 | while (!inTS.atEnd()) |
||
395 | { |
||
396 | lineTS = inTS.readLine(); |
||
397 | // convert (r) "�" to ®, "�" to ™ |
||
398 | // lineTS = QString::fromUtf8(lineTS); |
||
399 | lineTS.replace("<", "<"); |
||
400 | lineTS.replace(">", ">"); |
||
401 | lineTS.replace("�", "®"); |
||
402 | lineTS.replace("�", "™"); |
||
403 | name = ""; |
||
404 | contact = ""; |
||
405 | if (!lineTS.isEmpty()) |
||
406 | { |
||
407 | if (isTitle) |
||
408 | { |
||
409 | startTitle = false; |
||
410 | result += "<tr><td><b>"+About::trAuthorTitle(lineTS)+"</b></td><td></td></tr>"; |
||
411 | |||
412 | } // if is title |
||
413 | else |
||
414 | { |
||
415 | startText = false; |
||
416 | fieldTS = lineTS.split(" "); |
||
417 | contact = (fieldTS.isEmpty() ? "" : fieldTS.takeLast()); |
||
418 | name = (fieldTS.isEmpty() ? "" : fieldTS.join(" ")); |
||
419 | result += "<tr><td>"+name+"</td><td>"+(contact == "@" ? "" : contact)+"</td></tr>"; |
||
420 | } // else is title |
||
421 | } // if is empty line |
||
422 | else |
||
423 | { |
||
424 | // empty lines switch between title and text |
||
425 | if (!startText && !startTitle) |
||
426 | { |
||
427 | isTitle = !isTitle; |
||
428 | if (isTitle) |
||
429 | { |
||
430 | result += "<tr><td></td><td></td></tr>"; |
||
431 | startTitle = true; |
||
432 | } |
||
433 | else |
||
434 | { |
||
435 | startText = true; |
||
436 | } |
||
437 | } |
||
438 | } // else is empty line |
||
439 | } // while ! atEnd |
||
440 | result += "<table>"; |
||
441 | } // if file found |
||
442 | else |
||
443 | { |
||
444 | if (!fileName.isEmpty()) |
||
445 | { |
||
446 | QStringList field = fileName.split("/"); |
||
447 | if (!field.isEmpty()) |
||
448 | { |
||
449 | file = field.takeLast(); |
||
450 | } |
||
451 | } |
||
452 | result = tr("Unable to open %1 file. Please check your install directory or the Scribus website for %1 information.").arg(file); |
||
453 | result = ""; |
||
454 | } // else file found |
||
455 | return result; |
||
456 | } // parseTextFile() |
||
457 | |||
458 | /*! |
||
459 | * parse a text file and return an author list in an html table: |
||
460 | * left the names and right the contact address |
||
461 | * the html table can be "split" in sections |
||
462 | * @param QString fileName the file to be parsed |
||
463 | * @return QString the html table |
||
464 | */ |
||
465 | QString About::parseTranslationFile(QString fileName) |
||
466 | { |
||
467 | QString result; |
||
468 | QString file; |
||
469 | QFile translationFile(fileName); |
||
470 | if (translationFile.open(QIODevice::ReadOnly | QIODevice::Text)) |
||
471 | { |
||
472 | QTextStream inTS(&translationFile); |
||
15266 | jghali | 473 | inTS.setCodec("UTF-8"); |
474 | inTS.setAutoDetectUnicode(true); |
||
12531 | cbradney | 475 | QString lineTS; |
476 | QStringList fieldTS; |
||
477 | QString code; |
||
478 | QString name; |
||
479 | QString contact; |
||
12787 | pierre | 480 | // LanguageManager langmgr; |
481 | // langmgr.init(false); |
||
12531 | cbradney | 482 | bool isSectionTitle = true; |
483 | bool isTitle = false; |
||
484 | bool startText = false; |
||
485 | bool startTitle = false; |
||
486 | result = "<table>"; |
||
487 | while (!inTS.atEnd()) |
||
488 | { |
||
489 | lineTS = inTS.readLine(); |
||
490 | lineTS.replace("<", "<"); |
||
491 | lineTS.replace(">", ">"); |
||
492 | name = ""; |
||
493 | contact = ""; |
||
494 | if (!lineTS.isEmpty()) |
||
495 | { |
||
496 | if (isSectionTitle) |
||
497 | { |
||
498 | result += "<tr><td><b><i>"+About::trTranslationTitle(lineTS)+"</i></b></td><td></td></tr>"; |
||
499 | isSectionTitle = false; |
||
500 | isTitle = false; |
||
501 | startTitle = false; |
||
502 | } |
||
503 | else if (isTitle) |
||
504 | { |
||
505 | startTitle = false; |
||
506 | fieldTS = lineTS.split(" "); |
||
507 | code = (fieldTS.isEmpty() ? "" : fieldTS.takeLast()); |
||
508 | if (!code.isEmpty()) |
||
509 | { |
||
510 | code.replace("(", ""); |
||
511 | code.replace(")", ""); |
||
12967 | fschmid | 512 | code = LanguageManager::instance()->getLangFromAbbrev(code); |
12531 | cbradney | 513 | } |
514 | result += "<tr><td><b>"+code+"</b></td><td></td></tr>"; |
||
515 | isTitle = false; |
||
516 | |||
517 | } // if is title |
||
518 | else |
||
519 | { |
||
520 | startText = false; |
||
521 | fieldTS = lineTS.split(" "); |
||
522 | contact = (fieldTS.isEmpty() ? "" : fieldTS.takeLast()); |
||
523 | contact.replace("(", ""); |
||
524 | contact.replace(")", ""); |
||
525 | name = (fieldTS.isEmpty() ? "" : fieldTS.join(" ")); |
||
526 | result += "<tr><td>"+name+"</td><td>"+(contact == "@" ? "" : contact)+"</td></tr>"; |
||
527 | } // else is title |
||
528 | } // if is empty line |
||
529 | else |
||
530 | { |
||
531 | // empty lines switch between title and text |
||
532 | if (!startText && !startTitle) |
||
533 | { |
||
534 | isTitle = !isTitle; |
||
535 | if (isTitle) |
||
536 | { |
||
537 | result += "<tr><td></td><td></td></tr>"; |
||
538 | startTitle = true; |
||
539 | } |
||
540 | else |
||
541 | { |
||
542 | startText = true; |
||
543 | } |
||
544 | // |
||
545 | // multiple empty lines start a section instead of marking a title |
||
546 | } |
||
547 | else if (startTitle) |
||
548 | { |
||
549 | isTitle = false; |
||
550 | isSectionTitle = true; |
||
551 | } |
||
552 | } // else is empty line |
||
553 | } // while ! atEnd |
||
554 | result += "<table>"; |
||
555 | } // if file found |
||
556 | else |
||
557 | { |
||
558 | if (!fileName.isEmpty()) |
||
559 | { |
||
560 | QStringList field = fileName.split("/"); |
||
561 | if (!field.isEmpty()) |
||
562 | { |
||
563 | file = field.takeLast(); |
||
564 | } |
||
565 | } |
||
566 | result = tr("Unable to open %1 file. Please check your install directory or the Scribus website for %1 information.").arg(file); |
||
567 | result = ""; |
||
568 | } // else file found |
||
569 | return result; |
||
570 | } // parseTranslationFile() |
||
571 | |||
572 | /*! |
||
573 | * parse a text file and return a links list in html format: |
||
574 | * left the names and right the contact address |
||
575 | * the html table can be "split" in sections |
||
576 | * @param QString fileName the file to be parsed |
||
577 | * @return QString the html table |
||
578 | */ |
||
579 | QString About::parseLinksFile(QString fileName) |
||
580 | { |
||
581 | QString result; |
||
582 | QString file; |
||
583 | QFile linksFile(fileName); |
||
584 | if (linksFile.open(QIODevice::ReadOnly | QIODevice::Text)) |
||
585 | { |
||
586 | QTextStream inTS(&linksFile); |
||
587 | inTS.setCodec("UTF-8"); |
||
15266 | jghali | 588 | inTS.setAutoDetectUnicode(true); |
12531 | cbradney | 589 | QString lineTS; |
590 | bool isTitle = true; |
||
591 | result = "<table>"; |
||
592 | while (!inTS.atEnd()) |
||
593 | { |
||
594 | lineTS = inTS.readLine(); |
||
595 | // convert (r) "�" to ®, "�" to ™ |
||
596 | // lineTS = QString::fromUtf8(lineTS); |
||
597 | lineTS.replace("<", "<"); |
||
598 | lineTS.replace(">", ">"); |
||
599 | lineTS.replace("�", "®"); |
||
600 | lineTS.replace("�", "™"); |
||
601 | if (!lineTS.isEmpty()) |
||
602 | { |
||
603 | if (isTitle) |
||
604 | { |
||
605 | isTitle = false; |
||
606 | result += "<tr><td><b>"+About::trLinksTitle(lineTS)+"</b></td></tr>"; |
||
607 | |||
608 | } // if is title |
||
609 | else |
||
610 | { |
||
611 | result += "<tr><td><a href=\""+lineTS+"\">"+lineTS+"</a></td></tr>"; |
||
612 | } // else is title |
||
613 | } // if is empty line |
||
614 | else |
||
615 | { |
||
616 | // empty lines switch to title (one line) |
||
617 | result += "<tr><td></td></tr>"; |
||
618 | isTitle = true; |
||
619 | } // else is empty line |
||
620 | } // while ! atEnd |
||
621 | result += "<table>"; |
||
622 | } // if file found |
||
623 | else |
||
624 | { |
||
625 | if (!fileName.isEmpty()) |
||
626 | { |
||
627 | QStringList field = fileName.split("/"); |
||
628 | if (!field.isEmpty()) |
||
629 | { |
||
630 | file = field.takeLast(); |
||
631 | } |
||
632 | } |
||
633 | result = tr("Unable to open %1 file. Please check your install directory or the Scribus website for %1 information.").arg(file); |
||
634 | result = ""; |
||
635 | } // else file found |
||
636 | return result; |
||
637 | } // parseLinksFile() |
||
638 | |||
10913 | jghali | 639 | void About::setVisible (bool visible) |
640 | { |
||
641 | QDialog::setVisible(visible); |
||
642 | if (m_firstShow && (m_mode == About::CheckUpdates) && visible) |
||
643 | { |
||
644 | m_firstShow = false; |
||
645 | runUpdateCheck(); |
||
646 | } |
||
647 | } |
||
648 | |||
5923 | cbradney | 649 | void About::runUpdateCheck() |
650 | { |
||
10926 | cbradney | 651 | textView5->clear(); |
5924 | cbradney | 652 | UpgradeCheckerGUI uc(textView5); |
10926 | cbradney | 653 | disconnect( checkForUpdateButton, SIGNAL( clicked() ), this, SLOT( runUpdateCheck() ) ); |
654 | connect(checkForUpdateButton, SIGNAL( clicked() ), &uc, SLOT( abort() )); |
||
655 | checkForUpdateButton->setText( tr("Abort Update Check") ); |
||
656 | uc.fetch(); |
||
657 | checkForUpdateButton->setText( tr("Check for Updates") ); |
||
658 | connect( checkForUpdateButton, SIGNAL( clicked() ), this, SLOT( runUpdateCheck() ) ); |
||
5923 | cbradney | 659 | } |