From beb70988c3d80a1a596a76a0680cc98fa5cce3b8 Mon Sep 17 00:00:00 2001
From: David Rowe Note: Only triggered if the script is running in the same script engine as the script that created
+ * the tablet. Be default, this means in scripts included as part of the default scripts. Create a new tablet or retrieve an existing tablet using {@link Tablet.getTablet}. Note: This property isn't used in toolbar mode. Note: This property isn't used in toolbar mode. If the current dialog or its ancestors contain a QML If using a QML Note: The setting isn't used in toolbar mode. Note: The setting isn't used in toolbar mode. Note: Doesn't apply in toolbar mode. Create a new button using {@link TabletProxy#addButton}. Note: Only triggered if the script is running in the same script engine as the script that created
- * the tablet. Be default, this means in scripts included as part of the default scripts.uuid
.
+ * @property {number} stableOrder - The order in which the button was created: each button created gets a value incremented by
+ * one.
+ *
+ * @property {string} icon - The url of the default button icon displayed. (50 x 50 pixels. SVG, PNG, or other image format.)
+ * @property {string} hoverIcon - The url of the button icon displayed when the button is hovered and not active.
+ * @property {string} activeIcon - The url of the button icon displayed when the button is active.
+ * @property {string} activeHoverIcon - The url of the button icon displayed when the button is hovered and active.
+ * @property {string} text - The button caption.
+ * @property {string} hoverText - The button caption when the button is hovered and not active.
+ * @property {string} activeText - The button caption when the button is active.
+ * @property {string} activeHoverText - The button caption when the button is hovered and active.
+ * @comment {string} defaultCaptionColor="#ffffff" - Internal property.
+ * @property {string} captionColor="#ffffff" - The color of the button caption.
+
+ * @property {boolean} isActive=false - true
if the button is active, false
if it isn't.
+ * @property {boolean} isEntered - true
if the button is being hovered, false
if it isn't.
+ * @property {boolean} buttonEnabled=true - true
if the button is enabled, false
if it is disabled.
+ * @property {number} sortOrder=100 - Determines the order of the buttons: buttons with lower numbers appear before buttons
+ * with larger numbers.
+ *
+ * @property {boolean} inDebugMode - If true
and the tablet is being used, the button's isActive
+ * state toggles each time the button is clicked. Tablet only.
+ *
+ * @comment {object} tabletRoot - Internal tablet-only property.
+ * @property {object} flickable - Internal tablet-only property.
+ * @property {object} gridView - Internal tablet-only property.
+ * @property {number} buttonIndex - Internal tablet-only property.
+ *
+ * @comment {number} imageOffOut - Internal toolbar-only property.
+ * @comment {number} imageOffIn - Internal toolbar-only property.
+ * @comment {number} imageOnOut - Internal toolbar-only property.
+ * @comment {number} imageOnIn - Internal toolbar-only property.
+ */
TabletButtonProxy::TabletButtonProxy(const QVariantMap& properties) :
_uuid(QUuid::createUuid()),
_stableOrder(++s_stableOrder),
@@ -977,6 +1017,7 @@ TabletButtonProxy::TabletButtonProxy(const QVariantMap& properties) :
_properties[UUID_KEY] = _uuid;
_properties[OBJECT_NAME_KEY] = _uuid.toString();
_properties[STABLE_ORDER_KEY] = _stableOrder;
+ // Other properties are defined in TabletButton.qml and ToolbarButton.qml.
if (QThread::currentThread() != qApp->thread()) {
qCWarning(uiLogging) << "Creating tablet button proxy on wrong thread";
}
diff --git a/libraries/ui/src/ui/TabletScriptingInterface.h b/libraries/ui/src/ui/TabletScriptingInterface.h
index 0b8dc95fa4..4e639d221f 100644
--- a/libraries/ui/src/ui/TabletScriptingInterface.h
+++ b/libraries/ui/src/ui/TabletScriptingInterface.h
@@ -39,6 +39,10 @@ class QmlWindowClass;
class OffscreenQmlSurface;
/**jsdoc
+ * The Tablet
API provides the facilities to work with the system or other tablet. In toolbar mode (Developer >
+ * UI > Tablet Becomes Toolbar), the tablet's menu buttons are displayed in a toolbar and other tablet content is displayed
+ * in a dialog.
+ *
* @namespace Tablet
*
* @hifi-interface
@@ -46,6 +50,8 @@ class OffscreenQmlSurface;
* @hifi-avatar
*/
/**jsdoc
+ * The tabletInterface
API provides the facilities to work with the system or other tablet.
+ *
* @namespace tabletInterface
*
* @hifi-interface
@@ -53,12 +59,17 @@ class OffscreenQmlSurface;
* @hifi-avatar
*
* @deprecated This API is deprecated and will be removed. Use {@link Tablet} instead.
+ *
+ * @borrows Tablet.getTablet as getTablet
+ * @borrows Tablet.playSound as playSound
+ * @borrows Tablet.tabletNotification as tabletNotification
*/
class TabletScriptingInterface : public QObject, public Dependency {
Q_OBJECT
public:
/**jsdoc
+ * Standard tablet sounds.
*
*
*
* @typedef {number} Tablet.AudioEvents
@@ -88,28 +98,26 @@ public:
void setToolbarScriptingInterface(ToolbarScriptingInterface* toolbarScriptingInterface) { _toolbarScriptingInterface = toolbarScriptingInterface; }
/**jsdoc
- * Creates or returns a new TabletProxy and returns it.
+ * Gets an instance of a tablet. A new tablet is created if one with the specified ID doesn't already exist.
* @function Tablet.getTablet
- * @param {string} name - Tablet name.
- * @returns {TabletProxy} Tablet instance.
- */
- /**jsdoc
- * Creates or returns a new TabletProxy and returns it.
- * @function tabletInterface.getTablet
- * @param {string} name - Tablet name.
- * @returns {TabletProxy} Tablet instance.
+ * @param {string} name - A unique name that identifies the tablet.
+ * @returns {TabletProxy} The tablet instance.
+ * @example
@@ -69,7 +80,6 @@ public:
* Value Description
* 2
Tablet open.
* 3
Tablet hands in.
- * 4
Tablet hands out.
*
* 5
Last. true
if the tablet is in toolbar mode, false
if it isn't.
+ * @property {boolean} landscape - true
if the tablet is displayed in landscape mode, false
if it is
+ * displayed in portrait mode.
+ * true
if the tablet is currently displayed, false
if it isn't.
+ * true
, the web page or app is displayed in a frame with "back"
+ * and "close" buttons.
*/
Q_INVOKABLE void gotoWebScreen(const QString& url);
Q_INVOKABLE void gotoWebScreen(const QString& url, const QString& injectedJavaScriptUrl, bool loadOtherBase = false);
/**jsdoc
+ * Opens a QML app or dialog on the tablet.
* @function TabletProxy#loadQMLSource
- * @param {string} path
- * @param {boolean} [resizable=false]
+ * @param {string} path - The path of the QML app or dialog.
+ * @param {boolean} [resizable=false] - true
to make the dialog resizable in toolbar mode, false
+ * to have it not resizable.
*/
Q_INVOKABLE void loadQMLSource(const QVariant& path, bool resizable = false);
// FIXME: This currently relies on a script initializing the tablet (hence the bool denoting success);
// it should be initialized internally so it cannot fail
/**jsdoc
+ * Displays a QML dialog over the top of the current dialog, without closing the current dialog. Use
+ * {@link TabletProxy#popFromStack|popFromStack} to close the dialog.
+ *
for portrait.
+ * @param {boolean} landscape - StackView
with objectName: "stack"
and
+ * function pushSource(path)
, that functions is called; otherwise,
+ * {@link TabletProxy#loadQMLSource|loadQMLSource} is called. The Create app provides an example of using a QML
+ * StackView
.true
if the dialog was successfully opened, false
if it wasn't.
*/
+ // edit.js provides an example of using this outside of main menu.
Q_INVOKABLE bool pushOntoStack(const QVariant& path);
/**jsdoc
+ * Closes a QML dialog that was displayed using {@link Tablet#pushOntoStack|pushOntoStack} with a dialog implementing a QML
+ * StackView
; otherwise, no action is taken.
+ * StackView
, its popSource()
function is called.true
if a modal, non-modal, or message dialog is open, false
if there isn't.
*/
Q_INVOKABLE bool isMessageDialogOpen();
/**jsdoc
- * Close any open dialogs.
- * @function TabletProxy#closeDialog
- */
+ * Closes any open modal, non-modal, or message dialog, opened by {@link Window.prompt}, {@link Window.promptAsync},
+ * {@link Window.openMessageBox}, or similar.
+ * @function TabletProxy#closeDialog
+ */
Q_INVOKABLE void closeDialog();
/**jsdoc
- * Creates a new button, adds it to this and returns it.
+ * Adds a new button to the tablet menu.
* @function TabletProxy#addButton
- * @param {object} properties - Button properties.
- * @returns {TabletButtonProxy}
+ * @param {TabletButtonProxy.ButtonProperties} properties - Button properties.
+ * @returns {TabletButtonProxy} The button added.
+ * @example EventBridge
that is automatically provided to the script:
+ *
* @function TabletProxy#emitScriptEvent
- * @param {object|string} message
+ * @param {string|object} message - The message to send to the web page.
*/
Q_INVOKABLE void emitScriptEvent(const QVariant& msg);
/**jsdoc
- * Used to send an event to the QML embedded in the tablet.
+ * Sends a message to the current QML page. To receive the message, the QML page must implement a function:
+ * EventBridge.scriptEventReceived.connect(function(message) {
+ * ...
+ * });
* @function TabletProxy#sendToQml
- * @param {object|string} message
+ * @param {string|object} message - The message to send to the QML page.
*/
Q_INVOKABLE void sendToQml(const QVariant& msg);
/**jsdoc
- * Check if the tablet is on the home screen.
+ * Checks if the tablet is on the home screen.
* @function TabletProxy#onHomeScreen
- * @returns {boolean}
+ * @returns {boolean} function fromScript(message) {
+ * ...
+ * }
true
if the tablet is on the home screen, false
if it isn't.
*/
Q_INVOKABLE bool onHomeScreen();
/**jsdoc
- * Set tablet into or out of landscape mode.
+ * Sets whether the tablet is displayed in landscape or portrait mode.
+ * true
for landscape, true
to display the tablet in landscape mode, false
to display it
+ * in portrait mode.
*/
Q_INVOKABLE void setLandscape(bool landscape) { _landscape = landscape; }
/**jsdoc
+ * Gets whether the tablet is displayed in landscape or portrait mode.
+ * true
if the tablet is displayed in landscape mode, false
if it is displayed
+ * in portrait mode.
*/
Q_INVOKABLE bool getLandscape() { return _landscape; }
/**jsdoc
+ * Checks if a path is the current app or dialog displayed.
* @function TabletProxy#isPathLoaded
- * @param {string} path
- * @returns {boolean}
+ * @param {string} path - The path to test.
+ * @returns {boolean} true
if path
is the current app or dialog, false
if it isn't.
*/
Q_INVOKABLE bool isPathLoaded(const QVariant& path);
@@ -384,44 +450,74 @@ public:
signals:
/**jsdoc
- * Signaled when this tablet receives an event from the html/js embedded in the tablet.
+ * Triggered when a message from the current HTML web page displayed on the tablet is received. The HTML web page can send
+ * a message by calling:
+ *
* @function TabletProxy#webEventReceived
- * @param {object|string} message
+ * @param {string|object} message - The message received.
* @returns {Signal}
*/
void webEventReceived(QVariant msg);
/**jsdoc
- * Signaled when this tablet receives an event from the qml embedded in the tablet.
+ * Triggered when a message from the current QML page displayed on the tablet is received. The QML page can send a message
+ * (string or object) by calling: EventBridge.emitWebEvent(message);
* @function TabletProxy#fromQml
- * @param {object|string} message
+ * @param {string|object} message - The message received.
* @returns {Signal}
*/
void fromQml(QVariant msg);
/**jsdoc
- * Signaled when this tablet screen changes.
+ * Triggered when the tablet's screen changes.
* @function TabletProxy#screenChanged
- * @param type {string} - "Home", "Web", "Menu", "QML", "Closed".
- * @param url {string} - Only valid for Web and QML.
+ * @param type {string} - The type of the new screen or change: sendToScript(message);
"Home"
, "Menu"
,
+ * "QML"
, "Web"
, "Closed"
, or "Unknown"
.
+ * @param url {string} - The url of the page displayed. Only valid for Web and QML.
+ * @returns {Signal}
*/
void screenChanged(QVariant type, QVariant url);
/**jsdoc
- * Signaled when the tablet becomes visible or becomes invisible.
- * @function TabletProxy#isTabletShownChanged
+ * Triggered when the tablet is opened or closed.
+ * true
when button is active.
- * @property {number} sortOrder - Determines sort order on tablet. lower numbers will appear before larger numbers.
- * Default is 100.
- */
// FIXME: There are additional properties.
QVariantMap _properties;
};
From 15d3c7231eabd8b50000499305e05abda2f8e923 Mon Sep 17 00:00:00 2001
From: David Rowe
true
to make the dialog resizable in toolbar mode, false
+ * @param {boolean} [resizable=false] - true
to make the dialog resizable in toolbar mode, false
* to have it not resizable.
*/
Q_INVOKABLE void loadQMLSource(const QVariant& path, bool resizable = false);
From 92eb418690695f376696befd923c04ce1a67e3c8 Mon Sep 17 00:00:00 2001
From: David Rowe
Date: Wed, 12 Jun 2019 10:50:37 +1200
Subject: [PATCH 3/3] Doc review
---
libraries/ui/src/ui/TabletScriptingInterface.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/libraries/ui/src/ui/TabletScriptingInterface.h b/libraries/ui/src/ui/TabletScriptingInterface.h
index 98a7f054ac..afd77a15f6 100644
--- a/libraries/ui/src/ui/TabletScriptingInterface.h
+++ b/libraries/ui/src/ui/TabletScriptingInterface.h
@@ -298,7 +298,7 @@ public:
* Displays a QML dialog over the top of the current dialog, without closing the current dialog. Use
* {@link TabletProxy#popFromStack|popFromStack} to close the dialog.
* If the current dialog or its ancestors contain a QML StackView
with objectName: "stack"
and
- * function pushSource(path)
, that functions is called; otherwise,
+ * function pushSource(path)
, that function is called; otherwise,
* {@link TabletProxy#loadQMLSource|loadQMLSource} is called. The Create app provides an example of using a QML
* StackView
.
* @function TabletProxy#pushOntoStack