Rev 24704 | Rev 24798 | 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 | |
12570 | cbradney | 29 | #include "about.h" |
24486 | craig | 30 | #include "api/api_application.h" |
5364 | cbradney | 31 | #include "commonstrings.h" |
2688 | craig | 32 | #include "scconfig.h" |
11800 | cbradney | 33 | #include "scpaths.h" |
19240 | craig | 34 | #ifdef HAVE_SVNVERSION |
19226 | craig | 35 | #include "svnversion.h" |
19177 | jghali | 36 | #endif |
10212 | cbradney | 37 | #include "util_ghostscript.h" |
20185 | craig | 38 | #include "iconmanager.h" |
18438 | craig | 39 | #include "upgradechecker.h" |
2011 | cbradney | 40 | #include "langmgr.h" |
41 | |||
12531 | cbradney | 42 | /* |
43 | * The content for the About dialog is mostly built from the files in |
||
44 | * // SCRIBUS_INSTALL_DIRECTORY/share/doc/scribus-1.3.5svn/ |
||
45 | * |
||
46 | * The format of the files should follow this pattern: |
||
47 | * - AUTHOR |
||
48 | * Tr(Title) |
||
49 | * first_name name email_address |
||
50 | * first_name name email_address |
||
51 | * |
||
52 | * Tr(Title) |
||
53 | * ... |
||
54 | * |
||
55 | * - TRANSLATION |
||
56 | * Tr(Title) |
||
57 | * |
||
58 | * Language(language_code) |
||
59 | * first_name name (email_address) |
||
60 | * |
||
61 | * Language(language_code) |
||
62 | * first_name name (email_address) |
||
63 | * |
||
64 | * |
||
65 | * Tr(Title) |
||
66 | * ... |
||
67 | * - LINKS |
||
68 | * Tr(Title) |
||
69 | * url |
||
70 | * |
||
71 | * |
||
72 | * Tr(Title) |
||
73 | * ... |
||
74 | * |
||
75 | * |
||
76 | * Text which has to be translated has to be added to the local tr...Title() |
||
77 | * methods, otherwise in won't be added to the list of translatable strings |
||
78 | * |
||
79 | * a.l.e |
||
80 | */ |
||
81 | |||
1641 | cbradney | 82 | /*! |
12531 | cbradney | 83 | \fn About::About( QWidget* parent, AboutMode diaMode ) |
84 | \author Franz Schmid |
||
85 | \date |
||
86 | \brief Constructor for About dialog box |
||
87 | \param parent QWidget pointer to parent window |
||
88 | \param diaMode a dialog mode. See AboutMode. |
||
89 | \retval About dialog |
||
90 | */ |
||
10913 | jghali | 91 | About::About( QWidget* parent, AboutMode diaMode ) : QDialog( parent ) |
1641 | cbradney | 92 | { |
10913 | jghali | 93 | m_mode = diaMode; |
94 | m_firstShow = true; |
||
24486 | craig | 95 | setWindowTitle( tr("About Scribus %1").arg(ScribusAPI::getVersion()) ); |
23054 | craig | 96 | setWindowIcon(IconManager::instance().loadIcon("AppIcon.png", true)); |
9338 | fschmid | 97 | setModal(true); |
98 | aboutLayout = new QVBoxLayout( this ); |
||
24366 | jghali | 99 | aboutLayout->setSpacing(6); |
100 | aboutLayout->setContentsMargins(9, 9, 9, 9); |
||
10493 | fschmid | 101 | tabWidget2 = new QTabWidget( this ); |
102 | tab = new QWidget( tabWidget2 ); |
||
9338 | fschmid | 103 | tabLayout1 = new QVBoxLayout( tab ); |
24366 | jghali | 104 | tabLayout1->setSpacing(6); |
105 | tabLayout1->setContentsMargins(9, 9, 9, 9); |
||
24309 | jghali | 106 | |
107 | double pixelRatio = devicePixelRatioF(); |
||
108 | QPixmap splashPixmap = IconManager::instance().loadPixmap("scribus_splash.png", true); |
||
109 | double splashPixmapW = splashPixmap.width(); |
||
110 | double splashPixmapH = splashPixmap.height(); |
||
111 | if (pixelRatio != 1.0) |
||
112 | { |
||
113 | int w = qRound(splashPixmap.width() * pixelRatio); |
||
114 | int h = qRound(splashPixmap.height() * pixelRatio); |
||
115 | double integralPart = 0; |
||
116 | bool isIntegerRatio = (modf(pixelRatio, &integralPart) == 0.0); |
||
117 | splashPixmap = splashPixmap.scaled(w, h, Qt::IgnoreAspectRatio, isIntegerRatio ? Qt::FastTransformation : Qt::SmoothTransformation); |
||
118 | splashPixmap.setDevicePixelRatio(pixelRatio); |
||
119 | } |
||
120 | |||
10493 | fschmid | 121 | pixmapLabel1 = new QLabel( tab ); |
24309 | jghali | 122 | pixmapLabel1->setPixmap(splashPixmap); |
123 | pixmapLabel1->setFixedSize(QSize(splashPixmapW, splashPixmapH)); |
||
1641 | cbradney | 124 | pixmapLabel1->setAlignment(Qt::AlignCenter); |
125 | tabLayout1->addWidget( pixmapLabel1 ); |
||
10493 | fschmid | 126 | buildID = new QLabel( tab ); |
1641 | cbradney | 127 | buildID->setAlignment(Qt::AlignCenter); |
13438 | cbradney | 128 | buildID->setTextInteractionFlags(Qt::TextSelectableByMouse); |
24776 | craig | 129 | QString BUILD_DAY = "5"; |
130 | QString BUILD_MONTH = CommonStrings::december; |
||
24633 | craig | 131 | QString BUILD_YEAR = "2021"; |
9697 | craig | 132 | QString BUILD_TIME = ""; |
133 | QString BUILD_TZ = ""; |
||
134 | QString BUILD_NAME = ""; |
||
3587 | avox | 135 | |
21935 | craig | 136 | QString built = tr("%1 %2 %3").arg(BUILD_DAY, BUILD_MONTH, BUILD_YEAR); |
24486 | craig | 137 | QString version(ScribusAPI::getVersion()); |
9697 | craig | 138 | if (BUILD_NAME != "") |
139 | version += " \"" + BUILD_NAME + "\""; |
||
140 | if (BUILD_NAME == "BleedingEdge") |
||
21935 | craig | 141 | built = tr("%3-%2-%1 %4 %5").arg(BUILD_DAY, BUILD_MONTH, BUILD_YEAR, BUILD_TIME, BUILD_TZ); |
9697 | craig | 142 | |
24638 | craig | 143 | if (ScribusAPI::isSVN() && ScribusAPI::haveSVNRevision()) |
24486 | craig | 144 | { |
145 | QString revText(tr("SVN Revision: ")); |
||
146 | revText += ScribusAPI::getSVNRevision(); |
||
147 | built += " - "; |
||
148 | built += revText; |
||
149 | } |
||
1641 | cbradney | 150 | |
2840 | craig | 151 | QString gsver(getGSVersion()); |
12574 | jghali | 152 | if (!gsver.isEmpty()) |
3583 | cbradney | 153 | gsver = tr("Using Ghostscript version %1").arg(gsver); |
2840 | craig | 154 | else |
3583 | cbradney | 155 | gsver = tr("No Ghostscript version available"); |
24486 | craig | 156 | 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"), version, built, tr("Build ID:"), ScribusAPI::getBuildInformation(), gsver)); |
9755 | fschmid | 157 | tabLayout1->addWidget( buildID, 0, Qt::AlignHCenter ); |
24486 | craig | 158 | tabWidget2->addTab( tab, tr("&About") ); |
20197 | craig | 159 | |
160 | /*! AUTHORS tab */ |
||
10493 | fschmid | 161 | tab_2 = new QWidget( tabWidget2 ); |
9338 | fschmid | 162 | tabLayout = new QHBoxLayout( tab_2 ); |
24366 | jghali | 163 | tabLayout->setSpacing(6); |
164 | tabLayout->setContentsMargins(9, 9, 9, 9); |
||
20197 | craig | 165 | authorView = new QTextBrowser( tab_2 ); |
166 | authorView->setHtml(About::parseAuthorFile(ScPaths::instance().docDir() + "AUTHORS")); |
||
167 | tabLayout->addWidget( authorView ); |
||
168 | tabWidget2->addTab( tab_2, tr("A&uthors")); |
||
4363 | mrdocs | 169 | |
20197 | craig | 170 | /*! TRANSLATION tab */ |
10493 | fschmid | 171 | tab_3 = new QWidget( tabWidget2 ); |
9338 | fschmid | 172 | tabLayout_2 = new QHBoxLayout( tab_3 ); |
24366 | jghali | 173 | tabLayout_2->setSpacing(6); |
174 | tabLayout_2->setContentsMargins(9, 9, 9, 9); |
||
20197 | craig | 175 | transView = new QTextBrowser( tab_3); |
176 | transView->setHtml(About::parseTranslationFile(ScPaths::instance().docDir() + "TRANSLATION")); |
||
177 | tabLayout_2->addWidget( transView ); |
||
24486 | craig | 178 | tabWidget2->addTab( tab_3, tr("&Translations") ); |
1641 | cbradney | 179 | |
12531 | cbradney | 180 | /*! ONLINE tab (03/04/2004 petr vanek) */ |
10493 | fschmid | 181 | tab_4 = new QWidget( tabWidget2 ); |
20197 | craig | 182 | onlineView = new QTextBrowser( tab_4 ); |
183 | onlineView->setHtml(About::parseLinksFile(ScPaths::instance().docDir() + "LINKS")); |
||
184 | onlineView->setOpenExternalLinks(true); |
||
9338 | fschmid | 185 | tabLayout_4 = new QHBoxLayout( tab_4 ); |
24366 | jghali | 186 | tabLayout_4->setSpacing(6); |
187 | tabLayout_4->setContentsMargins(9, 9, 9, 9); |
||
20197 | craig | 188 | tabLayout_4->addWidget( onlineView ); |
24486 | craig | 189 | tabWidget2->addTab( tab_4, tr("&Online") ); |
20197 | craig | 190 | |
191 | |||
12531 | cbradney | 192 | /*! UPDATE tab */ |
10493 | fschmid | 193 | tab_5 = new QWidget( tabWidget2 ); |
24486 | craig | 194 | tabWidget2->addTab( tab_5, tr("&Updates") ); |
9338 | fschmid | 195 | updateLayout = new QVBoxLayout( tab_5 ); |
24366 | jghali | 196 | updateLayout->setSpacing(6); |
197 | updateLayout->setContentsMargins(9, 9, 9, 9); |
||
24486 | craig | 198 | checkForUpdateButton = new QPushButton( tr("Check for Updates"), tab_5 ); |
20197 | craig | 199 | updateView = new QTextBrowser( tab_5); |
5923 | cbradney | 200 | updateLayout->addWidget( checkForUpdateButton ); |
20197 | craig | 201 | updateLayout->addWidget( updateView ); |
11800 | cbradney | 202 | |
12531 | cbradney | 203 | /*! LICENCE tab */ |
11800 | cbradney | 204 | tab_Licence = new QWidget( tabWidget2 ); |
24486 | craig | 205 | tabWidget2->addTab( tab_Licence, tr("&Licence") ); |
11800 | cbradney | 206 | licenceLayout = new QVBoxLayout( tab_Licence ); |
24366 | jghali | 207 | licenceLayout->setSpacing(6); |
208 | licenceLayout->setContentsMargins(9, 9, 9, 9); |
||
20197 | craig | 209 | textViewLicence = new QTextBrowser( tab_Licence); |
11800 | cbradney | 210 | licenceLayout->addWidget( textViewLicence ); |
211 | |||
212 | QFile licenceFile(ScPaths::instance().docDir() + "/COPYING"); |
||
12531 | cbradney | 213 | if (!licenceFile.open(QIODevice::ReadOnly | QIODevice::Text)) |
20197 | craig | 214 | textViewLicence->setPlainText(tr("Unable to open licence file. Please check your install directory or the Scribus website for licencing information.") ); |
12531 | cbradney | 215 | else |
11800 | cbradney | 216 | { |
217 | QTextStream inTS(&licenceFile); |
||
18565 | jghali | 218 | inTS.setAutoDetectUnicode(true); |
219 | inTS.setCodec("UTF-8"); |
||
11800 | cbradney | 220 | QString licenceText = inTS.readAll(); |
20197 | craig | 221 | textViewLicence->setPlainText(licenceText); |
12531 | cbradney | 222 | } |
20197 | craig | 223 | |
11800 | cbradney | 224 | //Add tab widget to about window |
1641 | cbradney | 225 | aboutLayout->addWidget( tabWidget2 ); |
7368 | subik | 226 | |
9338 | fschmid | 227 | layout2 = new QHBoxLayout; |
24366 | jghali | 228 | layout2->setSpacing(6); |
229 | layout2->setContentsMargins(0, 0, 0, 0); |
||
1641 | cbradney | 230 | QSpacerItem* spacer = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum ); |
231 | layout2->addItem( spacer ); |
||
24486 | craig | 232 | okButton = new QPushButton( tr("&Close"), this ); |
1641 | cbradney | 233 | okButton->setDefault( true ); |
234 | layout2->addWidget( okButton ); |
||
235 | aboutLayout->addLayout( layout2 ); |
||
236 | setMaximumSize(sizeHint()); |
||
237 | |||
4363 | mrdocs | 238 | |
12574 | jghali | 239 | //tooltips |
24486 | craig | 240 | buildID->setToolTip( "<qt>" + tr("This panel shows the version, build date and compiled in library support in Scribus.")+"<br>" |
12531 | cbradney | 241 | + 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>" |
242 | + tr("Missing library support is indicated by a *. This also indicates the version of Ghostscript which Scribus has detected.")+"<br>" |
||
24486 | craig | 243 | + tr("The Windows version does not use fontconfig or CUPS libraries.") + "</qt>"); |
244 | checkForUpdateButton->setToolTip( "<qt>" + tr("Check for updates to Scribus. No data from your machine will be transferred off it.") + "</qt>"); |
||
5220 | mrdocs | 245 | // signals and slots connections |
246 | connect( okButton, SIGNAL( clicked() ), this, SLOT( accept() ) ); |
||
5923 | cbradney | 247 | connect( checkForUpdateButton, SIGNAL( clicked() ), this, SLOT( runUpdateCheck() ) ); |
14952 | fschmid | 248 | resize(minimumSizeHint()); |
5273 | mrdocs | 249 | } |
5923 | cbradney | 250 | |
10913 | jghali | 251 | void About::showEvent (QShowEvent * event) |
252 | { |
||
253 | if (m_mode == About::CheckUpdates && m_firstShow) |
||
254 | tabWidget2->setCurrentIndex(4); |
||
255 | QDialog::showEvent(event); |
||
256 | } |
||
257 | |||
22454 | craig | 258 | QString About::trAuthorTitle(const QString& title) |
12531 | cbradney | 259 | { |
260 | QString result; |
||
24486 | craig | 261 | if (title == "Development Team:") |
12531 | cbradney | 262 | result = tr("Development Team:"); |
24486 | craig | 263 | else if (title == "Mac OS® X Aqua Port:") |
12531 | cbradney | 264 | result = tr("Mac OS® X Aqua Port:"); |
24486 | craig | 265 | else if (title == "OS/2®/eComStation™ Port:") |
12531 | cbradney | 266 | result = tr("OS/2®/eComStation™ Port:"); |
24486 | craig | 267 | else if (title == "Windows® Port:") |
12531 | cbradney | 268 | result = tr("Windows® Port:"); |
24486 | craig | 269 | else if (title == "Haiku Port:") |
18438 | craig | 270 | result = tr("Haiku Port:"); |
24486 | craig | 271 | else if (title == "Contributions from:") |
12531 | cbradney | 272 | result = tr("Contributions from:"); |
24486 | craig | 273 | else if (title == "Official Documentation:") |
12531 | cbradney | 274 | result = tr("Official Documentation:"); |
24486 | craig | 275 | else if (title == "Doc Translators:") |
12531 | cbradney | 276 | result = tr("Doc Translators:"); |
24486 | craig | 277 | else if (title == "Other Documentation:") |
12531 | cbradney | 278 | result = tr("Other Documentation:"); |
24486 | craig | 279 | else if (title == "Webmasters:") |
12531 | cbradney | 280 | result = tr("Webmasters:"); |
24486 | craig | 281 | else if (title == "Splash Screen:") |
12531 | cbradney | 282 | result = tr("Splash Screen:"); |
24486 | craig | 283 | else if (title == "Tango Project Icons:") |
12531 | cbradney | 284 | result = tr("Tango Project Icons:"); |
24486 | craig | 285 | else if (title == "Scribus 1.5.1+ Icon Set:") |
20319 | craig | 286 | result = tr("Scribus 1.5.1+ Icon Set:"); |
24486 | craig | 287 | else if (title == "AppImage for Linux:") |
288 | result = tr("AppImage for Linux:"); |
||
289 | else if (title == "Refactoring text layout code, the new boxes model & CTL text layout, Oman House of Open Source Technology team:") |
||
21947 | craig | 290 | result = tr("Refactoring text layout code, the new boxes model & CTL text layout, Oman House of Open Source Technology team:"); |
12531 | cbradney | 291 | else |
12967 | fschmid | 292 | { |
12531 | cbradney | 293 | std::cout << "please add the untranslated title \"" << qPrintable(title) << "\" to About::trAuthorTitle()" << std::endl; |
294 | result = title; |
||
12967 | fschmid | 295 | } |
12531 | cbradney | 296 | return result; |
297 | } |
||
24553 | jghali | 298 | |
22454 | craig | 299 | QString About::trTranslationTitle(const QString& title) |
12531 | cbradney | 300 | { |
301 | QString result; |
||
24486 | craig | 302 | if (title == "Official Translations and Translators (in order of locale shortcode):") |
21260 | craig | 303 | result = tr("Official Translations and Translators (in order of locale shortcode):"); |
24486 | craig | 304 | else if (title == "Previous Translation Contributors:") |
12531 | cbradney | 305 | result = tr("Previous Translation Contributors:"); |
306 | else |
||
12967 | fschmid | 307 | { |
16756 | craig | 308 | std::cout << "please add the untranslated title \"" << qPrintable(title) << "\" to About::trTranslationTitle()" << std::endl; |
12531 | cbradney | 309 | result = title; |
12967 | fschmid | 310 | } |
12531 | cbradney | 311 | return result; |
312 | } |
||
313 | |||
22454 | craig | 314 | QString About::trLinksTitle(const QString& title) |
12531 | cbradney | 315 | { |
316 | QString result; |
||
24486 | craig | 317 | if (title == "Homepage") |
12531 | cbradney | 318 | result = tr("Homepage"); |
24486 | craig | 319 | else if (title == "Online Reference") |
12531 | cbradney | 320 | result = tr("Online Reference"); |
24486 | craig | 321 | else if (title == "Wiki") |
12531 | cbradney | 322 | result = tr("Wiki"); |
24486 | craig | 323 | else if (title == "Bugs and Feature Requests") |
12531 | cbradney | 324 | result = tr("Bugs and Feature Requests"); |
24486 | craig | 325 | else if (title == "Developer Blog") |
12531 | cbradney | 326 | result = tr("Developer Blog"); |
24486 | craig | 327 | else if (title == "Mailing List") |
12531 | cbradney | 328 | result = tr("Mailing List"); |
329 | else |
||
12967 | fschmid | 330 | { |
12531 | cbradney | 331 | std::cout << "please add the untranslated title \"" << qPrintable(title) << "\" to About::trLinksTitle()" << std::endl; |
332 | result = title; |
||
12967 | fschmid | 333 | } |
12531 | cbradney | 334 | return result; |
335 | } |
||
336 | |||
337 | /*! |
||
338 | * parse a text file and return an author list in an html table: |
||
339 | * left the names and right the contact address |
||
340 | * the html table can be "split" in sections |
||
341 | * @param QString fileName the file to be parsed |
||
342 | * @return QString the html table |
||
343 | */ |
||
22454 | craig | 344 | QString About::parseAuthorFile(const QString& fileName) |
12531 | cbradney | 345 | { |
346 | QString result; |
||
347 | QString file; |
||
348 | QFile authorsFile(fileName); |
||
349 | if (authorsFile.open(QIODevice::ReadOnly | QIODevice::Text)) |
||
350 | { |
||
351 | QTextStream inTS(&authorsFile); |
||
15267 | jghali | 352 | inTS.setCodec("UTF-8"); |
353 | inTS.setAutoDetectUnicode(true); |
||
12531 | cbradney | 354 | QString lineTS; |
355 | QStringList fieldTS; |
||
356 | QString name; |
||
357 | QString contact; |
||
358 | bool isTitle = true; |
||
359 | bool startText = false; |
||
360 | bool startTitle = false; |
||
361 | result = "<table>"; |
||
362 | while (!inTS.atEnd()) |
||
363 | { |
||
364 | lineTS = inTS.readLine(); |
||
365 | // convert (r) "�" to ®, "�" to ™ |
||
366 | // lineTS = QString::fromUtf8(lineTS); |
||
367 | lineTS.replace("<", "<"); |
||
368 | lineTS.replace(">", ">"); |
||
369 | lineTS.replace("�", "®"); |
||
370 | lineTS.replace("�", "™"); |
||
371 | name = ""; |
||
372 | contact = ""; |
||
373 | if (!lineTS.isEmpty()) |
||
374 | { |
||
375 | if (isTitle) |
||
376 | { |
||
377 | startTitle = false; |
||
23765 | jghali | 378 | result += "<tr><td><b>" + About::trAuthorTitle(lineTS) + "</b></td><td></td></tr>"; |
379 | } |
||
12531 | cbradney | 380 | else |
381 | { |
||
382 | startText = false; |
||
383 | fieldTS = lineTS.split(" "); |
||
23765 | jghali | 384 | contact = fieldTS.isEmpty() ? QString() : fieldTS.takeLast(); |
385 | name = fieldTS.isEmpty() ? QString() : fieldTS.join(" "); |
||
386 | result += "<tr><td>" +name + "</td><td>" + (contact == "@" ? "" : contact) + "</td></tr>"; |
||
387 | } |
||
12531 | cbradney | 388 | } // if is empty line |
389 | else |
||
390 | { |
||
391 | // empty lines switch between title and text |
||
392 | if (!startText && !startTitle) |
||
393 | { |
||
394 | isTitle = !isTitle; |
||
395 | if (isTitle) |
||
396 | { |
||
397 | result += "<tr><td></td><td></td></tr>"; |
||
398 | startTitle = true; |
||
399 | } |
||
400 | else |
||
401 | { |
||
402 | startText = true; |
||
403 | } |
||
404 | } |
||
405 | } // else is empty line |
||
406 | } // while ! atEnd |
||
407 | result += "<table>"; |
||
408 | } // if file found |
||
409 | else |
||
410 | { |
||
411 | if (!fileName.isEmpty()) |
||
412 | { |
||
413 | QStringList field = fileName.split("/"); |
||
414 | if (!field.isEmpty()) |
||
415 | { |
||
416 | file = field.takeLast(); |
||
417 | } |
||
418 | } |
||
419 | result = tr("Unable to open %1 file. Please check your install directory or the Scribus website for %1 information.").arg(file); |
||
420 | result = ""; |
||
421 | } // else file found |
||
422 | return result; |
||
423 | } // parseTextFile() |
||
424 | |||
425 | /*! |
||
426 | * parse a text file and return an author list in an html table: |
||
427 | * left the names and right the contact address |
||
428 | * the html table can be "split" in sections |
||
429 | * @param QString fileName the file to be parsed |
||
430 | * @return QString the html table |
||
431 | */ |
||
22454 | craig | 432 | QString About::parseTranslationFile(const QString& fileName) |
12531 | cbradney | 433 | { |
434 | QString result; |
||
435 | QString file; |
||
436 | QFile translationFile(fileName); |
||
437 | if (translationFile.open(QIODevice::ReadOnly | QIODevice::Text)) |
||
438 | { |
||
439 | QTextStream inTS(&translationFile); |
||
15267 | jghali | 440 | inTS.setCodec("UTF-8"); |
441 | inTS.setAutoDetectUnicode(true); |
||
12531 | cbradney | 442 | QString lineTS; |
443 | QStringList fieldTS; |
||
444 | QString code; |
||
445 | QString name; |
||
446 | QString contact; |
||
12787 | pierre | 447 | // LanguageManager langmgr; |
448 | // langmgr.init(false); |
||
12531 | cbradney | 449 | bool isSectionTitle = true; |
450 | bool isTitle = false; |
||
451 | bool startText = false; |
||
452 | bool startTitle = false; |
||
453 | result = "<table>"; |
||
19187 | craig | 454 | |
455 | QMap<QString, QString> sections; |
||
456 | QMap<QString, QString> languages; |
||
457 | QMultiMap<QString, QString> names; |
||
458 | QString currLang; |
||
459 | int section=0; |
||
460 | QString snum; |
||
12531 | cbradney | 461 | while (!inTS.atEnd()) |
462 | { |
||
463 | lineTS = inTS.readLine(); |
||
464 | lineTS.replace("<", "<"); |
||
465 | lineTS.replace(">", ">"); |
||
466 | name = ""; |
||
467 | contact = ""; |
||
468 | if (!lineTS.isEmpty()) |
||
469 | { |
||
470 | if (isSectionTitle) |
||
471 | { |
||
19187 | craig | 472 | ++section; |
473 | snum.setNum(section); |
||
474 | //result += "<tr><td><b><i>"+About::trTranslationTitle(lineTS)+"</i></b></td><td></td></tr>"; |
||
475 | |||
476 | sections.insert(snum, "<tr><td><b><i>"+About::trTranslationTitle(lineTS)+"</i></b></td><td></td></tr>"); |
||
12531 | cbradney | 477 | isSectionTitle = false; |
478 | isTitle = false; |
||
479 | startTitle = false; |
||
480 | } |
||
481 | else if (isTitle) |
||
482 | { |
||
483 | startTitle = false; |
||
484 | fieldTS = lineTS.split(" "); |
||
485 | code = (fieldTS.isEmpty() ? "" : fieldTS.takeLast()); |
||
486 | if (!code.isEmpty()) |
||
487 | { |
||
488 | code.replace("(", ""); |
||
489 | code.replace(")", ""); |
||
12967 | fschmid | 490 | code = LanguageManager::instance()->getLangFromAbbrev(code); |
12531 | cbradney | 491 | } |
19187 | craig | 492 | //result += "<tr><td><b>"+code+"</b></td><td></td></tr>"; |
493 | languages.insert(snum+":"+code, "<tr><td><b>"+code+"</b></td><td></td></tr>"); |
||
12531 | cbradney | 494 | isTitle = false; |
19187 | craig | 495 | currLang=code; |
12531 | cbradney | 496 | |
497 | } // if is title |
||
498 | else |
||
499 | { |
||
500 | startText = false; |
||
501 | fieldTS = lineTS.split(" "); |
||
502 | contact = (fieldTS.isEmpty() ? "" : fieldTS.takeLast()); |
||
503 | contact.replace("(", ""); |
||
504 | contact.replace(")", ""); |
||
505 | name = (fieldTS.isEmpty() ? "" : fieldTS.join(" ")); |
||
19187 | craig | 506 | //result += "<tr><td>"+name+"</td><td>"+(contact == "@" ? "" : contact)+"</td></tr>"; |
507 | names.insert(snum+":"+code, "<tr><td>"+name+"</td><td>"+(contact == "@" ? "" : contact)+"</td></tr>"); |
||
12531 | cbradney | 508 | } // else is title |
509 | } // if is empty line |
||
510 | else |
||
511 | { |
||
512 | // empty lines switch between title and text |
||
513 | if (!startText && !startTitle) |
||
514 | { |
||
515 | isTitle = !isTitle; |
||
516 | if (isTitle) |
||
517 | { |
||
19187 | craig | 518 | //result += "<tr><td></td><td></td></tr>"; |
12531 | cbradney | 519 | startTitle = true; |
520 | } |
||
521 | else |
||
522 | { |
||
523 | startText = true; |
||
524 | } |
||
525 | // |
||
526 | // multiple empty lines start a section instead of marking a title |
||
527 | } |
||
528 | else if (startTitle) |
||
529 | { |
||
530 | isTitle = false; |
||
531 | isSectionTitle = true; |
||
532 | } |
||
533 | } // else is empty line |
||
534 | } // while ! atEnd |
||
19187 | craig | 535 | |
536 | QMapIterator<QString, QString> s(sections); |
||
537 | while (s.hasNext()) |
||
538 | { |
||
539 | s.next(); |
||
540 | result += s.value(); |
||
21258 | jghali | 541 | result += "<tr><td></td><td></td></tr>"; |
19187 | craig | 542 | QMapIterator<QString, QString> l(languages); |
543 | while (l.hasNext()) |
||
544 | { |
||
545 | l.next(); |
||
546 | QStringList sl=l.key().split(":"); |
||
547 | if (s.key()==sl.first()) |
||
548 | { |
||
549 | result += l.value(); |
||
550 | |||
551 | QMapIterator<QString, QString> n(names); |
||
552 | while (n.hasNext()) |
||
553 | { |
||
554 | n.next(); |
||
555 | if (n.key()==l.key()) |
||
556 | result += n.value(); |
||
557 | } |
||
558 | result += "<tr><td></td><td></td></tr>"; |
||
559 | } |
||
560 | } |
||
561 | result += "<tr><td></td><td></td></tr><tr><td></td><td></td></tr>"; |
||
562 | } |
||
12531 | cbradney | 563 | result += "<table>"; |
564 | } // if file found |
||
565 | else |
||
566 | { |
||
567 | if (!fileName.isEmpty()) |
||
568 | { |
||
569 | QStringList field = fileName.split("/"); |
||
570 | if (!field.isEmpty()) |
||
571 | { |
||
572 | file = field.takeLast(); |
||
573 | } |
||
574 | } |
||
575 | result = tr("Unable to open %1 file. Please check your install directory or the Scribus website for %1 information.").arg(file); |
||
576 | result = ""; |
||
577 | } // else file found |
||
578 | return result; |
||
579 | } // parseTranslationFile() |
||
580 | |||
581 | /*! |
||
582 | * parse a text file and return a links list in html format: |
||
583 | * left the names and right the contact address |
||
584 | * the html table can be "split" in sections |
||
585 | * @param QString fileName the file to be parsed |
||
586 | * @return QString the html table |
||
587 | */ |
||
22454 | craig | 588 | QString About::parseLinksFile(const QString& fileName) |
12531 | cbradney | 589 | { |
590 | QString result; |
||
591 | QString file; |
||
592 | QFile linksFile(fileName); |
||
593 | if (linksFile.open(QIODevice::ReadOnly | QIODevice::Text)) |
||
594 | { |
||
595 | QTextStream inTS(&linksFile); |
||
596 | inTS.setCodec("UTF-8"); |
||
15267 | jghali | 597 | inTS.setAutoDetectUnicode(true); |
12531 | cbradney | 598 | QString lineTS; |
599 | bool isTitle = true; |
||
600 | result = "<table>"; |
||
601 | while (!inTS.atEnd()) |
||
602 | { |
||
603 | lineTS = inTS.readLine(); |
||
604 | // convert (r) "�" to ®, "�" to ™ |
||
605 | // lineTS = QString::fromUtf8(lineTS); |
||
606 | lineTS.replace("<", "<"); |
||
607 | lineTS.replace(">", ">"); |
||
608 | lineTS.replace("�", "®"); |
||
609 | lineTS.replace("�", "™"); |
||
610 | if (!lineTS.isEmpty()) |
||
611 | { |
||
612 | if (isTitle) |
||
613 | { |
||
614 | isTitle = false; |
||
615 | result += "<tr><td><b>"+About::trLinksTitle(lineTS)+"</b></td></tr>"; |
||
616 | |||
617 | } // if is title |
||
618 | else |
||
619 | { |
||
620 | result += "<tr><td><a href=\""+lineTS+"\">"+lineTS+"</a></td></tr>"; |
||
621 | } // else is title |
||
622 | } // if is empty line |
||
623 | else |
||
624 | { |
||
625 | // empty lines switch to title (one line) |
||
626 | result += "<tr><td></td></tr>"; |
||
627 | isTitle = true; |
||
628 | } // else is empty line |
||
629 | } // while ! atEnd |
||
630 | result += "<table>"; |
||
631 | } // if file found |
||
632 | else |
||
633 | { |
||
634 | if (!fileName.isEmpty()) |
||
635 | { |
||
636 | QStringList field = fileName.split("/"); |
||
637 | if (!field.isEmpty()) |
||
638 | file = field.takeLast(); |
||
639 | } |
||
640 | result = tr("Unable to open %1 file. Please check your install directory or the Scribus website for %1 information.").arg(file); |
||
641 | result = ""; |
||
642 | } // else file found |
||
643 | return result; |
||
644 | } // parseLinksFile() |
||
645 | |||
10913 | jghali | 646 | void About::setVisible (bool visible) |
647 | { |
||
648 | QDialog::setVisible(visible); |
||
649 | if (m_firstShow && (m_mode == About::CheckUpdates) && visible) |
||
650 | { |
||
651 | m_firstShow = false; |
||
652 | runUpdateCheck(); |
||
653 | } |
||
654 | } |
||
655 | |||
5923 | cbradney | 656 | void About::runUpdateCheck() |
657 | { |
||
20197 | craig | 658 | updateView->clear(); |
659 | UpgradeCheckerGUI uc(updateView); |
||
10926 | cbradney | 660 | disconnect( checkForUpdateButton, SIGNAL( clicked() ), this, SLOT( runUpdateCheck() ) ); |
661 | uc.fetch(); |
||
662 | connect( checkForUpdateButton, SIGNAL( clicked() ), this, SLOT( runUpdateCheck() ) ); |
||
5923 | cbradney | 663 | } |