diff --git a/ground/openpilotgcs/src/plugins/config/calibration/WizardStepIndicator.qml b/ground/openpilotgcs/src/plugins/config/calibration/WizardStepIndicator.qml new file mode 100644 index 000000000..5ec9e3b28 --- /dev/null +++ b/ground/openpilotgcs/src/plugins/config/calibration/WizardStepIndicator.qml @@ -0,0 +1,34 @@ +import QtQuick 2.0 + +Rectangle{ + property alias text : textLabel.text + property bool active + property bool done + height: 25 + color : "transparent" + Rectangle{ + id: line + x: parent.height / 2 -1 + y: 0 + width: 2 + height: parent.height + color: "#ff0000" + } + Rectangle{ + x: 3 + y: 3 + id: circle + width: parent.height - (y * 2) + height: width + color: parent.active ? "red" : ( parent.done ? "green" : "grey") + border.color: "transparent" + border.width: 0 + radius: parent.active ? 0 : width * 0.5 + rotation: 45 + } + Text{ + id: textLabel + x: parent.height + 4 + y: 0 //parent.height + } +} diff --git a/ground/openpilotgcs/src/plugins/config/calibration/wizardmodel.cpp b/ground/openpilotgcs/src/plugins/config/calibration/wizardmodel.cpp new file mode 100644 index 000000000..77758b9fe --- /dev/null +++ b/ground/openpilotgcs/src/plugins/config/calibration/wizardmodel.cpp @@ -0,0 +1,15 @@ +#include "wizardmodel.h" + +WizardModel::WizardModel(QObject *parent) : + QStateMachine(parent) +{ +} + +WizardState* WizardModel::currentState(){ + foreach (QAbstractState *value, this->configuration()){ + if(value->parent() != 0){\ + return static_cast(value); + } + } + return NULL; +} diff --git a/ground/openpilotgcs/src/plugins/config/calibration/wizardmodel.h b/ground/openpilotgcs/src/plugins/config/calibration/wizardmodel.h new file mode 100644 index 000000000..eaad2aa54 --- /dev/null +++ b/ground/openpilotgcs/src/plugins/config/calibration/wizardmodel.h @@ -0,0 +1,41 @@ +#ifndef WIZARDMODEL_H +#define WIZARDMODEL_H + +#include +#include +#include "wizardstate.h" + +class WizardModel : public QStateMachine +{ + Q_OBJECT + Q_PROPERTY(QQmlListProperty steps READ steps CONSTANT) + Q_PROPERTY(QString instructions READ instructions NOTIFY instructionChanged) + Q_PROPERTY(WizardState* currentState READ currentState NOTIFY currentStateChanged) +public: + explicit WizardModel(QObject *parent = 0); + + QQmlListProperty steps() { + return QQmlListProperty(this, m_steps); + } + + QString instructions(){ + return m_instructions; + } + + void setInstructions(QString instructions){ + m_instructions = instructions; + emit instructionChanged(); + } + WizardState *currentState(); +protected: + QList m_steps; +private: + QString m_instructions; +signals: + void instructionChanged(); + void currentStateChanged(); +public slots: + +}; + +#endif // WIZARDMODEL_H diff --git a/ground/openpilotgcs/src/plugins/config/calibration/wizardstate.cpp b/ground/openpilotgcs/src/plugins/config/calibration/wizardstate.cpp new file mode 100644 index 000000000..48a62fa2a --- /dev/null +++ b/ground/openpilotgcs/src/plugins/config/calibration/wizardstate.cpp @@ -0,0 +1,46 @@ +#include "wizardstate.h" + +WizardState::WizardState(QString name, QState *parent) : + QState(parent) +{ + m_stepName = name; + m_done = false; + m_active = false; +} + +void WizardState::setCompletion(qint8 completion){ + m_completion = completion; + emit completionChanged(); +} + +void WizardState::setStepName(QString name) +{ + m_stepName = name; + emit stepNameChanged(); +} + +void WizardState::onEntry(QEvent *event) +{ + Q_UNUSED(event); + m_active = true; + emit isActiveChanged(); +} + +void WizardState::onExit(QEvent *event) +{ + Q_UNUSED(event); + m_active = false; + setIsDone(true); + emit isActiveChanged(); +} + +void WizardState::clean() +{ + setIsDone(false); +} + +void WizardState::setIsDone(bool done) +{ + m_done = done; + emit isDoneChanged(); +} diff --git a/ground/openpilotgcs/src/plugins/config/calibration/wizardstate.h b/ground/openpilotgcs/src/plugins/config/calibration/wizardstate.h new file mode 100644 index 000000000..131dcecef --- /dev/null +++ b/ground/openpilotgcs/src/plugins/config/calibration/wizardstate.h @@ -0,0 +1,50 @@ +#ifndef WIZARDSTATE_H +#define WIZARDSTATE_H + +#include + +class WizardState : public QState +{ + Q_OBJECT + Q_PROPERTY(bool isActive READ isActive NOTIFY isActiveChanged) + Q_PROPERTY(bool isDone READ isDone NOTIFY isDoneChanged) + Q_PROPERTY(qint8 completion READ completion NOTIFY completionChanged) + Q_PROPERTY(QString stepName READ stepName NOTIFY stepNameChanged) +public: + explicit WizardState(QString name, QState *parent = 0); + bool isActive(){ + return m_active; + } + + bool isDone(){ + return m_done; + } + + qint8 completion(){ + return m_completion; + } + + QString stepName(){ + return m_stepName; + } + + void setStepName(QString name); + void setCompletion(qint8 completion); + virtual void onEntry(QEvent *event) Q_DECL_OVERRIDE; + virtual void onExit(QEvent *event) Q_DECL_OVERRIDE; +signals: + void isActiveChanged(); + void isDoneChanged(); + void stepNameChanged(); + void completionChanged(); +public slots: + void clean(); +private: + void setIsDone(bool done); + bool m_done; + bool m_active; + qint8 m_completion; + QString m_stepName; +}; + +#endif // WIZARDSTATE_H diff --git a/ground/openpilotgcs/src/plugins/config/config.pro b/ground/openpilotgcs/src/plugins/config/config.pro index 41f2c388d..df998b811 100644 --- a/ground/openpilotgcs/src/plugins/config/config.pro +++ b/ground/openpilotgcs/src/plugins/config/config.pro @@ -2,12 +2,16 @@ TEMPLATE = lib TARGET = Config DEFINES += CONFIG_LIBRARY QT += svg +QT += opengl +QT += qml quick include(config_dependencies.pri) INCLUDEPATH += ../../libs/eigen -OTHER_FILES += Config.pluginspec +OTHER_FILES += Config.pluginspec \ + calibration/magcalibrationui.qml \ + calibration/WizardStepIndicator.qml HEADERS += configplugin.h \ configgadgetwidget.h \ @@ -41,7 +45,9 @@ HEADERS += configplugin.h \ dblspindelegate.h \ configrevohwwidget.h \ calibration/calibrationutils.h \ - calibration/thermalcalibration.h + calibration/thermalcalibration.h \ + calibration/wizardstate.h \ + calibration/wizardmodel.h SOURCES += configplugin.cpp \ configgadgetwidget.cpp \ @@ -76,7 +82,9 @@ SOURCES += configplugin.cpp \ dblspindelegate.cpp \ configrevohwwidget.cpp \ calibration/calibrationutils.cpp \ - calibration/thermalcalibration.cpp + calibration/thermalcalibration.cpp \ + calibration/wizardstate.cpp \ + calibration/wizardmodel.cpp FORMS += airframe.ui \ airframe_ccpm.ui \ diff --git a/ground/openpilotgcs/src/plugins/config/configgadget.qrc b/ground/openpilotgcs/src/plugins/config/configgadget.qrc index adffc9568..98a214395 100644 --- a/ground/openpilotgcs/src/plugins/config/configgadget.qrc +++ b/ground/openpilotgcs/src/plugins/config/configgadget.qrc @@ -30,5 +30,6 @@ images/pipx-selected.png images/pipx-normal.png images/revolution_top.png + calibration/WizardStepIndicator.qml