valentina/src/app/puzzle/vpcommandline.h

88 lines
2.9 KiB
C
Raw Normal View History

2020-04-15 23:12:07 +02:00
/************************************************************************
**
2020-05-23 14:43:57 +02:00
** @file vpcommandline.h
2020-04-17 20:58:34 +02:00
** @author Dmytro Hladkykh <vorzelmir@gmail.com>
2020-04-15 23:12:07 +02:00
** @date 12 4, 2020
**
** @brief
** @copyright
** This source code is part of the Valentina project, a pattern making
** program, whose allow create and modeling patterns of clothing.
** Copyright (C) 2020 Valentina project
** <https://gitlab.com/smart-pattern/valentina> All Rights Reserved.
**
** Valentina is free software: you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation, either version 3 of the License, or
** (at your option) any later version.
**
** Valentina is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with Valentina. If not, see <http://www.gnu.org/licenses/>.
**
*************************************************************************/
2020-05-23 14:43:57 +02:00
#ifndef VPCOMMANDLINE_H
#define VPCOMMANDLINE_H
2020-04-03 22:05:03 +02:00
#include <QCommandLineParser>
2023-07-15 12:47:14 +02:00
#include <QCoreApplication>
#include <memory>
2020-04-03 22:05:03 +02:00
2023-07-17 15:33:57 +02:00
// Header <ciso646> is removed in C++20.
#if __cplusplus <= 201703L
#include <ciso646> // and, not, or
#endif
2020-05-23 14:43:57 +02:00
class VPCommandLine;
using VPCommandLinePtr = std::shared_ptr<VPCommandLine>;
2020-04-13 11:43:25 +02:00
2023-07-15 12:47:14 +02:00
class VPCommandLine : public QObject
2020-04-03 22:05:03 +02:00
{
2022-08-12 17:50:13 +02:00
Q_OBJECT // NOLINT
2023-07-15 12:47:14 +02:00
2022-08-12 17:50:13 +02:00
public:
~VPCommandLine() override = default;
2020-04-03 22:05:03 +02:00
/** @brief list with paths to the raw layout data files */
2022-08-12 17:50:13 +02:00
auto OptionRawLayouts() const -> QStringList;
2020-04-13 11:47:19 +02:00
/** @brief if gui enabled or not */
2022-08-12 17:50:13 +02:00
auto IsGuiEnabled() const -> bool;
2020-04-13 11:47:19 +02:00
/** @brief the file name which should be loaded */
2022-08-12 17:50:13 +02:00
auto OptionFileNames() const -> QStringList;
2020-04-13 11:47:19 +02:00
/** @brief if high dpi scaling is enabled */
2022-08-12 17:50:13 +02:00
auto IsNoScalingEnabled() const -> bool;
2020-04-21 17:58:01 +02:00
Q_NORETURN void ShowHelp(int exitCode = 0);
2023-07-15 12:47:14 +02:00
2020-04-03 22:05:03 +02:00
protected:
2020-05-23 14:43:57 +02:00
VPCommandLine();
2020-05-23 14:10:05 +02:00
/** @brief create the single instance of the class inside vpapplication */
2022-08-12 17:50:13 +02:00
static auto Instance() -> VPCommandLinePtr;
2020-05-23 14:43:57 +02:00
static void ProcessInstance(VPCommandLinePtr &instance, const QStringList &arguments);
2023-07-15 12:47:14 +02:00
2020-04-03 22:05:03 +02:00
private:
2022-08-12 17:50:13 +02:00
// cppcheck-suppress unknownMacro
Q_DISABLE_COPY_MOVE(VPCommandLine) // NOLINT
2023-07-15 12:47:14 +02:00
static VPCommandLinePtr instance; // NOLINT(cppcoreguidelines-avoid-non-const-global-variables)
2022-08-12 17:50:13 +02:00
QCommandLineParser parser{};
bool isGuiEnabled{true};
2020-05-23 14:10:05 +02:00
friend class VPApplication;
2020-04-03 22:05:03 +02:00
2020-04-13 11:47:19 +02:00
/** @brief add options to the QCommandLineParser that there are in the cmd can be */
2020-04-03 22:05:03 +02:00
void InitCommandLineOptions();
2020-04-06 23:57:01 +02:00
2023-07-15 12:47:14 +02:00
auto IsOptionSet(const QString &option) const -> bool;
2022-08-12 17:50:13 +02:00
auto OptionValue(const QString &option) const -> QString;
auto OptionValues(const QString &option) const -> QStringList;
2020-04-03 22:05:03 +02:00
};
2020-05-23 14:43:57 +02:00
#endif // VPCOMMANDLINE_H