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); } } } }
//------------------------------------------------------------------ int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE, LPSTR, int cmdShow) { int i; HDC dc; MSG mesg; RECT rc; inst = hInstance; //DPIAware typedef BOOL(WINAPI *TGetProcAddress)(); TGetProcAddress getProcAddress = (TGetProcAddress)GetProcAddress(GetModuleHandle(_T("user32")), "SetProcessDPIAware"); if(getProcAddress) getProcAddress(); memset(custom, 200, sizeof(custom)); _tcscpy(pdfObject.fn, _T("sudoku.pdf")); pdfObject.pageWidth=595; pdfObject.pageHeight=842; pdfObject.count=6; pdfObject.countPerPage=6; pdfObject.border=40; pdfObject.spacing=20; readini(); //load common controls #if _WIN32_IE >= 0x0300 INITCOMMONCONTROLSEX iccs; iccs.dwSize= sizeof(INITCOMMONCONTROLSEX); iccs.dwICC= ICC_BAR_CLASSES; InitCommonControlsEx(&iccs); #else InitCommonControls(); #endif // create the main window WNDCLASS wc; ZeroMemory(&wc, sizeof(wc)); wc.lpfnWndProc = WndMainProc; wc.hInstance = inst; wc.lpszClassName = CLASSNAME; wc.lpszMenuName = MAKEINTRESOURCE(IDR_MENU); wc.hCursor = LoadCursor(NULL, IDC_ARROW); wc.hIcon = LoadIcon(inst, MAKEINTRESOURCE(IDI_MAINICON)); if(!RegisterClass(&wc)){ #ifdef UNICODE msg("This version cannot run on Windows 95/98/ME."); #else msg("RegisterClass failed"); #endif return 2; } scrW= GetSystemMetrics(SM_CXSCREEN); scrH= GetSystemMetrics(SM_CYSCREEN); aminmax(mainLeft, 0, scrW-50); aminmax(mainTop, 0, scrH-50); hWin = CreateWindow(CLASSNAME, title, WS_OVERLAPPEDWINDOW | WS_CAPTION | WS_CLIPCHILDREN, mainLeft, mainTop, mainW, mainH, 0, 0, inst, 0); if(!hWin){ msg("CreateWindow failed"); return 3; } haccel= LoadAccelerators(inst, MAKEINTRESOURCE(IDR_ACCELERATOR)); Naccel= CopyAcceleratorTable(haccel, accel, sizeA(accel)); initLang(); //create status bar statusbar= CreateStatusWindow(WS_CHILD, 0, hWin, 1); static int parts[]={100, 140, 210, 230, -1}; dc=GetDC(hWin); for(i=0; i<sizeA(parts)-1; i++){ parts[i]=parts[i]*GetDeviceCaps(dc, LOGPIXELSX)/96; } ReleaseDC(hWin, dc); SendMessage(statusbar, SB_SETPARTS, sizeA(parts), (LPARAM)parts); ShowWindow(statusbar, SW_SHOW); //create tool bar i=sizeA(tbb); for(TBBUTTON *u=tbb; u<endA(tbb); u++){ if(u->fsStyle==TBSTYLE_SEP) i--; } toolbar = CreateToolbarEx(hWin, WS_CHILD|TBSTYLE_TOOLTIPS, 2, i, inst, IDB_TOOLBAR, tbb, sizeA(tbb), 16, 16, 16, 15, sizeof(TBBUTTON)); GetClientRect(toolbar, &rc); MapWindowPoints(toolbar, hWin, (POINT*)&rc, 2); toolH= rc.bottom; if(toolBarVisible) ShowWindow(toolbar, SW_SHOW); langChanged(); ShowWindow(hWin, cmdShow); initSquare(false); UpdateWindow(hWin); toolBitmap(); numButtons(); while(GetMessage(&mesg, NULL, 0, 0)==TRUE){ if(!TranslateAccelerator(hWin, haccel, &mesg)){ TranslateMessage(&mesg); DispatchMessage(&mesg); } } if(delreg) deleteini(HKEY_CURRENT_USER); return 0; }
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; #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); } } } }