diff --git a/gui/include/gui/tutorialbuilder.h b/gui/include/gui/tutorialbuilder.h index 667c249da4..818b958c38 100644 --- a/gui/include/gui/tutorialbuilder.h +++ b/gui/include/gui/tutorialbuilder.h @@ -97,6 +97,7 @@ public Q_SLOTS: int y_offset; HoverPosition anchor; HoverPosition content; + QString api_call; }; QMap m_chapters; diff --git a/gui/include/gui/tutorialchapter.h b/gui/include/gui/tutorialchapter.h index 793bac3970..cb0c085f43 100644 --- a/gui/include/gui/tutorialchapter.h +++ b/gui/include/gui/tutorialchapter.h @@ -37,7 +37,7 @@ class SCOPY_GUI_EXPORT TutorialChapter : public QObject static TutorialChapter *build(const QList &subjects, const QString &description, QWidget *mainSubject, int x_offset, int y_offset, HoverPosition anchor, - HoverPosition content, QObject *parent = nullptr); + HoverPosition content, QString api_call, QObject *parent = nullptr); void addSubject(QWidget *s); @@ -48,6 +48,7 @@ class SCOPY_GUI_EXPORT TutorialChapter : public QObject int y_offset; HoverPosition anchor; HoverPosition content; + QString api_call; int getXOffset() const; void setXOffset(int xOffset); @@ -67,6 +68,9 @@ class SCOPY_GUI_EXPORT TutorialChapter : public QObject QWidget *getMainSubject() const; void setMainSubject(QWidget *mainSubject); + QString getApi() const; + void setApi(QString apiCall); + Q_SIGNALS: void chapterStarted(); void chapterFinished(); diff --git a/gui/include/gui/tutorialoverlay.h b/gui/include/gui/tutorialoverlay.h index f718c6998f..d8165a0cb7 100644 --- a/gui/include/gui/tutorialoverlay.h +++ b/gui/include/gui/tutorialoverlay.h @@ -46,7 +46,7 @@ class SCOPY_GUI_EXPORT TutorialOverlay : public QWidget TutorialChapter *addChapter(const QList &subjects, const QString &description, QWidget *mainWidget = nullptr, int x_offset = 0, int y_offset = 0, HoverPosition anchor = HoverPosition::HP_CENTER, - HoverPosition content = HoverPosition::HP_CENTER); + HoverPosition content = HoverPosition::HP_CENTER, QString api_call = ""); TutorialChapter *addChapter(QWidget *subject, QString description); void addChapter(TutorialChapter *ch); diff --git a/gui/src/tutorialbuilder.cpp b/gui/src/tutorialbuilder.cpp index 78594a10e8..69d5152744 100644 --- a/gui/src/tutorialbuilder.cpp +++ b/gui/src/tutorialbuilder.cpp @@ -124,7 +124,8 @@ uint16_t TutorialBuilder::collectChapters() this->addChapter(chapter->widgets.values(), chapter->description, (chapter->mainWidget.isNull()) ? chapter->widgets.first() : chapter->widgets[chapter->mainWidget], - chapter->x_offset, chapter->y_offset, chapter->anchor, chapter->content); + chapter->x_offset, chapter->y_offset, chapter->anchor, chapter->content, + chapter->api_call); } return chaptersCollected; @@ -171,6 +172,7 @@ void TutorialBuilder::readTutorialRequirements() // "y_offset": int, optional // "anchor": string, HoverPosition, optional // "content": string, HoverPosition, optional + // "api_call": string, api function call, optional // } QJsonArray chapters_array = value.toArray(); for(QJsonValueRef item : chapters_array) { @@ -189,6 +191,7 @@ void TutorialBuilder::readTutorialRequirements() QString contentString = item_object.value("content").toString(); HoverPosition anchor = convertStringToHoverPosition(anchorString); HoverPosition content = convertStringToHoverPosition(contentString); + QString api_call = item_object.value("api_call").toString(); auto *chapterInstructions = new ChapterInstructions; for(const auto &name : qAsConst(names)) { @@ -200,6 +203,7 @@ void TutorialBuilder::readTutorialRequirements() chapterInstructions->y_offset = y_offset; chapterInstructions->anchor = anchor; chapterInstructions->content = content; + chapterInstructions->api_call = api_call; if(m_chapters.contains(index)) { qWarning(CAT_TUTORIALBUILDER) << "There is already a chapter with the key" << index; } else { diff --git a/gui/src/tutorialchapter.cpp b/gui/src/tutorialchapter.cpp index 7ed6d5d73c..02537be487 100644 --- a/gui/src/tutorialchapter.cpp +++ b/gui/src/tutorialchapter.cpp @@ -34,7 +34,7 @@ TutorialChapter::~TutorialChapter() {} TutorialChapter *TutorialChapter::build(const QList &subjects, const QString &description, QWidget *mainSubject, int x_offset, int y_offset, HoverPosition anchor, - HoverPosition content, QObject *parent) + HoverPosition content, QString api_call, QObject *parent) { TutorialChapter *ch = new TutorialChapter(parent); for(QWidget *subject : subjects) { @@ -46,6 +46,7 @@ TutorialChapter *TutorialChapter::build(const QList &subjects, const ch->setYOffset(y_offset); ch->setAnchor(anchor); ch->setContent(content); + ch->setApi(api_call); return ch; } @@ -81,4 +82,8 @@ scopy::HoverPosition TutorialChapter::getContent() const { return content; } void TutorialChapter::setContent(scopy::HoverPosition newContent) { content = newContent; } +QString TutorialChapter::getApi() const { return api_call; } + +void TutorialChapter::setApi(QString apiCall) { api_call = apiCall; } + #include "moc_tutorialchapter.cpp" diff --git a/gui/src/tutorialoverlay.cpp b/gui/src/tutorialoverlay.cpp index 216b0a8b58..bdba650675 100644 --- a/gui/src/tutorialoverlay.cpp +++ b/gui/src/tutorialoverlay.cpp @@ -41,14 +41,14 @@ TutorialOverlay::~TutorialOverlay() { qDebug(CAT_TUTORIALOVERLAY) << "dtor"; } TutorialChapter *TutorialOverlay::addChapter(const QList &subjects, const QString &description, QWidget *mainWidget, int x_offset, int y_offset, HoverPosition anchor, - HoverPosition content) + HoverPosition content, QString api_call) { // in case TutorialOverlay is used without TutorialBuilder if(!mainWidget) { mainWidget = subjects[0]; } - TutorialChapter *ch = - TutorialChapter::build(subjects, description, mainWidget, x_offset, y_offset, anchor, content, this); + TutorialChapter *ch = TutorialChapter::build(subjects, description, mainWidget, x_offset, y_offset, anchor, + content, api_call, this); chapter.append(ch); ch->setMainSubject(mainWidget); return ch; @@ -91,7 +91,6 @@ void TutorialOverlay::next() Q_EMIT chapter[cnt - 1]->chapterFinished(); Q_EMIT chapter[cnt]->chapterStarted(); - initPopupWidget(); m_popupWidget->setDescription(chapter[cnt]->description); overlay->raise(); diff --git a/plugins/datalogger/include/datalogger/datamonitortool.h b/plugins/datalogger/include/datalogger/datamonitortool.h index d177042ff4..01961df64f 100644 --- a/plugins/datalogger/include/datalogger/datamonitortool.h +++ b/plugins/datalogger/include/datalogger/datamonitortool.h @@ -72,6 +72,7 @@ class SCOPY_DATALOGGER_EXPORT DatamonitorTool : public QWidget void initTutorialProperties(); void startTutorial(); + void startVideoTutorial(); }; } // namespace scopy::datamonitor #endif // DATAMONITORTOOL_H diff --git a/plugins/datalogger/resources/resources.qrc b/plugins/datalogger/resources/resources.qrc index e07911db6a..6748600522 100644 --- a/plugins/datalogger/resources/resources.qrc +++ b/plugins/datalogger/resources/resources.qrc @@ -1,5 +1,6 @@ tutorial_chapters.json + video_tutorial_chapters.json diff --git a/plugins/datalogger/resources/video_tutorial_chapters.json b/plugins/datalogger/resources/video_tutorial_chapters.json new file mode 100644 index 0000000000..54b84aa75d --- /dev/null +++ b/plugins/datalogger/resources/video_tutorial_chapters.json @@ -0,0 +1,29 @@ +{ + "datamonitor": [ + { + "index": 1, + "names": ["MONITOR_MENU"], + "description": "Select the signals you want to log", + "anchor": "HP_RIGHT", + "content": "HP_RIGHT", + "x_offset": 10 + }, + { + "index": 2, + "names": ["RUN_BUTTON"], + "description": "Starts data collection", + "anchor": "HP_BOTTOM", + "content": "HP_BOTTOM", + "y_offset": 10, + "api_call": "datalogger.setRunning(true)" + }, + { + "index": 3, + "names": ["MONITOR_PLOT"], + "description": "Display values on plot ", + "anchor": "HP_RIGHT", + "content": "HP_RIGHT", + "x_offset": 10 + } + ] +} \ No newline at end of file diff --git a/plugins/datalogger/src/datamonitortool.cpp b/plugins/datalogger/src/datamonitortool.cpp index e941e1e978..799ab237db 100644 --- a/plugins/datalogger/src/datamonitortool.cpp +++ b/plugins/datalogger/src/datamonitortool.cpp @@ -45,7 +45,7 @@ DatamonitorTool::DatamonitorTool(DataAcquisitionManager *dataAcquisitionManager, clearBtn = new QPushButton("Clear", this); PrintBtn *printBtn = new PrintBtn(this); - connect(infoBtn, &QPushButton::clicked, this, &DatamonitorTool::startTutorial); + connect(infoBtn, &QPushButton::clicked, this, &DatamonitorTool::startVideoTutorial); //// add monitors addMonitorButton = new AddBtn(this); @@ -314,6 +314,8 @@ void DatamonitorTool::initTutorialProperties() showSegments->setProperty("tutorial_name", "SHOW_7SEG_BUTTON"); settingsButton->setProperty("tutorial_name", "SETTINGS_BUTTON"); monitorsButton->setProperty("tutorial_name", "MONITORS_MENU_BUTTON"); + m_monitorPlot->setProperty("tutorial_name", "MONITOR_PLOT"); + m_monitorSelectionMenu->setProperty("tutorial_name", "MONITOR_MENU"); } void DatamonitorTool::startTutorial() @@ -325,4 +327,13 @@ void DatamonitorTool::startTutorial() datamonitorTutorial->start(); } +void DatamonitorTool::startVideoTutorial() +{ + QWidget *parent = Util::findContainingWindow(this); + gui::TutorialBuilder *datamonitorTutorial = + new gui::TutorialBuilder(this, ":/datamonitor/video_tutorial_chapters.json", "datamonitor", parent); + datamonitorTutorial->setTitle("Video Tutorial"); + datamonitorTutorial->start(); +} + #include "moc_datamonitortool.cpp"