void ScribusQApp::neverSplash(bool splashOff) { QString prefsDir = ScPaths::getApplicationDataDir(); QFile ns(prefsDir + ".neversplash"); if (splashOff) { if (QFileInfo(QDir::homePath()).exists()) { QDir prefsDirectory(prefsDir); if (!QFileInfo(prefsDir).exists()) prefsDirectory.mkdir(prefsDir); if (!ns.exists() && ns.open(QIODevice::WriteOnly)) ns.close(); } } else { if (neverSplashExists()) ns.remove(); } }
void ScribusQApp::parseCommandLine() { m_showSplash=!neverSplashExists(); QString arg(""); bool usage=false; bool header=false; bool availlangs=false; bool version=false; bool runUpgradeCheck=false; #ifdef WITH_TESTS bool runtests = false; char** testargsv; int testargsc; #endif m_showFontInfo=false; m_showProfileInfo=false; bool neversplash = false; //Parse for command line options // Qt5 port: do this in a Qt compatible manner QStringList args = arguments(); int argsc = args.count(); useGUI = true; int argi = 1; for( ; argi < argsc; argi++) { //handle options (not positional parameters) arg = args[argi]; if (arg == ARG_PYTHONSCRIPT || arg == ARG_PYTHONSCRIPT_SHORT) { if (argi+1 == argsc) { std::cout << tr("Option %1 requires an argument.").arg(arg).toLocal8Bit().data() << std::endl; std::exit(EXIT_FAILURE); } pythonScript = QFile::decodeName(args[argi + 1].toLocal8Bit()); if (!QFileInfo(pythonScript).exists()) { std::cout << tr("Python script %1 does not exist, aborting.").arg(pythonScript).toLocal8Bit().data() << std::endl; std::exit(EXIT_FAILURE); } ++argi; while (++argi < argsc && (args[argi] != CMD_OPTIONS_END)) { pythonScriptArgs.append(args[argi]); // script argument } // We reached end of all arguments or CMD_OPTIONS_END marker. Stop parsing options if (argi < argsc) { argi++; // skip CMD_OPTIONS_END } break; } else if ((arg == ARG_LANG || arg == ARG_LANG_SHORT)) { if (++argi < argsc) m_lang = args[argi]; else { std::cout << tr("Option %1 requires an argument.").arg(arg).toLocal8Bit().data() << std::endl; std::exit(EXIT_FAILURE); } } else if (arg == ARG_VERSION || arg == ARG_VERSION_SHORT) { header=true; version=true; } else if (arg == ARG_HELP || arg == ARG_HELP_SHORT) { header=true; usage=true; } #ifdef WITH_TESTS else if (arg == ARG_TESTS || arg == ARG_TESTS_SHORT) { header=true; runtests=true; testargsc = argc() - argi; testargsv = argv() + argi; break; } #endif else if (arg == ARG_AVAILLANG || arg == ARG_AVAILLANG_SHORT) { header=true; availlangs=true; } else if (arg == ARG_UPGRADECHECK || arg == ARG_UPGRADECHECK_SHORT) { header=true; runUpgradeCheck=true; } else if ( arg == ARG_CONSOLE || arg == ARG_CONSOLE_SHORT ) { continue; } else if (arg == ARG_NOSPLASH || arg == ARG_NOSPLASH_SHORT) { m_showSplash = false; } else if (arg == ARG_NEVERSPLASH || arg == ARG_NEVERSPLASH_SHORT) { m_showSplash = false; neversplash = true; } else if (arg == ARG_NOGUI || arg == ARG_NOGUI_SHORT) { useGUI=false; } else if (arg == ARG_FONTINFO || arg == ARG_FONTINFO_SHORT) { m_showFontInfo=true; } else if (arg == ARG_PROFILEINFO || arg == ARG_PROFILEINFO_SHORT) { m_showProfileInfo=true; } else if ((arg == ARG_DISPLAY || arg==ARG_DISPLAY_SHORT || arg==ARG_DISPLAY_QT) && ++argi < argsc) { // allow setting of display, QT expect the option -display <display_name> so we discard the // last argument. FIXME: Qt only understands -display not --display and -d , we need to work // around this. } else if (arg == ARG_PREFS || arg == ARG_PREFS_SHORT) { if (argi+1 == argsc) { std::cout << tr("Option %1 requires an argument.").arg(arg).toLocal8Bit().data() << std::endl; std::exit(EXIT_FAILURE); } m_prefsUserFile = QFile::decodeName(args[argi + 1].toLocal8Bit()); if (!QFileInfo(m_prefsUserFile).exists()) { std::cout << tr("Preferences file %1 does not exist, aborting.").arg(m_prefsUserFile).toLocal8Bit().data() << std::endl; std::exit(EXIT_FAILURE); } else { ++argi; } } else if (strncmp(arg.toLocal8Bit().data(),"-psn_",4) == 0) { // Andreas Vox: Qt/Mac has -psn_blah flags that must be accepted. } else if (arg == CMD_OPTIONS_END) { //double dash, indicates end of command line options, see http://unix.stackexchange.com/questions/11376/what-does-double-dash-mean-also-known-as-bare-double-dash argi++; break; } else { //argument is not a known option, but either positional parameter or invalid. if (arg.left(1) == "-") { std::cout << tr("Invalid argument: %1").arg(arg).toLocal8Bit().data() << std::endl; std::exit(EXIT_FAILURE); } m_fileName = QFile::decodeName(args[argi].toLocal8Bit()); if (!QFileInfo(m_fileName).exists()) { std::cout << tr("File %1 does not exist, aborting.").arg(m_fileName).toLocal8Bit().data() << std::endl; std::exit(EXIT_FAILURE); } else { m_filesToLoad.append(m_fileName); } } } // parse for remaining (positional) arguments, if any for ( ; argi<argsc; argi++) { m_fileName = QFile::decodeName(args[argi].toLocal8Bit()); if (!QFileInfo(m_fileName).exists()) { std::cout << tr("File %1 does not exist, aborting.").arg(m_fileName).toLocal8Bit().data() << std::endl; std::exit(EXIT_FAILURE); } else { m_filesToLoad.append(m_fileName); } } //Init translations initLang(); //Show command line info if (header) { useGUI = false; showHeader(); } if (version) showVersion(); if (availlangs) showAvailLangs(); if (usage) showUsage(); #ifdef WITH_TESTS if (runtests) RunTests::runTests(testargsc, testargsv); #endif if (runUpgradeCheck) { UpgradeChecker uc; uc.fetch(); } //Don't run the GUI init process called from main.cpp, and return if (header) std::exit(EXIT_SUCCESS); //proceed if(neversplash) neverSplash(true); }
void ScribusQApp::parseCommandLine() { showSplash=!neverSplashExists(); QString arg(""); bool usage=false; bool header=false; bool availlangs=false; bool version=false; bool runUpgradeCheck=false; showFontInfo=false; showProfileInfo=false; swapDialogButtonOrder=false; //Parse for command line information options, and lang for(int i = 1; i < argc(); i++) { arg = argv()[i]; if ((arg == ARG_LANG || arg == ARG_LANG_SHORT) && (++i < argc())) { lang = argv()[i]; } else if (arg == ARG_VERSION || arg == ARG_VERSION_SHORT) { header=true; version=true; } else if (arg == ARG_HELP || arg == ARG_HELP_SHORT) { header=true; usage=true; } else if (arg == ARG_AVAILLANG || arg == ARG_AVAILLANG_SHORT) { header=true; availlangs=true; } else if (arg == ARG_UPGRADECHECK || arg == ARG_UPGRADECHECK_SHORT) { header=true; runUpgradeCheck=true; } } //Init translations initLang(); //Show command line help if (header) showHeader(); if (version) showVersion(); if (availlangs) showAvailLangs(); if (usage) showUsage(); if (runUpgradeCheck) { UpgradeChecker uc; uc.fetch(); } //Dont run the GUI init process called from main.cpp, and return if (!header) useGUI=true; else return; //We are going to run something other than command line help for(int i = 1; i < argc(); i++) { arg = argv()[i]; if ((arg == ARG_LANG || arg == ARG_LANG_SHORT) && (++i < argc())) { continue; } else if ( arg == ARG_CONSOLE || arg == ARG_CONSOLE_SHORT ) { continue; } else if (arg == ARG_NOSPLASH || arg == ARG_NOSPLASH_SHORT) { showSplash = false; } else if (arg == ARG_NEVERSPLASH || arg == ARG_NEVERSPLASH_SHORT) { showSplash = false; neverSplash(true); } else if (arg == ARG_NOGUI || arg == ARG_NOGUI_SHORT) { useGUI=false; } else if (arg == ARG_FONTINFO || arg == ARG_FONTINFO_SHORT) { showFontInfo=true; } else if (arg == ARG_PROFILEINFO || arg == ARG_PROFILEINFO_SHORT) { showProfileInfo=true; } else if (arg == ARG_SWAPDIABUTTONS || arg == ARG_SWAPDIABUTTONS_SHORT) { swapDialogButtonOrder=true; } else if ((arg == ARG_DISPLAY || arg==ARG_DISPLAY_SHORT || arg==ARG_DISPLAY_QT) && ++i < argc()) { // allow setting of display, QT expect the option -display <display_name> so we discard the // last argument. FIXME: Qt only understands -display not --display and -d , we need to work // around this. } else if (arg == ARG_PREFS || arg == ARG_PREFS_SHORT) { prefsUserFile = QFile::decodeName(argv()[i + 1]); if (!QFileInfo(prefsUserFile).exists()) { showHeader(); if (fileName.left(1) == "-" || fileName.left(2) == "--") { std::cout << tr("Invalid argument: ").toLocal8Bit().data() << fileName.toLocal8Bit().data() << std::endl; } else { std::cout << tr("File %1 does not exist, aborting.").arg(fileName).toLocal8Bit().data() << std::endl; } showUsage(); useGUI=false; return; } else { ++i; } } else if (strncmp(arg.toLocal8Bit().data(),"-psn_",4) == 0) { // Andreas Vox: Qt/Mac has -psn_blah flags that must be accepted. } else { fileName = QFile::decodeName(argv()[i]); if (!QFileInfo(fileName).exists()) { showHeader(); if (fileName.left(1) == "-" || fileName.left(2) == "--") { std::cout << tr("Invalid argument: %1").arg(fileName).toLocal8Bit().data() << std::endl; } else { std::cout << tr("File %1 does not exist, aborting.").arg(fileName).toLocal8Bit().data() << std::endl; } showUsage(); useGUI=false; return; } else { filesToLoad.append(fileName); } } } }
void ScribusQApp::parseCommandLine() { showSplash=!neverSplashExists(); QString arg(""); bool usage=false; bool header=false; bool availlangs=false; bool version=false; bool runUpgradeCheck=false; #ifdef WITH_TESTS bool runtests = false; char** testargsv; int testargsc; #endif showFontInfo=false; showProfileInfo=false; //Parse for command line information options, and lang // Qt5 port: do this in a Qt compatible manner QStringList args = arguments(); int argsc = args.count(); for(int i = 1; i < argsc; i++) { arg = args[i]; if ((arg == ARG_LANG || arg == ARG_LANG_SHORT) && (++i < argsc)) { lang = args[i]; } else if (arg == ARG_VERSION || arg == ARG_VERSION_SHORT) { header=true; version=true; } else if (arg == ARG_HELP || arg == ARG_HELP_SHORT) { header=true; usage=true; } #ifdef WITH_TESTS else if (arg == ARG_TESTS || arg == ARG_TESTS_SHORT) { header=true; runtests=true; testargsc = argc() - i; testargsv = argv() + i; break; } #endif else if (arg == ARG_AVAILLANG || arg == ARG_AVAILLANG_SHORT) { header=true; availlangs=true; } else if (arg == ARG_UPGRADECHECK || arg == ARG_UPGRADECHECK_SHORT) { header=true; runUpgradeCheck=true; } } //Init translations initLang(); //Show command line help if (header) showHeader(); if (version) showVersion(); if (availlangs) showAvailLangs(); if (usage) showUsage(); #ifdef WITH_TESTS if (runtests) RunTests::runTests(testargsc, testargsv); #endif if (runUpgradeCheck) { UpgradeChecker uc; uc.fetch(); } //Dont run the GUI init process called from main.cpp, and return if (header) std::exit(EXIT_SUCCESS); useGUI = true; //We are going to run something other than command line help for(int i = 1; i < argsc; i++) { arg = args[i]; if ((arg == ARG_LANG || arg == ARG_LANG_SHORT) && (++i < argsc)) { continue; } else if ( arg == ARG_CONSOLE || arg == ARG_CONSOLE_SHORT ) { continue; } else if (arg == ARG_NOSPLASH || arg == ARG_NOSPLASH_SHORT) { showSplash = false; } else if (arg == ARG_NEVERSPLASH || arg == ARG_NEVERSPLASH_SHORT) { showSplash = false; neverSplash(true); } else if (arg == ARG_NOGUI || arg == ARG_NOGUI_SHORT) { useGUI=false; } else if (arg == ARG_FONTINFO || arg == ARG_FONTINFO_SHORT) { showFontInfo=true; } else if (arg == ARG_PROFILEINFO || arg == ARG_PROFILEINFO_SHORT) { showProfileInfo=true; } else if ((arg == ARG_DISPLAY || arg==ARG_DISPLAY_SHORT || arg==ARG_DISPLAY_QT) && ++i < argsc) { // allow setting of display, QT expect the option -display <display_name> so we discard the // last argument. FIXME: Qt only understands -display not --display and -d , we need to work // around this. } else if (arg == ARG_PREFS || arg == ARG_PREFS_SHORT) { prefsUserFile = QFile::decodeName(args[i + 1].toLocal8Bit()); if (!QFileInfo(prefsUserFile).exists()) { showHeader(); if (prefsUserFile.left(1) == "-" || prefsUserFile.left(2) == "--") { std::cout << tr("Invalid argument: ").toLocal8Bit().data() << prefsUserFile.toLocal8Bit().data() << std::endl; } else { std::cout << tr("File %1 does not exist, aborting.").arg(prefsUserFile).toLocal8Bit().data() << std::endl; } showUsage(); std::exit(EXIT_FAILURE); } else { ++i; } } else if (strncmp(arg.toLocal8Bit().data(),"-psn_",4) == 0) { // Andreas Vox: Qt/Mac has -psn_blah flags that must be accepted. } else if (arg == ARG_PYTHONSCRIPT || arg == ARG_PYTHONSCRIPT_SHORT) { pythonScript = QFile::decodeName(args[i + 1].toLocal8Bit()); if (!QFileInfo(pythonScript).exists()) { showHeader(); if (pythonScript.left(1) == "-" || pythonScript.left(2) == "--") { std::cout << tr("Invalid argument: ").toLocal8Bit().data() << pythonScript.toLocal8Bit().data() << std::endl; } else { std::cout << tr("File %1 does not exist, aborting.").arg(pythonScript).toLocal8Bit().data() << std::endl; } showUsage(); std::exit(EXIT_FAILURE); } else { ++i; } } else { fileName = QFile::decodeName(args[i].toLocal8Bit()); if (!QFileInfo(fileName).exists()) { showHeader(); if (fileName.left(1) == "-" || fileName.left(2) == "--") { std::cout << tr("Invalid argument: %1").arg(fileName).toLocal8Bit().data() << std::endl; } else { std::cout << tr("File %1 does not exist, aborting.").arg(fileName).toLocal8Bit().data() << std::endl; } showUsage(); std::exit(EXIT_FAILURE); } else { filesToLoad.append(fileName); } } } }