From 4bc050e5835b542b7df09328af44e73cd465033c Mon Sep 17 00:00:00 2001 From: Dante Ruiz Date: Wed, 15 Mar 2017 19:26:50 +0100 Subject: [PATCH] added tablet notification --- libraries/script-engine/src/TabletScriptingInterface.h | 9 ++++++++- libraries/ui/src/OffscreenUi.cpp | 4 ++++ scripts/system/notifications.js | 10 ++++++++-- 3 files changed, 20 insertions(+), 3 deletions(-) diff --git a/libraries/script-engine/src/TabletScriptingInterface.h b/libraries/script-engine/src/TabletScriptingInterface.h index 00624254d7..acc53653f8 100644 --- a/libraries/script-engine/src/TabletScriptingInterface.h +++ b/libraries/script-engine/src/TabletScriptingInterface.h @@ -56,7 +56,14 @@ public: QQuickWindow* getTabletWindow(); QObject* getFlags(); - +signals: + /** jsdoc + * Signaled when a tablet message or dialog is created + * @function TabletProxy#tabletNotification + * @returns {Signal} + */ + void tabletNotification(); + private: void processMenuEvents(QObject* object, const QKeyEvent* event); void processTabletEvents(QObject* object, const QKeyEvent* event); diff --git a/libraries/ui/src/OffscreenUi.cpp b/libraries/ui/src/OffscreenUi.cpp index 982d58464f..1cb9045e79 100644 --- a/libraries/ui/src/OffscreenUi.cpp +++ b/libraries/ui/src/OffscreenUi.cpp @@ -223,6 +223,7 @@ QQuickItem* OffscreenUi::createMessageBox(Icon icon, const QString& title, const invokeResult = QMetaObject::invokeMethod(tabletRoot, "messageBox", Q_RETURN_ARG(QVariant, result), Q_ARG(QVariant, QVariant::fromValue(map))); + emit tabletScriptingInterface->tabletNotification(); } if (!invokeResult) { @@ -430,6 +431,7 @@ QQuickItem* OffscreenUi::createInputDialog(const Icon icon, const QString& title invokeResult = QMetaObject::invokeMethod(tabletRoot, "inputDialog", Q_RETURN_ARG(QVariant, result), Q_ARG(QVariant, QVariant::fromValue(map))); + emit tabletScriptingInterface->tabletNotification(); } if (!invokeResult) { qWarning() << "Failed to create message box"; @@ -457,6 +459,7 @@ QQuickItem* OffscreenUi::createCustomInputDialog(const Icon icon, const QString& invokeResult = QMetaObject::invokeMethod(tabletRoot, "inputDialog", Q_RETURN_ARG(QVariant, result), Q_ARG(QVariant, QVariant::fromValue(map))); + emit tabletScriptingInterface->tabletNotification(); } if (!invokeResult) { @@ -614,6 +617,7 @@ QString OffscreenUi::fileDialog(const QVariantMap& properties) { invokeResult = QMetaObject::invokeMethod(tabletRoot, "fileDialog", Q_RETURN_ARG(QVariant, buildDialogResult), Q_ARG(QVariant, QVariant::fromValue(properties))); + emit tabletScriptingInterface->tabletNotification(); } if (!invokeResult) { diff --git a/scripts/system/notifications.js b/scripts/system/notifications.js index b2ebb1fd46..0b7c2fa1b3 100644 --- a/scripts/system/notifications.js +++ b/scripts/system/notifications.js @@ -94,11 +94,13 @@ var NotificationType = { LOD_WARNING: 2, CONNECTION_REFUSED: 3, EDIT_ERROR: 4, + TABLET: 5, properties: [ { text: "Snapshot" }, { text: "Level of Detail" }, { text: "Connection Refused" }, - { text: "Edit error" } + { text: "Edit error" }, + { text: "Tablet" } ], getTypeFromMenuItem: function(menuItemName) { if (menuItemName.substr(menuItemName.length - NOTIFICATION_MENU_ITEM_POST.length) !== NOTIFICATION_MENU_ITEM_POST) { @@ -535,6 +537,10 @@ function onSnapshotTaken(pathStillSnapshot, pathAnimatedSnapshot, notify) { } } +function tabletNotification() { + createNotification("Tablet need your attention", NotificationType.TABLET); +} + function processingGif() { createNotification("Processing GIF snapshot...", NotificationType.SNAPSHOT); } @@ -641,7 +647,7 @@ Window.snapshotTaken.connect(onSnapshotTaken); Window.processingGif.connect(processingGif); Window.notifyEditError = onEditError; Window.notify = onNotify; - +Tablet.tabletNotification.connect(tabletNotification); setup(); }()); // END LOCAL_SCOPE