18 #include "commandlineparser.h"
20 #include <QTextStream>
22 CommandLineParser::CommandLineParser() : mParser(), mInputPath(), mOutputPaths(), mCamera()
24 mParser.setApplicationDescription(
tr(
"Pencil2D is an animation/drawing software for Mac OS X, Windows, and Linux. "
25 "It lets you create traditional hand-drawn animation (cartoon) using both bitmap and vector graphics."));
26 mParser.addHelpOption();
27 mParser.addVersionOption();
28 mParser.addPositionalArgument(
"input",
tr(
"Path to the input pencil file."));
31 tr(
"Render the file to <output_path>"),
33 mParser.addOption(exportOutOption);
37 tr(
"Render the file to <output_path>"),
39 #if QT_VERSION >= QT_VERSION_CHECK(5, 8, 0)
42 mParser.addOption(exportSeqOption);
45 tr(
"Name of the camera layer to use"),
47 mParser.addOption(cameraOption);
50 tr(
"Width of the output frames"),
52 mParser.addOption(widthOption);
55 tr(
"Height of the output frames"),
57 mParser.addOption(heightOption);
60 tr(
"The first frame you want to include in the exported movie"),
62 mParser.addOption(startOption);
65 tr(
"The last frame you want to include in the exported movie. "
66 "Can also be last or last-sound to automatically use the last "
67 "frame containing animation or sound, respectively"),
69 mParser.addOption(endOption);
72 tr(
"Render transparency when possible"));
73 mParser.addOption(transparencyOption);
76 void CommandLineParser::process(
QStringList arguments)
81 arguments.
removeOne(
"-NSDocumentRevisionsDebugMode");
88 mInputPath = posArgs.
at(0);
91 mOutputPaths << mParser.
values(
"export") << mParser.
values(
"export-sequence");
99 err <<
tr(
"Warning: width value %1 is not an integer, ignoring.").
arg(mParser.
value(
"width")) << endl;
110 err <<
tr(
"Warning: height value %1 is not an integer, ignoring.").
arg(mParser.
value(
"height")) << endl;
118 mStartFrame = mParser.
value(
"start").
toInt(&ok);
121 err <<
tr(
"Warning: start value %1 is not an integer, ignoring.").
arg(mParser.
value(
"start")) << endl;
126 err <<
tr(
"Warning: start value must be at least 1, ignoring.") <<
endl;
133 if (mParser.
value(
"end") ==
"last")
137 else if (mParser.
value(
"end") ==
"last-sound")
147 err <<
tr(
"Warning: end value %1 is not an integer, last or last-sound, ignoring.").
arg(mParser.
value(
"end")) << endl;
151 if (mEndFrame > -1 && mEndFrame < mStartFrame)
153 err <<
tr(
"Warning: end value %1 is smaller than start value %2, ignoring.").
arg(mEndFrame).
arg(mStartFrame) <<
endl;
154 mEndFrame = mStartFrame;
158 mTransparency = mParser.
isSet(
"transparency");
160 mCamera = mParser.
value(
"camera");
QStringList positionalArguments() const const
const T & at(int i) const const
QTextStream & endl(QTextStream &stream)
QString tr(const char *sourceText, const char *disambiguation, int n)
QStringList values(const QString &optionName) const const
int toInt(bool *ok, int base) const const
bool isEmpty() const const
bool isEmpty() const const
bool isSet(const QString &name) const const
void process(const QStringList &arguments)
QString arg(qlonglong a, int fieldWidth, int base, QChar fillChar) const const
bool removeOne(const T &value)
QString value(const QString &optionName) const const