-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathproblemwidgets.h
More file actions
64 lines (50 loc) · 1.58 KB
/
Copy pathproblemwidgets.h
File metadata and controls
64 lines (50 loc) · 1.58 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#ifndef PROBLEMWIDGETS_H
#define PROBLEMWIDGETS_H
#include "progressmanager.h"
#include <QWidget>
#include <QWebEngineView>
#include <QWebChannel>
#include <QFile>
#include <QJsonDocument>
#include <QJsonArray>
#include <QJsonObject>
class ProblemBrowserBridge : public QObject {
Q_OBJECT
public:
explicit ProblemBrowserBridge(QObject *parent = nullptr) : QObject(parent) {}
signals:
void openProblemRequested(const QString &path);
void browserReady();
public slots:
Q_INVOKABLE void openProblem(const QString &path) {
qDebug() << ">>> ProblemBrowserBridge::openProblem CALLED WITH PATH:" << path;
emit openProblemRequested(path);
}
Q_INVOKABLE void onBrowserReady() {
qDebug() << ">>> ProblemBrowserBridge::onBrowserReady CALLED";
emit browserReady();
}
};
class ProblemBrowser : public QWidget {
Q_OBJECT
public:
explicit ProblemBrowser(const QUrl &url, ProgressManager *pm, QWidget *parent = nullptr);
~ProblemBrowser() override;
void loadFromJson(const QString &filePath);
void applyTheme(const QString &script);
signals:
void navigateToEditor(const QString &problemPath);
private slots:
void onProgressChanged(const QString &problemId);
void onBridgeBrowserReady();
private:
void syncToWeb();
QJsonObject getSolvedMap() const;
QWebEngineView *m_view = nullptr;
QWebChannel *m_channel = nullptr;
ProblemBrowserBridge *m_bridge = nullptr;
bool m_isWebReady = false;
ProgressManager *progressManager = nullptr;
QJsonArray m_problemsArray;
};
#endif // PROBLEMWIDGETS_H