SyntaxTutor
Educational app designed to help compiler students understand LL(1) and SLR(1) parsing algorithms.
Loading...
Searching...
No Matches
tutorialmanager.h
Go to the documentation of this file.
1/*
2 * SyntaxTutor - Interactive Tutorial About Syntax Analyzers
3 * Copyright (C) 2025 Jose R. (jose-rzm)
4 *
5 * This program is free software: you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License as published by
7 * the Free Software Foundation, either version 3 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <https://www.gnu.org/licenses/>.
17 */
18
19#ifndef TUTORIALMANAGER_H
20#define TUTORIALMANAGER_H
21
22#include <QEvent>
23#include <QFrame>
24#include <QObject>
25#include <QPushButton>
26#include <QString>
27#include <QTextBrowser>
28#include <QVector>
29#include <QWidget>
30
39 QWidget* target;
40 QString htmlText;
41};
42
53class TutorialManager : public QObject {
54 Q_OBJECT
55 public:
61 TutorialManager(QWidget* rootWindow);
62
68 void addStep(QWidget* target, const QString& htmlText);
69
73 void start();
74
79 void setRootWindow(QWidget* newRoot);
80
84 void clearSteps();
85
89 void hideOverlay();
90
95 void finishLL1();
96
101 void finishSLR1();
102
103 protected:
107 bool eventFilter(QObject* obj, QEvent* ev) override;
108
109 signals:
114 void stepStarted(int index);
115
120
125
130
131 public slots:
135 void nextStep();
136
137 private:
141 void showOverlay();
142
146 void repositionOverlay();
147
148 QWidget* m_root;
149 QVector<TutorialStep> m_steps;
150 int m_index = -1;
151
152 QWidget* m_overlay = nullptr;
153 QFrame* m_highlight =
154 nullptr;
155 QTextBrowser* m_textBox = nullptr;
156 QPushButton* m_nextBtn = nullptr;
157};
158
159#endif // TUTORIALMANAGER_H
void slr1Finished()
Emitted when the SLR(1) tutorial ends.
void start()
Starts the tutorial from the beginning.
Definition tutorialmanager.cpp:87
void setRootWindow(QWidget *newRoot)
Sets the root window (used for repositioning the overlay).
Definition tutorialmanager.cpp:50
void addStep(QWidget *target, const QString &htmlText)
Adds a new step to the tutorial sequence.
Definition tutorialmanager.cpp:83
void nextStep()
Advances to the next tutorial step.
Definition tutorialmanager.cpp:92
void clearSteps()
Clears all steps in the tutorial.
Definition tutorialmanager.cpp:43
void hideOverlay()
Hides the tutorial overlay immediately.
Definition tutorialmanager.cpp:137
void stepStarted(int index)
Emitted when a new tutorial step starts.
void ll1Finished()
Emitted when the LL(1) tutorial ends.
void tutorialFinished()
Emitted when the full tutorial is finished.
void finishLL1()
Ends the LL(1) tutorial sequence and emits its corresponding signal.
Definition tutorialmanager.cpp:27
bool eventFilter(QObject *obj, QEvent *ev) override
Intercepts UI events to handle overlay behavior.
Definition tutorialmanager.cpp:35
TutorialManager(QWidget *rootWindow)
Constructs a TutorialManager for a given window.
Definition tutorialmanager.cpp:22
void finishSLR1()
Ends the SLR(1) tutorial sequence and emits its corresponding signal.
Definition tutorialmanager.cpp:31
Represents a single step in the tutorial sequence.
Definition tutorialmanager.h:38
QWidget * target
Widget to highlight during the tutorial step.
Definition tutorialmanager.h:39
QString htmlText
HTML text to show as instruction or explanation.
Definition tutorialmanager.h:40