-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathscriptformatter.h
More file actions
85 lines (68 loc) · 2.38 KB
/
Copy pathscriptformatter.h
File metadata and controls
85 lines (68 loc) · 2.38 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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
#ifndef SCRIPTFORMATTER_H
#define SCRIPTFORMATTER_H
#include <cstdint>
#include <QObject>
#include <QQmlEngine>
#include <QQuickTextDocument>
#include <QTextBlockFormat>
#include <QTextBlockUserData>
#include <unordered_map>
class ScriptFormatter : public QObject
{
Q_OBJECT
public:
explicit ScriptFormatter( QQmlEngine* newEngine = NULL, QObject *parent = 0 );
//NOTE: When changing the paragraphType enum, be sure to make corresponding changes in ScriptPage.qml and ReportsPage.qml
enum class paragraphType: uint_least8_t {
SCENE,
ACTION,
CHARACTER,
DIALOG,
PARENTHETICAL,
TRANSITION,
SHOT,
ACT_BREAK
};
Q_ENUMS( paragraphType );
std::map<paragraphType, paragraphType> nextType = {
{ paragraphType::SCENE, paragraphType::ACTION },
{ paragraphType::ACTION, paragraphType::ACTION },
{ paragraphType::CHARACTER, paragraphType::DIALOG },
{ paragraphType::DIALOG, paragraphType::CHARACTER },
{ paragraphType::PARENTHETICAL, paragraphType::DIALOG },
{ paragraphType::TRANSITION, paragraphType::SCENE },
{ paragraphType::SHOT, paragraphType::ACTION },
{ paragraphType::ACT_BREAK, paragraphType::SCENE }
};
Q_INVOKABLE void enforceFormatting( QQuickTextDocument* document );
Q_INVOKABLE int getFormat( QQuickTextDocument* document, int cursorPosition );
Q_INVOKABLE void setDefaultFontForDocument( QQuickTextDocument* document );
Q_INVOKABLE void setParagraphType( QQuickTextDocument* document, paragraphType newType, int cursorPosition );
Q_INVOKABLE void textChanged( QQuickTextDocument* document, unsigned int cursorPosition );
QFont sceneFont;
QTextBlockFormat sceneBlockFormat;
QFont actionFont;
QTextBlockFormat actionBlockFormat;
QFont characterFont;
QTextBlockFormat characterBlockFormat;
QFont dialogFont;
QTextBlockFormat dialogBlockFormat;
QFont parentheticalFont;
QTextBlockFormat parentheticalBlockFormat;
QFont transitionFont;
QTextBlockFormat transitionBlockFormat;
QFont shotFont;
QTextBlockFormat shotBlockFormat;
QFont actBreakFont;
QTextBlockFormat actBreakBlockFormat;
signals:
public slots:
private:
};
//Define the singleton type provider function
static QObject* scriptFormatter_provider( QQmlEngine* newEngine, QJSEngine* scriptEngine ) {
Q_UNUSED( scriptEngine )
ScriptFormatter* sf = new ScriptFormatter( newEngine );
return sf;
}
#endif // SCRIPTFORMATTER_H