aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/mobile
diff options
context:
space:
mode:
authorRenaud G <renaud@rolisteam.org>2016-09-25 10:04:28 +0200
committerRenaud G <renaud@rolisteam.org>2016-09-25 10:04:28 +0200
commitfac053c3aacc0e2ede8a85ff41e27eed1c360f6f (patch)
treec91ff176e60f1f6e634107b4e7a7282e831975ee /mobile
parentdbb57d52d351e340ce69fccaedbdf758b04ed8fe (diff)
parente225f2edfd365d1709df2cb5bb2f752ec8d82c1c (diff)
downloadOneRoll-fac053c3aacc0e2ede8a85ff41e27eed1c360f6f.tar.gz
OneRoll-fac053c3aacc0e2ede8a85ff41e27eed1c360f6f.zip
Merge branch 'master' of github.com:Rolisteam/DiceParser
Diffstat (limited to 'mobile')
-rw-r--r--mobile/CMakeLists.txt102
-rw-r--r--mobile/commandmodel.cpp57
-rw-r--r--mobile/commandmodel.h46
-rw-r--r--mobile/deployment.pri13
-rw-r--r--mobile/main.cpp39
-rw-r--r--mobile/main.qml172
-rw-r--r--mobile/maincontroler.cpp37
-rw-r--r--mobile/maincontroler.h28
-rw-r--r--mobile/mainwindow.cpp6
-rw-r--r--mobile/mainwindow.h17
-rw-r--r--mobile/mobile.pro20
-rw-r--r--mobile/mobile.qrc5
-rw-r--r--mobile/qml.qrc6
-rw-r--r--mobile/qml/main.qml17
-rw-r--r--mobile/resources/images/add.pngbin0 -> 4696 bytes
15 files changed, 565 insertions, 0 deletions
diff --git a/mobile/CMakeLists.txt b/mobile/CMakeLists.txt
new file mode 100644
index 0000000..0ccff18
--- /dev/null
+++ b/mobile/CMakeLists.txt
@@ -0,0 +1,102 @@
+cmake_minimum_required(VERSION 2.8)
+
+option(UPDATE_TRANSLATIONS "update Translation" OFF)
+MESSAGE(STATUS "UPDATE TRANSLATIONS: ${UPDATE_TRANSLATIONS}")
+
+
+project(diceGui)
+
+
+# Find includes in corresponding build directories
+set(CMAKE_INCLUDE_CURRENT_DIR ON)
+# Instruct CMake to run moc automatically when needed.
+set(CMAKE_AUTOMOC ON)
+
+# Find the QtWidgets library
+find_package(Qt5 COMPONENTS Quick Qml Core Widgets Gui)
+#find_package(Qt5QuickCompiler)
+
+set(EXECUTABLE_OUTPUT_PATH bin/)
+
+include_directories(${Qt5Core_INCLUDES} ${Qt5Widgets_INCLUDES} ${Qt5Gui_INCLUDES} ${Qt5Qml_INCLUDES} ${Qt5Quick_INCLUDES}../)
+add_definitions(${Qt5Core_DEFINITIONS} ${Qt5Qml_DEFINITIONS} ${Qt5Quick_DEFINITIONS} ${Qt5Widgets_DEFINITIONS} ${Qt5Gui_DEFINITIONS} )
+
+ADD_DEFINITIONS(
+ -std=c++11
+)
+
+set(diceGui_RESOURCES diceparser.qrc)
+FIND_PACKAGE(Qt5LinguistTools)
+
+
+IF(UPDATE_TRANSLATIONS)
+ MESSAGE( update Translation )
+ FILE(GLOB_RECURSE translate_diceGui_SRCS ../*.cpp ../*.h)
+ SET(translate_SRCS ${translate_dice_SRCS})
+ SET(diceGui_TS "${CMAKE_CURRENT_SOURCE_DIR}/i18n/diceGui_en.ts" "${CMAKE_CURRENT_SOURCE_DIR}/i18n/diceGui_fr.ts")
+ELSE()
+ MESSAGE( NO updates for translations)
+ FILE(GLOB diceGui_TS "${CMAKE_CURRENT_SOURCE_DIR}/i18n/*.ts")
+ENDIF(UPDATE_TRANSLATIONS)
+
+if(Qt5Core_FOUND)
+
+ IF(UPDATE_TRANSLATIONS)
+ MESSAGE(status "find" ${diceGui_TS} ${translate_SRCS} )
+ QT5_CREATE_TRANSLATION(diceGui_QM ${translate_SRCS} ${diceGui_TS})
+ ELSE()
+ QT5_ADD_TRANSLATION(diceGui_QM ${diceGui_TS})
+ ENDIF()
+
+ QT5_ADD_RESOURCES(diceGui_RESOURCES_RCC ${diceGui_RESOURCES})
+
+ # guess plugins and libraries directory
+ set(QT_PLUGINS_DIR "${Qt5Core_DIR}/../../../plugins")
+ get_target_property(QT_LIBRARY_DIR Qt5::Core LOCATION)
+ get_filename_component(QT_LIBRARY_DIR ${QT_LIBRARY_DIR} PATH)
+endif()
+
+SET( diceGui_sources
+ ../diceparser.cpp
+ ../range.cpp
+ ../booleancondition.cpp
+ ../validator.cpp
+ ../compositevalidator.cpp
+ ../operationcondition.cpp
+ ../die.cpp
+ ../parsingtoolbox.cpp
+ ../dicealias.cpp
+ ../result/result.cpp
+ ../result/scalarresult.cpp
+ ../result/stringresult.cpp
+ ../result/diceresult.cpp
+ ../node/countexecutenode.cpp
+ ../node/dicerollernode.cpp
+ ../node/executionnode.cpp
+ ../node/explosedicenode.cpp
+ ../node/helpnode.cpp
+ ../node/mergenode.cpp
+ ../node/jumpbackwardnode.cpp
+ ../node/keepdiceexecnode.cpp
+ ../node/listaliasnode.cpp
+ ../node/listsetrollnode.cpp
+ ../node/numbernode.cpp
+ ../node/parenthesesnode.cpp
+ ../node/paintnode.cpp
+ ../node/rerolldicenode.cpp
+ ../node/scalaroperatornode.cpp
+ ../node/sortresult.cpp
+ ../node/startingnode.cpp
+ ../node/ifnode.cpp
+ main.cpp
+ maincontroler.cpp
+ ../highlightdice.cpp
+)
+qt5_add_resources(RESOURCE_ADDED mobile.qrc)
+
+add_executable( diceGui ${diceGui_sources} ${diceGui_QM} ${RESOURCE_ADDED} )
+
+target_link_libraries(diceGui ${Qt5Core_LIBRARIES} ${Qt5Widgets_LIBRARIES} ${Qt5Gui_LIBRARIES} ${Qt5Qml_LIBRARIES} ${Qt5Quick_LIBRARIES})
+INSTALL_TARGETS(/bin diceGui)
+
+#qt5_use_modules()
diff --git a/mobile/commandmodel.cpp b/mobile/commandmodel.cpp
new file mode 100644
index 0000000..6a3ab1d
--- /dev/null
+++ b/mobile/commandmodel.cpp
@@ -0,0 +1,57 @@
+/***************************************************************************
+ * Copyright (C) 2016 by Renaud Guezennec *
+ * http://www.rolisteam.org/contact *
+ * *
+ * rolisteam 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 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ * This program 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 this program; if not, write to the *
+ * Free Software Foundation, Inc., *
+ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
+ ***************************************************************************/
+#include "commandmodel.h"
+
+CommandModel::CommandModel()
+{
+
+}
+
+QVariant CommandModel::data(const QModelIndex &index, int role) const
+{
+ QPair<QString,QString> indexP = m_data.at(index.row());
+ if(role == NameRole)
+ {
+ return indexP.first;
+ }
+ else if(role == CmdRole)
+ {
+ return indexP.second;
+ }
+}
+
+int CommandModel::rowCount(const QModelIndex &parent) const
+{
+ return m_data.count();
+}
+QHash<int, QByteArray> CommandModel::roleNames() const
+{
+ QHash<int, QByteArray> roles;
+ roles[NameRole] = "name";
+ roles[CmdRole] = "cmd";
+ return roles;
+}
+void CommandModel::insertCmd(QString name, QString cmd)
+{
+ QModelIndex index;
+ beginInsertRows(index,0,0);
+ m_data.prepend(QPair<QString,QString>(name,cmd));
+ endInsertRows();
+}
diff --git a/mobile/commandmodel.h b/mobile/commandmodel.h
new file mode 100644
index 0000000..2c20072
--- /dev/null
+++ b/mobile/commandmodel.h
@@ -0,0 +1,46 @@
+/***************************************************************************
+ * Copyright (C) 2016 by Renaud Guezennec *
+ * http://www.rolisteam.org/contact *
+ * *
+ * rolisteam 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 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ * This program 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 this program; if not, write to the *
+ * Free Software Foundation, Inc., *
+ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
+ ***************************************************************************/
+#ifndef COMMANDMODEL_H
+#define COMMANDMODEL_H
+
+#include <QObject>
+
+#include <QAbstractListModel>
+
+class CommandModel : public QAbstractListModel
+{
+ Q_OBJECT
+public:
+ enum CustomRole {NameRole = Qt::UserRole+1,CmdRole};
+ CommandModel();
+
+ virtual QVariant data(const QModelIndex& index, int role = Qt::DisplayRole ) const;
+ virtual int rowCount(const QModelIndex &parent) const;
+
+ QHash<int, QByteArray> roleNames() const;
+
+
+public slots:
+ void insertCmd(QString name, QString cmd);
+private:
+ QList<QPair<QString,QString> > m_data;
+};
+
+#endif // COMMANDMODEL_H
diff --git a/mobile/deployment.pri b/mobile/deployment.pri
new file mode 100644
index 0000000..265ce71
--- /dev/null
+++ b/mobile/deployment.pri
@@ -0,0 +1,13 @@
+unix:!android {
+ isEmpty(target.path) {
+ qnx {
+ target.path = /tmp/$${TARGET}/bin
+ } else {
+ target.path = /opt/$${TARGET}/bin
+ }
+ export(target.path)
+ }
+ INSTALLS += target
+}
+
+export(INSTALLS)
diff --git a/mobile/main.cpp b/mobile/main.cpp
new file mode 100644
index 0000000..c4c8b0a
--- /dev/null
+++ b/mobile/main.cpp
@@ -0,0 +1,39 @@
+/***************************************************************************
+ * Copyright (C) 2016 by Renaud Guezennec *
+ * http://www.rolisteam.org/contact *
+ * *
+ * rolisteam 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 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ * This program 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 this program; if not, write to the *
+ * Free Software Foundation, Inc., *
+ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
+ ***************************************************************************/
+#include <QGuiApplication>
+#include <QQmlApplicationEngine>
+
+#include "maincontroler.h"
+
+int main(int argc, char *argv[])
+{
+ QGuiApplication app(argc, argv);
+
+ MainControler* main = new MainControler();
+
+
+ QQmlApplicationEngine engine;
+ main->initEngine(&engine);
+ engine.load(QUrl(QStringLiteral("qrc:/main.qml")));
+
+ //main->setConnections(&engine);
+
+ return app.exec();
+}
diff --git a/mobile/main.qml b/mobile/main.qml
new file mode 100644
index 0000000..700f3a7
--- /dev/null
+++ b/mobile/main.qml
@@ -0,0 +1,172 @@
+import QtQuick 2.7
+import QtQuick.Window 2.2
+
+Window {
+ id:root
+ visible: true
+ signal addRoll(string name, string cmd )
+ signal roll(string cmd)
+ color: "black"
+ height: 1280
+ width: 720
+
+ Column{
+
+ anchors.fill: parent
+ leftPadding: width*0.025
+ rightPadding: width*0.025
+ topPadding: width*0.025
+ Rectangle {
+ height: parent.height*0.12
+ width: parent.width*0.95
+ Image {
+ anchors.fill: parent
+ horizontalAlignment: Image.AlignHCenter
+ verticalAlignment:Image.AlignVCenter
+ fillMode: Image.PreserveAspectFit
+ source: "qrc:/resources/images/add.png"
+ }
+ gradient: Gradient {
+ GradientStop { position: 0.0; color: "darkblue" }
+ GradientStop { position: 1.0; color: "blue" }
+ }
+ MouseArea {
+ anchors.fill: parent
+ onClicked:popupAdd.visible = true
+ }
+ }
+
+ ListView {
+ model: _model
+ focus: true
+ height: parent.height*0.88
+ width: parent.width*0.95
+ delegate: Item{
+ height: parent.height
+ width: parent.width
+ Column{
+ width: parent.width
+ height: parent.height
+ Text{
+ text: name
+ font.pointSize: 40
+ color: "white"
+
+
+ }
+ Text{
+ text: cmd
+ font.pointSize:30
+ color: "white"
+
+ }
+ }
+ MouseArea{
+ anchors.fill:parent
+ onClicked: roll(cmd)
+ }
+ }
+ }
+
+ }
+ Rectangle {
+ id: popupAdd
+ color: "black"
+ x: parent.width*0.1
+ y: parent.height*0.1
+ height: parent.height*0.80
+ width: parent.width*0.80
+ visible: false
+ border.color: "white"
+ border.width: 1
+
+ Column{
+ id:form
+ anchors.top: parent.top
+ anchors.left: parent.left
+ anchors.right: parent.right
+ height: parent.height*0.80
+ leftPadding: width*0.025
+ rightPadding: width*0.025
+ topPadding: width*0.025
+ property alias name : nameInp
+ property alias cmd : cmdInp
+ Text {
+ text: qsTr("Name")
+ color: "white"
+ height: parent.height*0.1
+ font.pointSize: 40
+ }
+ Rectangle{
+ height: parent.height*0.1
+ width: parent.width*0.90
+ border.color: "#BBBBBB"
+ border.width: 1
+ color: "black"
+ TextInput{
+ id: nameInp
+ color: "white"
+ anchors.fill: parent
+ font.pointSize: 40
+ }
+ }
+
+ Text {
+ text: qsTr("Command")
+ color: "white"
+ height: parent.height*0.1
+ font.pointSize: 40
+ }
+ Rectangle{
+ height: parent.height*0.1
+ width: parent.width*0.90
+ border.color: "#BBBBBB"
+ border.width: 1
+ color: "black"
+ TextInput{
+ id: cmdInp
+ color: "white"
+ anchors.fill: parent
+ font.pointSize: 40
+ }
+ }
+ }
+
+ Rectangle {
+ color:"red"
+ id: cancel
+ anchors.top: form.bottom
+ anchors.left: form.left
+ anchors.right: form.horizontalCenter
+ anchors.bottom: parent.bottom
+ radius: height/2
+ MouseArea {
+ anchors.fill: parent
+ onClicked:{
+ nameInp.text=""
+ cmdInp.text=""
+ popupAdd.visible = false
+ }
+ }
+ }
+ Rectangle {
+ color:"green"
+ anchors.top: form.bottom
+ anchors.left: cancel.right
+ anchors.right: form.right
+ anchors.bottom: parent.bottom
+ radius: height/2
+ MouseArea {
+ anchors.fill: parent
+ onClicked:
+ {
+ root.addRoll(nameInp,cmdInp.text);
+ nameInp.text=""
+ cmdInp.text=""
+ popupAdd.visible = false
+ }
+ }
+
+ }
+ }
+}
diff --git a/mobile/maincontroler.cpp b/mobile/maincontroler.cpp
new file mode 100644
index 0000000..4b40fa2
--- /dev/null
+++ b/mobile/maincontroler.cpp
@@ -0,0 +1,37 @@
+#include "maincontroler.h"
+
+#include <QQmlContext>
+#include <QDebug>
+
+MainControler::MainControler(QObject *parent)
+ : QObject(parent)
+{
+ m_model = new CommandModel();
+ m_model->insertCmd("L5R","8D10e10k4");
+
+ m_diceParser = new DiceParser();
+}
+void MainControler::initEngine(QQmlApplicationEngine* engine)
+{
+ m_engine = engine;
+ engine->rootContext()->setContextProperty("_model",m_model);
+ connect(m_engine,SIGNAL(objectCreated(QObject*,QUrl)),this,SLOT(setConnections(QObject*,QUrl)));
+
+
+}
+void MainControler::rollDice(QString cmd)
+{
+ if(m_diceParser->parseLine(cmd))
+ {
+ m_diceParser->Start();
+ qDebug() << m_diceParser->getSumOfDiceResult();
+ }
+}
+void MainControler::setConnections(QObject* root,QUrl url)
+{
+ //QObject* root = engine->rootContext()->contextObject();
+
+
+ connect(root,SIGNAL(roll(QString)),this,SLOT(rollDice(QString)));
+ connect(root,SIGNAL(addRoll(QString,QString)),m_model,SLOT(insertCmd(QString,QString)));
+}
diff --git a/mobile/maincontroler.h b/mobile/maincontroler.h
new file mode 100644
index 0000000..b94312d
--- /dev/null
+++ b/mobile/maincontroler.h
@@ -0,0 +1,28 @@
+#ifndef MAINCONTROLER_H
+#define MAINCONTROLER_H
+
+#include <QObject>
+#include <QQmlApplicationEngine>
+
+#include "commandmodel.h"
+#include "diceparser.h"
+
+class MainControler : public QObject
+{
+ Q_OBJECT
+public:
+ explicit MainControler(QObject *parent = 0);
+
+ void initEngine(QQmlApplicationEngine* );
+signals:
+
+public slots:
+ void setConnections(QObject* root,QUrl url);
+ void rollDice(QString cmd);
+private:
+ CommandModel* m_model;
+ DiceParser* m_diceParser;
+ QQmlApplicationEngine* m_engine;
+};
+
+#endif // MAINCONTROLER_H
diff --git a/mobile/mainwindow.cpp b/mobile/mainwindow.cpp
new file mode 100644
index 0000000..ec0bd08
--- /dev/null
+++ b/mobile/mainwindow.cpp
@@ -0,0 +1,6 @@
+#include "mainwindow.h"
+
+MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent)
+{
+
+}
diff --git a/mobile/mainwindow.h b/mobile/mainwindow.h
new file mode 100644
index 0000000..df67bfe
--- /dev/null
+++ b/mobile/mainwindow.h
@@ -0,0 +1,17 @@
+#ifndef MAINWINDOW_H
+#define MAINWINDOW_H
+
+#include <QMainWindow>
+
+class MainWindow : public QMainWindow
+{
+ Q_OBJECT
+public:
+ explicit MainWindow(QWidget *parent = 0);
+
+signals:
+
+public slots:
+};
+
+#endif // MAINWINDOW_H \ No newline at end of file
diff --git a/mobile/mobile.pro b/mobile/mobile.pro
new file mode 100644
index 0000000..2e33522
--- /dev/null
+++ b/mobile/mobile.pro
@@ -0,0 +1,20 @@
+TEMPLATE = app
+
+QT += qml quick
+CONFIG += c++11
+
+SOURCES += main.cpp maincontroler.cpp \
+ commandmodel.cpp
+
+HEADERS += maincontroler.h \
+ commandmodel.h
+
+RESOURCES += qml.qrc
+
+include(../diceparser.pri)
+
+# Additional import path used to resolve QML modules in Qt Creator's code model
+QML_IMPORT_PATH =
+
+# Default rules for deployment.
+include(deployment.pri)
diff --git a/mobile/mobile.qrc b/mobile/mobile.qrc
new file mode 100644
index 0000000..69145a8
--- /dev/null
+++ b/mobile/mobile.qrc
@@ -0,0 +1,5 @@
+<RCC>
+ <qresource prefix="/">
+ <file>qml/main.qml</file>
+ </qresource>
+</RCC>
diff --git a/mobile/qml.qrc b/mobile/qml.qrc
new file mode 100644
index 0000000..2cbbe08
--- /dev/null
+++ b/mobile/qml.qrc
@@ -0,0 +1,6 @@
+<RCC>
+ <qresource prefix="/">
+ <file>main.qml</file>
+ <file>resources/images/add.png</file>
+ </qresource>
+</RCC>
diff --git a/mobile/qml/main.qml b/mobile/qml/main.qml
new file mode 100644
index 0000000..ed9d480
--- /dev/null
+++ b/mobile/qml/main.qml
@@ -0,0 +1,17 @@
+import QtQuick 2.4
+
+Item {
+ id:root
+
+ ListView {
+ id: diceList
+ }
+
+ Item{
+ id: popupInput
+
+ }
+ Item {
+ id: popupResult
+ }
+}
diff --git a/mobile/resources/images/add.png b/mobile/resources/images/add.png
new file mode 100644
index 0000000..c8e1bd2
--- /dev/null
+++ b/mobile/resources/images/add.png
Binary files differ