Rev 7645 | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
4430 | cbradney | 1 | /* |
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 | */ |
||
2160 | cbradney | 7 | /*************************************************************************** |
8 | begin : May 2005 |
||
3873 | subik | 9 | copyright : (C) 2005 by Craig Bradney |
2160 | cbradney | 10 | email : cbradney@zip.com.au |
11 | copyright : (C) 2001 by Franz Schmid |
||
12 | email : Franz.Schmid@altmuehlnet.de |
||
13 | ***************************************************************************/ |
||
14 | |||
15 | /*************************************************************************** |
||
16 | * * |
||
4026 | craig | 17 | * ScMW program is free software; you can redistribute it and/or modify * |
2160 | cbradney | 18 | * it under the terms of the GNU General Public License as published by * |
19 | * the Free Software Foundation; either version 2 of the License, or * |
||
20 | * (at your option) any later version. * |
||
21 | * * |
||
22 | ***************************************************************************/ |
||
23 | |||
4207 | craig | 24 | |
2245 | cbradney | 25 | #include <iostream> |
26 | #include <cstdlib> |
||
27 | |||
4207 | craig | 28 | #include <qstring.h> |
2160 | cbradney | 29 | #include <qfont.h> |
30 | #include <qtranslator.h> |
||
31 | #include <qfileinfo.h> |
||
32 | #include <qfile.h> |
||
33 | #include <qdir.h> |
||
34 | #include <qtextcodec.h> |
||
35 | |||
36 | #include "scribusapp.h" |
||
3120 | fschmid | 37 | #include "scribusapp.moc" |
5243 | cbradney | 38 | #include "scribuscore.h" |
2160 | cbradney | 39 | #include "scpaths.h" |
40 | #include "prefsfile.h" |
||
2245 | cbradney | 41 | #include "langmgr.h" |
2834 | cbradney | 42 | #include "prefsmanager.h" |
2952 | cbradney | 43 | #include "commonstrings.h" |
5855 | cbradney | 44 | #include "upgradechecker.h" |
2160 | cbradney | 45 | |
6329 | jghali | 46 | #if defined(_WIN32) |
47 | #include <windows.h> |
||
48 | #endif |
||
49 | |||
2245 | cbradney | 50 | #define ARG_VERSION "--version" |
51 | #define ARG_HELP "--help" |
||
52 | #define ARG_LANG "--lang" |
||
53 | #define ARG_AVAILLANG "--langs-available" |
||
54 | #define ARG_NOSPLASH "--no-splash" |
||
5338 | cbradney | 55 | #define ARG_NEVERSPLASH "--never-splash" |
2245 | cbradney | 56 | #define ARG_NOGUI "--no-gui" |
57 | #define ARG_DISPLAY "--display" |
||
2295 | cbradney | 58 | #define ARG_FONTINFO "--font-info" |
7330 | jghali | 59 | #define ARG_PROFILEINFO "--profile-info" |
3571 | cbradney | 60 | #define ARG_SWAPDIABUTTONS "--swap-buttons" |
3873 | subik | 61 | #define ARG_PREFS "--prefs" |
5855 | cbradney | 62 | #define ARG_UPGRADECHECK "--upgradecheck" |
2245 | cbradney | 63 | |
64 | #define ARG_VERSION_SHORT "-v" |
||
65 | #define ARG_HELP_SHORT "-h" |
||
66 | #define ARG_LANG_SHORT "-l" |
||
67 | #define ARG_AVAILLANG_SHORT "-la" |
||
68 | #define ARG_NOSPLASH_SHORT "-ns" |
||
5338 | cbradney | 69 | #define ARG_NEVERSPLASH_SHORT "-nns" |
2245 | cbradney | 70 | #define ARG_NOGUI_SHORT "-g" |
71 | #define ARG_DISPLAY_SHORT "-d" |
||
2295 | cbradney | 72 | #define ARG_FONTINFO_SHORT "-fi" |
7330 | jghali | 73 | #define ARG_PROFILEINFO_SHORT "-pi" |
3571 | cbradney | 74 | #define ARG_SWAPDIABUTTONS_SHORT "-sb" |
4126 | cbradney | 75 | #define ARG_PREFS_SHORT "-pr" |
5855 | cbradney | 76 | #define ARG_UPGRADECHECK_SHORT "-u" |
2245 | cbradney | 77 | |
78 | // Qt wants -display not --display or -d |
||
79 | #define ARG_DISPLAY_QT "-display" |
||
80 | |||
5598 | jghali | 81 | // Windows specific options, allows to display a console windows |
82 | extern const char ARG_CONSOLE[] = "--console"; |
||
83 | extern const char ARG_CONSOLE_SHORT[] = "-cl"; |
||
84 | |||
2536 | cbradney | 85 | extern ScribusQApp* ScQApp; |
5243 | cbradney | 86 | extern ScribusCore* ScCore; |
2536 | cbradney | 87 | |
88 | bool ScribusQApp::useGUI=false; |
||
89 | |||
6839 | cbradney | 90 | ScribusQApp::ScribusQApp( int & argc, char ** argv ) : QApplication(argc, argv), |
91 | lang(""), |
||
92 | GUILang("") |
||
2160 | cbradney | 93 | { |
2536 | cbradney | 94 | ScQApp=this; |
5243 | cbradney | 95 | ScCore=NULL; |
2160 | cbradney | 96 | } |
97 | |||
2834 | cbradney | 98 | ScribusQApp::~ScribusQApp() |
99 | { |
||
100 | PrefsManager::deleteInstance(); |
||
101 | } |
||
102 | |||
2245 | cbradney | 103 | void ScribusQApp::initLang() |
2160 | cbradney | 104 | { |
105 | QStringList langs = getLang(QString(lang)); |
||
106 | |||
107 | if (!langs.isEmpty()) |
||
108 | installTranslators(langs); |
||
2245 | cbradney | 109 | } |
2160 | cbradney | 110 | |
2245 | cbradney | 111 | void ScribusQApp::parseCommandLine() |
112 | { |
||
5342 | cbradney | 113 | showSplash=!neverSplashExists(); |
6839 | cbradney | 114 | QString arg(""); |
2245 | cbradney | 115 | bool usage=false; |
116 | bool header=false; |
||
117 | bool availlangs=false; |
||
118 | bool version=false; |
||
5855 | cbradney | 119 | bool runUpgradeCheck=false; |
2295 | cbradney | 120 | showFontInfo=false; |
7330 | jghali | 121 | showProfileInfo=false; |
3571 | cbradney | 122 | swapDialogButtonOrder=false; |
2245 | cbradney | 123 | |
124 | //Parse for command line information options, and lang |
||
3873 | subik | 125 | for(int i = 1; i < argc(); i++) |
2245 | cbradney | 126 | { |
127 | arg = argv()[i]; |
||
3873 | subik | 128 | |
2245 | cbradney | 129 | if ((arg == ARG_LANG || arg == ARG_LANG_SHORT) && (++i < argc())) { |
130 | lang = argv()[i]; |
||
131 | } |
||
132 | else if (arg == ARG_VERSION || arg == ARG_VERSION_SHORT) { |
||
133 | header=true; |
||
134 | version=true; |
||
135 | } else if (arg == ARG_HELP || arg == ARG_HELP_SHORT) { |
||
136 | header=true; |
||
137 | usage=true; |
||
138 | } else if (arg == ARG_AVAILLANG || arg == ARG_AVAILLANG_SHORT) { |
||
139 | header=true; |
||
140 | availlangs=true; |
||
5855 | cbradney | 141 | } else if (arg == ARG_UPGRADECHECK || arg == ARG_UPGRADECHECK_SHORT) { |
142 | header=true; |
||
143 | runUpgradeCheck=true; |
||
2245 | cbradney | 144 | } |
145 | } |
||
146 | //Init translations |
||
3873 | subik | 147 | initLang(); |
2245 | cbradney | 148 | //Show command line help |
149 | if (header) |
||
150 | showHeader(); |
||
151 | if (version) |
||
152 | showVersion(); |
||
153 | if (availlangs) |
||
154 | showAvailLangs(); |
||
155 | if (usage) |
||
156 | showUsage(); |
||
5855 | cbradney | 157 | if (runUpgradeCheck) |
158 | { |
||
159 | UpgradeChecker uc; |
||
160 | bool error=uc.fetch(); |
||
161 | uc.show(error); |
||
162 | } |
||
2245 | cbradney | 163 | //Dont run the GUI init process called from main.cpp, and return |
2536 | cbradney | 164 | if (!header) |
165 | useGUI=true; |
||
166 | else |
||
2245 | cbradney | 167 | return; |
168 | //We are going to run something other than command line help |
||
169 | for(int i = 1; i < argc(); i++) { |
||
170 | arg = argv()[i]; |
||
3873 | subik | 171 | |
2245 | cbradney | 172 | if ((arg == ARG_LANG || arg == ARG_LANG_SHORT) && (++i < argc())) { |
5598 | jghali | 173 | continue; |
174 | } else if ( arg == ARG_CONSOLE || arg == ARG_CONSOLE_SHORT ) { |
||
175 | continue; |
||
176 | } else if (arg == ARG_NOSPLASH || arg == ARG_NOSPLASH_SHORT) { |
||
2245 | cbradney | 177 | showSplash = false; |
5338 | cbradney | 178 | } |
179 | else if (arg == ARG_NEVERSPLASH || arg == ARG_NEVERSPLASH_SHORT) { |
||
180 | showSplash = false; |
||
5342 | cbradney | 181 | neverSplash(true); |
2245 | cbradney | 182 | } else if (arg == ARG_NOGUI || arg == ARG_NOGUI_SHORT) { |
183 | useGUI=false; |
||
2295 | cbradney | 184 | } else if (arg == ARG_FONTINFO || arg == ARG_FONTINFO_SHORT) { |
185 | showFontInfo=true; |
||
7330 | jghali | 186 | } else if (arg == ARG_PROFILEINFO || arg == ARG_PROFILEINFO_SHORT) { |
187 | showProfileInfo=true; |
||
3571 | cbradney | 188 | } else if (arg == ARG_SWAPDIABUTTONS || arg == ARG_SWAPDIABUTTONS_SHORT) { |
3873 | subik | 189 | swapDialogButtonOrder=true; |
2245 | cbradney | 190 | } else if ((arg == ARG_DISPLAY || arg==ARG_DISPLAY_SHORT || arg==ARG_DISPLAY_QT) && ++i < argc()) { |
191 | // allow setting of display, QT expect the option -display <display_name> so we discard the |
||
192 | // last argument. FIXME: Qt only understands -display not --display and -d , we need to work |
||
193 | // around this. |
||
4126 | cbradney | 194 | } else if (arg == ARG_PREFS || arg == ARG_PREFS_SHORT) { |
3873 | subik | 195 | prefsUserFile = QFile::decodeName(argv()[i + 1]); |
196 | if (!QFileInfo(prefsUserFile).exists()) { |
||
197 | showHeader(); |
||
198 | if (file.left(1) == "-" || file.left(2) == "--") { |
||
4207 | craig | 199 | std::cout << tr("Invalid argument: ").local8Bit() << file << std::endl; |
3873 | subik | 200 | } else { |
4207 | craig | 201 | std::cout << tr("File %1 does not exist, aborting.").arg(file).local8Bit() << std::endl; |
3873 | subik | 202 | } |
203 | showUsage(); |
||
204 | useGUI=false; |
||
205 | return; |
||
206 | } else { |
||
207 | ++i; |
||
208 | } |
||
2245 | cbradney | 209 | } else if (strncmp(arg,"-psn_",4) == 0) |
210 | { |
||
211 | // Andreas Vox: Qt/Mac has -psn_blah flags that must be accepted. |
||
212 | } else { |
||
213 | file = QFile::decodeName(argv()[i]); |
||
214 | if (!QFileInfo(file).exists()) { |
||
215 | showHeader(); |
||
216 | if (file.left(1) == "-" || file.left(2) == "--") { |
||
4207 | craig | 217 | std::cout << tr("Invalid argument: ").local8Bit() << file << std::endl; |
2245 | cbradney | 218 | } else { |
4207 | craig | 219 | std::cout << tr("File %1 does not exist, aborting.").arg(file).local8Bit() << std::endl; |
2245 | cbradney | 220 | } |
221 | showUsage(); |
||
222 | useGUI=false; |
||
223 | return; |
||
224 | } |
||
225 | } |
||
226 | } |
||
227 | } |
||
228 | |||
229 | int ScribusQApp::init() |
||
230 | { |
||
5243 | cbradney | 231 | m_ScCore=new ScribusCore(); |
232 | Q_CHECK_PTR(m_ScCore); |
||
233 | if (!m_ScCore) |
||
234 | return EXIT_FAILURE; |
||
235 | ScCore=m_ScCore; |
||
2160 | cbradney | 236 | processEvents(); |
5243 | cbradney | 237 | ScCore->init(useGUI, swapDialogButtonOrder, file); |
238 | int retVal=EXIT_SUCCESS; |
||
2245 | cbradney | 239 | if (useGUI) |
7330 | jghali | 240 | retVal=ScCore->startGUI(showSplash, showFontInfo, showProfileInfo, lang, prefsUserFile); |
5243 | cbradney | 241 | return retVal; |
2160 | cbradney | 242 | } |
243 | |||
244 | QStringList ScribusQApp::getLang(QString lang) |
||
245 | { |
||
246 | QStringList langs; |
||
247 | |||
248 | // read the locales |
||
2877 | cbradney | 249 | if (!lang.isEmpty()) |
2160 | cbradney | 250 | langs.push_back(lang); |
3873 | subik | 251 | |
2160 | cbradney | 252 | //add in user preferences lang, only overridden by lang command line option |
5917 | jghali | 253 | QString Pff = QDir::convertSeparators(ScPaths::getApplicationDataDir()); |
2160 | cbradney | 254 | QFileInfo Pffi = QFileInfo(Pff); |
255 | if (Pffi.exists()) |
||
256 | { |
||
257 | QString PrefsPfad; |
||
258 | if (Pffi.isDir()) |
||
259 | PrefsPfad = Pff; |
||
260 | else |
||
261 | PrefsPfad = QDir::homeDirPath(); |
||
5508 | cbradney | 262 | QString prefsXMLFile=QDir::convertSeparators(PrefsPfad + "/prefs134.xml"); |
2160 | cbradney | 263 | QFileInfo infoPrefsFile(prefsXMLFile); |
264 | if (infoPrefsFile.exists()) |
||
265 | { |
||
266 | PrefsFile* prefsFile = new PrefsFile(prefsXMLFile); |
||
267 | if (prefsFile) { |
||
268 | PrefsContext* userprefsContext = prefsFile->getContext("user_preferences"); |
||
269 | if (userprefsContext) { |
||
270 | QString prefslang = userprefsContext->get("gui_language",""); |
||
2877 | cbradney | 271 | if (!prefslang.isEmpty()) |
2160 | cbradney | 272 | langs.push_back(prefslang); |
273 | } |
||
274 | } |
||
7645 | cbradney | 275 | delete prefsFile; |
2160 | cbradney | 276 | } |
277 | } |
||
278 | |||
2877 | cbradney | 279 | if (!(lang = ::getenv("LC_ALL")).isEmpty()) |
2160 | cbradney | 280 | langs.push_back(lang); |
2877 | cbradney | 281 | if (!(lang = ::getenv("LC_MESSAGES")).isEmpty()) |
2160 | cbradney | 282 | langs.push_back(lang); |
2877 | cbradney | 283 | if (!(lang = ::getenv("LANG")).isEmpty()) |
2160 | cbradney | 284 | langs.push_back(lang); |
285 | |||
6329 | jghali | 286 | #if defined(_WIN32) |
287 | wchar_t out[256]; |
||
288 | QString language, sublanguage; |
||
289 | LCID lcIdo = GetUserDefaultLCID(); |
||
290 | WORD sortId = SORTIDFROMLCID(lcIdo); |
||
291 | LANGID langId = GetUserDefaultUILanguage(); |
||
292 | LCID lcIdn = MAKELCID(langId, sortId); |
||
293 | if ( GetLocaleInfoW(lcIdn, LOCALE_SISO639LANGNAME , out, 255) ) |
||
294 | { |
||
295 | language = QString::fromUcs2( (ushort*)out ); |
||
296 | if ( GetLocaleInfoW(lcIdn, LOCALE_SISO3166CTRYNAME, out, 255) ) |
||
297 | { |
||
298 | sublanguage = QString::fromUcs2( (ushort*)out ).lower(); |
||
299 | lang = language; |
||
300 | if ( sublanguage != language && !sublanguage.isEmpty() ) |
||
301 | lang += "_" + sublanguage.upper(); |
||
302 | langs.push_back(lang); |
||
303 | } |
||
304 | } |
||
305 | #endif |
||
306 | |||
2160 | cbradney | 307 | langs.push_back(QString(QTextCodec::locale())); |
308 | |||
309 | // remove duplicate entries... |
||
310 | for (QStringList::Iterator it = langs.fromLast(); it != langs.begin(); --it) |
||
311 | if (langs.contains(*it) > 1) |
||
312 | it = langs.remove(it); |
||
313 | |||
314 | return langs; |
||
3873 | subik | 315 | } |
2160 | cbradney | 316 | |
4120 | craig | 317 | void ScribusQApp::installTranslators(const QStringList & langs) |
2160 | cbradney | 318 | { |
2161 | cbradney | 319 | static QTranslator *trans = 0; |
3873 | subik | 320 | |
2161 | cbradney | 321 | if ( trans ) |
322 | { |
||
323 | removeTranslator( trans ); |
||
324 | delete trans; |
||
325 | } |
||
326 | trans = new QTranslator(0); |
||
11051 | malex | 327 | QString path(ScPaths::instance().translationDir()); |
2160 | cbradney | 328 | path += "scribus"; |
329 | |||
330 | bool loaded = false; |
||
4120 | craig | 331 | QString lang; |
5508 | cbradney | 332 | for (QStringList::const_iterator it = langs.constBegin(); it != langs.constEnd() && !loaded; ++it) |
333 | { |
||
2160 | cbradney | 334 | lang=(*it).left(5); |
335 | if (lang == "en") |
||
336 | break; |
||
337 | else if (loaded = trans->load(QString(path + '.' + lang), ".")) |
||
338 | loaded = true; |
||
339 | } |
||
340 | if (loaded) |
||
5508 | cbradney | 341 | { |
2160 | cbradney | 342 | installTranslator(trans); |
5508 | cbradney | 343 | GUILang=lang; |
344 | } |
||
2161 | cbradney | 345 | /* CB TODO, currently disabled, because its broken broken broken |
2160 | cbradney | 346 | path = ScPaths::instance().pluginDir(); |
347 | QDir dir(path , "*.*", QDir::Name, QDir::Files | QDir::NoSymLinks); |
||
348 | if (dir.exists() && (dir.count() != 0)) { |
||
349 | for (uint i = 0; i < dir.count(); ++i) { |
||
350 | QFileInfo file(path + dir[i]); |
||
351 | if ((file.extension(false).lower() == "qm") |
||
352 | && (file.extension(true).lower().left(5) == lang)) { |
||
353 | trans = new QTranslator(0); |
||
354 | trans->load(QString(path + dir[i]), "."); |
||
355 | installTranslator(trans); |
||
356 | } |
||
357 | } |
||
2161 | cbradney | 358 | }*/ |
2160 | cbradney | 359 | } |
360 | |||
4120 | craig | 361 | void ScribusQApp::changeGUILanguage(const QString & newGUILang) |
2160 | cbradney | 362 | { |
363 | QStringList newLangs; |
||
2877 | cbradney | 364 | if (newGUILang.isEmpty()) |
2160 | cbradney | 365 | newLangs.append("en"); |
366 | else |
||
367 | newLangs.append(newGUILang); |
||
368 | installTranslators(newLangs); |
||
369 | } |
||
2245 | cbradney | 370 | |
4650 | subik | 371 | /*! \brief Format an arguments line for printing |
372 | Helper procedure */ |
||
4205 | craig | 373 | static void printArgLine(QTextStream & ts, const char * smallArg, |
374 | const char* fullArg, const QString desc) |
||
375 | { |
||
376 | const char* lineformat = " %1, %2 %3"; |
||
5338 | cbradney | 377 | const int saw = 4; // Short argument width |
4205 | craig | 378 | const int aw = -18; // Argument width (negative is left aligned) |
379 | QString line = QString(lineformat) |
||
380 | .arg(smallArg, saw) |
||
381 | .arg(fullArg, aw) |
||
382 | .arg(desc); |
||
383 | ts << line; |
||
384 | endl(ts); |
||
385 | } |
||
2245 | cbradney | 386 | |
387 | void ScribusQApp::showUsage() |
||
388 | { |
||
4204 | craig | 389 | QFile f; |
390 | f.open(IO_WriteOnly, stderr); |
||
391 | QTextStream ts(&f); |
||
4205 | craig | 392 | ts << tr("Usage: scribus [option ... ] [file]") ; endl(ts); |
393 | ts << tr("Options:") ; endl(ts); |
||
7332 | cbradney | 394 | printArgLine(ts, ARG_FONTINFO_SHORT, ARG_FONTINFO, tr("Show information on the console when fonts are being loaded") ); |
395 | printArgLine(ts, ARG_HELP_SHORT, ARG_HELP, tr("Print help (this message) and exit") ); |
||
396 | printArgLine(ts, ARG_LANG_SHORT, ARG_LANG, tr("Uses xx as shortcut for a language, eg `en' or `de'") ); |
||
397 | printArgLine(ts, ARG_AVAILLANG_SHORT, ARG_AVAILLANG, tr("List the currently installed interface languages") ); |
||
398 | printArgLine(ts, ARG_NOSPLASH_SHORT, ARG_NOSPLASH, tr("Do not show the splashscreen on startup") ); |
||
399 | printArgLine(ts, ARG_NEVERSPLASH_SHORT, ARG_NEVERSPLASH, tr("Stop the showing of the splashscreen on startup. Writes an empty file called .neversplash in ~/.scribus.") ); |
||
400 | printArgLine(ts, ARG_PREFS_SHORT, QString(ARG_PREFS)+" "+ tr("filename"), tr("Use filename as path for user given preferences") ); |
||
401 | printArgLine(ts, ARG_PROFILEINFO_SHORT, ARG_PROFILEINFO, tr("Show location ICC profile information on console while starting") ); |
||
402 | printArgLine(ts, ARG_SWAPDIABUTTONS_SHORT, ARG_SWAPDIABUTTONS, tr("Use right to left dialog button ordering (eg. Cancel/No/Yes instead of Yes/No/Cancel)") ); |
||
403 | printArgLine(ts, ARG_UPGRADECHECK_SHORT, ARG_UPGRADECHECK, tr("Download a file from the Scribus website and show the latest available version.") ); |
||
404 | printArgLine(ts, ARG_VERSION_SHORT, ARG_VERSION, tr("Output version information and exit") ); |
||
405 | |||
406 | |||
5598 | jghali | 407 | #if defined(_WIN32) && !defined(_CONSOLE) |
7332 | cbradney | 408 | printArgLine(ts, ARG_CONSOLE_SHORT, ARG_CONSOLE, tr("Display a console window") ); |
5598 | jghali | 409 | #endif |
4205 | craig | 410 | /* Delete me? |
4204 | craig | 411 | std::cout << "-file|-- name Open file 'name'" ; endl(ts); |
412 | std::cout << "name Open file 'name', the file name must not begin with '-'" ; endl(ts); |
||
413 | std::cout << "QT specific options as -display ..." ; endl(ts); |
||
2245 | cbradney | 414 | */ |
4204 | craig | 415 | endl(ts); |
2245 | cbradney | 416 | } |
417 | |||
418 | void ScribusQApp::showAvailLangs() |
||
419 | { |
||
4205 | craig | 420 | QFile f; |
421 | f.open(IO_WriteOnly, stderr); |
||
422 | QTextStream ts(&f); |
||
423 | ts << tr("Installed interface languages for Scribus are as follows:"); endl(ts); |
||
424 | endl(ts); |
||
2245 | cbradney | 425 | |
426 | LanguageManager langMgr; |
||
427 | langMgr.init(); |
||
428 | langMgr.printInstalledList(); |
||
429 | |||
4205 | craig | 430 | endl(ts); |
431 | ts << tr("To override the default language choice:"); endl(ts); |
||
432 | ts << tr("scribus -l xx or scribus --lang xx, where xx is the language of choice."); endl(ts); |
||
2245 | cbradney | 433 | } |
434 | |||
435 | void ScribusQApp::showVersion() |
||
436 | { |
||
4207 | craig | 437 | std::cout << tr("Scribus Version").local8Bit() << " " << VERSION << std::endl; |
2245 | cbradney | 438 | } |
439 | |||
440 | void ScribusQApp::showHeader() |
||
441 | { |
||
4205 | craig | 442 | QFile f; |
443 | f.open(IO_WriteOnly, stderr); |
||
444 | QTextStream ts(&f); |
||
445 | endl(ts); |
||
446 | QString heading( tr("Scribus, Open Source Desktop Publishing") ); |
||
4207 | craig | 447 | // Build a separator of ----s the same width as the heading |
4205 | craig | 448 | QString separator = QString("").rightJustify(heading.length(),'-'); |
4207 | craig | 449 | // Then output the heading, separator, and docs/www/etc info in an aligned table |
4205 | craig | 450 | const int urlwidth = 23; |
451 | const int descwidth = -(heading.length() - urlwidth - 1); |
||
452 | ts << heading; endl(ts); |
||
453 | ts << separator; endl(ts); |
||
6260 | fschmid | 454 | ts << QString("%1 %2").arg( tr("Homepage")+":", descwidth).arg("http://www.scribus.net" ); endl(ts); |
455 | ts << QString("%1 %2").arg( tr("Documentation")+":", descwidth).arg("http://docs.scribus.net"); endl(ts); |
||
456 | ts << QString("%1 %2").arg( tr("Wiki")+":", descwidth).arg("http://wiki.scribus.net"); endl(ts); |
||
457 | ts << QString("%1 %2").arg( tr("Issues")+":", descwidth).arg("http://bugs.scribus.net"); endl(ts); |
||
4205 | craig | 458 | endl(ts); |
2245 | cbradney | 459 | } |
5338 | cbradney | 460 | |
5342 | cbradney | 461 | void ScribusQApp::neverSplash(bool splashOff) |
5338 | cbradney | 462 | { |
5917 | jghali | 463 | QString prefsDir = ScPaths::getApplicationDataDir(); |
5342 | cbradney | 464 | QFile ns(prefsDir+"/.neversplash"); |
465 | if (splashOff) |
||
5338 | cbradney | 466 | { |
5342 | cbradney | 467 | if (QFileInfo(QDir::homeDirPath()).exists()) |
468 | { |
||
469 | QDir prefsDirectory(prefsDir); |
||
470 | if (!QFileInfo(prefsDir).exists()) |
||
471 | prefsDirectory.mkdir(prefsDir); |
||
472 | if (!ns.exists() && ns.open(IO_WriteOnly)) |
||
473 | ns.close(); |
||
5338 | cbradney | 474 | } |
475 | } |
||
5342 | cbradney | 476 | else |
477 | { |
||
478 | if (neverSplashExists()) |
||
479 | ns.remove(); |
||
480 | } |
||
5338 | cbradney | 481 | } |
482 | |||
483 | bool ScribusQApp::neverSplashExists() |
||
484 | { |
||
5917 | jghali | 485 | return QFileInfo(ScPaths::getApplicationDataDir() + ".neversplash").exists(); |
5338 | cbradney | 486 | } |