Clean Puzzle's command line keys.

Remove unused keys.
This commit is contained in:
Roman Telezhynskyi 2023-04-10 13:41:44 +03:00
parent 7dd8aa0058
commit c88da992a0
7 changed files with 5 additions and 205 deletions

28
dist/debian/puzzle.1 vendored
View File

@ -1,6 +1,6 @@
.\" Manpage for puzzle
.\" Contact dismine@gmail.com to correct errors.
.TH puzzle 1 "23 March, 2020" "puzzle man page"
.TH puzzle 1 "10 April, 2023" "puzzle man page"
.SH NAME
Puzzle \- Valentina's manual layout
.SH SYNOPSIS
@ -15,34 +15,8 @@ is a part of Valentina. And used for creating and editing manual layouts.
Displays this help.
.IP "-v, --version"
Displays version information.
.IP "-e, --exportFile <The filename of layout file>"
The filename of exported layout file. Use it to enable console export mode.
.IP "-r, --rawLayout <The raw layout data file>"
Load pattern pieces form the raw layout data file.
.IP "-f, --format <Format number>"
Number corresponding to tiled pdf page template (default = 0, export mode with tiled pdf format): <not defined>
.IP "--bdxf"
Export dxf in binary form.
.IP "--text2paths"
Export text as paths.
.IP "-c, --crop"
Auto crop unused length (export mode).
.IP "--cropWidth"
Auto crop unused width (export mode).
.IP "--tiledPageformat <Template number>"
Number corresponding to tiled pdf page template (default = 0, export mode with tiled pdf format): <not defined>
.IP "--tiledlmargin <The left margin>"
Tiled page left margin in current units like 3.0 (export mode). If not set will be used default value 1 cm.
.IP "--tiledrmargin <The right margin>"
Tiled page right margin in current units like 3.0 (export mode). If not set will be used default value 1 cm.
.IP "--tiledtmargin <The top margin>"
Tiled page top margin in current units like 3.0 (export mode). If not set will be used value default value 1 cm.
.IP "--tiledbmargin <The bottom margin>"
Tiled page bottom margin in current units like 3.0 (export mode). If not set will be used value default value 1 cm.
.IP "--tiledLandscape"
Set tiled page orienatation to landscape (export mode). Default value if not set portrait.
.IP "-t, --test"
Run the program in a test mode. The program in this mode loads a single layout file and silently quit without showing the main window. The key have priority before key 'exportFile'.
.IP "--no-scaling"
Disable high dpi scaling. Call this option if has problem with scaling (by default scaling enabled). Alternatively you can use the QT_AUTO_SCREEN_SCALE_FACTOR=0 environment variable.
.IP Arguments:

View File

