18#include "commandlineparser.h"
22#if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0)
25const auto qEndl =
endl;
28CommandLineParser::CommandLineParser() : mParser(), mInputPath(), mOutputPaths(), mCamera()
30 mParser.setApplicationDescription(tr(
"Pencil2D is an animation/drawing software for Mac OS X, Windows, and Linux. "
31 "It lets you create traditional hand-drawn animation (cartoon) using both bitmap and vector graphics."));
32 mParser.addHelpOption();
33 mParser.addVersionOption();
34 mParser.addPositionalArgument(
"input", tr(
"Path to the input pencil file."));
37 tr(
"Render the file to <output_path>"),
39 mParser.addOption(exportOutOption);
43 tr(
"Render the file to <output_path>"),
45#if QT_VERSION >= QT_VERSION_CHECK(5, 8, 0)
48 mParser.addOption(exportSeqOption);
51 tr(
"Name of the camera layer to use"),
53 mParser.addOption(cameraOption);
56 tr(
"Width of the output frames"),
58 mParser.addOption(widthOption);
61 tr(
"Height of the output frames"),
63 mParser.addOption(heightOption);
66 tr(
"The first frame you want to include in the exported movie"),
68 mParser.addOption(startOption);
71 tr(
"The last frame you want to include in the exported movie. "
72 "Can also be last or last-sound to automatically use the last "
73 "frame containing animation or sound, respectively"),
75 mParser.addOption(endOption);
78 tr(
"Render transparency when possible"));
79 mParser.addOption(transparencyOption);
82void CommandLineParser::process(
QStringList arguments)
87 arguments.
removeOne(
"-NSDocumentRevisionsDebugMode");
94 mInputPath = posArgs.
at(0);
97 mOutputPaths << mParser.
values(
"export") << mParser.
values(
"export-sequence");
105 err <<
tr(
"Warning: width value %1 is not an integer, ignoring.").
arg(mParser.
value(
"width")) << qEndl;
116 err <<
tr(
"Warning: height value %1 is not an integer, ignoring.").
arg(mParser.
value(
"height")) << qEndl;
124 mStartFrame = mParser.
value(
"start").
toInt(&ok);
127 err <<
tr(
"Warning: start value %1 is not an integer, ignoring.").
arg(mParser.
value(
"start")) << qEndl;
132 err <<
tr(
"Warning: start value must be at least 1, ignoring.") << qEndl;
139 if (mParser.
value(
"end") ==
"last")
143 else if (mParser.
value(
"end") ==
"last-sound")
153 err <<
tr(
"Warning: end value %1 is not an integer, last or last-sound, ignoring.").
arg(mParser.
value(
"end")) << qEndl;
157 if (mEndFrame > -1 && mEndFrame < mStartFrame)
159 err <<
tr(
"Warning: end value %1 is smaller than start value %2, ignoring.").
arg(mEndFrame).
arg(mStartFrame) << qEndl;
160 mEndFrame = mStartFrame;
164 mTransparency = mParser.
isSet(
"transparency");
166 mCamera = mParser.
value(
"camera");
bool isSet(const QString &name) const const
QStringList positionalArguments() const const
void process(const QStringList &arguments)
QString value(const QString &optionName) const const
QStringList values(const QString &optionName) const const
const T & at(int i) const const
bool isEmpty() const const
bool removeOne(const T &value)
QString tr(const char *sourceText, const char *disambiguation, int n)
QString arg(qlonglong a, int fieldWidth, int base, QChar fillChar) const const
bool isEmpty() const const
int toInt(bool *ok, int base) const const
QTextStream & endl(QTextStream &stream)