/** * Displays application and version information. */ void Application::about() { QString msg; QTextStream str(&msg); str << "Source browsing, analysis and editing\n"; str << "Version " << applicationVersion() << "\n"; str << "Copyright (c) 2007-2009 by Elad Lahav\n"; str << "Distributed under the terms of the GNU Public License v2"; QMessageBox::about(mainWnd_, applicationName(), msg); }
void FbxAPI::requestAuthorize() { QJsonObject json; json.insert("app_id", applicationId()); json.insert("app_name",applicationName()); json.insert("app_version",applicationVersion()); json.insert("device_name", QHostInfo::localHostName()); QNetworkRequest request = myCreateRequest("login/authorize"); QNetworkReply * reply = post(request,QJsonDocument(json).toJson()); connect(reply,SIGNAL(finished()),this,SLOT(requestAuthorizeFinished())); connect(reply,SIGNAL(error(QNetworkReply::NetworkError)),this,SLOT(errorReceived(QNetworkReply::NetworkError))); }
QSharedPointer<CaptureDevice> TimeLapseCapture::parseArguments() { QCommandLineParser parser; ErrorMessageHelper die(err.device(), &parser); parser.setApplicationDescription("Tool for capture sequence of images from digital camera (V4L or GPhoto2 API)."); parser.addHelpOption(); parser.addVersionOption(); QCommandLineOption outputOption(QStringList() << "o" << "output", QCoreApplication::translate("main", "Output directory."), QCoreApplication::translate("main", "directory")); parser.addOption(outputOption); QCommandLineOption verboseOption(QStringList() << "V" << "verbose", QCoreApplication::translate("main", "Verbose output.")); parser.addOption(verboseOption); QCommandLineOption deviceOption(QStringList() << "d" << "device", QCoreApplication::translate("main", "Capture device."), QCoreApplication::translate("main", "device")); parser.addOption(deviceOption); QCommandLineOption listOption(QStringList() << "l" << "list", QCoreApplication::translate("main", "List available capture devices and exits.")); parser.addOption(listOption); QCommandLineOption intervalOption(QStringList() << "i" << "interval", QCoreApplication::translate("main", "Capture interval (in milliseconds). Default is 10000."), QCoreApplication::translate("main", "interval")); parser.addOption(intervalOption); QCommandLineOption cntOption(QStringList() << "c" << "count", QCoreApplication::translate("main", "How many images should be captured. Default value is infinite."), QCoreApplication::translate("main", "count")); parser.addOption(cntOption); QCommandLineOption rowOption(QStringList() << "r" << "raw", QCoreApplication::translate("main", "Store all captured images in raw.")); parser.addOption(rowOption); QCommandLineOption getShutterSpeedOption(QStringList() << "s" << "shutterspeed-options", QCoreApplication::translate("main", "Prints available shutterspeed setting choices and exits.")); parser.addOption(getShutterSpeedOption); QCommandLineOption adaptiveShutterSpeedOption(QStringList() << "a" << "adaptive-shutterspeed", QCoreApplication::translate("main", "Camera shutterspeed will be adaptively changed after exposure metering.\n" "This option setup how many images should be used for exposure metering. \n" "Default value is 0 - it means that shutterspeed will not be changed by capture tool." ), QCoreApplication::translate("main", "count")); parser.addOption(adaptiveShutterSpeedOption); QCommandLineOption shutterSpeedStepOption(QStringList() << "shutterspeed-step", QCoreApplication::translate("main", "How large should be step when changing shutterspeed. \n" "Default value is 1." ), QCoreApplication::translate("main", "step")); parser.addOption(shutterSpeedStepOption); QCommandLineOption minShutterSpeedOption(QStringList() << "min-shutterspeed", QCoreApplication::translate("main", "Minimum shutterspeed (fastest shutter) used by adaptive shutterspeed"), QCoreApplication::translate("main", "shutterspeed")); parser.addOption(minShutterSpeedOption); QCommandLineOption maxShutterSpeedOption(QStringList() << "max-shutterspeed", QCoreApplication::translate("main", "Maximum shutterspeed (slowest shutter) used by adaptive shutterspeed.\n" "If camera supports BULB shutterspeed, it can be defined as \"BULB:XX\" here (it means bulb with XX s exposure)." ), QCoreApplication::translate("main", "shutterspeed")); parser.addOption(maxShutterSpeedOption); // Process the actual command line arguments given by the user parser.process(*this); // verbose? if (!parser.isSet(verboseOption)) { blackHole = new BlackHoleDevice(); verboseOutput.setDevice(blackHole); } else { // verbose verboseOutput << "Turning on verbose output..." << endl; verboseOutput << applicationName() << " " << applicationVersion() << endl; } // raw? storeRawImages = parser.isSet(rowOption); // interval if (parser.isSet(intervalOption)) { bool ok = false; long i = parser.value(intervalOption).toLong(&ok); if (!ok) die << "Cant parse interval."; if (i <= 0) die << "Interval have to be possitive"; interval = i; } // count if (parser.isSet(cntOption)) { bool ok = false; int i = parser.value(cntOption).toInt(&ok); if (!ok) die << "Cant parse count."; cnt = i; } // list devices? QList<QSharedPointer < CaptureDevice>> devices = listDevices(); QSharedPointer<CaptureDevice> dev; if (parser.isSet(listOption)) { if (devices.isEmpty()) { die << QCoreApplication::translate("main", "No compatible capture device found"); } else { out << "Found devices: " << endl; for (QSharedPointer<CaptureDevice> d : devices) { out << " " << d->toString() << endl; } } std::exit(0); } // capture device bool assigned = false; if (!parser.isSet(deviceOption)) { verboseOutput << "Found devices: " << endl; for (QSharedPointer<CaptureDevice> d : devices) { if (!assigned) { dev = d; assigned = true; } verboseOutput << " " << d->toString() << endl; } if (!assigned) die << "No supported device."; } else { QString devVal = parser.value(deviceOption); for (QSharedPointer<CaptureDevice> d : devices) { if (d->toString().contains(devVal, Qt::CaseInsensitive)) { assigned = true; dev = d; break; } } if (!assigned) { die << QString("No device matching \"%1\" found.").arg(devVal); } } out << "Using device " << dev->toString() << endl; // getShutterSpeedOption ? QList<ShutterSpeedChoice> choices = dev->getShutterSpeedChoices(); if (parser.isSet(getShutterSpeedOption)) { if (choices.isEmpty()) { err << "Device " << dev->toShortString() << " don't support shutterspeed setting" << endl; } else { out << "Device " << dev->toShortString() << " shutterspeed choices:" << endl; for (ShutterSpeedChoice ch : choices) { out << " " << ch.toString() << endl; } out << "Current shutter speed: " << dev->currentShutterSpeed().toString() << endl; } std::exit(0); } // automatic chutter speed // this functionality is experimental! if (parser.isSet(adaptiveShutterSpeedOption)) { bool ok = false; int changeThreshold = parser.value(adaptiveShutterSpeedOption).toInt(&ok); if (!ok) die << "Cant parse adaptive shutterspeed option."; if (changeThreshold > 0) { if (choices.isEmpty()) { die << "Camera don't support shutterspeed setting."; } else { ShutterSpeedChoice currentShutterSpeed; ShutterSpeedChoice minShutterSpeed; ShutterSpeedChoice maxShutterSpeed; currentShutterSpeed = dev->currentShutterSpeed(); minShutterSpeed = choices.first(); for (ShutterSpeedChoice ch : choices) { if ((!ch.isBulb()) && ch.toMicrosecond() > maxShutterSpeed.toMicrosecond()) maxShutterSpeed = ch; } int shutterSpeedStep = 1; if (parser.isSet(shutterSpeedStepOption)) { bool ok = false; shutterSpeedStep = parser.value(shutterSpeedStepOption).toInt(&ok); if (!ok) die << "Cant parse shutterspeed step."; if (shutterSpeedStep < 1) die << "Shutterspeed step can be less than one."; } if (parser.isSet(minShutterSpeedOption)) { QString optStr = parser.value(minShutterSpeedOption); minShutterSpeed = getShutterSpeed(optStr, choices, &die); } if (parser.isSet(maxShutterSpeedOption)) { QString optStr = parser.value(maxShutterSpeedOption); maxShutterSpeed = getShutterSpeed(optStr, choices, &die); } out << "Using automatic shutter speed:" << endl; out << " current shutter speed: " << currentShutterSpeed.toString() << endl; out << " min shutter speed: " << minShutterSpeed.toString() << endl; out << " max shutter speed: " << maxShutterSpeed.toString() << endl; out << " change threshold: " << changeThreshold << endl; out << " change step: " << shutterSpeedStep << endl; if (minShutterSpeed.toMicrosecond() <= 0 || maxShutterSpeed.toMicrosecond() <= 0 || maxShutterSpeed.toMicrosecond() < minShutterSpeed.toMicrosecond()) die << "Invalid shutter speed configurarion"; if (maxShutterSpeed.toMs() > interval) { err << QString("Warning: Maximum shutter speed (%1 ms) is greater than capture interval (%2 ms)!") .arg(maxShutterSpeed.toMs()) .arg(interval) << endl; } shutterSpdAlg = new MatrixMeteringAlg(choices, currentShutterSpeed, minShutterSpeed, maxShutterSpeed, &err, &verboseOutput, changeThreshold, shutterSpeedStep); } } } // output if (!parser.isSet(outputOption)) die << "Output directory is not set"; output = QDir(parser.value(outputOption)); if (output.exists()) err << "Output directory exists already." << endl; if (!output.mkpath(".")) die << QString("Can't create output directory %1 !").arg(output.path()); return dev; }
void Application::parseArguments(QStringList args) { QFileInfo program(args.at(0)); QString programName("renderer"); if (program.exists()) programName = program.baseName(); if (args.contains("-h") || args.contains("-help") || args.contains("--help")) { std::cout << "Usage: " << programName.toLatin1().data() << " [-version]" << " [-gui]" << " [-bookjs path]" << " [-custom-css path]" << " [-output path]" << " URL" << std::endl; appQuit(0); } if (args.contains("-version")) { std::cout << applicationName().toLatin1().data() << " " << applicationVersion().toLatin1().data() #if defined(Q_PROCESSOR_X86_32) << " x86" #elif defined(Q_PROCESSOR_X86_64) << " amd64" #endif << std::endl; appQuit(0); } m_gui = args.contains("-gui"); int bookjsPathIndex = args.indexOf("-bookjs"); if (bookjsPathIndex != -1) { QString path = takeOptionValue(&args, bookjsPathIndex); QDir dir(path); if (! dir.exists()) { appQuit(1, QString("path does not point to a directory: %1").arg(path)); } m_rendererOptions.bookjsPath = dir.absolutePath(); } int cssPathIndex = args.indexOf("-custom-css"); if (cssPathIndex != -1) { QString path = takeOptionValue(&args, cssPathIndex); if (! QFileInfo(path).isReadable()) { appQuit(1, QString("file does not exist or is not readable: %1").arg(path)); } QFile file(path); if (! file.open(QFile::ReadOnly)) { appQuit(1, QString("cout not open file: %1").arg(path)); } m_rendererOptions.customCSS = QTextStream(&file).readAll(); } int outputPathIndex = args.indexOf("-output"); if (outputPathIndex != -1) m_rendererOptions.outputFilePath = takeOptionValue(&args, outputPathIndex); int lastArg = args.lastIndexOf(QRegExp("^-.*")); m_urls = (lastArg != -1) ? args.mid(++lastArg) : args.mid(1); }