From dc95ae30e9c27e9d03d58e7f098bd5d36c0f063d Mon Sep 17 00:00:00 2001 From: Alex Date: Tue, 25 Aug 2015 22:27:21 +0300 Subject: [PATCH] Issue #334, try 2. Changed spaces, some minor stuffs like [[noreturn]]. Removed added by error clang settings. --HG-- branch : develop --- src/app/app.pri | 1 + src/app/app.pro | 2 - src/app/core/vapplication.cpp | 2 + src/app/core/vcmdexport.cpp | 84 +++++++++++++++++------- src/app/core/vcmdexport.h | 5 +- src/app/dialogs/dialoglayoutsettings.cpp | 11 +++- src/app/mainwindow.cpp | 7 -- src/app/mainwindow.h | 1 - src/app/mainwindowsnogui.cpp | 3 +- src/libs/vmisc/def.h | 2 +- 10 files changed, 78 insertions(+), 40 deletions(-) diff --git a/src/app/app.pri b/src/app/app.pri index 63f1a6720..5309ba83a 100644 --- a/src/app/app.pri +++ b/src/app/app.pri @@ -14,6 +14,7 @@ SOURCES += \ $$PWD/version.cpp \ $$PWD/mainwindowsnogui.cpp + # Some header files HEADERS += \ $$PWD/mainwindow.h \ diff --git a/src/app/app.pro b/src/app/app.pro index 71ccc3848..a8e1ac2a2 100644 --- a/src/app/app.pro +++ b/src/app/app.pro @@ -108,8 +108,6 @@ CONFIG(debug, debug|release){ # -isystem key works only for headers. In some cases it's not enough. But we can't delete this warnings and # want them in global list. Compromise decision delete them from local list. QMAKE_CXXFLAGS -= \ - -Wuninitialized \ - -Winit-self \ -Wmissing-prototypes \ -Wundefined-reinterpret-cast } diff --git a/src/app/core/vapplication.cpp b/src/app/core/vapplication.cpp index 9e16c176e..095ec4a3a 100644 --- a/src/app/core/vapplication.cpp +++ b/src/app/core/vapplication.cpp @@ -597,11 +597,13 @@ void VApplication::InitTrVars() { trVars = new VTranslateVars(Settings()); } + //--------------------------------------------------------------------------------------------------------------------- bool VApplication::CheckGUI() { return (VCommandLine::instance != nullptr) && VCommandLine::instance->IsGuiEnabled(); } + //--------------------------------------------------------------------------------------------------------------------- const VCommandLinePtr VApplication::CommandLine() const { diff --git a/src/app/core/vcmdexport.cpp b/src/app/core/vcmdexport.cpp index eefe28d6b..2dcfe8255 100644 --- a/src/app/core/vcmdexport.cpp +++ b/src/app/core/vcmdexport.cpp @@ -29,7 +29,7 @@ const static auto OPTION_SHIFTUNITS = QStringLiteral("layounits"); const static auto OPTION_GAPWIDTH = QStringLiteral("gapwidth"); const static auto OPTION_GROUPPING = QStringLiteral("groups"); -#define tr(A) QCoreApplication::translate("VCommandLine",(A)) +#define tr(A) QCoreApplication::translate("VCommandLine", (A)) //------------------------------------------------------------------------------------------------------ //such a tricky initialization is used, because it uses static functions which relay on static variables and order of initialization is not defined between compiled units. @@ -37,39 +37,73 @@ const static auto OPTION_GROUPPING = QStringLiteral("groups"); //------------------------------------------------------------------------------------------------------ VCommandLine::VCommandLine() : parser() , optionsUsed ({ - QCommandLineOption(OPTION_OUTFILE, tr("Path to output exported layout file. Use it to enable console export mode."), OPTION_OUTFILE), + //keep in mind order here - that is how user will see it, so group-up for usability + //=================================================================================== - QCommandLineOption(OPTION_MEASUREFILE, tr("Path to custom measure file (export mode)."), OPTION_MEASUREFILE), + QCommandLineOption(OPTION_OUTFILE, + tr("Path to output exported layout file. Use it to enable console export mode."), + OPTION_OUTFILE), - QCommandLineOption(OPTION_EXP2FORMAT, tr("Number corresponding to output format (default = 0, export mode): ") + + QCommandLineOption(OPTION_MEASUREFILE, + tr("Path to custom measure file (export mode)."), + OPTION_MEASUREFILE), + + QCommandLineOption(OPTION_EXP2FORMAT, + tr("Number corresponding to output format (default = 0, export mode): ") + DialogSaveLayout::MakeHelpFormatList(), OPTION_EXP2FORMAT, "0"), - QCommandLineOption(OPTION_PAGETEMPLATE, tr("Number corresponding to page template (default = 0, export mode): ")+ + //=================================================================================== + + QCommandLineOption(OPTION_PAGETEMPLATE, + tr("Number corresponding to page template (default = 0, export mode): ")+ DialogLayoutSettings::MakeHelpTemplateList(), OPTION_PAGETEMPLATE, "0"), - QCommandLineOption(OPTION_PAGEW, tr("Page width in current units like 12.0 (cannot be used with \"")+OPTION_PAGETEMPLATE+tr("\", export mode)."), OPTION_PAGEW), + QCommandLineOption(OPTION_PAGEW, + tr("Page width in current units like 12.0 (cannot be used with \"") + +OPTION_PAGETEMPLATE+tr("\", export mode)."), OPTION_PAGEW), - QCommandLineOption(OPTION_PAGEH, tr("Page height in current units like 12.0 (cannot be used with \"")+OPTION_PAGETEMPLATE+tr("\", export mode)."), OPTION_PAGEH), + QCommandLineOption(OPTION_PAGEH, + tr("Page height in current units like 12.0 (cannot be used with \"") + +OPTION_PAGETEMPLATE+tr("\", export mode)."), OPTION_PAGEH), - QCommandLineOption(OPTION_PAGEUNITS, tr("Page height/width measure units (cannot be used with \"")+ - OPTION_PAGETEMPLATE+tr("\", export mode): ") + VDomDocument::UnitsHelpString(), OPTION_PAGEUNITS), + QCommandLineOption(OPTION_PAGEUNITS, + tr("Page height/width measure units (cannot be used with \"")+ + OPTION_PAGETEMPLATE+tr("\", export mode): ") + VDomDocument::UnitsHelpString(), + OPTION_PAGEUNITS), - QCommandLineOption(OPTION_ROTATE, tr("Rotation in degrees (one of predefined). Default (or 0) is no-rotate (export mode)."), OPTION_ROTATE), + //=================================================================================== - QCommandLineOption(OPTION_CROP, tr("Auto crop unused length (export mode).")), + QCommandLineOption(OPTION_ROTATE, + tr("Rotation in degrees (one of predefined). Default (or 0) is no-rotate (export mode)."), + OPTION_ROTATE), - QCommandLineOption(OPTION_UNITE, tr("Unite pages if possible (export mode).")), + QCommandLineOption(OPTION_CROP, + tr("Auto crop unused length (export mode).")), - QCommandLineOption(OPTION_SAVELENGTH, tr("Save length of the sheet if set. (export mode).")), + QCommandLineOption(OPTION_UNITE, + tr("Unite pages if possible (export mode).")), - QCommandLineOption(OPTION_SHIFTUNITS, tr("Layout units (as paper's one except px, export mode)."), OPTION_SHIFTUNITS), + //=================================================================================== - QCommandLineOption(OPTION_SHIFTLENGTH, tr("Shift layout length measured in layout units (export mode)."), OPTION_SHIFTLENGTH), + QCommandLineOption(OPTION_SAVELENGTH, + tr("Save length of the sheet if set. (export mode).")), - QCommandLineOption(OPTION_GAPWIDTH, tr("Gap width x2, measured in layout units. (export mode)."), OPTION_GAPWIDTH), + QCommandLineOption(OPTION_SHIFTUNITS, + tr("Layout units (as paper's one except px, export mode)."), + OPTION_SHIFTUNITS), - QCommandLineOption(OPTION_GROUPPING, tr("Sets layout groupping (export mode): ") + DialogLayoutSettings::MakeGroupsHelp(), OPTION_GROUPPING, "2"), + QCommandLineOption(OPTION_SHIFTLENGTH, + tr("Shift layout length measured in layout units (export mode)."), + OPTION_SHIFTLENGTH), + + QCommandLineOption(OPTION_GAPWIDTH, + tr("Gap width x2, measured in layout units. (export mode)."), + OPTION_GAPWIDTH), + + QCommandLineOption(OPTION_GROUPPING, + tr("Sets layout groupping (export mode): ") + + DialogLayoutSettings::MakeGroupsHelp(), OPTION_GROUPPING, "2"), }), isGuiEnabled(false) { @@ -83,17 +117,20 @@ VCommandLine::VCommandLine() : parser() parser.addOption(o); } } + //------------------------------------------------------------------------------------------------------ int VCommandLine::Lo2Px(const QString &src, const DialogLayoutSettings &converter) { //that is dirty-dirty hack ...eventually number is converted float <--> int 3 or 4 times including inside dialog ... that will loose precision for sure return converter.LayoutToPixels(src.toFloat()); } + //------------------------------------------------------------------------------------------------------ int VCommandLine::Pg2Px(const QString& src, const DialogLayoutSettings& converter) { return converter.PageToPixels(src.toFloat()); } + //------------------------------------------------------------------------------------------------------ VLayoutGeneratorPtr VCommandLine::DefaultGenerator() const { @@ -194,8 +231,8 @@ VLayoutGeneratorPtr VCommandLine::DefaultGenerator() const return res; } -//------------------------------------------------------------------------------------------------------ +//------------------------------------------------------------------------------------------------------ VCommandLinePtr VCommandLine::Get(const QCoreApplication& app) { if (instance == nullptr) @@ -209,12 +246,14 @@ VCommandLinePtr VCommandLine::Get(const QCoreApplication& app) return instance; } + //------------------------------------------------------------------------------------------------------ NORET_ATTR void VCommandLine::Error(const QString &text) const { qStdErr() << text << "\n"; const_cast(this)->parser.showHelp(FAILED_HELP_SHOWN_STATUS); } + //------------------------------------------------------------------------------------------------------ void VCommandLine::Reset() { @@ -231,6 +270,7 @@ bool VCommandLine::IsExportEnabled() const } return r; } + //------------------------------------------------------------------------------------------------------ DialogLayoutSettings::PaperSizeTemplate VCommandLine::OptPaperSize() const { @@ -253,6 +293,7 @@ int VCommandLine::OptRotation() const return rotate; } + //------------------------------------------------------------------------------------------------------ Cases VCommandLine::OptGroup() const { @@ -263,8 +304,8 @@ Cases VCommandLine::OptGroup() const } return static_cast(r); } -//------------------------------------------------------------------------------------------------------ +//------------------------------------------------------------------------------------------------------ QString VCommandLine::OptMeasurePath() const { QString measure; @@ -279,7 +320,6 @@ QString VCommandLine::OptMeasurePath() const } //------------------------------------------------------------------------------------------------------ - QString VCommandLine::OptExportPath() const { QString path; @@ -290,8 +330,8 @@ QString VCommandLine::OptExportPath() const return path; } -//------------------------------------------------------------------------------------------------------ +//------------------------------------------------------------------------------------------------------ int VCommandLine::OptExportType() const { int r = 0; @@ -303,11 +343,11 @@ int VCommandLine::OptExportType() const } //--------------------------------------------------------------------------------------------------------------------- - QStringList VCommandLine::OptInputFileNames() const { return parser.positionalArguments(); } + //------------------------------------------------------------------------------------------------------ bool VCommandLine::IsGuiEnabled() const { diff --git a/src/app/core/vcmdexport.h b/src/app/core/vcmdexport.h index 6d2695270..4d53aaf2c 100644 --- a/src/app/core/vcmdexport.h +++ b/src/app/core/vcmdexport.h @@ -11,11 +11,10 @@ constexpr auto GENERAL_ERROR_STATUS = 255; constexpr auto INVALID_PARAMS_STATUS = 254; constexpr auto FAILED_TO_GEN_LAYOUT_STATUS = 253; constexpr auto FAILED_HELP_SHOWN_STATUS = 250; +constexpr auto FAILED_GEN_BASE_STATUS = 240; -//making QtCReator happy....[[noreturn]] is part of C++11 standard -//http://en.cppreference.com/w/cpp/language/attributes +#define NORET_ATTR Q_NORETURN -#define NORET_ATTR [[noreturn]] //--------------------------------------------------------------------------------------------------------------------- inline QTextStream& qStdErr() diff --git a/src/app/dialogs/dialoglayoutsettings.cpp b/src/app/dialogs/dialoglayoutsettings.cpp index c1a8d2716..153851606 100644 --- a/src/app/dialogs/dialoglayoutsettings.cpp +++ b/src/app/dialogs/dialoglayoutsettings.cpp @@ -269,6 +269,7 @@ void DialogLayoutSettings::SetUnitePages(bool save) { ui->checkBoxUnitePages->setChecked(save); } + //--------------------------------------------------------------------------------------------------------------------- void DialogLayoutSettings::TemplateSelected() { @@ -304,6 +305,7 @@ bool DialogLayoutSettings::SelectPaperUnit(const QString& units) } return indexUnit != -1; } + //--------------------------------------------------------------------------------------------------------------------- bool DialogLayoutSettings::SelectLayoutUnit(const QString &units) { @@ -314,16 +316,19 @@ bool DialogLayoutSettings::SelectLayoutUnit(const QString &units) } return indexUnit != -1; } + //--------------------------------------------------------------------------------------------------------------------- int DialogLayoutSettings::LayoutToPixels(qreal value) const { return static_cast(qFloor(UnitConvertor(value, LayoutUnit(), Unit::Px))); } + //--------------------------------------------------------------------------------------------------------------------- int DialogLayoutSettings::PageToPixels(qreal value) const { return static_cast(qFloor(UnitConvertor(value, PaperUnit(), Unit::Px))); } + //--------------------------------------------------------------------------------------------------------------------- QString DialogLayoutSettings::MakeGroupsHelp() { @@ -366,8 +371,8 @@ void DialogLayoutSettings::PaperSizeChanged() Label(); } -//--------------------------------------------------------------------------------------------------------------------- +//--------------------------------------------------------------------------------------------------------------------- bool DialogLayoutSettings::SelectTemplate(const PaperSizeTemplate& id) { int index = ui->comboBoxTemplates->findData(static_cast(id)); @@ -378,8 +383,8 @@ bool DialogLayoutSettings::SelectTemplate(const PaperSizeTemplate& id) return (index > -1); } -//--------------------------------------------------------------------------------------------------------------------- +//--------------------------------------------------------------------------------------------------------------------- void DialogLayoutSettings::Swap(bool checked) { if (checked) @@ -481,8 +486,8 @@ void DialogLayoutSettings::InitTemplates() } ui->comboBoxTemplates->setCurrentIndex(-1); } -//--------------------------------------------------------------------------------------------------------------------- +//--------------------------------------------------------------------------------------------------------------------- QString DialogLayoutSettings::MakeHelpTemplateList() { QString out = "\n"; diff --git a/src/app/mainwindow.cpp b/src/app/mainwindow.cpp index d5493e5fa..7ca0a96e7 100644 --- a/src/app/mainwindow.cpp +++ b/src/app/mainwindow.cpp @@ -756,12 +756,6 @@ void MainWindow::ToolTrueDarts(bool checked) &MainWindow::ClosedDialogWithApply, &MainWindow::ApplyDialog); } -//--------------------------------------------------------------------------------------------------------------------- - -void MainWindow::ToolRotate(bool checked) -{ - -} //--------------------------------------------------------------------------------------------------------------------- /** @@ -1080,7 +1074,6 @@ void MainWindow::InitToolButtons() connect(ui->toolButtonArcWithLength, &QToolButton::clicked, this, &MainWindow::ToolArcWithLength); connect(ui->toolButtonTrueDarts, &QToolButton::clicked, this, &MainWindow::ToolTrueDarts); - //connect(ui->toolButtonRotate, &QToolButton::clicked, this, &MainWindow::ToolRotate); } //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/app/mainwindow.h b/src/app/mainwindow.h index ba5327e35..64c4b344d 100644 --- a/src/app/mainwindow.h +++ b/src/app/mainwindow.h @@ -125,7 +125,6 @@ public slots: void ToolPointFromArcAndTangent(bool checked); void ToolArcWithLength(bool checked); void ToolTrueDarts(bool checked); - void ToolRotate(bool checked); void ClosedDialogDetail(int result); void ClosedDialogUnionDetails(int result); diff --git a/src/app/mainwindowsnogui.cpp b/src/app/mainwindowsnogui.cpp index 346d87629..8edcdf6e6 100644 --- a/src/app/mainwindowsnogui.cpp +++ b/src/app/mainwindowsnogui.cpp @@ -161,7 +161,8 @@ void MainWindowsNoGUI::ErrorConsoleMode(const LayoutErrors &state) default: break; } - AppAbort(text, FAILED_TO_GEN_LAYOUT_STATUS); + //just added different return status in console mode + AppAbort(text, FAILED_GEN_BASE_STATUS + static_cast(state)); } //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/libs/vmisc/def.h b/src/libs/vmisc/def.h index a6837175b..a01bc8c22 100644 --- a/src/libs/vmisc/def.h +++ b/src/libs/vmisc/def.h @@ -87,7 +87,7 @@ enum class Tool : unsigned char enum class Vis : unsigned char { - ControlPointSpline = static_cast(Tool::LAST_ONE_DO_NOT_USE), //38,// increase this value if need more positions in Tool enum + ControlPointSpline = static_cast(Tool::LAST_ONE_DO_NOT_USE), GraphicsSimpleTextItem, SimpleSplinePath, SimplePoint,