37 #include <QReadWriteLock> 38 #include <QThreadStorage> 45 typedef QMap<QString, ZScriptThread*>
ZScriptMap;
84 Q_ENUMS(QStandardButton)
96 : timerFunc(func), timerArg(arg){}
132 enum QStandardButton {
134 BtnNoButton = QMessageBox::NoButton,
135 BtnOk = QMessageBox::Ok,
136 BtnSave = QMessageBox::Save,
137 BtnSaveAll = QMessageBox::SaveAll,
138 BtnOpen = QMessageBox::Open,
139 BtnYes = QMessageBox::Yes,
140 BtnYesToAll = QMessageBox::YesToAll,
141 BtnNo = QMessageBox::No,
142 BtnNoToAll = QMessageBox::NoToAll,
143 BtnAbort = QMessageBox::Abort,
144 BtnRetry = QMessageBox::Retry,
145 BtnIgnore = QMessageBox::Ignore,
146 BtnClose = QMessageBox::Close,
147 BtnCancel = QMessageBox::Cancel,
148 BtnDiscard = QMessageBox::Discard,
149 BtnHelp = QMessageBox::Help,
150 BtnApply = QMessageBox::Apply,
151 BtnReset = QMessageBox::Reset,
152 BtnRestoreDefaults = QMessageBox::RestoreDefaults,
154 Q_DECLARE_FLAGS(QStandardButtons, QStandardButton)
175 Q_PROPERTY(QVariant tags READ getAppTags CONSTANT)
182 Q_PROPERTY(QString errorMessage READ errorMessage)
193 Q_PROPERTY(QString rootPath READ getRootPath NOTIFY appPathsChanged)
200 Q_PROPERTY(QString mainQmlPath READ getMainQmlPath NOTIFY appPathsChanged)
208 Q_PROPERTY(QString codePath READ getCodePath)
215 Q_PROPERTY(QString dataPath READ getDataPath)
222 explicit ZblApp(QJSEngine *scriptEngine,
224 QObject* parent =
nullptr);
233 static ZblApp& zInstance();
244 static QObject* getSingletonType(
245 QQmlEngine *engine, QJSEngine *scriptEngine);
259 static int registerSingletonType();
274 QString errorMessage();
284 QVariant getAppTags();
292 QString getRootPath();
300 QString getMainQmlPath();
311 QString getCodePath();
319 QString getDataPath();
332 Q_INVOKABLE
bool isResourcePath(
const QString& path);
342 Q_INVOKABLE
void addLibraryPath(
const QString& path);
359 Q_INVOKABLE QString resolveAppPath(
const QString& path,
bool includeUrlScheme =
true);
375 Q_INVOKABLE QString resolveHomePath(
const QString& path,
bool includeUrlScheme =
true);
393 Q_INVOKABLE QString resolvePath(
const QString& path,
bool includeUrlScheme =
true);
407 Q_INVOKABLE QVariant showInfo(QWidget * parent,
408 const QString & title,
409 const QString & text,
410 int buttons = ZblApp::BtnOk,
411 int defaultButton = ZblApp::BtnNoButton);
423 Q_INVOKABLE
bool isInMainThread();
437 Q_INVOKABLE
void sync();
447 Q_INVOKABLE
void sleep(
unsigned long milliseconds);
458 Q_INVOKABLE
void sleepEvents(
unsigned long milliseconds);
467 Q_INVOKABLE QVariant getAppData(
int dataKey);
474 Q_INVOKABLE QVariant getAppName();
481 Q_INVOKABLE
void status(
const QString& text);
517 Q_INVOKABLE QObject* newAppSettings(
int scope,
518 const QString& application,
519 const QString& organization);
526 Q_INVOKABLE QObject* newByteArray();
533 Q_INVOKABLE QObject* newDataStream(QObject* byteArray);
540 Q_INVOKABLE QObject* newDir();
547 Q_INVOKABLE QObject* newFile();
554 Q_INVOKABLE QObject* newFileSystemWatcher();
561 Q_INVOKABLE QObject* newTableModel();
568 Q_INVOKABLE QObject* newTextStream(
const QString& text);
577 Q_INVOKABLE QObject* newLogReader();
593 Q_INVOKABLE QObject* newObject(
const QString& sprocketUri,
const QString& objectName);
600 Q_INVOKABLE QObject* newProcess();
607 Q_INVOKABLE QObject* newMailbox();
614 Q_INVOKABLE QObject* newMailslot();
623 Q_INVOKABLE QObject* newMap();
630 Q_INVOKABLE QObject* newMessageQueue();
637 Q_INVOKABLE QObject* newSchemaValidator();
646 Q_INVOKABLE QObject* newScopedMap();
662 Q_INVOKABLE QObject* newSettingsFile(
const QString& filePath);
673 Q_INVOKABLE QObject* newThread();
685 Q_INVOKABLE QObject* newXmlQuery();
703 Q_INVOKABLE QObject* bundleSettings(
const QString& bundleID);
717 Q_INVOKABLE QString bundleMetapath(
const QString& bundleID);
731 Q_INVOKABLE QString bundleMetadata(
const QString& bundleID);
751 Q_INVOKABLE
bool import(
779 Q_INVOKABLE
bool mapResource(
783 const QString& fileName);
809 Q_INVOKABLE
bool registerResource(
810 const QString& uri,
int versionMajor,
int versionMinor);
840 Q_INVOKABLE
bool mapPluginResources(
const QString& fileName,
bool qmlregister =
false);
866 Q_INVOKABLE
bool loadPlugin(
const char* fileName,
bool load =
false);
900 Q_INVOKABLE QStringList getApplicationArguments();
907 Q_INVOKABLE QStringList getSystemEnvironment();
923 Q_INVOKABLE
bool isInterruptRequested();
930 Q_INVOKABLE QString getCurrentThreadAddress();
938 Q_INVOKABLE QString getObjectThreadAddress(QObject*
object);
946 Q_INVOKABLE QObject* getLogBuffer();
957 Q_INVOKABLE QObject* getLogRules();
968 void statusAvailable(
const QString& text);
976 void appPathsChanged();
985 void settingsBundleAvailable(QString bundleId);
995 void exit(
int returnCode);
1010 void throwAnException();
1016 void throwDeeperException();
1022 void catchDeeperException();
1029 QVariant returnAnException();
1035 void throwException();
1058 void setError(QJSValue theObject);
1091 QJSValue convertEvaluateError(
const QJSValue& evaluateError);
1099 QVariant include(
const QString& fileUrl);
1114 int startTimerInterval(
1115 QJSValue timerFunction,
1116 QJSValue timerArgument,
1126 void stopTimerInterval(
int timerID);
1133 void stopAllTimers();
1140 void collectGarbage();
1163 void alert(
const QString signalID, QVariant payload,
bool wait =
false);
1198 void print(
const QString& text,
bool newLine=
true);
1209 void printErr(
const QString& text,
bool newLine=
true);
1217 void onDestroyed(QObject* obj);
1233 void exitApp(
int returnCode = 0);
1249 virtual void timerEvent(QTimerEvent * event);
1315 throw ZblException(
"ZblApp::engine - ERROR: missing javascript engine");
#define ZBLCORESHARED_EXPORT
static QThreadStorage< AppPtr * > m_zApp
ZblApp is a thread singleton - ie one ZblApp object exists per Zuble thread. This variable holds a po...
#define ZBL_DECLARE_LOGGED_OBJECT
A mechanism for safely holding a ZblApp object pointer in thread local storage.
QJSEngine * m_engine
The QJSEngine that owns the javascript context for this ZblApp object.
QJSEngine & engine()
Returns the QJSEngine object associated with this object.
TimerMethodCall(const TimerMethodCall &source)
A thread class to support Zuble's background Javascript processing.
factoryMap m_factories
Maps sprocket plugin uri's to ZblFactory objects.
static QVariant m_tags
A QVariantMap used to pass ZApplication enumeration values to Javascript programs.
static QReadWriteLock m_lock
A lock for multi-threaded data access.
timerHash m_scriptTimers
A hash of javascript function/argument pairs keyed by timer ID.
QMap< QString, ZScriptThread * > ZScriptMap
QHash< int, TimerMethodCall > timerHash
The primary QML API to the Zuble plugin library. Zuble applications access this object through the ja...
ZScriptThread * m_container
The ZScriptThread object that represents the thread in which ZblApp is running.
This inner class allows ZblApp to store javascript function pointers that are used to provide timer s...
Zuble's Qt Exception Object.
QMap< QString, ZblFactory * > factoryMap
Map Zuble Sprocket uri's to Sprocket object factories.
TimerMethodCall(const QJSValue &func, const QJSValue &arg)