mirror of
https://github.com/overte-org/overte.git
synced 2025-08-10 22:13:12 +02:00
Merge pull request #16261 from ctrlaltdavid/BUGZ-491
BUGZ-491: Fix tablet.loadWebScreenOnTop()
This commit is contained in:
commit
e1de615cbe
2 changed files with 25 additions and 57 deletions
|
@ -330,7 +330,6 @@ QObject* TabletScriptingInterface::getFlags() {
|
||||||
//
|
//
|
||||||
|
|
||||||
static const char* TABLET_HOME_SOURCE_URL = "hifi/tablet/TabletHome.qml";
|
static const char* TABLET_HOME_SOURCE_URL = "hifi/tablet/TabletHome.qml";
|
||||||
static const char* WEB_VIEW_SOURCE_URL = "hifi/tablet/TabletWebView.qml";
|
|
||||||
static const char* VRMENU_SOURCE_URL = "hifi/tablet/TabletMenu.qml";
|
static const char* VRMENU_SOURCE_URL = "hifi/tablet/TabletMenu.qml";
|
||||||
|
|
||||||
class TabletRootWindow : public QmlWindowClass {
|
class TabletRootWindow : public QmlWindowClass {
|
||||||
|
@ -827,58 +826,24 @@ void TabletProxy::loadWebScreenOnTop(const QVariant& url) {
|
||||||
void TabletProxy::loadWebScreenOnTop(const QVariant& url, const QString& injectJavaScriptUrl) {
|
void TabletProxy::loadWebScreenOnTop(const QVariant& url, const QString& injectJavaScriptUrl) {
|
||||||
bool localSafeContext = hifi::scripting::isLocalAccessSafeThread();
|
bool localSafeContext = hifi::scripting::isLocalAccessSafeThread();
|
||||||
if (QThread::currentThread() != thread()) {
|
if (QThread::currentThread() != thread()) {
|
||||||
QMetaObject::invokeMethod(this, "loadHTMLSourceImpl", Q_ARG(QVariant, url), Q_ARG(QString, injectJavaScriptUrl), Q_ARG(bool, localSafeContext));
|
QMetaObject::invokeMethod(this, "loadHTMLSourceOnTopImpl", Q_ARG(QString, url.toString()), Q_ARG(QString, injectJavaScriptUrl), Q_ARG(bool, false), Q_ARG(bool, localSafeContext));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
loadHTMLSourceImpl(url, injectJavaScriptUrl, localSafeContext);
|
loadHTMLSourceOnTopImpl(url.toString(), injectJavaScriptUrl, false, localSafeContext);
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void TabletProxy::loadHTMLSourceImpl(const QVariant& url, const QString& injectJavaScriptUrl, bool localSafeContext) {
|
|
||||||
if (QThread::currentThread() != thread()) {
|
|
||||||
qCWarning(uiLogging) << __FUNCTION__ << "may not be called directly by scripts";
|
|
||||||
return;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
QObject* root = nullptr;
|
|
||||||
if (!_toolbarMode && _qmlTabletRoot) {
|
|
||||||
root = _qmlTabletRoot;
|
|
||||||
} else if (_toolbarMode && _desktopWindow) {
|
|
||||||
root = _desktopWindow->asQuickItem();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (root) {
|
|
||||||
if (localSafeContext) {
|
|
||||||
hifi::scripting::setLocalAccessSafeThread(true);
|
|
||||||
}
|
|
||||||
QMetaObject::invokeMethod(root, "loadQMLOnTop", Q_ARG(const QVariant&, QVariant(WEB_VIEW_SOURCE_URL)));
|
|
||||||
QMetaObject::invokeMethod(root, "setShown", Q_ARG(const QVariant&, QVariant(true)));
|
|
||||||
if (_toolbarMode && _desktopWindow) {
|
|
||||||
QMetaObject::invokeMethod(root, "setResizable", Q_ARG(const QVariant&, QVariant(false)));
|
|
||||||
}
|
|
||||||
QMetaObject::invokeMethod(root, "loadWebOnTop", Q_ARG(const QVariant&, QVariant(url)), Q_ARG(const QVariant&, QVariant(injectJavaScriptUrl)));
|
|
||||||
hifi::scripting::setLocalAccessSafeThread(false);
|
|
||||||
}
|
|
||||||
_state = State::Web;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void TabletProxy::gotoWebScreen(const QString& url, const QString& injectedJavaScriptUrl, bool loadOtherBase) {
|
void TabletProxy::gotoWebScreen(const QString& url, const QString& injectedJavaScriptUrl, bool loadOtherBase) {
|
||||||
bool localSafeContext = hifi::scripting::isLocalAccessSafeThread();
|
bool localSafeContext = hifi::scripting::isLocalAccessSafeThread();
|
||||||
if (QThread::currentThread() != thread()) {
|
if (QThread::currentThread() != thread()) {
|
||||||
QMetaObject::invokeMethod(this, "loadHTMLSourceImpl", Q_ARG(QString, url), Q_ARG(QString, injectedJavaScriptUrl), Q_ARG(bool, loadOtherBase), Q_ARG(bool, localSafeContext));
|
QMetaObject::invokeMethod(this, "loadHTMLSourceOnTopImpl", Q_ARG(QString, url), Q_ARG(QString, injectedJavaScriptUrl), Q_ARG(bool, loadOtherBase), Q_ARG(bool, localSafeContext));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
loadHTMLSourceOnTopImpl(url, injectedJavaScriptUrl, loadOtherBase, localSafeContext);
|
||||||
loadHTMLSourceImpl(url, injectedJavaScriptUrl, loadOtherBase, localSafeContext);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void TabletProxy::loadHTMLSourceImpl(const QString& url, const QString& injectedJavaScriptUrl, bool loadOtherBase, bool localSafeContext) {
|
void TabletProxy::loadHTMLSourceOnTopImpl(const QString& url, const QString& injectedJavaScriptUrl, bool loadOtherBase, bool localSafeContext) {
|
||||||
|
|
||||||
QObject* root = nullptr;
|
QObject* root = nullptr;
|
||||||
if (!_toolbarMode && _qmlTabletRoot) {
|
if (!_toolbarMode && _qmlTabletRoot) {
|
||||||
root = _qmlTabletRoot;
|
root = _qmlTabletRoot;
|
||||||
|
@ -911,7 +876,6 @@ void TabletProxy::loadHTMLSourceImpl(const QString& url, const QString& injected
|
||||||
_initialWebPathParams.first = injectedJavaScriptUrl;
|
_initialWebPathParams.first = injectedJavaScriptUrl;
|
||||||
_initialWebPathParams.second = loadOtherBase;
|
_initialWebPathParams.second = loadOtherBase;
|
||||||
_initialScreen = true;
|
_initialScreen = true;
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -273,7 +273,9 @@ public:
|
||||||
Q_INVOKABLE void gotoHomeScreen();
|
Q_INVOKABLE void gotoHomeScreen();
|
||||||
|
|
||||||
/**jsdoc
|
/**jsdoc
|
||||||
* Opens a web page or app on the tablet.
|
* Opens a web app or page in addition to any current app. In tablet mode, the app or page is displayed over the top of the
|
||||||
|
* current app; in toolbar mode, the app is opened in a new window that replaces any current window open. If in tablet
|
||||||
|
* mode, the app or page can be closed using {@link TabletProxy#returnToPreviousApp}.
|
||||||
* @function TabletProxy#gotoWebScreen
|
* @function TabletProxy#gotoWebScreen
|
||||||
* @param {string} url - The URL of the web page or app.
|
* @param {string} url - The URL of the web page or app.
|
||||||
* @param {string} [injectedJavaScriptUrl=""] - The URL of JavaScript to inject into the web page.
|
* @param {string} [injectedJavaScriptUrl=""] - The URL of JavaScript to inject into the web page.
|
||||||
|
@ -294,29 +296,31 @@ public:
|
||||||
Q_INVOKABLE void loadQMLSource(const QVariant& path, bool resizable = false);
|
Q_INVOKABLE void loadQMLSource(const QVariant& path, bool resizable = false);
|
||||||
|
|
||||||
/**jsdoc
|
/**jsdoc
|
||||||
* Internal function, do not call from scripts
|
|
||||||
* @function TabletProxy#loadQMLSourceImpl
|
* @function TabletProxy#loadQMLSourceImpl
|
||||||
|
* @deprecated This function is deprecated and will be removed.
|
||||||
*/
|
*/
|
||||||
|
// Internal function, do not call from scripts.
|
||||||
Q_INVOKABLE void loadQMLSourceImpl(const QVariant& path, bool resizable, bool localSafeContext);
|
Q_INVOKABLE void loadQMLSourceImpl(const QVariant& path, bool resizable, bool localSafeContext);
|
||||||
|
|
||||||
/**jsdoc
|
/**jsdoc
|
||||||
* Internal function, do not call from scripts
|
* @function TabletProxy#loadHTMLSourceOnTopImpl
|
||||||
* @function TabletProxy#loadHTMLSourceImpl
|
* @deprecated This function is deprecated and will be removed.
|
||||||
*/
|
*/
|
||||||
Q_INVOKABLE void loadHTMLSourceImpl(const QVariant& url, const QString& injectJavaScriptUrl, bool localSafeContext);
|
// Internal function, do not call from scripts.
|
||||||
|
Q_INVOKABLE void loadHTMLSourceOnTopImpl(const QString& url, const QString& injectedJavaScriptUrl, bool loadOtherBase, bool localSafeContext);
|
||||||
|
|
||||||
/**jsdoc
|
/**jsdoc
|
||||||
* Internal function, do not call from scripts
|
|
||||||
* @function TabletProxy#loadHTMLSourceImpl
|
|
||||||
*/
|
|
||||||
Q_INVOKABLE void loadHTMLSourceImpl(const QString& url, const QString& injectedJavaScriptUrl, bool loadOtherBase, bool localSafeContext);
|
|
||||||
|
|
||||||
/**jsdoc
|
|
||||||
* Internal function, do not call from scripts
|
|
||||||
* @function TabletProxy#returnToPreviousAppImpl
|
* @function TabletProxy#returnToPreviousAppImpl
|
||||||
|
* @deprecated This function is deprecated and will be removed.
|
||||||
*/
|
*/
|
||||||
|
// Internal function, do not call from scripts.
|
||||||
Q_INVOKABLE void returnToPreviousAppImpl(bool localSafeContext);
|
Q_INVOKABLE void returnToPreviousAppImpl(bool localSafeContext);
|
||||||
|
|
||||||
|
/**jsdoc
|
||||||
|
*@function TabletProxy#loadQMLOnTopImpl
|
||||||
|
* @deprecated This function is deprecated and will be removed.
|
||||||
|
*/
|
||||||
|
// Internal function, do not call from scripts.
|
||||||
Q_INVOKABLE void loadQMLOnTopImpl(const QVariant& path, bool localSafeContext);
|
Q_INVOKABLE void loadQMLOnTopImpl(const QVariant& path, bool localSafeContext);
|
||||||
|
|
||||||
// FIXME: This currently relies on a script initializing the tablet (hence the bool denoting success);
|
// FIXME: This currently relies on a script initializing the tablet (hence the bool denoting success);
|
||||||
|
@ -355,8 +359,8 @@ public:
|
||||||
|
|
||||||
/**jsdoc
|
/**jsdoc
|
||||||
* Opens a web app or page in addition to any current app. In tablet mode, the app or page is displayed over the top of the
|
* Opens a web app or page in addition to any current app. In tablet mode, the app or page is displayed over the top of the
|
||||||
* current app; in toolbar mode, the app is opened in a new window. If in tablet mode, the app or page can be closed using
|
* current app; in toolbar mode, the app is opened in a new window that replaces any current window open. If in tablet
|
||||||
* {@link TabletProxy#returnToPreviousApp}.
|
* mode, the app or page can be closed using {@link TabletProxy#returnToPreviousApp}.
|
||||||
* @function TabletProxy#loadWebScreenOnTop
|
* @function TabletProxy#loadWebScreenOnTop
|
||||||
* @param {string} path - The URL of the web page or HTML app.
|
* @param {string} path - The URL of the web page or HTML app.
|
||||||
* @param {string} [injectedJavaScriptURL=""] - The URL of JavaScript to inject into the web page.
|
* @param {string} [injectedJavaScriptURL=""] - The URL of JavaScript to inject into the web page.
|
||||||
|
|
Loading…
Reference in a new issue