From f0f5ef7b87d8d5c1a0c59f0e0410474155c1019c Mon Sep 17 00:00:00 2001 From: Renaud G Date: Fri, 28 Sep 2018 11:15:32 +0200 Subject: need for gui is not conditionnal add flag NO_PAINTER_OPERATOR --- cli/CMakeLists.txt | 11 +++++++---- cli/displaytoolbox.cpp | 9 +++++++-- cli/displaytoolbox.h | 3 ++- cli/main.cpp | 24 ++++++++++++++++++++++-- 4 files changed, 38 insertions(+), 9 deletions(-) (limited to 'cli') diff --git a/cli/CMakeLists.txt b/cli/CMakeLists.txt index 583e4af..4374b9f 100644 --- a/cli/CMakeLists.txt +++ b/cli/CMakeLists.txt @@ -20,10 +20,13 @@ find_package(Qt5Core) include_directories(${Qt5Core_INCLUDES} ../) add_definitions(${Qt5Core_DEFINITIONS}) -find_package(Qt5Gui) -include_directories(${Qt5Gui_INCLUDES} ../) -add_definitions(${Qt5Gui_DEFINITIONS}) - +IF(NOT DEFINED NO_PAINTER_OPERATOR) + MESSAGE(STATUS "Compilation of operator Paint") + find_package(Qt5Gui) + include_directories(${Qt5Gui_INCLUDES} ../) + add_definitions(${Qt5Gui_DEFINITIONS}) + add_definitions(-DPAINTER_OP) +endif() set(MODE "cli") diff --git a/cli/displaytoolbox.cpp b/cli/displaytoolbox.cpp index 8a2a681..78b3d7c 100644 --- a/cli/displaytoolbox.cpp +++ b/cli/displaytoolbox.cpp @@ -1,10 +1,14 @@ #include "displaytoolbox.h" #include #include +#include + +#ifdef PAINTER_OP #include #include -#include #include +#endif + #include #define LINE_SPACING 5 @@ -13,7 +17,7 @@ DisplayToolBox::DisplayToolBox() { } - +#ifdef PAINTER_OP QString DisplayToolBox::makeImage(QString scalarText, QString resultStr,QJsonArray array, bool withColor, QString cmd, QString comment, bool allSameFaceCount,bool allSameColor) { QString textTotal("%1 Details:[%3 %2]"); @@ -163,6 +167,7 @@ QString DisplayToolBox::makeImage(QString scalarText, QString resultStr,QJsonArr //return {}; return ba.toBase64(); } +#endif QString DisplayToolBox::colorToTermCode(QString str) { diff --git a/cli/displaytoolbox.h b/cli/displaytoolbox.h index 0b6cd12..e256be1 100644 --- a/cli/displaytoolbox.h +++ b/cli/displaytoolbox.h @@ -1,7 +1,6 @@ #ifndef GENERATEIMAGE_H #define GENERATEIMAGE_H -#include #include #include @@ -11,7 +10,9 @@ class DisplayToolBox { public: DisplayToolBox(); + #ifdef PAINTER_OP static QString makeImage(QString scalarText, QString resultStr,QJsonArray array, bool withColor, QString cmd, QString comment, bool allSameFaceCount,bool allSameColor); + #endif static QString colorToTermCode(QString str); static QString diceToText(QJsonArray array, bool withColor,bool allSameFaceCount, bool allSameColor); static QJsonArray diceToJson(QList &diceList, bool &allSameFaceCount, bool &allSameColor); diff --git a/cli/main.cpp b/cli/main.cpp index a165451..dee3d05 100644 --- a/cli/main.cpp +++ b/cli/main.cpp @@ -27,9 +27,14 @@ #include #include #include -#include #include +#ifdef PAINTER_OP +#include +#else +#include +#endif + #include "displaytoolbox.h" #include "diceparser.h" #include "highlightdice.h" @@ -49,7 +54,11 @@ QTextStream out(stdout, QIODevice::WriteOnly); bool markdown = false; +#ifdef PAINTER_OP enum EXPORTFORMAT {TERMINAL, SVG, IMAGE, MARKDOWN, JSON, BOT}; +#else +enum EXPORTFORMAT {TERMINAL, SVG, MARKDOWN, JSON, BOT}; +#endif int returnValue = 0; @@ -89,11 +98,12 @@ QString diceToMarkdown(QJsonArray array,bool withColor,bool allSameColor,bool al return result.join(' '); } } - +#ifdef PAINTER_OP void displayImage(QString scalarText, QString resultStr,QJsonArray array, bool withColor, QString cmd, QString comment, bool allSameFaceCount,bool allSameColor) { out << DisplayToolBox::makeImage( scalarText, resultStr, array, withColor, cmd, comment, allSameFaceCount, allSameColor); } +#endif void displayJSon(QString scalarText, QString resultStr,QJsonArray array, bool withColor, QString cmd, QString error, QString comment, bool allSameFaceCount,bool allSameColor) { Q_UNUSED(withColor); @@ -278,7 +288,11 @@ int startDiceParsing(QStringList& cmds,QString& treeFile,bool withColor, EXPORTF } else { + #ifdef PAINTER_OP format = IMAGE; + #else + format = MARKDOWN; + #endif } if(!error.isEmpty()) { @@ -300,9 +314,11 @@ int startDiceParsing(QStringList& cmds,QString& treeFile,bool withColor, EXPORTF case JSON: displayJSon(scalarText, resultStr, array, withColor, cmd, error, comment, allSameFaceCount, allSameColor); break; + #ifdef PAINTER_OP case IMAGE: displayImage(scalarText, resultStr, array, withColor, cmd, comment, allSameFaceCount, allSameColor); break; + #endif } if(!treeFile.isEmpty()) { @@ -325,7 +341,11 @@ int startDiceParsing(QStringList& cmds,QString& treeFile,bool withColor, EXPORTF #include int main(int argc, char *argv[]) { +#ifdef PAINTER_OP QGuiApplication a(argc, argv); +#else + QCoreApplication a(argc, argv); +#endif QStringList commands; QString cmd; -- cgit v1.2.3-70-g09d2