aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/cli
diff options
context:
space:
mode:
authorRenaud G <renaud@rolisteam.org>2018-09-28 11:15:32 +0200
committerRenaud G <renaud@rolisteam.org>2018-09-28 11:15:32 +0200
commitf0f5ef7b87d8d5c1a0c59f0e0410474155c1019c (patch)
treed4d795c803b4b07d653cd5c5e7b1eabbf01c0044 /cli
parent4dcc5ca9c840d16c9238aec2beb6783e85b28dfe (diff)
downloadOneRoll-f0f5ef7b87d8d5c1a0c59f0e0410474155c1019c.tar.gz
OneRoll-f0f5ef7b87d8d5c1a0c59f0e0410474155c1019c.zip
need for gui is not conditionnal add flag NO_PAINTER_OPERATOR
Diffstat (limited to 'cli')
-rw-r--r--cli/CMakeLists.txt11
-rw-r--r--cli/displaytoolbox.cpp9
-rw-r--r--cli/displaytoolbox.h3
-rw-r--r--cli/main.cpp24
4 files changed, 38 insertions, 9 deletions
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 <QJsonObject>
#include <QJsonArray>
+#include <QBuffer>
+
+#ifdef PAINTER_OP
#include <QFontMetrics>
#include <QPainter>
-#include <QBuffer>
#include <QFont>
+#endif
+
#include <QDebug>
#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 <QImage>
#include <QString>
#include <QJsonArray>
@@ -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<ExportedDiceResult> &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 <QJsonArray>
#include <QJsonObject>
#include <QJsonDocument>
-#include <QGuiApplication>
#include <QFile>
+#ifdef PAINTER_OP
+#include <QGuiApplication>
+#else
+#include <QCoreApplication>
+#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 <QTextCodec>
int main(int argc, char *argv[])
{
+#ifdef PAINTER_OP
QGuiApplication a(argc, argv);
+#else
+ QCoreApplication a(argc, argv);
+#endif
QStringList commands;
QString cmd;