-
Notifications
You must be signed in to change notification settings - Fork 351
/
Copy pathscriptobject.h
107 lines (80 loc) · 2.66 KB
/
scriptobject.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
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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
#ifndef SCRIPTOBJECT_H
#define SCRIPTOBJECT_H
#include "modifiedQObject.h"
#include <QVariant>
#include "qdocumentcursor.h"
class ProcessX;
class BuildManager;
class Texstudio;
class ScriptObject;
//script object for texworks compatibility
class SubScriptObject : public QObject
{
Q_OBJECT
public:
ScriptObject *script;
public slots:
QByteArray getScriptHash();
bool hasGlobal(const QString &name);
void setGlobal(const QString &name, const QVariant &value);
QVariant getGlobal(const QString &name);
bool hasPersistent(const QString &name);
void setPersistent(const QString &name, const QVariant &value);
QVariant getPersistent(const QString &name);
};
//global scope object
class ScriptObject : public QObject
{
Q_OBJECT
Q_PROPERTY(SubScriptObject *script READ getScript DESIGNABLE false STORED false)
//Q_PROPERTY(Texstudio *app READ getApp DESIGNABLE false STORED false)
public:
explicit ScriptObject(const QString &script, BuildManager *buildManager, Texstudio *app);
bool backgroundScript;
QByteArray getScriptHash();
void registerAllowedWrite();
signals:
public slots:
void alert(const QString &message);
void information(const QString &message);
void critical(const QString &message);
void warning(const QString &message);
bool confirm(const QString &message);
bool confirmWarning(const QString &message);
void debug(const QString &message);
#ifndef QT_NO_DEBUG
void crash_assert();
#endif
void crash_sigsegv();
void crash_sigfpe();
void crash_stack();
void crash_loop();
void crash_throw();
bool hasReadPrivileges();
bool hasWritePrivileges();
bool fileExists(const QString &fn);
ProcessX *system(const QString &commandline, const QString &workingDirectory=QString());
void writeFile(const QString &filename, const QString &content);
QVariant readFile(const QString &filename);
bool hasGlobal(const QString &name);
void setGlobal(const QString &name, const QVariant &value);
QVariant getGlobal(const QString &name);
bool hasPersistent(const QString &name);
void setPersistent(const QString &name, const QVariant &value);
QVariant getPersistent(const QString &name);
void registerAsBackgroundScript(const QString &name = "");
QWidget *createUI(const QString &path, QWidget *parent = nullptr);
QWidget *createUIFromString(const QString &path, QWidget *parent = nullptr);
public:
bool needReadPrivileges(const QString &fn, const QString ¶m);
bool needWritePrivileges(const QString &fn, const QString ¶m);
BuildManager *buildManager;
Texstudio *getApp();
private:
const QString &script;
Texstudio *app;
QByteArray scriptHash;
SubScriptObject subScriptObject;
SubScriptObject *getScript();
};
#endif // SCRIPTOBJECT_H