CLIProcessor.cpp   CLIProcessor.cpp 
skipping to change at line 30 skipping to change at line 30
#include "CLIProcessor.hpp" #include "CLIProcessor.hpp"
#include "StelFileMgr.hpp" #include "StelFileMgr.hpp"
#include "StelUtils.hpp" #include "StelUtils.hpp"
#include <QSettings> #include <QSettings>
#include <QDateTime> #include <QDateTime>
#include <QDebug> #include <QDebug>
#include <iostream> #include <iostream>
#include <QGuiApplication> #include <QGuiApplication>
#include <QStandardPaths>
#include <QDir> #include <QDir>
#include <stdio.h> #include <stdio.h>
void CLIProcessor::parseCLIArgsPreConfig(const QStringList& argList) void CLIProcessor::parseCLIArgsPreConfig(const QStringList& argList)
{ {
if (argsGetOption(argList, "-v", "--version")) if (argsGetOption(argList, "-v", "--version"))
{ {
std::cout << qPrintable(StelUtils::getApplicationName()) << std::endl; std::cout << qPrintable(StelUtils::getApplicationName()) << std::endl;
exit(0); exit(0);
skipping to change at line 235 skipping to change at line 236
{ {
try try
{ {
StelFileMgr::setScreenshotDir(confScreenshot Dir); StelFileMgr::setScreenshotDir(confScreenshot Dir);
} }
catch (std::runtime_error& e) catch (std::runtime_error& e)
{ {
qWarning() << "WARNING: problem while settin g screenshot from config file setting: " << e.what(); qWarning() << "WARNING: problem while settin g screenshot from config file setting: " << e.what();
} }
} }
else
{
QString screenshotDirSuffix = "/Stellarium";
if (!QStandardPaths::standardLocations(QStandardPath
s::PicturesLocation).isEmpty())
screenshotDir = QStandardPaths::standardLoca
tions(QStandardPaths::PicturesLocation)[0].append(screenshotDirSuffix);
else
screenshotDir = StelFileMgr::getUserDir().ap
pend(screenshotDirSuffix);
try
{
StelFileMgr::setScreenshotDir(screenshotDir)
;
confSettings->setValue("main/screenshot_dir"
, screenshotDir);
}
catch (std::runtime_error &e)
{
qDebug("Error: cannot create screenshot dire
ctory: %s", e.what());
}
}
} }
} }
bool CLIProcessor::argsGetOption(const QStringList& args, QString shortOpt, QString longOpt) bool CLIProcessor::argsGetOption(const QStringList& args, QString shortOpt, QString longOpt)
{ {
bool result=false; bool result=false;
// Don't see anything after a -- as an option // Don't see anything after a -- as an option
int lastOptIdx = args.indexOf("--"); int lastOptIdx = args.indexOf("--");
if (lastOptIdx == -1) if (lastOptIdx == -1)
skipping to change at line 271 skipping to change at line 290
int lastOptIdx = args.indexOf("--"); int lastOptIdx = args.indexOf("--");
if (lastOptIdx == -1) if (lastOptIdx == -1)
lastOptIdx = args.size(); lastOptIdx = args.size();
for (int i=0; i<lastOptIdx; i++) for (int i=0; i<lastOptIdx; i++)
{ {
bool match(false); bool match(false);
QString argStr; QString argStr;
// form -n=arg // form -n=arg
if ((shortOpt!="" && args.at(i).left(shortOpt.length()+1)==s hortOpt+"=")) if ((!shortOpt.isEmpty() && args.at(i).left(shortOpt.length( )+1)==shortOpt+"="))
{ {
match=true; match=true;
argStr=args.at(i).right(args.at(i).length() - shortO pt.length() - 1); argStr=args.at(i).right(args.at(i).length() - shortO pt.length() - 1);
} }
// form --number=arg // form --number=arg
else if (args.at(i).left(longOpt.length()+1)==longOpt+"=") else if (args.at(i).left(longOpt.length()+1)==longOpt+"=")
{ {
match=true; match=true;
argStr=args.at(i).right(args.at(i).length() - longOp t.length() - 1); argStr=args.at(i).right(args.at(i).length() - longOp t.length() - 1);
} }
// forms -n arg and --number arg // forms -n arg and --number arg
else if ((shortOpt!="" && args.at(i)==shortOpt) || args.at(i )==longOpt) else if ((!shortOpt.isEmpty() && args.at(i)==shortOpt) || ar gs.at(i)==longOpt)
{ {
if (i+1>=lastOptIdx) if (i+1>=lastOptIdx)
{ {
throw (std::runtime_error(qPrintable("optarg _missing ("+longOpt+")"))); throw (std::runtime_error(qPrintable("optarg _missing ("+longOpt+")")));
} }
else else
{ {
match=true; match=true;
argStr=args.at(i+1); argStr=args.at(i+1);
i++; // skip option argument in next iterat ion i++; // skip option argument in next iterat ion
 End of changes. 4 change blocks. 
2 lines changed or deleted 27 lines changed or added

This html diff was produced by rfcdiff 1.41. The latest version is available from http://tools.ietf.org/tools/rfcdiff/