/**jsdoc * Open a non-modal message box that can have a variety of button combinations. See also, * {@link Window.updateMessageBox|updateMessageBox} and {@link Window.closeMessageBox|closeMessageBox}. * @function Window.openMessageBox * @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. * @returns {number} The ID of the message box created. * @example <caption>Ask the user whether that want to reset something.</caption> * var messageBox; * var resetButton = 0x4000000; * var cancelButton = 0x400000; * * function onMessageBoxClosed(id, button) { * if (id === messageBox) { * 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 * Open a URL in the Interface window or other application, depending on the URL's scheme. If the URL starts with * <code>hifi://</code> then that URL is navigated to in Interface, otherwise the URL is opened in the application the OS * associates with the URL's scheme (e.g., a Web browser for <code>http://</code>). * @function Window.openUrl * @param {string} url - The URL to open. */ void openUrl(const QUrl& url); /**jsdoc * Open 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 * Update 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 * Close 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); float domainLoadingProgress(); 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 - If <code>true</code>, the user has been redirected to the error URL. * @returns {Signal} */ void redirectErrorStateChanged(bool isInErrorState); /**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–780 of 780. Previous lines
/**jsdoc * Open a non-modal message box that can have a variety of button combinations. See also, * {@link Window.updateMessageBox|updateMessageBox} and {@link Window.closeMessageBox|closeMessageBox}. * @function Window.openMessageBox * @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. * @returns {number} The ID of the message box created. * @example <caption>Ask the user whether that want to reset something.</caption> * var messageBox; * var resetButton = 0x4000000; * var cancelButton = 0x400000; * * function onMessageBoxClosed(id, button) { * if (id === messageBox) { * 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 * Open a URL in the Interface window or other application, depending on the URL's scheme. If the URL starts with * <code>hifi://</code> then that URL is navigated to in Interface, otherwise the URL is opened in the application the OS * associates with the URL's scheme (e.g., a Web browser for <code>http://</code>). * @function Window.openUrl * @param {string} url - The URL to open. */ void openUrl(const QUrl& url); /**jsdoc * Open 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 * Update 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 * Close 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); float domainLoadingProgress(); 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 - If <code>true</code>, the user has been redirected to the error URL. * @returns {Signal} */ void redirectErrorStateChanged(bool isInErrorState); /**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