aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/cli/main.cpp
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/main.cpp
parent4dcc5ca9c840d16c9238aec2beb6783e85b28dfe (diff)
downloadOneRoll-f0f5ef7b87d8d5c1a0c59f0e0410474155c1019c.tar.gz
OneRoll-f0f5ef7b87d8d5c1a0c59f0e0410474155c1019c.zip
need for gui is not conditionnal add flag NO_PAINTER_OPERATOR
Diffstat (limited to 'cli/main.cpp')
-rw-r--r--cli/main.cpp24
1 files changed, 22 insertions, 2 deletions
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;