@ -384,11 +384,8 @@ auto VPApplication::NewMainWindow(const VPCommandLinePtr &cmd) -> VPMainWindow *
{
auto *puzzle = new VPMainWindow(cmd);
m_mainWindows.prepend(puzzle);
if (not cmd->IsTestModeEnabled())
{
puzzle->show();
puzzle->UpdateWindowTitle();
}
puzzle->show();
puzzle->UpdateWindowTitle();
puzzle->InitZoom();
return puzzle;
}
@ -700,13 +697,6 @@ auto VPApplication::StartWithFiles(const VPCommandLinePtr &cmd, const QStringLis
//---------------------------------------------------------------------------------------------------------------------
auto VPApplication::SingleStart(const VPCommandLinePtr &cmd, const QStringList &rawLayouts) -> bool
{
if (cmd->IsTestModeEnabled())
{
qCCritical(pApp, "%s\n", qPrintable(tr("Please, provide one input file.")));
cmd.get()->parser.showHelp(V_EX_USAGE);
return false;
}
NewMainWindow(cmd);
if (not rawLayouts.isEmpty())
{

View File

@ -35,49 +35,12 @@ std::shared_ptr<VPCommandLine> VPCommandLine::instance = nullptr; // NOLINT(cppc
#define translate(context, source) QCoreApplication::translate((context), source)// NOLINT(cppcoreguidelines-macro-usage)
//------------------------------------------------------------------------------------------------
auto VPCommandLine::IsExportEnabled() const -> bool
{
const bool result = IsOptionSet(LONG_OPTION_EXPORT_FILE);
auto argSize = parser.positionalArguments().size();
if (result && argSize != 1)
{
qCritical() << translate("Puzzle", "Export options can be used with single input file only.") << "/n";
const_cast<VPCommandLine*>(this)->parser.showHelp(V_EX_USAGE);
}
return result;
}
//----------------------------------------------------------------------------------------------
auto VPCommandLine::OptionExportFile() const -> QString
{
QString path;
if (IsExportEnabled())
{
path = OptionValue(LONG_OPTION_EXPORT_FILE);
}
return path;
}
//---------------------------------------------------------------------------------------------------------------------
auto VPCommandLine::OptionRawLayouts() const -> QStringList
{
return OptionValues(LONG_OPTION_RAW_LAYOUT);
}
//--------------------------------------------------------------------------------------------
auto VPCommandLine::IsTestModeEnabled() const -> bool
{
const bool r = IsOptionSet(LONG_OPTION_TEST);
if (r && parser.positionalArguments().size() != 1)
{
qCritical() << translate("VCommandLine", "Test option can be used with single input file only.") << "/n";
const_cast<VPCommandLine*>(this)->parser.showHelp(V_EX_USAGE);
}
return r;
}
//--------------------------------------------------------------------------------------------
auto VPCommandLine::IsGuiEnabled() const -> bool
{
@ -128,8 +91,6 @@ void VPCommandLine::ProcessInstance(VPCommandLinePtr &instance, const QStringLis
instance.reset(new VPCommandLine);
}
instance->parser.process(arguments);
instance->isGuiEnabled = not (instance->IsGuiEnabled() || instance->IsExportEnabled());
}
//-------------------------------------------------------------------------------------------
@ -138,51 +99,9 @@ void VPCommandLine::InitCommandLineOptions()
//keep in mind order here - that is how user will see it, so group-up for usability
//=================================================================================================================
parser.addOptions({
{{SINGLE_OPTION_EXPORT_FILE, LONG_OPTION_EXPORT_FILE},
translate("VCommandLine", "The filename of exported layout file. Use it to enable console export mode."),
translate("VCommandLine", "The filename of layout file")},
{{SINGLE_OPTION_RAW_LAYOUT, LONG_OPTION_RAW_LAYOUT},
translate("VCommandLine", "Load pattern pieces from the raw layout data file."),
translate("VCommandLine", "The raw layout data file")},
{{SINGLE_OPTION_EXP2FORMAT, LONG_OPTION_EXP2FORMAT},
translate("VCommandLine", "Number corresponding to output format (default = 0, export mode): <not defined>"),
translate("VCommandLine", "Format number"), QChar('0')},
{LONG_OPTION_BINARYDXF, translate("VCommandLine", "Export dxf in binary form.")},
{LONG_OPTION_TEXT2PATHS, translate("VCommandLine", "Export text as paths.")},
//=================================================================================================================
{{SINGLE_OPTION_CROP_LENGTH, LONG_OPTION_CROP_LENGTH},
translate("VCommandLine", "Auto crop unused length (export mode).")},
{LONG_OPTION_CROP_WIDTH,
translate("VCommandLine", "Auto crop unused width (export mode).")},
//=================================================================================================================
{LONG_OPTION_TILED_PDF_PAGE_TEMPLATE,
translate("VCommandLine", "Number corresponding to tiled pdf page template (default = 0, export mode with "
"tiled pdf format): <not defined>"),
translate("VCommandLine", "Template number"), QChar('0')},
{LONG_OPTION_TILED_PDF_LEFT_MARGIN,
translate("VCommandLine","Tiled page left margin in current units like 3.0 (export mode). If not set will be "
"used default value 1 cm."),
translate("VCommandLine", "The left margin")},
{LONG_OPTION_TILED_PDF_RIGHT_MARGIN,
translate("VCommandLine", "Tiled page right margin in current units like 3.0 (export mode). If not set will "
"be used default value 1 cm."),
translate("VCommandLine", "The right margin")},
{LONG_OPTION_TILED_PDF_TOP_MARGIN,
translate("VCommandLine", "Tiled page top margin in current units like 3.0 (export mode). If not set will be "
"used value default value 1 cm."),
translate("VCommandLine", "The top margin")},
{LONG_OPTION_TILED_PDF_BOTTOM_MARGIN,
translate("VCommandLine", "Tiled page bottom margin in current units like 3.0 (export mode). If not set will "
"be used value default value 1 cm."),
translate("VCommandLine", "The bottom margin")},
{LONG_OPTION_TILED_PDF_LANDSCAPE,
translate("VCommandLine", "Set tiled page orienatation to landscape (export mode). Default value if not set "
"portrait.")},
//=================================================================================================================
{{SINGLE_OPTION_TEST, LONG_OPTION_TEST},
translate("VCommandLine", "Run the program in a test mode. The program in this mode loads a single layout "
"file and silently quit without showing the main window. The key have priority "
"before key '%1'.").arg(LONG_OPTION_EXPORT_FILE)},
{LONG_OPTION_NO_HDPI_SCALING,
translate("VCommandLine", "Disable high dpi scaling. Call this option if has problem with scaling (by default "
"scaling enabled). Alternatively you can use the %1 environment variable.")

View File

@ -44,18 +44,9 @@ class VPCommandLine: public QObject
public:
~VPCommandLine() override = default;
/** @brief if user enabled export from cmd */
auto IsExportEnabled() const -> bool;
/** @brief path to export file or empty string if not */
auto OptionExportFile() const -> QString;
/** @brief list with paths to the raw layout data files */
auto OptionRawLayouts() const -> QStringList;
/** @brief if user enabled test mode from cmd */
auto IsTestModeEnabled() const -> bool;
/** @brief if gui enabled or not */
auto IsGuiEnabled() const -> bool;
@ -77,7 +68,7 @@ private:
Q_DISABLE_COPY_MOVE(VPCommandLine) // NOLINT
static VPCommandLinePtr instance; // NOLINT(cppcoreguidelines-avoid-non-const-global-variables)
QCommandLineParser parser{};
bool isGuiEnabled{false};
bool isGuiEnabled{true};
friend class VPApplication;
/** @brief add options to the QCommandLineParser that there are in the cmd can be */

View File

@ -29,33 +29,9 @@
#include <QStringList>
const QString LONG_OPTION_EXPORT_FILE = QStringLiteral("exportFile"); // NOLINT
const QString SINGLE_OPTION_EXPORT_FILE = QStringLiteral("e"); // NOLINT
const QString LONG_OPTION_TEST = QStringLiteral("test"); // NOLINT
const QString SINGLE_OPTION_TEST = QStringLiteral("t"); // NOLINT
const QString LONG_OPTION_RAW_LAYOUT = QStringLiteral("rawLayout"); // NOLINT
const QString SINGLE_OPTION_RAW_LAYOUT = QStringLiteral("r"); // NOLINT
const QString LONG_OPTION_EXP2FORMAT = QStringLiteral("format"); // NOLINT
const QString SINGLE_OPTION_EXP2FORMAT = QStringLiteral("f"); // NOLINT
const QString LONG_OPTION_BINARYDXF = QStringLiteral("bdxf"); // NOLINT
const QString LONG_OPTION_TEXT2PATHS = QStringLiteral("text2paths"); // NOLINT
const QString LONG_OPTION_CROP_LENGTH = QStringLiteral("crop"); // NOLINT
const QString SINGLE_OPTION_CROP_LENGTH = QStringLiteral("c"); // NOLINT
const QString LONG_OPTION_CROP_WIDTH = QStringLiteral("cropWidth"); // NOLINT
const QString LONG_OPTION_TILED_PDF_PAGE_TEMPLATE = QStringLiteral("tiledPageformat"); // NOLINT
const QString LONG_OPTION_TILED_PDF_LEFT_MARGIN = QStringLiteral("tiledlmargin"); // NOLINT
const QString LONG_OPTION_TILED_PDF_RIGHT_MARGIN = QStringLiteral("tiledrmargin"); // NOLINT
const QString LONG_OPTION_TILED_PDF_TOP_MARGIN = QStringLiteral("tiledtmargin"); // NOLINT
const QString LONG_OPTION_TILED_PDF_BOTTOM_MARGIN = QStringLiteral("tiledbmargin"); // NOLINT
const QString LONG_OPTION_TILED_PDF_LANDSCAPE = QStringLiteral("tiledLandscape"); // NOLINT
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief AllKeys return list with all command line keys (short and long forms). Used for testing on conflicts.
@ -65,24 +41,7 @@ auto AllKeys() -> QStringList
{
return
{
LONG_OPTION_EXPORT_FILE,
SINGLE_OPTION_EXPORT_FILE,
LONG_OPTION_TEST,
SINGLE_OPTION_TEST,
LONG_OPTION_RAW_LAYOUT,
SINGLE_OPTION_RAW_LAYOUT,
LONG_OPTION_EXP2FORMAT,
SINGLE_OPTION_EXP2FORMAT,
LONG_OPTION_BINARYDXF,
LONG_OPTION_TEXT2PATHS,
LONG_OPTION_CROP_LENGTH,
SINGLE_OPTION_CROP_LENGTH,
LONG_OPTION_CROP_WIDTH,
LONG_OPTION_TILED_PDF_PAGE_TEMPLATE,
LONG_OPTION_TILED_PDF_LEFT_MARGIN,
LONG_OPTION_TILED_PDF_RIGHT_MARGIN,
LONG_OPTION_TILED_PDF_TOP_MARGIN,
LONG_OPTION_TILED_PDF_BOTTOM_MARGIN,
LONG_OPTION_TILED_PDF_LANDSCAPE
SINGLE_OPTION_RAW_LAYOUT
};
}

View File

@ -31,33 +31,9 @@
#include <QString>
extern const QString LONG_OPTION_EXPORT_FILE;
extern const QString SINGLE_OPTION_EXPORT_FILE;
extern const QString LONG_OPTION_TEST;
extern const QString SINGLE_OPTION_TEST;
extern const QString LONG_OPTION_RAW_LAYOUT;
extern const QString SINGLE_OPTION_RAW_LAYOUT;
extern const QString LONG_OPTION_EXP2FORMAT;
extern const QString SINGLE_OPTION_EXP2FORMAT;
extern const QString LONG_OPTION_BINARYDXF;
extern const QString LONG_OPTION_TEXT2PATHS;
extern const QString LONG_OPTION_CROP_LENGTH;
extern const QString SINGLE_OPTION_CROP_LENGTH;
extern const QString LONG_OPTION_CROP_WIDTH;
extern const QString LONG_OPTION_TILED_PDF_PAGE_TEMPLATE;
extern const QString LONG_OPTION_TILED_PDF_LEFT_MARGIN;
extern const QString LONG_OPTION_TILED_PDF_RIGHT_MARGIN;
extern const QString LONG_OPTION_TILED_PDF_TOP_MARGIN;
extern const QString LONG_OPTION_TILED_PDF_BOTTOM_MARGIN;
extern const QString LONG_OPTION_TILED_PDF_LANDSCAPE;
auto AllKeys() -> QStringList;
#endif // VPCOMMANDS_H

View File

@ -420,10 +420,6 @@ auto VPMainWindow::LoadFile(const QString& path) -> bool
if (not QFileInfo::exists(path))
{
qCCritical(pWindow, "%s", qUtf8Printable(tr("File '%1' doesn't exist!").arg(path)));
if (m_cmd->IsTestModeEnabled())
{
QCoreApplication::exit(V_EX_NOINPUT);
}
return false;
}
@ -471,11 +467,6 @@ auto VPMainWindow::LoadFile(const QString& path) -> bool
qCCritical(pWindow, "%s\n\n%s", qUtf8Printable(tr("File error.")),
qUtf8Printable(tr("Unable to read a layout file. %1").arg(fileReader.errorString())));
lock.reset();
if (m_cmd->IsTestModeEnabled())
{
QCoreApplication::exit(V_EX_NOINPUT);
}
return false;
}
}