forked from nathancarter/qtmathjax
-
Notifications
You must be signed in to change notification settings - Fork 0
/
texengine.h
44 lines (36 loc) · 1.04 KB
/
texengine.h
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
#ifndef TEXENGINE_H
#define TEXENGINE_H
#include <QWebView>
#include <QWebFrame>
#include <QCache>
class TeXEngine : QObject
{
Q_OBJECT
public:
TeXEngine ();
~TeXEngine ();
// compute immediately, waiting for result (via processEvents()) before returning it:
QString TeX2SVG ( QString TeXcode );
// queue computation for later iff it hasn't yet been done; cache result when done:
void asyncTeX2SVG ( QString TeXcode );
// detect whether a string has already been compiled in the past (i.e., is in cache):
bool hasComputed ( QString TeXcode );
QString error ();
Q_INVOKABLE void MathJaxDone ();
Q_INVOKABLE void MathJaxError ( QString errorMessage );
QWebView* webView ();
private:
QWebView* view;
QWebFrame* frame;
QString lastError;
bool running;
bool isReady;
QCache<QString,QString> cache;
QStringList queue;
QString currentInput;
void computeNextInBackground ();
private slots:
void addJSObject ();
void ready ( bool loadSucceeded );
};
#endif // TEXENGINE_H