* if (button === resetButton) { * print("Reset"); * } else { * print("Don't reset"); * } * } * } * Window.messageBoxClosed.connect(onMessageBoxClosed); * * messageBox = Window.openMessageBox("Reset Something", * "Do you want to reset something?", * resetButton + cancelButton, cancelButton); */ int openMessageBox(QString title, QString text, int buttons, int defaultButton); /**jsdoc * Opens a URL in the Interface window or other application, depending on the URL's scheme. The following schemes are * supported:<br /> * <ul> * <li><code>hifi</code>: Navigate to the URL in Interface.</li> * <li><code>hifiapp</code>: Open a system app in Interface.</li> * </ul> * Other schemes will either be handled by the OS (e.g. <code>http</code>, <code>https</code>, or <code>mailto</code>) or * will display a dialog asking the user to confirm that they want to try to open the URL. * @function Window.openUrl * @param {string} url - The URL to open. */ void openUrl(const QUrl& url); /**jsdoc * Opens an Android activity and optionally return back to the scene when the activity is completed. <em>Android only.</em> * @function Window.openAndroidActivity * @param {string} activityName - The name of the activity to open: one of <code>"Home"</code>, <code>"Login"</code>, or * <code>"Privacy Policy"</code>. * @param {boolean} backToScene - If <code>true</code>, the user is automatically returned back to the scene when the * activity is completed. */ void openAndroidActivity(const QString& activityName, const bool backToScene); /**jsdoc * Updates the content of a message box that was opened with {@link Window.openMessageBox|openMessageBox}. * @function Window.updateMessageBox * @param {number} id - The ID of the message box. * @param {string} title - The title to display for the message box. * @param {string} text - Text to display in the message box. * @param {Window.MessageBoxButton} buttons - The buttons to display on the message box; one or more button values added * together. * @param {Window.MessageBoxButton} defaultButton - The button that has focus when the message box is opened. */ void updateMessageBox(int id, QString title, QString text, int buttons, int defaultButton); /**jsdoc * Closes a message box that was opened with {@link Window.openMessageBox|openMessageBox}. * @function Window.closeMessageBox * @param {number} id - The ID of the message box. */ void closeMessageBox(int id); /**jsdoc * @function Window.domainLoadingProgress * @returns {number} Progress. * @deprecated This function is deprecated and will be removed. */ float domainLoadingProgress(); /**jsdoc * Gets the number of display plugins currently available. * @function Window.getDisplayPluginCount * @returns {number} The number of display plugins currently available. */ int getDisplayPluginCount(); /**jsdoc * Gets the name of a display plugin. * @function Window.getDisplayPluginName * @param {number} index - The index of the display plugin. Must be less than the value returned by * {@link Window.getDisplayPluginCount|getDisplayPluginCount}. The first display plugin has an index of <code>0</code>. * @returns {string} The name of the display plugin. * @example <caption>Print the names of all available display plugins.</caption> * for (var i = 0, length = Window.getDisplayPluginCount(); i < length; i++) { * print(Window.getDisplayPluginName(i)); * } */ QString getDisplayPluginName(int index); /**jsdoc * Checks whether a display plugin is an HMD. * @function Window.isDisplayPluginHmd * @param {number} index - The index of the display plugin. Must be less than the value returned by * {@link Window.getDisplayPluginCount|getDisplayPluginCount}. The first display plugin has an index of <code>0</code>. * @returns {boolean} <code>true</code> if the display plugin is a HMD, <code>false</code> if it isn't. */ bool isDisplayPluginHmd(int index); /**jsdoc * Gets the index of the currently active display plugin. * @function Window.getActiveDisplayPlugin * @returns {number} The index of the currently active display plugin. The first display plugin has an index of * <code>0</code>. */ int getActiveDisplayPlugin(); /**jsdoc * Sets the currently active display plugin. * @function Window.setActiveDisplayPlugin * @param {number} index - The index of the display plugin. Must be less than the value returned by * {@link Window.getDisplayPluginCount|getDisplayPluginCount}. The first display plugin has an index of <code>0</code>. */ void setActiveDisplayPlugin(int index); /**jsdoc * Opens a web browser in a pop-up window. * @function Window.openWebBrowser */ void openWebBrowser(); private slots: void onWindowGeometryChanged(const QRect& geometry); void onMessageBoxSelected(int button); void disconnectedFromDomain(); signals: /**jsdoc * Triggered when you change the domain you're visiting. <strong>Warning:</strong> Is not emitted if you go to a domain * that isn't running. * @function Window.domainChanged * @param {string} domainURL - The domain's URL. * @returns {Signal} * @example <caption>Report when you change domains.</caption> * function onDomainChanged(domain) { * print("Domain changed: " + domain); * } * * Window.domainChanged.connect(onDomainChanged); */ void domainChanged(QUrl domainURL); /**jsdoc * Triggered when you try to navigate to a *.json, *.svo, or *.svo.json URL in a Web browser within Interface. * @function Window.svoImportRequested * @param {string} url - The URL of the file to import. * @returns {Signal} */ void svoImportRequested(const QString& url); /**jsdoc * Triggered when you try to visit a domain but are refused connection. * @function Window.domainConnectionRefused * @param {string} reasonMessage - A description of the refusal. * @param {Window.ConnectionRefusedReason} reasonCode - Integer number that enumerates the reason for the refusal. * @param {string} extraInfo - Extra information about the refusal. * @returns {Signal} */ void domainConnectionRefused(const QString& reasonMessage, int reasonCode, const QString& extraInfo); /**jsdoc * Triggered when you try to visit a domain but are redirected into the error state. * @function Window.redirectErrorStateChanged * @param {boolean} isInErrorState - <code>true</code> if the user has been redirected to the error URL, <code>false</code> * if they haven't. * @returns {Signal} */ void redirectErrorStateChanged(bool isInErrorState); /**jsdoc * Triggered when the interstitial mode changes. * @function Window.interstitialModeChanged * @param {boolean} interstitialMode - <code>true</code> if the interstitial graphics are displayed when the domain is * loading, <code>false</code> if they are not. * @returns {Signal} */ void interstitialModeChanged(bool interstitialMode); /**jsdoc * Triggered when a still snapshot has been taken by calling {@link Window.takeSnapshot|takeSnapshot} with * <code>includeAnimated = false</code> or {@link Window.takeSecondaryCameraSnapshot|takeSecondaryCameraSnapshot}. * @function Window.stillSnapshotTaken * @param {string} pathStillSnapshot - The path and name of the snapshot image file. * @param {boolean} notify - The value of the <code>notify</code> parameter that {@link Window.takeSnapshot|takeSnapshot} * was called with. * @returns {Signal} */ void stillSnapshotTaken(const QString& pathStillSnapshot, bool notify); /**jsdoc * Triggered when a still 360° snapshot has been taken by calling * {@link Window.takeSecondaryCamera360Snapshot|takeSecondaryCamera360Snapshot}. * @function Window.snapshot360Taken * @param {string} pathStillSnapshot - The path and name of the snapshot image file. * @param {boolean} notify - The value of the <code>notify</code> parameter that {@link Window.takeSecondaryCamera360Snapshot|takeSecondaryCamera360Snapshot} * was called with. * @returns {Signal} */ void snapshot360Taken(const QString& path360Snapshot, bool notify); /**jsdoc * Triggered when a snapshot submitted via {@link Window.shareSnapshot|shareSnapshot} is ready for sharing. The snapshot * may then be shared via the {@link Account.metaverseServerURL} Web API. * @function Window.snapshotShared * @param {boolean} isError - <code>true</code> if an error was encountered preparing the snapshot for sharing, otherwise * <code>false</code>. * @param {string} reply - JSON-formatted information about the snapshot. * @returns {Signal} */ void snapshotShared(bool isError, const QString& reply); /**jsdoc * Triggered when the snapshot images have been captured by {@link Window.takeSnapshot|takeSnapshot} and the GIF is * starting to be processed. * @function Window.processingGifStarted * @param {string} pathStillSnapshot - The path and name of the still snapshot image file. * @returns {Signal} */ void processingGifStarted(const QString& pathStillSnapshot); /**jsdoc * Triggered when a GIF has been prepared of the snapshot images captured by {@link Window.takeSnapshot|takeSnapshot}. * @function Window.processingGifCompleted * @param {string} pathAnimatedSnapshot - The path and name of the moving snapshot GIF file. * @returns {Signal} */ void processingGifCompleted(const QString& pathAnimatedSnapshot); /**jsdoc * Triggered when you've successfully made a user connection. * @function Window.connectionAdded * @param {string} message - A description of the success. * @returns {Signal} */ void connectionAdded(const QString& connectionName); /**jsdoc * Triggered when you failed to make a user connection. * @function Window.connectionError * @param {string} message - A description of the error. * @returns {Signal} */ void connectionError(const QString& errorString); /**jsdoc * Triggered when a message is announced by {@link Window.displayAnnouncement|displayAnnouncement}. * @function Window.announcement * @param {string} message - The message text. * @returns {Signal} */ void announcement(const QString& message); /**jsdoc * Triggered when the user closes a message box that was opened with {@link Window.openMessageBox|openMessageBox}. * @function Window.messageBoxClosed * @param {number} id - The ID of the message box that was closed. * @param {number} button - The button that the user clicked. If the user presses Esc, the Cancel button value is returned, * whether or not the Cancel button is displayed in the message box. * @returns {Signal} */ void messageBoxClosed(int id, int button); /**jsdoc * Triggered when the user chooses a directory in a {@link Window.browseDirAsync|browseDirAsync} dialog. * @function Window.browseDirChanged * @param {string} directory - The directory the user chose in the dialog. * @returns {Signal} */ void browseDirChanged(QString browseDir); /**jsdoc * Triggered when the user chooses an asset in a {@link Window.browseAssetsAsync|browseAssetsAsync} dialog. * @function Window.assetsDirChanged * @param {string} asset - The path and name of the asset the user chose in the dialog. * @returns {Signal} */ void assetsDirChanged(QString assetsDir); /**jsdoc * Triggered when the user specifies a file in a {@link Window.saveAsync|saveAsync} dialog. * @function Window.saveFileChanged * @param {string} filename - The path and name of the file that the user specified in the dialog. * @returns {Signal} */ void saveFileChanged(QString filename); /**jsdoc * Triggered when the user chooses a file in a {@link Window.browseAsync|browseAsync} dialog. * @function Window.browseChanged * @param {string} filename - The path and name of the file the user chose in the dialog. * @returns {Signal} */ void browseChanged(QString filename); /**jsdoc * Triggered when the user OKs a {@link Window.promptAsync|promptAsync} dialog. * @function Window.promptTextChanged * @param {string} text - The text the user entered in the dialog. * @returns {Signal} */ void promptTextChanged(QString text); /**jsdoc * Triggered when the position or size of the Interface window changes. * @function Window.geometryChanged * @param {Rect} geometry - The position and size of the drawable area of the Interface window. * @returns {Signal} * @example <caption>Report the position of size of the Interface window when it changes.</caption> * function onWindowGeometryChanged(rect) { * print("Window geometry: " + JSON.stringify(rect)); * } * * Window.geometryChanged.connect(onWindowGeometryChanged); */ void geometryChanged(QRect geometry); private: QString getPreviousBrowseLocation() const; void setPreviousBrowseLocation(const QString& location); QString getPreviousBrowseAssetLocation() const; void setPreviousBrowseAssetLocation(const QString& location); bool getInterstitialModeEnabled() const; void setInterstitialModeEnabled(bool enableInterstitialMode); void ensureReticleVisible() const; int createMessageBox(QString title, QString text, int buttons, int defaultButton); QHash<int, QQuickItem*> _messageBoxes; int _lastMessageBoxID{ -1 };}; #endif // hifi_WindowScriptingInterface_hLines 501–834 of 834. Previous lines
* if (button === resetButton) { * print("Reset"); * } else { * print("Don't reset"); * } * } * } * Window.messageBoxClosed.connect(onMessageBoxClosed); * * messageBox = Window.openMessageBox("Reset Something", * "Do you want to reset something?", * resetButton + cancelButton, cancelButton); */ int openMessageBox(QString title, QString text, int buttons, int defaultButton); /**jsdoc * Opens a URL in the Interface window or other application, depending on the URL's scheme. The following schemes are * supported:<br /> * <ul> * <li><code>hifi</code>: Navigate to the URL in Interface.</li> * <li><code>hifiapp</code>: Open a system app in Interface.</li> * </ul> * Other schemes will either be handled by the OS (e.g. <code>http</code>, <code>https</code>, or <code>mailto</code>) or * will display a dialog asking the user to confirm that they want to try to open the URL. * @function Window.openUrl * @param {string} url - The URL to open. */ void openUrl(const QUrl& url); /**jsdoc * Opens an Android activity and optionally return back to the scene when the activity is completed. <em>Android only.</em> * @function Window.openAndroidActivity * @param {string} activityName - The name of the activity to open: one of <code>"Home"</code>, <code>"Login"</code>, or * <code>"Privacy Policy"</code>. * @param {boolean} backToScene - If <code>true</code>, the user is automatically returned back to the scene when the * activity is completed. */ void openAndroidActivity(const QString& activityName, const bool backToScene); /**jsdoc * Updates the content of a message box that was opened with {@link Window.openMessageBox|openMessageBox}. * @function Window.updateMessageBox * @param {number} id - The ID of the message box. * @param {string} title - The title to display for the message box. * @param {string} text - Text to display in the message box. * @param {Window.MessageBoxButton} buttons - The buttons to display on the message box; one or more button values added * together. * @param {Window.MessageBoxButton} defaultButton - The button that has focus when the message box is opened. */ void updateMessageBox(int id, QString title, QString text, int buttons, int defaultButton); /**jsdoc * Closes a message box that was opened with {@link Window.openMessageBox|openMessageBox}. * @function Window.closeMessageBox * @param {number} id - The ID of the message box. */ void closeMessageBox(int id); /**jsdoc * @function Window.domainLoadingProgress * @returns {number} Progress. * @deprecated This function is deprecated and will be removed. */ float domainLoadingProgress(); /**jsdoc * Gets the number of display plugins currently available. * @function Window.getDisplayPluginCount * @returns {number} The number of display plugins currently available. */ int getDisplayPluginCount(); /**jsdoc * Gets the name of a display plugin. * @function Window.getDisplayPluginName * @param {number} index - The index of the display plugin. Must be less than the value returned by * {@link Window.getDisplayPluginCount|getDisplayPluginCount}. The first display plugin has an index of <code>0</code>. * @returns {string} The name of the display plugin. * @example <caption>Print the names of all available display plugins.</caption> * for (var i = 0, length = Window.getDisplayPluginCount(); i < length; i++) { * print(Window.getDisplayPluginName(i)); * } */ QString getDisplayPluginName(int index); /**jsdoc * Checks whether a display plugin is an HMD. * @function Window.isDisplayPluginHmd * @param {number} index - The index of the display plugin. Must be less than the value returned by * {@link Window.getDisplayPluginCount|getDisplayPluginCount}. The first display plugin has an index of <code>0</code>. * @returns {boolean} <code>true</code> if the display plugin is a HMD, <code>false</code> if it isn't. */ bool isDisplayPluginHmd(int index); /**jsdoc * Gets the index of the currently active display plugin. * @function Window.getActiveDisplayPlugin * @returns {number} The index of the currently active display plugin. The first display plugin has an index of * <code>0</code>. */ int getActiveDisplayPlugin(); /**jsdoc * Sets the currently active display plugin. * @function Window.setActiveDisplayPlugin * @param {number} index - The index of the display plugin. Must be less than the value returned by * {@link Window.getDisplayPluginCount|getDisplayPluginCount}. The first display plugin has an index of <code>0</code>. */ void setActiveDisplayPlugin(int index); /**jsdoc * Opens a web browser in a pop-up window. * @function Window.openWebBrowser */ void openWebBrowser(); private slots: void onWindowGeometryChanged(const QRect& geometry); void onMessageBoxSelected(int button); void disconnectedFromDomain(); signals: /**jsdoc * Triggered when you change the domain you're visiting. <strong>Warning:</strong> Is not emitted if you go to a domain * that isn't running. * @function Window.domainChanged * @param {string} domainURL - The domain's URL. * @returns {Signal} * @example <caption>Report when you change domains.</caption> * function onDomainChanged(domain) { * print("Domain changed: " + domain); * } * * Window.domainChanged.connect(onDomainChanged); */ void domainChanged(QUrl domainURL); /**jsdoc * Triggered when you try to navigate to a *.json, *.svo, or *.svo.json URL in a Web browser within Interface. * @function Window.svoImportRequested * @param {string} url - The URL of the file to import. * @returns {Signal} */ void svoImportRequested(const QString& url); /**jsdoc * Triggered when you try to visit a domain but are refused connection. * @function Window.domainConnectionRefused * @param {string} reasonMessage - A description of the refusal. * @param {Window.ConnectionRefusedReason} reasonCode - Integer number that enumerates the reason for the refusal. * @param {string} extraInfo - Extra information about the refusal. * @returns {Signal} */ void domainConnectionRefused(const QString& reasonMessage, int reasonCode, const QString& extraInfo); /**jsdoc * Triggered when you try to visit a domain but are redirected into the error state. * @function Window.redirectErrorStateChanged * @param {boolean} isInErrorState - <code>true</code> if the user has been redirected to the error URL, <code>false</code> * if they haven't. * @returns {Signal} */ void redirectErrorStateChanged(bool isInErrorState); /**jsdoc * Triggered when the interstitial mode changes. * @function Window.interstitialModeChanged * @param {boolean} interstitialMode - <code>true</code> if the interstitial graphics are displayed when the domain is * loading, <code>false</code> if they are not. * @returns {Signal} */ void interstitialModeChanged(bool interstitialMode); /**jsdoc * Triggered when a still snapshot has been taken by calling {@link Window.takeSnapshot|takeSnapshot} with * <code>includeAnimated = false</code> or {@link Window.takeSecondaryCameraSnapshot|takeSecondaryCameraSnapshot}. * @function Window.stillSnapshotTaken * @param {string} pathStillSnapshot - The path and name of the snapshot image file. * @param {boolean} notify - The value of the <code>notify</code> parameter that {@link Window.takeSnapshot|takeSnapshot} * was called with. * @returns {Signal} */ void stillSnapshotTaken(const QString& pathStillSnapshot, bool notify); /**jsdoc * Triggered when a still 360° snapshot has been taken by calling * {@link Window.takeSecondaryCamera360Snapshot|takeSecondaryCamera360Snapshot}. * @function Window.snapshot360Taken * @param {string} pathStillSnapshot - The path and name of the snapshot image file. * @param {boolean} notify - The value of the <code>notify</code> parameter that {@link Window.takeSecondaryCamera360Snapshot|takeSecondaryCamera360Snapshot} * was called with. * @returns {Signal} */ void snapshot360Taken(const QString& path360Snapshot, bool notify); /**jsdoc * Triggered when a snapshot submitted via {@link Window.shareSnapshot|shareSnapshot} is ready for sharing. The snapshot * may then be shared via the {@link Account.metaverseServerURL} Web API. * @function Window.snapshotShared * @param {boolean} isError - <code>true</code> if an error was encountered preparing the snapshot for sharing, otherwise * <code>false</code>. * @param {string} reply - JSON-formatted information about the snapshot. * @returns {Signal} */ void snapshotShared(bool isError, const QString& reply); /**jsdoc * Triggered when the snapshot images have been captured by {@link Window.takeSnapshot|takeSnapshot} and the GIF is * starting to be processed. * @function Window.processingGifStarted * @param {string} pathStillSnapshot - The path and name of the still snapshot image file. * @returns {Signal} */ void processingGifStarted(const QString& pathStillSnapshot); /**jsdoc * Triggered when a GIF has been prepared of the snapshot images captured by {@link Window.takeSnapshot|takeSnapshot}. * @function Window.processingGifCompleted * @param {string} pathAnimatedSnapshot - The path and name of the moving snapshot GIF file. * @returns {Signal} */ void processingGifCompleted(const QString& pathAnimatedSnapshot); /**jsdoc * Triggered when you've successfully made a user connection. * @function Window.connectionAdded * @param {string} message - A description of the success. * @returns {Signal} */ void connectionAdded(const QString& connectionName); /**jsdoc * Triggered when you failed to make a user connection. * @function Window.connectionError * @param {string} message - A description of the error. * @returns {Signal} */ void connectionError(const QString& errorString); /**jsdoc * Triggered when a message is announced by {@link Window.displayAnnouncement|displayAnnouncement}. * @function Window.announcement * @param {string} message - The message text. * @returns {Signal} */ void announcement(const QString& message); /**jsdoc * Triggered when the user closes a message box that was opened with {@link Window.openMessageBox|openMessageBox}. * @function Window.messageBoxClosed * @param {number} id - The ID of the message box that was closed. * @param {number} button - The button that the user clicked. If the user presses Esc, the Cancel button value is returned, * whether or not the Cancel button is displayed in the message box. * @returns {Signal} */ void messageBoxClosed(int id, int button); /**jsdoc * Triggered when the user chooses a directory in a {@link Window.browseDirAsync|browseDirAsync} dialog. * @function Window.browseDirChanged * @param {string} directory - The directory the user chose in the dialog. * @returns {Signal} */ void browseDirChanged(QString browseDir); /**jsdoc * Triggered when the user chooses an asset in a {@link Window.browseAssetsAsync|browseAssetsAsync} dialog. * @function Window.assetsDirChanged * @param {string} asset - The path and name of the asset the user chose in the dialog. * @returns {Signal} */ void assetsDirChanged(QString assetsDir); /**jsdoc * Triggered when the user specifies a file in a {@link Window.saveAsync|saveAsync} dialog. * @function Window.saveFileChanged * @param {string} filename - The path and name of the file that the user specified in the dialog. * @returns {Signal} */ void saveFileChanged(QString filename); /**jsdoc * Triggered when the user chooses a file in a {@link Window.browseAsync|browseAsync} dialog. * @function Window.browseChanged * @param {string} filename - The path and name of the file the user chose in the dialog. * @returns {Signal} */ void browseChanged(QString filename); /**jsdoc * Triggered when the user OKs a {@link Window.promptAsync|promptAsync} dialog. * @function Window.promptTextChanged * @param {string} text - The text the user entered in the dialog. * @returns {Signal} */ void promptTextChanged(QString text); /**jsdoc * Triggered when the position or size of the Interface window changes. * @function Window.geometryChanged * @param {Rect} geometry - The position and size of the drawable area of the Interface window. * @returns {Signal} * @example <caption>Report the position of size of the Interface window when it changes.</caption> * function onWindowGeometryChanged(rect) { * print("Window geometry: " + JSON.stringify(rect)); * } * * Window.geometryChanged.connect(onWindowGeometryChanged); */ void geometryChanged(QRect geometry); private: QString getPreviousBrowseLocation() const; void setPreviousBrowseLocation(const QString& location); QString getPreviousBrowseAssetLocation() const; void setPreviousBrowseAssetLocation(const QString& location); bool getInterstitialModeEnabled() const; void setInterstitialModeEnabled(bool enableInterstitialMode); void ensureReticleVisible() const; int createMessageBox(QString title, QString text, int buttons, int defaultButton); QHash<int, QQuickItem*> _messageBoxes; int _lastMessageBoxID{ -1 }; }; #endif // hifi_WindowScriptingInterface_h